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