47e5972214b479744ff54d6a2cab591e4501b14e
[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 #elif PLATFORM(GTK) || PLATFORM(WPE)
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 setMDNSICECandidatesEnabled(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
158     // Local storage
159     void clearAllDatabases();
160     void setDatabaseQuota(uint64_t);
161     JSRetainPtr<JSStringRef> pathToLocalResource(JSStringRef);
162
163     // Application Cache
164     void clearAllApplicationCaches();
165     void clearApplicationCacheForOrigin(JSStringRef origin);
166     void setAppCacheMaximumSize(uint64_t);
167     long long applicationCacheDiskUsageForOrigin(JSStringRef origin);
168     void disallowIncreaseForApplicationCacheQuota();
169     bool shouldDisallowIncreaseForApplicationCacheQuota() { return m_disallowIncreaseForApplicationCacheQuota; }
170     JSValueRef originsWithApplicationCache();
171
172     void clearDOMCache(JSStringRef origin);
173     void clearDOMCaches();
174     bool hasDOMCache(JSStringRef origin);
175     uint64_t domCacheSize(JSStringRef origin);
176
177     // IndexedDB
178     void setIDBPerOriginQuota(uint64_t);
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     void waitToDumpWatchdogTimerFired();
232     void invalidateWaitToDumpWatchdogTimer();
233
234     // Downloads
235     bool shouldFinishAfterDownload() const { return m_shouldFinishAfterDownload; }
236     void setShouldLogDownloadCallbacks(bool);
237
238     bool shouldAllowEditing() const { return m_shouldAllowEditing; }
239
240     bool shouldCloseExtraWindowsAfterRunningTest() const { return m_shouldCloseExtraWindows; }
241
242     void evaluateScriptInIsolatedWorld(JSContextRef, unsigned worldID, JSStringRef script);
243     static unsigned worldIDForWorld(WKBundleScriptWorldRef);
244
245     void showWebInspector();
246     void closeWebInspector();
247     void evaluateInWebInspector(JSStringRef script);
248     JSRetainPtr<JSStringRef> inspectorTestStubURL();
249
250     void setPOSIXLocale(JSStringRef);
251
252     bool willSendRequestReturnsNull() const { return m_willSendRequestReturnsNull; }
253     void setWillSendRequestReturnsNull(bool f) { m_willSendRequestReturnsNull = f; }
254     bool willSendRequestReturnsNullOnRedirect() const { return m_willSendRequestReturnsNullOnRedirect; }
255     void setWillSendRequestReturnsNullOnRedirect(bool f) { m_willSendRequestReturnsNullOnRedirect = f; }
256     void setWillSendRequestAddsHTTPBody(JSStringRef body) { m_willSendRequestHTTPBody = toWTFString(toWK(body)); }
257     String willSendRequestHTTPBody() const { return m_willSendRequestHTTPBody; }
258
259     void setTextDirection(JSStringRef);
260
261     void setShouldStayOnPageAfterHandlingBeforeUnload(bool);
262
263     void setDefersLoading(bool);
264
265     void setStopProvisionalFrameLoads() { m_shouldStopProvisionalFrameLoads = true; }
266     bool shouldStopProvisionalFrameLoads() const { return m_shouldStopProvisionalFrameLoads; }
267     
268     bool globalFlag() const { return m_globalFlag; }
269     void setGlobalFlag(bool value) { m_globalFlag = value; }
270
271     double databaseDefaultQuota() const { return m_databaseDefaultQuota; }
272     void setDatabaseDefaultQuota(double quota) { m_databaseDefaultQuota = quota; }
273
274     double databaseMaxQuota() const { return m_databaseMaxQuota; }
275     void setDatabaseMaxQuota(double quota) { m_databaseMaxQuota = quota; }
276
277     void addChromeInputField(JSValueRef);
278     void removeChromeInputField(JSValueRef);
279     void focusWebView(JSValueRef);
280     void setBackingScaleFactor(double, JSValueRef);
281
282     void setWindowIsKey(bool);
283
284     void setViewSize(double width, double height);
285
286     void callAddChromeInputFieldCallback();
287     void callRemoveChromeInputFieldCallback();
288     void callFocusWebViewCallback();
289     void callSetBackingScaleFactorCallback();
290
291     void overridePreference(JSStringRef preference, JSStringRef value);
292
293     // Cookies testing
294     void setAlwaysAcceptCookies(bool);
295
296     // Custom full screen behavior.
297     void setHasCustomFullScreenBehavior(bool value) { m_customFullScreenBehavior = value; }
298     bool hasCustomFullScreenBehavior() const { return m_customFullScreenBehavior; }
299
300     // Web notifications.
301     static void grantWebNotificationPermission(JSStringRef origin);
302     static void denyWebNotificationPermission(JSStringRef origin);
303     static void removeAllWebNotificationPermissions();
304     static void simulateWebNotificationClick(JSValueRef notification);
305
306     // Geolocation.
307     void setGeolocationPermission(bool);
308     void setMockGeolocationPosition(double latitude, double longitude, double accuracy, JSValueRef altitude, JSValueRef altitudeAccuracy, JSValueRef heading, JSValueRef speed, JSValueRef floorLevel);
309     void setMockGeolocationPositionUnavailableError(JSStringRef message);
310     bool isGeolocationProviderActive();
311
312     // MediaStream
313     void setUserMediaPermission(bool);
314     void resetUserMediaPermission();
315     void setUserMediaPersistentPermissionForOrigin(bool permission, JSStringRef origin, JSStringRef parentOrigin);
316     unsigned userMediaPermissionRequestCountForOrigin(JSStringRef origin, JSStringRef parentOrigin) const;
317     void resetUserMediaPermissionRequestCountForOrigin(JSStringRef origin, JSStringRef parentOrigin);
318
319     void setPageVisibility(JSStringRef state);
320     void resetPageVisibility();
321
322     bool callShouldCloseOnWebView();
323
324     void setCustomTimeout(WTF::Seconds duration) { m_timeout = duration; }
325
326     // Work queue.
327     void queueBackNavigation(unsigned howFarBackward);
328     void queueForwardNavigation(unsigned howFarForward);
329     void queueLoad(JSStringRef url, JSStringRef target, bool shouldOpenExternalURLs);
330     void queueLoadHTMLString(JSStringRef content, JSStringRef baseURL, JSStringRef unreachableURL);
331     void queueReload();
332     void queueLoadingScript(JSStringRef script);
333     void queueNonLoadingScript(JSStringRef script);
334
335     bool secureEventInputIsEnabled() const;
336
337     JSValueRef failNextNewCodeBlock();
338     JSValueRef numberOfDFGCompiles(JSValueRef theFunction);
339     JSValueRef neverInlineFunction(JSValueRef theFunction);
340
341     bool shouldDecideNavigationPolicyAfterDelay() const { return m_shouldDecideNavigationPolicyAfterDelay; }
342     void setShouldDecideNavigationPolicyAfterDelay(bool);
343     bool shouldDecideResponsePolicyAfterDelay() const { return m_shouldDecideResponsePolicyAfterDelay; }
344     void setShouldDecideResponsePolicyAfterDelay(bool);
345     void setNavigationGesturesEnabled(bool);
346     void setIgnoresViewportScaleLimits(bool);
347     void setShouldDownloadUndisplayableMIMETypes(bool);
348
349     bool didCancelClientRedirect() const { return m_didCancelClientRedirect; }
350     void setDidCancelClientRedirect(bool value) { m_didCancelClientRedirect = value; }
351
352     void runUIScript(JSStringRef script, JSValueRef callback);
353     void runUIScriptCallback(unsigned callbackID, JSStringRef result);
354
355     void installDidBeginSwipeCallback(JSValueRef);
356     void installWillEndSwipeCallback(JSValueRef);
357     void installDidEndSwipeCallback(JSValueRef);
358     void installDidRemoveSwipeSnapshotCallback(JSValueRef);
359     void callDidBeginSwipeCallback();
360     void callWillEndSwipeCallback();
361     void callDidEndSwipeCallback();
362     void callDidRemoveSwipeSnapshotCallback();
363
364     void clearTestRunnerCallbacks();
365
366     void accummulateLogsForChannel(JSStringRef channel);
367
368     unsigned imageCountInGeneralPasteboard() const;
369
370     // Gamepads
371     void connectMockGamepad(unsigned index);
372     void disconnectMockGamepad(unsigned index);
373     void setMockGamepadDetails(unsigned index, JSStringRef gamepadID, unsigned axisCount, unsigned buttonCount);
374     void setMockGamepadAxisValue(unsigned index, unsigned axisIndex, double value);
375     void setMockGamepadButtonValue(unsigned index, unsigned buttonIndex, double value);
376     
377     // Resource Load Statistics
378     void installStatisticsDidModifyDataRecordsCallback(JSValueRef callback);
379     void installStatisticsDidScanDataRecordsCallback(JSValueRef callback);
380     void installStatisticsDidRunTelemetryCallback(JSValueRef callback);
381     void statisticsDidModifyDataRecordsCallback();
382     void statisticsDidScanDataRecordsCallback();
383     void statisticsDidRunTelemetryCallback(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins);
384     void statisticsNotifyObserver();
385     void statisticsProcessStatisticsAndDataRecords();
386     void statisticsUpdateCookieBlocking(JSValueRef completionHandler);
387     void statisticsCallDidSetBlockCookiesForHostCallback();
388     void statisticsSubmitTelemetry();
389     void setStatisticsDebugMode(bool value, JSValueRef completionHandler);
390     void statisticsCallDidSetDebugModeCallback();
391     void setStatisticsPrevalentResourceForDebugMode(JSStringRef hostName, JSValueRef completionHandler);
392     void statisticsCallDidSetPrevalentResourceForDebugModeCallback();
393     void setStatisticsLastSeen(JSStringRef hostName, double seconds, JSValueRef completionHandler);
394     void statisticsCallDidSetLastSeenCallback();
395     void setStatisticsPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler);
396     void statisticsCallDidSetPrevalentResourceCallback();
397     void setStatisticsVeryPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler);
398     void statisticsCallDidSetVeryPrevalentResourceCallback();
399     bool isStatisticsPrevalentResource(JSStringRef hostName);
400     bool isStatisticsVeryPrevalentResource(JSStringRef hostName);
401     bool isStatisticsRegisteredAsSubresourceUnder(JSStringRef subresourceHost, JSStringRef topFrameHost);
402     bool isStatisticsRegisteredAsSubFrameUnder(JSStringRef subFrameHost, JSStringRef topFrameHost);
403     bool isStatisticsRegisteredAsRedirectingTo(JSStringRef hostRedirectedFrom, JSStringRef hostRedirectedTo);
404     void setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value, JSValueRef completionHandler);
405     void statisticsCallDidSetHasHadUserInteractionCallback();
406     bool isStatisticsHasHadUserInteraction(JSStringRef hostName);
407     void setStatisticsGrandfathered(JSStringRef hostName, bool value);
408     bool isStatisticsGrandfathered(JSStringRef hostName);
409     void setStatisticsSubframeUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
410     void setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
411     void setStatisticsSubresourceUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo);
412     void setStatisticsSubresourceUniqueRedirectFrom(JSStringRef hostName, JSStringRef hostNameRedirectedFrom);
413     void setStatisticsTopFrameUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo);
414     void setStatisticsTopFrameUniqueRedirectFrom(JSStringRef hostName, JSStringRef hostNameRedirectedFrom);
415     void setStatisticsTimeToLiveUserInteraction(double seconds);
416     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
417     void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
418     void setStatisticsNotifyPagesWhenTelemetryWasCaptured(bool value);
419     void setStatisticsMinimumTimeBetweenDataRecordsRemoval(double);
420     void setStatisticsGrandfatheringTime(double seconds);
421     void setStatisticsMaxStatisticsEntries(unsigned);
422     void setStatisticsPruneEntriesDownTo(unsigned);
423     void statisticsClearInMemoryAndPersistentStore(JSValueRef callback);
424     void statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned hours, JSValueRef callback);
425     void statisticsClearThroughWebsiteDataRemoval(JSValueRef callback);
426     void statisticsCallClearThroughWebsiteDataRemovalCallback();
427     void setStatisticsCacheMaxAgeCap(double seconds);
428     void statisticsResetToConsistentState(JSValueRef completionHandler);
429     void statisticsCallDidResetToConsistentStateCallback();
430
431     // Injected bundle form client.
432     void installTextDidChangeInTextFieldCallback(JSValueRef callback);
433     void textDidChangeInTextFieldCallback();
434     void installTextFieldDidBeginEditingCallback(JSValueRef callback);
435     void textFieldDidBeginEditingCallback();
436     void installTextFieldDidEndEditingCallback(JSValueRef callback);
437     void textFieldDidEndEditingCallback();
438
439     // Storage Access API
440     void setStorageAccessAPIEnabled(bool);
441     void getAllStorageAccessEntries(JSValueRef callback);
442     void callDidReceiveAllStorageAccessEntriesCallback(Vector<String>& domains);
443
444     // Open panel
445     void setOpenPanelFiles(JSValueRef);
446
447     void terminateNetworkProcess();
448     void terminateServiceWorkerProcess();
449
450     void removeAllSessionCredentials(JSValueRef);
451     void callDidRemoveAllSessionCredentialsCallback();
452     
453     void getApplicationManifestThen(JSValueRef);
454     void didGetApplicationManifest();
455
456     void installFakeHelvetica(JSStringRef configuration);
457
458     void dumpAllHTTPRedirectedResponseHeaders() { m_dumpAllHTTPRedirectedResponseHeaders = true; }
459     bool shouldDumpAllHTTPRedirectedResponseHeaders() const { return m_dumpAllHTTPRedirectedResponseHeaders; }
460
461     void addMockCameraDevice(JSStringRef persistentId, JSStringRef label);
462     void addMockMicrophoneDevice(JSStringRef persistentId, JSStringRef label);
463     void addMockScreenDevice(JSStringRef persistentId, JSStringRef label);
464     void clearMockMediaDevices();
465     void removeMockMediaDevice(JSStringRef persistentId);
466     void resetMockMediaDevices();
467
468     size_t userScriptInjectedCount() const;
469     void injectUserScript(JSStringRef);
470
471     void sendDisplayConfigurationChangedMessageForTesting();
472
473     // WebAuthN
474     void setWebAuthenticationMockConfiguration(JSValueRef);
475     // FIXME(189876)
476     void addTestKeyToKeychain(JSStringRef privateKeyBase64, JSStringRef attrLabel, JSStringRef applicationTagBase64);
477     void cleanUpKeychain(JSStringRef attrLabel);
478     bool keyExistsInKeychain(JSStringRef attrLabel, JSStringRef applicationTagBase64);
479
480 private:
481     TestRunner();
482
483     void platformInitialize();
484     void initializeWaitToDumpWatchdogTimerIfNeeded();
485
486     void setDumpPixels(bool);
487     void setWaitUntilDone(bool);
488
489     void addMockMediaDevice(JSStringRef persistentId, JSStringRef label, const char* type);
490
491     WKRetainPtr<WKURLRef> m_testURL; // Set by InjectedBundlePage once provisional load starts.
492
493     bool m_shouldDumpAllFrameScrollPositions;
494     bool m_shouldDumpBackForwardListsForAllWindows;
495
496     bool m_shouldAllowEditing;
497     bool m_shouldCloseExtraWindows;
498
499     bool m_dumpEditingCallbacks;
500     bool m_dumpStatusCallbacks;
501     bool m_dumpTitleChanges;
502     bool m_dumpPixels;
503     bool m_dumpSelectionRect;
504     bool m_dumpFullScreenCallbacks;
505     bool m_dumpProgressFinishedCallback;
506     bool m_dumpResourceLoadCallbacks;
507     bool m_dumpResourceResponseMIMETypes;
508     bool m_dumpWillCacheResponse;
509     bool m_dumpApplicationCacheDelegateCallbacks;
510     bool m_dumpDatabaseCallbacks;
511     bool m_dumpPolicyCallbacks { false };
512     bool m_disallowIncreaseForApplicationCacheQuota;
513     bool m_testRepaint;
514     bool m_testRepaintSweepHorizontally;
515     bool m_isPrinting;
516
517     bool m_willSendRequestReturnsNull;
518     bool m_willSendRequestReturnsNullOnRedirect;
519     bool m_shouldStopProvisionalFrameLoads;
520     String m_willSendRequestHTTPBody;
521
522     bool m_policyDelegateEnabled;
523     bool m_policyDelegatePermissive;
524     
525     bool m_globalFlag;
526     bool m_customFullScreenBehavior;
527
528     WTF::Seconds m_timeout;
529
530     double m_databaseDefaultQuota;
531     double m_databaseMaxQuota;
532
533     bool m_shouldDecideNavigationPolicyAfterDelay { false };
534     bool m_shouldDecideResponsePolicyAfterDelay { false };
535     bool m_shouldFinishAfterDownload { false };
536     bool m_didCancelClientRedirect { false };
537
538     bool m_userStyleSheetEnabled;
539     WKRetainPtr<WKStringRef> m_userStyleSheetLocation;
540
541     WKRetainPtr<WKArrayRef> m_allowedHosts;
542
543     size_t m_userMediaPermissionRequestCount { 0 };
544
545     PlatformTimerRef m_waitToDumpWatchdogTimer;
546
547     bool m_dumpAllHTTPRedirectedResponseHeaders { false };
548 };
549
550 } // namespace WTR