Add the ability for tests to run script in the UI process in WebKitTestRunner
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Sep 2015 19:10:48 +0000 (19:10 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Sep 2015 19:10:48 +0000 (19:10 +0000)
commita0f965f867666d9721ae173f171c3bc606e7fd71
tree95c816e5b8bc3903fb5b7194f6f3fa6f71a32d40
parent2ce1c994571ebfa4a7fe5eff887b53d51a1b6fe6
Add the ability for tests to run script in the UI process in WebKitTestRunner
https://bugs.webkit.org/show_bug.cgi?id=149356

Reviewed by Tim Horton.

Source/WebKit2:

Expose a few private functions for testing.

* UIProcess/API/Cocoa/WKWebView.mm:
* UIProcess/API/Cocoa/WKWebViewPrivate.h:

Tools:

This change adds testRunner.runUIScript(script, callback), which allows a test
to execute script in a JSContext which runs in the UI process. That context
has bindings exposed through the UIScriptController interface; currently one test
function, and some iOS-specific functions are included. UIScriptController can be
async with a callback, and runUIScript() itself is asynchronous. When the UI
script is complete, it calls uiController.uiScriptComplete(result), where 'result'
is a string passed back to the web process, and given to the runUIScript()
callback function.

Thanks to Gyuyoung Kim for help with the Gtk/Efl build.

* WebKitTestRunner/DerivedSources.make: Build UIScriptController.idl.
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: Add runUIScript().
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessageToPage): When the UI-side script is
complete, call back into TestRunner.
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::nextUIScriptCallbackID):
(WTR::TestRunner::runUIScript): Post a message to the injected bundle to run the UI script.
(WTR::TestRunner::runUIScriptCallback): When the UI script is done, execute its callback function.
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/PlatformWebView.h:
* WebKitTestRunner/TestController.cpp:
(WTR::updateTestOptionsFromTestHeader):
(WTR::TestController::testOptionsForTest): Support "useFlexibleViewport" as a test argument.
(WTR::shouldUseFixedLayout): Deleted. Moved to a TestInvocation function.
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::shouldUseFixedLayout):
(WTR::TestInvocation::shouldUseThreadedScrolling):
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
(WTR::TestInvocation::runUISideScript): Run the UI-side script!
(WTR::TestInvocation::uiScriptDidComplete): Send a message back to the injected bundle.
* WebKitTestRunner/TestInvocation.h:
* WebKitTestRunner/TestOptions.h:
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
* WebKitTestRunner/cocoa/TestRunnerWKWebView.h: Copied from Tools/WebKitTestRunner/TestOptions.h.
* WebKitTestRunner/cocoa/TestRunnerWKWebView.mm: Added.
(-[TestRunnerWKWebView dragImage:at:offset:event:pasteboard:source:slideBack:]):
(-[TestRunnerWKWebView zoomToScale:animated:completionHandler:]):
(-[TestRunnerWKWebView scrollViewDidEndZooming:withView:atScale:]):
(-[TestRunnerWKWebView onDidEndZooming:]): Allow a test to hook into the end of zooming.
* WebKitTestRunner/ios/PlatformWebViewIOS.mm:
(WTR::PlatformWebView::PlatformWebView): Make a TestRunnerWKWebView on iOS.
* WebKitTestRunner/ios/UIScriptControllerIOS.mm: Added.
(WTR::UIScriptController::doAsyncTask):
(WTR::UIScriptController::zoomToScale):
(WTR::UIScriptController::zoomScale):
(WTR::UIScriptController::minimumZoomScale):
(WTR::UIScriptController::maximumZoomScale):
(WTR::UIScriptController::contentVisibleRect):
* WebKitTestRunner/mac/EventSenderProxy.mm:
* WebKitTestRunner/mac/PlatformWebViewMac.mm:
(-[TestRunnerWKWebView dragImage:at:offset:event:pasteboard:source:slideBack:]): Deleted.
* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::TestController::updatePlatformSpecificTestOptionsForTest):
(WTR::shouldUseThreadedScrolling): Deleted. Moved to TestInvocation.
* WebKitTestRunner/mac/WebKitTestRunnerDraggingInfo.h:
* WebKitTestRunner/uiscriptcontext/UIScriptContext.cpp: Added. Owns the JS context in the UI process.
(UIScriptContext::UIScriptContext):
(UIScriptContext::~UIScriptContext):
(UIScriptContext::runUIScript): Entrypoint to running the UI script. If the script didn't do anything
asynchronous, call the callback.
(UIScriptContext::nextTaskCallbackID):
(UIScriptContext::prepareForAsyncTask): Do setup for one async task (i.e. a UIScriptController function
that has a callback). Has to store the callbackID of the script, so code called from the completion
callback knows which UI script invoked it.
(UIScriptContext::asyncTaskComplete): Called when one task is finished.
(UIScriptContext::uiScriptComplete):
(UIScriptContext::objectFromRect): Make a JS object from a rect.
* WebKitTestRunner/uiscriptcontext/UIScriptContext.h: Copied from Tools/WebKitTestRunner/TestOptions.h.
(WTR::UIScriptContext::hasOutstandingAsyncTasks):
* WebKitTestRunner/uiscriptcontext/UIScriptController.cpp: Copied from Tools/WebKitTestRunner/TestOptions.h.
(WTR::UIScriptController::UIScriptController):
(WTR::UIScriptController::makeWindowObject):
(WTR::UIScriptController::wrapperClass):
(WTR::UIScriptController::doAsyncTask):
(WTR::UIScriptController::zoomToScale):
(WTR::UIScriptController::zoomScale):
(WTR::UIScriptController::minimumZoomScale):
(WTR::UIScriptController::maximumZoomScale):
(WTR::UIScriptController::contentVisibleRect):
(WTR::UIScriptController::uiScriptComplete):
* WebKitTestRunner/uiscriptcontext/UIScriptController.h: Copied from Tools/WebKitTestRunner/TestOptions.h.
(WTR::UIScriptController::create):
* WebKitTestRunner/uiscriptcontext/bindings/UIScriptController.idl: Copied from Tools/WebKitTestRunner/TestOptions.h.

LayoutTests:

Some new tests that exercise testRunner.runUIScript().

* TestExpectations:
* fast/harness/concurrent-ui-side-scripts-expected.txt: Added.
* fast/harness/concurrent-ui-side-scripts.html: Added.
* fast/harness/ui-side-scripts-expected.txt: Added.
* fast/harness/ui-side-scripts.html: Added.
* fast/zooming/zoom-to-scale.html: Added.
* platform/ios-simulator/TestExpectations:
* platform/mac/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190065 268f45cc-cd09-0410-ab3c-d52691b4dbfc
41 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/harness/concurrent-ui-side-scripts-expected.txt [new file with mode: 0644]
LayoutTests/fast/harness/concurrent-ui-side-scripts.html [new file with mode: 0644]
LayoutTests/fast/harness/ui-side-scripts-expected.txt [new file with mode: 0644]
LayoutTests/fast/harness/ui-side-scripts.html [new file with mode: 0644]
LayoutTests/fast/zooming/ios/zoom-to-scale-expected.txt [new file with mode: 0644]
LayoutTests/fast/zooming/ios/zoom-to-scale.html [new file with mode: 0644]
LayoutTests/platform/ios-simulator-wk2/TestExpectations
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Tools/ChangeLog
Tools/WebKitTestRunner/CMakeLists.txt
Tools/WebKitTestRunner/DerivedSources.make
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/PlatformWebView.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestInvocation.cpp
Tools/WebKitTestRunner/TestInvocation.h
Tools/WebKitTestRunner/TestOptions.h
Tools/WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl [new file with mode: 0644]
Tools/WebKitTestRunner/UIScriptContext/UIScriptContext.cpp [new file with mode: 0644]
Tools/WebKitTestRunner/UIScriptContext/UIScriptContext.h [new file with mode: 0644]
Tools/WebKitTestRunner/UIScriptContext/UIScriptController.cpp [new file with mode: 0644]
Tools/WebKitTestRunner/UIScriptContext/UIScriptController.h [new file with mode: 0644]
Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h [new file with mode: 0644]
Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm [new file with mode: 0644]
Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm [new file with mode: 0644]
Tools/WebKitTestRunner/mac/EventSenderProxy.mm
Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm
Tools/WebKitTestRunner/mac/TestControllerMac.mm
Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm [new file with mode: 0644]
Tools/WebKitTestRunner/mac/WebKitTestRunnerDraggingInfo.h