test_new_source-02.js (1111B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Check that sourceURL has the correct effect when using threadFront.eval. 8 */ 9 10 add_task( 11 threadFrontTest(async ({ commands, threadFront, debuggee }) => { 12 await executeOnNextTickAndWaitForPause( 13 () => evalCode(debuggee), 14 threadFront 15 ); 16 17 const packet1 = await waitForEvent(threadFront, "newSource"); 18 19 Assert.ok(!!packet1.source); 20 Assert.ok(packet1.source.introductionType, "eval"); 21 22 commands.scriptCommand.execute( 23 "function f() { }\n//# sourceURL=http://example.com/code.js" 24 ); 25 26 const packet2 = await waitForEvent(threadFront, "newSource"); 27 dump(JSON.stringify(packet2, null, 2)); 28 Assert.ok(!!packet2.source); 29 Assert.ok(!!packet2.source.url.match(/example\.com/)); 30 }) 31 ); 32 33 function evalCode(debuggee) { 34 /* eslint-disable */ 35 debuggee.eval( 36 "(" + 37 function () { 38 function stopMe(arg1) { 39 debugger; 40 } 41 stopMe({ obj: true }); 42 } + 43 ")()" 44 ); 45 /* eslint-enable */ 46 }