browser_webconsole_cached_messages_no_duplicate.js (1083B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // Test to see if we don't get duplicated messages (cached and "live"). 5 // See Bug 1578138 for more information. 6 7 "use strict"; 8 9 // Log 1 message every 50ms, until we reach 50 messages. 10 const TEST_URI = `data:text/html,<!DOCTYPE html><meta charset=utf8><script> 11 var i = 0; 12 var intervalId = setInterval(() => { 13 if (i >= 50) { 14 clearInterval(intervalId); 15 intervalId = null; 16 return; 17 } 18 console.log("startup message " + (++i)); 19 }, 50); 20 </script>`; 21 22 add_task(async function () { 23 info("Add a tab and open the console"); 24 const tab = await addTab(TEST_URI, { waitForLoad: false }); 25 const hud = await openConsole(tab); 26 27 info("wait until all the messages are displayed"); 28 await waitFor( 29 () => 30 findConsoleAPIMessage(hud, "message 1") && 31 findConsoleAPIMessage(hud, "message 50") 32 ); 33 34 is( 35 (await findAllMessagesVirtualized(hud)).length, 36 50, 37 "We have the expected number of messages" 38 ); 39 });