browser_console_dead_objects.js (1393B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // Check that Dead Objects do not break the Web/Browser Consoles. 5 // 6 // This test: 7 // - Opens the Browser Console. 8 // - Creates a sandbox. 9 // - Stores a reference to the sandbox on the chrome window object. 10 // - Nukes the sandbox 11 // - Tries to use the sandbox. This is the dead object. 12 13 "use strict"; 14 15 add_task(async function () { 16 // Needed for the execute() function below 17 await pushPref("security.allow_parent_unrestricted_js_loads", true); 18 19 const hud = await BrowserConsoleManager.toggleBrowserConsole(); 20 ok(hud, "browser console opened"); 21 22 // Add the reference to the nuked sandbox. 23 execute( 24 hud, 25 "window.nukedSandbox = Cu.Sandbox(null); Cu.nukeSandbox(nukedSandbox);" 26 ); 27 28 await executeAndWaitForResultMessage(hud, "nukedSandbox", "DeadObject"); 29 const msg = await executeAndWaitForErrorMessage( 30 hud, 31 "nukedSandbox.hello", 32 "can't access dead object" 33 ); 34 35 // Check that the link contains an anchor. We can't click on the link because 36 // clicking links from tests attempts to access an external URL and crashes Firefox. 37 const anchor = msg.node.querySelector("a"); 38 is(anchor.textContent, "[Learn More]", "Link text is correct"); 39 40 await executeAndWaitForResultMessage( 41 hud, 42 "delete window.nukedSandbox; 1 + 1", 43 "2" 44 ); 45 });