browser_console_webconsole_iframe_messages.js (1806B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // Check that cached messages from nested iframes are displayed in the 5 // Web/Browser Console. 6 7 "use strict"; 8 9 const TEST_URI = 10 "http://example.com/browser/devtools/client/webconsole/" + 11 "test/browser/test-console-iframes.html"; 12 13 const expectedMessages = [ 14 ["main file", ".console-api"], 15 ["blah", ".error"], 16 ["iframe 2", ".console-api"], 17 ["iframe 3", ".console-api"], 18 ]; 19 20 // This log comes from test-iframe1.html, which is included from test-console-iframes.html 21 // __and__ from test-iframe3.html as well, so we should see it twice. 22 const expectedDupedMessage = "iframe 1"; 23 24 add_task(async function () { 25 // On e10s, the exception is triggered in child process 26 // and is ignored by test harness 27 if (!Services.appinfo.browserTabsRemoteAutostart) { 28 expectUncaughtException(); 29 } 30 31 let hud = await openNewTabAndConsole(TEST_URI); 32 33 await testMessages(hud); 34 await closeConsole(); 35 info("web console closed"); 36 37 // Show the content messages 38 await pushPref("devtools.browsertoolbox.scope", "everything"); 39 hud = await BrowserConsoleManager.toggleBrowserConsole(); 40 ok(hud, "browser console opened"); 41 await testMessages(hud); 42 43 // clear the browser console. 44 await clearOutput(hud); 45 await waitForTick(); 46 await safeCloseBrowserConsole(); 47 }); 48 49 async function testMessages(hud) { 50 for (const [message, selector] of expectedMessages) { 51 info(`checking that the message "${message}" exists`); 52 await waitFor(() => findMessageByType(hud, message, selector)); 53 } 54 55 ok(true, "Found expected unique messages"); 56 57 await waitFor( 58 () => findConsoleAPIMessages(hud, expectedDupedMessage).length == 2 59 ); 60 ok(true, `${expectedDupedMessage} is present twice`); 61 }