test_blackboxing-03.js (3079B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Test that we don't stop at debugger statements inside black boxed sources. 8 */ 9 10 add_task( 11 threadFrontTest(async ({ threadFront, debuggee }) => { 12 // Set up 13 const packet = await executeOnNextTickAndWaitForPause( 14 () => evalCode(debuggee), 15 threadFront 16 ); 17 18 const source = await getSourceById(threadFront, packet.frame.where.actor); 19 threadFront.setBreakpoint({ sourceUrl: source.url, line: 4 }, {}); 20 await threadFront.resume(); 21 22 // Test the debugger statement in the black boxed source 23 await threadFront.getSources(); 24 const sourceFront = await getSource(threadFront, BLACK_BOXED_URL); 25 26 await blackBox(sourceFront); 27 28 const packet2 = await executeOnNextTickAndWaitForPause( 29 debuggee.runTest, 30 threadFront 31 ); 32 33 Assert.equal( 34 packet2.why.type, 35 "breakpoint", 36 "We should pass over the debugger statement." 37 ); 38 39 threadFront.removeBreakpoint({ sourceUrl: source.url, line: 4 }, {}); 40 41 await threadFront.resume(); 42 43 // Test the debugger statement in the unblack boxed source 44 await unBlackBox(sourceFront); 45 46 const packet3 = await executeOnNextTickAndWaitForPause( 47 debuggee.runTest, 48 threadFront 49 ); 50 51 Assert.equal( 52 packet3.why.type, 53 "debuggerStatement", 54 "We should stop at the debugger statement again" 55 ); 56 await threadFront.resume(); 57 58 // Test the debugger statement in the black boxed range 59 threadFront.setBreakpoint({ sourceUrl: source.url, line: 4 }, {}); 60 61 await blackBox(sourceFront, { 62 start: { line: 1, column: 0 }, 63 end: { line: 9, column: 0 }, 64 }); 65 66 const packet4 = await executeOnNextTickAndWaitForPause( 67 debuggee.runTest, 68 threadFront 69 ); 70 71 Assert.equal( 72 packet4.why.type, 73 "breakpoint", 74 "We should pass over the debugger statement." 75 ); 76 77 threadFront.removeBreakpoint({ sourceUrl: source.url, line: 4 }, {}); 78 await unBlackBox(sourceFront); 79 await threadFront.resume(); 80 }) 81 ); 82 83 const BLACK_BOXED_URL = "http://example.com/blackboxme.js"; 84 const SOURCE_URL = "http://example.com/source.js"; 85 86 function evalCode(debuggee) { 87 /* eslint-disable no-multi-spaces, no-undef */ 88 // prettier-ignore 89 Cu.evalInSandbox( 90 "" + function doStuff(k) { // line 1 91 debugger; // line 2 - Break here 92 k(100); // line 3 93 }, // line 4 94 debuggee, 95 "1.8", 96 BLACK_BOXED_URL, 97 1 98 ); 99 // prettier-ignore 100 Cu.evalInSandbox( 101 "" + function runTest() { // line 1 102 doStuff( // line 2 103 function(n) { // line 3 104 Math.abs(n); // line 4 - Break here 105 } // line 5 106 ); // line 6 107 } // line 7 108 + "\n debugger;", // line 8 109 debuggee, 110 "1.8", 111 SOURCE_URL, 112 1 113 ); 114 /* eslint-enable no-multi-spaces, no-undef */ 115 }