Enable Pointer Events on watchOS
[WebKit-https.git] / Source / WebCore / testing / Internals.h
1 /*
2  * Copyright (C) 2012 Google Inc. All rights reserved.
3  * Copyright (C) 2013-2019 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 "Cookie.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>
40
41 #if ENABLE(MEDIA_SESSION)
42 #include "MediaSessionInterruptionProvider.h"
43 #endif
44
45 #if ENABLE(VIDEO)
46 #include "MediaElementSession.h"
47 #endif
48
49 namespace WebCore {
50
51 class AnimationTimeline;
52 class AudioContext;
53 class CacheStorageConnection;
54 class DOMRect;
55 class DOMRectList;
56 class DOMURL;
57 class DOMWindow;
58 class Document;
59 class Element;
60 class ExtendableEvent;
61 class FetchResponse;
62 class File;
63 class Frame;
64 class GCObservation;
65 class HTMLAnchorElement;
66 class HTMLImageElement;
67 class HTMLInputElement;
68 class HTMLLinkElement;
69 class HTMLMediaElement;
70 class HTMLPictureElement;
71 class HTMLSelectElement;
72 class ImageData;
73 class InspectorStubFrontend;
74 class InternalSettings;
75 class MallocStatistics;
76 class MediaSession;
77 class MediaStream;
78 class MediaStreamTrack;
79 class MemoryInfo;
80 class MockCDMFactory;
81 class MockContentFilterSettings;
82 class MockPageOverlay;
83 class MockPaymentCoordinator;
84 class NodeList;
85 class Page;
86 class RTCPeerConnection;
87 class Range;
88 class RenderedDocumentMarker;
89 class SVGSVGElement;
90 class SerializedScriptValue;
91 class SourceBuffer;
92 class StringCallback;
93 class StyleSheet;
94 class TextTrackCueGeneric;
95 class TimeRanges;
96 class TypeConversions;
97 class VoidCallback;
98 class WebGLRenderingContext;
99 class XMLHttpRequest;
100
101 #if ENABLE(SERVICE_WORKER)
102 class ServiceWorker;
103 #endif
104
105 class Internals final : public RefCounted<Internals>, private ContextDestructionObserver
106 #if ENABLE(MEDIA_STREAM)
107     , private RealtimeMediaSource::Observer
108 #endif
109     {
110 public:
111     static Ref<Internals> create(Document&);
112     virtual ~Internals();
113
114     static void resetToConsistentState(Page&);
115
116     ExceptionOr<String> elementRenderTreeAsText(Element&);
117     bool hasPausedImageAnimations(Element&);
118
119     bool isPaintingFrequently(Element&);
120     void incrementFrequentPaintCounter(Element&);
121
122     String address(Node&);
123     bool nodeNeedsStyleRecalc(Node&);
124     String styleChangeType(Node&);
125     String description(JSC::JSValue);
126
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);
139
140     void clearMemoryCache();
141     void pruneMemoryCacheToSize(unsigned size);
142     void destroyDecodedDataForAllImages();
143     unsigned memoryCacheSize() const;
144
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);
154
155     void setGridMaxTracksLimit(unsigned);
156
157     void clearPageCache();
158     unsigned pageCacheSize() const;
159
160     void disableTileSizeUpdateDelay();
161
162     void setSpeculativeTilingDelayDisabledForTesting(bool);
163
164     Ref<CSSComputedStyleDeclaration> computedStyleIncludingVisitedInfo(Element&) const;
165
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&);
171
172     // CSS Deferred Parsing Testing
173     unsigned deferredStyleRulesCount(StyleSheet&);
174     unsigned deferredGroupRulesCount(StyleSheet&);
175     unsigned deferredKeyframesRulesCount(StyleSheet&);
176
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;
183
184     enum EventThrottlingBehavior { Responsive, Unresponsive };
185     void setEventThrottlingBehaviorOverride(Optional<EventThrottlingBehavior>);
186     Optional<EventThrottlingBehavior> eventThrottlingBehaviorOverride() const;
187
188     // Spatial Navigation testing.
189     ExceptionOr<unsigned> lastSpatialNavigationCandidateCount() const;
190
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;
199
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);
203
204     // Web Animations testing.
205     struct AcceleratedAnimation {
206         String property;
207         double speed;
208     };
209     Vector<AcceleratedAnimation> acceleratedAnimationsForElement(Element&);
210     unsigned numberOfAnimationTimelineInvalidations() const;
211
212     // For animations testing, we need a way to get at pseudo elements.
213     ExceptionOr<RefPtr<Element>> pseudoElement(Element&, const String&);
214
215     Node* treeScopeRootNode(Node&);
216     Node* parentTreeScope(Node&);
217
218     String visiblePlaceholder(Element&);
219     void selectColorInColorChooser(HTMLInputElement&, const String& colorValue);
220     ExceptionOr<Vector<String>> formControlStateOfPreviousHistoryItem();
221     ExceptionOr<void> setFormControlStateOfPreviousHistoryItem(const Vector<String>&);
222
223     ExceptionOr<Ref<DOMRect>> absoluteCaretBounds();
224     ExceptionOr<bool> isCaretBlinkingSuspended();
225
226     Ref<DOMRect> boundingBox(Element&);
227
228     ExceptionOr<Ref<DOMRectList>> inspectorHighlightRects();
229
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);
236
237     void invalidateFontCache();
238     void setFontSmoothingEnabled(bool);
239
240     ExceptionOr<void> setLowPowerModeEnabled(bool);
241
242     ExceptionOr<void> setScrollViewPosition(int x, int y);
243     ExceptionOr<void> unconstrainedScrollTo(Element&, double x, double y);
244
245     ExceptionOr<Ref<DOMRect>> layoutViewportRect();
246     ExceptionOr<Ref<DOMRect>> visualViewportRect();
247
248     ExceptionOr<void> setViewIsTransparent(bool);
249
250     ExceptionOr<String> viewBaseBackgroundColor();
251     ExceptionOr<void> setViewBaseBackgroundColor(const String& colorValue);
252
253     ExceptionOr<void> setPagination(const String& mode, int gap, int pageLength);
254     ExceptionOr<void> setPaginationLineGridEnabled(bool);
255     ExceptionOr<String> configurationForViewport(float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight);
256
257     ExceptionOr<bool> wasLastChangeUserEdit(Element& textField);
258     bool elementShouldAutoComplete(HTMLInputElement&);
259     void setAutofilled(HTMLInputElement&, bool enabled);
260     enum class AutoFillButtonType { None, Contacts, Credentials, StrongPassword, CreditCard };
261     void setShowAutoFillButton(HTMLInputElement&, AutoFillButtonType);
262     AutoFillButtonType autoFillButtonType(const HTMLInputElement&);
263     AutoFillButtonType lastAutoFillButtonType(const HTMLInputElement&);
264     ExceptionOr<void> scrollElementToRect(Element&, int x, int y, int w, int h);
265
266     ExceptionOr<String> autofillFieldName(Element&);
267
268     ExceptionOr<void> invalidateControlTints();
269
270     RefPtr<Range> rangeFromLocationAndLength(Element& scope, int rangeLocation, int rangeLength);
271     unsigned locationFromRange(Element& scope, const Range&);
272     unsigned lengthFromRange(Element& scope, const Range&);
273     String rangeAsText(const Range&);
274     Ref<Range> subrange(Range&, int rangeLocation, int rangeLength);
275     ExceptionOr<RefPtr<Range>> rangeForDictionaryLookupAtLocation(int x, int y);
276     RefPtr<Range> rangeOfStringNearLocation(const Range&, const String&, unsigned);
277
278     ExceptionOr<void> setDelegatesScrolling(bool enabled);
279
280     ExceptionOr<int> lastSpellCheckRequestSequence();
281     ExceptionOr<int> lastSpellCheckProcessedSequence();
282
283     Vector<String> userPreferredLanguages() const;
284     void setUserPreferredLanguages(const Vector<String>&);
285
286     Vector<String> userPreferredAudioCharacteristics() const;
287     void setUserPreferredAudioCharacteristic(const String&);
288
289     ExceptionOr<unsigned> wheelEventHandlerCount();
290     ExceptionOr<unsigned> touchEventHandlerCount();
291
292     ExceptionOr<Ref<DOMRectList>> touchEventRectsForEvent(const String&);
293     ExceptionOr<Ref<DOMRectList>> passiveTouchEventListenerRects();
294
295     ExceptionOr<RefPtr<NodeList>> nodesFromRect(Document&, int x, int y, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowUserAgentShadowContent, bool allowChildFrameContent) const;
296
297     String parserMetaData(JSC::JSValue = JSC::JSValue::JSUndefined);
298
299     void updateEditorUINowIfScheduled();
300
301     bool sentenceRetroCorrectionEnabled() const
302     {
303 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
304         return true;
305 #else
306         return false;
307 #endif
308     }
309     bool hasSpellingMarker(int from, int length);
310     bool hasGrammarMarker(int from, int length);
311     bool hasAutocorrectedMarker(int from, int length);
312     void setContinuousSpellCheckingEnabled(bool);
313     void setAutomaticQuoteSubstitutionEnabled(bool);
314     void setAutomaticLinkDetectionEnabled(bool);
315     void setAutomaticDashSubstitutionEnabled(bool);
316     void setAutomaticTextReplacementEnabled(bool);
317     void setAutomaticSpellingCorrectionEnabled(bool);
318
319     void handleAcceptedCandidate(const String& candidate, unsigned location, unsigned length);
320     void changeSelectionListType();
321
322     bool isOverwriteModeEnabled();
323     void toggleOverwriteModeEnabled();
324
325     ExceptionOr<RefPtr<Range>> rangeOfString(const String&, RefPtr<Range>&&, const Vector<String>& findOptions);
326     ExceptionOr<unsigned> countMatchesForText(const String&, const Vector<String>& findOptions, const String& markMatches);
327     ExceptionOr<unsigned> countFindMatches(const String&, const Vector<String>& findOptions);
328
329     unsigned numberOfScrollableAreas();
330
331     ExceptionOr<bool> isPageBoxVisible(int pageNumber);
332
333     static const char* internalsId;
334
335     InternalSettings* settings() const;
336     unsigned workerThreadCount() const;
337     ExceptionOr<bool> areSVGAnimationsPaused() const;
338     ExceptionOr<double> svgAnimationsInterval(SVGSVGElement&) const;
339
340     enum {
341         // Values need to be kept in sync with Internals.idl.
342         LAYER_TREE_INCLUDES_VISIBLE_RECTS = 1,
343         LAYER_TREE_INCLUDES_TILE_CACHES = 2,
344         LAYER_TREE_INCLUDES_REPAINT_RECTS = 4,
345         LAYER_TREE_INCLUDES_PAINTING_PHASES = 8,
346         LAYER_TREE_INCLUDES_CONTENT_LAYERS = 16,
347         LAYER_TREE_INCLUDES_ACCELERATES_DRAWING = 32,
348         LAYER_TREE_INCLUDES_BACKING_STORE_ATTACHED = 64,
349         LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES = 128,
350         LAYER_TREE_INCLUDES_EVENT_REGION = 256,
351     };
352     ExceptionOr<String> layerTreeAsText(Document&, unsigned short flags) const;
353     ExceptionOr<uint64_t> layerIDForElement(Element&);
354     ExceptionOr<String> repaintRectsAsText() const;
355
356     ExceptionOr<String> scrollbarOverlayStyle(Node*) const;
357     ExceptionOr<bool> scrollbarUsingDarkAppearance(Node*) const;
358
359     ExceptionOr<String> scrollingStateTreeAsText() const;
360     ExceptionOr<String> mainThreadScrollingReasons() const;
361     ExceptionOr<Ref<DOMRectList>> nonFastScrollableRects() const;
362
363     ExceptionOr<void> setElementUsesDisplayListDrawing(Element&, bool usesDisplayListDrawing);
364     ExceptionOr<void> setElementTracksDisplayListReplay(Element&, bool isTrackingReplay);
365
366     enum {
367         // Values need to be kept in sync with Internals.idl.
368         DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS = 1,
369     };
370     ExceptionOr<String> displayListForElement(Element&, unsigned short flags);
371     ExceptionOr<String> replayDisplayListForElement(Element&, unsigned short flags);
372
373     ExceptionOr<void> garbageCollectDocumentResources() const;
374
375     void beginSimulatedMemoryPressure();
376     void endSimulatedMemoryPressure();
377     bool isUnderMemoryPressure();
378
379     ExceptionOr<void> insertAuthorCSS(const String&) const;
380     ExceptionOr<void> insertUserCSS(const String&) const;
381
382     unsigned numberOfIDBTransactions() const;
383
384     unsigned numberOfLiveNodes() const;
385     unsigned numberOfLiveDocuments() const;
386     unsigned referencingNodeCount(const Document&) const;
387
388 #if ENABLE(INTERSECTION_OBSERVER)
389     unsigned numberOfIntersectionObservers(const Document&) const;
390 #endif
391
392     uint64_t documentIdentifier(const Document&) const;
393     bool isDocumentAlive(uint64_t documentIdentifier) const;
394
395     bool isAnyWorkletGlobalScopeAlive() const;
396
397     String serviceWorkerClientIdentifier(const Document&) const;
398
399     RefPtr<WindowProxy> openDummyInspectorFrontend(const String& url);
400     void closeDummyInspectorFrontend();
401     ExceptionOr<void> setInspectorIsUnderTest(bool);
402
403     String counterValue(Element&);
404
405     int pageNumber(Element&, float pageWidth = 800, float pageHeight = 600);
406     Vector<String> shortcutIconURLs() const;
407
408     int numberOfPages(float pageWidthInPixels = 800, float pageHeightInPixels = 600);
409     ExceptionOr<String> pageProperty(const String& propertyName, int pageNumber) const;
410     ExceptionOr<String> pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const;
411
412     ExceptionOr<float> pageScaleFactor() const;
413
414     ExceptionOr<void> setPageScaleFactor(float scaleFactor, int x, int y);
415     ExceptionOr<void> setPageZoomFactor(float);
416     ExceptionOr<void> setTextZoomFactor(float);
417
418     ExceptionOr<void> setUseFixedLayout(bool);
419     ExceptionOr<void> setFixedLayoutSize(int width, int height);
420     ExceptionOr<void> setViewExposedRect(float left, float top, float width, float height);
421     void setPrinting(int width, int height);
422
423     void setHeaderHeight(float);
424     void setFooterHeight(float);
425
426     void setTopContentInset(float);
427
428 #if ENABLE(FULLSCREEN_API)
429     void webkitWillEnterFullScreenForElement(Element&);
430     void webkitDidEnterFullScreenForElement(Element&);
431     void webkitWillExitFullScreenForElement(Element&);
432     void webkitDidExitFullScreenForElement(Element&);
433     bool isAnimatingFullScreen() const;
434 #endif
435
436     struct FullscreenInsets {
437         float top { 0 };
438         float left { 0 };
439         float bottom { 0 };
440         float right { 0 };
441     };
442     void setFullscreenInsets(FullscreenInsets);
443     void setFullscreenAutoHideDuration(double);
444     void setFullscreenControlsHidden(bool);
445
446     WEBCORE_TESTSUPPORT_EXPORT void setApplicationCacheOriginQuota(unsigned long long);
447
448     void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme);
449     void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme);
450
451     void registerDefaultPortForProtocol(unsigned short port, const String& protocol);
452
453     Ref<MallocStatistics> mallocStatistics() const;
454     Ref<TypeConversions> typeConversions() const;
455     Ref<MemoryInfo> memoryInfo() const;
456
457     Vector<String> getReferencedFilePaths() const;
458
459     ExceptionOr<void> startTrackingRepaints();
460     ExceptionOr<void> stopTrackingRepaints();
461
462     ExceptionOr<void> startTrackingLayerFlushes();
463     ExceptionOr<unsigned> layerFlushCount();
464
465     ExceptionOr<void> startTrackingStyleRecalcs();
466     ExceptionOr<unsigned> styleRecalcCount();
467     unsigned lastStyleUpdateSize() const;
468
469     ExceptionOr<void> startTrackingCompositingUpdates();
470     ExceptionOr<unsigned> compositingUpdateCount();
471
472     enum CompositingPolicy { Normal, Conservative };
473     ExceptionOr<void> setCompositingPolicyOverride(Optional<CompositingPolicy>);
474     ExceptionOr<Optional<CompositingPolicy>> compositingPolicyOverride() const;
475
476     ExceptionOr<void> updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*);
477     unsigned layoutCount() const;
478
479     Ref<ArrayBuffer> serializeObject(const RefPtr<SerializedScriptValue>&) const;
480     Ref<SerializedScriptValue> deserializeBuffer(ArrayBuffer&) const;
481
482     bool isFromCurrentWorld(JSC::JSValue) const;
483
484     void setUsesOverlayScrollbars(bool);
485     void setUsesMockScrollAnimator(bool);
486
487     ExceptionOr<String> getCurrentCursorInfo();
488
489     String markerTextForListItem(Element&);
490
491     String toolTipFromElement(Element&) const;
492
493     void forceReload(bool endToEnd);
494     void reloadExpiredOnly();
495
496     void enableAutoSizeMode(bool enabled, int width, int height);
497
498 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
499     void initializeMockCDM();
500 #endif
501
502 #if ENABLE(ENCRYPTED_MEDIA)
503     Ref<MockCDMFactory> registerMockCDM();
504 #endif
505
506     void enableMockMediaCapabilities();
507
508 #if ENABLE(SPEECH_SYNTHESIS)
509     void enableMockSpeechSynthesizer();
510 #endif
511
512 #if ENABLE(MEDIA_STREAM)
513     void setMockMediaCaptureDevicesEnabled(bool);
514     void setMediaCaptureRequiresSecureConnection(bool);
515     void setCustomPrivateRecorderCreator();
516 #endif
517
518 #if ENABLE(WEB_RTC)
519     void emulateRTCPeerConnectionPlatformEvent(RTCPeerConnection&, const String& action);
520     void useMockRTCPeerConnectionFactory(const String&);
521     void setICECandidateFiltering(bool);
522     void setEnumeratingAllNetworkInterfacesEnabled(bool);
523     void stopPeerConnection(RTCPeerConnection&);
524     void clearPeerConnectionFactory();
525     void applyRotationForOutgoingVideoSources(RTCPeerConnection&);
526 #endif
527
528     String getImageSourceURL(Element&);
529
530 #if ENABLE(VIDEO)
531     Vector<String> mediaResponseSources(HTMLMediaElement&);
532     Vector<String> mediaResponseContentRanges(HTMLMediaElement&);
533     void simulateAudioInterruption(HTMLMediaElement&);
534     ExceptionOr<bool> mediaElementHasCharacteristic(HTMLMediaElement&, const String&);
535     void beginSimulatedHDCPError(HTMLMediaElement&);
536     void endSimulatedHDCPError(HTMLMediaElement&);
537
538     bool elementShouldBufferData(HTMLMediaElement&);
539 #endif
540
541     bool isSelectPopupVisible(HTMLSelectElement&);
542
543     ExceptionOr<String> captionsStyleSheetOverride();
544     ExceptionOr<void> setCaptionsStyleSheetOverride(const String&);
545     ExceptionOr<void> setPrimaryAudioTrackLanguageOverride(const String&);
546     ExceptionOr<void> setCaptionDisplayMode(const String&);
547     RefPtr<TextTrackCueGeneric> createGenericCue(double startTime, double endTime, String text);
548
549 #if ENABLE(VIDEO)
550     Ref<TimeRanges> createTimeRanges(Float32Array& startTimes, Float32Array& endTimes);
551     double closestTimeToTimeRanges(double time, TimeRanges&);
552 #endif
553
554     ExceptionOr<Ref<DOMRect>> selectionBounds();
555     void setSelectionWithoutValidation(Ref<Node> baseNode, unsigned baseOffset, RefPtr<Node> extentNode, unsigned extentOffset);
556
557     ExceptionOr<bool> isPluginUnavailabilityIndicatorObscured(Element&);
558     ExceptionOr<String> unavailablePluginReplacementText(Element&);
559     bool isPluginSnapshotted(Element&);
560     bool pluginIsBelowSizeThreshold(Element&);
561
562 #if ENABLE(MEDIA_SOURCE)
563     WEBCORE_TESTSUPPORT_EXPORT void initializeMockMediaSource();
564     Vector<String> bufferedSamplesForTrackID(SourceBuffer&, const AtomicString&);
565     Vector<String> enqueuedSamplesForTrackID(SourceBuffer&, const AtomicString&);
566     void setShouldGenerateTimestamps(SourceBuffer&, bool);
567 #endif
568
569 #if ENABLE(VIDEO)
570     ExceptionOr<void> beginMediaSessionInterruption(const String&);
571     void endMediaSessionInterruption(const String&);
572     void applicationWillBecomeInactive();
573     void applicationDidBecomeActive();
574     void applicationWillEnterForeground(bool suspendedUnderLock) const;
575     void applicationDidEnterBackground(bool suspendedUnderLock) const;
576     ExceptionOr<void> setMediaSessionRestrictions(const String& mediaType, StringView restrictionsString);
577     ExceptionOr<String> mediaSessionRestrictions(const String& mediaType) const;
578     void setMediaElementRestrictions(HTMLMediaElement&, StringView restrictionsString);
579     ExceptionOr<void> postRemoteControlCommand(const String&, float argument);
580     bool elementIsBlockingDisplaySleep(HTMLMediaElement&) const;
581 #endif
582
583 #if ENABLE(MEDIA_SESSION)
584     void sendMediaSessionStartOfInterruptionNotification(MediaSessionInterruptingCategory);
585     void sendMediaSessionEndOfInterruptionNotification(MediaSessionInterruptingCategory);
586     String mediaSessionCurrentState(MediaSession&) const;
587     double mediaElementPlayerVolume(HTMLMediaElement&) const;
588     enum class MediaControlEvent { PlayPause, NextTrack, PreviousTrack };
589     void sendMediaControlEvent(MediaControlEvent);
590 #endif
591
592 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
593     void setMockMediaPlaybackTargetPickerEnabled(bool);
594     ExceptionOr<void> setMockMediaPlaybackTargetPickerState(const String& deviceName, const String& deviceState);
595 #endif
596
597 #if ENABLE(WEB_AUDIO)
598     void setAudioContextRestrictions(AudioContext&, StringView restrictionsString);
599 #endif
600
601     void simulateSystemSleep() const;
602     void simulateSystemWake() const;
603
604     enum class PageOverlayType { View, Document };
605     ExceptionOr<Ref<MockPageOverlay>> installMockPageOverlay(PageOverlayType);
606     ExceptionOr<String> pageOverlayLayerTreeAsText(unsigned short flags) const;
607
608     void setPageMuted(StringView);
609     String pageMediaState();
610
611     void setPageDefersLoading(bool);
612     ExceptionOr<bool> pageDefersLoading();
613
614     RefPtr<File> createFile(const String&);
615     void queueMicroTask(int);
616     bool testPreloaderSettingViewport();
617
618 #if ENABLE(CONTENT_FILTERING)
619     MockContentFilterSettings& mockContentFilterSettings();
620 #endif
621
622 #if ENABLE(CSS_SCROLL_SNAP)
623     ExceptionOr<String> scrollSnapOffsets(Element&);
624     void setPlatformMomentumScrollingPredictionEnabled(bool);
625 #endif
626
627     ExceptionOr<String> pathStringWithShrinkWrappedRects(const Vector<double>& rectComponents, double radius);
628
629     String getCurrentMediaControlsStatusForElement(HTMLMediaElement&);
630
631     String userVisibleString(const DOMURL&);
632     void setShowAllPlugins(bool);
633
634     String resourceLoadStatisticsForURL(const DOMURL&);
635     void setResourceLoadStatisticsEnabled(bool);
636     void setUserGrantsStorageAccess(bool);
637
638 #if ENABLE(STREAMS_API)
639     bool isReadableStreamDisturbed(JSC::ExecState&, JSC::JSValue);
640     JSC::JSValue cloneArrayBuffer(JSC::ExecState&, JSC::JSValue, JSC::JSValue, JSC::JSValue);
641 #endif
642
643     String composedTreeAsText(Node&);
644
645     bool isProcessingUserGesture();
646     double lastHandledUserGestureTimestamp();
647
648     void withUserGesture(RefPtr<VoidCallback>&&);
649
650     RefPtr<GCObservation> observeGC(JSC::JSValue);
651
652     enum class UserInterfaceLayoutDirection : uint8_t { LTR, RTL };
653     void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection);
654
655     bool userPrefersReducedMotion() const;
656
657     void reportBacktrace();
658
659     enum class BaseWritingDirection { Natural, Ltr, Rtl };
660     void setBaseWritingDirection(BaseWritingDirection);
661
662 #if ENABLE(POINTER_LOCK)
663     bool pageHasPendingPointerLock() const;
664     bool pageHasPointerLock() const;
665 #endif
666
667     Vector<String> accessKeyModifiers() const;
668
669     void setQuickLookPassword(const String&);
670
671     void setAsRunningUserScripts(Document&);
672 #if ENABLE(APPLE_PAY)
673     void setHasStartedApplePaySession(Document&);
674 #endif
675
676 #if ENABLE(WEBGL)
677     void simulateWebGLContextChanged(WebGLRenderingContext&);
678     void failNextGPUStatusCheck(WebGLRenderingContext&);
679     bool hasLowAndHighPowerGPUs();
680 #endif
681
682     void setPageVisibility(bool isVisible);
683     void setPageIsFocusedAndActive(bool);
684
685
686 #if ENABLE(WEB_RTC)
687     void setH264HardwareEncoderAllowed(bool allowed);
688 #endif
689
690 #if ENABLE(MEDIA_STREAM)
691     void setCameraMediaStreamTrackOrientation(MediaStreamTrack&, int orientation);
692     unsigned long trackAudioSampleCount() const { return m_trackAudioSampleCount; }
693     unsigned long trackVideoSampleCount() const { return m_trackVideoSampleCount; }
694     void observeMediaStreamTrack(MediaStreamTrack&);
695     using TrackFramePromise = DOMPromiseDeferred<IDLInterface<ImageData>>;
696     void grabNextMediaStreamTrackFrame(TrackFramePromise&&);
697     void delayMediaStreamTrackSamples(MediaStreamTrack&, float);
698     void setMediaStreamTrackMuted(MediaStreamTrack&, bool);
699     void removeMediaStreamTrack(MediaStream&, MediaStreamTrack&);
700     void simulateMediaStreamTrackCaptureSourceFailure(MediaStreamTrack&);
701     void setMediaStreamTrackIdentifier(MediaStreamTrack&, String&& id);
702     void setMediaStreamSourceInterrupted(MediaStreamTrack&, bool);
703 #endif
704
705     String audioSessionCategory() const;
706     double preferredAudioBufferSize() const;
707     bool audioSessionActive() const;
708
709     void clearCacheStorageMemoryRepresentation(DOMPromiseDeferred<void>&&);
710     void cacheStorageEngineRepresentation(DOMPromiseDeferred<IDLDOMString>&&);
711     void setResponseSizeWithPadding(FetchResponse&, uint64_t size);
712     uint64_t responseSizeWithPadding(FetchResponse&) const;
713
714     void updateQuotaBasedOnSpaceUsage();
715
716     void setConsoleMessageListener(RefPtr<StringCallback>&&);
717
718 #if ENABLE(SERVICE_WORKER)
719     using HasRegistrationPromise = DOMPromiseDeferred<IDLBoolean>;
720     void hasServiceWorkerRegistration(const String& clientURL, HasRegistrationPromise&&);
721     void terminateServiceWorker(ServiceWorker&);
722     bool hasServiceWorkerConnection();
723 #endif
724
725 #if ENABLE(APPLE_PAY)
726     MockPaymentCoordinator& mockPaymentCoordinator(Document&);
727 #endif
728
729     bool isSystemPreviewLink(Element&) const;
730     bool isSystemPreviewImage(Element&) const;
731
732     void postTask(RefPtr<VoidCallback>&&);
733     void markContextAsInsecure();
734
735     bool usingAppleInternalSDK() const;
736
737     struct NowPlayingState {
738         String title;
739         double duration;
740         double elapsedTime;
741         uint64_t uniqueIdentifier;
742         bool hasActiveSession;
743         bool registeredAsNowPlayingApplication;
744     };
745     ExceptionOr<NowPlayingState> nowPlayingState() const;
746
747 #if ENABLE(VIDEO)
748     using PlaybackControlsPurpose = MediaElementSession::PlaybackControlsPurpose;
749     RefPtr<HTMLMediaElement> bestMediaElementForShowingPlaybackControlsManager(PlaybackControlsPurpose);
750
751     using MediaSessionState = PlatformMediaSession::State;
752     MediaSessionState mediaSessionState(HTMLMediaElement&);
753 #endif
754
755     void setCaptureExtraNetworkLoadMetricsEnabled(bool);
756     String ongoingLoadsDescriptions() const;
757
758     void reloadWithoutContentExtensions();
759
760     void setUseSystemAppearance(bool);
761
762     size_t pluginCount();
763
764     void notifyResourceLoadObserver();
765
766     unsigned primaryScreenDisplayID();
767
768     bool capsLockIsOn();
769         
770     bool supportsVCPEncoder();
771         
772     using HEVCParameterSet = WebCore::HEVCParameterSet;
773     Optional<HEVCParameterSet> parseHEVCCodecParameters(const String& codecString);
774
775     struct CookieData {
776         String name;
777         String value;
778         String domain;
779         // Expiration dates are expressed as milliseconds since the UNIX epoch.
780         double expires { 0 };
781         bool isHttpOnly { false };
782         bool isSecure { false };
783         bool isSession { false };
784         bool isSameSiteLax { false };
785         bool isSameSiteStrict { false };
786
787         CookieData(Cookie cookie)
788             : name(cookie.name)
789             , value(cookie.value)
790             , domain(cookie.domain)
791             , expires(cookie.expires)
792             , isHttpOnly(cookie.httpOnly)
793             , isSecure(cookie.secure)
794             , isSession(cookie.session)
795             , isSameSiteLax(cookie.sameSite == Cookie::SameSitePolicy::Lax)
796             , isSameSiteStrict(cookie.sameSite == Cookie::SameSitePolicy::Strict)
797         {
798             ASSERT(!(isSameSiteLax && isSameSiteStrict));
799         }
800
801         CookieData()
802         {
803         }
804     };
805     Vector<CookieData> getCookies() const;
806
807     void setAlwaysAllowLocalWebarchive(bool);
808     void processWillSuspend();
809     void processDidResume();
810
811 private:
812     explicit Internals(Document&);
813     Document* contextDocument() const;
814     Frame* frame() const;
815
816     ExceptionOr<RenderedDocumentMarker*> markerAt(Node&, const String& markerType, unsigned index);
817
818     // RealtimeMediaSource::Observer API
819 #if ENABLE(MEDIA_STREAM)
820     void videoSampleAvailable(MediaSample&) final;
821     void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final { m_trackAudioSampleCount++; }
822
823     OrientationNotifier m_orientationNotifier;
824     unsigned long m_trackVideoSampleCount { 0 };
825     unsigned long m_trackAudioSampleCount { 0 };
826     RefPtr<MediaStreamTrack> m_track;
827     Optional<TrackFramePromise> m_nextTrackFramePromise;
828 #endif
829
830     std::unique_ptr<InspectorStubFrontend> m_inspectorFrontend;
831     RefPtr<CacheStorageConnection> m_cacheStorageConnection;
832 };
833
834 } // namespace WebCore