commit 198fc64bac829ec18d3de6832ebc7fc59d21ed23
parent 5d54cd6d9cdc090c024771f28d3d2b273f50bf7e
Author: Rob Wu <rob@robwu.nl>
Date: Mon, 5 Jan 2026 16:08:59 +0000
Bug 2007587 - Fix findUnexpectedCrashDumpFiles to avoid breaking mochitest TestRunner r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D277475
Diffstat:
4 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/testing/mochitest/tests/Harness_sanity/mochitest.toml b/testing/mochitest/tests/Harness_sanity/mochitest.toml
@@ -24,6 +24,8 @@ support-files = "file_spawn.html"
["test_SpecialPowersSpawnChrome.html"]
+["test_SpecialPowersStructuredClone.html"]
+
["test_TestsRunningAfterSimpleTestFinish.html"]
skip-if = [
"true", # depends on fix for bug 1048446
diff --git a/testing/mochitest/tests/Harness_sanity/test_SpecialPowersStructuredClone.html b/testing/mochitest/tests/Harness_sanity/test_SpecialPowersStructuredClone.html
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for structured clone of SpecialPowers methods</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+
+<script>
+ add_task(async function test_findUnexpectedCrashDumpFiles() {
+ let retval = await SpecialPowers.findUnexpectedCrashDumpFiles();
+
+ ok(SpecialPowers.isWrapper(retval), "Returns wrapper");
+
+ let realValue = SpecialPowers.unwrap(retval);
+ ok(Array.isArray(realValue), "Unwrapped value is array");
+
+ is(
+ SpecialPowers.unwrap(SpecialPowers.Cu.getGlobalForObject(realValue)),
+ window,
+ "Value part of current global"
+ );
+
+ // Now the part of interest: Can we clone? Regression test for bug 2007587:
+ structuredClone(realValue);
+
+ let actualError;
+ try {
+ structuredClone(retval);
+ actualError = "(no error thrown)";
+ } catch (e) {
+ actualError = e.toString();
+ }
+ is(
+ actualError,
+ "DataCloneError: Proxy object could not be cloned.",
+ "Wrapped value cannot be structured cloned"
+ );
+ });
+</script>
+</body>
+</html>
diff --git a/testing/mochitest/tests/SimpleTest/TestRunner.js b/testing/mochitest/tests/SimpleTest/TestRunner.js
@@ -752,8 +752,9 @@ TestRunner.testFinished = function (tests) {
result = "ERROR";
}
- var unexpectedCrashDumpFiles =
- await SpecialPowers.findUnexpectedCrashDumpFiles();
+ var unexpectedCrashDumpFiles = SpecialPowers.unwrap(
+ await SpecialPowers.findUnexpectedCrashDumpFiles()
+ );
TestRunner._expectingProcessCrash = false;
if (unexpectedCrashDumpFiles.length) {
let subtest = "unexpected-crash-dump-found";
diff --git a/testing/specialpowers/content/SpecialPowersChild.sys.mjs b/testing/specialpowers/content/SpecialPowersChild.sys.mjs
@@ -738,6 +738,12 @@ export class SpecialPowersChild extends JSWindowActorChild {
crashDumpFiles.forEach(function (aFilename) {
self._unexpectedCrashDumpFiles[aFilename] = true;
});
+ // The value is an Array of strings. Export into the scope of the window to
+ // allow the caller to read its value without wrapper. Callers of
+ // findUnexpectedCrashDumpFiles will automatically get a wrapper; call
+ // SpecialPowers.unwrap() on its return value to access the raw value that
+ // we are returning here (see bug 2007587 for context).
+ crashDumpFiles = Cu.cloneInto(crashDumpFiles, this.contentWindow);
return crashDumpFiles;
}