test_pause_exceptions-04.js (2558B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const { waitForTick } = require("resource://devtools/shared/DevToolsUtils.js"); 7 8 /** 9 * Test that setting pauseOnExceptions to true and then to false will not cause 10 * the debuggee to pause when an exception is thrown. 11 */ 12 13 add_task( 14 threadFrontTest( 15 async ({ threadFront, debuggee, commands }) => { 16 let onResume = null; 17 let packet = null; 18 19 threadFront.once("paused", function (pkt) { 20 packet = pkt; 21 onResume = threadFront.resume(); 22 }); 23 24 await commands.threadConfigurationCommand.updateConfiguration({ 25 pauseOnExceptions: true, 26 ignoreCaughtExceptions: true, 27 }); 28 29 await evaluateTestCode(debuggee, "42"); 30 31 await onResume; 32 33 Assert.equal(!!packet, true); 34 Assert.equal(packet.why.type, "exception"); 35 Assert.equal(packet.why.exception, "42"); 36 packet = null; 37 38 threadFront.once("paused", function (pkt) { 39 packet = pkt; 40 onResume = threadFront.resume(); 41 }); 42 43 await commands.threadConfigurationCommand.updateConfiguration({ 44 pauseOnExceptions: false, 45 ignoreCaughtExceptions: true, 46 }); 47 48 await evaluateTestCode(debuggee, "43"); 49 50 // Test that the paused listener callback hasn't been called 51 // on the thrown error from dontStopMe() 52 Assert.equal(!!packet, false); 53 54 await commands.threadConfigurationCommand.updateConfiguration({ 55 pauseOnExceptions: true, 56 ignoreCaughtExceptions: true, 57 }); 58 59 await evaluateTestCode(debuggee, "44"); 60 61 await onResume; 62 63 // Test that the paused listener callback has been called 64 // on the thrown error from stopMeAgain() 65 Assert.equal(!!packet, true); 66 Assert.equal(packet.why.type, "exception"); 67 Assert.equal(packet.why.exception, "44"); 68 }, 69 { 70 // Bug 1508289, exception tests fails in worker scope 71 doNotRunWorker: true, 72 } 73 ) 74 ); 75 76 async function evaluateTestCode(debuggee, throwValue) { 77 await waitForTick(); 78 try { 79 // prettier-ignore 80 Cu.evalInSandbox( 81 ` // 1 82 function stopMeAgain() { // 2 83 throw ${throwValue}; // 3 84 } // 4 85 stopMeAgain(); // 5 86 `, // 6 87 debuggee, 88 "1.8", 89 "test_pause_exceptions-04.js", 90 1 91 ); 92 } catch (e) {} 93 }