[iOS WK2] Add viewport tests and fix runUIScript() timing issues
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 26 Sep 2015 00:17:27 +0000 (00:17 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 26 Sep 2015 00:17:27 +0000 (00:17 +0000)
commit506f25bb5af49c5636f3561e5d4d75ae8e46b96e
treec58ada0eac9f41b8efc79a1fd7b48fb7f655ec71
parent6a74cc1c02d8b670bf443cceaaee727ae21253a9
[iOS WK2] Add viewport tests and fix runUIScript() timing issues
https://bugs.webkit.org/show_bug.cgi?id=149577

Reviewed by Tim Horton.

Source/WebKit2:

When calling testRunner.runUIScript() from a page load event, the script could run
in the UI process before the current remote layer tree transaction had been handled
there. This meant that runUIScript() could query state which was about to change.

Fix by delaying the execution of the UI script until a layer tree transaction has
been handled by the UI process, leveraging the existing DrawingAreaProxy::dispatchAfterEnsuringDrawing().

This is done using a new C SPI function WKPageCallAfterNextPresentationUpdate(),
which is mirrored in the Obj-C SPI as -_doAfterNextPresentationUpdate:.

Move WKWebView SPI which is testing-related into a WKTesting category. It is expected
that this will grow significantly.

* UIProcess/API/C/WKPage.cpp:
(WKPageCallAfterNextPresentationUpdate):
* UIProcess/API/C/WKPagePrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::callAfterNextPresentationUpdate):
* UIProcess/WebPageProxy.h:
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
(WebKit::TiledCoreAnimationDrawingAreaProxy::dispatchAfterEnsuringDrawing):

Tools:

When calling testRunner.runUIScript() from a page load event, the script could run
in the UI process before the current remote layer tree transaction had been handled
there. This meant that runUIScript() could query state which was about to change.

Fix by delaying the execution of the UI script until a layer tree transaction has
been handled by the UI process, leveraging the existing DrawingAreaProxy::dispatchAfterEnsuringDrawing().

* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
(WTR::TestInvocation::runUISideScriptAfterUpdateCallback):
* WebKitTestRunner/TestInvocation.h:

LayoutTests:

New viewport tests which read the scale etc. in the UI process.

* TestExpectations:
* fast/viewport/ios/resources/viewport-test-utils.js: Added.
(getUIScript):
(tableFromJSON):
(getViewport):
(runTest):
* fast/viewport/ios/width-is-device-width-expected.txt: Added.
* fast/viewport/ios/width-is-device-width-overflowing-body-overflow-hidden-tall-expected.txt: Added.
* fast/viewport/ios/width-is-device-width-overflowing-body-overflow-hidden-tall.html: Added.
* fast/viewport/ios/width-is-device-width-overflowing-body-overflow-hidden.html: Added.
* fast/viewport/ios/width-is-device-width-overflowing-expected.txt: Added.
* fast/viewport/ios/width-is-device-width-overflowing-no-shrink-to-fit-expected.txt: Added.
* fast/viewport/ios/width-is-device-width-overflowing-no-shrink-to-fit.html: Added.
* fast/viewport/ios/width-is-device-width-overflowing.html: Added.
* fast/viewport/ios/width-is-device-width.html: Added.
* platform/ios-simulator-wk2/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190260 268f45cc-cd09-0410-ab3c-d52691b4dbfc
25 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/viewport/ios/resources/viewport-test-utils.js [new file with mode: 0644]
LayoutTests/fast/viewport/ios/width-is-device-width-expected.txt [new file with mode: 0644]
LayoutTests/fast/viewport/ios/width-is-device-width-overflowing-body-overflow-hidden-tall-expected.txt [new file with mode: 0644]
LayoutTests/fast/viewport/ios/width-is-device-width-overflowing-body-overflow-hidden-tall.html [new file with mode: 0644]
LayoutTests/fast/viewport/ios/width-is-device-width-overflowing-body-overflow-hidden.html [new file with mode: 0644]
LayoutTests/fast/viewport/ios/width-is-device-width-overflowing-expected.txt [new file with mode: 0644]
LayoutTests/fast/viewport/ios/width-is-device-width-overflowing-no-shrink-to-fit-expected.txt [new file with mode: 0644]
LayoutTests/fast/viewport/ios/width-is-device-width-overflowing-no-shrink-to-fit.html [new file with mode: 0644]
LayoutTests/fast/viewport/ios/width-is-device-width-overflowing.html [new file with mode: 0644]
LayoutTests/fast/viewport/ios/width-is-device-width.html [new file with mode: 0644]
LayoutTests/platform/ios-simulator-wk2/TestExpectations
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPagePrivate.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h
Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm
Tools/ChangeLog
Tools/WebKitTestRunner/TestInvocation.cpp
Tools/WebKitTestRunner/TestInvocation.h