Skip to content

Commit

Permalink
Fix Sandbox WPT using a non-existing file
Browse files Browse the repository at this point in the history
Another file that was using ./common/blank.html instead of an existing
file. I also propose a fix for firefox behavior where it might not throw
if the origin is checked synchronously, this by adding a timeout and
trying again.

Change-Id: I2ce8277d09d03b4be575315b0828a4a279dd7337
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3720219
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Pâris Meuleman <pmeuleman@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1021191}
  • Loading branch information
ParisMeuleman authored and chromium-wpt-export-bot committed Jul 6, 2022
1 parent 98439fb commit cfb2e6a
Showing 1 changed file with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
Expand Down Expand Up @@ -26,6 +27,12 @@
assert_false(msg.data.access_first_navigation_to_about_blank_throws,
"Failed to access navigation to about:blank, it is probably sandboxed"
);
assert_false(msg.data.access_after_delay_initial_navigation_to_about_blank_throws,
"Failed to access navigation to about:blank, it is probably sandboxed"
);
assert_false(msg.data.access_after_delay_first_navigation_to_about_blank_throws,
"Failed to access navigation to about:blank, it is probably sandboxed"
);
}, "Popup do not inherit sandbox, because of " +
"'allow-popups-to-escape-sandbox'. The document isn't sandboxed.")

Expand All @@ -36,8 +43,10 @@
<script>
let access_initial_navigation_to_about_blank_throws = false;
let access_first_navigation_to_about_blank_throws = false;
let access_after_delay_initial_navigation_to_about_blank_throws = false;
let access_after_delay_first_navigation_to_about_blank_throws = false;
const initial_about_blank_window =
window.open('common/blank.html?pipe=status(204)');
window.open('/common/blank.html?pipe=status(204)');
try {
initial_about_blank_window.origin;
} catch(e) {
Expand All @@ -49,12 +58,28 @@
} catch(e) {
access_first_navigation_to_about_blank_throws = true;
}
top.postMessage({
'access_initial_navigation_to_about_blank_throws':
access_initial_navigation_to_about_blank_throws,
'access_first_navigation_to_about_blank_throws':
access_first_navigation_to_about_blank_throws
}, '*');
setTimeout(() => {
try {
initial_about_blank_window.origin;
} catch(e) {
access_after_delay_initial_navigation_to_about_blank_throws = true;
}
try {
renavigated_about_blank_window.origin;
} catch(e) {
access_after_delay_first_navigation_to_about_blank_throws = true;
}
top.postMessage({
'access_initial_navigation_to_about_blank_throws':
access_initial_navigation_to_about_blank_throws,
'access_first_navigation_to_about_blank_throws':
access_first_navigation_to_about_blank_throws,
'access_after_delay_initial_navigation_to_about_blank_throws':
access_after_delay_initial_navigation_to_about_blank_throws,
'access_after_delay_first_navigation_to_about_blank_throws':
access_after_delay_first_navigation_to_about_blank_throws
}, '*');
}, 500);
</script>"
>
</iframe>
Expand Down

0 comments on commit cfb2e6a

Please sign in to comment.