test_listsources-01.js (1359B)
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 basic getSources functionality. 8 */ 9 10 var gNumTimesSourcesSent = 0; 11 12 add_task( 13 threadFrontTest(async ({ threadFront, debuggee, client }) => { 14 client.request = (function (origRequest) { 15 return function (request, onResponse) { 16 if (request.type === "sources") { 17 ++gNumTimesSourcesSent; 18 } 19 return origRequest.call(this, request, onResponse); 20 }; 21 })(client.request); 22 23 await executeOnNextTickAndWaitForPause( 24 () => evalCode(debuggee), 25 threadFront 26 ); 27 28 const response = await threadFront.getSources(); 29 30 Assert.ok( 31 response.sources.some(function (s) { 32 return s.url && s.url.match(/test_listsources-01.js/); 33 }) 34 ); 35 36 Assert.lessOrEqual( 37 gNumTimesSourcesSent, 38 1, 39 "Should only send one sources request at most, even though we" + 40 " might have had to send one to determine feature support." 41 ); 42 43 await threadFront.resume(); 44 }) 45 ); 46 47 function evalCode(debuggee) { 48 /* eslint-disable */ 49 Cu.evalInSandbox( 50 "var line0 = Error().lineNumber;\n" + 51 "debugger;\n" + // line0 + 1 52 "var a = 1;\n" + // line0 + 2 53 "var b = 2;\n", // line0 + 3 54 debuggee 55 ); 56 /* eslint-enable */ 57 }