Title: [268795] trunk/Tools
Revision
268795
Author
wei...@apple.com
Date
2020-10-21 08:04:20 -0700 (Wed, 21 Oct 2020)

Log Message

Cleanup DumpRenderTree in preparation for supporting arbitrary test header commands
https://bugs.webkit.org/show_bug.cgi?id=217962

Reviewed by Darin Adler.

- Moves DumpRenderTree's TestOptions to be fully backed by TestFeatures like WebKitTestRunnner,
  allowing future changes to utilize any WebPreference once SPI is available from WebKitLegacy.

- Removes use of using namespace std; from DumpRenderTree.mm, which is not something we normally
  do and made the code a bit confusing.

- Move some random setting of preferences to centralized reset functions.

* DumpRenderTree/TestOptions.cpp:
* DumpRenderTree/TestOptions.h:
* DumpRenderTree/mac/DumpRenderTree.mm:
* DumpRenderTree/mac/TestRunnerMac.mm:
* DumpRenderTree/mac/UIDelegate.mm:
* DumpRenderTree/win/DumpRenderTree.cpp:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (268794 => 268795)


--- trunk/Tools/ChangeLog	2020-10-21 14:06:02 UTC (rev 268794)
+++ trunk/Tools/ChangeLog	2020-10-21 15:04:20 UTC (rev 268795)
@@ -1,3 +1,25 @@
+2020-10-20  Sam Weinig  <wei...@apple.com>
+
+        Cleanup DumpRenderTree in preparation for supporting arbitrary test header commands
+        https://bugs.webkit.org/show_bug.cgi?id=217962
+
+        Reviewed by Darin Adler.
+
+        - Moves DumpRenderTree's TestOptions to be fully backed by TestFeatures like WebKitTestRunnner,
+          allowing future changes to utilize any WebPreference once SPI is available from WebKitLegacy.
+
+        - Removes use of using namespace std; from DumpRenderTree.mm, which is not something we normally
+          do and made the code a bit confusing.
+
+        - Move some random setting of preferences to centralized reset functions.
+
+        * DumpRenderTree/TestOptions.cpp:
+        * DumpRenderTree/TestOptions.h:
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        * DumpRenderTree/mac/TestRunnerMac.mm:
+        * DumpRenderTree/mac/UIDelegate.mm:
+        * DumpRenderTree/win/DumpRenderTree.cpp:
+
 2020-10-21  Carlos Garcia Campos  <cgar...@igalia.com>
 
         WebDriver: add support for wheel actions

Modified: trunk/Tools/DumpRenderTree/TestOptions.cpp (268794 => 268795)


--- trunk/Tools/DumpRenderTree/TestOptions.cpp	2020-10-21 14:06:02 UTC (rev 268794)
+++ trunk/Tools/DumpRenderTree/TestOptions.cpp	2020-10-21 15:04:20 UTC (rev 268795)
@@ -30,6 +30,44 @@
 
 namespace WTR {
 
+const TestFeatures& TestOptions::defaults()
+{
+    static TestFeatures features;
+    if (features.boolWebPreferenceFeatures.empty()) {
+        features.boolWebPreferenceFeatures = {
+            // These are WebPreference values that must always be set as they may
+            // differ from the default set in the WebPreferences*.yaml configuration.
+            { "AllowCrossOriginSubresourcesToAskForCredentials", false },
+            { "AllowTopNavigationToDataURLs", true },
+            { "AcceleratedDrawingEnabled", false },
+            { "AttachmentElementEnabled", false },
+            { "UsesBackForwardCache", false },
+            { "ColorFilterEnabled", false },
+            { "InspectorAdditionsEnabled", false },
+            { "IntersectionObserverEnabled", false },
+            { "KeygenElementEnabled", false },
+            { "MenuItemElementEnabled", false },
+            { "ModernMediaControlsEnabled", true },
+
+            { "CSSLogicalEnabled", false },
+            { "LineHeightUnitsEnabled", false },
+            { "SelectionAcrossShadowBoundariesEnabled", true },
+            { "LayoutFormattingContextIntegrationEnabled", true },
+
+            { "AdClickAttributionEnabled", false },
+            { "AspectRatioOfImgFromWidthAndHeightEnabled", false },
+            { "AsyncClipboardAPIEnabled", false },
+            { "CSSOMViewSmoothScrollingEnabled", false },
+            { "ContactPickerAPIEnabled", false },
+            { "CoreMathMLEnabled", false },
+            { "RequestIdleCallbackEnabled", false },
+            { "ResizeObserverEnabled", false },
+            { "WebGPUEnabled", false },
+        };
+    }
+    return features;
+}
+
 const std::unordered_map<std::string, TestHeaderKeyType>& TestOptions::keyTypeMapping()
 {
     static const std::unordered_map<std::string, TestHeaderKeyType> map {
@@ -47,56 +85,47 @@
     return map;
 }
 
-template<typename T> static void setValueIfSetInMap(T& valueToSet, std::string key, const std::unordered_map<std::string, T>& map)
+bool TestOptions::webViewIsCompatibleWithOptions(const TestOptions& options) const
 {
+    if (m_features.experimentalFeatures != options.m_features.experimentalFeatures)
+        return false;
+    if (m_features.internalDebugFeatures != options.m_features.internalDebugFeatures)
+        return false;
+    if (m_features.boolWebPreferenceFeatures != options.m_features.boolWebPreferenceFeatures)
+        return false;
+    if (m_features.doubleWebPreferenceFeatures != options.m_features.doubleWebPreferenceFeatures)
+        return false;
+    if (m_features.uint32WebPreferenceFeatures != options.m_features.uint32WebPreferenceFeatures)
+        return false;
+    if (m_features.stringWebPreferenceFeatures != options.m_features.stringWebPreferenceFeatures)
+        return false;
+    if (m_features.boolTestRunnerFeatures != options.m_features.boolTestRunnerFeatures)
+        return false;
+    if (m_features.doubleTestRunnerFeatures != options.m_features.doubleTestRunnerFeatures)
+        return false;
+    if (m_features.stringTestRunnerFeatures != options.m_features.stringTestRunnerFeatures)
+        return false;
+    if (m_features.stringVectorTestRunnerFeatures != options.m_features.stringVectorTestRunnerFeatures)
+        return false;
+    return true;
+}
+
+template<typename T> T featureValue(std::string key, T defaultValue, const std::unordered_map<std::string, T>& map)
+{
     auto it = map.find(key);
-    if (it == map.end())
-        return;
-    valueToSet = it->second;
+    if (it != map.end())
+        return it->second;
+    return defaultValue;
 }
 
-TestOptions::TestOptions(TestFeatures testFeatures)
+bool TestOptions::boolTestRunnerFeatureValue(std::string key, bool defaultValue) const
 {
-    setValueIfSetInMap(allowCrossOriginSubresourcesToAskForCredentials, "AllowCrossOriginSubresourcesToAskForCredentials", testFeatures.boolWebPreferenceFeatures);
-    setValueIfSetInMap(allowTopNavigationToDataURLs, "AllowTopNavigationToDataURLs", testFeatures.boolWebPreferenceFeatures);
-    setValueIfSetInMap(enableAcceleratedDrawing, "AcceleratedDrawingEnabled", testFeatures.boolWebPreferenceFeatures);
-    setValueIfSetInMap(enableAttachmentElement, "AttachmentElementEnabled", testFeatures.boolWebPreferenceFeatures);
-    setValueIfSetInMap(enableBackForwardCache, "UsesBackForwardCache", testFeatures.boolWebPreferenceFeatures);
-    setValueIfSetInMap(enableColorFilter, "ColorFilterEnabled", testFeatures.boolWebPreferenceFeatures);
-    setValueIfSetInMap(enableInspectorAdditions, "InspectorAdditionsEnabled", testFeatures.boolWebPreferenceFeatures);
-    setValueIfSetInMap(enableIntersectionObserver, "IntersectionObserverEnabled", testFeatures.boolWebPreferenceFeatures);
-    setValueIfSetInMap(enableKeygenElement, "KeygenElementEnabled", testFeatures.boolWebPreferenceFeatures);
-    setValueIfSetInMap(enableMenuItemElement, "MenuItemElementEnabled", testFeatures.boolWebPreferenceFeatures);
-    setValueIfSetInMap(enableModernMediaControls, "ModernMediaControlsEnabled", testFeatures.boolWebPreferenceFeatures);
-
-    setValueIfSetInMap(enableDragDestinationActionLoad, "enableDragDestinationActionLoad", testFeatures.boolTestRunnerFeatures);
-    setValueIfSetInMap(dumpJSConsoleLogInStdErr, "dumpJSConsoleLogInStdErr", testFeatures.boolTestRunnerFeatures);
-    setValueIfSetInMap(layerBackedWebView, "layerBackedWebView", testFeatures.boolTestRunnerFeatures);
-    setValueIfSetInMap(useEphemeralSession, "useEphemeralSession", testFeatures.boolTestRunnerFeatures);
-
-    setValueIfSetInMap(additionalSupportedImageTypes, "additionalSupportedImageTypes", testFeatures.stringTestRunnerFeatures);
-    setValueIfSetInMap(jscOptions, "jscOptions", testFeatures.stringTestRunnerFeatures);
-
-    setValueIfSetInMap(enableCSSLogical, "CSSLogicalEnabled", testFeatures.internalDebugFeatures);
-    setValueIfSetInMap(enableLineHeightUnits, "LineHeightUnitsEnabled", testFeatures.internalDebugFeatures);
-    setValueIfSetInMap(enableSelectionAcrossShadowBoundaries, "selectionAcrossShadowBoundariesEnabled", testFeatures.internalDebugFeatures);
-    setValueIfSetInMap(layoutFormattingContextIntegrationEnabled, "LayoutFormattingContextIntegrationEnabled", testFeatures.internalDebugFeatures);
-
-    setValueIfSetInMap(adClickAttributionEnabled, "AdClickAttributionEnabled", testFeatures.experimentalFeatures);
-    setValueIfSetInMap(enableAspectRatioOfImgFromWidthAndHeight, "AspectRatioOfImgFromWidthAndHeightEnabled", testFeatures.experimentalFeatures);
-    setValueIfSetInMap(enableAsyncClipboardAPI, "AsyncClipboardAPIEnabled", testFeatures.experimentalFeatures);
-    setValueIfSetInMap(enableCSSOMViewSmoothScrolling, "CSSOMViewSmoothScrollingEnabled", testFeatures.experimentalFeatures);
-    setValueIfSetInMap(enableContactPickerAPI, "ContactPickerAPIEnabled", testFeatures.experimentalFeatures);
-    setValueIfSetInMap(enableCoreMathML, "CoreMathMLEnabled", testFeatures.experimentalFeatures);
-    setValueIfSetInMap(enableRequestIdleCallback, "RequestIdleCallbackEnabled", testFeatures.experimentalFeatures);
-    setValueIfSetInMap(enableResizeObserver, "ResizeObserverEnabled", testFeatures.experimentalFeatures);
-    setValueIfSetInMap(enableWebGPU, "WebGPUEnabled", testFeatures.experimentalFeatures);
+    return featureValue(key, defaultValue, m_features.boolTestRunnerFeatures);
 }
 
-bool TestOptions::webViewIsCompatibleWithOptions(const TestOptions& other) const
+std::string TestOptions::stringTestRunnerFeatureValue(std::string key, std::string defaultValue) const
 {
-    return other.layerBackedWebView == layerBackedWebView
-        && other.jscOptions == jscOptions;
+    return featureValue(key, defaultValue, m_features.stringTestRunnerFeatures);
 }
 
 }

Modified: trunk/Tools/DumpRenderTree/TestOptions.h (268794 => 268795)


--- trunk/Tools/DumpRenderTree/TestOptions.h	2020-10-21 14:06:02 UTC (rev 268794)
+++ trunk/Tools/DumpRenderTree/TestOptions.h	2020-10-21 15:04:20 UTC (rev 268795)
@@ -31,53 +31,38 @@
 
 namespace WTR {
 
-struct TestOptions {
-    // FIXME: Remove these and replace with access to TestFeatures set.
-    // Web Preferences
-    bool allowCrossOriginSubresourcesToAskForCredentials { false };
-    bool allowTopNavigationToDataURLs { true };
-    bool enableAcceleratedDrawing { false };
-    bool enableAttachmentElement { false };
-    bool enableBackForwardCache { false };
-    bool enableColorFilter { false };
-    bool enableInspectorAdditions { false };
-    bool enableIntersectionObserver { false };
-    bool enableKeygenElement { false };
-    bool enableMenuItemElement { false };
-    bool enableModernMediaControls { true };
+class TestOptions {
+public:
+    static const TestFeatures& defaults();
+    static const std::unordered_map<std::string, TestHeaderKeyType>& keyTypeMapping();
 
-    // FIXME: Remove these and replace with access to TestFeatures set.
-    // Internal Features
-    bool enableCSSLogical { false };
-    bool enableLineHeightUnits { false };
-    bool enableSelectionAcrossShadowBoundaries { true };
-    bool layoutFormattingContextIntegrationEnabled { true };
+    explicit TestOptions(TestFeatures features)
+        : m_features(std::move(features))
+    {
+    }
 
-    // FIXME: Remove these and replace with access to TestFeatures set.
-    // Experimental Features
-    bool adClickAttributionEnabled { false };
-    bool enableAspectRatioOfImgFromWidthAndHeight { false };
-    bool enableAsyncClipboardAPI { false };
-    bool enableCSSOMViewSmoothScrolling { false };
-    bool enableContactPickerAPI { false };
-    bool enableCoreMathML { false };
-    bool enableRequestIdleCallback { false };
-    bool enableResizeObserver { false };
-    bool enableWebGPU { false };
+    bool webViewIsCompatibleWithOptions(const TestOptions&) const;
 
-    // Test Runner Specific Features
-    bool dumpJSConsoleLogInStdErr { false };
-    bool enableDragDestinationActionLoad { false };
-    bool enableWebSQL { true };
-    bool layerBackedWebView { false };
-    bool useEphemeralSession { false };
-    std::string additionalSupportedImageTypes;
-    std::string jscOptions;
+    // Test-Runner-Specific Features
+    bool dumpJSConsoleLogInStdErr() const { return boolTestRunnerFeatureValue("dumpJSConsoleLogInStdErr", false); }
+    bool enableDragDestinationActionLoad() const { return boolTestRunnerFeatureValue("enableDragDestinationActionLoad", false); }
+    bool layerBackedWebView() const { return boolTestRunnerFeatureValue("layerBackedWebView", false); }
+    bool useEphemeralSession() const { return boolTestRunnerFeatureValue("useEphemeralSession", false); }
+    std::string additionalSupportedImageTypes() const { return stringTestRunnerFeatureValue("additionalSupportedImageTypes", { }); }
+    std::string jscOptions() const { return stringTestRunnerFeatureValue("jscOptions", { }); }
 
-    explicit TestOptions(TestFeatures);
-    bool webViewIsCompatibleWithOptions(const TestOptions&) const;
-    
-    static const std::unordered_map<std::string, TestHeaderKeyType>& keyTypeMapping();
+    const auto& boolWebPreferenceFeatures() const { return m_features.boolWebPreferenceFeatures; }
+    const auto& doubleWebPreferenceFeatures() const { return m_features.doubleWebPreferenceFeatures; }
+    const auto& uint32WebPreferenceFeatures() const { return m_features.uint32WebPreferenceFeatures; }
+    const auto& stringWebPreferenceFeatures() const { return m_features.stringWebPreferenceFeatures; }
+
+    static std::string toWebKitLegacyPreferenceKey(const std::string&);
+
+private:
+    bool boolTestRunnerFeatureValue(std::string key, bool defaultValue) const;
+    std::string stringTestRunnerFeatureValue(std::string key, std::string defaultValue) const;
+
+    TestFeatures m_features;
 };
 
 }

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (268794 => 268795)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2020-10-21 14:06:02 UTC (rev 268794)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2020-10-21 15:04:20 UTC (rev 268795)
@@ -130,8 +130,6 @@
 #import <mach-o/getsect.h>
 }
 
-using namespace std;
-
 #if !PLATFORM(IOS_FAMILY)
 @interface DumpRenderTreeApplication : NSApplication
 @end
@@ -152,7 +150,7 @@
     ASSERT(scrollView && [scrollView isKindOfClass:[UIWebScrollView class]]);
     const CGSize scrollViewSize = [scrollView bounds].size;
     CGSize contentSize = newFrame.size;
-    contentSize.height = CGRound(max(CGRectGetMaxY(newFrame), scrollViewSize.height));
+    contentSize.height = CGRound(std::max(CGRectGetMaxY(newFrame), scrollViewSize.height));
     [(UIWebScrollView *)scrollView setContentSize:contentSize];
 }
 @end
@@ -178,7 +176,7 @@
 @end
 #endif
 
-static void runTest(const string& testURL);
+static void runTest(const std::string& testURL);
 
 // Deciding when it's OK to dump out the state is a bit tricky.  All these must be true:
 // - There is no load in progress
@@ -249,7 +247,7 @@
     persistentUserStyleSheetLocation = url;
 }
 
-static bool shouldIgnoreWebCoreNodeLeaks(const string& urlString)
+static bool shouldIgnoreWebCoreNodeLeaks(const std::string& urlString)
 {
     static char* const ignoreSet[] = {
         // Keeping this infrastructure around in case we ever need it again.
@@ -258,7 +256,7 @@
 
     for (int i = 0; i < ignoreSetCount; i++) {
         // FIXME: ignore case
-        string curIgnore(ignoreSet[i]);
+        std::string curIgnore(ignoreSet[i]);
         // Match at the end of the urlString.
         if (!urlString.compare(urlString.length() - curIgnore.length(), curIgnore.length(), curIgnore))
             return true;
@@ -616,8 +614,8 @@
     BOOL isHorizontal = frameRect.size.width > frameRect.size.height;
     CGFloat trackLength = isHorizontal ? bounds.size.width : bounds.size.height;
     CGFloat minKnobSize = isHorizontal ? bounds.size.height : bounds.size.width;
-    CGFloat knobLength = max(minKnobSize, static_cast<CGFloat>(round(trackLength * [self knobProportion])));
-    CGFloat knobPosition = static_cast<CGFloat>((round([self doubleValue] * (trackLength - knobLength))));
+    CGFloat knobLength = std::max(minKnobSize, static_cast<CGFloat>(std::round(trackLength * [self knobProportion])));
+    CGFloat knobPosition = static_cast<CGFloat>((std::round([self doubleValue] * (trackLength - knobLength))));
 
     if (isHorizontal)
         return NSMakeRect(bounds.origin.x + knobPosition, bounds.origin.y, knobLength, bounds.size.height);
@@ -686,8 +684,6 @@
     [WebView registerURLSchemeAsLocal:@"feeds"];
     [WebView registerURLSchemeAsLocal:@"feedsearch"];
 
-    [[webView preferences] _setMediaRecorderEnabled:YES];
-
 #if PLATFORM(MAC)
     [webView setWindowOcclusionDetectionEnabled:NO];
     [WebView _setFontAllowList:fontAllowList()];
@@ -757,8 +753,6 @@
     NSBitmapImageRep *imageRep = [webView bitmapImageRepForCachingDisplayInRect:[webView bounds]];
     [webView cacheDisplayInRect:[webView bounds] toBitmapImageRep:imageRep];
 #else
-    [[webView preferences] _setTelephoneNumberParsingEnabled:NO];
-
     // Initialize the global UIViews, and set the key UIWindow to be painted.
     if (!gWebBrowserView) {
         gWebBrowserView = [webBrowserView retain];
@@ -827,7 +821,7 @@
     [preferences setReadableByteStreamAPIEnabled:YES];
     [preferences setWritableStreamAPIEnabled:YES];
     [preferences setTransformStreamAPIEnabled:YES];
-    preferences.encryptedMediaAPIEnabled = YES;
+    [preferences setEncryptedMediaAPIEnabled:YES];
     [preferences setAccessibilityObjectModelEnabled:YES];
     [preferences setAriaReflectionEnabled:YES];
     [preferences setVisualViewportAPIEnabled:YES];
@@ -834,7 +828,7 @@
     [preferences setColorFilterEnabled:YES];
     [preferences setServerTimingEnabled:YES];
     [preferences setIntersectionObserverEnabled:YES];
-    preferences.sourceBufferChangeTypeEnabled = YES;
+    [preferences setSourceBufferChangeTypeEnabled:YES];
     [preferences setCSSOMViewScrollingAPIEnabled:YES];
     [preferences setMediaRecorderEnabled:YES];
     [preferences setReferrerPolicyAttributeEnabled:YES];
@@ -851,9 +845,8 @@
 }
 
 // Called before each test.
-static void resetWebPreferencesToConsistentValues()
+static void resetWebPreferencesToConsistentValues(WebPreferences *preferences)
 {
-    WebPreferences *preferences = [WebPreferences standardPreferences];
     enableExperimentalFeatures(preferences);
 
     [preferences setNeedsStorageAccessFromFileURLsQuirk: NO];
@@ -921,6 +914,7 @@
     // Enable the tracker before creating the first WebView will
     // cause initialization to use the correct database paths.
     [preferences setStorageTrackerEnabled:YES];
+    [preferences _setTelephoneNumberParsingEnabled:NO];
 #endif
 
     [preferences _setTextAutosizingEnabled:NO];
@@ -936,7 +930,7 @@
     [preferences setUsePreHTML5ParserQuirks:NO];
     [preferences setAsynchronousSpellCheckingEnabled:NO];
 #if !PLATFORM(IOS_FAMILY)
-    ASSERT([preferences mockScrollbarsEnabled]);
+    [preferences setMockScrollbarsEnabled:YES];
 #endif
 
     [preferences setWebAudioEnabled:YES];
@@ -964,44 +958,52 @@
     [preferences setModernMediaControlsEnabled:YES];
 
     [preferences setCacheAPIEnabled:NO];
-    preferences.mediaCapabilitiesEnabled = YES;
+    [preferences setMediaCapabilitiesEnabled:YES];
 
-    preferences.selectionAcrossShadowBoundariesEnabled = YES;
+    [preferences setSelectionAcrossShadowBoundariesEnabled:YES];
 
     [preferences setWebSQLEnabled:YES];
+    [preferences _setMediaRecorderEnabled:YES];
 
     [WebPreferences _clearNetworkLoaderSession];
     [WebPreferences _setCurrentNetworkLoaderSessionCookieAcceptPolicy:NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain];
 }
 
-static void setWebPreferencesForTestOptions(const WTR::TestOptions& options)
+static bool boolWebPreferenceFeatureValue(std::string key, bool defaultValue, const WTR::TestOptions& options)
 {
-    WebPreferences *preferences = [WebPreferences standardPreferences];
+    auto it = options.boolWebPreferenceFeatures().find(key);
+    if (it != options.boolWebPreferenceFeatures().end())
+        return it->second;
+    return defaultValue;
+}
 
-    preferences.attachmentElementEnabled = options.enableAttachmentElement;
-    preferences.acceleratedDrawingEnabled = options.enableAcceleratedDrawing;
-    preferences.menuItemElementEnabled = options.enableMenuItemElement;
-    preferences.keygenElementEnabled = options.enableKeygenElement;
-    preferences.modernMediaControlsEnabled = options.enableModernMediaControls;
-    preferences.inspectorAdditionsEnabled = options.enableInspectorAdditions;
-    preferences.allowCrossOriginSubresourcesToAskForCredentials = options.allowCrossOriginSubresourcesToAskForCredentials;
-    preferences.colorFilterEnabled = options.enableColorFilter;
-    preferences.selectionAcrossShadowBoundariesEnabled = options.enableSelectionAcrossShadowBoundaries;
-    preferences.webGPUEnabled = options.enableWebGPU;
-    preferences.CSSLogicalEnabled = options.enableCSSLogical;
-    preferences.lineHeightUnitsEnabled = options.enableLineHeightUnits;
-    preferences.adClickAttributionEnabled = options.adClickAttributionEnabled;
-    preferences.resizeObserverEnabled = options.enableResizeObserver;
-    preferences.CSSOMViewSmoothScrollingEnabled = options.enableCSSOMViewSmoothScrolling;
-    preferences.coreMathMLEnabled = options.enableCoreMathML;
-    preferences.requestIdleCallbackEnabled = options.enableRequestIdleCallback;
-    preferences.asyncClipboardAPIEnabled = options.enableAsyncClipboardAPI;
-    preferences.privateBrowsingEnabled = options.useEphemeralSession;
-    preferences.usesPageCache = options.enableBackForwardCache;
-    preferences.layoutFormattingContextIntegrationEnabled = options.layoutFormattingContextIntegrationEnabled;
-    preferences.aspectRatioOfImgFromWidthAndHeightEnabled = options.enableAspectRatioOfImgFromWidthAndHeight;
-    preferences.allowTopNavigationToDataURLs = options.allowTopNavigationToDataURLs;
-    preferences.contactPickerAPIEnabled = options.enableContactPickerAPI;
+static void setWebPreferencesForTestOptions(WebPreferences *preferences, const WTR::TestOptions& options)
+{
+    preferences.privateBrowsingEnabled = options.useEphemeralSession();
+
+    preferences.attachmentElementEnabled = boolWebPreferenceFeatureValue("AttachmentElementEnabled", false, options);
+    preferences.acceleratedDrawingEnabled = boolWebPreferenceFeatureValue("AcceleratedDrawingEnabled", false, options);
+    preferences.menuItemElementEnabled = boolWebPreferenceFeatureValue("MenuItemElementEnabled", false, options);
+    preferences.keygenElementEnabled = boolWebPreferenceFeatureValue("KeygenElementEnabled", false, options);
+    preferences.modernMediaControlsEnabled = boolWebPreferenceFeatureValue("ModernMediaControlsEnabled", true, options);
+    preferences.inspectorAdditionsEnabled = boolWebPreferenceFeatureValue("InspectorAdditionsEnabled", false, options);
+    preferences.allowCrossOriginSubresourcesToAskForCredentials = boolWebPreferenceFeatureValue("AllowCrossOriginSubresourcesToAskForCredentials", false, options);
+    preferences.colorFilterEnabled = boolWebPreferenceFeatureValue("ColorFilterEnabled", false, options);
+    preferences.selectionAcrossShadowBoundariesEnabled = boolWebPreferenceFeatureValue("SelectionAcrossShadowBoundariesEnabled", true, options);
+    preferences.webGPUEnabled = boolWebPreferenceFeatureValue("WebGPUEnabled", false, options);
+    preferences.CSSLogicalEnabled = boolWebPreferenceFeatureValue("CSSLogicalEnabled", false, options);
+    preferences.lineHeightUnitsEnabled = boolWebPreferenceFeatureValue("LineHeightUnitsEnabled", false, options);
+    preferences.adClickAttributionEnabled = boolWebPreferenceFeatureValue("AdClickAttributionEnabled", false, options);
+    preferences.resizeObserverEnabled = boolWebPreferenceFeatureValue("ResizeObserverEnabled", false, options);
+    preferences.CSSOMViewSmoothScrollingEnabled = boolWebPreferenceFeatureValue("CSSOMViewSmoothScrollingEnabled", false, options);
+    preferences.coreMathMLEnabled = boolWebPreferenceFeatureValue("CoreMathMLEnabled", false, options);
+    preferences.requestIdleCallbackEnabled = boolWebPreferenceFeatureValue("RequestIdleCallbackEnabled", false, options);
+    preferences.asyncClipboardAPIEnabled = boolWebPreferenceFeatureValue("AsyncClipboardAPIEnabled", false, options);
+    preferences.usesPageCache = boolWebPreferenceFeatureValue("UsesBackForwardCache", false, options);
+    preferences.layoutFormattingContextIntegrationEnabled = boolWebPreferenceFeatureValue("LayoutFormattingContextIntegrationEnabled", true, options);
+    preferences.aspectRatioOfImgFromWidthAndHeightEnabled = boolWebPreferenceFeatureValue("AspectRatioOfImgFromWidthAndHeightEnabled", false, options);
+    preferences.allowTopNavigationToDataURLs = boolWebPreferenceFeatureValue("AllowTopNavigationToDataURLs", true, options);
+    preferences.contactPickerAPIEnabled = boolWebPreferenceFeatureValue("ContactPickerAPIEnabled", false, options);
 }
 
 // Called once on DumpRenderTree startup.
@@ -1438,7 +1440,7 @@
 
 static NSData *dumpAudio()
 {
-    const vector<char>& dataVector = gTestRunner->audioResult();
+    const auto& dataVector = gTestRunner->audioResult();
 
     NSData *data = "" dataWithBytes:dataVector.data() length:dataVector.size()];
     return data;
@@ -1634,7 +1636,7 @@
     [uiDelegate resetWindowOrigin];
 
     // W3C SVG tests expect to be 480x360
-    bool isSVGW3CTest = (gTestRunner->testURL().find("svg/W3C-SVG-1.1") != string::npos);
+    bool isSVGW3CTest = (gTestRunner->testURL().find("svg/W3C-SVG-1.1") != std::string::npos);
     NSSize frameSize = isSVGW3CTest ? NSMakeSize(TestRunner::w3cSVGViewWidth, TestRunner::w3cSVGViewHeight) : NSMakeSize(TestRunner::viewWidth, TestRunner::viewHeight);
     [[mainFrame webView] setFrameSize:frameSize];
     [[mainFrame frameView] setFrame:NSMakeRect(0, 0, frameSize.width, frameSize.height)];
@@ -1833,9 +1835,9 @@
         savedOptions.clear();
     }
 
-    if (options.jscOptions.length()) {
+    if (options.jscOptions().length()) {
         JSC::Options::dumpAllOptionsInALine(savedOptions);
-        JSC::Options::setOptions(options.jscOptions.c_str());
+        JSC::Options::setOptions(options.jscOptions().c_str());
     }
 }
 
@@ -1874,10 +1876,10 @@
 
     [WebCache clearCachedCredentials];
 
-    resetWebPreferencesToConsistentValues();
-    setWebPreferencesForTestOptions(options);
+    resetWebPreferencesToConsistentValues(webView.preferences);
+    setWebPreferencesForTestOptions(webView.preferences, options);
 #if PLATFORM(MAC)
-    [webView setWantsLayer:options.layerBackedWebView];
+    [webView setWantsLayer:options.layerBackedWebView()];
 #endif
 
     TestRunner::setSerializeHTTPLoads(false);
@@ -1921,7 +1923,7 @@
     [[NSPasteboard generalPasteboard] declareTypes:@[NSStringPboardType] owner:nil];
 #endif
 
-    WebCoreTestSupport::setAdditionalSupportedImageTypesForTesting(options.additionalSupportedImageTypes.c_str());
+    WebCoreTestSupport::setAdditionalSupportedImageTypesForTesting(options.additionalSupportedImageTypes().c_str());
 
     [mainFrame _clearOpener];
 
@@ -1977,7 +1979,7 @@
 
 static WTR::TestOptions testOptionsForTest(const WTR::TestCommand& command)
 {
-    WTR::TestFeatures features;
+    WTR::TestFeatures features = WTR::TestOptions::defaults();
     WTR::merge(features, WTR::hardcodedFeaturesBasedOnPathForTest(command));
     WTR::merge(features, WTR::featureDefaultsFromTestHeaderForTest(command, WTR::TestOptions::keyTypeMapping()));
 
@@ -1984,12 +1986,12 @@
     return WTR::TestOptions { WTFMove(features) };
 }
 
-static void runTest(const string& inputLine)
+static void runTest(const std::string& inputLine)
 {
     ASSERT(!inputLine.empty());
 
     auto command = WTR::parseInputLine(inputLine);
-    const string& pathOrURL = command.pathOrURL;
+    auto pathOrURL = command.pathOrURL;
     dumpPixelsForCurrentTest = command.shouldDumpPixels || dumpPixelsForAllTests;
 
     NSString *pathOrURLString = [NSString stringWithUTF8String:pathOrURL.c_str()];
@@ -2024,7 +2026,7 @@
     gTestRunner = TestRunner::create(testURL, command.expectedPixelHash);
     gTestRunner->setAllowedHosts(allowedHosts);
     gTestRunner->setCustomTimeout(command.timeout.milliseconds());
-    gTestRunner->setDumpJSConsoleLogInStdErr(command.dumpJSConsoleLogInStdErr || options.dumpJSConsoleLogInStdErr);
+    gTestRunner->setDumpJSConsoleLogInStdErr(command.dumpJSConsoleLogInStdErr || options.dumpJSConsoleLogInStdErr());
 
     resetWebViewToConsistentState(options, ResetTime::BeforeTest);
 

Modified: trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm (268794 => 268795)


--- trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm	2020-10-21 14:06:02 UTC (rev 268794)
+++ trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm	2020-10-21 15:04:20 UTC (rev 268795)
@@ -576,7 +576,7 @@
 
 void TestRunner::setUserStyleSheetEnabled(bool flag)
 {
-    [[WebPreferences standardPreferences] setUserStyleSheetEnabled:flag];
+    [[[mainFrame webView] preferences] setUserStyleSheetEnabled:flag];
 }
 
 void TestRunner::setUserStyleSheetLocation(JSStringRef path)
@@ -583,7 +583,7 @@
 {
     RetainPtr<CFStringRef> pathCF = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, path));
     NSURL *url = "" URLWithString:(__bridge NSString *)pathCF.get()];
-    [[WebPreferences standardPreferences] setUserStyleSheetLocation:url];
+    [[[mainFrame webView] preferences] setUserStyleSheetLocation:url];
 }
 
 void TestRunner::setValueForUser(JSContextRef context, JSValueRef nodeObject, JSStringRef value)
@@ -609,7 +609,7 @@
     RetainPtr<CFStringRef> valueCF = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, value));
     NSString *valueNS = (__bridge NSString *)valueCF.get();
 
-    [[WebPreferences standardPreferences] _setPreferenceForTestWithValue:valueNS forKey:keyNS];
+    [[[mainFrame webView] preferences] _setPreferenceForTestWithValue:valueNS forKey:keyNS];
 }
 
 void TestRunner::removeAllVisitedLinks()
@@ -700,7 +700,7 @@
 
 void TestRunner::setCacheModel(int cacheModel)
 {
-    [[WebPreferences standardPreferences] setCacheModel:(WebCacheModel)cacheModel];
+    [[[mainFrame webView] preferences] setCacheModel:(WebCacheModel)cacheModel];
 }
 
 bool TestRunner::isCommandEnabled(JSStringRef name)

Modified: trunk/Tools/DumpRenderTree/mac/UIDelegate.mm (268794 => 268795)


--- trunk/Tools/DumpRenderTree/mac/UIDelegate.mm	2020-10-21 14:06:02 UTC (rev 268794)
+++ trunk/Tools/DumpRenderTree/mac/UIDelegate.mm	2020-10-21 15:04:20 UTC (rev 268795)
@@ -60,7 +60,7 @@
 
 - (void)resetToConsistentStateBeforeTesting:(const WTR::TestOptions&)options
 {
-    m_enableDragDestinationActionLoad = options.enableDragDestinationActionLoad;
+    m_enableDragDestinationActionLoad = options.enableDragDestinationActionLoad();
 }
 
 - (void)webView:(WebView *)sender setFrame:(NSRect)frame
@@ -179,7 +179,8 @@
     ASSERT(gTestRunner->waitToDump());
 
     WebView *webView = createWebViewAndOffscreenWindow();
-    
+    [webView setPreferences:[sender preferences]];
+
     if (gTestRunner->newWindowsCopyBackForwardList())
         [webView _loadBackForwardListFromOtherView:sender];
     

Modified: trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp (268794 => 268795)


--- trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp	2020-10-21 14:06:02 UTC (rev 268794)
+++ trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp	2020-10-21 15:04:20 UTC (rev 268795)
@@ -906,6 +906,8 @@
 
     preferences->setFontSmoothing(FontSmoothingTypeStandard);
 
+    prefsPrivate->setWebSQLEnabled(true);
+
     prefsPrivate->setDataTransferItemsEnabled(TRUE);
     prefsPrivate->clearNetworkLoaderSession();
 
@@ -912,22 +914,29 @@
     setAlwaysAcceptCookies(false);
 }
 
+static bool boolWebPreferenceFeatureValue(std::string key, bool defaultValue, const WTR::TestOptions& options)
+{
+    auto it = options.boolWebPreferenceFeatures().find(key);
+    if (it != options.boolWebPreferenceFeatures().end())
+        return it->second;
+    return defaultValue;
+}
+
 static void setWebPreferencesForTestOptions(IWebPreferences* preferences, const WTR::TestOptions& options)
 {
     COMPtr<IWebPreferencesPrivate8> prefsPrivate { Query, preferences };
 
-    prefsPrivate->setMenuItemElementEnabled(options.enableMenuItemElement);
-    prefsPrivate->setKeygenElementEnabled(options.enableKeygenElement);
-    prefsPrivate->setModernMediaControlsEnabled(options.enableModernMediaControls);
-    prefsPrivate->setInspectorAdditionsEnabled(options.enableInspectorAdditions);
-    prefsPrivate->setRequestIdleCallbackEnabled(options.enableRequestIdleCallback);
-    prefsPrivate->setAsyncClipboardAPIEnabled(options.enableAsyncClipboardAPI);
-    prefsPrivate->setContactPickerAPIEnabled(options.enableContactPickerAPI);
-    prefsPrivate->setWebSQLEnabled(options.enableWebSQL);
-    prefsPrivate->setAllowTopNavigationToDataURLs(options.allowTopNavigationToDataURLs);
-    preferences->setPrivateBrowsingEnabled(options.useEphemeralSession);
-    preferences->setUsesPageCache(options.enableBackForwardCache);
-    prefsPrivate->setCSSOMViewSmoothScrollingEnabled(options.enableCSSOMViewSmoothScrolling);
+    preferences->setPrivateBrowsingEnabled(options.useEphemeralSession());
+    preferences->setUsesPageCache(boolWebPreferenceFeatureValue("UsesBackForwardCache", false, options));
+    prefsPrivate->setMenuItemElementEnabled(boolWebPreferenceFeatureValue("MenuItemElementEnabled", false, options));
+    prefsPrivate->setKeygenElementEnabled(boolWebPreferenceFeatureValue("KeygenElementEnabled", false, options));
+    prefsPrivate->setModernMediaControlsEnabled(boolWebPreferenceFeatureValue("ModernMediaControlsEnabled", true, options));
+    prefsPrivate->setInspectorAdditionsEnabled(boolWebPreferenceFeatureValue("InspectorAdditionsEnabled", false, options));
+    prefsPrivate->setRequestIdleCallbackEnabled(boolWebPreferenceFeatureValue("RequestIdleCallbackEnabled", false, options));
+    prefsPrivate->setAsyncClipboardAPIEnabled(boolWebPreferenceFeatureValue("AsyncClipboardAPIEnabled", false, options));
+    prefsPrivate->setContactPickerAPIEnabled(boolWebPreferenceFeatureValue("ContactPickerAPIEnabled", false, options));
+    prefsPrivate->setAllowTopNavigationToDataURLs(boolWebPreferenceFeatureValue("AllowTopNavigationToDataURLs", true, options));
+    prefsPrivate->setCSSOMViewSmoothScrollingEnabled(boolWebPreferenceFeatureValue("CSSOMViewSmoothScrollingEnabled", false, options));
 }
 
 static String applicationId()
@@ -973,9 +982,9 @@
         savedOptions.clear();
     }
 
-    if (options.jscOptions.length()) {
+    if (!options.jscOptions().empty()) {
         JSC::Options::dumpAllOptionsInALine(savedOptions);
-        JSC::Options::setOptions(options.jscOptions.c_str());
+        JSC::Options::setOptions(options.jscOptions().c_str());
     }
 }
 
@@ -1168,7 +1177,7 @@
 
 static WTR::TestOptions testOptionsForTest(const WTR::TestCommand& command)
 {
-    WTR::TestFeatures features;
+    WTR::TestFeatures features = WTR::TestOptions::defaults();
     WTR::merge(features, WTR::hardcodedFeaturesBasedOnPathForTest(command));
     WTR::merge(features, WTR::featureDefaultsFromTestHeaderForTest(command, WTR::TestOptions::keyTypeMapping()));
 
@@ -1229,7 +1238,7 @@
 
     ::gTestRunner = TestRunner::create(testURL.data(), command.expectedPixelHash);
     ::gTestRunner->setCustomTimeout(command.timeout.milliseconds());
-    ::gTestRunner->setDumpJSConsoleLogInStdErr(command.dumpJSConsoleLogInStdErr || options.dumpJSConsoleLogInStdErr);
+    ::gTestRunner->setDumpJSConsoleLogInStdErr(command.dumpJSConsoleLogInStdErr || options.dumpJSConsoleLogInStdErr());
 
     topLoadingFrame = nullptr;
     done = false;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to