Update web-platform-tests to revision b7a8b84debb42268ea95a45bdad8f727d1facdf7

This commit is contained in:
WPT Sync Bot 2019-03-21 21:40:20 -04:00
parent ba929208e4
commit 953dbda9a6
215 changed files with 6409 additions and 1644 deletions

View file

@ -1,11 +1,11 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Clipboard IDL test</title>
<link rel="help" href="https://w3c.github.io/clipboard-apis/">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/resources/WebIDLParser.js></script>
<script src=/resources/idlharness.js></script>
<link rel='help' href='https://w3c.github.io/clipboard-apis/'>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
<script>
'use strict';
@ -31,9 +31,9 @@ function fetchText(url) {
promise_test(() => {
return Promise.all(
[
"/interfaces/clipboard-apis.idl",
"/interfaces/dom.idl",
'/interfaces/clipboard-apis.idl',
'/interfaces/dom.idl',
].map(fetchText))
.then(([idl, dom]) => doTest(idl, dom));
}, "Test driver");
}, 'Test driver');
</script>

View file

@ -9,55 +9,59 @@ test(() => {
assert_not_equals(navigator.clipboard, undefined);
assert_true(navigator.clipboard instanceof Clipboard);
assert_equals(navigator.clipboard, navigator.clipboard);
}, "navigator.clipboard exists");
}, 'navigator.clipboard exists');
promise_test(async () => {
const blob = new Blob(["hello"], {type: 'text/plain'});
await navigator.clipboard.write([blob]);
}, "navigator.clipboard.write([text/plain Blob]) succeeds");
const blob = new Blob(['hello'], {type: 'text/plain'});
await navigator.clipboard.write({'text/plain': blob});
}, 'navigator.clipboard.write({string : text/plain Blob}) succeeds');
promise_test(async t => {
await promise_rejects(t, new TypeError(),
navigator.clipboard.write());
}, "navigator.clipboard.write() fails (expect [Blob])");
}, 'navigator.clipboard.write() fails (expect {string : Blob})');
promise_test(async t => {
await promise_rejects(t, new TypeError(),
navigator.clipboard.write(null));
}, "navigator.clipboard.write(null) fails (expect [Blob])");
}, 'navigator.clipboard.write(null) fails (expect {string : Blob})');
promise_test(async t => {
await promise_rejects(t, new TypeError(),
navigator.clipboard.write("Bad string"));
}, "navigator.clipboard.write(DOMString) fails (expect [Blob])");
navigator.clipboard.write('Bad string'));
}, 'navigator.clipboard.write(DOMString) fails (expect {string : Blob})');
promise_test(async t => {
const blob = new Blob(['hello'], {type: 'text/plain'});
await promise_rejects(t, 'NotAllowedError',
navigator.clipboard.write(blob));
}, 'navigator.clipboard.write(Blob) fails (expect {string : Blob})');
promise_test(async () => {
await navigator.clipboard.writeText("New clipboard text");
}, "navigator.clipboard.writeText(DOMString) succeeds");
await navigator.clipboard.writeText('New clipboard text');
}, 'navigator.clipboard.writeText(DOMString) succeeds');
promise_test(async t => {
await promise_rejects(t, new TypeError(),
navigator.clipboard.writeText());
}, "navigator.clipboard.writeText() fails (expect DOMString)");
}, 'navigator.clipboard.writeText() fails (expect DOMString)');
promise_test(async () => {
const fetched = await fetch(
'http://localhost:8001/clipboard-apis/resources/greenbox.png');
const image = await fetched.blob();
await navigator.clipboard.write([image]);
}, "navigator.clipboard.write([image/png Blob]) succeeds");
await navigator.clipboard.write({'image/png' : image});
}, 'navigator.clipboard.write({string : image/png Blob}) succeeds');
promise_test(async () => {
const result = await navigator.clipboard.read();
assert_true(result instanceof Array);
assert_true(result[0] instanceof Blob);
assert_equals(typeof result, "object");
}, "navigator.clipboard.read() succeeds");
assert_true(result instanceof Object);
}, 'navigator.clipboard.read() succeeds');
promise_test(async () => {
const result = await navigator.clipboard.readText();
assert_equals(typeof result, "string");
}, "navigator.clipboard.readText() succeeds");
assert_equals(typeof result, 'string');
}, 'navigator.clipboard.readText() succeeds');
</script>

View file

@ -13,19 +13,20 @@ async function loadBlob(fileName) {
}
promise_test(async t => {
const blobText = new Blob(["test text"], {type: 'text/plain'});
const blobText = new Blob(['test text'], {type: 'text/plain'});
const blobImage = await loadBlob('resources/greenbox.png');
assert_equals(blobText.type, "text/plain");
assert_equals(blobImage.type, "image/png");
assert_equals(blobText.type, 'text/plain');
assert_equals(blobImage.type, 'image/png');
await navigator.clipboard.write([blobText, blobImage]);
await navigator.clipboard.write(
{'text/plain' : blobText, 'image/png' : blobImage});
const output = await navigator.clipboard.read();
assert_equals(output.length, 2);
assert_equals(output[0].type, "text/plain");
assert_equals(output[1].type, "image/png");
}, "Verify write and read clipboard (multiple blobs)");
assert_equals(Object.keys(output).length, 2);
assert_equals(output['text/plain'].type, 'text/plain');
assert_equals(output['image/png'].type, 'image/png');
}, 'Verify write and read clipboard (multiple blobs)');
</script>
<p>
Note: This is a manual test because it writes/reads to the shared system

View file

@ -10,19 +10,19 @@ async function readWriteTest(textInput) {
promise_test(async t => {
const blobInput = new Blob([textInput], {type: 'text/plain'});
await navigator.clipboard.write([blobInput]);
await navigator.clipboard.write({'text/plain': blobInput});
const blobsOutput = await navigator.clipboard.read();
assert_equals(blobsOutput.length, 1);
const blobOutput = blobsOutput[0];
assert_equals(blobOutput.type, "text/plain");
assert_equals(Object.keys(blobsOutput).length, 1);
const blobOutput = blobsOutput['text/plain'];
assert_equals(blobOutput.type, 'text/plain');
const textOutput = await (new Response(blobOutput)).text();
assert_equals(textOutput, textInput);
}, "Verify write and read clipboard given text: " + textInput);
}, 'Verify write and read clipboard given text: ' + textInput);
}
readWriteTest("Clipboard write ([text/plain Blob]) -> read ([text/plain Blob]) test");
readWriteTest("non-Latin1 text encoding test データ");
readWriteTest('Clipboard write ([text/plain Blob]) -> read ([text/plain Blob]) test');
readWriteTest('non-Latin1 text encoding test データ');
</script>
<p>
Note: This is a manual test because it writes/reads to the shared system

View file

@ -8,15 +8,15 @@ async function readWriteTest(textInput) {
promise_test(async t => {
const blobInput = new Blob([textInput], {type: 'text/plain'});
await navigator.clipboard.write([blobInput]);
await navigator.clipboard.write({'text/plain': blobInput});
const textOutput = await navigator.clipboard.readText();
assert_equals(textOutput, textInput);
}, "Verify write and read clipboard given text: " + textInput);
}, 'Verify write and read clipboard given text: ' + textInput);
}
readWriteTest("Clipboard write ([text/plain Blob]) -> read text test");
readWriteTest("non-Latin1 text encoding test データ");
readWriteTest('Clipboard write ([text/plain Blob]) -> read text test');
readWriteTest('non-Latin1 text encoding test データ');
</script>
<p>
Note: This is a manual test because it writes/reads to the shared system

View file

@ -1,26 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>
Async Clipboard write duplicate mime type test
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
promise_test(async t => {
const blobText = new Blob(["test text"], {type: 'text/plain'});
const blobText2 = new Blob(["test text"], {type: 'text/plain'});
assert_equals(blobText.type, "text/plain");
assert_equals(blobText2.type, "text/plain");
await promise_rejects(t, 'NotAllowedError',
navigator.clipboard.write([blobText, blobText2]));
}, "Verify write and read clipboard (multiple blobs)");
</script>
<p>
Note: This is a manual test because it writes/reads to the shared system
clipboard and thus cannot be run async with other tests that might interact
with the clipboard.
</p>

View file

@ -9,11 +9,11 @@
<p>
<p>The bottom image should display the same image as the top image.</p>
<p>Original Image:</p>
<image id='image-to-copy' width='20' height='20'
<image id="image-to-copy" width="20" height="20"
src="resources/greenbox.png"></image>
<p>Image after copy/paste:</p>
<image id='image-on-clipboard'></image>
<canvas id='canvas' width='20' height='20'></canvas>
<image id="image-on-clipboard"></image>
<canvas id="canvas" width="20" height="20"></canvas>
</p>
<script>
@ -39,12 +39,12 @@ async function loadBlob(fileName) {
promise_test(async t => {
const blobInput = await loadBlob('resources/greenbox.png');
assert_equals(blobInput.type, "image/png");
await navigator.clipboard.write([blobInput]);
assert_equals(blobInput.type, 'image/png');
await navigator.clipboard.write({'image/png' : blobInput});
const blobsOutput = await navigator.clipboard.read();
assert_equals(blobsOutput.length, 1);
const blobOutput = blobsOutput[0];
assert_equals(blobOutput.type, "image/png");
assert_equals(Object.keys(blobsOutput).length, 1);
const blobOutput = blobsOutput['image/png'];
assert_equals(blobOutput.type, 'image/png');
document.getElementById('image-on-clipboard').src =
window.URL.createObjectURL(blobOutput);
@ -53,7 +53,7 @@ promise_test(async t => {
const comparableOutput = await getBitmapString(blobOutput);
assert_equals(comparableOutput, comparableInput);
}, "Verify write and read clipboard ([image/png Blob])");
}, 'Verify write and read clipboard ([image/png Blob])');
</script>
<p>
Note: This is a manual test because it writes/reads to the shared system

View file

@ -8,17 +8,17 @@ async function readWriteTest(textInput) {
promise_test(async t => {
await navigator.clipboard.writeText(textInput);
const blobsOutput = await navigator.clipboard.read();
assert_equals(blobsOutput.length, 1);
const blobOutput = blobsOutput[0];
assert_equals(blobOutput.type, "text/plain");
assert_equals(Object.keys(blobsOutput).length, 1);
const blobOutput = blobsOutput['text/plain'];
assert_equals(blobOutput.type, 'text/plain');
const textOutput = await (new Response(blobOutput)).text();
assert_equals(textOutput, textInput);
}, "Verify write and read clipboard given text: " + textInput);
}, 'Verify write and read clipboard given text: ' + textInput);
}
readWriteTest("Clipboard write text -> read ([text/plain Blob]) test");
readWriteTest("non-Latin1 text encoding test データ");
readWriteTest('Clipboard write text -> read ([text/plain Blob]) test');
readWriteTest('non-Latin1 text encoding test データ');
</script>
<p>
Note: This is a manual test because it writes/reads to the shared system

View file

@ -10,11 +10,11 @@ async function readWriteTest(textInput) {
const textOutput = await navigator.clipboard.readText();
assert_equals(textOutput, textInput);
}, "Verify write and read clipboard given text: " + textInput);
}, 'Verify write and read clipboard given text: ' + textInput);
}
readWriteTest("Clipboard write text -> read text test");
readWriteTest("non-Latin1 text encoding test データ");
readWriteTest('Clipboard write text -> read text test');
readWriteTest('non-Latin1 text encoding test データ');
</script>
<p>
Note: This is a manual test because it writes/reads to the shared system

View file

@ -11,9 +11,9 @@ async_test(t => {
document.oncopy = t.step_func_done(event => {
// Nothing can be asserted about the event target until
// https://github.com/w3c/clipboard-apis/issues/70 is resolved.
// assert_equals(event.target, document.body, "event.target");
assert_true(event.isTrusted, "event.isTrusted");
assert_true(event.composed, "event.composed");
// assert_equals(event.target, document.body, 'event.target');
assert_true(event.isTrusted, 'event.isTrusted');
assert_true(event.composed, 'event.composed');
});
});
</script>

View file

@ -11,9 +11,9 @@ async_test(t => {
document.oncut = t.step_func_done(event => {
// Nothing can be asserted about the event target until
// https://github.com/w3c/clipboard-apis/issues/70 is resolved.
// assert_equals(event.target, document.body, "event.target");
assert_true(event.isTrusted, "event.isTrusted");
assert_true(event.composed, "event.composed");
// assert_equals(event.target, document.body, 'event.target');
assert_true(event.isTrusted, 'event.isTrusted');
assert_true(event.composed, 'event.composed');
});
});
</script>

View file

@ -9,13 +9,13 @@
<script>
setup({explicit_timeout: true});
async_test(t => {
getSelection().selectAllChildren(document.querySelector("p"));
getSelection().selectAllChildren(document.querySelector('p'));
document.onpaste = t.step_func_done(event => {
// Nothing can be asserted about the event target until
// https://github.com/w3c/clipboard-apis/issues/70 is resolved.
// assert_equals(event.target, document.body, "event.target");
assert_true(event.isTrusted, "event.isTrusted");
assert_true(event.composed, "event.composed");
// assert_equals(event.target, document.body, 'event.target');
assert_true(event.isTrusted, 'event.isTrusted');
assert_true(event.composed, 'event.composed');
});
});
</script>