2 * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
28 #include "GeolocationProviderMock.h"
29 #include "TestOptions.h"
30 #include "WebNotificationProvider.h"
31 #include "WorkQueueManager.h"
32 #include <WebKit/WKRetainPtr.h>
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>
43 #include "ClassMethodSwizzler.h"
44 #include "InstanceMethodSwizzler.h"
48 OBJC_CLASS UIKeyboardInputMode
;
49 OBJC_CLASS WKWebViewConfiguration
;
55 class PlatformWebView
;
56 class EventSenderProxy
;
62 AsyncTask(WTF::Function
<void ()>&& task
, WTF::Seconds timeout
)
63 : m_task(WTFMove(task
))
66 ASSERT(!currentTask());
69 // Returns false on timeout.
77 static AsyncTask
* currentTask();
80 static AsyncTask
* m_currentTask
;
82 WTF::Function
<void ()> m_task
;
83 WTF::Seconds m_timeout
;
84 bool m_taskDone
{ false };
87 // FIXME: Rename this TestRunner?
88 class TestController
{
90 static TestController
& singleton();
91 static WKWebsiteDataStoreRef
websiteDataStore();
93 static const unsigned viewWidth
;
94 static const unsigned viewHeight
;
96 static const unsigned w3cSVGViewWidth
;
97 static const unsigned w3cSVGViewHeight
;
99 static const WTF::Seconds defaultShortTimeout
;
100 static const WTF::Seconds noTimeout
;
102 TestController(int argc
, const char* argv
[]);
105 bool verbose() const { return m_verbose
; }
107 WKStringRef
injectedBundlePath() const { return m_injectedBundlePath
.get(); }
108 WKStringRef
testPluginDirectory() const { return m_testPluginDirectory
.get(); }
110 PlatformWebView
* mainWebView() { return m_mainWebView
.get(); }
111 WKContextRef
context() { return m_context
.get(); }
112 WKUserContentControllerRef
userContentController() { return m_userContentController
.get(); }
114 EventSenderProxy
* eventSenderProxy() { return m_eventSenderProxy
.get(); }
116 bool shouldUseRemoteLayerTree() const { return m_shouldUseRemoteLayerTree
; }
118 // Runs the run loop until `done` is true or the timeout elapses.
119 bool useWaitToDumpWatchdogTimer() { return m_useWaitToDumpWatchdogTimer
; }
120 void runUntil(bool& done
, WTF::Seconds timeout
);
123 bool shouldShowWebView() const { return m_shouldShowWebView
; }
124 bool usingServerMode() const { return m_usingServerMode
; }
125 void configureViewForTest(const TestInvocation
&);
127 bool shouldShowTouches() const { return m_shouldShowTouches
; }
129 bool beforeUnloadReturnValue() const { return m_beforeUnloadReturnValue
; }
130 void setBeforeUnloadReturnValue(bool value
) { m_beforeUnloadReturnValue
= value
; }
132 void simulateWebNotificationClick(uint64_t notificationID
);
135 void setGeolocationPermission(bool);
136 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
);
137 void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage
);
138 void handleGeolocationPermissionRequest(WKGeolocationPermissionRequestRef
);
139 bool isGeolocationProviderActive() const;
142 String
saltForOrigin(WKFrameRef
, String
);
143 void getUserMediaInfoForOrigin(WKFrameRef
, WKStringRef originKey
, bool&, WKRetainPtr
<WKStringRef
>&);
144 WKStringRef
getUserMediaSaltForOrigin(WKFrameRef
, WKStringRef originKey
);
145 void setUserMediaPermission(bool);
146 void resetUserMediaPermission();
147 void setUserMediaPersistentPermissionForOrigin(bool, WKStringRef userMediaDocumentOriginString
, WKStringRef topLevelDocumentOriginString
);
148 void handleUserMediaPermissionRequest(WKFrameRef
, WKSecurityOriginRef
, WKSecurityOriginRef
, WKUserMediaPermissionRequestRef
);
149 void handleCheckOfUserMediaPermissionForOrigin(WKFrameRef
, WKSecurityOriginRef
, WKSecurityOriginRef
, const WKUserMediaPermissionCheckRef
&);
150 OriginSettings
& settingsForOrigin(const String
&);
151 unsigned userMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString
, WKStringRef topLevelDocumentOriginString
);
152 void resetUserMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString
, WKStringRef topLevelDocumentOriginString
);
154 // Device Orientation / Motion.
155 bool handleDeviceOrientationAndMotionAccessRequest(WKSecurityOriginRef
);
157 // Content Extensions.
158 void configureContentExtensionForTest(const TestInvocation
&);
159 void resetContentExtensions();
162 void setCustomPolicyDelegate(bool enabled
, bool permissive
);
165 void setHidden(bool);
167 unsigned imageCountInGeneralPasteboard() const;
169 enum class ResetStage
{ BeforeTest
, AfterTest
};
170 bool resetStateToConsistentValues(const TestOptions
&, ResetStage
);
171 void resetPreferencesToConsistentValues(const TestOptions
&);
173 void willDestroyWebView();
175 void terminateWebContentProcess();
176 void reattachPageToWebProcess();
178 static const char* webProcessName();
179 static const char* networkProcessName();
180 static const char* databaseProcessName();
182 WorkQueueManager
& workQueueManager() { return m_workQueueManager
; }
184 void setRejectsProtectionSpaceAndContinueForAuthenticationChallenges(bool value
) { m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges
= value
; }
185 void setHandlesAuthenticationChallenges(bool value
) { m_handlesAuthenticationChallenges
= value
; }
186 void setAuthenticationUsername(String username
) { m_authenticationUsername
= username
; }
187 void setAuthenticationPassword(String password
) { m_authenticationPassword
= password
; }
188 void setAllowsAnySSLCertificate(bool);
189 void setShouldSwapToEphemeralSessionOnNextNavigation(bool value
) { m_shouldSwapToEphemeralSessionOnNextNavigation
= value
; }
190 void setShouldSwapToDefaultSessionOnNextNavigation(bool value
) { m_shouldSwapToDefaultSessionOnNextNavigation
= value
; }
192 void setBlockAllPlugins(bool shouldBlock
);
193 void setPluginSupportedMode(const String
&);
195 void setShouldLogHistoryClientCallbacks(bool shouldLog
) { m_shouldLogHistoryClientCallbacks
= shouldLog
; }
196 void setShouldLogCanAuthenticateAgainstProtectionSpace(bool shouldLog
) { m_shouldLogCanAuthenticateAgainstProtectionSpace
= shouldLog
; }
197 void setShouldLogDownloadCallbacks(bool shouldLog
) { m_shouldLogDownloadCallbacks
= shouldLog
; }
199 bool isCurrentInvocation(TestInvocation
* invocation
) const { return invocation
== m_currentInvocation
.get(); }
201 void setShouldDecideNavigationPolicyAfterDelay(bool value
) { m_shouldDecideNavigationPolicyAfterDelay
= value
; }
202 void setShouldDecideResponsePolicyAfterDelay(bool value
) { m_shouldDecideResponsePolicyAfterDelay
= value
; }
204 void setNavigationGesturesEnabled(bool value
);
205 void setIgnoresViewportScaleLimits(bool);
207 void setShouldDownloadUndisplayableMIMETypes(bool value
) { m_shouldDownloadUndisplayableMIMETypes
= value
; }
208 void setShouldAllowDeviceOrientationAndMotionAccess(bool value
) { m_shouldAllowDeviceOrientationAndMotionAccess
= value
; }
210 void setStatisticsDebugMode(bool value
);
211 void setStatisticsPrevalentResourceForDebugMode(WKStringRef hostName
);
212 void setStatisticsLastSeen(WKStringRef hostName
, double seconds
);
213 void setStatisticsMergeStatistic(WKStringRef host
, WKStringRef topFrameDomain1
, WKStringRef topFrameDomain2
, double lastSeen
, bool hadUserInteraction
, double mostRecentUserInteraction
, bool isGrandfathered
, bool isPrevalent
, bool isVeryPrevalent
, int dataRecordsRemoved
);
214 void setStatisticsPrevalentResource(WKStringRef hostName
, bool value
);
215 void setStatisticsVeryPrevalentResource(WKStringRef hostName
, bool value
);
216 String
dumpResourceLoadStatistics();
217 bool isStatisticsPrevalentResource(WKStringRef hostName
);
218 bool isStatisticsVeryPrevalentResource(WKStringRef hostName
);
219 bool isStatisticsRegisteredAsSubresourceUnder(WKStringRef subresourceHost
, WKStringRef topFrameHost
);
220 bool isStatisticsRegisteredAsSubFrameUnder(WKStringRef subFrameHost
, WKStringRef topFrameHost
);
221 bool isStatisticsRegisteredAsRedirectingTo(WKStringRef hostRedirectedFrom
, WKStringRef hostRedirectedTo
);
222 void setStatisticsHasHadUserInteraction(WKStringRef hostName
, bool value
);
223 bool isStatisticsHasHadUserInteraction(WKStringRef hostName
);
224 bool isStatisticsOnlyInDatabaseOnce(WKStringRef subHost
, WKStringRef topHost
);
225 void setStatisticsGrandfathered(WKStringRef hostName
, bool value
);
226 bool isStatisticsGrandfathered(WKStringRef hostName
);
227 void setUseITPDatabase(bool value
);
228 void setStatisticsSubframeUnderTopFrameOrigin(WKStringRef hostName
, WKStringRef topFrameHostName
);
229 void setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName
, WKStringRef topFrameHostName
);
230 void setStatisticsSubresourceUniqueRedirectTo(WKStringRef hostName
, WKStringRef hostNameRedirectedTo
);
231 void setStatisticsSubresourceUniqueRedirectFrom(WKStringRef host
, WKStringRef hostRedirectedFrom
);
232 void setStatisticsTopFrameUniqueRedirectTo(WKStringRef host
, WKStringRef hostRedirectedTo
);
233 void setStatisticsTopFrameUniqueRedirectFrom(WKStringRef host
, WKStringRef hostRedirectedFrom
);
234 void setStatisticsCrossSiteLoadWithLinkDecoration(WKStringRef fromHost
, WKStringRef toHost
);
235 void setStatisticsTimeToLiveUserInteraction(double seconds
);
236 void statisticsProcessStatisticsAndDataRecords();
237 void statisticsUpdateCookieBlocking();
238 void statisticsSubmitTelemetry();
239 void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
240 void setStatisticsIsRunningTest(bool);
241 void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
242 void setStatisticsNotifyPagesWhenTelemetryWasCaptured(bool value
);
243 void setStatisticsMinimumTimeBetweenDataRecordsRemoval(double);
244 void setStatisticsGrandfatheringTime(double seconds
);
245 void setStatisticsMaxStatisticsEntries(unsigned);
246 void setStatisticsPruneEntriesDownTo(unsigned);
247 void statisticsClearInMemoryAndPersistentStore();
248 void statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned);
249 void statisticsClearThroughWebsiteDataRemoval();
250 void statisticsDeleteCookiesForHost(WKStringRef host
, bool includeHttpOnlyCookies
);
251 bool isStatisticsHasLocalStorage(WKStringRef hostName
);
252 void setStatisticsCacheMaxAgeCap(double seconds
);
253 bool hasStatisticsIsolatedSession(WKStringRef hostName
);
254 void setStatisticsShouldDowngradeReferrer(bool value
);
255 void setStatisticsShouldBlockThirdPartyCookies(bool value
);
256 void statisticsResetToConsistentState();
258 void getAllStorageAccessEntries();
260 WKArrayRef
openPanelFileURLs() const { return m_openPanelFileURLs
.get(); }
261 void setOpenPanelFileURLs(WKArrayRef fileURLs
) { m_openPanelFileURLs
= fileURLs
; }
263 #if PLATFORM(IOS_FAMILY)
264 WKDataRef
openPanelFileURLsMediaIcon() const { return m_openPanelFileURLsMediaIcon
.get(); }
265 void setOpenPanelFileURLsMediaIcon(WKDataRef mediaIcon
) { m_openPanelFileURLsMediaIcon
= mediaIcon
; }
268 void terminateNetworkProcess();
269 void terminateServiceWorkerProcess();
271 void removeAllSessionCredentials();
273 void clearIndexedDatabases();
274 void clearLocalStorage();
275 void syncLocalStorage();
277 void clearServiceWorkerRegistrations();
279 void clearDOMCache(WKStringRef origin
);
280 void clearDOMCaches();
281 bool hasDOMCache(WKStringRef origin
);
282 uint64_t domCacheSize(WKStringRef origin
);
284 void setAllowStorageQuotaIncrease(bool);
286 bool didReceiveServerRedirectForProvisionalNavigation() const { return m_didReceiveServerRedirectForProvisionalNavigation
; }
287 void clearDidReceiveServerRedirectForProvisionalNavigation() { m_didReceiveServerRedirectForProvisionalNavigation
= false; }
289 void addMockMediaDevice(WKStringRef persistentID
, WKStringRef label
, WKStringRef type
);
290 void clearMockMediaDevices();
291 void removeMockMediaDevice(WKStringRef persistentID
);
292 void resetMockMediaDevices();
294 void injectUserScript(WKStringRef
);
296 void sendDisplayConfigurationChangedMessageForTesting();
298 void setServiceWorkerFetchTimeoutForTesting(double seconds
);
300 void addTestKeyToKeychain(const String
& privateKeyBase64
, const String
& attrLabel
, const String
& applicationTagBase64
);
301 void cleanUpKeychain(const String
& attrLabel
, const String
& applicationTagBase64
);
302 bool keyExistsInKeychain(const String
& attrLabel
, const String
& applicationTagBase64
);
305 RetainPtr
<NSString
> getOverriddenCalendarIdentifier() const;
306 void setDefaultCalendarType(NSString
*identifier
);
307 #endif // PLATFORM(COCOA)
309 #if PLATFORM(IOS_FAMILY)
310 void setKeyboardInputModeIdentifier(const String
&);
311 UIKeyboardInputMode
*overriddenKeyboardInputMode() const { return m_overriddenKeyboardInputMode
.get(); }
314 void setAllowedMenuActions(const Vector
<String
>&);
315 void installCustomMenuAction(const String
& name
, bool dismissesAutomatically
);
317 uint64_t serverTrustEvaluationCallbackCallsCount() const { return m_serverTrustEvaluationCallbackCallsCount
; }
319 void setShouldDismissJavaScriptAlertsAsynchronously(bool);
320 void handleJavaScriptAlert(WKPageRunJavaScriptAlertResultListenerRef
);
323 bool isDoingMediaCapture() const;
325 String
dumpAdClickAttribution();
326 void clearAdClickAttribution();
327 void clearAdClickAttributionsThroughWebsiteDataRemoval();
328 void setAdClickAttributionOverrideTimerForTesting(bool value
);
329 void setAdClickAttributionConversionURLForTesting(WKURLRef
);
330 void markAdClickAttributionsAsExpiredForTesting();
333 WKRetainPtr
<WKPageConfigurationRef
> generatePageConfiguration(const TestOptions
&);
334 WKRetainPtr
<WKContextConfigurationRef
> generateContextConfiguration(const TestOptions::ContextOptions
&) const;
335 void initialize(int argc
, const char* argv
[]);
336 void createWebViewWithOptions(const TestOptions
&);
339 void runTestingServerLoop();
340 bool runTest(const char* pathOrURL
);
342 // Returns false if timed out.
343 bool waitForCompletion(const WTF::Function
<void ()>&, WTF::Seconds timeout
);
345 bool handleControlCommand(const char* command
);
347 void platformInitialize();
348 void platformDestroy();
349 WKContextRef
platformAdjustContext(WKContextRef
, WKContextConfigurationRef
);
350 void platformInitializeContext();
351 void platformAddTestOptions(TestOptions
&) const;
352 void platformCreateWebView(WKPageConfigurationRef
, const TestOptions
&);
353 static PlatformWebView
* platformCreateOtherPage(PlatformWebView
* parentView
, WKPageConfigurationRef
, const TestOptions
&);
354 void platformResetPreferencesToConsistentValues();
355 void platformResetStateToConsistentValues(const TestOptions
&);
357 void cocoaPlatformInitialize();
358 void cocoaResetStateToConsistentValues(const TestOptions
&);
360 void platformConfigureViewForTest(const TestInvocation
&);
361 void platformWillRunTest(const TestInvocation
&);
362 void platformRunUntil(bool& done
, WTF::Seconds timeout
);
363 void platformDidCommitLoadForFrame(WKPageRef
, WKFrameRef
);
364 WKContextRef
platformContext();
365 WKPreferencesRef
platformPreferences();
366 void initializeInjectedBundlePath();
367 void initializeTestPluginDirectory();
369 void ensureViewSupportsOptionsForTest(const TestInvocation
&);
370 TestOptions
testOptionsForTest(const TestCommand
&) const;
371 void updatePlatformSpecificTestOptionsForTest(TestOptions
&, const std::string
& pathOrURL
) const;
373 void updateWebViewSizeForTest(const TestInvocation
&);
374 void updateWindowScaleForTest(PlatformWebView
*, const TestInvocation
&);
376 void updateLiveDocumentsAfterTest();
377 void checkForWorldLeaks();
379 void didReceiveLiveDocumentsList(WKArrayRef
);
380 void dumpResponse(const String
&);
381 void findAndDumpWebKitProcessIdentifiers();
382 void findAndDumpWorldLeaks();
384 void decidePolicyForGeolocationPermissionRequestIfPossible();
385 void decidePolicyForUserMediaPermissionRequestIfPossible();
387 // WKContextInjectedBundleClient
388 static void didReceiveMessageFromInjectedBundle(WKContextRef
, WKStringRef messageName
, WKTypeRef messageBody
, const void*);
389 static void didReceiveSynchronousMessageFromInjectedBundleWithListener(WKContextRef
, WKStringRef messageName
, WKTypeRef messageBody
, WKMessageListenerRef
, const void*);
390 static WKTypeRef
getInjectedBundleInitializationUserData(WKContextRef
, const void *clientInfo
);
392 // WKPageInjectedBundleClient
393 static void didReceivePageMessageFromInjectedBundle(WKPageRef
, WKStringRef messageName
, WKTypeRef messageBody
, const void*);
394 static void didReceiveSynchronousPageMessageFromInjectedBundleWithListener(WKPageRef
, WKStringRef messageName
, WKTypeRef messageBody
, WKMessageListenerRef
, const void*);
395 void didReceiveMessageFromInjectedBundle(WKStringRef messageName
, WKTypeRef messageBody
);
396 void didReceiveSynchronousMessageFromInjectedBundle(WKStringRef messageName
, WKTypeRef messageBody
, WKMessageListenerRef
);
397 WKRetainPtr
<WKTypeRef
> getInjectedBundleInitializationUserData();
399 void didReceiveKeyDownMessageFromInjectedBundle(WKDictionaryRef messageBodyDictionary
, bool synchronous
);
402 static void networkProcessDidCrash(WKContextRef
, const void*);
403 void networkProcessDidCrash();
405 // WKPageNavigationClient
406 static void didCommitNavigation(WKPageRef
, WKNavigationRef
, WKTypeRef userData
, const void*);
407 void didCommitNavigation(WKPageRef
, WKNavigationRef
);
409 static void didFinishNavigation(WKPageRef
, WKNavigationRef
, WKTypeRef userData
, const void*);
410 void didFinishNavigation(WKPageRef
, WKNavigationRef
);
412 // WKContextDownloadClient
413 static void downloadDidStart(WKContextRef
, WKDownloadRef
, const void*);
414 void downloadDidStart(WKContextRef
, WKDownloadRef
);
415 static WKStringRef
decideDestinationWithSuggestedFilename(WKContextRef
, WKDownloadRef
, WKStringRef filename
, bool* allowOverwrite
, const void *clientInfo
);
416 WKStringRef
decideDestinationWithSuggestedFilename(WKContextRef
, WKDownloadRef
, WKStringRef filename
, bool*& allowOverwrite
);
417 static void downloadDidFinish(WKContextRef
, WKDownloadRef
, const void*);
418 void downloadDidFinish(WKContextRef
, WKDownloadRef
);
419 static void downloadDidFail(WKContextRef
, WKDownloadRef
, WKErrorRef
, const void*);
420 void downloadDidFail(WKContextRef
, WKDownloadRef
, WKErrorRef
);
421 static void downloadDidCancel(WKContextRef
, WKDownloadRef
, const void*);
422 void downloadDidCancel(WKContextRef
, WKDownloadRef
);
423 static void downloadDidReceiveServerRedirectToURL(WKContextRef
, WKDownloadRef
, WKURLRef
, const void*);
424 void downloadDidReceiveServerRedirectToURL(WKContextRef
, WKDownloadRef
, WKURLRef
);
426 static void processDidCrash(WKPageRef
, const void* clientInfo
);
427 void processDidCrash();
429 static void didBeginNavigationGesture(WKPageRef
, const void*);
430 static void willEndNavigationGesture(WKPageRef
, WKBackForwardListItemRef
, const void*);
431 static void didEndNavigationGesture(WKPageRef
, WKBackForwardListItemRef
, const void*);
432 static void didRemoveNavigationGestureSnapshot(WKPageRef
, const void*);
433 void didBeginNavigationGesture(WKPageRef
);
434 void willEndNavigationGesture(WKPageRef
, WKBackForwardListItemRef
);
435 void didEndNavigationGesture(WKPageRef
, WKBackForwardListItemRef
);
436 void didRemoveNavigationGestureSnapshot(WKPageRef
);
438 static WKPluginLoadPolicy
decidePolicyForPluginLoad(WKPageRef
, WKPluginLoadPolicy currentPluginLoadPolicy
, WKDictionaryRef pluginInformation
, WKStringRef
* unavailabilityDescription
, const void* clientInfo
);
439 WKPluginLoadPolicy
decidePolicyForPluginLoad(WKPageRef
, WKPluginLoadPolicy currentPluginLoadPolicy
, WKDictionaryRef pluginInformation
, WKStringRef
* unavailabilityDescription
);
442 static void decidePolicyForNotificationPermissionRequest(WKPageRef
, WKSecurityOriginRef
, WKNotificationPermissionRequestRef
, const void*);
443 void decidePolicyForNotificationPermissionRequest(WKPageRef
, WKSecurityOriginRef
, WKNotificationPermissionRequestRef
);
445 static void unavailablePluginButtonClicked(WKPageRef
, WKPluginUnavailabilityReason
, WKDictionaryRef
, const void*);
447 static void didReceiveServerRedirectForProvisionalNavigation(WKPageRef
, WKNavigationRef
, WKTypeRef
, const void*);
448 void didReceiveServerRedirectForProvisionalNavigation(WKPageRef
, WKNavigationRef
, WKTypeRef
);
450 static bool canAuthenticateAgainstProtectionSpace(WKPageRef
, WKProtectionSpaceRef
, const void*);
451 bool canAuthenticateAgainstProtectionSpace(WKPageRef
, WKProtectionSpaceRef
);
453 static void didReceiveAuthenticationChallenge(WKPageRef
, WKAuthenticationChallengeRef
, const void*);
454 void didReceiveAuthenticationChallenge(WKPageRef
, WKAuthenticationChallengeRef
);
456 static void decidePolicyForNavigationAction(WKPageRef
, WKNavigationActionRef
, WKFramePolicyListenerRef
, WKTypeRef
, const void*);
457 void decidePolicyForNavigationAction(WKNavigationActionRef
, WKFramePolicyListenerRef
);
459 static void decidePolicyForNavigationResponse(WKPageRef
, WKNavigationResponseRef
, WKFramePolicyListenerRef
, WKTypeRef
, const void*);
460 void decidePolicyForNavigationResponse(WKNavigationResponseRef
, WKFramePolicyListenerRef
);
462 // WKContextHistoryClient
463 static void didNavigateWithNavigationData(WKContextRef
, WKPageRef
, WKNavigationDataRef
, WKFrameRef
, const void*);
464 void didNavigateWithNavigationData(WKNavigationDataRef
, WKFrameRef
);
466 static void didPerformClientRedirect(WKContextRef
, WKPageRef
, WKURLRef sourceURL
, WKURLRef destinationURL
, WKFrameRef
, const void*);
467 void didPerformClientRedirect(WKURLRef sourceURL
, WKURLRef destinationURL
, WKFrameRef
);
469 static void didPerformServerRedirect(WKContextRef
, WKPageRef
, WKURLRef sourceURL
, WKURLRef destinationURL
, WKFrameRef
, const void*);
470 void didPerformServerRedirect(WKURLRef sourceURL
, WKURLRef destinationURL
, WKFrameRef
);
472 static void didUpdateHistoryTitle(WKContextRef
, WKPageRef
, WKStringRef title
, WKURLRef
, WKFrameRef
, const void*);
473 void didUpdateHistoryTitle(WKStringRef title
, WKURLRef
, WKFrameRef
);
475 static WKPageRef
createOtherPage(WKPageRef
, WKPageConfigurationRef
, WKNavigationActionRef
, WKWindowFeaturesRef
, const void*);
476 WKPageRef
createOtherPage(PlatformWebView
* parentView
, WKPageConfigurationRef
, WKNavigationActionRef
, WKWindowFeaturesRef
);
478 static void runModal(WKPageRef
, const void* clientInfo
);
479 static void runModal(PlatformWebView
*);
482 static void finishCreatingPlatformWebView(PlatformWebView
*, const TestOptions
&);
483 void configureContentMode(WKWebViewConfiguration
*, const TestOptions
&);
486 static const char* libraryPathForTesting();
487 static const char* platformLibraryPathForTesting();
489 std::unique_ptr
<TestInvocation
> m_currentInvocation
;
491 std::unique_ptr
<ClassMethodSwizzler
> m_calendarSwizzler
;
492 RetainPtr
<NSString
> m_overriddenCalendarIdentifier
;
493 #endif // PLATFORM(COCOA)
494 bool m_verbose
{ false };
495 bool m_printSeparators
{ false };
496 bool m_usingServerMode
{ false };
497 bool m_gcBetweenTests
{ false };
498 bool m_shouldDumpPixelsForAllTests
{ false };
499 std::vector
<std::string
> m_paths
;
500 std::set
<std::string
> m_allowedHosts
;
501 WKRetainPtr
<WKStringRef
> m_injectedBundlePath
;
502 WKRetainPtr
<WKStringRef
> m_testPluginDirectory
;
504 WebNotificationProvider m_webNotificationProvider
;
506 std::unique_ptr
<PlatformWebView
> m_mainWebView
;
507 WKRetainPtr
<WKContextRef
> m_context
;
508 Optional
<TestOptions::ContextOptions
> m_contextOptions
;
509 WKRetainPtr
<WKPageGroupRef
> m_pageGroup
;
510 WKRetainPtr
<WKUserContentControllerRef
> m_userContentController
;
512 #if PLATFORM(IOS_FAMILY)
513 Vector
<std::unique_ptr
<InstanceMethodSwizzler
>> m_inputModeSwizzlers
;
514 RetainPtr
<UIKeyboardInputMode
> m_overriddenKeyboardInputMode
;
515 Vector
<std::unique_ptr
<InstanceMethodSwizzler
>> m_presentPopoverSwizzlers
;
523 State m_state
{ Initial
};
524 bool m_doneResetting
{ false };
526 bool m_useWaitToDumpWatchdogTimer
{ true };
527 bool m_forceNoTimeout
{ false };
529 bool m_didPrintWebProcessCrashedMessage
{ false };
530 bool m_shouldExitWhenWebProcessCrashes
{ true };
532 bool m_beforeUnloadReturnValue
{ true };
534 std::unique_ptr
<GeolocationProviderMock
> m_geolocationProvider
;
535 Vector
<WKRetainPtr
<WKGeolocationPermissionRequestRef
> > m_geolocationPermissionRequests
;
536 bool m_isGeolocationPermissionSet
{ false };
537 bool m_isGeolocationPermissionAllowed
{ false };
539 HashMap
<String
, RefPtr
<OriginSettings
>> m_cachedUserMediaPermissions
;
541 typedef Vector
<std::pair
<String
, WKRetainPtr
<WKUserMediaPermissionRequestRef
>>> PermissionRequestList
;
542 PermissionRequestList m_userMediaPermissionRequests
;
544 bool m_isUserMediaPermissionSet
{ false };
545 bool m_isUserMediaPermissionAllowed
{ false };
547 bool m_policyDelegateEnabled
{ false };
548 bool m_policyDelegatePermissive
{ false };
549 bool m_shouldDownloadUndisplayableMIMETypes
{ false };
550 bool m_shouldAllowDeviceOrientationAndMotionAccess
{ false };
552 bool m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges
{ false };
553 bool m_handlesAuthenticationChallenges
{ false };
554 String m_authenticationUsername
;
555 String m_authenticationPassword
;
557 bool m_shouldBlockAllPlugins
{ false };
558 String m_unsupportedPluginMode
;
560 bool m_forceComplexText
{ false };
561 bool m_shouldUseAcceleratedDrawing
{ false };
562 bool m_shouldUseRemoteLayerTree
{ false };
564 bool m_shouldLogCanAuthenticateAgainstProtectionSpace
{ false };
565 bool m_shouldLogDownloadCallbacks
{ false };
566 bool m_shouldLogHistoryClientCallbacks
{ false };
567 bool m_shouldShowWebView
{ false };
569 bool m_shouldShowTouches
{ false };
570 bool m_checkForWorldLeaks
{ false };
572 bool m_allowAnyHTTPSCertificateForAllowedHosts
{ false };
574 bool m_shouldDecideNavigationPolicyAfterDelay
{ false };
575 bool m_shouldDecideResponsePolicyAfterDelay
{ false };
577 bool m_didReceiveServerRedirectForProvisionalNavigation
{ false };
579 WKRetainPtr
<WKArrayRef
> m_openPanelFileURLs
;
580 #if PLATFORM(IOS_FAMILY)
581 WKRetainPtr
<WKDataRef
> m_openPanelFileURLsMediaIcon
;
584 std::unique_ptr
<EventSenderProxy
> m_eventSenderProxy
;
588 RunLoopQt
* m_runLoop
;
591 WorkQueueManager m_workQueueManager
;
593 struct AbandonedDocumentInfo
{
595 String abandonedDocumentURL
;
597 AbandonedDocumentInfo() = default;
598 AbandonedDocumentInfo(String inTestURL
, String inAbandonedDocumentURL
)
600 , abandonedDocumentURL(inAbandonedDocumentURL
)
603 HashMap
<uint64_t, AbandonedDocumentInfo
> m_abandonedDocumentInfo
;
605 uint64_t m_serverTrustEvaluationCallbackCallsCount
{ 0 };
606 bool m_shouldDismissJavaScriptAlertsAsynchronously
{ false };
607 bool m_allowsAnySSLCertificate
{ true };
608 bool m_shouldSwapToEphemeralSessionOnNextNavigation
{ false };
609 bool m_shouldSwapToDefaultSessionOnNextNavigation
{ false };
613 std::string pathOrURL
;
614 std::string absolutePath
;
615 std::string expectedPixelHash
;
616 WTF::Seconds timeout
;
617 bool shouldDumpPixels
{ false };
618 bool dumpJSConsoleLogInStdErr
{ false };