Title: [188807] trunk
Revision
188807
Author
[email protected]
Date
2015-08-21 17:34:31 -0700 (Fri, 21 Aug 2015)

Log Message

WebKitTestRunner should use WKWebView on OS X and iOS
https://bugs.webkit.org/show_bug.cgi?id=143743
<rdar://problem/16947123>

Reviewed by Anders Carlsson.
Patch by Enrica Casucci and myself.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _windowOcclusionDetectionEnabled]):
(-[WKWebView _setWindowOcclusionDetectionEnabled:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
Add SPI to disable window occlusion detection, for WebKitTestRunner's use.

* Shared/WebPreferencesDefinitions.h:
Remove a completely unused WebPreference. It is a WebCore Setting,
but in the API it's exposed as a WKPage setter and WKView and WKWebView property
instead of as a WKPreference, so there's no need for the WebPreference.

* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageAddUserScript):
(WKBundlePageAddUserStyleSheet):
(WKBundlePageRemoveAllUserContent):
* WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::addUserScript):
(WebKit::WebPage::addUserStyleSheet):
(WebKit::WebPage::removeAllUserContent):
* WebProcess/WebPage/WebPage.h:
Add WKBundlePage functions for user script and style sheet manipulation.
These use the WebPage's WebUserContentController instead of the WebPageGroupProxy's
(used by the WKBundle functions), so they work correctly with the modern API.

* WebKitTestRunner/PlatformWebView.h:
(WTR::PlatformWebView::windowSnapshotEnabled): Deleted.
Add a PlatformWebView constructor that takes a WKWebViewConfiguration
instead of WKContext and WKPageGroup.

Remove the unused, always-true windowSnapshotEnabled().
While technically some platforms don't have window snapshotting,
they just return null instead of implementing windowSnapshotEnabled().

* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::createOtherPage):
(WTR::TestController::initialize):
(WTR::TestController::createWebViewWithOptions):
Delegate to the various platforms for creating PlatformWebView instances,
for creating WKContexts, and for accessing WKPreferences,
so that they can do special things (like, use WKWebView instead!).

(WTR::TestController::resetPreferencesToConsistentValues):
Make explicit WebKitTestRunner's desired default for two preferences
which have differing defaults between the antique and modern API,
for consistency's sake.

(WTR::TestController::resetStateToConsistentValues):
Add platformResetStateToConsistentValues.

* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::dumpResults):
Adjust to the aforementioned removal of windowSnapshotEnabled().

* WebKitTestRunner/ios/TestControllerCocoa.mm:
(WTR::TestController::platformResetStateToConsistentValues):
(WTR::TestController::platformPreferences):
(WTR::TestController::platformCreateWebView):
(WTR::TestController::platformCreateOtherPage):
(WTR::TestController::platformInitializeConfiguration):
Implement the new platform functions for the Modern WebKit2 API,
in a new TestControllerCocoa file that is shared between iOS and Mac.

For platformMaybeCreateContext, use the trick that we know we can cast
the WKProcessPool to a WKContextRef to retrieve a WKContextRef from
WKWebView's configuration.

Ditto for WKPreferencesRef and WKPreferences.

Remove user content filters on the WKWebView's userContentController.

* WebKitTestRunner/mac/TestControllerMac.mm:
* WebKitTestRunner/ios/TestControllerIOS.mm:
Move code into TestControllerCocoa.

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::beginTesting):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::addUserScript):
(WTR::TestRunner::addUserStyleSheet):
Adopt WKBundlePage API for user scripts/sheets.

* WebKitTestRunner/ios/PlatformWebViewIOS.mm:
* WebKitTestRunner/mac/PlatformWebViewMac.mm:
Make and keep a WKWebView instead of a WKView.

* WebKitTestRunner/mac/EventSenderProxy.mm:
(WTR::EventSenderProxy::mouseUp):
(WTR::EventSenderProxy::mouseMoveTo):
Reach inside the WKWebView to the WKView when dispatching events.
This is fairly ugly and we should come up with a better solution.
Also, fix some flipping and style errors.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (188806 => 188807)


--- trunk/Source/WebKit2/ChangeLog	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Source/WebKit2/ChangeLog	2015-08-22 00:34:31 UTC (rev 188807)
@@ -1,3 +1,37 @@
+2015-08-21  Timothy Horton  <[email protected]>
+
+        WebKitTestRunner should use WKWebView on OS X and iOS
+        https://bugs.webkit.org/show_bug.cgi?id=143743
+        <rdar://problem/16947123>
+
+        Reviewed by Anders Carlsson.
+        Patch by Enrica Casucci and myself.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _windowOcclusionDetectionEnabled]):
+        (-[WKWebView _setWindowOcclusionDetectionEnabled:]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        Add SPI to disable window occlusion detection, for WebKitTestRunner's use.
+
+        * Shared/WebPreferencesDefinitions.h:
+        Remove a completely unused WebPreference. It is a WebCore Setting,
+        but in the API it's exposed as a WKPage setter and WKView and WKWebView property
+        instead of as a WKPreference, so there's no need for the WebPreference.
+
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+        (WKBundlePageAddUserScript):
+        (WKBundlePageAddUserStyleSheet):
+        (WKBundlePageRemoveAllUserContent):
+        * WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::addUserScript):
+        (WebKit::WebPage::addUserStyleSheet):
+        (WebKit::WebPage::removeAllUserContent):
+        * WebProcess/WebPage/WebPage.h:
+        Add WKBundlePage functions for user script and style sheet manipulation.
+        These use the WebPage's WebUserContentController instead of the WebPageGroupProxy's
+        (used by the WKBundle functions), so they work correctly with the modern API.
+
 2015-08-21  Alexey Proskuryakov  <[email protected]>
 
         Improve how UI events are dispatched by WebKitTestRunner

Modified: trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h (188806 => 188807)


--- trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h	2015-08-22 00:34:31 UTC (rev 188807)
@@ -180,7 +180,6 @@
     macro(ThreadedScrollingEnabled, threadedScrollingEnabled, Bool, bool, true) \
     macro(SimpleLineLayoutEnabled, simpleLineLayoutEnabled, Bool, bool, true) \
     macro(SubpixelCSSOMElementMetricsEnabled, subpixelCSSOMElementMetricsEnabled, Bool, bool, false) \
-    macro(BackgroundShouldExtendBeyondPage, backgroundShouldExtendBeyondPage, Bool, bool, false) \
     macro(MediaStreamEnabled, mediaStreamEnabled, Bool, bool, false) \
     macro(UseLegacyTextAlignPositionedElementBehavior, useLegacyTextAlignPositionedElementBehavior, Bool, bool, false) \
     macro(SpatialNavigationEnabled, spatialNavigationEnabled, Bool, bool, false) \

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (188806 => 188807)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-08-22 00:34:31 UTC (rev 188807)
@@ -3083,6 +3083,16 @@
     return [_wkView _topContentInset];
 }
 
+- (BOOL)_windowOcclusionDetectionEnabled
+{
+    return [_wkView windowOcclusionDetectionEnabled];
+}
+
+- (void)_setWindowOcclusionDetectionEnabled:(BOOL)flag
+{
+    [_wkView setWindowOcclusionDetectionEnabled:flag];
+}
+
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
 
 - (void)_setAutomaticallyAdjustsContentInsets:(BOOL)automaticallyAdjustsContentInsets

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (188806 => 188807)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2015-08-22 00:34:31 UTC (rev 188807)
@@ -173,6 +173,9 @@
 
 // Default value is 0. A value of 0 means the window's backing scale factor will be used and automatically update when the window moves screens.
 @property (nonatomic, setter=_setOverrideDeviceScaleFactor:) CGFloat _overrideDeviceScaleFactor WK_AVAILABLE(WK_MAC_TBA, NA);
+
+@property (nonatomic, setter=_setWindowOcclusionDetectionEnabled:) BOOL _windowOcclusionDetectionEnabled;
+
 #endif
 
 - (void)_killWebContentProcessAndResetState;

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp (188806 => 188807)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp	2015-08-22 00:34:31 UTC (rev 188807)
@@ -615,3 +615,18 @@
     if (returnDataRef)
         *returnDataRef = toAPI(returnData.release().leakRef());
 }
+
+void WKBundlePageAddUserScript(WKBundlePageRef pageRef, WKStringRef source, _WKUserScriptInjectionTime injectionTime, WKUserContentInjectedFrames injectedFrames)
+{
+    toImpl(pageRef)->addUserScript(toWTFString(source), toUserContentInjectedFrames(injectedFrames), toUserScriptInjectionTime(injectionTime));
+}
+
+void WKBundlePageAddUserStyleSheet(WKBundlePageRef pageRef, WKStringRef source, WKUserContentInjectedFrames injectedFrames)
+{
+    toImpl(pageRef)->addUserStyleSheet(toWTFString(source), toUserContentInjectedFrames(injectedFrames));
+}
+
+void WKBundlePageRemoveAllUserContent(WKBundlePageRef pageRef)
+{
+    toImpl(pageRef)->removeAllUserContent();
+}

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h (188806 => 188807)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h	2015-08-22 00:34:31 UTC (rev 188807)
@@ -29,6 +29,8 @@
 #include <WebKit/WKBase.h>
 #include <WebKit/WKEvent.h>
 #include <WebKit/WKGeometry.h>
+#include <WebKit/WKUserContentInjectedFrames.h>
+#include <WebKit/WKUserScriptInjectionTime.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -93,6 +95,11 @@
 WK_EXPORT WKRenderingSuppressionToken WKBundlePageExtendIncrementalRenderingSuppression(WKBundlePageRef);
 WK_EXPORT void WKBundlePageStopExtendingIncrementalRenderingSuppression(WKBundlePageRef, WKRenderingSuppressionToken);
 
+// UserContent API (compatible with Modern API, for WKTR)
+WK_EXPORT void WKBundlePageAddUserScript(WKBundlePageRef page, WKStringRef source, _WKUserScriptInjectionTime injectionTime, WKUserContentInjectedFrames injectedFrames);
+WK_EXPORT void WKBundlePageAddUserStyleSheet(WKBundlePageRef page, WKStringRef source, WKUserContentInjectedFrames injectedFrames);
+WK_EXPORT void WKBundlePageRemoveAllUserContent(WKBundlePageRef page);
+
 #if TARGET_OS_IPHONE
 WK_EXPORT void WKBundlePageSetUseTestingViewportConfiguration(WKBundlePageRef, bool);
 #endif

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (188806 => 188807)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2015-08-22 00:34:31 UTC (rev 188807)
@@ -5006,4 +5006,30 @@
     send(Messages::WebPageProxy::ImageOrMediaDocumentSizeChanged(newSize));
 }
 
+void WebPage::addUserScript(const String& source, WebCore::UserContentInjectedFrames injectedFrames, WebCore::UserScriptInjectionTime injectionTime)
+{
+    ASSERT(m_userContentController);
+
+    WebCore::UserScript userScript(source, WebCore::blankURL(), Vector<String>(), Vector<String>(), injectionTime, injectedFrames);
+
+    m_userContentController->userContentController().addUserScript(mainThreadNormalWorld(), std::make_unique<WebCore::UserScript>(userScript));
+}
+
+void WebPage::addUserStyleSheet(const String& source, WebCore::UserContentInjectedFrames injectedFrames)
+{
+    ASSERT(m_userContentController);
+
+    WebCore::UserStyleSheet userStyleSheet(source, WebCore::blankURL(), Vector<String>(), Vector<String>(), injectedFrames, UserStyleUserLevel);
+
+    m_userContentController->userContentController().addUserStyleSheet(mainThreadNormalWorld(), std::make_unique<WebCore::UserStyleSheet>(userStyleSheet), InjectInExistingDocuments);
+}
+
+void WebPage::removeAllUserContent()
+{
+    if (!m_userContentController)
+        return;
+
+    m_userContentController->userContentController().removeAllUserContent();
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (188806 => 188807)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2015-08-22 00:34:31 UTC (rev 188807)
@@ -63,6 +63,8 @@
 #include <WebCore/TextChecking.h>
 #include <WebCore/TextIndicator.h>
 #include <WebCore/UserActivity.h>
+#include <WebCore/UserContentTypes.h>
+#include <WebCore/UserScriptTypes.h>
 #include <WebCore/ViewState.h>
 #include <WebCore/ViewportConfiguration.h>
 #include <WebCore/WebCoreKeyboardUIMode.h>
@@ -914,6 +916,10 @@
 #endif
 #endif
 
+    void addUserScript(const String& source, WebCore::UserContentInjectedFrames, WebCore::UserScriptInjectionTime);
+    void addUserStyleSheet(const String& source, WebCore::UserContentInjectedFrames);
+    void removeAllUserContent();
+
 private:
     WebPage(uint64_t pageID, const WebPageCreationParameters&);
 

Modified: trunk/Tools/ChangeLog (188806 => 188807)


--- trunk/Tools/ChangeLog	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Tools/ChangeLog	2015-08-22 00:34:31 UTC (rev 188807)
@@ -1,3 +1,81 @@
+2015-08-21  Timothy Horton  <[email protected]>
+
+        WebKitTestRunner should use WKWebView on OS X and iOS
+        https://bugs.webkit.org/show_bug.cgi?id=143743
+        <rdar://problem/16947123>
+
+        Reviewed by Anders Carlsson.
+        Patch by Enrica Casucci and myself.
+
+        * WebKitTestRunner/PlatformWebView.h:
+        (WTR::PlatformWebView::windowSnapshotEnabled): Deleted.
+        Add a PlatformWebView constructor that takes a WKWebViewConfiguration
+        instead of WKContext and WKPageGroup.
+
+        Remove the unused, always-true windowSnapshotEnabled().
+        While technically some platforms don't have window snapshotting,
+        they just return null instead of implementing windowSnapshotEnabled().
+
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::createOtherPage):
+        (WTR::TestController::initialize):
+        (WTR::TestController::createWebViewWithOptions):
+        Delegate to the various platforms for creating PlatformWebView instances,
+        for creating WKContexts, and for accessing WKPreferences,
+        so that they can do special things (like, use WKWebView instead!).
+
+        (WTR::TestController::resetPreferencesToConsistentValues):
+        Make explicit WebKitTestRunner's desired default for two preferences
+        which have differing defaults between the antique and modern API,
+        for consistency's sake.
+
+        (WTR::TestController::resetStateToConsistentValues):
+        Add platformResetStateToConsistentValues.
+
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::dumpResults):
+        Adjust to the aforementioned removal of windowSnapshotEnabled().
+
+        * WebKitTestRunner/ios/TestControllerCocoa.mm:
+        (WTR::TestController::platformResetStateToConsistentValues):
+        (WTR::TestController::platformPreferences):
+        (WTR::TestController::platformCreateWebView):
+        (WTR::TestController::platformCreateOtherPage):
+        (WTR::TestController::platformInitializeConfiguration):
+        Implement the new platform functions for the Modern WebKit2 API,
+        in a new TestControllerCocoa file that is shared between iOS and Mac.
+        
+        For platformMaybeCreateContext, use the trick that we know we can cast
+        the WKProcessPool to a WKContextRef to retrieve a WKContextRef from
+        WKWebView's configuration.
+
+        Ditto for WKPreferencesRef and WKPreferences.
+
+        Remove user content filters on the WKWebView's userContentController.
+
+        * WebKitTestRunner/mac/TestControllerMac.mm:
+        * WebKitTestRunner/ios/TestControllerIOS.mm:
+        Move code into TestControllerCocoa.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::beginTesting):
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::addUserScript):
+        (WTR::TestRunner::addUserStyleSheet):
+        Adopt WKBundlePage API for user scripts/sheets.
+
+        * WebKitTestRunner/ios/PlatformWebViewIOS.mm:
+        * WebKitTestRunner/mac/PlatformWebViewMac.mm:
+        Make and keep a WKWebView instead of a WKView.
+        
+        * WebKitTestRunner/mac/EventSenderProxy.mm:
+        (WTR::EventSenderProxy::mouseUp):
+        (WTR::EventSenderProxy::mouseMoveTo):
+        Reach inside the WKWebView to the WKView when dispatching events.
+        This is fairly ugly and we should come up with a better solution.
+        Also, fix some flipping and style errors.
+
 2015-08-21  Alexey Proskuryakov  <[email protected]>
 
         Improve how UI events are dispatched by WebKitTestRunner

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (188806 => 188807)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2015-08-22 00:34:31 UTC (rev 188807)
@@ -261,7 +261,7 @@
     WKBundleSetPluginsEnabled(m_bundle, m_pageGroup, true);
     WKBundleSetPopupBlockingEnabled(m_bundle, m_pageGroup, false);
 
-    WKBundleRemoveAllUserContent(m_bundle, m_pageGroup);
+    WKBundlePageRemoveAllUserContent(page()->page());
 
     m_testRunner->setShouldDumpFrameLoadCallbacks(booleanForKey(settings, "DumpFrameLoadDelegates"));
     m_testRunner->setUserStyleSheetEnabled(false);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (188806 => 188807)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2015-08-22 00:34:31 UTC (rev 188807)
@@ -172,10 +172,8 @@
 void TestRunner::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
 {
     WKRetainPtr<WKStringRef> sourceWK = toWK(source);
-    WKRetainPtr<WKBundleScriptWorldRef> scriptWorld(AdoptWK, WKBundleScriptWorldCreateWorld());
 
-    auto& injectedBundle = InjectedBundle::singleton();
-    WKBundleAddUserScript(injectedBundle.bundle(), injectedBundle.pageGroup(), scriptWorld.get(), sourceWK.get(), 0, 0, 0,
+    WKBundlePageAddUserScript(InjectedBundle::singleton().page()->page(), sourceWK.get(),
         (runAtStart ? kWKInjectAtDocumentStart : kWKInjectAtDocumentEnd),
         (allFrames ? kWKInjectInAllFrames : kWKInjectInTopFrameOnly));
 }
@@ -183,10 +181,8 @@
 void TestRunner::addUserStyleSheet(JSStringRef source, bool allFrames)
 {
     WKRetainPtr<WKStringRef> sourceWK = toWK(source);
-    WKRetainPtr<WKBundleScriptWorldRef> scriptWorld(AdoptWK, WKBundleScriptWorldCreateWorld());
 
-    auto& injectedBundle = InjectedBundle::singleton();
-    WKBundleAddUserStyleSheet(injectedBundle.bundle(), injectedBundle.pageGroup(), scriptWorld.get(), sourceWK.get(), 0, 0, 0,
+    WKBundlePageAddUserStyleSheet(InjectedBundle::singleton().page()->page(), sourceWK.get(),
         (allFrames ? kWKInjectInAllFrames : kWKInjectInTopFrameOnly));
 }
 

Modified: trunk/Tools/WebKitTestRunner/PlatformWebView.h (188806 => 188807)


--- trunk/Tools/WebKitTestRunner/PlatformWebView.h	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Tools/WebKitTestRunner/PlatformWebView.h	2015-08-22 00:34:31 UTC (rev 188807)
@@ -29,15 +29,14 @@
 #include "ViewOptions.h"
 #include <WebKit/WKRetainPtr.h>
 
-#if defined(__APPLE__) && __APPLE__
-#ifdef __OBJC__
-@class WKView;
-@class WebKitTestRunnerWindow;
-#else
-class WKView;
-class WebKitTestRunnerWindow;
-#endif
-typedef WKView* PlatformWKView;
+#if PLATFORM(COCOA)
+OBJC_CLASS NSView;
+OBJC_CLASS UIView;
+OBJC_CLASS WKWebView;
+OBJC_CLASS WKWebViewConfiguration;
+OBJC_CLASS WebKitTestRunnerWindow;
+
+typedef WKWebView* PlatformWKView;
 typedef WebKitTestRunnerWindow* PlatformWindow;
 #elif defined(BUILDING_GTK__)
 typedef struct _GtkWidget GtkWidget;
@@ -52,7 +51,11 @@
 
 class PlatformWebView {
 public:
+#if PLATFORM(COCOA)
+    PlatformWebView(WKWebViewConfiguration*, const ViewOptions&);
+#else
     PlatformWebView(WKPageConfigurationRef, const ViewOptions&);
+#endif
     ~PlatformWebView();
 
     WKPageRef page();
@@ -61,9 +64,6 @@
     void resizeTo(unsigned width, unsigned height);
     void focus();
 
-    // Window snapshot is always enabled by default on all other platform.
-    static bool windowSnapshotEnabled() { return true; }
-
     WKRect windowFrame();
     void setWindowFrame(WKRect);
 

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (188806 => 188807)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2015-08-22 00:34:31 UTC (rev 188807)
@@ -197,11 +197,11 @@
     TestController::singleton().handleUserMediaPermissionRequest(permissionRequest);
 }
 
-WKPageRef TestController::createOtherPage(WKPageRef oldPpage, WKPageConfigurationRef configuration, WKNavigationActionRef navigationAction, WKWindowFeaturesRef windowFeatures, const void *clientInfo)
+WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKPageConfigurationRef configuration, WKNavigationActionRef navigationAction, WKWindowFeaturesRef windowFeatures, const void *clientInfo)
 {
     PlatformWebView* parentView = static_cast<PlatformWebView*>(const_cast<void*>(clientInfo));
 
-    PlatformWebView* view = new PlatformWebView(configuration, parentView->options());
+    PlatformWebView* view = platformCreateOtherPage(parentView, configuration, parentView->options());
     WKPageRef newPage = view->page();
 
     view->resizeTo(800, 600);
@@ -310,7 +310,6 @@
     return platformLibraryPathForTesting();
 }
 
-
 void TestController::initialize(int argc, const char* argv[])
 {
     platformInitialize();
@@ -372,8 +371,8 @@
         WKContextConfigurationSetWebSQLDatabaseDirectory(configuration.get(), toWK(temporaryFolder + separator + "Databases" + separator + "WebSQL").get());
         WKContextConfigurationSetMediaKeysStorageDirectory(configuration.get(), toWK(temporaryFolder + separator + "MediaKeys").get());
     }
+    m_context = platformAdjustContext(adoptWK(WKContextCreateWithConfiguration(configuration.get())).get(), configuration.get());
 
-    m_context = adoptWK(WKContextCreateWithConfiguration(configuration.get()));
     m_geolocationProvider = std::make_unique<GeolocationProviderMock>(m_context.get());
 
 #if PLATFORM(EFL)
@@ -435,6 +434,7 @@
     m_configuration = adoptWK(WKPageConfigurationCreate());
     WKPageConfigurationSetContext(m_configuration.get(), m_context.get());
     WKPageConfigurationSetPageGroup(m_configuration.get(), m_pageGroup.get());
+    WKPageConfigurationSetUserContentController(m_configuration.get(), adoptWK(WKUserContentControllerCreate()).get());
 
     // Some preferences (notably mock scroll bars setting) currently cannot be re-applied to an existing view, so we need to set them now.
     resetPreferencesToConsistentValues();
@@ -442,7 +442,7 @@
 
 void TestController::createWebViewWithOptions(const ViewOptions& options)
 {
-    m_mainWebView = std::make_unique<PlatformWebView>(m_configuration.get(), options);
+    platformCreateWebView(m_configuration.get(), options);
     WKPageUIClientV6 pageUIClient = {
         { 6, m_mainWebView.get() },
         0, // createNewPage_deprecatedForUseWithV0
@@ -568,7 +568,7 @@
 void TestController::resetPreferencesToConsistentValues()
 {
     // Reset preferences
-    WKPreferencesRef preferences = WKPageGroupGetPreferences(m_pageGroup.get());
+    WKPreferencesRef preferences = platformPreferences();
     WKPreferencesResetTestRunnerOverrides(preferences);
     WKPreferencesSetPageVisibilityBasedProcessSuppressionEnabled(preferences, false);
     WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true);
@@ -622,6 +622,8 @@
     WKPreferencesSetHiddenPageCSSAnimationSuspensionEnabled(preferences, false);
 
     WKPreferencesSetAcceleratedDrawingEnabled(preferences, m_shouldUseAcceleratedDrawing);
+    // FIXME: We should be testing the default.
+    WKPreferencesSetStorageBlockingPolicy(preferences, kWKAllowAllStorage);
 
     WKCookieManagerDeleteAllCookies(WKContextGetCookieManager(m_context.get()));
 
@@ -634,6 +636,11 @@
 
     m_beforeUnloadReturnValue = true;
 
+    // This setting differs between the antique and modern Mac WebKit2 API.
+    // For now, maintain the antique behavior, because some tests depend on it!
+    // FIXME: We should be testing the default.
+    WKPageSetBackgroundExtendsBeyondPage(m_mainWebView->page(), false);
+
     WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("Reset"));
     WKRetainPtr<WKMutableDictionaryRef> resetMessageBody = adoptWK(WKMutableDictionaryCreate());
 
@@ -668,7 +675,7 @@
     WKTextCheckerContinuousSpellCheckingEnabledStateChanged(true);
 #endif
 
-    // in the case that a test using the chrome input field failed, be sure to clean up for the next test
+    // In the case that a test using the chrome input field failed, be sure to clean up for the next test.
     m_mainWebView->removeChromeInputField();
     m_mainWebView->focus();
 
@@ -710,10 +717,10 @@
 
     m_shouldLogHistoryClientCallbacks = false;
 
-    WKPageGroupRemoveAllUserContentFilters(WKPageGetPageGroup(m_mainWebView->page()));
-
     setHidden(false);
 
+    platformResetStateToConsistentValues();
+
     // Reset main page back to about:blank
     m_doneResetting = false;
 
@@ -1593,4 +1600,36 @@
     m_currentInvocation->outputText(String::format("WebView updated the title for history URL \"%s\" to \"%s\".\n", toSTD(urlStringWK).c_str(), toSTD(title).c_str()));
 }
 
+#if !PLATFORM(COCOA)
+void TestController::platformWillRunTest(const TestInvocation&)
+{
+}
+
+WKPreferencesRef TestController::platformPreferences()
+{
+    WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageCopyPageConfiguration(m_mainWebView->page())); 
+    return WKPageConfigurationGetPreferences(configuration.get());
+}
+
+void TestController::platformCreateWebView(WKPageConfigurationRef configuration, const ViewOptions& options)
+{
+    m_mainWebView = std::make_unique<PlatformWebView>(configuration, options);
+}
+
+PlatformWebView* TestController::platformCreateOtherPage(PlatformWebView* parentView, WKPageConfigurationRef configuration, const ViewOptions& options)
+{
+    return new PlatformWebView(configuration, options);
+}
+
+WKContextRef TestController::platformAdjustContext(WKContextRef context, WKContextConfigurationRef contextConfiguration)
+{
+    return context;
+}
+
+void TestController::platformResetStateToConsistentValues()
+{
+
+}
+#endif
+
 } // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/TestController.h (188806 => 188807)


--- trunk/Tools/WebKitTestRunner/TestController.h	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Tools/WebKitTestRunner/TestController.h	2015-08-22 00:34:31 UTC (rev 188807)
@@ -34,6 +34,8 @@
 #include <vector>
 #include <wtf/Vector.h>
 
+OBJC_CLASS WKWebViewConfiguration;
+
 namespace WTR {
 
 class TestInvocation;
@@ -132,12 +134,17 @@
 
     void platformInitialize();
     void platformDestroy();
+    WKContextRef platformAdjustContext(WKContextRef, WKContextConfigurationRef);
     void platformInitializeContext();
+    void platformCreateWebView(WKPageConfigurationRef, const ViewOptions&);
+    static PlatformWebView* platformCreateOtherPage(PlatformWebView* parentView, WKPageConfigurationRef, const ViewOptions&);
     void platformResetPreferencesToConsistentValues();
+    void platformResetStateToConsistentValues();
     void platformConfigureViewForTest(const TestInvocation&);
     void platformWillRunTest(const TestInvocation&);
     void platformRunUntil(bool& done, double timeout);
     void platformDidCommitLoadForFrame(WKPageRef, WKFrameRef);
+    WKPreferencesRef platformPreferences();
     void initializeInjectedBundlePath();
     void initializeTestPluginDirectory();
 

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (188806 => 188807)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2015-08-22 00:34:31 UTC (rev 188807)
@@ -268,15 +268,13 @@
         dumpAudio(m_audioResult.get());
 
     if (m_dumpPixels && m_pixelResult) {
-        if (PlatformWebView::windowSnapshotEnabled()) {
-            m_gotRepaint = false;
-            WKPageForceRepaint(TestController::singleton().mainWebView()->page(), this, TestInvocation::forceRepaintDoneCallback);
-            TestController::singleton().runUntil(m_gotRepaint, TestController::shortTimeout);
-            if (!m_gotRepaint) {
-                m_errorMessage = "Timed out waiting for pre-pixel dump repaint\n";
-                m_webProcessIsUnresponsive = true;
-                return;
-            }
+        m_gotRepaint = false;
+        WKPageForceRepaint(TestController::singleton().mainWebView()->page(), this, TestInvocation::forceRepaintDoneCallback);
+        TestController::singleton().runUntil(m_gotRepaint, TestController::shortTimeout);
+        if (!m_gotRepaint) {
+            m_errorMessage = "Timed out waiting for pre-pixel dump repaint\n";
+            m_webProcessIsUnresponsive = true;
+            return;
         }
         dumpPixelsAndCompareWithExpected(m_pixelResult.get(), m_repaintRects.get());
     }

Modified: trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj (188806 => 188807)


--- trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2015-08-22 00:34:31 UTC (rev 188807)
@@ -40,6 +40,8 @@
 		29A8FCDD145F0337009045A6 /* JSAccessibilityTextMarkerRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29A8FCE1345E7021006AA5A6 /* JSAccessibilityTextMarkerRange.cpp */; };
 		29A8FCE2145F037B009045A6 /* AccessibilityTextMarkerRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29A8FCE1145F037B009045A6 /* AccessibilityTextMarkerRange.cpp */; };
 		29A8FCE5145F0464009045A6 /* AccessibilityTextMarkerRangeMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29A8FCE4145F0464009045A6 /* AccessibilityTextMarkerRangeMac.mm */; };
+		2DCE2CD31B8452F800C7F832 /* TestControllerCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DCE2CD11B84524500C7F832 /* TestControllerCocoa.mm */; };
+		2DCE2CD41B84530A00C7F832 /* TestControllerCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DCE2CD11B84524500C7F832 /* TestControllerCocoa.mm */; };
 		2E34C90018B68808000067BB /* WebKitTestRunnerInjectedBundle.bundle in Resources */ = {isa = PBXBuildFile; fileRef = BC25186211D15D54002EBC01 /* WebKitTestRunnerInjectedBundle.bundle */; };
 		2E63ED8A1891AD7E002A7AFC /* AccessibilityControllerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E63ED751891ACE9002A7AFC /* AccessibilityControllerIOS.mm */; };
 		2E63ED8B1891AD7E002A7AFC /* AccessibilityTextMarkerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E63ED771891ACE9002A7AFC /* AccessibilityTextMarkerIOS.mm */; };
@@ -171,6 +173,7 @@
 		29A8FCE1345E7021006AA5A6 /* JSAccessibilityTextMarkerRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSAccessibilityTextMarkerRange.cpp; path = DerivedSources/WebKitTestRunner/JSAccessibilityTextMarkerRange.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
 		29A8FCE1345E7021006AA5A7 /* JSAccessibilityTextMarkerRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSAccessibilityTextMarkerRange.h; path = DerivedSources/WebKitTestRunner/JSAccessibilityTextMarkerRange.h; sourceTree = BUILT_PRODUCTS_DIR; };
 		29A8FCE4145F0464009045A6 /* AccessibilityTextMarkerRangeMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AccessibilityTextMarkerRangeMac.mm; sourceTree = "<group>"; };
+		2DCE2CD11B84524500C7F832 /* TestControllerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestControllerCocoa.mm; path = cocoa/TestControllerCocoa.mm; sourceTree = "<group>"; };
 		2E63ED751891ACE9002A7AFC /* AccessibilityControllerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AccessibilityControllerIOS.mm; sourceTree = "<group>"; };
 		2E63ED761891ACE9002A7AFC /* AccessibilityNotificationHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityNotificationHandler.h; sourceTree = "<group>"; };
 		2E63ED771891ACE9002A7AFC /* AccessibilityTextMarkerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AccessibilityTextMarkerIOS.mm; sourceTree = "<group>"; };
@@ -397,6 +400,7 @@
 			children = (
 				0FEB90A21905BC6A000FDBF3 /* CrashReporterInfo.h */,
 				0FEB90A31905BC6A000FDBF3 /* CrashReporterInfo.mm */,
+				2DCE2CD11B84524500C7F832 /* TestControllerCocoa.mm */,
 			);
 			name = cocoa;
 			sourceTree = "<group>";
@@ -786,6 +790,7 @@
 				2E63ED971891ADC7002A7AFC /* PixelDumpSupport.cpp in Sources */,
 				2E63ED981891ADC7002A7AFC /* TestController.cpp in Sources */,
 				2E63ED921891ADAD002A7AFC /* TestControllerIOS.mm in Sources */,
+				2DCE2CD31B8452F800C7F832 /* TestControllerCocoa.mm in Sources */,
 				0FEB90A81905C537000FDBF3 /* CrashReporterInfo.mm in Sources */,
 				2E63ED991891ADC7002A7AFC /* TestInvocation.cpp in Sources */,
 				2E63EDA51891BD8E002A7AFC /* TestInvocationCG.cpp in Sources */,
@@ -805,6 +810,7 @@
 				E1C642C317CBCC7300D66A3C /* PoseAsClass.mm in Sources */,
 				E132AA3D17CE776F00611DF0 /* WebKitTestRunnerEvent.mm in Sources */,
 				5670B8281386FCA5002EB355 /* EventSenderProxy.mm in Sources */,
+				2DCE2CD41B84530A00C7F832 /* TestControllerCocoa.mm in Sources */,
 				26D758E7160BECDD00268472 /* GeolocationProviderMock.cpp in Sources */,
 				BC793400118F7C84005EA8E2 /* main.mm in Sources */,
 				5322FB4613FDA0EA0041ABCC /* PixelDumpSupport.cpp in Sources */,

Added: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (0 => 188807)


--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	                        (rev 0)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2015-08-22 00:34:31 UTC (rev 188807)
@@ -0,0 +1,110 @@
+/*
+ * 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 "TestController.h"
+
+#import "CrashReporterInfo.h"
+#import "PlatformWebView.h"
+#import "TestInvocation.h"
+#import <Foundation/Foundation.h>
+#import <WebKit/WKContextConfigurationRef.h>
+#import <WebKit/WKPreferencesRefPrivate.h>
+#import <WebKit/WKProcessPoolPrivate.h>
+#import <WebKit/WKStringCF.h>
+#import <WebKit/WKUserContentControllerPrivate.h>
+#import <WebKit/WKWebView.h>
+#import <WebKit/WKWebViewConfiguration.h>
+#import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/_WKProcessPoolConfiguration.h>
+#import <WebKit/_WKUserContentExtensionStore.h>
+#import <WebKit/_WKUserContentExtensionStorePrivate.h>
+#import <wtf/MainThread.h>
+
+namespace WTR {
+
+static WKWebViewConfiguration *globalWebViewConfiguration;
+
+void initializeWebViewConfiguration(const char* libraryPath, WKStringRef injectedBundlePath, WKContextRef context, WKContextConfigurationRef contextConfiguration)
+{
+    ASSERT(!globalWebViewConfiguration);
+    globalWebViewConfiguration = [[WKWebViewConfiguration alloc] init];
+
+    globalWebViewConfiguration.processPool = [[WKProcessPool alloc] _initWithConfiguration:(_WKProcessPoolConfiguration *)contextConfiguration];
+    globalWebViewConfiguration.websiteDataStore = (WKWebsiteDataStore *)WKContextGetWebsiteDataStore(context);
+}
+
+WKPreferencesRef TestController::platformPreferences()
+{
+    return (WKPreferencesRef)globalWebViewConfiguration.preferences;
+}
+
+void TestController::platformCreateWebView(WKPageConfigurationRef, const ViewOptions& options)
+{
+    m_mainWebView = std::make_unique<PlatformWebView>(globalWebViewConfiguration, options);
+}
+
+PlatformWebView* TestController::platformCreateOtherPage(PlatformWebView* parentView, WKPageConfigurationRef, const ViewOptions& options)
+{
+    WKWebViewConfiguration *newConfiguration = [[globalWebViewConfiguration copy] autorelease];
+    newConfiguration._relatedWebView = static_cast<WKWebView*>(parentView->platformView());
+    return new PlatformWebView(newConfiguration, options);
+}
+
+WKContextRef TestController::platformAdjustContext(WKContextRef context, WKContextConfigurationRef contextConfiguration)
+{
+    initializeWebViewConfiguration(libraryPathForTesting(), injectedBundlePath(), context, contextConfiguration);
+    return (WKContextRef)globalWebViewConfiguration.processPool;
+}
+
+void TestController::platformRunUntil(bool& done, double timeout)
+{
+    NSDate *endDate = (timeout > 0) ? [NSDate dateWithTimeIntervalSinceNow:timeout] : [NSDate distantFuture];
+
+    while (!done && [endDate compare:[NSDate date]] == NSOrderedDescending)
+        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:endDate];
+}
+
+void TestController::platformResetStateToConsistentValues()
+{
+#if WK_API_ENABLED
+    __block bool doneRemoving = false;
+    [[_WKUserContentExtensionStore defaultStore] removeContentExtensionForIdentifier:@"TestContentExtensions" completionHandler:^(NSError *error) {
+        doneRemoving = true;
+    }];
+    platformRunUntil(doneRemoving, 0);
+    [[_WKUserContentExtensionStore defaultStore] _removeAllContentExtensions];
+#endif
+
+    if (PlatformWebView* webView = mainWebView())
+        [webView->platformView().configuration.userContentController _removeAllUserContentFilters];
+}
+
+void TestController::platformWillRunTest(const TestInvocation& testInvocation)
+{
+    setCrashReportApplicationSpecificInformationToURL(testInvocation.url());
+}
+
+} // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/efl/TestControllerEfl.cpp (188806 => 188807)


--- trunk/Tools/WebKitTestRunner/efl/TestControllerEfl.cpp	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Tools/WebKitTestRunner/efl/TestControllerEfl.cpp	2015-08-22 00:34:31 UTC (rev 188807)
@@ -64,10 +64,6 @@
 {
 }
 
-void TestController::platformWillRunTest(const TestInvocation&)
-{
-}
-
 void TestController::platformRunUntil(bool& condition, double timeout)
 {
     if (timeout <= 0) {

Modified: trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp (188806 => 188807)


--- trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp	2015-08-22 00:34:31 UTC (rev 188807)
@@ -52,10 +52,6 @@
 {
 }
 
-void TestController::platformWillRunTest(const TestInvocation&)
-{
-}
-
 void TestController::platformRunUntil(bool&, double timeout)
 {
     if (timeout > 0) {

Modified: trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm (188806 => 188807)


--- trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm	2015-08-22 00:34:31 UTC (rev 188807)
@@ -28,10 +28,15 @@
 #include "TestController.h"
 
 #import <WebKit/WKImageCG.h>
-#import <WebKit/WKViewPrivate.h>
 #import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WKWebViewConfiguration.h>
+#import <WebKit/WKWebViewPrivate.h>
 #import <wtf/RetainPtr.h>
 
+@interface WKWebView (Details)
+- (WKPageRef)_pageForTesting;
+@end
+
 @interface WebKitTestRunnerWindow : UIWindow {
     WTR::PlatformWebView* _platformWebView;
     CGPoint _fakeOrigin;
@@ -40,33 +45,6 @@
 @property (nonatomic, assign) WTR::PlatformWebView* platformWebView;
 @end
 
-@interface TestRunnerWKView : WKView {
-    BOOL _useTiledDrawing;
-}
-
-@property (nonatomic, assign) BOOL useTiledDrawing;
-@end
-
-@implementation TestRunnerWKView
-
-@synthesize useTiledDrawing = _useTiledDrawing;
-
-- (id)initWithFrame:(CGRect)frame configurationRef:(WKPageConfigurationRef)configuration useTiledDrawing:(BOOL)useTiledDrawing
-{
-    if (!(self = [super initWithFrame:frame configurationRef:configuration]))
-        return nil;
-
-    _useTiledDrawing = useTiledDrawing;
-    return self;
-}
-
-- (BOOL)_shouldUseTiledDrawingArea
-{
-    return _useTiledDrawing;
-}
-
-@end
-
 @implementation WebKitTestRunnerWindow
 @synthesize platformWebView = _platformWebView;
 
@@ -122,18 +100,13 @@
 
 namespace WTR {
 
-PlatformWebView::PlatformWebView(WKPageConfigurationRef configuration, const ViewOptions& options)
+PlatformWebView::PlatformWebView(WKWebViewConfiguration* configuration, const ViewOptions& options)
     : m_windowIsKey(true)
     , m_options(options)
 {
     CGRect rect = CGRectMake(0, 0, TestController::viewWidth, TestController::viewHeight);
-    m_view = [[TestRunnerWKView alloc] initWithFrame:rect configurationRef:configuration useTiledDrawing:m_options.useTiledDrawing];
+    m_view = [[WKWebView alloc] initWithFrame:rect configuration:configuration];
 
-    WKPageGroupRef pageGroupRef = WKPageConfigurationGetPageGroup(configuration);
-
-    WKPreferencesSetCompositingBordersVisible(WKPageGroupGetPreferences(pageGroupRef), YES);
-    WKPreferencesSetCompositingRepaintCountersVisible(WKPageGroupGetPreferences(pageGroupRef), YES);
-
     CGRect windowRect = rect;
     m_window = [[WebKitTestRunnerWindow alloc] initWithFrame:windowRect];
     m_window.platformWebView = this;
@@ -153,19 +126,18 @@
 PlatformWebView::~PlatformWebView()
 {
     m_window.platformWebView = 0;
-//    [m_window close];
     [m_view release];
     [m_window release];
 }
 
 WKPageRef PlatformWebView::page()
 {
-    return [m_view pageRef];
+    return [m_view _pageForTesting];
 }
 
 void PlatformWebView::focus()
 {
-//    [m_window makeFirstResponder:m_view]; // FIXME: iOS equivalent?
+    makeWebViewFirstResponder();
     setWindowIsKey(true);
 }
 
@@ -184,7 +156,7 @@
 void PlatformWebView::setWindowFrame(WKRect frame)
 {
     [m_window setFrame:CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height)];
-    [m_view setFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
+    [platformView() setFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
 }
 
 void PlatformWebView::didInitializeClients()
@@ -215,7 +187,8 @@
 
 void PlatformWebView::makeWebViewFirstResponder()
 {
-//    [m_window makeFirstResponder:m_view];
+    // FIXME: iOS equivalent?
+    // [m_window makeFirstResponder:m_view];
 }
 
 void PlatformWebView::changeWindowScaleIfNeeded(float)
@@ -225,14 +198,12 @@
 
 WKRetainPtr<WKImageRef> PlatformWebView::windowSnapshotImage()
 {
-    return 0; // FIXME for iOS?
+    // FIXME: Need an implementation of this, or we're depending on software paints!
+    return nullptr;
 }
 
 bool PlatformWebView::viewSupportsOptions(const ViewOptions& options) const
 {
-    if (m_options.useTiledDrawing != options.useTiledDrawing)
-        return false;
-
     return true;
 }
 

Modified: trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm (188806 => 188807)


--- trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm	2015-08-22 00:34:31 UTC (rev 188807)
@@ -26,12 +26,16 @@
 #import "config.h"
 #import "TestController.h"
 
-#import "CrashReporterInfo.h"
-#import <Foundation/Foundation.h>
 #import "PlatformWebView.h"
 #import "TestInvocation.h"
+#import <Foundation/Foundation.h>
 #import <WebKit/WKPreferencesRefPrivate.h>
+#import <WebKit/WKProcessPoolPrivate.h>
 #import <WebKit/WKStringCF.h>
+#import <WebKit/WKUserContentControllerPrivate.h>
+#import <WebKit/WKWebView.h>
+#import <WebKit/WKWebViewConfiguration.h>
+#import <WebKit/WKWebViewConfigurationPrivate.h>
 #import <wtf/MainThread.h>
 
 namespace WTR {
@@ -70,11 +74,6 @@
     m_testPluginDirectory.adopt(WKStringCreateWithCFString((CFStringRef)[[NSBundle mainBundle] bundlePath]));
 }
 
-void TestController::platformWillRunTest(const TestInvocation& testInvocation)
-{
-    setCrashReportApplicationSpecificInformationToURL(testInvocation.url());
-}
-
 static bool shouldMakeViewportFlexible(const TestInvocation& test)
 {
     return test.urlContains("viewport/");
@@ -82,7 +81,7 @@
 
 void TestController::platformResetPreferencesToConsistentValues()
 {
-    WKPreferencesRef preferences = WKPageGroupGetPreferences(m_pageGroup.get());
+    WKPreferencesRef preferences = platformPreferences();
     // Note that WKPreferencesSetTextAutosizingEnabled has no effect on iOS.
     WKPreferencesSetMinimumZoomFontSize(preferences, 0);
 }
@@ -102,14 +101,6 @@
 {
 }
 
-void TestController::platformRunUntil(bool& done, double timeout)
-{
-    NSDate *endDate = (timeout > 0) ? [NSDate dateWithTimeIntervalSinceNow:timeout] : [NSDate distantFuture];
-
-    while (!done && [endDate compare:[NSDate date]] == NSOrderedDescending)
-        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:endDate];
-}
-
 void TestController::platformInitializeContext()
 {
 }

Modified: trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm (188806 => 188807)


--- trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Tools/WebKitTestRunner/mac/EventSenderProxy.mm	2015-08-22 00:34:31 UTC (rev 188807)
@@ -33,6 +33,7 @@
 #import <Carbon/Carbon.h>
 #import <WebKit/WKString.h>
 #import <WebKit/WKPagePrivate.h>
+#import <WebKit/WKWebView.h>
 #import <wtf/RetainPtr.h>
 
 @interface NSApplication (Details)
@@ -268,7 +269,17 @@
     // FIXME: Silly hack to teach WKTR to respect capturing mouse events outside the WKView.
     // The right solution is just to use NSApplication's built-in event sending methods, 
     // instead of rolling our own algorithm for selecting an event target.
-    targetView = targetView ? targetView : m_testController->mainWebView()->platformView();
+    // FIXME: This is even worse now, because we need to hit the WKWebView's inner WKView
+    // when using the modern API, so the level of fakery and horror increases.
+    if (!targetView) {
+        targetView = m_testController->mainWebView()->platformView();
+        for (NSView *wkWebViewChild in targetView.subviews) {
+            if ([wkWebViewChild isKindOfClass:[WKView class]]) {
+                targetView = wkWebViewChild;
+                break;
+            }
+        }
+    }
     ASSERT(targetView);
     [NSApp _setCurrentEvent:event];
     [targetView mouseUp:event];
@@ -401,28 +412,27 @@
 void EventSenderProxy::mouseMoveTo(double x, double y)
 {
     NSView *view = m_testController->mainWebView()->platformView();
-    NSPoint position = [view convertPoint:NSMakePoint(x, y) toView:nil];
+    NSPoint position = [view convertPoint:NSMakePoint(x, view.frame.size.height - y) toView:nil];
     m_position.x = position.x;
     m_position.y = position.y;
     NSEvent *event = [NSEvent mouseEventWithType:(m_leftMouseButtonDown ? NSLeftMouseDragged : NSMouseMoved)
                                         location:position
                                    modifierFlags:0 
                                        timestamp:absoluteTimeForEventTime(currentEventTime())
-                                    windowNumber:[[view window] windowNumber] 
+                                    windowNumber:view.window.windowNumber
                                          context:[NSGraphicsContext currentContext] 
                                      eventNumber:++eventNumber 
                                       clickCount:(m_leftMouseButtonDown ? m_clickCount : 0) 
-                                        pressure:0.0];
+                                        pressure:0];
 
-    NSView *targetView = [m_testController->mainWebView()->platformView() hitTest:[event locationInWindow]];
+    NSPoint windowLocation = event.locationInWindow;
+    NSView *targetView = [m_testController->mainWebView()->platformView() hitTest:windowLocation];
     if (targetView) {
         [NSApp _setCurrentEvent:event];
         [targetView mouseMoved:event];
         [NSApp _setCurrentEvent:nil];
-    } else {
-        NSPoint windowLocation = [event locationInWindow];
+    } else
         WTFLogAlways("mouseMoveTo failed to find a target view at %f,%f\n", windowLocation.x, windowLocation.y);
-    }
 }
 
 void EventSenderProxy::leapForward(int milliseconds)

Modified: trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm (188806 => 188807)


--- trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm	2015-08-22 00:34:31 UTC (rev 188807)
@@ -30,9 +30,14 @@
 #import "WebKitTestRunnerDraggingInfo.h"
 #import <WebKit/WKImageCG.h>
 #import <WebKit/WKPreferencesPrivate.h>
-#import <WebKit/WKViewPrivate.h>
+#import <WebKit/WKWebViewConfiguration.h>
+#import <WebKit/WKWebViewPrivate.h>
 #import <wtf/RetainPtr.h>
 
+@interface WKWebView (Details)
+- (WKPageRef)_pageForTesting;
+@end
+
 using namespace WTR;
 
 enum {
@@ -46,26 +51,11 @@
 @property (nonatomic, assign) PlatformWebView* platformWebView;
 @end
 
-@interface TestRunnerWKView : WKView {
-    BOOL _useThreadedScrolling;
-}
-
-@property (nonatomic, assign) BOOL useThreadedScrolling;
+@interface TestRunnerWKWebView : WKWebView
 @end
 
-@implementation TestRunnerWKView
+@implementation TestRunnerWKWebView
 
-@synthesize useThreadedScrolling = _useThreadedScrolling;
-
-- (id)initWithFrame:(NSRect)frame configurationRef:(WKPageConfigurationRef)configuration useThreadedScrolling:(BOOL)useThreadedScrolling
-{
-    if (!(self = [super initWithFrame:frame configurationRef:configuration]))
-        return nil;
-
-    _useThreadedScrolling = useThreadedScrolling;
-    return self;
-}
-
 - (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]);
@@ -120,23 +110,20 @@
 
 namespace WTR {
 
-PlatformWebView::PlatformWebView(WKPageConfigurationRef configuration, const ViewOptions& options)
+PlatformWebView::PlatformWebView(WKWebViewConfiguration* configuration, const ViewOptions& options)
     : m_windowIsKey(true)
     , m_options(options)
 {
-    WKPageGroupRef pageGroupRef = WKPageConfigurationGetPageGroup(configuration);
-
-    // The tiled drawing specific tests also depend on threaded scrolling.
-    WKPreferencesRef preferences = WKPageGroupGetPreferences(pageGroupRef);
-    WKPreferencesSetThreadedScrollingEnabled(preferences, m_options.useThreadedScrolling);
-
     // FIXME: Not sure this is the best place for this; maybe we should have API to set this so we can do it from TestController?
     if (m_options.useRemoteLayerTree)
         [[NSUserDefaults standardUserDefaults] setValue:@YES forKey:@"WebKit2UseRemoteLayerTreeDrawingArea"];
 
+    RetainPtr<WKWebViewConfiguration> copiedConfiguration = adoptNS([configuration copy]);
+    WKPreferencesSetThreadedScrollingEnabled((WKPreferencesRef)[copiedConfiguration preferences], m_options.useThreadedScrolling);
+
     NSRect rect = NSMakeRect(0, 0, TestController::viewWidth, TestController::viewHeight);
-    m_view = [[TestRunnerWKView alloc] initWithFrame:rect configurationRef:configuration useThreadedScrolling:options.useThreadedScrolling];
-    [m_view setWindowOcclusionDetectionEnabled:NO];
+    m_view = [[TestRunnerWKWebView alloc] initWithFrame:rect configuration:copiedConfiguration.get()];
+    [m_view _setWindowOcclusionDetectionEnabled:NO];
 
     NSScreen *firstScreen = [[NSScreen screens] objectAtIndex:0];
     NSRect windowRect = m_options.shouldShowWebView ? NSOffsetRect(rect, 100, 100) : NSOffsetRect(rect, -10000, [firstScreen frame].size.height - rect.size.height + 10000);
@@ -170,12 +157,12 @@
 
 WKPageRef PlatformWebView::page()
 {
-    return [m_view pageRef];
+    return [m_view _pageForTesting];
 }
 
 void PlatformWebView::focus()
 {
-    [m_window makeFirstResponder:m_view];
+    [m_window makeFirstResponder:platformView()];
     setWindowIsKey(true);
 }
 
@@ -194,7 +181,7 @@
 void PlatformWebView::setWindowFrame(WKRect frame)
 {
     [m_window setFrame:NSMakeRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height) display:YES];
-    [m_view setFrame:NSMakeRect(0, 0, frame.size.width, frame.size.height)];
+    [platformView() setFrame:NSMakeRect(0, 0, frame.size.width, frame.size.height)];
 }
 
 void PlatformWebView::didInitializeClients()
@@ -205,18 +192,19 @@
 
 void PlatformWebView::addChromeInputField()
 {
-    NSTextField* textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 20)];
+    NSTextField *textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 20)];
     textField.tag = 1;
     [[m_window contentView] addSubview:textField];
     [textField release];
 
-    [textField setNextKeyView:m_view];
-    [m_view setNextKeyView:textField];
+    NSView *view = platformView();
+    [textField setNextKeyView:view];
+    [view setNextKeyView:textField];
 }
 
 void PlatformWebView::removeChromeInputField()
 {
-    NSView* textField = [[m_window contentView] viewWithTag:1];
+    NSView *textField = [[m_window contentView] viewWithTag:1];
     if (textField) {
         [textField removeFromSuperview];
         makeWebViewFirstResponder();
@@ -225,12 +213,12 @@
 
 void PlatformWebView::makeWebViewFirstResponder()
 {
-    [m_window makeFirstResponder:m_view];
+    [m_window makeFirstResponder:platformView()];
 }
 
 WKRetainPtr<WKImageRef> PlatformWebView::windowSnapshotImage()
 {
-    [m_view display];
+    [platformView() display];
     CGWindowImageOption options = kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque;
 
     if ([m_window backingScaleFactor] == 1)

Modified: trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm (188806 => 188807)


--- trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm	2015-08-22 00:07:38 UTC (rev 188806)
+++ trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm	2015-08-22 00:34:31 UTC (rev 188807)
@@ -26,15 +26,19 @@
 #import "config.h"
 #import "TestController.h"
 
-#import "CrashReporterInfo.h"
 #import "PlatformWebView.h"
 #import "PoseAsClass.h"
 #import "TestInvocation.h"
 #import "WebKitTestRunnerPasteboard.h"
 #import <WebKit/WKContextPrivate.h>
 #import <WebKit/WKPageGroup.h>
+#import <WebKit/WKProcessPoolPrivate.h>
 #import <WebKit/WKStringCF.h>
 #import <WebKit/WKURLCF.h>
+#import <WebKit/WKUserContentControllerPrivate.h>
+#import <WebKit/WKWebView.h>
+#import <WebKit/WKWebViewConfiguration.h>
+#import <WebKit/WKWebViewConfigurationPrivate.h>
 #import <WebKit/_WKUserContentExtensionStore.h>
 #import <WebKit/_WKUserContentExtensionStorePrivate.h>
 #import <mach-o/dyld.h>
@@ -73,11 +77,6 @@
     m_testPluginDirectory.adopt(WKStringCreateWithCFString((CFStringRef)[[NSBundle mainBundle] bundlePath]));
 }
 
-void TestController::platformWillRunTest(const TestInvocation& testInvocation)
-{
-    setCrashReportApplicationSpecificInformationToURL(testInvocation.url());
-}
-
 static bool shouldUseThreadedScrolling(const TestInvocation& test)
 {
     return test.urlContains("tiled-drawing/");
@@ -85,15 +84,6 @@
 
 void TestController::platformResetPreferencesToConsistentValues()
 {
-#if WK_API_ENABLED
-    __block bool doneRemoving = false;
-    [[_WKUserContentExtensionStore defaultStore] removeContentExtensionForIdentifier:@"TestContentExtensions" completionHandler:^(NSError *error)
-    {
-        doneRemoving = true;
-    }];
-    platformRunUntil(doneRemoving, 0);
-    [[_WKUserContentExtensionStore defaultStore] _removeAllContentExtensions];
-#endif
 }
 
 void TestController::updatePlatformSpecificViewOptionsForTest(ViewOptions& viewOptions, const TestInvocation& test) const
@@ -121,7 +111,7 @@
     [[_WKUserContentExtensionStore defaultStore] compileContentExtensionForIdentifier:@"TestContentExtensions" encodedContentExtension:contentExtensionString completionHandler:^(_WKUserContentFilter *filter, NSError *error)
     {
         if (!error)
-            WKPageGroupAddUserContentFilter(WKPageGetPageGroup(TestController::singleton().mainWebView()->page()), (__bridge WKUserContentFilterRef)filter);
+            [mainWebView()->platformView().configuration.userContentController _addUserContentFilter:filter];
         else
             NSLog(@"%@", [error helpAnchor]);
         doneCompiling = true;
@@ -130,14 +120,6 @@
 #endif
 }
 
-void TestController::platformRunUntil(bool& done, double timeout)
-{
-    NSDate *endDate = (timeout > 0) ? [NSDate dateWithTimeIntervalSinceNow:timeout] : [NSDate distantFuture];
-
-    while (!done && [endDate compare:[NSDate date]] == NSOrderedDescending)
-        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:endDate];
-}
-
 #if ENABLE(PLATFORM_FONT_LOOKUP)
 static NSSet *allowedFontFamilySet()
 {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to