diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/shared/tests/unit/test_invisible_loader.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/shared/tests/unit/test_invisible_loader.js')
-rw-r--r-- | devtools/shared/tests/unit/test_invisible_loader.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/devtools/shared/tests/unit/test_invisible_loader.js b/devtools/shared/tests/unit/test_invisible_loader.js new file mode 100644 index 000000000..96a68abc4 --- /dev/null +++ b/devtools/shared/tests/unit/test_invisible_loader.js @@ -0,0 +1,60 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const { addDebuggerToGlobal } = Cu.import("resource://gre/modules/jsdebugger.jsm", {}); +addDebuggerToGlobal(this); + +/** + * Ensure that sandboxes created via the Dev Tools loader respect the + * invisibleToDebugger flag. + */ +function run_test() { + visible_loader(); + invisible_loader(); +} + +function visible_loader() { + let loader = new DevToolsLoader(); + loader.invisibleToDebugger = false; + loader.require("devtools/shared/indentation"); + + let dbg = new Debugger(); + let sandbox = loader._provider.loader.sharedGlobalSandbox; + + try { + dbg.addDebuggee(sandbox); + do_check_true(true); + } catch (e) { + do_throw("debugger could not add visible value"); + } + + // Check that for common loader used for tabs, promise modules is Promise.jsm + // Which is required to support unhandled promises rejection in mochitests + const promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise; + do_check_eq(loader.require("promise"), promise); +} + +function invisible_loader() { + let loader = new DevToolsLoader(); + loader.invisibleToDebugger = true; + loader.require("devtools/shared/indentation"); + + let dbg = new Debugger(); + let sandbox = loader._provider.loader.sharedGlobalSandbox; + + try { + dbg.addDebuggee(sandbox); + do_throw("debugger added invisible value"); + } catch (e) { + do_check_true(true); + } + + // But for browser toolbox loader, promise is loaded as a regular modules out + // of Promise-backend.js, that to be invisible to the debugger and not step + // into it. + const promise = loader.require("promise"); + const promiseModule = loader._provider.loader.modules["resource://gre/modules/Promise-backend.js"]; + do_check_eq(promise, promiseModule.exports); +} |