REGRESSION (r230523): Caps lock indicator not shown in password field
[WebKit-https.git] / Tools / WebKitTestRunner / TestController.h
1 /*
2  * Copyright (C) 2010, 2015-2017 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 "WebNotificationProvider.h"
30 #include "WorkQueueManager.h"
31 #include <WebKit/WKRetainPtr.h>
32 #include <set>
33 #include <string>
34 #include <vector>
35 #include <wtf/HashMap.h>
36 #include <wtf/Seconds.h>
37 #include <wtf/Vector.h>
38 #include <wtf/text/StringHash.h>
39
40 OBJC_CLASS WKWebViewConfiguration;
41
42 namespace WTR {
43
44 class TestInvocation;
45 class OriginSettings;
46 class PlatformWebView;
47 class EventSenderProxy;
48 struct TestCommand;
49 struct TestOptions;
50
51 class AsyncTask {
52 public:
53     AsyncTask(WTF::Function<void ()>&& task, WTF::Seconds timeout)
54         : m_task(WTFMove(task))
55         , m_timeout(timeout)
56     {
57         ASSERT(!currentTask());
58     }
59
60     // Returns false on timeout.
61     bool run();
62
63     void taskComplete()
64     {
65         m_taskDone = true;
66     }
67
68     static AsyncTask* currentTask();
69
70 private:
71     static AsyncTask* m_currentTask;
72
73     WTF::Function<void ()> m_task;
74     WTF::Seconds m_timeout;
75     bool m_taskDone { false };
76 };
77
78 // FIXME: Rename this TestRunner?
79 class TestController {
80 public:
81     static TestController& singleton();
82
83     static const unsigned viewWidth;
84     static const unsigned viewHeight;
85
86     static const unsigned w3cSVGViewWidth;
87     static const unsigned w3cSVGViewHeight;
88
89     static const WTF::Seconds defaultShortTimeout;
90     static const WTF::Seconds noTimeout;
91
92     TestController(int argc, const char* argv[]);
93     ~TestController();
94
95     bool verbose() const { return m_verbose; }
96
97     WKStringRef injectedBundlePath() const { return m_injectedBundlePath.get(); }
98     WKStringRef testPluginDirectory() const { return m_testPluginDirectory.get(); }
99
100     PlatformWebView* mainWebView() { return m_mainWebView.get(); }
101     WKContextRef context() { return m_context.get(); }
102
103     EventSenderProxy* eventSenderProxy() { return m_eventSenderProxy.get(); }
104
105     bool shouldUseRemoteLayerTree() const { return m_shouldUseRemoteLayerTree; }
106     
107     // Runs the run loop until `done` is true or the timeout elapses.
108     bool useWaitToDumpWatchdogTimer() { return m_useWaitToDumpWatchdogTimer; }
109     void runUntil(bool& done, WTF::Seconds timeout);
110     void notifyDone();
111
112     bool shouldShowWebView() const { return m_shouldShowWebView; }
113     bool usingServerMode() const { return m_usingServerMode; }
114     void configureViewForTest(const TestInvocation&);
115     
116     bool shouldShowTouches() const { return m_shouldShowTouches; }
117     
118     bool beforeUnloadReturnValue() const { return m_beforeUnloadReturnValue; }
119     void setBeforeUnloadReturnValue(bool value) { m_beforeUnloadReturnValue = value; }
120
121     void simulateWebNotificationClick(uint64_t notificationID);
122
123     // Geolocation.
124     void setGeolocationPermission(bool);
125     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);
126     void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage);
127     void handleGeolocationPermissionRequest(WKGeolocationPermissionRequestRef);
128     bool isGeolocationProviderActive() const;
129
130     // MediaStream.
131     String saltForOrigin(WKFrameRef, String);
132     void getUserMediaInfoForOrigin(WKFrameRef, WKStringRef originKey, bool&, WKRetainPtr<WKStringRef>&);
133     WKStringRef getUserMediaSaltForOrigin(WKFrameRef, WKStringRef originKey);
134     void setUserMediaPermission(bool);
135     void resetUserMediaPermission();
136     void setUserMediaPersistentPermissionForOrigin(bool, WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
137     void handleUserMediaPermissionRequest(WKFrameRef, WKSecurityOriginRef, WKSecurityOriginRef, WKUserMediaPermissionRequestRef);
138     void handleCheckOfUserMediaPermissionForOrigin(WKFrameRef, WKSecurityOriginRef, WKSecurityOriginRef, const WKUserMediaPermissionCheckRef&);
139     OriginSettings& settingsForOrigin(const String&);
140     unsigned userMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
141     void resetUserMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
142
143     // Policy delegate.
144     void setCustomPolicyDelegate(bool enabled, bool permissive);
145
146     // Page Visibility.
147     void setHidden(bool);
148
149     unsigned imageCountInGeneralPasteboard() const;
150
151     enum class ResetStage { BeforeTest, AfterTest };
152     bool resetStateToConsistentValues(const TestOptions&, ResetStage);
153     void resetPreferencesToConsistentValues(const TestOptions&);
154
155     void willDestroyWebView();
156
157     void terminateWebContentProcess();
158     void reattachPageToWebProcess();
159
160     static const char* webProcessName();
161     static const char* networkProcessName();
162     static const char* databaseProcessName();
163
164     WorkQueueManager& workQueueManager() { return m_workQueueManager; }
165
166     void setRejectsProtectionSpaceAndContinueForAuthenticationChallenges(bool value) { m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges = value; }
167     void setHandlesAuthenticationChallenges(bool value) { m_handlesAuthenticationChallenges = value; }
168     void setAuthenticationUsername(String username) { m_authenticationUsername = username; }
169     void setAuthenticationPassword(String password) { m_authenticationPassword = password; }
170     void setAllowsAnySSLCertificate(bool);
171
172     void setBlockAllPlugins(bool shouldBlock);
173     void setPluginSupportedMode(const String&);
174
175     void setShouldLogHistoryClientCallbacks(bool shouldLog) { m_shouldLogHistoryClientCallbacks = shouldLog; }
176     void setShouldLogCanAuthenticateAgainstProtectionSpace(bool shouldLog) { m_shouldLogCanAuthenticateAgainstProtectionSpace = shouldLog; }
177     void setShouldLogDownloadCallbacks(bool shouldLog) { m_shouldLogDownloadCallbacks = shouldLog; }
178
179     bool isCurrentInvocation(TestInvocation* invocation) const { return invocation == m_currentInvocation.get(); }
180
181     void setShouldDecideNavigationPolicyAfterDelay(bool value) { m_shouldDecideNavigationPolicyAfterDelay = value; }
182     void setShouldDecideResponsePolicyAfterDelay(bool value) { m_shouldDecideResponsePolicyAfterDelay = value; }
183
184     void setNavigationGesturesEnabled(bool value);
185     void setIgnoresViewportScaleLimits(bool);
186
187     void setShouldDownloadUndisplayableMIMETypes(bool value) { m_shouldDownloadUndisplayableMIMETypes = value; }
188
189     void setStatisticsDebugMode(bool value);
190     void setStatisticsPrevalentResourceForDebugMode(WKStringRef hostName);
191     void setStatisticsLastSeen(WKStringRef hostName, double seconds);
192     void setStatisticsPrevalentResource(WKStringRef hostName, bool value);
193     void setStatisticsVeryPrevalentResource(WKStringRef hostName, bool value);
194     String dumpResourceLoadStatistics();
195     bool isStatisticsPrevalentResource(WKStringRef hostName);
196     bool isStatisticsVeryPrevalentResource(WKStringRef hostName);
197     bool isStatisticsRegisteredAsSubresourceUnder(WKStringRef subresourceHost, WKStringRef topFrameHost);
198     bool isStatisticsRegisteredAsSubFrameUnder(WKStringRef subFrameHost, WKStringRef topFrameHost);
199     bool isStatisticsRegisteredAsRedirectingTo(WKStringRef hostRedirectedFrom, WKStringRef hostRedirectedTo);
200     void setStatisticsHasHadUserInteraction(WKStringRef hostName, bool value);
201     bool isStatisticsHasHadUserInteraction(WKStringRef hostName);
202     void setStatisticsGrandfathered(WKStringRef hostName, bool value);
203     bool isStatisticsGrandfathered(WKStringRef hostName);
204     void setStatisticsSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
205     void setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
206     void setStatisticsSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo);
207     void setStatisticsSubresourceUniqueRedirectFrom(WKStringRef host, WKStringRef hostRedirectedFrom);
208     void setStatisticsTopFrameUniqueRedirectTo(WKStringRef host, WKStringRef hostRedirectedTo);
209     void setStatisticsTopFrameUniqueRedirectFrom(WKStringRef host, WKStringRef hostRedirectedFrom);
210     void setStatisticsTimeToLiveUserInteraction(double seconds);
211     void statisticsProcessStatisticsAndDataRecords();
212     void statisticsUpdateCookieBlocking();
213     void statisticsSubmitTelemetry();
214     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
215     void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
216     void setStatisticsNotifyPagesWhenTelemetryWasCaptured(bool value);
217     void setStatisticsMinimumTimeBetweenDataRecordsRemoval(double);
218     void setStatisticsGrandfatheringTime(double seconds);
219     void setStatisticsMaxStatisticsEntries(unsigned);
220     void setStatisticsPruneEntriesDownTo(unsigned);
221     void statisticsClearInMemoryAndPersistentStore();
222     void statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned);
223     void statisticsClearThroughWebsiteDataRemoval();
224     void setStatisticsCacheMaxAgeCap(double seconds);
225     void statisticsResetToConsistentState();
226
227     void getAllStorageAccessEntries();
228
229     WKArrayRef openPanelFileURLs() const { return m_openPanelFileURLs.get(); }
230     void setOpenPanelFileURLs(WKArrayRef fileURLs) { m_openPanelFileURLs = fileURLs; }
231
232     void terminateNetworkProcess();
233     void terminateServiceWorkerProcess();
234
235     void removeAllSessionCredentials();
236
237     void clearServiceWorkerRegistrations();
238
239     void clearDOMCache(WKStringRef origin);
240     void clearDOMCaches();
241     bool hasDOMCache(WKStringRef origin);
242     uint64_t domCacheSize(WKStringRef origin);
243
244     void setIDBPerOriginQuota(uint64_t);
245
246     bool didReceiveServerRedirectForProvisionalNavigation() const { return m_didReceiveServerRedirectForProvisionalNavigation; }
247     void clearDidReceiveServerRedirectForProvisionalNavigation() { m_didReceiveServerRedirectForProvisionalNavigation = false; }
248
249     void addMockMediaDevice(WKStringRef persistentID, WKStringRef label, WKStringRef type);
250     void clearMockMediaDevices();
251     void removeMockMediaDevice(WKStringRef persistentID);
252     void resetMockMediaDevices();
253
254     void injectUserScript(WKStringRef);
255     
256     void sendDisplayConfigurationChangedMessageForTesting();
257
258     void setWebAuthenticationMockConfiguration(WKDictionaryRef);
259     void addTestKeyToKeychain(const String& privateKeyBase64, const String& attrLabel, const String& applicationTagBase64);
260     void cleanUpKeychain(const String& attrLabel);
261     bool keyExistsInKeychain(const String& attrLabel, const String& applicationTagBase64);
262
263     void toggleCapsLock();
264
265 private:
266     WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration(WKContextConfigurationRef);
267     WKRetainPtr<WKContextConfigurationRef> generateContextConfiguration() const;
268     void initialize(int argc, const char* argv[]);
269     void createWebViewWithOptions(const TestOptions&);
270     void run();
271
272     void runTestingServerLoop();
273     bool runTest(const char* pathOrURL);
274     
275     // Returns false if timed out.
276     bool waitForCompletion(const WTF::Function<void ()>&, WTF::Seconds timeout);
277
278     bool handleControlCommand(const char* command);
279
280     void platformInitialize();
281     void platformDestroy();
282     WKContextRef platformAdjustContext(WKContextRef, WKContextConfigurationRef);
283     void platformInitializeContext();
284     void platformAddTestOptions(TestOptions&) const;
285     void platformCreateWebView(WKPageConfigurationRef, const TestOptions&);
286     static PlatformWebView* platformCreateOtherPage(PlatformWebView* parentView, WKPageConfigurationRef, const TestOptions&);
287     void platformResetPreferencesToConsistentValues();
288     void platformResetStateToConsistentValues();
289 #if PLATFORM(COCOA)
290     void cocoaPlatformInitialize();
291     void cocoaResetStateToConsistentValues();
292 #endif
293     void platformConfigureViewForTest(const TestInvocation&);
294     void platformWillRunTest(const TestInvocation&);
295     void platformRunUntil(bool& done, WTF::Seconds timeout);
296     void platformDidCommitLoadForFrame(WKPageRef, WKFrameRef);
297     WKContextRef platformContext();
298     WKPreferencesRef platformPreferences();
299     void initializeInjectedBundlePath();
300     void initializeTestPluginDirectory();
301
302     void ensureViewSupportsOptionsForTest(const TestInvocation&);
303     TestOptions testOptionsForTest(const TestCommand&) const;
304     void updatePlatformSpecificTestOptionsForTest(TestOptions&, const std::string& pathOrURL) const;
305
306     void updateWebViewSizeForTest(const TestInvocation&);
307     void updateWindowScaleForTest(PlatformWebView*, const TestInvocation&);
308
309     void updateLiveDocumentsAfterTest();
310     void checkForWorldLeaks();
311
312     void didReceiveLiveDocumentsList(WKArrayRef);
313     void findAndDumpWorldLeaks();
314
315     void decidePolicyForGeolocationPermissionRequestIfPossible();
316     void decidePolicyForUserMediaPermissionRequestIfPossible();
317
318     // WKContextInjectedBundleClient
319     static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, const void*);
320     static void didReceiveSynchronousMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void*);
321     static WKTypeRef getInjectedBundleInitializationUserData(WKContextRef, const void *clientInfo);
322
323     // WKPageInjectedBundleClient
324     static void didReceivePageMessageFromInjectedBundle(WKPageRef, WKStringRef messageName, WKTypeRef messageBody, const void*);
325     static void didReceiveSynchronousPageMessageFromInjectedBundle(WKPageRef, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void*);
326     void didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
327     WKRetainPtr<WKTypeRef> didReceiveSynchronousMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
328     WKRetainPtr<WKTypeRef> getInjectedBundleInitializationUserData();
329
330     void didReceiveKeyDownMessageFromInjectedBundle(WKDictionaryRef messageBodyDictionary, bool synchronous);
331
332     // WKContextClient
333     static void networkProcessDidCrash(WKContextRef, const void*);
334     void networkProcessDidCrash();
335
336     // WKPageNavigationClient
337     static void didCommitNavigation(WKPageRef, WKNavigationRef, WKTypeRef userData, const void*);
338     void didCommitNavigation(WKPageRef, WKNavigationRef);
339
340     static void didFinishNavigation(WKPageRef, WKNavigationRef, WKTypeRef userData, const void*);
341     void didFinishNavigation(WKPageRef, WKNavigationRef);
342
343     // WKContextDownloadClient
344     static void downloadDidStart(WKContextRef, WKDownloadRef, const void*);
345     void downloadDidStart(WKContextRef, WKDownloadRef);
346     static WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef, WKStringRef filename, bool* allowOverwrite, const void *clientInfo);
347     WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef, WKStringRef filename, bool*& allowOverwrite);
348     static void downloadDidFinish(WKContextRef, WKDownloadRef, const void*);
349     void downloadDidFinish(WKContextRef, WKDownloadRef);
350     static void downloadDidFail(WKContextRef, WKDownloadRef, WKErrorRef, const void*);
351     void downloadDidFail(WKContextRef, WKDownloadRef, WKErrorRef);
352     static void downloadDidCancel(WKContextRef, WKDownloadRef, const void*);
353     void downloadDidCancel(WKContextRef, WKDownloadRef);
354     static void downloadDidReceiveServerRedirectToURL(WKContextRef, WKDownloadRef, WKURLRef, const void*);
355     void downloadDidReceiveServerRedirectToURL(WKContextRef, WKDownloadRef, WKURLRef);
356     
357     static void processDidCrash(WKPageRef, const void* clientInfo);
358     void processDidCrash();
359
360     static void didBeginNavigationGesture(WKPageRef, const void*);
361     static void willEndNavigationGesture(WKPageRef, WKBackForwardListItemRef, const void*);
362     static void didEndNavigationGesture(WKPageRef, WKBackForwardListItemRef, const void*);
363     static void didRemoveNavigationGestureSnapshot(WKPageRef, const void*);
364     void didBeginNavigationGesture(WKPageRef);
365     void willEndNavigationGesture(WKPageRef, WKBackForwardListItemRef);
366     void didEndNavigationGesture(WKPageRef, WKBackForwardListItemRef);
367     void didRemoveNavigationGestureSnapshot(WKPageRef);
368
369     static WKPluginLoadPolicy decidePolicyForPluginLoad(WKPageRef, WKPluginLoadPolicy currentPluginLoadPolicy, WKDictionaryRef pluginInformation, WKStringRef* unavailabilityDescription, const void* clientInfo);
370     WKPluginLoadPolicy decidePolicyForPluginLoad(WKPageRef, WKPluginLoadPolicy currentPluginLoadPolicy, WKDictionaryRef pluginInformation, WKStringRef* unavailabilityDescription);
371     
372
373     static void decidePolicyForNotificationPermissionRequest(WKPageRef, WKSecurityOriginRef, WKNotificationPermissionRequestRef, const void*);
374     void decidePolicyForNotificationPermissionRequest(WKPageRef, WKSecurityOriginRef, WKNotificationPermissionRequestRef);
375
376     static void unavailablePluginButtonClicked(WKPageRef, WKPluginUnavailabilityReason, WKDictionaryRef, const void*);
377
378     static void didReceiveServerRedirectForProvisionalNavigation(WKPageRef, WKNavigationRef, WKTypeRef, const void*);
379     void didReceiveServerRedirectForProvisionalNavigation(WKPageRef, WKNavigationRef, WKTypeRef);
380
381     static bool canAuthenticateAgainstProtectionSpace(WKPageRef, WKProtectionSpaceRef, const void*);
382     bool canAuthenticateAgainstProtectionSpace(WKPageRef, WKProtectionSpaceRef);
383
384     static void didReceiveAuthenticationChallenge(WKPageRef, WKAuthenticationChallengeRef, const void*);
385     void didReceiveAuthenticationChallenge(WKPageRef, WKAuthenticationChallengeRef);
386
387     static void decidePolicyForNavigationAction(WKPageRef, WKNavigationActionRef, WKFramePolicyListenerRef, WKTypeRef, const void*);
388     void decidePolicyForNavigationAction(WKFramePolicyListenerRef);
389
390     static void decidePolicyForNavigationResponse(WKPageRef, WKNavigationResponseRef, WKFramePolicyListenerRef, WKTypeRef, const void*);
391     void decidePolicyForNavigationResponse(WKNavigationResponseRef, WKFramePolicyListenerRef);
392
393     // WKContextHistoryClient
394     static void didNavigateWithNavigationData(WKContextRef, WKPageRef, WKNavigationDataRef, WKFrameRef, const void*);
395     void didNavigateWithNavigationData(WKNavigationDataRef, WKFrameRef);
396
397     static void didPerformClientRedirect(WKContextRef, WKPageRef, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef, const void*);
398     void didPerformClientRedirect(WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef);
399
400     static void didPerformServerRedirect(WKContextRef, WKPageRef, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef, const void*);
401     void didPerformServerRedirect(WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef);
402
403     static void didUpdateHistoryTitle(WKContextRef, WKPageRef, WKStringRef title, WKURLRef, WKFrameRef, const void*);
404     void didUpdateHistoryTitle(WKStringRef title, WKURLRef, WKFrameRef);
405
406     static WKPageRef createOtherPage(WKPageRef, WKPageConfigurationRef, WKNavigationActionRef, WKWindowFeaturesRef, const void*);
407     WKPageRef createOtherPage(PlatformWebView* parentView, WKPageConfigurationRef, WKNavigationActionRef, WKWindowFeaturesRef);
408
409     static void runModal(WKPageRef, const void* clientInfo);
410     static void runModal(PlatformWebView*);
411
412     static const char* libraryPathForTesting();
413     static const char* platformLibraryPathForTesting();
414
415     std::unique_ptr<TestInvocation> m_currentInvocation;
416
417     bool m_verbose { false };
418     bool m_printSeparators { false };
419     bool m_usingServerMode { false };
420     bool m_gcBetweenTests { false };
421     bool m_shouldDumpPixelsForAllTests { false };
422     std::vector<std::string> m_paths;
423     std::set<std::string> m_allowedHosts;
424     WKRetainPtr<WKStringRef> m_injectedBundlePath;
425     WKRetainPtr<WKStringRef> m_testPluginDirectory;
426
427     WebNotificationProvider m_webNotificationProvider;
428
429     std::unique_ptr<PlatformWebView> m_mainWebView;
430     WKRetainPtr<WKContextRef> m_context;
431     WKRetainPtr<WKPageGroupRef> m_pageGroup;
432
433     enum State {
434         Initial,
435         Resetting,
436         RunningTest
437     };
438     State m_state { Initial };
439     bool m_doneResetting { false };
440
441     bool m_useWaitToDumpWatchdogTimer { true };
442     bool m_forceNoTimeout { false };
443
444     bool m_didPrintWebProcessCrashedMessage { false };
445     bool m_shouldExitWhenWebProcessCrashes { true };
446     
447     bool m_beforeUnloadReturnValue { true };
448
449     std::unique_ptr<GeolocationProviderMock> m_geolocationProvider;
450     Vector<WKRetainPtr<WKGeolocationPermissionRequestRef> > m_geolocationPermissionRequests;
451     bool m_isGeolocationPermissionSet { false };
452     bool m_isGeolocationPermissionAllowed { false };
453
454     HashMap<String, RefPtr<OriginSettings>> m_cachedUserMediaPermissions;
455
456     typedef Vector<std::pair<String, WKRetainPtr<WKUserMediaPermissionRequestRef>>> PermissionRequestList;
457     PermissionRequestList m_userMediaPermissionRequests;
458
459     bool m_isUserMediaPermissionSet { false };
460     bool m_isUserMediaPermissionAllowed { false };
461
462     bool m_policyDelegateEnabled { false };
463     bool m_policyDelegatePermissive { false };
464     bool m_shouldDownloadUndisplayableMIMETypes { false };
465
466     bool m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges { false };
467     bool m_handlesAuthenticationChallenges { false };
468     String m_authenticationUsername;
469     String m_authenticationPassword;
470
471     bool m_shouldBlockAllPlugins { false };
472     String m_unsupportedPluginMode;
473
474     bool m_forceComplexText { false };
475     bool m_shouldUseAcceleratedDrawing { false };
476     bool m_shouldUseRemoteLayerTree { false };
477
478     bool m_shouldLogCanAuthenticateAgainstProtectionSpace { false };
479     bool m_shouldLogDownloadCallbacks { false };
480     bool m_shouldLogHistoryClientCallbacks { false };
481     bool m_shouldShowWebView { false };
482     
483     bool m_shouldShowTouches { false };
484     bool m_checkForWorldLeaks { false };
485
486     bool m_allowAnyHTTPSCertificateForAllowedHosts { false };
487     
488     bool m_shouldDecideNavigationPolicyAfterDelay { false };
489     bool m_shouldDecideResponsePolicyAfterDelay { false };
490
491     bool m_didReceiveServerRedirectForProvisionalNavigation { false };
492
493     bool m_capsLockOn { false };
494
495     WKRetainPtr<WKArrayRef> m_openPanelFileURLs;
496
497     std::unique_ptr<EventSenderProxy> m_eventSenderProxy;
498
499     WorkQueueManager m_workQueueManager;
500
501     struct AbandonedDocumentInfo {
502         String testURL;
503         String abandonedDocumentURL;
504
505         AbandonedDocumentInfo() = default;
506         AbandonedDocumentInfo(String inTestURL, String inAbandonedDocumentURL)
507             : testURL(inTestURL)
508             , abandonedDocumentURL(inAbandonedDocumentURL)
509         { }
510     };
511     HashMap<uint64_t, AbandonedDocumentInfo> m_abandonedDocumentInfo;
512 };
513
514 struct TestCommand {
515     std::string pathOrURL;
516     std::string absolutePath;
517     std::string expectedPixelHash;
518     WTF::Seconds timeout;
519     bool shouldDumpPixels { false };
520     bool dumpJSConsoleLogInStdErr { false };
521 };
522
523 } // namespace WTR