Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / devtools / server / tests / chrome / test_inspector-reload.html
blob09bd31cf75048f18e6fda8f7a10b09738e10e528
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>
10 <script 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" src="inspector-helpers.js"></script>
13 <script type="application/javascript">
14 "use strict";
16 window.onload = function() {
17 SimpleTest.waitForExplicitFinish();
18 runNextTest();
21 let gInspectee = null;
22 let gWalker = null;
23 let gResourceCommand = null;
24 let gCommands = null;
26 addTest(async function setup() {
27 const url = document.getElementById("inspectorContent").href;
28 const { commands, doc } = await attachURL(url);
29 const target = commands.targetCommand.targetFront;
30 const inspector = await target.getFront("inspector");
31 gInspectee = doc;
32 const walker = inspector.walker;
33 gWalker = await inspector.getWalker();
34 gResourceCommand = commands.resourceCommand;
35 gCommands = commands;
37 ok(walker === gWalker, "getWalker() twice should return the same walker.");
38 runNextTest();
39 });
41 addTest(async function testReload() {
42 const oldRootID = gWalker.rootNode.actorID;
44 info("Start watching for root nodes and wait for the initial root node");
45 let rootNodeResolve;
46 let rootNodePromise = new Promise(r => (rootNodeResolve = r));
47 const onAvailable = rootNodeFront => rootNodeResolve(rootNodeFront);
48 await gResourceCommand.watchResources([gResourceCommand.TYPES.ROOT_NODE], {
49 onAvailable,
50 });
51 await rootNodePromise;
53 info("Retrieve the node front for the selector `#a`");
54 const nodeFront = await gWalker.querySelector(gWalker.rootNode, "#a");
55 ok(nodeFront.actorID, "Node front has a valid actor ID");
57 info("Reload the page and wait for the newRoot mutation");
58 rootNodePromise = new Promise(r => (rootNodeResolve = r));
60 gInspectee.defaultView.location.reload();
61 await rootNodePromise;
62 gWalker = (await gCommands.targetCommand.targetFront.getFront("inspector")).walker;
64 info("Retrieve the (new) node front for the selector `#a`");
65 const newNodeFront = await gWalker.querySelector(gWalker.rootNode, "#a");
66 ok(newNodeFront.actorID, "Got a new actor ID");
67 ok(gWalker.rootNode.actorID != oldRootID, "Root node should have changed.");
69 runNextTest();
70 });
72 addTest(function cleanup() {
73 gWalker = null;
74 gInspectee = null;
75 gResourceCommand = null;
76 runNextTest();
77 });
78 </script>
79 </head>
80 <body>
81 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
82 <a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
83 <p id="display"></p>
84 <div id="content" style="display: none">
86 </div>
87 <pre id="test">
88 </pre>
89 </body>
90 </html>