|
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 testRearrange() { |
|
46 let longlist = null; |
|
47 let nodeA = null; |
|
48 let nextNode = null; |
|
49 |
|
50 promiseDone(gWalker.querySelector(gWalker.rootNode, "#longlist").then(listFront => { |
|
51 longlist = listFront; |
|
52 }).then(() => { |
|
53 return gWalker.children(longlist); |
|
54 }).then(response => { |
|
55 nodeA = response.nodes[0]; |
|
56 is(nodeA.id, "a", "Got the expected node."); |
|
57 // Move nodeA to the end of the list. |
|
58 return gWalker.insertBefore(nodeA, longlist, null); |
|
59 }).then(() => { |
|
60 ok(!gInspectee.querySelector("#a").nextSibling, "a should now be at the end of the list."); |
|
61 return gWalker.children(longlist); |
|
62 }).then(response => { |
|
63 is(nodeA, response.nodes[response.nodes.length - 1], "a should now be the last returned child."); |
|
64 // Now move it to the middle of the list. |
|
65 nextNode = response.nodes[13]; |
|
66 return gWalker.insertBefore(nodeA, longlist, nextNode); |
|
67 }).then(response => { |
|
68 let sibling = inspector._documentWalker(gInspectee.querySelector("#a"), window).nextSibling(); |
|
69 is(sibling, nextNode.rawNode(), "Node should match the expected next node."); |
|
70 return gWalker.children(longlist); |
|
71 }).then(response => { |
|
72 is(nodeA, response.nodes[13], "a should be where we expect it."); |
|
73 is(nextNode, response.nodes[14], "next node should be where we expect it."); |
|
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> |