-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fixit] Move some frameNavigation web tests to WPTs.
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
Showing
5 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...ing-across-documents/cross-origin-top-navigation-with-user-activation-in-parent.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
11 changes: 11 additions & 0 deletions
11
...navigating-across-documents/cross-origin-top-navigation-without-user-activation.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
6 changes: 6 additions & 0 deletions
6
...wsing-the-web/navigating-across-documents/resources/page-that-post-message-to-opener.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
24 changes: 24 additions & 0 deletions
24
...owsing-the-web/navigating-across-documents/resources/page-with-top-navigating-iframe.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
15 changes: 15 additions & 0 deletions
15
.../browsers/browsing-the-web/navigating-across-documents/resources/top-navigating-page.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |