Commit 4c74be06 authored by weinig@apple.com's avatar weinig@apple.com

WebCore:

2008-07-07  Sam Weinig  <sam@webkit.org>

        Reviewed by Geoffrey Garen.

        Fix for https://bugs.webkit.org/show_bug.cgi?id=19928
        querySelectorAll should throw an exception if a NSResolver is passed in.

        - Throw an NOT_SUPPORTED_ERR if a non-null or undefined parameter is passed
          as the second argument to querySelector or querySelectorAll.

        Test: fast/dom/SelectorAPI/not-supported-NSResolver.html

        * bindings/js/JSDocumentCustom.cpp:
        (WebCore::JSDocument::querySelector):
        (WebCore::JSDocument::querySelectorAll):
        * bindings/js/JSElementCustom.cpp:
        (WebCore::JSElement::querySelector):
        (WebCore::JSElement::querySelectorAll):
        * dom/Document.idl:
        * dom/Element.idl:

LayoutTests:

2008-07-07  Sam Weinig  <sam@webkit.org>

        Reviewed by Geoffrey Garen.

        Fix for https://bugs.webkit.org/show_bug.cgi?id=19928
        querySelectorAll should throw an exception if a NSResolver is passed in.

        * fast/dom/SelectorAPI/not-supported-NSResolver-expected.txt: Added.
        * fast/dom/SelectorAPI/not-supported-NSResolver.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@35041 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 687069ee
2008-07-07 Sam Weinig <sam@webkit.org>
Reviewed by Geoffrey Garen.
Fix for https://bugs.webkit.org/show_bug.cgi?id=19928
querySelectorAll should throw an exception if a NSResolver is passed in.
* fast/dom/SelectorAPI/not-supported-NSResolver-expected.txt: Added.
* fast/dom/SelectorAPI/not-supported-NSResolver.html: Added.
2008-07-07 Brady Eidson <beidson@apple.com>
Reviewed by Mitz and Geoff
This tests that we throw a NOT_SUPPORTED_ERR when passing a NSResolver to querySelector and querySelectorAll since we do not support it.
PASS: Document.querySelector throws: Error: NOT_SUPPORTED_ERR: DOM Exception 9
PASS: Document.querySelectorAll throws: Error: NOT_SUPPORTED_ERR: DOM Exception 9
PASS: Element.querySelector throws: Error: NOT_SUPPORTED_ERR: DOM Exception 9
PASS: Element.querySelectorAll throws: Error: NOT_SUPPORTED_ERR: DOM Exception 9
<html>
<head>
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();
log = function(msg)
{
document.getElementById('console').appendChild(document.createTextNode(msg + "\n"));
}
onload = function()
{
try {
document.querySelector("bbb|pre", function(prefix) { return "aaa"; });
log("FAIL: Document.querySelector did not throw");
} catch(ex) {
log("PASS: Document.querySelector throws: " + ex);
}
try {
document.querySelectorAll("bbb|pre", function(prefix) { return "aaa"; });
log("FAIL: Document.querySelectorAll did not throw");
} catch(ex) {
log("PASS: Document.querySelectorAll throws: " + ex);
}
try {
document.body.querySelector("bbb|pre", function(prefix) { return "aaa"; });
log("FAIL: Element.querySelector did not throw");
} catch(ex) {
log("PASS: Element.querySelector throws: " + ex);
}
try {
document.body.querySelectorAll("bbb|pre", function(prefix) { return "aaa"; });
log("FAIL: Element.querySelectorAll did not throw");
} catch(ex) {
log("PASS: Element.querySelectorAll throws: " + ex);
}
}
</script>
</head>
<body>
<p>This tests that we throw a NOT_SUPPORTED_ERR when passing a NSResolver to querySelector and querySelectorAll
since we do not support it.</p>
<pre id="console"></pre>
</body>
</html>
2008-07-07 Sam Weinig <sam@webkit.org>
Reviewed by Geoffrey Garen.
Fix for https://bugs.webkit.org/show_bug.cgi?id=19928
querySelectorAll should throw an exception if a NSResolver is passed in.
- Throw an NOT_SUPPORTED_ERR if a non-null or undefined parameter is passed
as the second argument to querySelector or querySelectorAll.
Test: fast/dom/SelectorAPI/not-supported-NSResolver.html
* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::querySelector):
(WebCore::JSDocument::querySelectorAll):
* bindings/js/JSElementCustom.cpp:
(WebCore::JSElement::querySelector):
(WebCore::JSElement::querySelectorAll):
* dom/Document.idl:
* dom/Element.idl:
2008-07-07 Brady Eidson <beidson@apple.com>
Reviewed by Mitz and Geoff
......@@ -21,13 +21,16 @@
#include "JSDocument.h"
#include "DOMWindow.h"
#include "ExceptionCode.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "HTMLDocument.h"
#include "JSDOMWindowCustom.h"
#include "JSHTMLDocument.h"
#include "JSLocation.h"
#include "JSNodeList.h"
#include "Location.h"
#include "NodeList.h"
#include "ScriptController.h"
#if ENABLE(SVG)
......@@ -72,6 +75,34 @@ void JSDocument::setLocation(ExecState* exec, JSValue* value)
frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), false, userGesture);
}
JSValue* JSDocument::querySelector(ExecState* exec, const ArgList& args)
{
if (!args[1]->isUndefinedOrNull()) {
setDOMException(exec, NOT_SUPPORTED_ERR);
return jsUndefined();
}
Document* imp = impl();
ExceptionCode ec = 0;
JSValue* result = toJS(exec, imp->querySelector(valueToStringWithUndefinedOrNullCheck(exec, args[0]), ec));
setDOMException(exec, ec);
return result;
}
JSValue* JSDocument::querySelectorAll(ExecState* exec, const ArgList& args)
{
if (!args[1]->isUndefinedOrNull()) {
setDOMException(exec, NOT_SUPPORTED_ERR);
return jsUndefined();
}
Document* imp = impl();
ExceptionCode ec = 0;
JSValue* result = toJS(exec, imp->querySelectorAll(valueToStringWithUndefinedOrNullCheck(exec, args[0]), ec));
setDOMException(exec, ec);
return result;
}
JSValue* toJS(ExecState* exec, Document* doc)
{
if (!doc)
......
......@@ -36,6 +36,8 @@
#include "HTMLNames.h"
#include "JSAttr.h"
#include "JSHTMLElementWrapperFactory.h"
#include "JSNodeList.h"
#include "NodeList.h"
#if ENABLE(SVG)
#include "JSSVGElementWrapperFactory.h"
......@@ -125,7 +127,34 @@ JSValue* JSElement::setAttributeNodeNS(ExecState* exec, const ArgList& args)
return result;
}
JSValue* JSElement::querySelector(ExecState* exec, const ArgList& args)
{
if (!args[1]->isUndefinedOrNull()) {
setDOMException(exec, NOT_SUPPORTED_ERR);
return jsUndefined();
}
Element* imp = impl();
ExceptionCode ec = 0;
JSValue* result = toJS(exec, imp->querySelector(valueToStringWithUndefinedOrNullCheck(exec, args[0]), ec));
setDOMException(exec, ec);
return result;
}
JSValue* JSElement::querySelectorAll(ExecState* exec, const ArgList& args)
{
if (!args[1]->isUndefinedOrNull()) {
setDOMException(exec, NOT_SUPPORTED_ERR);
return jsUndefined();
}
Element* imp = impl();
ExceptionCode ec = 0;
JSValue* result = toJS(exec, imp->querySelectorAll(valueToStringWithUndefinedOrNullCheck(exec, args[0]), ec));
setDOMException(exec, ec);
return result;
}
JSValue* toJSNewlyCreated(ExecState* exec, Element* element)
{
if (!element)
......
......@@ -233,12 +233,12 @@ module core {
#endif
// HTML 5
NodeList getElementsByClassName(in DOMString tagname);
NodeList getElementsByClassName(in DOMString tagname);
// DocumentSelector - Selector API
Element querySelector(in [ConvertUndefinedOrNullToNullString] DOMString selectors)
// NodeSelector - Selector API
[Custom] Element querySelector(in [ConvertUndefinedOrNullToNullString] DOMString selectors)
raises(DOMException);
NodeList querySelectorAll(in [ConvertUndefinedOrNullToNullString] DOMString selectors)
[Custom] NodeList querySelectorAll(in [ConvertUndefinedOrNullToNullString] DOMString selectors)
raises(DOMException);
};
......
......@@ -103,10 +103,10 @@ module core {
// HTML 5
NodeList getElementsByClassName(in DOMString name);
// ElementSelector - Selector API
Element querySelector(in [ConvertUndefinedOrNullToNullString] DOMString selectors)
// NodeSelector - Selector API
[Custom] Element querySelector(in [ConvertUndefinedOrNullToNullString] DOMString selectors)
raises(DOMException);
NodeList querySelectorAll(in [ConvertUndefinedOrNullToNullString] DOMString selectors)
[Custom] NodeList querySelectorAll(in [ConvertUndefinedOrNullToNullString] DOMString selectors)
raises(DOMException);
// ElementTraversal API
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment