2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013-2019 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"
35 #include "OrientationNotifier.h"
36 #include "PageConsoleClient.h"
37 #include "RealtimeMediaSource.h"
38 #include "TextIndicator.h"
39 #include <JavaScriptCore/Float32Array.h>
40 #include <wtf/Optional.h>
42 #if ENABLE(MEDIA_SESSION)
43 #include "MediaSessionInterruptionProvider.h"
47 #include "MediaElementSession.h"
52 class AnimationTimeline;
54 class CacheStorageConnection;
57 class DOMRectReadOnly;
63 class ExtendableEvent;
68 class HTMLAnchorElement;
69 class HTMLImageElement;
70 class HTMLInputElement;
71 class HTMLLinkElement;
72 class HTMLMediaElement;
73 class HTMLPictureElement;
74 class HTMLSelectElement;
76 class InspectorStubFrontend;
77 class InternalSettings;
78 class MallocStatistics;
81 class MediaStreamTrack;
84 class MockContentFilterSettings;
85 class MockPageOverlay;
86 class MockPaymentCoordinator;
89 class RTCPeerConnection;
91 class RenderedDocumentMarker;
93 class SerializedScriptValue;
98 class TypeConversions;
99 class UnsuspendableActiveDOMObject;
101 class WebGLRenderingContext;
103 class XMLHttpRequest;
105 #if ENABLE(VIDEO_TRACK)
106 class TextTrackCueGeneric;
109 #if ENABLE(SERVICE_WORKER)
113 template<typename IDLType> class DOMPromiseDeferred;
115 struct MockWebAuthenticationConfiguration;
117 class Internals final : public RefCounted<Internals>, private ContextDestructionObserver
118 #if ENABLE(MEDIA_STREAM)
119 , private RealtimeMediaSource::Observer
123 static Ref<Internals> create(Document&);
124 virtual ~Internals();
126 static void resetToConsistentState(Page&);
128 ExceptionOr<String> elementRenderTreeAsText(Element&);
129 bool hasPausedImageAnimations(Element&);
131 bool isPaintingFrequently(Element&);
132 void incrementFrequentPaintCounter(Element&);
134 String address(Node&);
135 bool nodeNeedsStyleRecalc(Node&);
136 String styleChangeType(Node&);
137 String description(JSC::JSValue);
139 bool isPreloaded(const String& url);
140 bool isLoadingFromMemoryCache(const String& url);
141 String fetchResponseSource(FetchResponse&);
142 String xhrResponseSource(XMLHttpRequest&);
143 bool isSharingStyleSheetContents(HTMLLinkElement&, HTMLLinkElement&);
144 bool isStyleSheetLoadingSubresources(HTMLLinkElement&);
145 enum class CachePolicy { UseProtocolCachePolicy, ReloadIgnoringCacheData, ReturnCacheDataElseLoad, ReturnCacheDataDontLoad };
146 void setOverrideCachePolicy(CachePolicy);
147 ExceptionOr<void> setCanShowModalDialogOverride(bool allow);
148 enum class ResourceLoadPriority { ResourceLoadPriorityVeryLow, ResourceLoadPriorityLow, ResourceLoadPriorityMedium, ResourceLoadPriorityHigh, ResourceLoadPriorityVeryHigh };
149 void setOverrideResourceLoadPriority(ResourceLoadPriority);
150 void setStrictRawResourceValidationPolicyDisabled(bool);
152 void clearMemoryCache();
153 void pruneMemoryCacheToSize(unsigned size);
154 void destroyDecodedDataForAllImages();
155 unsigned memoryCacheSize() const;
157 unsigned imageFrameIndex(HTMLImageElement&);
158 unsigned imageFrameCount(HTMLImageElement&);
159 float imageFrameDurationAtIndex(HTMLImageElement&, unsigned index);
160 void setImageFrameDecodingDuration(HTMLImageElement&, float duration);
161 void resetImageAnimation(HTMLImageElement&);
162 bool isImageAnimating(HTMLImageElement&);
163 unsigned imagePendingDecodePromisesCountForTesting(HTMLImageElement&);
164 void setClearDecoderAfterAsyncFrameRequestForTesting(HTMLImageElement&, bool enabled);
165 unsigned imageDecodeCount(HTMLImageElement&);
166 unsigned pdfDocumentCachingCount(HTMLImageElement&);
167 void setLargeImageAsyncDecodingEnabledForTesting(HTMLImageElement&, bool enabled);
168 void setForceUpdateImageDataEnabledForTesting(HTMLImageElement&, bool enabled);
170 void setGridMaxTracksLimit(unsigned);
172 void clearBackForwardCache();
173 unsigned backForwardCacheSize() const;
174 void preventDocumentForEnteringBackForwardCache();
176 void disableTileSizeUpdateDelay();
178 void setSpeculativeTilingDelayDisabledForTesting(bool);
180 Ref<CSSComputedStyleDeclaration> computedStyleIncludingVisitedInfo(Element&) const;
182 Node* ensureUserAgentShadowRoot(Element& host);
183 Node* shadowRoot(Element& host);
184 ExceptionOr<String> shadowRootType(const Node&) const;
185 String shadowPseudoId(Element&);
186 void setShadowPseudoId(Element&, const String&);
188 // CSS Deferred Parsing Testing
189 unsigned deferredStyleRulesCount(StyleSheet&);
190 unsigned deferredGroupRulesCount(StyleSheet&);
191 unsigned deferredKeyframesRulesCount(StyleSheet&);
193 // DOMTimers throttling testing.
194 ExceptionOr<bool> isTimerThrottled(int timeoutId);
195 bool isRequestAnimationFrameThrottled() const;
196 double requestAnimationFrameInterval() const;
197 bool scriptedAnimationsAreSuspended() const;
198 bool areTimersThrottled() const;
200 enum EventThrottlingBehavior { Responsive, Unresponsive };
201 void setEventThrottlingBehaviorOverride(Optional<EventThrottlingBehavior>);
202 Optional<EventThrottlingBehavior> eventThrottlingBehaviorOverride() const;
204 // Spatial Navigation testing.
205 ExceptionOr<unsigned> lastSpatialNavigationCandidateCount() const;
207 // CSS Animation testing.
208 unsigned numberOfActiveAnimations() const;
209 ExceptionOr<bool> animationsAreSuspended() const;
210 ExceptionOr<void> suspendAnimations() const;
211 ExceptionOr<void> resumeAnimations() const;
212 ExceptionOr<bool> pauseAnimationAtTimeOnElement(const String& animationName, double pauseTime, Element&);
213 ExceptionOr<bool> pauseAnimationAtTimeOnPseudoElement(const String& animationName, double pauseTime, Element&, const String& pseudoId);
214 double animationsInterval() const;
216 // CSS Transition testing.
217 ExceptionOr<bool> pauseTransitionAtTimeOnElement(const String& propertyName, double pauseTime, Element&);
218 ExceptionOr<bool> pauseTransitionAtTimeOnPseudoElement(const String& property, double pauseTime, Element&, const String& pseudoId);
220 // Web Animations testing.
221 struct AcceleratedAnimation {
225 Vector<AcceleratedAnimation> acceleratedAnimationsForElement(Element&);
226 unsigned numberOfAnimationTimelineInvalidations() const;
228 // For animations testing, we need a way to get at pseudo elements.
229 ExceptionOr<RefPtr<Element>> pseudoElement(Element&, const String&);
231 Node* treeScopeRootNode(Node&);
232 Node* parentTreeScope(Node&);
234 String visiblePlaceholder(Element&);
235 void selectColorInColorChooser(HTMLInputElement&, const String& colorValue);
236 ExceptionOr<Vector<String>> formControlStateOfPreviousHistoryItem();
237 ExceptionOr<void> setFormControlStateOfPreviousHistoryItem(const Vector<String>&);
239 ExceptionOr<Ref<DOMRect>> absoluteCaretBounds();
240 ExceptionOr<bool> isCaretBlinkingSuspended();
242 Ref<DOMRect> boundingBox(Element&);
244 ExceptionOr<Ref<DOMRectList>> inspectorHighlightRects();
246 ExceptionOr<unsigned> markerCountForNode(Node&, const String&);
247 ExceptionOr<RefPtr<Range>> markerRangeForNode(Node&, const String& markerType, unsigned index);
248 ExceptionOr<String> markerDescriptionForNode(Node&, const String& markerType, unsigned index);
249 ExceptionOr<String> dumpMarkerRects(const String& markerType);
250 void addTextMatchMarker(const Range&, bool isActive);
251 ExceptionOr<void> setMarkedTextMatchesAreHighlighted(bool);
253 void invalidateFontCache();
254 void setFontSmoothingEnabled(bool);
256 ExceptionOr<void> setLowPowerModeEnabled(bool);
258 ExceptionOr<void> setScrollViewPosition(int x, int y);
259 ExceptionOr<void> unconstrainedScrollTo(Element&, double x, double y);
261 ExceptionOr<Ref<DOMRect>> layoutViewportRect();
262 ExceptionOr<Ref<DOMRect>> visualViewportRect();
264 ExceptionOr<void> setViewIsTransparent(bool);
266 ExceptionOr<String> viewBaseBackgroundColor();
267 ExceptionOr<void> setViewBaseBackgroundColor(const String& colorValue);
269 ExceptionOr<void> setPagination(const String& mode, int gap, int pageLength);
270 ExceptionOr<void> setPaginationLineGridEnabled(bool);
271 ExceptionOr<String> configurationForViewport(float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight);
273 ExceptionOr<bool> wasLastChangeUserEdit(Element& textField);
274 bool elementShouldAutoComplete(HTMLInputElement&);
275 void setAutofilled(HTMLInputElement&, bool enabled);
276 void setAutoFilledAndViewable(HTMLInputElement&, bool enabled);
277 enum class AutoFillButtonType { None, Contacts, Credentials, StrongPassword, CreditCard };
278 void setShowAutoFillButton(HTMLInputElement&, AutoFillButtonType);
279 AutoFillButtonType autoFillButtonType(const HTMLInputElement&);
280 AutoFillButtonType lastAutoFillButtonType(const HTMLInputElement&);
281 ExceptionOr<void> scrollElementToRect(Element&, int x, int y, int w, int h);
283 ExceptionOr<String> autofillFieldName(Element&);
285 ExceptionOr<void> invalidateControlTints();
287 RefPtr<Range> rangeFromLocationAndLength(Element& scope, int rangeLocation, int rangeLength);
288 unsigned locationFromRange(Element& scope, const Range&);
289 unsigned lengthFromRange(Element& scope, const Range&);
290 String rangeAsText(const Range&);
291 String rangeAsTextUsingBackwardsTextIterator(const Range&);
292 Ref<Range> subrange(Range&, int rangeLocation, int rangeLength);
293 ExceptionOr<RefPtr<Range>> rangeForDictionaryLookupAtLocation(int x, int y);
294 RefPtr<Range> rangeOfStringNearLocation(const Range&, const String&, unsigned);
296 ExceptionOr<void> setDelegatesScrolling(bool enabled);
298 ExceptionOr<int> lastSpellCheckRequestSequence();
299 ExceptionOr<int> lastSpellCheckProcessedSequence();
301 Vector<String> userPreferredLanguages() const;
302 void setUserPreferredLanguages(const Vector<String>&);
304 Vector<String> userPreferredAudioCharacteristics() const;
305 void setUserPreferredAudioCharacteristic(const String&);
307 void setMaxCanvasPixelMemory(unsigned);
309 ExceptionOr<unsigned> wheelEventHandlerCount();
310 ExceptionOr<unsigned> touchEventHandlerCount();
312 ExceptionOr<Ref<DOMRectList>> touchEventRectsForEvent(const String&);
313 ExceptionOr<Ref<DOMRectList>> passiveTouchEventListenerRects();
315 ExceptionOr<RefPtr<NodeList>> nodesFromRect(Document&, int x, int y, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowUserAgentShadowContent, bool allowChildFrameContent) const;
317 String parserMetaData(JSC::JSValue = JSC::JSValue::JSUndefined);
319 void updateEditorUINowIfScheduled();
321 bool sentenceRetroCorrectionEnabled() const
323 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
329 bool hasSpellingMarker(int from, int length);
330 bool hasGrammarMarker(int from, int length);
331 bool hasAutocorrectedMarker(int from, int length);
332 void setContinuousSpellCheckingEnabled(bool);
333 void setAutomaticQuoteSubstitutionEnabled(bool);
334 void setAutomaticLinkDetectionEnabled(bool);
335 void setAutomaticDashSubstitutionEnabled(bool);
336 void setAutomaticTextReplacementEnabled(bool);
337 void setAutomaticSpellingCorrectionEnabled(bool);
339 void handleAcceptedCandidate(const String& candidate, unsigned location, unsigned length);
340 void changeSelectionListType();
342 bool isOverwriteModeEnabled();
343 void toggleOverwriteModeEnabled();
345 bool testProcessIncomingSyncMessagesWhenWaitingForSyncReply();
347 ExceptionOr<RefPtr<Range>> rangeOfString(const String&, RefPtr<Range>&&, const Vector<String>& findOptions);
348 ExceptionOr<unsigned> countMatchesForText(const String&, const Vector<String>& findOptions, const String& markMatches);
349 ExceptionOr<unsigned> countFindMatches(const String&, const Vector<String>& findOptions);
351 unsigned numberOfScrollableAreas();
353 ExceptionOr<bool> isPageBoxVisible(int pageNumber);
355 static const char* internalsId;
357 InternalSettings* settings() const;
358 unsigned workerThreadCount() const;
359 ExceptionOr<bool> areSVGAnimationsPaused() const;
360 ExceptionOr<double> svgAnimationsInterval(SVGSVGElement&) const;
363 // Values need to be kept in sync with Internals.idl.
364 LAYER_TREE_INCLUDES_VISIBLE_RECTS = 1,
365 LAYER_TREE_INCLUDES_TILE_CACHES = 2,
366 LAYER_TREE_INCLUDES_REPAINT_RECTS = 4,
367 LAYER_TREE_INCLUDES_PAINTING_PHASES = 8,
368 LAYER_TREE_INCLUDES_CONTENT_LAYERS = 16,
369 LAYER_TREE_INCLUDES_ACCELERATES_DRAWING = 32,
370 LAYER_TREE_INCLUDES_CLIPPING = 64,
371 LAYER_TREE_INCLUDES_BACKING_STORE_ATTACHED = 128,
372 LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES = 256,
373 LAYER_TREE_INCLUDES_EVENT_REGION = 512,
374 LAYER_TREE_INCLUDES_DEEP_COLOR = 1024,
376 ExceptionOr<String> layerTreeAsText(Document&, unsigned short flags) const;
377 ExceptionOr<uint64_t> layerIDForElement(Element&);
378 ExceptionOr<String> repaintRectsAsText() const;
380 ExceptionOr<String> scrollbarOverlayStyle(Node*) const;
381 ExceptionOr<bool> scrollbarUsingDarkAppearance(Node*) const;
383 ExceptionOr<String> scrollingStateTreeAsText() const;
384 ExceptionOr<String> mainThreadScrollingReasons() const;
385 ExceptionOr<Ref<DOMRectList>> nonFastScrollableRects() const;
387 ExceptionOr<void> setElementUsesDisplayListDrawing(Element&, bool usesDisplayListDrawing);
388 ExceptionOr<void> setElementTracksDisplayListReplay(Element&, bool isTrackingReplay);
391 // Values need to be kept in sync with Internals.idl.
392 DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS = 1,
394 ExceptionOr<String> displayListForElement(Element&, unsigned short flags);
395 ExceptionOr<String> replayDisplayListForElement(Element&, unsigned short flags);
397 ExceptionOr<void> garbageCollectDocumentResources() const;
399 void beginSimulatedMemoryPressure();
400 void endSimulatedMemoryPressure();
401 bool isUnderMemoryPressure();
403 ExceptionOr<void> insertAuthorCSS(const String&) const;
404 ExceptionOr<void> insertUserCSS(const String&) const;
406 #if ENABLE(INDEXED_DATABASE)
407 unsigned numberOfIDBTransactions() const;
410 unsigned numberOfLiveNodes() const;
411 unsigned numberOfLiveDocuments() const;
412 unsigned referencingNodeCount(const Document&) const;
414 #if ENABLE(INTERSECTION_OBSERVER)
415 unsigned numberOfIntersectionObservers(const Document&) const;
418 uint64_t documentIdentifier(const Document&) const;
419 bool isDocumentAlive(uint64_t documentIdentifier) const;
421 uint64_t elementIdentifier(Element&) const;
422 uint64_t frameIdentifier(const Document&) const;
423 uint64_t pageIdentifier(const Document&) const;
425 bool isAnyWorkletGlobalScopeAlive() const;
427 String serviceWorkerClientIdentifier(const Document&) const;
429 RefPtr<WindowProxy> openDummyInspectorFrontend(const String& url);
430 void closeDummyInspectorFrontend();
431 ExceptionOr<void> setInspectorIsUnderTest(bool);
433 String counterValue(Element&);
435 int pageNumber(Element&, float pageWidth = 800, float pageHeight = 600);
436 Vector<String> shortcutIconURLs() const;
438 int numberOfPages(float pageWidthInPixels = 800, float pageHeightInPixels = 600);
439 ExceptionOr<String> pageProperty(const String& propertyName, int pageNumber) const;
440 ExceptionOr<String> pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const;
442 ExceptionOr<float> pageScaleFactor() const;
444 ExceptionOr<void> setPageScaleFactor(float scaleFactor, int x, int y);
445 ExceptionOr<void> setPageZoomFactor(float);
446 ExceptionOr<void> setTextZoomFactor(float);
448 ExceptionOr<void> setUseFixedLayout(bool);
449 ExceptionOr<void> setFixedLayoutSize(int width, int height);
450 ExceptionOr<void> setViewExposedRect(float left, float top, float width, float height);
451 void setPrinting(int width, int height);
453 void setHeaderHeight(float);
454 void setFooterHeight(float);
456 void setTopContentInset(float);
458 #if ENABLE(FULLSCREEN_API)
459 void webkitWillEnterFullScreenForElement(Element&);
460 void webkitDidEnterFullScreenForElement(Element&);
461 void webkitWillExitFullScreenForElement(Element&);
462 void webkitDidExitFullScreenForElement(Element&);
463 bool isAnimatingFullScreen() const;
466 struct FullscreenInsets {
472 void setFullscreenInsets(FullscreenInsets);
473 void setFullscreenAutoHideDuration(double);
474 void setFullscreenControlsHidden(bool);
476 WEBCORE_TESTSUPPORT_EXPORT void setApplicationCacheOriginQuota(unsigned long long);
478 void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme);
479 void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme);
481 void registerDefaultPortForProtocol(unsigned short port, const String& protocol);
483 Ref<MallocStatistics> mallocStatistics() const;
484 Ref<TypeConversions> typeConversions() const;
485 Ref<MemoryInfo> memoryInfo() const;
487 Vector<String> getReferencedFilePaths() const;
489 ExceptionOr<void> startTrackingRepaints();
490 ExceptionOr<void> stopTrackingRepaints();
492 ExceptionOr<void> startTrackingLayerFlushes();
493 ExceptionOr<unsigned> layerFlushCount();
495 ExceptionOr<void> startTrackingStyleRecalcs();
496 ExceptionOr<unsigned> styleRecalcCount();
497 unsigned lastStyleUpdateSize() const;
499 ExceptionOr<void> startTrackingCompositingUpdates();
500 ExceptionOr<unsigned> compositingUpdateCount();
502 enum CompositingPolicy { Normal, Conservative };
503 ExceptionOr<void> setCompositingPolicyOverride(Optional<CompositingPolicy>);
504 ExceptionOr<Optional<CompositingPolicy>> compositingPolicyOverride() const;
506 ExceptionOr<void> updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*);
507 unsigned layoutCount() const;
509 Ref<ArrayBuffer> serializeObject(const RefPtr<SerializedScriptValue>&) const;
510 Ref<SerializedScriptValue> deserializeBuffer(ArrayBuffer&) const;
512 bool isFromCurrentWorld(JSC::JSValue) const;
514 void setUsesOverlayScrollbars(bool);
515 void setUsesMockScrollAnimator(bool);
517 ExceptionOr<String> getCurrentCursorInfo();
519 String markerTextForListItem(Element&);
521 String toolTipFromElement(Element&) const;
523 void forceReload(bool endToEnd);
524 void reloadExpiredOnly();
526 void enableAutoSizeMode(bool enabled, int width, int height);
528 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
529 void initializeMockCDM();
532 #if ENABLE(ENCRYPTED_MEDIA)
533 Ref<MockCDMFactory> registerMockCDM();
536 void enableMockMediaCapabilities();
538 #if ENABLE(SPEECH_SYNTHESIS)
539 void enableMockSpeechSynthesizer();
542 #if ENABLE(MEDIA_STREAM)
543 void setShouldInterruptAudioOnPageVisibilityChange(bool);
544 void setMockMediaCaptureDevicesEnabled(bool);
545 void setMediaCaptureRequiresSecureConnection(bool);
546 void setCustomPrivateRecorderCreator();
550 void emulateRTCPeerConnectionPlatformEvent(RTCPeerConnection&, const String& action);
551 void useMockRTCPeerConnectionFactory(const String&);
552 void setICECandidateFiltering(bool);
553 void setEnumeratingAllNetworkInterfacesEnabled(bool);
554 void stopPeerConnection(RTCPeerConnection&);
555 void clearPeerConnectionFactory();
556 void applyRotationForOutgoingVideoSources(RTCPeerConnection&);
557 void setEnableWebRTCEncryption(bool);
558 void setUseDTLS10(bool);
561 String getImageSourceURL(Element&);
564 Vector<String> mediaResponseSources(HTMLMediaElement&);
565 Vector<String> mediaResponseContentRanges(HTMLMediaElement&);
566 void simulateAudioInterruption(HTMLMediaElement&);
567 ExceptionOr<bool> mediaElementHasCharacteristic(HTMLMediaElement&, const String&);
568 void beginSimulatedHDCPError(HTMLMediaElement&);
569 void endSimulatedHDCPError(HTMLMediaElement&);
571 bool elementShouldBufferData(HTMLMediaElement&);
572 String elementBufferingPolicy(HTMLMediaElement&);
573 double privatePlayerVolume(const HTMLMediaElement&);
576 bool isSelectPopupVisible(HTMLSelectElement&);
578 ExceptionOr<String> captionsStyleSheetOverride();
579 ExceptionOr<void> setCaptionsStyleSheetOverride(const String&);
580 ExceptionOr<void> setPrimaryAudioTrackLanguageOverride(const String&);
581 ExceptionOr<void> setCaptionDisplayMode(const String&);
582 #if ENABLE(VIDEO_TRACK)
583 RefPtr<TextTrackCueGeneric> createGenericCue(double startTime, double endTime, String text);
587 Ref<TimeRanges> createTimeRanges(Float32Array& startTimes, Float32Array& endTimes);
588 double closestTimeToTimeRanges(double time, TimeRanges&);
591 ExceptionOr<Ref<DOMRect>> selectionBounds();
592 void setSelectionWithoutValidation(Ref<Node> baseNode, unsigned baseOffset, RefPtr<Node> extentNode, unsigned extentOffset);
594 ExceptionOr<bool> isPluginUnavailabilityIndicatorObscured(Element&);
595 ExceptionOr<String> unavailablePluginReplacementText(Element&);
596 bool isPluginSnapshotted(Element&);
597 bool pluginIsBelowSizeThreshold(Element&);
599 #if ENABLE(MEDIA_SOURCE)
600 WEBCORE_TESTSUPPORT_EXPORT void initializeMockMediaSource();
601 Vector<String> bufferedSamplesForTrackID(SourceBuffer&, const AtomString&);
602 Vector<String> enqueuedSamplesForTrackID(SourceBuffer&, const AtomString&);
603 double minimumUpcomingPresentationTimeForTrackID(SourceBuffer&, const AtomString&);
604 void setShouldGenerateTimestamps(SourceBuffer&, bool);
605 void setMaximumQueueDepthForTrackID(SourceBuffer&, const AtomString&, size_t);
609 ExceptionOr<void> beginMediaSessionInterruption(const String&);
610 void endMediaSessionInterruption(const String&);
611 void applicationWillBecomeInactive();
612 void applicationDidBecomeActive();
613 void applicationWillEnterForeground(bool suspendedUnderLock) const;
614 void applicationDidEnterBackground(bool suspendedUnderLock) const;
615 ExceptionOr<void> setMediaSessionRestrictions(const String& mediaType, StringView restrictionsString);
616 ExceptionOr<String> mediaSessionRestrictions(const String& mediaType) const;
617 void setMediaElementRestrictions(HTMLMediaElement&, StringView restrictionsString);
618 ExceptionOr<void> postRemoteControlCommand(const String&, float argument);
619 bool elementIsBlockingDisplaySleep(HTMLMediaElement&) const;
622 #if ENABLE(MEDIA_SESSION)
623 void sendMediaSessionStartOfInterruptionNotification(MediaSessionInterruptingCategory);
624 void sendMediaSessionEndOfInterruptionNotification(MediaSessionInterruptingCategory);
625 String mediaSessionCurrentState(MediaSession&) const;
626 double mediaElementPlayerVolume(HTMLMediaElement&) const;
627 enum class MediaControlEvent { PlayPause, NextTrack, PreviousTrack };
628 void sendMediaControlEvent(MediaControlEvent);
631 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
632 void setMockMediaPlaybackTargetPickerEnabled(bool);
633 ExceptionOr<void> setMockMediaPlaybackTargetPickerState(const String& deviceName, const String& deviceState);
636 #if ENABLE(WEB_AUDIO)
637 void setAudioContextRestrictions(AudioContext&, StringView restrictionsString);
638 void useMockAudioDestinationCocoa();
641 void simulateSystemSleep() const;
642 void simulateSystemWake() const;
644 enum class PageOverlayType { View, Document };
645 ExceptionOr<Ref<MockPageOverlay>> installMockPageOverlay(PageOverlayType);
646 ExceptionOr<String> pageOverlayLayerTreeAsText(unsigned short flags) const;
648 void setPageMuted(StringView);
649 String pageMediaState();
651 void setPageDefersLoading(bool);
652 ExceptionOr<bool> pageDefersLoading();
654 RefPtr<File> createFile(const String&);
655 void queueMicroTask(int);
656 bool testPreloaderSettingViewport();
658 #if ENABLE(CONTENT_FILTERING)
659 MockContentFilterSettings& mockContentFilterSettings();
662 #if ENABLE(CSS_SCROLL_SNAP)
663 ExceptionOr<String> scrollSnapOffsets(Element&);
664 void setPlatformMomentumScrollingPredictionEnabled(bool);
667 ExceptionOr<String> pathStringWithShrinkWrappedRects(const Vector<double>& rectComponents, double radius);
669 String getCurrentMediaControlsStatusForElement(HTMLMediaElement&);
671 String userVisibleString(const DOMURL&);
672 void setShowAllPlugins(bool);
674 String resourceLoadStatisticsForURL(const DOMURL&);
675 void setResourceLoadStatisticsEnabled(bool);
677 #if ENABLE(STREAMS_API)
678 bool isReadableStreamDisturbed(JSC::JSGlobalObject&, JSC::JSValue);
679 JSC::JSValue cloneArrayBuffer(JSC::JSGlobalObject&, JSC::JSValue, JSC::JSValue, JSC::JSValue);
682 String composedTreeAsText(Node&);
684 bool isProcessingUserGesture();
685 double lastHandledUserGestureTimestamp();
687 void withUserGesture(RefPtr<VoidCallback>&&);
689 bool userIsInteracting();
691 RefPtr<GCObservation> observeGC(JSC::JSValue);
693 enum class UserInterfaceLayoutDirection : uint8_t { LTR, RTL };
694 void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection);
696 bool userPrefersReducedMotion() const;
698 void reportBacktrace();
700 enum class BaseWritingDirection { Natural, Ltr, Rtl };
701 void setBaseWritingDirection(BaseWritingDirection);
703 #if ENABLE(POINTER_LOCK)
704 bool pageHasPendingPointerLock() const;
705 bool pageHasPointerLock() const;
708 Vector<String> accessKeyModifiers() const;
710 void setQuickLookPassword(const String&);
712 void setAsRunningUserScripts(Document&);
713 #if ENABLE(APPLE_PAY)
714 void setApplePayIsActive(Document&);
718 void simulateWebGLContextChanged(WebGLRenderingContext&);
719 void failNextGPUStatusCheck(WebGLRenderingContext&);
720 bool hasLowAndHighPowerGPUs();
723 void setPageVisibility(bool isVisible);
724 void setPageIsFocusedAndActive(bool);
728 void setH264HardwareEncoderAllowed(bool allowed);
731 #if ENABLE(MEDIA_STREAM)
732 void setMockAudioTrackChannelNumber(MediaStreamTrack&, unsigned short);
733 void setCameraMediaStreamTrackOrientation(MediaStreamTrack&, int orientation);
734 unsigned long trackAudioSampleCount() const { return m_trackAudioSampleCount; }
735 unsigned long trackVideoSampleCount() const { return m_trackVideoSampleCount; }
736 void observeMediaStreamTrack(MediaStreamTrack&);
737 using TrackFramePromise = DOMPromiseDeferred<IDLInterface<ImageData>>;
738 void grabNextMediaStreamTrackFrame(TrackFramePromise&&);
739 void delayMediaStreamTrackSamples(MediaStreamTrack&, float);
740 void setMediaStreamTrackMuted(MediaStreamTrack&, bool);
741 void removeMediaStreamTrack(MediaStream&, MediaStreamTrack&);
742 void simulateMediaStreamTrackCaptureSourceFailure(MediaStreamTrack&);
743 void setMediaStreamTrackIdentifier(MediaStreamTrack&, String&& id);
744 void setMediaStreamSourceInterrupted(MediaStreamTrack&, bool);
745 void setDisableGetDisplayMediaUserGestureConstraint(bool);
748 bool supportsAudioSession() const;
749 String audioSessionCategory() const;
750 double preferredAudioBufferSize() const;
751 bool audioSessionActive() const;
753 void storeRegistrationsOnDisk(DOMPromiseDeferred<void>&&);
755 void clearCacheStorageMemoryRepresentation(DOMPromiseDeferred<void>&&);
756 void cacheStorageEngineRepresentation(DOMPromiseDeferred<IDLDOMString>&&);
757 void setResponseSizeWithPadding(FetchResponse&, uint64_t size);
758 uint64_t responseSizeWithPadding(FetchResponse&) const;
760 void updateQuotaBasedOnSpaceUsage();
762 void setConsoleMessageListener(RefPtr<StringCallback>&&);
764 #if ENABLE(SERVICE_WORKER)
765 using HasRegistrationPromise = DOMPromiseDeferred<IDLBoolean>;
766 void hasServiceWorkerRegistration(const String& clientURL, HasRegistrationPromise&&);
767 void terminateServiceWorker(ServiceWorker&);
770 #if ENABLE(APPLE_PAY)
771 MockPaymentCoordinator& mockPaymentCoordinator(Document&);
774 bool isSystemPreviewLink(Element&) const;
775 bool isSystemPreviewImage(Element&) const;
777 void postTask(RefPtr<VoidCallback>&&);
778 void markContextAsInsecure();
780 bool usingAppleInternalSDK() const;
782 struct NowPlayingState {
786 uint64_t uniqueIdentifier;
787 bool hasActiveSession;
788 bool registeredAsNowPlayingApplication;
790 ExceptionOr<NowPlayingState> nowPlayingState() const;
793 using PlaybackControlsPurpose = MediaElementSession::PlaybackControlsPurpose;
794 RefPtr<HTMLMediaElement> bestMediaElementForShowingPlaybackControlsManager(PlaybackControlsPurpose);
796 using MediaSessionState = PlatformMediaSession::State;
797 MediaSessionState mediaSessionState(HTMLMediaElement&);
800 void setCaptureExtraNetworkLoadMetricsEnabled(bool);
801 String ongoingLoadsDescriptions() const;
803 void reloadWithoutContentExtensions();
805 void setUseSystemAppearance(bool);
807 size_t pluginCount();
809 void notifyResourceLoadObserver();
811 unsigned primaryScreenDisplayID();
815 bool supportsVCPEncoder();
817 using HEVCParameterSet = WebCore::HEVCParameterSet;
818 Optional<HEVCParameterSet> parseHEVCCodecParameters(const String& codecString);
820 using DoViParameterSet = WebCore::DoViParameterSet;
821 Optional<DoViParameterSet> parseDoViCodecParameters(const String& codecString);
827 // Expiration dates are expressed as milliseconds since the UNIX epoch.
828 double expires { 0 };
829 bool isHttpOnly { false };
830 bool isSecure { false };
831 bool isSession { false };
832 bool isSameSiteLax { false };
833 bool isSameSiteStrict { false };
835 CookieData(Cookie cookie)
837 , value(cookie.value)
838 , domain(cookie.domain)
839 , expires(cookie.expires)
840 , isHttpOnly(cookie.httpOnly)
841 , isSecure(cookie.secure)
842 , isSession(cookie.session)
843 , isSameSiteLax(cookie.sameSite == Cookie::SameSitePolicy::Lax)
844 , isSameSiteStrict(cookie.sameSite == Cookie::SameSitePolicy::Strict)
846 ASSERT(!(isSameSiteLax && isSameSiteStrict));
853 Vector<CookieData> getCookies() const;
855 void setAlwaysAllowLocalWebarchive(bool);
856 void processWillSuspend();
857 void processDidResume();
859 void testDictionaryLogging();
861 void setXHRMaximumIntervalForUserGestureForwarding(XMLHttpRequest&, double);
863 void setIsPlayingToAutomotiveHeadUnit(bool);
865 struct TextIndicatorInfo {
866 RefPtr<DOMRectReadOnly> textBoundingRectInRootViewCoordinates;
867 RefPtr<DOMRectList> textRectsInBoundingRectCoordinates;
870 TextIndicatorInfo(const WebCore::TextIndicatorData&);
871 ~TextIndicatorInfo();
874 struct TextIndicatorOptions {
875 bool useBoundingRectAndPaintAllContentForComplexRanges { false };
876 bool computeEstimatedBackgroundColor { false };
877 bool respectTextColor { false };
879 WebCore::TextIndicatorOptions core()
881 WebCore::TextIndicatorOptions options = 0;
882 if (useBoundingRectAndPaintAllContentForComplexRanges)
883 options = options | TextIndicatorOptionUseBoundingRectAndPaintAllContentForComplexRanges;
884 if (computeEstimatedBackgroundColor)
885 options = options | TextIndicatorOptionComputeEstimatedBackgroundColor;
886 if (respectTextColor)
887 options = options | TextIndicatorOptionRespectTextColor;
892 TextIndicatorInfo textIndicatorForRange(const Range&, TextIndicatorOptions);
894 void addPrefetchLoadEventListener(HTMLLinkElement&, RefPtr<EventListener>&&);
896 #if ENABLE(WEB_AUTHN)
897 void setMockWebAuthenticationConfiguration(const MockWebAuthenticationConfiguration&);
900 int processIdentifier() const;
903 explicit Internals(Document&);
904 Document* contextDocument() const;
905 Frame* frame() const;
907 ExceptionOr<RenderedDocumentMarker*> markerAt(Node&, const String& markerType, unsigned index);
909 // RealtimeMediaSource::Observer API
910 #if ENABLE(MEDIA_STREAM)
911 void videoSampleAvailable(MediaSample&) final;
912 void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final { m_trackAudioSampleCount++; }
914 OrientationNotifier m_orientationNotifier;
915 unsigned long m_trackVideoSampleCount { 0 };
916 unsigned long m_trackAudioSampleCount { 0 };
917 RefPtr<MediaStreamTrack> m_track;
918 std::unique_ptr<TrackFramePromise> m_nextTrackFramePromise;
921 std::unique_ptr<InspectorStubFrontend> m_inspectorFrontend;
922 RefPtr<CacheStorageConnection> m_cacheStorageConnection;
924 RefPtr<UnsuspendableActiveDOMObject> m_unsuspendableActiveDOMObject;
927 } // namespace WebCore