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.

     1 /* -*- Mode: javascript; js-indent-level: 2; -*- */
     2 /* Any copyright is dedicated to the Public Domain.
     3    http://creativecommons.org/publicdomain/zero/1.0/ */
     5 // Test that we can detect nested event loops in tabs with the same URL.
     7 var gClient1, gClient2, gThreadClient1, gThreadClient2;
     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 }
    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 }
    34 function test_nesting() {
    35   const { resolve, reject, promise: p } = promise.defer();
    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);
    43       gThreadClient1.resume(aResponse => {
    44         do_check_true(!aResponse.error);
    45         do_check_eq(aResponse.from, gThreadClient1.actor);
    47         gClient1.close(() => finishClient(gClient2));
    48       });
    49     });
    50   });
    51 }

mercurial