mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
Update web-platform-tests to revision e45156b5e558c062a609356905c83a0258c516e3
This commit is contained in:
parent
9f6005be16
commit
5fcf52d946
199 changed files with 4430 additions and 530 deletions
|
@ -1,4 +1,5 @@
|
|||
spec: https://wicg.github.io/web-share/
|
||||
suggested_reviewers:
|
||||
- ewilligers
|
||||
- mgiuca
|
||||
- marcoscaceres
|
||||
|
|
|
@ -28,7 +28,7 @@ function setupManualShareTestCommon() {
|
|||
// 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;
|
||||
const {title, text, url, files} = expected_share_data;
|
||||
let [instruction, list] = setupManualShareTestCommon();
|
||||
let item = document.createElement('li');
|
||||
list.appendChild(item);
|
||||
|
@ -50,6 +50,27 @@ function setupManualShareTest(expected_share_data) {
|
|||
item = document.createElement('li');
|
||||
list.appendChild(item);
|
||||
item.innerText = `url = "${url}"`;
|
||||
if (files) {
|
||||
item = document.createElement('li');
|
||||
list.appendChild(item);
|
||||
item.innerText = `files = ${files.length} file(s)`;
|
||||
for (let file of files) {
|
||||
const div = document.createElement('div');
|
||||
if (file.type.startsWith('text/')) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
div.textContent = reader.result;
|
||||
};
|
||||
reader.readAsText(file);
|
||||
} else if (file.type.startsWith('image/')) {
|
||||
const image = document.createElement('img');
|
||||
image.src = URL.createObjectURL(file);
|
||||
image.alt = file.name;
|
||||
div.appendChild(image);
|
||||
}
|
||||
item.appendChild(div);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setupManualShareTestRequiringCancellation() {
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share multiple files</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 options = {type: 'text/plain'};
|
||||
const first = new File(['one'], 'first.txt', options);
|
||||
const second = new File(['two'], 'second.txt', options);
|
||||
const third = new File(['three'], 'third.txt', options);
|
||||
const fourth = new File(['four'], 'fourth.txt', options);
|
||||
const fifth = new File(['five'], 'fifth.txt', options);
|
||||
const data = {
|
||||
title: 'Counting to 5',
|
||||
text: 'Here are the numbers',
|
||||
url: 'https://example.com/',
|
||||
files: [first, second, third, fourth, fifth]
|
||||
};
|
||||
setupManualShareTest(data);
|
||||
callWhenButtonClicked(() => navigator.share(data));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebShare Test: Share single image file</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 fileBits = [
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="80px" height="80px">',
|
||||
'<circle cx="40" cy="40" r="28" fill="lime" />',
|
||||
'</svg>'
|
||||
];
|
||||
const fileName = 'circle.svg';
|
||||
const options = {type: 'image/svg+xml'};
|
||||
const file = new File(fileBits, fileName, options);
|
||||
setupManualShareTest({title: '', text: '', url: '', files: [file]});
|
||||
callWhenButtonClicked(() => navigator.share({files: [file]}));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue