|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Check basic getSources functionality. |
|
6 */ |
|
7 |
|
8 var gDebuggee; |
|
9 var gClient; |
|
10 var gThreadClient; |
|
11 |
|
12 var gNumTimesSourcesSent = 0; |
|
13 |
|
14 function run_test() |
|
15 { |
|
16 initTestDebuggerServer(); |
|
17 gDebuggee = addTestGlobal("test-stack"); |
|
18 gClient = new DebuggerClient(DebuggerServer.connectPipe()); |
|
19 gClient.request = (function (request) { |
|
20 return function (aRequest, aOnResponse) { |
|
21 if (aRequest.type === "sources") { |
|
22 ++gNumTimesSourcesSent; |
|
23 } |
|
24 return request.call(this, aRequest, aOnResponse); |
|
25 }; |
|
26 }(gClient.request)); |
|
27 gClient.connect(function () { |
|
28 attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { |
|
29 gThreadClient = aThreadClient; |
|
30 test_simple_listsources(); |
|
31 }); |
|
32 }); |
|
33 do_test_pending(); |
|
34 } |
|
35 |
|
36 function test_simple_listsources() |
|
37 { |
|
38 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { |
|
39 gThreadClient.getSources(function (aResponse) { |
|
40 do_check_true(aResponse.sources.some(function (s) { |
|
41 return s.url.match(/test_listsources-01.js$/); |
|
42 })); |
|
43 |
|
44 do_check_true(gNumTimesSourcesSent <= 1, |
|
45 "Should only send one sources request at most, even though we" |
|
46 + " might have had to send one to determine feature support."); |
|
47 |
|
48 gThreadClient.resume(function () { |
|
49 finishClient(gClient); |
|
50 }); |
|
51 }); |
|
52 }); |
|
53 |
|
54 gDebuggee.eval("var line0 = Error().lineNumber;\n" + |
|
55 "debugger;\n" + // line0 + 1 |
|
56 "var a = 1;\n" + // line0 + 2 |
|
57 "var b = 2;\n"); // line0 + 3 |
|
58 } |