REGRESSION (AsyncImageDecoding): A tab with the WWDC keynote paused is killed for...
[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 <runtime/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 AudioContext;
46 class DOMRect;
47 class DOMRectList;
48 class DOMURL;
49 class DOMWindow;
50 class Document;
51 class Element;
52 class File;
53 class Frame;
54 class GCObservation;
55 class HTMLImageElement;
56 class HTMLInputElement;
57 class HTMLLinkElement;
58 class HTMLMediaElement;
59 class HTMLSelectElement;
60 class ImageData;
61 class InspectorStubFrontend;
62 class InternalSettings;
63 class MallocStatistics;
64 class MediaSession;
65 class MediaStream;
66 class MediaStreamTrack;
67 class MemoryInfo;
68 class MockCDMFactory;
69 class MockContentFilterSettings;
70 class MockPageOverlay;
71 class NodeList;
72 class Page;
73 class Range;
74 class RenderedDocumentMarker;
75 class RTCPeerConnection;
76 class SVGSVGElement;
77 class SerializedScriptValue;
78 class SourceBuffer;
79 class StyleSheet;
80 class TimeRanges;
81 class TypeConversions;
82 class WebGLRenderingContext;
83 class XMLHttpRequest;
84
85 class Internals final : public RefCounted<Internals>,  private ContextDestructionObserver
86 #if ENABLE(MEDIA_STREAM)
87     , private RealtimeMediaSource::Observer
88 #endif
89     {
90 public:
91     static Ref<Internals> create(Document&);
92     virtual ~Internals();
93
94     static void resetToConsistentState(Page&);
95
96     ExceptionOr<String> elementRenderTreeAsText(Element&);
97     bool hasPausedImageAnimations(Element&);
98
99     String address(Node&);
100     bool nodeNeedsStyleRecalc(Node&);
101     String styleChangeType(Node&);
102     String description(JSC::JSValue);
103
104     bool isPreloaded(const String& url);
105     bool isLoadingFromMemoryCache(const String& url);
106     String xhrResponseSource(XMLHttpRequest&);
107     Vector<String> mediaResponseSources(HTMLMediaElement&);
108     Vector<String> mediaResponseContentRanges(HTMLMediaElement&);
109     bool isSharingStyleSheetContents(HTMLLinkElement&, HTMLLinkElement&);
110     bool isStyleSheetLoadingSubresources(HTMLLinkElement&);
111     enum class CachePolicy { UseProtocolCachePolicy, ReloadIgnoringCacheData, ReturnCacheDataElseLoad, ReturnCacheDataDontLoad };
112     void setOverrideCachePolicy(CachePolicy);
113     ExceptionOr<void> setCanShowModalDialogOverride(bool allow);
114     enum class ResourceLoadPriority { ResourceLoadPriorityVeryLow, ResourceLoadPriorityLow, ResourceLoadPriorityMedium, ResourceLoadPriorityHigh, ResourceLoadPriorityVeryHigh };
115     void setOverrideResourceLoadPriority(ResourceLoadPriority);
116     void setStrictRawResourceValidationPolicyDisabled(bool);
117
118     void clearMemoryCache();
119     void pruneMemoryCacheToSize(unsigned size);
120     void destroyDecodedDataForAllImages();
121     unsigned memoryCacheSize() const;
122
123     unsigned imageFrameIndex(HTMLImageElement&);
124     void setImageFrameDecodingDuration(HTMLImageElement&, float duration);
125     void resetImageAnimation(HTMLImageElement&);
126     bool isImageAnimating(HTMLImageElement&);
127     void setClearDecoderAfterAsyncFrameRequestForTesting(HTMLImageElement&, bool);
128     unsigned imageDecodeCount(HTMLImageElement&);
129
130     void setGridMaxTracksLimit(unsigned);
131
132     void clearPageCache();
133     unsigned pageCacheSize() const;
134
135     void disableTileSizeUpdateDelay();
136
137     void setSpeculativeTilingDelayDisabledForTesting(bool);
138
139     Ref<CSSComputedStyleDeclaration> computedStyleIncludingVisitedInfo(Element&) const;
140
141     Node* ensureUserAgentShadowRoot(Element& host);
142     Node* shadowRoot(Element& host);
143     ExceptionOr<String> shadowRootType(const Node&) const;
144     String shadowPseudoId(Element&);
145     void setShadowPseudoId(Element&, const String&);
146
147     // CSS Deferred Parsing Testing
148     unsigned deferredStyleRulesCount(StyleSheet&);
149     unsigned deferredGroupRulesCount(StyleSheet&);
150     unsigned deferredKeyframesRulesCount(StyleSheet&);
151
152     // DOMTimers throttling testing.
153     ExceptionOr<bool> isTimerThrottled(int timeoutId);
154     bool isRequestAnimationFrameThrottled() const;
155     double requestAnimationFrameInterval() const;
156     bool scriptedAnimationsAreSuspended() const;
157     bool areTimersThrottled() const;
158
159     enum EventThrottlingBehavior { Responsive, Unresponsive };
160     void setEventThrottlingBehaviorOverride(std::optional<EventThrottlingBehavior>);
161     std::optional<EventThrottlingBehavior> eventThrottlingBehaviorOverride() const;
162
163     // Spatial Navigation testing.
164     ExceptionOr<unsigned> lastSpatialNavigationCandidateCount() const;
165
166     // CSS Animation testing.
167     unsigned numberOfActiveAnimations() const;
168     ExceptionOr<bool> animationsAreSuspended() const;
169     ExceptionOr<void> suspendAnimations() const;
170     ExceptionOr<void> resumeAnimations() const;
171     ExceptionOr<bool> pauseAnimationAtTimeOnElement(const String& animationName, double pauseTime, Element&);
172     ExceptionOr<bool> pauseAnimationAtTimeOnPseudoElement(const String& animationName, double pauseTime, Element&, const String& pseudoId);
173     double animationsInterval() const;
174
175     // CSS Transition testing.
176     ExceptionOr<bool> pauseTransitionAtTimeOnElement(const String& propertyName, double pauseTime, Element&);
177     ExceptionOr<bool> pauseTransitionAtTimeOnPseudoElement(const String& property, double pauseTime, Element&, const String& pseudoId);
178
179     Node* treeScopeRootNode(Node&);
180     Node* parentTreeScope(Node&);
181
182     String visiblePlaceholder(Element&);
183     void selectColorInColorChooser(HTMLInputElement&, const String& colorValue);
184     ExceptionOr<Vector<String>> formControlStateOfPreviousHistoryItem();
185     ExceptionOr<void> setFormControlStateOfPreviousHistoryItem(const Vector<String>&);
186
187     ExceptionOr<Ref<DOMRect>> absoluteCaretBounds();
188
189     Ref<DOMRect> boundingBox(Element&);
190
191     ExceptionOr<Ref<DOMRectList>> inspectorHighlightRects();
192     ExceptionOr<String> inspectorHighlightObject();
193
194     ExceptionOr<unsigned> markerCountForNode(Node&, const String&);
195     ExceptionOr<RefPtr<Range>> markerRangeForNode(Node&, const String& markerType, unsigned index);
196     ExceptionOr<String> markerDescriptionForNode(Node&, const String& markerType, unsigned index);
197     ExceptionOr<String> dumpMarkerRects(const String& markerType);
198     void addTextMatchMarker(const Range&, bool isActive);
199     ExceptionOr<void> setMarkedTextMatchesAreHighlighted(bool);
200
201     void invalidateFontCache();
202     void setFontSmoothingEnabled(bool);
203
204     ExceptionOr<void> setLowPowerModeEnabled(bool);
205
206     ExceptionOr<void> setScrollViewPosition(int x, int y);
207
208     ExceptionOr<Ref<DOMRect>> layoutViewportRect();
209     ExceptionOr<Ref<DOMRect>> visualViewportRect();
210
211     ExceptionOr<void> setViewBaseBackgroundColor(const String& colorValue);
212
213     ExceptionOr<void> setPagination(const String& mode, int gap, int pageLength);
214     ExceptionOr<void> setPaginationLineGridEnabled(bool);
215     ExceptionOr<String> configurationForViewport(float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight);
216
217     ExceptionOr<bool> wasLastChangeUserEdit(Element& textField);
218     bool elementShouldAutoComplete(HTMLInputElement&);
219     void setEditingValue(HTMLInputElement&, const String&);
220     void setAutofilled(HTMLInputElement&, bool enabled);
221     enum class AutoFillButtonType { AutoFillButtonTypeNone, AutoFillButtonTypeContacts, AutoFillButtonTypeCredentials };
222     void setShowAutoFillButton(HTMLInputElement&, AutoFillButtonType);
223     ExceptionOr<void> scrollElementToRect(Element&, int x, int y, int w, int h);
224
225     ExceptionOr<String> autofillFieldName(Element&);
226
227     ExceptionOr<void> paintControlTints();
228
229     RefPtr<Range> rangeFromLocationAndLength(Element& scope, int rangeLocation, int rangeLength);
230     unsigned locationFromRange(Element& scope, const Range&);
231     unsigned lengthFromRange(Element& scope, const Range&);
232     String rangeAsText(const Range&);
233     Ref<Range> subrange(Range&, int rangeLocation, int rangeLength);
234     ExceptionOr<RefPtr<Range>> rangeForDictionaryLookupAtLocation(int x, int y);
235     RefPtr<Range> rangeOfStringNearLocation(const Range&, const String&, unsigned);
236
237     ExceptionOr<void> setDelegatesScrolling(bool enabled);
238
239     ExceptionOr<int> lastSpellCheckRequestSequence();
240     ExceptionOr<int> lastSpellCheckProcessedSequence();
241
242     Vector<String> userPreferredLanguages() const;
243     void setUserPreferredLanguages(const Vector<String>&);
244
245     Vector<String> userPreferredAudioCharacteristics() const;
246     void setUserPreferredAudioCharacteristic(const String&);
247
248     ExceptionOr<unsigned> wheelEventHandlerCount();
249     ExceptionOr<unsigned> touchEventHandlerCount();
250
251     ExceptionOr<Ref<DOMRectList>> touchEventRectsForEvent(const String&);
252     ExceptionOr<Ref<DOMRectList>> passiveTouchEventListenerRects();
253
254     ExceptionOr<RefPtr<NodeList>> nodesFromRect(Document&, int x, int y, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowShadowContent, bool allowChildFrameContent) const;
255
256     String parserMetaData(JSC::JSValue = JSC::JSValue::JSUndefined);
257
258     void updateEditorUINowIfScheduled();
259
260     bool hasSpellingMarker(int from, int length);
261     bool hasGrammarMarker(int from, int length);
262     bool hasAutocorrectedMarker(int from, int length);
263     void setContinuousSpellCheckingEnabled(bool);
264     void setAutomaticQuoteSubstitutionEnabled(bool);
265     void setAutomaticLinkDetectionEnabled(bool);
266     void setAutomaticDashSubstitutionEnabled(bool);
267     void setAutomaticTextReplacementEnabled(bool);
268     void setAutomaticSpellingCorrectionEnabled(bool);
269
270     void handleAcceptedCandidate(const String& candidate, unsigned location, unsigned length);
271
272     bool isOverwriteModeEnabled();
273     void toggleOverwriteModeEnabled();
274
275     ExceptionOr<RefPtr<Range>> rangeOfString(const String&, RefPtr<Range>&&, const Vector<String>& findOptions);
276     ExceptionOr<unsigned> countMatchesForText(const String&, const Vector<String>& findOptions, const String& markMatches);
277     ExceptionOr<unsigned> countFindMatches(const String&, const Vector<String>& findOptions);
278
279     unsigned numberOfScrollableAreas();
280
281     ExceptionOr<bool> isPageBoxVisible(int pageNumber);
282
283     static const char* internalsId;
284
285     InternalSettings* settings() const;
286     unsigned workerThreadCount() const;
287     ExceptionOr<bool> areSVGAnimationsPaused() const;
288     ExceptionOr<double> svgAnimationsInterval(SVGSVGElement&) const;
289
290     ExceptionOr<void> setDeviceProximity(const String& eventType, double value, double min, double max);
291
292     enum {
293         // Values need to be kept in sync with Internals.idl.
294         LAYER_TREE_INCLUDES_VISIBLE_RECTS = 1,
295         LAYER_TREE_INCLUDES_TILE_CACHES = 2,
296         LAYER_TREE_INCLUDES_REPAINT_RECTS = 4,
297         LAYER_TREE_INCLUDES_PAINTING_PHASES = 8,
298         LAYER_TREE_INCLUDES_CONTENT_LAYERS = 16,
299         LAYER_TREE_INCLUDES_ACCELERATES_DRAWING = 32,
300         LAYER_TREE_INCLUDES_BACKING_STORE_ATTACHED = 64,
301     };
302     ExceptionOr<String> layerTreeAsText(Document&, unsigned short flags) const;
303     ExceptionOr<uint64_t> layerIDForElement(Element&);
304     ExceptionOr<String> repaintRectsAsText() const;
305     ExceptionOr<String> scrollingStateTreeAsText() const;
306     ExceptionOr<String> mainThreadScrollingReasons() const;
307     ExceptionOr<Ref<DOMRectList>> nonFastScrollableRects() const;
308
309     ExceptionOr<void> setElementUsesDisplayListDrawing(Element&, bool usesDisplayListDrawing);
310     ExceptionOr<void> setElementTracksDisplayListReplay(Element&, bool isTrackingReplay);
311
312     enum {
313         // Values need to be kept in sync with Internals.idl.
314         DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS = 1,
315     };
316     ExceptionOr<String> displayListForElement(Element&, unsigned short flags);
317     ExceptionOr<String> replayDisplayListForElement(Element&, unsigned short flags);
318
319     ExceptionOr<void> garbageCollectDocumentResources() const;
320
321     void beginSimulatedMemoryPressure();
322     void endSimulatedMemoryPressure();
323     bool isUnderMemoryPressure();
324
325     ExceptionOr<void> insertAuthorCSS(const String&) const;
326     ExceptionOr<void> insertUserCSS(const String&) const;
327
328     unsigned numberOfLiveNodes() const;
329     unsigned numberOfLiveDocuments() const;
330     unsigned referencingNodeCount(const Document&) const;
331
332     RefPtr<DOMWindow> openDummyInspectorFrontend(const String& url);
333     void closeDummyInspectorFrontend();
334     ExceptionOr<void> setInspectorIsUnderTest(bool);
335
336     String counterValue(Element&);
337
338     int pageNumber(Element&, float pageWidth = 800, float pageHeight = 600);
339     Vector<String> shortcutIconURLs() const;
340
341     int numberOfPages(float pageWidthInPixels = 800, float pageHeightInPixels = 600);
342     ExceptionOr<String> pageProperty(const String& propertyName, int pageNumber) const;
343     ExceptionOr<String> pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const;
344
345     ExceptionOr<float> pageScaleFactor() const;
346
347     ExceptionOr<void> setPageScaleFactor(float scaleFactor, int x, int y);
348     ExceptionOr<void> setPageZoomFactor(float);
349     ExceptionOr<void> setTextZoomFactor(float);
350
351     ExceptionOr<void> setUseFixedLayout(bool);
352     ExceptionOr<void> setFixedLayoutSize(int width, int height);
353     ExceptionOr<void> setViewExposedRect(float left, float top, float width, float height);
354     void setPrinting(int width, int height);
355
356     void setHeaderHeight(float);
357     void setFooterHeight(float);
358
359     void setTopContentInset(float);
360
361 #if ENABLE(FULLSCREEN_API)
362     void webkitWillEnterFullScreenForElement(Element&);
363     void webkitDidEnterFullScreenForElement(Element&);
364     void webkitWillExitFullScreenForElement(Element&);
365     void webkitDidExitFullScreenForElement(Element&);
366 #endif
367
368     WEBCORE_TESTSUPPORT_EXPORT void setApplicationCacheOriginQuota(unsigned long long);
369
370     void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme);
371     void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme);
372
373     void registerDefaultPortForProtocol(unsigned short port, const String& protocol);
374
375     Ref<MallocStatistics> mallocStatistics() const;
376     Ref<TypeConversions> typeConversions() const;
377     Ref<MemoryInfo> memoryInfo() const;
378
379     Vector<String> getReferencedFilePaths() const;
380
381     ExceptionOr<void> startTrackingRepaints();
382     ExceptionOr<void> stopTrackingRepaints();
383
384     ExceptionOr<void> startTrackingLayerFlushes();
385     ExceptionOr<unsigned> layerFlushCount();
386
387     ExceptionOr<void> startTrackingStyleRecalcs();
388     ExceptionOr<unsigned> styleRecalcCount();
389     unsigned lastStyleUpdateSize() const;
390
391     ExceptionOr<void> startTrackingCompositingUpdates();
392     ExceptionOr<unsigned> compositingUpdateCount();
393
394     ExceptionOr<void> updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*);
395     unsigned layoutCount() const;
396
397     Ref<ArrayBuffer> serializeObject(const RefPtr<SerializedScriptValue>&) const;
398     Ref<SerializedScriptValue> deserializeBuffer(ArrayBuffer&) const;
399
400     bool isFromCurrentWorld(JSC::JSValue) const;
401
402     void setUsesOverlayScrollbars(bool);
403     void setUsesMockScrollAnimator(bool);
404
405     ExceptionOr<String> getCurrentCursorInfo();
406
407     String markerTextForListItem(Element&);
408
409     String toolTipFromElement(Element&) const;
410
411     void forceReload(bool endToEnd);
412     void reloadExpiredOnly();
413
414     void enableAutoSizeMode(bool enabled, int minimumWidth, int minimumHeight, int maximumWidth, int maximumHeight);
415
416 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
417     void initializeMockCDM();
418 #endif
419
420 #if ENABLE(ENCRYPTED_MEDIA)
421     Ref<MockCDMFactory> registerMockCDM();
422 #endif
423
424 #if ENABLE(SPEECH_SYNTHESIS)
425     void enableMockSpeechSynthesizer();
426 #endif
427
428 #if ENABLE(MEDIA_STREAM)
429     void setMockMediaCaptureDevicesEnabled(bool);
430 #endif
431
432 #if ENABLE(WEB_RTC)
433 #if USE(OPENWEBRTC)
434     void enableMockMediaEndpoint();
435 #endif
436     void emulateRTCPeerConnectionPlatformEvent(RTCPeerConnection&, const String& action);
437     void useMockRTCPeerConnectionFactory(const String&);
438     void setICECandidateFiltering(bool);
439     void setEnumeratingAllNetworkInterfacesEnabled(bool);
440     void stopPeerConnection(RTCPeerConnection&);
441     void applyRotationForOutgoingVideoSources(RTCPeerConnection&);
442 #endif
443
444     String getImageSourceURL(Element&);
445
446 #if ENABLE(VIDEO)
447     void simulateAudioInterruption(HTMLMediaElement&);
448     ExceptionOr<bool> mediaElementHasCharacteristic(HTMLMediaElement&, const String&);
449 #endif
450
451     bool isSelectPopupVisible(HTMLSelectElement&);
452
453     ExceptionOr<String> captionsStyleSheetOverride();
454     ExceptionOr<void> setCaptionsStyleSheetOverride(const String&);
455     ExceptionOr<void> setPrimaryAudioTrackLanguageOverride(const String&);
456     ExceptionOr<void> setCaptionDisplayMode(const String&);
457
458 #if ENABLE(VIDEO)
459     Ref<TimeRanges> createTimeRanges(Float32Array& startTimes, Float32Array& endTimes);
460     double closestTimeToTimeRanges(double time, TimeRanges&);
461 #endif
462
463     ExceptionOr<Ref<DOMRect>> selectionBounds();
464
465     ExceptionOr<bool> isPluginUnavailabilityIndicatorObscured(Element&);
466     bool isPluginSnapshotted(Element&);
467
468 #if ENABLE(MEDIA_SOURCE)
469     WEBCORE_TESTSUPPORT_EXPORT void initializeMockMediaSource();
470     Vector<String> bufferedSamplesForTrackID(SourceBuffer&, const AtomicString&);
471     Vector<String> enqueuedSamplesForTrackID(SourceBuffer&, const AtomicString&);
472     void setShouldGenerateTimestamps(SourceBuffer&, bool);
473 #endif
474
475 #if ENABLE(VIDEO)
476     ExceptionOr<void> beginMediaSessionInterruption(const String&);
477     void endMediaSessionInterruption(const String&);
478     void applicationWillBecomeInactive();
479     void applicationDidBecomeActive();
480     void applicationWillEnterForeground(bool suspendedUnderLock) const;
481     void applicationDidEnterBackground(bool suspendedUnderLock) const;
482     ExceptionOr<void> setMediaSessionRestrictions(const String& mediaType, StringView restrictionsString);
483     ExceptionOr<String> mediaSessionRestrictions(const String& mediaType) const;
484     void setMediaElementRestrictions(HTMLMediaElement&, StringView restrictionsString);
485     ExceptionOr<void> postRemoteControlCommand(const String&, float argument);
486     bool elementIsBlockingDisplaySleep(HTMLMediaElement&) const;
487 #endif
488
489 #if ENABLE(MEDIA_SESSION)
490     void sendMediaSessionStartOfInterruptionNotification(MediaSessionInterruptingCategory);
491     void sendMediaSessionEndOfInterruptionNotification(MediaSessionInterruptingCategory);
492     String mediaSessionCurrentState(MediaSession&) const;
493     double mediaElementPlayerVolume(HTMLMediaElement&) const;
494     enum class MediaControlEvent { PlayPause, NextTrack, PreviousTrack };
495     void sendMediaControlEvent(MediaControlEvent);
496 #endif
497
498 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
499     void setMockMediaPlaybackTargetPickerEnabled(bool);
500     ExceptionOr<void> setMockMediaPlaybackTargetPickerState(const String& deviceName, const String& deviceState);
501 #endif
502
503 #if ENABLE(WEB_AUDIO)
504     void setAudioContextRestrictions(AudioContext&, StringView restrictionsString);
505 #endif
506
507     void simulateSystemSleep() const;
508     void simulateSystemWake() const;
509
510     enum class PageOverlayType { View, Document };
511     ExceptionOr<Ref<MockPageOverlay>> installMockPageOverlay(PageOverlayType);
512     ExceptionOr<String> pageOverlayLayerTreeAsText(unsigned short flags) const;
513
514     void setPageMuted(StringView);
515     String pageMediaState();
516
517     void setPageDefersLoading(bool);
518
519     RefPtr<File> createFile(const String&);
520     void queueMicroTask(int);
521     bool testPreloaderSettingViewport();
522
523 #if ENABLE(CONTENT_FILTERING)
524     MockContentFilterSettings& mockContentFilterSettings();
525 #endif
526
527 #if ENABLE(CSS_SCROLL_SNAP)
528     ExceptionOr<String> scrollSnapOffsets(Element&);
529     void setPlatformMomentumScrollingPredictionEnabled(bool);
530 #endif
531
532     ExceptionOr<String> pathStringWithShrinkWrappedRects(const Vector<double>& rectComponents, double radius);
533
534     String getCurrentMediaControlsStatusForElement(HTMLMediaElement&);
535
536     String userVisibleString(const DOMURL&);
537     void setShowAllPlugins(bool);
538
539     String resourceLoadStatisticsForOrigin(const String& origin);
540     void setResourceLoadStatisticsEnabled(bool);
541
542 #if ENABLE(STREAMS_API)
543     bool isReadableStreamDisturbed(JSC::ExecState&, JSC::JSValue);
544     JSC::JSValue cloneArrayBuffer(JSC::ExecState&, JSC::JSValue, JSC::JSValue, JSC::JSValue);
545 #endif
546
547     String composedTreeAsText(Node&);
548
549     bool isProcessingUserGesture();
550     double lastHandledUserGestureTimestamp();
551
552     RefPtr<GCObservation> observeGC(JSC::JSValue);
553
554     enum class UserInterfaceLayoutDirection { LTR, RTL };
555     void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection);
556
557     bool userPrefersReducedMotion() const;
558
559     void reportBacktrace();
560
561     enum class BaseWritingDirection { Natural, Ltr, Rtl };
562     void setBaseWritingDirection(BaseWritingDirection);
563
564 #if ENABLE(POINTER_LOCK)
565     bool pageHasPendingPointerLock() const;
566     bool pageHasPointerLock() const;
567 #endif
568
569     Vector<String> accessKeyModifiers() const;
570
571 #if PLATFORM(IOS)
572     void setQuickLookPassword(const String&);
573 #endif
574
575     void setAsRunningUserScripts(Document&);
576
577 #if ENABLE(WEBGL)
578     void simulateWebGLContextChanged(WebGLRenderingContext&);
579     void failNextGPUStatusCheck(WebGLRenderingContext&);
580 #endif
581
582     void setPageVisibility(bool isVisible);
583
584 #if ENABLE(WEB_RTC)
585     void setH264HardwareEncoderAllowed(bool allowed);
586 #endif
587
588 #if ENABLE(MEDIA_STREAM)
589     void setCameraMediaStreamTrackOrientation(MediaStreamTrack&, int orientation);
590     ExceptionOr<void> setMediaDeviceState(const String& id, const String& property, bool value);
591     unsigned long trackAudioSampleCount() const { return m_trackAudioSampleCount; }
592     unsigned long trackVideoSampleCount() const { return m_trackVideoSampleCount; }
593     void observeMediaStreamTrack(MediaStreamTrack&);
594     using TrackFramePromise = DOMPromiseDeferred<IDLInterface<ImageData>>;
595     void grabNextMediaStreamTrackFrame(TrackFramePromise&&);
596     void delayMediaStreamTrackSamples(MediaStreamTrack&, float);
597     void setMediaStreamTrackMuted(MediaStreamTrack&, bool);
598     void removeMediaStreamTrack(MediaStream&, MediaStreamTrack&);
599 #endif
600
601     String audioSessionCategory() const;
602
603 private:
604     explicit Internals(Document&);
605     Document* contextDocument() const;
606     Frame* frame() const;
607
608     ExceptionOr<RenderedDocumentMarker*> markerAt(Node&, const String& markerType, unsigned index);
609
610     // RealtimeMediaSource::Observer API
611 #if ENABLE(MEDIA_STREAM)
612     void videoSampleAvailable(MediaSample&) final;
613     void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final { m_trackAudioSampleCount++; }
614
615     OrientationNotifier m_orientationNotifier;
616     unsigned long m_trackVideoSampleCount { 0 };
617     unsigned long m_trackAudioSampleCount { 0 };
618     RefPtr<MediaStreamTrack> m_track;
619     std::optional<TrackFramePromise> m_nextTrackFramePromise;
620 #endif
621
622     std::unique_ptr<InspectorStubFrontend> m_inspectorFrontend;
623 };
624
625 } // namespace WebCore