Bug 1638481 [wpt PR 23648] - Clipboard API Tests: Await set_permission to deflake tests., a=testonly
authorDarwin Huang <huangdarwin@chromium.org>
Tue, 26 May 2020 02:46:23 +0000
changeset 532369 b5c451767c9508fb8cacb99b9a821aa2c480ab8a
parent 532368 9cb196a05a658779f433b0a0d8a21da56b611324
child 532370 9a125d552a9f1f198ca410040eca4e8918717392
push id37455
push userapavel@mozilla.com
push dateWed, 27 May 2020 21:33:21 +0000
treeherdermozilla-central@50d550c87f07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1638481, 23648, 2065346, 2200278, 1083268, 1082747, 2204838, 769578
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1638481 [wpt PR 23648] - Clipboard API Tests: Await set_permission to deflake tests., a=testonly Automatic update from web-platform-tests Clipboard API Tests: Await set_permission to deflake tests. await set_permission, which is an async function. Somehow, this was missed in https://crrev.com/c/2065346 and https://crrev.com/c/2200278, causing some of these tests to flake (1/10 times). Bug: 1083268, 1082747 Change-Id: Iedf7e63a02d200c76df0aaa431980493c6a35e61 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2204838 Auto-Submit: Darwin Huang <huangdarwin@chromium.org> Commit-Queue: Victor Costan <pwnall@chromium.org> Reviewed-by: Victor Costan <pwnall@chromium.org> Cr-Commit-Position: refs/heads/master@{#769578} -- wpt-commits: 9d125e099c58a27e70a2f669c5308e98667d38f9 wpt-pr: 23648
testing/web-platform/tests/clipboard-apis/async-write-blobs-read-blobs.https.html
testing/web-platform/tests/clipboard-apis/async-write-image-read-image.https.html
testing/web-platform/tests/clipboard-apis/detached-iframe/read-on-detaching-iframe.https.html
testing/web-platform/tests/clipboard-apis/detached-iframe/write-on-detaching-iframe.https.html
testing/web-platform/tests/clipboard-apis/detached-iframe/write-read-on-detached-iframe.https.html
testing/web-platform/tests/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe.https.html
testing/web-platform/tests/clipboard-apis/permissions/readText-denied.https.html
testing/web-platform/tests/clipboard-apis/permissions/readText-granted.https.html
testing/web-platform/tests/clipboard-apis/permissions/writeText-denied.https.html
testing/web-platform/tests/clipboard-apis/permissions/writeText-granted.https.html
testing/web-platform/tests/clipboard-apis/text-write-read/async-write-read.https.html
testing/web-platform/tests/clipboard-apis/text-write-read/async-write-readText.https.html
testing/web-platform/tests/clipboard-apis/text-write-read/async-writeText-read.https.html
testing/web-platform/tests/clipboard-apis/text-write-read/async-writeText-readText.https.html
--- a/testing/web-platform/tests/clipboard-apis/async-write-blobs-read-blobs.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-write-blobs-read-blobs.https.html
@@ -11,18 +11,18 @@
 
 <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');
+  await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+  await 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(
--- a/testing/web-platform/tests/clipboard-apis/async-write-image-read-image.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-write-image-read-image.https.html
@@ -35,18 +35,18 @@ async function getBitmapString(blob) {
 };
 
 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');
+  await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+  await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
 
   const blobInput = await loadBlob('resources/greenbox.png');
 
   assert_equals(blobInput.type, 'image/png');
   const clipboardItemInput = new ClipboardItem({'image/png' : blobInput});
   await navigator.clipboard.write([clipboardItemInput]);
   const clipboardItems = await navigator.clipboard.read();
 
@@ -62,18 +62,18 @@ promise_test(async t => {
 
   const comparableInput = await getBitmapString(blobInput);
   const comparableOutput = await getBitmapString(blobOutput);
 
   assert_equals(comparableOutput, comparableInput);
 }, 'Verify write and read clipboard [image/png Blob]');
 
 promise_test(async t => {
-  test_driver.set_permission({name: 'clipboard-read'}, 'granted');
-  test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+  await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+  await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
 
   const invalidPngBlob = new Blob(['this text is not a valid png image'],
       {type: 'image/png'});
   const clipboardItemInput = new ClipboardItem({'image/png' : invalidPngBlob});
   await promise_rejects_dom(t, 'DataError',
       navigator.clipboard.write([clipboardItemInput]));
 }, 'Verify write error on malformed data [image/png ClipboardItem]');
 </script>
--- a/testing/web-platform/tests/clipboard-apis/detached-iframe/read-on-detaching-iframe.https.html
+++ b/testing/web-platform/tests/clipboard-apis/detached-iframe/read-on-detaching-iframe.https.html
@@ -6,29 +6,29 @@
 <script src="/resources/testharnessreport.js"></script>
 <script src="/resources/testdriver.js"></script>
 <script src="/resources/testdriver-vendor.js"></script>
 <iframe id="iframe"></iframe>
 <script>
 'use strict';
 
 promise_test(async t => {
-  // Note: This tests proper behavior on a detaching iframe. text/plain is
-  // chosen for simplicity, and the test should fail the same way no matter what
-  // the input type is.
-  test_driver.set_permission({name: 'clipboard-read'}, 'granted');
-  test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+  // This tests proper behavior on a detaching iframe. text/plain is chosen for
+  // simplicity, and the test should fail the same way no matter what the input
+  // type is.
+  await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+  await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
 
   const iframe = document.getElementById('iframe');
   const iframeClipboard = iframe.contentWindow.navigator.clipboard;
   const blobInput = new Blob(['test string'], {type: 'text/plain'});
   const clipboardItemInput = new ClipboardItem({'text/plain': blobInput});
   // Clipboard API must only be available in focused documents.
   // reference: https://www.w3.org/TR/clipboard-apis/#privacy-async
   iframe.focus();
 
   // An iframe detaching while writing to the clipboard should fail, but not
-  // crash. Note the lack of await here, meaning that the iframe will detach
-  // while the read operation is running.
+  // crash. The lack of await here means that the iframe will detach while the
+  // write operation is running.
   iframeClipboard.read([clipboardItemInput]);
   iframe.parentNode.removeChild(iframe);
 }, 'Verify read fails on detaching iframe');
 </script>
--- a/testing/web-platform/tests/clipboard-apis/detached-iframe/write-on-detaching-iframe.https.html
+++ b/testing/web-platform/tests/clipboard-apis/detached-iframe/write-on-detaching-iframe.https.html
@@ -6,29 +6,29 @@
 <script src="/resources/testharnessreport.js"></script>
 <script src="/resources/testdriver.js"></script>
 <script src="/resources/testdriver-vendor.js"></script>
 <iframe id="iframe"></iframe>
 <script>
 'use strict';
 
 promise_test(async t => {
-  // Note: This tests proper behavior on a detaching iframe. text/plain is
-  // chosen for simplicity, and the test should fail the same way no matter what
-  // the input type is.
-  test_driver.set_permission({name: 'clipboard-read'}, 'granted');
-  test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+  // This tests proper behavior on a detaching iframe. text/plain is chosen for
+  // simplicity, and the test should fail the same way no matter what the input
+  // type is.
+  await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+  await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
 
   const iframe = document.getElementById('iframe');
   const iframeClipboard = iframe.contentWindow.navigator.clipboard;
   const blobInput = new Blob(['test string'], {type: 'text/plain'});
   const clipboardItemInput = new ClipboardItem({'text/plain': blobInput});
   // Clipboard API must only be available in focused documents.
   // reference: https://www.w3.org/TR/clipboard-apis/#privacy-async
   iframe.focus();
 
   // An iframe detaching while writing to the clipboard should fail, but not
-  // crash. Note the lack of await here, meaning that the iframe will detach
-  // while the write operation is running.
+  // crash. The lack of await here means that the iframe will detach while the
+  // write operation is running.
   iframeClipboard.write([clipboardItemInput]);
   iframe.parentNode.removeChild(iframe);
 }, 'Verify write fails on detaching iframe');
 </script>
--- a/testing/web-platform/tests/clipboard-apis/detached-iframe/write-read-on-detached-iframe.https.html
+++ b/testing/web-platform/tests/clipboard-apis/detached-iframe/write-read-on-detached-iframe.https.html
@@ -6,21 +6,21 @@
 <script src="/resources/testharnessreport.js"></script>
 <script src="/resources/testdriver.js"></script>
 <script src="/resources/testdriver-vendor.js"></script>
 <iframe id="iframe"></iframe>
 <script>
 'use strict';
 
 promise_test(async t => {
-  // Note: This tests proper detached iframe behavior. text/plain is chosen for
+  // This tests proper behavior on a detaching iframe. text/plain is chosen for
   // simplicity, and the test should fail the same way no matter what the input
   // type is.
-  test_driver.set_permission({name: 'clipboard-read'}, 'granted');
-  test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+  await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+  await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
 
   const iframe = document.getElementById('iframe');
   const iframeClipboard = iframe.contentWindow.navigator.clipboard;
   const blobInput = new Blob(['test string'], {type: 'text/plain'});
   const clipboardItemInput = new ClipboardItem({'text/plain': blobInput});
   // Clipboard API must only be available in focused documents.
   // reference: https://www.w3.org/TR/clipboard-apis/#privacy-async
   iframe.focus();
--- a/testing/web-platform/tests/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe.https.html
+++ b/testing/web-platform/tests/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe.https.html
@@ -6,18 +6,18 @@
 <script src="/resources/testharnessreport.js"></script>
 <script src="/resources/testdriver.js"></script>
 <script src="/resources/testdriver-vendor.js"></script>
 <iframe id="iframe"></iframe>
 <script>
 'use strict';
 
 promise_test(async t => {
-  test_driver.set_permission({name: 'clipboard-read'}, 'granted');
-  test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+  await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+  await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
 
   const iframe = document.getElementById('iframe');
   // Clipboard API must only be available in focused documents.
   // reference: https://www.w3.org/TR/clipboard-apis/#privacy-async
   iframe.focus();
   const iframeClipboard = iframe.contentWindow.navigator.clipboard;
 
   // Writing and reading should succeed on same-origin iframes.
--- a/testing/web-platform/tests/clipboard-apis/permissions/readText-denied.https.html
+++ b/testing/web-platform/tests/clipboard-apis/permissions/readText-denied.https.html
@@ -5,13 +5,13 @@
 <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>
 'use strict';
 
 promise_test(async t => {
-  test_driver.set_permission({name: 'clipboard-read'}, 'denied');
+  await test_driver.set_permission({name: 'clipboard-read'}, 'denied');
   await promise_rejects_dom(t,
       'NotAllowedError', navigator.clipboard.readText());
 }, 'navigator.clipboard.readText() fails when permission denied');
 </script>
--- a/testing/web-platform/tests/clipboard-apis/permissions/readText-granted.https.html
+++ b/testing/web-platform/tests/clipboard-apis/permissions/readText-granted.https.html
@@ -5,12 +5,12 @@
 <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>
 'use strict';
 
 promise_test(async () => {
-  test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+  await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
   await navigator.clipboard.readText();
 }, 'navigator.clipboard.readText() succeeds when permission granted');
 </script>
\ No newline at end of file
--- a/testing/web-platform/tests/clipboard-apis/permissions/writeText-denied.https.html
+++ b/testing/web-platform/tests/clipboard-apis/permissions/writeText-denied.https.html
@@ -5,13 +5,13 @@
 <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>
 'use strict';
 
 promise_test(async t => {
-  test_driver.set_permission({name: 'clipboard-write'}, 'denied');
+  await test_driver.set_permission({name: 'clipboard-write'}, 'denied');
   await promise_rejects_dom(t, 'NotAllowedError',
       navigator.clipboard.writeText('xyz'));
 }, 'navigator.clipboard.writeText() fails when permission denied');
 </script>
--- a/testing/web-platform/tests/clipboard-apis/permissions/writeText-granted.https.html
+++ b/testing/web-platform/tests/clipboard-apis/permissions/writeText-granted.https.html
@@ -5,12 +5,12 @@
 <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>
 'use strict';
 
 promise_test(async () => {
-  test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+  await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
   await navigator.clipboard.writeText('xyz');
 }, 'navigator.clipboard.writeText() succeeds when permission granted');
 </script>
\ No newline at end of file
--- a/testing/web-platform/tests/clipboard-apis/text-write-read/async-write-read.https.html
+++ b/testing/web-platform/tests/clipboard-apis/text-write-read/async-write-read.https.html
@@ -7,18 +7,18 @@
 <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 readWriteTest(textInput) {
   promise_test(async t => {
-    test_driver.set_permission({name: 'clipboard-read'}, 'granted');
-    test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+    await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+    await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
 
     const blobInput = new Blob([textInput], {type: 'text/plain'});
     const clipboardItemInput = new ClipboardItem({'text/plain': blobInput});
 
     await navigator.clipboard.write([clipboardItemInput]);
     const clipboardItems = await navigator.clipboard.read();
     assert_equals(clipboardItems.length, 1);
     const clipboardItemOutput = clipboardItems[0];
--- a/testing/web-platform/tests/clipboard-apis/text-write-read/async-write-readText.https.html
+++ b/testing/web-platform/tests/clipboard-apis/text-write-read/async-write-readText.https.html
@@ -6,18 +6,18 @@
 <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 readWriteTest(textInput) {
   promise_test(async t => {
-    test_driver.set_permission({name: 'clipboard-read'}, 'granted');
-    test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+    await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+    await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
 
     const blobInput = new Blob([textInput], {type: 'text/plain'});
     const clipboardItem = new ClipboardItem({'text/plain': blobInput});
 
     await navigator.clipboard.write([clipboardItem]);
     const textOutput = await navigator.clipboard.readText();
 
     assert_equals(textOutput, textInput);
--- a/testing/web-platform/tests/clipboard-apis/text-write-read/async-writeText-read.https.html
+++ b/testing/web-platform/tests/clipboard-apis/text-write-read/async-writeText-read.https.html
@@ -6,18 +6,18 @@
 <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 readWriteTest(textInput) {
   promise_test(async t => {
-    test_driver.set_permission({name: 'clipboard-read'}, 'granted');
-    test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+    await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+    await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
 
     await navigator.clipboard.writeText(textInput);
     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, 1);
     const blobOutput = await clipboardItem.getType('text/plain');
--- a/testing/web-platform/tests/clipboard-apis/text-write-read/async-writeText-readText.https.html
+++ b/testing/web-platform/tests/clipboard-apis/text-write-read/async-writeText-readText.https.html
@@ -4,18 +4,18 @@
 <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 readWriteTest(textInput) {
   promise_test(async t => {
-    test_driver.set_permission({name: 'clipboard-read'}, 'granted');
-    test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+    await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+    await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
 
     await navigator.clipboard.writeText(textInput);
     const textOutput = await navigator.clipboard.readText();
 
     assert_equals(textOutput, textInput);
   }, 'Verify write and read clipboard given text: ' + textInput);
 }