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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/devtools/server/tests/unit/test_nesting-03.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,51 @@
     1.4 +/* -*- Mode: javascript; js-indent-level: 2; -*- */
     1.5 +/* Any copyright is dedicated to the Public Domain.
     1.6 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.7 +
     1.8 +// Test that we can detect nested event loops in tabs with the same URL.
     1.9 +
    1.10 +var gClient1, gClient2, gThreadClient1, gThreadClient2;
    1.11 +
    1.12 +function run_test() {
    1.13 +  initTestDebuggerServer();
    1.14 +  addTestGlobal("test-nesting1");
    1.15 +  addTestGlobal("test-nesting1");
    1.16 +  // Conect the first client to the first debuggee.
    1.17 +  gClient1 = new DebuggerClient(DebuggerServer.connectPipe());
    1.18 +  gClient1.connect(function () {
    1.19 +    attachTestThread(gClient1, "test-nesting1", function (aResponse, aTabClient, aThreadClient) {
    1.20 +      gThreadClient1 = aThreadClient;
    1.21 +      start_second_connection();
    1.22 +    });
    1.23 +  });
    1.24 +  do_test_pending();
    1.25 +}
    1.26 +
    1.27 +function start_second_connection() {
    1.28 +  gClient2 = new DebuggerClient(DebuggerServer.connectPipe());
    1.29 +  gClient2.connect(function () {
    1.30 +    attachTestThread(gClient2, "test-nesting1", function (aResponse, aTabClient, aThreadClient) {
    1.31 +      gThreadClient2 = aThreadClient;
    1.32 +      test_nesting();
    1.33 +    });
    1.34 +  });
    1.35 +}
    1.36 +
    1.37 +function test_nesting() {
    1.38 +  const { resolve, reject, promise: p } = promise.defer();
    1.39 +
    1.40 +  gThreadClient1.resume(aResponse => {
    1.41 +    do_check_eq(aResponse.error, "wrongOrder");
    1.42 +    gThreadClient2.resume(aResponse => {
    1.43 +      do_check_true(!aResponse.error);
    1.44 +      do_check_eq(aResponse.from, gThreadClient2.actor);
    1.45 +
    1.46 +      gThreadClient1.resume(aResponse => {
    1.47 +        do_check_true(!aResponse.error);
    1.48 +        do_check_eq(aResponse.from, gThreadClient1.actor);
    1.49 +
    1.50 +        gClient1.close(() => finishClient(gClient2));
    1.51 +      });
    1.52 +    });
    1.53 +  });
    1.54 +}

mercurial