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