test_blackboxing-05.js (2584B)
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 exceptions inside black boxed sources. 8 */ 9 10 add_task( 11 threadFrontTest(async ({ threadFront, debuggee, commands }) => { 12 await executeOnNextTickAndWaitForPause( 13 () => evalCode(debuggee), 14 threadFront 15 ); 16 17 const { error } = await threadFront.getSources(); 18 Assert.ok(!error, "Should not get an error: " + error); 19 20 const sourceFront = await getSource(threadFront, BLACK_BOXED_URL); 21 await blackBox(sourceFront); 22 await commands.threadConfigurationCommand.updateConfiguration({ 23 pauseOnExceptions: true, 24 ignoreCaughtExceptions: false, 25 }); 26 27 const packet = await resumeAndWaitForPause(threadFront); 28 const source = await getSourceById(threadFront, packet.frame.where.actor); 29 30 Assert.equal( 31 source.url, 32 SOURCE_URL, 33 "We shouldn't pause while in the black boxed source." 34 ); 35 36 await unBlackBox(sourceFront); 37 await blackBox(sourceFront, { 38 start: { line: 1, column: 0 }, 39 end: { line: 4, column: 0 }, 40 }); 41 42 await threadFront.resume(); 43 44 await executeOnNextTickAndWaitForPause( 45 () => evalCode(debuggee), 46 threadFront 47 ); 48 49 const packet2 = await resumeAndWaitForPause(threadFront); 50 const source2 = await getSourceById(threadFront, packet2.frame.where.actor); 51 52 Assert.equal( 53 source2.url, 54 SOURCE_URL, 55 "We shouldn't pause while in the black boxed source." 56 ); 57 58 await threadFront.resume(); 59 }) 60 ); 61 62 const BLACK_BOXED_URL = "http://example.com/blackboxme.js"; 63 const SOURCE_URL = "http://example.com/source.js"; 64 65 function evalCode(debuggee) { 66 /* eslint-disable no-multi-spaces, no-unreachable, no-undef */ 67 // prettier-ignore 68 Cu.evalInSandbox( 69 "" + 70 function doStuff(k) { // line 1 71 throw new Error("error msg"); // line 2 72 k(100); // line 3 73 }, // line 4 74 debuggee, 75 "1.8", 76 BLACK_BOXED_URL, 77 1 78 ); 79 // prettier-ignore 80 Cu.evalInSandbox( 81 "" + 82 function runTest() { // line 1 83 doStuff( // line 2 84 function() { // line 3 85 debugger; // line 4 86 } // line 5 87 ); // line 6 88 } + // line 7 89 "\ndebugger;\n" + // line 8 90 "try { runTest() } catch (ex) { }", // line 9 91 debuggee, 92 "1.8", 93 SOURCE_URL, 94 1 95 ); 96 /* eslint-enable no-multi-spaces, no-unreachable, no-undef */ 97 }