Bug 1146566 - 2 - Avoid using CPOWs in test browser_markupview_tag_edit_03.js; r=bgrins
authorPatrick Brosset <pbrosset@mozilla.com>
Tue, 24 Mar 2015 10:55:02 +0100
changeset 265854 0b91f8d552c888287ae1fbb8606f4da722d6d82f
parent 265853 f97ddbbe1f8bcaacb635e4810317ce48316dc59f
child 265855 e03fe49513913f8e2acc27d751472d277faf791b
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
bugs1146566
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 1146566 - 2 - Avoid using CPOWs in test browser_markupview_tag_edit_03.js; r=bgrins This change updates the browser_markupview_tag_edit_03.js test by making use of the getDomElementInfo message listener to retrieve information about the tested nodes without having to go through CPOWs.
browser/devtools/markupview/test/browser_markupview_tag_edit_03.js
browser/devtools/markupview/test/head.js
--- a/browser/devtools/markupview/test/browser_markupview_tag_edit_03.js
+++ b/browser/devtools/markupview/test/browser_markupview_tag_edit_03.js
@@ -9,31 +9,42 @@
 const TEST_URL = "data:text/html;charset=utf-8,<div id='retag-me'><div id='retag-me-2'></div></div>";
 
 add_task(function*() {
   let {toolbox, inspector} = yield addTab(TEST_URL).then(openInspector);
 
   yield inspector.markup.expandAll();
 
   info("Selecting the test node");
-  let node = content.document.querySelector("#retag-me");
-  let child = content.document.querySelector("#retag-me-2");
   yield selectNode("#retag-me", inspector);
 
+  info("Getting the markup-container for the test node");
   let container = yield getContainerForSelector("#retag-me", inspector);
-  is(node.tagName, "DIV", "We've got #retag-me element, it's a DIV");
-  ok(container.expanded, "It is expanded");
-  is(child.parentNode, node, "Child #retag-me-2 is inside #retag-me");
+  ok(container.expanded, "The container is expanded");
 
-  info("Changing the tagname");
+  let parentInfo = yield getNodeInfo("#retag-me");
+  is(parentInfo.tagName.toLowerCase(), "div",
+     "We've got #retag-me element, it's a DIV");
+  is(parentInfo.numChildren, 1, "#retag-me has one child");
+  let childInfo = yield getNodeInfo("#retag-me > *");
+  is(childInfo.attributes[0].value, "retag-me-2",
+     "#retag-me's only child is #retag-me-2");
+
+  info("Changing #retag-me's tagname in the markup-view");
   let mutated = inspector.once("markupmutation");
   let tagEditor = container.editor.tag;
   setEditableFieldValue(tagEditor, "p", inspector);
   yield mutated;
 
-  info("Checking that the tagname change was done");
-  node = content.document.querySelector("#retag-me");
+  info("Checking that the markup-container exists and is correct");
   container = yield getContainerForSelector("#retag-me", inspector);
-  is(node.tagName, "P", "We've got #retag-me, it should now be a P");
-  ok(container.expanded, "It is still expanded");
-  ok(container.selected, "It is still selected");
-  is(child.parentNode, node, "Child #retag-me-2 is still inside #retag-me");
+  ok(container.expanded, "The container is still expanded");
+  ok(container.selected, "The container is still selected");
+
+  info("Checking that the tagname change was done");
+  parentInfo = yield getNodeInfo("#retag-me");
+  is(parentInfo.tagName.toLowerCase(), "p",
+     "The #retag-me element is now a P");
+  is(parentInfo.numChildren, 1, "#retag-me still has one child");
+  childInfo = yield getNodeInfo("#retag-me > *");
+  is(childInfo.attributes[0].value, "retag-me-2",
+     "#retag-me's only child is #retag-me-2");
 });
--- a/browser/devtools/markupview/test/head.js
+++ b/browser/devtools/markupview/test/head.js
@@ -196,16 +196,25 @@ function getNode(nodeOrSelector) {
 function getNodeFront(selector, {walker}) {
   if (selector._form) {
     return selector;
   }
   return walker.querySelector(walker.rootNode, selector);
 }
 
 /**
+ * Get information about a DOM element, identified by its selector.
+ * @param {String} selector.
+ * @return {Promise} a promise that resolves to the element's information.
+ */
+function getNodeInfo(selector) {
+  return executeInContent("devtools:test:getDomElementInfo", {selector});
+}
+
+/**
  * Highlight a node and set the inspector's current selection to the node or
  * the first match of the given css selector.
  * @param {String|DOMNode} nodeOrSelector
  * @param {InspectorPanel} inspector
  *        The instance of InspectorPanel currently loaded in the toolbox
  * @return a promise that resolves when the inspector is updated with the new
  * node
  */