Commit b990bcde authored by Nick Burris's avatar Nick Burris Committed by Commit Bot

Perform cross-origin navigation for scroll to text security WPTs

These tests need to perform cross-origin navigations as they test
security restrictions that only apply to cross-origin.

Bug: 1049624
Change-Id: I241962c44eaa1e4862e3df38be4b614491818b64
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2042402Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Commit-Queue: Nick Burris <nburris@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739095}
parent 928037da
This is a testharness.js-based test.
PASS Test that a text fragment directive requires a user activation (user_activation=true).
PASS Test that a text fragment directive requires a user activation (user_activation=false).
PASS Test that a text fragment directive is not activated when there is a window opener (noopener=true).
FAIL Test that a text fragment directive is not activated when there is a window opener (noopener=false). assert_equals: Expected window.open() with opener to not activate text fragment directive. expected "top" but got "text"
FAIL Test that a text fragment directive is not activated within an iframe. assert_equals: Expected iframe navigation to not activate text fragment directive. expected "top" but got "text"
Harness: the test ran to completion.
......@@ -34,6 +34,8 @@ for (let user_activation of [true, false]) {
}), `Test that a text fragment directive requires a user activation (user_activation=${user_activation}).`);
}
const crossOriginTarget = "http://{{hosts[alt][www]}}:{{ports[http][0]}}/scroll-to-text-fragment/scroll-to-text-fragment-target.html";
// Test security restriction for no window opener
for (let noopener of [true, false]) {
promise_test(t => new Promise((resolve, reject) => {
......@@ -41,9 +43,9 @@ for (let noopener of [true, false]) {
test_driver.bless('Open a URL with a text fragment directive', () => {
if (noopener) {
window.open(`scroll-to-text-fragment-target.html?key=${key}#:~:text=test`, '_blank', 'noopener');
window.open(`${crossOriginTarget}?key=${key}#:~:text=test`, '_blank', 'noopener');
} else {
window.open(`scroll-to-text-fragment-target.html?key=${key}#:~:text=test`, '_blank');
window.open(`${crossOriginTarget}?key=${key}#:~:text=test`, '_blank');
}
});
......@@ -67,7 +69,7 @@ promise_test(t => new Promise((resolve, reject) => {
document.body.appendChild(frame);
test_driver.bless('Navigate the iframe with a text fragment directive', () => {
frame.src = `scroll-to-text-fragment-target.html?key=${key}#:~:text=test`;
frame.src = `${crossOriginTarget}?key=${key}#:~:text=test`;
});
fetchResults(key, resolve, reject);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment