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