+2015-09-21 Simon Fraser <simon.fraser@apple.com>
+
+ 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.
+
+ 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:
+
2015-09-21 Tim Horton <timothy_horton@apple.com>
Turn on threaded scrolling by default in the tests
editing/pasteboard/gtk [ Skip ]
tiled-drawing [ Skip ]
swipe [ Skip ]
+fast/zooming/ios [ Skip ]
fast/forms/attributed-strings.html [ Skip ]
fast/scrolling/latching [ Skip ]
# This test is WebKit2-only
http/tests/appcache/decide-navigation-policy-after-delay.html [ Skip ]
+# Only Mac and iOS have an implementation of UIScriptController::doAsyncTask().
+fast/harness/ui-side-scripts.html [ Skip ]
+fast/harness/concurrent-ui-side-scripts.html [ Skip ]
+
#//////////////////////////////////////////////////////////////////////////////////////////
# End platform-specific tests.
#//////////////////////////////////////////////////////////////////////////////////////////
--- /dev/null
+Script 2:
+Running UI-side script 2
+Completed async task 2.1. Script done.
+Script 1:
+Running UI-side script 1
+Completed async task 1.1.
+Completed async task 1.2.
+Completed async task 1.3. Script done.
+.
--- /dev/null
+<!DOCTYPE html>
+
+<html>
+<head>
+ <script id="ui-script1" type="text/plain">
+ (function() {
+ var completions = 'Running UI-side script 1\n';
+
+ uiController.doAsyncTask(function() {
+ completions += 'Completed async task 1.1.\n';
+
+ uiController.doAsyncTask(function() {
+ completions += 'Completed async task 1.2.\n';
+
+ uiController.doAsyncTask(function() {
+ completions += 'Completed async task 1.3. Script done.\n';
+
+ uiController.uiScriptComplete(completions);
+ });
+ });
+ });
+ })();
+ </script>
+
+ <script id="ui-script2" type="text/plain">
+ (function() {
+ var completions2 = 'Running UI-side script 2\n';
+
+ uiController.doAsyncTask(function() {
+ completions2 += 'Completed async task 2.1. Script done.\n';
+
+ uiController.uiScriptComplete(completions2);
+ });
+ })();
+ </script>
+
+ <script>
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ var outstandingScripts = 2;
+ function runTest()
+ {
+ if (testRunner.runUIScript) {
+ var uiScript = document.getElementById('ui-script1').text;
+ testRunner.runUIScript(uiScript, function(result) {
+ document.getElementById('results').textContent += 'Script 1:\n' + result;
+ --outstandingScripts;
+ checkIfScriptsComplete();
+ });
+
+ var uiScript2 = document.getElementById('ui-script2').text;
+ testRunner.runUIScript(uiScript2, function(result) {
+ document.getElementById('results').textContent += 'Script 2:\n' + result;
+ --outstandingScripts;
+ checkIfScriptsComplete();
+ });
+ }
+ }
+
+ function checkIfScriptsComplete(remaining)
+ {
+ if (outstandingScripts)
+ return;
+
+ testRunner.notifyDone();
+ }
+
+ window.addEventListener('load', runTest, false);
+ </script>
+</head>
+<body>
+
+<pre id="results"></pre>
+
+</body>
+</html>
+.
\ No newline at end of file
--- /dev/null
+Running the UI-side script
+Completed async task 1.1.
+Completed async task 2.1.
+Completed async task 1.2.
+Completed async task 2.1.
+Completed async task 2.2.1.
+Completed async task 1.3.
+Completed async task 2.3.
+Completed async task 2.2.2.
+.
--- /dev/null
+<!DOCTYPE html>
+
+<html>
+<head>
+ <script id="ui-script" type="text/plain">
+ (function() {
+ var completions = 'Running the UI-side script\n';
+ var outstandingTaskCount = 3;
+
+ uiController.doAsyncTask(function() {
+ completions += 'Completed async task 1.1.\n';
+
+ uiController.doAsyncTask(function() {
+ completions += 'Completed async task 1.2.\n';
+
+ uiController.doAsyncTask(function() {
+ completions += 'Completed async task 1.3.\n';
+
+ --outstandingTaskCount;
+ checkIfTasksFinished();
+ });
+ });
+ });
+
+ uiController.doAsyncTask(function() {
+ completions += 'Completed async task 2.1.\n';
+
+ uiController.doAsyncTask(function() {
+ completions += 'Completed async task 2.1.\n';
+
+ uiController.doAsyncTask(function() {
+ completions += 'Completed async task 2.3.\n';
+
+ --outstandingTaskCount;
+ checkIfTasksFinished();
+ });
+ });
+
+ uiController.doAsyncTask(function() {
+ completions += 'Completed async task 2.2.1.\n';
+
+ uiController.doAsyncTask(function() {
+ completions += 'Completed async task 2.2.2.\n';
+
+ --outstandingTaskCount;
+ checkIfTasksFinished();
+ });
+ });
+ });
+
+ function checkIfTasksFinished()
+ {
+ if (!outstandingTaskCount)
+ uiController.uiScriptComplete(completions);
+ }
+ })();
+ </script>
+
+ <script>
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ function runTest()
+ {
+ if (testRunner.runUIScript) {
+ var uiScript = document.getElementById('ui-script').text;
+ testRunner.runUIScript(uiScript, function(result) {
+ document.getElementById('result').textContent = result;
+ testRunner.notifyDone();
+ });
+ }
+ }
+
+ window.addEventListener('load', runTest, false);
+ </script>
+</head>
+<body>
+
+<pre id="result">This test has to run in iOS WebKitTestRunner.</pre>
+
+</body>
+</html>
+.
\ No newline at end of file
--- /dev/null
+PASS: final zoom scale was 1.2
+
+.
--- /dev/null
+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+ <meta name="viewport" content="width=device-width">
+ <script id="ui-script" type="text/plain">
+ (function() {
+ uiController.zoomToScale(1.2, function() {
+ uiController.uiScriptComplete(uiController.zoomScale);
+ });
+ })();
+ </script>
+
+ <script>
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ function runTest()
+ {
+ if (testRunner.runUIScript) {
+ var uiScript = document.getElementById('ui-script').text;
+ testRunner.runUIScript(uiScript, function(result) {
+
+ var resultText;
+ if (result == "1.2")
+ resultText = "PASS: final zoom scale was " + result;
+ else
+ resultText = "FAIL: final zoom scale was " + result + ", should be 1.2";
+
+ document.getElementById('result').textContent = resultText;
+ testRunner.notifyDone();
+ });
+ }
+ }
+
+ window.addEventListener('load', runTest, false);
+ </script>
+</head>
+<body>
+
+<p id="result">This test has to run in iOS WebKitTestRunner.</p>
+
+</body>
+</html>
+.
\ No newline at end of file
#
# See http://trac.webkit.org/wiki/TestExpectations for more information on this file.
+#//////////////////////////////////////////////////////////////////////////////////////////
+# Platform-specific directories. Skipped globally, then re-enabled here.
+#//////////////////////////////////////////////////////////////////////////////////////////
+
+fast/harness/ui-side-scripts.html [ Pass ]
+fast/harness/concurrent-ui-side-scripts.html [ Pass ]
+fast/zooming/ios [ Pass ]
+
+#//////////////////////////////////////////////////////////////////////////////////////////
+# End platform-specific directories.
+#//////////////////////////////////////////////////////////////////////////////////////////
+
# Animation tests that fail:
webkit.org/b/129562 [ Debug ] animations/animation-direction-reverse-fill-mode.html [ Skip ]
[ Release ] animations/animation-direction-reverse-fill-mode.html [ Timeout Pass ]
fast/events/force-click-on-link-navigation.html [ Pass ]
fast/events/force-click-text-selection-behavior.html [ Failure ]
+fast/harness/ui-side-scripts.html [ Pass ]
+fast/harness/concurrent-ui-side-scripts.html [ Pass ]
+
#//////////////////////////////////////////////////////////////////////////////////////////
# End platform-specific directories.
#//////////////////////////////////////////////////////////////////////////////////////////
+2015-09-21 Simon Fraser <simon.fraser@apple.com>
+
+ 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.
+
+ Expose a few private functions for testing.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
2015-09-21 Tim Horton <timothy_horton@apple.com>
Layout milestones aren't synchronized with UI-side compositing transactions
[self _updateVisibleContentRects];
}
-// 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.
+// 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.
- (CGRect)_contentRectForUserInteraction
{
// FIXME: handle split keyboard.
return _viewportMetaTagWidth;
}
+- (CGRect)_contentVisibleRect
+{
+ return [self convertRect:[self bounds] toView:self._currentContentView];
+}
+
+- (CGPoint)_convertPointFromContentsToView:(CGPoint)point
+{
+ return [self convertPoint:point fromView:self._currentContentView];
+}
+
+- (CGPoint)_convertPointFromViewToContents:(CGPoint)point
+{
+ return [self convertPoint:point toView:self._currentContentView];
+}
+
- (_WKWebViewPrintFormatter *)_webViewPrintFormatter
{
UIViewPrintFormatter *viewPrintFormatter = self.viewPrintFormatter;
// The viewport meta tag width is negative if the value is not defined.
@property (nonatomic, readonly) CGFloat _viewportMetaTagWidth;
+@property (nonatomic, readonly) CGRect _contentVisibleRect;
+
@property (nonatomic, readonly) _WKWebViewPrintFormatter *_webViewPrintFormatter;
+- (CGPoint)_convertPointFromContentsToView:(CGPoint)point;
+- (CGPoint)_convertPointFromViewToContents:(CGPoint)point;
+
- (void)_beginInteractiveObscuredInsetsChange;
- (void)_endInteractiveObscuredInsetsChange;
- (void)_hideContentUntilNextUpdate;
+2015-09-21 Simon Fraser <simon.fraser@apple.com>
+
+ 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.
+
+ 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.
+
2015-09-21 Tim Horton <timothy_horton@apple.com>
Turn on threaded scrolling by default in the tests
set(WEBKIT_TESTRUNNER_DIR "${TOOLS_DIR}/WebKitTestRunner")
set(WEBKIT_TESTRUNNER_INJECTEDBUNDLE_DIR "${TOOLS_DIR}/WebKitTestRunner/InjectedBundle")
+set(WEBKIT_TESTRUNNER_UISCRIPTCONTEXT_DIR "${TOOLS_DIR}/WebKitTestRunner/UIScriptContext")
file(MAKE_DIRECTORY ${DERIVED_SOURCES_DIR}/InjectedBundle)
+file(MAKE_DIRECTORY ${DERIVED_SOURCES_DIR}/UIScriptContext)
set(WebKitTestRunner_SOURCES
${WEBKIT_TESTRUNNER_DIR}/CyclicRedundancyCheck.cpp
${WEBKIT_TESTRUNNER_DIR}/TestInvocation.cpp
${WEBKIT_TESTRUNNER_DIR}/WebNotificationProvider.cpp
${WEBKIT_TESTRUNNER_DIR}/WorkQueueManager.cpp
+ ${WEBKIT_TESTRUNNER_UISCRIPTCONTEXT_DIR}/UIScriptContext.cpp
+ ${WEBKIT_TESTRUNNER_UISCRIPTCONTEXT_DIR}/UIScriptController.cpp
+
+ ${WEBKIT_TESTRUNNER_INJECTEDBUNDLE_DIR}/Bindings/JSWrapper.cpp
)
set(WebKitTestRunner_LIBRARIES
${WEBKIT_TESTRUNNER_DIR}/InjectedBundle
${WEBKIT_TESTRUNNER_DIR}/InjectedBundle/Bindings
${WEBKIT_TESTRUNNER_DIR}/InjectedBundle/atk
+ ${WEBKIT_TESTRUNNER_UISCRIPTCONTEXT_DIR}
+ ${WEBKIT_TESTRUNNER_UISCRIPTCONTEXT_DIR}/Bindings
${JAVASCRIPTCORE_DIR}
${JAVASCRIPTCORE_DIR}/ForwardingHeaders
${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}
${WEBKIT2_DIR}/WebProcess/InjectedBundle/API/c
${WTF_DIR}
${DERIVED_SOURCES_DIR}/InjectedBundle
+ ${DERIVED_SOURCES_DIR}/UIScriptContext
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/Source
)
"${WEBKIT_TESTRUNNER_INJECTEDBUNDLE_DIR}/Bindings/TextInputController.idl"
)
-set(WebKitTestRunnerInjectedBundle_LIBRARIES
- ${WebKitTestRunner_LIBRARIES}
+set(WebKitTestRunner_IDL_FILES
+ "${WEBKIT_TESTRUNNER_DIR}/UIScriptContext/Bindings/UIScriptController.idl"
)
GENERATE_BINDINGS(WebKitTestRunnerInjectedBundle_SOURCES
${DERIVED_SOURCES_DIR}/InjectedBundle JS TestRunner cpp
${WEBCORE_DIR}/bindings/scripts/IDLAttributes.txt)
+GENERATE_BINDINGS(WebKitTestRunner_SOURCES
+ "${WebKitTestRunner_IDL_FILES}"
+ "${WEBKIT_TESTRUNNER_INJECTEDBUNDLE_DIR}/Bindings"
+ "--include=${WEBKIT_TESTRUNNER_INJECTEDBUNDLE_DIR}/Bindings"
+ "${FEATURE_DEFINES_WITH_SPACE_SEPARATOR}"
+ ${DERIVED_SOURCES_DIR}/UIScriptContext JS TestRunner cpp
+ ${WEBCORE_DIR}/bindings/scripts/IDLAttributes.txt)
+
WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
include_directories(${WebKitTestRunner_INCLUDE_DIRECTORIES})
include_directories(SYSTEM ${WebKitTestRunner_SYSTEM_INCLUDE_DIRECTORIES})
add_library(TestRunnerInjectedBundle SHARED ${WebKitTestRunnerInjectedBundle_SOURCES})
-target_link_libraries(TestRunnerInjectedBundle ${WebKitTestRunnerInjectedBundle_LIBRARIES})
+target_link_libraries(TestRunnerInjectedBundle ${WebKitTestRunner_LIBRARIES})
add_executable(WebKitTestRunner ${WebKitTestRunner_SOURCES})
target_link_libraries(WebKitTestRunner ${WebKitTestRunner_LIBRARIES})
VPATH = \
$(WebKitTestRunner)/InjectedBundle/Bindings \
+ $(WebKitTestRunner)/UIScriptContext/Bindings \
#
-INTERFACES = \
+INJECTED_BUNDLE_INTERFACES = \
AccessibilityController \
AccessibilityTextMarker \
AccessibilityTextMarkerRange \
TextInputController \
#
+UICONTEXT_INTERFACES = \
+ UIScriptController \
+#
+
SCRIPTS = \
$(WebCoreScripts)/CodeGenerator.pm \
$(WebKitTestRunner)/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm \
JS%.h JS%.cpp : %.idl $(SCRIPTS)
@echo Generating bindings for $*...
- @perl -I $(WebCoreScripts) -I $(WebKitTestRunner)/InjectedBundle/Bindings $(WebCoreScripts)/generate-bindings.pl --defines "" --include InjectedBundle/Bindings --outputDir . --generator TestRunner $<
+ @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 $<
all : \
- $(INTERFACES:%=JS%.h) \
- $(INTERFACES:%=JS%.cpp) \
+ $(INJECTED_BUNDLE_INTERFACES:%=JS%.h) \
+ $(INJECTED_BUNDLE_INTERFACES:%=JS%.cpp) \
+ $(UICONTEXT_INTERFACES:%=JS%.h) \
+ $(UICONTEXT_INTERFACES:%=JS%.cpp) \
#
void installWillEndSwipeCallback(object callback);
void installDidEndSwipeCallback(object callback);
void installDidRemoveSwipeSnapshotCallback(object callback);
+
+ // UI Process Testing
+ void runUIScript(DOMString script, object callback);
};
return;
}
+ if (WKStringIsEqualToUTF8CString(messageName, "CallUISideScriptCallback")) {
+ WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
+
+ WKRetainPtr<WKStringRef> resultKey(AdoptWK, WKStringCreateWithUTF8CString("Result"));
+ WKRetainPtr<WKStringRef> callbackIDKey(AdoptWK, WKStringCreateWithUTF8CString("CallbackID"));
+
+ unsigned callbackID = (unsigned)WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, callbackIDKey.get())));
+
+ WKStringRef resultString = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, resultKey.get()));
+ auto resultJSString = toJS(resultString);
+
+ m_testRunner->runUIScriptCallback(callbackID, resultJSString.get());
+ return;
+ }
+
if (WKStringIsEqualToUTF8CString(messageName, "WorkQueueProcessedCallback")) {
if (!topLoadingFrame() && !m_testRunner->waitToDump())
InjectedBundle::page()->dump();
DidBeginSwipeCallbackID,
WillEndSwipeCallbackID,
DidEndSwipeCallbackID,
- DidRemoveSwipeSnapshotCallbackID
+ DidRemoveSwipeSnapshotCallbackID,
+ FirstUIScriptCallbackID = 100
};
static void cacheTestRunnerCallback(unsigned index, JSValueRef callback)
callbackMap().add(index, callback);
}
-static void callTestRunnerCallback(unsigned index)
+static void callTestRunnerCallback(unsigned index, size_t argumentCount = 0, const JSValueRef arguments[] = nullptr)
{
if (!callbackMap().contains(index))
return;
WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::singleton().page()->page());
JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
JSObjectRef callback = JSValueToObject(context, callbackMap().take(index), 0);
- JSObjectCallAsFunction(context, callback, JSContextGetGlobalObject(context), 0, 0, 0);
+ JSObjectCallAsFunction(context, callback, JSContextGetGlobalObject(context), argumentCount, arguments, 0);
JSValueUnprotect(context, callback);
}
WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
}
+static unsigned nextUIScriptCallbackID()
+{
+ static unsigned callbackID = FirstUIScriptCallbackID;
+ return callbackID++;
+}
+
+void TestRunner::runUIScript(JSStringRef script, JSValueRef callback)
+{
+ unsigned callbackID = nextUIScriptCallbackID();
+ cacheTestRunnerCallback(callbackID, callback);
+
+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("RunUIProcessScript"));
+
+ WKRetainPtr<WKMutableDictionaryRef> testDictionary(AdoptWK, WKMutableDictionaryCreate());
+
+ WKRetainPtr<WKStringRef> scriptKey(AdoptWK, WKStringCreateWithUTF8CString("Script"));
+ WKRetainPtr<WKStringRef> scriptValue(AdoptWK, WKStringCreateWithJSString(script));
+
+ WKRetainPtr<WKStringRef> callbackIDKey(AdoptWK, WKStringCreateWithUTF8CString("CallbackID"));
+ WKRetainPtr<WKUInt64Ref> callbackIDValue = adoptWK(WKUInt64Create(callbackID));
+
+ WKDictionarySetItem(testDictionary.get(), scriptKey.get(), scriptValue.get());
+ WKDictionarySetItem(testDictionary.get(), callbackIDKey.get(), callbackIDValue.get());
+
+ WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), testDictionary.get());
+}
+
+void TestRunner::runUIScriptCallback(unsigned callbackID, JSStringRef result)
+{
+ WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::singleton().page()->page());
+ JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
+
+ JSValueRef resultValue = JSValueMakeString(context, result);
+ callTestRunnerCallback(callbackID, 1, &resultValue);
+}
+
void TestRunner::installDidBeginSwipeCallback(JSValueRef callback)
{
cacheTestRunnerCallback(DidBeginSwipeCallbackID, callback);
void setShouldDecideNavigationPolicyAfterDelay(bool);
void setNavigationGesturesEnabled(bool);
+ void runUIScript(JSStringRef script, JSValueRef callback);
+ void runUIScriptCallback(unsigned callbackID, JSStringRef result);
+
void installDidBeginSwipeCallback(JSValueRef);
void installWillEndSwipeCallback(JSValueRef);
void installDidEndSwipeCallback(JSValueRef);
#include <WebKit/WKFoundation.h>
OBJC_CLASS NSView;
OBJC_CLASS UIView;
-OBJC_CLASS WKWebView;
+OBJC_CLASS TestRunnerWKWebView;
OBJC_CLASS WKWebViewConfiguration;
OBJC_CLASS WebKitTestRunnerWindow;
#if WK_API_ENABLED
-typedef WKWebView *PlatformWKView;
+typedef TestRunnerWKWebView *PlatformWKView;
#else
typedef NSView *PlatformWKView;
#endif
#endif
}
-static bool shouldUseFixedLayout(const TestInvocation& test)
-{
-#if ENABLE(CSS_DEVICE_ADAPTATION)
- if (test.urlContains("device-adapt/") || test.urlContains("device-adapt\\"))
- return true;
-#endif
-
- return false;
-}
-
static std::string testPath(const WKURLRef url)
{
auto scheme = adoptWK(WKURLCopyScheme(url));
String(value.c_str()).split(",", false, testOptions.overrideLanguages);
if (key == "useThreadedScrolling")
testOptions.useThreadedScrolling = parseBooleanTestHeaderValue(value);
+ if (key == "useFlexibleViewport")
+ testOptions.useFlexibleViewport = parseBooleanTestHeaderValue(value);
pairStart = pairEnd + 1;
}
}
options.useRemoteLayerTree = m_shouldUseRemoteLayerTree;
options.shouldShowWebView = m_shouldShowWebView;
- options.useFixedLayout = shouldUseFixedLayout(test);
+ options.useFixedLayout = test.shouldUseFixedLayout();
+ options.useFlexibleViewport = test.shouldMakeViewportFlexible();
updatePlatformSpecificTestOptionsForTest(options, test);
#include "PlatformWebView.h"
#include "StringFunctions.h"
#include "TestController.h"
+#include "UIScriptController.h"
#include <WebKit/WKContextPrivate.h>
#include <WebKit/WKCookieManager.h>
#include <WebKit/WKData.h>
#include <unistd.h> // For getcwd.
+using namespace JSC;
using namespace WebKit;
using namespace std;
return urlContains("viewport/");
}
+bool TestInvocation::shouldUseFixedLayout() const
+{
+#if ENABLE(CSS_DEVICE_ADAPTATION)
+ if (urlContains("device-adapt/") || urlContains("device-adapt\\"))
+ return true;
+#endif
+
+ return false;
+}
+
void TestInvocation::invoke()
{
TestController::singleton().configureViewForTest(*this);
return;
}
+ if (WKStringIsEqualToUTF8CString(messageName, "RunUIProcessScript")) {
+ WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
+ WKRetainPtr<WKStringRef> scriptKey(AdoptWK, WKStringCreateWithUTF8CString("Script"));
+ WKRetainPtr<WKStringRef> callbackIDKey(AdoptWK, WKStringCreateWithUTF8CString("CallbackID"));
+
+ unsigned callbackID = (unsigned)WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, callbackIDKey.get())));
+ WKStringRef scriptString = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, scriptKey.get()));
+
+ runUISideScript(scriptString, callbackID);
+ return;
+ }
+
ASSERT_NOT_REACHED();
}
ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
WKBooleanRef isKeyValue = static_cast<WKBooleanRef>(messageBody);
TestController::singleton().mainWebView()->setWindowIsKey(WKBooleanGetValue(isKeyValue));
- return 0;
+ return nullptr;
}
if (WKStringIsEqualToUTF8CString(messageName, "IsGeolocationClientActive")) {
WKHTTPCookieAcceptPolicy policy = WKBooleanGetValue(accept) ? kWKHTTPCookieAcceptPolicyAlways : kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
// FIXME: This updates the policy in WebProcess and in NetworkProcess asynchronously, which might break some tests' expectations.
WKCookieManagerSetHTTPCookieAcceptPolicy(WKContextGetCookieManager(TestController::singleton().context()), policy);
- return 0;
+ return nullptr;
}
ASSERT_NOT_REACHED();
- return 0;
+ return nullptr;
+}
+
+void TestInvocation::runUISideScript(WKStringRef script, unsigned scriptCallbackID)
+{
+ if (!m_UIScriptContext)
+ m_UIScriptContext = std::make_unique<UIScriptContext>(*this);
+
+ m_UIScriptContext->runUIScript(script, scriptCallbackID);
+}
+
+void TestInvocation::uiScriptDidComplete(WKStringRef result, unsigned scriptCallbackID)
+{
+ WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallUISideScriptCallback"));
+
+ WKRetainPtr<WKMutableDictionaryRef> messageBody(AdoptWK, WKMutableDictionaryCreate());
+ WKRetainPtr<WKStringRef> resultKey(AdoptWK, WKStringCreateWithUTF8CString("Result"));
+ WKRetainPtr<WKStringRef> callbackIDKey(AdoptWK, WKStringCreateWithUTF8CString("CallbackID"));
+ WKRetainPtr<WKUInt64Ref> callbackIDValue = adoptWK(WKUInt64Create(scriptCallbackID));
+
+ WKDictionarySetItem(messageBody.get(), resultKey.get(), result);
+ WKDictionarySetItem(messageBody.get(), callbackIDKey.get(), callbackIDValue.get());
+
+ WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), messageBody.get());
}
void TestInvocation::outputText(const WTF::String& text)
#ifndef TestInvocation_h
#define TestInvocation_h
+#include "JSWrappable.h"
+#include "UIScriptContext.h"
+#include <JavaScriptCore/JSRetainPtr.h>
#include <WebKit/WKRetainPtr.h>
#include <string>
#include <wtf/Noncopyable.h>
namespace WTR {
-class TestInvocation {
+class TestInvocation : public UIScriptContextDelegate {
WTF_MAKE_NONCOPYABLE(TestInvocation);
public:
explicit TestInvocation(const std::string& pathOrURL);
void didRemoveSwipeSnapshot();
bool shouldMakeViewportFlexible() const;
+ bool shouldUseFixedLayout() const;
private:
void dumpResults();
bool shouldLogFrameLoadDelegates() const;
bool shouldLogHistoryClientCallbacks() const;
+ void runUISideScript(WKStringRef, unsigned callbackID);
+ // UIScriptContextDelegate
+ void uiScriptDidComplete(WKStringRef result, unsigned callbackID) override;
+
WKRetainPtr<WKURLRef> m_url;
WTF::String m_urlString;
WKRetainPtr<WKArrayRef> m_repaintRects;
std::string m_errorMessage;
bool m_webProcessIsUnresponsive;
+
+ std::unique_ptr<UIScriptContext> m_UIScriptContext;
};
bool useThreadedScrolling { false };
bool useRemoteLayerTree { false };
bool shouldShowWebView { false };
-
+ bool useFlexibleViewport { false };
bool useFixedLayout { false };
Vector<String> overrideLanguages;
};
--- /dev/null
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+interface UIScriptController {
+
+ void doAsyncTask(object callback); // Used to test the harness.
+
+ void zoomToScale(double scale, object callback);
+
+ readonly attribute double zoomScale;
+ readonly attribute double minimumZoomScale;
+ readonly attribute double maximumZoomScale;
+
+ readonly attribute object contentVisibleRect; // Returned object has 'left', 'top', 'width', 'height' properties.
+
+ void uiScriptComplete(DOMString result);
+};
--- /dev/null
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "UIScriptContext.h"
+
+#include "StringFunctions.h"
+#include "UIScriptController.h"
+#include <JavaScriptCore/JSContextRef.h>
+#include <JavaScriptCore/JSValueRef.h>
+#include <WebKit/WKRetainPtr.h>
+#include <WebKit/WKString.h>
+#include <WebKit/WKStringPrivate.h>
+
+using namespace WTR;
+
+UIScriptContext::UIScriptContext(UIScriptContextDelegate& delegate)
+ : m_context(Adopt, JSGlobalContextCreate(nullptr))
+ , m_delegate(delegate)
+{
+ m_controller = UIScriptController::create(*this);
+
+ JSObjectRef globalObject = JSContextGetGlobalObject(m_context.get());
+
+ JSValueRef exception = nullptr;
+ m_controller->makeWindowObject(m_context.get(), globalObject, &exception);
+}
+
+void UIScriptContext::runUIScript(WKStringRef script, unsigned scriptCallbackID)
+{
+ m_currentScriptCallbackID = scriptCallbackID;
+
+ auto scriptRef = toJS(script);
+
+ JSValueRef exception = nullptr;
+ JSValueRef result = JSEvaluateScript(m_context.get(), scriptRef.get(), 0, 0, 1, &exception);
+
+ if (!hasOutstandingAsyncTasks()) {
+ JSValueRef stringifyException = nullptr;
+ JSRetainPtr<JSStringRef> resultString(Adopt, JSValueToStringCopy(m_context.get(), result, &stringifyException));
+ uiScriptComplete(resultString.get());
+ m_currentScriptCallbackID = 0;
+ }
+}
+
+unsigned UIScriptContext::nextTaskCallbackID()
+{
+ return ++m_nextTaskCallbackID;
+}
+
+unsigned UIScriptContext::prepareForAsyncTask(JSValueRef callback)
+{
+ unsigned callbackID = nextTaskCallbackID();
+
+ JSValueProtect(m_context.get(), callback);
+ Task task;
+ task.parentScriptCallbackID = m_currentScriptCallbackID;
+ task.callback = callback;
+
+ ASSERT(!m_callbacks.contains(callbackID));
+ m_callbacks.add(callbackID, task);
+
+ return callbackID;
+}
+
+void UIScriptContext::asyncTaskComplete(unsigned callbackID)
+{
+ Task task = m_callbacks.take(callbackID);
+ ASSERT(task.callback);
+
+ JSValueRef exception = nullptr;
+ JSObjectRef callbackObject = JSValueToObject(m_context.get(), task.callback, &exception);
+
+ m_currentScriptCallbackID = task.parentScriptCallbackID;
+
+ exception = nullptr;
+ JSObjectCallAsFunction(m_context.get(), callbackObject, JSContextGetGlobalObject(m_context.get()), 0, nullptr, &exception);
+ JSValueUnprotect(m_context.get(), task.callback);
+
+ m_currentScriptCallbackID = 0;
+}
+
+void UIScriptContext::uiScriptComplete(JSStringRef result)
+{
+ WKRetainPtr<WKStringRef> uiScriptResult = WKStringCreateWithJSString(result);
+ m_delegate.uiScriptDidComplete(uiScriptResult.get(), m_currentScriptCallbackID);
+ m_currentScriptCallbackID = 0;
+}
+
+JSObjectRef UIScriptContext::objectFromRect(const WKRect& rect) const
+{
+ JSObjectRef object = JSObjectMake(m_context.get(), nullptr, nullptr);
+
+ JSObjectSetProperty(m_context.get(), object, adopt(JSStringCreateWithUTF8CString("left")).get(), JSValueMakeNumber(m_context.get(), rect.origin.x), kJSPropertyAttributeNone, nullptr);
+ JSObjectSetProperty(m_context.get(), object, adopt(JSStringCreateWithUTF8CString("top")).get(), JSValueMakeNumber(m_context.get(), rect.origin.y), kJSPropertyAttributeNone, nullptr);
+ JSObjectSetProperty(m_context.get(), object, adopt(JSStringCreateWithUTF8CString("width")).get(), JSValueMakeNumber(m_context.get(), rect.size.width), kJSPropertyAttributeNone, nullptr);
+ JSObjectSetProperty(m_context.get(), object, adopt(JSStringCreateWithUTF8CString("height")).get(), JSValueMakeNumber(m_context.get(), rect.size.height), kJSPropertyAttributeNone, nullptr);
+
+ return object;
+}
+
--- /dev/null
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef UIScriptContext_h
+#define UIScriptContext_h
+
+#include <JavaScriptCore/JSRetainPtr.h>
+#include <wtf/HashMap.h>
+#include <wtf/RefPtr.h>
+
+namespace WTR {
+
+class UIScriptController;
+
+class UIScriptContextDelegate {
+public:
+ virtual void uiScriptDidComplete(WKStringRef result, unsigned callbackID) = 0;
+};
+
+class UIScriptContext {
+public:
+
+ UIScriptContext(UIScriptContextDelegate&);
+
+ void runUIScript(WKStringRef script, unsigned scriptCallbackID);
+ void uiScriptComplete(JSStringRef);
+
+ unsigned prepareForAsyncTask(JSValueRef taskCallback);
+ void asyncTaskComplete(unsigned taskCallbackID);
+
+ unsigned nextTaskCallbackID();
+
+ JSObjectRef objectFromRect(const WKRect&) const;
+
+private:
+ JSRetainPtr<JSGlobalContextRef> m_context;
+
+ bool hasOutstandingAsyncTasks() const { return !m_callbacks.isEmpty(); }
+
+ struct Task {
+ unsigned parentScriptCallbackID { 0 };
+ JSValueRef callback { nullptr };
+ };
+ HashMap<unsigned, Task> m_callbacks;
+
+ UIScriptContextDelegate& m_delegate;
+ RefPtr<UIScriptController> m_controller;
+
+ unsigned m_currentScriptCallbackID { 0 };
+ unsigned m_nextTaskCallbackID { 0 };
+};
+
+}
+
+#endif // UIScriptContext_h
--- /dev/null
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "UIScriptController.h"
+
+#include "JSUIScriptController.h"
+#include "UIScriptContext.h"
+// #include <JavaScriptCore/JavaScriptCore.h>
+
+namespace WTR {
+
+UIScriptController::UIScriptController(UIScriptContext& context)
+ : m_context(context)
+{
+}
+
+void UIScriptController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
+{
+ setProperty(context, windowObject, "uiController", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
+}
+
+JSClassRef UIScriptController::wrapperClass()
+{
+ return JSUIScriptController::uIScriptControllerClass();
+}
+
+#if !PLATFORM(COCOA)
+void UIScriptController::doAsyncTask(JSValueRef)
+{
+}
+#endif
+
+#if !PLATFORM(IOS)
+void UIScriptController::zoomToScale(double, JSValueRef)
+{
+}
+
+double UIScriptController::zoomScale() const
+{
+ return 1;
+}
+
+double UIScriptController::minimumZoomScale() const
+{
+ return 1;
+}
+
+double UIScriptController::maximumZoomScale() const
+{
+ return 1;
+}
+
+JSObjectRef UIScriptController::contentVisibleRect() const
+{
+ return nullptr;
+}
+#endif
+
+void UIScriptController::uiScriptComplete(JSStringRef result)
+{
+ m_context.uiScriptComplete(result);
+}
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef UIScriptController_h
+#define UIScriptController_h
+
+#include "JSWrappable.h"
+#include <wtf/Ref.h>
+
+namespace WTR {
+
+class UIScriptContext;
+
+class UIScriptController : public JSWrappable {
+public:
+ static Ref<UIScriptController> create(UIScriptContext& context)
+ {
+ return adoptRef(*new UIScriptController(context));
+ }
+
+ void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception);
+
+ void doAsyncTask(JSValueRef callback);
+ void zoomToScale(double scale, JSValueRef callback);
+
+ double zoomScale() const;
+ double minimumZoomScale() const;
+ double maximumZoomScale() const;
+
+ JSObjectRef contentVisibleRect() const;
+
+ void uiScriptComplete(JSStringRef result);
+
+private:
+ UIScriptController(UIScriptContext&);
+
+ virtual JSClassRef wrapperClass() override;
+
+ JSObjectRef objectFromRect(const WKRect&) const;
+
+ UIScriptContext& m_context;
+};
+
+}
+
+#endif // UIScriptController_h
/* Begin PBXBuildFile section */
0F5169CC1445222D00E0A9D7 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F5169CA1445222D00E0A9D7 /* WebKit.framework */; };
- 0F831AEA1BAB84F400F96CD8 /* Launch.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0F831AE91BAB84F400F96CD8 /* Launch.storyboard */; settings = {ASSET_TAGS = (); }; };
+ 0F73B5511BA78968004B3EF4 /* JSUIScriptController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F73B54F1BA78968004B3EF4 /* JSUIScriptController.cpp */; };
+ 0F73B5521BA78968004B3EF4 /* JSUIScriptController.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F73B5501BA78968004B3EF4 /* JSUIScriptController.h */; };
+ 0F73B55A1BA792FF004B3EF4 /* JSWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC952C0C11F3B965003398B4 /* JSWrapper.cpp */; };
+ 0F73B55C1BA89042004B3EF4 /* UIScriptControllerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F73B55B1BA89042004B3EF4 /* UIScriptControllerIOS.mm */; };
+ 0F87B6131BACAD82004EC572 /* UIScriptControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F87B6111BACAD6F004EC572 /* UIScriptControllerMac.mm */; settings = {ASSET_TAGS = (); }; };
+ 0F87B6171BACC4C0004EC572 /* TestRunnerWKWebView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F87B6151BACC4B9004EC572 /* TestRunnerWKWebView.mm */; settings = {ASSET_TAGS = (); }; };
+ 0F87B6191BACC558004EC572 /* Launch.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0F87B6181BACC558004EC572 /* Launch.storyboard */; settings = {ASSET_TAGS = (); }; };
+ 0F87B61E1BACDA93004EC572 /* UIScriptContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F87B61A1BACDA93004EC572 /* UIScriptContext.cpp */; settings = {ASSET_TAGS = (); }; };
+ 0F87B6201BACDA93004EC572 /* UIScriptController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F87B61C1BACDA93004EC572 /* UIScriptController.cpp */; settings = {ASSET_TAGS = (); }; };
0FEB90A01905A834000FDBF3 /* InjectedBundlePageCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FEB909E1905A776000FDBF3 /* InjectedBundlePageCocoa.mm */; };
0FEB90A51905C016000FDBF3 /* CrashReporterInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FEB90A31905BC6A000FDBF3 /* CrashReporterInfo.mm */; };
29210EAE144CACB700835BB5 /* AccessibilityUIElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29210EA9144CACB200835BB5 /* AccessibilityUIElement.cpp */; };
/* Begin PBXFileReference section */
0F2109C7189C650D00F879A3 /* BaseTarget.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = BaseTarget.xcconfig; sourceTree = "<group>"; };
0F5169CA1445222D00E0A9D7 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
- 0F831AE91BAB84F400F96CD8 /* Launch.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Launch.storyboard; sourceTree = "<group>"; };
+ 0F73B54F1BA78968004B3EF4 /* JSUIScriptController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSUIScriptController.cpp; path = DerivedSources/WebKitTestRunner/JSUIScriptController.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
+ 0F73B5501BA78968004B3EF4 /* JSUIScriptController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSUIScriptController.h; path = DerivedSources/WebKitTestRunner/JSUIScriptController.h; sourceTree = BUILT_PRODUCTS_DIR; };
+ 0F73B5571BA7929E004B3EF4 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
+ 0F73B55B1BA89042004B3EF4 /* UIScriptControllerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIScriptControllerIOS.mm; sourceTree = "<group>"; };
+ 0F831AE71BAB72D000F96CD8 /* Launch.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Launch.storyboard; sourceTree = "<group>"; };
+ 0F87B6111BACAD6F004EC572 /* UIScriptControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIScriptControllerMac.mm; sourceTree = "<group>"; };
+ 0F87B6141BACC4B9004EC572 /* TestRunnerWKWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestRunnerWKWebView.h; path = cocoa/TestRunnerWKWebView.h; sourceTree = "<group>"; };
+ 0F87B6151BACC4B9004EC572 /* TestRunnerWKWebView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestRunnerWKWebView.mm; path = cocoa/TestRunnerWKWebView.mm; sourceTree = "<group>"; };
+ 0F87B6181BACC558004EC572 /* Launch.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Launch.storyboard; sourceTree = "<group>"; };
+ 0F87B61A1BACDA93004EC572 /* UIScriptContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UIScriptContext.cpp; path = UIScriptContext/UIScriptContext.cpp; sourceTree = "<group>"; };
+ 0F87B61B1BACDA93004EC572 /* UIScriptContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UIScriptContext.h; path = UIScriptContext/UIScriptContext.h; sourceTree = "<group>"; };
+ 0F87B61C1BACDA93004EC572 /* UIScriptController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UIScriptController.cpp; path = UIScriptContext/UIScriptController.cpp; sourceTree = "<group>"; };
+ 0F87B61D1BACDA93004EC572 /* UIScriptController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UIScriptController.h; path = UIScriptContext/UIScriptController.h; sourceTree = "<group>"; };
+ 0F87B6221BACDAA2004EC572 /* UIScriptController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = UIScriptController.idl; path = UIScriptContext/Bindings/UIScriptController.idl; sourceTree = "<group>"; };
0FEB909E1905A776000FDBF3 /* InjectedBundlePageCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InjectedBundlePageCocoa.mm; sourceTree = "<group>"; };
0FEB90A21905BC6A000FDBF3 /* CrashReporterInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CrashReporterInfo.h; path = cocoa/CrashReporterInfo.h; sourceTree = "<group>"; };
0FEB90A31905BC6A000FDBF3 /* CrashReporterInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CrashReporterInfo.mm; path = cocoa/CrashReporterInfo.mm; sourceTree = "<group>"; };
3110BE0F15BA011400D216AC /* WebNotificationProvider.h */,
4429FC5E1627089600F66D8B /* WorkQueueManager.cpp */,
4429FC611627089600F66D8B /* WorkQueueManager.h */,
+ 0F73B5471BA782FE004B3EF4 /* UIScriptContext */,
);
name = TestRunner;
sourceTree = "<group>";
name = "External Frameworks and Libraries";
sourceTree = "<group>";
};
+ 0F73B5471BA782FE004B3EF4 /* UIScriptContext */ = {
+ isa = PBXGroup;
+ children = (
+ 0F73B54E1BA78954004B3EF4 /* Derived Sources */,
+ 0F73B54B1BA78350004B3EF4 /* Bindings */,
+ 0F87B61A1BACDA93004EC572 /* UIScriptContext.cpp */,
+ 0F87B61B1BACDA93004EC572 /* UIScriptContext.h */,
+ 0F87B61C1BACDA93004EC572 /* UIScriptController.cpp */,
+ 0F87B61D1BACDA93004EC572 /* UIScriptController.h */,
+ );
+ name = UIScriptContext;
+ sourceTree = "<group>";
+ };
+ 0F73B54B1BA78350004B3EF4 /* Bindings */ = {
+ isa = PBXGroup;
+ children = (
+ 0F87B6221BACDAA2004EC572 /* UIScriptController.idl */,
+ );
+ name = Bindings;
+ sourceTree = "<group>";
+ };
+ 0F73B54E1BA78954004B3EF4 /* Derived Sources */ = {
+ isa = PBXGroup;
+ children = (
+ 0F73B54F1BA78968004B3EF4 /* JSUIScriptController.cpp */,
+ 0F73B5501BA78968004B3EF4 /* JSUIScriptController.h */,
+ );
+ name = "Derived Sources";
+ sourceTree = "<group>";
+ };
0FEB909D1905A75D000FDBF3 /* cocoa */ = {
isa = PBXGroup;
children = (
0FEB90A21905BC6A000FDBF3 /* CrashReporterInfo.h */,
0FEB90A31905BC6A000FDBF3 /* CrashReporterInfo.mm */,
2DCE2CD11B84524500C7F832 /* TestControllerCocoa.mm */,
+ 0F87B6141BACC4B9004EC572 /* TestRunnerWKWebView.h */,
+ 0F87B6151BACC4B9004EC572 /* TestRunnerWKWebView.mm */,
);
name = cocoa;
sourceTree = "<group>";
2EE52CE11890A9A80010ED21 /* Frameworks */ = {
isa = PBXGroup;
children = (
+ 0F73B5571BA7929E004B3EF4 /* JavaScriptCore.framework */,
2EE52CE21890A9A80010ED21 /* Foundation.framework */,
2EE52CE41890A9A80010ED21 /* CoreGraphics.framework */,
2EE52CE61890A9A80010ED21 /* UIKit.framework */,
2EE52D121890A9FB0010ED21 /* ios */ = {
isa = PBXGroup;
children = (
- 0F831AE91BAB84F400F96CD8 /* Launch.storyboard */,
+ 0F87B6181BACC558004EC572 /* Launch.storyboard */,
2EE52CEB1890A9A80010ED21 /* InfoPlist.strings */,
2EE52D131890A9FB0010ED21 /* PlatformWebViewIOS.mm */,
2EE52D141890A9FB0010ED21 /* TestControllerIOS.mm */,
+ 0F73B55B1BA89042004B3EF4 /* UIScriptControllerIOS.mm */,
2EE52D151890A9FB0010ED21 /* WebArchiveDumpSupportIOS.mm */,
2EE52D161890A9FB0010ED21 /* mainIOS.mm */,
+ 0F831AE71BAB72D000F96CD8 /* Launch.storyboard */,
);
path = ios;
sourceTree = "<group>";
E1C642C217CBCC7300D66A3C /* PoseAsClass.h */,
E1C642C117CBCC7300D66A3C /* PoseAsClass.mm */,
BC8C795B11D2785D004535A1 /* TestControllerMac.mm */,
+ 0F87B6111BACAD6F004EC572 /* UIScriptControllerMac.mm */,
E132AA3917CD5F1000611DF0 /* WebKitTestRunnerDraggingInfo.h */,
E132AA3817CD5F1000611DF0 /* WebKitTestRunnerDraggingInfo.mm */,
E132AA3C17CE776F00611DF0 /* WebKitTestRunnerEvent.h */,
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
+ 0F73B5521BA78968004B3EF4 /* JSUIScriptController.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
files = (
2E34C90018B68808000067BB /* WebKitTestRunnerInjectedBundle.bundle in Resources */,
2EE52CED1890A9A80010ED21 /* InfoPlist.strings in Resources */,
- 0F831AEA1BAB84F400F96CD8 /* Launch.storyboard in Resources */,
+ 0F87B6191BACC558004EC572 /* Launch.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
5670B8281386FCA5002EB355 /* EventSenderProxy.mm in Sources */,
BC793400118F7C84005EA8E2 /* main.mm in Sources */,
E1C642C617CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm in Sources */,
+ 0F87B6131BACAD82004EC572 /* UIScriptControllerMac.mm in Sources */,
BC7934E811906846005EA8E2 /* PlatformWebViewMac.mm in Sources */,
BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,
E132AA3A17CD5F1000611DF0 /* WebKitTestRunnerDraggingInfo.mm in Sources */,
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 0F73B55A1BA792FF004B3EF4 /* JSWrapper.cpp in Sources */,
A18510441B9AE14A00744AEB /* WorkQueueManager.cpp in Sources */,
A185103F1B9AE12900744AEB /* GeolocationProviderMock.cpp in Sources */,
+ 0F73B55C1BA89042004B3EF4 /* UIScriptControllerIOS.mm in Sources */,
A185103C1B9AE0FE00744AEB /* Options.cpp in Sources */,
A18510431B9AE14500744AEB /* WebNotificationProvider.cpp in Sources */,
A18510411B9AE13800744AEB /* TestController.cpp in Sources */,
+ 0F87B6201BACDA93004EC572 /* UIScriptController.cpp in Sources */,
A18510421B9AE13E00744AEB /* TestInvocation.cpp in Sources */,
A18510401B9AE13100744AEB /* PixelDumpSupport.cpp in Sources */,
A185103D1B9AE10600744AEB /* TestInvocationCG.cpp in Sources */,
A185103A1B9AE0DA00744AEB /* CrashReporterInfo.mm in Sources */,
+ 0F73B5511BA78968004B3EF4 /* JSUIScriptController.cpp in Sources */,
+ 0F87B61E1BACDA93004EC572 /* UIScriptContext.cpp in Sources */,
A185103E1B9AE12200744AEB /* CyclicRedundancyCheck.cpp in Sources */,
+ 0F87B6171BACC4C0004EC572 /* TestRunnerWKWebView.mm in Sources */,
A185103B1B9AE0E200744AEB /* TestControllerCocoa.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
A115CCB81B9D769D00E89159 /* Production */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Production;
};
A185102D1B9ADE4800744AEB /* Build configuration list for PBXNativeTarget "WebKitTestRunner (Library)" */ = {
isa = XCConfigurationList;
#import "CrashReporterInfo.h"
#import "PlatformWebView.h"
#import "TestInvocation.h"
+#import "TestRunnerWKWebView.h"
#import <Foundation/Foundation.h>
#import <WebKit/WKContextConfigurationRef.h>
#import <WebKit/WKPreferencesRefPrivate.h>
--- /dev/null
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <WebKit/WebKit.h>
+
+#if WK_API_ENABLED
+
+@interface TestRunnerWKWebView : WKWebView
+
+#if PLATFORM(IOS)
+- (void)zoomToScale:(double)scale animated:(BOOL)animated completionHandler:(void (^)(void))completionHandler;
+- (void)onDidEndZooming:(void (^)(void))completionHandler;
+#endif
+
+@end
+
+#endif // #if WK_API_ENABLED
--- /dev/null
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "TestRunnerWKWebView.h"
+
+#import "WebKitTestRunnerDraggingInfo.h"
+#import <wtf/Assertions.h>
+#import <wtf/RetainPtr.h>
+
+@interface WKWebView ()
+
+#if PLATFORM(IOS)
+- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(nullable UIView *)view atScale:(CGFloat)scale;
+#endif
+
+@end
+
+#if WK_API_ENABLED
+
+@interface TestRunnerWKWebView ()
+@property (nonatomic, copy) void (^zoomCompletionHandler)(void);
+@end
+
+@implementation TestRunnerWKWebView
+
+#if PLATFORM(MAC)
+- (void)dragImage:(NSImage *)anImage at:(NSPoint)viewLocation offset:(NSSize)initialOffset event:(NSEvent *)event pasteboard:(NSPasteboard *)pboard source:(id)sourceObj slideBack:(BOOL)slideFlag
+{
+ RetainPtr<WebKitTestRunnerDraggingInfo> draggingInfo = adoptNS([[WebKitTestRunnerDraggingInfo alloc] initWithImage:anImage offset:initialOffset pasteboard:pboard source:sourceObj]);
+ [self draggingUpdated:draggingInfo.get()];
+}
+#endif
+
+#if PLATFORM(IOS)
+- (void)zoomToScale:(double)scale animated:(BOOL)animated completionHandler:(void (^)(void))completionHandler
+{
+ ASSERT(!self.zoomCompletionHandler);
+ self.zoomCompletionHandler = completionHandler;
+
+ [self.scrollView setZoomScale:scale animated:animated];
+}
+
+- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(nullable UIView *)view atScale:(CGFloat)scale
+{
+ [super scrollViewDidEndZooming:scrollView withView:view atScale:scale];
+
+ if (self.zoomCompletionHandler) {
+ self.zoomCompletionHandler();
+ self.zoomCompletionHandler = nullptr;
+ }
+}
+
+- (void)onDidEndZooming:(void (^)(void))completionHandler
+{
+ ASSERT(!self.zoomCompletionHandler);
+ self.zoomCompletionHandler = completionHandler;
+}
+#endif
+
+@end
+
+#endif // WK_API_ENABLED
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
-#include "PlatformWebView.h"
-#include "TestController.h"
+#import "config.h"
+#import "PlatformWebView.h"
+#import "TestController.h"
+#import "TestRunnerWKWebView.h"
#import <WebKit/WKImageCG.h>
#import <WebKit/WKPreferencesPrivate.h>
#import <WebKit/WKWebViewConfiguration.h>
, m_options(options)
{
CGRect rect = CGRectMake(0, 0, TestController::viewWidth, TestController::viewHeight);
- m_view = [[WKWebView alloc] initWithFrame:rect configuration:configuration];
+ m_view = [[TestRunnerWKWebView alloc] initWithFrame:rect configuration:configuration];
m_window = [[WebKitTestRunnerWindow alloc] initWithFrame:rect];
m_window.platformWebView = this;
--- /dev/null
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "UIScriptController.h"
+
+#if PLATFORM(IOS)
+
+#import "PlatformWebView.h"
+#import "TestController.h"
+#import "TestRunnerWKWebView.h"
+#import "UIScriptContext.h"
+#import <UIKit/UIKit.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/WebKit.h>
+
+namespace WTR {
+
+void UIScriptController::doAsyncTask(JSValueRef callback)
+{
+ unsigned callbackID = m_context.prepareForAsyncTask(callback);
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ m_context.asyncTaskComplete(callbackID);
+ });
+}
+
+void UIScriptController::zoomToScale(double scale, JSValueRef callback)
+{
+ TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+
+ unsigned callbackID = m_context.prepareForAsyncTask(callback);
+
+ [webView zoomToScale:scale animated:YES completionHandler:^{
+ m_context.asyncTaskComplete(callbackID);
+ }];
+}
+
+double UIScriptController::zoomScale() const
+{
+ TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+ return webView.scrollView.zoomScale;
+}
+
+double UIScriptController::minimumZoomScale() const
+{
+ TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+ return webView.scrollView.minimumZoomScale;
+}
+
+double UIScriptController::maximumZoomScale() const
+{
+ TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+ return webView.scrollView.maximumZoomScale;
+}
+
+JSObjectRef UIScriptController::contentVisibleRect() const
+{
+ TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+
+ CGRect contentVisibleRect = webView._contentVisibleRect;
+
+ WKRect wkRect = WKRectMake(contentVisibleRect.origin.x, contentVisibleRect.origin.y, contentVisibleRect.size.width, contentVisibleRect.size.height);
+ return m_context.objectFromRect(wkRect);
+}
+
+}
+
+#endif // PLATFORM(IOS)
#import "PlatformWebView.h"
#import "StringFunctions.h"
#import "TestController.h"
+#import "TestRunnerWKWebView.h"
#import <Carbon/Carbon.h>
#import <WebKit/WKString.h>
#import <WebKit/WKPagePrivate.h>
#import "PlatformWebView.h"
#import "TestController.h"
+#import "TestRunnerWKWebView.h"
#import "WebKitTestRunnerDraggingInfo.h"
#import <WebKit/WKImageCG.h>
#import <WebKit/WKPreferencesPrivate.h>
@property (nonatomic, assign) PlatformWebView* platformWebView;
@end
-#if WK_API_ENABLED
-@interface TestRunnerWKWebView : WKWebView
-@end
-
-@implementation TestRunnerWKWebView
-
-- (void)dragImage:(NSImage *)anImage at:(NSPoint)viewLocation offset:(NSSize)initialOffset event:(NSEvent *)event pasteboard:(NSPasteboard *)pboard source:(id)sourceObj slideBack:(BOOL)slideFlag
-{
- RetainPtr<WebKitTestRunnerDraggingInfo> draggingInfo = adoptNS([[WebKitTestRunnerDraggingInfo alloc] initWithImage:anImage offset:initialOffset pasteboard:pboard source:sourceObj]);
- [self draggingUpdated:draggingInfo.get()];
-}
-
-@end
-#endif
-
@implementation WebKitTestRunnerWindow
@synthesize platformWebView = _platformWebView;
#import "PlatformWebView.h"
#import "PoseAsClass.h"
#import "TestInvocation.h"
+#import "TestRunnerWKWebView.h"
#import "WebKitTestRunnerPasteboard.h"
#import <WebKit/WKContextPrivate.h>
#import <WebKit/WKPageGroup.h>
--- /dev/null
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "UIScriptController.h"
+
+#import "UIScriptContext.h"
+
+namespace WTR {
+
+void UIScriptController::doAsyncTask(JSValueRef callback)
+{
+ unsigned callbackID = m_context.prepareForAsyncTask(callback);
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ m_context.asyncTaskComplete(callbackID);
+ });
+}
+
+}
* THE POSSIBILITY OF SUCH DAMAGE.
*/
+#if PLATFORM(MAC)
+
@interface WebKitTestRunnerDraggingInfo : NSObject <NSDraggingInfo> {
@private
NSSize _offset;
- (void)resetSpringLoading;
#endif
@end
+
+#endif // PLATFORM(MAC)