Skip to content

Commit 1107415

Browse files
yutakahiranopull[bot]
authored andcommitted
Fix wpt/html/.../window-domain-failure.https.sub.html
self.SharedArrayBuffer is defined if and only if the environment is crossOriginIsolated. Fix the WPT accordingly. Bug: 1088220 Change-Id: If5ca273a9e513087b8fb192a18237d36ce54f2c8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3689131 Commit-Queue: Yutaka Hirano <[email protected]> Reviewed-by: Domenic Denicola <[email protected]> Cr-Commit-Position: refs/heads/main@{#1011058}
1 parent 4ce1067 commit 1107415

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/iframe-domain-failure.sub.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
parent.postMessage({name: "domain", value: document.domain}, "*");
1010
parent.postMessage(
1111
{name: "crossOriginIsolated", value: self.crossOriginIsolated}, "*");
12-
parent.postMessage(new SharedArrayBuffer(10), "*");
12+
parent.postMessage(
13+
{name: "hasSharedArrayBuffer", value: Boolean(self.SharedArrayBuffer)}, "*");
1314
</script>

html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/window-domain-failure.https.sub.html

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
<link rel="author" title="Domenic Denicola" href="mailto:[email protected]">
66
<script src="/resources/testharness.js"></script>
77
<script src="/resources/testharnessreport.js"></script>
8-
9-
<div id="log"></div>
10-
8+
<body>
119
<script>
1210
"use strict";
1311
document.domain = "{{host}}";
@@ -16,8 +14,8 @@
1614
const iframe = document.createElement("iframe");
1715
t.add_cleanup(() => iframe.remove());
1816
iframe.src = "//{{domains[www1]}}:{{location[port]}}/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/iframe-domain-failure.sub.html";
19-
let domain = null;
20-
let childCrossOriginIsolated = null;
17+
let domain;
18+
let childCrossOriginIsolated;
2119
window.onmessage = t.step_func((e) => {
2220
if (e.data.name === "domain") {
2321
domain = e.data.value;
@@ -27,16 +25,25 @@
2725
childCrossOriginIsolated = e.data.value;
2826
return;
2927
}
28+
if (e.data.name === "hasSharedArrayBuffer") {
29+
const hasSharedArrayBuffer = e.data.value;
30+
31+
// document.domain mutation is no-op because the surrounding agent
32+
// cluster's cross-origin isolated is true.
33+
assert_equals(domain, "{{domains[www1]}}");
34+
35+
// crossOriginIsolated is false in the nested frame because the frame is
36+
// cross-origin and hence the cross-origin isolated capability is false.
37+
// We use assert_equals instead of assert_false here to see if
38+
// `childCrossOriginIsolated` is set.
39+
assert_equals(childCrossOriginIsolated, false);
40+
41+
assert_false(hasSharedArrayBuffer);
42+
t.done();
43+
return;
44+
}
3045
assert_unreached("Got a message event, expected a messageerror event");
3146
});
32-
window.onmessageerror = t.step_func_done(() => {
33-
// crossOriginIsolated is false in the nested frame because the frame is
34-
// cross-origin and hence the cross-origin isolated capability is false.
35-
assert_equals(childCrossOriginIsolated, false);
36-
// But document.domain mutation is no-op because the surrounding agent
37-
// cluster's cross-origin isolated is true.
38-
assert_equals(domain, "{{domains[www1]}}");
39-
});
4047
document.body.append(iframe);
4148
}, "SharedArrayBuffer and a same-origin-domain (but not same-origin) iframe");
4249
</script>

0 commit comments

Comments
 (0)