1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/unit/test_listsources-02.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Check getting sources before there are any. 1.9 + */ 1.10 + 1.11 +var gDebuggee; 1.12 +var gClient; 1.13 +var gThreadClient; 1.14 + 1.15 +var gNumTimesSourcesSent = 0; 1.16 + 1.17 +function run_test() 1.18 +{ 1.19 + initTestDebuggerServer(); 1.20 + gDebuggee = addTestGlobal("test-stack"); 1.21 + gClient = new DebuggerClient(DebuggerServer.connectPipe()); 1.22 + gClient.request = (function (request) { 1.23 + return function (aRequest, aOnResponse) { 1.24 + if (aRequest.type === "sources") { 1.25 + ++gNumTimesSourcesSent; 1.26 + } 1.27 + return request.call(this, aRequest, aOnResponse); 1.28 + }; 1.29 + }(gClient.request)); 1.30 + gClient.connect(function () { 1.31 + attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { 1.32 + gThreadClient = aThreadClient; 1.33 + test_listing_zero_sources(); 1.34 + }); 1.35 + }); 1.36 + do_test_pending(); 1.37 +} 1.38 + 1.39 +function test_listing_zero_sources() 1.40 +{ 1.41 + gThreadClient.getSources(function (aPacket) { 1.42 + do_check_true(!aPacket.error); 1.43 + do_check_true(!!aPacket.sources); 1.44 + do_check_eq(aPacket.sources.length, 0); 1.45 + 1.46 + do_check_true(gNumTimesSourcesSent <= 1, 1.47 + "Should only send one sources request at most, even though we" 1.48 + + " might have had to send one to determine feature support."); 1.49 + 1.50 + finishClient(gClient); 1.51 + }); 1.52 +}