-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1527584 [wpt PR 15352] - HTML: window.open("", "", "noreferrer"),…
… a=testonly Automatic update from web-platform-tests HTML: window.open("", "", "noreferrer") For whatwg/html#4331. -- wpt-commits: 22abb9c5c4a78f5deecc49417f5e57ba27f404cb wpt-pr: 15352 UltraBlame original commit: 5c6bfad36ca045e19786e7eb97104d31a04d81fd
- Loading branch information
Showing
5 changed files
with
198 additions
and
153 deletions.
There are no files selected for viewing
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
11 changes: 11 additions & 0 deletions
11
...ating-and-navigating-browsing-contexts-by-name/open-features-tokenization-noreferrer.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,11 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML: window.open `features`: tokenization -- `noreferrer`</title> | ||
<meta name=timeout content=long> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/tokenization-noopener-noreferrer.js"></script> | ||
<script> | ||
booleanTests("noreferrer"); | ||
</script> |
152 changes: 152 additions & 0 deletions
152
...ng-and-navigating-browsing-contexts-by-name/resources/tokenization-noopener-noreferrer.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,152 @@ | ||
function booleanTests(feature) { | ||
const windowURL = 'resources/close-self.html'; | ||
|
||
|
||
|
||
const featureUpper = feature.toUpperCase(), | ||
featureSplitBegin = feature.slice(0, 2), | ||
featureSplitEnd = feature.slice(2), | ||
featureMixedCase = featureSplitBegin.toUpperCase() + featureSplitEnd; | ||
featureMixedCase2 = featureSplitBegin + featureSplitEnd.toUpperCase(); | ||
|
||
test (t => { | ||
|
||
|
||
[ | ||
` ${feature}`, | ||
`=${feature}`, | ||
`,,${feature}`, | ||
`,=, ${feature}`, | ||
`\n=${feature}=`, | ||
`\t${feature}`, | ||
`\r,,,=${feature}`, | ||
`\u000C${feature}` | ||
].forEach(variant => { | ||
const win = window.open(windowURL, "", variant); | ||
assert_equals(win, null, `"${variant}" should activate feature "${feature}"`); | ||
}); | ||
}, `Tokenization of "${feature}" should skip window features separators before feature`); | ||
|
||
test (t => { | ||
|
||
|
||
|
||
|
||
[ | ||
`${featureUpper}`, | ||
`${featureMixedCase}`, | ||
` ${featureMixedCase2}`, | ||
`=${featureUpper}`, | ||
`${featureUpper}=1`, | ||
`${featureUpper}=1`, | ||
`${featureUpper}=yes`, | ||
`${feature}=YES`, | ||
].forEach(variant => { | ||
const win = window.open(windowURL, '', variant); | ||
assert_equals(win, null, `"${variant}" should activate feature "${feature}"`); | ||
}); | ||
}, `Feature "${feature}" should be converted to ASCII lowercase`); | ||
|
||
test (t => { | ||
|
||
|
||
|
||
|
||
[ | ||
`${feature}`, | ||
` ${feature}\r`, | ||
`${feature}\n =`, | ||
`${feature},`, | ||
`${feature} =,`, | ||
`, ${feature} =`, | ||
`${feature},=`, | ||
`${feature} foo`, | ||
`foo ${feature}=1`, | ||
`foo=\u000Cbar\u000C${feature}` | ||
].forEach(variant => { | ||
const win = window.open(windowURL, '', variant); | ||
assert_equals(win, null, `"${variant}" should activate feature "${feature}"`); | ||
}); | ||
}, `After "${feature}", tokenization should skip window features separators that are not "=" or ","`); | ||
|
||
test (t => { | ||
|
||
|
||
|
||
|
||
[ | ||
`${feature}= yes`, | ||
`${feature}==,`, | ||
`${feature}=\n ,`, | ||
`${feature} = \t ,`, | ||
`${feature}\n=\r 1,`, | ||
`${feature}=,yes`, | ||
`${feature}= yes=,`, | ||
`${feature} = \u000Cyes` | ||
].forEach(variant => { | ||
const win = window.open(windowURL, '', variant); | ||
assert_equals(win, null, `"${variant}" should activate feature "${feature}"`); | ||
}); | ||
}, `Tokenizing "${feature}" should ignore window feature separators except "," after initial "=" and before value`); | ||
|
||
test (t => { | ||
|
||
[ | ||
`${feature}=1`, | ||
`${feature}=yes`, | ||
`${feature} = yes ,`, | ||
`${feature}=\nyes ,`, | ||
`${feature}=yes yes`, | ||
`${feature}=yes\ts`, | ||
`${feature}==`, | ||
`${feature}=1\n,`, | ||
`==${feature}===`, | ||
`${feature}==\u000C` | ||
].forEach(variant => { | ||
const win = window.open(windowURL, '', variant); | ||
assert_equals(win, null, `"${variant}" should set "${feature}"`); | ||
}); | ||
}, `Tokenizing "${feature}" should read characters until first window feature separator as \`value\``); | ||
|
||
test (t => { | ||
[ | ||
`${feature}=1`, | ||
`${feature}=2`, | ||
`${feature}=12345`, | ||
`${feature}=1.5`, | ||
`${feature}=-1`, | ||
].forEach(variant => { | ||
const win = window.open(windowURL, '', variant); | ||
assert_equals(win, null, `"${variant}" should activate feature "${feature}"`); | ||
}); | ||
}, 'Integer values other than 0 should activate the feature'); | ||
|
||
test (t => { | ||
[ | ||
`${feature}=0`, | ||
`${feature}=0.5`, | ||
`${feature}=error`, | ||
].forEach(variant => { | ||
const win = window.open(windowURL, '', variant); | ||
assert_not_equals(win, null, `"${variant}" should NOT activate feature "${feature}"`); | ||
}); | ||
}, `Integer value of 0 should not activate "${feature}"`); | ||
|
||
test (t => { | ||
[ | ||
`-${feature}`, | ||
`${featureUpper}RRR`, | ||
`${featureMixedCase}R`, | ||
`${featureSplitBegin}_${featureSplitEnd}`, | ||
` ${featureSplitBegin} ${featureSplitEnd}`, | ||
`${featureSplitBegin}\n${featureSplitEnd}`, | ||
`${featureSplitBegin},${featureSplitEnd}`, | ||
`\0${feature}`, | ||
`${feature}\u0000=yes`, | ||
`foo=\u000C${feature}` | ||
].forEach(variant => { | ||
const win = window.open(windowURL, '', variant); | ||
assert_not_equals(win, null, `"${variant}" should NOT activate feature "${feature}"`); | ||
}); | ||
}, `Invalid feature names should not tokenize as "${feature}"`); | ||
} |
13 changes: 13 additions & 0 deletions
13
testing/web-platform/tests/html/browsers/the-window-object/support/noreferrer-target.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,13 @@ | ||
<script> | ||
const channelName = location.search.substr(1), | ||
channel = new BroadcastChannel(channelName); | ||
channel.postMessage({ name: window.name, | ||
haveOpener: window.opener !== null, | ||
referrer: document.referrer }); | ||
|
||
// Because messages are not delivered synchronously and because closing a | ||
// browsing context prompts the eventual clearing of all task sources, this | ||
// document should not be closed until the opener document has confirmed | ||
// receipt. | ||
channel.onmessage = () => window.close(); | ||
</script> |
20 changes: 20 additions & 0 deletions
20
testing/web-platform/tests/html/browsers/the-window-object/window-open-noreferrer.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,20 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>window.open() with "noreferrer" tests</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script> | ||
async_test(t => { | ||
const channelName = "343243423432", | ||
channel = new BroadcastChannel(channelName); | ||
window.open("support/noreferrer-target.html?" + channelName, "", "noreferrer"); | ||
channel.onmessage = t.step_func_done(e => { | ||
// Send message first so if asserts throw the popup is still closed | ||
channel.postMessage(null); | ||
|
||
assert_equals(e.data.name, ""); | ||
assert_equals(e.data.referrer, ""); | ||
assert_equals(e.data.haveOpener, false); | ||
}); | ||
}); | ||
</script> |