Bug 816387 part 2. Hook up the Document WebIDL API to quickstubs. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Sun, 23 Dec 2012 14:34:22 -0800
changeset 126081 b7bb8951d3e2e5770d5ef24e4514dcecc656e910
parent 126080 b190d329f7f3123f4941a31b9908eb0f3d757835
child 126082 9db20066eb63dbfbf0ebe0f5182ff2669477f521
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs816387
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 816387 part 2. Hook up the Document WebIDL API to quickstubs. r=peterv
dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json
dom/interfaces/core/nsIDOMDocument.idl
dom/tests/mochitest/bugs/test_bug411103.html
dom/webidl/Document.webidl
js/xpconnect/src/dom_quickstubs.qsconf
js/xpconnect/tests/mochitest/test_bug505915.html
--- a/dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json
+++ b/dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json
@@ -70,30 +70,16 @@
   "MutationCallback interface: operation handleEvent(MutationRecord,MutationObserver)": true,
   "Document interface: operation importNode(Node,boolean)": true,
   "Document interface: operation createNodeIterator(Node,unsigned long,NodeFilter)": true,
   "Document interface: operation createTreeWalker(Node,unsigned long,NodeFilter)": true,
   "XMLDocument interface: existence and properties of interface object": true,
   "XMLDocument interface: existence and properties of interface prototype object": true,
   "XMLDocument interface: existence and properties of interface prototype object's \"constructor\" property": true,
   "Stringification of xmlDoc": "debug",
-  "Document interface: calling getElementsByTagName(DOMString) on xmlDoc with too few arguments must throw TypeError": true,
-  "Document interface: calling getElementsByTagNameNS(DOMString,DOMString) on xmlDoc with too few arguments must throw TypeError": true,
-  "Document interface: calling getElementsByClassName(DOMString) on xmlDoc with too few arguments must throw TypeError": true,
-  "Document interface: calling getElementById(DOMString) on xmlDoc with too few arguments must throw TypeError": true,
-  "Document interface: calling createElement(DOMString) on xmlDoc with too few arguments must throw TypeError": true,
-  "Document interface: calling createElementNS(DOMString,DOMString) on xmlDoc with too few arguments must throw TypeError": true,
-  "Document interface: calling createTextNode(DOMString) on xmlDoc with too few arguments must throw TypeError": true,
-  "Document interface: calling createComment(DOMString) on xmlDoc with too few arguments must throw TypeError": true,
-  "Document interface: calling createProcessingInstruction(DOMString,DOMString) on xmlDoc with too few arguments must throw TypeError": true,
-  "Document interface: calling importNode(Node,boolean) on xmlDoc with too few arguments must throw TypeError": true,
-  "Document interface: calling adoptNode(Node) on xmlDoc with too few arguments must throw TypeError": true,
-  "Document interface: calling createEvent(DOMString) on xmlDoc with too few arguments must throw TypeError": true,
-  "Document interface: calling createNodeIterator(Node,unsigned long,NodeFilter) on xmlDoc with too few arguments must throw TypeError": true,
-  "Document interface: calling createTreeWalker(Node,unsigned long,NodeFilter) on xmlDoc with too few arguments must throw TypeError": true,
   "EventTarget interface: calling addEventListener(DOMString,EventListener,boolean) on xmlDoc with too few arguments must throw TypeError": true,
   "EventTarget interface: calling removeEventListener(DOMString,EventListener,boolean) on xmlDoc with too few arguments must throw TypeError": true,
   "EventTarget interface: calling dispatchEvent(Event) on xmlDoc with too few arguments must throw TypeError": true,
   "DocumentFragment interface: existence and properties of interface object": true,
   "DocumentFragment interface: existence and properties of interface prototype object": true,
   "DocumentFragment interface: existence and properties of interface prototype object's \"constructor\" property": true,
   "Stringification of document.createDocumentFragment()": "debug",
   "EventTarget interface: calling addEventListener(DOMString,EventListener,boolean) on document.createDocumentFragment() with too few arguments must throw TypeError": true,
--- a/dom/interfaces/core/nsIDOMDocument.idl
+++ b/dom/interfaces/core/nsIDOMDocument.idl
@@ -48,17 +48,17 @@ interface nsIDOMDocument : nsIDOMNode
   nsIDOMNodeList                getElementsByTagName(in DOMString tagname);
 
   // Introduced in DOM Level 2:
   [optional_argc] nsIDOMNode    importNode(in nsIDOMNode importedNode,
                                            [optional] in boolean deep)
                                   raises(DOMException);
   // Introduced in DOM Level 2:
   nsIDOMElement                 createElementNS(in DOMString namespaceURI,
-                                                in DOMString qualifiedName)
+                                                [Null(Stringify)] in DOMString qualifiedName)
                                   raises(DOMException);
   // Introduced in DOM Level 2:
   nsIDOMAttr                    createAttributeNS(in DOMString namespaceURI,
                                                   in DOMString qualifiedName)
                                   raises(DOMException);
   // Introduced in DOM Level 2:
   nsIDOMNodeList                getElementsByTagNameNS(in DOMString namespaceURI,
                                                        in DOMString localName);
--- a/dom/tests/mochitest/bugs/test_bug411103.html
+++ b/dom/tests/mochitest/bugs/test_bug411103.html
@@ -25,20 +25,20 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 SimpleTest.waitForExplicitFinish();
 
 /** Test for Bug 411103 **/
 var allNSTests =
   [
    { args: [undefined, undefined] },
    { args: [null, undefined] },
-   { args: [undefined, null], code: 5 },
-   { args: [null, null], code: 5 },
+   { args: [undefined, null] },
+   { args: [null, null] },
    { args: [null, ""], code: 5 },
-   { args: ["", null], code: 5 },
+   { args: ["", null] },
    { args: ["", ""], code: 5 },
    { args: [null, "<div>"], code: 5 },
    { args: [null, "0div"], code: 5 },
    { args: [null, "di v"], code: 5 },
    { args: [null, "di<v"], code: 5 },
    { args: [null, "-div"], code: 5 },
    { args: [null, ".div"], code: 5 },
    { args: ["http://example.com/", "<div>"], code: 5 },
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -406,16 +406,18 @@ partial interface Document {
   void removeBinding(Element elt, DOMString bindingURL);
   Element? getBindingParent(Node node);
   [Throws]
   void loadBindingDocument(DOMString documentURL);
 
   // nsIDOMDocumentTouch
   // XXXbz I can't find the sane spec for this stuff, so just cribbing
   // from our xpidl for now.
+  // XXXbz commented out for now because quickstubs can't do pref-ability
+  /*
   [SetterThrows, Pref="dom.w3c_touch_events.expose"]
   attribute EventHandler ontouchstart;
   [SetterThrows, Pref="dom.w3c_touch_events.expose"]
   attribute EventHandler ontouchend;
   [SetterThrows, Pref="dom.w3c_touch_events.expose"]
   attribute EventHandler ontouchmove;
   [SetterThrows, Pref="dom.w3c_touch_events.expose"]
   attribute EventHandler ontouchenter;
@@ -440,11 +442,12 @@ partial interface Document {
                     optional long radiusX = 0,
                     optional long radiusY = 0,
                     optional float rotationAngle = 0,
                     optional float force = 0);
   [Creator, Pref="dom.w3c_touch_events.expose"]
   TouchList createTouchList(Touch touch);
   [Creator, Pref="dom.w3c_touch_events.expose"]
   TouchList createTouchList(sequence<Touch> touches);
+  */
 };
 
 Document implements XPathEvaluator;
--- a/js/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/xpconnect/src/dom_quickstubs.qsconf
@@ -60,46 +60,16 @@ members = [
     # canvas friends
     'nsIDOMTextMetrics.*',
     'nsIDOMCanvasGradient.*',
     'nsIDOMCanvasPattern.*',
 
     # dom/interfaces/core
     'nsIDOMCharacterData.data',
     'nsIDOMCharacterData.length',
-    'nsIDOMDocument.documentElement',
-    'nsIDOMDocument.implementation',
-    'nsIDOMDocument.getElementsByTagName',
-    'nsIDOMDocument.doctype',
-    'nsIDOMDocument.getElementsByTagNameNS',
-    'nsIDOMDocument.getElementById',
-    'nsIDOMDocument.createDocumentFragment',
-    'nsIDOMDocument.createElement',
-    'nsIDOMDocument.createElementNS',
-    'nsIDOMDocument.importNode',
-    'nsIDOMDocument.createTextNode',
-    'nsIDOMDocument.documentURI',
-    'nsIDOMDocument.adoptNode',
-    'nsIDOMDocument.defaultView',
-    'nsIDOMDocument.createNodeIterator',
-    'nsIDOMDocument.createEvent',
-    'nsIDOMDocument.getElementsByClassName',
-    'nsIDOMDocument.title',
-    'nsIDOMDocument.referrer',
-    'nsIDOMDocument.hasFocus',
-    # This property is treated specially in nsDOMClassInfo in a way that
-    # would shadow any quick stub.  Also, document.location is a special
-    # case for security.
-    #'nsIDOMDocument.location',
-    'nsIDOMDocument.elementFromPoint',
-    'nsIDOMDocument.activeElement',
-    'nsIDOMDocument.onreadystatechange',
-    'nsIDOMDocument.onmouseenter',
-    'nsIDOMDocument.onmouseleave',
-    'nsIDOMDocument.URL',
     'nsIDOMNamedNodeMap.item',
     'nsIDOMNamedNodeMap.length',
     'nsIDOMNodeSelector.querySelector',
     'nsIDOMNodeSelector.querySelectorAll',
     'nsIDOMText.splitText',
     'nsIDOMDOMStringList.*',
     'nsIDOMXULDocument.getBoxObjectFor',
 
@@ -310,19 +280,16 @@ members = [
     'nsIDOMSVGStylable.*',
 
     # dom/interfaces/traversal
     'nsIDOMNodeIterator.nextNode',
 
     # dom/interfaces/xbl - None.
 
     # dom/interfaces/xpath
-    'nsIDOMXPathEvaluator.evaluate',
-    'nsIDOMXPathEvaluator.createExpression',
-    'nsIDOMXPathEvaluator.createNSResolver',
     'nsIDOMXPathExpression.evaluate',
     'nsIDOMXPathNSResolver.lookupNamespaceURI',
     'nsIDOMXPathResult.snapshotItem',
     'nsIDOMXPathResult.iterateNext',
     'nsIDOMXPathResult.snapshotLength',
     'nsIDOMXPathResult.resultType',
     'nsIDOMXPathResult.numberValue',
     'nsIDOMXPathResult.stringValue',
@@ -414,17 +381,18 @@ customIncludes = [
     'nsHTMLDocument.h',
     'nsDOMQS.h',
     'nsDOMStringMap.h',
     'HTMLPropertiesCollection.h',
     'nsHTMLMenuElement.h',
     'nsICSSDeclaration.h',
     'mozilla/dom/NodeBinding.h',
     'mozilla/dom/ElementBinding.h',
-    'mozilla/dom/HTMLElementBinding.h'
+    'mozilla/dom/HTMLElementBinding.h',
+    'mozilla/dom/DocumentBinding.h'
     ]
 
 customReturnInterfaces = [
     'nsIDOMCanvasPattern',
     'nsIDOMCanvasGradient',
     ]
 
 nsIDOMHTMLDocument_Write_customMethodCallCode = """
@@ -501,83 +469,16 @@ customMethodCalls = {
                 '    nsIDOMCSSStyleDeclaration* result = '
                 'self->GetStyle(&rv);'
         },
     'nsIDOMSVGStylable_GetStyle': {
         'thisType': 'nsSVGStylableElement',
         'code': '    nsICSSDeclaration* result = '
                 'self->GetStyle(&rv);'
         },
-    'nsIDOMDocument_': {
-        'thisType': 'nsDocument'
-        },
-    'nsIDOMDocument_GetElementById': {
-        'thisType': 'nsDocument',
-        'code': '    mozilla::dom::Element *result = self->GetElementById(arg0);',
-        'canFail': False
-        },
-    'nsIDOMDocument_GetElementsByTagName': {
-        'thisType': 'nsDocument',
-        'code': '    nsRefPtr<nsContentList> result ='
-                'self->GetElementsByTagName(arg0);',
-        'canFail': False
-        },
-    'nsIDOMDocument_GetElementsByTagNameNS': {
-        'thisType': 'nsDocument',
-        'code': '    nsRefPtr<nsContentList> result ='
-                'self->nsIDocument::GetElementsByTagNameNS(arg0, arg1);',
-        'canFail': False
-        },
-    'nsIDOMDocument_CreateElement': {
-        'thisType': 'nsDocument',
-        'code': '    mozilla::ErrorResult error;\n'
-                '    nsCOMPtr<mozilla::dom::Element> result = self->nsIDocument::CreateElement(arg0, error);\n'
-                '    rv = error.ErrorCode();'
-    },
-    'nsIDOMDocument_CreateElementNS': {
-        'thisType': 'nsDocument',
-        'code': '    mozilla::ErrorResult error;\n'
-                '    nsCOMPtr<mozilla::dom::Element> result = self->nsIDocument::CreateElementNS(arg0, arg1, error);\n'
-                '    rv = error.ErrorCode();'
-    },
-    'nsIDOMDocument_CreateTextNode': {
-        'thisType': 'nsDocument',
-        'code': '    nsCOMPtr<nsIContent> result;\n'
-                '    rv = self->CreateTextNode(arg0, getter_AddRefs(result));'
-    },
-    'nsIDOMDocument_GetOnreadystatechange' : {
-        'thisType' : 'nsDocument',
-        'unwrapThisFailureFatal' : False
-        },
-    'nsIDOMDocument_SetOnreadystatechange' : {
-        'thisType' : 'nsDocument',
-        'unwrapThisFailureFatal' : False
-        },
-    'nsIDOMDocument_GetOnmouseenter' : {
-        'thisType' : 'nsDocument',
-        'unwrapThisFailureFatal' : False
-        },
-    'nsIDOMDocument_SetOnmouseenter' : {
-        'thisType' : 'nsDocument',
-        'unwrapThisFailureFatal' : False
-        },
-    'nsIDOMDocument_GetOnmouseleave' : {
-        'thisType' : 'nsDocument',
-        'unwrapThisFailureFatal' : False
-        },
-    'nsIDOMDocument_SetOnmouseleave' : {
-        'thisType' : 'nsDocument',
-        'unwrapThisFailureFatal' : False
-        },
-    'nsIDOMDocument_GetTitle' : {
-        'thisType' : 'nsDocument',
-        'code': '    nsString result;\n'
-                '    self->GetTitle(result);',
-        'canFail': False
-        },
     'nsIDOMWindow_GetOnmouseenter' : {
         'thisType' : 'nsIDOMWindow',
         'unwrapThisFailureFatal' : False
         },
     'nsIDOMWindow_SetOnmouseenter' : {
         'thisType' : 'nsIDOMWindow',
         'unwrapThisFailureFatal' : False
         },
@@ -589,10 +490,11 @@ customMethodCalls = {
         'thisType' : 'nsIDOMWindow',
         'unwrapThisFailureFatal' : False
         }
     }
 
 newBindingProperties = {
     'nsIDOMNode': 'mozilla::dom::NodeBinding::sNativePropertyHooks.mNativeProperties.regular',
     'nsIDOMElement': 'mozilla::dom::ElementBinding::sNativePropertyHooks.mNativeProperties.regular',
-    'nsIDOMHTMLElement': 'mozilla::dom::HTMLElementBinding::sNativePropertyHooks.mNativeProperties.regular'
+    'nsIDOMHTMLElement': 'mozilla::dom::HTMLElementBinding::sNativePropertyHooks.mNativeProperties.regular',
+    'nsIDOMDocument': 'mozilla::dom::DocumentBinding::sNativePropertyHooks.mNativeProperties.regular'
     }
--- a/js/xpconnect/tests/mochitest/test_bug505915.html
+++ b/js/xpconnect/tests/mochitest/test_bug505915.html
@@ -21,18 +21,20 @@ https://bugzilla.mozilla.org/show_bug.cg
 window.addEventListener("message", function () { gen.next() }, false);
 
 function go() {
     var ifr = $('ifr');
     try {
         document.createTreeWalker(ifr.contentDocument, 0, null, false);
         ok(false, "should have thrown a security exception");
     } catch (e) {
-        ok(/NS_ERROR_XPC_SECURITY_MANAGER_VETO/.test(e),
-           "threw a security exception instead of an invalid child exception");
+        ok(/NS_ERROR_XPC_SECURITY_MANAGER_VETO/.test(e) ||
+           /TypeError: Value does not implement interface Node/.test(e),
+           "threw a security exception or binding exception instead of an " +
+           "invalid child exception");
     }
 
     SimpleTest.finish();
     yield;
 }
 
 SimpleTest.waitForExplicitFinish();