2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
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 <JavaScriptCore/Float32Array.h>
37 #include <wtf/Optional.h>
39 #if ENABLE(MEDIA_SESSION)
40 #include "MediaSessionInterruptionProvider.h"
45 class AnimationTimeline;
47 class CacheStorageConnection;
54 class ExtendableEvent;
59 class HTMLAnchorElement;
60 class HTMLImageElement;
61 class HTMLInputElement;
62 class HTMLLinkElement;
63 class HTMLMediaElement;
64 class HTMLPictureElement;
65 class HTMLSelectElement;
67 class InspectorStubFrontend;
68 class InternalSettings;
69 class MallocStatistics;
72 class MediaStreamTrack;
75 class MockContentFilterSettings;
76 class MockCredentialsMessenger;
77 class MockPageOverlay;
78 class MockPaymentCoordinator;
81 class RTCPeerConnection;
83 class RenderedDocumentMarker;
85 class SerializedScriptValue;
90 class TypeConversions;
92 class WebGLRenderingContext;
95 #if ENABLE(SERVICE_WORKER)
99 class Internals final : public RefCounted<Internals>, private ContextDestructionObserver
100 #if ENABLE(MEDIA_STREAM)
101 , private RealtimeMediaSource::Observer
105 static Ref<Internals> create(Document&);
106 virtual ~Internals();
108 static void resetToConsistentState(Page&);
110 ExceptionOr<String> elementRenderTreeAsText(Element&);
111 bool hasPausedImageAnimations(Element&);
113 bool isPaintingFrequently(Element&);
114 void incrementFrequentPaintCounter(Element&);
116 String address(Node&);
117 bool nodeNeedsStyleRecalc(Node&);
118 String styleChangeType(Node&);
119 String description(JSC::JSValue);
121 bool isPreloaded(const String& url);
122 bool isLoadingFromMemoryCache(const String& url);
123 String fetchResponseSource(FetchResponse&);
124 String xhrResponseSource(XMLHttpRequest&);
125 bool isSharingStyleSheetContents(HTMLLinkElement&, HTMLLinkElement&);
126 bool isStyleSheetLoadingSubresources(HTMLLinkElement&);
127 enum class CachePolicy { UseProtocolCachePolicy, ReloadIgnoringCacheData, ReturnCacheDataElseLoad, ReturnCacheDataDontLoad };
128 void setOverrideCachePolicy(CachePolicy);
129 ExceptionOr<void> setCanShowModalDialogOverride(bool allow);
130 enum class ResourceLoadPriority { ResourceLoadPriorityVeryLow, ResourceLoadPriorityLow, ResourceLoadPriorityMedium, ResourceLoadPriorityHigh, ResourceLoadPriorityVeryHigh };
131 void setOverrideResourceLoadPriority(ResourceLoadPriority);
132 void setStrictRawResourceValidationPolicyDisabled(bool);
134 void clearMemoryCache();
135 void pruneMemoryCacheToSize(unsigned size);
136 void destroyDecodedDataForAllImages();
137 unsigned memoryCacheSize() const;
139 unsigned imageFrameIndex(HTMLImageElement&);
140 void setImageFrameDecodingDuration(HTMLImageElement&, float duration);
141 void resetImageAnimation(HTMLImageElement&);
142 bool isImageAnimating(HTMLImageElement&);
143 void setClearDecoderAfterAsyncFrameRequestForTesting(HTMLImageElement&, bool enabled);
144 unsigned imageDecodeCount(HTMLImageElement&);
145 unsigned pdfDocumentCachingCount(HTMLImageElement&);
146 void setLargeImageAsyncDecodingEnabledForTesting(HTMLImageElement&, bool enabled);
147 void setForceUpdateImageDataEnabledForTesting(HTMLImageElement&, bool enabled);
149 void setGridMaxTracksLimit(unsigned);
151 void clearPageCache();
152 unsigned pageCacheSize() const;
154 void disableTileSizeUpdateDelay();
156 void setSpeculativeTilingDelayDisabledForTesting(bool);
158 Ref<CSSComputedStyleDeclaration> computedStyleIncludingVisitedInfo(Element&) const;
160 Node* ensureUserAgentShadowRoot(Element& host);
161 Node* shadowRoot(Element& host);
162 ExceptionOr<String> shadowRootType(const Node&) const;
163 String shadowPseudoId(Element&);
164 void setShadowPseudoId(Element&, const String&);
166 // CSS Deferred Parsing Testing
167 unsigned deferredStyleRulesCount(StyleSheet&);
168 unsigned deferredGroupRulesCount(StyleSheet&);
169 unsigned deferredKeyframesRulesCount(StyleSheet&);
171 // DOMTimers throttling testing.
172 ExceptionOr<bool> isTimerThrottled(int timeoutId);
173 bool isRequestAnimationFrameThrottled() const;
174 double requestAnimationFrameInterval() const;
175 bool scriptedAnimationsAreSuspended() const;
176 bool areTimersThrottled() const;
178 enum EventThrottlingBehavior { Responsive, Unresponsive };
179 void setEventThrottlingBehaviorOverride(std::optional<EventThrottlingBehavior>);
180 std::optional<EventThrottlingBehavior> eventThrottlingBehaviorOverride() const;
182 // Spatial Navigation testing.
183 ExceptionOr<unsigned> lastSpatialNavigationCandidateCount() const;
185 // CSS Animation testing.
186 unsigned numberOfActiveAnimations() const;
187 ExceptionOr<bool> animationsAreSuspended() const;
188 ExceptionOr<void> suspendAnimations() const;
189 ExceptionOr<void> resumeAnimations() const;
190 ExceptionOr<bool> pauseAnimationAtTimeOnElement(const String& animationName, double pauseTime, Element&);
191 ExceptionOr<bool> pauseAnimationAtTimeOnPseudoElement(const String& animationName, double pauseTime, Element&, const String& pseudoId);
192 double animationsInterval() const;
194 // CSS Transition testing.
195 ExceptionOr<bool> pauseTransitionAtTimeOnElement(const String& propertyName, double pauseTime, Element&);
196 ExceptionOr<bool> pauseTransitionAtTimeOnPseudoElement(const String& property, double pauseTime, Element&, const String& pseudoId);
198 // For animations testing, we need a way to get at pseudo elements.
199 ExceptionOr<RefPtr<Element>> pseudoElement(Element&, const String&);
201 Node* treeScopeRootNode(Node&);
202 Node* parentTreeScope(Node&);
204 String visiblePlaceholder(Element&);
205 void selectColorInColorChooser(HTMLInputElement&, const String& colorValue);
206 ExceptionOr<Vector<String>> formControlStateOfPreviousHistoryItem();
207 ExceptionOr<void> setFormControlStateOfPreviousHistoryItem(const Vector<String>&);
209 ExceptionOr<Ref<DOMRect>> absoluteCaretBounds();
211 Ref<DOMRect> boundingBox(Element&);
213 ExceptionOr<Ref<DOMRectList>> inspectorHighlightRects();
214 ExceptionOr<String> inspectorHighlightObject();
216 ExceptionOr<unsigned> markerCountForNode(Node&, const String&);
217 ExceptionOr<RefPtr<Range>> markerRangeForNode(Node&, const String& markerType, unsigned index);
218 ExceptionOr<String> markerDescriptionForNode(Node&, const String& markerType, unsigned index);
219 ExceptionOr<String> dumpMarkerRects(const String& markerType);
220 void addTextMatchMarker(const Range&, bool isActive);
221 ExceptionOr<void> setMarkedTextMatchesAreHighlighted(bool);
223 void invalidateFontCache();
224 void setFontSmoothingEnabled(bool);
226 ExceptionOr<void> setLowPowerModeEnabled(bool);
228 ExceptionOr<void> setScrollViewPosition(int x, int y);
229 ExceptionOr<void> unconstrainedScrollTo(Element&, double x, double y);
231 ExceptionOr<Ref<DOMRect>> layoutViewportRect();
232 ExceptionOr<Ref<DOMRect>> visualViewportRect();
234 ExceptionOr<void> setViewBaseBackgroundColor(const String& colorValue);
236 ExceptionOr<void> setPagination(const String& mode, int gap, int pageLength);
237 ExceptionOr<void> setPaginationLineGridEnabled(bool);
238 ExceptionOr<String> configurationForViewport(float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight);
240 ExceptionOr<bool> wasLastChangeUserEdit(Element& textField);
241 bool elementShouldAutoComplete(HTMLInputElement&);
242 void setEditingValue(HTMLInputElement&, const String&);
243 void setAutofilled(HTMLInputElement&, bool enabled);
244 enum class AutoFillButtonType { None, Contacts, Credentials, StrongPassword, StrongConfirmationPassword };
245 void setShowAutoFillButton(HTMLInputElement&, AutoFillButtonType);
246 AutoFillButtonType autoFillButtonType(const HTMLInputElement&);
247 AutoFillButtonType lastAutoFillButtonType(const HTMLInputElement&);
248 ExceptionOr<void> scrollElementToRect(Element&, int x, int y, int w, int h);
250 ExceptionOr<String> autofillFieldName(Element&);
252 ExceptionOr<void> paintControlTints();
254 RefPtr<Range> rangeFromLocationAndLength(Element& scope, int rangeLocation, int rangeLength);
255 unsigned locationFromRange(Element& scope, const Range&);
256 unsigned lengthFromRange(Element& scope, const Range&);
257 String rangeAsText(const Range&);
258 Ref<Range> subrange(Range&, int rangeLocation, int rangeLength);
259 ExceptionOr<RefPtr<Range>> rangeForDictionaryLookupAtLocation(int x, int y);
260 RefPtr<Range> rangeOfStringNearLocation(const Range&, const String&, unsigned);
262 ExceptionOr<void> setDelegatesScrolling(bool enabled);
264 ExceptionOr<int> lastSpellCheckRequestSequence();
265 ExceptionOr<int> lastSpellCheckProcessedSequence();
267 Vector<String> userPreferredLanguages() const;
268 void setUserPreferredLanguages(const Vector<String>&);
270 Vector<String> userPreferredAudioCharacteristics() const;
271 void setUserPreferredAudioCharacteristic(const String&);
273 ExceptionOr<unsigned> wheelEventHandlerCount();
274 ExceptionOr<unsigned> touchEventHandlerCount();
276 ExceptionOr<Ref<DOMRectList>> touchEventRectsForEvent(const String&);
277 ExceptionOr<Ref<DOMRectList>> passiveTouchEventListenerRects();
279 ExceptionOr<RefPtr<NodeList>> nodesFromRect(Document&, int x, int y, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowUserAgentShadowContent, bool allowChildFrameContent) const;
281 String parserMetaData(JSC::JSValue = JSC::JSValue::JSUndefined);
283 void updateEditorUINowIfScheduled();
285 bool hasSpellingMarker(int from, int length);
286 bool hasGrammarMarker(int from, int length);
287 bool hasAutocorrectedMarker(int from, int length);
288 void setContinuousSpellCheckingEnabled(bool);
289 void setAutomaticQuoteSubstitutionEnabled(bool);
290 void setAutomaticLinkDetectionEnabled(bool);
291 void setAutomaticDashSubstitutionEnabled(bool);
292 void setAutomaticTextReplacementEnabled(bool);
293 void setAutomaticSpellingCorrectionEnabled(bool);
295 void handleAcceptedCandidate(const String& candidate, unsigned location, unsigned length);
297 bool isOverwriteModeEnabled();
298 void toggleOverwriteModeEnabled();
300 ExceptionOr<RefPtr<Range>> rangeOfString(const String&, RefPtr<Range>&&, const Vector<String>& findOptions);
301 ExceptionOr<unsigned> countMatchesForText(const String&, const Vector<String>& findOptions, const String& markMatches);
302 ExceptionOr<unsigned> countFindMatches(const String&, const Vector<String>& findOptions);
304 unsigned numberOfScrollableAreas();
306 ExceptionOr<bool> isPageBoxVisible(int pageNumber);
308 static const char* internalsId;
310 InternalSettings* settings() const;
311 unsigned workerThreadCount() const;
312 ExceptionOr<bool> areSVGAnimationsPaused() const;
313 ExceptionOr<double> svgAnimationsInterval(SVGSVGElement&) const;
316 // Values need to be kept in sync with Internals.idl.
317 LAYER_TREE_INCLUDES_VISIBLE_RECTS = 1,
318 LAYER_TREE_INCLUDES_TILE_CACHES = 2,
319 LAYER_TREE_INCLUDES_REPAINT_RECTS = 4,
320 LAYER_TREE_INCLUDES_PAINTING_PHASES = 8,
321 LAYER_TREE_INCLUDES_CONTENT_LAYERS = 16,
322 LAYER_TREE_INCLUDES_ACCELERATES_DRAWING = 32,
323 LAYER_TREE_INCLUDES_BACKING_STORE_ATTACHED = 64,
325 ExceptionOr<String> layerTreeAsText(Document&, unsigned short flags) const;
326 ExceptionOr<uint64_t> layerIDForElement(Element&);
327 ExceptionOr<String> repaintRectsAsText() const;
328 ExceptionOr<String> scrollingStateTreeAsText() const;
329 ExceptionOr<String> mainThreadScrollingReasons() const;
330 ExceptionOr<Ref<DOMRectList>> nonFastScrollableRects() const;
332 ExceptionOr<void> setElementUsesDisplayListDrawing(Element&, bool usesDisplayListDrawing);
333 ExceptionOr<void> setElementTracksDisplayListReplay(Element&, bool isTrackingReplay);
336 // Values need to be kept in sync with Internals.idl.
337 DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS = 1,
339 ExceptionOr<String> displayListForElement(Element&, unsigned short flags);
340 ExceptionOr<String> replayDisplayListForElement(Element&, unsigned short flags);
342 ExceptionOr<void> garbageCollectDocumentResources() const;
344 void beginSimulatedMemoryPressure();
345 void endSimulatedMemoryPressure();
346 bool isUnderMemoryPressure();
348 ExceptionOr<void> insertAuthorCSS(const String&) const;
349 ExceptionOr<void> insertUserCSS(const String&) const;
351 unsigned numberOfLiveNodes() const;
352 unsigned numberOfLiveDocuments() const;
353 unsigned referencingNodeCount(const Document&) const;
355 RefPtr<WindowProxy> openDummyInspectorFrontend(const String& url);
356 void closeDummyInspectorFrontend();
357 ExceptionOr<void> setInspectorIsUnderTest(bool);
359 String counterValue(Element&);
361 int pageNumber(Element&, float pageWidth = 800, float pageHeight = 600);
362 Vector<String> shortcutIconURLs() const;
364 int numberOfPages(float pageWidthInPixels = 800, float pageHeightInPixels = 600);
365 ExceptionOr<String> pageProperty(const String& propertyName, int pageNumber) const;
366 ExceptionOr<String> pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const;
368 ExceptionOr<float> pageScaleFactor() const;
370 ExceptionOr<void> setPageScaleFactor(float scaleFactor, int x, int y);
371 ExceptionOr<void> setPageZoomFactor(float);
372 ExceptionOr<void> setTextZoomFactor(float);
374 ExceptionOr<void> setUseFixedLayout(bool);
375 ExceptionOr<void> setFixedLayoutSize(int width, int height);
376 ExceptionOr<void> setViewExposedRect(float left, float top, float width, float height);
377 void setPrinting(int width, int height);
379 void setHeaderHeight(float);
380 void setFooterHeight(float);
382 void setTopContentInset(float);
384 #if ENABLE(FULLSCREEN_API)
385 void webkitWillEnterFullScreenForElement(Element&);
386 void webkitDidEnterFullScreenForElement(Element&);
387 void webkitWillExitFullScreenForElement(Element&);
388 void webkitDidExitFullScreenForElement(Element&);
391 void setFullscreenInsetTop(double);
392 void setFullscreenAutoHideDelay(double);
394 WEBCORE_TESTSUPPORT_EXPORT void setApplicationCacheOriginQuota(unsigned long long);
396 void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme);
397 void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme);
399 void registerDefaultPortForProtocol(unsigned short port, const String& protocol);
401 Ref<MallocStatistics> mallocStatistics() const;
402 Ref<TypeConversions> typeConversions() const;
403 Ref<MemoryInfo> memoryInfo() const;
405 Vector<String> getReferencedFilePaths() const;
407 ExceptionOr<void> startTrackingRepaints();
408 ExceptionOr<void> stopTrackingRepaints();
410 ExceptionOr<void> startTrackingLayerFlushes();
411 ExceptionOr<unsigned> layerFlushCount();
413 ExceptionOr<void> startTrackingStyleRecalcs();
414 ExceptionOr<unsigned> styleRecalcCount();
415 unsigned lastStyleUpdateSize() const;
417 ExceptionOr<void> startTrackingCompositingUpdates();
418 ExceptionOr<unsigned> compositingUpdateCount();
420 ExceptionOr<void> updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*);
421 unsigned layoutCount() const;
423 Ref<ArrayBuffer> serializeObject(const RefPtr<SerializedScriptValue>&) const;
424 Ref<SerializedScriptValue> deserializeBuffer(ArrayBuffer&) const;
426 bool isFromCurrentWorld(JSC::JSValue) const;
428 void setUsesOverlayScrollbars(bool);
429 void setUsesMockScrollAnimator(bool);
431 ExceptionOr<String> getCurrentCursorInfo();
433 String markerTextForListItem(Element&);
435 String toolTipFromElement(Element&) const;
437 void forceReload(bool endToEnd);
438 void reloadExpiredOnly();
440 void enableAutoSizeMode(bool enabled, int minimumWidth, int minimumHeight, int maximumWidth, int maximumHeight);
442 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
443 void initializeMockCDM();
446 #if ENABLE(ENCRYPTED_MEDIA)
447 Ref<MockCDMFactory> registerMockCDM();
450 #if ENABLE(SPEECH_SYNTHESIS)
451 void enableMockSpeechSynthesizer();
454 #if ENABLE(MEDIA_STREAM)
455 void setMockMediaCaptureDevicesEnabled(bool);
459 void emulateRTCPeerConnectionPlatformEvent(RTCPeerConnection&, const String& action);
460 void useMockRTCPeerConnectionFactory(const String&);
461 void setICECandidateFiltering(bool);
462 void setEnumeratingAllNetworkInterfacesEnabled(bool);
463 void stopPeerConnection(RTCPeerConnection&);
464 void applyRotationForOutgoingVideoSources(RTCPeerConnection&);
467 String getImageSourceURL(Element&);
470 Vector<String> mediaResponseSources(HTMLMediaElement&);
471 Vector<String> mediaResponseContentRanges(HTMLMediaElement&);
472 void simulateAudioInterruption(HTMLMediaElement&);
473 ExceptionOr<bool> mediaElementHasCharacteristic(HTMLMediaElement&, const String&);
474 void beginSimulatedHDCPError(HTMLMediaElement&);
475 void endSimulatedHDCPError(HTMLMediaElement&);
478 bool isSelectPopupVisible(HTMLSelectElement&);
480 ExceptionOr<String> captionsStyleSheetOverride();
481 ExceptionOr<void> setCaptionsStyleSheetOverride(const String&);
482 ExceptionOr<void> setPrimaryAudioTrackLanguageOverride(const String&);
483 ExceptionOr<void> setCaptionDisplayMode(const String&);
486 Ref<TimeRanges> createTimeRanges(Float32Array& startTimes, Float32Array& endTimes);
487 double closestTimeToTimeRanges(double time, TimeRanges&);
490 ExceptionOr<Ref<DOMRect>> selectionBounds();
492 ExceptionOr<bool> isPluginUnavailabilityIndicatorObscured(Element&);
493 ExceptionOr<String> unavailablePluginReplacementText(Element&);
494 bool isPluginSnapshotted(Element&);
496 #if ENABLE(MEDIA_SOURCE)
497 WEBCORE_TESTSUPPORT_EXPORT void initializeMockMediaSource();
498 Vector<String> bufferedSamplesForTrackID(SourceBuffer&, const AtomicString&);
499 Vector<String> enqueuedSamplesForTrackID(SourceBuffer&, const AtomicString&);
500 void setShouldGenerateTimestamps(SourceBuffer&, bool);
504 ExceptionOr<void> beginMediaSessionInterruption(const String&);
505 void endMediaSessionInterruption(const String&);
506 void applicationWillBecomeInactive();
507 void applicationDidBecomeActive();
508 void applicationWillEnterForeground(bool suspendedUnderLock) const;
509 void applicationDidEnterBackground(bool suspendedUnderLock) const;
510 ExceptionOr<void> setMediaSessionRestrictions(const String& mediaType, StringView restrictionsString);
511 ExceptionOr<String> mediaSessionRestrictions(const String& mediaType) const;
512 void setMediaElementRestrictions(HTMLMediaElement&, StringView restrictionsString);
513 ExceptionOr<void> postRemoteControlCommand(const String&, float argument);
514 bool elementIsBlockingDisplaySleep(HTMLMediaElement&) const;
517 #if ENABLE(MEDIA_SESSION)
518 void sendMediaSessionStartOfInterruptionNotification(MediaSessionInterruptingCategory);
519 void sendMediaSessionEndOfInterruptionNotification(MediaSessionInterruptingCategory);
520 String mediaSessionCurrentState(MediaSession&) const;
521 double mediaElementPlayerVolume(HTMLMediaElement&) const;
522 enum class MediaControlEvent { PlayPause, NextTrack, PreviousTrack };
523 void sendMediaControlEvent(MediaControlEvent);
526 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
527 void setMockMediaPlaybackTargetPickerEnabled(bool);
528 ExceptionOr<void> setMockMediaPlaybackTargetPickerState(const String& deviceName, const String& deviceState);
531 #if ENABLE(WEB_AUDIO)
532 void setAudioContextRestrictions(AudioContext&, StringView restrictionsString);
535 void simulateSystemSleep() const;
536 void simulateSystemWake() const;
538 enum class PageOverlayType { View, Document };
539 ExceptionOr<Ref<MockPageOverlay>> installMockPageOverlay(PageOverlayType);
540 ExceptionOr<String> pageOverlayLayerTreeAsText(unsigned short flags) const;
542 void setPageMuted(StringView);
543 String pageMediaState();
545 void setPageDefersLoading(bool);
546 ExceptionOr<bool> pageDefersLoading();
548 RefPtr<File> createFile(const String&);
549 void queueMicroTask(int);
550 bool testPreloaderSettingViewport();
552 #if ENABLE(CONTENT_FILTERING)
553 MockContentFilterSettings& mockContentFilterSettings();
556 #if ENABLE(CSS_SCROLL_SNAP)
557 ExceptionOr<String> scrollSnapOffsets(Element&);
558 void setPlatformMomentumScrollingPredictionEnabled(bool);
561 ExceptionOr<String> pathStringWithShrinkWrappedRects(const Vector<double>& rectComponents, double radius);
563 String getCurrentMediaControlsStatusForElement(HTMLMediaElement&);
565 String userVisibleString(const DOMURL&);
566 void setShowAllPlugins(bool);
568 String resourceLoadStatisticsForOrigin(const String& origin);
569 void setResourceLoadStatisticsEnabled(bool);
570 void setUserGrantsStorageAccess(bool);
572 #if ENABLE(STREAMS_API)
573 bool isReadableStreamDisturbed(JSC::ExecState&, JSC::JSValue);
574 JSC::JSValue cloneArrayBuffer(JSC::ExecState&, JSC::JSValue, JSC::JSValue, JSC::JSValue);
577 String composedTreeAsText(Node&);
579 bool isProcessingUserGesture();
580 double lastHandledUserGestureTimestamp();
582 void withUserGesture(RefPtr<VoidCallback>&&);
584 RefPtr<GCObservation> observeGC(JSC::JSValue);
586 enum class UserInterfaceLayoutDirection { LTR, RTL };
587 void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection);
589 bool userPrefersReducedMotion() const;
591 void reportBacktrace();
593 enum class BaseWritingDirection { Natural, Ltr, Rtl };
594 void setBaseWritingDirection(BaseWritingDirection);
596 #if ENABLE(POINTER_LOCK)
597 bool pageHasPendingPointerLock() const;
598 bool pageHasPointerLock() const;
601 Vector<String> accessKeyModifiers() const;
603 void setQuickLookPassword(const String&);
605 void setAsRunningUserScripts(Document&);
608 void simulateWebGLContextChanged(WebGLRenderingContext&);
609 void failNextGPUStatusCheck(WebGLRenderingContext&);
612 void setPageVisibility(bool isVisible);
615 void setH264HardwareEncoderAllowed(bool allowed);
618 #if ENABLE(MEDIA_STREAM)
619 void setCameraMediaStreamTrackOrientation(MediaStreamTrack&, int orientation);
620 ExceptionOr<void> setMediaDeviceState(const String& id, const String& property, bool value);
621 unsigned long trackAudioSampleCount() const { return m_trackAudioSampleCount; }
622 unsigned long trackVideoSampleCount() const { return m_trackVideoSampleCount; }
623 void observeMediaStreamTrack(MediaStreamTrack&);
624 using TrackFramePromise = DOMPromiseDeferred<IDLInterface<ImageData>>;
625 void grabNextMediaStreamTrackFrame(TrackFramePromise&&);
626 void delayMediaStreamTrackSamples(MediaStreamTrack&, float);
627 void setMediaStreamTrackMuted(MediaStreamTrack&, bool);
628 void removeMediaStreamTrack(MediaStream&, MediaStreamTrack&);
629 void simulateMediaStreamTrackCaptureSourceFailure(MediaStreamTrack&);
630 void setMediaStreamTrackIdentifier(MediaStreamTrack&, String&& id);
633 String audioSessionCategory() const;
635 void clearCacheStorageMemoryRepresentation(DOMPromiseDeferred<void>&&);
636 void cacheStorageEngineRepresentation(DOMPromiseDeferred<IDLDOMString>&&);
637 void setResponseSizeWithPadding(FetchResponse&, uint64_t size);
638 uint64_t responseSizeWithPadding(FetchResponse&) const;
640 void setConsoleMessageListener(RefPtr<StringCallback>&&);
642 #if ENABLE(SERVICE_WORKER)
643 using HasRegistrationPromise = DOMPromiseDeferred<IDLBoolean>;
644 void hasServiceWorkerRegistration(const String& clientURL, HasRegistrationPromise&&);
645 void terminateServiceWorker(ServiceWorker&);
646 bool hasServiceWorkerConnection();
649 #if ENABLE(APPLE_PAY)
650 MockPaymentCoordinator& mockPaymentCoordinator() const;
653 String timelineDescription(AnimationTimeline&);
654 void pauseTimeline(AnimationTimeline&);
655 void setTimelineCurrentTime(AnimationTimeline&, double);
657 void testIncomingSyncIPCMessageWhileWaitingForSyncReply();
659 #if ENABLE(WEB_AUTHN)
660 MockCredentialsMessenger& mockCredentialsMessenger() const;
663 String systemPreviewRelType();
664 bool isSystemPreviewLink(Element&) const;
665 bool isSystemPreviewImage(Element&) const;
667 bool usingAppleInternalSDK() const;
670 explicit Internals(Document&);
671 Document* contextDocument() const;
672 Frame* frame() const;
674 ExceptionOr<RenderedDocumentMarker*> markerAt(Node&, const String& markerType, unsigned index);
676 // RealtimeMediaSource::Observer API
677 #if ENABLE(MEDIA_STREAM)
678 void videoSampleAvailable(MediaSample&) final;
679 void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final { m_trackAudioSampleCount++; }
681 OrientationNotifier m_orientationNotifier;
682 unsigned long m_trackVideoSampleCount { 0 };
683 unsigned long m_trackAudioSampleCount { 0 };
684 RefPtr<MediaStreamTrack> m_track;
685 std::optional<TrackFramePromise> m_nextTrackFramePromise;
688 std::unique_ptr<InspectorStubFrontend> m_inspectorFrontend;
689 RefPtr<CacheStorageConnection> m_cacheStorageConnection;
691 #if ENABLE(APPLE_PAY)
692 MockPaymentCoordinator* m_mockPaymentCoordinator { nullptr };
695 #if ENABLE(WEB_AUTHN)
696 std::unique_ptr<MockCredentialsMessenger> m_mockCredentialsMessenger;
700 } // namespace WebCore