summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/clipboard-apis
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/clipboard-apis')
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-custom-formats-write-fail.tentative.https.html16
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-custom-formats-write-read-web-prefix.tentative.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-custom-formats-write-read-without-web-prefix.tentative.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-custom-formats-write-read.tentative.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-html-script-removal.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-basics.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-read-resource-load.https.html2
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html2
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-write-multiple.tentative.https.sub.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-promise-write-blobs-read-blobs.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-unsanitized-html-formats-write-read.tentative.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-unsanitized-plaintext-formats-write-read.tentative.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-unsanitized-standard-html-read-fail.tentative.https.html10
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-write-blobs-read-blobs.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-write-html-read-html.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/async-write-image-read-image.https.html8
-rw-r--r--testing/web-platform/tests/clipboard-apis/detached-iframe/read-on-detaching-iframe.https.html5
-rw-r--r--testing/web-platform/tests/clipboard-apis/detached-iframe/write-on-detaching-iframe.https.html5
-rw-r--r--testing/web-platform/tests/clipboard-apis/detached-iframe/write-read-on-detached-iframe.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-disabled-by-feature-policy.tentative.https.sub.html3
-rw-r--r--testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy.tentative.https.sub.html2
-rw-r--r--testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html2
-rw-r--r--testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-write/clipboard-write-disabled-by-feature-policy.tentative.https.sub.html3
-rw-r--r--testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy.tentative.https.sub.html2
-rw-r--r--testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html2
-rw-r--r--testing/web-platform/tests/clipboard-apis/permissions/readText-denied.https.html2
-rw-r--r--testing/web-platform/tests/clipboard-apis/permissions/readText-granted.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/permissions/writeText-denied.https.html2
-rw-r--r--testing/web-platform/tests/clipboard-apis/permissions/writeText-granted.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/resources/page.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/resources/user-activation.js19
-rw-r--r--testing/web-platform/tests/clipboard-apis/text-write-read/async-write-read.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/text-write-read/async-write-readText.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/text-write-read/async-writeText-read.https.html4
-rw-r--r--testing/web-platform/tests/clipboard-apis/text-write-read/async-writeText-readText.https.html4
36 files changed, 94 insertions, 71 deletions
diff --git a/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-fail.tentative.https.html b/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-fail.tentative.https.html
index 8b1b42ec78..305222a58f 100644
--- a/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-fail.tentative.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-fail.tentative.https.html
@@ -12,7 +12,7 @@
'use strict';
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantWritePermission();
const customFormatArray = [];
const customFormatMap = {};
@@ -28,7 +28,7 @@ promise_test(async t => {
}, 'navigator.clipboard.write() fails for more than 100 custom formats');
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantWritePermission();
const format1 = 'application/x-custom-format-clipboard-test-format-1';
const format2 = 'application/x-custom-format-clipboard-test-format-2';
@@ -42,7 +42,7 @@ promise_test(async t => {
}, 'navigator.clipboard.write() fails for custom formats without web prefix');
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantWritePermission();
const format1 = 'web ';
const format2 = 'web a';
@@ -56,7 +56,7 @@ promise_test(async t => {
}, 'navigator.clipboard.write() fails for custom formats with web prefix, but invalid MIME types');
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantWritePermission();
const format1 = 'web text/plain';
const format2 = 'text/custom';
@@ -69,7 +69,7 @@ promise_test(async t => {
}, 'navigator.clipboard.write() fails for custom format with web prefix, but different Blob type');
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantWritePermission();
const format1 = 'web Text/plain';
const format2 = 'text/plain';
@@ -82,7 +82,7 @@ promise_test(async t => {
}, 'navigator.clipboard.write() fails for custom format with different case than the Blob type');
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantWritePermission();
const format1 = 'web text/plain';
const format2 = 'Text/plain';
@@ -95,7 +95,7 @@ promise_test(async t => {
}, 'navigator.clipboard.write() fails for invalid mime type that is different than the Blob type');
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantWritePermission();
const format1 = 'web Text/plain';
const format2 = 'web text/plain';
@@ -108,7 +108,7 @@ promise_test(async t => {
}, 'navigator.clipboard.write() fails for invalid mime type with web prefix and the Blob type');
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantWritePermission();
const format1 = 'Text/plain';
const format2 = 'text/plain';
diff --git a/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-read-web-prefix.tentative.https.html b/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-read-web-prefix.tentative.https.html
index 9a6e5da6ff..a5ee7c5bf0 100644
--- a/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-read-web-prefix.tentative.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-read-web-prefix.tentative.https.html
@@ -12,8 +12,8 @@
'use strict';
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const format1 = 'web text/plain';
const format2 = 'web text/plain';
diff --git a/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-read-without-web-prefix.tentative.https.html b/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-read-without-web-prefix.tentative.https.html
index 8b9d4de0a1..e20b66b551 100644
--- a/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-read-without-web-prefix.tentative.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-read-without-web-prefix.tentative.https.html
@@ -12,8 +12,8 @@
'use strict';
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const format1 = 'web text/plain';
const format2 = 'text/plain';
diff --git a/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-read.tentative.https.html b/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-read.tentative.https.html
index a005f8c98f..d174df6749 100644
--- a/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-read.tentative.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-custom-formats-write-read.tentative.https.html
@@ -12,8 +12,8 @@
'use strict';
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const format1 = 'web application/x-custom-format-clipboard-test-format-1';
const format2 = 'web application/x-custom-format-clipboard-test-format-2';
const blobInput1 = new Blob(['input data 1'], {type: format1});
diff --git a/testing/web-platform/tests/clipboard-apis/async-html-script-removal.https.html b/testing/web-platform/tests/clipboard-apis/async-html-script-removal.https.html
index 44c11add85..9ec9a37356 100644
--- a/testing/web-platform/tests/clipboard-apis/async-html-script-removal.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-html-script-removal.https.html
@@ -34,8 +34,8 @@ const html_with_script =
const html_without_script =
'<title>Title of the document</title> <p>Hello World</p>';
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const blobInput = new Blob([html_with_script], {type: 'text/html'});
const clipboardItem = new ClipboardItem({'text/html': blobInput});
await waitForUserActivation();
diff --git a/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-basics.https.html b/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-basics.https.html
index 4a11d5ac66..5d6f701bdb 100644
--- a/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-basics.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-basics.https.html
@@ -13,8 +13,8 @@
// Permissions are required in order to invoke navigator.clipboard functions in
// an automated test.
async function getPermissions() {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
await waitForUserActivation();
}
diff --git a/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-read-resource-load.https.html b/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-read-resource-load.https.html
index d1e3019e7f..25a90a2d08 100644
--- a/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-read-resource-load.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-read-resource-load.https.html
@@ -26,7 +26,7 @@ promise_test(async test => {
let loadObserved = false;
const observer = new PerformanceObserver(() => loadObserved = true);
observer.observe({type: 'resource'});
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+ await tryGrantReadPermission();
await test_driver.click(button);
await waitForUserActivation();
diff --git a/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html b/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html
index cc18367534..4f8463cd7c 100644
--- a/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html
@@ -28,7 +28,7 @@ document.oncopy = ev => {
};
promise_test(async test => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+ await tryGrantReadPermission();
await test_driver.click(button);
await waitForUserActivation();
diff --git a/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-write-multiple.tentative.https.sub.html b/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-write-multiple.tentative.https.sub.html
index 73cdd2f049..c310203503 100644
--- a/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-write-multiple.tentative.https.sub.html
+++ b/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-write-multiple.tentative.https.sub.html
@@ -18,8 +18,8 @@
// Permissions are required in order to invoke navigator.clipboard functions in
// an automated test.
async function getPermissions() {
- await test_driver.set_permission({name: "clipboard-read"}, "granted");
- await test_driver.set_permission({name: "clipboard-write"}, "granted");
+ await tryGrantReadPermission();
+ await tryGrantWritePermission()
await waitForUserActivation();
}
diff --git a/testing/web-platform/tests/clipboard-apis/async-promise-write-blobs-read-blobs.https.html b/testing/web-platform/tests/clipboard-apis/async-promise-write-blobs-read-blobs.https.html
index 12184c92e0..6b79893160 100644
--- a/testing/web-platform/tests/clipboard-apis/async-promise-write-blobs-read-blobs.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-promise-write-blobs-read-blobs.https.html
@@ -21,8 +21,8 @@ promise_test(async t => {
const promise1 = new Promise((resolve, reject) => {
resolve(loadBlob('resources/greenbox.png'));
});
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const blobText = new Blob(['test text'], {type: 'text/plain'});
diff --git a/testing/web-platform/tests/clipboard-apis/async-unsanitized-html-formats-write-read.tentative.https.html b/testing/web-platform/tests/clipboard-apis/async-unsanitized-html-formats-write-read.tentative.https.html
index 46e335c804..848900830f 100644
--- a/testing/web-platform/tests/clipboard-apis/async-unsanitized-html-formats-write-read.tentative.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-unsanitized-html-formats-write-read.tentative.https.html
@@ -27,8 +27,8 @@ function reformatHtml(html) {
// Writes a payload with custom content and checks to ensure the correct data
// was written successfully.
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
// Create and write unsanitized version of standard HTML and custom formats.
const format1 = 'text/html';
diff --git a/testing/web-platform/tests/clipboard-apis/async-unsanitized-plaintext-formats-write-read.tentative.https.html b/testing/web-platform/tests/clipboard-apis/async-unsanitized-plaintext-formats-write-read.tentative.https.html
index 1c5638ca0a..dea91b41d7 100644
--- a/testing/web-platform/tests/clipboard-apis/async-unsanitized-plaintext-formats-write-read.tentative.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-unsanitized-plaintext-formats-write-read.tentative.https.html
@@ -14,8 +14,8 @@
// Writes a payload with custom content and checks to ensure the correct data
// was written successfully.
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const dataToWrite = 'Test text.';
const format1 = 'web text/plain';
diff --git a/testing/web-platform/tests/clipboard-apis/async-unsanitized-standard-html-read-fail.tentative.https.html b/testing/web-platform/tests/clipboard-apis/async-unsanitized-standard-html-read-fail.tentative.https.html
index e7ddbb0cdf..f0884d6c20 100644
--- a/testing/web-platform/tests/clipboard-apis/async-unsanitized-standard-html-read-fail.tentative.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-unsanitized-standard-html-read-fail.tentative.https.html
@@ -12,7 +12,7 @@
'use strict';
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+ await tryGrantReadPermission();
await waitForUserActivation();
await promise_rejects_dom(t, 'NotAllowedError',
@@ -20,7 +20,7 @@ promise_test(async t => {
}, 'navigator.clipboard.read() fails for multiple unsanitized formats requested.');
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+ await tryGrantReadPermission();
await waitForUserActivation();
await promise_rejects_dom(t, 'NotAllowedError',
@@ -28,7 +28,7 @@ promise_test(async t => {
}, 'navigator.clipboard.read() fails for unsanitized text/plain requested.');
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+ await tryGrantReadPermission();
await waitForUserActivation();
await promise_rejects_dom(t, 'NotAllowedError',
@@ -36,11 +36,11 @@ promise_test(async t => {
}, 'navigator.clipboard.read() fails for unsanitized image/png requested.');
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+ await tryGrantReadPermission();
await waitForUserActivation();
await promise_rejects_dom(t, 'NotAllowedError',
navigator.clipboard.read({unsanitized: ['image/svg+xml']}));
}, 'navigator.clipboard.read() fails for unsanitized image/svg+xml requested.');
-</script> \ No newline at end of file
+</script>
diff --git 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
index 8bec558b2b..d89640d58a 100644
--- 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
@@ -18,8 +18,8 @@ async function loadBlob(fileName) {
}
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const blobText = new Blob(['test text'], {type: 'text/plain'});
const blobImage = await loadBlob('resources/greenbox.png');
diff --git a/testing/web-platform/tests/clipboard-apis/async-write-html-read-html.https.html b/testing/web-platform/tests/clipboard-apis/async-write-html-read-html.https.html
index ec1817c027..2573916bd6 100644
--- a/testing/web-platform/tests/clipboard-apis/async-write-html-read-html.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-write-html-read-html.https.html
@@ -26,8 +26,8 @@ function reformatHtml(html) {
}
async function readWriteTest(textInput) {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const blobInput = new Blob([textInput], {type: 'text/html'});
const clipboardItem = new ClipboardItem({'text/html': blobInput});
await waitForUserActivation();
diff --git 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
index e10b69d824..a8aa7d457c 100644
--- 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
@@ -42,8 +42,8 @@ async function loadBlob(fileName) {
}
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const blobInput = await loadBlob('resources/greenbox.png');
@@ -71,8 +71,8 @@ promise_test(async t => {
}, 'Verify write and read clipboard [image/png Blob]');
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const invalidPngBlob = new Blob(['this text is not a valid png image'],
{type: 'image/png'});
diff --git 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
index 8e8e015aa0..827c17a9e3 100644
--- 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,6 +6,7 @@
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
+<script src="../resources/user-activation.js"></script>
<iframe id="iframe"></iframe>
<script>
'use strict';
@@ -14,8 +15,8 @@ promise_test(async t => {
// 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');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const iframe = document.getElementById('iframe');
const iframeClipboard = iframe.contentWindow.navigator.clipboard;
diff --git 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
index c6913d9e9f..b3836799df 100644
--- 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,6 +6,7 @@
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
+<script src="../resources/user-activation.js"></script>
<iframe id="iframe"></iframe>
<script>
'use strict';
@@ -14,8 +15,8 @@ promise_test(async t => {
// 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');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const iframe = document.getElementById('iframe');
const iframeClipboard = iframe.contentWindow.navigator.clipboard;
diff --git 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
index b21e6b20bc..155f9d004a 100644
--- 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
@@ -15,8 +15,8 @@ promise_test(async t => {
// 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');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const iframe = document.getElementById('iframe');
const iframeClipboard = iframe.contentWindow.navigator.clipboard;
diff --git 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
index 24fa586fc7..8c6448d5cc 100644
--- 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
@@ -12,8 +12,8 @@
'use strict';
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const iframe = document.getElementById('iframe');
await waitForUserActivation();
diff --git a/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-disabled-by-feature-policy.tentative.https.sub.html b/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-disabled-by-feature-policy.tentative.https.sub.html
index 7af2b8944e..8ca1819df8 100644
--- a/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-disabled-by-feature-policy.tentative.https.sub.html
+++ b/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-disabled-by-feature-policy.tentative.https.sub.html
@@ -5,6 +5,7 @@
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/feature-policy/resources/featurepolicy.js"></script>
+<script src="../../resources/user-activation.js"></script>
<script>
'use strict';
@@ -14,7 +15,7 @@ const cross_origin_src =
'https://{{domains[www]}}:{{ports[https][0]}}' + same_origin_src;
promise_test(async t => {
- await test_driver.set_permission({ name: 'clipboard-read' }, 'granted');
+ await tryGrantReadPermission();
return promise_rejects_dom(t, 'NotAllowedError',
navigator.clipboard.readText('test text'));
}, 'Feature-Policy header clipboard-read "none" disallows the top-level document.');
diff --git a/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy.tentative.https.sub.html b/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy.tentative.https.sub.html
index 552183cc67..c21d6cf0f6 100644
--- a/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy.tentative.https.sub.html
+++ b/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy.tentative.https.sub.html
@@ -15,7 +15,7 @@ const cross_origin_src =
'https://{{domains[www]}}:{{ports[https][0]}}' + same_origin_src;
promise_test(async t => {
- await test_driver.set_permission({ name: 'clipboard-read' }, 'granted');
+ await tryGrantReadPermission();
await waitForUserActivation();
await navigator.clipboard.readText('test text');
}, 'Feature-Policy header clipboard-read "*" allows the top-level document.');
diff --git a/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html b/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html
index 17dc3628a7..79dd6cf891 100644
--- a/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html
+++ b/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html
@@ -15,7 +15,7 @@ const cross_origin_src =
'https://{{domains[www]}}:{{ports[https][0]}}' + same_origin_src;
promise_test(async t => {
- await test_driver.set_permission({ name: 'clipboard-read' }, 'granted');
+ await tryGrantReadPermission();
await waitForUserActivation();
await navigator.clipboard.readText('test text');
}, 'Feature-Policy header clipboard-read "self" allows the top-level document.');
diff --git a/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-write/clipboard-write-disabled-by-feature-policy.tentative.https.sub.html b/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-write/clipboard-write-disabled-by-feature-policy.tentative.https.sub.html
index 5d19d8dd6f..b328debde2 100644
--- a/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-write/clipboard-write-disabled-by-feature-policy.tentative.https.sub.html
+++ b/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-write/clipboard-write-disabled-by-feature-policy.tentative.https.sub.html
@@ -5,6 +5,7 @@
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/feature-policy/resources/featurepolicy.js"></script>
+<script src="../../resources/user-activation.js"></script>
<script>
'use strict';
@@ -14,7 +15,7 @@ const cross_origin_src =
'https://{{domains[www]}}:{{ports[https][0]}}' + same_origin_src;
promise_test(async t => {
- await test_driver.set_permission({ name: 'clipboard-write' }, 'granted');
+ await tryGrantWritePermission();
return promise_rejects_dom(t, 'NotAllowedError',
navigator.clipboard.writeText('test text'));
}, 'Feature-Policy header clipboard-write "none" disallows the top-level document.');
diff --git a/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy.tentative.https.sub.html b/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy.tentative.https.sub.html
index ca97994c61..cb908df65f 100644
--- a/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy.tentative.https.sub.html
+++ b/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy.tentative.https.sub.html
@@ -15,7 +15,7 @@ const cross_origin_src =
'https://{{domains[www]}}:{{ports[https][0]}}' + same_origin_src;
promise_test(async t => {
- await test_driver.set_permission({ name: 'clipboard-write' }, 'granted');
+ await tryGrantWritePermission();
await waitForUserActivation();
await navigator.clipboard.writeText('test text');
}, 'Feature-Policy header clipboard-write "*" allows the top-level document.');
diff --git a/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html b/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html
index 5615a68ac5..532c72545c 100644
--- a/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html
+++ b/testing/web-platform/tests/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html
@@ -15,7 +15,7 @@ const cross_origin_src =
'https://{{domains[www]}}:{{ports[https][0]}}' + same_origin_src;
promise_test(async t => {
- await test_driver.set_permission({ name: 'clipboard-write' }, 'granted');
+ await tryGrantWritePermission();
await waitForUserActivation();
await navigator.clipboard.writeText('test text');
}, 'Feature-Policy header clipboard-write "self" allows the top-level document.');
diff --git a/testing/web-platform/tests/clipboard-apis/permissions/readText-denied.https.html b/testing/web-platform/tests/clipboard-apis/permissions/readText-denied.https.html
index 010f4ba21b..379b0ff18b 100644
--- a/testing/web-platform/tests/clipboard-apis/permissions/readText-denied.https.html
+++ b/testing/web-platform/tests/clipboard-apis/permissions/readText-denied.https.html
@@ -12,7 +12,7 @@
'use strict';
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'denied');
+ await trySetPermission('clipboard-read', 'denied');
await waitForUserActivation();
await promise_rejects_dom(t,
'NotAllowedError', navigator.clipboard.readText());
diff --git a/testing/web-platform/tests/clipboard-apis/permissions/readText-granted.https.html b/testing/web-platform/tests/clipboard-apis/permissions/readText-granted.https.html
index e912bd64a8..0b2d7034df 100644
--- a/testing/web-platform/tests/clipboard-apis/permissions/readText-granted.https.html
+++ b/testing/web-platform/tests/clipboard-apis/permissions/readText-granted.https.html
@@ -12,8 +12,8 @@
'use strict';
promise_test(async () => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
+ await tryGrantReadPermission();
await waitForUserActivation();
await navigator.clipboard.readText();
}, 'navigator.clipboard.readText() succeeds when permission granted');
-</script> \ No newline at end of file
+</script>
diff --git a/testing/web-platform/tests/clipboard-apis/permissions/writeText-denied.https.html b/testing/web-platform/tests/clipboard-apis/permissions/writeText-denied.https.html
index 5fbcab4117..3d6b4397a0 100644
--- a/testing/web-platform/tests/clipboard-apis/permissions/writeText-denied.https.html
+++ b/testing/web-platform/tests/clipboard-apis/permissions/writeText-denied.https.html
@@ -12,7 +12,7 @@
'use strict';
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-write'}, 'denied');
+ await trySetPermission('clipboard-write', 'denied');
await waitForUserActivation();
await promise_rejects_dom(t, 'NotAllowedError',
navigator.clipboard.writeText('xyz'));
diff --git a/testing/web-platform/tests/clipboard-apis/permissions/writeText-granted.https.html b/testing/web-platform/tests/clipboard-apis/permissions/writeText-granted.https.html
index ff347b7add..c0307811dc 100644
--- a/testing/web-platform/tests/clipboard-apis/permissions/writeText-granted.https.html
+++ b/testing/web-platform/tests/clipboard-apis/permissions/writeText-granted.https.html
@@ -12,8 +12,8 @@
'use strict';
promise_test(async () => {
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantWritePermission();
await waitForUserActivation();
await navigator.clipboard.writeText('xyz');
}, 'navigator.clipboard.writeText() succeeds when permission granted');
-</script> \ No newline at end of file
+</script>
diff --git a/testing/web-platform/tests/clipboard-apis/resources/page.html b/testing/web-platform/tests/clipboard-apis/resources/page.html
index 35bde8e501..fc8bd895d1 100644
--- a/testing/web-platform/tests/clipboard-apis/resources/page.html
+++ b/testing/web-platform/tests/clipboard-apis/resources/page.html
@@ -9,8 +9,8 @@
window.addEventListener("message", async (e) => {
if (e.data && e.data[0] == "write") {
test_driver.set_test_context(window.parent);
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
await waitForUserActivation();
await navigator.clipboard.write([
new ClipboardItem({
diff --git a/testing/web-platform/tests/clipboard-apis/resources/user-activation.js b/testing/web-platform/tests/clipboard-apis/resources/user-activation.js
index ed294bb9cb..4535f8c6d7 100644
--- a/testing/web-platform/tests/clipboard-apis/resources/user-activation.js
+++ b/testing/web-platform/tests/clipboard-apis/resources/user-activation.js
@@ -23,3 +23,22 @@ async function waitForUserActivation() {
test_driver.click(document.body);
await clickedPromise;
}
+
+async function trySetPermission(perm, state) {
+ try {
+ await test_driver.set_permission({ name: perm }, state)
+ } catch {
+ // This is expected, as clipboard permissions are not supported by every engine
+ // and also the set_permission. The permission is not required by such engines as
+ // they require user activation instead.
+ }
+}
+
+async function tryGrantReadPermission() {
+ await trySetPermission("clipboard-read", "granted");
+}
+
+async function tryGrantWritePermission() {
+ await trySetPermission("clipboard-write", "granted");
+}
+
diff --git 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
index c46e5d4317..516783edae 100644
--- 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
@@ -14,8 +14,8 @@
<script>
async function readWriteTest(textInput) {
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const blobInput = new Blob([textInput], {type: 'text/plain'});
const clipboardItemInput = new ClipboardItem({'text/plain': blobInput});
diff --git 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
index 66969b1777..ab7b619ac9 100644
--- 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
@@ -13,8 +13,8 @@
<script>
async function readWriteTest(textInput) {
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
const blobInput = new Blob([textInput], {type: 'text/plain'});
const clipboardItem = new ClipboardItem({'text/plain': blobInput});
diff --git 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
index ddf563269a..40f26d4786 100644
--- 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
@@ -13,8 +13,8 @@
<script>
async function readWriteTest(textInput) {
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
await waitForUserActivation();
await navigator.clipboard.writeText(textInput);
diff --git 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
index 0defdf7a70..647a00e050 100644
--- 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
@@ -11,8 +11,8 @@
<script>
async function readWriteTest(textInput) {
promise_test(async t => {
- await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
- await test_driver.set_permission({name: 'clipboard-write'}, 'granted');
+ await tryGrantReadPermission();
+ await tryGrantWritePermission();
await waitForUserActivation();
await navigator.clipboard.writeText(textInput);