Bug 1402848 - Add a test case for expanding object with proper length; r=Honza draft
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Wed, 04 Oct 2017 10:38:01 +0200
changeset 674733 80cca9b2e784341fdca6461ef8171db349d95f80
parent 674516 c97190c389c4cfef20fe55b4bacade95a36ae6ef
child 734412 c0d9f97cddf79596dfd132a95f92b7ae5434d159
push id82926
push userbmo:nchevobbe@mozilla.com
push dateWed, 04 Oct 2017 08:43:14 +0000
reviewersHonza
bugs1402848, 1403065
milestone58.0a1
Bug 1402848 - Add a test case for expanding object with proper length; r=Honza In Bug 1403065, we introduce a server fix for that as well as some tests. But they are testing specific server functions. Adding a test on the client side will prevent any regression if we end up using other server methods. MozReview-Commit-ID: D3FGGOtiTBw
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_object_inspector.js
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_object_inspector.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_object_inspector.js
@@ -23,57 +23,73 @@ add_task(async function () {
       }, []);
     info("messages : " + JSON.stringify(messages));
   });
 
   await ContentTask.spawn(gBrowser.selectedBrowser, null, function () {
     content.wrappedJSObject.console.log(
       "oi-test",
       [1, 2, {a: "a", b: "b"}],
-      {c: "c", d: [3, 4]}
+      {c: "c", d: [3, 4], length: 987}
     );
   });
 
   let node = await waitFor(() => findMessage(hud, "oi-test"));
   const objectInspectors = [...node.querySelectorAll(".tree")];
   is(objectInspectors.length, 2, "There is the expected number of object inspectors");
 
-  const [arrayOi] = objectInspectors;
+  const [arrayOi, objectOi] = objectInspectors;
 
   info("Expanding the array object inspector");
 
   let onArrayOiMutation = waitForNodeMutation(arrayOi, {
     childList: true
   });
 
   arrayOi.querySelector(".arrow").click();
   await onArrayOiMutation;
 
   ok(arrayOi.querySelector(".arrow").classList.contains("expanded"),
     "The arrow of the root node of the tree is expanded after clicking on it");
 
   let arrayOiNodes = arrayOi.querySelectorAll(".node");
-  // There are 6 nodes: the root, 1, 2, {a: "a", b: "b"}, length and the proto.
+
+  // The object inspector now looks like:
+  // ▼ […]
+  // |  0: 1
+  // |  1: 2
+  // |  ▶︎ 2: {a: "a", b: "b"}
+  // |  length: 3
+  // |  ▶︎ __proto__
   is(arrayOiNodes.length, 6, "There is the expected number of nodes in the tree");
 
   info("Expanding a leaf of the array object inspector");
   let arrayOiNestedObject = arrayOiNodes[3];
   onArrayOiMutation = waitForNodeMutation(arrayOi, {
     childList: true
   });
 
   arrayOiNestedObject.querySelector(".arrow").click();
   await onArrayOiMutation;
 
   ok(arrayOiNestedObject.querySelector(".arrow").classList.contains("expanded"),
     "The arrow of the root node of the tree is expanded after clicking on it");
 
   arrayOiNodes = arrayOi.querySelectorAll(".node");
-  // There are now 9 nodes, the 6 original ones, and 3 new from the expanded object:
-  // a, b and the proto.
+
+  // The object inspector now looks like:
+  // ▼ […]
+  // |  0: 1
+  // |  1: 2
+  // |  ▼ 2: {…}
+  // |  |  a: "a"
+  // |  |  b: "b"
+  // |  |  ▶︎ __proto__
+  // |  length: 3
+  // |  ▶︎ __proto__
   is(arrayOiNodes.length, 9, "There is the expected number of nodes in the tree");
 
   info("Collapsing the root");
   onArrayOiMutation = waitForNodeMutation(arrayOi, {
     childList: true
   });
   arrayOi.querySelector(".arrow").click();
 
@@ -93,9 +109,28 @@ add_task(async function () {
     "The arrow of the root node of the tree is expanded again after clicking on it");
 
   arrayOiNodes = arrayOi.querySelectorAll(".node");
   arrayOiNestedObject = arrayOiNodes[3];
   ok(arrayOiNestedObject.querySelector(".arrow").classList.contains("expanded"),
     "The object tree is still expanded");
 
   is(arrayOiNodes.length, 9, "There is the expected number of nodes in the tree");
+
+  let onObjectOiMutation = waitForNodeMutation(objectOi, {
+    childList: true
+  });
+
+  objectOi.querySelector(".arrow").click();
+  await onObjectOiMutation;
+
+  ok(objectOi.querySelector(".arrow").classList.contains("expanded"),
+    "The arrow of the root node of the tree is expanded after clicking on it");
+
+  let objectOiNodes = objectOi.querySelectorAll(".node");
+  // The object inspector now looks like:
+  // ▼ {…}
+  // |  c: "c"
+  // |  ▶︎ d: [3, 4]
+  // |  length: 987
+  // |  ▶︎ __proto__
+  is(objectOiNodes.length, 5, "There is the expected number of nodes in the tree");
 });