diff --git a/remote/marionette/driver.sys.mjs b/remote/marionette/driver.sys.mjs index f4642e756e6a..6b5b1cf082e2 100644 --- a/remote/marionette/driver.sys.mjs +++ b/remote/marionette/driver.sys.mjs @@ -3346,23 +3346,6 @@ GeckoDriver.prototype.setPermission = async function (cmd) { const { descriptor, state, oneRealm = false } = cmd.parameters; const browsingContext = lazy.assert.open(this.getBrowsingContext()); - // XXX: WPT should not have these but currently they do and we pass testing pref to - // pass them, see bug 1875837. - if ( - ["clipboard-read", "clipboard-write"].includes(descriptor.name) && - state === "granted" - ) { - if ( - Services.prefs.getBoolPref("dom.events.testing.asyncClipboard", false) - ) { - // Okay, do nothing. The clipboard module will work without permission. - return; - } - throw new lazy.error.UnsupportedOperationError( - "setPermission: expected dom.events.testing.asyncClipboard to be set" - ); - } - // XXX: We currently depend on camera/microphone tests throwing UnsupportedOperationError, // the fix is ongoing in bug 1609427. if (["camera", "microphone"].includes(descriptor.name)) { diff --git a/testing/web-platform/meta/clipboard-apis/__dir__.ini b/testing/web-platform/meta/clipboard-apis/__dir__.ini index 7d7dc7068a1b..cc1333cccf5e 100644 --- a/testing/web-platform/meta/clipboard-apis/__dir__.ini +++ b/testing/web-platform/meta/clipboard-apis/__dir__.ini @@ -1 +1 @@ -prefs: [dom.events.asyncClipboard.clipboardItem: true, dom.events.asyncClipboard.readText: true, dom.events.testing.asyncClipboard:true, marionette.setpermission.enabled:true] +prefs: [dom.events.asyncClipboard.clipboardItem: true, dom.events.asyncClipboard.readText: true, marionette.setpermission.enabled:true] diff --git a/testing/web-platform/meta/clipboard-apis/async-html-script-removal.https.html.ini b/testing/web-platform/meta/clipboard-apis/async-html-script-removal.https.html.ini index 9aac277f4178..cbbda46d7037 100644 --- a/testing/web-platform/meta/clipboard-apis/async-html-script-removal.https.html.ini +++ b/testing/web-platform/meta/clipboard-apis/async-html-script-removal.https.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails on Android without the testing pref, see bug 1888179 +prefs: [dom.events.testing.asyncClipboard:true] + [async-html-script-removal.https.html] [Verify write and read clipboard with scripts removed given text/html:
Hello World
] expected: diff --git a/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-basics.https.html.ini b/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-basics.https.html.ini index 7eca35fb99f0..692255c319c2 100644 --- a/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-basics.https.html.ini +++ b/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-basics.https.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails on Android without the testing pref, see bug 1888179 +prefs: [dom.events.testing.asyncClipboard:true] + [async-navigator-clipboard-basics.https.html] expected: if (os == "android") and fission: [OK, TIMEOUT] diff --git a/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-read-resource-load.https.html.ini b/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-read-resource-load.https.html.ini index e2f2d2487d7e..952722c2ed67 100644 --- a/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-read-resource-load.https.html.ini +++ b/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-read-resource-load.https.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails on Android without the testing pref, see bug 1888179 +prefs: [dom.events.testing.asyncClipboard:true] + [async-navigator-clipboard-read-resource-load.https.html] expected: if (os == "android") and fission: [OK, TIMEOUT] diff --git a/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html.ini b/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html.ini index 84ec85604da4..145c9ef371b1 100644 --- a/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html.ini +++ b/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails on Android without the testing pref, see bug 1888179 +prefs: [dom.events.testing.asyncClipboard:true] + [async-navigator-clipboard-read-sanitize.https.html] [Async Clipboard.read() should sanitize text/html] expected: diff --git a/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-write-multiple.tentative.https.sub.html.ini b/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-write-multiple.tentative.https.sub.html.ini index 7aa80650e888..dfdb81dd869e 100644 --- a/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-write-multiple.tentative.https.sub.html.ini +++ b/testing/web-platform/meta/clipboard-apis/async-navigator-clipboard-write-multiple.tentative.https.sub.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails without the testing pref, see bug 1888182 +prefs: [dom.events.testing.asyncClipboard:true] + [async-navigator-clipboard-write-multiple.tentative.https.sub.html] [clipboard.write() should cancel the prior pending one (same-origin iframe)] expected: diff --git a/testing/web-platform/meta/clipboard-apis/async-unsanitized-standard-html-read-fail.tentative.https.html.ini b/testing/web-platform/meta/clipboard-apis/async-unsanitized-standard-html-read-fail.tentative.https.html.ini index a0c1bddf23f4..cfdc752ea26d 100644 --- a/testing/web-platform/meta/clipboard-apis/async-unsanitized-standard-html-read-fail.tentative.https.html.ini +++ b/testing/web-platform/meta/clipboard-apis/async-unsanitized-standard-html-read-fail.tentative.https.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test passes on Android without the testing pref and fails everywhere else +prefs: [dom.events.testing.asyncClipboard:true] + [async-unsanitized-standard-html-read-fail.tentative.https.html] [navigator.clipboard.read() fails for multiple unsanitized formats requested.] expected: FAIL diff --git a/testing/web-platform/meta/clipboard-apis/async-write-html-read-html.https.html.ini b/testing/web-platform/meta/clipboard-apis/async-write-html-read-html.https.html.ini index 248697533607..7a7a54208d21 100644 --- a/testing/web-platform/meta/clipboard-apis/async-write-html-read-html.https.html.ini +++ b/testing/web-platform/meta/clipboard-apis/async-write-html-read-html.https.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails on Android without the testing pref, see bug 1888179 +prefs: [dom.events.testing.asyncClipboard:true] + [async-write-html-read-html.https.html] expected: if (os == "android") and debug and fission: [OK, TIMEOUT] diff --git a/testing/web-platform/meta/clipboard-apis/detached-iframe/write-read-on-detached-iframe.https.html.ini b/testing/web-platform/meta/clipboard-apis/detached-iframe/write-read-on-detached-iframe.https.html.ini index 7b5992afa81c..ed862d84bda1 100644 --- a/testing/web-platform/meta/clipboard-apis/detached-iframe/write-read-on-detached-iframe.https.html.ini +++ b/testing/web-platform/meta/clipboard-apis/detached-iframe/write-read-on-detached-iframe.https.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails on Android without the testing pref, see bug 1888179 +prefs: [dom.events.testing.asyncClipboard:true] + [write-read-on-detached-iframe.https.html] expected: if (os == "android") and not debug: [TIMEOUT, CRASH] diff --git a/testing/web-platform/meta/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe.https.html.ini b/testing/web-platform/meta/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe.https.html.ini index f5e7ca02d32a..b0b6996d98b5 100644 --- a/testing/web-platform/meta/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe.https.html.ini +++ b/testing/web-platform/meta/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe.https.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails on Android without the testing pref, see bug 1888179 +prefs: [dom.events.testing.asyncClipboard:true] + [writeText-readText-on-detached-iframe.https.html] expected: if (os == "android") and not debug: [TIMEOUT, CRASH] diff --git a/testing/web-platform/meta/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy.tentative.https.sub.html.ini b/testing/web-platform/meta/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy.tentative.https.sub.html.ini index 022fd394a56f..a5acbde11ea9 100644 --- a/testing/web-platform/meta/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy.tentative.https.sub.html.ini +++ b/testing/web-platform/meta/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy.tentative.https.sub.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails without the testing pref, see bug 1888182 +prefs: [dom.events.testing.asyncClipboard:true] + [clipboard-read-enabled-by-feature-policy.tentative.https.sub.html] expected: if (os == "android") and debug and fission: [OK, TIMEOUT] diff --git a/testing/web-platform/meta/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html.ini b/testing/web-platform/meta/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html.ini index e2a3882b8086..cbf2f06cc1c9 100644 --- a/testing/web-platform/meta/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html.ini +++ b/testing/web-platform/meta/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails without the testing pref, see bug 1888182 +prefs: [dom.events.testing.asyncClipboard:true] + [clipboard-read-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html] expected: if (os == "android") and debug and fission: [OK, TIMEOUT] diff --git a/testing/web-platform/meta/clipboard-apis/permissions/readText-denied.https.html.ini b/testing/web-platform/meta/clipboard-apis/permissions/readText-denied.https.html.ini index a1571c251e36..f4256f800ad7 100644 --- a/testing/web-platform/meta/clipboard-apis/permissions/readText-denied.https.html.ini +++ b/testing/web-platform/meta/clipboard-apis/permissions/readText-denied.https.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails without the testing pref, see bug 1888182 +prefs: [dom.events.testing.asyncClipboard:true] + [readText-denied.https.html] expected: if (os == "android") and not debug: [OK, CRASH] diff --git a/testing/web-platform/meta/clipboard-apis/permissions/readText-granted.https.html.ini b/testing/web-platform/meta/clipboard-apis/permissions/readText-granted.https.html.ini index eeb3a5255060..e6aa89e3d118 100644 --- a/testing/web-platform/meta/clipboard-apis/permissions/readText-granted.https.html.ini +++ b/testing/web-platform/meta/clipboard-apis/permissions/readText-granted.https.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails without the testing pref, see bug 1888182 +prefs: [dom.events.testing.asyncClipboard:true] + [readText-granted.https.html] expected: if (os == "android") and not debug: [OK, CRASH] diff --git a/testing/web-platform/meta/clipboard-apis/text-write-read/async-write-read.https.html.ini b/testing/web-platform/meta/clipboard-apis/text-write-read/async-write-read.https.html.ini index 0e37e836a0be..60f7e48ffd43 100644 --- a/testing/web-platform/meta/clipboard-apis/text-write-read/async-write-read.https.html.ini +++ b/testing/web-platform/meta/clipboard-apis/text-write-read/async-write-read.https.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails on Android without the testing pref, see bug 1888179 +prefs: [dom.events.testing.asyncClipboard:true] + [async-write-read.https.html] expected: if (os == "android") and not debug: [OK, CRASH] diff --git a/testing/web-platform/meta/clipboard-apis/text-write-read/async-write-readText.https.html.ini b/testing/web-platform/meta/clipboard-apis/text-write-read/async-write-readText.https.html.ini index 5e361058ae58..14c01448fa0a 100644 --- a/testing/web-platform/meta/clipboard-apis/text-write-read/async-write-readText.https.html.ini +++ b/testing/web-platform/meta/clipboard-apis/text-write-read/async-write-readText.https.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails on Android without the testing pref, see bug 1888179 +prefs: [dom.events.testing.asyncClipboard:true] + [async-write-readText.https.html] expected: if (os == "android") and debug and fission: [OK, TIMEOUT] diff --git a/testing/web-platform/meta/clipboard-apis/text-write-read/async-writeText-read.https.html.ini b/testing/web-platform/meta/clipboard-apis/text-write-read/async-writeText-read.https.html.ini index ddb654688a67..6235629fdf76 100644 --- a/testing/web-platform/meta/clipboard-apis/text-write-read/async-writeText-read.https.html.ini +++ b/testing/web-platform/meta/clipboard-apis/text-write-read/async-writeText-read.https.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails on Android without the testing pref, see bug 1888179 +prefs: [dom.events.testing.asyncClipboard:true] + [async-writeText-read.https.html] expected: if (os == "android") and debug and fission: [OK, TIMEOUT] diff --git a/testing/web-platform/meta/clipboard-apis/text-write-read/async-writeText-readText.https.html.ini b/testing/web-platform/meta/clipboard-apis/text-write-read/async-writeText-readText.https.html.ini index efd4b27a626e..2bcc2483570a 100644 --- a/testing/web-platform/meta/clipboard-apis/text-write-read/async-writeText-readText.https.html.ini +++ b/testing/web-platform/meta/clipboard-apis/text-write-read/async-writeText-readText.https.html.ini @@ -1,3 +1,6 @@ +# XXX(krosylight): The test fails on Android without the testing pref, see bug 1888179 +prefs: [dom.events.testing.asyncClipboard:true] + [async-writeText-readText.https.html] expected: if (os == "android") and debug and fission: [OK, TIMEOUT] 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 8b1b42ec78d6..305222a58ff3 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 9a6e5da6fff1..a5ee7c5bf0ed 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 8b9d4de0a1f9..e20b66b55182 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 a005f8c98f02..d174df67498d 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 44c11add8551..9ec9a3735642 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 = 'Hello World
'; 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 4a11d5ac66d8..5d6f701bdb75 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 d1e3019e7f93..25a90a2d0822 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 cc1836753478..4f8463cd7cc7 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 73cdd2f049e3..c310203503f3 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 12184c92e077..6b7989316002 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 46e335c804b7..848900830f13 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 1c5638ca0a5f..dea91b41d7eb 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 e7ddbb0cdf6e..f0884d6c20cb 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.'); - \ No newline at end of file + 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 8bec558b2b2d..d89640d58a03 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 ec1817c027bb..2573916bd6af 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 e10b69d824c2..a8aa7d457cba 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 8e8e015aa051..827c17a9e32f 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 @@ + + \ No newline at end of file + 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 5fbcab411748..3d6b4397a042 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 ff347b7adda0..c0307811dcc4 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'); - \ No newline at end of file + diff --git a/testing/web-platform/tests/clipboard-apis/resources/page.html b/testing/web-platform/tests/clipboard-apis/resources/page.html index 35bde8e5016b..fc8bd895d100 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 ed294bb9cb27..6fa5bcba4054 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(state) { + 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 c46e5d431713..516783edaedf 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 @@