Fix broken build when ENABLE_VIDEO is disabled.
[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     bool isSharingStyleSheetContents(HTMLLinkElement&, HTMLLinkElement&);
108     bool isStyleSheetLoadingSubresources(HTMLLinkElement&);
109     enum class CachePolicy { UseProtocolCachePolicy, ReloadIgnoringCacheData, ReturnCacheDataElseLoad, ReturnCacheDataDontLoad };
110     void setOverrideCachePolicy(CachePolicy);
111     ExceptionOr<void> setCanShowModalDialogOverride(bool allow);
112     enum class ResourceLoadPriority { ResourceLoadPriorityVeryLow, ResourceLoadPriorityLow, ResourceLoadPriorityMedium, ResourceLoadPriorityHigh, ResourceLoadPriorityVeryHigh };
113     void setOverrideResourceLoadPriority(ResourceLoadPriority);
114     void setStrictRawResourceValidationPolicyDisabled(bool);
115
116     void clearMemoryCache();
117     void pruneMemoryCacheToSize(unsigned size);
118     void destroyDecodedDataForAllImages();
119     unsigned memoryCacheSize() const;
120
121     unsigned imageFrameIndex(HTMLImageElement&);
122     void setImageFrameDecodingDuration(HTMLImageElement&, float duration);
123     void resetImageAnimation(HTMLImageElement&);
124     bool isImageAnimating(HTMLImageElement&);
125     void setClearDecoderAfterAsyncFrameRequestForTesting(HTMLImageElement&, bool);
126     unsigned imageDecodeCount(HTMLImageElement&);
127
128     void setGridMaxTracksLimit(unsigned);
129
130     void clearPageCache();
131     unsigned pageCacheSize() const;
132
133     void disableTileSizeUpdateDelay();
134
135     void setSpeculativeTilingDelayDisabledForTesting(bool);
136
137     Ref<CSSComputedStyleDeclaration> computedStyleIncludingVisitedInfo(Element&) const;
138
139     Node* ensureUserAgentShadowRoot(Element& host);
140     Node* shadowRoot(Element& host);
141     ExceptionOr<String> shadowRootType(const Node&) const;
142     String shadowPseudoId(Element&);
143     void setShadowPseudoId(Element&, const String&);
144
145     // CSS Deferred Parsing Testing
146     unsigned deferredStyleRulesCount(StyleSheet&);
147     unsigned deferredGroupRulesCount(StyleSheet&);
148     unsigned deferredKeyframesRulesCount(StyleSheet&);
149
150     // DOMTimers throttling testing.
151     ExceptionOr<bool> isTimerThrottled(int timeoutId);
152     bool isRequestAnimationFrameThrottled() const;
153     double requestAnimationFrameInterval() const;
154     bool scriptedAnimationsAreSuspended() const;
155     bool areTimersThrottled() const;
156
157     enum EventThrottlingBehavior { Responsive, Unresponsive };
158     void setEventThrottlingBehaviorOverride(std::optional<EventThrottlingBehavior>);
159     std::optional<EventThrottlingBehavior> eventThrottlingBehaviorOverride() const;
160
161     // Spatial Navigation testing.
162     ExceptionOr<unsigned> lastSpatialNavigationCandidateCount() const;
163
164     // CSS Animation testing.
165     unsigned numberOfActiveAnimations() const;
166     ExceptionOr<bool> animationsAreSuspended() const;
167     ExceptionOr<void> suspendAnimations() const;
168     ExceptionOr<void> resumeAnimations() const;
169     ExceptionOr<bool> pauseAnimationAtTimeOnElement(const String& animationName, double pauseTime, Element&);
170     ExceptionOr<bool> pauseAnimationAtTimeOnPseudoElement(const String& animationName, double pauseTime, Element&, const String& pseudoId);
171     double animationsInterval() const;
172
173     // CSS Transition testing.
174     ExceptionOr<bool> pauseTransitionAtTimeOnElement(const String& propertyName, double pauseTime, Element&);
175     ExceptionOr<bool> pauseTransitionAtTimeOnPseudoElement(const String& property, double pauseTime, Element&, const String& pseudoId);
176
177     Node* treeScopeRootNode(Node&);
178     Node* parentTreeScope(Node&);
179
180     String visiblePlaceholder(Element&);
181     void selectColorInColorChooser(HTMLInputElement&, const String& colorValue);
182     ExceptionOr<Vector<String>> formControlStateOfPreviousHistoryItem();
183     ExceptionOr<void> setFormControlStateOfPreviousHistoryItem(const Vector<String>&);
184
185     ExceptionOr<Ref<DOMRect>> absoluteCaretBounds();
186
187     Ref<DOMRect> boundingBox(Element&);
188
189     ExceptionOr<Ref<DOMRectList>> inspectorHighlightRects();
190     ExceptionOr<String> inspectorHighlightObject();
191
192     ExceptionOr<unsigned> markerCountForNode(Node&, const String&);
193     ExceptionOr<RefPtr<Range>> markerRangeForNode(Node&, const String& markerType, unsigned index);
194     ExceptionOr<String> markerDescriptionForNode(Node&, const String& markerType, unsigned index);
195     ExceptionOr<String> dumpMarkerRects(const String& markerType);
196     void addTextMatchMarker(const Range&, bool isActive);
197     ExceptionOr<void> setMarkedTextMatchesAreHighlighted(bool);
198
199     void invalidateFontCache();
200     void setFontSmoothingEnabled(bool);
201
202     ExceptionOr<void> setLowPowerModeEnabled(bool);
203
204     ExceptionOr<void> setScrollViewPosition(int x, int y);
205
206     ExceptionOr<Ref<DOMRect>> layoutViewportRect();
207     ExceptionOr<Ref<DOMRect>> visualViewportRect();
208
209     ExceptionOr<void> setViewBaseBackgroundColor(const String& colorValue);
210
211     ExceptionOr<void> setPagination(const String& mode, int gap, int pageLength);
212     ExceptionOr<void> setPaginationLineGridEnabled(bool);
213     ExceptionOr<String> configurationForViewport(float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight);
214
215     ExceptionOr<bool> wasLastChangeUserEdit(Element& textField);
216     bool elementShouldAutoComplete(HTMLInputElement&);
217     void setEditingValue(HTMLInputElement&, const String&);
218     void setAutofilled(HTMLInputElement&, bool enabled);
219     enum class AutoFillButtonType { AutoFillButtonTypeNone, AutoFillButtonTypeContacts, AutoFillButtonTypeCredentials };
220     void setShowAutoFillButton(HTMLInputElement&, AutoFillButtonType);
221     ExceptionOr<void> scrollElementToRect(Element&, int x, int y, int w, int h);
222
223     ExceptionOr<String> autofillFieldName(Element&);
224
225     ExceptionOr<void> paintControlTints();
226
227     RefPtr<Range> rangeFromLocationAndLength(Element& scope, int rangeLocation, int rangeLength);
228     unsigned locationFromRange(Element& scope, const Range&);
229     unsigned lengthFromRange(Element& scope, const Range&);
230     String rangeAsText(const Range&);
231     Ref<Range> subrange(Range&, int rangeLocation, int rangeLength);
232     ExceptionOr<RefPtr<Range>> rangeForDictionaryLookupAtLocation(int x, int y);
233     RefPtr<Range> rangeOfStringNearLocation(const Range&, const String&, unsigned);
234
235     ExceptionOr<void> setDelegatesScrolling(bool enabled);
236
237     ExceptionOr<int> lastSpellCheckRequestSequence();
238     ExceptionOr<int> lastSpellCheckProcessedSequence();
239
240     Vector<String> userPreferredLanguages() const;
241     void setUserPreferredLanguages(const Vector<String>&);
242
243     Vector<String> userPreferredAudioCharacteristics() const;
244     void setUserPreferredAudioCharacteristic(const String&);
245
246     ExceptionOr<unsigned> wheelEventHandlerCount();
247     ExceptionOr<unsigned> touchEventHandlerCount();
248
249     ExceptionOr<Ref<DOMRectList>> touchEventRectsForEvent(const String&);
250     ExceptionOr<Ref<DOMRectList>> passiveTouchEventListenerRects();
251
252     ExceptionOr<RefPtr<NodeList>> nodesFromRect(Document&, int x, int y, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowShadowContent, bool allowChildFrameContent) const;
253
254     String parserMetaData(JSC::JSValue = JSC::JSValue::JSUndefined);
255
256     void updateEditorUINowIfScheduled();
257
258     bool hasSpellingMarker(int from, int length);
259     bool hasGrammarMarker(int from, int length);
260     bool hasAutocorrectedMarker(int from, int length);
261     void setContinuousSpellCheckingEnabled(bool);
262     void setAutomaticQuoteSubstitutionEnabled(bool);
263     void setAutomaticLinkDetectionEnabled(bool);
264     void setAutomaticDashSubstitutionEnabled(bool);
265     void setAutomaticTextReplacementEnabled(bool);
266     void setAutomaticSpellingCorrectionEnabled(bool);
267
268     void handleAcceptedCandidate(const String& candidate, unsigned location, unsigned length);
269
270     bool isOverwriteModeEnabled();
271     void toggleOverwriteModeEnabled();
272
273     ExceptionOr<RefPtr<Range>> rangeOfString(const String&, RefPtr<Range>&&, const Vector<String>& findOptions);
274     ExceptionOr<unsigned> countMatchesForText(const String&, const Vector<String>& findOptions, const String& markMatches);
275     ExceptionOr<unsigned> countFindMatches(const String&, const Vector<String>& findOptions);
276
277     unsigned numberOfScrollableAreas();
278
279     ExceptionOr<bool> isPageBoxVisible(int pageNumber);
280
281     static const char* internalsId;
282
283     InternalSettings* settings() const;
284     unsigned workerThreadCount() const;
285     ExceptionOr<bool> areSVGAnimationsPaused() const;
286     ExceptionOr<double> svgAnimationsInterval(SVGSVGElement&) const;
287
288     ExceptionOr<void> setDeviceProximity(const String& eventType, double value, double min, double max);
289
290     enum {
291         // Values need to be kept in sync with Internals.idl.
292         LAYER_TREE_INCLUDES_VISIBLE_RECTS = 1,
293         LAYER_TREE_INCLUDES_TILE_CACHES = 2,
294         LAYER_TREE_INCLUDES_REPAINT_RECTS = 4,
295         LAYER_TREE_INCLUDES_PAINTING_PHASES = 8,
296         LAYER_TREE_INCLUDES_CONTENT_LAYERS = 16,
297         LAYER_TREE_INCLUDES_ACCELERATES_DRAWING = 32,
298         LAYER_TREE_INCLUDES_BACKING_STORE_ATTACHED = 64,
299     };
300     ExceptionOr<String> layerTreeAsText(Document&, unsigned short flags) const;
301     ExceptionOr<uint64_t> layerIDForElement(Element&);
302     ExceptionOr<String> repaintRectsAsText() const;
303     ExceptionOr<String> scrollingStateTreeAsText() const;
304     ExceptionOr<String> mainThreadScrollingReasons() const;
305     ExceptionOr<Ref<DOMRectList>> nonFastScrollableRects() const;
306
307     ExceptionOr<void> setElementUsesDisplayListDrawing(Element&, bool usesDisplayListDrawing);
308     ExceptionOr<void> setElementTracksDisplayListReplay(Element&, bool isTrackingReplay);
309
310     enum {
311         // Values need to be kept in sync with Internals.idl.
312         DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS = 1,
313     };
314     ExceptionOr<String> displayListForElement(Element&, unsigned short flags);
315     ExceptionOr<String> replayDisplayListForElement(Element&, unsigned short flags);
316
317     ExceptionOr<void> garbageCollectDocumentResources() const;
318
319     void beginSimulatedMemoryPressure();
320     void endSimulatedMemoryPressure();
321     bool isUnderMemoryPressure();
322
323     ExceptionOr<void> insertAuthorCSS(const String&) const;
324     ExceptionOr<void> insertUserCSS(const String&) const;
325
326     unsigned numberOfLiveNodes() const;
327     unsigned numberOfLiveDocuments() const;
328     unsigned referencingNodeCount(const Document&) const;
329
330     RefPtr<DOMWindow> openDummyInspectorFrontend(const String& url);
331     void closeDummyInspectorFrontend();
332     ExceptionOr<void> setInspectorIsUnderTest(bool);
333
334     String counterValue(Element&);
335
336     int pageNumber(Element&, float pageWidth = 800, float pageHeight = 600);
337     Vector<String> shortcutIconURLs() const;
338
339     int numberOfPages(float pageWidthInPixels = 800, float pageHeightInPixels = 600);
340     ExceptionOr<String> pageProperty(const String& propertyName, int pageNumber) const;
341     ExceptionOr<String> pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const;
342
343     ExceptionOr<float> pageScaleFactor() const;
344
345     ExceptionOr<void> setPageScaleFactor(float scaleFactor, int x, int y);
346     ExceptionOr<void> setPageZoomFactor(float);
347     ExceptionOr<void> setTextZoomFactor(float);
348
349     ExceptionOr<void> setUseFixedLayout(bool);
350     ExceptionOr<void> setFixedLayoutSize(int width, int height);
351     ExceptionOr<void> setViewExposedRect(float left, float top, float width, float height);
352     void setPrinting(int width, int height);
353
354     void setHeaderHeight(float);
355     void setFooterHeight(float);
356
357     void setTopContentInset(float);
358
359 #if ENABLE(FULLSCREEN_API)
360     void webkitWillEnterFullScreenForElement(Element&);
361     void webkitDidEnterFullScreenForElement(Element&);
362     void webkitWillExitFullScreenForElement(Element&);
363     void webkitDidExitFullScreenForElement(Element&);
364 #endif
365
366     WEBCORE_TESTSUPPORT_EXPORT void setApplicationCacheOriginQuota(unsigned long long);
367
368     void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme);
369     void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme);
370
371     void registerDefaultPortForProtocol(unsigned short port, const String& protocol);
372
373     Ref<MallocStatistics> mallocStatistics() const;
374     Ref<TypeConversions> typeConversions() const;
375     Ref<MemoryInfo> memoryInfo() const;
376
377     Vector<String> getReferencedFilePaths() const;
378
379     ExceptionOr<void> startTrackingRepaints();
380     ExceptionOr<void> stopTrackingRepaints();
381
382     ExceptionOr<void> startTrackingLayerFlushes();
383     ExceptionOr<unsigned> layerFlushCount();
384
385     ExceptionOr<void> startTrackingStyleRecalcs();
386     ExceptionOr<unsigned> styleRecalcCount();
387     unsigned lastStyleUpdateSize() const;
388
389     ExceptionOr<void> startTrackingCompositingUpdates();
390     ExceptionOr<unsigned> compositingUpdateCount();
391
392     ExceptionOr<void> updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*);
393     unsigned layoutCount() const;
394
395     Ref<ArrayBuffer> serializeObject(const RefPtr<SerializedScriptValue>&) const;
396     Ref<SerializedScriptValue> deserializeBuffer(ArrayBuffer&) const;
397
398     bool isFromCurrentWorld(JSC::JSValue) const;
399
400     void setUsesOverlayScrollbars(bool);
401     void setUsesMockScrollAnimator(bool);
402
403     ExceptionOr<String> getCurrentCursorInfo();
404
405     String markerTextForListItem(Element&);
406
407     String toolTipFromElement(Element&) const;
408
409     void forceReload(bool endToEnd);
410     void reloadExpiredOnly();
411
412     void enableAutoSizeMode(bool enabled, int minimumWidth, int minimumHeight, int maximumWidth, int maximumHeight);
413
414 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
415     void initializeMockCDM();
416 #endif
417
418 #if ENABLE(ENCRYPTED_MEDIA)
419     Ref<MockCDMFactory> registerMockCDM();
420 #endif
421
422 #if ENABLE(SPEECH_SYNTHESIS)
423     void enableMockSpeechSynthesizer();
424 #endif
425
426 #if ENABLE(MEDIA_STREAM)
427     void setMockMediaCaptureDevicesEnabled(bool);
428 #endif
429
430 #if ENABLE(WEB_RTC)
431 #if USE(OPENWEBRTC)
432     void enableMockMediaEndpoint();
433 #endif
434     void emulateRTCPeerConnectionPlatformEvent(RTCPeerConnection&, const String& action);
435     void useMockRTCPeerConnectionFactory(const String&);
436     void setICECandidateFiltering(bool);
437     void setEnumeratingAllNetworkInterfacesEnabled(bool);
438     void stopPeerConnection(RTCPeerConnection&);
439     void applyRotationForOutgoingVideoSources(RTCPeerConnection&);
440 #endif
441
442     String getImageSourceURL(Element&);
443
444 #if ENABLE(VIDEO)
445     Vector<String> mediaResponseSources(HTMLMediaElement&);
446     Vector<String> mediaResponseContentRanges(HTMLMediaElement&);
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     void setResourceLoadStatisticsShouldThrottleObserverNotifications(bool);
542
543 #if ENABLE(STREAMS_API)
544     bool isReadableStreamDisturbed(JSC::ExecState&, JSC::JSValue);
545     JSC::JSValue cloneArrayBuffer(JSC::ExecState&, JSC::JSValue, JSC::JSValue, JSC::JSValue);
546 #endif
547
548     String composedTreeAsText(Node&);
549
550     bool isProcessingUserGesture();
551     double lastHandledUserGestureTimestamp();
552
553     RefPtr<GCObservation> observeGC(JSC::JSValue);
554
555     enum class UserInterfaceLayoutDirection { LTR, RTL };
556     void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection);
557
558     bool userPrefersReducedMotion() const;
559
560     void reportBacktrace();
561
562     enum class BaseWritingDirection { Natural, Ltr, Rtl };
563     void setBaseWritingDirection(BaseWritingDirection);
564
565 #if ENABLE(POINTER_LOCK)
566     bool pageHasPendingPointerLock() const;
567     bool pageHasPointerLock() const;
568 #endif
569
570     Vector<String> accessKeyModifiers() const;
571
572     void setQuickLookPassword(const String&);
573
574     void setAsRunningUserScripts(Document&);
575
576 #if ENABLE(WEBGL)
577     void simulateWebGLContextChanged(WebGLRenderingContext&);
578     void failNextGPUStatusCheck(WebGLRenderingContext&);
579 #endif
580
581     void setPageVisibility(bool isVisible);
582
583 #if ENABLE(WEB_RTC)
584     void setH264HardwareEncoderAllowed(bool allowed);
585 #endif
586
587 #if ENABLE(MEDIA_STREAM)
588     void setCameraMediaStreamTrackOrientation(MediaStreamTrack&, int orientation);
589     ExceptionOr<void> setMediaDeviceState(const String& id, const String& property, bool value);
590     unsigned long trackAudioSampleCount() const { return m_trackAudioSampleCount; }
591     unsigned long trackVideoSampleCount() const { return m_trackVideoSampleCount; }
592     void observeMediaStreamTrack(MediaStreamTrack&);
593     using TrackFramePromise = DOMPromiseDeferred<IDLInterface<ImageData>>;
594     void grabNextMediaStreamTrackFrame(TrackFramePromise&&);
595     void delayMediaStreamTrackSamples(MediaStreamTrack&, float);
596     void setMediaStreamTrackMuted(MediaStreamTrack&, bool);
597     void removeMediaStreamTrack(MediaStream&, MediaStreamTrack&);
598 #endif
599
600     String audioSessionCategory() const;
601
602 private:
603     explicit Internals(Document&);
604     Document* contextDocument() const;
605     Frame* frame() const;
606
607     ExceptionOr<RenderedDocumentMarker*> markerAt(Node&, const String& markerType, unsigned index);
608
609     // RealtimeMediaSource::Observer API
610 #if ENABLE(MEDIA_STREAM)
611     void videoSampleAvailable(MediaSample&) final;
612     void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final { m_trackAudioSampleCount++; }
613
614     OrientationNotifier m_orientationNotifier;
615     unsigned long m_trackVideoSampleCount { 0 };
616     unsigned long m_trackAudioSampleCount { 0 };
617     RefPtr<MediaStreamTrack> m_track;
618     std::optional<TrackFramePromise> m_nextTrackFramePromise;
619 #endif
620
621     std::unique_ptr<InspectorStubFrontend> m_inspectorFrontend;
622 };
623
624 } // namespace WebCore