1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/unit/test_frameactor-05.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,89 @@ 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 that frame actors retrieved with the frames request 1.9 + * are included in the pause packet's popped-frames property. 1.10 + */ 1.11 + 1.12 +var gDebuggee; 1.13 +var gClient; 1.14 +var gThreadClient; 1.15 + 1.16 +function run_test() 1.17 +{ 1.18 + initTestDebuggerServer(); 1.19 + gDebuggee = addTestGlobal("test-stack"); 1.20 + gClient = new DebuggerClient(DebuggerServer.connectPipe()); 1.21 + gClient.connect(function() { 1.22 + attachTestTabAndResume(gClient, "test-stack", function(aResponse, aTabClient, aThreadClient) { 1.23 + gThreadClient = aThreadClient; 1.24 + test_pause_frame(); 1.25 + }); 1.26 + }); 1.27 + do_test_pending(); 1.28 +} 1.29 + 1.30 +function test_frame_slice() { 1.31 + if (gSliceTests.length == 0) { 1.32 + gThreadClient.resume(function() { finishClient(gClient); }); 1.33 + return; 1.34 + } 1.35 + 1.36 + let test = gSliceTests.shift(); 1.37 + gThreadClient.getFrames(test.start, test.count, function(aResponse) { 1.38 + var testFrames = gFrames.slice(test.start, test.count ? test.start + test.count : undefined); 1.39 + do_check_eq(testFrames.length, aResponse.frames.length); 1.40 + for (var i = 0; i < testFrames.length; i++) { 1.41 + let expected = testFrames[i]; 1.42 + let actual = aResponse.frames[i]; 1.43 + 1.44 + if (test.resetActors) { 1.45 + expected.actor = actual.actor; 1.46 + } 1.47 + 1.48 + for (var key in expected) { 1.49 + do_check_eq(expected[key], actual[key]); 1.50 + } 1.51 + } 1.52 + test_frame_slice(); 1.53 + }); 1.54 +} 1.55 + 1.56 +function test_pause_frame() 1.57 +{ 1.58 + gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket1) { 1.59 + gThreadClient.getFrames(0, null, function(aFrameResponse) { 1.60 + do_check_eq(aFrameResponse.frames.length, 5); 1.61 + // Now wait for the next pause, after which the three 1.62 + // youngest actors should be popped.. 1.63 + let expectPopped = [frame.actor for each (frame in aFrameResponse.frames.slice(0, 3))]; 1.64 + expectPopped.sort() 1.65 + 1.66 + gThreadClient.addOneTimeListener("paused", function(aEvent, aPausePacket) { 1.67 + let popped = aPausePacket.poppedFrames.sort(); 1.68 + do_check_eq(popped.length, 3); 1.69 + for (let i = 0; i < 3; i++) { 1.70 + do_check_eq(expectPopped[i], popped[i]); 1.71 + } 1.72 + 1.73 + gThreadClient.resume(function() { finishClient(gClient); }); 1.74 + }); 1.75 + gThreadClient.resume(); 1.76 + }); 1.77 + }); 1.78 + 1.79 + gDebuggee.eval("(" + function() { 1.80 + function depth3() { 1.81 + debugger; 1.82 + } 1.83 + function depth2() { 1.84 + depth3(); 1.85 + } 1.86 + function depth1() { 1.87 + depth2(); 1.88 + }; 1.89 + depth1(); 1.90 + debugger; 1.91 + } + ")()"); 1.92 +}