1 | /* |
2 | * Copyright (C) 2010-2019 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 | * THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #pragma once |
27 | |
28 | #include "GeolocationProviderMock.h" |
29 | #include "TestOptions.h" |
30 | #include "WebNotificationProvider.h" |
31 | #include "WorkQueueManager.h" |
32 | #include <WebKit/WKRetainPtr.h> |
33 | #include <set> |
34 | #include <string> |
35 | #include <vector> |
36 | #include <wtf/HashMap.h> |
37 | #include <wtf/Noncopyable.h> |
38 | #include <wtf/Seconds.h> |
39 | #include <wtf/Vector.h> |
40 | #include <wtf/text/StringHash.h> |
41 | |
42 | #if PLATFORM(COCOA) |
43 | #include "ClassMethodSwizzler.h" |
44 | #include "InstanceMethodSwizzler.h" |
45 | #endif |
46 | |
47 | OBJC_CLASS NSString; |
48 | OBJC_CLASS UIKeyboardInputMode; |
49 | OBJC_CLASS WKWebViewConfiguration; |
50 | |
51 | namespace WTR { |
52 | |
53 | class TestInvocation; |
54 | class OriginSettings; |
55 | class PlatformWebView; |
56 | class EventSenderProxy; |
57 | struct TestCommand; |
58 | struct TestOptions; |
59 | |
60 | class AsyncTask { |
61 | public: |
62 | AsyncTask(WTF::Function<void ()>&& task, WTF::Seconds timeout) |
63 | : m_task(WTFMove(task)) |
64 | , m_timeout(timeout) |
65 | { |
66 | ASSERT(!currentTask()); |
67 | } |
68 | |
69 | // Returns false on timeout. |
70 | bool run(); |
71 | |
72 | void taskComplete() |
73 | { |
74 | m_taskDone = true; |
75 | } |
76 | |
77 | static AsyncTask* currentTask(); |
78 | |
79 | private: |
80 | static AsyncTask* m_currentTask; |
81 | |
82 | WTF::Function<void ()> m_task; |
83 | WTF::Seconds m_timeout; |
84 | bool m_taskDone { false }; |
85 | }; |
86 | |
87 | // FIXME: Rename this TestRunner? |
88 | class TestController { |
89 | public: |
90 | static TestController& singleton(); |
91 | |
92 | static const unsigned viewWidth; |
93 | static const unsigned viewHeight; |
94 | |
95 | static const unsigned w3cSVGViewWidth; |
96 | static const unsigned w3cSVGViewHeight; |
97 | |
98 | static const WTF::Seconds defaultShortTimeout; |
99 | static const WTF::Seconds noTimeout; |
100 | |
101 | TestController(int argc, const char* argv[]); |
102 | ~TestController(); |
103 | |
104 | bool verbose() const { return m_verbose; } |
105 | |
106 | WKStringRef injectedBundlePath() const { return m_injectedBundlePath.get(); } |
107 | WKStringRef testPluginDirectory() const { return m_testPluginDirectory.get(); } |
108 | |
109 | PlatformWebView* mainWebView() { return m_mainWebView.get(); } |
110 | WKContextRef context() { return m_context.get(); } |
111 | WKUserContentControllerRef userContentController() { return m_userContentController.get(); } |
112 | |
113 | EventSenderProxy* eventSenderProxy() { return m_eventSenderProxy.get(); } |
114 | |
115 | bool shouldUseRemoteLayerTree() const { return m_shouldUseRemoteLayerTree; } |
116 | |
117 | // Runs the run loop until `done` is true or the timeout elapses. |
118 | bool useWaitToDumpWatchdogTimer() { return m_useWaitToDumpWatchdogTimer; } |
119 | void runUntil(bool& done, WTF::Seconds timeout); |
120 | void notifyDone(); |
121 | |
122 | bool shouldShowWebView() const { return m_shouldShowWebView; } |
123 | bool usingServerMode() const { return m_usingServerMode; } |
124 | void configureViewForTest(const TestInvocation&); |
125 | |
126 | bool shouldShowTouches() const { return m_shouldShowTouches; } |
127 | |
128 | bool beforeUnloadReturnValue() const { return m_beforeUnloadReturnValue; } |
129 | void setBeforeUnloadReturnValue(bool value) { m_beforeUnloadReturnValue = value; } |
130 | |
131 | void simulateWebNotificationClick(uint64_t notificationID); |
132 | |
133 | // Geolocation. |
134 | void setGeolocationPermission(bool); |
135 | void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed, bool providesFloorLevel, double floorLevel); |
136 | void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage); |
137 | void handleGeolocationPermissionRequest(WKGeolocationPermissionRequestRef); |
138 | bool isGeolocationProviderActive() const; |
139 | |
140 | // MediaStream. |
141 | String saltForOrigin(WKFrameRef, String); |
142 | void getUserMediaInfoForOrigin(WKFrameRef, WKStringRef originKey, bool&, WKRetainPtr<WKStringRef>&); |
143 | WKStringRef getUserMediaSaltForOrigin(WKFrameRef, WKStringRef originKey); |
144 | void setUserMediaPermission(bool); |
145 | void resetUserMediaPermission(); |
146 | void setUserMediaPersistentPermissionForOrigin(bool, WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString); |
147 | void handleUserMediaPermissionRequest(WKFrameRef, WKSecurityOriginRef, WKSecurityOriginRef, WKUserMediaPermissionRequestRef); |
148 | void handleCheckOfUserMediaPermissionForOrigin(WKFrameRef, WKSecurityOriginRef, WKSecurityOriginRef, const WKUserMediaPermissionCheckRef&); |
149 | OriginSettings& settingsForOrigin(const String&); |
150 | unsigned userMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString); |
151 | void resetUserMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString); |
152 | |
153 | // Device Orientation / Motion. |
154 | bool handleDeviceOrientationAndMotionAccessRequest(WKSecurityOriginRef); |
155 | |
156 | // Content Extensions. |
157 | void configureContentExtensionForTest(const TestInvocation&); |
158 | void resetContentExtensions(); |
159 | |
160 | // Policy delegate. |
161 | void setCustomPolicyDelegate(bool enabled, bool permissive); |
162 | |
163 | // Page Visibility. |
164 | void setHidden(bool); |
165 | |
166 | unsigned imageCountInGeneralPasteboard() const; |
167 | |
168 | enum class ResetStage { BeforeTest, AfterTest }; |
169 | bool resetStateToConsistentValues(const TestOptions&, ResetStage); |
170 | void resetPreferencesToConsistentValues(const TestOptions&); |
171 | |
172 | void willDestroyWebView(); |
173 | |
174 | void terminateWebContentProcess(); |
175 | void reattachPageToWebProcess(); |
176 | |
177 | static const char* webProcessName(); |
178 | static const char* networkProcessName(); |
179 | static const char* databaseProcessName(); |
180 | |
181 | WorkQueueManager& workQueueManager() { return m_workQueueManager; } |
182 | |
183 | void setRejectsProtectionSpaceAndContinueForAuthenticationChallenges(bool value) { m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges = value; } |
184 | void setHandlesAuthenticationChallenges(bool value) { m_handlesAuthenticationChallenges = value; } |
185 | void setAuthenticationUsername(String username) { m_authenticationUsername = username; } |
186 | void setAuthenticationPassword(String password) { m_authenticationPassword = password; } |
187 | void setAllowsAnySSLCertificate(bool); |
188 | |
189 | void setBlockAllPlugins(bool shouldBlock); |
190 | void setPluginSupportedMode(const String&); |
191 | |
192 | void setShouldLogHistoryClientCallbacks(bool shouldLog) { m_shouldLogHistoryClientCallbacks = shouldLog; } |
193 | void setShouldLogCanAuthenticateAgainstProtectionSpace(bool shouldLog) { m_shouldLogCanAuthenticateAgainstProtectionSpace = shouldLog; } |
194 | void setShouldLogDownloadCallbacks(bool shouldLog) { m_shouldLogDownloadCallbacks = shouldLog; } |
195 | |
196 | bool isCurrentInvocation(TestInvocation* invocation) const { return invocation == m_currentInvocation.get(); } |
197 | |
198 | void setShouldDecideNavigationPolicyAfterDelay(bool value) { m_shouldDecideNavigationPolicyAfterDelay = value; } |
199 | void setShouldDecideResponsePolicyAfterDelay(bool value) { m_shouldDecideResponsePolicyAfterDelay = value; } |
200 | |
201 | void setNavigationGesturesEnabled(bool value); |
202 | void setIgnoresViewportScaleLimits(bool); |
203 | |
204 | void setShouldDownloadUndisplayableMIMETypes(bool value) { m_shouldDownloadUndisplayableMIMETypes = value; } |
205 | void setShouldAllowDeviceOrientationAndMotionAccess(bool value) { m_shouldAllowDeviceOrientationAndMotionAccess = value; } |
206 | |
207 | void setStatisticsDebugMode(bool value); |
208 | void setStatisticsPrevalentResourceForDebugMode(WKStringRef hostName); |
209 | void setStatisticsLastSeen(WKStringRef hostName, double seconds); |
210 | void setStatisticsPrevalentResource(WKStringRef hostName, bool value); |
211 | void setStatisticsVeryPrevalentResource(WKStringRef hostName, bool value); |
212 | String dumpResourceLoadStatistics(); |
213 | bool isStatisticsPrevalentResource(WKStringRef hostName); |
214 | bool isStatisticsVeryPrevalentResource(WKStringRef hostName); |
215 | bool isStatisticsRegisteredAsSubresourceUnder(WKStringRef subresourceHost, WKStringRef topFrameHost); |
216 | bool isStatisticsRegisteredAsSubFrameUnder(WKStringRef subFrameHost, WKStringRef topFrameHost); |
217 | bool isStatisticsRegisteredAsRedirectingTo(WKStringRef hostRedirectedFrom, WKStringRef hostRedirectedTo); |
218 | void setStatisticsHasHadUserInteraction(WKStringRef hostName, bool value); |
219 | bool isStatisticsHasHadUserInteraction(WKStringRef hostName); |
220 | void setStatisticsGrandfathered(WKStringRef hostName, bool value); |
221 | bool isStatisticsGrandfathered(WKStringRef hostName); |
222 | void setStatisticsSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName); |
223 | void setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName); |
224 | void setStatisticsSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo); |
225 | void setStatisticsSubresourceUniqueRedirectFrom(WKStringRef host, WKStringRef hostRedirectedFrom); |
226 | void setStatisticsTopFrameUniqueRedirectTo(WKStringRef host, WKStringRef hostRedirectedTo); |
227 | void setStatisticsTopFrameUniqueRedirectFrom(WKStringRef host, WKStringRef hostRedirectedFrom); |
228 | void setStatisticsCrossSiteLoadWithLinkDecoration(WKStringRef fromHost, WKStringRef toHost); |
229 | void setStatisticsTimeToLiveUserInteraction(double seconds); |
230 | void statisticsProcessStatisticsAndDataRecords(); |
231 | void statisticsUpdateCookieBlocking(); |
232 | void statisticsSubmitTelemetry(); |
233 | void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool); |
234 | void setStatisticsIsRunningTest(bool); |
235 | void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool); |
236 | void setStatisticsNotifyPagesWhenTelemetryWasCaptured(bool value); |
237 | void setStatisticsMinimumTimeBetweenDataRecordsRemoval(double); |
238 | void setStatisticsGrandfatheringTime(double seconds); |
239 | void setStatisticsMaxStatisticsEntries(unsigned); |
240 | void setStatisticsPruneEntriesDownTo(unsigned); |
241 | void statisticsClearInMemoryAndPersistentStore(); |
242 | void statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned); |
243 | void statisticsClearThroughWebsiteDataRemoval(); |
244 | void statisticsDeleteCookiesForHost(WKStringRef host, bool includeHttpOnlyCookies); |
245 | bool isStatisticsHasLocalStorage(WKStringRef hostName); |
246 | void setStatisticsCacheMaxAgeCap(double seconds); |
247 | void statisticsResetToConsistentState(); |
248 | |
249 | void getAllStorageAccessEntries(); |
250 | |
251 | WKArrayRef openPanelFileURLs() const { return m_openPanelFileURLs.get(); } |
252 | void setOpenPanelFileURLs(WKArrayRef fileURLs) { m_openPanelFileURLs = fileURLs; } |
253 | |
254 | #if PLATFORM(IOS_FAMILY) |
255 | WKDataRef openPanelFileURLsMediaIcon() const { return m_openPanelFileURLsMediaIcon.get(); } |
256 | void setOpenPanelFileURLsMediaIcon(WKDataRef mediaIcon) { m_openPanelFileURLsMediaIcon = mediaIcon; } |
257 | #endif |
258 | |
259 | void terminateNetworkProcess(); |
260 | void terminateServiceWorkerProcess(); |
261 | |
262 | void removeAllSessionCredentials(); |
263 | |
264 | void ClearIndexedDatabases(); |
265 | |
266 | void clearServiceWorkerRegistrations(); |
267 | |
268 | void clearDOMCache(WKStringRef origin); |
269 | void clearDOMCaches(); |
270 | bool hasDOMCache(WKStringRef origin); |
271 | uint64_t domCacheSize(WKStringRef origin); |
272 | |
273 | void setAllowStorageQuotaIncrease(bool); |
274 | |
275 | void setIDBPerOriginQuota(uint64_t); |
276 | |
277 | bool didReceiveServerRedirectForProvisionalNavigation() const { return m_didReceiveServerRedirectForProvisionalNavigation; } |
278 | void clearDidReceiveServerRedirectForProvisionalNavigation() { m_didReceiveServerRedirectForProvisionalNavigation = false; } |
279 | |
280 | void addMockMediaDevice(WKStringRef persistentID, WKStringRef label, WKStringRef type); |
281 | void clearMockMediaDevices(); |
282 | void removeMockMediaDevice(WKStringRef persistentID); |
283 | void resetMockMediaDevices(); |
284 | |
285 | void injectUserScript(WKStringRef); |
286 | |
287 | void sendDisplayConfigurationChangedMessageForTesting(); |
288 | |
289 | void setWebAuthenticationMockConfiguration(WKDictionaryRef); |
290 | void addTestKeyToKeychain(const String& privateKeyBase64, const String& attrLabel, const String& applicationTagBase64); |
291 | void cleanUpKeychain(const String& attrLabel); |
292 | bool keyExistsInKeychain(const String& attrLabel, const String& applicationTagBase64); |
293 | |
294 | #if PLATFORM(COCOA) |
295 | RetainPtr<NSString> getOverriddenCalendarIdentifier() const; |
296 | void setDefaultCalendarType(NSString *identifier); |
297 | #endif // PLATFORM(COCOA) |
298 | |
299 | #if PLATFORM(IOS_FAMILY) |
300 | void setKeyboardInputModeIdentifier(const String&); |
301 | UIKeyboardInputMode *overriddenKeyboardInputMode() const { return m_overriddenKeyboardInputMode.get(); } |
302 | #endif |
303 | |
304 | void (const Vector<String>&); |
305 | void (const String& name, bool dismissesAutomatically); |
306 | |
307 | bool canDoServerTrustEvaluationInNetworkProcess() const; |
308 | uint64_t serverTrustEvaluationCallbackCallsCount() const { return m_serverTrustEvaluationCallbackCallsCount; } |
309 | |
310 | void setShouldDismissJavaScriptAlertsAsynchronously(bool); |
311 | void handleJavaScriptAlert(WKPageRunJavaScriptAlertResultListenerRef); |
312 | void abortModal(); |
313 | |
314 | bool isDoingMediaCapture() const; |
315 | |
316 | String dumpAdClickAttribution(); |
317 | void clearAdClickAttribution(); |
318 | void clearAdClickAttributionsThroughWebsiteDataRemoval(); |
319 | void setAdClickAttributionOverrideTimerForTesting(bool value); |
320 | void setAdClickAttributionConversionURLForTesting(WKURLRef); |
321 | void markAdClickAttributionsAsExpiredForTesting(); |
322 | |
323 | private: |
324 | WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration(const TestOptions&); |
325 | WKRetainPtr<WKContextConfigurationRef> generateContextConfiguration(const TestOptions::ContextOptions&) const; |
326 | void initialize(int argc, const char* argv[]); |
327 | void createWebViewWithOptions(const TestOptions&); |
328 | void run(); |
329 | |
330 | void runTestingServerLoop(); |
331 | bool runTest(const char* pathOrURL); |
332 | |
333 | // Returns false if timed out. |
334 | bool waitForCompletion(const WTF::Function<void ()>&, WTF::Seconds timeout); |
335 | |
336 | bool handleControlCommand(const char* command); |
337 | |
338 | void platformInitialize(); |
339 | void platformDestroy(); |
340 | WKContextRef platformAdjustContext(WKContextRef, WKContextConfigurationRef); |
341 | void platformInitializeContext(); |
342 | void platformAddTestOptions(TestOptions&) const; |
343 | void platformCreateWebView(WKPageConfigurationRef, const TestOptions&); |
344 | static PlatformWebView* platformCreateOtherPage(PlatformWebView* parentView, WKPageConfigurationRef, const TestOptions&); |
345 | void platformResetPreferencesToConsistentValues(); |
346 | void platformResetStateToConsistentValues(const TestOptions&); |
347 | #if PLATFORM(COCOA) |
348 | void cocoaPlatformInitialize(); |
349 | void cocoaResetStateToConsistentValues(const TestOptions&); |
350 | #endif |
351 | void platformConfigureViewForTest(const TestInvocation&); |
352 | void platformWillRunTest(const TestInvocation&); |
353 | void platformRunUntil(bool& done, WTF::Seconds timeout); |
354 | void platformDidCommitLoadForFrame(WKPageRef, WKFrameRef); |
355 | WKContextRef platformContext(); |
356 | WKPreferencesRef platformPreferences(); |
357 | void initializeInjectedBundlePath(); |
358 | void initializeTestPluginDirectory(); |
359 | |
360 | void ensureViewSupportsOptionsForTest(const TestInvocation&); |
361 | TestOptions testOptionsForTest(const TestCommand&) const; |
362 | void updatePlatformSpecificTestOptionsForTest(TestOptions&, const std::string& pathOrURL) const; |
363 | |
364 | void updateWebViewSizeForTest(const TestInvocation&); |
365 | void updateWindowScaleForTest(PlatformWebView*, const TestInvocation&); |
366 | |
367 | void updateLiveDocumentsAfterTest(); |
368 | void checkForWorldLeaks(); |
369 | |
370 | void didReceiveLiveDocumentsList(WKArrayRef); |
371 | void dumpResponse(const String&); |
372 | void findAndDumpWebKitProcessIdentifiers(); |
373 | void findAndDumpWorldLeaks(); |
374 | |
375 | void decidePolicyForGeolocationPermissionRequestIfPossible(); |
376 | void decidePolicyForUserMediaPermissionRequestIfPossible(); |
377 | |
378 | // WKContextInjectedBundleClient |
379 | static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, const void*); |
380 | static void didReceiveSynchronousMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void*); |
381 | static WKTypeRef getInjectedBundleInitializationUserData(WKContextRef, const void *clientInfo); |
382 | |
383 | // WKPageInjectedBundleClient |
384 | static void didReceivePageMessageFromInjectedBundle(WKPageRef, WKStringRef messageName, WKTypeRef messageBody, const void*); |
385 | static void didReceiveSynchronousPageMessageFromInjectedBundle(WKPageRef, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void*); |
386 | void didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody); |
387 | WKRetainPtr<WKTypeRef> didReceiveSynchronousMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody); |
388 | WKRetainPtr<WKTypeRef> getInjectedBundleInitializationUserData(); |
389 | |
390 | void didReceiveKeyDownMessageFromInjectedBundle(WKDictionaryRef messageBodyDictionary, bool synchronous); |
391 | |
392 | // WKContextClient |
393 | static void networkProcessDidCrash(WKContextRef, const void*); |
394 | void networkProcessDidCrash(); |
395 | |
396 | // WKPageNavigationClient |
397 | static void didCommitNavigation(WKPageRef, WKNavigationRef, WKTypeRef userData, const void*); |
398 | void didCommitNavigation(WKPageRef, WKNavigationRef); |
399 | |
400 | static void didFinishNavigation(WKPageRef, WKNavigationRef, WKTypeRef userData, const void*); |
401 | void didFinishNavigation(WKPageRef, WKNavigationRef); |
402 | |
403 | // WKContextDownloadClient |
404 | static void downloadDidStart(WKContextRef, WKDownloadRef, const void*); |
405 | void downloadDidStart(WKContextRef, WKDownloadRef); |
406 | static WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef, WKStringRef filename, bool* allowOverwrite, const void *clientInfo); |
407 | WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef, WKStringRef filename, bool*& allowOverwrite); |
408 | static void downloadDidFinish(WKContextRef, WKDownloadRef, const void*); |
409 | void downloadDidFinish(WKContextRef, WKDownloadRef); |
410 | static void downloadDidFail(WKContextRef, WKDownloadRef, WKErrorRef, const void*); |
411 | void downloadDidFail(WKContextRef, WKDownloadRef, WKErrorRef); |
412 | static void downloadDidCancel(WKContextRef, WKDownloadRef, const void*); |
413 | void downloadDidCancel(WKContextRef, WKDownloadRef); |
414 | static void downloadDidReceiveServerRedirectToURL(WKContextRef, WKDownloadRef, WKURLRef, const void*); |
415 | void downloadDidReceiveServerRedirectToURL(WKContextRef, WKDownloadRef, WKURLRef); |
416 | |
417 | static void processDidCrash(WKPageRef, const void* clientInfo); |
418 | void processDidCrash(); |
419 | |
420 | static void didBeginNavigationGesture(WKPageRef, const void*); |
421 | static void willEndNavigationGesture(WKPageRef, WKBackForwardListItemRef, const void*); |
422 | static void didEndNavigationGesture(WKPageRef, WKBackForwardListItemRef, const void*); |
423 | static void didRemoveNavigationGestureSnapshot(WKPageRef, const void*); |
424 | void didBeginNavigationGesture(WKPageRef); |
425 | void willEndNavigationGesture(WKPageRef, WKBackForwardListItemRef); |
426 | void didEndNavigationGesture(WKPageRef, WKBackForwardListItemRef); |
427 | void didRemoveNavigationGestureSnapshot(WKPageRef); |
428 | |
429 | static WKPluginLoadPolicy decidePolicyForPluginLoad(WKPageRef, WKPluginLoadPolicy currentPluginLoadPolicy, WKDictionaryRef pluginInformation, WKStringRef* unavailabilityDescription, const void* clientInfo); |
430 | WKPluginLoadPolicy decidePolicyForPluginLoad(WKPageRef, WKPluginLoadPolicy currentPluginLoadPolicy, WKDictionaryRef pluginInformation, WKStringRef* unavailabilityDescription); |
431 | |
432 | |
433 | static void decidePolicyForNotificationPermissionRequest(WKPageRef, WKSecurityOriginRef, WKNotificationPermissionRequestRef, const void*); |
434 | void decidePolicyForNotificationPermissionRequest(WKPageRef, WKSecurityOriginRef, WKNotificationPermissionRequestRef); |
435 | |
436 | static void unavailablePluginButtonClicked(WKPageRef, WKPluginUnavailabilityReason, WKDictionaryRef, const void*); |
437 | |
438 | static void didReceiveServerRedirectForProvisionalNavigation(WKPageRef, WKNavigationRef, WKTypeRef, const void*); |
439 | void didReceiveServerRedirectForProvisionalNavigation(WKPageRef, WKNavigationRef, WKTypeRef); |
440 | |
441 | static bool canAuthenticateAgainstProtectionSpace(WKPageRef, WKProtectionSpaceRef, const void*); |
442 | bool canAuthenticateAgainstProtectionSpace(WKPageRef, WKProtectionSpaceRef); |
443 | |
444 | static void didReceiveAuthenticationChallenge(WKPageRef, WKAuthenticationChallengeRef, const void*); |
445 | void didReceiveAuthenticationChallenge(WKPageRef, WKAuthenticationChallengeRef); |
446 | |
447 | static void decidePolicyForNavigationAction(WKPageRef, WKNavigationActionRef, WKFramePolicyListenerRef, WKTypeRef, const void*); |
448 | void decidePolicyForNavigationAction(WKNavigationActionRef, WKFramePolicyListenerRef); |
449 | |
450 | static void decidePolicyForNavigationResponse(WKPageRef, WKNavigationResponseRef, WKFramePolicyListenerRef, WKTypeRef, const void*); |
451 | void decidePolicyForNavigationResponse(WKNavigationResponseRef, WKFramePolicyListenerRef); |
452 | |
453 | // WKContextHistoryClient |
454 | static void didNavigateWithNavigationData(WKContextRef, WKPageRef, WKNavigationDataRef, WKFrameRef, const void*); |
455 | void didNavigateWithNavigationData(WKNavigationDataRef, WKFrameRef); |
456 | |
457 | static void didPerformClientRedirect(WKContextRef, WKPageRef, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef, const void*); |
458 | void didPerformClientRedirect(WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef); |
459 | |
460 | static void didPerformServerRedirect(WKContextRef, WKPageRef, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef, const void*); |
461 | void didPerformServerRedirect(WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef); |
462 | |
463 | static void didUpdateHistoryTitle(WKContextRef, WKPageRef, WKStringRef title, WKURLRef, WKFrameRef, const void*); |
464 | void didUpdateHistoryTitle(WKStringRef title, WKURLRef, WKFrameRef); |
465 | |
466 | static WKPageRef createOtherPage(WKPageRef, WKPageConfigurationRef, WKNavigationActionRef, WKWindowFeaturesRef, const void*); |
467 | WKPageRef createOtherPage(PlatformWebView* parentView, WKPageConfigurationRef, WKNavigationActionRef, WKWindowFeaturesRef); |
468 | |
469 | static void runModal(WKPageRef, const void* clientInfo); |
470 | static void runModal(PlatformWebView*); |
471 | |
472 | #if PLATFORM(COCOA) |
473 | static void finishCreatingPlatformWebView(PlatformWebView*, const TestOptions&); |
474 | void enableModernCompatibilityMode(WKWebViewConfiguration *); |
475 | #endif |
476 | |
477 | static const char* libraryPathForTesting(); |
478 | static const char* platformLibraryPathForTesting(); |
479 | |
480 | std::unique_ptr<TestInvocation> m_currentInvocation; |
481 | #if PLATFORM(COCOA) |
482 | std::unique_ptr<ClassMethodSwizzler> m_calendarSwizzler; |
483 | RetainPtr<NSString> m_overriddenCalendarIdentifier; |
484 | #endif // PLATFORM(COCOA) |
485 | bool m_verbose { false }; |
486 | bool m_printSeparators { false }; |
487 | bool m_usingServerMode { false }; |
488 | bool m_gcBetweenTests { false }; |
489 | bool m_shouldDumpPixelsForAllTests { false }; |
490 | std::vector<std::string> m_paths; |
491 | std::set<std::string> m_allowedHosts; |
492 | WKRetainPtr<WKStringRef> m_injectedBundlePath; |
493 | WKRetainPtr<WKStringRef> m_testPluginDirectory; |
494 | |
495 | WebNotificationProvider m_webNotificationProvider; |
496 | |
497 | std::unique_ptr<PlatformWebView> m_mainWebView; |
498 | WKRetainPtr<WKContextRef> m_context; |
499 | Optional<TestOptions::ContextOptions> m_contextOptions; |
500 | WKRetainPtr<WKPageGroupRef> m_pageGroup; |
501 | WKRetainPtr<WKUserContentControllerRef> m_userContentController; |
502 | |
503 | #if PLATFORM(IOS_FAMILY) |
504 | Vector<std::unique_ptr<InstanceMethodSwizzler>> m_inputModeSwizzlers; |
505 | RetainPtr<UIKeyboardInputMode> m_overriddenKeyboardInputMode; |
506 | Vector<std::unique_ptr<InstanceMethodSwizzler>> m_presentPopoverSwizzlers; |
507 | #endif |
508 | |
509 | enum State { |
510 | Initial, |
511 | Resetting, |
512 | RunningTest |
513 | }; |
514 | State m_state { Initial }; |
515 | bool m_doneResetting { false }; |
516 | |
517 | bool m_useWaitToDumpWatchdogTimer { true }; |
518 | bool m_forceNoTimeout { false }; |
519 | |
520 | bool m_didPrintWebProcessCrashedMessage { false }; |
521 | bool m_shouldExitWhenWebProcessCrashes { true }; |
522 | |
523 | bool m_beforeUnloadReturnValue { true }; |
524 | |
525 | std::unique_ptr<GeolocationProviderMock> m_geolocationProvider; |
526 | Vector<WKRetainPtr<WKGeolocationPermissionRequestRef> > m_geolocationPermissionRequests; |
527 | bool m_isGeolocationPermissionSet { false }; |
528 | bool m_isGeolocationPermissionAllowed { false }; |
529 | |
530 | HashMap<String, RefPtr<OriginSettings>> m_cachedUserMediaPermissions; |
531 | |
532 | typedef Vector<std::pair<String, WKRetainPtr<WKUserMediaPermissionRequestRef>>> PermissionRequestList; |
533 | PermissionRequestList m_userMediaPermissionRequests; |
534 | |
535 | bool m_isUserMediaPermissionSet { false }; |
536 | bool m_isUserMediaPermissionAllowed { false }; |
537 | |
538 | bool m_policyDelegateEnabled { false }; |
539 | bool m_policyDelegatePermissive { false }; |
540 | bool m_shouldDownloadUndisplayableMIMETypes { false }; |
541 | bool m_shouldAllowDeviceOrientationAndMotionAccess { false }; |
542 | |
543 | bool m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges { false }; |
544 | bool m_handlesAuthenticationChallenges { false }; |
545 | String m_authenticationUsername; |
546 | String m_authenticationPassword; |
547 | |
548 | bool m_shouldBlockAllPlugins { false }; |
549 | String m_unsupportedPluginMode; |
550 | |
551 | bool m_forceComplexText { false }; |
552 | bool m_shouldUseAcceleratedDrawing { false }; |
553 | bool m_shouldUseRemoteLayerTree { false }; |
554 | |
555 | bool m_shouldLogCanAuthenticateAgainstProtectionSpace { false }; |
556 | bool m_shouldLogDownloadCallbacks { false }; |
557 | bool m_shouldLogHistoryClientCallbacks { false }; |
558 | bool m_shouldShowWebView { false }; |
559 | |
560 | bool m_shouldShowTouches { false }; |
561 | bool m_checkForWorldLeaks { false }; |
562 | |
563 | bool m_allowAnyHTTPSCertificateForAllowedHosts { false }; |
564 | |
565 | bool m_shouldDecideNavigationPolicyAfterDelay { false }; |
566 | bool m_shouldDecideResponsePolicyAfterDelay { false }; |
567 | |
568 | bool m_didReceiveServerRedirectForProvisionalNavigation { false }; |
569 | |
570 | WKRetainPtr<WKArrayRef> m_openPanelFileURLs; |
571 | #if PLATFORM(IOS_FAMILY) |
572 | WKRetainPtr<WKDataRef> m_openPanelFileURLsMediaIcon; |
573 | #endif |
574 | |
575 | std::unique_ptr<EventSenderProxy> m_eventSenderProxy; |
576 | |
577 | WorkQueueManager m_workQueueManager; |
578 | |
579 | struct AbandonedDocumentInfo { |
580 | String testURL; |
581 | String abandonedDocumentURL; |
582 | |
583 | AbandonedDocumentInfo() = default; |
584 | AbandonedDocumentInfo(String inTestURL, String inAbandonedDocumentURL) |
585 | : testURL(inTestURL) |
586 | , abandonedDocumentURL(inAbandonedDocumentURL) |
587 | { } |
588 | }; |
589 | HashMap<uint64_t, AbandonedDocumentInfo> m_abandonedDocumentInfo; |
590 | |
591 | uint64_t m_serverTrustEvaluationCallbackCallsCount { 0 }; |
592 | bool m_shouldDismissJavaScriptAlertsAsynchronously { false }; |
593 | }; |
594 | |
595 | struct TestCommand { |
596 | std::string pathOrURL; |
597 | std::string absolutePath; |
598 | std::string expectedPixelHash; |
599 | WTF::Seconds timeout; |
600 | bool shouldDumpPixels { false }; |
601 | bool dumpJSConsoleLogInStdErr { false }; |
602 | }; |
603 | |
604 | } // namespace WTR |
605 | |