1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/unit/test_blackboxing-04.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,79 @@ 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 + * Test behavior of blackboxing sources we are currently paused in. 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-black-box"); 1.19 + gClient = new DebuggerClient(DebuggerServer.connectPipe()); 1.20 + gClient.connect(function() { 1.21 + attachTestTabAndResume(gClient, "test-black-box", function(aResponse, aTabClient, aThreadClient) { 1.22 + gThreadClient = aThreadClient; 1.23 + test_black_box(); 1.24 + }); 1.25 + }); 1.26 + do_test_pending(); 1.27 +} 1.28 + 1.29 +const BLACK_BOXED_URL = "http://example.com/blackboxme.js"; 1.30 +const SOURCE_URL = "http://example.com/source.js"; 1.31 + 1.32 +function test_black_box() 1.33 +{ 1.34 + gClient.addOneTimeListener("paused", function () { 1.35 + gThreadClient.setBreakpoint({ 1.36 + url: BLACK_BOXED_URL, 1.37 + line: 2 1.38 + }, function (aResponse) { 1.39 + do_check_true(!aResponse.error, "Should be able to set breakpoint."); 1.40 + test_black_box_paused(); 1.41 + }); 1.42 + }); 1.43 + 1.44 + Components.utils.evalInSandbox( 1.45 + "" + function doStuff(k) { // line 1 1.46 + debugger; // line 2 1.47 + k(100); // line 3 1.48 + }, // line 4 1.49 + gDebuggee, 1.50 + "1.8", 1.51 + BLACK_BOXED_URL, 1.52 + 1 1.53 + ); 1.54 + 1.55 + Components.utils.evalInSandbox( 1.56 + "" + function runTest() { // line 1 1.57 + doStuff( // line 2 1.58 + function (n) { // line 3 1.59 + return n; // line 4 1.60 + } // line 5 1.61 + ); // line 6 1.62 + } // line 7 1.63 + + "\n runTest();", // line 8 1.64 + gDebuggee, 1.65 + "1.8", 1.66 + SOURCE_URL, 1.67 + 1 1.68 + ); 1.69 +} 1.70 + 1.71 +function test_black_box_paused() { 1.72 + gThreadClient.getSources(function ({error, sources}) { 1.73 + do_check_true(!error, "Should not get an error: " + error); 1.74 + let sourceClient = gThreadClient.source(sources.filter(s => s.url == BLACK_BOXED_URL)[0]); 1.75 + 1.76 + sourceClient.blackBox(function ({error, pausedInSource}) { 1.77 + do_check_true(!error, "Should not get an error: " + error); 1.78 + do_check_true(pausedInSource, "We should be notified that we are currently paused in this source"); 1.79 + finishClient(gClient); 1.80 + }); 1.81 + }); 1.82 +}