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