[iOS] Video occasionally mixes with other system audio instead of interrupting
[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 "OrientationNotifer.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
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 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
329     RefPtr<DOMWindow> openDummyInspectorFrontend(const String& url);
330     void closeDummyInspectorFrontend();
331     ExceptionOr<void> setInspectorIsUnderTest(bool);
332
333     String counterValue(Element&);
334
335     int pageNumber(Element&, float pageWidth = 800, float pageHeight = 600);
336     Vector<String> shortcutIconURLs() const;
337
338     int numberOfPages(float pageWidthInPixels = 800, float pageHeightInPixels = 600);
339     ExceptionOr<String> pageProperty(const String& propertyName, int pageNumber) const;
340     ExceptionOr<String> pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const;
341
342     ExceptionOr<float> pageScaleFactor() const;
343
344     ExceptionOr<void> setPageScaleFactor(float scaleFactor, int x, int y);
345     ExceptionOr<void> setPageZoomFactor(float);
346     ExceptionOr<void> setTextZoomFactor(float);
347
348     ExceptionOr<void> setUseFixedLayout(bool);
349     ExceptionOr<void> setFixedLayoutSize(int width, int height);
350     ExceptionOr<void> setViewExposedRect(float left, float top, float width, float height);
351     void setPrinting(int width, int height);
352
353     void setHeaderHeight(float);
354     void setFooterHeight(float);
355
356     void setTopContentInset(float);
357
358 #if ENABLE(FULLSCREEN_API)
359     void webkitWillEnterFullScreenForElement(Element&);
360     void webkitDidEnterFullScreenForElement(Element&);
361     void webkitWillExitFullScreenForElement(Element&);
362     void webkitDidExitFullScreenForElement(Element&);
363 #endif
364
365     WEBCORE_TESTSUPPORT_EXPORT void setApplicationCacheOriginQuota(unsigned long long);
366
367     void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme);
368     void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme);
369
370     void registerDefaultPortForProtocol(unsigned short port, const String& protocol);
371
372     Ref<MallocStatistics> mallocStatistics() const;
373     Ref<TypeConversions> typeConversions() const;
374     Ref<MemoryInfo> memoryInfo() const;
375
376     Vector<String> getReferencedFilePaths() const;
377
378     ExceptionOr<void> startTrackingRepaints();
379     ExceptionOr<void> stopTrackingRepaints();
380
381     ExceptionOr<void> startTrackingLayerFlushes();
382     ExceptionOr<unsigned> layerFlushCount();
383
384     ExceptionOr<void> startTrackingStyleRecalcs();
385     ExceptionOr<unsigned> styleRecalcCount();
386     unsigned lastStyleUpdateSize() const;
387
388     ExceptionOr<void> startTrackingCompositingUpdates();
389     ExceptionOr<unsigned> compositingUpdateCount();
390
391     ExceptionOr<void> updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*);
392     unsigned layoutCount() const;
393
394     Ref<ArrayBuffer> serializeObject(const RefPtr<SerializedScriptValue>&) const;
395     Ref<SerializedScriptValue> deserializeBuffer(ArrayBuffer&) const;
396
397     bool isFromCurrentWorld(JSC::JSValue) const;
398
399     void setUsesOverlayScrollbars(bool);
400     void setUsesMockScrollAnimator(bool);
401
402     ExceptionOr<String> getCurrentCursorInfo();
403
404     String markerTextForListItem(Element&);
405
406     String toolTipFromElement(Element&) const;
407
408     void forceReload(bool endToEnd);
409     void reloadExpiredOnly();
410
411     void enableAutoSizeMode(bool enabled, int minimumWidth, int minimumHeight, int maximumWidth, int maximumHeight);
412
413 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
414     void initializeMockCDM();
415 #endif
416
417 #if ENABLE(ENCRYPTED_MEDIA)
418     Ref<MockCDMFactory> registerMockCDM();
419 #endif
420
421 #if ENABLE(SPEECH_SYNTHESIS)
422     void enableMockSpeechSynthesizer();
423 #endif
424
425 #if ENABLE(MEDIA_STREAM)
426     void setMockMediaCaptureDevicesEnabled(bool);
427 #endif
428
429 #if ENABLE(WEB_RTC)
430 #if USE(OPENWEBRTC)
431     void enableMockMediaEndpoint();
432 #endif
433     void emulateRTCPeerConnectionPlatformEvent(RTCPeerConnection&, const String& action);
434     void useMockRTCPeerConnectionFactory(const String&);
435     void setICECandidateFiltering(bool);
436     void setEnumeratingAllNetworkInterfacesEnabled(bool);
437     void stopPeerConnection(RTCPeerConnection&);
438     void applyRotationForOutgoingVideoSources(RTCPeerConnection&);
439 #endif
440
441     String getImageSourceURL(Element&);
442
443 #if ENABLE(VIDEO)
444     void simulateAudioInterruption(HTMLMediaElement&);
445     ExceptionOr<bool> mediaElementHasCharacteristic(HTMLMediaElement&, const String&);
446 #endif
447
448     bool isSelectPopupVisible(HTMLSelectElement&);
449
450     ExceptionOr<String> captionsStyleSheetOverride();
451     ExceptionOr<void> setCaptionsStyleSheetOverride(const String&);
452     ExceptionOr<void> setPrimaryAudioTrackLanguageOverride(const String&);
453     ExceptionOr<void> setCaptionDisplayMode(const String&);
454
455 #if ENABLE(VIDEO)
456     Ref<TimeRanges> createTimeRanges(Float32Array& startTimes, Float32Array& endTimes);
457     double closestTimeToTimeRanges(double time, TimeRanges&);
458 #endif
459
460     ExceptionOr<Ref<DOMRect>> selectionBounds();
461
462     ExceptionOr<bool> isPluginUnavailabilityIndicatorObscured(Element&);
463     bool isPluginSnapshotted(Element&);
464
465 #if ENABLE(MEDIA_SOURCE)
466     WEBCORE_TESTSUPPORT_EXPORT void initializeMockMediaSource();
467     Vector<String> bufferedSamplesForTrackID(SourceBuffer&, const AtomicString&);
468     Vector<String> enqueuedSamplesForTrackID(SourceBuffer&, const AtomicString&);
469     void setShouldGenerateTimestamps(SourceBuffer&, bool);
470 #endif
471
472 #if ENABLE(VIDEO)
473     ExceptionOr<void> beginMediaSessionInterruption(const String&);
474     void endMediaSessionInterruption(const String&);
475     void applicationDidEnterForeground() const;
476     void applicationWillEnterBackground() const;
477     ExceptionOr<void> setMediaSessionRestrictions(const String& mediaType, StringView restrictionsString);
478     ExceptionOr<String> mediaSessionRestrictions(const String& mediaType) const;
479     void setMediaElementRestrictions(HTMLMediaElement&, StringView restrictionsString);
480     ExceptionOr<void> postRemoteControlCommand(const String&, float argument);
481     bool elementIsBlockingDisplaySleep(HTMLMediaElement&) const;
482 #endif
483
484 #if ENABLE(MEDIA_SESSION)
485     void sendMediaSessionStartOfInterruptionNotification(MediaSessionInterruptingCategory);
486     void sendMediaSessionEndOfInterruptionNotification(MediaSessionInterruptingCategory);
487     String mediaSessionCurrentState(MediaSession&) const;
488     double mediaElementPlayerVolume(HTMLMediaElement&) const;
489     enum class MediaControlEvent { PlayPause, NextTrack, PreviousTrack };
490     void sendMediaControlEvent(MediaControlEvent);
491 #endif
492
493 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
494     void setMockMediaPlaybackTargetPickerEnabled(bool);
495     ExceptionOr<void> setMockMediaPlaybackTargetPickerState(const String& deviceName, const String& deviceState);
496 #endif
497
498 #if ENABLE(WEB_AUDIO)
499     void setAudioContextRestrictions(AudioContext&, StringView restrictionsString);
500 #endif
501
502     void simulateSystemSleep() const;
503     void simulateSystemWake() const;
504
505     enum class PageOverlayType { View, Document };
506     ExceptionOr<Ref<MockPageOverlay>> installMockPageOverlay(PageOverlayType);
507     ExceptionOr<String> pageOverlayLayerTreeAsText(unsigned short flags) const;
508
509     void setPageMuted(StringView);
510     String pageMediaState();
511
512     void setPageDefersLoading(bool);
513
514     RefPtr<File> createFile(const String&);
515     void queueMicroTask(int);
516     bool testPreloaderSettingViewport();
517
518 #if ENABLE(CONTENT_FILTERING)
519     MockContentFilterSettings& mockContentFilterSettings();
520 #endif
521
522 #if ENABLE(CSS_SCROLL_SNAP)
523     ExceptionOr<String> scrollSnapOffsets(Element&);
524     void setPlatformMomentumScrollingPredictionEnabled(bool);
525 #endif
526
527     ExceptionOr<String> pathStringWithShrinkWrappedRects(const Vector<double>& rectComponents, double radius);
528
529     String getCurrentMediaControlsStatusForElement(HTMLMediaElement&);
530
531     String userVisibleString(const DOMURL&);
532     void setShowAllPlugins(bool);
533
534     String resourceLoadStatisticsForOrigin(const String& origin);
535     void setResourceLoadStatisticsEnabled(bool);
536
537 #if ENABLE(STREAMS_API)
538     bool isReadableStreamDisturbed(JSC::ExecState&, JSC::JSValue);
539     JSC::JSValue cloneArrayBuffer(JSC::ExecState&, JSC::JSValue, JSC::JSValue, JSC::JSValue);
540 #endif
541
542     String composedTreeAsText(Node&);
543
544     bool isProcessingUserGesture();
545     double lastHandledUserGestureTimestamp();
546
547     RefPtr<GCObservation> observeGC(JSC::JSValue);
548
549     enum class UserInterfaceLayoutDirection { LTR, RTL };
550     void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection);
551
552     bool userPrefersReducedMotion() const;
553
554     void reportBacktrace();
555
556     enum class BaseWritingDirection { Natural, Ltr, Rtl };
557     void setBaseWritingDirection(BaseWritingDirection);
558
559 #if ENABLE(POINTER_LOCK)
560     bool pageHasPendingPointerLock() const;
561     bool pageHasPointerLock() const;
562 #endif
563
564     Vector<String> accessKeyModifiers() const;
565
566 #if PLATFORM(IOS)
567     void setQuickLookPassword(const String&);
568 #endif
569
570     void setAsRunningUserScripts(Document&);
571
572 #if ENABLE(WEBGL)
573     void simulateWebGLContextChanged(WebGLRenderingContext&);
574     void failNextGPUStatusCheck(WebGLRenderingContext&);
575 #endif
576
577     void setPageVisibility(bool isVisible);
578
579 #if ENABLE(MEDIA_STREAM)
580     void setCameraMediaStreamTrackOrientation(MediaStreamTrack&, int orientation);
581     ExceptionOr<void> setMediaDeviceState(const String& id, const String& property, bool value);
582     unsigned long trackAudioSampleCount() const { return m_trackAudioSampleCount; }
583     unsigned long trackVideoSampleCount() const { return m_trackVideoSampleCount; }
584     void observeMediaStreamTrack(MediaStreamTrack&);
585     using TrackFramePromise = DOMPromiseDeferred<IDLInterface<ImageData>>;
586     void grabNextMediaStreamTrackFrame(TrackFramePromise&&);
587     void delayMediaStreamTrackSamples(MediaStreamTrack&, float);
588     void setMediaStreamTrackMuted(MediaStreamTrack&, bool);
589     void removeMediaStreamTrack(MediaStream&, MediaStreamTrack&);
590 #endif
591
592     String audioSessionCategory() const;
593
594 private:
595     explicit Internals(Document&);
596     Document* contextDocument() const;
597     Frame* frame() const;
598
599     ExceptionOr<RenderedDocumentMarker*> markerAt(Node&, const String& markerType, unsigned index);
600
601     // RealtimeMediaSource::Observer API
602 #if ENABLE(MEDIA_STREAM)
603     void videoSampleAvailable(MediaSample&) final;
604     void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final { m_trackAudioSampleCount++; }
605
606     OrientationNotifier m_orientationNotifier;
607     unsigned long m_trackVideoSampleCount { 0 };
608     unsigned long m_trackAudioSampleCount { 0 };
609     RefPtr<MediaStreamTrack> m_track;
610     std::optional<TrackFramePromise> m_nextTrackFramePromise;
611 #endif
612
613     std::unique_ptr<InspectorStubFrontend> m_inspectorFrontend;
614 };
615
616 } // namespace WebCore