Title: [263567] trunk
- Revision
- 263567
- Author
- [email protected]
- Date
- 2020-06-26 10:00:50 -0700 (Fri, 26 Jun 2020)
Log Message
Add a test to verify that async clipboard API write access is granted when copying in subframes
https://bugs.webkit.org/show_bug.cgi?id=213581
Reviewed by Darin Adler.
Source/WebKitLegacy/mac:
* WebView/WebView.mm:
(-[WebView _executeCoreCommandByName:value:]):
Adjust the behavior of this SPI to trigger the editing command in the focused frame, rather than always the
mainframe. This matches the behavior of `WKBundlePageExecuteEditingCommand`, and is also consistent with
user-triggered editing commands.
LayoutTests:
Add a new test to verify that clipboard write access is granted when copying in a subframe.
* editing/async-clipboard/clipboard-write-in-copy-event-handler-in-subframe-expected.txt: Added.
* editing/async-clipboard/clipboard-write-in-copy-event-handler-in-subframe.html: Added.
* platform/win/TestExpectations:
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (263566 => 263567)
--- trunk/LayoutTests/ChangeLog 2020-06-26 16:51:47 UTC (rev 263566)
+++ trunk/LayoutTests/ChangeLog 2020-06-26 17:00:50 UTC (rev 263567)
@@ -1,3 +1,16 @@
+2020-06-26 Wenson Hsieh <[email protected]>
+
+ Add a test to verify that async clipboard API write access is granted when copying in subframes
+ https://bugs.webkit.org/show_bug.cgi?id=213581
+
+ Reviewed by Darin Adler.
+
+ Add a new test to verify that clipboard write access is granted when copying in a subframe.
+
+ * editing/async-clipboard/clipboard-write-in-copy-event-handler-in-subframe-expected.txt: Added.
+ * editing/async-clipboard/clipboard-write-in-copy-event-handler-in-subframe.html: Added.
+ * platform/win/TestExpectations:
+
2020-06-26 Karl Rackler <[email protected]>
Change expectations to http/tests/webarchive/test-css-url-encoding-shift-jis.html and
Added: trunk/LayoutTests/editing/async-clipboard/clipboard-write-in-copy-event-handler-in-subframe-expected.txt (0 => 263567)
--- trunk/LayoutTests/editing/async-clipboard/clipboard-write-in-copy-event-handler-in-subframe-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/async-clipboard/clipboard-write-in-copy-event-handler-in-subframe-expected.txt 2020-06-26 17:00:50 UTC (rev 263567)
@@ -0,0 +1,10 @@
+This test verifies that clipboard items can be written while dispatching the 'copy' event. To manually run the test, copy the 'Copy me' text below.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyWrote is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/editing/async-clipboard/clipboard-write-in-copy-event-handler-in-subframe.html (0 => 263567)
--- trunk/LayoutTests/editing/async-clipboard/clipboard-write-in-copy-event-handler-in-subframe.html (rev 0)
+++ trunk/LayoutTests/editing/async-clipboard/clipboard-write-in-copy-event-handler-in-subframe.html 2020-06-26 17:00:50 UTC (rev 263567)
@@ -0,0 +1,60 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true experimental:AsyncClipboardAPIEnabled=true ] -->
+<html>
+ <meta charset="utf8">
+ <head>
+ <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+ <script src=""
+ <style>
+ button {
+ width: 100px;
+ padding: 1em;
+ }
+ </style>
+ </head>
+ <script>
+ jsTestIsAsync = true;
+ successfullyWrote = false;
+
+ if (window.testRunner)
+ testRunner.setJavaScriptCanAccessClipboard(false);
+
+ description("This test verifies that clipboard items can be written while dispatching the 'copy' event. To manually run the test, copy the 'Copy me' text below.");
+
+ addEventListener("load", function() {
+ addEventListener("message", event => {
+ if (event.data ="" "finished") {
+ shouldBeTrue("successfullyWrote");
+ finishJSTest();
+ }
+ });
+
+ const frame = document.querySelector("iframe");
+ frame.focus();
+
+ const frameDocument = frame.contentDocument;
+ frameDocument.getSelection().selectAllChildren(frameDocument.getElementById("target"));
+
+ if (window.testRunner)
+ testRunner.execCommand("Copy");
+ });
+ </script>
+ <body>
+ <iframe srcdoc="<span id='target'>Copy me</span>
+ <script>
+ const target = document.getElementById('target');
+ const textBlob = new Blob([ (new TextEncoder()).encode('Hello world') ], { type : 'text/plain' });
+ target.addEventListener('copy', async event => {
+ try {
+ event.preventDefault();
+ await navigator.clipboard.write([ new ClipboardItem({ 'text/plain' : textBlob })]);
+ parent.successfullyWrote = true;
+ } catch (e) {
+ console.log(e);
+ } finally {
+ parent.postMessage('finished', '*');
+ }
+ });
+ </script>
+ "></iframe>
+ </body>
+</html>
Modified: trunk/LayoutTests/platform/win/TestExpectations (263566 => 263567)
--- trunk/LayoutTests/platform/win/TestExpectations 2020-06-26 16:51:47 UTC (rev 263566)
+++ trunk/LayoutTests/platform/win/TestExpectations 2020-06-26 17:00:50 UTC (rev 263567)
@@ -1203,6 +1203,7 @@
webkit.org/b/203100 editing/async-clipboard/clipboard-write-basic.html [ Skip ]
webkit.org/b/203100 editing/async-clipboard/clipboard-write-items-twice.html [ Skip ]
webkit.org/b/203100 editing/async-clipboard/clipboard-write-in-copy-event-handler.html [ Skip ]
+webkit.org/b/203100 editing/async-clipboard/clipboard-write-in-copy-event-handler-in-subframe.html [ Skip ]
webkit.org/b/203100 editing/async-clipboard/clipboard-write-text.html [ Skip ]
webkit.org/b/203100 editing/async-clipboard/clipboard-do-not-read-text-from-platform-if-text-changes.html [ Skip ]
webkit.org/b/203100 editing/async-clipboard/clipboard-read-text-from-platform.html [ Skip ]
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (263566 => 263567)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2020-06-26 16:51:47 UTC (rev 263566)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2020-06-26 17:00:50 UTC (rev 263567)
@@ -1,3 +1,17 @@
+2020-06-26 Wenson Hsieh <[email protected]>
+
+ Add a test to verify that async clipboard API write access is granted when copying in subframes
+ https://bugs.webkit.org/show_bug.cgi?id=213581
+
+ Reviewed by Darin Adler.
+
+ * WebView/WebView.mm:
+ (-[WebView _executeCoreCommandByName:value:]):
+
+ Adjust the behavior of this SPI to trigger the editing command in the focused frame, rather than always the
+ mainframe. This matches the behavior of `WKBundlePageExecuteEditingCommand`, and is also consistent with
+ user-triggered editing commands.
+
2020-06-24 David Kilzer <[email protected]>
Use ObjectIdentifier<>instead of WebCore::nextPlaybackTargetClientContextId() in Document.cpp
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (263566 => 263567)
--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2020-06-26 16:51:47 UTC (rev 263566)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2020-06-26 17:00:50 UTC (rev 263567)
@@ -4580,10 +4580,8 @@
- (void)_executeCoreCommandByName:(NSString *)name value:(NSString *)value
{
- auto* coreFrame = [self _mainCoreFrame];
- if (!coreFrame)
- return;
- coreFrame->editor().command(name).execute(value);
+ if (auto* page = _private->page)
+ page->focusController().focusedOrMainFrame().editor().command(name).execute(value);
}
- (void)_clearMainFrameName
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes