Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit cf0e518

Browse files
littledanjgraham
authored andcommitted
Bug 1439159 [wpt PR 9565] - html: Add tests to verify BigInt structured clone integration, a=testonly
Automatic update from web-platform-testsHTML: add tests to verify BigInt structured clone integration See whatwg/html#3480. wpt-commits: c92168a4fbb507dae4f8caa49ecf0dd6d6bf271e wpt-pr: 9565 wpt-commits: c92168a4fbb507dae4f8caa49ecf0dd6d6bf271e wpt-pr: 9565
1 parent f6e28fd commit cf0e518

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

testing/web-platform/meta/MANIFEST.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327898,6 +327898,12 @@
327898327898
{}
327899327899
]
327900327900
],
327901+
"html/infrastructure/safe-passing-of-structured-data/structured_clone_bigint.html": [
327902+
[
327903+
"/html/infrastructure/safe-passing-of-structured-data/structured_clone_bigint.html",
327904+
{}
327905+
]
327906+
],
327901327907
"html/infrastructure/safe-passing-of-structured-data/structured_clone_blob.html": [
327902327908
[
327903327909
"/html/infrastructure/safe-passing-of-structured-data/structured_clone_blob.html",
@@ -558861,6 +558867,10 @@
558861558867
"7c0b8b2e411236aeeed3a8b7962dc70d8a94969f",
558862558868
"testharness"
558863558869
],
558870+
"html/infrastructure/safe-passing-of-structured-data/structured_clone_bigint.html": [
558871+
"5ca99a8e8550e55246e16980bdf5f5b65ceafd09",
558872+
"testharness"
558873+
],
558864558874
"html/infrastructure/safe-passing-of-structured-data/structured_clone_blob.html": [
558865558875
"2a3deba2534cad6f5e0aa85cfc3c90debcead20a",
558866558876
"testharness"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
5+
<title>2.7 Safe passing of structured data</title>
6+
<link rel="help" href="https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data" />
7+
<script src="/resources/testharness.js"></script>
8+
<script src="/resources/testharnessreport.js"></script>
9+
</head>
10+
<body>
11+
<div id="log"></div>
12+
13+
<script type="text/javascript">
14+
// Note, this test is designed to be in a similar style to
15+
// html/infrastructure/safe-passing-of-structured-data/structuredclone_0.html
16+
// It is in a separate file to avoid causing a syntax error on UAs which
17+
// do not yet support BigInt, so the rest of the test can continue running.
18+
19+
var worker;
20+
var testCollection;
21+
setup(function()
22+
{
23+
//the worker is used for each test in sequence
24+
//worker's callback will be set for each test
25+
//worker's internal onmessage echoes the data back to this thread through postMessage
26+
worker = new Worker("./echo.js");
27+
testCollection = [
28+
function() {
29+
var t = async_test("Primitive BigInt is cloned");
30+
t.id = 0;
31+
worker.onmessage = t.step_func(function(e) {assert_equals(1n, e.data, "1n === event.data"); t.done(); });
32+
t.step(function() { worker.postMessage(1n);});
33+
},
34+
function() {
35+
var t = async_test("Instance of BigInt is cloned");
36+
t.id = 1;
37+
var obj;
38+
t.step(function() {obj = Object(1n);});
39+
worker.onmessage = t.step_func(function(e) {
40+
assert_equals(obj.constructor, e.data.constructor, "BigInt === event.data.constructor");
41+
assert_equals(obj.valueOf(), e.data.valueOf(), "(BigInt(1n)).valueOf() === event.data.valueOf()");
42+
t.done();
43+
});
44+
t.step(function() { worker.postMessage(obj);});
45+
},
46+
];
47+
}, {explicit_done:true});
48+
49+
//Callback for result_callback
50+
//queues the next test in the array testCollection
51+
//serves to make test execution sequential from the async worker callbacks
52+
//alternatively, we would have to create a worker for each test
53+
function testFinished(test) {
54+
if(test.id < testCollection.length - 1) {
55+
//queue the function so that stack remains shallow
56+
queue(testCollection[test.id+1]);
57+
} else {
58+
//when the last test has run, explicitly end test suite
59+
done();
60+
}
61+
}
62+
function queue(func) {
63+
step_timeout(func, 10);
64+
}
65+
66+
add_result_callback(testFinished);
67+
//start the first test manually
68+
queue(testCollection[0]);
69+
70+
71+
72+
73+
</script>
74+
</body>
75+
</html>
76+

0 commit comments

Comments
 (0)