5f23a80e51d7a4ded2d7d4ff4d4fcf1a9c733ab2
[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 setCustomUserAgent(JSStringRef);
135     void setWebAPIStatisticsEnabled(bool);
136
137     // Special DOM functions.
138     void clearBackForwardList();
139     void execCommand(JSStringRef name, JSStringRef showUI, JSStringRef value);
140     bool isCommandEnabled(JSStringRef name);
141     unsigned windowCount();
142
143     // Repaint testing.
144     void testRepaint() { m_testRepaint = true; }
145     void repaintSweepHorizontally() { m_testRepaintSweepHorizontally = true; }
146     void display();
147     void displayAndTrackRepaints();
148
149     // UserContent testing.
150     void addUserScript(JSStringRef source, bool runAtStart, bool allFrames);
151     void addUserStyleSheet(JSStringRef source, bool allFrames);
152
153     // Text search testing.
154     bool findString(JSStringRef, JSValueRef optionsArray);
155     void findStringMatchesInPage(JSStringRef, JSValueRef optionsArray);
156     void replaceFindMatchesAtIndices(JSValueRef matchIndices, JSStringRef replacementText, bool selectionOnly);
157
158     // Local storage
159     void clearAllDatabases();
160     void setDatabaseQuota(uint64_t);
161     JSRetainPtr<JSStringRef> pathToLocalResource(JSStringRef);
162     void syncLocalStorage();
163
164     // Application Cache
165     void clearAllApplicationCaches();
166     void clearApplicationCacheForOrigin(JSStringRef origin);
167     void setAppCacheMaximumSize(uint64_t);
168     long long applicationCacheDiskUsageForOrigin(JSStringRef origin);
169     void disallowIncreaseForApplicationCacheQuota();
170     bool shouldDisallowIncreaseForApplicationCacheQuota() { return m_disallowIncreaseForApplicationCacheQuota; }
171     JSValueRef originsWithApplicationCache();
172
173     void clearDOMCache(JSStringRef origin);
174     void clearDOMCaches();
175     bool hasDOMCache(JSStringRef origin);
176     uint64_t domCacheSize(JSStringRef origin);
177     void setAllowStorageQuotaIncrease(bool);
178
179     // Failed load condition testing
180     void forceImmediateCompletion();
181
182     // Printing
183     bool isPageBoxVisible(int pageIndex);
184     bool isPrinting() { return m_isPrinting; }
185     void setPrinting() { m_isPrinting = true; }
186
187     // Authentication
188     void setRejectsProtectionSpaceAndContinueForAuthenticationChallenges(bool);
189     void setHandlesAuthenticationChallenges(bool);
190     void setShouldLogCanAuthenticateAgainstProtectionSpace(bool);
191     void setAuthenticationUsername(JSStringRef);
192     void setAuthenticationPassword(JSStringRef);
193
194     void setValueForUser(JSContextRef, JSValueRef element, JSStringRef value);
195
196     // Audio testing.
197     void setAudioResult(JSContextRef, JSValueRef data);
198
199     void setBlockAllPlugins(bool);
200     void setPluginSupportedMode(JSStringRef);
201
202     WhatToDump whatToDump() const;
203     void setWhatToDump(WhatToDump);
204
205     bool shouldDumpAllFrameScrollPositions() const { return m_shouldDumpAllFrameScrollPositions; }
206     bool shouldDumpBackForwardListsForAllWindows() const { return m_shouldDumpBackForwardListsForAllWindows; }
207     bool shouldDumpEditingCallbacks() const { return m_dumpEditingCallbacks; }
208     bool shouldDumpMainFrameScrollPosition() const { return whatToDump() == WhatToDump::RenderTree; }
209     bool shouldDumpStatusCallbacks() const { return m_dumpStatusCallbacks; }
210     bool shouldDumpTitleChanges() const { return m_dumpTitleChanges; }
211     bool shouldDumpPixels() const;
212     bool shouldDumpFullScreenCallbacks() const { return m_dumpFullScreenCallbacks; }
213     bool shouldDumpFrameLoadCallbacks();
214     bool shouldDumpProgressFinishedCallback() const { return m_dumpProgressFinishedCallback; }
215     bool shouldDumpResourceLoadCallbacks() const { return m_dumpResourceLoadCallbacks; }
216     bool shouldDumpResourceResponseMIMETypes() const { return m_dumpResourceResponseMIMETypes; }
217     bool shouldDumpWillCacheResponse() const { return m_dumpWillCacheResponse; }
218     bool shouldDumpApplicationCacheDelegateCallbacks() const { return m_dumpApplicationCacheDelegateCallbacks; }
219     bool shouldDumpDatabaseCallbacks() const { return m_dumpDatabaseCallbacks; }
220     bool shouldDumpSelectionRect() const { return m_dumpSelectionRect; }
221     bool shouldDumpPolicyCallbacks() const { return m_dumpPolicyCallbacks; }
222
223     bool isPolicyDelegateEnabled() const { return m_policyDelegateEnabled; }
224     bool isPolicyDelegatePermissive() const { return m_policyDelegatePermissive; }
225
226     bool didReceiveServerRedirectForProvisionalNavigation() const;
227     void clearDidReceiveServerRedirectForProvisionalNavigation();
228
229     bool shouldWaitUntilDone() const;
230
231     // Downloads
232     bool shouldFinishAfterDownload() const { return m_shouldFinishAfterDownload; }
233     void setShouldLogDownloadCallbacks(bool);
234
235     bool shouldAllowEditing() const { return m_shouldAllowEditing; }
236
237     bool shouldCloseExtraWindowsAfterRunningTest() const { return m_shouldCloseExtraWindows; }
238
239     void evaluateScriptInIsolatedWorld(JSContextRef, unsigned worldID, JSStringRef script);
240     static unsigned worldIDForWorld(WKBundleScriptWorldRef);
241
242     void showWebInspector();
243     void closeWebInspector();
244     void evaluateInWebInspector(JSStringRef script);
245     JSRetainPtr<JSStringRef> inspectorTestStubURL();
246
247     void setPOSIXLocale(JSStringRef);
248
249     bool willSendRequestReturnsNull() const { return m_willSendRequestReturnsNull; }
250     void setWillSendRequestReturnsNull(bool f) { m_willSendRequestReturnsNull = f; }
251     bool willSendRequestReturnsNullOnRedirect() const { return m_willSendRequestReturnsNullOnRedirect; }
252     void setWillSendRequestReturnsNullOnRedirect(bool f) { m_willSendRequestReturnsNullOnRedirect = f; }
253     void setWillSendRequestAddsHTTPBody(JSStringRef body) { m_willSendRequestHTTPBody = toWTFString(toWK(body)); }
254     String willSendRequestHTTPBody() const { return m_willSendRequestHTTPBody; }
255
256     void setTextDirection(JSStringRef);
257
258     void setShouldStayOnPageAfterHandlingBeforeUnload(bool);
259
260     void setStopProvisionalFrameLoads() { m_shouldStopProvisionalFrameLoads = true; }
261     bool shouldStopProvisionalFrameLoads() const { return m_shouldStopProvisionalFrameLoads; }
262     
263     bool globalFlag() const { return m_globalFlag; }
264     void setGlobalFlag(bool value) { m_globalFlag = value; }
265
266     double databaseDefaultQuota() const { return m_databaseDefaultQuota; }
267     void setDatabaseDefaultQuota(double quota) { m_databaseDefaultQuota = quota; }
268
269     double databaseMaxQuota() const { return m_databaseMaxQuota; }
270     void setDatabaseMaxQuota(double quota) { m_databaseMaxQuota = quota; }
271
272     void addChromeInputField(JSValueRef);
273     void removeChromeInputField(JSValueRef);
274     void focusWebView(JSValueRef);
275     void setBackingScaleFactor(double, JSValueRef);
276
277     void setWindowIsKey(bool);
278
279     void setViewSize(double width, double height);
280
281     void callAddChromeInputFieldCallback();
282     void callRemoveChromeInputFieldCallback();
283     void callFocusWebViewCallback();
284     void callSetBackingScaleFactorCallback();
285
286     void overridePreference(JSStringRef preference, JSStringRef value);
287
288     // Cookies testing
289     void setAlwaysAcceptCookies(bool);
290     void setOnlyAcceptFirstPartyCookies(bool);
291
292     // Custom full screen behavior.
293     void setHasCustomFullScreenBehavior(bool value) { m_customFullScreenBehavior = value; }
294     bool hasCustomFullScreenBehavior() const { return m_customFullScreenBehavior; }
295
296     // Web notifications.
297     static void grantWebNotificationPermission(JSStringRef origin);
298     static void denyWebNotificationPermission(JSStringRef origin);
299     static void removeAllWebNotificationPermissions();
300     static void simulateWebNotificationClick(JSValueRef notification);
301
302     // Geolocation.
303     void setGeolocationPermission(bool);
304     void setMockGeolocationPosition(double latitude, double longitude, double accuracy, JSValueRef altitude, JSValueRef altitudeAccuracy, JSValueRef heading, JSValueRef speed, JSValueRef floorLevel);
305     void setMockGeolocationPositionUnavailableError(JSStringRef message);
306     bool isGeolocationProviderActive();
307
308     // MediaStream
309     void setUserMediaPermission(bool);
310     void resetUserMediaPermission();
311     void setUserMediaPersistentPermissionForOrigin(bool permission, JSStringRef origin, JSStringRef parentOrigin);
312     unsigned userMediaPermissionRequestCountForOrigin(JSStringRef origin, JSStringRef parentOrigin) const;
313     void resetUserMediaPermissionRequestCountForOrigin(JSStringRef origin, JSStringRef parentOrigin);
314     bool isDoingMediaCapture() const;
315
316     void setPageVisibility(JSStringRef state);
317     void resetPageVisibility();
318
319     bool callShouldCloseOnWebView();
320
321     void setCustomTimeout(WTF::Seconds duration) { m_timeout = duration; }
322
323     // Work queue.
324     void queueBackNavigation(unsigned howFarBackward);
325     void queueForwardNavigation(unsigned howFarForward);
326     void queueLoad(JSStringRef url, JSStringRef target, bool shouldOpenExternalURLs);
327     void queueLoadHTMLString(JSStringRef content, JSStringRef baseURL, JSStringRef unreachableURL);
328     void queueReload();
329     void queueLoadingScript(JSStringRef script);
330     void queueNonLoadingScript(JSStringRef script);
331
332     bool secureEventInputIsEnabled() const;
333
334     JSValueRef failNextNewCodeBlock();
335     JSValueRef numberOfDFGCompiles(JSValueRef theFunction);
336     JSValueRef neverInlineFunction(JSValueRef theFunction);
337
338     bool shouldDecideNavigationPolicyAfterDelay() const { return m_shouldDecideNavigationPolicyAfterDelay; }
339     void setShouldDecideNavigationPolicyAfterDelay(bool);
340     bool shouldDecideResponsePolicyAfterDelay() const { return m_shouldDecideResponsePolicyAfterDelay; }
341     void setShouldDecideResponsePolicyAfterDelay(bool);
342     void setNavigationGesturesEnabled(bool);
343     void setIgnoresViewportScaleLimits(bool);
344     void setShouldDownloadUndisplayableMIMETypes(bool);
345     void setShouldAllowDeviceOrientationAndMotionAccess(bool);
346
347     bool didCancelClientRedirect() const { return m_didCancelClientRedirect; }
348     void setDidCancelClientRedirect(bool value) { m_didCancelClientRedirect = value; }
349
350     void runUIScript(JSStringRef script, JSValueRef callback);
351     void runUIScriptCallback(unsigned callbackID, JSStringRef result);
352
353     // Contextual menu actions
354     void setAllowedMenuActions(JSValueRef);
355     void installCustomMenuAction(JSStringRef name, bool dismissesAutomatically, JSValueRef callback);
356     void performCustomMenuAction();
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 numberOfPrevalentResources, unsigned numberOfPrevalentResourcesWithUserInteraction, unsigned numberOfPrevalentResourcesWithoutUserInteraction, unsigned topPrevalentResourceWithUserInteractionDaysSinceUserInteraction, unsigned medianDaysSinceUserInteractionPrevalentResourceWithUserInteraction, unsigned top3NumberOfPrevalentResourcesWithUI, unsigned top3MedianSubFrameWithoutUI, unsigned top3MedianSubResourceWithoutUI, unsigned top3MedianUniqueRedirectsWithoutUI, unsigned top3MedianDataRecordsRemovedWithoutUI);
387     bool 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 setStatisticsMergeStatistic(JSStringRef hostName, JSStringRef topFrameDomain1, JSStringRef topFrameDomain2, double lastSeen, bool hadUserInteraction, double mostRecentUserInteraction, bool isGrandfathered, bool isPrevalent, bool isVeryPrevalent, unsigned dataRecordsRemoved, JSValueRef completionHandler);
399     void statisticsCallDidSetMergeStatisticCallback();
400     void setStatisticsPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler);
401     void statisticsCallDidSetPrevalentResourceCallback();
402     void setStatisticsVeryPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler);
403     void statisticsCallDidSetVeryPrevalentResourceCallback();
404     bool isStatisticsPrevalentResource(JSStringRef hostName);
405     bool isStatisticsVeryPrevalentResource(JSStringRef hostName);
406     bool isStatisticsRegisteredAsSubresourceUnder(JSStringRef subresourceHost, JSStringRef topFrameHost);
407     bool isStatisticsRegisteredAsSubFrameUnder(JSStringRef subFrameHost, JSStringRef topFrameHost);
408     bool isStatisticsRegisteredAsRedirectingTo(JSStringRef hostRedirectedFrom, JSStringRef hostRedirectedTo);
409     void setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value, JSValueRef completionHandler);
410     void statisticsCallDidSetHasHadUserInteractionCallback();
411     bool isStatisticsHasHadUserInteraction(JSStringRef hostName);
412     bool isStatisticsOnlyInDatabaseOnce(JSStringRef subHost, JSStringRef topHost);
413     void setStatisticsGrandfathered(JSStringRef hostName, bool value);
414     bool isStatisticsGrandfathered(JSStringRef hostName);
415     void setUseITPDatabase(bool value);
416     void setStatisticsSubframeUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
417     void setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
418     void setStatisticsSubresourceUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo);
419     void setStatisticsSubresourceUniqueRedirectFrom(JSStringRef hostName, JSStringRef hostNameRedirectedFrom);
420     void setStatisticsTopFrameUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo);
421     void setStatisticsTopFrameUniqueRedirectFrom(JSStringRef hostName, JSStringRef hostNameRedirectedFrom);
422     void setStatisticsCrossSiteLoadWithLinkDecoration(JSStringRef fromHost, JSStringRef toHost);
423     void setStatisticsTimeToLiveUserInteraction(double seconds);
424     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
425     void setStatisticsIsRunningTest(bool);
426     void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
427     void setStatisticsNotifyPagesWhenTelemetryWasCaptured(bool value);
428     void setStatisticsMinimumTimeBetweenDataRecordsRemoval(double);
429     void setStatisticsGrandfatheringTime(double seconds);
430     void setStatisticsMaxStatisticsEntries(unsigned);
431     void setStatisticsPruneEntriesDownTo(unsigned);
432     void statisticsClearInMemoryAndPersistentStore(JSValueRef callback);
433     void statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned hours, JSValueRef callback);
434     void statisticsClearThroughWebsiteDataRemoval(JSValueRef callback);
435     void statisticsDeleteCookiesForHost(JSStringRef hostName, bool includeHttpOnlyCookies);
436     void statisticsCallClearThroughWebsiteDataRemovalCallback();
437     bool isStatisticsHasLocalStorage(JSStringRef hostName);
438     void setStatisticsCacheMaxAgeCap(double seconds);
439     bool hasStatisticsIsolatedSession(JSStringRef hostName);
440     void setStatisticsShouldDowngradeReferrer(bool, JSValueRef callback);
441     void statisticsCallDidSetShouldDowngradeReferrerCallback();
442     void statisticsResetToConsistentState(JSValueRef completionHandler);
443     void statisticsCallDidResetToConsistentStateCallback();
444
445     // Injected bundle form client.
446     void installTextDidChangeInTextFieldCallback(JSValueRef callback);
447     void textDidChangeInTextFieldCallback();
448     void installTextFieldDidBeginEditingCallback(JSValueRef callback);
449     void textFieldDidBeginEditingCallback();
450     void installTextFieldDidEndEditingCallback(JSValueRef callback);
451     void textFieldDidEndEditingCallback();
452
453     // Storage Access API
454     void setStorageAccessAPIEnabled(bool);
455     void getAllStorageAccessEntries(JSValueRef callback);
456     void callDidReceiveAllStorageAccessEntriesCallback(Vector<String>& domains);
457
458     // Open panel
459     void setOpenPanelFiles(JSValueRef);
460     void setOpenPanelFilesMediaIcon(JSValueRef);
461
462     // Modal alerts
463     void setShouldDismissJavaScriptAlertsAsynchronously(bool);
464     void abortModal();
465
466     void terminateNetworkProcess();
467     void terminateServiceWorkerProcess();
468
469     void removeAllSessionCredentials(JSValueRef);
470     void callDidRemoveAllSessionCredentialsCallback();
471     
472     void getApplicationManifestThen(JSValueRef);
473     void didGetApplicationManifest();
474
475     void installFakeHelvetica(JSStringRef configuration);
476
477     void dumpAllHTTPRedirectedResponseHeaders() { m_dumpAllHTTPRedirectedResponseHeaders = true; }
478     bool shouldDumpAllHTTPRedirectedResponseHeaders() const { return m_dumpAllHTTPRedirectedResponseHeaders; }
479
480     void addMockCameraDevice(JSStringRef persistentId, JSStringRef label);
481     void addMockMicrophoneDevice(JSStringRef persistentId, JSStringRef label);
482     void addMockScreenDevice(JSStringRef persistentId, JSStringRef label);
483     void clearMockMediaDevices();
484     void removeMockMediaDevice(JSStringRef persistentId);
485     void resetMockMediaDevices();
486
487     size_t userScriptInjectedCount() const;
488     void injectUserScript(JSStringRef);
489
490     void sendDisplayConfigurationChangedMessageForTesting();
491
492     void setServiceWorkerFetchTimeout(double seconds);
493     
494     // WebAuthN
495     void setWebAuthenticationMockConfiguration(JSValueRef);
496     // FIXME(189876)
497     void addTestKeyToKeychain(JSStringRef privateKeyBase64, JSStringRef attrLabel, JSStringRef applicationTagBase64);
498     void cleanUpKeychain(JSStringRef attrLabel, JSStringRef applicationTagBase64);
499     bool keyExistsInKeychain(JSStringRef attrLabel, JSStringRef applicationTagBase64);
500
501     unsigned long serverTrustEvaluationCallbackCallsCount();
502
503     // Ad Click Attribution.
504     void dumpAdClickAttribution();
505     void clearAdClickAttribution();
506     void clearAdClickAttributionsThroughWebsiteDataRemoval();
507     void setAdClickAttributionOverrideTimerForTesting(bool value);
508     void setAdClickAttributionConversionURLForTesting(JSStringRef);
509     void markAdClickAttributionsAsExpiredForTesting();
510
511 private:
512     TestRunner();
513
514     void platformInitialize();
515
516     void setDumpPixels(bool);
517     void setWaitUntilDone(bool);
518
519     void addMockMediaDevice(JSStringRef persistentId, JSStringRef label, const char* type);
520
521     WKRetainPtr<WKURLRef> m_testURL; // Set by InjectedBundlePage once provisional load starts.
522
523     String m_willSendRequestHTTPBody;
524     WTF::Seconds m_timeout { 30_s };
525
526     WKRetainPtr<WKStringRef> m_userStyleSheetLocation;
527     WKRetainPtr<WKArrayRef> m_allowedHosts;
528
529     double m_databaseDefaultQuota { -1 };
530     double m_databaseMaxQuota { -1 };
531
532     size_t m_userMediaPermissionRequestCount { 0 };
533
534     unsigned m_renderTreeDumpOptions { 0 };
535     bool m_shouldDumpAllFrameScrollPositions { false };
536     bool m_shouldDumpBackForwardListsForAllWindows { false };
537     bool m_shouldAllowEditing { true };
538     bool m_shouldCloseExtraWindows { false };
539
540     bool m_dumpEditingCallbacks { false };
541     bool m_dumpStatusCallbacks { false };
542     bool m_dumpTitleChanges { false };
543     bool m_dumpPixels { false };
544     bool m_dumpSelectionRect { false };
545     bool m_dumpFullScreenCallbacks { false };
546     bool m_dumpProgressFinishedCallback { false };
547     bool m_dumpResourceLoadCallbacks { false };
548     bool m_dumpResourceResponseMIMETypes { false };
549     bool m_dumpWillCacheResponse { false };
550     bool m_dumpApplicationCacheDelegateCallbacks { false };
551     bool m_dumpDatabaseCallbacks { false };
552     bool m_dumpPolicyCallbacks { false };
553
554     bool m_disallowIncreaseForApplicationCacheQuota { false };
555     bool m_testRepaint { false };
556     bool m_testRepaintSweepHorizontally { false };
557     bool m_isPrinting { false };
558     bool m_willSendRequestReturnsNull { false };
559     bool m_willSendRequestReturnsNullOnRedirect { false };
560     bool m_shouldStopProvisionalFrameLoads { false };
561
562     bool m_policyDelegateEnabled { false };
563     bool m_policyDelegatePermissive { false };
564
565     bool m_globalFlag { false };
566     bool m_customFullScreenBehavior { false };
567
568     bool m_shouldDecideNavigationPolicyAfterDelay { false };
569     bool m_shouldDecideResponsePolicyAfterDelay { false };
570     bool m_shouldFinishAfterDownload { false };
571     bool m_didCancelClientRedirect { false };
572
573     bool m_userStyleSheetEnabled { false };
574     bool m_dumpAllHTTPRedirectedResponseHeaders { false };
575     bool m_hasSetDowngradeReferrerCallback { false };
576 };
577
578 } // namespace WTR