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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial