Add support for Device Orientation / Motion permission API
[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     void setShouldAllowDeviceOrientationAndMotionAccess(bool);
352
353     bool didCancelClientRedirect() const { return m_didCancelClientRedirect; }
354     void setDidCancelClientRedirect(bool value) { m_didCancelClientRedirect = value; }
355
356     void runUIScript(JSStringRef script, JSValueRef callback);
357     void runUIScriptCallback(unsigned callbackID, JSStringRef result);
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     void 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 setStatisticsSubframeUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
414     void setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
415     void setStatisticsSubresourceUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo);
416     void setStatisticsSubresourceUniqueRedirectFrom(JSStringRef hostName, JSStringRef hostNameRedirectedFrom);
417     void setStatisticsTopFrameUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo);
418     void setStatisticsTopFrameUniqueRedirectFrom(JSStringRef hostName, JSStringRef hostNameRedirectedFrom);
419     void setStatisticsTimeToLiveUserInteraction(double seconds);
420     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
421     void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
422     void setStatisticsNotifyPagesWhenTelemetryWasCaptured(bool value);
423     void setStatisticsMinimumTimeBetweenDataRecordsRemoval(double);
424     void setStatisticsGrandfatheringTime(double seconds);
425     void setStatisticsMaxStatisticsEntries(unsigned);
426     void setStatisticsPruneEntriesDownTo(unsigned);
427     void statisticsClearInMemoryAndPersistentStore(JSValueRef callback);
428     void statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned hours, JSValueRef callback);
429     void statisticsClearThroughWebsiteDataRemoval(JSValueRef callback);
430     void statisticsDeleteCookiesForHost(JSStringRef hostName, bool includeHttpOnlyCookies);
431     void statisticsCallClearThroughWebsiteDataRemovalCallback();
432     void setStatisticsCacheMaxAgeCap(double seconds);
433     void statisticsResetToConsistentState(JSValueRef completionHandler);
434     void statisticsCallDidResetToConsistentStateCallback();
435
436     // Injected bundle form client.
437     void installTextDidChangeInTextFieldCallback(JSValueRef callback);
438     void textDidChangeInTextFieldCallback();
439     void installTextFieldDidBeginEditingCallback(JSValueRef callback);
440     void textFieldDidBeginEditingCallback();
441     void installTextFieldDidEndEditingCallback(JSValueRef callback);
442     void textFieldDidEndEditingCallback();
443
444     // Storage Access API
445     void setStorageAccessAPIEnabled(bool);
446     void getAllStorageAccessEntries(JSValueRef callback);
447     void callDidReceiveAllStorageAccessEntriesCallback(Vector<String>& domains);
448
449     // Open panel
450     void setOpenPanelFiles(JSValueRef);
451
452     // Modal alerts
453     void setShouldDismissJavaScriptAlertsAsynchronously(bool);
454
455     void terminateNetworkProcess();
456     void terminateServiceWorkerProcess();
457
458     void removeAllSessionCredentials(JSValueRef);
459     void callDidRemoveAllSessionCredentialsCallback();
460     
461     void getApplicationManifestThen(JSValueRef);
462     void didGetApplicationManifest();
463
464     void installFakeHelvetica(JSStringRef configuration);
465
466     void dumpAllHTTPRedirectedResponseHeaders() { m_dumpAllHTTPRedirectedResponseHeaders = true; }
467     bool shouldDumpAllHTTPRedirectedResponseHeaders() const { return m_dumpAllHTTPRedirectedResponseHeaders; }
468
469     void addMockCameraDevice(JSStringRef persistentId, JSStringRef label);
470     void addMockMicrophoneDevice(JSStringRef persistentId, JSStringRef label);
471     void addMockScreenDevice(JSStringRef persistentId, JSStringRef label);
472     void clearMockMediaDevices();
473     void removeMockMediaDevice(JSStringRef persistentId);
474     void resetMockMediaDevices();
475
476     size_t userScriptInjectedCount() const;
477     void injectUserScript(JSStringRef);
478
479     void sendDisplayConfigurationChangedMessageForTesting();
480
481     // WebAuthN
482     void setWebAuthenticationMockConfiguration(JSValueRef);
483     // FIXME(189876)
484     void addTestKeyToKeychain(JSStringRef privateKeyBase64, JSStringRef attrLabel, JSStringRef applicationTagBase64);
485     void cleanUpKeychain(JSStringRef attrLabel);
486     bool keyExistsInKeychain(JSStringRef attrLabel, JSStringRef applicationTagBase64);
487
488     void setCanHandleHTTPSServerTrustEvaluation(bool canHandle);
489     bool canDoServerTrustEvaluationInNetworkProcess();
490     unsigned long serverTrustEvaluationCallbackCallsCount();
491
492     // Ad Click Attribution.
493     void dumpAdClickAttribution();
494     void clearAdClickAttribution();
495
496 private:
497     TestRunner();
498
499     void platformInitialize();
500     void initializeWaitToDumpWatchdogTimerIfNeeded();
501
502     void setDumpPixels(bool);
503     void setWaitUntilDone(bool);
504
505     void addMockMediaDevice(JSStringRef persistentId, JSStringRef label, const char* type);
506
507     WKRetainPtr<WKURLRef> m_testURL; // Set by InjectedBundlePage once provisional load starts.
508
509     bool m_shouldDumpAllFrameScrollPositions;
510     bool m_shouldDumpBackForwardListsForAllWindows;
511
512     bool m_shouldAllowEditing;
513     bool m_shouldCloseExtraWindows;
514
515     bool m_dumpEditingCallbacks;
516     bool m_dumpStatusCallbacks;
517     bool m_dumpTitleChanges;
518     bool m_dumpPixels;
519     bool m_dumpSelectionRect;
520     bool m_dumpFullScreenCallbacks;
521     bool m_dumpProgressFinishedCallback;
522     bool m_dumpResourceLoadCallbacks;
523     bool m_dumpResourceResponseMIMETypes;
524     bool m_dumpWillCacheResponse;
525     bool m_dumpApplicationCacheDelegateCallbacks;
526     bool m_dumpDatabaseCallbacks;
527     bool m_dumpPolicyCallbacks { false };
528     bool m_disallowIncreaseForApplicationCacheQuota;
529     bool m_testRepaint;
530     bool m_testRepaintSweepHorizontally;
531     bool m_isPrinting;
532
533     bool m_willSendRequestReturnsNull;
534     bool m_willSendRequestReturnsNullOnRedirect;
535     bool m_shouldStopProvisionalFrameLoads;
536     String m_willSendRequestHTTPBody;
537
538     bool m_policyDelegateEnabled;
539     bool m_policyDelegatePermissive;
540     
541     bool m_globalFlag;
542     bool m_customFullScreenBehavior;
543
544     WTF::Seconds m_timeout;
545
546     double m_databaseDefaultQuota;
547     double m_databaseMaxQuota;
548
549     bool m_shouldDecideNavigationPolicyAfterDelay { false };
550     bool m_shouldDecideResponsePolicyAfterDelay { false };
551     bool m_shouldFinishAfterDownload { false };
552     bool m_didCancelClientRedirect { false };
553
554     bool m_userStyleSheetEnabled;
555     WKRetainPtr<WKStringRef> m_userStyleSheetLocation;
556
557     WKRetainPtr<WKArrayRef> m_allowedHosts;
558
559     size_t m_userMediaPermissionRequestCount { 0 };
560
561     PlatformTimerRef m_waitToDumpWatchdogTimer;
562
563     bool m_dumpAllHTTPRedirectedResponseHeaders { false };
564 };
565
566 } // namespace WTR