Changeset 190065 in webkit


Ignore:
Timestamp:
Sep 21, 2015 12:10:48 PM (9 years ago)
Author:
Simon Fraser
Message:

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:
Location:
trunk
Files:
13 added
26 edited
6 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r190060 r190065  
     12015-09-21  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Add the ability for tests to run script in the UI process in WebKitTestRunner
     4        https://bugs.webkit.org/show_bug.cgi?id=149356
     5
     6        Reviewed by Tim Horton.
     7
     8        Some new tests that exercise testRunner.runUIScript().
     9
     10        * TestExpectations:
     11        * fast/harness/concurrent-ui-side-scripts-expected.txt: Added.
     12        * fast/harness/concurrent-ui-side-scripts.html: Added.
     13        * fast/harness/ui-side-scripts-expected.txt: Added.
     14        * fast/harness/ui-side-scripts.html: Added.
     15        * fast/zooming/zoom-to-scale.html: Added.
     16        * platform/ios-simulator/TestExpectations:
     17        * platform/mac/TestExpectations:
     18
    1192015-09-21  Tim Horton  <timothy_horton@apple.com>
    220
  • trunk/LayoutTests/TestExpectations

    r190041 r190065  
    1515tiled-drawing [ Skip ]
    1616swipe [ Skip ]
     17fast/zooming/ios [ Skip ]
    1718
    1819fast/forms/attributed-strings.html [ Skip ]
     
    3940# This test is WebKit2-only
    4041http/tests/appcache/decide-navigation-policy-after-delay.html [ Skip ]
     42
     43# Only Mac and iOS have an implementation of UIScriptController::doAsyncTask().
     44fast/harness/ui-side-scripts.html [ Skip ]
     45fast/harness/concurrent-ui-side-scripts.html [ Skip ]
    4146
    4247#//////////////////////////////////////////////////////////////////////////////////////////
  • trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations

    r189864 r190065  
    22#
    33# See http://trac.webkit.org/wiki/TestExpectations for more information on this file.
     4
     5#//////////////////////////////////////////////////////////////////////////////////////////
     6# Platform-specific directories. Skipped globally, then re-enabled here.
     7#//////////////////////////////////////////////////////////////////////////////////////////
     8
     9fast/harness/ui-side-scripts.html [ Pass ]
     10fast/harness/concurrent-ui-side-scripts.html [ Pass ]
     11fast/zooming/ios [ Pass ]
     12
     13#//////////////////////////////////////////////////////////////////////////////////////////
     14# End platform-specific directories.
     15#//////////////////////////////////////////////////////////////////////////////////////////
    416
    517# Animation tests that fail:
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r190010 r190065  
    1313fast/events/force-click-on-link-navigation.html [ Pass ]
    1414fast/events/force-click-text-selection-behavior.html [ Failure ]
     15
     16fast/harness/ui-side-scripts.html [ Pass ]
     17fast/harness/concurrent-ui-side-scripts.html [ Pass ]
    1518
    1619#//////////////////////////////////////////////////////////////////////////////////////////
  • trunk/Source/WebKit2/ChangeLog

    r190064 r190065  
     12015-09-21  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Add the ability for tests to run script in the UI process in WebKitTestRunner
     4        https://bugs.webkit.org/show_bug.cgi?id=149356
     5
     6        Reviewed by Tim Horton.
     7
     8        Expose a few private functions for testing.
     9
     10        * UIProcess/API/Cocoa/WKWebView.mm:
     11        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
     12
    1132015-09-21  Tim Horton  <timothy_horton@apple.com>
    214
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r189986 r190065  
    15971597}
    15981598
    1599 // Unobscured content rect where the user can interact. When the keyboard is up, this should be the area above or bellow the keyboard, wherever there is enough space.
     1599// Unobscured content rect where the user can interact. When the keyboard is up, this should be the area above or below the keyboard, wherever there is enough space.
    16001600- (CGRect)_contentRectForUserInteraction
    16011601{
     
    30213021}
    30223022
     3023- (CGRect)_contentVisibleRect
     3024{
     3025    return [self convertRect:[self bounds] toView:self._currentContentView];
     3026}
     3027
     3028- (CGPoint)_convertPointFromContentsToView:(CGPoint)point
     3029{
     3030    return [self convertPoint:point fromView:self._currentContentView];
     3031}
     3032
     3033- (CGPoint)_convertPointFromViewToContents:(CGPoint)point
     3034{
     3035    return [self convertPoint:point toView:self._currentContentView];
     3036}
     3037
    30233038- (_WKWebViewPrintFormatter *)_webViewPrintFormatter
    30243039{
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r189551 r190065  
    126126@property (nonatomic, readonly) CGFloat _viewportMetaTagWidth;
    127127
     128@property (nonatomic, readonly) CGRect _contentVisibleRect;
     129
    128130@property (nonatomic, readonly) _WKWebViewPrintFormatter *_webViewPrintFormatter;
     131
     132- (CGPoint)_convertPointFromContentsToView:(CGPoint)point;
     133- (CGPoint)_convertPointFromViewToContents:(CGPoint)point;
    129134
    130135- (void)_beginInteractiveObscuredInsetsChange;
  • trunk/Tools/ChangeLog

    r190060 r190065  
     12015-09-21  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Add the ability for tests to run script in the UI process in WebKitTestRunner
     4        https://bugs.webkit.org/show_bug.cgi?id=149356
     5
     6        Reviewed by Tim Horton.
     7
     8        This change adds testRunner.runUIScript(script, callback), which allows a test
     9        to execute script in a JSContext which runs in the UI process. That context
     10        has bindings exposed through the UIScriptController interface; currently one test
     11        function, and some iOS-specific functions are included. UIScriptController can be
     12        async with a callback, and runUIScript() itself is asynchronous. When the UI
     13        script is complete, it calls uiController.uiScriptComplete(result), where 'result'
     14        is a string passed back to the web process, and given to the runUIScript()
     15        callback function.
     16       
     17        Thanks to Gyuyoung Kim for help with the Gtk/Efl build.
     18
     19        * WebKitTestRunner/DerivedSources.make: Build UIScriptController.idl.
     20        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: Add runUIScript().
     21        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
     22        (WTR::InjectedBundle::didReceiveMessageToPage): When the UI-side script is
     23        complete, call back into TestRunner.
     24        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     25        (WTR::nextUIScriptCallbackID):
     26        (WTR::TestRunner::runUIScript): Post a message to the injected bundle to run the UI script.
     27        (WTR::TestRunner::runUIScriptCallback): When the UI script is done, execute its callback function.
     28        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     29        * WebKitTestRunner/PlatformWebView.h:
     30        * WebKitTestRunner/TestController.cpp:
     31        (WTR::updateTestOptionsFromTestHeader):
     32        (WTR::TestController::testOptionsForTest): Support "useFlexibleViewport" as a test argument.
     33        (WTR::shouldUseFixedLayout): Deleted. Moved to a TestInvocation function.
     34        * WebKitTestRunner/TestInvocation.cpp:
     35        (WTR::TestInvocation::shouldUseFixedLayout):
     36        (WTR::TestInvocation::shouldUseThreadedScrolling):
     37        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
     38        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     39        (WTR::TestInvocation::runUISideScript): Run the UI-side script!
     40        (WTR::TestInvocation::uiScriptDidComplete): Send a message back to the injected bundle.
     41        * WebKitTestRunner/TestInvocation.h:
     42        * WebKitTestRunner/TestOptions.h:
     43        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
     44        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
     45        * WebKitTestRunner/cocoa/TestRunnerWKWebView.h: Copied from Tools/WebKitTestRunner/TestOptions.h.
     46        * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm: Added.
     47        (-[TestRunnerWKWebView dragImage:at:offset:event:pasteboard:source:slideBack:]):
     48        (-[TestRunnerWKWebView zoomToScale:animated:completionHandler:]):
     49        (-[TestRunnerWKWebView scrollViewDidEndZooming:withView:atScale:]):
     50        (-[TestRunnerWKWebView onDidEndZooming:]): Allow a test to hook into the end of zooming.
     51        * WebKitTestRunner/ios/PlatformWebViewIOS.mm:
     52        (WTR::PlatformWebView::PlatformWebView): Make a TestRunnerWKWebView on iOS.
     53        * WebKitTestRunner/ios/UIScriptControllerIOS.mm: Added.
     54        (WTR::UIScriptController::doAsyncTask):
     55        (WTR::UIScriptController::zoomToScale):
     56        (WTR::UIScriptController::zoomScale):
     57        (WTR::UIScriptController::minimumZoomScale):
     58        (WTR::UIScriptController::maximumZoomScale):
     59        (WTR::UIScriptController::contentVisibleRect):
     60        * WebKitTestRunner/mac/EventSenderProxy.mm:
     61        * WebKitTestRunner/mac/PlatformWebViewMac.mm:
     62        (-[TestRunnerWKWebView dragImage:at:offset:event:pasteboard:source:slideBack:]): Deleted.
     63        * WebKitTestRunner/mac/TestControllerMac.mm:
     64        (WTR::TestController::updatePlatformSpecificTestOptionsForTest):
     65        (WTR::shouldUseThreadedScrolling): Deleted. Moved to TestInvocation.
     66        * WebKitTestRunner/mac/WebKitTestRunnerDraggingInfo.h:
     67        * WebKitTestRunner/uiscriptcontext/UIScriptContext.cpp: Added. Owns the JS context in the UI process.
     68        (UIScriptContext::UIScriptContext):
     69        (UIScriptContext::~UIScriptContext):
     70        (UIScriptContext::runUIScript): Entrypoint to running the UI script. If the script didn't do anything
     71        asynchronous, call the callback.
     72        (UIScriptContext::nextTaskCallbackID):
     73        (UIScriptContext::prepareForAsyncTask): Do setup for one async task (i.e. a UIScriptController function
     74        that has a callback). Has to store the callbackID of the script, so code called from the completion
     75        callback knows which UI script invoked it.
     76        (UIScriptContext::asyncTaskComplete): Called when one task is finished.
     77        (UIScriptContext::uiScriptComplete):
     78        (UIScriptContext::objectFromRect): Make a JS object from a rect.
     79        * WebKitTestRunner/uiscriptcontext/UIScriptContext.h: Copied from Tools/WebKitTestRunner/TestOptions.h.
     80        (WTR::UIScriptContext::hasOutstandingAsyncTasks):
     81        * WebKitTestRunner/uiscriptcontext/UIScriptController.cpp: Copied from Tools/WebKitTestRunner/TestOptions.h.
     82        (WTR::UIScriptController::UIScriptController):
     83        (WTR::UIScriptController::makeWindowObject):
     84        (WTR::UIScriptController::wrapperClass):
     85        (WTR::UIScriptController::doAsyncTask):
     86        (WTR::UIScriptController::zoomToScale):
     87        (WTR::UIScriptController::zoomScale):
     88        (WTR::UIScriptController::minimumZoomScale):
     89        (WTR::UIScriptController::maximumZoomScale):
     90        (WTR::UIScriptController::contentVisibleRect):
     91        (WTR::UIScriptController::uiScriptComplete):
     92        * WebKitTestRunner/uiscriptcontext/UIScriptController.h: Copied from Tools/WebKitTestRunner/TestOptions.h.
     93        (WTR::UIScriptController::create):
     94        * WebKitTestRunner/uiscriptcontext/bindings/UIScriptController.idl: Copied from Tools/WebKitTestRunner/TestOptions.h.
     95
    1962015-09-21  Tim Horton  <timothy_horton@apple.com>
    297
  • trunk/Tools/WebKitTestRunner/CMakeLists.txt

    r185806 r190065  
    11set(WEBKIT_TESTRUNNER_DIR "${TOOLS_DIR}/WebKitTestRunner")
    22set(WEBKIT_TESTRUNNER_INJECTEDBUNDLE_DIR "${TOOLS_DIR}/WebKitTestRunner/InjectedBundle")
     3set(WEBKIT_TESTRUNNER_UISCRIPTCONTEXT_DIR "${TOOLS_DIR}/WebKitTestRunner/UIScriptContext")
    34
    45file(MAKE_DIRECTORY ${DERIVED_SOURCES_DIR}/InjectedBundle)
     6file(MAKE_DIRECTORY ${DERIVED_SOURCES_DIR}/UIScriptContext)
    57
    68set(WebKitTestRunner_SOURCES
     
    1315    ${WEBKIT_TESTRUNNER_DIR}/WebNotificationProvider.cpp
    1416    ${WEBKIT_TESTRUNNER_DIR}/WorkQueueManager.cpp
     17    ${WEBKIT_TESTRUNNER_UISCRIPTCONTEXT_DIR}/UIScriptContext.cpp
     18    ${WEBKIT_TESTRUNNER_UISCRIPTCONTEXT_DIR}/UIScriptController.cpp
     19
     20    ${WEBKIT_TESTRUNNER_INJECTEDBUNDLE_DIR}/Bindings/JSWrapper.cpp
    1521)
    1622
     
    2733    ${WEBKIT_TESTRUNNER_DIR}/InjectedBundle/Bindings
    2834    ${WEBKIT_TESTRUNNER_DIR}/InjectedBundle/atk
     35    ${WEBKIT_TESTRUNNER_UISCRIPTCONTEXT_DIR}
     36    ${WEBKIT_TESTRUNNER_UISCRIPTCONTEXT_DIR}/Bindings
    2937    ${JAVASCRIPTCORE_DIR}
    3038    ${JAVASCRIPTCORE_DIR}/ForwardingHeaders
     
    4856    ${WTF_DIR}
    4957    ${DERIVED_SOURCES_DIR}/InjectedBundle
     58    ${DERIVED_SOURCES_DIR}/UIScriptContext
    5059    ${CMAKE_BINARY_DIR}
    5160    ${CMAKE_SOURCE_DIR}/Source
     
    8392)
    8493
    85 set(WebKitTestRunnerInjectedBundle_LIBRARIES
    86     ${WebKitTestRunner_LIBRARIES}
     94set(WebKitTestRunner_IDL_FILES
     95    "${WEBKIT_TESTRUNNER_DIR}/UIScriptContext/Bindings/UIScriptController.idl"
    8796)
    8897
     
    95104    ${WEBCORE_DIR}/bindings/scripts/IDLAttributes.txt)
    96105
     106GENERATE_BINDINGS(WebKitTestRunner_SOURCES
     107    "${WebKitTestRunner_IDL_FILES}"
     108    "${WEBKIT_TESTRUNNER_INJECTEDBUNDLE_DIR}/Bindings"
     109    "--include=${WEBKIT_TESTRUNNER_INJECTEDBUNDLE_DIR}/Bindings"
     110    "${FEATURE_DEFINES_WITH_SPACE_SEPARATOR}"
     111    ${DERIVED_SOURCES_DIR}/UIScriptContext JS TestRunner cpp
     112    ${WEBCORE_DIR}/bindings/scripts/IDLAttributes.txt)
     113
    97114WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
    98115
     
    101118
    102119add_library(TestRunnerInjectedBundle SHARED ${WebKitTestRunnerInjectedBundle_SOURCES})
    103 target_link_libraries(TestRunnerInjectedBundle ${WebKitTestRunnerInjectedBundle_LIBRARIES})
     120target_link_libraries(TestRunnerInjectedBundle ${WebKitTestRunner_LIBRARIES})
    104121
    105122add_executable(WebKitTestRunner ${WebKitTestRunner_SOURCES})
  • trunk/Tools/WebKitTestRunner/DerivedSources.make

    r135129 r190065  
    2424VPATH = \
    2525    $(WebKitTestRunner)/InjectedBundle/Bindings \
     26    $(WebKitTestRunner)/UIScriptContext/Bindings \
    2627#
    2728
    28 INTERFACES = \
     29INJECTED_BUNDLE_INTERFACES = \
    2930    AccessibilityController \
    3031    AccessibilityTextMarker \
     
    3536    TestRunner \
    3637    TextInputController \
     38#
     39
     40UICONTEXT_INTERFACES = \
     41    UIScriptController \
    3742#
    3843
     
    4853JS%.h JS%.cpp : %.idl $(SCRIPTS)
    4954        @echo Generating bindings for $*...
    50         @perl -I $(WebCoreScripts) -I $(WebKitTestRunner)/InjectedBundle/Bindings $(WebCoreScripts)/generate-bindings.pl --defines "" --include InjectedBundle/Bindings --outputDir . --generator TestRunner $<
     55        @perl -I $(WebCoreScripts) -I $(WebKitTestRunner)/InjectedBundle/Bindings -I $(WebKitTestRunner)/UIScriptContext/Bindings $(WebCoreScripts)/generate-bindings.pl --defines "" --include InjectedBundle/Bindings --include UIScriptContext/Bindings --outputDir . --generator TestRunner $<
    5156
    5257all : \
    53     $(INTERFACES:%=JS%.h) \
    54     $(INTERFACES:%=JS%.cpp) \
     58    $(INJECTED_BUNDLE_INTERFACES:%=JS%.h) \
     59    $(INJECTED_BUNDLE_INTERFACES:%=JS%.cpp) \
     60    $(UICONTEXT_INTERFACES:%=JS%.h) \
     61    $(UICONTEXT_INTERFACES:%=JS%.cpp) \
    5562#
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r189321 r190065  
    214214    void installDidEndSwipeCallback(object callback);
    215215    void installDidRemoveSwipeSnapshotCallback(object callback);
     216
     217    // UI Process Testing
     218    void runUIScript(DOMString script, object callback);
    216219};
    217220
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

    r190035 r190065  
    236236    }
    237237
     238    if (WKStringIsEqualToUTF8CString(messageName, "CallUISideScriptCallback")) {
     239        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
     240
     241        WKRetainPtr<WKStringRef> resultKey(AdoptWK, WKStringCreateWithUTF8CString("Result"));
     242        WKRetainPtr<WKStringRef> callbackIDKey(AdoptWK, WKStringCreateWithUTF8CString("CallbackID"));
     243
     244        unsigned callbackID = (unsigned)WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, callbackIDKey.get())));
     245
     246        WKStringRef resultString = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, resultKey.get()));
     247        auto resultJSString = toJS(resultString);
     248
     249        m_testRunner->runUIScriptCallback(callbackID, resultJSString.get());
     250        return;
     251    }
     252
    238253    if (WKStringIsEqualToUTF8CString(messageName, "WorkQueueProcessedCallback")) {
    239254        if (!topLoadingFrame() && !m_testRunner->waitToDump())
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r189321 r190065  
    514514    WillEndSwipeCallbackID,
    515515    DidEndSwipeCallbackID,
    516     DidRemoveSwipeSnapshotCallbackID
     516    DidRemoveSwipeSnapshotCallbackID,
     517    FirstUIScriptCallbackID = 100
    517518};
    518519
     
    533534}
    534535
    535 static void callTestRunnerCallback(unsigned index)
     536static void callTestRunnerCallback(unsigned index, size_t argumentCount = 0, const JSValueRef arguments[] = nullptr)
    536537{
    537538    if (!callbackMap().contains(index))
     
    540541    JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
    541542    JSObjectRef callback = JSValueToObject(context, callbackMap().take(index), 0);
    542     JSObjectCallAsFunction(context, callback, JSContextGetGlobalObject(context), 0, 0, 0);
     543    JSObjectCallAsFunction(context, callback, JSContextGetGlobalObject(context), argumentCount, arguments, 0);
    543544    JSValueUnprotect(context, callback);
    544545}
     
    889890}
    890891
     892static unsigned nextUIScriptCallbackID()
     893{
     894    static unsigned callbackID = FirstUIScriptCallbackID;
     895    return callbackID++;
     896}
     897
     898void TestRunner::runUIScript(JSStringRef script, JSValueRef callback)
     899{
     900    unsigned callbackID = nextUIScriptCallbackID();
     901    cacheTestRunnerCallback(callbackID, callback);
     902
     903    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("RunUIProcessScript"));
     904
     905    WKRetainPtr<WKMutableDictionaryRef> testDictionary(AdoptWK, WKMutableDictionaryCreate());
     906
     907    WKRetainPtr<WKStringRef> scriptKey(AdoptWK, WKStringCreateWithUTF8CString("Script"));
     908    WKRetainPtr<WKStringRef> scriptValue(AdoptWK, WKStringCreateWithJSString(script));
     909
     910    WKRetainPtr<WKStringRef> callbackIDKey(AdoptWK, WKStringCreateWithUTF8CString("CallbackID"));
     911    WKRetainPtr<WKUInt64Ref> callbackIDValue = adoptWK(WKUInt64Create(callbackID));
     912
     913    WKDictionarySetItem(testDictionary.get(), scriptKey.get(), scriptValue.get());
     914    WKDictionarySetItem(testDictionary.get(), callbackIDKey.get(), callbackIDValue.get());
     915
     916    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), testDictionary.get());
     917}
     918
     919void TestRunner::runUIScriptCallback(unsigned callbackID, JSStringRef result)
     920{
     921    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::singleton().page()->page());
     922    JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
     923
     924    JSValueRef resultValue = JSValueMakeString(context, result);
     925    callTestRunnerCallback(callbackID, 1, &resultValue);
     926}
     927
    891928void TestRunner::installDidBeginSwipeCallback(JSValueRef callback)
    892929{
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r189321 r190065  
    288288    void setNavigationGesturesEnabled(bool);
    289289
     290    void runUIScript(JSStringRef script, JSValueRef callback);
     291    void runUIScriptCallback(unsigned callbackID, JSStringRef result);
     292
    290293    void installDidBeginSwipeCallback(JSValueRef);
    291294    void installWillEndSwipeCallback(JSValueRef);
  • trunk/Tools/WebKitTestRunner/PlatformWebView.h

    r189959 r190065  
    3434OBJC_CLASS NSView;
    3535OBJC_CLASS UIView;
    36 OBJC_CLASS WKWebView;
     36OBJC_CLASS TestRunnerWKWebView;
    3737OBJC_CLASS WKWebViewConfiguration;
    3838OBJC_CLASS WebKitTestRunnerWindow;
    3939
    4040#if WK_API_ENABLED
    41 typedef WKWebView *PlatformWKView;
     41typedef TestRunnerWKWebView *PlatformWKView;
    4242#else
    4343typedef NSView *PlatformWKView;
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r189981 r190065  
    808808}
    809809
    810 static bool shouldUseFixedLayout(const TestInvocation& test)
    811 {
    812 #if ENABLE(CSS_DEVICE_ADAPTATION)
    813     if (test.urlContains("device-adapt/") || test.urlContains("device-adapt\\"))
    814         return true;
    815 #endif
    816 
    817     return false;
    818 }
    819 
    820810static std::string testPath(const WKURLRef url)
    821811{
     
    879869        if (key == "useThreadedScrolling")
    880870            testOptions.useThreadedScrolling = parseBooleanTestHeaderValue(value);
     871        if (key == "useFlexibleViewport")
     872            testOptions.useFlexibleViewport = parseBooleanTestHeaderValue(value);
    881873        pairStart = pairEnd + 1;
    882874    }
     
    889881    options.useRemoteLayerTree = m_shouldUseRemoteLayerTree;
    890882    options.shouldShowWebView = m_shouldShowWebView;
    891     options.useFixedLayout = shouldUseFixedLayout(test);
     883    options.useFixedLayout = test.shouldUseFixedLayout();
     884    options.useFlexibleViewport = test.shouldMakeViewportFlexible();
    892885
    893886    updatePlatformSpecificTestOptionsForTest(options, test);
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r190009 r190065  
    3131#include "StringFunctions.h"
    3232#include "TestController.h"
     33#include "UIScriptController.h"
    3334#include <WebKit/WKContextPrivate.h>
    3435#include <WebKit/WKCookieManager.h>
     
    5354#include <unistd.h> // For getcwd.
    5455
     56using namespace JSC;
    5557using namespace WebKit;
    5658using namespace std;
     
    148150}
    149151
     152bool TestInvocation::shouldUseFixedLayout() const
     153{
     154#if ENABLE(CSS_DEVICE_ADAPTATION)
     155    if (urlContains("device-adapt/") || urlContains("device-adapt\\"))
     156        return true;
     157#endif
     158
     159    return false;
     160}
     161
    150162void TestInvocation::invoke()
    151163{
     
    652664    }
    653665
     666    if (WKStringIsEqualToUTF8CString(messageName, "RunUIProcessScript")) {
     667        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
     668        WKRetainPtr<WKStringRef> scriptKey(AdoptWK, WKStringCreateWithUTF8CString("Script"));
     669        WKRetainPtr<WKStringRef> callbackIDKey(AdoptWK, WKStringCreateWithUTF8CString("CallbackID"));
     670
     671        unsigned callbackID = (unsigned)WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, callbackIDKey.get())));
     672        WKStringRef scriptString = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, scriptKey.get()));
     673
     674        runUISideScript(scriptString, callbackID);
     675        return;
     676    }
     677
    654678    ASSERT_NOT_REACHED();
    655679}
     
    661685        WKBooleanRef isKeyValue = static_cast<WKBooleanRef>(messageBody);
    662686        TestController::singleton().mainWebView()->setWindowIsKey(WKBooleanGetValue(isKeyValue));
    663         return 0;
     687        return nullptr;
    664688    }
    665689
     
    690714        // FIXME: This updates the policy in WebProcess and in NetworkProcess asynchronously, which might break some tests' expectations.
    691715        WKCookieManagerSetHTTPCookieAcceptPolicy(WKContextGetCookieManager(TestController::singleton().context()), policy);
    692         return 0;
     716        return nullptr;
    693717    }
    694718
    695719    ASSERT_NOT_REACHED();
    696     return 0;
     720    return nullptr;
     721}
     722
     723void TestInvocation::runUISideScript(WKStringRef script, unsigned scriptCallbackID)
     724{
     725    if (!m_UIScriptContext)
     726        m_UIScriptContext = std::make_unique<UIScriptContext>(*this);
     727   
     728    m_UIScriptContext->runUIScript(script, scriptCallbackID);
     729}
     730
     731void TestInvocation::uiScriptDidComplete(WKStringRef result, unsigned scriptCallbackID)
     732{
     733    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallUISideScriptCallback"));
     734
     735    WKRetainPtr<WKMutableDictionaryRef> messageBody(AdoptWK, WKMutableDictionaryCreate());
     736    WKRetainPtr<WKStringRef> resultKey(AdoptWK, WKStringCreateWithUTF8CString("Result"));
     737    WKRetainPtr<WKStringRef> callbackIDKey(AdoptWK, WKStringCreateWithUTF8CString("CallbackID"));
     738    WKRetainPtr<WKUInt64Ref> callbackIDValue = adoptWK(WKUInt64Create(scriptCallbackID));
     739
     740    WKDictionarySetItem(messageBody.get(), resultKey.get(), result);
     741    WKDictionarySetItem(messageBody.get(), callbackIDKey.get(), callbackIDValue.get());
     742
     743    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), messageBody.get());
    697744}
    698745
  • trunk/Tools/WebKitTestRunner/TestInvocation.h

    r190009 r190065  
    2727#define TestInvocation_h
    2828
     29#include "JSWrappable.h"
     30#include "UIScriptContext.h"
     31#include <JavaScriptCore/JSRetainPtr.h>
    2932#include <WebKit/WKRetainPtr.h>
    3033#include <string>
     
    3437namespace WTR {
    3538
    36 class TestInvocation {
     39class TestInvocation : public UIScriptContextDelegate {
    3740    WTF_MAKE_NONCOPYABLE(TestInvocation);
    3841public:
     
    6265
    6366    bool shouldMakeViewportFlexible() const;
     67    bool shouldUseFixedLayout() const;
    6468
    6569private:
     
    7478    bool shouldLogFrameLoadDelegates() const;
    7579    bool shouldLogHistoryClientCallbacks() const;
     80
     81    void runUISideScript(WKStringRef, unsigned callbackID);
     82    // UIScriptContextDelegate
     83    void uiScriptDidComplete(WKStringRef result, unsigned callbackID) override;
    7684
    7785    WKRetainPtr<WKURLRef> m_url;
     
    95103    std::string m_errorMessage;
    96104    bool m_webProcessIsUnresponsive;
     105   
     106    std::unique_ptr<UIScriptContext> m_UIScriptContext;
    97107
    98108};
  • trunk/Tools/WebKitTestRunner/TestOptions.h

    r189669 r190065  
    3636    bool useRemoteLayerTree { false };
    3737    bool shouldShowWebView { false };
    38 
     38    bool useFlexibleViewport { false };
    3939    bool useFixedLayout { false };
    4040    Vector<String> overrideLanguages;
  • trunk/Tools/WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl

    r190064 r190065  
    2424 */
    2525
    26 #ifndef TestOptions_h
    27 #define TestOptions_h
     26interface UIScriptController {
    2827
    29 #include <wtf/Vector.h>
    30 #include <wtf/text/WTFString.h>
     28    void doAsyncTask(object callback); // Used to test the harness.
    3129
    32 namespace WTR {
     30    void zoomToScale(double scale, object callback);
    3331
    34 struct TestOptions {
    35     bool useThreadedScrolling { false };
    36     bool useRemoteLayerTree { false };
    37     bool shouldShowWebView { false };
     32    readonly attribute double zoomScale;
     33    readonly attribute double minimumZoomScale;
     34    readonly attribute double maximumZoomScale;
    3835
    39     bool useFixedLayout { false };
    40     Vector<String> overrideLanguages;
     36    readonly attribute object contentVisibleRect; // Returned object has 'left', 'top', 'width', 'height' properties.
     37
     38    void uiScriptComplete(DOMString result);
    4139};
    42 
    43 }
    44 
    45 #endif // TestOptions_h
  • trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptContext.h

    r190064 r190065  
    2424 */
    2525
    26 #ifndef TestOptions_h
    27 #define TestOptions_h
     26#ifndef UIScriptContext_h
     27#define UIScriptContext_h
    2828
    29 #include <wtf/Vector.h>
    30 #include <wtf/text/WTFString.h>
     29#include <JavaScriptCore/JSRetainPtr.h>
     30#include <wtf/HashMap.h>
     31#include <wtf/RefPtr.h>
    3132
    3233namespace WTR {
    3334
    34 struct TestOptions {
    35     bool useThreadedScrolling { false };
    36     bool useRemoteLayerTree { false };
    37     bool shouldShowWebView { false };
     35class UIScriptController;
    3836
    39     bool useFixedLayout { false };
    40     Vector<String> overrideLanguages;
     37class UIScriptContextDelegate {
     38public:
     39    virtual void uiScriptDidComplete(WKStringRef result, unsigned callbackID) = 0;
     40};
     41
     42class UIScriptContext {
     43public:
     44
     45    UIScriptContext(UIScriptContextDelegate&);
     46
     47    void runUIScript(WKStringRef script, unsigned scriptCallbackID);
     48    void uiScriptComplete(JSStringRef);
     49
     50    unsigned prepareForAsyncTask(JSValueRef taskCallback);
     51    void asyncTaskComplete(unsigned taskCallbackID);
     52
     53    unsigned nextTaskCallbackID();
     54
     55    JSObjectRef objectFromRect(const WKRect&) const;
     56
     57private:
     58    JSRetainPtr<JSGlobalContextRef> m_context;
     59   
     60    bool hasOutstandingAsyncTasks() const { return !m_callbacks.isEmpty(); }
     61   
     62    struct Task {
     63        unsigned parentScriptCallbackID { 0 };
     64        JSValueRef callback { nullptr };
     65    };
     66    HashMap<unsigned, Task> m_callbacks;
     67
     68    UIScriptContextDelegate& m_delegate;
     69    RefPtr<UIScriptController> m_controller;
     70   
     71    unsigned m_currentScriptCallbackID { 0 };
     72    unsigned m_nextTaskCallbackID { 0 };
    4173};
    4274
    4375}
    4476
    45 #endif // TestOptions_h
     77#endif // UIScriptContext_h
  • trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.cpp

    r190064 r190065  
    2424 */
    2525
    26 #ifndef TestOptions_h
    27 #define TestOptions_h
     26#include "config.h"
     27#include "UIScriptController.h"
    2828
    29 #include <wtf/Vector.h>
    30 #include <wtf/text/WTFString.h>
     29#include "JSUIScriptController.h"
     30#include "UIScriptContext.h"
     31// #include <JavaScriptCore/JavaScriptCore.h>
    3132
    3233namespace WTR {
    3334
    34 struct TestOptions {
    35     bool useThreadedScrolling { false };
    36     bool useRemoteLayerTree { false };
    37     bool shouldShowWebView { false };
     35UIScriptController::UIScriptController(UIScriptContext& context)
     36    : m_context(context)
     37{
     38}
    3839
    39     bool useFixedLayout { false };
    40     Vector<String> overrideLanguages;
    41 };
     40void UIScriptController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
     41{
     42    setProperty(context, windowObject, "uiController", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
     43}
     44
     45JSClassRef UIScriptController::wrapperClass()
     46{
     47    return JSUIScriptController::uIScriptControllerClass();
     48}
     49
     50#if !PLATFORM(COCOA)
     51void UIScriptController::doAsyncTask(JSValueRef)
     52{
     53}
     54#endif
     55
     56#if !PLATFORM(IOS)
     57void UIScriptController::zoomToScale(double, JSValueRef)
     58{
     59}
     60
     61double UIScriptController::zoomScale() const
     62{
     63    return 1;
     64}
     65
     66double UIScriptController::minimumZoomScale() const
     67{
     68    return 1;
     69}
     70
     71double UIScriptController::maximumZoomScale() const
     72{
     73    return 1;
     74}
     75
     76JSObjectRef UIScriptController::contentVisibleRect() const
     77{
     78    return nullptr;
     79}
     80#endif
     81
     82void UIScriptController::uiScriptComplete(JSStringRef result)
     83{
     84    m_context.uiScriptComplete(result);
     85}
    4286
    4387}
    44 
    45 #endif // TestOptions_h
  • trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.h

    r190064 r190065  
    2424 */
    2525
    26 #ifndef TestOptions_h
    27 #define TestOptions_h
     26#ifndef UIScriptController_h
     27#define UIScriptController_h
    2828
    29 #include <wtf/Vector.h>
    30 #include <wtf/text/WTFString.h>
     29#include "JSWrappable.h"
     30#include <wtf/Ref.h>
    3131
    3232namespace WTR {
    3333
    34 struct TestOptions {
    35     bool useThreadedScrolling { false };
    36     bool useRemoteLayerTree { false };
    37     bool shouldShowWebView { false };
     34class UIScriptContext;
    3835
    39     bool useFixedLayout { false };
    40     Vector<String> overrideLanguages;
     36class UIScriptController : public JSWrappable {
     37public:
     38    static Ref<UIScriptController> create(UIScriptContext& context)
     39    {
     40        return adoptRef(*new UIScriptController(context));
     41    }
     42   
     43    void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception);
     44   
     45    void doAsyncTask(JSValueRef callback);
     46    void zoomToScale(double scale, JSValueRef callback);
     47
     48    double zoomScale() const;
     49    double minimumZoomScale() const;
     50    double maximumZoomScale() const;
     51
     52    JSObjectRef contentVisibleRect() const;
     53
     54    void uiScriptComplete(JSStringRef result);
     55
     56private:
     57    UIScriptController(UIScriptContext&);
     58
     59    virtual JSClassRef wrapperClass() override;
     60
     61    JSObjectRef objectFromRect(const WKRect&) const;
     62
     63    UIScriptContext& m_context;
    4164};
    4265
    4366}
    4467
    45 #endif // TestOptions_h
     68#endif // UIScriptController_h
  • trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj

    r189948 r190065  
    3535/* Begin PBXBuildFile section */
    3636                0F5169CC1445222D00E0A9D7 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F5169CA1445222D00E0A9D7 /* WebKit.framework */; };
    37                 0F831AEA1BAB84F400F96CD8 /* Launch.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0F831AE91BAB84F400F96CD8 /* Launch.storyboard */; settings = {ASSET_TAGS = (); }; };
     37                0F73B5511BA78968004B3EF4 /* JSUIScriptController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F73B54F1BA78968004B3EF4 /* JSUIScriptController.cpp */; };
     38                0F73B5521BA78968004B3EF4 /* JSUIScriptController.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F73B5501BA78968004B3EF4 /* JSUIScriptController.h */; };
     39                0F73B55A1BA792FF004B3EF4 /* JSWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC952C0C11F3B965003398B4 /* JSWrapper.cpp */; };
     40                0F73B55C1BA89042004B3EF4 /* UIScriptControllerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F73B55B1BA89042004B3EF4 /* UIScriptControllerIOS.mm */; };
     41                0F87B6131BACAD82004EC572 /* UIScriptControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F87B6111BACAD6F004EC572 /* UIScriptControllerMac.mm */; settings = {ASSET_TAGS = (); }; };
     42                0F87B6171BACC4C0004EC572 /* TestRunnerWKWebView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F87B6151BACC4B9004EC572 /* TestRunnerWKWebView.mm */; settings = {ASSET_TAGS = (); }; };
     43                0F87B6191BACC558004EC572 /* Launch.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0F87B6181BACC558004EC572 /* Launch.storyboard */; settings = {ASSET_TAGS = (); }; };
     44                0F87B61E1BACDA93004EC572 /* UIScriptContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F87B61A1BACDA93004EC572 /* UIScriptContext.cpp */; settings = {ASSET_TAGS = (); }; };
     45                0F87B6201BACDA93004EC572 /* UIScriptController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F87B61C1BACDA93004EC572 /* UIScriptController.cpp */; settings = {ASSET_TAGS = (); }; };
    3846                0FEB90A01905A834000FDBF3 /* InjectedBundlePageCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FEB909E1905A776000FDBF3 /* InjectedBundlePageCocoa.mm */; };
    3947                0FEB90A51905C016000FDBF3 /* CrashReporterInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FEB90A31905BC6A000FDBF3 /* CrashReporterInfo.mm */; };
     
    163171                0F2109C7189C650D00F879A3 /* BaseTarget.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = BaseTarget.xcconfig; sourceTree = "<group>"; };
    164172                0F5169CA1445222D00E0A9D7 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
    165                 0F831AE91BAB84F400F96CD8 /* Launch.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Launch.storyboard; sourceTree = "<group>"; };
     173                0F73B54F1BA78968004B3EF4 /* JSUIScriptController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSUIScriptController.cpp; path = DerivedSources/WebKitTestRunner/JSUIScriptController.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
     174                0F73B5501BA78968004B3EF4 /* JSUIScriptController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSUIScriptController.h; path = DerivedSources/WebKitTestRunner/JSUIScriptController.h; sourceTree = BUILT_PRODUCTS_DIR; };
     175                0F73B5571BA7929E004B3EF4 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
     176                0F73B55B1BA89042004B3EF4 /* UIScriptControllerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIScriptControllerIOS.mm; sourceTree = "<group>"; };
     177                0F831AE71BAB72D000F96CD8 /* Launch.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Launch.storyboard; sourceTree = "<group>"; };
     178                0F87B6111BACAD6F004EC572 /* UIScriptControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIScriptControllerMac.mm; sourceTree = "<group>"; };
     179                0F87B6141BACC4B9004EC572 /* TestRunnerWKWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestRunnerWKWebView.h; path = cocoa/TestRunnerWKWebView.h; sourceTree = "<group>"; };
     180                0F87B6151BACC4B9004EC572 /* TestRunnerWKWebView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestRunnerWKWebView.mm; path = cocoa/TestRunnerWKWebView.mm; sourceTree = "<group>"; };
     181                0F87B6181BACC558004EC572 /* Launch.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Launch.storyboard; sourceTree = "<group>"; };
     182                0F87B61A1BACDA93004EC572 /* UIScriptContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UIScriptContext.cpp; path = UIScriptContext/UIScriptContext.cpp; sourceTree = "<group>"; };
     183                0F87B61B1BACDA93004EC572 /* UIScriptContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UIScriptContext.h; path = UIScriptContext/UIScriptContext.h; sourceTree = "<group>"; };
     184                0F87B61C1BACDA93004EC572 /* UIScriptController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UIScriptController.cpp; path = UIScriptContext/UIScriptController.cpp; sourceTree = "<group>"; };
     185                0F87B61D1BACDA93004EC572 /* UIScriptController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UIScriptController.h; path = UIScriptContext/UIScriptController.h; sourceTree = "<group>"; };
     186                0F87B6221BACDAA2004EC572 /* UIScriptController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = UIScriptController.idl; path = UIScriptContext/Bindings/UIScriptController.idl; sourceTree = "<group>"; };
    166187                0FEB909E1905A776000FDBF3 /* InjectedBundlePageCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InjectedBundlePageCocoa.mm; sourceTree = "<group>"; };
    167188                0FEB90A21905BC6A000FDBF3 /* CrashReporterInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CrashReporterInfo.h; path = cocoa/CrashReporterInfo.h; sourceTree = "<group>"; };
     
    392413                                4429FC5E1627089600F66D8B /* WorkQueueManager.cpp */,
    393414                                4429FC611627089600F66D8B /* WorkQueueManager.h */,
     415                                0F73B5471BA782FE004B3EF4 /* UIScriptContext */,
    394416                        );
    395417                        name = TestRunner;
     
    409431                        sourceTree = "<group>";
    410432                };
     433                0F73B5471BA782FE004B3EF4 /* UIScriptContext */ = {
     434                        isa = PBXGroup;
     435                        children = (
     436                                0F73B54E1BA78954004B3EF4 /* Derived Sources */,
     437                                0F73B54B1BA78350004B3EF4 /* Bindings */,
     438                                0F87B61A1BACDA93004EC572 /* UIScriptContext.cpp */,
     439                                0F87B61B1BACDA93004EC572 /* UIScriptContext.h */,
     440                                0F87B61C1BACDA93004EC572 /* UIScriptController.cpp */,
     441                                0F87B61D1BACDA93004EC572 /* UIScriptController.h */,
     442                        );
     443                        name = UIScriptContext;
     444                        sourceTree = "<group>";
     445                };
     446                0F73B54B1BA78350004B3EF4 /* Bindings */ = {
     447                        isa = PBXGroup;
     448                        children = (
     449                                0F87B6221BACDAA2004EC572 /* UIScriptController.idl */,
     450                        );
     451                        name = Bindings;
     452                        sourceTree = "<group>";
     453                };
     454                0F73B54E1BA78954004B3EF4 /* Derived Sources */ = {
     455                        isa = PBXGroup;
     456                        children = (
     457                                0F73B54F1BA78968004B3EF4 /* JSUIScriptController.cpp */,
     458                                0F73B5501BA78968004B3EF4 /* JSUIScriptController.h */,
     459                        );
     460                        name = "Derived Sources";
     461                        sourceTree = "<group>";
     462                };
    411463                0FEB909D1905A75D000FDBF3 /* cocoa */ = {
    412464                        isa = PBXGroup;
     
    424476                                0FEB90A31905BC6A000FDBF3 /* CrashReporterInfo.mm */,
    425477                                2DCE2CD11B84524500C7F832 /* TestControllerCocoa.mm */,
     478                                0F87B6141BACC4B9004EC572 /* TestRunnerWKWebView.h */,
     479                                0F87B6151BACC4B9004EC572 /* TestRunnerWKWebView.mm */,
    426480                        );
    427481                        name = cocoa;
     
    473527                        isa = PBXGroup;
    474528                        children = (
     529                                0F73B5571BA7929E004B3EF4 /* JavaScriptCore.framework */,
    475530                                2EE52CE21890A9A80010ED21 /* Foundation.framework */,
    476531                                2EE52CE41890A9A80010ED21 /* CoreGraphics.framework */,
     
    492547                        isa = PBXGroup;
    493548                        children = (
    494                                 0F831AE91BAB84F400F96CD8 /* Launch.storyboard */,
     549                                0F87B6181BACC558004EC572 /* Launch.storyboard */,
    495550                                2EE52CEB1890A9A80010ED21 /* InfoPlist.strings */,
    496551                                2EE52D131890A9FB0010ED21 /* PlatformWebViewIOS.mm */,
    497552                                2EE52D141890A9FB0010ED21 /* TestControllerIOS.mm */,
     553                                0F73B55B1BA89042004B3EF4 /* UIScriptControllerIOS.mm */,
    498554                                2EE52D151890A9FB0010ED21 /* WebArchiveDumpSupportIOS.mm */,
    499555                                2EE52D161890A9FB0010ED21 /* mainIOS.mm */,
     556                                0F831AE71BAB72D000F96CD8 /* Launch.storyboard */,
    500557                        );
    501558                        path = ios;
     
    588645                                E1C642C117CBCC7300D66A3C /* PoseAsClass.mm */,
    589646                                BC8C795B11D2785D004535A1 /* TestControllerMac.mm */,
     647                                0F87B6111BACAD6F004EC572 /* UIScriptControllerMac.mm */,
    590648                                E132AA3917CD5F1000611DF0 /* WebKitTestRunnerDraggingInfo.h */,
    591649                                E132AA3817CD5F1000611DF0 /* WebKitTestRunnerDraggingInfo.mm */,
     
    678736                        buildActionMask = 2147483647;
    679737                        files = (
     738                                0F73B5521BA78968004B3EF4 /* JSUIScriptController.h in Headers */,
    680739                        );
    681740                        runOnlyForDeploymentPostprocessing = 0;
     
    804863                                2E34C90018B68808000067BB /* WebKitTestRunnerInjectedBundle.bundle in Resources */,
    805864                                2EE52CED1890A9A80010ED21 /* InfoPlist.strings in Resources */,
    806                                 0F831AEA1BAB84F400F96CD8 /* Launch.storyboard in Resources */,
     865                                0F87B6191BACC558004EC572 /* Launch.storyboard in Resources */,
    807866                        );
    808867                        runOnlyForDeploymentPostprocessing = 0;
     
    866925                                BC793400118F7C84005EA8E2 /* main.mm in Sources */,
    867926                                E1C642C617CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm in Sources */,
     927                                0F87B6131BACAD82004EC572 /* UIScriptControllerMac.mm in Sources */,
    868928                                BC7934E811906846005EA8E2 /* PlatformWebViewMac.mm in Sources */,
    869929                                BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,
     
    876936                        buildActionMask = 2147483647;
    877937                        files = (
     938                                0F73B55A1BA792FF004B3EF4 /* JSWrapper.cpp in Sources */,
    878939                                A18510441B9AE14A00744AEB /* WorkQueueManager.cpp in Sources */,
    879940                                A185103F1B9AE12900744AEB /* GeolocationProviderMock.cpp in Sources */,
     941                                0F73B55C1BA89042004B3EF4 /* UIScriptControllerIOS.mm in Sources */,
    880942                                A185103C1B9AE0FE00744AEB /* Options.cpp in Sources */,
    881943                                A18510431B9AE14500744AEB /* WebNotificationProvider.cpp in Sources */,
    882944                                A18510411B9AE13800744AEB /* TestController.cpp in Sources */,
     945                                0F87B6201BACDA93004EC572 /* UIScriptController.cpp in Sources */,
    883946                                A18510421B9AE13E00744AEB /* TestInvocation.cpp in Sources */,
    884947                                A18510401B9AE13100744AEB /* PixelDumpSupport.cpp in Sources */,
    885948                                A185103D1B9AE10600744AEB /* TestInvocationCG.cpp in Sources */,
    886949                                A185103A1B9AE0DA00744AEB /* CrashReporterInfo.mm in Sources */,
     950                                0F73B5511BA78968004B3EF4 /* JSUIScriptController.cpp in Sources */,
     951                                0F87B61E1BACDA93004EC572 /* UIScriptContext.cpp in Sources */,
    887952                                A185103E1B9AE12200744AEB /* CyclicRedundancyCheck.cpp in Sources */,
     953                                0F87B6171BACC4C0004EC572 /* TestRunnerWKWebView.mm in Sources */,
    888954                                A185103B1B9AE0E200744AEB /* TestControllerCocoa.mm in Sources */,
    889955                        );
     
    11941260                        );
    11951261                        defaultConfigurationIsVisible = 0;
     1262                        defaultConfigurationName = Production;
    11961263                };
    11971264                A185102D1B9ADE4800744AEB /* Build configuration list for PBXNativeTarget "WebKitTestRunner (Library)" */ = {
  • trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm

    r189668 r190065  
    3030#import "PlatformWebView.h"
    3131#import "TestInvocation.h"
     32#import "TestRunnerWKWebView.h"
    3233#import <Foundation/Foundation.h>
    3334#import <WebKit/WKContextConfigurationRef.h>
  • trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h

    r190064 r190065  
    2424 */
    2525
    26 #ifndef TestOptions_h
    27 #define TestOptions_h
     26#import <WebKit/WebKit.h>
    2827
    29 #include <wtf/Vector.h>
    30 #include <wtf/text/WTFString.h>
     28#if WK_API_ENABLED
    3129
    32 namespace WTR {
     30@interface TestRunnerWKWebView : WKWebView
    3331
    34 struct TestOptions {
    35     bool useThreadedScrolling { false };
    36     bool useRemoteLayerTree { false };
    37     bool shouldShowWebView { false };
     32#if PLATFORM(IOS)
     33- (void)zoomToScale:(double)scale animated:(BOOL)animated completionHandler:(void (^)(void))completionHandler;
     34- (void)onDidEndZooming:(void (^)(void))completionHandler;
     35#endif
    3836
    39     bool useFixedLayout { false };
    40     Vector<String> overrideLanguages;
    41 };
     37@end
    4238
    43 }
    44 
    45 #endif // TestOptions_h
     39#endif // #if WK_API_ENABLED
  • trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm

    r189959 r190065  
    2424 */
    2525
    26 #include "config.h"
    27 #include "PlatformWebView.h"
    28 #include "TestController.h"
    29 
     26#import "config.h"
     27#import "PlatformWebView.h"
     28
     29#import "TestController.h"
     30#import "TestRunnerWKWebView.h"
    3031#import <WebKit/WKImageCG.h>
    3132#import <WebKit/WKPreferencesPrivate.h>
     
    107108{
    108109    CGRect rect = CGRectMake(0, 0, TestController::viewWidth, TestController::viewHeight);
    109     m_view = [[WKWebView alloc] initWithFrame:rect configuration:configuration];
     110    m_view = [[TestRunnerWKWebView alloc] initWithFrame:rect configuration:configuration];
    110111
    111112    m_window = [[WebKitTestRunnerWindow alloc] initWithFrame:rect];
  • trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm

    r189400 r190065  
    3131#import "StringFunctions.h"
    3232#import "TestController.h"
     33#import "TestRunnerWKWebView.h"
    3334#import <Carbon/Carbon.h>
    3435#import <WebKit/WKString.h>
  • trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm

    r189959 r190065  
    2828
    2929#import "TestController.h"
     30#import "TestRunnerWKWebView.h"
    3031#import "WebKitTestRunnerDraggingInfo.h"
    3132#import <WebKit/WKImageCG.h>
     
    5354@property (nonatomic, assign) PlatformWebView* platformWebView;
    5455@end
    55 
    56 #if WK_API_ENABLED
    57 @interface TestRunnerWKWebView : WKWebView
    58 @end
    59 
    60 @implementation TestRunnerWKWebView
    61 
    62 - (void)dragImage:(NSImage *)anImage at:(NSPoint)viewLocation offset:(NSSize)initialOffset event:(NSEvent *)event pasteboard:(NSPasteboard *)pboard source:(id)sourceObj slideBack:(BOOL)slideFlag
    63 {
    64     RetainPtr<WebKitTestRunnerDraggingInfo> draggingInfo = adoptNS([[WebKitTestRunnerDraggingInfo alloc] initWithImage:anImage offset:initialOffset pasteboard:pboard source:sourceObj]);
    65     [self draggingUpdated:draggingInfo.get()];
    66 }
    67 
    68 @end
    69 #endif
    7056
    7157@implementation WebKitTestRunnerWindow
  • trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm

    r190060 r190065  
    3030#import "PoseAsClass.h"
    3131#import "TestInvocation.h"
     32#import "TestRunnerWKWebView.h"
    3233#import "WebKitTestRunnerPasteboard.h"
    3334#import <WebKit/WKContextPrivate.h>
  • trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm

    r190064 r190065  
    2424 */
    2525
    26 #ifndef TestOptions_h
    27 #define TestOptions_h
     26#import "config.h"
     27#import "UIScriptController.h"
    2828
    29 #include <wtf/Vector.h>
    30 #include <wtf/text/WTFString.h>
     29#import "UIScriptContext.h"
    3130
    3231namespace WTR {
    3332
    34 struct TestOptions {
    35     bool useThreadedScrolling { false };
    36     bool useRemoteLayerTree { false };
    37     bool shouldShowWebView { false };
     33void UIScriptController::doAsyncTask(JSValueRef callback)
     34{
     35    unsigned callbackID = m_context.prepareForAsyncTask(callback);
    3836
    39     bool useFixedLayout { false };
    40     Vector<String> overrideLanguages;
    41 };
     37    dispatch_async(dispatch_get_main_queue(), ^{
     38        m_context.asyncTaskComplete(callbackID);
     39    });
     40}
    4241
    4342}
    44 
    45 #endif // TestOptions_h
  • trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerDraggingInfo.h

    r185530 r190065  
    2323 * THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
     25
     26#if PLATFORM(MAC)
    2527
    2628@interface WebKitTestRunnerDraggingInfo : NSObject <NSDraggingInfo> {
     
    5153#endif
    5254@end
     55
     56#endif // PLATFORM(MAC)
Note: See TracChangeset for help on using the changeset viewer.