summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/xpcshell/test_nativewrappers.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/server/tests/xpcshell/test_nativewrappers.js
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/server/tests/xpcshell/test_nativewrappers.js')
-rw-r--r--devtools/server/tests/xpcshell/test_nativewrappers.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/devtools/server/tests/xpcshell/test_nativewrappers.js b/devtools/server/tests/xpcshell/test_nativewrappers.js
new file mode 100644
index 0000000000..170a2a1e6e
--- /dev/null
+++ b/devtools/server/tests/xpcshell/test_nativewrappers.js
@@ -0,0 +1,39 @@
+/* eslint-disable strict */
+function run_test() {
+ Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
+ registerCleanupFunction(() => {
+ Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
+ });
+ const { addDebuggerToGlobal } = ChromeUtils.importESModule(
+ "resource://gre/modules/jsdebugger.sys.mjs"
+ );
+ addDebuggerToGlobal(globalThis);
+ const g = createTestGlobal("test1");
+
+ const dbg = makeDebugger();
+ dbg.addDebuggee(g);
+ dbg.onDebuggerStatement = function (frame) {
+ const args = frame.arguments;
+ try {
+ args[0];
+ Assert.ok(true);
+ } catch (ex) {
+ Assert.ok(false);
+ }
+ };
+
+ g.eval("function stopMe(arg) {debugger;}");
+
+ const g2 = createTestGlobal("test2");
+ g2.g = g;
+ // Not using the "stringify a function" trick because that runs afoul of the
+ // Cu.importGlobalProperties lint and we don't need it here anyway.
+ g2.eval(`(function createBadEvent() {
+ Cu.importGlobalProperties(["DOMParser"]);
+ let parser = new DOMParser();
+ let doc = parser.parseFromString("<foo></foo>", "text/xml");
+ g.stopMe(doc.createEvent("MouseEvent"));
+ } )()`);
+
+ dbg.disable();
+}