Changeset 268604 in webkit


Ignore:
Timestamp:
Oct 16, 2020 12:37:06 PM (4 years ago)
Author:
weinig@apple.com
Message:

[Testing] Support configuring any preference from test headers for WebKitTestRunner
https://bugs.webkit.org/show_bug.cgi?id=217645

Reviewed by Tim Horton.

Support using any preference defined in any of the WebPreference*.yaml configuration files
as a test header command rather than limiting it to a hard coded subset by generating the
list of supported commands and their types from the yaml files themselves.

This currently only works for WebKitTestRunner, but will be made to work with DumpRenderTree
in subsequent changes.

  • WebKitTestRunner/CMakeLists.txt:
  • WebKitTestRunner/Configurations/Base.xcconfig:
  • WebKitTestRunner/DerivedSources-input.xcfilelist:
  • WebKitTestRunner/DerivedSources-output.xcfilelist:
  • WebKitTestRunner/DerivedSources.make:
  • WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
  • WebKitTestRunner/Scripts/PreferencesTemplates: Added.
  • WebKitTestRunner/Scripts/PreferencesTemplates/TestOptionsGeneratedKeys.h.erb: Added.

Add generation of TestOptionsGeneratedKeys.h from the WebPreference*.yaml using
the shared GeneratePreferences.rb script in WTF.

  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::resetPreferencesToConsistentValues):
Move preference setting to the bottom of the file to allow any preference
to be overriden. Also adds in support for double, uint32_t, and string preferences
though none of those are currently being used.

  • WebKitTestRunner/TestOptions.cpp:

(WTR::TestOptions::keyTypeMapping):
Use generated macro GENERATED_WEB_PREFERENCE_KEY_TYPE_MAPPINGS rather than hardcoding
all the preferences types.

  • WebKitTestRunner/TestOptions.h:

(WTR::TestOptions::boolWebPreferenceFeatures const):
(WTR::TestOptions::doubleWebPreferenceFeatures const):
(WTR::TestOptions::uint32WebPreferenceFeatures const):
(WTR::TestOptions::stringWebPreferenceFeatures const):
Expose accessors for preferences values for use in setting the actual preference
values. Rather than setting all preferences, we now only set preferences that have
been explicitly requested, using the default value for any that have not.

Location:
trunk/Tools
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r268601 r268604  
     12020-10-16  Sam Weinig  <weinig@apple.com>
     2
     3        [Testing] Support configuring any preference from test headers for WebKitTestRunner
     4        https://bugs.webkit.org/show_bug.cgi?id=217645
     5
     6        Reviewed by Tim Horton.
     7
     8        Support using any preference defined in any of the WebPreference*.yaml configuration files
     9        as a test header command rather than limiting it to a hard coded subset by generating the
     10        list of supported commands and their types from the yaml files themselves.
     11       
     12        This currently only works for WebKitTestRunner, but will be made to work with DumpRenderTree
     13        in subsequent changes.
     14
     15        * WebKitTestRunner/CMakeLists.txt:
     16        * WebKitTestRunner/Configurations/Base.xcconfig:
     17        * WebKitTestRunner/DerivedSources-input.xcfilelist:
     18        * WebKitTestRunner/DerivedSources-output.xcfilelist:
     19        * WebKitTestRunner/DerivedSources.make:
     20        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
     21        * WebKitTestRunner/Scripts/PreferencesTemplates: Added.
     22        * WebKitTestRunner/Scripts/PreferencesTemplates/TestOptionsGeneratedKeys.h.erb: Added.
     23        Add generation of TestOptionsGeneratedKeys.h from the WebPreference*.yaml using
     24        the shared GeneratePreferences.rb script in WTF.
     25
     26        * WebKitTestRunner/TestController.cpp:
     27        (WTR::TestController::resetPreferencesToConsistentValues):
     28        Move preference setting to the bottom of the file to allow any preference
     29        to be overriden. Also adds in support for double, uint32_t, and string preferences
     30        though none of those are currently being used.
     31
     32        * WebKitTestRunner/TestOptions.cpp:
     33        (WTR::TestOptions::keyTypeMapping):
     34        Use generated macro GENERATED_WEB_PREFERENCE_KEY_TYPE_MAPPINGS rather than hardcoding
     35        all the preferences types.
     36
     37        * WebKitTestRunner/TestOptions.h:
     38        (WTR::TestOptions::boolWebPreferenceFeatures const):
     39        (WTR::TestOptions::doubleWebPreferenceFeatures const):
     40        (WTR::TestOptions::uint32WebPreferenceFeatures const):
     41        (WTR::TestOptions::stringWebPreferenceFeatures const):
     42        Expose accessors for preferences values for use in setting the actual preference
     43        values. Rather than setting all preferences, we now only set preferences that have
     44        been explicitly requested, using the default value for any that have not.
     45
    1462020-10-16  Aakash Jain  <aakash_jain@apple.com>
    247
  • trunk/Tools/WebKitTestRunner/CMakeLists.txt

    r268498 r268604  
    3131    ${WebKitTestRunner_SHARED_DIR}
    3232    ${WebKitTestRunner_BINDINGS_DIR}
     33    ${WebKitTestRunner_DERIVED_SOURCES_DIR}
    3334    ${WebKitTestRunner_DERIVED_SOURCES_DIR}/UIScriptContext
    3435    ${WebKitTestRunner_DIR}
     
    4243list(APPEND WebKitTestRunner_INCLUDE_DIRECTORIES
    4344    ${WebCore_PRIVATE_FRAMEWORK_HEADERS_DIR}
     45)
     46
     47set(WebKitTestRunner_WEB_PREFERENCES_TEMPLATES
     48    ${WebKitTestRunner_DIR}/Scripts/PreferencesTemplates/TestOptionsGeneratedKeys.h.erb
     49)
     50
     51set(WebKitTestRunner_WEB_PREFERENCES
     52    ${WTF_SCRIPTS_DIR}/Preferences/WebPreferences.yaml
     53    ${WTF_SCRIPTS_DIR}/Preferences/WebPreferencesDebug.yaml
     54    ${WTF_SCRIPTS_DIR}/Preferences/WebPreferencesExperimental.yaml
     55    ${WTF_SCRIPTS_DIR}/Preferences/WebPreferencesInternal.yaml
     56)
     57
     58set_source_files_properties(${WebKitTestRunner_WEB_PREFERENCES} PROPERTIES GENERATED TRUE)
     59
     60add_custom_command(
     61    OUTPUT ${WebKitTestRunner_DERIVED_SOURCES_DIR}/TestOptionsGeneratedKeys.h
     62    DEPENDS ${WebKitTestRunner_WEB_PREFERENCES_TEMPLATES} ${WebKitTestRunner_WEB_PREFERENCES} WTF_CopyPreferences
     63    COMMAND ${RUBY_EXECUTABLE} ${WTF_SCRIPTS_DIR}/GeneratePreferences.rb --frontend WebKit --base ${WTF_SCRIPTS_DIR}/Preferences/WebPreferences.yaml --debug ${WTF_SCRIPTS_DIR}/Preferences/WebPreferencesDebug.yaml --experimental ${WTF_SCRIPTS_DIR}/Preferences/WebPreferencesExperimental.yaml --internal ${WTF_SCRIPTS_DIR}/Preferences/WebPreferencesInternal.yaml --outputDir "${WebKitTestRunner_DERIVED_SOURCES_DIR}" --template ${WebKitTestRunner_DIR}/Scripts/PreferencesTemplates/TestOptionsGeneratedKeys.h.erb
     64    VERBATIM)
     65
     66list(APPEND WebKitTestRunner_SOURCES
     67    ${WebKitTestRunner_DERIVED_SOURCES_DIR}/TestOptionsGeneratedKeys.h
    4468)
    4569
  • trunk/Tools/WebKitTestRunner/Configurations/Base.xcconfig

    r268498 r268604  
    101101PRODUCTION_FRAMEWORKS_DIR[sdk=macosx*] = $(SDKROOT)$(NEXT_ROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/WebKit.framework/Versions/A/Frameworks;
    102102
     103WTF_BUILD_SCRIPTS_DIR = $(WTF_BUILD_SCRIPTS_DIR_$(CONFIGURATION));
     104WTF_BUILD_SCRIPTS_DIR_Release = $(WTF_BUILD_SCRIPTS_DIR_engineering);
     105WTF_BUILD_SCRIPTS_DIR_Debug = $(WTF_BUILD_SCRIPTS_DIR_engineering);
     106WTF_BUILD_SCRIPTS_DIR_Production = $(WTF_BUILD_SCRIPTS_DIR_Production_COCOA_TOUCH_$(WK_IS_COCOA_TOUCH));
     107WTF_BUILD_SCRIPTS_DIR_Production_COCOA_TOUCH_YES = $(SDKROOT)$(WK_ALTERNATE_WEBKIT_SDK_PATH)/usr/local/include/wtf/Scripts;
     108WTF_BUILD_SCRIPTS_DIR_Production_COCOA_TOUCH_NO = $(SDKROOT)/usr/local/include/wtf/Scripts;
     109WTF_BUILD_SCRIPTS_DIR_engineering = $(BUILT_PRODUCTS_DIR)/usr/local/include/wtf/Scripts;
     110
    103111WEBCORE_PRIVATE_HEADERS_DIR = $(WEBCORE_PRIVATE_HEADERS_DIR_$(CONFIGURATION));
    104112WEBCORE_PRIVATE_HEADERS_DIR_Release = $(WEBCORE_PRIVATE_HEADERS_DIR_engineering);
     
    124132WK_COCOA_TOUCH_appletvos = cocoatouch;
    125133WK_COCOA_TOUCH_appletvsimulator = cocoatouch;
     134WK_IS_COCOA_TOUCH = $(WK_NOT_$(WK_EMPTY_$(WK_COCOA_TOUCH)));
    126135
    127136HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include $(BUILT_PRODUCTS_DIR)/WebCoreTestSupport $(WEBCORE_PRIVATE_HEADERS_DIR)/ForwardingHeaders $(NEXT_ROOT)/usr/local/include/WebCoreTestSupport $(HEADER_SEARCH_PATHS_$(WK_COCOA_TOUCH));
  • trunk/Tools/WebKitTestRunner/DerivedSources-input.xcfilelist

    r268498 r268604  
    11# This file is generated by the generate-xcfilelists script.
     2$(BUILT_PRODUCTS_DIR)/usr/local/include/wtf/Scripts/GeneratePreferences.rb
     3$(BUILT_PRODUCTS_DIR)/usr/local/include/wtf/Scripts/Preferences/WebPreferences.yaml
     4$(BUILT_PRODUCTS_DIR)/usr/local/include/wtf/Scripts/Preferences/WebPreferencesDebug.yaml
     5$(BUILT_PRODUCTS_DIR)/usr/local/include/wtf/Scripts/Preferences/WebPreferencesExperimental.yaml
     6$(BUILT_PRODUCTS_DIR)/usr/local/include/wtf/Scripts/Preferences/WebPreferencesInternal.yaml
    27$(PROJECT_DIR)/../TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
    38$(PROJECT_DIR)/InjectedBundle/Bindings/AccessibilityController.idl
     
    1015$(PROJECT_DIR)/InjectedBundle/Bindings/TestRunner.idl
    1116$(PROJECT_DIR)/InjectedBundle/Bindings/TextInputController.idl
     17$(PROJECT_DIR)/Scripts/PreferencesTemplates/TestOptionsGeneratedKeys.h.erb
    1218$(WEBCORE_PRIVATE_HEADERS_DIR)/CodeGenerator.pm
    1319$(WEBCORE_PRIVATE_HEADERS_DIR)/IDLAttributes.json
  • trunk/Tools/WebKitTestRunner/DerivedSources-output.xcfilelist

    r268498 r268604  
    1818$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKitTestRunner/JSUIScriptController.cpp
    1919$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKitTestRunner/JSUIScriptController.h
     20$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKitTestRunner/TestOptionsGeneratedKeys.h
  • trunk/Tools/WebKitTestRunner/DerivedSources.make

    r268498 r268604  
    1 # Copyright (C) 2010 Apple Inc. All rights reserved.
     1# Copyright (C) 2010-2020 Apple Inc. All rights reserved.
    22#
    33# Redistribution and use in source and binary forms, with or without
     
    2626    $(WebKitTestRunner)/../TestRunnerShared/UIScriptContext/Bindings \
    2727#
     28
     29RUBY = ruby
     30
     31WEB_PREFERENCES = \
     32    ${WTF_BUILD_SCRIPTS_DIR}/Preferences/WebPreferences.yaml \
     33    ${WTF_BUILD_SCRIPTS_DIR}/Preferences/WebPreferencesDebug.yaml \
     34    ${WTF_BUILD_SCRIPTS_DIR}/Preferences/WebPreferencesExperimental.yaml \
     35    ${WTF_BUILD_SCRIPTS_DIR}/Preferences/WebPreferencesInternal.yaml \
     36#
     37
     38WEB_PREFERENCES_TEMPLATES = \
     39    $(WebKitTestRunner)/Scripts/PreferencesTemplates/TestOptionsGeneratedKeys.h.erb \
     40#
     41WEB_PREFERENCES_FILES = $(basename $(notdir $(WEB_PREFERENCES_TEMPLATES)))
     42WEB_PREFERENCES_PATTERNS = $(subst .erb,,$(WEB_PREFERENCES_FILES))
     43
     44all : $(WEB_PREFERENCES_FILES)
     45
     46$(WEB_PREFERENCES_PATTERNS) : $(WTF_BUILD_SCRIPTS_DIR)/GeneratePreferences.rb $(WEB_PREFERENCES_TEMPLATES) $(WEB_PREFERENCES)
     47        $(RUBY) $< --frontend WebKit --base ${WTF_BUILD_SCRIPTS_DIR}/Preferences/WebPreferences.yaml --debug ${WTF_BUILD_SCRIPTS_DIR}/Preferences/WebPreferencesDebug.yaml --experimental ${WTF_BUILD_SCRIPTS_DIR}/Preferences/WebPreferencesExperimental.yaml --internal ${WTF_BUILD_SCRIPTS_DIR}/Preferences/WebPreferencesInternal.yaml $(addprefix --template , $(WEB_PREFERENCES_TEMPLATES))
     48
    2849
    2950INJECTED_BUNDLE_INTERFACES = \
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r268498 r268604  
    470470    m_allowAnyHTTPSCertificateForAllowedHosts = options.allowAnyHTTPSCertificateForAllowedHosts;
    471471
     472    m_globalFeatures = TestOptions::defaults();
    472473    m_globalFeatures.internalDebugFeatures = options.internalFeatures;
    473474    m_globalFeatures.experimentalFeatures = options.experimentalFeatures;
     
    498499}
    499500
    500 WKRetainPtr<WKContextConfigurationRef> TestController::generateContextConfiguration(const ContextOptions& options) const
     501WKRetainPtr<WKContextConfigurationRef> TestController::generateContextConfiguration(const TestOptions& options) const
    501502{
    502503    auto configuration = adoptWK(WKContextConfigurationCreate());
    503504    WKContextConfigurationSetInjectedBundlePath(configuration.get(), injectedBundlePath());
    504505    WKContextConfigurationSetFullySynchronousModeIsAllowedForTesting(configuration.get(), true);
    505     WKContextConfigurationSetIgnoreSynchronousMessagingTimeoutsForTesting(configuration.get(), options.ignoreSynchronousMessagingTimeouts);
     506    WKContextConfigurationSetIgnoreSynchronousMessagingTimeoutsForTesting(configuration.get(), options.ignoreSynchronousMessagingTimeouts());
    506507
    507508    auto overrideLanguages = adoptWK(WKMutableArrayCreate());
    508     for (auto& language : options.overrideLanguages)
     509    for (auto& language : options.overrideLanguages())
    509510        WKArrayAppendItem(overrideLanguages.get(), toWK(language).get());
    510511    WKContextConfigurationSetOverrideLanguages(configuration.get(), overrideLanguages.get());
     
    512513    if (options.shouldEnableProcessSwapOnNavigation()) {
    513514        WKContextConfigurationSetProcessSwapsOnNavigation(configuration.get(), true);
    514         if (options.enableProcessSwapOnWindowOpen)
     515        if (options.enableProcessSwapOnWindowOpen())
    515516            WKContextConfigurationSetProcessSwapsOnWindowOpenWithOpener(configuration.get(), true);
    516517    }
     
    561562WKRetainPtr<WKPageConfigurationRef> TestController::generatePageConfiguration(const TestOptions& options)
    562563{
    563     auto contextOptions = options.contextOptions();
    564     if (!m_context || !m_contextOptions->hasSameInitializationOptions(contextOptions)) {
    565         auto contextConfiguration = generateContextConfiguration(contextOptions);
     564    if (!m_context || !m_mainWebView || !m_mainWebView->viewSupportsOptions(options)) {
     565        auto contextConfiguration = generateContextConfiguration(options);
    566566        m_context = platformAdjustContext(adoptWK(WKContextCreateWithConfiguration(contextConfiguration.get())).get(), contextConfiguration.get());
    567         m_contextOptions = contextOptions;
    568567
    569568        m_geolocationProvider = makeUnique<GeolocationProviderMock>(m_context.get());
     
    825824    }
    826825
    827 
    828826    createWebViewWithOptions(options);
    829827
     
    857855        WKPreferencesSetInternalDebugFeatureForKey(preferences, value, toWK(key).get());
    858856
    859     for (const auto& [key, value] : options.boolWKPreferences())
    860         WKPreferencesSetBoolValueForKey(preferences, value, toWK(key).get());
    861 
    862857    // FIXME: Convert these to default values for TestOptions.
    863     WKPreferencesSetProcessSwapOnNavigationEnabled(preferences, options.contextOptions().shouldEnableProcessSwapOnNavigation());
     858    WKPreferencesSetProcessSwapOnNavigationEnabled(preferences, options.shouldEnableProcessSwapOnNavigation());
    864859    WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true);
    865860    WKPreferencesSetSubpixelAntialiasedLayerTextEnabled(preferences, false);
     
    925920
    926921    platformResetPreferencesToConsistentValues();
     922
     923    for (const auto& [key, value] : options.boolWebPreferenceFeatures())
     924        WKPreferencesSetBoolValueForKey(preferences, value, toWK(key).get());
     925
     926    for (const auto& [key, value] : options.doubleWebPreferenceFeatures())
     927        WKPreferencesSetDoubleValueForKey(preferences, value, toWK(key).get());
     928
     929    for (const auto& [key, value] : options.uint32WebPreferenceFeatures())
     930        WKPreferencesSetUInt32ValueForKey(preferences, value, toWK(key).get());
     931
     932    for (const auto& [key, value] : options.stringWebPreferenceFeatures())
     933        WKPreferencesSetStringValueForKey(preferences, toWK(value).get(), toWK(key).get());
     934
    927935}
    928936
  • trunk/Tools/WebKitTestRunner/TestController.h

    r268458 r268604  
    354354private:
    355355    WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration(const TestOptions&);
    356     WKRetainPtr<WKContextConfigurationRef> generateContextConfiguration(const ContextOptions&) const;
     356    WKRetainPtr<WKContextConfigurationRef> generateContextConfiguration(const TestOptions&) const;
    357357    void initialize(int argc, const char* argv[]);
    358358    void createWebViewWithOptions(const TestOptions&);
     
    539539    std::unique_ptr<PlatformWebView> m_mainWebView;
    540540    WKRetainPtr<WKContextRef> m_context;
    541     Optional<ContextOptions> m_contextOptions;
    542541    WKRetainPtr<WKPageGroupRef> m_pageGroup;
    543542    WKRetainPtr<WKUserContentControllerRef> m_userContentController;
  • trunk/Tools/WebKitTestRunner/TestOptions.cpp

    r268498 r268604  
    2727#include "TestOptions.h"
    2828
    29 #include <fstream>
    30 #include <string>
     29#include "TestOptionsGeneratedKeys.h"
    3130#include <wtf/Assertions.h>
    32 #include <wtf/StdFilesystem.h>
    3331
    3432namespace WTR {
    3533
    36 static const std::unordered_map<std::string, bool>& boolWebPreferencesDefaultsMap()
    37 {
    38     static std::unordered_map<std::string, bool> map {
    39         { "AcceleratedDrawingEnabled", false },
    40         { "AllowCrossOriginSubresourcesToAskForCredentials", false },
    41         { "AllowTopNavigationToDataURLs", true },
    42         { "AttachmentElementEnabled", false },
    43         { "CaptureAudioInGPUProcessEnabled", false },
    44         { "CaptureAudioInUIProcessEnabled", false },
    45         { "CaptureVideoInGPUProcessEnabled", false },
    46         { "CaptureVideoInUIProcessEnabled", false },
    47         { "ColorFilterEnabled", false },
    48         { "DOMPasteAllowed", true },
    49         { "InspectorAdditionsEnabled", false },
    50         { "KeygenElementEnabled", false },
    51         { "MenuItemElementEnabled", false },
    52         { "MockScrollbarsEnabled", true },
    53         { "ModernMediaControlsEnabled", true },
    54         { "NeedsSiteSpecificQuirks", false },
    55         { "PageVisibilityBasedProcessSuppressionEnabled", false },
    56         { "PunchOutWhiteBackgroundsInDarkMode", false },
    57         { "ServiceControlsEnabled", false },
    58         { "ShouldIgnoreMetaViewport", false },
    59         { "ShouldUseServiceWorkerShortTimeout", false },
    60         { "UsesBackForwardCache", false },
    61         { "WebAuthenticationEnabled", true },
    62         { "WebAuthenticationLocalAuthenticatorEnabled", true },
    63     };
    64     return map;
    65 }
    66 
    67 static const std::unordered_map<std::string, bool>& boolTestRunnerDefaultsMap()
    68 {
    69     static std::unordered_map<std::string, bool> map {
    70         { "allowsLinkPreview", true },
    71         { "dumpJSConsoleLogInStdErr", false },
    72         { "editable", false },
    73         { "enableInAppBrowserPrivacy", false },
    74         { "enableProcessSwapOnNavigation", true },
    75         { "enableProcessSwapOnWindowOpen", false },
    76         { "ignoreSynchronousMessagingTimeouts", false },
    77         { "ignoresViewportScaleLimits", false },
    78         { "isAppBoundWebView", false },
    79         { "runSingly", false },
    80         { "shouldHandleRunOpenPanel", true },
    81         { "shouldPresentPopovers", true },
    82         { "shouldShowTouches", false },
    83         { "shouldShowWebView", false },
    84         { "spellCheckingDots", false },
    85         { "useCharacterSelectionGranularity", false },
    86         { "useDataDetection", false },
    87         { "useEphemeralSession", false },
    88         { "useFlexibleViewport", false },
    89         { "useRemoteLayerTree", false },
    90         { "useThreadedScrolling", false },
    91     };
    92     return map;
    93 }
    94 
    95 static const std::unordered_map<std::string, double>& doubleTestRunnerDefaultsMap()
    96 {
    97     static std::unordered_map<std::string, double> map {
    98         { "contentInset.top", 0 },
    99         { "deviceScaleFactor", 1 },
    100         { "viewHeight", 600 },
    101         { "viewWidth", 800 },
    102     };
    103     return map;
    104 }
    105 
    106 static const std::unordered_map<std::string, std::string>& stringTestRunnerDefaultsMap()
    107 {
    108     static std::unordered_map<std::string, std::string> map {
    109         { "additionalSupportedImageTypes", { } },
    110         { "applicationBundleIdentifier", { } },
    111         { "applicationManifest", { } },
    112         { "contentMode", { } },
    113         { "jscOptions", { } },
    114         { "standaloneWebApplicationURL", { } },
    115     };
    116     return map;
    117 }
    118 
    119 static const std::unordered_map<std::string, std::vector<std::string>>& stringVectorTestRunnerDefaultsMap()
    120 {
    121     static std::unordered_map<std::string, std::vector<std::string>> map {
    122         { "language", { } },
    123     };
    124     return map;
     34const TestFeatures& TestOptions::defaults()
     35{
     36    static TestFeatures features;
     37    if (features.boolWebPreferenceFeatures.empty()) {
     38        features.boolWebPreferenceFeatures = {
     39            // These are WebPreference values that must always be set as they may
     40            // differ from the default set in the WebPreferences*.yaml configuration.
     41            { "AllowTopNavigationToDataURLs", true },
     42            { "CaptureAudioInGPUProcessEnabled", false },
     43            { "CaptureAudioInUIProcessEnabled", false },
     44            { "CaptureVideoInGPUProcessEnabled", false },
     45            { "CaptureVideoInUIProcessEnabled", false },
     46            { "DOMPasteAllowed", true },
     47            { "MockScrollbarsEnabled", true },
     48            { "ModernMediaControlsEnabled", true },
     49            { "NeedsSiteSpecificQuirks", false },
     50            { "PageVisibilityBasedProcessSuppressionEnabled", false },
     51            { "UsesBackForwardCache", false },
     52            { "WebAuthenticationEnabled", true },
     53            { "WebAuthenticationLocalAuthenticatorEnabled", true },
     54        };
     55        features.boolTestRunnerFeatures = {
     56            { "allowsLinkPreview", true },
     57            { "dumpJSConsoleLogInStdErr", false },
     58            { "editable", false },
     59            { "enableInAppBrowserPrivacy", false },
     60            { "enableProcessSwapOnNavigation", true },
     61            { "enableProcessSwapOnWindowOpen", false },
     62            { "ignoreSynchronousMessagingTimeouts", false },
     63            { "ignoresViewportScaleLimits", false },
     64            { "isAppBoundWebView", false },
     65            { "runSingly", false },
     66            { "shouldHandleRunOpenPanel", true },
     67            { "shouldPresentPopovers", true },
     68            { "shouldShowTouches", false },
     69            { "shouldShowWebView", false },
     70            { "spellCheckingDots", false },
     71            { "useCharacterSelectionGranularity", false },
     72            { "useDataDetection", false },
     73            { "useEphemeralSession", false },
     74            { "useFlexibleViewport", false },
     75            { "useRemoteLayerTree", false },
     76            { "useThreadedScrolling", false },
     77        };
     78        features.doubleTestRunnerFeatures = {
     79            { "contentInset.top", 0 },
     80            { "deviceScaleFactor", 1 },
     81            { "viewHeight", 600 },
     82            { "viewWidth", 800 },
     83        };
     84        features.stringTestRunnerFeatures = {
     85            { "additionalSupportedImageTypes", { } },
     86            { "applicationBundleIdentifier", { } },
     87            { "applicationManifest", { } },
     88            { "contentMode", { } },
     89            { "jscOptions", { } },
     90            { "standaloneWebApplicationURL", { } },
     91        };
     92        features.stringVectorTestRunnerFeatures = {
     93            { "language", { } },
     94        };
     95    }
     96   
     97    return features;
    12598}
    12699
    127100const std::unordered_map<std::string, TestHeaderKeyType>& TestOptions::keyTypeMapping()
    128101{
    129     static std::unordered_map<std::string, TestHeaderKeyType> map {
    130         { "AcceleratedDrawingEnabled", TestHeaderKeyType::BoolWebPreference },
    131         { "AllowCrossOriginSubresourcesToAskForCredentials", TestHeaderKeyType::BoolWebPreference },
    132         { "AllowTopNavigationToDataURLs", TestHeaderKeyType::BoolWebPreference },
    133         { "AttachmentElementEnabled", TestHeaderKeyType::BoolWebPreference },
    134         { "CaptureAudioInGPUProcessEnabled", TestHeaderKeyType::BoolWebPreference },
    135         { "CaptureAudioInUIProcessEnabled", TestHeaderKeyType::BoolWebPreference },
    136         { "CaptureVideoInGPUProcessEnabled", TestHeaderKeyType::BoolWebPreference },
    137         { "CaptureVideoInUIProcessEnabled", TestHeaderKeyType::BoolWebPreference },
    138         { "ColorFilterEnabled", TestHeaderKeyType::BoolWebPreference },
    139         { "DOMPasteAllowed", TestHeaderKeyType::BoolWebPreference },
    140         { "InspectorAdditionsEnabled", TestHeaderKeyType::BoolWebPreference },
    141         { "KeygenElementEnabled", TestHeaderKeyType::BoolWebPreference },
    142         { "MenuItemElementEnabled", TestHeaderKeyType::BoolWebPreference },
    143         { "MockScrollbarsEnabled", TestHeaderKeyType::BoolWebPreference },
    144         { "ModernMediaControlsEnabled", TestHeaderKeyType::BoolWebPreference },
    145         { "NeedsSiteSpecificQuirks", TestHeaderKeyType::BoolWebPreference },
    146         { "PageVisibilityBasedProcessSuppressionEnabled", TestHeaderKeyType::BoolWebPreference },
    147         { "PunchOutWhiteBackgroundsInDarkMode", TestHeaderKeyType::BoolWebPreference },
    148         { "ServiceControlsEnabled", TestHeaderKeyType::BoolWebPreference },
    149         { "ShouldIgnoreMetaViewport", TestHeaderKeyType::BoolWebPreference },
    150         { "ShouldUseServiceWorkerShortTimeout", TestHeaderKeyType::BoolWebPreference },
    151         { "UsesBackForwardCache", TestHeaderKeyType::BoolWebPreference },
    152         { "WebAuthenticationEnabled", TestHeaderKeyType::BoolWebPreference },
    153         { "WebAuthenticationLocalAuthenticatorEnabled", TestHeaderKeyType::BoolWebPreference },
     102    static const std::unordered_map<std::string, TestHeaderKeyType> map {
     103        GENERATED_WEB_PREFERENCE_KEY_TYPE_MAPPINGS
    154104
    155105        { "allowsLinkPreview", TestHeaderKeyType::BoolTestRunner },
     
    193143}
    194144
    195 TestOptions::TestOptions(TestFeatures features)
    196     : m_features { features }
    197 {
    198 }
    199 
    200145bool TestOptions::hasSameInitializationOptions(const TestOptions& options) const
    201146{
     
    223168}
    224169
    225 std::vector<std::pair<std::string, bool>> TestOptions::boolWKPreferences() const
    226 {
    227     std::vector<std::pair<std::string, bool>> result;
    228 
    229     for (auto [key, defaultValue] : boolWebPreferencesDefaultsMap())
    230         result.push_back({ key, boolWebPreferenceFeatureValue(key) });
    231 
    232     return result;
    233 }
    234 
    235 template<typename T> T featureValue(std::string key, const std::unordered_map<std::string, T>& map, const std::unordered_map<std::string, T>& defaultsMap)
    236 {
     170bool TestOptions::boolWebPreferenceFeatureValue(std::string key, bool defaultValue) const
     171{
     172    auto it = m_features.boolWebPreferenceFeatures.find(key);
     173    if (it != m_features.boolWebPreferenceFeatures.end())
     174        return it->second;
     175    return defaultValue;
     176}
     177
     178template<typename T> T testRunnerFeatureValue(std::string key, const std::unordered_map<std::string, T>& map)
     179{
     180    // All test runner features should always exist in their corresponding map since the base/global defaults
     181    // contains default values for all of them.
     182
    237183    auto it = map.find(key);
    238     if (it != map.end())
    239         return it->second;
    240    
    241     auto defaultsMapIt = defaultsMap.find(key);
    242     ASSERT(defaultsMapIt != defaultsMap.end());
    243     return defaultsMapIt->second;
    244 }
    245 
    246 bool TestOptions::boolWebPreferenceFeatureValue(std::string key) const
    247 {
    248     return featureValue(key, m_features.boolWebPreferenceFeatures, boolWebPreferencesDefaultsMap());
    249 }
     184    ASSERT(it != map.end());
     185    return it->second;
     186}
     187
    250188bool TestOptions::boolTestRunnerFeatureValue(std::string key) const
    251189{
    252     return featureValue(key, m_features.boolTestRunnerFeatures, boolTestRunnerDefaultsMap());
    253 }
     190    return testRunnerFeatureValue(key, m_features.boolTestRunnerFeatures);
     191}
     192
    254193double TestOptions::doubleTestRunnerFeatureValue(std::string key) const
    255194{
    256     return featureValue(key, m_features.doubleTestRunnerFeatures, doubleTestRunnerDefaultsMap());
    257 }
     195    return testRunnerFeatureValue(key, m_features.doubleTestRunnerFeatures);
     196}
     197
    258198std::string TestOptions::stringTestRunnerFeatureValue(std::string key) const
    259199{
    260     return featureValue(key, m_features.stringTestRunnerFeatures, stringTestRunnerDefaultsMap());
    261 }
     200    return testRunnerFeatureValue(key, m_features.stringTestRunnerFeatures);
     201}
     202
    262203std::vector<std::string> TestOptions::stringVectorTestRunnerFeatureValue(std::string key) const
    263204{
    264     return featureValue(key, m_features.stringVectorTestRunnerFeatures, stringVectorTestRunnerDefaultsMap());
    265 }
    266 
    267 }
     205    return testRunnerFeatureValue(key, m_features.stringVectorTestRunnerFeatures);
     206}
     207
     208}
  • trunk/Tools/WebKitTestRunner/TestOptions.h

    r268498 r268604  
    3434namespace WTR {
    3535
    36 struct ContextOptions {
    37     std::vector<std::string> overrideLanguages;
    38     bool ignoreSynchronousMessagingTimeouts;
    39     bool enableProcessSwapOnNavigation;
    40     bool enableProcessSwapOnWindowOpen;
    41     bool useServiceWorkerShortTimeout;
     36class TestOptions {
     37public:
     38    static const TestFeatures& defaults();
     39    static const std::unordered_map<std::string, TestHeaderKeyType>& keyTypeMapping();
    4240
    43     bool hasSameInitializationOptions(const ContextOptions& options) const
     41    explicit TestOptions(TestFeatures features)
     42        : m_features { std::move(features) }
    4443    {
    45         if (ignoreSynchronousMessagingTimeouts != options.ignoreSynchronousMessagingTimeouts
    46             || overrideLanguages != options.overrideLanguages
    47             || enableProcessSwapOnNavigation != options.enableProcessSwapOnNavigation
    48             || enableProcessSwapOnWindowOpen != options.enableProcessSwapOnWindowOpen
    49             || useServiceWorkerShortTimeout != options.useServiceWorkerShortTimeout)
    50             return false;
    51         return true;
    5244    }
    5345
    54     bool shouldEnableProcessSwapOnNavigation() const
    55     {
    56         return enableProcessSwapOnNavigation || enableProcessSwapOnWindowOpen;
    57     }
    58 };
    59 
    60 class TestOptions {
    61 public:
    62     static const std::unordered_map<std::string, TestHeaderKeyType>& keyTypeMapping();
    63 
    64     explicit TestOptions(TestFeatures);
    65 
    66     ContextOptions contextOptions() const
    67     {
    68         return {
    69             overrideLanguages(),
    70             ignoreSynchronousMessagingTimeouts(),
    71             enableProcessSwapOnNavigation(),
    72             enableProcessSwapOnWindowOpen(),
    73             useServiceWorkerShortTimeout()
    74         };
    75     }
    76 
    77     bool allowTopNavigationToDataURLs() const { return boolWebPreferenceFeatureValue("AllowTopNavigationToDataURLs"); }
    78     bool enableAttachmentElement() const { return boolWebPreferenceFeatureValue("AttachmentElementEnabled"); }
    79     bool punchOutWhiteBackgroundsInDarkMode() const { return boolWebPreferenceFeatureValue("PunchOutWhiteBackgroundsInDarkMode"); }
    80     bool useServiceWorkerShortTimeout() const { return boolWebPreferenceFeatureValue("ShouldUseServiceWorkerShortTimeout"); }
     46    bool allowTopNavigationToDataURLs() const { return boolWebPreferenceFeatureValue("AllowTopNavigationToDataURLs", true); }
     47    bool enableAttachmentElement() const { return boolWebPreferenceFeatureValue("AttachmentElementEnabled", false); }
     48    bool punchOutWhiteBackgroundsInDarkMode() const { return boolWebPreferenceFeatureValue("PunchOutWhiteBackgroundsInDarkMode", false); }
     49    bool useServiceWorkerShortTimeout() const { return boolWebPreferenceFeatureValue("ShouldUseServiceWorkerShortTimeout", false); }
    8150
    8251    bool allowsLinkPreview() const { return boolTestRunnerFeatureValue("allowsLinkPreview"); }
     
    11382    std::vector<std::string> overrideLanguages() const { return stringVectorTestRunnerFeatureValue("language"); }
    11483
     84    bool shouldEnableProcessSwapOnNavigation() const
     85    {
     86        return enableProcessSwapOnNavigation() || enableProcessSwapOnWindowOpen();
     87    }
     88
    11589    const std::unordered_map<std::string, bool>& experimentalFeatures() const { return m_features.experimentalFeatures; }
    11690    const std::unordered_map<std::string, bool>& internalDebugFeatures() const { return m_features.internalDebugFeatures; }
    11791
    118     std::vector<std::pair<std::string, bool>> boolWKPreferences() const;
     92    const std::unordered_map<std::string, bool>& boolWebPreferenceFeatures() const { return m_features.boolWebPreferenceFeatures; }
     93    const std::unordered_map<std::string, double>& doubleWebPreferenceFeatures() const { return m_features.doubleWebPreferenceFeatures; }
     94    const std::unordered_map<std::string, uint32_t>& uint32WebPreferenceFeatures() const { return m_features.uint32WebPreferenceFeatures; }
     95    const std::unordered_map<std::string, std::string>& stringWebPreferenceFeatures() const { return m_features.stringWebPreferenceFeatures; }
    11996
    12097    bool hasSameInitializationOptions(const TestOptions&) const;
    12198
    12299private:
    123     bool boolWebPreferenceFeatureValue(std::string key) const;
     100    bool boolWebPreferenceFeatureValue(std::string key, bool defaultValue) const;
    124101    bool boolTestRunnerFeatureValue(std::string key) const;
    125102    double doubleTestRunnerFeatureValue(std::string key) const;
  • trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj

    r268498 r268604  
    352352                65EB859D11EC67CC0034D300 /* ActivateFonts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActivateFonts.h; sourceTree = "<group>"; };
    353353                65EB859F11EC67CC0034D300 /* ActivateFontsCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ActivateFontsCocoa.mm; sourceTree = "<group>"; };
     354                7C8A1F5625351EC600C5291E /* TestOptionsGeneratedKeys.h.erb */ = {isa = PBXFileReference; lastKnownFileType = text; path = TestOptionsGeneratedKeys.h.erb; sourceTree = "<group>"; };
     355                7C8A1F5725351EC600C5291E /* check-xcfilelists.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "check-xcfilelists.sh"; sourceTree = "<group>"; };
     356                7C8A1F5825351EC600C5291E /* generate-derived-sources.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "generate-derived-sources.sh"; sourceTree = "<group>"; };
     357                7CAA0E7625353BF500C519E5 /* TestOptionsGeneratedKeys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestOptionsGeneratedKeys.h; sourceTree = "<group>"; };
    354358                7CFF9BC52534AF1D0008009F /* TestFeatures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestFeatures.h; path = ../TestRunnerShared/TestFeatures.h; sourceTree = "<group>"; };
    355359                7CFF9BC62534AF1D0008009F /* TestFeatures.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TestFeatures.cpp; path = ../TestRunnerShared/TestFeatures.cpp; sourceTree = "<group>"; };
     
    481485                        children = (
    482486                                49AEEF692407278200C87E4C /* Info.plist */,
    483                                 0F18E71A1D6BC4BC0027E547 /* TestRunnerShared */,
    484487                                BC952EC511F3C10F003398B4 /* DerivedSources.make */,
    485488                                2EE52CEA1890A9A80010ED21 /* WebKitTestRunnerApp-Info.plist */,
    486489                                BC99CBF11207642D00FDEE76 /* Shared */,
    487490                                08FB7795FE84155DC02AAC07 /* TestRunner */,
     491                                0F18E71A1D6BC4BC0027E547 /* TestRunnerShared */,
    488492                                BC25183511D1571D002EBC01 /* InjectedBundle */,
    489493                                BC793401118F7C8A005EA8E2 /* Configurations */,
     
    491495                                BC25194411D15DBE002EBC01 /* Resources */,
    492496                                2EE52CE81890A9A80010ED21 /* WebKitTestRunnerApp */,
     497                                7C8A1F5425351EC600C5291E /* Scripts */,
    493498                                2EE52CE11890A9A80010ED21 /* Frameworks */,
    494499                                1AB674ADFE9D54B511CA2CBB /* Products */,
     
    500505                        isa = PBXGroup;
    501506                        children = (
     507                                7CAA0E7525353BC500C519E5 /* Derived Sources */,
    502508                                BC9192021333E4CD003011DC /* cg */,
    503509                                0FEB90A11905BC4A000FDBF3 /* cocoa */,
     
    750756                        path = mac;
    751757                        sourceTree = "<group>";
     758                };
     759                7C8A1F5425351EC600C5291E /* Scripts */ = {
     760                        isa = PBXGroup;
     761                        children = (
     762                                7C8A1F5525351EC600C5291E /* PreferencesTemplates */,
     763                                7C8A1F5725351EC600C5291E /* check-xcfilelists.sh */,
     764                                7C8A1F5825351EC600C5291E /* generate-derived-sources.sh */,
     765                        );
     766                        path = Scripts;
     767                        sourceTree = "<group>";
     768                };
     769                7C8A1F5525351EC600C5291E /* PreferencesTemplates */ = {
     770                        isa = PBXGroup;
     771                        children = (
     772                                7C8A1F5625351EC600C5291E /* TestOptionsGeneratedKeys.h.erb */,
     773                        );
     774                        path = PreferencesTemplates;
     775                        sourceTree = "<group>";
     776                };
     777                7CAA0E7525353BC500C519E5 /* Derived Sources */ = {
     778                        isa = PBXGroup;
     779                        children = (
     780                                7CAA0E7625353BF500C519E5 /* TestOptionsGeneratedKeys.h */,
     781                        );
     782                        name = "Derived Sources";
     783                        path = DerivedSources/WebKitTestRunner;
     784                        sourceTree = BUILT_PRODUCTS_DIR;
    752785                };
    753786                BC14E4E0120E02F900826C0C /* Controllers */ = {
Note: See TracChangeset for help on using the changeset viewer.