browser_console_eager_eval.js (1660B)
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 "use strict"; 6 7 // Check evaluating eager-evaluation values. 8 const TEST_URI = "data:text/html;charset=utf8,<!DOCTYPE html>"; 9 10 add_task(async function () { 11 await addTab(TEST_URI); 12 13 await pushPref("devtools.chrome.enabled", true); 14 15 info("Open the Browser Console"); 16 const hud = await BrowserConsoleManager.toggleBrowserConsole(); 17 18 await executeNonDebuggeeSideeffect(hud); 19 }); 20 21 // Test that code is still terminated, even if it is calling into realms 22 // that aren't the normal debuggee realms (bug 1620087). 23 async function executeNonDebuggeeSideeffect(hud) { 24 await executeAndWaitForResultMessage( 25 hud, 26 `globalThis.eagerLoader = ChromeUtils.importESModule("resource://devtools/shared/loader/Loader.sys.mjs");`, 27 `DevToolsLoader` 28 ); 29 30 // "require" should terminate execution because it will try to create a new 31 // module record for the given URL, as long as the loader's debuggee 32 // has been properly added to the debugger. The termination should 33 // happen before it starts processing the path, so we don't need to provide 34 // a real path here. 35 setInputValue(hud, `globalThis.eagerLoader.require("fake://path");`); 36 37 // Wait a bit to make sure that the command has time to fail before we 38 // validate the eager-eval result. 39 await wait(500); 40 await waitForEagerEvaluationResult(hud, ""); 41 42 setInputValue(hud, ""); 43 44 await executeAndWaitForResultMessage( 45 hud, 46 `delete globalThis.eagerLoader;`, 47 `true` 48 ); 49 }