aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/clipboard-apis/async-write-blobs-read-blobs.https.html
diff options
context:
space:
mode:
authorWPT Sync Bot <josh+wptsync@joshmatthews.net>2020-05-15 08:19:23 +0000
committerWPT Sync Bot <josh+wptsync@joshmatthews.net>2020-05-15 10:39:22 +0000
commitdb12fbb0be4e0c689070a27221f27de6cb447618 (patch)
tree04d0ca1bbcc8476a43e7c75b7d24e436b2bc186f /tests/wpt/web-platform-tests/clipboard-apis/async-write-blobs-read-blobs.https.html
parente1cc38bea8a701108b6f2fa809f341769613b55f (diff)
downloadservo-db12fbb0be4e0c689070a27221f27de6cb447618.tar.gz
servo-db12fbb0be4e0c689070a27221f27de6cb447618.zip
Update web-platform-tests to revision 73bd4355b891665829c66e1b83d64bcc29197a16
Diffstat (limited to 'tests/wpt/web-platform-tests/clipboard-apis/async-write-blobs-read-blobs.https.html')
-rw-r--r--tests/wpt/web-platform-tests/clipboard-apis/async-write-blobs-read-blobs.https.html44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/wpt/web-platform-tests/clipboard-apis/async-write-blobs-read-blobs.https.html b/tests/wpt/web-platform-tests/clipboard-apis/async-write-blobs-read-blobs.https.html
new file mode 100644
index 00000000000..f9bf38d5d58
--- /dev/null
+++ b/tests/wpt/web-platform-tests/clipboard-apis/async-write-blobs-read-blobs.https.html
@@ -0,0 +1,44 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>
+ Async Clipboard write blobs -> read blobs tests
+</title>
+<link rel="help" href="https://w3c.github.io/clipboard-apis/#async-clipboard-api">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+
+<script>
+async function loadBlob(fileName) {
+ const fetched = await fetch(fileName);
+ return await fetched.blob();
+}
+
+promise_test(async t => {
+ test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+ test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+
+ 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');
+
+ const clipboardItemInput = new ClipboardItem(
+ {'text/plain' : blobText, 'image/png' : blobImage});
+
+ await navigator.clipboard.write([clipboardItemInput]);
+ const clipboardItems = await navigator.clipboard.read();
+
+ assert_equals(clipboardItems.length, 1);
+ const clipboardItem = clipboardItems[0];
+ assert_true(clipboardItem instanceof ClipboardItem);
+
+ assert_equals(clipboardItem.types.length, 2);
+ const blobTextOutput = await clipboardItem.getType('text/plain');
+ const blobImageOutput = await clipboardItem.getType('image/png');
+ assert_equals(blobTextOutput.type, 'text/plain');
+ assert_equals(blobImageOutput.type, 'image/png');
+}, 'Verify write and read clipboard (multiple types)');
+</script>