Skip to content

Commit

Permalink
Fix wpt/html/.../window-domain-failure.https.sub.html
Browse files Browse the repository at this point in the history
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 <yhirano@chromium.org>
Reviewed-by: Domenic Denicola <domenic@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1011058}
  • Loading branch information
yutakahirano authored and pull[bot] committed Jun 26, 2023
1 parent 4ce1067 commit 1107415
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
parent.postMessage({name: "domain", value: document.domain}, "*");
parent.postMessage(
{name: "crossOriginIsolated", value: self.crossOriginIsolated}, "*");
parent.postMessage(new SharedArrayBuffer(10), "*");
parent.postMessage(
{name: "hasSharedArrayBuffer", value: Boolean(self.SharedArrayBuffer)}, "*");
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<div id="log"></div>

<body>
<script>
"use strict";
document.domain = "{{host}}";
Expand All @@ -16,8 +14,8 @@
const iframe = document.createElement("iframe");
t.add_cleanup(() => iframe.remove());
iframe.src = "//{{domains[www1]}}:{{location[port]}}/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/iframe-domain-failure.sub.html";
let domain = null;
let childCrossOriginIsolated = null;
let domain;
let childCrossOriginIsolated;
window.onmessage = t.step_func((e) => {
if (e.data.name === "domain") {
domain = e.data.value;
Expand All @@ -27,16 +25,25 @@
childCrossOriginIsolated = e.data.value;
return;
}
if (e.data.name === "hasSharedArrayBuffer") {
const hasSharedArrayBuffer = e.data.value;

// document.domain mutation is no-op because the surrounding agent
// cluster's cross-origin isolated is true.
assert_equals(domain, "{{domains[www1]}}");

// crossOriginIsolated is false in the nested frame because the frame is
// cross-origin and hence the cross-origin isolated capability is false.
// We use assert_equals instead of assert_false here to see if
// `childCrossOriginIsolated` is set.
assert_equals(childCrossOriginIsolated, false);

assert_false(hasSharedArrayBuffer);
t.done();
return;
}
assert_unreached("Got a message event, expected a messageerror event");
});
window.onmessageerror = t.step_func_done(() => {
// crossOriginIsolated is false in the nested frame because the frame is
// cross-origin and hence the cross-origin isolated capability is false.
assert_equals(childCrossOriginIsolated, false);
// But document.domain mutation is no-op because the surrounding agent
// cluster's cross-origin isolated is true.
assert_equals(domain, "{{domains[www1]}}");
});
document.body.append(iframe);
}, "SharedArrayBuffer and a same-origin-domain (but not same-origin) iframe");
</script>

0 comments on commit 1107415

Please sign in to comment.