<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[212254] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/212254">212254</a></dd>
<dt>Author</dt> <dd>wenson_hsieh@apple.com</dd>
<dt>Date</dt> <dd>2017-02-13 15:10:10 -0800 (Mon, 13 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WK2] Add test infrastructure and unit tests for data interaction
https://bugs.webkit.org/show_bug.cgi?id=168159
&lt;rdar://problem/30477634&gt;

Reviewed by Tim Horton.

Source/WebKit2:

Adds support at the WebKit2 layer for testing data interaction. Introduces the _WKTestingDelegate, which a
protocol which can specified for a WKWebView and used to install mock objects and simulate the state of the
platform. By default, this delegate is nil, which results in normal behavior. For data interaction, we are able
to specify a mock data interaction gesture recognizer for use by the WKContentView to simulate firing a long
press and subsequent movement. This gesture recognizer is used in place of the regular data interaction gesture
recognizer, and allows for TestWebKitAPI to drive interaction without actually sending events through the
UIApplication. The _WKTestingDelegate also contains optional method hooks which are invoked at key points in
time when performing a data interaction gesture.

Since all methods of the testing delegate are optional, the testing delegate can be easily extended to support
testing for other features -- the idea is that leaving all but the relevant methods in the protocol
unimplemented will result in default behavior for everything other than those methods, so a client need only
implement and add WebKit2 hooks for a few methods to support testing for a new feature.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _testingDelegate]):
(-[WKWebView _setTestingDelegate:]):

Specify the testing delegate to use for this WKWebView (see above for more details).

(-[WKWebView _simulateDataInteractionGestureRecognized]):
(-[WKWebView _simulateDataInteractionEntered:]):
(-[WKWebView _simulateDataInteractionUpdated:]):
(-[WKWebView _simulateDataInteractionPerformOperation:]):
(-[WKWebView _simulateDataInteractionEnded:]):
(-[WKWebView _simulateDataInteractionSessionDidEnd:withOperation:]):
(-[WKWebView _simulateFailedDataInteractionWithIndex:]):
(-[WKWebView _simulateWillBeginDataInteractionWithIndex:withSession:]):
(-[WKWebView _simulatedItemsForDataInteractionWithIndex:]):

Used by TestWebKitAPI to drive data interaction tests. See DataInteractionTests.mm.

* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/Cocoa/_WKTestingDelegate.h: Added.
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setupInteraction]):
(-[WKContentView _dataInteractionGestureRecognizer]):
* WebKit2.xcodeproj/project.pbxproj:

Tools:

Uses the testing delegate introduced in WebKit2 to override the gesture recognizer used to initiate data
interaction. Instead of being driven by UIKit, the DataInteractionSimulator drives this overridden gesture
recognizer by making the WKContentView call its dataInteractionGestureRecognized method. To simulate an actual
gesture being performed, we fire the gesture recognizer (or call the data interaction delegate methods, if the
gesture has already been recognized) at regular intervals over the course of the test.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/autofocus-contenteditable.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/image-and-contenteditable.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/image-and-textarea.html: Added.

New test pages for data interaction.

* TestWebKitAPI/Tests/ios/DataInteractionTests.mm: Added.
(TestWebKitAPI::runTestsExpectingToObserveEvents):
(TestWebKitAPI::TEST):
* TestWebKitAPI/cocoa/TestWKWebView.mm:
(-[TestWKWebView stringByEvaluatingJavaScript:]):
* TestWebKitAPI/ios/DataInteractionSimulator.h: Added.
* TestWebKitAPI/ios/DataInteractionSimulator.mm: Added.
(-[MockLongPressGestureRecognizer initWithWindow:]):
(-[MockLongPressGestureRecognizer locationInView:]):
(-[MockLongPressGestureRecognizer state]):
(-[MockLongPressGestureRecognizer numberOfTouches]):
(-[DataInteractionSimulator initWithWebView:startLocation:endLocation:]):
(-[DataInteractionSimulator dealloc]):
(-[DataInteractionSimulator run]):

Performs a data interaction gesture from the start location to the end location with linear interpolation. For
now, the timestep and progress per tick are 30ms and 3.33%, respectively, which means that tests should complete
in a little under 1 second, though this can be easily changed to be configurable in the future if needed.

(-[DataInteractionSimulator _advanceProgress]):

Fired periodically to drive the data interaction gesture. Schedules a call of itself until the test is
completed, and calls _finishDataInteraction when progress is at 1.

(-[DataInteractionSimulator _finishDataInteraction]):
(-[DataInteractionSimulator _currentLocation]):
(-[DataInteractionSimulator _scheduleAdvanceProgress]):
(-[DataInteractionSimulator _recognizeGestureAtLocation:withState:]):
(-[DataInteractionSimulator dataInteractionGestureRecognizer]):
(-[DataInteractionSimulator webViewDidPerformDataInteractionControllerOperation:]):
(-[DataInteractionSimulator webView:beginDataInteractionWithSourceIndex:gestureRecognizer:]):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionh">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPIcocoaTestWKWebViewmm">trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKTestingDelegateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKTestingDelegate.h</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoaautofocuscontenteditablehtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autofocus-contenteditable.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoaimageandcontenteditablehtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/image-and-contenteditable.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoaimageandtextareahtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/image-and-textarea.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsiosDataInteractionTestsmm">trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPIiosDataInteractionSimulatorh">trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h</a></li>
<li><a href="#trunkToolsTestWebKitAPIiosDataInteractionSimulatormm">trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (212253 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-02-13 23:07:44 UTC (rev 212253)
+++ trunk/Source/WebKit2/ChangeLog        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -1,3 +1,51 @@
</span><ins>+2017-02-13  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
+
+        [WK2] Add test infrastructure and unit tests for data interaction
+        https://bugs.webkit.org/show_bug.cgi?id=168159
+        &lt;rdar://problem/30477634&gt;
+
+        Reviewed by Tim Horton.
+
+        Adds support at the WebKit2 layer for testing data interaction. Introduces the _WKTestingDelegate, which a
+        protocol which can specified for a WKWebView and used to install mock objects and simulate the state of the
+        platform. By default, this delegate is nil, which results in normal behavior. For data interaction, we are able
+        to specify a mock data interaction gesture recognizer for use by the WKContentView to simulate firing a long
+        press and subsequent movement. This gesture recognizer is used in place of the regular data interaction gesture
+        recognizer, and allows for TestWebKitAPI to drive interaction without actually sending events through the
+        UIApplication. The _WKTestingDelegate also contains optional method hooks which are invoked at key points in
+        time when performing a data interaction gesture.
+
+        Since all methods of the testing delegate are optional, the testing delegate can be easily extended to support
+        testing for other features -- the idea is that leaving all but the relevant methods in the protocol
+        unimplemented will result in default behavior for everything other than those methods, so a client need only
+        implement and add WebKit2 hooks for a few methods to support testing for a new feature.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _testingDelegate]):
+        (-[WKWebView _setTestingDelegate:]):
+
+        Specify the testing delegate to use for this WKWebView (see above for more details).
+
+        (-[WKWebView _simulateDataInteractionGestureRecognized]):
+        (-[WKWebView _simulateDataInteractionEntered:]):
+        (-[WKWebView _simulateDataInteractionUpdated:]):
+        (-[WKWebView _simulateDataInteractionPerformOperation:]):
+        (-[WKWebView _simulateDataInteractionEnded:]):
+        (-[WKWebView _simulateDataInteractionSessionDidEnd:withOperation:]):
+        (-[WKWebView _simulateFailedDataInteractionWithIndex:]):
+        (-[WKWebView _simulateWillBeginDataInteractionWithIndex:withSession:]):
+        (-[WKWebView _simulatedItemsForDataInteractionWithIndex:]):
+
+        Used by TestWebKitAPI to drive data interaction tests. See DataInteractionTests.mm.
+
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/API/Cocoa/_WKTestingDelegate.h: Added.
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView setupInteraction]):
+        (-[WKContentView _dataInteractionGestureRecognizer]):
+        * WebKit2.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2017-02-13  Eric Carlson  &lt;eric.carlson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [MediaStream Mac] Video capture needs access to /Library/CoreMediaIO/Plug-Ins/DAL/
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (212253 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2017-02-13 23:07:44 UTC (rev 212253)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -86,6 +86,7 @@
</span><span class="cx"> #import &quot;_WKInputDelegate.h&quot;
</span><span class="cx"> #import &quot;_WKRemoteObjectRegistryInternal.h&quot;
</span><span class="cx"> #import &quot;_WKSessionStateInternal.h&quot;
</span><ins>+#import &quot;_WKTestingDelegate.h&quot;
</ins><span class="cx"> #import &quot;_WKVisitedLinkStoreInternal.h&quot;
</span><span class="cx"> #import &quot;_WKWebsitePoliciesInternal.h&quot;
</span><span class="cx"> #import &lt;WebCore/GraphicsContextCG.h&gt;
</span><span class="lines">@@ -286,6 +287,8 @@
</span><span class="cx">     std::unique_ptr&lt;WebKit::WebViewImpl&gt; _impl;
</span><span class="cx">     RetainPtr&lt;WKTextFinderClient&gt; _textFinderClient;
</span><span class="cx"> #endif
</span><ins>+
+    id&lt;_WKTestingDelegate&gt; _testingDelegate;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (instancetype)initWithFrame:(CGRect)frame
</span><span class="lines">@@ -4874,6 +4877,16 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (id&lt;_WKTestingDelegate&gt;)_testingDelegate
+{
+    return _testingDelegate;
+}
+
+- (void)_setTestingDelegate:(id&lt;_WKTestingDelegate&gt;)testingDelegate
+{
+    _testingDelegate = testingDelegate;
+}
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> 
</span><span class="cx"> - (CGRect)_contentVisibleRect
</span><span class="lines">@@ -5098,6 +5111,72 @@
</span><span class="cx">     WebKit::ViewSnapshotStore::singleton().setDisableSnapshotVolatilityForTesting(true);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+
+- (void)_simulateDataInteractionGestureRecognized
+{
+#if ENABLE(DATA_INTERACTION)
+    [_contentView _simulateDataInteractionGestureRecognized:_testingDelegate.dataInteractionGestureRecognizer];
+#endif
+}
+
+- (void)_simulateDataInteractionEntered:(id)info
+{
+#if ENABLE(DATA_INTERACTION)
+    [_contentView _simulateDataInteractionEntered:info];
+#endif
+}
+
+- (void)_simulateDataInteractionUpdated:(id)info
+{
+#if ENABLE(DATA_INTERACTION)
+    [_contentView _simulateDataInteractionUpdated:info];
+#endif
+}
+
+- (void)_simulateDataInteractionPerformOperation:(id)info
+{
+#if ENABLE(DATA_INTERACTION)
+    [_contentView _simulateDataInteractionPerformOperation:info];
+#endif
+}
+
+- (void)_simulateDataInteractionEnded:(id)info
+{
+#if ENABLE(DATA_INTERACTION)
+    [_contentView _simulateDataInteractionEnded:info];
+#endif
+}
+
+- (void)_simulateDataInteractionSessionDidEnd:(id)session withOperation:(NSUInteger)operation
+{
+#if ENABLE(DATA_INTERACTION)
+    [_contentView _simulateDataInteractionSessionDidEnd:session withOperation:operation];
+#endif
+}
+
+- (void)_simulateFailedDataInteractionWithIndex:(NSInteger)sourceIndex
+{
+#if ENABLE(DATA_INTERACTION)
+    [_contentView _simulateFailedDataInteractionWithIndex:sourceIndex];
+#endif
+}
+
+- (void)_simulateWillBeginDataInteractionWithIndex:(NSInteger)sourceIndex withSession:(id)session
+{
+#if ENABLE(DATA_INTERACTION)
+    [_contentView _simulateWillBeginDataInteractionWithIndex:sourceIndex withSession:session];
+#endif
+}
+
+- (NSArray *)_simulatedItemsForDataInteractionWithIndex:(NSInteger)sourceIndex
+{
+#if ENABLE(DATA_INTERACTION)
+    return [_contentView _simulatedItemsForDataInteractionWithIndex:sourceIndex];
+#else
+    return @[ ];
+#endif
+}
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (212253 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2017-02-13 23:07:44 UTC (rev 212253)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -68,6 +68,7 @@
</span><span class="cx"> @protocol _WKIconLoadingDelegate;
</span><span class="cx"> @protocol _WKInputDelegate;
</span><span class="cx"> @protocol _WKFullscreenDelegate;
</span><ins>+@protocol _WKTestingDelegate;
</ins><span class="cx"> 
</span><span class="cx"> @interface WKWebView (WKPrivate)
</span><span class="cx"> 
</span><span class="lines">@@ -276,6 +277,7 @@
</span><span class="cx"> @interface WKWebView (WKTesting)
</span><span class="cx"> 
</span><span class="cx"> - (NSDictionary *)_contentsOfUserInterfaceItem:(NSString *)userInterfaceItem WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
</span><ins>+@property (nonatomic, weak, setter=_setTestingDelegate:) id&lt;_WKTestingDelegate&gt; _testingDelegate WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
</ins><span class="cx"> 
</span><span class="cx"> #if TARGET_OS_IPHONE
</span><span class="cx"> 
</span><span class="lines">@@ -303,6 +305,16 @@
</span><span class="cx"> 
</span><span class="cx"> @property (nonatomic, readonly) NSNumber *_stableStateOverride WK_API_AVAILABLE(ios(WK_IOS_TBA));
</span><span class="cx"> 
</span><ins>+- (void)_simulateDataInteractionGestureRecognized WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_simulateDataInteractionEntered:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_simulateDataInteractionUpdated:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_simulateDataInteractionPerformOperation:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_simulateDataInteractionEnded:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_simulateDataInteractionSessionDidEnd:(id)session withOperation:(NSUInteger)operation WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_simulateFailedDataInteractionWithIndex:(NSInteger)sourceIndex WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_simulateWillBeginDataInteractionWithIndex:(NSInteger)sourceIndex withSession:(id)session WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (NSArray *)_simulatedItemsForDataInteractionWithIndex:(NSInteger)sourceIndex WK_API_AVAILABLE(ios(WK_IOS_TBA));
+
</ins><span class="cx"> #endif // TARGET_OS_IPHONE
</span><span class="cx"> 
</span><span class="cx"> #if !TARGET_OS_IPHONE
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKTestingDelegateh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKTestingDelegate.h (0 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKTestingDelegate.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKTestingDelegate.h        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &lt;WebKit/WKFoundation.h&gt;
+
+#if WK_API_ENABLED
+
+#import &lt;wtf/RetainPtr.h&gt;
+
+@class WKWebView;
+
+#if TARGET_OS_IPHONE
+@class UIGestureRecognizer;
+@class UILongPressGestureRecognizer;
+#endif
+
+NS_ASSUME_NONNULL_BEGIN
+
+@protocol _WKTestingDelegate &lt;NSObject&gt;
+@optional
+
+#if TARGET_OS_IPHONE
+@property (nonatomic, readonly) UILongPressGestureRecognizer *dataInteractionGestureRecognizer;
+- (void)webViewDidPerformDataInteractionControllerOperation:(WKWebView *)webView;
+- (void)webView:(WKWebView *)webView beginDataInteractionWithSourceIndex:(NSInteger)sourceIndex gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer;
+#endif // TARGET_OS_PHONE
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif // WK_API_ENABLED
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (212253 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2017-02-13 23:07:44 UTC (rev 212253)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -271,6 +271,15 @@
</span><span class="cx"> - (void)_didPerformDataInteractionControllerOperation;
</span><span class="cx"> - (void)_didHandleStartDataInteractionRequest:(BOOL)started;
</span><span class="cx"> - (void)_startDataInteractionWithImage:(RetainPtr&lt;CGImageRef&gt;)image atClientPosition:(CGPoint)clientPosition anchorPoint:(CGPoint)anchorPoint isLink:(BOOL)isLink;
</span><ins>+- (void)_simulateDataInteractionGestureRecognized:(UILongPressGestureRecognizer *)gestureRecognizer WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_simulateDataInteractionEntered:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_simulateDataInteractionUpdated:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_simulateDataInteractionPerformOperation:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_simulateDataInteractionEnded:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_simulateDataInteractionSessionDidEnd:(id)session withOperation:(NSUInteger)operation WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_simulateFailedDataInteractionWithIndex:(NSInteger)sourceIndex WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_simulateWillBeginDataInteractionWithIndex:(NSInteger)sourceIndex withSession:(id)session WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (NSArray *)_simulatedItemsForDataInteractionWithIndex:(NSInteger)sourceIndex WK_API_AVAILABLE(ios(WK_IOS_TBA));
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (212253 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2017-02-13 23:07:44 UTC (rev 212253)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx"> #import &quot;_WKFocusedElementInfo.h&quot;
</span><span class="cx"> #import &quot;_WKFormInputSession.h&quot;
</span><span class="cx"> #import &quot;_WKInputDelegate.h&quot;
</span><ins>+#import &quot;_WKTestingDelegate.h&quot;
</ins><span class="cx"> #import &lt;CoreText/CTFont.h&gt;
</span><span class="cx"> #import &lt;CoreText/CTFontDescriptor.h&gt;
</span><span class="cx"> #import &lt;MobileCoreServices/UTCoreTypes.h&gt;
</span><span class="lines">@@ -557,7 +558,7 @@
</span><span class="cx">     [self _createAndConfigureLongPressGestureRecognizer];
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(DATA_INTERACTION)
</span><del>-    _dataInteractionGestureRecognizer = adoptNS([[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(_dataInteractionGestureRecognizer:)]);
</del><ins>+    _dataInteractionGestureRecognizer = adoptNS([[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(_dataInteractionGestureRecognized:)]);
</ins><span class="cx">     [_dataInteractionGestureRecognizer setDelay:0.5];
</span><span class="cx">     [_dataInteractionGestureRecognizer setDelegate:self];
</span><span class="cx">     [_dataInteractionGestureRecognizer _setRequiresQuietImpulse:YES];
</span><span class="lines">@@ -1467,6 +1468,14 @@
</span><span class="cx">     return _positionInformation.hasDataInteractionAtPosition;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (UILongPressGestureRecognizer *)_dataInteractionGestureRecognizer
+{
+    if ([_webView._testingDelegate respondsToSelector:@selector(dataInteractionGestureRecognizer)])
+        return _webView._testingDelegate.dataInteractionGestureRecognizer;
+
+    return _dataInteractionGestureRecognizer.get();
+}
+
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)pointIsNearMarkedText:(CGPoint)point
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (212253 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2017-02-13 23:07:44 UTC (rev 212253)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -1947,6 +1947,7 @@
</span><span class="cx">                 ED82A7F2128C6FAF004477B3 /* WKBundlePageOverlay.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A22F0FF1289FCD90085E74F /* WKBundlePageOverlay.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 EDCA71B7128DDA8C00201B26 /* WKBundlePageOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A22F1001289FCD90085E74F /* WKBundlePageOverlay.cpp */; };
</span><span class="cx">                 F036978815F4BF0500C3A80E /* WebColorPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F036978715F4BF0500C3A80E /* WebColorPicker.cpp */; };
</span><ins>+                F43370971E4D72ED00052B0E /* _WKTestingDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = F43370961E4D6A4400052B0E /* _WKTestingDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 F6113E25126CE1820057D0A7 /* APIUserContentURLPattern.h in Headers */ = {isa = PBXBuildFile; fileRef = F6113E24126CE1820057D0A7 /* APIUserContentURLPattern.h */; };
</span><span class="cx">                 F6113E28126CE19B0057D0A7 /* WKUserContentURLPattern.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6113E26126CE19B0057D0A7 /* WKUserContentURLPattern.cpp */; };
</span><span class="cx">                 F6113E29126CE19B0057D0A7 /* WKUserContentURLPattern.h in Headers */ = {isa = PBXBuildFile; fileRef = F6113E27126CE19B0057D0A7 /* WKUserContentURLPattern.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -4197,6 +4198,7 @@
</span><span class="cx">                 E4E8648E1B1673FB00C82F40 /* VersionChecks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VersionChecks.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E4E8648F1B1673FB00C82F40 /* VersionChecks.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VersionChecks.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F036978715F4BF0500C3A80E /* WebColorPicker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebColorPicker.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                F43370961E4D6A4400052B0E /* _WKTestingDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKTestingDelegate.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 F6113E24126CE1820057D0A7 /* APIUserContentURLPattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIUserContentURLPattern.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F6113E26126CE19B0057D0A7 /* WKUserContentURLPattern.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKUserContentURLPattern.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F6113E27126CE19B0057D0A7 /* WKUserContentURLPattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUserContentURLPattern.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5397,6 +5399,7 @@
</span><span class="cx">                                 1A002D3F196B329400B9AD44 /* _WKSessionState.h */,
</span><span class="cx">                                 1A002D3E196B329400B9AD44 /* _WKSessionState.mm */,
</span><span class="cx">                                 1A002D42196B337000B9AD44 /* _WKSessionStateInternal.h */,
</span><ins>+                                F43370961E4D6A4400052B0E /* _WKTestingDelegate.h */,
</ins><span class="cx">                                 2D6B371918A967AD0042AE80 /* _WKThumbnailView.h */,
</span><span class="cx">                                 2D6B371A18A967AD0042AE80 /* _WKThumbnailView.mm */,
</span><span class="cx">                                 2DACE64D18ADBFF000E4CA76 /* _WKThumbnailViewInternal.h */,
</span><span class="lines">@@ -8623,6 +8626,7 @@
</span><span class="cx">                                 373CEAD6185417AE008C363D /* WKNSData.h in Headers */,
</span><span class="cx">                                 371A19421824D29300F32A5E /* WKNSDictionary.h in Headers */,
</span><span class="cx">                                 372CAF0B1833FD910040AC27 /* WKNSError.h in Headers */,
</span><ins>+                                F43370971E4D72ED00052B0E /* _WKTestingDelegate.h in Headers */,
</ins><span class="cx">                                 375E0E141D66432700EFEC2C /* WKNSNumber.h in Headers */,
</span><span class="cx">                                 378E1A4A18208CD60031007A /* WKNSString.h in Headers */,
</span><span class="cx">                                 378E1A4E18208D700031007A /* WKNSURL.h in Headers */,
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (212253 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-02-13 23:07:44 UTC (rev 212253)
+++ trunk/Tools/ChangeLog        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -1,3 +1,56 @@
</span><ins>+2017-02-13  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
+
+        [WK2] Add test infrastructure and unit tests for data interaction
+        https://bugs.webkit.org/show_bug.cgi?id=168159
+        &lt;rdar://problem/30477634&gt;
+
+        Reviewed by Tim Horton.
+
+        Uses the testing delegate introduced in WebKit2 to override the gesture recognizer used to initiate data
+        interaction. Instead of being driven by UIKit, the DataInteractionSimulator drives this overridden gesture
+        recognizer by making the WKContentView call its dataInteractionGestureRecognized method. To simulate an actual
+        gesture being performed, we fire the gesture recognizer (or call the data interaction delegate methods, if the
+        gesture has already been recognized) at regular intervals over the course of the test.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/autofocus-contenteditable.html: Added.
+        * TestWebKitAPI/Tests/WebKit2Cocoa/image-and-contenteditable.html: Added.
+        * TestWebKitAPI/Tests/WebKit2Cocoa/image-and-textarea.html: Added.
+
+        New test pages for data interaction.
+
+        * TestWebKitAPI/Tests/ios/DataInteractionTests.mm: Added.
+        (TestWebKitAPI::runTestsExpectingToObserveEvents):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/cocoa/TestWKWebView.mm:
+        (-[TestWKWebView stringByEvaluatingJavaScript:]):
+        * TestWebKitAPI/ios/DataInteractionSimulator.h: Added.
+        * TestWebKitAPI/ios/DataInteractionSimulator.mm: Added.
+        (-[MockLongPressGestureRecognizer initWithWindow:]):
+        (-[MockLongPressGestureRecognizer locationInView:]):
+        (-[MockLongPressGestureRecognizer state]):
+        (-[MockLongPressGestureRecognizer numberOfTouches]):
+        (-[DataInteractionSimulator initWithWebView:startLocation:endLocation:]):
+        (-[DataInteractionSimulator dealloc]):
+        (-[DataInteractionSimulator run]):
+
+        Performs a data interaction gesture from the start location to the end location with linear interpolation. For
+        now, the timestep and progress per tick are 30ms and 3.33%, respectively, which means that tests should complete
+        in a little under 1 second, though this can be easily changed to be configurable in the future if needed.
+
+        (-[DataInteractionSimulator _advanceProgress]):
+
+        Fired periodically to drive the data interaction gesture. Schedules a call of itself until the test is
+        completed, and calls _finishDataInteraction when progress is at 1.
+
+        (-[DataInteractionSimulator _finishDataInteraction]):
+        (-[DataInteractionSimulator _currentLocation]):
+        (-[DataInteractionSimulator _scheduleAdvanceProgress]):
+        (-[DataInteractionSimulator _recognizeGestureAtLocation:withState:]):
+        (-[DataInteractionSimulator dataInteractionGestureRecognizer]):
+        (-[DataInteractionSimulator webViewDidPerformDataInteractionControllerOperation:]):
+        (-[DataInteractionSimulator webView:beginDataInteractionWithSourceIndex:gestureRecognizer:]):
+
</ins><span class="cx"> 2017-02-13  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Percent should be allowed in non-special URL hosts
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (212253 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-02-13 23:07:44 UTC (rev 212253)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -553,12 +553,17 @@
</span><span class="cx">                 E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; };
</span><span class="cx">                 F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F415086C1DA040C10044BE9B /* play-audio-on-click.html */; };
</span><span class="cx">                 F42DA5161D8CEFE400336F40 /* large-input-field-focus-onload.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */; };
</span><ins>+                F45B960C1E50708800CFAC5D /* autofocus-contenteditable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F45B960B1E50708200CFAC5D /* autofocus-contenteditable.html */; };
</ins><span class="cx">                 F47728991E4AE3C1007ABF6A /* full-page-contenteditable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F47728981E4AE3AD007ABF6A /* full-page-contenteditable.html */; };
</span><span class="cx">                 F4BFA68E1E4AD08000154298 /* DragAndDropPasteboardTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */; };
</span><span class="cx">                 F4C2AB221DD6D95E00E06D5B /* enormous-video-with-sound.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */; };
</span><ins>+                F4D4F3B61E4E2BCB00BB2767 /* DataInteractionSimulator.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D4F3B41E4E2BCB00BB2767 /* DataInteractionSimulator.mm */; };
+                F4D4F3B91E4E36E400BB2767 /* DataInteractionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D4F3B71E4E36E400BB2767 /* DataInteractionTests.mm */; };
+                F4D4F3BC1E4E511F00BB2767 /* image-and-contenteditable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4D4F3BB1E4E50EF00BB2767 /* image-and-contenteditable.html */; };
</ins><span class="cx">                 F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */; };
</span><span class="cx">                 F4F405BC1D4C0D1C007A9707 /* full-size-autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */; };
</span><span class="cx">                 F4F405BD1D4C0D1C007A9707 /* skinny-autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F405BB1D4C0CF8007A9707 /* skinny-autoplaying-video-with-audio.html */; };
</span><ins>+                F4F93F341E4E918D00E33E2E /* image-and-textarea.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F93F331E4E918500E33E2E /* image-and-textarea.html */; };
</ins><span class="cx">                 F660AA1115A5F631003A1243 /* GetInjectedBundleInitializationUserDataCallback_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F660AA0F15A5F624003A1243 /* GetInjectedBundleInitializationUserDataCallback_Bundle.cpp */; };
</span><span class="cx">                 F660AA1515A61ABF003A1243 /* InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F660AA1415A61ABF003A1243 /* InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp */; };
</span><span class="cx">                 F6B7BE9517469212008A3445 /* DidAssociateFormControls_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6B7BE92174691EF008A3445 /* DidAssociateFormControls_Bundle.cpp */; };
</span><span class="lines">@@ -630,6 +635,9 @@
</span><span class="cx">                         files = (
</span><span class="cx">                                 C25CCA0D1E5141840026CB8A /* AllAhem.svg in Copy Resources */,
</span><span class="cx">                                 C25CCA0B1E5140C10026CB8A /* LineBreaking.html in Copy Resources */,
</span><ins>+                                F45B960C1E50708800CFAC5D /* autofocus-contenteditable.html in Copy Resources */,
+                                F4F93F341E4E918D00E33E2E /* image-and-textarea.html in Copy Resources */,
+                                F4D4F3BC1E4E511F00BB2767 /* image-and-contenteditable.html in Copy Resources */,
</ins><span class="cx">                                 F47728991E4AE3C1007ABF6A /* full-page-contenteditable.html in Copy Resources */,
</span><span class="cx">                                 C99B675F1E39736F00FC6C80 /* no-autoplay-with-controls.html in Copy Resources */,
</span><span class="cx">                                 C99B675D1E39722000FC6C80 /* js-play-with-controls.html in Copy Resources */,
</span><span class="lines">@@ -1373,12 +1381,18 @@
</span><span class="cx">                 F3FC3EE213678B7300126A65 /* libgtest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgtest.a; sourceTree = BUILT_PRODUCTS_DIR; };
</span><span class="cx">                 F415086C1DA040C10044BE9B /* play-audio-on-click.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;play-audio-on-click.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = &quot;large-input-field-focus-onload.html&quot;; path = &quot;Tests/WebKit2Cocoa/large-input-field-focus-onload.html&quot;; sourceTree = SOURCE_ROOT; };
</span><ins>+                F45B960B1E50708200CFAC5D /* autofocus-contenteditable.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;autofocus-contenteditable.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 F47728981E4AE3AD007ABF6A /* full-page-contenteditable.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;full-page-contenteditable.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragAndDropPasteboardTests.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;enormous-video-with-sound.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                F4D4F3B41E4E2BCB00BB2767 /* DataInteractionSimulator.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataInteractionSimulator.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                F4D4F3B51E4E2BCB00BB2767 /* DataInteractionSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataInteractionSimulator.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                F4D4F3B71E4E36E400BB2767 /* DataInteractionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataInteractionTests.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                F4D4F3BB1E4E50EF00BB2767 /* image-and-contenteditable.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;image-and-contenteditable.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;large-video-test-now-playing.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;full-size-autoplaying-video-with-audio.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F4F405BB1D4C0CF8007A9707 /* skinny-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;skinny-autoplaying-video-with-audio.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                F4F93F331E4E918500E33E2E /* image-and-textarea.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;image-and-textarea.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 F660AA0C15A5F061003A1243 /* GetInjectedBundleInitializationUserDataCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetInjectedBundleInitializationUserDataCallback.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F660AA0F15A5F624003A1243 /* GetInjectedBundleInitializationUserDataCallback_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetInjectedBundleInitializationUserDataCallback_Bundle.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F660AA1215A619C8003A1243 /* InjectedBundleInitializationUserDataCallbackWins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleInitializationUserDataCallbackWins.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1617,6 +1631,8 @@
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><span class="cx">                                 2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */,
</span><ins>+                                F4D4F3B41E4E2BCB00BB2767 /* DataInteractionSimulator.mm */,
+                                F4D4F3B51E4E2BCB00BB2767 /* DataInteractionSimulator.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = ios;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -1666,6 +1682,7 @@
</span><span class="cx">                         children = (
</span><span class="cx">                                 A1C4FB6F1BACCEFA003742D0 /* Resources */,
</span><span class="cx">                                 7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */,
</span><ins>+                                F4D4F3B71E4E36E400BB2767 /* DataInteractionTests.mm */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = ios;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -1702,6 +1719,8 @@
</span><span class="cx">                 A16F66B81C40E9E100BD4D24 /* Resources */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                F45B960B1E50708200CFAC5D /* autofocus-contenteditable.html */,
+                                F4F93F331E4E918500E33E2E /* image-and-textarea.html */,
</ins><span class="cx">                                 F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */,
</span><span class="cx">                                 F415086C1DA040C10044BE9B /* play-audio-on-click.html */,
</span><span class="cx">                                 F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */,
</span><span class="lines">@@ -1750,6 +1769,7 @@
</span><span class="cx">                                 51A5877C1D1B3D8D004BA9AF /* IndexedDBMultiProcess-3.html */,
</span><span class="cx">                                 51B1EE941C80FADD0064FB98 /* IndexedDBPersistence-1.html */,
</span><span class="cx">                                 51B1EE951C80FADD0064FB98 /* IndexedDBPersistence-2.html */,
</span><ins>+                                F4D4F3BB1E4E50EF00BB2767 /* image-and-contenteditable.html */,
</ins><span class="cx">                                 2E1B7B011D41B1B3007558B4 /* large-video-hides-controls-after-seek-to-end.html */,
</span><span class="cx">                                 2E1B7AFF1D41A95F007558B4 /* large-video-seek-after-ending.html */,
</span><span class="cx">                                 2E1DFDF01D42E14400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html */,
</span><span class="lines">@@ -2624,6 +2644,7 @@
</span><span class="cx">                                 7A909A831D877480007E10F8 /* IntSize.cpp in Sources */,
</span><span class="cx">                                 7CCE7EEF1A411AE600447C4C /* EphemeralSessionPushStateNoHistoryCallback.cpp in Sources */,
</span><span class="cx">                                 7CCE7EF01A411AE600447C4C /* EvaluateJavaScript.cpp in Sources */,
</span><ins>+                                F4D4F3B91E4E36E400BB2767 /* DataInteractionTests.mm in Sources */,
</ins><span class="cx">                                 7CCE7EF11A411AE600447C4C /* FailedLoad.cpp in Sources */,
</span><span class="cx">                                 7C83E04F1D0A641800FEBCF3 /* FileSystem.cpp in Sources */,
</span><span class="cx">                                 7CCE7EF31A411AE600447C4C /* Find.cpp in Sources */,
</span><span class="lines">@@ -2676,6 +2697,7 @@
</span><span class="cx">                                 7C83E0C01D0A652700FEBCF3 /* LoadInvalidURLRequest.mm in Sources */,
</span><span class="cx">                                 7CCE7F001A411AE600447C4C /* LoadPageOnCrash.cpp in Sources */,
</span><span class="cx">                                 51E6A8941D2F1C0A00C004B6 /* LocalStorageClear.mm in Sources */,
</span><ins>+                                F4D4F3B61E4E2BCB00BB2767 /* DataInteractionSimulator.mm in Sources */,
</ins><span class="cx">                                 46C519DA1D355AB200DAA51A /* LocalStorageNullEntries.mm in Sources */,
</span><span class="cx">                                 7CCE7EB21A411A5100447C4C /* MemoryCacheAddImageToCacheIOS.mm in Sources */,
</span><span class="cx">                                 7CCE7EC51A411A7E00447C4C /* MemoryCacheDisableWithinResourceLoadDelegate.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoaautofocuscontenteditablehtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autofocus-contenteditable.html (0 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autofocus-contenteditable.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autofocus-contenteditable.html        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+&lt;head&gt;
+    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot;&gt;
+        &lt;style&gt;
+        body {
+            width: 100%;
+            height: 100%;
+            margin: 0;
+        }
+
+        #source, #editor {
+            width: 100%;
+            height: 200px;
+            font-size: 200px;
+            white-space: nowrap;
+        }
+
+        #editor {
+            border: black 1px solid;
+        }
+        &lt;/style&gt;
+&lt;/head&gt;
+
+&lt;body&gt;
+    &lt;div contenteditable id=&quot;source&quot;&gt;Hello world&lt;/div&gt;
+    &lt;div contenteditable id=&quot;editor&quot;&gt;&lt;/div&gt;
+    &lt;script&gt;
+    function postEventType(event) {
+       webkit.messageHandlers.testHandler.postMessage(event.type);
+    }
+
+    editor.addEventListener(&quot;drop&quot;, postEventType);
+    editor.addEventListener(&quot;dragenter&quot;, postEventType);
+    editor.addEventListener(&quot;dragover&quot;, postEventType);
+
+    let text = source.childNodes[0];
+    getSelection().setBaseAndExtent(text, 0, text, text.data.length);
+    &lt;/script&gt;
+&lt;/body&gt;
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoaimageandcontenteditablehtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/image-and-contenteditable.html (0 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/image-and-contenteditable.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/image-and-contenteditable.html        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;head&gt;
+    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot;&gt;
+        &lt;style&gt;
+        body {
+            width: 100%;
+            height: 100%;
+            margin: 0;
+        }
+
+        #source, #editor {
+            width: 200px;
+            height: 200px;
+        }
+
+        #editor {
+            border: black 1px solid;
+        }
+        &lt;/style&gt;
+&lt;/head&gt;
+
+&lt;body&gt;
+    &lt;div&gt;&lt;img id=&quot;source&quot; src=&quot;icon.png&quot;&gt;&lt;/img&gt;&lt;/div&gt;
+    &lt;div contenteditable id=&quot;editor&quot;&gt;&lt;/div&gt;
+    &lt;script&gt;
+    function postEventType(event) {
+       webkit.messageHandlers.testHandler.postMessage(event.type);
+    }
+
+    editor.addEventListener(&quot;drop&quot;, postEventType);
+    editor.addEventListener(&quot;dragenter&quot;, postEventType);
+    editor.addEventListener(&quot;dragover&quot;, postEventType);
+    &lt;/script&gt;
+&lt;/body&gt;
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoaimageandtextareahtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/image-and-textarea.html (0 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/image-and-textarea.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/image-and-textarea.html        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;head&gt;
+    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot;&gt;
+        &lt;style&gt;
+        body {
+            width: 100%;
+            height: 100%;
+            margin: 0;
+        }
+
+        #source, #editor {
+            width: 200px;
+            height: 200px;
+        }
+
+        #editor {
+            border: black 1px solid;
+        }
+        &lt;/style&gt;
+&lt;/head&gt;
+
+&lt;body&gt;
+    &lt;div&gt;&lt;img id=&quot;source&quot; src=&quot;icon.png&quot;&gt;&lt;/img&gt;&lt;/div&gt;
+    &lt;textarea contenteditable id=&quot;editor&quot;&gt;&lt;/textarea&gt;
+    &lt;script&gt;
+    function postEventType(event) {
+       webkit.messageHandlers.testHandler.postMessage(event.type);
+    }
+
+    editor.addEventListener(&quot;drop&quot;, postEventType);
+    editor.addEventListener(&quot;dragenter&quot;, postEventType);
+    editor.addEventListener(&quot;dragover&quot;, postEventType);
+    &lt;/script&gt;
+&lt;/body&gt;
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsiosDataInteractionTestsmm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm (0 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -0,0 +1,94 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+
+#if ENABLE(DATA_INTERACTION)
+
+#import &quot;DataInteractionSimulator.h&quot;
+#import &quot;PlatformUtilities.h&quot;
+#import &quot;TestWKWebView.h&quot;
+
+namespace TestWebKitAPI {
+
+static void runTestsExpectingToObserveEvents(TestWKWebView *webView, NSArray *eventNamesToObserve, dispatch_block_t test)
+{
+    NSMutableSet *observedEvents = [NSMutableSet set];
+    for (NSString *eventName in eventNamesToObserve) {
+        [webView performAfterReceivingMessage:eventName action:^() {
+            [observedEvents addObject:eventName];
+        }];
+    }
+
+    test();
+
+    for (NSString *eventName in eventNamesToObserve)
+        EXPECT_TRUE([observedEvents containsObject:eventName]);
+}
+
+TEST(DataInteractionTests, ImageToContentEditable)
+{
+    RetainPtr&lt;TestWKWebView&gt; webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    runTestsExpectingToObserveEvents(webView.get(), @[ DataInteractionEnterEventName, DataInteractionOverEventName, DataInteractionPerformOperationEventName ], ^() {
+        [webView synchronouslyLoadTestPageNamed:@&quot;image-and-contenteditable&quot;];
+
+        RetainPtr&lt;DataInteractionSimulator&gt; dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get() startLocation:CGPointMake(100, 100) endLocation:CGPointMake(100, 300)]);
+        [dataInteractionSimulator run];
+
+        EXPECT_TRUE([webView stringByEvaluatingJavaScript:@&quot;!!editor.querySelector('img')&quot;].boolValue);
+    });
+}
+
+TEST(DataInteractionTests, ImageToTextarea)
+{
+    RetainPtr&lt;TestWKWebView&gt; webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    runTestsExpectingToObserveEvents(webView.get(), @[ DataInteractionEnterEventName, DataInteractionOverEventName, DataInteractionPerformOperationEventName ], ^() {
+        [webView synchronouslyLoadTestPageNamed:@&quot;image-and-textarea&quot;];
+
+        RetainPtr&lt;DataInteractionSimulator&gt; dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get() startLocation:CGPointMake(100, 100) endLocation:CGPointMake(100, 300)]);
+        [dataInteractionSimulator run];
+
+        NSURL *imageURL = [NSURL fileURLWithPath:[webView stringByEvaluatingJavaScript:@&quot;editor.value&quot;]];
+        EXPECT_WK_STREQ(&quot;icon.png&quot;, imageURL.lastPathComponent);
+    });
+}
+
+TEST(DataInteractionTests, ContentEditableToContentEditable)
+{
+    RetainPtr&lt;TestWKWebView&gt; webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    runTestsExpectingToObserveEvents(webView.get(), @[ DataInteractionEnterEventName, DataInteractionOverEventName, DataInteractionPerformOperationEventName ], ^() {
+        [webView synchronouslyLoadTestPageNamed:@&quot;autofocus-contenteditable&quot;];
+
+        RetainPtr&lt;DataInteractionSimulator&gt; dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get() startLocation:CGPointMake(100, 100) endLocation:CGPointMake(100, 300)]);
+        [dataInteractionSimulator run];
+
+        EXPECT_EQ([webView stringByEvaluatingJavaScript:@&quot;source.textContent&quot;].length, 0UL);
+        EXPECT_WK_STREQ(&quot;Hello world&quot;, [webView stringByEvaluatingJavaScript:@&quot;editor.textContent&quot;].UTF8String);
+    });
+}
+
+} // namespace TestWebKitAPI
+
+#endif // ENABLE(DATA_INTERACTION)
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPIcocoaTestWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm (212253 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm        2017-02-13 23:07:44 UTC (rev 212253)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -215,13 +215,13 @@
</span><span class="cx">     __block NSString *evalResult = nil;
</span><span class="cx">     [self evaluateJavaScript:script completionHandler:^(id result, NSError *error)
</span><span class="cx">     {
</span><del>-        evalResult = [NSString stringWithFormat:@&quot;%@&quot;, result];
</del><ins>+        evalResult = [[NSString alloc] initWithFormat:@&quot;%@&quot;, result];
</ins><span class="cx">         isWaitingForJavaScript = true;
</span><span class="cx">         EXPECT_TRUE(!error);
</span><span class="cx">     }];
</span><span class="cx"> 
</span><span class="cx">     TestWebKitAPI::Util::run(&amp;isWaitingForJavaScript);
</span><del>-    return evalResult;
</del><ins>+    return [evalResult autorelease];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)waitForMessage:(NSString *)message
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIiosDataInteractionSimulatorh"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h (0 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -0,0 +1,65 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if ENABLE(DATA_INTERACTION)
+
+#import &lt;UIKit/UIItemProvider.h&gt;
+#import &lt;UIKit/UIKit.h&gt;
+#import &lt;WebKit/WebKit.h&gt;
+#import &lt;WebKit/_WKTestingDelegate.h&gt;
+#import &lt;wtf/BlockPtr.h&gt;
+
+@class MockLongPressGestureRecognizer;
+@class MockDataInteractionInfo;
+
+extern NSString * const DataInteractionEnterEventName;
+extern NSString * const DataInteractionOverEventName;
+extern NSString * const DataInteractionPerformOperationEventName;
+
+typedef NS_ENUM(NSInteger, DataInteractionPhase) {
+    DataInteractionUnrecognized = 1,
+    DataInteractionBegan = 2,
+    DataInteractionEntered = 3,
+    DataInteractionPerforming = 4
+};
+
+@interface DataInteractionSimulator : NSObject&lt;_WKTestingDelegate&gt; {
+    RetainPtr&lt;WKWebView&gt; _webView;
+    RetainPtr&lt;MockLongPressGestureRecognizer&gt; _gestureRecognizer;
+    RetainPtr&lt;MockDataInteractionInfo&gt; _dataInteractionInfo;
+    CGPoint _startLocation;
+    CGPoint _endLocation;
+
+    double _gestureProgress;
+    bool _isDoneWithDataInteraction;
+    DataInteractionPhase _phase;
+}
+
+- (instancetype)initWithWebView:(WKWebView *)webView startLocation:(CGPoint)startLocation endLocation:(CGPoint)endLocation;
+- (void)run;
+
+@end
+
+#endif // ENABLE(DATA_INTERACTION)
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPIiosDataInteractionSimulatormm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm (0 => 212254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm        2017-02-13 23:10:10 UTC (rev 212254)
</span><span class="lines">@@ -0,0 +1,208 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;DataInteractionSimulator.h&quot;
+
+#if ENABLE(DATA_INTERACTION)
+
+#import &quot;PlatformUtilities.h&quot;
+#import &lt;UIKit/UIItemProvider_Private.h&gt;
+#import &lt;WebKit/WKWebViewPrivate.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+using namespace TestWebKitAPI;
+
+#if USE(APPLE_INTERNAL_SDK) &amp;&amp; __has_include(&lt;WebKitAdditions/DataInteractionSimulatorAdditions.mm&gt;)
+#include &lt;WebKitAdditions/DataInteractionSimulatorAdditions.mm&gt;
+#endif
+
+@interface MockLongPressGestureRecognizer : UILongPressGestureRecognizer {
+    RetainPtr&lt;UIWindow&gt; _window;
+}
+
+@property (nonatomic) CGPoint mockLocationInWindow;
+@property (nonatomic) UIGestureRecognizerState mockState;
+@property (nonatomic) NSInteger mockNumberOfTouches;
+
+@end
+
+@implementation MockLongPressGestureRecognizer
+
+- (instancetype)initWithWindow:(UIWindow *)window
+{
+    if (self = [super init]) {
+        _window = window;
+        _mockState = UIGestureRecognizerStatePossible;
+        _mockNumberOfTouches = 0;
+        _mockLocationInWindow = CGPointZero;
+    }
+    return self;
+}
+
+- (CGPoint)locationInView:(UIView *)view
+{
+    return [view convertPoint:_mockLocationInWindow fromView:_window.get()];
+}
+
+- (UIGestureRecognizerState)state
+{
+    return _mockState;
+}
+
+- (NSUInteger)numberOfTouches
+{
+    return _mockNumberOfTouches;
+}
+
+@end
+
+static double progressIncrementStep = 0.033;
+static double progressTimeStep = 0.03;
+
+@implementation DataInteractionSimulator
+
+- (instancetype)initWithWebView:(WKWebView *)webView startLocation:(CGPoint)startLocation endLocation:(CGPoint)endLocation
+{
+    if (self = [super init]) {
+        _webView = webView;
+        _gestureRecognizer = adoptNS([[MockLongPressGestureRecognizer alloc] initWithWindow:webView.window]);
+        _startLocation = startLocation;
+        _endLocation = endLocation;
+
+        [_gestureRecognizer setMockNumberOfTouches:0];
+        [_webView _setTestingDelegate:self];
+    }
+    return self;
+}
+
+- (void)dealloc
+{
+    if ([_webView _testingDelegate] == self)
+        [_webView _setTestingDelegate:nil];
+
+    [super dealloc];
+}
+
+- (void)run
+{
+    _gestureProgress = 0;
+    _phase = DataInteractionUnrecognized;
+    _isDoneWithDataInteraction = NO;
+    [_gestureRecognizer setMockNumberOfTouches:1];
+
+    [self _recognizeGestureAtLocation:_startLocation withState:UIGestureRecognizerStateBegan];
+    [self _scheduleAdvanceProgress];
+
+    TestWebKitAPI::Util::run(&amp;_isDoneWithDataInteraction);
+    [_gestureRecognizer setMockNumberOfTouches:0];
+}
+
+- (void)_advanceProgress
+{
+    _gestureProgress = std::min(1.0, std::max(0.0, progressIncrementStep + _gestureProgress));
+    [_dataInteractionInfo setMockLocationInWindow:self._currentLocation];
+    if (_gestureProgress &gt;= 1) {
+        [self _finishDataInteraction];
+        return;
+    }
+
+    switch (_phase) {
+    case DataInteractionUnrecognized:
+        [self _recognizeGestureAtLocation:self._currentLocation withState:UIGestureRecognizerStateChanged];
+        [self _scheduleAdvanceProgress];
+        break;
+    case DataInteractionBegan:
+        [_webView _simulateDataInteractionEntered:_dataInteractionInfo.get()];
+        _phase = DataInteractionEntered;
+        [self _scheduleAdvanceProgress];
+        break;
+    case DataInteractionEntered:
+        [_dataInteractionInfo setMockLocationInWindow:self._currentLocation];
+        [_webView _simulateDataInteractionUpdated:_dataInteractionInfo.get()];
+        [self _scheduleAdvanceProgress];
+        break;
+    default:
+        break;
+    }
+}
+
+- (void)_finishDataInteraction
+{
+    _phase = DataInteractionPerforming;
+    [_webView _simulateDataInteractionPerformOperation:_dataInteractionInfo.get()];
+    [_webView _simulateDataInteractionEnded:_dataInteractionInfo.get()];
+    [_webView _simulateDataInteractionSessionDidEnd:nil withOperation:0];
+}
+
+- (CGPoint)_currentLocation
+{
+    CGFloat distanceX = _endLocation.x - _startLocation.x;
+    CGFloat distanceY = _endLocation.y - _startLocation.y;
+    return { _startLocation.x + _gestureProgress * distanceX, _startLocation.y + _gestureProgress * distanceY };
+}
+
+- (void)_scheduleAdvanceProgress
+{
+    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_advanceProgress) object:nil];
+    [self performSelector:@selector(_advanceProgress) withObject:nil afterDelay:progressTimeStep];
+}
+
+- (void)_recognizeGestureAtLocation:(CGPoint)locationInWindow withState:(UIGestureRecognizerState)state
+{
+    [_gestureRecognizer setMockState:state];
+    [_gestureRecognizer setMockLocationInWindow:locationInWindow];
+    [_webView _simulateDataInteractionGestureRecognized];
+}
+
+#pragma mark - _WKTestingDelegate
+
+- (UILongPressGestureRecognizer *)dataInteractionGestureRecognizer
+{
+    return _gestureRecognizer.get();
+}
+
+- (void)webViewDidPerformDataInteractionControllerOperation:(WKWebView *)webView
+{
+    _isDoneWithDataInteraction = true;
+}
+
+- (void)webView:(WKWebView *)webView beginDataInteractionWithSourceIndex:(NSInteger)sourceIndex gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
+{
+    _phase = DataInteractionBegan;
+
+    // End the data interaction gesture recognizer.
+    auto location = self._currentLocation;
+    [self _recognizeGestureAtLocation:location withState:UIGestureRecognizerStateEnded];
+
+    // Officially begin data interaction by initializing the info.
+    NSArray *items = [_webView _simulatedItemsForDataInteractionWithIndex:sourceIndex];
+    _dataInteractionInfo = adoptNS([[MockDataInteractionInfo alloc] initWithItems:items location:location window:[_webView window]]);
+    [_webView _simulateWillBeginDataInteractionWithIndex:sourceIndex withSession:nil];
+}
+
+@end
+
+#endif // ENABLE(DATA_INTERACTION)
</ins></span></pre>
</div>
</div>

</body>
</html>