Skip to content

Commit

Permalink
[Fixit] Move some frameNavigation web tests to WPTs.
Browse files Browse the repository at this point in the history
Convert some older web tests into WPTs.

Bug: 1187081
Change-Id: I6b24765bb311608110646259ca6db0d4faebb8ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3284525
Commit-Queue: Arthur Hemery <[email protected]>
Reviewed-by: Titouan Rigoudy <[email protected]>
Cr-Commit-Position: refs/heads/main@{#943060}
  • Loading branch information
hemeryar authored and pull[bot] committed Jul 11, 2023
1 parent 81bc253 commit 1031542
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// META: script=/resources/testharness.js
// META: script=/resources/testharnessreport.js

async_test(t => {
addEventListener('message', t.step_func_done(e => {
assert_equals(e.data, 'Denied');
}));
const w = open("resources/page-with-top-navigating-iframe.html?parent_user_gesture=true");
t.add_cleanup(() => {w.close()});

}, "Cross-origin top navigation is blocked without user activation, even if the parent has user activation");
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// META: script=/resources/testharness.js
// META: script=/resources/testharnessreport.js

async_test(t => {
addEventListener('message', t.step_func_done(e => {
assert_equals(e.data, 'Denied');
}));
const w = open("resources/page-with-top-navigating-iframe.html");
t.add_cleanup(() => {w.close()});

}, "Cross-origin top navigation is blocked without user activation");
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Page that postMessage to its opener</title>
<script>
opener.postMessage('Allowed', '*');
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<meta charset="utf-8">
<script src=/common/get-host-info.sub.js></script>
<script src=/resources/testdriver.js></script>
<script src=/resources/testdriver-vendor.js></script>
<title>Page that embeds an iframe that navigates its top</title>
<script>
function addIframe() {
const iframe = document.createElement('iframe');
const path = new URL("top-navigating-page.html", window.location).pathname;
iframe.src = get_host_info().HTTP_NOTSAMESITE_ORIGIN + path;
document.body.appendChild(iframe);
}

addEventListener('load', () => {
const urlParams = new URLSearchParams(location.search);
const parentUserGesture = urlParams.get('parent_user_gesture') === 'true';
if (parentUserGesture)
test_driver.bless("Giving parent frame user activation").then(addIframe);
else
addIframe();
});
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Page that navigates its top</title>
<script src=/common/get-host-info.sub.js></script>
<script>

let path = new URL("page-that-post-message-to-opener.html", window.location).pathname;
let fullUrl = get_host_info().HTTP_NOTSAMESITE_ORIGIN + path;
try {
top.location = fullUrl;
} catch {
top.opener.postMessage('Denied', '*');
}

</script>

0 comments on commit 1031542

Please sign in to comment.