|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Check getting sources before there are any. |
|
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_listing_zero_sources(); |
|
31 }); |
|
32 }); |
|
33 do_test_pending(); |
|
34 } |
|
35 |
|
36 function test_listing_zero_sources() |
|
37 { |
|
38 gThreadClient.getSources(function (aPacket) { |
|
39 do_check_true(!aPacket.error); |
|
40 do_check_true(!!aPacket.sources); |
|
41 do_check_eq(aPacket.sources.length, 0); |
|
42 |
|
43 do_check_true(gNumTimesSourcesSent <= 1, |
|
44 "Should only send one sources request at most, even though we" |
|
45 + " might have had to send one to determine feature support."); |
|
46 |
|
47 finishClient(gClient); |
|
48 }); |
|
49 } |