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 /testing/mochitest/tests/Harness_sanity/test_SpecialPowersSpawn.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/mochitest/tests/Harness_sanity/test_SpecialPowersSpawn.html')
-rw-r--r-- | testing/mochitest/tests/Harness_sanity/test_SpecialPowersSpawn.html | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSpawn.html b/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSpawn.html new file mode 100644 index 0000000000..fe93c1fe83 --- /dev/null +++ b/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSpawn.html @@ -0,0 +1,69 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test for SpecialPowers.spawn</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> + +<iframe id="iframe"></iframe> + +<span id="hello">World.</span> + +<script> +/* globals SpecialPowers, content */ + + add_task(async function() { + let frame = document.getElementById("iframe"); + frame.src = "https://example.com/tests/testing/mochitest/tests/Harness_sanity/file_spawn.html"; + + await new Promise(resolve => { + frame.addEventListener("load", resolve, {once: true}); + }); + + let result = await SpecialPowers.spawn(frame, ["#span"], selector => { + let elem = content.document.querySelector(selector); + return elem.textContent; + }); + + is(result, "Hello there.", "Got correct element text from frame"); + + /* eslint-disable no-shadow */ + result = await SpecialPowers.spawn(frame, ["#hello"], selector => { + return SpecialPowers.spawn(content.parent, [selector], selector => { + let elem = content.document.querySelector(selector); + return elem.textContent; + }); + }); + + is(result, "World.", "Got correct element text from frame's window.parent"); + + result = await SpecialPowers.spawn(frame.contentWindow, ["#span"], selector => { + let elem = content.document.querySelector(selector); + return elem.textContent; + }); + + is(result, "Hello there.", "Got correct element text from window proxy"); + + result = await SpecialPowers.spawn(SpecialPowers.getPrivilegedProps(frame, "browsingContext"), + ["#span"], selector => { + let elem = content.document.querySelector(selector); + return elem.textContent; + }); + + is(result, "Hello there.", "Got correct element text from browsing context"); + + let line = 58; // Keep this in sync with the line number where the callback function starts. + let callback = () => { + let e = new Error("Hello."); + return { filename: e.fileName, lineNumber: e.lineNumber }; + }; + + let loc = await SpecialPowers.spawn(frame, [], callback); + is(loc.filename, location.href, "Error should have correct script filename"); + is(loc.lineNumber, line + 2, "Error should have correct script line number"); + }); +</script> +</body> +</html> |