Diff
Modified: trunk/LayoutTests/ChangeLog (189286 => 189287)
--- trunk/LayoutTests/ChangeLog 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/LayoutTests/ChangeLog 2015-09-03 21:11:44 UTC (rev 189287)
@@ -1,3 +1,31 @@
+2015-09-03 Tim Horton <[email protected]>
+
+ [Mac] Add support for testing swipes
+ https://bugs.webkit.org/show_bug.cgi?id=148700
+
+ Reviewed by Beth Dakin.
+
+ * swipe/basic-cached-back-swipe-expected.txt: Added.
+ * swipe/basic-cached-back-swipe.html: Added.
+ * swipe/resources/swipe-test.js: Added.
+ (eventQueue.enqueueScrollEvent):
+ (eventQueue.enqueueSwipeEvent):
+ (eventQueue.hasPendingEvents):
+ (eventQueue._processEventQueue):
+ (eventQueue._processEventQueueSoon):
+ (shouldBe):
+ (log):
+ (dumpLog):
+ (initializeLog):
+ (startMeasuringDuration):
+ (measuredDurationShouldBeLessThan):
+ Add a test for the simplest case, a back swipe after a normal navigation
+ with the page cache enabled.
+
+ * TestExpectations:
+ * platform/mac-wk2/TestExpectations:
+ Disable these tests everywhere except Mac WebKit2.
+
2015-09-03 Alexey Proskuryakov <[email protected]>
Test Russian ".рф" domain support
Modified: trunk/LayoutTests/TestExpectations (189286 => 189287)
--- trunk/LayoutTests/TestExpectations 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/LayoutTests/TestExpectations 2015-09-03 21:11:44 UTC (rev 189287)
@@ -13,6 +13,7 @@
editing/mac [ Skip ]
editing/pasteboard/gtk [ Skip ]
tiled-drawing [ Skip ]
+swipe [ Skip ]
fast/forms/attributed-strings.html [ Skip ]
fast/scrolling/latching [ Skip ]
Modified: trunk/LayoutTests/platform/mac-mavericks/TestExpectations (189286 => 189287)
--- trunk/LayoutTests/platform/mac-mavericks/TestExpectations 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/LayoutTests/platform/mac-mavericks/TestExpectations 2015-09-03 21:11:44 UTC (rev 189287)
@@ -22,3 +22,6 @@
# Colorspaces on CA OpenGL layers not available in Mavericks and Yosemite
fast/canvas/webgl/match-page-color-space.html [ Skip ]
+
+# Swipe tests don't work on Mavericks (needs investigation)
+swipe [ Skip ]
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (189286 => 189287)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2015-09-03 21:11:44 UTC (rev 189287)
@@ -6,6 +6,7 @@
#//////////////////////////////////////////////////////////////////////////////////////////
tiled-drawing [ Pass ]
+swipe [ Pass ]
#//////////////////////////////////////////////////////////////////////////////////////////
# End platform-specific directories.
Added: trunk/LayoutTests/swipe/basic-cached-back-swipe-expected.txt (0 => 189287)
--- trunk/LayoutTests/swipe/basic-cached-back-swipe-expected.txt (rev 0)
+++ trunk/LayoutTests/swipe/basic-cached-back-swipe-expected.txt 2015-09-03 21:11:44 UTC (rev 189287)
@@ -0,0 +1,11 @@
+swipe event (delta 0 0, phase 'maybegin')
+scroll event (delta 1 0, phase 'began')
+scroll event (delta 1 0, phase 'changed')
+didBeginSwipe
+swipe event (delta 1 0, phase 'changed')
+swipe event (delta 256 0, phase 'changed')
+swipe event (delta 0 0, phase 'ended')
+willEndSwipe
+didEndSwipe
+didRemoveSwipeSnapshot
+
Added: trunk/LayoutTests/swipe/basic-cached-back-swipe.html (0 => 189287)
--- trunk/LayoutTests/swipe/basic-cached-back-swipe.html (rev 0)
+++ trunk/LayoutTests/swipe/basic-cached-back-swipe.html 2015-09-03 21:11:44 UTC (rev 189287)
@@ -0,0 +1,98 @@
+<head>
+<style>
+html {
+ font-size: 32pt;
+}
+</style>
+<script src=""
+<script>
+function startSwipeGesture()
+{
+ eventSender.mouseMoveTo(100, 100);
+
+ eventQueue.enqueueSwipeEvent(0, 0, 'maybegin');
+ eventQueue.enqueueScrollEvent(1, 0, 'began');
+ eventQueue.enqueueScrollEvent(1, 0, 'changed');
+}
+
+function completeSwipeGesture()
+{
+ eventQueue.enqueueSwipeEvent(1, 0, 'changed');
+ eventQueue.enqueueSwipeEvent(256, 0, 'changed');
+ eventQueue.enqueueSwipeEvent(0, 0, 'ended');
+}
+
+function didBeginSwipeCallback()
+{
+ log("didBeginSwipe");
+
+ shouldBe(false, eventQueue.hasPendingEvents(), "Event queue should be empty. Both scroll events should be required to start the swipe because of the swipe-start hysteresis.");
+
+ completeSwipeGesture();
+}
+
+function willEndSwipeCallback()
+{
+ log("willEndSwipe");
+
+ shouldBe(false, isFirstPage(), "The swipe should not yet have navigated away from the second page.");
+}
+
+function didEndSwipeCallback()
+{
+ log("didEndSwipe");
+
+ shouldBe(0, eventQueue.hasPendingEvents(), "Event queue should be empty. The swipe isn't complete until we see the end of the gesture.");
+ startMeasuringDuration("snapshotRemoval");
+}
+
+function didRemoveSwipeSnapshotCallback()
+{
+ log("didRemoveSwipeSnapshot");
+
+ shouldBe(true, isFirstPage(), "The swipe should have navigated back to the first page.");
+ measuredDurationShouldBeLessThan("snapshotRemoval", 1000, "Because we're using the page cache, it shouldn't be long between the gesture completing and the snapshot being removed.")
+
+ dumpLog();
+ testRunner.notifyDone();
+}
+
+function isFirstPage()
+{
+ return window.location.href.indexOf("second") == -1;
+}
+
+window._onload_ = function () {
+ if (!window.eventSender || !window.testRunner) {
+ document.body.innerHTML = "This test must be run in WebKitTestRunner.";
+ return;
+ }
+
+ document.body.innerHTML = isFirstPage() ? "first" : "second";
+
+ if (isFirstPage()) {
+ initializeLog();
+
+ testRunner.setNavigationGesturesEnabled(true);
+
+ testRunner.installDidBeginSwipeCallback(didBeginSwipeCallback);
+ testRunner.installWillEndSwipeCallback(willEndSwipeCallback);
+ testRunner.installDidEndSwipeCallback(didEndSwipeCallback);
+ testRunner.installDidRemoveSwipeSnapshotCallback(didRemoveSwipeSnapshotCallback);
+
+ testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+
+ setTimeout(function () {
+ window.location.href = "" + "?second";
+ }, 0);
+ return;
+ }
+
+ startSwipeGesture();
+};
+</script>
+</head>
+<body>
+</body>
\ No newline at end of file
Added: trunk/LayoutTests/swipe/resources/swipe-test.js (0 => 189287)
--- trunk/LayoutTests/swipe/resources/swipe-test.js (rev 0)
+++ trunk/LayoutTests/swipe/resources/swipe-test.js 2015-09-03 21:11:44 UTC (rev 189287)
@@ -0,0 +1,70 @@
+var eventQueue = {
+ enqueueScrollEvent: function (x, y, phase) {
+ this._queue.push(function () {
+ log("scroll event (delta " + x + " " + y + ", phase '" + phase + "')");
+ window.eventSender.mouseScrollByWithWheelAndMomentumPhases(x, y, phase, 'none');
+ });
+ this._processEventQueueSoon();
+ },
+
+ enqueueSwipeEvent: function (x, y, phase) {
+ this._queue.push(function () {
+ log("swipe event (delta " + x + " " + y + ", phase '" + phase + "')");
+ window.eventSender.swipeGestureWithWheelAndMomentumPhases(x, y, phase, 'none');
+ });
+ this._processEventQueueSoon();
+ },
+
+ hasPendingEvents: function () {
+ return this._queue.length != 0;
+ },
+
+ _queue: [],
+
+ _processEventQueue: function () {
+ if (!this._queue.length)
+ return;
+
+ var item = this._queue.shift();
+ item();
+ this._processEventQueueSoon();
+ },
+
+ _processEventQueueSoon: function () {
+ clearTimeout(this._processingTimeout);
+ this._processingTimeout = setTimeout(this._processEventQueue.bind(this), 0);
+ }
+}
+
+function shouldBe(expected, actual, message)
+{
+ if (expected != actual)
+ log("Failure. " + message + " (expected: " + expected + ", actual: " + actual + ")");
+}
+
+function log(s)
+{
+ window.localStorage["swipeLogging"] += s + "<br/>";
+}
+
+function dumpLog()
+{
+ window.document.body.innerHTML = window.localStorage["swipeLogging"];
+}
+
+function initializeLog()
+{
+ window.localStorage["swipeLogging"] = "";
+}
+
+function startMeasuringDuration(key)
+{
+ window.localStorage[key + "swipeStartTime"] = Date.now();
+}
+
+function measuredDurationShouldBeLessThan(key, timeInMS, message)
+{
+ var duration = Date.now() - window.localStorage[key + "swipeStartTime"];
+ if (duration >= timeInMS)
+ log("Failure. " + message + " (expected: " + timeInMS + ", actual: " + duration + ")");
+}
\ No newline at end of file
Modified: trunk/Source/WebKit2/ChangeLog (189286 => 189287)
--- trunk/Source/WebKit2/ChangeLog 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Source/WebKit2/ChangeLog 2015-09-03 21:11:44 UTC (rev 189287)
@@ -1,3 +1,17 @@
+2015-09-03 Tim Horton <[email protected]>
+
+ [Mac] Add support for testing swipes
+ https://bugs.webkit.org/show_bug.cgi?id=148700
+
+ Reviewed by Beth Dakin.
+
+ * UIProcess/API/mac/WKView.mm:
+ (takeWindowSnapshot):
+ (-[WKView _takeViewSnapshot]):
+ Fall back to the non-hardware snapshotting path if the hardware path fails,
+ which usually happens if the view is fully off-screen (as in the case
+ of WebKitTestRunner).
+
2015-09-02 Tim Horton <[email protected]>
Add a modern API way to know that the navigation gesture snapshot was removed, for WebKitTestRunner
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (189286 => 189287)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-09-03 21:11:44 UTC (rev 189287)
@@ -3343,6 +3343,24 @@
return _data->_rootLayer.get();
}
+static RetainPtr<CGImageRef> takeWindowSnapshot(CGSWindowID windowID, bool captureAtNominalResolution)
+{
+ CGSWindowCaptureOptions options = kCGSCaptureIgnoreGlobalClipShape;
+ if (captureAtNominalResolution)
+ options |= kCGSWindowCaptureNominalResolution;
+ RetainPtr<CFArrayRef> windowSnapshotImages = adoptCF(CGSHWCaptureWindowList(CGSMainConnectionID(), &windowID, 1, options));
+
+ if (windowSnapshotImages && CFArrayGetCount(windowSnapshotImages.get()))
+ return (CGImageRef)CFArrayGetValueAtIndex(windowSnapshotImages.get(), 0);
+
+ // Fall back to the non-hardware capture path if we didn't get a snapshot
+ // (which usually happens if the window is fully off-screen).
+ CGWindowImageOption imageOptions = kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque;
+ if (captureAtNominalResolution)
+ imageOptions |= kCGWindowImageNominalResolution;
+ return adoptCF(CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowID, imageOptions));
+}
+
- (PassRefPtr<ViewSnapshot>)_takeViewSnapshot
{
NSWindow *window = self.window;
@@ -3353,21 +3371,19 @@
CGSWindowCaptureOptions options = kCGSCaptureIgnoreGlobalClipShape;
RetainPtr<CFArrayRef> windowSnapshotImages = adoptCF(CGSHWCaptureWindowList(CGSMainConnectionID(), &windowID, 1, options));
- if (!windowSnapshotImages || !CFArrayGetCount(windowSnapshotImages.get()))
+
+ RetainPtr<CGImageRef> windowSnapshotImage = takeWindowSnapshot(windowID, false);
+ if (!windowSnapshotImage)
return nullptr;
- RetainPtr<CGImageRef> windowSnapshotImage = (CGImageRef)CFArrayGetValueAtIndex(windowSnapshotImages.get(), 0);
-
// Work around <rdar://problem/17084993>; re-request the snapshot at kCGWindowImageNominalResolution if it was captured at the wrong scale.
CGFloat desiredSnapshotWidth = window.frame.size.width * window.screen.backingScaleFactor;
- if (CGImageGetWidth(windowSnapshotImage.get()) != desiredSnapshotWidth) {
- options |= kCGSWindowCaptureNominalResolution;
- windowSnapshotImages = adoptCF(CGSHWCaptureWindowList(CGSMainConnectionID(), &windowID, 1, options));
- if (!windowSnapshotImages || !CFArrayGetCount(windowSnapshotImages.get()))
- return nullptr;
- windowSnapshotImage = (CGImageRef)CFArrayGetValueAtIndex(windowSnapshotImages.get(), 0);
- }
+ if (CGImageGetWidth(windowSnapshotImage.get()) != desiredSnapshotWidth)
+ windowSnapshotImage = takeWindowSnapshot(windowID, true);
+ if (!windowSnapshotImage)
+ return nullptr;
+
[self _ensureGestureController];
NSRect windowCaptureRect;
Modified: trunk/Tools/ChangeLog (189286 => 189287)
--- trunk/Tools/ChangeLog 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/ChangeLog 2015-09-03 21:11:44 UTC (rev 189287)
@@ -1,3 +1,77 @@
+2015-09-03 Tim Horton <[email protected]>
+
+ [Mac] Add support for testing swipes
+ https://bugs.webkit.org/show_bug.cgi?id=148700
+
+ Reviewed by Beth Dakin.
+
+ * WebKitTestRunner/EventSenderProxy.h:
+ * WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl:
+ * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+ * WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
+ (WTR::cgEventPhaseFromString):
+ (WTR::cgEventMomentumPhaseFromString):
+ (WTR::EventSendingController::mouseScrollByWithWheelAndMomentumPhases):
+ (WTR::EventSendingController::swipeGestureWithWheelAndMomentumPhases):
+ * WebKitTestRunner/InjectedBundle/EventSendingController.h:
+ * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+ (WTR::InjectedBundle::didReceiveMessageToPage):
+ * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+ (WTR::TestRunner::installDidBeginSwipeCallback):
+ (WTR::TestRunner::installWillEndSwipeCallback):
+ (WTR::TestRunner::installDidEndSwipeCallback):
+ (WTR::TestRunner::installDidRemoveSwipeSnapshotCallback):
+ (WTR::TestRunner::callDidBeginSwipeCallback):
+ (WTR::TestRunner::callWillEndSwipeCallback):
+ (WTR::TestRunner::callDidEndSwipeCallback):
+ (WTR::TestRunner::callDidRemoveSwipeSnapshotCallback):
+ * WebKitTestRunner/InjectedBundle/TestRunner.h:
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::TestController::createOtherPage):
+ (WTR::TestController::createWebViewWithOptions):
+ (WTR::TestController::didReceiveMessageFromInjectedBundle):
+ (WTR::TestController::didBeginNavigationGesture):
+ (WTR::TestController::willEndNavigationGesture):
+ (WTR::TestController::didEndNavigationGesture):
+ (WTR::TestController::didRemoveNavigationGestureSnapshot):
+ * WebKitTestRunner/TestController.h:
+ * WebKitTestRunner/TestInvocation.cpp:
+ (WTR::TestInvocation::didBeginSwipe):
+ (WTR::TestInvocation::willEndSwipe):
+ (WTR::TestInvocation::didEndSwipe):
+ (WTR::TestInvocation::didRemoveSwipeSnapshot):
+ * WebKitTestRunner/TestInvocation.h:
+ Add callbacks when navigation gestures didBegin/willEnd/didEnd, and
+ when the snapshot is removed.
+
+ Add swipeGestureWithWheelAndMomentumPhases, just like the equivalent
+ mouseScrollBy function.
+
+ * WebKitTestRunner/mac/EventSenderProxy.mm:
+ (-[EventSenderSyntheticEvent initPressureEventAtLocation:globalLocation:stage:pressure:phase:time:eventNumber:]):
+ (-[EventSenderSyntheticEvent type]):
+ (-[EventSenderSyntheticEvent subtype]):
+ (-[EventSenderSyntheticEvent locationInWindow]):
+ (-[EventSenderSyntheticEvent location]):
+ (-[EventSenderSyntheticEvent momentumPhase]):
+ (-[EventSenderSyntheticEvent _isTouchesEnded]):
+ (-[EventSenderSyntheticEvent _cgsEventRecord]):
+ Rename EventSenderPressureEvent to EventSenderSyntheticEvent and add some
+ more adjustable values.
+
+ (WTR::EventSenderProxy::mouseForceDown):
+ (WTR::EventSenderProxy::mouseForceUp):
+ (WTR::EventSenderProxy::mouseForceChanged):
+ Adopt EventSenderSyntheticEvent.
+
+ (WTR::nsEventPhaseFromCGEventPhase):
+ (WTR::EventSenderProxy::swipeGestureWithWheelAndMomentumPhases):
+ Make use of EventSenderSyntheticEvent to synthesize swipe gesture events.
+
+ * WebKitTestRunner/mac/PlatformWebViewMac.mm:
+ (WTR::PlatformWebView::PlatformWebView):
+ Enable swipe.
+
2015-09-03 Myles C. Maxfield <[email protected]>
[WK2] Allow tagging tests with metadata which needs to be known at web process creation time
Modified: trunk/Tools/WebKitTestRunner/EventSenderProxy.h (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/EventSenderProxy.h 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/EventSenderProxy.h 2015-09-03 21:11:44 UTC (rev 189287)
@@ -64,6 +64,7 @@
void mouseMoveTo(double x, double y);
void mouseScrollBy(int x, int y);
void mouseScrollByWithWheelAndMomentumPhases(int x, int y, int phase, int momentum);
+ void swipeGestureWithWheelAndMomentumPhases(int x, int y, int phase, int momentum);
void continuousMouseScrollBy(int x, int y, bool paged);
void leapForward(int milliseconds);
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl 2015-09-03 21:11:44 UTC (rev 189287)
@@ -32,6 +32,7 @@
void mouseForceChanged(double force);
void mouseScrollBy(long x, long y);
void mouseScrollByWithWheelAndMomentumPhases(long x, long y, DOMString phase, DOMString momentum);
+ void swipeGestureWithWheelAndMomentumPhases(long x, long y, DOMString phase, DOMString momentum);
void continuousMouseScrollBy(long x, long y, optional boolean paged);
object contextClick();
void scheduleAsynchronousClick();
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2015-09-03 21:11:44 UTC (rev 189287)
@@ -76,6 +76,7 @@
void setAsynchronousSpellCheckingEnabled(boolean value);
void setPrinting();
void setShouldDecideNavigationPolicyAfterDelay(boolean value);
+ void setNavigationGesturesEnabled(boolean value);
// Special DOM functions.
void clearBackForwardList();
@@ -204,5 +205,11 @@
// Hooks to the JSC compiler.
object numberOfDFGCompiles(object function);
object neverInlineFunction(object function);
+
+ // Swipe gestures
+ void installDidBeginSwipeCallback(object callback);
+ void installWillEndSwipeCallback(object callback);
+ void installDidEndSwipeCallback(object callback);
+ void installDidRemoveSwipeSnapshotCallback(object callback);
};
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp 2015-09-03 21:11:44 UTC (rev 189287)
@@ -391,6 +391,40 @@
WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get());
}
+static uint64_t cgEventPhaseFromString(JSStringRef phaseStr)
+{
+ if (JSStringIsEqualToUTF8CString(phaseStr, "none"))
+ return 0;
+ if (JSStringIsEqualToUTF8CString(phaseStr, "began"))
+ return 1; // kCGScrollPhaseBegan
+ if (JSStringIsEqualToUTF8CString(phaseStr, "changed"))
+ return 2; // kCGScrollPhaseChanged
+ if (JSStringIsEqualToUTF8CString(phaseStr, "ended"))
+ return 4; // kCGScrollPhaseEnded
+ if (JSStringIsEqualToUTF8CString(phaseStr, "cancelled"))
+ return 8; // kCGScrollPhaseCancelled
+ if (JSStringIsEqualToUTF8CString(phaseStr, "maybegin"))
+ return 128; // kCGScrollPhaseMayBegin
+
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+static uint64_t cgEventMomentumPhaseFromString(JSStringRef phaseStr)
+{
+ if (JSStringIsEqualToUTF8CString(phaseStr, "none"))
+ return 0; // kCGMomentumScrollPhaseNone
+ if (JSStringIsEqualToUTF8CString(phaseStr, "begin"))
+ return 1; // kCGMomentumScrollPhaseBegin
+ if (JSStringIsEqualToUTF8CString(phaseStr, "continue"))
+ return 2; // kCGMomentumScrollPhaseContinue
+ if (JSStringIsEqualToUTF8CString(phaseStr, "end"))
+ return 3; // kCGMomentumScrollPhaseEnd
+
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
void EventSendingController::mouseScrollByWithWheelAndMomentumPhases(int x, int y, JSStringRef phaseStr, JSStringRef momentumStr)
{
WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender"));
@@ -408,34 +442,45 @@
WKRetainPtr<WKDoubleRef> yRef(AdoptWK, WKDoubleCreate(y));
WKDictionarySetItem(EventSenderMessageBody.get(), yKey.get(), yRef.get());
- uint64_t phase = 0;
- if (JSStringIsEqualToUTF8CString(phaseStr, "none"))
- phase = 0;
- else if (JSStringIsEqualToUTF8CString(phaseStr, "began"))
- phase = 1; // kCGScrollPhaseBegan
- else if (JSStringIsEqualToUTF8CString(phaseStr, "changed"))
- phase = 2; // kCGScrollPhaseChanged
- else if (JSStringIsEqualToUTF8CString(phaseStr, "ended"))
- phase = 4; // kCGScrollPhaseEnded
- else if (JSStringIsEqualToUTF8CString(phaseStr, "cancelled"))
- phase = 8; // kCGScrollPhaseCancelled
- else if (JSStringIsEqualToUTF8CString(phaseStr, "maybegin"))
- phase = 128; // kCGScrollPhaseMayBegin
+ uint64_t phase = cgEventPhaseFromString(phaseStr);
+ uint64_t momentum = cgEventMomentumPhaseFromString(momentumStr);
WKRetainPtr<WKStringRef> phaseKey(AdoptWK, WKStringCreateWithUTF8CString("Phase"));
WKRetainPtr<WKUInt64Ref> phaseRef(AdoptWK, WKUInt64Create(phase));
WKDictionarySetItem(EventSenderMessageBody.get(), phaseKey.get(), phaseRef.get());
- uint64_t momentum = 0;
- if (JSStringIsEqualToUTF8CString(momentumStr, "none"))
- momentum = 0; // kCGMomentumScrollPhaseNone
- else if (JSStringIsEqualToUTF8CString(momentumStr, "begin"))
- momentum = 1; // kCGMomentumScrollPhaseBegin
- else if (JSStringIsEqualToUTF8CString(momentumStr, "continue"))
- momentum = 2; // kCGMomentumScrollPhaseContinue
- else if (JSStringIsEqualToUTF8CString(momentumStr, "end"))
- momentum = 3; // kCGMomentumScrollPhaseEnd
+ WKRetainPtr<WKStringRef> momentumKey(AdoptWK, WKStringCreateWithUTF8CString("Momentum"));
+ WKRetainPtr<WKUInt64Ref> momentumRef(AdoptWK, WKUInt64Create(momentum));
+ WKDictionarySetItem(EventSenderMessageBody.get(), momentumKey.get(), momentumRef.get());
+ WKBundlePageForceRepaint(InjectedBundle::singleton().page()->page()); // Triggers a scrolling tree commit.
+ WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), EventSenderMessageName.get(), EventSenderMessageBody.get());
+}
+
+void EventSendingController::swipeGestureWithWheelAndMomentumPhases(int x, int y, JSStringRef phaseStr, JSStringRef momentumStr)
+{
+ WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender"));
+ WKRetainPtr<WKMutableDictionaryRef> EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate());
+
+ WKRetainPtr<WKStringRef> subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage"));
+ WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("SwipeGestureWithWheelAndMomentumPhases"));
+ WKDictionarySetItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get());
+
+ WKRetainPtr<WKStringRef> xKey(AdoptWK, WKStringCreateWithUTF8CString("X"));
+ WKRetainPtr<WKDoubleRef> xRef(AdoptWK, WKDoubleCreate(x));
+ WKDictionarySetItem(EventSenderMessageBody.get(), xKey.get(), xRef.get());
+
+ WKRetainPtr<WKStringRef> yKey(AdoptWK, WKStringCreateWithUTF8CString("Y"));
+ WKRetainPtr<WKDoubleRef> yRef(AdoptWK, WKDoubleCreate(y));
+ WKDictionarySetItem(EventSenderMessageBody.get(), yKey.get(), yRef.get());
+
+ uint64_t phase = cgEventPhaseFromString(phaseStr);
+ uint64_t momentum = cgEventMomentumPhaseFromString(momentumStr);
+
+ WKRetainPtr<WKStringRef> phaseKey(AdoptWK, WKStringCreateWithUTF8CString("Phase"));
+ WKRetainPtr<WKUInt64Ref> phaseRef(AdoptWK, WKUInt64Create(phase));
+ WKDictionarySetItem(EventSenderMessageBody.get(), phaseKey.get(), phaseRef.get());
+
WKRetainPtr<WKStringRef> momentumKey(AdoptWK, WKStringCreateWithUTF8CString("Momentum"));
WKRetainPtr<WKUInt64Ref> momentumRef(AdoptWK, WKUInt64Create(momentum));
WKDictionarySetItem(EventSenderMessageBody.get(), momentumKey.get(), momentumRef.get());
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h 2015-09-03 21:11:44 UTC (rev 189287)
@@ -51,6 +51,7 @@
void mouseForceChanged(double force);
void mouseScrollBy(int x, int y);
void mouseScrollByWithWheelAndMomentumPhases(int x, int y, JSStringRef phase, JSStringRef momentum);
+ void swipeGestureWithWheelAndMomentumPhases(int x, int y, JSStringRef phase, JSStringRef momentum);
void continuousMouseScrollBy(int x, int y, bool paged);
JSValueRef contextClick();
void leapForward(int milliseconds);
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp 2015-09-03 21:11:44 UTC (rev 189287)
@@ -215,6 +215,26 @@
return;
}
+ if (WKStringIsEqualToUTF8CString(messageName, "CallDidBeginSwipeCallback")) {
+ m_testRunner->callDidBeginSwipeCallback();
+ return;
+ }
+
+ if (WKStringIsEqualToUTF8CString(messageName, "CallWillEndSwipeCallback")) {
+ m_testRunner->callWillEndSwipeCallback();
+ return;
+ }
+
+ if (WKStringIsEqualToUTF8CString(messageName, "CallDidEndSwipeCallback")) {
+ m_testRunner->callDidEndSwipeCallback();
+ return;
+ }
+
+ if (WKStringIsEqualToUTF8CString(messageName, "CallDidRemoveSwipeSnapshotCallback")) {
+ m_testRunner->callDidRemoveSwipeSnapshotCallback();
+ return;
+ }
+
if (WKStringIsEqualToUTF8CString(messageName, "WorkQueueProcessedCallback")) {
if (!topLoadingFrame() && !m_testRunner->waitToDump())
InjectedBundle::page()->dump();
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2015-09-03 21:11:44 UTC (rev 189287)
@@ -509,7 +509,11 @@
AddChromeInputFieldCallbackID = 1,
RemoveChromeInputFieldCallbackID,
FocusWebViewCallbackID,
- SetBackingScaleFactorCallbackID
+ SetBackingScaleFactorCallbackID,
+ DidBeginSwipeCallbackID,
+ WillEndSwipeCallbackID,
+ DidEndSwipeCallbackID,
+ DidRemoveSwipeSnapshotCallbackID
};
static void cacheTestRunnerCallback(unsigned index, JSValueRef callback)
@@ -860,4 +864,51 @@
WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
}
+void TestRunner::setNavigationGesturesEnabled(bool value)
+{
+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetNavigationGesturesEnabled"));
+ WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value));
+ WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
+}
+
+void TestRunner::installDidBeginSwipeCallback(JSValueRef callback)
+{
+ cacheTestRunnerCallback(DidBeginSwipeCallbackID, callback);
+}
+
+void TestRunner::installWillEndSwipeCallback(JSValueRef callback)
+{
+ cacheTestRunnerCallback(WillEndSwipeCallbackID, callback);
+}
+
+void TestRunner::installDidEndSwipeCallback(JSValueRef callback)
+{
+ cacheTestRunnerCallback(DidEndSwipeCallbackID, callback);
+}
+
+void TestRunner::installDidRemoveSwipeSnapshotCallback(JSValueRef callback)
+{
+ cacheTestRunnerCallback(DidRemoveSwipeSnapshotCallbackID, callback);
+}
+
+void TestRunner::callDidBeginSwipeCallback()
+{
+ callTestRunnerCallback(DidBeginSwipeCallbackID);
+}
+
+void TestRunner::callWillEndSwipeCallback()
+{
+ callTestRunnerCallback(WillEndSwipeCallbackID);
+}
+
+void TestRunner::callDidEndSwipeCallback()
+{
+ callTestRunnerCallback(DidEndSwipeCallbackID);
+}
+
+void TestRunner::callDidRemoveSwipeSnapshotCallback()
+{
+ callTestRunnerCallback(DidRemoveSwipeSnapshotCallbackID);
+}
+
} // namespace WTR
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2015-09-03 21:11:44 UTC (rev 189287)
@@ -285,7 +285,17 @@
bool shouldDecideNavigationPolicyAfterDelay() const { return m_shouldDecideNavigationPolicyAfterDelay; }
void setShouldDecideNavigationPolicyAfterDelay(bool);
+ void setNavigationGesturesEnabled(bool);
+ void installDidBeginSwipeCallback(JSValueRef);
+ void installWillEndSwipeCallback(JSValueRef);
+ void installDidEndSwipeCallback(JSValueRef);
+ void installDidRemoveSwipeSnapshotCallback(JSValueRef);
+ void callDidBeginSwipeCallback();
+ void callWillEndSwipeCallback();
+ void callDidEndSwipeCallback();
+ void callDidRemoveSwipeSnapshotCallback();
+
private:
TestRunner();
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/ios/EventSenderProxyIOS.mm (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/ios/EventSenderProxyIOS.mm 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/ios/EventSenderProxyIOS.mm 2015-09-03 21:11:44 UTC (rev 189287)
@@ -103,6 +103,11 @@
// Write me.
}
+void EventSenderProxy::swipeGestureWithWheelAndMomentumPhases(int, int, int, int)
+{
+ // Write me.
+}
+
void EventSenderProxy::continuousMouseScrollBy(int x, int y, bool paged)
{
// Write me.
Modified: trunk/Tools/WebKitTestRunner/PlatformWebView.h (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/PlatformWebView.h 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/PlatformWebView.h 2015-09-03 21:11:44 UTC (rev 189287)
@@ -86,6 +86,7 @@
const ViewOptions& options() const { return m_options; }
void changeWindowScaleIfNeeded(float newScale);
+ void setNavigationGesturesEnabled(bool);
#if PLATFORM(GTK)
void dismissAllPopupMenus();
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2015-09-03 21:11:44 UTC (rev 189287)
@@ -294,10 +294,10 @@
didReceiveAuthenticationChallenge,
processDidCrash,
copyWebCryptoMasterKey,
- 0, // didBeginNavigationGesture
- 0, // willEndNavigationGesture
- 0, // didEndNavigationGesture
- 0, // didRemoveNavigationGestureSnapshot
+ didBeginNavigationGesture,
+ willEndNavigationGesture,
+ didEndNavigationGesture,
+ didRemoveNavigationGestureSnapshot
};
WKPageSetPageNavigationClient(newPage, &pageNavigationClient.base);
@@ -539,10 +539,10 @@
didReceiveAuthenticationChallenge,
processDidCrash,
copyWebCryptoMasterKey,
- 0, // didBeginNavigationGesture
- 0, // willEndNavigationGesture
- 0, // didEndNavigationGesture
- 0, // didRemoveNavigationGestureSnapshot
+ didBeginNavigationGesture,
+ willEndNavigationGesture,
+ didEndNavigationGesture,
+ didRemoveNavigationGestureSnapshot
};
WKPageSetPageNavigationClient(m_mainWebView->page(), &pageNavigationClient.base);
@@ -746,6 +746,8 @@
m_shouldDecideNavigationPolicyAfterDelay = false;
+ setNavigationGesturesEnabled(false);
+
WKPageLoadURL(m_mainWebView->page(), blankURL());
runUntil(m_doneResetting, shortTimeout);
return m_doneResetting;
@@ -1137,6 +1139,23 @@
return;
}
+ if (WKStringIsEqualToUTF8CString(subMessageName, "SwipeGestureWithWheelAndMomentumPhases")) {
+ WKRetainPtr<WKStringRef> xKey = adoptWK(WKStringCreateWithUTF8CString("X"));
+ double x = WKDoubleGetValue(static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, xKey.get())));
+
+ WKRetainPtr<WKStringRef> yKey = adoptWK(WKStringCreateWithUTF8CString("Y"));
+ double y = WKDoubleGetValue(static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(messageBodyDictionary, yKey.get())));
+
+ WKRetainPtr<WKStringRef> phaseKey = adoptWK(WKStringCreateWithUTF8CString("Phase"));
+ int phase = static_cast<int>(WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, phaseKey.get()))));
+ WKRetainPtr<WKStringRef> momentumKey = adoptWK(WKStringCreateWithUTF8CString("Momentum"));
+ int momentum = static_cast<int>(WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, momentumKey.get()))));
+
+ m_eventSenderProxy->swipeGestureWithWheelAndMomentumPhases(x, y, phase, momentum);
+
+ return;
+ }
+
ASSERT_NOT_REACHED();
}
@@ -1373,6 +1392,26 @@
static_cast<TestController*>(const_cast<void*>(clientInfo))->processDidCrash();
}
+void TestController::didBeginNavigationGesture(WKPageRef page, const void *clientInfo)
+{
+ static_cast<TestController*>(const_cast<void*>(clientInfo))->didBeginNavigationGesture(page);
+}
+
+void TestController::willEndNavigationGesture(WKPageRef page, WKBackForwardListItemRef backForwardListItem, const void *clientInfo)
+{
+ static_cast<TestController*>(const_cast<void*>(clientInfo))->willEndNavigationGesture(page, backForwardListItem);
+}
+
+void TestController::didEndNavigationGesture(WKPageRef page, WKBackForwardListItemRef backForwardListItem, const void *clientInfo)
+{
+ static_cast<TestController*>(const_cast<void*>(clientInfo))->didEndNavigationGesture(page, backForwardListItem);
+}
+
+void TestController::didRemoveNavigationGestureSnapshot(WKPageRef page, const void *clientInfo)
+{
+ static_cast<TestController*>(const_cast<void*>(clientInfo))->didRemoveNavigationGestureSnapshot(page);
+}
+
WKPluginLoadPolicy TestController::decidePolicyForPluginLoad(WKPageRef page, WKPluginLoadPolicy currentPluginLoadPolicy, WKDictionaryRef pluginInformation, WKStringRef* unavailabilityDescription, const void* clientInfo)
{
return static_cast<TestController*>(const_cast<void*>(clientInfo))->decidePolicyForPluginLoad(page, currentPluginLoadPolicy, pluginInformation, unavailabilityDescription);
@@ -1470,6 +1509,26 @@
exit(1);
}
+void TestController::didBeginNavigationGesture(WKPageRef)
+{
+ m_currentInvocation->didBeginSwipe();
+}
+
+void TestController::willEndNavigationGesture(WKPageRef, WKBackForwardListItemRef)
+{
+ m_currentInvocation->willEndSwipe();
+}
+
+void TestController::didEndNavigationGesture(WKPageRef, WKBackForwardListItemRef)
+{
+ m_currentInvocation->didEndSwipe();
+}
+
+void TestController::didRemoveNavigationGestureSnapshot(WKPageRef)
+{
+ m_currentInvocation->didRemoveSwipeSnapshot();
+}
+
void TestController::simulateWebNotificationClick(uint64_t notificationID)
{
m_webNotificationProvider.simulateWebNotificationClick(notificationID);
@@ -1688,6 +1747,11 @@
m_currentInvocation->outputText(String::format("WebView updated the title for history URL \"%s\" to \"%s\".\n", toSTD(urlStringWK).c_str(), toSTD(title).c_str()));
}
+void TestController::setNavigationGesturesEnabled(bool value)
+{
+ m_mainWebView->setNavigationGesturesEnabled(value);
+}
+
#if !PLATFORM(COCOA)
void TestController::platformWillRunTest(const TestInvocation&)
{
Modified: trunk/Tools/WebKitTestRunner/TestController.h (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/TestController.h 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/TestController.h 2015-09-03 21:11:44 UTC (rev 189287)
@@ -126,6 +126,8 @@
void setShouldDecideNavigationPolicyAfterDelay(bool value) { m_shouldDecideNavigationPolicyAfterDelay = value; }
+ void setNavigationGesturesEnabled(bool value);
+
private:
void initialize(int argc, const char* argv[]);
void createWebViewWithOptions(const ViewOptions&);
@@ -142,6 +144,9 @@
static PlatformWebView* platformCreateOtherPage(PlatformWebView* parentView, WKPageConfigurationRef, const ViewOptions&);
void platformResetPreferencesToConsistentValues();
void platformResetStateToConsistentValues();
+#if PLATFORM(COCOA)
+ void cocoaResetStateToConsistentValues();
+#endif
void platformConfigureViewForTest(const TestInvocation&);
void platformWillRunTest(const TestInvocation&);
void platformRunUntil(bool& done, double timeout);
@@ -186,6 +191,15 @@
static void processDidCrash(WKPageRef, const void* clientInfo);
void processDidCrash();
+ static void didBeginNavigationGesture(WKPageRef, const void*);
+ static void willEndNavigationGesture(WKPageRef, WKBackForwardListItemRef, const void*);
+ static void didEndNavigationGesture(WKPageRef, WKBackForwardListItemRef, const void*);
+ static void didRemoveNavigationGestureSnapshot(WKPageRef, const void*);
+ void didBeginNavigationGesture(WKPageRef);
+ void willEndNavigationGesture(WKPageRef, WKBackForwardListItemRef);
+ void didEndNavigationGesture(WKPageRef, WKBackForwardListItemRef);
+ void didRemoveNavigationGestureSnapshot(WKPageRef);
+
static WKPluginLoadPolicy decidePolicyForPluginLoad(WKPageRef, WKPluginLoadPolicy currentPluginLoadPolicy, WKDictionaryRef pluginInformation, WKStringRef* unavailabilityDescription, const void* clientInfo);
WKPluginLoadPolicy decidePolicyForPluginLoad(WKPageRef, WKPluginLoadPolicy currentPluginLoadPolicy, WKDictionaryRef pluginInformation, WKStringRef* unavailabilityDescription);
Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2015-09-03 21:11:44 UTC (rev 189287)
@@ -635,6 +635,13 @@
return;
}
+ if (WKStringIsEqualToUTF8CString(messageName, "SetNavigationGesturesEnabled")) {
+ ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
+ WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);
+ TestController::singleton().setNavigationGesturesEnabled(WKBooleanGetValue(value));
+ return;
+ }
+
ASSERT_NOT_REACHED();
}
@@ -685,4 +692,28 @@
m_textOutput.append(text);
}
+void TestInvocation::didBeginSwipe()
+{
+ WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidBeginSwipeCallback"));
+ WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
+}
+
+void TestInvocation::willEndSwipe()
+{
+ WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallWillEndSwipeCallback"));
+ WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
+}
+
+void TestInvocation::didEndSwipe()
+{
+ WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidEndSwipeCallback"));
+ WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
+}
+
+void TestInvocation::didRemoveSwipeSnapshot()
+{
+ WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidRemoveSwipeSnapshotCallback"));
+ WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
+}
+
} // namespace WTR
Modified: trunk/Tools/WebKitTestRunner/TestInvocation.h (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/TestInvocation.h 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.h 2015-09-03 21:11:44 UTC (rev 189287)
@@ -54,6 +54,12 @@
void dumpWebProcessUnresponsiveness();
static void dumpWebProcessUnresponsiveness(const char* errorMessage);
void outputText(const WTF::String&);
+
+ void didBeginSwipe();
+ void willEndSwipe();
+ void didEndSwipe();
+ void didRemoveSwipeSnapshot();
+
private:
void dumpResults();
static void dump(const char* textToStdout, const char* textToStderr = 0, bool seenError = false);
Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm 2015-09-03 21:11:44 UTC (rev 189287)
@@ -108,7 +108,7 @@
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:endDate];
}
-void TestController::platformResetStateToConsistentValues()
+void TestController::cocoaResetStateToConsistentValues()
{
#if WK_API_ENABLED
__block bool doneRemoving = false;
Modified: trunk/Tools/WebKitTestRunner/efl/EventSenderProxyEfl.cpp (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/efl/EventSenderProxyEfl.cpp 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/efl/EventSenderProxyEfl.cpp 2015-09-03 21:11:44 UTC (rev 189287)
@@ -399,6 +399,11 @@
mouseScrollBy(x, y);
}
+void EventSenderProxy::swipeGestureWithWheelAndMomentumPhases(int, int, int, int)
+{
+ notImplemented();
+}
+
void EventSenderProxy::leapForward(int milliseconds)
{
if (m_eventQueue.isEmpty())
Modified: trunk/Tools/WebKitTestRunner/efl/PlatformWebViewEfl.cpp (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/efl/PlatformWebViewEfl.cpp 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/efl/PlatformWebViewEfl.cpp 2015-09-03 21:11:44 UTC (rev 189287)
@@ -156,5 +156,9 @@
{
}
+void PlatformWebView::setNavigationGesturesEnabled(bool)
+{
+}
+
} // namespace WTR
Modified: trunk/Tools/WebKitTestRunner/gtk/EventSenderProxyGtk.cpp (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/gtk/EventSenderProxyGtk.cpp 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/gtk/EventSenderProxyGtk.cpp 2015-09-03 21:11:44 UTC (rev 189287)
@@ -451,6 +451,11 @@
mouseScrollBy(x, y);
}
+void EventSenderProxy::swipeGestureWithWheelAndMomentumPhases(int, int, int, int)
+{
+ notImplemented();
+}
+
void EventSenderProxy::leapForward(int milliseconds)
{
if (m_eventQueue.isEmpty())
Modified: trunk/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp 2015-09-03 21:11:44 UTC (rev 189287)
@@ -158,5 +158,9 @@
}, nullptr);
}
+void PlatformWebView::setNavigationGesturesEnabled(bool)
+{
+}
+
} // namespace WTR
Modified: trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm 2015-09-03 21:11:44 UTC (rev 189287)
@@ -207,4 +207,8 @@
return true;
}
+void PlatformWebView::setNavigationGesturesEnabled(bool enabled)
+{
+}
+
} // namespace WTR
Modified: trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm 2015-09-03 21:11:44 UTC (rev 189287)
@@ -86,6 +86,11 @@
WKPreferencesSetMinimumZoomFontSize(preferences, 0);
}
+void TestController::platformResetStateToConsistentValues()
+{
+ cocoaResetStateToConsistentValues();
+}
+
void TestController::platformConfigureViewForTest(const TestInvocation& test)
{
if (shouldMakeViewportFlexible(test)) {
Modified: trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm 2015-09-03 21:11:44 UTC (rev 189287)
@@ -40,25 +40,42 @@
- (void)_setCurrentEvent:(NSEvent *)event;
@end
-#if defined(__LP64__) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101003
-@interface EventSenderPressureEvent : NSEvent {
+#if defined(__LP64__)
+struct WKTRCGSEventRecord {
+ char offset1[150];
+ uint8_t phase;
+ char offset2[13];
+ float deltaX;
+ float deltaY;
+ char offset3[76];
+} __attribute__((packed));
+#endif
+
+@interface EventSenderSyntheticEvent : NSEvent {
@public
NSPoint _eventSender_locationInWindow;
NSPoint _eventSender_location;
NSInteger _eventSender_stage;
float _eventSender_pressure;
NSEventPhase _eventSender_phase;
+ NSEventPhase _eventSender_momentumPhase;
NSTimeInterval _eventSender_timestamp;
NSInteger _eventSender_eventNumber;
+ short _eventSender_subtype;
+ NSEventType _eventSender_type;
+
+#if defined(__LP64__)
+ WKTRCGSEventRecord _eventSender_cgsEventRecord;
+#endif
}
-- (id)initAtLocation:(NSPoint)location globalLocation:(NSPoint)globalLocation stage:(NSInteger)stage pressure:(float)pressure phase:(NSEventPhase)phase time:(NSTimeInterval)time eventNumber:(NSInteger)eventNumber;
+- (id)initPressureEventAtLocation:(NSPoint)location globalLocation:(NSPoint)globalLocation stage:(NSInteger)stage pressure:(float)pressure phase:(NSEventPhase)phase time:(NSTimeInterval)time eventNumber:(NSInteger)eventNumber;
- (NSTimeInterval)timestamp;
@end
-@implementation EventSenderPressureEvent
+@implementation EventSenderSyntheticEvent
-- (id)initAtLocation:(NSPoint)location globalLocation:(NSPoint)globalLocation stage:(NSInteger)stage pressure:(float)pressure phase:(NSEventPhase)phase time:(NSTimeInterval)time eventNumber:(NSInteger)eventNumber
+- (id)initPressureEventAtLocation:(NSPoint)location globalLocation:(NSPoint)globalLocation stage:(NSInteger)stage pressure:(float)pressure phase:(NSEventPhase)phase time:(NSTimeInterval)time eventNumber:(NSInteger)eventNumber
{
self = [super init];
@@ -72,6 +89,9 @@
_eventSender_phase = phase;
_eventSender_timestamp = time;
_eventSender_eventNumber = eventNumber;
+#if defined(__LP64__) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101003
+ _eventSender_type = NSEventTypePressure;
+#endif
return self;
}
@@ -83,17 +103,29 @@
- (NSEventType)type
{
- return NSEventTypePressure;
+ return _eventSender_type;
}
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 10100
+- (NSEventSubtype)subtype
+{
+ return (NSEventSubtype)_eventSender_subtype;
+}
+#else
+- (short)subtype
+{
+ return _eventSender_subtype;
+}
+#endif
+
- (NSPoint)locationInWindow
{
- return self->_eventSender_location;
+ return _eventSender_location;
}
- (NSPoint)location
{
- return self->_eventSender_locationInWindow;
+ return _eventSender_locationInWindow;
}
- (NSInteger)stage
@@ -111,13 +143,29 @@
return _eventSender_phase;
}
+- (NSEventPhase)momentumPhase
+{
+ return _eventSender_momentumPhase;
+}
+
- (NSInteger)eventNumber
{
return _eventSender_eventNumber;
}
+- (BOOL)_isTouchesEnded
+{
+ return false;
+}
+
+#if defined(__LP64__)
+- (WKTRCGSEventRecord)_cgsEventRecord
+{
+ return _eventSender_cgsEventRecord;
+}
+#endif
+
@end
-#endif // defined(__LP64__) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101003
namespace WTR {
@@ -290,17 +338,17 @@
m_clickPosition = m_position;
}
-#if defined(__LP64__) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101003
+#if defined(__LP64__) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101003
void EventSenderProxy::mouseForceDown()
{
- EventSenderPressureEvent *firstEvent = [[EventSenderPressureEvent alloc] initAtLocation:NSMakePoint(m_position.x, m_position.y)
+ EventSenderSyntheticEvent *firstEvent = [[EventSenderSyntheticEvent alloc] initPressureEventAtLocation:NSMakePoint(m_position.x, m_position.y)
globalLocation:([m_testController->mainWebView()->platformWindow() convertRectToScreen:NSMakeRect(m_position.x, m_position.y, 1, 1)].origin)
stage:1
pressure:0.9
phase:NSEventPhaseChanged
time:absoluteTimeForEventTime(currentEventTime())
eventNumber:++eventNumber];
- EventSenderPressureEvent *secondEvent = [[EventSenderPressureEvent alloc] initAtLocation:NSMakePoint(m_position.x, m_position.y)
+ EventSenderSyntheticEvent *secondEvent = [[EventSenderSyntheticEvent alloc] initPressureEventAtLocation:NSMakePoint(m_position.x, m_position.y)
globalLocation:([m_testController->mainWebView()->platformWindow() convertRectToScreen:NSMakeRect(m_position.x, m_position.y, 1, 1)].origin)
stage:2
pressure:0.1
@@ -332,14 +380,14 @@
void EventSenderProxy::mouseForceUp()
{
- EventSenderPressureEvent *firstEvent = [[EventSenderPressureEvent alloc] initAtLocation:NSMakePoint(m_position.x, m_position.y)
+ EventSenderSyntheticEvent *firstEvent = [[EventSenderSyntheticEvent alloc] initPressureEventAtLocation:NSMakePoint(m_position.x, m_position.y)
globalLocation:([m_testController->mainWebView()->platformWindow() convertRectToScreen:NSMakeRect(m_position.x, m_position.y, 1, 1)].origin)
stage:2
pressure:0.1
phase:NSEventPhaseChanged
time:absoluteTimeForEventTime(currentEventTime())
eventNumber:++eventNumber];
- EventSenderPressureEvent *secondEvent = [[EventSenderPressureEvent alloc] initAtLocation:NSMakePoint(m_position.x, m_position.y)
+ EventSenderSyntheticEvent *secondEvent = [[EventSenderSyntheticEvent alloc] initPressureEventAtLocation:NSMakePoint(m_position.x, m_position.y)
globalLocation:([m_testController->mainWebView()->platformWindow() convertRectToScreen:NSMakeRect(m_position.x, m_position.y, 1, 1)].origin)
stage:1
pressure:0.9
@@ -372,7 +420,7 @@
void EventSenderProxy::mouseForceChanged(float force)
{
- EventSenderPressureEvent *event = [[EventSenderPressureEvent alloc] initAtLocation:NSMakePoint(m_position.x, m_position.y)
+ EventSenderSyntheticEvent *event = [[EventSenderSyntheticEvent alloc] initPressureEventAtLocation:NSMakePoint(m_position.x, m_position.y)
globalLocation:([m_testController->mainWebView()->platformWindow() convertRectToScreen:NSMakeRect(m_position.x, m_position.y, 1, 1)].origin)
stage:force < 1 ? 1 : 2
pressure:force
@@ -407,7 +455,7 @@
void EventSenderProxy::mouseForceChanged(float)
{
}
-#endif // defined(__LP64__) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101003
+#endif // defined(__LP64__) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101003
void EventSenderProxy::mouseMoveTo(double x, double y)
{
@@ -705,4 +753,51 @@
}
}
+static NSEventPhase nsEventPhaseFromCGEventPhase(int phase)
+{
+ switch (phase) {
+ case 0: // kCGSGesturePhaseNone
+ return NSEventPhaseNone;
+ case 1: // kCGSGesturePhaseBegan
+ return NSEventPhaseBegan;
+ case 2: // kCGSGesturePhaseChanged
+ return NSEventPhaseChanged;
+ case 4: // kCGSGesturePhaseEnded
+ return NSEventPhaseEnded;
+ case 8: // kCGSGesturePhaseCancelled
+ return NSEventPhaseCancelled;
+ case 128: // kCGSGesturePhaseMayBegin
+ return NSEventPhaseMayBegin;
+ }
+
+ ASSERT_NOT_REACHED();
+ return NSEventPhaseNone;
+}
+
+void EventSenderProxy::swipeGestureWithWheelAndMomentumPhases(int x, int y, int phase, int momentum)
+{
+ EventSenderSyntheticEvent *event = [[EventSenderSyntheticEvent alloc] init];
+
+ // "mayBegin" a swipe is actually a scroll wheel event.
+ event->_eventSender_type = (phase == 128) ? NSScrollWheel : NSEventTypeGesture;
+ event->_eventSender_subtype = 6; // kIOHIDEventTypeScroll
+ event->_eventSender_locationInWindow = NSMakePoint(m_position.x, m_position.y);
+ event->_eventSender_location = ([m_testController->mainWebView()->platformWindow() convertRectToScreen:NSMakeRect(m_position.x, m_position.y, 1, 1)].origin);
+ event->_eventSender_phase = nsEventPhaseFromCGEventPhase(phase);
+ event->_eventSender_momentumPhase = nsEventPhaseFromCGEventPhase(momentum);
+ event->_eventSender_timestamp = absoluteTimeForEventTime(currentEventTime());
+ event->_eventSender_eventNumber = ++eventNumber;
+
+#if defined(__LP64__)
+ event->_eventSender_cgsEventRecord.phase = phase;
+ event->_eventSender_cgsEventRecord.deltaX = (float)x;
+ event->_eventSender_cgsEventRecord.deltaY = (float)y;
+#else
+ NSLog(@"Synthetic swipe gestures are not implemented for 32-bit WebKitTestRunner.");
+#endif
+
+ NSLog(@"sending swipe event %d %d phase %d", x, y, phase);
+ [NSApp sendEvent:event];
+}
+
} // namespace WTR
Modified: trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm 2015-09-03 21:11:44 UTC (rev 189287)
@@ -269,4 +269,9 @@
setWindowFrame(wkFrame);
}
+void PlatformWebView::setNavigationGesturesEnabled(bool enabled)
+{
+ [platformView() setAllowsBackForwardNavigationGestures:enabled];
+}
+
} // namespace WTR
Modified: trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm (189286 => 189287)
--- trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm 2015-09-03 21:03:46 UTC (rev 189286)
+++ trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm 2015-09-03 21:11:44 UTC (rev 189287)
@@ -86,6 +86,15 @@
{
}
+void TestController::platformResetStateToConsistentValues()
+{
+ cocoaResetStateToConsistentValues();
+
+ while ([NSApp nextEventMatchingMask:NSEventMaskGesture | NSScrollWheelMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES]) {
+ // Clear out (and ignore) any pending gesture and scroll wheel events.
+ }
+}
+
void TestController::updatePlatformSpecificViewOptionsForTest(ViewOptions& viewOptions, const TestInvocation& test) const
{
viewOptions.useThreadedScrolling = shouldUseThreadedScrolling(test);