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"
32 #include "ExceptionOr.h"
33 #include "HEVCUtilities.h"
34 #include "JSDOMPromiseDeferred.h"
35 #include "OrientationNotifier.h"
36 #include "PageConsoleClient.h"
37 #include "RealtimeMediaSource.h"
38 #include <JavaScriptCore/Float32Array.h>
39 #include <wtf/Optional.h>
41 #if ENABLE(MEDIA_SESSION)
42 #include "MediaSessionInterruptionProvider.h"
46 #include "MediaElementSession.h"
51 class AnimationTimeline;
53 class CacheStorageConnection;
60 class ExtendableEvent;
65 class HTMLAnchorElement;
66 class HTMLImageElement;
67 class HTMLInputElement;
68 class HTMLLinkElement;
69 class HTMLMediaElement;
70 class HTMLPictureElement;
71 class HTMLSelectElement;
73 class InspectorStubFrontend;
74 class InternalSettings;
75 class MallocStatistics;
78 class MediaStreamTrack;
81 class MockContentFilterSettings;
82 class MockAuthenticatorCoordinator;
83 class MockPageOverlay;
84 class MockPaymentCoordinator;
87 class RTCPeerConnection;
89 class RenderedDocumentMarker;
91 class SerializedScriptValue;
96 class TypeConversions;
98 class WebGLRenderingContext;
101 #if ENABLE(SERVICE_WORKER)
105 class Internals final : public RefCounted<Internals>, private ContextDestructionObserver
106 #if ENABLE(MEDIA_STREAM)
107 , private RealtimeMediaSource::Observer
111 static Ref<Internals> create(Document&);
112 virtual ~Internals();
114 static void resetToConsistentState(Page&);
116 ExceptionOr<String> elementRenderTreeAsText(Element&);
117 bool hasPausedImageAnimations(Element&);
119 bool isPaintingFrequently(Element&);
120 void incrementFrequentPaintCounter(Element&);
122 String address(Node&);
123 bool nodeNeedsStyleRecalc(Node&);
124 String styleChangeType(Node&);
125 String description(JSC::JSValue);
127 bool isPreloaded(const String& url);
128 bool isLoadingFromMemoryCache(const String& url);
129 String fetchResponseSource(FetchResponse&);
130 String xhrResponseSource(XMLHttpRequest&);
131 bool isSharingStyleSheetContents(HTMLLinkElement&, HTMLLinkElement&);
132 bool isStyleSheetLoadingSubresources(HTMLLinkElement&);
133 enum class CachePolicy { UseProtocolCachePolicy, ReloadIgnoringCacheData, ReturnCacheDataElseLoad, ReturnCacheDataDontLoad };
134 void setOverrideCachePolicy(CachePolicy);
135 ExceptionOr<void> setCanShowModalDialogOverride(bool allow);
136 enum class ResourceLoadPriority { ResourceLoadPriorityVeryLow, ResourceLoadPriorityLow, ResourceLoadPriorityMedium, ResourceLoadPriorityHigh, ResourceLoadPriorityVeryHigh };
137 void setOverrideResourceLoadPriority(ResourceLoadPriority);
138 void setStrictRawResourceValidationPolicyDisabled(bool);
140 void clearMemoryCache();
141 void pruneMemoryCacheToSize(unsigned size);
142 void destroyDecodedDataForAllImages();
143 unsigned memoryCacheSize() const;
145 unsigned imageFrameIndex(HTMLImageElement&);
146 void setImageFrameDecodingDuration(HTMLImageElement&, float duration);
147 void resetImageAnimation(HTMLImageElement&);
148 bool isImageAnimating(HTMLImageElement&);
149 void setClearDecoderAfterAsyncFrameRequestForTesting(HTMLImageElement&, bool enabled);
150 unsigned imageDecodeCount(HTMLImageElement&);
151 unsigned pdfDocumentCachingCount(HTMLImageElement&);
152 void setLargeImageAsyncDecodingEnabledForTesting(HTMLImageElement&, bool enabled);
153 void setForceUpdateImageDataEnabledForTesting(HTMLImageElement&, bool enabled);
155 void setGridMaxTracksLimit(unsigned);
157 void clearPageCache();
158 unsigned pageCacheSize() const;
160 void disableTileSizeUpdateDelay();
162 void setSpeculativeTilingDelayDisabledForTesting(bool);
164 Ref<CSSComputedStyleDeclaration> computedStyleIncludingVisitedInfo(Element&) const;
166 Node* ensureUserAgentShadowRoot(Element& host);
167 Node* shadowRoot(Element& host);
168 ExceptionOr<String> shadowRootType(const Node&) const;
169 String shadowPseudoId(Element&);
170 void setShadowPseudoId(Element&, const String&);
172 // CSS Deferred Parsing Testing
173 unsigned deferredStyleRulesCount(StyleSheet&);
174 unsigned deferredGroupRulesCount(StyleSheet&);
175 unsigned deferredKeyframesRulesCount(StyleSheet&);
177 // DOMTimers throttling testing.
178 ExceptionOr<bool> isTimerThrottled(int timeoutId);
179 bool isRequestAnimationFrameThrottled() const;
180 double requestAnimationFrameInterval() const;
181 bool scriptedAnimationsAreSuspended() const;
182 bool areTimersThrottled() const;
184 enum EventThrottlingBehavior { Responsive, Unresponsive };
185 void setEventThrottlingBehaviorOverride(std::optional<EventThrottlingBehavior>);
186 std::optional<EventThrottlingBehavior> eventThrottlingBehaviorOverride() const;
188 // Spatial Navigation testing.
189 ExceptionOr<unsigned> lastSpatialNavigationCandidateCount() const;
191 // CSS Animation testing.
192 unsigned numberOfActiveAnimations() const;
193 ExceptionOr<bool> animationsAreSuspended() const;
194 ExceptionOr<void> suspendAnimations() const;
195 ExceptionOr<void> resumeAnimations() const;
196 ExceptionOr<bool> pauseAnimationAtTimeOnElement(const String& animationName, double pauseTime, Element&);
197 ExceptionOr<bool> pauseAnimationAtTimeOnPseudoElement(const String& animationName, double pauseTime, Element&, const String& pseudoId);
198 double animationsInterval() const;
200 // CSS Transition testing.
201 ExceptionOr<bool> pauseTransitionAtTimeOnElement(const String& propertyName, double pauseTime, Element&);
202 ExceptionOr<bool> pauseTransitionAtTimeOnPseudoElement(const String& property, double pauseTime, Element&, const String& pseudoId);
204 // Web Animations testing.
205 struct AcceleratedAnimation {
209 Vector<AcceleratedAnimation> acceleratedAnimationsForElement(Element&);
210 unsigned numberOfAnimationTimelineInvalidations() const;
212 // For animations testing, we need a way to get at pseudo elements.
213 ExceptionOr<RefPtr<Element>> pseudoElement(Element&, const String&);
215 Node* treeScopeRootNode(Node&);
216 Node* parentTreeScope(Node&);
218 String visiblePlaceholder(Element&);
219 void selectColorInColorChooser(HTMLInputElement&, const String& colorValue);
220 ExceptionOr<Vector<String>> formControlStateOfPreviousHistoryItem();
221 ExceptionOr<void> setFormControlStateOfPreviousHistoryItem(const Vector<String>&);
223 ExceptionOr<Ref<DOMRect>> absoluteCaretBounds();
225 Ref<DOMRect> boundingBox(Element&);
227 ExceptionOr<Ref<DOMRectList>> inspectorHighlightRects();
228 ExceptionOr<String> inspectorHighlightObject();
230 ExceptionOr<unsigned> markerCountForNode(Node&, const String&);
231 ExceptionOr<RefPtr<Range>> markerRangeForNode(Node&, const String& markerType, unsigned index);
232 ExceptionOr<String> markerDescriptionForNode(Node&, const String& markerType, unsigned index);
233 ExceptionOr<String> dumpMarkerRects(const String& markerType);
234 void addTextMatchMarker(const Range&, bool isActive);
235 ExceptionOr<void> setMarkedTextMatchesAreHighlighted(bool);
237 void invalidateFontCache();
238 void setFontSmoothingEnabled(bool);
240 ExceptionOr<void> setLowPowerModeEnabled(bool);
242 ExceptionOr<void> setScrollViewPosition(int x, int y);
243 ExceptionOr<void> unconstrainedScrollTo(Element&, double x, double y);
245 ExceptionOr<Ref<DOMRect>> layoutViewportRect();
246 ExceptionOr<Ref<DOMRect>> visualViewportRect();
248 ExceptionOr<void> setViewBaseBackgroundColor(const String& colorValue);
250 ExceptionOr<void> setPagination(const String& mode, int gap, int pageLength);
251 ExceptionOr<void> setPaginationLineGridEnabled(bool);
252 ExceptionOr<String> configurationForViewport(float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight);
254 ExceptionOr<bool> wasLastChangeUserEdit(Element& textField);
255 bool elementShouldAutoComplete(HTMLInputElement&);
256 void setEditingValue(HTMLInputElement&, const String&);
257 void setAutofilled(HTMLInputElement&, bool enabled);
258 enum class AutoFillButtonType { None, Contacts, Credentials, StrongPassword };
259 void setShowAutoFillButton(HTMLInputElement&, AutoFillButtonType);
260 AutoFillButtonType autoFillButtonType(const HTMLInputElement&);
261 AutoFillButtonType lastAutoFillButtonType(const HTMLInputElement&);
262 ExceptionOr<void> scrollElementToRect(Element&, int x, int y, int w, int h);
264 ExceptionOr<String> autofillFieldName(Element&);
266 ExceptionOr<void> invalidateControlTints();
268 RefPtr<Range> rangeFromLocationAndLength(Element& scope, int rangeLocation, int rangeLength);
269 unsigned locationFromRange(Element& scope, const Range&);
270 unsigned lengthFromRange(Element& scope, const Range&);
271 String rangeAsText(const Range&);
272 Ref<Range> subrange(Range&, int rangeLocation, int rangeLength);
273 ExceptionOr<RefPtr<Range>> rangeForDictionaryLookupAtLocation(int x, int y);
274 RefPtr<Range> rangeOfStringNearLocation(const Range&, const String&, unsigned);
276 ExceptionOr<void> setDelegatesScrolling(bool enabled);
278 ExceptionOr<int> lastSpellCheckRequestSequence();
279 ExceptionOr<int> lastSpellCheckProcessedSequence();
281 Vector<String> userPreferredLanguages() const;
282 void setUserPreferredLanguages(const Vector<String>&);
284 Vector<String> userPreferredAudioCharacteristics() const;
285 void setUserPreferredAudioCharacteristic(const String&);
287 ExceptionOr<unsigned> wheelEventHandlerCount();
288 ExceptionOr<unsigned> touchEventHandlerCount();
290 ExceptionOr<Ref<DOMRectList>> touchEventRectsForEvent(const String&);
291 ExceptionOr<Ref<DOMRectList>> passiveTouchEventListenerRects();
293 ExceptionOr<RefPtr<NodeList>> nodesFromRect(Document&, int x, int y, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowUserAgentShadowContent, bool allowChildFrameContent) const;
295 String parserMetaData(JSC::JSValue = JSC::JSValue::JSUndefined);
297 void updateEditorUINowIfScheduled();
299 bool sentenceRetroCorrectionEnabled() const
301 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
307 bool hasSpellingMarker(int from, int length);
308 bool hasGrammarMarker(int from, int length);
309 bool hasAutocorrectedMarker(int from, int length);
310 void setContinuousSpellCheckingEnabled(bool);
311 void setAutomaticQuoteSubstitutionEnabled(bool);
312 void setAutomaticLinkDetectionEnabled(bool);
313 void setAutomaticDashSubstitutionEnabled(bool);
314 void setAutomaticTextReplacementEnabled(bool);
315 void setAutomaticSpellingCorrectionEnabled(bool);
317 void handleAcceptedCandidate(const String& candidate, unsigned location, unsigned length);
319 bool isOverwriteModeEnabled();
320 void toggleOverwriteModeEnabled();
322 ExceptionOr<RefPtr<Range>> rangeOfString(const String&, RefPtr<Range>&&, const Vector<String>& findOptions);
323 ExceptionOr<unsigned> countMatchesForText(const String&, const Vector<String>& findOptions, const String& markMatches);
324 ExceptionOr<unsigned> countFindMatches(const String&, const Vector<String>& findOptions);
326 unsigned numberOfScrollableAreas();
328 ExceptionOr<bool> isPageBoxVisible(int pageNumber);
330 static const char* internalsId;
332 InternalSettings* settings() const;
333 unsigned workerThreadCount() const;
334 ExceptionOr<bool> areSVGAnimationsPaused() const;
335 ExceptionOr<double> svgAnimationsInterval(SVGSVGElement&) const;
338 // Values need to be kept in sync with Internals.idl.
339 LAYER_TREE_INCLUDES_VISIBLE_RECTS = 1,
340 LAYER_TREE_INCLUDES_TILE_CACHES = 2,
341 LAYER_TREE_INCLUDES_REPAINT_RECTS = 4,
342 LAYER_TREE_INCLUDES_PAINTING_PHASES = 8,
343 LAYER_TREE_INCLUDES_CONTENT_LAYERS = 16,
344 LAYER_TREE_INCLUDES_ACCELERATES_DRAWING = 32,
345 LAYER_TREE_INCLUDES_BACKING_STORE_ATTACHED = 64,
347 ExceptionOr<String> layerTreeAsText(Document&, unsigned short flags) const;
348 ExceptionOr<uint64_t> layerIDForElement(Element&);
349 ExceptionOr<String> repaintRectsAsText() const;
350 ExceptionOr<String> scrollingStateTreeAsText() const;
351 ExceptionOr<String> mainThreadScrollingReasons() const;
352 ExceptionOr<Ref<DOMRectList>> nonFastScrollableRects() const;
354 ExceptionOr<void> setElementUsesDisplayListDrawing(Element&, bool usesDisplayListDrawing);
355 ExceptionOr<void> setElementTracksDisplayListReplay(Element&, bool isTrackingReplay);
358 // Values need to be kept in sync with Internals.idl.
359 DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS = 1,
361 ExceptionOr<String> displayListForElement(Element&, unsigned short flags);
362 ExceptionOr<String> replayDisplayListForElement(Element&, unsigned short flags);
364 ExceptionOr<void> garbageCollectDocumentResources() const;
366 void beginSimulatedMemoryPressure();
367 void endSimulatedMemoryPressure();
368 bool isUnderMemoryPressure();
370 ExceptionOr<void> insertAuthorCSS(const String&) const;
371 ExceptionOr<void> insertUserCSS(const String&) const;
373 unsigned numberOfLiveNodes() const;
374 unsigned numberOfLiveDocuments() const;
375 unsigned referencingNodeCount(const Document&) const;
377 #if ENABLE(INTERSECTION_OBSERVER)
378 unsigned numberOfIntersectionObservers(const Document&) const;
381 uint64_t documentIdentifier(const Document&) const;
382 bool isDocumentAlive(uint64_t documentIdentifier) const;
384 String serviceWorkerClientIdentifier(const Document&) const;
386 RefPtr<WindowProxy> openDummyInspectorFrontend(const String& url);
387 void closeDummyInspectorFrontend();
388 ExceptionOr<void> setInspectorIsUnderTest(bool);
390 String counterValue(Element&);
392 int pageNumber(Element&, float pageWidth = 800, float pageHeight = 600);
393 Vector<String> shortcutIconURLs() const;
395 int numberOfPages(float pageWidthInPixels = 800, float pageHeightInPixels = 600);
396 ExceptionOr<String> pageProperty(const String& propertyName, int pageNumber) const;
397 ExceptionOr<String> pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const;
399 ExceptionOr<float> pageScaleFactor() const;
401 ExceptionOr<void> setPageScaleFactor(float scaleFactor, int x, int y);
402 ExceptionOr<void> setPageZoomFactor(float);
403 ExceptionOr<void> setTextZoomFactor(float);
405 ExceptionOr<void> setUseFixedLayout(bool);
406 ExceptionOr<void> setFixedLayoutSize(int width, int height);
407 ExceptionOr<void> setViewExposedRect(float left, float top, float width, float height);
408 void setPrinting(int width, int height);
410 void setHeaderHeight(float);
411 void setFooterHeight(float);
413 void setTopContentInset(float);
415 #if ENABLE(FULLSCREEN_API)
416 void webkitWillEnterFullScreenForElement(Element&);
417 void webkitDidEnterFullScreenForElement(Element&);
418 void webkitWillExitFullScreenForElement(Element&);
419 void webkitDidExitFullScreenForElement(Element&);
420 bool isAnimatingFullScreen() const;
423 struct FullscreenInsets {
429 void setFullscreenInsets(FullscreenInsets);
430 void setFullscreenAutoHideDuration(double);
431 void setFullscreenControlsHidden(bool);
433 WEBCORE_TESTSUPPORT_EXPORT void setApplicationCacheOriginQuota(unsigned long long);
435 void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme);
436 void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme);
438 void registerDefaultPortForProtocol(unsigned short port, const String& protocol);
440 Ref<MallocStatistics> mallocStatistics() const;
441 Ref<TypeConversions> typeConversions() const;
442 Ref<MemoryInfo> memoryInfo() const;
444 Vector<String> getReferencedFilePaths() const;
446 ExceptionOr<void> startTrackingRepaints();
447 ExceptionOr<void> stopTrackingRepaints();
449 ExceptionOr<void> startTrackingLayerFlushes();
450 ExceptionOr<unsigned> layerFlushCount();
452 ExceptionOr<void> startTrackingStyleRecalcs();
453 ExceptionOr<unsigned> styleRecalcCount();
454 unsigned lastStyleUpdateSize() const;
456 ExceptionOr<void> startTrackingCompositingUpdates();
457 ExceptionOr<unsigned> compositingUpdateCount();
459 enum CompositingPolicy { Normal, Conservative };
460 ExceptionOr<void> setCompositingPolicyOverride(std::optional<CompositingPolicy>);
461 ExceptionOr<std::optional<CompositingPolicy>> compositingPolicyOverride() const;
463 ExceptionOr<void> updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*);
464 unsigned layoutCount() const;
466 Ref<ArrayBuffer> serializeObject(const RefPtr<SerializedScriptValue>&) const;
467 Ref<SerializedScriptValue> deserializeBuffer(ArrayBuffer&) const;
469 bool isFromCurrentWorld(JSC::JSValue) const;
471 void setUsesOverlayScrollbars(bool);
472 void setUsesMockScrollAnimator(bool);
474 ExceptionOr<String> getCurrentCursorInfo();
476 String markerTextForListItem(Element&);
478 String toolTipFromElement(Element&) const;
480 void forceReload(bool endToEnd);
481 void reloadExpiredOnly();
483 void enableAutoSizeMode(bool enabled, int minimumWidth, int minimumHeight, int maximumWidth, int maximumHeight);
485 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
486 void initializeMockCDM();
489 #if ENABLE(ENCRYPTED_MEDIA)
490 Ref<MockCDMFactory> registerMockCDM();
493 void enableMockMediaCapabilities();
495 #if ENABLE(SPEECH_SYNTHESIS)
496 void enableMockSpeechSynthesizer();
499 #if ENABLE(MEDIA_STREAM)
500 void setMockMediaCaptureDevicesEnabled(bool);
504 void emulateRTCPeerConnectionPlatformEvent(RTCPeerConnection&, const String& action);
505 void useMockRTCPeerConnectionFactory(const String&);
506 void setICECandidateFiltering(bool);
507 void setEnumeratingAllNetworkInterfacesEnabled(bool);
508 void stopPeerConnection(RTCPeerConnection&);
509 void applyRotationForOutgoingVideoSources(RTCPeerConnection&);
512 String getImageSourceURL(Element&);
515 Vector<String> mediaResponseSources(HTMLMediaElement&);
516 Vector<String> mediaResponseContentRanges(HTMLMediaElement&);
517 void simulateAudioInterruption(HTMLMediaElement&);
518 ExceptionOr<bool> mediaElementHasCharacteristic(HTMLMediaElement&, const String&);
519 void beginSimulatedHDCPError(HTMLMediaElement&);
520 void endSimulatedHDCPError(HTMLMediaElement&);
522 bool elementShouldBufferData(HTMLMediaElement&);
525 bool isSelectPopupVisible(HTMLSelectElement&);
527 ExceptionOr<String> captionsStyleSheetOverride();
528 ExceptionOr<void> setCaptionsStyleSheetOverride(const String&);
529 ExceptionOr<void> setPrimaryAudioTrackLanguageOverride(const String&);
530 ExceptionOr<void> setCaptionDisplayMode(const String&);
533 Ref<TimeRanges> createTimeRanges(Float32Array& startTimes, Float32Array& endTimes);
534 double closestTimeToTimeRanges(double time, TimeRanges&);
537 ExceptionOr<Ref<DOMRect>> selectionBounds();
539 ExceptionOr<bool> isPluginUnavailabilityIndicatorObscured(Element&);
540 ExceptionOr<String> unavailablePluginReplacementText(Element&);
541 bool isPluginSnapshotted(Element&);
543 #if ENABLE(MEDIA_SOURCE)
544 WEBCORE_TESTSUPPORT_EXPORT void initializeMockMediaSource();
545 Vector<String> bufferedSamplesForTrackID(SourceBuffer&, const AtomicString&);
546 Vector<String> enqueuedSamplesForTrackID(SourceBuffer&, const AtomicString&);
547 void setShouldGenerateTimestamps(SourceBuffer&, bool);
551 ExceptionOr<void> beginMediaSessionInterruption(const String&);
552 void endMediaSessionInterruption(const String&);
553 void applicationWillBecomeInactive();
554 void applicationDidBecomeActive();
555 void applicationWillEnterForeground(bool suspendedUnderLock) const;
556 void applicationDidEnterBackground(bool suspendedUnderLock) const;
557 ExceptionOr<void> setMediaSessionRestrictions(const String& mediaType, StringView restrictionsString);
558 ExceptionOr<String> mediaSessionRestrictions(const String& mediaType) const;
559 void setMediaElementRestrictions(HTMLMediaElement&, StringView restrictionsString);
560 ExceptionOr<void> postRemoteControlCommand(const String&, float argument);
561 bool elementIsBlockingDisplaySleep(HTMLMediaElement&) const;
564 #if ENABLE(MEDIA_SESSION)
565 void sendMediaSessionStartOfInterruptionNotification(MediaSessionInterruptingCategory);
566 void sendMediaSessionEndOfInterruptionNotification(MediaSessionInterruptingCategory);
567 String mediaSessionCurrentState(MediaSession&) const;
568 double mediaElementPlayerVolume(HTMLMediaElement&) const;
569 enum class MediaControlEvent { PlayPause, NextTrack, PreviousTrack };
570 void sendMediaControlEvent(MediaControlEvent);
573 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
574 void setMockMediaPlaybackTargetPickerEnabled(bool);
575 ExceptionOr<void> setMockMediaPlaybackTargetPickerState(const String& deviceName, const String& deviceState);
578 #if ENABLE(WEB_AUDIO)
579 void setAudioContextRestrictions(AudioContext&, StringView restrictionsString);
582 void simulateSystemSleep() const;
583 void simulateSystemWake() const;
585 enum class PageOverlayType { View, Document };
586 ExceptionOr<Ref<MockPageOverlay>> installMockPageOverlay(PageOverlayType);
587 ExceptionOr<String> pageOverlayLayerTreeAsText(unsigned short flags) const;
589 void setPageMuted(StringView);
590 String pageMediaState();
592 void setPageDefersLoading(bool);
593 ExceptionOr<bool> pageDefersLoading();
595 RefPtr<File> createFile(const String&);
596 void queueMicroTask(int);
597 bool testPreloaderSettingViewport();
599 #if ENABLE(CONTENT_FILTERING)
600 MockContentFilterSettings& mockContentFilterSettings();
603 #if ENABLE(CSS_SCROLL_SNAP)
604 ExceptionOr<String> scrollSnapOffsets(Element&);
605 void setPlatformMomentumScrollingPredictionEnabled(bool);
608 ExceptionOr<String> pathStringWithShrinkWrappedRects(const Vector<double>& rectComponents, double radius);
610 String getCurrentMediaControlsStatusForElement(HTMLMediaElement&);
612 String userVisibleString(const DOMURL&);
613 void setShowAllPlugins(bool);
615 String resourceLoadStatisticsForOrigin(const String& origin);
616 void setResourceLoadStatisticsEnabled(bool);
617 void setUserGrantsStorageAccess(bool);
619 #if ENABLE(STREAMS_API)
620 bool isReadableStreamDisturbed(JSC::ExecState&, JSC::JSValue);
621 JSC::JSValue cloneArrayBuffer(JSC::ExecState&, JSC::JSValue, JSC::JSValue, JSC::JSValue);
624 String composedTreeAsText(Node&);
626 bool isProcessingUserGesture();
627 double lastHandledUserGestureTimestamp();
629 void withUserGesture(RefPtr<VoidCallback>&&);
631 RefPtr<GCObservation> observeGC(JSC::JSValue);
633 enum class UserInterfaceLayoutDirection : uint8_t { LTR, RTL };
634 void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection);
636 bool userPrefersReducedMotion() const;
638 void reportBacktrace();
640 enum class BaseWritingDirection { Natural, Ltr, Rtl };
641 void setBaseWritingDirection(BaseWritingDirection);
643 #if ENABLE(POINTER_LOCK)
644 bool pageHasPendingPointerLock() const;
645 bool pageHasPointerLock() const;
648 Vector<String> accessKeyModifiers() const;
650 void setQuickLookPassword(const String&);
652 void setAsRunningUserScripts(Document&);
655 void simulateWebGLContextChanged(WebGLRenderingContext&);
656 void failNextGPUStatusCheck(WebGLRenderingContext&);
659 void setPageVisibility(bool isVisible);
660 void setPageIsFocusedAndActive(bool);
664 void setH264HardwareEncoderAllowed(bool allowed);
667 #if ENABLE(MEDIA_STREAM)
668 void setCameraMediaStreamTrackOrientation(MediaStreamTrack&, int orientation);
669 ExceptionOr<void> setMediaDeviceState(const String& id, const String& property, bool value);
670 unsigned long trackAudioSampleCount() const { return m_trackAudioSampleCount; }
671 unsigned long trackVideoSampleCount() const { return m_trackVideoSampleCount; }
672 void observeMediaStreamTrack(MediaStreamTrack&);
673 using TrackFramePromise = DOMPromiseDeferred<IDLInterface<ImageData>>;
674 void grabNextMediaStreamTrackFrame(TrackFramePromise&&);
675 void delayMediaStreamTrackSamples(MediaStreamTrack&, float);
676 void setMediaStreamTrackMuted(MediaStreamTrack&, bool);
677 void removeMediaStreamTrack(MediaStream&, MediaStreamTrack&);
678 void simulateMediaStreamTrackCaptureSourceFailure(MediaStreamTrack&);
679 void setMediaStreamTrackIdentifier(MediaStreamTrack&, String&& id);
682 String audioSessionCategory() const;
683 double preferredAudioBufferSize() const;
685 void clearCacheStorageMemoryRepresentation(DOMPromiseDeferred<void>&&);
686 void cacheStorageEngineRepresentation(DOMPromiseDeferred<IDLDOMString>&&);
687 void setResponseSizeWithPadding(FetchResponse&, uint64_t size);
688 uint64_t responseSizeWithPadding(FetchResponse&) const;
690 void setConsoleMessageListener(RefPtr<StringCallback>&&);
692 #if ENABLE(SERVICE_WORKER)
693 using HasRegistrationPromise = DOMPromiseDeferred<IDLBoolean>;
694 void hasServiceWorkerRegistration(const String& clientURL, HasRegistrationPromise&&);
695 void terminateServiceWorker(ServiceWorker&);
696 bool hasServiceWorkerConnection();
699 #if ENABLE(APPLE_PAY)
700 MockPaymentCoordinator& mockPaymentCoordinator() const;
703 String timelineDescription(AnimationTimeline&);
704 void pauseTimeline(AnimationTimeline&);
705 void setTimelineCurrentTime(AnimationTimeline&, double);
707 void testIncomingSyncIPCMessageWhileWaitingForSyncReply();
709 #if ENABLE(WEB_AUTHN)
710 MockAuthenticatorCoordinator& mockAuthenticatorCoordinator() const;
713 bool isSystemPreviewLink(Element&) const;
714 bool isSystemPreviewImage(Element&) const;
716 bool usingAppleInternalSDK() const;
718 struct NowPlayingState {
722 uint64_t uniqueIdentifier;
723 bool hasActiveSession;
724 bool registeredAsNowPlayingApplication;
726 ExceptionOr<NowPlayingState> nowPlayingState() const;
729 using PlaybackControlsPurpose = MediaElementSession::PlaybackControlsPurpose;
730 RefPtr<HTMLMediaElement> bestMediaElementForShowingPlaybackControlsManager(PlaybackControlsPurpose);
732 using MediaSessionState = PlatformMediaSession::State;
733 MediaSessionState mediaSessionState(HTMLMediaElement&);
736 void setCaptureExtraNetworkLoadMetricsEnabled(bool);
737 String ongoingLoadsDescriptions() const;
739 void reloadWithoutContentExtensions();
741 void setUseSystemAppearance(bool);
743 size_t pluginCount();
745 void notifyResourceLoadObserver();
747 unsigned primaryScreenDisplayID();
749 bool supportsVCPEncoder();
751 using HEVCParameterSet = WebCore::HEVCParameterSet;
752 std::optional<HEVCParameterSet> parseHEVCCodecParameters(const String& codecString);
758 // Expiration dates are expressed as milliseconds since the UNIX epoch.
759 double expires { 0 };
760 bool isHttpOnly { false };
761 bool isSecure { false };
762 bool isSession { false };
763 bool isSameSiteLax { false };
764 bool isSameSiteStrict { false };
766 CookieData(Cookie cookie)
768 , value(cookie.value)
769 , domain(cookie.domain)
770 , expires(cookie.expires)
771 , isHttpOnly(cookie.httpOnly)
772 , isSecure(cookie.secure)
773 , isSession(cookie.session)
774 , isSameSiteLax(cookie.sameSite == Cookie::SameSitePolicy::Lax)
775 , isSameSiteStrict(cookie.sameSite == Cookie::SameSitePolicy::Strict)
777 ASSERT(!(isSameSiteLax && isSameSiteStrict));
784 Vector<CookieData> getCookies() const;
787 explicit Internals(Document&);
788 Document* contextDocument() const;
789 Frame* frame() const;
791 ExceptionOr<RenderedDocumentMarker*> markerAt(Node&, const String& markerType, unsigned index);
793 // RealtimeMediaSource::Observer API
794 #if ENABLE(MEDIA_STREAM)
795 void videoSampleAvailable(MediaSample&) final;
796 void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final { m_trackAudioSampleCount++; }
798 OrientationNotifier m_orientationNotifier;
799 unsigned long m_trackVideoSampleCount { 0 };
800 unsigned long m_trackAudioSampleCount { 0 };
801 RefPtr<MediaStreamTrack> m_track;
802 std::optional<TrackFramePromise> m_nextTrackFramePromise;
805 std::unique_ptr<InspectorStubFrontend> m_inspectorFrontend;
806 RefPtr<CacheStorageConnection> m_cacheStorageConnection;
808 #if ENABLE(APPLE_PAY)
809 MockPaymentCoordinator* m_mockPaymentCoordinator { nullptr };
812 #if ENABLE(WEB_AUTHN)
813 WeakPtr<MockAuthenticatorCoordinator> m_mockAuthenticatorCoordinator;
817 } // namespace WebCore