test_listsources-02.js (957B)
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 getting sources before there are any. 8 */ 9 10 var gNumTimesSourcesSent = 0; 11 12 add_task( 13 threadFrontTest(async ({ threadFront, 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 // Test listing zero sources 24 const packet = await threadFront.getSources(); 25 26 Assert.ok(!packet.error); 27 Assert.ok(!!packet.sources); 28 Assert.equal(packet.sources.length, 0); 29 30 Assert.lessOrEqual( 31 gNumTimesSourcesSent, 32 1, 33 "Should only send one sources request at most, even though we" + 34 " might have had to send one to determine feature support." 35 ); 36 }) 37 );