mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1875837 - Make clipboard-read/write permission optional in clipboard WPT r=webdriver-reviewers,dom-core,edgar,whimboo
Blink is the only engine supporting it, and thus it should not be the WPT requirement. Some tests still need the testing pref, and for now this patch gives the pref for such failing tests without modifying them, for simplicity sake. Modification can happen separately. Differential Revision: https://phabricator.services.mozilla.com/D201999
This commit is contained in:
parent
8851ada603
commit
52f9697770
@ -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)) {
|
||||
|
@ -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]
|
||||
|
@ -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: <title>Title of the document</title> <script>const a = 5;</script> <p>Hello World</p>]
|
||||
expected:
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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});
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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'});
|
||||
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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>
|
||||
</script>
|
||||
|
@ -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');
|
||||
|
@ -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();
|
||||
|
@ -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'});
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -14,7 +14,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.');
|
||||
|
@ -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.');
|
||||
|
@ -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.');
|
||||
|
@ -14,7 +14,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.');
|
||||
|
@ -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.');
|
||||
|
@ -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.');
|
||||
|
@ -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());
|
||||
|
@ -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>
|
||||
</script>
|
||||
|
@ -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'));
|
||||
|
@ -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>
|
||||
</script>
|
||||
|
@ -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({
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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});
|
||||
|
@ -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});
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user