From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- js/ductwork/debugger/tests/head_dbg.js | 13 ++++++++ js/ductwork/debugger/tests/test_nativewrappers.js | 38 +++++++++++++++++++++++ js/ductwork/debugger/tests/xpcshell.ini | 7 +++++ 3 files changed, 58 insertions(+) create mode 100644 js/ductwork/debugger/tests/head_dbg.js create mode 100644 js/ductwork/debugger/tests/test_nativewrappers.js create mode 100644 js/ductwork/debugger/tests/xpcshell.ini (limited to 'js/ductwork/debugger/tests') diff --git a/js/ductwork/debugger/tests/head_dbg.js b/js/ductwork/debugger/tests/head_dbg.js new file mode 100644 index 0000000000..aad37f5f12 --- /dev/null +++ b/js/ductwork/debugger/tests/head_dbg.js @@ -0,0 +1,13 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +function testGlobal(aName) { + let systemPrincipal = Cc["@mozilla.org/systemprincipal;1"] + .createInstance(Ci.nsIPrincipal); + + let sandbox = Cu.Sandbox(systemPrincipal); + Cu.evalInSandbox("this.__name = '" + aName + "'", sandbox); + return sandbox; +} diff --git a/js/ductwork/debugger/tests/test_nativewrappers.js b/js/ductwork/debugger/tests/test_nativewrappers.js new file mode 100644 index 0000000000..ccddb1e845 --- /dev/null +++ b/js/ductwork/debugger/tests/test_nativewrappers.js @@ -0,0 +1,38 @@ +function run_test() +{ + const {addDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm"); + const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); + + Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true); + registerCleanupFunction(() => { + Services.prefs.clearUserPref("security.allow_eval_with_system_principal"); + }); + + addDebuggerToGlobal(this); + var g = testGlobal("test1"); + + var dbg = new Debugger(); + dbg.addDebuggee(g); + dbg.onDebuggerStatement = function(aFrame) { + let args = aFrame["arguments"]; + try { + args[0]; + Assert.ok(true); + } catch(ex) { + Assert.ok(false); + } + }; + + g.eval("function stopMe(arg) {debugger;}"); + + g2 = testGlobal("test2"); + g2.g = g; + g2.eval("(" + function createBadEvent() { + Cu.importGlobalProperties(["DOMParser"]); + let parser = new DOMParser(); + let doc = parser.parseFromString("", "text/xml"); + g.stopMe(doc.createEvent("MouseEvent")); + } + ")()"); + + dbg.removeAllDebuggees(); +} diff --git a/js/ductwork/debugger/tests/xpcshell.ini b/js/ductwork/debugger/tests/xpcshell.ini new file mode 100644 index 0000000000..c2a1cd07af --- /dev/null +++ b/js/ductwork/debugger/tests/xpcshell.ini @@ -0,0 +1,7 @@ +[DEFAULT] +head = head_dbg.js +skip-if = toolkit == 'android' + +[test_nativewrappers.js] +# Bug 685068 +fail-if = os == "android" -- cgit v1.2.3