async-write-readText.https.html (1264B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <title> 4 Async Clipboard write ([text/plain ClipboardItem]) -> readText tests 5 </title> 6 <link rel="help" href="https://w3c.github.io/clipboard-apis/#async-clipboard-api"> 7 <body>Body needed for test_driver.click()</body> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src="/resources/testdriver.js"></script> 11 <script src="/resources/testdriver-vendor.js"></script> 12 <script src="../resources/user-activation.js"></script> 13 <script> 14 async function readWriteTest(textInput) { 15 promise_test(async t => { 16 await tryGrantReadPermission(); 17 await tryGrantWritePermission(); 18 19 const blobInput = new Blob([textInput], {type: 'text/plain'}); 20 const clipboardItem = new ClipboardItem({'text/plain': blobInput}); 21 22 await waitForUserActivation(); 23 await navigator.clipboard.write([clipboardItem]); 24 await waitForUserActivation(); 25 const textOutput = await navigator.clipboard.readText(); 26 27 assert_equals(textOutput, textInput); 28 }, 'Verify write and read clipboard given text: ' + textInput); 29 } 30 31 readWriteTest('Clipboard write ([text/plain ClipboardItem) -> read text test'); 32 readWriteTest('non-Latin1 text encoding test データ'); 33 </script>