-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
TestRunner.h
639 lines (524 loc) · 29.9 KB
/
TestRunner.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
/*
* Copyright (C) 2010-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "JSWrappable.h"
#include "StringFunctions.h"
#include "WhatToDump.h"
#include <JavaScriptCore/JSRetainPtr.h>
#include <WebKit/WKBundleScriptWorld.h>
#include <WebKit/WKRetainPtr.h>
#include <string>
#include <wtf/Ref.h>
#include <wtf/Seconds.h>
#include <wtf/text/WTFString.h>
namespace WTR {
class TestRunner : public JSWrappable {
public:
static Ref<TestRunner> create();
virtual ~TestRunner();
// JSWrappable
virtual JSClassRef wrapperClass();
void makeWindowObject(JSContextRef);
bool isIOSFamily() const
{
#if PLATFORM(IOS_FAMILY)
return true;
#else
return false;
#endif
}
bool isWebKit2() const { return true; }
// The basics.
WKURLRef testURL() const { return m_testURL.get(); }
void setTestURL(WKURLRef url) { m_testURL = url; }
void dumpAsText(bool dumpPixels);
void waitForPolicyDelegate();
void dumpChildFramesAsText() { setWhatToDump(WhatToDump::AllFramesText); }
void waitUntilDownloadFinished();
void waitUntilDone();
void notifyDone();
double preciseTime();
double timeout() { return m_timeout.milliseconds(); }
void setRenderTreeDumpOptions(unsigned short);
unsigned renderTreeDumpOptions() const { return m_renderTreeDumpOptions; }
// Other dumping.
void dumpBackForwardList() { m_shouldDumpBackForwardListsForAllWindows = true; }
void dumpChildFrameScrollPositions() { m_shouldDumpAllFrameScrollPositions = true; }
void dumpEditingCallbacks() { m_dumpEditingCallbacks = true; }
void dumpSelectionRect() { m_dumpSelectionRect = true; }
void dumpStatusCallbacks() { m_dumpStatusCallbacks = true; }
void dumpTitleChanges() { m_dumpTitleChanges = true; }
void dumpFullScreenCallbacks() { m_dumpFullScreenCallbacks = true; }
void dumpFrameLoadCallbacks() { setShouldDumpFrameLoadCallbacks(true); }
void dumpProgressFinishedCallback() { setShouldDumpProgressFinishedCallback(true); }
void dumpResourceLoadCallbacks() { m_dumpResourceLoadCallbacks = true; }
void dumpResourceResponseMIMETypes() { m_dumpResourceResponseMIMETypes = true; }
void dumpWillCacheResponse() { m_dumpWillCacheResponse = true; }
void dumpApplicationCacheDelegateCallbacks() { m_dumpApplicationCacheDelegateCallbacks = true; }
void dumpDatabaseCallbacks() { m_dumpDatabaseCallbacks = true; }
void dumpDOMAsWebArchive() { setWhatToDump(WhatToDump::DOMAsWebArchive); }
void dumpPolicyDelegateCallbacks();
void dumpResourceLoadStatistics();
void setShouldDumpFrameLoadCallbacks(bool value);
void setShouldDumpProgressFinishedCallback(bool value) { m_dumpProgressFinishedCallback = value; }
// Special options.
void keepWebHistory();
void setAcceptsEditing(bool value) { m_shouldAllowEditing = value; }
void preventPopupWindows();
void setCustomPolicyDelegate(bool enabled, bool permissive = false);
void skipPolicyDelegateNotifyDone();
void addOriginAccessAllowListEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains);
void removeOriginAccessAllowListEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains);
void setUserStyleSheetEnabled(bool);
void setUserStyleSheetLocation(JSStringRef);
void setTabKeyCyclesThroughElements(bool);
void setSerializeHTTPLoads();
void dispatchPendingLoadRequests();
void setCacheModel(int);
void setAsynchronousSpellCheckingEnabled(bool);
void setAllowsAnySSLCertificate(bool);
void setShouldSwapToEphemeralSessionOnNextNavigation(bool);
void setShouldSwapToDefaultSessionOnNextNavigation(bool);
void setCustomUserAgent(JSStringRef);
// Special DOM functions.
void clearBackForwardList();
void execCommand(JSStringRef name, JSStringRef showUI, JSStringRef value);
bool isCommandEnabled(JSStringRef name);
unsigned windowCount();
// Repaint testing.
void testRepaint() { m_testRepaint = true; }
void repaintSweepHorizontally() { m_testRepaintSweepHorizontally = true; }
void display();
void displayAndTrackRepaints();
void displayOnLoadFinish() { m_displayOnLoadFinish = true; }
bool shouldDisplayOnLoadFinish() { return m_displayOnLoadFinish; }
// UserContent testing.
void addUserScript(JSStringRef source, bool runAtStart, bool allFrames);
void addUserStyleSheet(JSStringRef source, bool allFrames);
// Text search testing.
bool findString(JSStringRef, JSValueRef optionsArray);
void findStringMatchesInPage(JSStringRef, JSValueRef optionsArray);
void replaceFindMatchesAtIndices(JSValueRef matchIndices, JSStringRef replacementText, bool selectionOnly);
// Local storage
void clearAllDatabases();
void setDatabaseQuota(uint64_t);
JSRetainPtr<JSStringRef> pathToLocalResource(JSStringRef);
void syncLocalStorage();
// Application Cache
void clearAllApplicationCaches();
void clearApplicationCacheForOrigin(JSStringRef origin);
void setAppCacheMaximumSize(uint64_t);
long long applicationCacheDiskUsageForOrigin(JSStringRef origin);
void disallowIncreaseForApplicationCacheQuota();
bool shouldDisallowIncreaseForApplicationCacheQuota() { return m_disallowIncreaseForApplicationCacheQuota; }
JSValueRef originsWithApplicationCache();
void clearDOMCache(JSStringRef origin);
void clearDOMCaches();
bool hasDOMCache(JSStringRef origin);
uint64_t domCacheSize(JSStringRef origin);
void setAllowStorageQuotaIncrease(bool);
void setQuota(uint64_t);
// Failed load condition testing
void forceImmediateCompletion();
// Printing
bool isPageBoxVisible(int pageIndex);
bool isPrinting() { return m_isPrinting; }
void setPrinting() { m_isPrinting = true; }
// Authentication
void setRejectsProtectionSpaceAndContinueForAuthenticationChallenges(bool);
void setHandlesAuthenticationChallenges(bool);
void setShouldLogCanAuthenticateAgainstProtectionSpace(bool);
void setAuthenticationUsername(JSStringRef);
void setAuthenticationPassword(JSStringRef);
void setValueForUser(JSContextRef, JSValueRef element, JSStringRef value);
// Audio testing.
void setAudioResult(JSContextRef, JSValueRef data);
void setBlockAllPlugins(bool);
void setPluginSupportedMode(JSStringRef);
WhatToDump whatToDump() const;
void setWhatToDump(WhatToDump);
bool shouldDumpAllFrameScrollPositions() const { return m_shouldDumpAllFrameScrollPositions; }
bool shouldDumpBackForwardListsForAllWindows() const { return m_shouldDumpBackForwardListsForAllWindows; }
bool shouldDumpEditingCallbacks() const { return m_dumpEditingCallbacks; }
bool shouldDumpMainFrameScrollPosition() const { return whatToDump() == WhatToDump::RenderTree; }
bool shouldDumpStatusCallbacks() const { return m_dumpStatusCallbacks; }
bool shouldDumpTitleChanges() const { return m_dumpTitleChanges; }
bool shouldDumpPixels() const;
bool shouldDumpFullScreenCallbacks() const { return m_dumpFullScreenCallbacks; }
bool shouldDumpFrameLoadCallbacks();
bool shouldDumpProgressFinishedCallback() const { return m_dumpProgressFinishedCallback; }
bool shouldDumpResourceLoadCallbacks() const { return m_dumpResourceLoadCallbacks; }
bool shouldDumpResourceResponseMIMETypes() const { return m_dumpResourceResponseMIMETypes; }
bool shouldDumpWillCacheResponse() const { return m_dumpWillCacheResponse; }
bool shouldDumpApplicationCacheDelegateCallbacks() const { return m_dumpApplicationCacheDelegateCallbacks; }
bool shouldDumpDatabaseCallbacks() const { return m_dumpDatabaseCallbacks; }
bool shouldDumpSelectionRect() const { return m_dumpSelectionRect; }
bool didReceiveServerRedirectForProvisionalNavigation() const;
void clearDidReceiveServerRedirectForProvisionalNavigation();
bool shouldWaitUntilDone() const;
// Downloads
bool shouldFinishAfterDownload() const { return m_shouldFinishAfterDownload; }
void setShouldLogDownloadCallbacks(bool);
void setShouldLogDownloadSize(bool);
bool shouldAllowEditing() const { return m_shouldAllowEditing; }
void evaluateScriptInIsolatedWorld(JSContextRef, unsigned worldID, JSStringRef script);
static unsigned worldIDForWorld(WKBundleScriptWorldRef);
void showWebInspector();
void closeWebInspector();
void evaluateInWebInspector(JSStringRef script);
JSRetainPtr<JSStringRef> inspectorTestStubURL();
void setPOSIXLocale(JSStringRef);
bool willSendRequestReturnsNull() const { return m_willSendRequestReturnsNull; }
void setWillSendRequestReturnsNull(bool f) { m_willSendRequestReturnsNull = f; }
bool willSendRequestReturnsNullOnRedirect() const { return m_willSendRequestReturnsNullOnRedirect; }
void setWillSendRequestReturnsNullOnRedirect(bool f) { m_willSendRequestReturnsNullOnRedirect = f; }
void setWillSendRequestAddsHTTPBody(JSStringRef body) { m_willSendRequestHTTPBody = toWTFString(body); }
String willSendRequestHTTPBody() const { return m_willSendRequestHTTPBody; }
void setTextDirection(JSStringRef);
void setShouldStayOnPageAfterHandlingBeforeUnload(bool);
void setStopProvisionalFrameLoads() { m_shouldStopProvisionalFrameLoads = true; }
bool shouldStopProvisionalFrameLoads() const { return m_shouldStopProvisionalFrameLoads; }
bool globalFlag() const { return m_globalFlag; }
void setGlobalFlag(bool value) { m_globalFlag = value; }
double databaseDefaultQuota() const { return m_databaseDefaultQuota; }
void setDatabaseDefaultQuota(double quota) { m_databaseDefaultQuota = quota; }
double databaseMaxQuota() const { return m_databaseMaxQuota; }
void setDatabaseMaxQuota(double quota) { m_databaseMaxQuota = quota; }
void addChromeInputField(JSValueRef);
void removeChromeInputField(JSValueRef);
void focusWebView(JSValueRef);
void setTextInChromeInputField(JSStringRef text, JSValueRef callback);
void selectChromeInputField(JSValueRef callback);
void getSelectedTextInChromeInputField(JSValueRef callback);
void setBackingScaleFactor(double, JSValueRef);
void setWindowIsKey(bool);
void setViewSize(double width, double height);
void callAddChromeInputFieldCallback();
void callRemoveChromeInputFieldCallback();
void callFocusWebViewCallback();
void callSetBackingScaleFactorCallback();
void callSetTextInChromeInputFieldCallback();
void callSelectChromeInputFieldCallback();
void callGetSelectedTextInChromeInputFieldCallback(JSStringRef);
static void overridePreference(JSStringRef preference, JSStringRef value);
// Cookies testing
void setAlwaysAcceptCookies(bool);
void setOnlyAcceptFirstPartyCookies(bool);
void removeAllCookies(JSValueRef callback);
void callRemoveAllCookiesCallback();
// Custom full screen behavior.
void setHasCustomFullScreenBehavior(bool value) { m_customFullScreenBehavior = value; }
bool hasCustomFullScreenBehavior() const { return m_customFullScreenBehavior; }
void setEnterFullscreenForElementCallback(JSValueRef);
void callEnterFullscreenForElementCallback();
void setExitFullscreenForElementCallback(JSValueRef);
void callExitFullscreenForElementCallback();
// Web notifications.
static void grantWebNotificationPermission(JSStringRef origin);
static void denyWebNotificationPermission(JSStringRef origin);
static void denyWebNotificationPermissionOnPrompt(JSStringRef origin);
static void removeAllWebNotificationPermissions();
static void simulateWebNotificationClick(JSValueRef notification);
static void simulateWebNotificationClickForServiceWorkerNotifications();
JSRetainPtr<JSStringRef> getBackgroundFetchIdentifier();
void abortBackgroundFetch(JSStringRef);
void pauseBackgroundFetch(JSStringRef);
void resumeBackgroundFetch(JSStringRef);
void simulateClickBackgroundFetch(JSStringRef);
void setBackgroundFetchPermission(bool);
JSRetainPtr<JSStringRef> lastAddedBackgroundFetchIdentifier() const;
JSRetainPtr<JSStringRef> lastRemovedBackgroundFetchIdentifier() const;
JSRetainPtr<JSStringRef> lastUpdatedBackgroundFetchIdentifier() const;
JSRetainPtr<JSStringRef> backgroundFetchState(JSStringRef);
// Geolocation.
void setGeolocationPermission(bool);
void setMockGeolocationPosition(double latitude, double longitude, double accuracy, std::optional<double> altitude, std::optional<double> altitudeAccuracy, std::optional<double> heading, std::optional<double> speed, std::optional<double> floorLevel);
void setMockGeolocationPositionUnavailableError(JSStringRef message);
bool isGeolocationProviderActive();
// Screen Wake Lock.
void setScreenWakeLockPermission(bool);
// MediaStream
void setUserMediaPermission(bool);
void resetUserMediaPermission();
void setUserMediaPersistentPermissionForOrigin(bool permission, JSStringRef origin, JSStringRef parentOrigin);
unsigned userMediaPermissionRequestCountForOrigin(JSStringRef origin, JSStringRef parentOrigin) const;
void resetUserMediaPermissionRequestCountForOrigin(JSStringRef origin, JSStringRef parentOrigin);
bool isDoingMediaCapture() const;
void setPageVisibility(JSStringRef state);
void resetPageVisibility();
bool callShouldCloseOnWebView();
void setCustomTimeout(WTF::Seconds duration) { m_timeout = duration; }
// Work queue.
void queueBackNavigation(unsigned howFarBackward);
void queueForwardNavigation(unsigned howFarForward);
void queueLoad(JSStringRef url, JSStringRef target, bool shouldOpenExternalURLs);
void queueLoadHTMLString(JSStringRef content, JSStringRef baseURL, JSStringRef unreachableURL);
void queueReload();
void reloadFromOrigin();
void queueLoadingScript(JSStringRef script);
void queueNonLoadingScript(JSStringRef script);
bool secureEventInputIsEnabled() const;
JSValueRef failNextNewCodeBlock();
JSValueRef numberOfDFGCompiles(JSValueRef function);
JSValueRef neverInlineFunction(JSValueRef function);
bool shouldDecideNavigationPolicyAfterDelay() const { return m_shouldDecideNavigationPolicyAfterDelay; }
void setShouldDecideNavigationPolicyAfterDelay(bool);
bool shouldDecideResponsePolicyAfterDelay() const { return m_shouldDecideResponsePolicyAfterDelay; }
void setShouldDecideResponsePolicyAfterDelay(bool);
void setNavigationGesturesEnabled(bool);
void setIgnoresViewportScaleLimits(bool);
void setShouldDownloadUndisplayableMIMETypes(bool);
void setShouldAllowDeviceOrientationAndMotionAccess(bool);
void stopLoading();
bool didCancelClientRedirect() const { return m_didCancelClientRedirect; }
void setDidCancelClientRedirect(bool value) { m_didCancelClientRedirect = value; }
void runUIScript(JSStringRef script, JSValueRef callback);
void runUIScriptImmediately(JSStringRef script, JSValueRef callback);
void runUIScriptCallback(unsigned callbackID, JSStringRef result);
// Contextual menu actions
void setAllowedMenuActions(JSValueRef);
void installDidBeginSwipeCallback(JSValueRef);
void installWillEndSwipeCallback(JSValueRef);
void installDidEndSwipeCallback(JSValueRef);
void installDidRemoveSwipeSnapshotCallback(JSValueRef);
void callDidBeginSwipeCallback();
void callWillEndSwipeCallback();
void callDidEndSwipeCallback();
void callDidRemoveSwipeSnapshotCallback();
void clearTestRunnerCallbacks();
void accummulateLogsForChannel(JSStringRef channel);
unsigned imageCountInGeneralPasteboard() const;
// Gamepads
void connectMockGamepad(unsigned index);
void disconnectMockGamepad(unsigned index);
void setMockGamepadDetails(unsigned index, JSStringRef gamepadID, JSStringRef mapping, unsigned axisCount, unsigned buttonCount, bool supportsDualRumble);
void setMockGamepadAxisValue(unsigned index, unsigned axisIndex, double value);
void setMockGamepadButtonValue(unsigned index, unsigned buttonIndex, double value);
// Resource Load Statistics
void clearStatisticsDataForDomain(JSStringRef domain);
bool doesStatisticsDomainIDExistInDatabase(unsigned domainID);
void setStatisticsEnabled(bool value);
bool isStatisticsEphemeral();
void installStatisticsDidModifyDataRecordsCallback(JSValueRef callback);
void installStatisticsDidScanDataRecordsCallback(JSValueRef callback);
void statisticsDidModifyDataRecordsCallback();
void statisticsDidScanDataRecordsCallback();
bool statisticsNotifyObserver();
void statisticsProcessStatisticsAndDataRecords();
void statisticsUpdateCookieBlocking(JSValueRef completionHandler);
void statisticsCallDidSetBlockCookiesForHostCallback();
void setStatisticsDebugMode(bool value, JSValueRef completionHandler);
void statisticsCallDidSetDebugModeCallback();
void setStatisticsPrevalentResourceForDebugMode(JSStringRef hostName, JSValueRef completionHandler);
void statisticsCallDidSetPrevalentResourceForDebugModeCallback();
void setStatisticsLastSeen(JSStringRef hostName, double seconds, JSValueRef completionHandler);
void statisticsCallDidSetLastSeenCallback();
void setStatisticsMergeStatistic(JSStringRef hostName, JSStringRef topFrameDomain1, JSStringRef topFrameDomain2, double lastSeen, bool hadUserInteraction, double mostRecentUserInteraction, bool isGrandfathered, bool isPrevalent, bool isVeryPrevalent, unsigned dataRecordsRemoved, JSValueRef completionHandler);
void statisticsCallDidSetMergeStatisticCallback();
void setStatisticsExpiredStatistic(JSStringRef hostName, unsigned numberOfOperatingDaysPassed, bool hadUserInteraction, bool isScheduledForAllButCookieDataRemoval, bool isPrevalent, JSValueRef completionHandler);
void statisticsCallDidSetExpiredStatisticCallback();
void setStatisticsPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler);
void statisticsCallDidSetPrevalentResourceCallback();
void setStatisticsVeryPrevalentResource(JSStringRef hostName, bool value, JSValueRef completionHandler);
void statisticsCallDidSetVeryPrevalentResourceCallback();
bool isStatisticsPrevalentResource(JSStringRef hostName);
bool isStatisticsVeryPrevalentResource(JSStringRef hostName);
bool isStatisticsRegisteredAsSubresourceUnder(JSStringRef subresourceHost, JSStringRef topFrameHost);
bool isStatisticsRegisteredAsSubFrameUnder(JSStringRef subFrameHost, JSStringRef topFrameHost);
bool isStatisticsRegisteredAsRedirectingTo(JSStringRef hostRedirectedFrom, JSStringRef hostRedirectedTo);
void setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value, JSValueRef completionHandler);
void statisticsCallDidSetHasHadUserInteractionCallback();
bool isStatisticsHasHadUserInteraction(JSStringRef hostName);
bool isStatisticsOnlyInDatabaseOnce(JSStringRef subHost, JSStringRef topHost);
void setStatisticsGrandfathered(JSStringRef hostName, bool value);
bool isStatisticsGrandfathered(JSStringRef hostName);
void setStatisticsSubframeUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
void setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
void setStatisticsSubresourceUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo);
void setStatisticsSubresourceUniqueRedirectFrom(JSStringRef hostName, JSStringRef hostNameRedirectedFrom);
void setStatisticsTopFrameUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo);
void setStatisticsTopFrameUniqueRedirectFrom(JSStringRef hostName, JSStringRef hostNameRedirectedFrom);
void setStatisticsCrossSiteLoadWithLinkDecoration(JSStringRef fromHost, JSStringRef toHost);
void setStatisticsTimeToLiveUserInteraction(double seconds);
void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
void setStatisticsIsRunningTest(bool);
void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
void setStatisticsMinimumTimeBetweenDataRecordsRemoval(double);
void setStatisticsGrandfatheringTime(double seconds);
void setStatisticsMaxStatisticsEntries(unsigned);
void setStatisticsPruneEntriesDownTo(unsigned);
void statisticsClearInMemoryAndPersistentStore(JSValueRef callback);
void statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned hours, JSValueRef callback);
void statisticsClearThroughWebsiteDataRemoval(JSValueRef callback);
void statisticsDeleteCookiesForHost(JSStringRef hostName, bool includeHttpOnlyCookies);
void statisticsCallClearInMemoryAndPersistentStoreCallback();
void statisticsCallClearThroughWebsiteDataRemovalCallback();
bool isStatisticsHasLocalStorage(JSStringRef hostName);
void setStatisticsCacheMaxAgeCap(double seconds);
bool hasStatisticsIsolatedSession(JSStringRef hostName);
void setStatisticsShouldDowngradeReferrer(bool, JSValueRef callback);
void statisticsCallDidSetShouldDowngradeReferrerCallback();
void setStatisticsShouldBlockThirdPartyCookies(bool value, JSValueRef callback, bool onlyOnSitesWithoutUserInteraction);
void statisticsCallDidSetShouldBlockThirdPartyCookiesCallback();
void setStatisticsFirstPartyWebsiteDataRemovalMode(bool value, JSValueRef callback);
void statisticsCallDidSetFirstPartyWebsiteDataRemovalModeCallback();
void statisticsSetToSameSiteStrictCookies(JSStringRef hostName, JSValueRef callback);
void statisticsCallDidSetToSameSiteStrictCookiesCallback();
void statisticsSetFirstPartyHostCNAMEDomain(JSStringRef firstPartyURLString, JSStringRef cnameURLString, JSValueRef completionHandler);
void statisticsCallDidSetFirstPartyHostCNAMEDomainCallback();
void statisticsSetThirdPartyCNAMEDomain(JSStringRef cnameURLString, JSValueRef completionHandler);
void statisticsCallDidSetThirdPartyCNAMEDomainCallback();
void statisticsResetToConsistentState(JSValueRef completionHandler);
void statisticsCallDidResetToConsistentStateCallback();
void loadedSubresourceDomains(JSValueRef callback);
void callDidReceiveLoadedSubresourceDomainsCallback(Vector<String>&& domains);
// Injected bundle form client.
void installTextDidChangeInTextFieldCallback(JSValueRef callback);
void textDidChangeInTextFieldCallback();
void installTextFieldDidBeginEditingCallback(JSValueRef callback);
void textFieldDidBeginEditingCallback();
void installTextFieldDidEndEditingCallback(JSValueRef callback);
void textFieldDidEndEditingCallback();
// Storage Access API
void getAllStorageAccessEntries(JSValueRef callback);
void callDidReceiveAllStorageAccessEntriesCallback(Vector<String>& domains);
// Open panel
void setOpenPanelFiles(JSValueRef);
void setOpenPanelFilesMediaIcon(JSValueRef);
// Modal alerts
void setShouldDismissJavaScriptAlertsAsynchronously(bool);
void abortModal();
void terminateGPUProcess();
void terminateNetworkProcess();
void terminateServiceWorkers();
void setUseSeparateServiceWorkerProcess(bool);
void removeAllSessionCredentials(JSValueRef);
void callDidRemoveAllSessionCredentialsCallback();
void getApplicationManifestThen(JSValueRef);
void didGetApplicationManifest();
void installFakeHelvetica(JSStringRef configuration);
void dumpAllHTTPRedirectedResponseHeaders() { m_dumpAllHTTPRedirectedResponseHeaders = true; }
bool shouldDumpAllHTTPRedirectedResponseHeaders() const { return m_dumpAllHTTPRedirectedResponseHeaders; }
void addMockCameraDevice(JSStringRef persistentId, JSStringRef label, JSValueRef properties);
void addMockMicrophoneDevice(JSStringRef persistentId, JSStringRef label);
void addMockScreenDevice(JSStringRef persistentId, JSStringRef label);
void clearMockMediaDevices();
void removeMockMediaDevice(JSStringRef persistentId);
void setMockMediaDeviceIsEphemeral(JSStringRef persistentId, bool isEphemeral);
void resetMockMediaDevices();
void setMockCameraOrientation(unsigned);
bool isMockRealtimeMediaSourceCenterEnabled();
void setMockCaptureDevicesInterrupted(bool isCameraInterrupted, bool isMicrophoneInterrupted);
void triggerMockMicrophoneConfigurationChange();
bool hasAppBoundSession();
void clearAppBoundSession();
void setAppBoundDomains(JSValueRef originArray, JSValueRef callback);
void didSetAppBoundDomainsCallback();
void setManagedDomains(JSValueRef originArray, JSValueRef callback);
void didSetManagedDomainsCallback();
bool didLoadAppInitiatedRequest();
bool didLoadNonAppInitiatedRequest();
size_t userScriptInjectedCount() const;
void injectUserScript(JSStringRef);
void sendDisplayConfigurationChangedMessageForTesting();
void setServiceWorkerFetchTimeout(double seconds);
// FIXME(189876)
void addTestKeyToKeychain(JSStringRef privateKeyBase64, JSStringRef attrLabel, JSStringRef applicationTagBase64);
void cleanUpKeychain(JSStringRef attrLabel, JSStringRef applicationLabelBase64);
bool keyExistsInKeychain(JSStringRef attrLabel, JSStringRef applicationLabelBase64);
unsigned long serverTrustEvaluationCallbackCallsCount();
void clearMemoryCache();
// Private Click Measurement.
void dumpPrivateClickMeasurement();
void clearPrivateClickMeasurement();
void clearPrivateClickMeasurementsThroughWebsiteDataRemoval();
void setPrivateClickMeasurementOverrideTimerForTesting(bool value);
void setPrivateClickMeasurementTokenPublicKeyURLForTesting(JSStringRef);
void setPrivateClickMeasurementTokenSignatureURLForTesting(JSStringRef);
void setPrivateClickMeasurementAttributionReportURLsForTesting(JSStringRef sourceURL, JSStringRef destinationURL);
void markPrivateClickMeasurementsAsExpiredForTesting();
void markAttributedPrivateClickMeasurementsAsExpiredForTesting();
void setPrivateClickMeasurementEphemeralMeasurementForTesting(bool value);
void setPrivateClickMeasurementFraudPreventionValuesForTesting(JSStringRef unlinkableToken, JSStringRef secretToken, JSStringRef signature, JSStringRef keyID);
void setPrivateClickMeasurementAppBundleIDForTesting(JSStringRef);
void simulatePrivateClickMeasurementSessionRestart();
void setIsSpeechRecognitionPermissionGranted(bool);
void setIsMediaKeySystemPermissionGranted(bool);
void takeViewPortSnapshot(JSValueRef callback);
void viewPortSnapshotTaken(WKStringRef);
// Reporting API
void generateTestReport(JSStringRef message, JSStringRef group);
private:
TestRunner();
void platformInitialize();
void setDumpPixels(bool);
void setWaitUntilDone(bool);
void addMockMediaDevice(JSStringRef persistentId, JSStringRef label, const char* type, WKDictionaryRef);
WKRetainPtr<WKURLRef> m_testURL; // Set by InjectedBundlePage once provisional load starts.
String m_willSendRequestHTTPBody;
WTF::Seconds m_timeout { 30_s };
WKRetainPtr<WKStringRef> m_userStyleSheetLocation;
WKRetainPtr<WKArrayRef> m_allowedHosts;
double m_databaseDefaultQuota { -1 };
double m_databaseMaxQuota { -1 };
size_t m_userMediaPermissionRequestCount { 0 };
unsigned m_renderTreeDumpOptions { 0 };
bool m_shouldDumpAllFrameScrollPositions { false };
bool m_shouldDumpBackForwardListsForAllWindows { false };
bool m_shouldAllowEditing { true };
bool m_dumpEditingCallbacks { false };
bool m_dumpStatusCallbacks { false };
bool m_dumpTitleChanges { false };
bool m_dumpPixels { false };
bool m_dumpSelectionRect { false };
bool m_dumpFullScreenCallbacks { false };
bool m_dumpProgressFinishedCallback { false };
bool m_dumpResourceLoadCallbacks { false };
bool m_dumpResourceResponseMIMETypes { false };
bool m_dumpWillCacheResponse { false };
bool m_dumpApplicationCacheDelegateCallbacks { false };
bool m_dumpDatabaseCallbacks { false };
bool m_disallowIncreaseForApplicationCacheQuota { false };
bool m_testRepaint { false };
bool m_testRepaintSweepHorizontally { false };
bool m_displayOnLoadFinish { false };
bool m_isPrinting { false };
bool m_willSendRequestReturnsNull { false };
bool m_willSendRequestReturnsNullOnRedirect { false };
bool m_shouldStopProvisionalFrameLoads { false };
bool m_globalFlag { false };
bool m_customFullScreenBehavior { false };
bool m_shouldDecideNavigationPolicyAfterDelay { false };
bool m_shouldDecideResponsePolicyAfterDelay { false };
bool m_shouldFinishAfterDownload { false };
bool m_didCancelClientRedirect { false };
bool m_userStyleSheetEnabled { false };
bool m_dumpAllHTTPRedirectedResponseHeaders { false };
bool m_hasSetDowngradeReferrerCallback { false };
bool m_hasSetBlockThirdPartyCookiesCallback { false };
bool m_hasSetFirstPartyWebsiteDataRemovalModeCallback { false };
bool m_takeViewPortSnapshot { false };
};
} // namespace WTR