-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1603802 [wpt PR 20771] - Add/update tests for cross-realm Error s…
…erialization, a=testonly Automatic update from web-platform-tests Add/update tests for cross-realm Error serialization Follows whatwg/html#5150. -- wpt-commits: 9882946dd9fcf7251387c2bfc778331b7ae85846 wpt-pr: 20771
- Loading branch information
1 parent
37adf8e
commit c972c20
Showing
3 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...html/infrastructure/safe-passing-of-structured-data/resources/post-parent-type-error.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Helper that posts its parent a TypeError</title> | ||
|
||
<script> | ||
window.doIt = () => { | ||
parent.postMessage(new TypeError("!!"), "*"); | ||
}; | ||
</script> |
46 changes: 46 additions & 0 deletions
46
...s/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-extra.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Structured cloning of Error objects: extra tests</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<!-- Most tests are in the general framework in structuredclone_0.html. | ||
This contains specialty tests that don't fit into that framework. --> | ||
|
||
<body> | ||
|
||
<script> | ||
"use strict"; | ||
test(t => { | ||
const exceptionToThrow = new Error("throw me!"); | ||
|
||
const badError = new Error(); | ||
Object.defineProperty(badError, "name", { get() { throw exceptionToThrow; } }); | ||
|
||
const worker = new Worker("./resources/echo-worker.js"); | ||
t.add_cleanup(() => worker.terminate()); | ||
|
||
assert_throws_exactly(exceptionToThrow, () => { | ||
worker.postMessage(badError); | ||
}); | ||
}, "Throwing name getter fails serialization"); | ||
|
||
// https://bugs.chromium.org/p/chromium/issues/detail?id=1030086 | ||
// https://github.com/whatwg/html/pull/5150 | ||
async_test(t => { | ||
window.onmessage = t.step_func_done(e => { | ||
assert_equals(e.data.name, "TypeError"); | ||
}); | ||
|
||
const iframe = document.createElement("iframe"); | ||
iframe.onload = () => { | ||
if (iframe.contentWindow.location === "about:blank") { | ||
return; | ||
} | ||
|
||
iframe.contentWindow.doIt(); | ||
}; | ||
iframe.src = "resources/post-parent-type-error.html"; | ||
document.body.append(iframe); | ||
}, "Errors sent across realms should preserve their type"); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters