[Web Animations] Tests using the new animation engine may crash under WebCore::FrameV...
[WebKit-https.git] / Source / WebCore / testing / Internals.h
1 /*
2  * Copyright (C) 2012 Google Inc. All rights reserved.
3  * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  * 2.  Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
16  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #pragma once
28
29 #include "CSSComputedStyleDeclaration.h"
30 #include "ContextDestructionObserver.h"
31 #include "ExceptionOr.h"
32 #include "JSDOMPromiseDeferred.h"
33 #include "OrientationNotifier.h"
34 #include "PageConsoleClient.h"
35 #include "RealtimeMediaSource.h"
36 #include <JavaScriptCore/Float32Array.h>
37 #include <wtf/Optional.h>
38
39 #if ENABLE(MEDIA_SESSION)
40 #include "MediaSessionInterruptionProvider.h"
41 #endif
42
43 namespace WebCore {
44
45 class AnimationTimeline;
46 class AudioContext;
47 class CacheStorageConnection;
48 class DOMRect;
49 class DOMRectList;
50 class DOMURL;
51 class DOMWindow;
52 class Document;
53 class Element;
54 class ExtendableEvent;
55 class FetchResponse;
56 class File;
57 class Frame;
58 class GCObservation;
59 class HTMLAnchorElement;
60 class HTMLImageElement;
61 class HTMLInputElement;
62 class HTMLLinkElement;
63 class HTMLMediaElement;
64 class HTMLPictureElement;
65 class HTMLSelectElement;
66 class ImageData;
67 class InspectorStubFrontend;
68 class InternalSettings;
69 class MallocStatistics;
70 class MediaSession;
71 class MediaStream;
72 class MediaStreamTrack;
73 class MemoryInfo;
74 class MockCDMFactory;
75 class MockContentFilterSettings;
76 class MockCredentialsMessenger;
77 class MockPageOverlay;
78 class MockPaymentCoordinator;
79 class NodeList;
80 class Page;
81 class RTCPeerConnection;
82 class Range;
83 class RenderedDocumentMarker;
84 class SVGSVGElement;
85 class SerializedScriptValue;
86 class SourceBuffer;
87 class StringCallback;
88 class StyleSheet;
89 class TimeRanges;
90 class TypeConversions;
91 class VoidCallback;
92 class WebGLRenderingContext;
93 class XMLHttpRequest;
94
95 #if ENABLE(SERVICE_WORKER)
96 class ServiceWorker;
97 #endif
98
99 class Internals final : public RefCounted<Internals>, private ContextDestructionObserver
100 #if ENABLE(MEDIA_STREAM)
101     , private RealtimeMediaSource::Observer
102 #endif
103     {
104 public:
105     static Ref<Internals> create(Document&);
106     virtual ~Internals();
107
108     static void resetToConsistentState(Page&);
109
110     ExceptionOr<String> elementRenderTreeAsText(Element&);
111     bool hasPausedImageAnimations(Element&);
112
113     bool isPaintingFrequently(Element&);
114     void incrementFrequentPaintCounter(Element&);
115
116     String address(Node&);
117     bool nodeNeedsStyleRecalc(Node&);
118     String styleChangeType(Node&);
119     String description(JSC::JSValue);
120
121     bool isPreloaded(const String& url);
122     bool isLoadingFromMemoryCache(const String& url);
123     String fetchResponseSource(FetchResponse&);
124     String xhrResponseSource(XMLHttpRequest&);
125     bool isSharingStyleSheetContents(HTMLLinkElement&, HTMLLinkElement&);
126     bool isStyleSheetLoadingSubresources(HTMLLinkElement&);
127     enum class CachePolicy { UseProtocolCachePolicy, ReloadIgnoringCacheData, ReturnCacheDataElseLoad, ReturnCacheDataDontLoad };
128     void setOverrideCachePolicy(CachePolicy);
129     ExceptionOr<void> setCanShowModalDialogOverride(bool allow);
130     enum class ResourceLoadPriority { ResourceLoadPriorityVeryLow, ResourceLoadPriorityLow, ResourceLoadPriorityMedium, ResourceLoadPriorityHigh, ResourceLoadPriorityVeryHigh };
131     void setOverrideResourceLoadPriority(ResourceLoadPriority);
132     void setStrictRawResourceValidationPolicyDisabled(bool);
133
134     void clearMemoryCache();
135     void pruneMemoryCacheToSize(unsigned size);
136     void destroyDecodedDataForAllImages();
137     unsigned memoryCacheSize() const;
138
139     unsigned imageFrameIndex(HTMLImageElement&);
140     void setImageFrameDecodingDuration(HTMLImageElement&, float duration);
141     void resetImageAnimation(HTMLImageElement&);
142     bool isImageAnimating(HTMLImageElement&);
143     void setClearDecoderAfterAsyncFrameRequestForTesting(HTMLImageElement&, bool enabled);
144     unsigned imageDecodeCount(HTMLImageElement&);
145     unsigned pdfDocumentCachingCount(HTMLImageElement&);
146     void setLargeImageAsyncDecodingEnabledForTesting(HTMLImageElement&, bool enabled);
147     void setForceUpdateImageDataEnabledForTesting(HTMLImageElement&, bool enabled);
148
149     void setGridMaxTracksLimit(unsigned);
150
151     void clearPageCache();
152     unsigned pageCacheSize() const;
153
154     void disableTileSizeUpdateDelay();
155
156     void setSpeculativeTilingDelayDisabledForTesting(bool);
157
158     Ref<CSSComputedStyleDeclaration> computedStyleIncludingVisitedInfo(Element&) const;
159
160     Node* ensureUserAgentShadowRoot(Element& host);
161     Node* shadowRoot(Element& host);
162     ExceptionOr<String> shadowRootType(const Node&) const;
163     String shadowPseudoId(Element&);
164     void setShadowPseudoId(Element&, const String&);
165
166     // CSS Deferred Parsing Testing
167     unsigned deferredStyleRulesCount(StyleSheet&);
168     unsigned deferredGroupRulesCount(StyleSheet&);
169     unsigned deferredKeyframesRulesCount(StyleSheet&);
170
171     // DOMTimers throttling testing.
172     ExceptionOr<bool> isTimerThrottled(int timeoutId);
173     bool isRequestAnimationFrameThrottled() const;
174     double requestAnimationFrameInterval() const;
175     bool scriptedAnimationsAreSuspended() const;
176     bool areTimersThrottled() const;
177
178     enum EventThrottlingBehavior { Responsive, Unresponsive };
179     void setEventThrottlingBehaviorOverride(std::optional<EventThrottlingBehavior>);
180     std::optional<EventThrottlingBehavior> eventThrottlingBehaviorOverride() const;
181
182     // Spatial Navigation testing.
183     ExceptionOr<unsigned> lastSpatialNavigationCandidateCount() const;
184
185     // CSS Animation testing.
186     unsigned numberOfActiveAnimations() const;
187     ExceptionOr<bool> animationsAreSuspended() const;
188     ExceptionOr<void> suspendAnimations() const;
189     ExceptionOr<void> resumeAnimations() const;
190     ExceptionOr<bool> pauseAnimationAtTimeOnElement(const String& animationName, double pauseTime, Element&);
191     ExceptionOr<bool> pauseAnimationAtTimeOnPseudoElement(const String& animationName, double pauseTime, Element&, const String& pseudoId);
192     double animationsInterval() const;
193
194     // CSS Transition testing.
195     ExceptionOr<bool> pauseTransitionAtTimeOnElement(const String& propertyName, double pauseTime, Element&);
196     ExceptionOr<bool> pauseTransitionAtTimeOnPseudoElement(const String& property, double pauseTime, Element&, const String& pseudoId);
197
198     // For animations testing, we need a way to get at pseudo elements.
199     ExceptionOr<RefPtr<Element>> pseudoElement(Element&, const String&);
200
201     Node* treeScopeRootNode(Node&);
202     Node* parentTreeScope(Node&);
203
204     String visiblePlaceholder(Element&);
205     void selectColorInColorChooser(HTMLInputElement&, const String& colorValue);
206     ExceptionOr<Vector<String>> formControlStateOfPreviousHistoryItem();
207     ExceptionOr<void> setFormControlStateOfPreviousHistoryItem(const Vector<String>&);
208
209     ExceptionOr<Ref<DOMRect>> absoluteCaretBounds();
210
211     Ref<DOMRect> boundingBox(Element&);
212
213     ExceptionOr<Ref<DOMRectList>> inspectorHighlightRects();
214     ExceptionOr<String> inspectorHighlightObject();
215
216     ExceptionOr<unsigned> markerCountForNode(Node&, const String&);
217     ExceptionOr<RefPtr<Range>> markerRangeForNode(Node&, const String& markerType, unsigned index);
218     ExceptionOr<String> markerDescriptionForNode(Node&, const String& markerType, unsigned index);
219     ExceptionOr<String> dumpMarkerRects(const String& markerType);
220     void addTextMatchMarker(const Range&, bool isActive);
221     ExceptionOr<void> setMarkedTextMatchesAreHighlighted(bool);
222
223     void invalidateFontCache();
224     void setFontSmoothingEnabled(bool);
225
226     ExceptionOr<void> setLowPowerModeEnabled(bool);
227
228     ExceptionOr<void> setScrollViewPosition(int x, int y);
229     ExceptionOr<void> unconstrainedScrollTo(Element&, double x, double y);
230
231     ExceptionOr<Ref<DOMRect>> layoutViewportRect();
232     ExceptionOr<Ref<DOMRect>> visualViewportRect();
233
234     ExceptionOr<void> setViewBaseBackgroundColor(const String& colorValue);
235
236     ExceptionOr<void> setPagination(const String& mode, int gap, int pageLength);
237     ExceptionOr<void> setPaginationLineGridEnabled(bool);
238     ExceptionOr<String> configurationForViewport(float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight);
239
240     ExceptionOr<bool> wasLastChangeUserEdit(Element& textField);
241     bool elementShouldAutoComplete(HTMLInputElement&);
242     void setEditingValue(HTMLInputElement&, const String&);
243     void setAutofilled(HTMLInputElement&, bool enabled);
244     enum class AutoFillButtonType { None, Contacts, Credentials, StrongPassword, StrongConfirmationPassword };
245     void setShowAutoFillButton(HTMLInputElement&, AutoFillButtonType);
246     AutoFillButtonType autoFillButtonType(const HTMLInputElement&);
247     AutoFillButtonType lastAutoFillButtonType(const HTMLInputElement&);
248     ExceptionOr<void> scrollElementToRect(Element&, int x, int y, int w, int h);
249
250     ExceptionOr<String> autofillFieldName(Element&);
251
252     ExceptionOr<void> paintControlTints();
253
254     RefPtr<Range> rangeFromLocationAndLength(Element& scope, int rangeLocation, int rangeLength);
255     unsigned locationFromRange(Element& scope, const Range&);
256     unsigned lengthFromRange(Element& scope, const Range&);
257     String rangeAsText(const Range&);
258     Ref<Range> subrange(Range&, int rangeLocation, int rangeLength);
259     ExceptionOr<RefPtr<Range>> rangeForDictionaryLookupAtLocation(int x, int y);
260     RefPtr<Range> rangeOfStringNearLocation(const Range&, const String&, unsigned);
261
262     ExceptionOr<void> setDelegatesScrolling(bool enabled);
263
264     ExceptionOr<int> lastSpellCheckRequestSequence();
265     ExceptionOr<int> lastSpellCheckProcessedSequence();
266
267     Vector<String> userPreferredLanguages() const;
268     void setUserPreferredLanguages(const Vector<String>&);
269
270     Vector<String> userPreferredAudioCharacteristics() const;
271     void setUserPreferredAudioCharacteristic(const String&);
272
273     ExceptionOr<unsigned> wheelEventHandlerCount();
274     ExceptionOr<unsigned> touchEventHandlerCount();
275
276     ExceptionOr<Ref<DOMRectList>> touchEventRectsForEvent(const String&);
277     ExceptionOr<Ref<DOMRectList>> passiveTouchEventListenerRects();
278
279     ExceptionOr<RefPtr<NodeList>> nodesFromRect(Document&, int x, int y, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowUserAgentShadowContent, bool allowChildFrameContent) const;
280
281     String parserMetaData(JSC::JSValue = JSC::JSValue::JSUndefined);
282
283     void updateEditorUINowIfScheduled();
284
285     bool hasSpellingMarker(int from, int length);
286     bool hasGrammarMarker(int from, int length);
287     bool hasAutocorrectedMarker(int from, int length);
288     void setContinuousSpellCheckingEnabled(bool);
289     void setAutomaticQuoteSubstitutionEnabled(bool);
290     void setAutomaticLinkDetectionEnabled(bool);
291     void setAutomaticDashSubstitutionEnabled(bool);
292     void setAutomaticTextReplacementEnabled(bool);
293     void setAutomaticSpellingCorrectionEnabled(bool);
294
295     void handleAcceptedCandidate(const String& candidate, unsigned location, unsigned length);
296
297     bool isOverwriteModeEnabled();
298     void toggleOverwriteModeEnabled();
299
300     ExceptionOr<RefPtr<Range>> rangeOfString(const String&, RefPtr<Range>&&, const Vector<String>& findOptions);
301     ExceptionOr<unsigned> countMatchesForText(const String&, const Vector<String>& findOptions, const String& markMatches);
302     ExceptionOr<unsigned> countFindMatches(const String&, const Vector<String>& findOptions);
303
304     unsigned numberOfScrollableAreas();
305
306     ExceptionOr<bool> isPageBoxVisible(int pageNumber);
307
308     static const char* internalsId;
309
310     InternalSettings* settings() const;
311     unsigned workerThreadCount() const;
312     ExceptionOr<bool> areSVGAnimationsPaused() const;
313     ExceptionOr<double> svgAnimationsInterval(SVGSVGElement&) const;
314
315     enum {
316         // Values need to be kept in sync with Internals.idl.
317         LAYER_TREE_INCLUDES_VISIBLE_RECTS = 1,
318         LAYER_TREE_INCLUDES_TILE_CACHES = 2,
319         LAYER_TREE_INCLUDES_REPAINT_RECTS = 4,
320         LAYER_TREE_INCLUDES_PAINTING_PHASES = 8,
321         LAYER_TREE_INCLUDES_CONTENT_LAYERS = 16,
322         LAYER_TREE_INCLUDES_ACCELERATES_DRAWING = 32,
323         LAYER_TREE_INCLUDES_BACKING_STORE_ATTACHED = 64,
324     };
325     ExceptionOr<String> layerTreeAsText(Document&, unsigned short flags) const;
326     ExceptionOr<uint64_t> layerIDForElement(Element&);
327     ExceptionOr<String> repaintRectsAsText() const;
328     ExceptionOr<String> scrollingStateTreeAsText() const;
329     ExceptionOr<String> mainThreadScrollingReasons() const;
330     ExceptionOr<Ref<DOMRectList>> nonFastScrollableRects() const;
331
332     ExceptionOr<void> setElementUsesDisplayListDrawing(Element&, bool usesDisplayListDrawing);
333     ExceptionOr<void> setElementTracksDisplayListReplay(Element&, bool isTrackingReplay);
334
335     enum {
336         // Values need to be kept in sync with Internals.idl.
337         DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS = 1,
338     };
339     ExceptionOr<String> displayListForElement(Element&, unsigned short flags);
340     ExceptionOr<String> replayDisplayListForElement(Element&, unsigned short flags);
341
342     ExceptionOr<void> garbageCollectDocumentResources() const;
343
344     void beginSimulatedMemoryPressure();
345     void endSimulatedMemoryPressure();
346     bool isUnderMemoryPressure();
347
348     ExceptionOr<void> insertAuthorCSS(const String&) const;
349     ExceptionOr<void> insertUserCSS(const String&) const;
350
351     unsigned numberOfLiveNodes() const;
352     unsigned numberOfLiveDocuments() const;
353     unsigned referencingNodeCount(const Document&) const;
354
355     RefPtr<WindowProxy> openDummyInspectorFrontend(const String& url);
356     void closeDummyInspectorFrontend();
357     ExceptionOr<void> setInspectorIsUnderTest(bool);
358
359     String counterValue(Element&);
360
361     int pageNumber(Element&, float pageWidth = 800, float pageHeight = 600);
362     Vector<String> shortcutIconURLs() const;
363
364     int numberOfPages(float pageWidthInPixels = 800, float pageHeightInPixels = 600);
365     ExceptionOr<String> pageProperty(const String& propertyName, int pageNumber) const;
366     ExceptionOr<String> pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const;
367
368     ExceptionOr<float> pageScaleFactor() const;
369
370     ExceptionOr<void> setPageScaleFactor(float scaleFactor, int x, int y);
371     ExceptionOr<void> setPageZoomFactor(float);
372     ExceptionOr<void> setTextZoomFactor(float);
373
374     ExceptionOr<void> setUseFixedLayout(bool);
375     ExceptionOr<void> setFixedLayoutSize(int width, int height);
376     ExceptionOr<void> setViewExposedRect(float left, float top, float width, float height);
377     void setPrinting(int width, int height);
378
379     void setHeaderHeight(float);
380     void setFooterHeight(float);
381
382     void setTopContentInset(float);
383
384 #if ENABLE(FULLSCREEN_API)
385     void webkitWillEnterFullScreenForElement(Element&);
386     void webkitDidEnterFullScreenForElement(Element&);
387     void webkitWillExitFullScreenForElement(Element&);
388     void webkitDidExitFullScreenForElement(Element&);
389 #endif
390
391     void setFullscreenInsetTop(double);
392     void setFullscreenAutoHideDelay(double);
393
394     WEBCORE_TESTSUPPORT_EXPORT void setApplicationCacheOriginQuota(unsigned long long);
395
396     void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme);
397     void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme);
398
399     void registerDefaultPortForProtocol(unsigned short port, const String& protocol);
400
401     Ref<MallocStatistics> mallocStatistics() const;
402     Ref<TypeConversions> typeConversions() const;
403     Ref<MemoryInfo> memoryInfo() const;
404
405     Vector<String> getReferencedFilePaths() const;
406
407     ExceptionOr<void> startTrackingRepaints();
408     ExceptionOr<void> stopTrackingRepaints();
409
410     ExceptionOr<void> startTrackingLayerFlushes();
411     ExceptionOr<unsigned> layerFlushCount();
412
413     ExceptionOr<void> startTrackingStyleRecalcs();
414     ExceptionOr<unsigned> styleRecalcCount();
415     unsigned lastStyleUpdateSize() const;
416
417     ExceptionOr<void> startTrackingCompositingUpdates();
418     ExceptionOr<unsigned> compositingUpdateCount();
419
420     ExceptionOr<void> updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*);
421     unsigned layoutCount() const;
422
423     Ref<ArrayBuffer> serializeObject(const RefPtr<SerializedScriptValue>&) const;
424     Ref<SerializedScriptValue> deserializeBuffer(ArrayBuffer&) const;
425
426     bool isFromCurrentWorld(JSC::JSValue) const;
427
428     void setUsesOverlayScrollbars(bool);
429     void setUsesMockScrollAnimator(bool);
430
431     ExceptionOr<String> getCurrentCursorInfo();
432
433     String markerTextForListItem(Element&);
434
435     String toolTipFromElement(Element&) const;
436
437     void forceReload(bool endToEnd);
438     void reloadExpiredOnly();
439
440     void enableAutoSizeMode(bool enabled, int minimumWidth, int minimumHeight, int maximumWidth, int maximumHeight);
441
442 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
443     void initializeMockCDM();
444 #endif
445
446 #if ENABLE(ENCRYPTED_MEDIA)
447     Ref<MockCDMFactory> registerMockCDM();
448 #endif
449
450 #if ENABLE(SPEECH_SYNTHESIS)
451     void enableMockSpeechSynthesizer();
452 #endif
453
454 #if ENABLE(MEDIA_STREAM)
455     void setMockMediaCaptureDevicesEnabled(bool);
456 #endif
457
458 #if ENABLE(WEB_RTC)
459     void emulateRTCPeerConnectionPlatformEvent(RTCPeerConnection&, const String& action);
460     void useMockRTCPeerConnectionFactory(const String&);
461     void setICECandidateFiltering(bool);
462     void setEnumeratingAllNetworkInterfacesEnabled(bool);
463     void stopPeerConnection(RTCPeerConnection&);
464     void applyRotationForOutgoingVideoSources(RTCPeerConnection&);
465 #endif
466
467     String getImageSourceURL(Element&);
468
469 #if ENABLE(VIDEO)
470     Vector<String> mediaResponseSources(HTMLMediaElement&);
471     Vector<String> mediaResponseContentRanges(HTMLMediaElement&);
472     void simulateAudioInterruption(HTMLMediaElement&);
473     ExceptionOr<bool> mediaElementHasCharacteristic(HTMLMediaElement&, const String&);
474     void beginSimulatedHDCPError(HTMLMediaElement&);
475     void endSimulatedHDCPError(HTMLMediaElement&);
476 #endif
477
478     bool isSelectPopupVisible(HTMLSelectElement&);
479
480     ExceptionOr<String> captionsStyleSheetOverride();
481     ExceptionOr<void> setCaptionsStyleSheetOverride(const String&);
482     ExceptionOr<void> setPrimaryAudioTrackLanguageOverride(const String&);
483     ExceptionOr<void> setCaptionDisplayMode(const String&);
484
485 #if ENABLE(VIDEO)
486     Ref<TimeRanges> createTimeRanges(Float32Array& startTimes, Float32Array& endTimes);
487     double closestTimeToTimeRanges(double time, TimeRanges&);
488 #endif
489
490     ExceptionOr<Ref<DOMRect>> selectionBounds();
491
492     ExceptionOr<bool> isPluginUnavailabilityIndicatorObscured(Element&);
493     ExceptionOr<String> unavailablePluginReplacementText(Element&);
494     bool isPluginSnapshotted(Element&);
495
496 #if ENABLE(MEDIA_SOURCE)
497     WEBCORE_TESTSUPPORT_EXPORT void initializeMockMediaSource();
498     Vector<String> bufferedSamplesForTrackID(SourceBuffer&, const AtomicString&);
499     Vector<String> enqueuedSamplesForTrackID(SourceBuffer&, const AtomicString&);
500     void setShouldGenerateTimestamps(SourceBuffer&, bool);
501 #endif
502
503 #if ENABLE(VIDEO)
504     ExceptionOr<void> beginMediaSessionInterruption(const String&);
505     void endMediaSessionInterruption(const String&);
506     void applicationWillBecomeInactive();
507     void applicationDidBecomeActive();
508     void applicationWillEnterForeground(bool suspendedUnderLock) const;
509     void applicationDidEnterBackground(bool suspendedUnderLock) const;
510     ExceptionOr<void> setMediaSessionRestrictions(const String& mediaType, StringView restrictionsString);
511     ExceptionOr<String> mediaSessionRestrictions(const String& mediaType) const;
512     void setMediaElementRestrictions(HTMLMediaElement&, StringView restrictionsString);
513     ExceptionOr<void> postRemoteControlCommand(const String&, float argument);
514     bool elementIsBlockingDisplaySleep(HTMLMediaElement&) const;
515 #endif
516
517 #if ENABLE(MEDIA_SESSION)
518     void sendMediaSessionStartOfInterruptionNotification(MediaSessionInterruptingCategory);
519     void sendMediaSessionEndOfInterruptionNotification(MediaSessionInterruptingCategory);
520     String mediaSessionCurrentState(MediaSession&) const;
521     double mediaElementPlayerVolume(HTMLMediaElement&) const;
522     enum class MediaControlEvent { PlayPause, NextTrack, PreviousTrack };
523     void sendMediaControlEvent(MediaControlEvent);
524 #endif
525
526 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
527     void setMockMediaPlaybackTargetPickerEnabled(bool);
528     ExceptionOr<void> setMockMediaPlaybackTargetPickerState(const String& deviceName, const String& deviceState);
529 #endif
530
531 #if ENABLE(WEB_AUDIO)
532     void setAudioContextRestrictions(AudioContext&, StringView restrictionsString);
533 #endif
534
535     void simulateSystemSleep() const;
536     void simulateSystemWake() const;
537
538     enum class PageOverlayType { View, Document };
539     ExceptionOr<Ref<MockPageOverlay>> installMockPageOverlay(PageOverlayType);
540     ExceptionOr<String> pageOverlayLayerTreeAsText(unsigned short flags) const;
541
542     void setPageMuted(StringView);
543     String pageMediaState();
544
545     void setPageDefersLoading(bool);
546     ExceptionOr<bool> pageDefersLoading();
547
548     RefPtr<File> createFile(const String&);
549     void queueMicroTask(int);
550     bool testPreloaderSettingViewport();
551
552 #if ENABLE(CONTENT_FILTERING)
553     MockContentFilterSettings& mockContentFilterSettings();
554 #endif
555
556 #if ENABLE(CSS_SCROLL_SNAP)
557     ExceptionOr<String> scrollSnapOffsets(Element&);
558     void setPlatformMomentumScrollingPredictionEnabled(bool);
559 #endif
560
561     ExceptionOr<String> pathStringWithShrinkWrappedRects(const Vector<double>& rectComponents, double radius);
562
563     String getCurrentMediaControlsStatusForElement(HTMLMediaElement&);
564
565     String userVisibleString(const DOMURL&);
566     void setShowAllPlugins(bool);
567
568     String resourceLoadStatisticsForOrigin(const String& origin);
569     void setResourceLoadStatisticsEnabled(bool);
570     void setUserGrantsStorageAccess(bool);
571
572 #if ENABLE(STREAMS_API)
573     bool isReadableStreamDisturbed(JSC::ExecState&, JSC::JSValue);
574     JSC::JSValue cloneArrayBuffer(JSC::ExecState&, JSC::JSValue, JSC::JSValue, JSC::JSValue);
575 #endif
576
577     String composedTreeAsText(Node&);
578
579     bool isProcessingUserGesture();
580     double lastHandledUserGestureTimestamp();
581
582     void withUserGesture(RefPtr<VoidCallback>&&);
583
584     RefPtr<GCObservation> observeGC(JSC::JSValue);
585
586     enum class UserInterfaceLayoutDirection { LTR, RTL };
587     void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection);
588
589     bool userPrefersReducedMotion() const;
590
591     void reportBacktrace();
592
593     enum class BaseWritingDirection { Natural, Ltr, Rtl };
594     void setBaseWritingDirection(BaseWritingDirection);
595
596 #if ENABLE(POINTER_LOCK)
597     bool pageHasPendingPointerLock() const;
598     bool pageHasPointerLock() const;
599 #endif
600
601     Vector<String> accessKeyModifiers() const;
602
603     void setQuickLookPassword(const String&);
604
605     void setAsRunningUserScripts(Document&);
606
607 #if ENABLE(WEBGL)
608     void simulateWebGLContextChanged(WebGLRenderingContext&);
609     void failNextGPUStatusCheck(WebGLRenderingContext&);
610 #endif
611
612     void setPageVisibility(bool isVisible);
613
614 #if ENABLE(WEB_RTC)
615     void setH264HardwareEncoderAllowed(bool allowed);
616 #endif
617
618 #if ENABLE(MEDIA_STREAM)
619     void setCameraMediaStreamTrackOrientation(MediaStreamTrack&, int orientation);
620     ExceptionOr<void> setMediaDeviceState(const String& id, const String& property, bool value);
621     unsigned long trackAudioSampleCount() const { return m_trackAudioSampleCount; }
622     unsigned long trackVideoSampleCount() const { return m_trackVideoSampleCount; }
623     void observeMediaStreamTrack(MediaStreamTrack&);
624     using TrackFramePromise = DOMPromiseDeferred<IDLInterface<ImageData>>;
625     void grabNextMediaStreamTrackFrame(TrackFramePromise&&);
626     void delayMediaStreamTrackSamples(MediaStreamTrack&, float);
627     void setMediaStreamTrackMuted(MediaStreamTrack&, bool);
628     void removeMediaStreamTrack(MediaStream&, MediaStreamTrack&);
629     void simulateMediaStreamTrackCaptureSourceFailure(MediaStreamTrack&);
630     void setMediaStreamTrackIdentifier(MediaStreamTrack&, String&& id);
631 #endif
632
633     String audioSessionCategory() const;
634
635     void clearCacheStorageMemoryRepresentation(DOMPromiseDeferred<void>&&);
636     void cacheStorageEngineRepresentation(DOMPromiseDeferred<IDLDOMString>&&);
637     void setResponseSizeWithPadding(FetchResponse&, uint64_t size);
638     uint64_t responseSizeWithPadding(FetchResponse&) const;
639
640     void setConsoleMessageListener(RefPtr<StringCallback>&&);
641
642 #if ENABLE(SERVICE_WORKER)
643     using HasRegistrationPromise = DOMPromiseDeferred<IDLBoolean>;
644     void hasServiceWorkerRegistration(const String& clientURL, HasRegistrationPromise&&);
645     void terminateServiceWorker(ServiceWorker&);
646     bool hasServiceWorkerConnection();
647 #endif
648
649 #if ENABLE(APPLE_PAY)
650     MockPaymentCoordinator& mockPaymentCoordinator() const;
651 #endif
652
653     String timelineDescription(AnimationTimeline&);
654     void pauseTimeline(AnimationTimeline&);
655     void setTimelineCurrentTime(AnimationTimeline&, double);
656
657     void testIncomingSyncIPCMessageWhileWaitingForSyncReply();
658
659 #if ENABLE(WEB_AUTHN)
660     MockCredentialsMessenger& mockCredentialsMessenger() const;
661 #endif
662
663     String systemPreviewRelType();
664     bool isSystemPreviewLink(Element&) const;
665     bool isSystemPreviewImage(Element&) const;
666
667     bool usingAppleInternalSDK() const;
668
669 private:
670     explicit Internals(Document&);
671     Document* contextDocument() const;
672     Frame* frame() const;
673
674     ExceptionOr<RenderedDocumentMarker*> markerAt(Node&, const String& markerType, unsigned index);
675
676     // RealtimeMediaSource::Observer API
677 #if ENABLE(MEDIA_STREAM)
678     void videoSampleAvailable(MediaSample&) final;
679     void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final { m_trackAudioSampleCount++; }
680
681     OrientationNotifier m_orientationNotifier;
682     unsigned long m_trackVideoSampleCount { 0 };
683     unsigned long m_trackAudioSampleCount { 0 };
684     RefPtr<MediaStreamTrack> m_track;
685     std::optional<TrackFramePromise> m_nextTrackFramePromise;
686 #endif
687
688     std::unique_ptr<InspectorStubFrontend> m_inspectorFrontend;
689     RefPtr<CacheStorageConnection> m_cacheStorageConnection;
690
691 #if ENABLE(APPLE_PAY)
692     MockPaymentCoordinator* m_mockPaymentCoordinator { nullptr };
693 #endif
694
695 #if ENABLE(WEB_AUTHN)
696     std::unique_ptr<MockCredentialsMessenger> m_mockCredentialsMessenger;
697 #endif
698 };
699
700 } // namespace WebCore