Title: [214556] trunk
Revision
214556
Author
wenson_hs...@apple.com
Date
2017-03-29 12:29:25 -0700 (Wed, 29 Mar 2017)

Log Message

Links with empty hrefs should not be drag sources
https://bugs.webkit.org/show_bug.cgi?id=170241
<rdar://problem/31305505>

Reviewed by Tim Horton.

Source/WebCore:

The m_dragSouceAction member of DragController represents the drag source actions that are available to the
document, rather than the available actions given the dragging element. Thus, it is not correct to only check
that (m_dragSourceAction & DragSourceActionAttachment) before proceeding down the attachment dragging codepath.
This should be additionally guarded with a check that the element being dragged is, in fact, an attachment
element.

New API test (see Tools/ChangeLog).

* page/DragController.cpp:
(WebCore::DragController::startDrag):

Tools:

Adds a new API test: DataInteractionTests.LinkWithEmptyHREF.

* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/ios/DataInteractionSimulator.h:

Expose the current phase of the data interaction simulator for verifying behaviors in unit tests.

* TestWebKitAPI/ios/DataInteractionSimulator.mm:
(-[DataInteractionSimulator phase]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (214555 => 214556)


--- trunk/Source/WebCore/ChangeLog	2017-03-29 19:25:39 UTC (rev 214555)
+++ trunk/Source/WebCore/ChangeLog	2017-03-29 19:29:25 UTC (rev 214556)
@@ -1,3 +1,22 @@
+2017-03-29  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Links with empty hrefs should not be drag sources
+        https://bugs.webkit.org/show_bug.cgi?id=170241
+        <rdar://problem/31305505>
+
+        Reviewed by Tim Horton.
+
+        The m_dragSouceAction member of DragController represents the drag source actions that are available to the
+        document, rather than the available actions given the dragging element. Thus, it is not correct to only check
+        that (m_dragSourceAction & DragSourceActionAttachment) before proceeding down the attachment dragging codepath.
+        This should be additionally guarded with a check that the element being dragged is, in fact, an attachment
+        element.
+
+        New API test (see Tools/ChangeLog).
+
+        * page/DragController.cpp:
+        (WebCore::DragController::startDrag):
+
 2017-03-29  Jeremy Jones  <jere...@apple.com>
 
         WebVideoFullscreenInterfaceAVKit needs a strong self ref before dispatching to the main thread.

Modified: trunk/Source/WebCore/page/DragController.cpp (214555 => 214556)


--- trunk/Source/WebCore/page/DragController.cpp	2017-03-29 19:25:39 UTC (rev 214555)
+++ trunk/Source/WebCore/page/DragController.cpp	2017-03-29 19:29:25 UTC (rev 214556)
@@ -1013,7 +1013,7 @@
     }
 
 #if ENABLE(ATTACHMENT_ELEMENT)
-    if (m_dragSourceAction & DragSourceActionAttachment) {
+    if (is<HTMLAttachmentElement>(element) && m_dragSourceAction & DragSourceActionAttachment) {
         if (!dataTransfer.pasteboard().hasData()) {
             selectElement(element);
             if (!attachmentURL.isEmpty()) {

Modified: trunk/Tools/ChangeLog (214555 => 214556)


--- trunk/Tools/ChangeLog	2017-03-29 19:25:39 UTC (rev 214555)
+++ trunk/Tools/ChangeLog	2017-03-29 19:29:25 UTC (rev 214556)
@@ -1,3 +1,22 @@
+2017-03-29  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Links with empty hrefs should not be drag sources
+        https://bugs.webkit.org/show_bug.cgi?id=170241
+        <rdar://problem/31305505>
+
+        Reviewed by Tim Horton.
+
+        Adds a new API test: DataInteractionTests.LinkWithEmptyHREF.
+
+        * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/ios/DataInteractionSimulator.h:
+
+        Expose the current phase of the data interaction simulator for verifying behaviors in unit tests.
+
+        * TestWebKitAPI/ios/DataInteractionSimulator.mm:
+        (-[DataInteractionSimulator phase]):
+
 2017-03-29  Jonathan Bedard  <jbed...@apple.com>
 
         Use TCP instead of FIFOs for Simulator/Device communication

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm (214555 => 214556)


--- trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm	2017-03-29 19:25:39 UTC (rev 214555)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm	2017-03-29 19:29:25 UTC (rev 214556)
@@ -172,6 +172,7 @@
     RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
     [dataInteractionSimulator runFrom:CGPointMake(100, 50) to:CGPointMake(100, 300)];
 
+    EXPECT_EQ(DataInteractionCancelled, [dataInteractionSimulator phase]);
     EXPECT_FALSE([webView editorContainsImageElement]);
 
     NSArray *observedEventNames = [dataInteractionSimulator observedEventNames];
@@ -292,6 +293,19 @@
     EXPECT_WK_STREQ("PASS", [webView stringByEvaluatingJavaScript:@"target.textContent"].UTF8String);
 }
 
+TEST(DataInteractionTests, LinkWithEmptyHREF)
+{
+    RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    [webView synchronouslyLoadTestPageNamed:@"link-and-input"];
+    [webView stringByEvaluatingJavaScript:@"document.querySelector('a').href = ''"];
+
+    RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
+    [dataInteractionSimulator runFrom:CGPointMake(100, 50) to:CGPointMake(100, 300)];
+
+    EXPECT_EQ(DataInteractionCancelled, [dataInteractionSimulator phase]);
+    EXPECT_WK_STREQ("", [webView editorValue].UTF8String);
+}
+
 } // namespace TestWebKitAPI
 
 #endif // ENABLE(DATA_INTERACTION)

Modified: trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h (214555 => 214556)


--- trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h	2017-03-29 19:25:39 UTC (rev 214555)
+++ trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h	2017-03-29 19:29:25 UTC (rev 214556)
@@ -71,6 +71,7 @@
 @property (nonatomic, strong) UIItemProvider *externalItemProvider;
 @property (nonatomic, readonly) NSArray *observedEventNames;
 @property (nonatomic, readonly) NSArray *finalSelectionRects;
+@property (nonatomic, readonly) DataInteractionPhase phase;
 
 @end
 

Modified: trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm (214555 => 214556)


--- trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm	2017-03-29 19:25:39 UTC (rev 214555)
+++ trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm	2017-03-29 19:29:25 UTC (rev 214556)
@@ -209,6 +209,11 @@
     _externalItemProvider = externalItemProvider;
 }
 
+- (DataInteractionPhase)phase
+{
+    return _phase;
+}
+
 #pragma mark - _WKTestingDelegate
 
 - (void)webViewDidPerformDataInteractionControllerOperation:(WKWebView *)webView
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to