mirror of
https://github.com/servo/servo.git
synced 2025-08-24 14:48:21 +01:00
Update web-platform-tests to revision 8a2ceb5f18911302b7a5c1cd2791f4ab50ad4326
This commit is contained in:
parent
462c272380
commit
1f531f66ea
5377 changed files with 174916 additions and 84369 deletions
2
tests/wpt/web-platform-tests/web-share/OWNERS
Normal file
2
tests/wpt/web-platform-tests/web-share/OWNERS
Normal file
|
@ -0,0 +1,2 @@
|
|||
@mgiuca
|
||||
@marcoscaceres
|
32
tests/wpt/web-platform-tests/web-share/idlharness.https.html
Normal file
32
tests/wpt/web-platform-tests/web-share/idlharness.https.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare IDL test</title>
|
||||
<link rel="help" href="https://wicg.github.io/web-share/">
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src=/resources/WebIDLParser.js></script>
|
||||
<script src=/resources/idlharness.js></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
"use strict";
|
||||
var idl_array = new IdlArray();
|
||||
|
||||
function doTest(idl) {
|
||||
idl_array.add_untested_idls('interface Navigator {};');
|
||||
idl_array.add_idls(idl);
|
||||
idl_array.add_objects({
|
||||
Navigator: ['navigator']
|
||||
});
|
||||
idl_array.test();
|
||||
}
|
||||
|
||||
promise_test(async () => {
|
||||
const response = await fetch('../interfaces/web-share.idl');
|
||||
doTest(await response.text());
|
||||
}, 'Test driver');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,78 @@
|
|||
// Internal function. Returns [instruction, list] DOM elements.
|
||||
function setupManualShareTestCommon() {
|
||||
const div = document.createElement('div');
|
||||
document.body.appendChild(div);
|
||||
|
||||
const instruction = document.createElement('div');
|
||||
instruction.id = 'instruction';
|
||||
div.appendChild(instruction);
|
||||
|
||||
const shareButton = document.createElement('input');
|
||||
shareButton.id = 'share_button';
|
||||
shareButton.value = 'Share button';
|
||||
shareButton.type = 'button';
|
||||
div.appendChild(shareButton);
|
||||
|
||||
let heading = document.createElement('h2');
|
||||
heading.innerText = 'Instructions:';
|
||||
instruction.appendChild(heading);
|
||||
let list = document.createElement('ol');
|
||||
instruction.appendChild(list);
|
||||
let item = document.createElement('li');
|
||||
list.appendChild(item);
|
||||
item.innerText = 'Click the Share button.';
|
||||
|
||||
return [instruction, list];
|
||||
}
|
||||
|
||||
// Sets up the page for running manual tests. Automatically creates the
|
||||
// instructions (based on the parameters) and the share button.
|
||||
function setupManualShareTest(expected_share_data) {
|
||||
const {title, text, url} = expected_share_data;
|
||||
let [instruction, list] = setupManualShareTestCommon();
|
||||
let item = document.createElement('li');
|
||||
list.appendChild(item);
|
||||
item.innerText = 'Choose a valid share target.';
|
||||
|
||||
heading = document.createElement('h2');
|
||||
heading.innerText = 'Pass the test iff the target app received:';
|
||||
instruction.appendChild(heading);
|
||||
|
||||
list = document.createElement('ul');
|
||||
instruction.appendChild(list);
|
||||
|
||||
item = document.createElement('li');
|
||||
list.appendChild(item);
|
||||
item.innerText = `title = "${title}"`;
|
||||
item = document.createElement('li');
|
||||
list.appendChild(item);
|
||||
item.innerText = `text = "${text}"`;
|
||||
item = document.createElement('li');
|
||||
list.appendChild(item);
|
||||
item.innerText = `url = "${url}"`;
|
||||
}
|
||||
|
||||
function setupManualShareTestRequiringCancellation() {
|
||||
const [instruction, list] = setupManualShareTestCommon();
|
||||
const item = document.createElement('li');
|
||||
list.appendChild(item);
|
||||
item.innerText = 'Cancel the share dialog.';
|
||||
}
|
||||
|
||||
// Returns a promise. When the user clicks the button, calls
|
||||
// |click_handler| and resolves the promise with the result.
|
||||
function callWhenButtonClicked(click_handler) {
|
||||
return new Promise((resolve, reject) => {
|
||||
document.querySelector('#share_button').onclick = () => {
|
||||
try {
|
||||
resolve(click_handler());
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function getAbsoluteUrl(url) {
|
||||
return new URL(url, document.baseURI).toString();
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share cancelled by user</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual-helper.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
setupManualShareTestRequiringCancellation();
|
||||
|
||||
promise_test(t => {
|
||||
return callWhenButtonClicked(() => promise_rejects(
|
||||
t, 'AbortError',
|
||||
navigator.share({title: 'the title', text: 'the message',
|
||||
url: 'data:the url'})));
|
||||
}, 'share with user cancellation');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share no known fields</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual-helper.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
promise_test(t => {
|
||||
return promise_rejects(t, new TypeError(), navigator.share());
|
||||
}, 'share with no arguments (same as empty dictionary)');
|
||||
|
||||
promise_test(t => {
|
||||
return promise_rejects(t, new TypeError(), navigator.share({}));
|
||||
}, 'share with an empty dictionary');
|
||||
|
||||
promise_test(t => {
|
||||
return promise_rejects(t, new TypeError(), navigator.share(undefined));
|
||||
}, 'share with a undefined argument (same as empty dictionary)');
|
||||
|
||||
promise_test(t => {
|
||||
return promise_rejects(t, new TypeError(), navigator.share(null));
|
||||
}, 'share with a null argument (same as empty dictionary)');
|
||||
|
||||
promise_test(t => {
|
||||
return promise_rejects(t,
|
||||
new TypeError(), navigator.share({unused: 'unexpected field'}));
|
||||
}, 'share with a dictionary containing only surplus fields');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Surplus arguments ignored</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual-helper.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
setupManualShareTest(
|
||||
{title: 'the title', text: 'the message', url: 'data:the url'});
|
||||
callWhenButtonClicked(() => navigator.share(
|
||||
{title: 'the title', text: 'the message', url: 'data:the url'},
|
||||
'more than required'));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Surplus fields ignored</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual-helper.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
setupManualShareTest(
|
||||
{title: 'the title', text: 'the message', url: 'data:the url'});
|
||||
callWhenButtonClicked(() => navigator.share(
|
||||
{title: 'the title', text: 'the message', url: 'data:the url',
|
||||
unused: 'unexpected field'}));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share non-string types (test implicit conversion)</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual-helper.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
// Expect that each of the non-string values is converted into a string.
|
||||
setupManualShareTest(
|
||||
{title: 'true', text: 'the object', url: getAbsoluteUrl('384957')});
|
||||
|
||||
const objectWithToString = {toString() { return 'the object'; }};
|
||||
callWhenButtonClicked(() => navigator.share(
|
||||
{title: true, text: objectWithToString, url: 384957}));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share null and undefined values</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual-helper.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
// Expect null to be converted into the string 'null'. On the other
|
||||
// hand, undefined should be equivalent to omitting the attribute.
|
||||
setupManualShareTest(
|
||||
{title: 'null', text: '', url: getAbsoluteUrl('null')});
|
||||
callWhenButtonClicked(() => navigator.share(
|
||||
{title: null, text: undefined, url: null}));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share from non-secure context</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
test(() => {
|
||||
assert_false('share' in navigator, 'navigator has attribute \'share\'.');
|
||||
}, 'navigator.share must be undefined in non-secure context');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Simple share</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual-helper.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
const url = 'https://www.example.com/some/path?some_query#some_fragment';
|
||||
setupManualShareTest({title: 'the title', text: 'the message', url});
|
||||
callWhenButtonClicked(() => navigator.share(
|
||||
{title: 'the title', text: 'the message', url})).then(
|
||||
result => {
|
||||
// Check that promise resolved with undefined. This is guarded
|
||||
// by an if statement because we do not want it to register as a
|
||||
// test if it passes (since this is a manual test).
|
||||
if (result !== undefined) {
|
||||
assert_equals(result, undefined);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share with non-ASCII Unicode strings</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual-helper.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
// Title is a string with BMP and non-BMP characters.
|
||||
// Text contains invalid surrogates which should be converted into U+FFFD.
|
||||
// URL contains non-ASCII characters in host and path.
|
||||
const title = 'fáncy 写作 😱';
|
||||
const url = 'https://测试.example.com/📄';
|
||||
// Host is IDNA-encoded. Path is percent-encoded.
|
||||
const url_ascii = 'https://xn--0zwm56d.example.com/%F0%9F%93%84';
|
||||
setupManualShareTest({title, text: '\ufffdx', url: url_ascii});
|
||||
callWhenButtonClicked(() => navigator.share({title, text: '\ud9a3x', url}));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="windows-1252">
|
||||
<title>WebShare Test: Share with non-ASCII Unicode strings in a Latin-1-encoded page</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual-helper.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
assert_equals(document.characterSet, 'windows-1252');
|
||||
|
||||
// Exact same test as in share-unicode-strings-manual.html, with same
|
||||
// expectations. This tests that the page's encoding (ISO-8859-1) is
|
||||
// ignored and Unicode characters are always percent-encoded in UTF-8.
|
||||
const title = 'f\xe1ncy \u5199\u4f5c \ud83d\ude31';
|
||||
const url = 'https://\u6d4b\u8bd5.example.com/\ud83d\udcc4';
|
||||
// Host is IDNA-encoded. Path is percent-encoded with UTF-8.
|
||||
const url_ascii = 'https://xn--0zwm56d.example.com/%F0%9F%93%84';
|
||||
setupManualShareTest({title, text: '\ufffdx', url: url_ascii});
|
||||
callWhenButtonClicked(() => navigator.share({title, text: '\ud9a3x', url}));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share with data URL</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual-helper.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
const url = 'data:foo';
|
||||
setupManualShareTest({title: '', text: '', url: getAbsoluteUrl(url)});
|
||||
callWhenButtonClicked(() => navigator.share({url}));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share with empty URL</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual-helper.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
setupManualShareTest({title: '', text: '', url: document.baseURI});
|
||||
callWhenButtonClicked(() => navigator.share({url: ''}));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share URL with illegal characters (test percent encoding)</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual-helper.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
const url = 'http://example.com/foo\\ab%63\r\n\t "<>`{}';
|
||||
// Expect '\' to normalize to '/', "%63" to normalize to 'c', '\r\n\t'
|
||||
// to be removed, and all the other illegal characters to be percent-escaped.
|
||||
const url_encoded = 'http://example.com/foo/abc%20%22%3C%3E%60%7B%7D';
|
||||
setupManualShareTest({title: '', text: '', url: url_encoded});
|
||||
callWhenButtonClicked(() => navigator.share({url}));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share with an invalid URL</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
promise_test(t => {
|
||||
// URL is invalid in that the URL Parser returns failure (port is too
|
||||
// large).
|
||||
const url = 'http://example.com:65536';
|
||||
return promise_rejects(
|
||||
t, new TypeError(), navigator.share({url}));
|
||||
}, 'share with an invalid URL');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share with URL without a scheme</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual-helper.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
const url = '//www.example.com/some/path?some_query#some_fragment';
|
||||
setupManualShareTest({title: '', text: '', url: getAbsoluteUrl(url)});
|
||||
callWhenButtonClicked(() => navigator.share({url}));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share with absolute path-only URL</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual-helper.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
const url = '/some/path?some_query#some_fragment';
|
||||
setupManualShareTest({title: '', text: '', url: getAbsoluteUrl(url)});
|
||||
callWhenButtonClicked(() => navigator.share({url}));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share with relative URL</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual-helper.js"></script>
|
||||
<base href="https://www.example.com/some/path.html">
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
const url = 'foo';
|
||||
setupManualShareTest({title: '', text: '', url: getAbsoluteUrl(url)});
|
||||
callWhenButtonClicked(() => navigator.share({url}));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share without user gesture error</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
promise_test(t => {
|
||||
return promise_rejects(
|
||||
t, 'NotAllowedError',
|
||||
navigator.share({title: 'the title', text: 'the message',
|
||||
url: 'data:the url'}));
|
||||
}, 'share without a user gesture');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue