Add a way to opt into modern compatibility mode in layout tests
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Apr 2019 17:46:44 +0000 (17:46 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Apr 2019 17:46:44 +0000 (17:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196770
<rdar://problem/49777550>

Reviewed by Antoine Quint.

Add a new test option to enable modern compatibility mode in layout tests.

* WebKitTestRunner/TestController.cpp:
(WTR::updateTestOptionsFromTestHeader):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions const):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::platformCreateWebView):
(WTR::TestController::enableModernCompatibilityMode):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244134 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestOptions.h
Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm

index 25590b0..f4614d7 100644 (file)
@@ -1,3 +1,22 @@
+2019-04-10  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Add a way to opt into modern compatibility mode in layout tests
+        https://bugs.webkit.org/show_bug.cgi?id=196770
+        <rdar://problem/49777550>
+
+        Reviewed by Antoine Quint.
+
+        Add a new test option to enable modern compatibility mode in layout tests.
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::updateTestOptionsFromTestHeader):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestOptions.h:
+        (WTR::TestOptions::hasSameInitializationOptions const):
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::platformCreateWebView):
+        (WTR::TestController::enableModernCompatibilityMode):
+
 2019-04-10  Andy Estes  <aestes@apple.com>
 
         Try to fix the 32-bit watchOS build.
index 7866721..73db303 100644 (file)
@@ -1366,6 +1366,8 @@ static void updateTestOptionsFromTestHeader(TestOptions& testOptions, const std:
             testOptions.contentInsetTop = std::stod(value);
         else if (key == "ignoreSynchronousMessagingTimeouts")
             testOptions.contextOptions.ignoreSynchronousMessagingTimeouts = parseBooleanTestHeaderValue(value);
+        else if (key == "shouldUseModernCompatibilityMode")
+            testOptions.shouldUseModernCompatibilityMode = parseBooleanTestHeaderValue(value);
         pairStart = pairEnd + 1;
     }
 }
index ace6a54..de9130c 100644 (file)
@@ -458,6 +458,7 @@ private:
 
 #if PLATFORM(COCOA)
     static void finishCreatingPlatformWebView(PlatformWebView*, const TestOptions&);
+    void enableModernCompatibilityMode(WKWebViewConfiguration *);
 #endif
 
     static const char* libraryPathForTesting();
index 4d7ea15..2b1dbf9 100644 (file)
@@ -91,6 +91,7 @@ struct TestOptions {
     bool enableUndoManagerAPI { false };
     bool shouldHandleRunOpenPanel { true };
     bool shouldPresentPopovers { true };
+    bool shouldUseModernCompatibilityMode { false };
 
     double contentInsetTop { 0 };
 
@@ -140,7 +141,8 @@ struct TestOptions {
             || enableUndoManagerAPI != options.enableUndoManagerAPI
             || shouldHandleRunOpenPanel != options.shouldHandleRunOpenPanel
             || shouldPresentPopovers != options.shouldPresentPopovers
-            || contentInsetTop != options.contentInsetTop)
+            || contentInsetTop != options.contentInsetTop
+            || shouldUseModernCompatibilityMode != options.shouldUseModernCompatibilityMode)
             return false;
 
         if (!contextOptions.hasSameInitializationOptions(options.contextOptions))
index 6e8d944..bd5f39f 100644 (file)
@@ -159,6 +159,9 @@ void TestController::platformCreateWebView(WKPageConfigurationRef, const TestOpt
     if (options.enableUndoManagerAPI)
         [copiedConfiguration _setUndoManagerAPIEnabled:YES];
 
+    if (options.shouldUseModernCompatibilityMode)
+        enableModernCompatibilityMode(copiedConfiguration.get());
+
     if (options.applicationManifest.length()) {
         auto manifestPath = [NSString stringWithUTF8String:options.applicationManifest.c_str()];
         NSString *text = [NSString stringWithContentsOfFile:manifestPath usedEncoding:nullptr error:nullptr];
@@ -402,4 +405,14 @@ bool TestController::isDoingMediaCapture() const
     return m_mainWebView->platformView()._mediaCaptureState != _WKMediaCaptureStateNone;
 }
 
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/TestControllerCocoaAdditions.mm>
+#else
+
+void TestController::enableModernCompatibilityMode(WKWebViewConfiguration *)
+{
+}
+
+#endif
+
 } // namespace WTR