|
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 gInspectee = null; |
|
25 var gClient = null; |
|
26 var gWalker = null; |
|
27 var checkActorIDs = []; |
|
28 |
|
29 function assertOwnership() { |
|
30 assertOwnershipTrees(gWalker); |
|
31 } |
|
32 |
|
33 addTest(function setup() { |
|
34 let url = document.getElementById("inspectorContent").href; |
|
35 attachURL(url, function(err, client, tab, doc) { |
|
36 gInspectee = doc; |
|
37 let {InspectorFront} = devtools.require("devtools/server/actors/inspector"); |
|
38 let inspector = InspectorFront(client, tab); |
|
39 promiseDone(inspector.getWalker().then(walker => { |
|
40 ok(walker, "getWalker() should return an actor."); |
|
41 gClient = client; |
|
42 gWalker = walker; |
|
43 }).then(runNextTest)); |
|
44 }); |
|
45 }); |
|
46 |
|
47 addTest(function testChangeAttrs() { |
|
48 let attrNode = gInspectee.querySelector("#a"); |
|
49 let attrFront; |
|
50 promiseDone(gWalker.querySelector(gWalker.rootNode, "#a").then(front => { |
|
51 attrFront = front; |
|
52 dump("attrFront is: " + attrFront + "\n"); |
|
53 // Add a few attributes. |
|
54 let list = attrFront.startModifyingAttributes(); |
|
55 list.setAttribute("data-newattr", "newvalue"); |
|
56 list.setAttribute("data-newattr2", "newvalue"); |
|
57 return list.apply(); |
|
58 }).then(() => { |
|
59 // We're only going to test that the change hit the document. |
|
60 // There are other tests that make sure changes are propagated |
|
61 // to the client. |
|
62 is(attrNode.getAttribute("data-newattr"), "newvalue", "Node should have the first new attribute"); |
|
63 is(attrNode.getAttribute("data-newattr2"), "newvalue", "Node should have the second new attribute."); |
|
64 }).then(() => { |
|
65 // Change an attribute. |
|
66 let list = attrFront.startModifyingAttributes(); |
|
67 list.setAttribute("data-newattr", "changedvalue"); |
|
68 return list.apply(); |
|
69 }).then(() => { |
|
70 is(attrNode.getAttribute("data-newattr"), "changedvalue", "Node should have the changed first value."); |
|
71 is(attrNode.getAttribute("data-newattr2"), "newvalue", "Second value should remain unchanged."); |
|
72 }).then(() => { |
|
73 let list = attrFront.startModifyingAttributes(); |
|
74 list.removeAttribute("data-newattr2"); |
|
75 return list.apply(); |
|
76 }).then(() => { |
|
77 is(attrNode.getAttribute("data-newattr"), "changedvalue", "Node should have the changed first value."); |
|
78 ok(!attrNode.hasAttribute("data-newattr2"), "Second value should be removed."); |
|
79 }).then(runNextTest)); |
|
80 }); |
|
81 |
|
82 addTest(function cleanup() { |
|
83 delete gWalker; |
|
84 delete gInspectee; |
|
85 delete gClient; |
|
86 runNextTest(); |
|
87 }); |
|
88 |
|
89 |
|
90 </script> |
|
91 </head> |
|
92 <body> |
|
93 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a> |
|
94 <a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a> |
|
95 <p id="display"></p> |
|
96 <div id="content" style="display: none"> |
|
97 |
|
98 </div> |
|
99 <pre id="test"> |
|
100 </pre> |
|
101 </body> |
|
102 </html> |