diff --git a/clipboard-apis/async-custom-formats-write-fail.tentative.https.html b/clipboard-apis/async-custom-formats-write-fail.tentative.https.html index 305222a58ff34b..c129ee5cfe4fe9 100644 --- a/clipboard-apis/async-custom-formats-write-fail.tentative.https.html +++ b/clipboard-apis/async-custom-formats-write-fail.tentative.https.html @@ -22,7 +22,7 @@ customFormatMap[customFormatArray[i]] = blobInput; } const clipboardItemInput = new ClipboardItem(customFormatMap); - await waitForUserActivation(); + await test_driver.bless(); await promise_rejects_dom(t, 'NotAllowedError', navigator.clipboard.write([clipboardItemInput])); }, 'navigator.clipboard.write() fails for more than 100 custom formats'); @@ -36,7 +36,7 @@ const blobInput2 = new Blob(['input data 2'], {type: format2}); const clipboardItemInput = new ClipboardItem( {[format1]: blobInput1, [format2]: blobInput2}); - await waitForUserActivation(); + await test_driver.bless(); await promise_rejects_dom(t, 'NotAllowedError', navigator.clipboard.write([clipboardItemInput])); }, 'navigator.clipboard.write() fails for custom formats without web prefix'); @@ -50,7 +50,7 @@ const blobInput2 = new Blob(['input data 2'], {type: format2}); const clipboardItemInput = new ClipboardItem( {[format1]: blobInput1, [format2]: blobInput2}); - await waitForUserActivation(); + await test_driver.bless(); await promise_rejects_dom(t, 'NotAllowedError', navigator.clipboard.write([clipboardItemInput])); }, 'navigator.clipboard.write() fails for custom formats with web prefix, but invalid MIME types'); @@ -63,7 +63,7 @@ const blobInput1 = new Blob(['input data 1'], {type: format2}); const clipboardItemInput = new ClipboardItem( {[format1]: blobInput1}); - await waitForUserActivation(); + await test_driver.bless(); await promise_rejects_dom(t, 'NotAllowedError', navigator.clipboard.write([clipboardItemInput])); }, 'navigator.clipboard.write() fails for custom format with web prefix, but different Blob type'); @@ -76,7 +76,7 @@ const blobInput1 = new Blob(['input data 1'], {type: format2}); const clipboardItemInput = new ClipboardItem( {[format1]: blobInput1}); - await waitForUserActivation(); + await test_driver.bless(); await promise_rejects_dom(t, 'NotAllowedError', navigator.clipboard.write([clipboardItemInput])); }, 'navigator.clipboard.write() fails for custom format with different case than the Blob type'); @@ -89,7 +89,7 @@ const blobInput1 = new Blob(['input data 1'], {type: format1}); const clipboardItemInput = new ClipboardItem( {[format2]: blobInput1}); - await waitForUserActivation(); + await test_driver.bless(); await promise_rejects_dom(t, 'NotAllowedError', navigator.clipboard.write([clipboardItemInput])); }, 'navigator.clipboard.write() fails for invalid mime type that is different than the Blob type'); @@ -102,7 +102,7 @@ const blobInput1 = new Blob(['input data 1'], {type: format2}); const clipboardItemInput = new ClipboardItem( {[format1]: blobInput1}); - await waitForUserActivation(); + await test_driver.bless(); await promise_rejects_dom(t, 'NotAllowedError', navigator.clipboard.write([clipboardItemInput])); }, 'navigator.clipboard.write() fails for invalid mime type with web prefix and the Blob type'); @@ -115,7 +115,7 @@ const blobInput1 = new Blob(['input data 1'], {type: format2}); const clipboardItemInput = new ClipboardItem( {[format1]: blobInput1}); - await waitForUserActivation(); + await test_driver.bless(); await promise_rejects_dom(t, 'NotAllowedError', navigator.clipboard.write([clipboardItemInput])); }, 'navigator.clipboard.write() fails for custom format and Blob type with different case'); diff --git a/clipboard-apis/async-custom-formats-write-read-web-prefix.tentative.https.html b/clipboard-apis/async-custom-formats-write-read-web-prefix.tentative.https.html index a5ee7c5bf0edd2..c96a2966ae2c9e 100644 --- a/clipboard-apis/async-custom-formats-write-read-web-prefix.tentative.https.html +++ b/clipboard-apis/async-custom-formats-write-read-web-prefix.tentative.https.html @@ -20,9 +20,9 @@ const blobInput1 = new Blob(['input data 1'], {type: format2}); const clipboardItemInput = new ClipboardItem( {[format1]: blobInput1}); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.write([clipboardItemInput]); - await waitForUserActivation(); + await test_driver.bless(); const clipboardItems = await navigator.clipboard.read(); assert_equals(clipboardItems.length, 1); const clipboardItem = clipboardItems[0]; diff --git a/clipboard-apis/async-custom-formats-write-read-without-web-prefix.tentative.https.html b/clipboard-apis/async-custom-formats-write-read-without-web-prefix.tentative.https.html index e20b66b55182ec..8e897e5c2566cf 100644 --- a/clipboard-apis/async-custom-formats-write-read-without-web-prefix.tentative.https.html +++ b/clipboard-apis/async-custom-formats-write-read-without-web-prefix.tentative.https.html @@ -20,9 +20,9 @@ const blobInput1 = new Blob(['input data 1'], {type: format2}); const clipboardItemInput = new ClipboardItem( {[format1]: blobInput1}); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.write([clipboardItemInput]); - await waitForUserActivation(); + await test_driver.bless(); const clipboardItems = await navigator.clipboard.read(); assert_equals(clipboardItems.length, 1); const clipboardItem = clipboardItems[0]; diff --git a/clipboard-apis/async-custom-formats-write-read.tentative.https.html b/clipboard-apis/async-custom-formats-write-read.tentative.https.html index d174df67498dd9..25990962756284 100644 --- a/clipboard-apis/async-custom-formats-write-read.tentative.https.html +++ b/clipboard-apis/async-custom-formats-write-read.tentative.https.html @@ -20,12 +20,12 @@ const blobInput2 = new Blob(['input data 2'], {type: format2}); const clipboardItemInput = new ClipboardItem( {[format1]: blobInput1, [format2]: blobInput2}); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.write([clipboardItemInput]); // Items should be readable on a custom format clipboard after custom format // write. - await waitForUserActivation(); + await test_driver.bless(); const clipboardItems = await navigator.clipboard.read(); assert_equals(clipboardItems.length, 1); const clipboardItem = clipboardItems[0]; diff --git a/clipboard-apis/async-html-script-removal.https.html b/clipboard-apis/async-html-script-removal.https.html index 9ec9a3735642c7..2e9bba34a7b1fb 100644 --- a/clipboard-apis/async-html-script-removal.https.html +++ b/clipboard-apis/async-html-script-removal.https.html @@ -38,9 +38,9 @@ await tryGrantWritePermission(); const blobInput = new Blob([html_with_script], {type: 'text/html'}); const clipboardItem = new ClipboardItem({'text/html': blobInput}); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.write([clipboardItem]); - await waitForUserActivation(); + await test_driver.bless(); const clipboardItems = await navigator.clipboard.read(); const html = clipboardItems[0]; diff --git a/clipboard-apis/async-navigator-clipboard-basics.https.html b/clipboard-apis/async-navigator-clipboard-basics.https.html index 5d6f701bdb7516..b3d28fcfc31c6f 100644 --- a/clipboard-apis/async-navigator-clipboard-basics.https.html +++ b/clipboard-apis/async-navigator-clipboard-basics.https.html @@ -15,7 +15,7 @@ async function getPermissions() { await tryGrantReadPermission(); await tryGrantWritePermission(); - await waitForUserActivation(); + await test_driver.bless(); } test(() => { diff --git a/clipboard-apis/async-navigator-clipboard-read-resource-load.https.html b/clipboard-apis/async-navigator-clipboard-read-resource-load.https.html index 25a90a2d082250..973b16dae6f4e3 100644 --- a/clipboard-apis/async-navigator-clipboard-read-resource-load.https.html +++ b/clipboard-apis/async-navigator-clipboard-read-resource-load.https.html @@ -29,7 +29,7 @@ await tryGrantReadPermission(); await test_driver.click(button); - await waitForUserActivation(); + await test_driver.bless(); const items = await navigator.clipboard.read(); const htmlBlob = await items[0].getType("text/html"); const html = await htmlBlob.text(); diff --git a/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html b/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html index 4f8463cd7cc78c..5ad7f2ac41c5d3 100644 --- a/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html +++ b/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html @@ -31,7 +31,7 @@ await tryGrantReadPermission(); await test_driver.click(button); - await waitForUserActivation(); + await test_driver.bless(); const items = await navigator.clipboard.read(); const htmlBlob = await items[0].getType("text/html"); const html = await htmlBlob.text(); diff --git a/clipboard-apis/async-navigator-clipboard-write-multiple.tentative.https.sub.html b/clipboard-apis/async-navigator-clipboard-write-multiple.tentative.https.sub.html index c310203503f353..73e741ef2b7c80 100644 --- a/clipboard-apis/async-navigator-clipboard-write-multiple.tentative.https.sub.html +++ b/clipboard-apis/async-navigator-clipboard-write-multiple.tentative.https.sub.html @@ -20,7 +20,7 @@ async function getPermissions() { await tryGrantReadPermission(); await tryGrantWritePermission() - await waitForUserActivation(); + await test_driver.bless(); } function waitForMessage(msg) { diff --git a/clipboard-apis/async-promise-write-blobs-read-blobs.https.html b/clipboard-apis/async-promise-write-blobs-read-blobs.https.html index 6b798931600219..c13401f188bcde 100644 --- a/clipboard-apis/async-promise-write-blobs-read-blobs.https.html +++ b/clipboard-apis/async-promise-write-blobs-read-blobs.https.html @@ -28,9 +28,9 @@ const clipboardItemInput = new ClipboardItem( {'text/plain' : blobText, 'image/png' : promise1}); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.write([clipboardItemInput]); - await waitForUserActivation(); + await test_driver.bless(); const clipboardItems = await navigator.clipboard.read(); assert_equals(clipboardItems.length, 1); diff --git a/clipboard-apis/async-unsanitized-html-formats-write-read.tentative.https.html b/clipboard-apis/async-unsanitized-html-formats-write-read.tentative.https.html index 848900830f136d..aed3f1c8e65004 100644 --- a/clipboard-apis/async-unsanitized-html-formats-write-read.tentative.https.html +++ b/clipboard-apis/async-unsanitized-html-formats-write-read.tentative.https.html @@ -38,11 +38,11 @@ const blobInput2 = new Blob([textInput], {type: format2}); const clipboardItemInput = new ClipboardItem( {[format1]: blobInput1, [format2]: blobInput2}); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.write([clipboardItemInput]); // Read unsanitized version of HTML format. - await waitForUserActivation(); + await test_driver.bless(); const clipboardItems = await navigator.clipboard.read(); assert_equals(clipboardItems.length, 1); diff --git a/clipboard-apis/async-unsanitized-plaintext-formats-write-read.tentative.https.html b/clipboard-apis/async-unsanitized-plaintext-formats-write-read.tentative.https.html index dea91b41d7eb1a..34945ee8c25ed2 100644 --- a/clipboard-apis/async-unsanitized-plaintext-formats-write-read.tentative.https.html +++ b/clipboard-apis/async-unsanitized-plaintext-formats-write-read.tentative.https.html @@ -28,11 +28,11 @@ assert_equals(blobInput2.type, format2.toLowerCase()); const clipboardItemInput = new ClipboardItem( {[format1]: blobInput1, [format2]: blobInput2}); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.write([clipboardItemInput]); // Items should be readable on a system clipboard after custom format write. - await waitForUserActivation(); + await test_driver.bless(); const clipboardItems = await navigator.clipboard.read(); assert_equals(clipboardItems.length, 1); const clipboardItem = clipboardItems[0]; @@ -45,7 +45,7 @@ // These examples use native text formats, so these formats should be // accessible as text. - await waitForUserActivation(); + await test_driver.bless(); const textOutput = await navigator.clipboard.readText(); assert_equals(textOutput, dataToWrite); }, 'Verify write and read unsanitized content to the clipboard given standard and custom formats as input'); diff --git a/clipboard-apis/async-unsanitized-standard-html-read-fail.tentative.https.html b/clipboard-apis/async-unsanitized-standard-html-read-fail.tentative.https.html index f0884d6c20cbe3..edf3b5e52b67ab 100644 --- a/clipboard-apis/async-unsanitized-standard-html-read-fail.tentative.https.html +++ b/clipboard-apis/async-unsanitized-standard-html-read-fail.tentative.https.html @@ -14,7 +14,7 @@ promise_test(async t => { await tryGrantReadPermission(); - await waitForUserActivation(); + await test_driver.bless(); await promise_rejects_dom(t, 'NotAllowedError', navigator.clipboard.read({unsanitized: ['text/html', 'text/plain']})); }, 'navigator.clipboard.read() fails for multiple unsanitized formats requested.'); @@ -22,7 +22,7 @@ promise_test(async t => { await tryGrantReadPermission(); - await waitForUserActivation(); + await test_driver.bless(); await promise_rejects_dom(t, 'NotAllowedError', navigator.clipboard.read({unsanitized: ['text/plain']})); }, 'navigator.clipboard.read() fails for unsanitized text/plain requested.'); @@ -30,7 +30,7 @@ promise_test(async t => { await tryGrantReadPermission(); - await waitForUserActivation(); + await test_driver.bless(); await promise_rejects_dom(t, 'NotAllowedError', navigator.clipboard.read({unsanitized: ['image/png']})); }, 'navigator.clipboard.read() fails for unsanitized image/png requested.'); @@ -38,7 +38,7 @@ promise_test(async t => { await tryGrantReadPermission(); - await waitForUserActivation(); + await test_driver.bless(); await promise_rejects_dom(t, 'NotAllowedError', navigator.clipboard.read({unsanitized: ['image/svg+xml']})); }, 'navigator.clipboard.read() fails for unsanitized image/svg+xml requested.'); diff --git a/clipboard-apis/async-write-blobs-read-blobs.https.html b/clipboard-apis/async-write-blobs-read-blobs.https.html index d89640d58a034b..df8b7eea2f155a 100644 --- a/clipboard-apis/async-write-blobs-read-blobs.https.html +++ b/clipboard-apis/async-write-blobs-read-blobs.https.html @@ -30,9 +30,9 @@ const clipboardItemInput = new ClipboardItem( {'text/plain' : blobText, 'image/png' : blobImage}); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.write([clipboardItemInput]); - await waitForUserActivation(); + await test_driver.bless(); const clipboardItems = await navigator.clipboard.read(); assert_equals(clipboardItems.length, 1); diff --git a/clipboard-apis/async-write-html-read-html.https.html b/clipboard-apis/async-write-html-read-html.https.html index 2573916bd6af25..6429742883cd4c 100644 --- a/clipboard-apis/async-write-html-read-html.https.html +++ b/clipboard-apis/async-write-html-read-html.https.html @@ -30,9 +30,9 @@ await tryGrantWritePermission(); const blobInput = new Blob([textInput], {type: 'text/html'}); const clipboardItem = new ClipboardItem({'text/html': blobInput}); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.write([clipboardItem]); - await waitForUserActivation(); + await test_driver.bless(); const clipboardItems = await navigator.clipboard.read({type: 'text/html'}); const html = clipboardItems[0]; diff --git a/clipboard-apis/async-write-image-read-image.https.html b/clipboard-apis/async-write-image-read-image.https.html index a8aa7d457cbaf1..2413f28300297f 100644 --- a/clipboard-apis/async-write-image-read-image.https.html +++ b/clipboard-apis/async-write-image-read-image.https.html @@ -49,9 +49,9 @@ assert_equals(blobInput.type, 'image/png'); const clipboardItemInput = new ClipboardItem({'image/png' : blobInput}); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.write([clipboardItemInput]); - await waitForUserActivation(); + await test_driver.bless(); const clipboardItems = await navigator.clipboard.read(); assert_equals(clipboardItems.length, 1); @@ -77,7 +77,7 @@ const invalidPngBlob = new Blob(['this text is not a valid png image'], {type: 'image/png'}); const clipboardItemInput = new ClipboardItem({'image/png' : invalidPngBlob}); - await waitForUserActivation(); + await test_driver.bless(); await promise_rejects_dom(t, 'DataError', navigator.clipboard.write([clipboardItemInput])); }, 'Verify write error on malformed data [image/png ClipboardItem]'); diff --git a/clipboard-apis/detached-iframe/write-read-on-detached-iframe.https.html b/clipboard-apis/detached-iframe/write-read-on-detached-iframe.https.html index 155f9d004aee2a..063ad261b3850e 100644 --- a/clipboard-apis/detached-iframe/write-read-on-detached-iframe.https.html +++ b/clipboard-apis/detached-iframe/write-read-on-detached-iframe.https.html @@ -19,10 +19,15 @@ await tryGrantWritePermission(); const iframe = document.getElementById('iframe'); + await new Promise(resolve => { + iframe.onload = resolve; + iframe.src = 'about:blank'; + }); const iframeClipboard = iframe.contentWindow.navigator.clipboard; const blobInput = new Blob(['test string'], {type: 'text/plain'}); const clipboardItemInput = new ClipboardItem({'text/plain': blobInput}); - await waitForUserActivation(); + await test_driver.bless("clipboard", null, iframe.contentWindow); + // Clipboard API must only be available in focused documents. // reference: https://www.w3.org/TR/clipboard-apis/#privacy-async iframe.focus(); @@ -34,7 +39,7 @@ assert_equals(readResultAttached.length, 1, 'attached iframes should be able to read and write normally'); - iframe.parentNode.removeChild(iframe); + iframe.remove(); // Writing onto a detached iframe's clipboard should fail, but not crash. await iframeClipboard.write([clipboardItemInput]); const readResultDetached = await iframeClipboard.read(); diff --git a/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe.https.html b/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe.https.html index 8c6448d5cc9e4c..efe24891d71430 100644 --- a/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe.https.html +++ b/clipboard-apis/detached-iframe/writeText-readText-on-detached-iframe.https.html @@ -16,7 +16,11 @@ await tryGrantWritePermission(); const iframe = document.getElementById('iframe'); - await waitForUserActivation(); + await new Promise(resolve => { + iframe.onload = resolve; + iframe.src = 'about:blank'; + }); + await test_driver.bless("clipboard", null, iframe.contentWindow); // Clipboard API must only be available in focused documents. // reference: https://www.w3.org/TR/clipboard-apis/#privacy-async iframe.focus(); @@ -29,7 +33,7 @@ assert_equals(attachedWriteResult, attachedWriteText, 'attached iframes should be able to readText and writeText normally'); - iframe.parentNode.removeChild(iframe); + iframe.remove(); // Writing onto a detached iframe's clipboard should fail, but not crash. const detachedWriteText = 'detached write text'; await iframeClipboard.writeText(detachedWriteText); diff --git a/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy-attribute-cross-origin-tentative.https.sub.html b/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy-attribute-cross-origin-tentative.https.sub.html index 2998e058b3d09f..d07d42234fccd9 100644 --- a/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy-attribute-cross-origin-tentative.https.sub.html +++ b/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy-attribute-cross-origin-tentative.https.sub.html @@ -19,7 +19,7 @@ // only, cross-origin focus is asynchronous. Implement WPT support for // cross-origin focus. promise_test(async t => { - await waitForUserActivation(); + await test_driver.bless(); test_feature_availability( 'navigator.clipboard.readText()', t, diff --git a/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy-attribute-tentative.https.sub.html b/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy-attribute-tentative.https.sub.html index e812854b4c7505..0b3ac836b1aca6 100644 --- a/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy-attribute-tentative.https.sub.html +++ b/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy-attribute-tentative.https.sub.html @@ -13,7 +13,7 @@ '/feature-policy/resources/feature-policy-clipboard-read.html'; promise_test(async t => { - await waitForUserActivation(); + await test_driver.bless(); test_feature_availability( 'navigator.clipboard.readText()', t, diff --git a/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy-cross-origin-tentative.https.sub.html b/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy-cross-origin-tentative.https.sub.html index 88c8d845b26e45..253841991267d6 100644 --- a/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy-cross-origin-tentative.https.sub.html +++ b/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy-cross-origin-tentative.https.sub.html @@ -19,7 +19,7 @@ // only, cross-origin focus is asynchronous. Implement WPT support for // cross-origin focus. promise_test(async t => { - await waitForUserActivation(); + await test_driver.bless(); test_feature_availability( 'navigator.clipboard.readText()', t, diff --git a/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy.tentative.https.sub.html b/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy.tentative.https.sub.html index e392def5e9076a..a58ade63067b54 100644 --- a/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy.tentative.https.sub.html +++ b/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy.tentative.https.sub.html @@ -16,12 +16,12 @@ promise_test(async t => { await tryGrantReadPermission(); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.readText('test text'); }, 'Feature-Policy header clipboard-read "*" allows the top-level document.'); promise_test(async t => { - await waitForUserActivation(); + await test_driver.bless(); test_feature_availability( 'navigator.clipboard.readText()', t, diff --git a/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html b/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html index e9df891d4bd51d..015b969884e793 100644 --- a/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html +++ b/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html @@ -16,12 +16,12 @@ promise_test(async t => { await tryGrantReadPermission(); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.readText('test text'); }, 'Feature-Policy header clipboard-read "self" allows the top-level document.'); promise_test(async t => { - await waitForUserActivation(); + await test_driver.bless(); test_feature_availability( 'navigator.clipboard.readText()', t, diff --git a/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy-attribute-cross-origin-tentative.https.sub.html b/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy-attribute-cross-origin-tentative.https.sub.html index 45bba1b8d35ec2..c463e7169fa9f2 100644 --- a/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy-attribute-cross-origin-tentative.https.sub.html +++ b/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy-attribute-cross-origin-tentative.https.sub.html @@ -19,7 +19,7 @@ // only, cross-origin focus is asynchronous. Implement WPT support for // cross-origin focus. promise_test(async t => { - await waitForUserActivation(); + await test_driver.bless(); test_feature_availability( 'navigator.clipboard.writeText("test text")', t, diff --git a/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy-attribute-tentative.https.sub.html b/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy-attribute-tentative.https.sub.html index b57dfe3dd2888d..1668ec88435393 100644 --- a/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy-attribute-tentative.https.sub.html +++ b/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy-attribute-tentative.https.sub.html @@ -13,7 +13,7 @@ '/feature-policy/resources/feature-policy-clipboard-write.html'; promise_test(async t => { - await waitForUserActivation(); + await test_driver.bless(); test_feature_availability( 'navigator.clipboard.writeText("test text")', t, diff --git a/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy-cross-origin-tentative.https.sub.html b/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy-cross-origin-tentative.https.sub.html index 8f64fdbe02ebd1..208959ea43747c 100644 --- a/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy-cross-origin-tentative.https.sub.html +++ b/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy-cross-origin-tentative.https.sub.html @@ -19,7 +19,7 @@ // only, cross-origin focus is asynchronous. Implement WPT support for // cross-origin focus. promise_test(async t => { - await waitForUserActivation(); + await test_driver.bless(); test_feature_availability( 'navigator.clipboard.writeText("test text")', t, diff --git a/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy.tentative.https.sub.html b/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy.tentative.https.sub.html index 701759b61c935d..6f4f7355be9286 100644 --- a/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy.tentative.https.sub.html +++ b/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-by-feature-policy.tentative.https.sub.html @@ -16,12 +16,12 @@ promise_test(async t => { await tryGrantWritePermission(); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.writeText('test text'); }, 'Feature-Policy header clipboard-write "*" allows the top-level document.'); promise_test(async t => { - await waitForUserActivation(); + await test_driver.bless(); test_feature_availability( 'navigator.clipboard.writeText("test text")', t, diff --git a/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html b/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html index b976a17a7cbff6..a277b60814929e 100644 --- a/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html +++ b/clipboard-apis/feature-policy/clipboard-write/clipboard-write-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html @@ -16,12 +16,12 @@ promise_test(async t => { await tryGrantWritePermission(); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.writeText('test text'); }, 'Feature-Policy header clipboard-write "self" allows the top-level document.'); promise_test(async t => { - await waitForUserActivation(); + await test_driver.bless(); test_feature_availability( 'navigator.clipboard.writeText("test text")', t, diff --git a/clipboard-apis/permissions/readText-denied.https.html b/clipboard-apis/permissions/readText-denied.https.html index 379b0ff18b8b55..bf491ae82091b2 100644 --- a/clipboard-apis/permissions/readText-denied.https.html +++ b/clipboard-apis/permissions/readText-denied.https.html @@ -13,7 +13,7 @@ promise_test(async t => { await trySetPermission('clipboard-read', 'denied'); - await waitForUserActivation(); + await test_driver.bless(); await promise_rejects_dom(t, 'NotAllowedError', navigator.clipboard.readText()); }, 'navigator.clipboard.readText() fails when permission denied'); diff --git a/clipboard-apis/permissions/readText-granted.https.html b/clipboard-apis/permissions/readText-granted.https.html index 0b2d7034df34ff..0127fd4aa54ed8 100644 --- a/clipboard-apis/permissions/readText-granted.https.html +++ b/clipboard-apis/permissions/readText-granted.https.html @@ -13,7 +13,7 @@ promise_test(async () => { await tryGrantReadPermission(); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.readText(); }, 'navigator.clipboard.readText() succeeds when permission granted'); diff --git a/clipboard-apis/permissions/writeText-denied.https.html b/clipboard-apis/permissions/writeText-denied.https.html index 3d6b4397a04233..a3d099f3e98538 100644 --- a/clipboard-apis/permissions/writeText-denied.https.html +++ b/clipboard-apis/permissions/writeText-denied.https.html @@ -13,7 +13,7 @@ promise_test(async t => { await trySetPermission('clipboard-write', 'denied'); - await waitForUserActivation(); + await test_driver.bless(); await promise_rejects_dom(t, 'NotAllowedError', navigator.clipboard.writeText('xyz')); }, 'navigator.clipboard.writeText() fails when permission denied'); diff --git a/clipboard-apis/permissions/writeText-granted.https.html b/clipboard-apis/permissions/writeText-granted.https.html index c0307811dcc4ca..05d3a986500a5e 100644 --- a/clipboard-apis/permissions/writeText-granted.https.html +++ b/clipboard-apis/permissions/writeText-granted.https.html @@ -9,11 +9,11 @@ diff --git a/clipboard-apis/resources/page.html b/clipboard-apis/resources/page.html index fc8bd895d10012..f47e684ea90c53 100644 --- a/clipboard-apis/resources/page.html +++ b/clipboard-apis/resources/page.html @@ -11,16 +11,18 @@ test_driver.set_test_context(window.parent); await tryGrantReadPermission(); await tryGrantWritePermission(); - await waitForUserActivation(); - await navigator.clipboard.write([ - new ClipboardItem({ - "text/plain": e.data[1], - }), - ]).catch(() => { - assert_true(false, `should not fail`); - }); - window.parent.postMessage("done", "*"); + await test_driver.bless(); + try { + await navigator.clipboard.write([ + new ClipboardItem({ + "text/plain": e.data[1], + }), + ]); + } catch (e) { + assert_unreached("should not fail"); + } finally { + window.parent.postMessage("done", "*"); + } } -}); + }); - diff --git a/clipboard-apis/resources/user-activation.js b/clipboard-apis/resources/user-activation.js index 4535f8c6d7446e..9e003a380b8969 100644 --- a/clipboard-apis/resources/user-activation.js +++ b/clipboard-apis/resources/user-activation.js @@ -1,29 +1,5 @@ 'use strict'; -// In order to use this function, please import testdriver.js and -// testdriver-vendor.js, and include a element. -async function waitForUserActivation() { - if (window.opener) { - throw new Error( - "waitForUserActivation() only works in the top-level frame"); - } - const loadedPromise = new Promise(resolve => { - if(document.readyState == 'complete') { - resolve(); - return; - } - window.addEventListener('load', resolve, {once: true}); - }); - await loadedPromise; - - const clickedPromise = new Promise(resolve => { - document.body.addEventListener('click', resolve, {once: true}); - }); - - test_driver.click(document.body); - await clickedPromise; -} - async function trySetPermission(perm, state) { try { await test_driver.set_permission({ name: perm }, state) diff --git a/clipboard-apis/text-write-read/async-write-read.https.html b/clipboard-apis/text-write-read/async-write-read.https.html index 516783edaedf85..1605830411a913 100644 --- a/clipboard-apis/text-write-read/async-write-read.https.html +++ b/clipboard-apis/text-write-read/async-write-read.https.html @@ -20,9 +20,9 @@ const blobInput = new Blob([textInput], {type: 'text/plain'}); const clipboardItemInput = new ClipboardItem({'text/plain': blobInput}); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.write([clipboardItemInput]); - await waitForUserActivation(); + await test_driver.bless(); const clipboardItems = await navigator.clipboard.read(); assert_equals(clipboardItems.length, 1); const clipboardItemOutput = clipboardItems[0]; diff --git a/clipboard-apis/text-write-read/async-write-readText.https.html b/clipboard-apis/text-write-read/async-write-readText.https.html index ab7b619ac99ed4..de231268b07569 100644 --- a/clipboard-apis/text-write-read/async-write-readText.https.html +++ b/clipboard-apis/text-write-read/async-write-readText.https.html @@ -19,9 +19,9 @@ const blobInput = new Blob([textInput], {type: 'text/plain'}); const clipboardItem = new ClipboardItem({'text/plain': blobInput}); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.write([clipboardItem]); - await waitForUserActivation(); + await test_driver.bless(); const textOutput = await navigator.clipboard.readText(); assert_equals(textOutput, textInput); diff --git a/clipboard-apis/text-write-read/async-writeText-read.https.html b/clipboard-apis/text-write-read/async-writeText-read.https.html index 40f26d4786a6b7..5fc4497ae7c8ca 100644 --- a/clipboard-apis/text-write-read/async-writeText-read.https.html +++ b/clipboard-apis/text-write-read/async-writeText-read.https.html @@ -16,9 +16,9 @@ await tryGrantReadPermission(); await tryGrantWritePermission(); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.writeText(textInput); - await waitForUserActivation(); + await test_driver.bless(); const clipboardItems = await navigator.clipboard.read(); assert_equals(clipboardItems.length, 1); const clipboardItem = clipboardItems[0]; diff --git a/clipboard-apis/text-write-read/async-writeText-readText.https.html b/clipboard-apis/text-write-read/async-writeText-readText.https.html index 647a00e050b5c0..d309c7a5ff0188 100644 --- a/clipboard-apis/text-write-read/async-writeText-readText.https.html +++ b/clipboard-apis/text-write-read/async-writeText-readText.https.html @@ -14,9 +14,9 @@ await tryGrantReadPermission(); await tryGrantWritePermission(); - await waitForUserActivation(); + await test_driver.bless(); await navigator.clipboard.writeText(textInput); - await waitForUserActivation(); + await test_driver.bless(); const textOutput = await navigator.clipboard.readText(); assert_equals(textOutput, textInput);