|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id= |
|
5 --> |
|
6 <head> |
|
7 <meta charset="utf-8"> |
|
8 <title>Test for Bug </title> |
|
9 |
|
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
11 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> |
|
12 <script type="application/javascript;version=1.8" src="inspector-helpers.js"></script> |
|
13 <script type="application/javascript;version=1.8"> |
|
14 Components.utils.import("resource://gre/modules/devtools/Loader.jsm"); |
|
15 const {Promise: promise} = Components.utils.import("resource://gre/modules/Promise.jsm", {}); |
|
16 |
|
17 const inspector = devtools.require("devtools/server/actors/inspector"); |
|
18 |
|
19 window.onload = function() { |
|
20 SimpleTest.waitForExplicitFinish(); |
|
21 runNextTest(); |
|
22 } |
|
23 |
|
24 var gWalker = null; |
|
25 var gClient = null; |
|
26 |
|
27 function assertOwnership() { |
|
28 return assertOwnershipTrees(gWalker); |
|
29 } |
|
30 |
|
31 addTest(function setup() { |
|
32 let url = document.getElementById("inspectorContent").href; |
|
33 attachURL(url, function(err, client, tab, doc) { |
|
34 gInspectee = doc; |
|
35 let {InspectorFront} = devtools.require("devtools/server/actors/inspector"); |
|
36 let inspector = InspectorFront(client, tab); |
|
37 promiseDone(inspector.getWalker().then(walker => { |
|
38 ok(walker, "getWalker() should return an actor."); |
|
39 gClient = client; |
|
40 gWalker = walker; |
|
41 }).then(runNextTest)); |
|
42 }); |
|
43 }); |
|
44 |
|
45 addTest(function testRemoveSubtree() { |
|
46 let originalOwnershipSize = 0; |
|
47 let longlist = null; |
|
48 let longlistID = null; |
|
49 |
|
50 let nextSibling = gInspectee.querySelector("#longlist").nextSibling; |
|
51 // Duplicate the walker logic to skip blank nodes... |
|
52 while (nextSibling && nextSibling.nodeType === Components.interfaces.nsIDOMNode.TEXT_NODE && !/[^\s]/.exec(nextSibling.nodeValue)) { |
|
53 nextSibling = nextSibling.nextSibling; |
|
54 } |
|
55 |
|
56 promiseDone(gWalker.querySelector(gWalker.rootNode, "#longlist").then(listFront => { |
|
57 longlist = listFront; |
|
58 longlistID = longlist.actorID; |
|
59 }).then(() => { |
|
60 return gWalker.children(longlist); |
|
61 }).then((items)=> { |
|
62 originalOwnershipSize = assertOwnership(); |
|
63 ok(originalOwnershipSize > 26, "Should have at least 26 items in our ownership tree"); |
|
64 return gWalker.removeNode(longlist); |
|
65 }).then(nextSiblingFront => { |
|
66 is(nextSiblingFront.rawNode(), nextSibling, "Should have returned the next sibling."); |
|
67 return waitForMutation(gWalker, isChildList); |
|
68 }).then(() => { |
|
69 // Our ownership size should now be 26 fewer (we forgot about #longlist + 26 children, but learned about #longlist's next sibling) |
|
70 let newOwnershipSize = assertOwnership(); |
|
71 is(newOwnershipSize, originalOwnershipSize - 26, "Ownership tree should have dropped by 27 nodes"); |
|
72 // Now verify that some nodes have gone away |
|
73 return checkMissing(gClient, longlistID); |
|
74 }).then(runNextTest)); |
|
75 }); |
|
76 |
|
77 addTest(function cleanup() { |
|
78 delete gWalker; |
|
79 delete gClient; |
|
80 runNextTest(); |
|
81 }); |
|
82 |
|
83 |
|
84 </script> |
|
85 </head> |
|
86 <body> |
|
87 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a> |
|
88 <a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a> |
|
89 <p id="display"></p> |
|
90 <div id="content" style="display: none"> |
|
91 |
|
92 </div> |
|
93 <pre id="test"> |
|
94 </pre> |
|
95 </body> |
|
96 </html> |