1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/unit/test_frameactor-04.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,91 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Verify the "frames" request on the thread. 1.9 + */ 1.10 + 1.11 +var gDebuggee; 1.12 +var gClient; 1.13 +var gThreadClient; 1.14 + 1.15 +function run_test() 1.16 +{ 1.17 + initTestDebuggerServer(); 1.18 + gDebuggee = addTestGlobal("test-stack"); 1.19 + gClient = new DebuggerClient(DebuggerServer.connectPipe()); 1.20 + gClient.connect(function() { 1.21 + attachTestTabAndResume(gClient, "test-stack", function(aResponse, aTabClient, aThreadClient) { 1.22 + gThreadClient = aThreadClient; 1.23 + test_pause_frame(); 1.24 + }); 1.25 + }); 1.26 + do_test_pending(); 1.27 +} 1.28 + 1.29 +var gFrames = [ 1.30 + // Function calls... 1.31 + { type: "call", callee: { name: "depth3" } }, 1.32 + { type: "call", callee: { name: "depth2" } }, 1.33 + { type: "call", callee: { name: "depth1" } }, 1.34 + 1.35 + // Anonymous function call in our eval... 1.36 + { type: "call", callee: { name: undefined } }, 1.37 + 1.38 + // The eval itself. 1.39 + { type: "eval", callee: { name: undefined } }, 1.40 +]; 1.41 + 1.42 +var gSliceTests = [ 1.43 + { start: 0, count: undefined, resetActors: true }, 1.44 + { start: 0, count: 1 }, 1.45 + { start: 2, count: 2 }, 1.46 + { start: 1, count: 15 }, 1.47 + { start: 15, count: undefined }, 1.48 +]; 1.49 + 1.50 +function test_frame_slice() { 1.51 + if (gSliceTests.length == 0) { 1.52 + gThreadClient.resume(function() { finishClient(gClient); }); 1.53 + return; 1.54 + } 1.55 + 1.56 + let test = gSliceTests.shift(); 1.57 + gThreadClient.getFrames(test.start, test.count, function(aResponse) { 1.58 + var testFrames = gFrames.slice(test.start, test.count ? test.start + test.count : undefined); 1.59 + do_check_eq(testFrames.length, aResponse.frames.length); 1.60 + for (var i = 0; i < testFrames.length; i++) { 1.61 + let expected = testFrames[i]; 1.62 + let actual = aResponse.frames[i]; 1.63 + 1.64 + if (test.resetActors) { 1.65 + expected.actor = actual.actor; 1.66 + } 1.67 + 1.68 + for each (let key in ["type", "callee-name"]) { 1.69 + do_check_eq(expected[key], actual[key]); 1.70 + } 1.71 + } 1.72 + test_frame_slice(); 1.73 + }); 1.74 +} 1.75 + 1.76 +function test_pause_frame() 1.77 +{ 1.78 + gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket1) { 1.79 + test_frame_slice(); 1.80 + }); 1.81 + 1.82 + gDebuggee.eval("(" + function() { 1.83 + function depth3() { 1.84 + debugger; 1.85 + } 1.86 + function depth2() { 1.87 + depth3(); 1.88 + } 1.89 + function depth1() { 1.90 + depth2(); 1.91 + }; 1.92 + depth1(); 1.93 + } + ")()"); 1.94 +}