toolkit/devtools/server/tests/unit/test_nesting-03.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:8f6ff2fa7239
1 /* -*- Mode: javascript; js-indent-level: 2; -*- */
2 /* Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/ */
4
5 // Test that we can detect nested event loops in tabs with the same URL.
6
7 var gClient1, gClient2, gThreadClient1, gThreadClient2;
8
9 function run_test() {
10 initTestDebuggerServer();
11 addTestGlobal("test-nesting1");
12 addTestGlobal("test-nesting1");
13 // Conect the first client to the first debuggee.
14 gClient1 = new DebuggerClient(DebuggerServer.connectPipe());
15 gClient1.connect(function () {
16 attachTestThread(gClient1, "test-nesting1", function (aResponse, aTabClient, aThreadClient) {
17 gThreadClient1 = aThreadClient;
18 start_second_connection();
19 });
20 });
21 do_test_pending();
22 }
23
24 function start_second_connection() {
25 gClient2 = new DebuggerClient(DebuggerServer.connectPipe());
26 gClient2.connect(function () {
27 attachTestThread(gClient2, "test-nesting1", function (aResponse, aTabClient, aThreadClient) {
28 gThreadClient2 = aThreadClient;
29 test_nesting();
30 });
31 });
32 }
33
34 function test_nesting() {
35 const { resolve, reject, promise: p } = promise.defer();
36
37 gThreadClient1.resume(aResponse => {
38 do_check_eq(aResponse.error, "wrongOrder");
39 gThreadClient2.resume(aResponse => {
40 do_check_true(!aResponse.error);
41 do_check_eq(aResponse.from, gThreadClient2.actor);
42
43 gThreadClient1.resume(aResponse => {
44 do_check_true(!aResponse.error);
45 do_check_eq(aResponse.from, gThreadClient1.actor);
46
47 gClient1.close(() => finishClient(gClient2));
48 });
49 });
50 });
51 }

mercurial