Bug 1202458 - part4: update inspector actor&front tests after removing shortValue;r=pbro
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 02 Jun 2016 16:25:56 +0200
changeset 339346 c60e3877ccf650d0b665b2395c9dc9794ff820a5
parent 339345 96f3ba6f40966164d51a040b8c8eb25c80ff07ed
child 339347 c8ca3bba2124d009256972f3b08bf5592c047005
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1202458
milestone49.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 1202458 - part4: update inspector actor&front tests after removing shortValue;r=pbro Adapt existing tests checking for updates to shortValue and incompleteValue on NodeFront instances. Instead we now check for mutations of inlineTextChild type as well as for the inlineTextChild property of the parent front. MozReview-Commit-ID: 1mujxwVfvvP
devtools/server/tests/mochitest/test_inspector-mutations-value.html
devtools/server/tests/mochitest/test_inspector-traversal.html
--- a/devtools/server/tests/mochitest/test_inspector-mutations-value.html
+++ b/devtools/server/tests/mochitest/test_inspector-mutations-value.html
@@ -24,16 +24,17 @@ SimpleTest.registerCleanupFunction(funct
   inspector.setValueSummaryLength(inspector.DEFAULT_VALUE_SUMMARY_LENGTH);
 });
 
 var gInspectee = null;
 var gWalker = null;
 var gClient = null;
 var valueNode;
 var valueFront;
+var longStringFront;
 var longString = "stringstringstringstringstringstringstringstringstringstringstring";
 var truncatedLongString = longString.substring(0, testSummaryLength);
 var shortString = "str";
 var shortString2 = "str2";
 
 addTest(function setup() {
   let url = document.getElementById("inspectorContent").href;
   attachURL(url, function(err, client, tab, doc) {
@@ -57,87 +58,106 @@ addTest(setupFrameValueTest);
 addTest(testKeepLongValue);
 addTest(testSetShortValue);
 addTest(testKeepShortValue);
 addTest(testSetLongValue);
 
 function setupValueTest() {
   valueNode = gInspectee.querySelector("#longstring").firstChild;
   promiseDone(gWalker.querySelector(gWalker.rootNode, "#longstring").then(node => {
+    longStringFront = node;
     return gWalker.children(node);
   }).then(children => {
     valueFront = children.nodes[0];
   }).then(runNextTest));
 }
 
 function setupFrameValueTest() {
   let frame = gInspectee.querySelector('#childFrame');
   valueNode = frame.contentDocument.querySelector("#longstring").firstChild;
 
   promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => {
     return gWalker.children(childFrame);
   }).then(children => {
     let nodes = children.nodes;
-    ok(nodes.length, 1, "There should be only one child of the iframe");
+    is(nodes.length, 1, "There should be only one child of the iframe");
     is(nodes[0].nodeType, Node.DOCUMENT_NODE, "iframe child should be a document node");
     return gWalker.querySelector(nodes[0], "#longstring");
   }).then(node => {
+    longStringFront = node;
     return gWalker.children(node);
   }).then(children => {
     valueFront = children.nodes[0];
   }).then(runNextTest));
 }
 
+function checkNodeFrontValue(front, expectedValue) {
+  return front.getNodeValue().then(longstring => {
+    return longstring.string();
+  }).then(str => {
+    is(str, expectedValue, "Node value is as expected");
+  })
+}
+
 function testKeepLongValue() {
   // After first setup we should have a long string in the node
-  is(valueFront.shortValue.length, testSummaryLength, "After setup the test node should be truncated.");
-  ok(valueFront.incompleteValue, "After setup the node value should be incomplete.");
+  ok(!longStringFront.inlineTextChild, "Text node is too long to be inlined.");
+
   valueNode.nodeValue = longString;
-  gWalker.once("mutations", () => {
-    is(valueFront.shortValue, truncatedLongString, "Value should have changed to a truncated value");
-    ok(valueFront.incompleteValue, "Node value should stay incomplete.");
-    runNextTest();
+  gWalker.once("mutations", (changes) => {
+    ok(!longStringFront.inlineTextChild, "Text node is too long to be inlined.");
+    ok(!changes.some(change => change.type === "inlineTextChild"),
+      "No inline text child mutation was fired.");
+    checkNodeFrontValue(valueFront, longString).then(runNextTest);
   });
 }
 
 function testSetShortValue() {
+  ok(!longStringFront.inlineTextChild, "Text node is too long to be inlined.");
+
   valueNode.nodeValue = shortString;
-  gWalker.once("mutations", () => {
-    is(valueFront.shortValue, shortString, "Value should not be truncated.");
-    ok(!valueFront.incompleteValue, "Value should not be incomplete.");
-    runNextTest();
+  gWalker.once("mutations", (changes) => {
+    ok(!!longStringFront.inlineTextChild, "Text node is short enough to be inlined.");
+    ok(changes.some(change => change.type === "inlineTextChild"),
+      "An inlineTextChild mutation was fired.");
+    checkNodeFrontValue(valueFront, shortString).then(runNextTest);
   });
 }
 
 function testKeepShortValue() {
+  ok(!!longStringFront.inlineTextChild, "Text node is short enough to be inlined.");
+
   valueNode.nodeValue = shortString2;
-  gWalker.once("mutations", () => {
-    is(valueFront.shortValue, shortString2, "Value should not be truncated.");
-    ok(!valueFront.incompleteValue, "Value should not be incomplete.");
-    runNextTest();
+  gWalker.once("mutations", (changes) => {
+    ok(!!longStringFront.inlineTextChild, "Text node is short enough to be inlined.");
+    ok(!changes.some(change => change.type === "inlineTextChild"),
+      "No inline text child mutation was fired.");
+    checkNodeFrontValue(valueFront, shortString2).then(runNextTest);
   });
 }
 
 function testSetLongValue() {
+  ok(!!longStringFront.inlineTextChild, "Text node is short enough to be inlined.");
+
   valueNode.nodeValue = longString;
-  gWalker.once("mutations", () => {
-    is(valueFront.shortValue, truncatedLongString, "Value should have changed to a truncated value");
-    ok(valueFront.incompleteValue, "Node value should stay incomplete.");
-    runNextTest();
+  gWalker.once("mutations", (changes) => {
+    ok(!longStringFront.inlineTextChild, "Text node is too long to be inlined.");
+    ok(changes.some(change => change.type === "inlineTextChild"),
+      "An inlineTextChild mutation was fired.");
+    checkNodeFrontValue(valueFront, longString).then(runNextTest);
   });
 }
 
 addTest(function cleanup() {
   delete gInspectee;
   delete gWalker;
   delete gClient;
   runNextTest();
 });
 
-
   </script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
 <a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
 <p id="display"></p>
 <div id="content" style="display: none">
 
--- a/devtools/server/tests/mochitest/test_inspector-traversal.html
+++ b/devtools/server/tests/mochitest/test_inspector-traversal.html
@@ -256,17 +256,17 @@ addTest(function testPreviousSibling() {
 });
 
 
 addTest(function testFrameTraversal() {
   promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => {
     return gWalker.children(childFrame);
   }).then(children => {
     let nodes = children.nodes;
-    ok(nodes.length, 1, "There should be only one child of the iframe");
+    is(nodes.length, 1, "There should be only one child of the iframe");
     is(nodes[0].nodeType, Node.DOCUMENT_NODE, "iframe child should be a document node");
     return gWalker.querySelector(nodes[0], "#z");
   }).then(childDocumentZ => {
     return gWalker.parents(childDocumentZ);
   }).then(parents => {
     // Expected set of parent tag names for this item:
     let expectedParents = ['DIV', 'BODY', 'HTML', '#document', 'IFRAME', 'BODY', 'HTML', '#document'];
     for (let parent of parents) {
@@ -281,44 +281,42 @@ addTest(function testLongValue() {
   inspector.setValueSummaryLength(testSummaryLength);
   SimpleTest.registerCleanupFunction(function() {
     inspector.setValueSummaryLength(inspector.DEFAULT_VALUE_SUMMARY_LENGTH);
   });
 
   let longstringText = gInspectee.getElementById("longstring").firstChild.nodeValue;
 
   promiseDone(gWalker.querySelector(gWalker.rootNode, "#longstring").then(node => {
+    ok(!node.inlineTextChild, "Text is too long to be inlined");
     // Now we need to get the text node child...
     return gWalker.children(node, { maxNodes: 1 });
   }).then(children => {
     let textNode = children.nodes[0];
     is(textNode.nodeType, Node.TEXT_NODE, "Value should be a text node");
-    is(textNode.shortValue.length, 10, "Value summary should be limited to the summary value length");
-    ok(textNode.incompleteValue, "Value should be incomplete");
     return textNode;
   }).then(textNode => {
     return textNode.getNodeValue();
   }).then(value => {
     return value.string();
   }).then(valueStr => {
     is(valueStr, longstringText, "Full node value should match the string from the document.");
   }).then(runNextTest));
 });
 
 addTest(function testShortValue() {
   let shortstringText = gInspectee.getElementById("shortstring").firstChild.nodeValue;
 
   promiseDone(gWalker.querySelector(gWalker.rootNode, "#shortstring").then(node => {
+    ok(!!node.inlineTextChild, "Text is short enough to be inlined");
     // Now we need to get the text node child...
     return gWalker.children(node, { maxNodes: 1 });
   }).then(children => {
     let textNode = children.nodes[0];
     is(textNode.nodeType, Node.TEXT_NODE, "Value should be a text node");
-    is(textNode.shortValue, shortstringText, "Value should be complete");
-    ok(!textNode.incompleteValue, "Value should be complete");
     return textNode;
   }).then(textNode => {
     return textNode.getNodeValue();
   }).then(value => {
     return value.string();
   }).then(valueStr => {
     is(valueStr, shortstringText, "Full node value should match the string from the document.");
   }).then(runNextTest));