browser_webconsole_output_order.js (1584B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // Tests that any output created from calls to the console API comes before the 5 // echoed JavaScript. 6 7 "use strict"; 8 9 const TEST_URI = 10 "http://example.com/browser/devtools/client/webconsole/" + 11 "test/browser/test-console.html"; 12 13 add_task(async function () { 14 const hud = await openNewTabAndConsole(TEST_URI); 15 16 const evaluationResultMessage = await executeAndWaitForResultMessage( 17 hud, 18 `for (let i = 0; i < 5; i++) { console.log("item-" + i); }`, 19 "undefined" 20 ); 21 22 info("Wait for all the log messages to be displayed"); 23 // Console messages are batched by the Resource watcher API and might be rendered after 24 // the result message. 25 const logMessages = await waitFor(() => { 26 const messages = findConsoleAPIMessages(hud, "item-", ".log"); 27 return messages.length === 5 ? messages : null; 28 }); 29 30 const commandMessage = findMessageByType(hud, "", ".command"); 31 is( 32 commandMessage.nextElementSibling, 33 logMessages[0], 34 `the command message is followed by the first log message ( Got "${commandMessage.nextElementSibling.textContent}")` 35 ); 36 37 for (let i = 0; i < logMessages.length; i++) { 38 ok( 39 logMessages[i].textContent.includes(`item-${i}`), 40 `The log message item-${i} is at the expected position ( Got "${logMessages[i].textContent}")` 41 ); 42 } 43 44 is( 45 logMessages[logMessages.length - 1].nextElementSibling, 46 evaluationResultMessage.node, 47 "The evaluation result is after the last log message" 48 ); 49 });