6d11648bbc946fa86656407ff31227471bb33248
[WebKit-https.git] / Tools / WebKitTestRunner / InjectedBundle / TestRunner.h
1 /*
2  * Copyright (C) 2010-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 "JSWrappable.h"
29 #include "StringFunctions.h"
30 #include "WhatToDump.h"
31 #include <JavaScriptCore/JSRetainPtr.h>
32 #include <WebKit/WKBundleScriptWorld.h>
33 #include <WebKit/WKRetainPtr.h>
34 #include <string>
35 #include <wtf/Ref.h>
36 #include <wtf/Seconds.h>
37 #include <wtf/text/WTFString.h>
38
39 #if PLATFORM(COCOA)
40 #include <wtf/RetainPtr.h>
41 #include <CoreFoundation/CFRunLoop.h>
42 typedef RetainPtr<CFRunLoopTimerRef> PlatformTimerRef;
43 #else
44 #include <wtf/RunLoop.h>
45 namespace WTR {
46 class TestRunner;
47 typedef RunLoop::Timer<TestRunner> PlatformTimerRef;
48 }
49 #endif
50
51 namespace WTR {
52
53 class TestRunner : public JSWrappable {
54 public:
55     static Ref<TestRunner> create();
56     virtual ~TestRunner();
57
58     // JSWrappable
59     virtual JSClassRef wrapperClass();
60
61     void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception);
62
63     bool isWebKit2() const { return true; }
64
65     // The basics.
66     WKURLRef testURL() const { return m_testURL.get(); }
67     void setTestURL(WKURLRef url) { m_testURL = url; }
68     void dumpAsText(bool dumpPixels);
69     void waitForPolicyDelegate();
70     void dumpChildFramesAsText() { setWhatToDump(WhatToDump::AllFramesText); }
71     void waitUntilDownloadFinished();
72     void waitUntilDone();
73     void notifyDone();
74     double preciseTime();
75     double timeout() { return m_timeout.milliseconds(); }
76
77     // Other dumping.
78     void dumpBackForwardList() { m_shouldDumpBackForwardListsForAllWindows = true; }
79     void dumpChildFrameScrollPositions() { m_shouldDumpAllFrameScrollPositions = true; }
80     void dumpEditingCallbacks() { m_dumpEditingCallbacks = true; }
81     void dumpSelectionRect() { m_dumpSelectionRect = true; }
82     void dumpStatusCallbacks() { m_dumpStatusCallbacks = true; }
83     void dumpTitleChanges() { m_dumpTitleChanges = true; }
84     void dumpFullScreenCallbacks() { m_dumpFullScreenCallbacks = true; }
85     void dumpFrameLoadCallbacks() { setShouldDumpFrameLoadCallbacks(true); }
86     void dumpProgressFinishedCallback() { setShouldDumpProgressFinishedCallback(true); }
87     void dumpResourceLoadCallbacks() { m_dumpResourceLoadCallbacks = true; }
88     void dumpResourceResponseMIMETypes() { m_dumpResourceResponseMIMETypes = true; }
89     void dumpWillCacheResponse() { m_dumpWillCacheResponse = true; }
90     void dumpApplicationCacheDelegateCallbacks() { m_dumpApplicationCacheDelegateCallbacks = true; }
91     void dumpDatabaseCallbacks() { m_dumpDatabaseCallbacks = true; }
92     void dumpDOMAsWebArchive() { setWhatToDump(WhatToDump::DOMAsWebArchive); }
93     void dumpPolicyDelegateCallbacks() { m_dumpPolicyCallbacks = true; }
94     void dumpResourceLoadStatistics();
95
96     void setShouldDumpFrameLoadCallbacks(bool value);
97     void setShouldDumpProgressFinishedCallback(bool value) { m_dumpProgressFinishedCallback = value; }
98
99     // Special options.
100     void keepWebHistory();
101     void setAcceptsEditing(bool value) { m_shouldAllowEditing = value; }
102     void setCanOpenWindows();
103     void setCloseRemainingWindowsWhenComplete(bool value) { m_shouldCloseExtraWindows = value; }
104     void setXSSAuditorEnabled(bool);
105     void setModernMediaControlsEnabled(bool);
106     void setWebGL2Enabled(bool);
107     void setWebMetalEnabled(bool);
108     void setWritableStreamAPIEnabled(bool);
109     void setReadableByteStreamAPIEnabled(bool);
110
111     void setAllowUniversalAccessFromFileURLs(bool);
112     void setAllowFileAccessFromFileURLs(bool);
113     void setNeedsStorageAccessFromFileURLsQuirk(bool);
114     void setPluginsEnabled(bool);
115     void setJavaScriptCanAccessClipboard(bool);
116     void setPrivateBrowsingEnabled(bool);
117     void setUseDashboardCompatibilityMode(bool);
118     void setPopupBlockingEnabled(bool);
119     void setAuthorAndUserStylesEnabled(bool);
120     void setCustomPolicyDelegate(bool enabled, bool permissive = false);
121     void addOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains);
122     void removeOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains);
123     void setUserStyleSheetEnabled(bool);
124     void setUserStyleSheetLocation(JSStringRef);
125     void setSpatialNavigationEnabled(bool);
126     void setTabKeyCyclesThroughElements(bool);
127     void setSerializeHTTPLoads();
128     void dispatchPendingLoadRequests();
129     void setCacheModel(int);
130     void setAsynchronousSpellCheckingEnabled(bool);
131     void setAllowsAnySSLCertificate(bool);
132     void setEncryptedMediaAPIEnabled(bool);
133     void setMediaDevicesEnabled(bool);
134     void setWebRTCMDNSICECandidatesEnabled(bool);
135     void setWebRTCUnifiedPlanEnabled(bool);
136     void setCustomUserAgent(JSStringRef);
137     void setWebAPIStatisticsEnabled(bool);
138
139     // Special DOM functions.
140     void clearBackForwardList();
141     void execCommand(JSStringRef name, JSStringRef showUI, JSStringRef value);
142     bool isCommandEnabled(JSStringRef name);
143     unsigned windowCount();
144
145     // Repaint testing.
146     void testRepaint() { m_testRepaint = true; }
147     void repaintSweepHorizontally() { m_testRepaintSweepHorizontally = true; }
148     void display();
149     void displayAndTrackRepaints();
150
151     // UserContent testing.
152     void addUserScript(JSStringRef source, bool runAtStart, bool allFrames);
153     void addUserStyleSheet(JSStringRef source, bool allFrames);
154
155     // Text search testing.
156     bool findString(JSStringRef, JSValueRef optionsArray);
157     void findStringMatchesInPage(JSStringRef, JSValueRef optionsArray);
158     void replaceFindMatchesAtIndices(JSValueRef matchIndices, JSStringRef replacementText, bool selectionOnly);
159
160     // Local storage
161     void clearAllDatabases();
162     void setDatabaseQuota(uint64_t);
163     JSRetainPtr<JSStringRef> pathToLocalResource(JSStringRef);
164
165     // Application Cache
166     void clearAllApplicationCaches();
167     void clearApplicationCacheForOrigin(JSStringRef origin);
168     void setAppCacheMaximumSize(uint64_t);
169     long long applicationCacheDiskUsageForOrigin(JSStringRef origin);
170     void disallowIncreaseForApplicationCacheQuota();
171     bool shouldDisallowIncreaseForApplicationCacheQuota() { return m_disallowIncreaseForApplicationCacheQuota; }
172     JSValueRef originsWithApplicationCache();
173
174     void clearDOMCache(JSStringRef origin);
175     void clearDOMCaches();
176     bool hasDOMCache(JSStringRef origin);
177     uint64_t domCacheSize(JSStringRef origin);
178     void allowCacheStorageQuotaIncrease();
179
180     // IndexedDB
181     void setIDBPerOriginQuota(uint64_t);
182
183     // Failed load condition testing
184     void forceImmediateCompletion();
185
186     // Printing
187     bool isPageBoxVisible(int pageIndex);
188     bool isPrinting() { return m_isPrinting; }
189     void setPrinting() { m_isPrinting = true; }
190
191     // Authentication
192     void setRejectsProtectionSpaceAndContinueForAuthenticationChallenges(bool);
193     void setHandlesAuthenticationChallenges(bool);
194     void setShouldLogCanAuthenticateAgainstProtectionSpace(bool);
195     void setAuthenticationUsername(JSStringRef);
196     void setAuthenticationPassword(JSStringRef);
197
198     void setValueForUser(JSContextRef, JSValueRef element, JSStringRef value);
199
200     // Audio testing.
201     void setAudioResult(JSContextRef, JSValueRef data);
202
203     void setBlockAllPlugins(bool);
204     void setPluginSupportedMode(JSStringRef);
205
206     WhatToDump whatToDump() const;
207     void setWhatToDump(WhatToDump);
208
209     bool shouldDumpAllFrameScrollPositions() const { return m_shouldDumpAllFrameScrollPositions; }
210     bool shouldDumpBackForwardListsForAllWindows() const { return m_shouldDumpBackForwardListsForAllWindows; }
211     bool shouldDumpEditingCallbacks() const { return m_dumpEditingCallbacks; }
212     bool shouldDumpMainFrameScrollPosition() const { return whatToDump() == WhatToDump::RenderTree; }
213     bool shouldDumpStatusCallbacks() const { return m_dumpStatusCallbacks; }
214     bool shouldDumpTitleChanges() const { return m_dumpTitleChanges; }
215     bool shouldDumpPixels() const;
216     bool shouldDumpFullScreenCallbacks() const { return m_dumpFullScreenCallbacks; }
217     bool shouldDumpFrameLoadCallbacks();
218     bool shouldDumpProgressFinishedCallback() const { return m_dumpProgressFinishedCallback; }
219     bool shouldDumpResourceLoadCallbacks() const { return m_dumpResourceLoadCallbacks; }
220     bool shouldDumpResourceResponseMIMETypes() const { return m_dumpResourceResponseMIMETypes; }
221     bool shouldDumpWillCacheResponse() const { return m_dumpWillCacheResponse; }
222     bool shouldDumpApplicationCacheDelegateCallbacks() const { return m_dumpApplicationCacheDelegateCallbacks; }
223     bool shouldDumpDatabaseCallbacks() const { return m_dumpDatabaseCallbacks; }
224     bool shouldDumpSelectionRect() const { return m_dumpSelectionRect; }
225     bool shouldDumpPolicyCallbacks() const { return m_dumpPolicyCallbacks; }
226
227     bool isPolicyDelegateEnabled() const { return m_policyDelegateEnabled; }
228     bool isPolicyDelegatePermissive() const { return m_policyDelegatePermissive; }
229
230     bool didReceiveServerRedirectForProvisionalNavigation() const;
231     void clearDidReceiveServerRedirectForProvisionalNavigation();
232
233     bool shouldWaitUntilDone() const;
234     void waitToDumpWatchdogTimerFired();
235     void invalidateWaitToDumpWatchdogTimer();
236
237     // Downloads
238     bool shouldFinishAfterDownload() const { return m_shouldFinishAfterDownload; }
239     void setShouldLogDownloadCallbacks(bool);
240
241     bool shouldAllowEditing() const { return m_shouldAllowEditing; }
242
243     bool shouldCloseExtraWindowsAfterRunningTest() const { return m_shouldCloseExtraWindows; }
244
245     void evaluateScriptInIsolatedWorld(JSContextRef, unsigned worldID, JSStringRef script);
246     static unsigned worldIDForWorld(WKBundleScriptWorldRef);
247
248     void showWebInspector();
249     void closeWebInspector();
250     void evaluateInWebInspector(JSStringRef script);
251     JSRetainPtr<JSStringRef> inspectorTestStubURL();
252
253     void setPOSIXLocale(JSStringRef);
254
255     bool willSendRequestReturnsNull() const { return m_willSendRequestReturnsNull; }
256     void setWillSendRequestReturnsNull(bool f) { m_willSendRequestReturnsNull = f; }
257     bool willSendRequestReturnsNullOnRedirect() const { return m_willSendRequestReturnsNullOnRedirect; }
258     void setWillSendRequestReturnsNullOnRedirect(bool f) { m_willSendRequestReturnsNullOnRedirect = f; }
259     void setWillSendRequestAddsHTTPBody(JSStringRef body) { m_willSendRequestHTTPBody = toWTFString(toWK(body)); }
260     String willSendRequestHTTPBody() const { return m_willSendRequestHTTPBody; }
261
262     void setTextDirection(JSStringRef);
263
264     void setShouldStayOnPageAfterHandlingBeforeUnload(bool);
265
266     void setStopProvisionalFrameLoads() { m_shouldStopProvisionalFrameLoads = true; }
267     bool shouldStopProvisionalFrameLoads() const { return m_shouldStopProvisionalFrameLoads; }
268     
269     bool globalFlag() const { return m_globalFlag; }
270     void setGlobalFlag(bool value) { m_globalFlag = value; }
271
272     double databaseDefaultQuota() const { return m_databaseDefaultQuota; }
273     void setDatabaseDefaultQuota(double quota) { m_databaseDefaultQuota = quota; }
274
275     double databaseMaxQuota() const { return m_databaseMaxQuota; }
276     void setDatabaseMaxQuota(double quota) { m_databaseMaxQuota = quota; }
277
278     void addChromeInputField(JSValueRef);
279     void removeChromeInputField(JSValueRef);
280     void focusWebView(JSValueRef);
281     void setBackingScaleFactor(double, JSValueRef);
282
283     void setWindowIsKey(bool);
284
285     void setViewSize(double width, double height);
286
287     void callAddChromeInputFieldCallback();
288     void callRemoveChromeInputFieldCallback();
289     void callFocusWebViewCallback();
290     void callSetBackingScaleFactorCallback();
291
292     void overridePreference(JSStringRef preference, JSStringRef value);
293
294     // Cookies testing
295     void setAlwaysAcceptCookies(bool);
296     void setOnlyAcceptFirstPartyCookies(bool);
297
298     // Custom full screen behavior.
299     void setHasCustomFullScreenBehavior(bool value) { m_customFullScreenBehavior = value; }
300     bool hasCustomFullScreenBehavior() const { return m_customFullScreenBehavior; }
301
302     // Web notifications.
303     static void grantWebNotificationPermission(JSStringRef origin);
304     static void denyWebNotificationPermission(JSStringRef origin);
305     static void removeAllWebNotificationPermissions();
306     static void simulateWebNotificationClick(JSValueRef notification);
307
308     // Geolocation.
309     void setGeolocationPermission(bool);
310     void setMockGeolocationPosition(double latitude, double longitude, double accuracy, JSValueRef altitude, JSValueRef altitudeAccuracy, JSValueRef heading, JSValueRef speed, JSValueRef floorLevel);
311     void setMockGeolocationPositionUnavailableError(JSStringRef message);
312     bool isGeolocationProviderActive();
313
314     // MediaStream
315     void setUserMediaPermission(bool);
316     void resetUserMediaPermission();
317     void setUserMediaPersistentPermissionForOrigin(bool permission, JSStringRef origin, JSStringRef parentOrigin);
318     unsigned userMediaPermissionRequestCountForOrigin(JSStringRef origin, JSStringRef parentOrigin) const;
319     void resetUserMediaPermissionRequestCountForOrigin(JSStringRef origin, JSStringRef parentOrigin);
320     bool isDoingMediaCapture() const;
321
322     void setPageVisibility(JSStringRef state);
323     void resetPageVisibility();
324
325     bool callShouldCloseOnWebView();
326
327     void setCustomTimeout(WTF::Seconds duration) { m_timeout = duration; }
328
329     // Work queue.
330     void queueBackNavigation(unsigned howFarBackward);
331     void queueForwardNavigation(unsigned howFarForward);
332     void queueLoad(JSStringRef url, JSStringRef target, bool shouldOpenExternalURLs);
333     void queueLoadHTMLString(JSStringRef content, JSStringRef baseURL, JSStringRef unreachableURL);
334     void queueReload();
335     void queueLoadingScript(JSStringRef script);
336     void queueNonLoadingScript(JSStringRef script);
337
338     bool secureEventInputIsEnabled() const;
339
340     JSValueRef failNextNewCodeBlock();
341     JSValueRef numberOfDFGCompiles(JSValueRef theFunction);
342     JSValueRef neverInlineFunction(JSValueRef theFunction);
343
344     bool shouldDecideNavigationPolicyAfterDelay() const { return m_shouldDecideNavigationPolicyAfterDelay; }
345     void setShouldDecideNavigationPolicyAfterDelay(bool);
346     bool shouldDecideResponsePolicyAfterDelay() const { return m_shouldDecideResponsePolicyAfterDelay; }
347     void setShouldDecideResponsePolicyAfterDelay(bool);
348     void setNavigationGesturesEnabled(bool);
349     void setIgnoresViewportScaleLimits(bool);
350     void setShouldDownloadUndisplayableMIMETypes(bool);
351
352     bool didCancelClientRedirect() const { return m_didCancelClientRedirect; }
353     void setDidCancelClientRedirect(bool value) { m_didCancelClientRedirect = value; }
354
355     void runUIScript(JSStringRef script, JSValueRef callback);
356     void runUIScriptCallback(unsigned callbackID, JSStringRef result);
357
358     void installDidBeginSwipeCallback(JSValueRef);
359     void installWillEndSwipeCallback(JSValueRef);
360     void installDidEndSwipeCallback(JSValueRef);
361     void installDidRemoveSwipeSnapshotCallback(JSValueRef);
362     void callDidBeginSwipeCallback();
363     void callWillEndSwipeCallback();
364     void callDidEndSwipeCallback();
365     void callDidRemoveSwipeSnapshotCallback();
366
367     void clearTestRunnerCallbacks();
368
369     void accummulateLogsForChannel(JSStringRef channel);
370
371     unsigned imageCountInGeneralPasteboard() const;
372
373     // Gamepads
374     void connectMockGamepad(unsigned index);
375     void disconnectMockGamepad(unsigned index);
376     void setMockGamepadDetails(unsigned index, JSStringRef gamepadID, unsigned axisCount, unsigned buttonCount);
377     void setMockGamepadAxisValue(unsigned index, unsigned axisIndex, double value);
378     void setMockGamepadButtonValue(unsigned index, unsigned buttonIndex, double value);
379     
380     // Resource Load Statistics
381     void installStatisticsDidModifyDataRecordsCallback(JSValueRef callback);
382     void installStatisticsDidScanDataRecordsCallback(JSValueRef callback);
383     void installStatisticsDidRunTelemetryCallback(JSValueRef callback);
384     void statisticsDidModifyDataRecordsCallback();
385     void statisticsDidScanDataRecordsCallback();
386     void statisticsDidRunTelemetryCallback(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins);
387     void statisticsNotifyObserver();
388     void statisticsProcessStatisticsAndDataRecords();
389     void statisticsUpdateCookieBlocking(JSValueRef completionHandler);
390     void statisticsCallDidSetBlockCookiesForHostCallback();
391     void statisticsSubmitTelemetry();
392     void setStatisticsDebugMode(bool value, JSValueRef completionHandler);
393     void statisticsCallDidSetDebugModeCallback();
394     void setStatisticsPrevalentResourceForDebugMode(JSStringRef hostName, JSValueRef completionHandler);
395     void statisticsCallDidSetPrevalentResourceForDebugModeCallback();
396     void setStatisticsLastSeen(JSStringRef hostName, double seconds, JSValueRef completionHandler);
397     void statisticsCallDidSetLastSeenCallback();
398     void setStatisticsPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler);
399     void statisticsCallDidSetPrevalentResourceCallback();
400     void setStatisticsVeryPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler);
401     void statisticsCallDidSetVeryPrevalentResourceCallback();
402     bool isStatisticsPrevalentResource(JSStringRef hostName);
403     bool isStatisticsVeryPrevalentResource(JSStringRef hostName);
404     bool isStatisticsRegisteredAsSubresourceUnder(JSStringRef subresourceHost, JSStringRef topFrameHost);
405     bool isStatisticsRegisteredAsSubFrameUnder(JSStringRef subFrameHost, JSStringRef topFrameHost);
406     bool isStatisticsRegisteredAsRedirectingTo(JSStringRef hostRedirectedFrom, JSStringRef hostRedirectedTo);
407     void setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value, JSValueRef completionHandler);
408     void statisticsCallDidSetHasHadUserInteractionCallback();
409     bool isStatisticsHasHadUserInteraction(JSStringRef hostName);
410     void setStatisticsGrandfathered(JSStringRef hostName, bool value);
411     bool isStatisticsGrandfathered(JSStringRef hostName);
412     void setStatisticsSubframeUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
413     void setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
414     void setStatisticsSubresourceUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo);
415     void setStatisticsSubresourceUniqueRedirectFrom(JSStringRef hostName, JSStringRef hostNameRedirectedFrom);
416     void setStatisticsTopFrameUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo);
417     void setStatisticsTopFrameUniqueRedirectFrom(JSStringRef hostName, JSStringRef hostNameRedirectedFrom);
418     void setStatisticsTimeToLiveUserInteraction(double seconds);
419     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
420     void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
421     void setStatisticsNotifyPagesWhenTelemetryWasCaptured(bool value);
422     void setStatisticsMinimumTimeBetweenDataRecordsRemoval(double);
423     void setStatisticsGrandfatheringTime(double seconds);
424     void setStatisticsMaxStatisticsEntries(unsigned);
425     void setStatisticsPruneEntriesDownTo(unsigned);
426     void statisticsClearInMemoryAndPersistentStore(JSValueRef callback);
427     void statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned hours, JSValueRef callback);
428     void statisticsClearThroughWebsiteDataRemoval(JSValueRef callback);
429     void statisticsDeleteCookiesForHost(JSStringRef hostName, bool includeHttpOnlyCookies);
430     void statisticsCallClearThroughWebsiteDataRemovalCallback();
431     void setStatisticsCacheMaxAgeCap(double seconds);
432     void statisticsResetToConsistentState(JSValueRef completionHandler);
433     void statisticsCallDidResetToConsistentStateCallback();
434
435     // Injected bundle form client.
436     void installTextDidChangeInTextFieldCallback(JSValueRef callback);
437     void textDidChangeInTextFieldCallback();
438     void installTextFieldDidBeginEditingCallback(JSValueRef callback);
439     void textFieldDidBeginEditingCallback();
440     void installTextFieldDidEndEditingCallback(JSValueRef callback);
441     void textFieldDidEndEditingCallback();
442
443     // Storage Access API
444     void setStorageAccessAPIEnabled(bool);
445     void getAllStorageAccessEntries(JSValueRef callback);
446     void callDidReceiveAllStorageAccessEntriesCallback(Vector<String>& domains);
447
448     // Open panel
449     void setOpenPanelFiles(JSValueRef);
450
451     // Modal alerts
452     void setShouldDismissJavaScriptAlertsAsynchronously(bool);
453
454     void terminateNetworkProcess();
455     void terminateServiceWorkerProcess();
456
457     void removeAllSessionCredentials(JSValueRef);
458     void callDidRemoveAllSessionCredentialsCallback();
459     
460     void getApplicationManifestThen(JSValueRef);
461     void didGetApplicationManifest();
462
463     void installFakeHelvetica(JSStringRef configuration);
464
465     void dumpAllHTTPRedirectedResponseHeaders() { m_dumpAllHTTPRedirectedResponseHeaders = true; }
466     bool shouldDumpAllHTTPRedirectedResponseHeaders() const { return m_dumpAllHTTPRedirectedResponseHeaders; }
467
468     void addMockCameraDevice(JSStringRef persistentId, JSStringRef label);
469     void addMockMicrophoneDevice(JSStringRef persistentId, JSStringRef label);
470     void addMockScreenDevice(JSStringRef persistentId, JSStringRef label);
471     void clearMockMediaDevices();
472     void removeMockMediaDevice(JSStringRef persistentId);
473     void resetMockMediaDevices();
474
475     size_t userScriptInjectedCount() const;
476     void injectUserScript(JSStringRef);
477
478     void sendDisplayConfigurationChangedMessageForTesting();
479
480     // WebAuthN
481     void setWebAuthenticationMockConfiguration(JSValueRef);
482     // FIXME(189876)
483     void addTestKeyToKeychain(JSStringRef privateKeyBase64, JSStringRef attrLabel, JSStringRef applicationTagBase64);
484     void cleanUpKeychain(JSStringRef attrLabel);
485     bool keyExistsInKeychain(JSStringRef attrLabel, JSStringRef applicationTagBase64);
486
487     void setCanHandleHTTPSServerTrustEvaluation(bool canHandle);
488     bool canDoServerTrustEvaluationInNetworkProcess();
489     unsigned long serverTrustEvaluationCallbackCallsCount();
490
491     // Ad Click Attribution.
492     void dumpAdClickAttribution();
493     void clearAdClickAttribution();
494
495 private:
496     TestRunner();
497
498     void platformInitialize();
499     void initializeWaitToDumpWatchdogTimerIfNeeded();
500
501     void setDumpPixels(bool);
502     void setWaitUntilDone(bool);
503
504     void addMockMediaDevice(JSStringRef persistentId, JSStringRef label, const char* type);
505
506     WKRetainPtr<WKURLRef> m_testURL; // Set by InjectedBundlePage once provisional load starts.
507
508     bool m_shouldDumpAllFrameScrollPositions;
509     bool m_shouldDumpBackForwardListsForAllWindows;
510
511     bool m_shouldAllowEditing;
512     bool m_shouldCloseExtraWindows;
513
514     bool m_dumpEditingCallbacks;
515     bool m_dumpStatusCallbacks;
516     bool m_dumpTitleChanges;
517     bool m_dumpPixels;
518     bool m_dumpSelectionRect;
519     bool m_dumpFullScreenCallbacks;
520     bool m_dumpProgressFinishedCallback;
521     bool m_dumpResourceLoadCallbacks;
522     bool m_dumpResourceResponseMIMETypes;
523     bool m_dumpWillCacheResponse;
524     bool m_dumpApplicationCacheDelegateCallbacks;
525     bool m_dumpDatabaseCallbacks;
526     bool m_dumpPolicyCallbacks { false };
527     bool m_disallowIncreaseForApplicationCacheQuota;
528     bool m_testRepaint;
529     bool m_testRepaintSweepHorizontally;
530     bool m_isPrinting;
531
532     bool m_willSendRequestReturnsNull;
533     bool m_willSendRequestReturnsNullOnRedirect;
534     bool m_shouldStopProvisionalFrameLoads;
535     String m_willSendRequestHTTPBody;
536
537     bool m_policyDelegateEnabled;
538     bool m_policyDelegatePermissive;
539     
540     bool m_globalFlag;
541     bool m_customFullScreenBehavior;
542
543     WTF::Seconds m_timeout;
544
545     double m_databaseDefaultQuota;
546     double m_databaseMaxQuota;
547
548     bool m_shouldDecideNavigationPolicyAfterDelay { false };
549     bool m_shouldDecideResponsePolicyAfterDelay { false };
550     bool m_shouldFinishAfterDownload { false };
551     bool m_didCancelClientRedirect { false };
552
553     bool m_userStyleSheetEnabled;
554     WKRetainPtr<WKStringRef> m_userStyleSheetLocation;
555
556     WKRetainPtr<WKArrayRef> m_allowedHosts;
557
558     size_t m_userMediaPermissionRequestCount { 0 };
559
560     PlatformTimerRef m_waitToDumpWatchdogTimer;
561
562     bool m_dumpAllHTTPRedirectedResponseHeaders { false };
563 };
564
565 } // namespace WTR