Bug 1146591 - Avoid unsafe CPOW usage in helper_outerhtml_test_runner.js; r=bgrins
authorPatrick Brosset <pbrosset@mozilla.com>
Wed, 25 Mar 2015 18:03:22 +0100
changeset 266035 3bf5485eb14b0bcb71363ca85a711f91926c5fd6
parent 266034 e88d6472a87f172e978f544949778f024ab0196e
child 266036 16dff8194cdeb9268b29d1b5216ed6037d038190
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1146591
milestone39.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 1146591 - Avoid unsafe CPOW usage in helper_outerhtml_test_runner.js; r=bgrins helper_outerhtml_test_runner.js was accessing DOM nodes directly in content (via CPOWs) to check their outerHTML. This change adds outerHTML, innerHTML and textContent to the common devtools:test:getDomElementInfo frame-script message listener so that the test can get it there instead.
browser/devtools/markupview/test/helper_outerhtml_test_runner.js
browser/devtools/shared/frame-script-utils.js
--- a/browser/devtools/markupview/test/helper_outerhtml_test_runner.js
+++ b/browser/devtools/markupview/test/helper_outerhtml_test_runner.js
@@ -45,25 +45,26 @@ function* runEditOuterHTMLTest(test, ins
   let onUpdated = inspector.once("inspector-updated");
 
   info("Listen for reselectedonremoved and edit the outerHTML");
   let onReselected = inspector.markup.once("reselectedonremoved");
   yield inspector.markup.updateNodeOuterHTML(inspector.selection.nodeFront,
                                              test.newHTML, test.oldHTML);
   yield onReselected;
 
-  // Typically selectedNode will === pageNode, but if a new element has been injected in front
-  // of it, this will not be the case.  If this happens.
+  // Typically selectedNode will === pageNode, but if a new element has been
+  // injected in front of it, this will not be the case. If this happens.
   let selectedNodeFront = inspector.selection.nodeFront;
   let pageNodeFront = yield inspector.walker.querySelector(inspector.walker.rootNode, test.selector);
   let pageNode = getNode(test.selector);
 
   if (test.validate) {
     yield test.validate(pageNode, pageNodeFront, selectedNodeFront, inspector);
   } else {
     is(pageNodeFront, selectedNodeFront, "Original node (grabbed by selector) is selected");
-    is(pageNode.outerHTML, test.newHTML, "Outer HTML has been updated");
+    let {outerHTML} = yield getNodeInfo(test.selector);
+    is(outerHTML, test.newHTML, "Outer HTML has been updated");
   }
 
   // Wait for the inspector to be fully updated to avoid causing errors by
   // abruptly closing hanging requests when the test ends
   yield onUpdated;
 }
--- a/browser/devtools/shared/frame-script-utils.js
+++ b/browser/devtools/shared/frame-script-utils.js
@@ -138,30 +138,36 @@ addMessageListener("devtools:test:setSty
  * @param {Object} data
  * - {String} selector The CSS selector to get the node (can be a "super"
  *   selector).
  * @return {Object} data Null if selector didn't match any node, otherwise:
  * - {String} tagName.
  * - {String} namespaceURI.
  * - {Number} numChildren The number of children in the element.
  * - {Array} attributes An array of {name, value, namespaceURI} objects.
+ * - {String} outerHTML.
+ * - {String} innerHTML.
+ * - {String} textContent.
  */
 addMessageListener("devtools:test:getDomElementInfo", function(msg) {
   let {selector} = msg.data;
   let node = superQuerySelector(selector);
 
   let info = null;
   if (node) {
     info = {
       tagName: node.tagName,
       namespaceURI: node.namespaceURI,
       numChildren: node.children.length,
       attributes: [...node.attributes].map(({name, value, namespaceURI}) => {
         return {name, value, namespaceURI};
-      })
+      }),
+      outerHTML: node.outerHTML,
+      innerHTML: node.innerHTML,
+      textContent: node.textContent
     };
   }
 
   sendAsyncMessage("devtools:test:getDomElementInfo", info);
 });
 
 /**
  * Set a given attribute value on a node.