From 957c333350503196cc1bf72cc9f6d8b4fdfc2b2c Mon Sep 17 00:00:00 2001 From: Darwin Huang Date: Sun, 3 May 2020 17:51:58 -0700 Subject: [PATCH] Clipboard API Tests: Automate Web Platform Tests Since https://github.com/web-platform-tests/wpt/pull/20461 and https://github.com/web-platform-tests/wpt/issues/5671 were fixed, it now becomes possible to automate some Web Platform Tests, and have them run on all browsers automatically. Clipboard API tests previously were duplicated in non-WPT in order to automate them via PermissionsHelper and detect regressions. This allows us to shed a lot of duplicate tests, as well as a difficult-to-remember process of remembering to update both test suites when changes were made. Bug: 1076691 Change-Id: Ibdfdf37e75da68d7a4b1e2ba986e4198b73230ac Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2065346 Commit-Queue: Victor Costan Reviewed-by: Victor Costan Cr-Commit-Position: refs/heads/master@{#764967} --- ...> async-write-blobs-read-blobs.https.html} | 10 +++++----- ...> async-write-image-read-image.https.html} | 18 +++++++++-------- ...ml => read-on-detaching-iframe.https.html} | 14 ++++++------- ...l => write-on-detaching-iframe.https.html} | 14 ++++++------- ... write-read-on-detached-iframe.https.html} | 18 ++++++++--------- ...xt-readText-on-detached-iframe.https.html} | 20 +++++++++---------- ...https.html => async-write-read.https.html} | 10 +++++----- ...s.html => async-write-readText.https.html} | 10 +++++----- ...s.html => async-writeText-read.https.html} | 10 +++++----- ...ml => async-writeText-readText.https.html} | 10 +++++----- 10 files changed, 68 insertions(+), 66 deletions(-) rename clipboard-apis/{async-write-blobs-read-blobs-manual.https.html => async-write-blobs-read-blobs.https.html} (85%) rename clipboard-apis/{async-write-image-read-image-manual.https.html => async-write-image-read-image.https.html} (85%) rename clipboard-apis/detached-iframe/{read-on-detaching-iframe-manual.https.html => read-on-detaching-iframe.https.html} (77%) rename clipboard-apis/detached-iframe/{write-on-detaching-iframe-manual.https.html => write-on-detaching-iframe.https.html} (77%) rename clipboard-apis/detached-iframe/{write-read-on-detached-iframe-manual.https.html => write-read-on-detached-iframe.https.html} (74%) rename clipboard-apis/detached-iframe/{writeText-readText-on-detached-iframe-manual.https.html => writeText-readText-on-detached-iframe.https.html} (68%) rename clipboard-apis/text-write-read/{async-write-read-manual.https.html => async-write-read.https.html} (84%) rename clipboard-apis/text-write-read/{async-write-readText-manual.https.html => async-write-readText.https.html} (78%) rename clipboard-apis/text-write-read/{async-writeText-read-manual.https.html => async-writeText-read.https.html} (82%) rename clipboard-apis/text-write-read/{async-writeText-readText-manual.https.html => async-writeText-readText.https.html} (74%) diff --git a/clipboard-apis/async-write-blobs-read-blobs-manual.https.html b/clipboard-apis/async-write-blobs-read-blobs.https.html similarity index 85% rename from clipboard-apis/async-write-blobs-read-blobs-manual.https.html rename to clipboard-apis/async-write-blobs-read-blobs.https.html index f53d7f9c36e2b2..f9bf38d5d581db 100644 --- a/clipboard-apis/async-write-blobs-read-blobs-manual.https.html +++ b/clipboard-apis/async-write-blobs-read-blobs.https.html @@ -6,6 +6,8 @@ + + -

- 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. -

diff --git a/clipboard-apis/async-write-image-read-image-manual.https.html b/clipboard-apis/async-write-image-read-image.https.html similarity index 85% rename from clipboard-apis/async-write-image-read-image-manual.https.html rename to clipboard-apis/async-write-image-read-image.https.html index 71d14984953974..881b8ababb2588 100644 --- a/clipboard-apis/async-write-image-read-image-manual.https.html +++ b/clipboard-apis/async-write-image-read-image.https.html @@ -7,7 +7,8 @@ - + +

The bottom image should display the same image as the top image.

Original Image:

@@ -39,6 +40,9 @@ } promise_test(async t => { + test_driver.set_permission({name: 'clipboard-read'}, 'granted'); + test_driver.set_permission({name: 'clipboard-write'}, 'granted'); + const blobInput = await loadBlob('resources/greenbox.png'); assert_equals(blobInput.type, 'image/png'); @@ -63,15 +67,13 @@ }, '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'); + const invalidPngBlob = new Blob(['this text is not a valid png image'], - {type: "image/png"}); + {type: 'image/png'}); const clipboardItemInput = new ClipboardItem({'image/png' : invalidPngBlob}); - await promise_rejects_dom(t, "DataError", + await promise_rejects_dom(t, 'DataError', navigator.clipboard.write([clipboardItemInput])); }, 'Verify write error on malformed data [image/png ClipboardItem]'); -

- 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. -

diff --git a/clipboard-apis/detached-iframe/read-on-detaching-iframe-manual.https.html b/clipboard-apis/detached-iframe/read-on-detaching-iframe.https.html similarity index 77% rename from clipboard-apis/detached-iframe/read-on-detaching-iframe-manual.https.html rename to clipboard-apis/detached-iframe/read-on-detaching-iframe.https.html index 8361ceff125c69..8022f0e269c4f2 100644 --- a/clipboard-apis/detached-iframe/read-on-detaching-iframe-manual.https.html +++ b/clipboard-apis/detached-iframe/read-on-detaching-iframe.https.html @@ -4,6 +4,8 @@ + + -

- 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. -

diff --git a/clipboard-apis/detached-iframe/write-on-detaching-iframe-manual.https.html b/clipboard-apis/detached-iframe/write-on-detaching-iframe.https.html similarity index 77% rename from clipboard-apis/detached-iframe/write-on-detaching-iframe-manual.https.html rename to clipboard-apis/detached-iframe/write-on-detaching-iframe.https.html index 4a3dbd7dc327fc..0ed1098bcad037 100644 --- a/clipboard-apis/detached-iframe/write-on-detaching-iframe-manual.https.html +++ b/clipboard-apis/detached-iframe/write-on-detaching-iframe.https.html @@ -4,6 +4,8 @@ + + -

- 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. -

diff --git a/clipboard-apis/detached-iframe/write-read-on-detached-iframe-manual.https.html b/clipboard-apis/detached-iframe/write-read-on-detached-iframe.https.html similarity index 74% rename from clipboard-apis/detached-iframe/write-read-on-detached-iframe-manual.https.html rename to clipboard-apis/detached-iframe/write-read-on-detached-iframe.https.html index af12ff8d880df8..1859c4bd11b445 100644 --- a/clipboard-apis/detached-iframe/write-read-on-detached-iframe-manual.https.html +++ b/clipboard-apis/detached-iframe/write-read-on-detached-iframe.https.html @@ -4,6 +4,8 @@ + + -

- 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. -

diff --git a/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe-manual.https.html b/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe.https.html similarity index 68% rename from clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe-manual.https.html rename to clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe.https.html index c2d8be1ace2528..40854ccc7a3150 100644 --- a/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe-manual.https.html +++ b/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe.https.html @@ -4,11 +4,16 @@ + + -

- 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. -

diff --git a/clipboard-apis/text-write-read/async-write-read-manual.https.html b/clipboard-apis/text-write-read/async-write-read.https.html similarity index 84% rename from clipboard-apis/text-write-read/async-write-read-manual.https.html rename to clipboard-apis/text-write-read/async-write-read.https.html index 14488b1e716660..1d170f2fa4a7a4 100644 --- a/clipboard-apis/text-write-read/async-write-read-manual.https.html +++ b/clipboard-apis/text-write-read/async-write-read.https.html @@ -7,9 +7,14 @@ + + -

- 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. -

diff --git a/clipboard-apis/text-write-read/async-write-readText-manual.https.html b/clipboard-apis/text-write-read/async-write-readText.https.html similarity index 78% rename from clipboard-apis/text-write-read/async-write-readText-manual.https.html rename to clipboard-apis/text-write-read/async-write-readText.https.html index c76df06a8b0216..3fe05a53742add 100644 --- a/clipboard-apis/text-write-read/async-write-readText-manual.https.html +++ b/clipboard-apis/text-write-read/async-write-readText.https.html @@ -6,9 +6,14 @@ + + -

- 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. -

diff --git a/clipboard-apis/text-write-read/async-writeText-read-manual.https.html b/clipboard-apis/text-write-read/async-writeText-read.https.html similarity index 82% rename from clipboard-apis/text-write-read/async-writeText-read-manual.https.html rename to clipboard-apis/text-write-read/async-writeText-read.https.html index e74726ec5e7f3d..6745d7cdb67ba9 100644 --- a/clipboard-apis/text-write-read/async-writeText-read-manual.https.html +++ b/clipboard-apis/text-write-read/async-writeText-read.https.html @@ -6,9 +6,14 @@ + + -

- 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. -

diff --git a/clipboard-apis/text-write-read/async-writeText-readText-manual.https.html b/clipboard-apis/text-write-read/async-writeText-readText.https.html similarity index 74% rename from clipboard-apis/text-write-read/async-writeText-readText-manual.https.html rename to clipboard-apis/text-write-read/async-writeText-readText.https.html index d2c43f0b6f20ad..f9fbdff879c18d 100644 --- a/clipboard-apis/text-write-read/async-writeText-readText-manual.https.html +++ b/clipboard-apis/text-write-read/async-writeText-readText.https.html @@ -4,9 +4,14 @@ + + -

- 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. -