Changeset 212974 in webkit


Ignore:
Timestamp:
Feb 24, 2017 4:05:45 PM (7 years ago)
Author:
Wenson Hsieh
Message:

Refactor data interaction to use new WKDataInteraction SPI
https://bugs.webkit.org/show_bug.cgi?id=168602
Work towards <rdar://problem/30313681>

Reviewed by Tim Horton.

Source/WebKit2:

Adjust testing SPI to match new data interaction interfaces.

  • Platform/spi/ios/UIKitSPI.h:
  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _simulateDataInteractionEntered:]):
(-[WKWebView _simulateDataInteractionUpdated:]):
(-[WKWebView _simulateDataInteractionPerformOperation:]):
(-[WKWebView _simulateDataInteractionEnded:]):
(-[WKWebView _simulateDataInteractionSessionDidEnd:]):
(-[WKWebView _simulateWillBeginDataInteractionWithSession:]):
(-[WKWebView _simulatedItemsForSession:]):
(-[WKWebView _simulatePrepareForDataInteractionSession:completion:]):
(-[WKWebView _simulateDataInteractionSessionDidEnd:withOperation:]): Deleted.
(-[WKWebView _simulateFailedDataInteractionWithIndex:]): Deleted.
(-[WKWebView _simulateWillBeginDataInteractionWithIndex:withSession:]): Deleted.
(-[WKWebView _simulatedItemsForDataInteractionWithIndex:]): Deleted.

  • UIProcess/API/Cocoa/WKWebViewPrivate.h:
  • UIProcess/ios/WKContentViewInteraction.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _positionInformationDidChange:]):

  • UIProcess/ios/WKScrollView.h:
  • UIProcess/ios/WKScrollView.mm:

Tools:

Update DataInteractionSimulator to simulate data interaction using updated SPI. See changes in WebKit2 for more details.

  • TestWebKitAPI/Tests/ios/DataInteractionTests.mm:

(TestWebKitAPI::TEST):

  • TestWebKitAPI/ios/DataInteractionSimulator.h:
  • TestWebKitAPI/ios/DataInteractionSimulator.mm:

(-[DataInteractionSimulator _resetSimulatedState]):
(-[DataInteractionSimulator runFrom:to:]):
(-[DataInteractionSimulator _advanceProgress]):
(-[DataInteractionSimulator _currentLocation]):
(-[DataInteractionSimulator _finishDataInteraction]): Deleted.
(-[DataInteractionSimulator webViewDidSendDataInteractionStartRequest:]): Deleted.
(-[DataInteractionSimulator webView:didReceiveDataInteractionStartResponse:]): Deleted.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r212973 r212974  
     12017-02-20  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Refactor data interaction to use new WKDataInteraction SPI
     4        https://bugs.webkit.org/show_bug.cgi?id=168602
     5        Work towards <rdar://problem/30313681>
     6
     7        Reviewed by Tim Horton.
     8
     9        Adjust testing SPI to match new data interaction interfaces.
     10
     11        * Platform/spi/ios/UIKitSPI.h:
     12        * UIProcess/API/Cocoa/WKWebView.mm:
     13        (-[WKWebView _simulateDataInteractionEntered:]):
     14        (-[WKWebView _simulateDataInteractionUpdated:]):
     15        (-[WKWebView _simulateDataInteractionPerformOperation:]):
     16        (-[WKWebView _simulateDataInteractionEnded:]):
     17        (-[WKWebView _simulateDataInteractionSessionDidEnd:]):
     18        (-[WKWebView _simulateWillBeginDataInteractionWithSession:]):
     19        (-[WKWebView _simulatedItemsForSession:]):
     20        (-[WKWebView _simulatePrepareForDataInteractionSession:completion:]):
     21        (-[WKWebView _simulateDataInteractionSessionDidEnd:withOperation:]): Deleted.
     22        (-[WKWebView _simulateFailedDataInteractionWithIndex:]): Deleted.
     23        (-[WKWebView _simulateWillBeginDataInteractionWithIndex:withSession:]): Deleted.
     24        (-[WKWebView _simulatedItemsForDataInteractionWithIndex:]): Deleted.
     25        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
     26        * UIProcess/ios/WKContentViewInteraction.h:
     27        * UIProcess/ios/WKContentViewInteraction.mm:
     28        (-[WKContentView _positionInformationDidChange:]):
     29        * UIProcess/ios/WKScrollView.h:
     30        * UIProcess/ios/WKScrollView.mm:
     31
    1322017-02-20  Wenson Hsieh  <wenson_hsieh@apple.com>
    233
  • trunk/Source/WebKit2/Platform/spi/ios/UIKitSPI.h

    r212211 r212974  
    5555#import <UIKit/UITableViewCell_Private.h>
    5656#import <UIKit/UITapGestureRecognizer_Private.h>
     57#import <UIKit/UITextEffectsWindow.h>
    5758#import <UIKit/UITextInput_Private.h>
    5859#import <UIKit/UITextInteractionAssistant_Private.h>
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r212973 r212974  
    52365236- (void)_simulateDataInteractionEntered:(id)info
    52375237{
     5238#if ENABLE(DATA_INTERACTION)
     5239    [_contentView _simulateDataInteractionEntered:info];
     5240#endif
    52385241}
    52395242
    52405243- (void)_simulateDataInteractionUpdated:(id)info
    52415244{
     5245#if ENABLE(DATA_INTERACTION)
     5246    [_contentView _simulateDataInteractionUpdated:info];
     5247#endif
    52425248}
    52435249
    52445250- (void)_simulateDataInteractionPerformOperation:(id)info
    52455251{
     5252#if ENABLE(DATA_INTERACTION)
     5253    [_contentView _simulateDataInteractionPerformOperation:info];
     5254#endif
    52465255}
    52475256
    52485257- (void)_simulateDataInteractionEnded:(id)info
    52495258{
    5250 }
    5251 
    5252 - (void)_simulateDataInteractionSessionDidEnd:(id)session withOperation:(NSUInteger)operation
    5253 {
    5254 }
    5255 
    5256 - (void)_simulateFailedDataInteractionWithIndex:(NSInteger)sourceIndex
    5257 {
    5258 }
    5259 
    5260 - (void)_simulateWillBeginDataInteractionWithIndex:(NSInteger)sourceIndex withSession:(id)session
    5261 {
    5262 }
    5263 
    5264 - (NSArray *)_simulatedItemsForDataInteractionWithIndex:(NSInteger)sourceIndex
    5265 {
     5259#if ENABLE(DATA_INTERACTION)
     5260    [_contentView _simulateDataInteractionEnded:info];
     5261#endif
     5262}
     5263
     5264- (void)_simulateDataInteractionSessionDidEnd:(id)session
     5265{
     5266#if ENABLE(DATA_INTERACTION)
     5267    [_contentView _simulateDataInteractionSessionDidEnd:session];
     5268#endif
     5269}
     5270
     5271- (void)_simulateWillBeginDataInteractionWithSession:(id)session
     5272{
     5273#if ENABLE(DATA_INTERACTION)
     5274    [_contentView _simulateWillBeginDataInteractionWithSession:session];
     5275#endif
     5276}
     5277
     5278- (NSArray *)_simulatedItemsForSession:(id)session
     5279{
     5280#if ENABLE(DATA_INTERACTION)
     5281    return [_contentView _simulatedItemsForSession:session];
     5282#else
    52665283    return @[ ];
     5284#endif
     5285}
     5286
     5287- (void)_simulatePrepareForDataInteractionSession:(id)session completion:(dispatch_block_t)completion
     5288{
     5289#if ENABLE(DATA_INTERACTION)
     5290    [_contentView _simulatePrepareForDataInteractionSession:session completion:completion];
     5291#endif
    52675292}
    52685293
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r212973 r212974  
    311311- (void)_simulateDataInteractionPerformOperation:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
    312312- (void)_simulateDataInteractionEnded:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
    313 - (void)_simulateDataInteractionSessionDidEnd:(id)session withOperation:(NSUInteger)operation WK_API_AVAILABLE(ios(WK_IOS_TBA));
    314 - (void)_simulateFailedDataInteractionWithIndex:(NSInteger)sourceIndex WK_API_AVAILABLE(ios(WK_IOS_TBA));
    315 - (void)_simulateWillBeginDataInteractionWithIndex:(NSInteger)sourceIndex withSession:(id)session WK_API_AVAILABLE(ios(WK_IOS_TBA));
    316 - (NSArray *)_simulatedItemsForDataInteractionWithIndex:(NSInteger)sourceIndex WK_API_AVAILABLE(ios(WK_IOS_TBA));
     313- (void)_simulateDataInteractionSessionDidEnd:(id)session WK_API_AVAILABLE(ios(WK_IOS_TBA));
     314- (void)_simulateWillBeginDataInteractionWithSession:(id)session WK_API_AVAILABLE(ios(WK_IOS_TBA));
     315- (NSArray *)_simulatedItemsForSession:(id)session WK_API_AVAILABLE(ios(WK_IOS_TBA));
     316- (void)_simulatePrepareForDataInteractionSession:(id)session completion:(dispatch_block_t)completion WK_API_AVAILABLE(ios(WK_IOS_TBA));
    317317
    318318#endif // TARGET_OS_IPHONE
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h

    r212973 r212974  
    189189    WebKit::WKDataInteractionState _dataInteractionState;
    190190    BOOL _isPerformingDataInteractionOperation;
     191    RetainPtr<WKDataInteraction> _dataInteraction;
     192    CGPoint _deferredActionSheetRequestLocation;
    191193#endif
    192194}
     
    196198@interface WKContentView (WKInteraction) <UIGestureRecognizerDelegate, UIWebTouchEventsGestureRecognizerDelegate, UITextInputPrivate, UIWebFormAccessoryDelegate, UIWKInteractionViewProtocol, WKFileUploadPanelDelegate, WKActionSheetAssistantDelegate
    197199#if ENABLE(DATA_INTERACTION)
    198     , WKViewDataInteractionSourceDelegate, WKDataInteractionSessionDelegate, WKViewDataInteractionDestinationDelegate, WKDataInteractionItemVisualTarget
     200    , WKDataInteractionItemVisualTarget, WKDataInteractionDelegate, WKViewDataInteractionDestinationDelegate
    199201#endif
    200202>
     
    270272- (void)_didHandleStartDataInteractionRequest:(BOOL)started;
    271273- (void)_startDataInteractionWithImage:(RetainPtr<CGImageRef>)image withIndicatorData:(std::optional<WebCore::TextIndicatorData>)indicatorData atClientPosition:(CGPoint)clientPosition anchorPoint:(CGPoint)anchorPoint action:(uint64_t)action;
    272 - (void)_simulateDataInteractionEntered:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
    273 - (void)_simulateDataInteractionUpdated:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
    274 - (void)_simulateDataInteractionPerformOperation:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
    275 - (void)_simulateDataInteractionEnded:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
    276 - (void)_simulateDataInteractionSessionDidEnd:(id)session withOperation:(NSUInteger)operation WK_API_AVAILABLE(ios(WK_IOS_TBA));
    277 - (void)_simulateFailedDataInteractionWithIndex:(NSInteger)sourceIndex WK_API_AVAILABLE(ios(WK_IOS_TBA));
    278 - (void)_simulateWillBeginDataInteractionWithIndex:(NSInteger)sourceIndex withSession:(id)session WK_API_AVAILABLE(ios(WK_IOS_TBA));
    279 - (NSArray *)_simulatedItemsForDataInteractionWithIndex:(NSInteger)sourceIndex WK_API_AVAILABLE(ios(WK_IOS_TBA));
     274- (void)_simulateDataInteractionEntered:(id)info;
     275- (void)_simulateDataInteractionUpdated:(id)info;
     276- (void)_simulateDataInteractionPerformOperation:(id)info;
     277- (void)_simulateDataInteractionEnded:(id)info;
     278- (void)_simulateDataInteractionSessionDidEnd:(id)session;
     279- (void)_simulateWillBeginDataInteractionWithSession:(id)session;
     280- (NSArray *)_simulatedItemsForSession:(id)session;
     281- (void)_simulatePrepareForDataInteractionSession:(id)session completion:(dispatch_block_t)completion;
    280282#endif
    281283
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r212973 r212974  
    17211721    if (_actionSheetAssistant)
    17221722        [_actionSheetAssistant updateSheetPosition];
    1723 
    1724 #if ENABLE(DATA_INTERACTION)
    1725     [self _updateDataInteractionPreviewSnapshotIfPossible];
    1726 #endif
    17271723}
    17281724
  • trunk/Source/WebKit2/UIProcess/ios/WKScrollView.mm

    r212459 r212974  
    130130}
    131131
     132#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKScrollViewAdditions.mm>)
     133#import <WebKitAdditions/WKScrollViewAdditions.mm>
     134#endif
     135
    132136- (void)setInternalDelegate:(WKWebView <UIScrollViewDelegate> *)internalDelegate
    133137{
  • trunk/Tools/ChangeLog

    r212973 r212974  
     12017-02-20  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Refactor data interaction to use new WKDataInteraction SPI
     4        https://bugs.webkit.org/show_bug.cgi?id=168602
     5        Work towards <rdar://problem/30313681>
     6
     7        Reviewed by Tim Horton.
     8
     9        Update DataInteractionSimulator to simulate data interaction using updated SPI. See changes in WebKit2 for more details.
     10
     11        * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
     12        (TestWebKitAPI::TEST):
     13        * TestWebKitAPI/ios/DataInteractionSimulator.h:
     14        * TestWebKitAPI/ios/DataInteractionSimulator.mm:
     15        (-[DataInteractionSimulator _resetSimulatedState]):
     16        (-[DataInteractionSimulator runFrom:to:]):
     17        (-[DataInteractionSimulator _advanceProgress]):
     18        (-[DataInteractionSimulator _currentLocation]):
     19        (-[DataInteractionSimulator _finishDataInteraction]): Deleted.
     20        (-[DataInteractionSimulator webViewDidSendDataInteractionStartRequest:]): Deleted.
     21        (-[DataInteractionSimulator webView:didReceiveDataInteractionStartResponse:]): Deleted.
     22
    1232017-02-20  Wenson Hsieh  <wenson_hsieh@apple.com>
    224
  • trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm

    r212901 r212974  
    2626#include "config.h"
    2727
    28 #if 0
     28#if ENABLE(DATA_INTERACTION)
    2929
    3030#import "DataInteractionSimulator.h"
     
    8282    NSURL *imageURL = [NSURL fileURLWithPath:[webView editorValue]];
    8383    EXPECT_WK_STREQ("icon.png", imageURL.lastPathComponent);
    84     EXPECT_TRUE([dataInteractionSimulator didTryToBeginDataInteraction]);
    8584
    8685    NSArray *observedEventNames = [dataInteractionSimulator observedEventNames];
     
    103102    EXPECT_EQ([webView stringByEvaluatingJavaScript:@"source.textContent"].length, 0UL);
    104103    EXPECT_WK_STREQ("Hello world", [webView stringByEvaluatingJavaScript:@"editor.textContent"].UTF8String);
    105     EXPECT_TRUE([dataInteractionSimulator didTryToBeginDataInteraction]);
    106104
    107105    NSArray *observedEventNames = [dataInteractionSimulator observedEventNames];
     
    122120    EXPECT_EQ([webView stringByEvaluatingJavaScript:@"source.textContent"].length, 0UL);
    123121    EXPECT_WK_STREQ("Hello world", [webView editorValue].UTF8String);
    124     EXPECT_TRUE([dataInteractionSimulator didTryToBeginDataInteraction]);
    125122
    126123    NSArray *observedEventNames = [dataInteractionSimulator observedEventNames];
     
    140137
    141138    EXPECT_WK_STREQ("https://www.daringfireball.net/", [webView editorValue].UTF8String);
    142     EXPECT_TRUE([dataInteractionSimulator didTryToBeginDataInteraction]);
    143139
    144140    NSArray *observedEventNames = [dataInteractionSimulator observedEventNames];
     
    158154
    159155    EXPECT_WK_STREQ("https://www.daringfireball.net/", [webView editorValue].UTF8String);
    160     EXPECT_TRUE([dataInteractionSimulator didTryToBeginDataInteraction]);
    161156
    162157    NSArray *observedEventNames = [dataInteractionSimulator observedEventNames];
     
    176171
    177172    EXPECT_FALSE([webView editorContainsImageElement]);
    178     EXPECT_FALSE([dataInteractionSimulator didTryToBeginDataInteraction]);
    179173
    180174    NSArray *observedEventNames = [dataInteractionSimulator observedEventNames];
     
    193187
    194188    EXPECT_FALSE([webView editorContainsImageElement]);
    195     EXPECT_TRUE([dataInteractionSimulator didTryToBeginDataInteraction]);
    196189
    197190    NSArray *observedEventNames = [dataInteractionSimulator observedEventNames];
     
    210203
    211204    EXPECT_WK_STREQ("", [webView editorValue].UTF8String);
    212     EXPECT_TRUE([dataInteractionSimulator didTryToBeginDataInteraction]);
    213205
    214206    NSArray *observedEventNames = [dataInteractionSimulator observedEventNames];
     
    218210    EXPECT_FALSE([observedEventNames containsObject:DataInteractionPerformOperationEventName]);
    219211    EXPECT_TRUE([[dataInteractionSimulator finalSelectionRects] isEqualToArray:@[ ]]);
    220 }
    221 
    222 TEST(DataInteractionTests, HandlesDataInteractionFailureGracefully)
    223 {
    224     RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
    225     [webView synchronouslyLoadTestPageNamed:@"link-and-input"];
    226 
    227     RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
    228     [dataInteractionSimulator setForceRequestToFail:YES];
    229     [dataInteractionSimulator runFrom:CGPointMake(100, 50) to:CGPointMake(100, 300)];
    230     EXPECT_WK_STREQ("", [webView editorValue].UTF8String);
    231 
    232     // Before r212266, starting a subsequent gesture would have caused a debug assertion in the web process.
    233     [dataInteractionSimulator setForceRequestToFail:NO];
    234     [dataInteractionSimulator runFrom:CGPointMake(100, 50) to:CGPointMake(100, 300)];
    235     EXPECT_WK_STREQ("https://www.daringfireball.net/", [webView editorValue].UTF8String);
    236212}
    237213
  • trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h

    r212973 r212974  
    3333
    3434@class MockDataInteractionInfo;
     35@class MockDataInteractionSession;
    3536
    3637extern NSString * const DataInteractionEnterEventName;
     
    4142
    4243typedef NS_ENUM(NSInteger, DataInteractionPhase) {
    43     DataInteractionUnrecognized = 1,
     44    DataInteractionCancelled = 0,
     45    DataInteractionBeginning = 1,
    4446    DataInteractionBegan = 2,
    4547    DataInteractionEntered = 3,
     
    4951@interface DataInteractionSimulator : NSObject<_WKTestingDelegate> {
    5052    RetainPtr<TestWKWebView> _webView;
     53    RetainPtr<MockDataInteractionSession> _dataInteractionSession;
    5154    RetainPtr<MockDataInteractionInfo> _dataInteractionInfo;
    5255    RetainPtr<NSMutableArray> _observedEventNames;
     
    5659    CGPoint _endLocation;
    5760
    58     double _gestureProgress;
     61    double _currentProgress;
    5962    bool _isDoneWithCurrentRun;
    6063    DataInteractionPhase _phase;
     
    6467- (void)runFrom:(CGPoint)startLocation to:(CGPoint)endLocation;
    6568
    66 @property (nonatomic) BOOL forceRequestToFail;
    6769@property (nonatomic, strong) UIItemProvider *externalItemProvider;
    68 @property (nonatomic, readonly) BOOL didTryToBeginDataInteraction;
    6970@property (nonatomic, readonly) NSArray *observedEventNames;
    7071@property (nonatomic, readonly) NSArray *finalSelectionRects;
  • trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm

    r212973 r212974  
    7474- (void)_resetSimulatedState
    7575{
    76     _gestureProgress = 0;
    77     _phase = DataInteractionUnrecognized;
     76    _phase = DataInteractionBeginning;
     77    _currentProgress = 0;
    7878    _isDoneWithCurrentRun = false;
    79     _didTryToBeginDataInteraction = NO;
    8079    _observedEventNames = adoptNS([[NSMutableArray alloc] init]);
    8180    _finalSelectionRects = @[ ];
     81    _dataInteractionSession = nil;
     82    _dataInteractionInfo = nil;
    8283}
    8384
     
    103104
    104105    if (self.externalItemProvider) {
     106        _dataInteractionInfo = adoptNS([[MockDataInteractionInfo alloc] initWithProvider:self.externalItemProvider location:_startLocation window:[_webView window]]);
    105107        _phase = DataInteractionBegan;
    106         _dataInteractionInfo = adoptNS([[MockDataInteractionInfo alloc] initWithProvider:self.externalItemProvider location:startLocation window:[_webView window]]);
    107     }
    108 
    109     [self _scheduleAdvanceProgress];
     108        [self _advanceProgress];
     109    } else {
     110        _dataInteractionSession = adoptNS([[MockDataInteractionSession alloc] initWithWindow:[_webView window]]);
     111        [_dataInteractionSession setMockLocationInWindow:_startLocation];
     112        [_webView _simulatePrepareForDataInteractionSession:_dataInteractionSession.get() completion:^() {
     113            DataInteractionSimulator *weakSelf = strongSelf.get();
     114            weakSelf->_phase = DataInteractionBeginning;
     115            [weakSelf _advanceProgress];
     116        }];
     117    }
    110118
    111119    Util::run(&_isDoneWithCurrentRun);
     
    121129- (void)_advanceProgress
    122130{
    123     _gestureProgress = std::min(1.0, std::max(0.0, progressIncrementStep + _gestureProgress));
    124     [_dataInteractionInfo setMockLocationInWindow:self._currentLocation];
    125     if (_gestureProgress >= 1) {
    126         [self _finishDataInteraction];
     131    _currentProgress += progressIncrementStep;
     132    CGPoint locationInWindow = self._currentLocation;
     133    [_dataInteractionSession setMockLocationInWindow:locationInWindow];
     134    [_dataInteractionInfo setMockLocationInWindow:locationInWindow];
     135
     136    if (_currentProgress >= 1) {
     137        [_webView _simulateDataInteractionPerformOperation:_dataInteractionInfo.get()];
     138        [_webView _simulateDataInteractionEnded:_dataInteractionInfo.get()];
     139        if (_dataInteractionSession)
     140            [_webView _simulateDataInteractionSessionDidEnd:_dataInteractionSession.get()];
     141
     142        _phase = DataInteractionPerforming;
     143        _currentProgress = 1;
    127144        return;
    128145    }
    129146
    130147    switch (_phase) {
    131     case DataInteractionUnrecognized:
    132         [self _scheduleAdvanceProgress];
    133         break;
     148    case DataInteractionBeginning: {
     149        NSMutableArray<UIItemProvider *> *itemProviders = [NSMutableArray array];
     150        NSArray<WKDataInteractionItem *> *items = [_webView _simulatedItemsForSession:_dataInteractionSession.get()];
     151        if (!items.count) {
     152            _phase = DataInteractionCancelled;
     153            _currentProgress = 1;
     154            _isDoneWithCurrentRun = true;
     155            return;
     156        }
     157
     158        for (WKDataInteractionItem *item in items)
     159            [itemProviders addObject:item.itemProvider];
     160
     161        _dataInteractionInfo = adoptNS([[MockDataInteractionInfo alloc] initWithProvider:itemProviders.firstObject location:self._currentLocation window:[_webView window]]);
     162        [_dataInteractionSession setItems:items];
     163        [_webView _simulateWillBeginDataInteractionWithSession:_dataInteractionSession.get()];
     164        _phase = DataInteractionBegan;
     165        break;
     166    }
    134167    case DataInteractionBegan:
    135168        [_webView _simulateDataInteractionEntered:_dataInteractionInfo.get()];
    136169        _phase = DataInteractionEntered;
    137         [self _scheduleAdvanceProgress];
    138170        break;
    139171    case DataInteractionEntered:
    140172        [_webView _simulateDataInteractionUpdated:_dataInteractionInfo.get()];
    141         [self _scheduleAdvanceProgress];
    142173        break;
    143174    default:
    144175        break;
    145176    }
    146 }
    147 
    148 - (void)_finishDataInteraction
    149 {
    150     if (_phase == DataInteractionUnrecognized) {
    151         _isDoneWithCurrentRun = true;
    152         return;
    153     }
    154 
    155     _phase = DataInteractionPerforming;
    156     [_webView _simulateDataInteractionPerformOperation:_dataInteractionInfo.get()];
    157     [_webView _simulateDataInteractionEnded:_dataInteractionInfo.get()];
    158     [_webView _simulateDataInteractionSessionDidEnd:nil withOperation:0];
     177
     178    [self _scheduleAdvanceProgress];
    159179}
    160180
     
    163183    CGFloat distanceX = _endLocation.x - _startLocation.x;
    164184    CGFloat distanceY = _endLocation.y - _startLocation.y;
    165     return CGPointMake(_startLocation.x + _gestureProgress * distanceX, _startLocation.y + _gestureProgress * distanceY);
     185    return CGPointMake(_startLocation.x + _currentProgress * distanceX, _startLocation.y + _currentProgress * distanceY);
    166186}
    167187
     
    189209}
    190210
    191 - (void)webViewDidSendDataInteractionStartRequest:(WKWebView *)webView
    192 {
    193     // This addresses a race condition in the testing harness wherein the web process might take longer than usual to process the
    194     // request to start data interaction, and in the meantime, DataInteractionSimulator would end up completing the rest of the test
    195     // before a response from the web process is received. We instead defer test progress until after the web process has indicated
    196     // whether or not data interaction should commence.
    197     [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_advanceProgress) object:nil];
    198 }
    199 
    200 - (void)webView:(WKWebView *)webView didReceiveDataInteractionStartResponse:(BOOL)started
    201 {
    202     [self _scheduleAdvanceProgress];
    203 }
    204 
    205211@end
    206212
Note: See TracChangeset for help on using the changeset viewer.