Backed out changeset 06f41c22f3a6 (bug 1888460) for causing linux xpcshell failures...
[gecko.git] / dom / workers / test / test_WorkerDebuggerManager.xhtml
blob1ed09563de3abc076b4c435ec25e2b673d277659
1 <?xml version="1.0"?>
2 <!--
3 Any copyright is dedicated to the Public Domain.
4 http://creativecommons.org/publicdomain/zero/1.0/
5 -->
6 <window title="Test for WorkerDebuggerManager"
7 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
10 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
11 <script type="application/javascript" src="dom_worker_helper.js"/>
13 <script type="application/javascript">
14 <![CDATA[
16 const WORKER_URL = "WorkerDebuggerManager_worker.js";
17 const CHILD_WORKER_URL = "WorkerDebuggerManager_childWorker.js";
19 add_task(
20 async function runTest() {
21 info("Check that worker debuggers are not enumerated before they are " +
22 "registered.");
23 ok(!findDebugger(WORKER_URL),
24 "Worker debugger should not be enumerated before it is registered.");
25 ok(!findDebugger(CHILD_WORKER_URL),
26 "Child worker debugger should not be enumerated before it is " +
27 "registered.");
29 info("Create a worker that creates a child worker, and wait for " +
30 "their debuggers to be registered.");
31 let promise = waitForMultiple([
32 waitForRegister(WORKER_URL),
33 waitForRegister(CHILD_WORKER_URL)
34 ]);
35 let worker = new Worker(WORKER_URL);
36 let [dbg, childDbg] = await promise;
38 info("Check that worker debuggers are enumerated after they are " +
39 "registered.");
40 ok(findDebugger(WORKER_URL),
41 "Worker debugger should be enumerated after it is registered.");
42 ok(findDebugger(CHILD_WORKER_URL),
43 "Child worker debugger should be enumerated after it is " +
44 "registered.");
46 info("Check that worker debuggers are not closed before they are " +
47 "unregistered.");
48 is(dbg.isClosed, false,
49 "Worker debugger should not be closed before it is unregistered.");
50 is(childDbg.isClosed, false,
51 "Child worker debugger should not be closed before it is " +
52 "unregistered");
54 info("Terminate the worker and the child worker, and wait for their " +
55 "debuggers to be unregistered.");
56 promise = waitForMultiple([
57 waitForUnregister(CHILD_WORKER_URL),
58 waitForUnregister(WORKER_URL),
59 ]);
60 worker.terminate();
61 await promise;
63 info("Check that worker debuggers are not enumerated after they are " +
64 "unregistered.");
65 ok(!findDebugger(WORKER_URL),
66 "Worker debugger should not be enumerated after it is " +
67 "unregistered.");
68 ok(!findDebugger(CHILD_WORKER_URL),
69 "Child worker debugger should not be enumerated after it is " +
70 "unregistered.");
72 info("Check that worker debuggers are closed after they are " +
73 "unregistered.");
74 is(dbg.isClosed, true,
75 "Worker debugger should be closed after it is unregistered.");
76 is(childDbg.isClosed, true,
77 "Child worker debugger should be closed after it is unregistered.");
79 info("Check that property accesses on worker debuggers throws " +
80 "after they are closed.");
81 assertThrows(() => dbg.url,
82 "Property accesses on worker debugger should throw " +
83 "after it is closed.");
84 assertThrows(() => childDbg.url,
85 "Property accesses on child worker debugger should " +
86 "throw after it is closed.");
90 ]]>
91 </script>
93 <body xmlns="http://www.w3.org/1999/xhtml">
94 <p id="display"></p>
95 <div id="content" style="display:none;"></div>
96 <pre id="test"></pre>
97 </body>
98 <label id="test-result"/>
99 </window>