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