Bug 1453053 part 1. Remove useless QIs to nsIDOMNode. r=qdot
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 12 Apr 2018 00:06:25 -0400
changeset 466463 f57ccba9c9b51bf5bb1c01517c8af1f5f3ebe099
parent 466462 3406e123d279f0959468a4de10e8983cc3d327dc
child 466464 4b2e0e54b9301a779838c9989a9ee5569b348c02
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1453053
milestone61.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 1453053 part 1. Remove useless QIs to nsIDOMNode. r=qdot MozReview-Commit-ID: GokPD2buxzN
accessible/tests/mochitest/events/test_focus_autocomplete.xul
dom/base/test/chrome/cpows_parent.xul
dom/base/test/unit/test_isequalnode.js
js/xpconnect/tests/unit/test_xpcomutils.js
netwerk/test/httpserver/test/test_default_index_handler.js
toolkit/components/passwordmgr/test/pwmgr_common.js
--- a/accessible/tests/mochitest/events/test_focus_autocomplete.xul
+++ b/accessible/tests/mochitest/events/test_focus_autocomplete.xul
@@ -254,17 +254,17 @@
       }
 
       // XUL autocomplete
       var popupNode = autocompleteNode.popup;
       if (!popupNode) {
         // HTML form autocomplete
         var controller = Cc["@mozilla.org/autocomplete/controller;1"].
           getService(Ci.nsIAutoCompleteController);
-        popupNode = controller.input.popup.QueryInterface(nsIDOMNode);
+        popupNode = controller.input.popup;
       }
 
       if (popupNode) {
         if ("richlistbox" in popupNode) {
           var list = getAccessible(popupNode.richlistbox);
           return list.getChildAt(aItemObj.index);
         }
 
--- a/dom/base/test/chrome/cpows_parent.xul
+++ b/dom/base/test/chrome/cpows_parent.xul
@@ -206,18 +206,16 @@
     }
 
     let savedElement = null;
     function recvDomTest(message) {
       savedElement = message.objects.element;
 
       is(savedElement.QueryInterface(Ci.nsISupports), savedElement,
          "QI to nsISupports works");
-      is(savedElement.QueryInterface(Ci.nsIDOMNode), savedElement,
-         "QI to a random (implemented) interface works");
 
       function testNoInterface(savedElement, i) {
         try {
           savedElement.QueryInterface(i);
           ok(false, "should have thrown an exception");
         } catch (e) {
           is(e.result, Cr.NS_ERROR_NO_INTERFACE, "threw the right exception");
         }
--- a/dom/base/test/unit/test_isequalnode.js
+++ b/dom/base/test/unit/test_isequalnode.js
@@ -41,20 +41,20 @@ function test_isEqualNode_setAttribute()
   // NOTE: 0, 2 are whitespace
   var test1 = doc.getElementById("test_setAttribute");
   var node1 = test1.childNodes.item(1);
   var node2 = test1.childNodes.item(3);
 
   check_eq_nodes(node1, node2);
 
 
-  el(node1).setAttribute("bar", "baz");
+  node1.setAttribute("bar", "baz");
   check_neq_nodes(node1, node2);
 
-  el(node2).setAttribute("bar", "baz");
+  node2.setAttribute("bar", "baz");
   check_eq_nodes(node1, node2);
 
 
   // the null namespace is equivalent to no namespace -- section 1.3.3
   // (XML Namespaces) of DOM 3 Core
   node1.setAttributeNS(null, "quux", "17");
   check_neq_nodes(node1, node2);
 
@@ -80,17 +80,17 @@ function test_isEqualNode_setAttribute()
 }
 
 function test_isEqualNode_clones()
 {
   // tests all elements and attributes in the document
   var all_elts = doc.getElementsByTagName("*");
   for (var i = 0; i < all_elts.length; i++)
   {
-    var elt = el(all_elts.item(i));
+    var elt = all_elts.item(i);
     check_eq_nodes(elt, elt.cloneNode(true));
 
     var attrs = elt.attributes;
     for (var j = 0; j < attrs.length; j++)
     {
       var attr = attrs.item(j);
       check_eq_nodes(attr, attr.cloneNode(true));
     }
@@ -381,22 +381,16 @@ function test_isEqualNode_wholeDoc()
     doc2.createTreeWalker(doc2, NodeFilter.SHOW_ALL,
                           null);
   do {
     check_eq_nodes(tw1.currentNode, tw2.currentNode);
     tw1.nextNode();
   } while(tw2.nextNode());
 }
 
-// UTILITY FUNCTIONS
-
-function n(node)  { return node ? node.QueryInterface(nsIDOMNode) : null; }
-function el(node) { return node ? node.QueryInterface(nsIDOMElement) : null; }
-
-
 // TESTING FUNCTIONS
 
 /**
  * Compares the first and third (zero-indexed) child nodes of the element
  * (typically to allow whitespace) referenced by parentId for isEqualNode
  * equality or inequality based on the value of areEqual.
  *
  * Note that this means that the contents of the element referenced by parentId
--- a/js/xpconnect/tests/unit/test_xpcomutils.js
+++ b/js/xpconnect/tests/unit/test_xpcomutils.js
@@ -14,32 +14,32 @@ ChromeUtils.import("resource://gre/modul
 ////////////////////////////////////////////////////////////////////////////////
 //// Tests
 
 add_test(function test_generateQI_string_names()
 {
     var x = {
         QueryInterface: XPCOMUtils.generateQI([
             Ci.nsIClassInfo,
-            "nsIDOMNode"
+            "nsIObserver"
         ])
     };
 
     try {
         x.QueryInterface(Ci.nsIClassInfo);
     } catch(e) {
         do_throw("Should QI to nsIClassInfo");
     }
     try {
-        x.QueryInterface(Ci.nsIDOMNode);
+        x.QueryInterface(Ci.nsIObserver);
     } catch(e) {
-        do_throw("Should QI to nsIDOMNode");
+        do_throw("Should QI to nsIObserver");
     }
     try {
-        x.QueryInterface(Ci.nsIDOMDocument);
+        x.QueryInterface(Ci.nsIObserverService);
         do_throw("QI should not have succeeded!");
     } catch(e) {}
     run_next_test();
 });
 
 
 add_test(function test_generateCI()
 {
--- a/netwerk/test/httpserver/test/test_default_index_handler.js
+++ b/netwerk/test/httpserver/test/test_default_index_handler.js
@@ -103,53 +103,43 @@ function hiddenDataCheck(bytes, uri, pat
   {
     var doc = parser.parseFromString(data, "application/xml");
   }
   catch (e)
   {
     do_throw("document failed to parse as XML");
   }
 
-  // See all the .QueryInterface()s and .item()s happening here?  That's because
-  // xpcshell sucks and doesn't have classinfo, so no automatic interface
-  // flattening or array-style access to items in NodeLists.  Suck.
-
   var body = doc.documentElement.getElementsByTagName("body");
   Assert.equal(body.length, 1);
-  body = body.item(0);
+  body = body[0];
 
   // header
-  var header = body.QueryInterface(Ci.nsIDOMElement)
-                   .getElementsByTagName("h1");
+  var header = body.getElementsByTagName("h1");
   Assert.equal(header.length, 1);
 
-  Assert.equal(header.item(0).QueryInterface(Ci.nsIDOMNode).textContent, path);
+  Assert.equal(header[0].textContent, path);
 
   // files
   var lst = body.getElementsByTagName("ol");
   Assert.equal(lst.length, 1);
-  var items = lst.item(0).QueryInterface(Ci.nsIDOMElement)
-                         .getElementsByTagName("li");
+  var items = lst[0].getElementsByTagName("li");
 
   var ios = Cc["@mozilla.org/network/io-service;1"]
               .getService(Ci.nsIIOService);
 
   var top = ios.newURI(uri);
 
   // N.B. No ERROR_IF_SEE_THIS.txt^ file!
   var dirEntries = [{name: "file.txt", isDirectory: false},
                     {name: "SHOULD_SEE_THIS.txt^", isDirectory: false}];
 
   for (var i = 0; i < items.length; i++)
   {
-    var link = items.item(i)
-                    .childNodes
-                    .item(0)
-                    .QueryInterface(Ci.nsIDOMNode)
-                    .QueryInterface(Ci.nsIDOMElement);
+    var link = items[i].childNodes[0];
     var f = dirEntries[i];
 
     var sep = f.isDirectory ? "/" : "";
 
     Assert.equal(link.textContent, f.name + sep);
 
     uri = ios.newURI(link.getAttribute("href"), null, top);
     Assert.equal(decodeURIComponent(uri.pathQueryRef), path + f.name + sep);
@@ -187,49 +177,39 @@ function dataCheck(bytes, uri, path, dir
   {
     var doc = parser.parseFromString(data, "application/xml");
   }
   catch (e)
   {
     do_throw("document failed to parse as XML");
   }
 
-  // See all the .QueryInterface()s and .item()s happening here?  That's because
-  // xpcshell sucks and doesn't have classinfo, so no automatic interface
-  // flattening or array-style access to items in NodeLists.  Suck.
-
   var body = doc.documentElement.getElementsByTagName("body");
   Assert.equal(body.length, 1);
-  body = body.item(0);
+  body = body[0];
 
   // header
-  var header = body.QueryInterface(Ci.nsIDOMElement)
-                   .getElementsByTagName("h1");
+  var header = body.getElementsByTagName("h1");
   Assert.equal(header.length, 1);
 
-  Assert.equal(header.item(0).QueryInterface(Ci.nsIDOMNode).textContent, path);
+  Assert.equal(header[0].textContent, path);
 
   // files
   var lst = body.getElementsByTagName("ol");
   Assert.equal(lst.length, 1);
-  var items = lst.item(0).QueryInterface(Ci.nsIDOMElement)
-                         .getElementsByTagName("li");
+  var items = lst[0].getElementsByTagName("li");
 
   var ios = Cc["@mozilla.org/network/io-service;1"]
               .getService(Ci.nsIIOService);
 
   var dirURI = ios.newURI(uri);
 
   for (var i = 0; i < items.length; i++)
   {
-    var link = items.item(i)
-                    .childNodes
-                    .item(0)
-                    .QueryInterface(Ci.nsIDOMNode)
-                    .QueryInterface(Ci.nsIDOMElement);
+    var link = items[i].childNodes[0];
     var f = dirEntries[i];
 
     var sep = f.isDirectory ? "/" : "";
 
     Assert.equal(link.textContent, f.name + sep);
 
     uri = ios.newURI(link.getAttribute("href"), null, top);
     Assert.equal(decodeURIComponent(uri.pathQueryRef), path + f.name + sep);
--- a/toolkit/components/passwordmgr/test/pwmgr_common.js
+++ b/toolkit/components/passwordmgr/test/pwmgr_common.js
@@ -156,17 +156,17 @@ function registerRunTests() {
       username.name = "testuser";
       form.appendChild(username);
       var password = document.createElement("input");
       password.name = "testpass";
       password.type = "password";
       form.appendChild(password);
 
       var observer = SpecialPowers.wrapCallback(function(subject, topic, data) {
-        var formLikeRoot = subject.QueryInterface(SpecialPowers.Ci.nsIDOMNode);
+        var formLikeRoot = subject;
         if (formLikeRoot.id !== "observerforcer")
           return;
         SpecialPowers.removeObserver(observer, "passwordmgr-processed-form");
         formLikeRoot.remove();
         SimpleTest.executeSoon(() => {
           var runTestEvent = new Event("runTests");
           window.dispatchEvent(runTestEvent);
           resolve();