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