toolkit/devtools/server/tests/unit/test_frameactor-04.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 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Verify the "frames" request on the thread.
     6  */
     8 var gDebuggee;
     9 var gClient;
    10 var gThreadClient;
    12 function run_test()
    13 {
    14   initTestDebuggerServer();
    15   gDebuggee = addTestGlobal("test-stack");
    16   gClient = new DebuggerClient(DebuggerServer.connectPipe());
    17   gClient.connect(function() {
    18     attachTestTabAndResume(gClient, "test-stack", function(aResponse, aTabClient, aThreadClient) {
    19       gThreadClient = aThreadClient;
    20       test_pause_frame();
    21     });
    22   });
    23   do_test_pending();
    24 }
    26 var gFrames = [
    27   // Function calls...
    28   { type: "call", callee: { name: "depth3" } },
    29   { type: "call", callee: { name: "depth2" } },
    30   { type: "call", callee: { name: "depth1" } },
    32   // Anonymous function call in our eval...
    33   { type: "call", callee: { name: undefined } },
    35   // The eval itself.
    36   { type: "eval", callee: { name: undefined } },
    37 ];
    39 var gSliceTests = [
    40   { start: 0, count: undefined, resetActors: true },
    41   { start: 0, count: 1 },
    42   { start: 2, count: 2 },
    43   { start: 1, count: 15 },
    44   { start: 15, count: undefined },
    45 ];
    47 function test_frame_slice() {
    48   if (gSliceTests.length == 0) {
    49     gThreadClient.resume(function() { finishClient(gClient); });
    50     return;
    51   }
    53   let test = gSliceTests.shift();
    54   gThreadClient.getFrames(test.start, test.count, function(aResponse) {
    55     var testFrames = gFrames.slice(test.start, test.count ? test.start + test.count : undefined);
    56     do_check_eq(testFrames.length, aResponse.frames.length);
    57     for (var i = 0; i < testFrames.length; i++) {
    58       let expected = testFrames[i];
    59       let actual = aResponse.frames[i];
    61       if (test.resetActors) {
    62         expected.actor = actual.actor;
    63       }
    65       for each (let key in ["type", "callee-name"]) {
    66         do_check_eq(expected[key], actual[key]);
    67       }
    68     }
    69     test_frame_slice();
    70   });
    71 }
    73 function test_pause_frame()
    74 {
    75   gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket1) {
    76     test_frame_slice();
    77   });
    79   gDebuggee.eval("(" + function() {
    80     function depth3() {
    81       debugger;
    82     }
    83     function depth2() {
    84       depth3();
    85     }
    86     function depth1() {
    87       depth2();
    88     };
    89     depth1();
    90   } + ")()");
    91 }

mercurial