forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestOptions.h
135 lines (122 loc) · 9.66 KB
/
TestOptions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
* Copyright (C) 2015-2020 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.
*/
#pragma once
#include "TestFeatures.h"
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
namespace WTR {
class TestOptions {
public:
static const TestFeatures& defaults();
static const std::unordered_map<std::string, TestHeaderKeyType>& keyTypeMapping();
explicit TestOptions(TestFeatures features)
: m_features { std::move(features) }
{
}
bool allowTopNavigationToDataURLs() const { return boolWebPreferenceFeatureValue("AllowTopNavigationToDataURLs", true); }
bool enableAttachmentElement() const { return boolWebPreferenceFeatureValue("AttachmentElementEnabled", false); }
bool enableAttachmentWideLayout() const { return boolWebPreferenceFeatureValue("AttachmentWideLayoutEnabled", false); }
bool punchOutWhiteBackgroundsInDarkMode() const { return boolWebPreferenceFeatureValue("PunchOutWhiteBackgroundsInDarkMode", false); }
bool useServiceWorkerShortTimeout() const { return boolWebPreferenceFeatureValue("ShouldUseServiceWorkerShortTimeout", false); }
bool accessibilityIsolatedTreeMode() const { return boolWebPreferenceFeatureValue("IsAccessibilityIsolatedTreeEnabled", false); }
bool siteIsolationEnabled() const { return boolWebPreferenceFeatureValue("SiteIsolationEnabled", false); }
bool allowsLinkPreview() const { return boolTestRunnerFeatureValue("allowsLinkPreview"); }
bool appHighlightsEnabled() const { return boolTestRunnerFeatureValue("appHighlightsEnabled"); }
bool allowTestOnlyIPC() const { return boolTestRunnerFeatureValue("allowTestOnlyIPC"); }
bool dumpJSConsoleLogInStdErr() const { return boolTestRunnerFeatureValue("dumpJSConsoleLogInStdErr"); }
bool editable() const { return boolTestRunnerFeatureValue("editable"); }
bool enableInAppBrowserPrivacy() const { return boolTestRunnerFeatureValue("enableInAppBrowserPrivacy"); }
bool enableProcessSwapOnNavigation() const { return boolTestRunnerFeatureValue("enableProcessSwapOnNavigation"); }
bool findInteractionEnabled() const { return boolTestRunnerFeatureValue("findInteractionEnabled") ; }
bool ignoreSynchronousMessagingTimeouts() const { return boolTestRunnerFeatureValue("ignoreSynchronousMessagingTimeouts"); }
bool ignoresViewportScaleLimits() const { return boolTestRunnerFeatureValue("ignoresViewportScaleLimits"); }
bool isAppBoundWebView() const { return boolTestRunnerFeatureValue("isAppBoundWebView"); }
bool isAppInitiated() const { return boolTestRunnerFeatureValue("isAppInitiated"); }
bool advancedPrivacyProtectionsEnabled() const { return boolTestRunnerFeatureValue("advancedPrivacyProtectionsEnabled"); }
bool runSingly() const { return boolTestRunnerFeatureValue("runSingly"); }
bool runInCrossOriginFrame() const { return boolTestRunnerFeatureValue("runInCrossOriginFrame"); }
bool shouldHandleRunOpenPanel() const { return boolTestRunnerFeatureValue("shouldHandleRunOpenPanel"); }
bool shouldPresentPopovers() const { return boolTestRunnerFeatureValue("shouldPresentPopovers"); }
bool shouldShowSpellCheckingDots() const { return boolTestRunnerFeatureValue("spellCheckingDots"); }
bool shouldShowTouches() const { return boolTestRunnerFeatureValue("shouldShowTouches"); }
bool shouldShowWindow() const { return boolTestRunnerFeatureValue("shouldShowWindow"); }
bool textInteractionEnabled() const { return boolTestRunnerFeatureValue("textInteractionEnabled"); }
bool useCharacterSelectionGranularity() const { return boolTestRunnerFeatureValue("useCharacterSelectionGranularity"); }
bool useDataDetection() const { return boolTestRunnerFeatureValue("useDataDetection"); }
bool useEphemeralSession() const { return boolTestRunnerFeatureValue("useEphemeralSession"); }
bool useFlexibleViewport() const { return boolTestRunnerFeatureValue("useFlexibleViewport"); }
bool useRemoteLayerTree() const { return boolTestRunnerFeatureValue("useRemoteLayerTree"); }
bool noUseRemoteLayerTree() const { return boolTestRunnerFeatureValue("noUseRemoteLayerTree"); }
bool useThreadedScrolling() const { return boolTestRunnerFeatureValue("useThreadedScrolling"); }
bool suppressInputAccessoryView() const { return boolTestRunnerFeatureValue("suppressInputAccessoryView"); }
bool allowsInlinePredictions() const { return boolTestRunnerFeatureValue("allowsInlinePredictions"); }
bool showsScrollIndicators() const { return boolTestRunnerFeatureValue("showsScrollIndicators"); }
bool longPressActionsEnabled() const { return boolTestRunnerFeatureValue("longPressActionsEnabled"); }
bool enhancedWindowingEnabled() const { return boolTestRunnerFeatureValue("enhancedWindowingEnabled"); }
bool textExtractionEnabled() const { return boolTestRunnerFeatureValue("textExtractionEnabled"); }
bool useHardwareKeyboardMode() const { return boolTestRunnerFeatureValue("useHardwareKeyboardMode"); }
bool shouldIgnoreWebProcessTermination() const { return boolTestRunnerFeatureValue("ignoreWebProcessTermination"); }
bool enableMetalDebugDevice() const { return boolTestRunnerFeatureValue("enableMetalDebugDevice"); }
bool enableMetalShaderValidation() const { return boolTestRunnerFeatureValue("enableMetalShaderValidation"); }
double contentInsetTop() const { return doubleTestRunnerFeatureValue("contentInset.top"); }
double obscuredInsetTop() const { return doubleTestRunnerFeatureValue("obscuredInset.top"); }
double horizontalSystemMinimumLayoutMargin() const { return doubleTestRunnerFeatureValue("horizontalSystemMinimumLayoutMargin"); }
double deviceScaleFactor() const { return doubleTestRunnerFeatureValue("deviceScaleFactor"); }
double viewHeight() const { return doubleTestRunnerFeatureValue("viewHeight"); }
double viewWidth() const { return doubleTestRunnerFeatureValue("viewWidth"); }
uint16_t insecureUpgradePort() const { return uint16TestRunnerFeatureValue("insecureUpgradePort"); };
uint16_t secureUpgradePort() const { return uint16TestRunnerFeatureValue("secureUpgradePort"); };
std::string additionalSupportedImageTypes() const { return stringTestRunnerFeatureValue("additionalSupportedImageTypes"); }
std::string applicationBundleIdentifier() const { return stringTestRunnerFeatureValue("applicationBundleIdentifier"); }
std::string applicationManifest() const { return stringTestRunnerFeatureValue("applicationManifest"); }
std::string contentMode() const { return stringTestRunnerFeatureValue("contentMode"); }
std::string contentSecurityPolicyExtensionMode() const { return stringTestRunnerFeatureValue("contentSecurityPolicyExtensionMode"); }
std::string dragInteractionPolicy() const { return stringTestRunnerFeatureValue("dragInteractionPolicy"); }
std::string focusStartsInputSessionPolicy() const { return stringTestRunnerFeatureValue("focusStartsInputSessionPolicy"); }
std::string jscOptions() const { return stringTestRunnerFeatureValue("jscOptions"); }
std::string captionDisplayMode() const { return stringTestRunnerFeatureValue("captionDisplayMode"); }
std::string standaloneWebApplicationURL() const { return stringTestRunnerFeatureValue("standaloneWebApplicationURL"); }
std::vector<std::string> overrideLanguages() const { return stringVectorTestRunnerFeatureValue("language"); }
bool shouldEnableProcessSwapOnNavigation() const
{
return enableProcessSwapOnNavigation();
}
const std::unordered_map<std::string, bool>& boolWebPreferenceFeatures() const { return m_features.boolWebPreferenceFeatures; }
const std::unordered_map<std::string, double>& doubleWebPreferenceFeatures() const { return m_features.doubleWebPreferenceFeatures; }
const std::unordered_map<std::string, uint32_t>& uint32WebPreferenceFeatures() const { return m_features.uint32WebPreferenceFeatures; }
const std::unordered_map<std::string, std::string>& stringWebPreferenceFeatures() const { return m_features.stringWebPreferenceFeatures; }
bool hasSameInitializationOptions(const TestOptions&) const;
private:
bool boolWebPreferenceFeatureValue(std::string key, bool defaultValue) const;
bool boolTestRunnerFeatureValue(std::string key) const;
double doubleTestRunnerFeatureValue(std::string key) const;
uint16_t uint16TestRunnerFeatureValue(std::string key) const;
std::string stringTestRunnerFeatureValue(std::string key) const;
std::vector<std::string> stringVectorTestRunnerFeatureValue(std::string key) const;
TestFeatures m_features;
};
}