browser_toolbox_console_new_process.js (2034B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 // Test that when the multiprocess browser toolbox is used, console messages 6 // from newly opened content processes appear. 7 8 "use strict"; 9 10 requestLongerTimeout(4); 11 12 const TEST_URI = `data:text/html,<!DOCTYPE html><meta charset=utf8>console API calls<script> 13 console.log("Data Message"); 14 </script>`; 15 16 const EXAMPLE_URI = 17 "http://example.com/browser/devtools/client/webconsole/" + 18 "test/browser/test-console.html"; 19 20 /* global gToolbox */ 21 Services.scriptloader.loadSubScript( 22 "chrome://mochitests/content/browser/devtools/client/framework/browser-toolbox/test/helpers-browser-toolbox.js", 23 this 24 ); 25 26 add_task(async function () { 27 // Needed for the invokeInTab() function below 28 await pushPref("security.allow_parent_unrestricted_js_loads", true); 29 30 await addTab(TEST_URI); 31 const ToolboxTask = await initBrowserToolboxTask(); 32 await ToolboxTask.importFunctions({ 33 findMessagesVirtualized, 34 findMessageVirtualizedByType, 35 waitUntil, 36 }); 37 38 // Make sure the data: URL message appears in the OBT. 39 await ToolboxTask.spawn(null, async () => { 40 await gToolbox.selectTool("webconsole"); 41 const hud = gToolbox.getCurrentPanel().hud; 42 await waitUntil(() => 43 findMessageVirtualizedByType({ 44 hud, 45 text: "Data Message", 46 typeSelector: ".console-api", 47 }) 48 ); 49 }); 50 ok(true, "First message appeared in toolbox"); 51 52 await addTab(EXAMPLE_URI); 53 invokeInTab("stringLog"); 54 55 // Make sure the example.com message appears in the OBT. 56 await ToolboxTask.spawn(null, async () => { 57 const hud = gToolbox.getCurrentPanel().hud; 58 await waitUntil(() => 59 findMessageVirtualizedByType({ 60 hud, 61 text: "stringLog", 62 typeSelector: ".console-api", 63 }) 64 ); 65 }); 66 ok(true, "New message appeared in toolbox"); 67 68 await ToolboxTask.destroy(); 69 });