diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/xpconnect/tests/chrome/test_wrappers.xhtml | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/xpconnect/tests/chrome/test_wrappers.xhtml | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/js/xpconnect/tests/chrome/test_wrappers.xhtml b/js/xpconnect/tests/chrome/test_wrappers.xhtml new file mode 100644 index 0000000000..73c808a9df --- /dev/null +++ b/js/xpconnect/tests/chrome/test_wrappers.xhtml @@ -0,0 +1,85 @@ +<?xml version="1.0"?> +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" + type="text/css"?> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=500931 +--> +<window title="Mozilla Bug 500931" + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + + <!-- test results are displayed in the html:body --> + <body xmlns="http://www.w3.org/1999/xhtml"> + <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=533596" + target="_blank">Mozilla Bug 533596</a> + </body> + + <!-- test code goes here --> + <script type="application/javascript"><![CDATA[ + + /** Test for Bug 533596 **/ + + function go() { + var win = $('ifr').contentWindow; + var utils = window.windowUtils; + is(utils.getClassName(window), "Proxy", "our window is wrapped correctly") + is(utils.getClassName(location), "Location", "chrome doesn't have location wrappers") + is(utils.getClassName(win), "Proxy", "win is an Proxy"); + is(utils.getClassName(win.location), "Proxy", "deep wrapping works"); + is(win.location.href, "https://example.org/tests/js/xpconnect/tests/mochitest/chrome_wrappers_helper.html", + "can still get strings out"); + + var unsafeWin = win.wrappedJSObject; + is(utils.getClassName(unsafeWin), "Proxy", "can get a Proxy"); + is(utils.getClassName(unsafeWin.location), "Proxy", "deep wrapping works"); + + Object.defineProperty(unsafeWin, "defprop1", { value: 1, writable: true, enumerable: true, configurable: true }); + /* TODO (bug 552854): the getter isn't visible in content. + function checkWrapper(val) { + ok(utils.getClassName(val) == "Proxy", "wrapped properly"); + } + Object.defineProperty(unsafeWin, "defprop2", { set: checkWrapper, enumerable: true, configurable: true }); + */ + unsafeWin.run_test(ok, win, unsafeWin); + + win.setTimeout(function() { + is(utils.getClassName(this), "Proxy", + "this is wrapped correctly"); + SimpleTest.finish(); + }, 0) + + var saw0 = false; + for (let i in $('ifr').contentDocument.getElementsByTagName('body')) { + if (i === "0") + saw0 = true; + } + ok(saw0, "properly enumerated the 0 value"); + + ok(win.XPathEvaluator.toString().includes("XPathEvaluator"), + "Can access content window.XPathEvaluator"); + + var nativeToString = + ("" + Math.sin).replace("sin", "EventTarget"); + var eventTargetToString = "" + win.EventTarget; + ok(eventTargetToString.indexOf(nativeToString) > -1, + "Stringifying a DOM interface object should return the same string as " + + "stringifying a native function. " + eventTargetToString + " " + nativeToString); + + is(win.XPathResult.NUMBER_TYPE, 1, "can access constants on constructors"); + is(typeof win.IDBKeyRange.bound, "function", "can access crazy IDBKeyRange static functions"); + + // Test getter/setter lookup on Xray wrappers. + ok(Object.prototype.__lookupGetter__.call(win.document, 'title'), 'found getter on document'); + ok(Object.prototype.__lookupGetter__.call(win.document, 'title'), 'found getter on document'); + } + + SimpleTest.waitForExplicitFinish(); + + ]]></script> + <iframe type="content" + src="https://example.org/tests/js/xpconnect/tests/mochitest/chrome_wrappers_helper.html" + onload="go()" + id="ifr"> + </iframe> +</window> |