mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Update web-platform-tests to revision 78f764c05c229883e87ad135c7153051a66e2851
This commit is contained in:
parent
55347aa39f
commit
bf84a079f9
1983 changed files with 58006 additions and 31437 deletions
|
@ -5,158 +5,7 @@
|
|||
<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>
|
||||
var windowURL = 'resources/close-self.html';
|
||||
|
||||
// Tests for how windows features are tokenized into 'name', 'value'
|
||||
// window features separators are ASCII whitespace, '=' and ','
|
||||
|
||||
test (t => {
|
||||
// Tokenizing `name`: initial window features separators are ignored
|
||||
// Each of these variants should tokenize to ('noopener', '')
|
||||
var featureVariants = [
|
||||
' noopener',
|
||||
'=noopener',
|
||||
',,noopener',
|
||||
',=, noopener',
|
||||
'\n=noopener=',
|
||||
'\tnoopener',
|
||||
'\r,,,=noopener',
|
||||
'\u000Cnoopener'
|
||||
];
|
||||
featureVariants.forEach(feature => {
|
||||
var win = window.open(windowURL, '', feature);
|
||||
assert_equals(win, null, `"${feature}" should activate feature "noopener"`);
|
||||
});
|
||||
}, 'tokenization should skip window features separators before `name`');
|
||||
|
||||
test (t => {
|
||||
// Tokenizing `name`: lowercase conversion
|
||||
// Each of these variants should tokenize as feature ('noopener', '')
|
||||
// except where indicated
|
||||
// Note also that `value` is lowercased during tokenization
|
||||
var featureVariants = [
|
||||
'NOOPENER',
|
||||
'noOpenER',
|
||||
' NOopener',
|
||||
'=NOOPENER',
|
||||
'noopener=1',
|
||||
'NOOPENER=1',
|
||||
'NOOPENER=yes',
|
||||
'noopener=YES',
|
||||
];
|
||||
featureVariants.forEach(feature => {
|
||||
var win = window.open(windowURL, '', feature);
|
||||
assert_equals(win, null, `"${feature}" should activate feature "noopener"`);
|
||||
});
|
||||
}, 'feature `name` should be converted to ASCII lowercase');
|
||||
|
||||
test (t => {
|
||||
// After `name` has been collected, ignore any window features separators until '='
|
||||
// except ',' OR a non-window-features-separator — break in those cases
|
||||
// i.e. ignore whitespace until '=' unless a ',' is encountered first
|
||||
// Each of these variants should tokenize as feature ('noopener', '')
|
||||
var featureVariants = [
|
||||
'noopener',
|
||||
' noopener\r',
|
||||
'noopener\n =',
|
||||
'noopener,',
|
||||
'noopener =,',
|
||||
', noopener =',
|
||||
'noopener,=',
|
||||
'noopener foo', // => ('noopener', ''), ('foo', '')
|
||||
'foo noopener=1', // => ('foo', ''), ('noopener', '1')
|
||||
'foo=\u000Cbar\u000Cnoopener' // => ('foo', 'bar'), ('noopener', '')
|
||||
];
|
||||
featureVariants.forEach(feature => {
|
||||
var win = window.open(windowURL, '', feature);
|
||||
assert_equals(win, null, `"${feature}" should activate feature "noopener"`);
|
||||
});
|
||||
}, 'after `name`, tokenization should skip window features separators that are not "=" or ","');
|
||||
|
||||
test (t => {
|
||||
// After initial '=', tokenizing should ignore all separators except ','
|
||||
// before collecting `value`
|
||||
// Each of these variants should tokenize as feature ('noopener', '')
|
||||
// Except where indicated
|
||||
var featureVariants = [
|
||||
'noopener= yes', // => ('noopener', 'yes')
|
||||
'noopener==,',
|
||||
'noopener=\n ,',
|
||||
'noopener = \t ,',
|
||||
'noopener\n=\r 1,', // => ('noopener', '1')
|
||||
'noopener=,yes', // => ('noopener'), ('yes')
|
||||
'noopener= yes=,', // => ('noopener', 'yes')
|
||||
'noopener = \u000Cyes' // => ('noopener', 'yes')
|
||||
];
|
||||
featureVariants.forEach(feature => {
|
||||
var win = window.open(windowURL, '', feature);
|
||||
assert_equals(win, null, `"${feature}" should activate feature "noopener"`);
|
||||
});
|
||||
}, 'Tokenizing should ignore window feature separators except "," after initial "=" and before value');
|
||||
|
||||
test (t => {
|
||||
// Tokenizing `value` should collect any non-separator code points until first separator
|
||||
var featureVariants = [
|
||||
'noopener=1', // => ('noopener', 'noopener')
|
||||
'noopener=yes', // => ('noopener', 'yes')
|
||||
'noopener = yes ,', // => ('noopener', 'yes')
|
||||
'noopener=\nyes ,', // => ('noopener', 'yes')
|
||||
'noopener=yes yes', // => ('noopener', 'yes'), ('yes', '')
|
||||
'noopener=yes\ts', // => ('noopener', 'yes'), ('s', '')
|
||||
'noopener==', // => ('noopener', '')
|
||||
'noopener=1\n,', // => ('noopener', '1')
|
||||
'==noopener===', // => ('noopener', '')
|
||||
'noopener==\u000C' // => ('noopener', '')
|
||||
];
|
||||
featureVariants.forEach(feature => {
|
||||
var win = window.open(windowURL, '', feature);
|
||||
assert_equals(win, null, `"${feature}" should set "noopener"`);
|
||||
});
|
||||
}, 'Tokenizing should read characters until first window feature separator as `value`');
|
||||
|
||||
test (t => {
|
||||
var featureVariants = [
|
||||
'noopener=1',
|
||||
'noopener=2',
|
||||
'noopener=12345',
|
||||
'noopener=1.5',
|
||||
'noopener=-1',
|
||||
];
|
||||
featureVariants.forEach(feature => {
|
||||
var win = window.open(windowURL, '', feature);
|
||||
assert_equals(win, null, `"${feature}" should activate feature "noopener"`);
|
||||
});
|
||||
}, 'Integer values other than 0 should activate the feature');
|
||||
|
||||
test (t => {
|
||||
var featureVariants = [
|
||||
'noopener=0',
|
||||
'noopener=0.5',
|
||||
'noopener=error',
|
||||
];
|
||||
featureVariants.forEach(feature => {
|
||||
var win = window.open(windowURL, '', feature);
|
||||
assert_not_equals(win, null, `"${feature}" should NOT activate feature "noopener"`);
|
||||
});
|
||||
}, 'Integer value of 0 should not activate the feature');
|
||||
|
||||
test (t => {
|
||||
var invalidFeatureVariants = [
|
||||
'-noopener', // => ('-noopener', '')
|
||||
'NOOPENERRRR', // => ('noopenerrr', '')
|
||||
'noOpenErR', // => ('noopenerr', '')
|
||||
'no_opener', // => ('no_opener', '')
|
||||
' no opener', // => ('no', ''), ('opener', '')
|
||||
'no\nopener', // => ('no', ''), ('opener', '')
|
||||
'no,opener', // => ('no', ''), ('opener', '')
|
||||
'\0noopener', // => ('\0noopener', '')
|
||||
'noopener\u0000=yes', // => ('noopener\0', 'yes')
|
||||
'foo=\u000Cnoopener' // => ('foo', 'noopener')
|
||||
];
|
||||
invalidFeatureVariants.forEach(feature => {
|
||||
var win = window.open(windowURL, '', feature);
|
||||
assert_not_equals(win, null, `"${feature}" should NOT activate feature "noopener"`);
|
||||
});
|
||||
}, 'invalid feature names should not tokenize as "noopener"');
|
||||
booleanTests("noopener");
|
||||
</script>
|
||||
|
|
|
@ -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>
|
|
@ -0,0 +1,152 @@
|
|||
function booleanTests(feature) {
|
||||
const windowURL = 'resources/close-self.html';
|
||||
// Tests for how windows features are tokenized into 'name', 'value'
|
||||
// window features separators are ASCII whitespace, '=' and ','
|
||||
|
||||
const featureUpper = feature.toUpperCase(),
|
||||
featureSplitBegin = feature.slice(0, 2),
|
||||
featureSplitEnd = feature.slice(2),
|
||||
featureMixedCase = featureSplitBegin.toUpperCase() + featureSplitEnd;
|
||||
featureMixedCase2 = featureSplitBegin + featureSplitEnd.toUpperCase();
|
||||
|
||||
test (t => {
|
||||
// Tokenizing `name`: initial window features separators are ignored
|
||||
// Each of these variants should tokenize to (`${feature}`, '')
|
||||
[
|
||||
` ${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 => {
|
||||
// Tokenizing `name`: lowercase conversion
|
||||
// Each of these variants should tokenize as feature (`${feature}`, '')
|
||||
// except where indicated
|
||||
// Note also that `value` is lowercased during tokenization
|
||||
[
|
||||
`${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 => {
|
||||
// After `name` has been collected, ignore any window features separators until '='
|
||||
// except ',' OR a non-window-features-separator — break in those cases
|
||||
// i.e. ignore whitespace until '=' unless a ',' is encountered first
|
||||
// Each of these variants should tokenize as feature ('noopener', '')
|
||||
[
|
||||
`${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 => {
|
||||
// After initial '=', tokenizing should ignore all separators except ','
|
||||
// before collecting `value`
|
||||
// Each of these variants should tokenize as feature ('noopener', '')
|
||||
// Except where indicated
|
||||
[
|
||||
`${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 => {
|
||||
// Tokenizing `value` should collect any non-separator code points until first separator
|
||||
[
|
||||
`${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}"`);
|
||||
}
|
|
@ -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>
|
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue