1/*
2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 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[
28    DoNotCheckConstants,
29    GarbageCollected,
30    Iterable,
31] interface Internals {
32    DOMString address(Node node);
33
34    GCObservation observeGC(any observed);
35
36    [RaisesException, TypeChecking=Interface] DOMString elementRenderTreeAsText(Element element);
37    boolean isPreloaded(DOMString url);
38    boolean isLoadingFromMemoryCache(DOMString url);
39
40    [TypeChecking=Interface] boolean isSharingStyle(Element element1, Element element2);
41
42    [TypeChecking=Interface] CSSStyleDeclaration computedStyleIncludingVisitedInfo(Node node);
43
44    [TypeChecking=Interface] ShadowRoot shadowRoot(Element host);
45    [TypeChecking=Interface] ShadowRoot youngestShadowRoot(Element host);
46    [TypeChecking=Interface] ShadowRoot oldestShadowRoot(Element host);
47    [RaisesException, TypeChecking=Interface] ShadowRoot youngerShadowRoot(Node root);
48
49    [RaisesException, TypeChecking=Interface] DOMString shadowRootType(Node root);
50    [RaisesException] boolean hasShadowInsertionPoint(Node root);
51    [RaisesException] boolean hasContentElement(Node root);
52    [RaisesException, TypeChecking=Interface] unsigned long countElementShadow(Node Root);
53    [TypeChecking=Interface] DOMString shadowPseudoId(Element element);
54    [RaisesException, TypeChecking=Interface] boolean isValidContentSelect(Element contentElement);
55    [TypeChecking=Interface] Node treeScopeRootNode(Node node);
56    [TypeChecking=Interface] Node parentTreeScope(Node node);
57    [RaisesException, TypeChecking=Interface] boolean hasSelectorForIdInShadow(Element host, DOMString id);
58    [RaisesException, TypeChecking=Interface] boolean hasSelectorForClassInShadow(Element host, DOMString className);
59    [RaisesException, TypeChecking=Interface] boolean hasSelectorForAttributeInShadow(Element host, DOMString attributeName);
60    [RaisesException, TypeChecking=Interface] boolean hasSelectorForPseudoClassInShadow(Element host, DOMString pseudoClass);
61    [RaisesException, TypeChecking=Interface] unsigned short compareTreeScopePosition(Node treeScope1, Node treeScope2);
62    [RaisesException] unsigned long updateStyleAndReturnAffectedElementCount();
63    [RaisesException] unsigned long needsLayoutCount();
64    [RaisesException] unsigned long hitTestCount(Document document);
65
66    // CSS Animation and Transition testing.
67    [RaisesException] void pauseAnimations(double pauseTime);
68
69    [TypeChecking=Interface] Node nextSiblingByWalker(Node node);
70    [TypeChecking=Interface] Node firstChildByWalker(Node node);
71    [TypeChecking=Interface] Node lastChildByWalker(Node node);
72    [TypeChecking=Interface] Node nextNodeByWalker(Node node);
73    [TypeChecking=Interface] Node previousNodeByWalker(Node node);
74
75    DOMString visiblePlaceholder(Element element);
76
77    [TypeChecking=Interface] void selectColorInColorChooser(Element element, DOMString colorValue);
78    [TypeChecking=Interface] void endColorChooser(Element element);
79
80    // If the argument is omitted, the top-level document is used.
81    boolean hasAutofocusRequest(optional Document document);
82    [RaisesException] DOMString[] formControlStateOfHistoryItem();
83    [RaisesException] void setFormControlStateOfHistoryItem(sequence<DOMString> values);
84    [RaisesException] void setEnableMockPagePopup(boolean enabled);
85    readonly attribute PagePopupController pagePopupController;
86
87    [RaisesException] ClientRect absoluteCaretBounds();
88
89    [TypeChecking=Interface] ClientRect boundingBox(Element element);
90
91    [RaisesException, TypeChecking=Interface] unsigned long markerCountForNode(Node node, DOMString markerType);
92    [TypeChecking=Interface] unsigned long activeMarkerCountForNode(Node node);
93    [RaisesException, TypeChecking=Interface] Range markerRangeForNode(Node node, DOMString markerType, unsigned long index);
94    [RaisesException, TypeChecking=Interface] DOMString markerDescriptionForNode(Node node, DOMString markerType, unsigned long index);
95    [TypeChecking=Interface] void addTextMatchMarker(Range range, boolean isActive);
96    [TypeChecking=Interface] void setMarkersActive(Node node, unsigned long startOffset, unsigned long endOffset, boolean active);
97    void setMarkedTextMatchesAreHighlighted(Document document, boolean highlight);
98
99    [RaisesException, TypeChecking=Interface] void setScrollViewPosition(Document document, long x, long y);
100
101    [RaisesException, TypeChecking=Interface] DOMString viewportAsText(Document document,
102                                                                       float devicePixelRatio,
103                                                                       long availableWidth,
104                                                                       long availableHeight);
105
106    [RaisesException, TypeChecking=Interface] boolean wasLastChangeUserEdit(Element textField);
107    [RaisesException, TypeChecking=Interface] boolean elementShouldAutoComplete(Element inputElement);
108    [RaisesException, TypeChecking=Interface] DOMString suggestedValue(Element inputElement);
109    [RaisesException, TypeChecking=Interface] void setSuggestedValue(Element inputElement, DOMString value);
110    [RaisesException, TypeChecking=Interface] void setEditingValue(Element inputElement, DOMString value);
111    [RaisesException, TypeChecking=Interface] void setAutofilled(Element inputElement, boolean enabled);
112
113    [RaisesException, TypeChecking=Interface] void scrollElementToRect(Element element, long x, long y, long w, long h);
114
115    [TypeChecking=Interface] Range rangeFromLocationAndLength(Element scope, long rangeLocation, long rangeLength);
116    [TypeChecking=Interface] unsigned long locationFromRange(Element scope, Range range);
117    [TypeChecking=Interface] unsigned long lengthFromRange(Element scope, Range range);
118    [TypeChecking=Interface] DOMString rangeAsText(Range range);
119
120    [RaisesException, TypeChecking=Interface] DOMPoint touchPositionAdjustedToBestClickableNode(long x, long y, long width, long height, Document document);
121    [RaisesException, TypeChecking=Interface] Node touchNodeAdjustedToBestClickableNode(long x, long y, long width, long height, Document document);
122    [RaisesException, TypeChecking=Interface] DOMPoint touchPositionAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document document);
123    [RaisesException, TypeChecking=Interface] Node touchNodeAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document document);
124    [RaisesException, TypeChecking=Interface] ClientRect bestZoomableAreaForTouchPoint(long x, long y, long width, long height, Document document);
125
126    [RaisesException] long lastSpellCheckRequestSequence(Document document);
127    [RaisesException] long lastSpellCheckProcessedSequence(Document document);
128
129    sequence<DOMString> userPreferredLanguages();
130    void setUserPreferredLanguages(sequence<DOMString> languages);
131
132    [TypeChecking=Interface] unsigned long activeDOMObjectCount(Document document);
133    [TypeChecking=Interface] unsigned long wheelEventHandlerCount(Document document);
134    [TypeChecking=Interface] unsigned long scrollEventHandlerCount(Document document);
135    [TypeChecking=Interface] unsigned long touchEventHandlerCount(Document document);
136    [RaisesException, TypeChecking=Interface] LayerRectList touchEventTargetLayerRects(Document document);
137
138
139    [RaisesException, TypeChecking=Interface] NodeList nodesFromRect(Document document, long x, long y,
140        unsigned long topPadding, unsigned long rightPadding, unsigned long bottomPadding, unsigned long leftPadding,
141        boolean ignoreClipping, boolean allowChildFrameContent);
142
143    [TypeChecking=Interface] boolean hasSpellingMarker(Document document, long from, long length);
144    [TypeChecking=Interface] boolean hasGrammarMarker(Document document, long from, long length);
145    void setContinuousSpellCheckingEnabled(boolean enabled);
146
147    [TypeChecking=Interface] boolean isOverwriteModeEnabled(Document document);
148    [TypeChecking=Interface] void toggleOverwriteModeEnabled(Document document);
149
150    [TypeChecking=Interface] unsigned long numberOfScrollableAreas(Document document);
151
152    [TypeChecking=Interface] boolean isPageBoxVisible(Document document, long pageNumber);
153
154    readonly attribute InternalSettings settings;
155    readonly attribute InternalProfilers profilers;
156    readonly attribute InternalRuntimeFlags runtimeFlags;
157    readonly attribute unsigned long workerThreadCount;
158
159    // Flags for layerTreeAsText.
160    // The values of these constants must be kept in sync with the values of LayerTreeAsTextBehaviorFlags in GraphicsLayerClient.h.
161    const unsigned short LAYER_TREE_INCLUDES_REPAINT_RECTS = 2;
162    const unsigned short LAYER_TREE_INCLUDES_PAINTING_PHASES = 4;
163    const unsigned short LAYER_TREE_INCLUDES_ROOT_LAYER = 8;
164    const unsigned short LAYER_TREE_INCLUDES_CLIP_AND_SCROLL_PARENTS = 16;
165    [RaisesException, TypeChecking=Interface] DOMString layerTreeAsText(Document document, optional unsigned short flags);
166    [RaisesException, TypeChecking=Interface] DOMString elementLayerTreeAsText(Element element, optional unsigned short flags);
167
168    [RaisesException, TypeChecking=Interface] boolean scrollsWithRespectTo(Element element1, Element element2);
169    [RaisesException, TypeChecking=Interface] boolean isUnclippedDescendant(Element element);
170
171    [TypeChecking=Interface] DOMString scrollingStateTreeAsText(Document document);
172    [RaisesException, TypeChecking=Interface] DOMString mainThreadScrollingReasons(Document document);
173    [RaisesException, TypeChecking=Interface] ClientRectList nonFastScrollableRects(Document document);
174
175    [TypeChecking=Interface] void garbageCollectDocumentResources(Document document);
176    void evictAllResources();
177
178    unsigned long numberOfLiveNodes();
179    unsigned long numberOfLiveDocuments();
180    DOMString dumpRefCountedInstanceCounts();
181    sequence<DOMString> consoleMessageArgumentCounts(Document document);
182    unsigned long[] setMemoryCacheCapacities(unsigned long minDeadBytes, unsigned long maxDeadBytes, unsigned long totalBytes);
183    [RaisesException] void setInspectorResourcesDataSizeLimits(long maximumResourcesContentSize, long maximumSingleResourceContentSize);
184
185    DOMString counterValue(Element element);
186    long pageNumber(Element element, optional float pageWidth, optional float pageHeight);
187    DOMString[] shortcutIconURLs(Document document);
188    DOMString[] allIconURLs(Document document);
189    long numberOfPages(optional double pageWidthInPixels, optional double pageHeightInPixels);
190    [RaisesException] DOMString pageProperty(DOMString propertyName, long pageNumber);
191    [RaisesException] DOMString pageSizeAndMarginsInPixels(long pageIndex, long width, long height, long marginTop, long marginRight, long marginBottom, long marginLeft);
192
193    [RaisesException] void setDeviceScaleFactor(float scaleFactor);
194
195    [RaisesException, TypeChecking=Interface] void setIsCursorVisible(Document document, boolean isVisible);
196
197    void mediaPlayerRequestFullscreen(HTMLMediaElement mediaElement);
198    double effectiveMediaVolume(HTMLMediaElement mediaElement);
199    void mediaPlayerRemoteRouteAvailabilityChanged(HTMLMediaElement mediaElement, boolean available);
200    void mediaPlayerPlayingRemotelyChanged(HTMLMediaElement mediaElement, boolean remote);
201
202    void registerURLSchemeAsBypassingContentSecurityPolicy(DOMString scheme);
203    void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(DOMString scheme);
204
205    TypeConversions typeConversions();
206
207    // This is enabled only in Debug builds.
208    // This is because we want to avoid putting the byte stream of testing private scripts
209    // into the binary of Release builds.
210    PrivateScriptTest privateScriptTest();
211
212    DOMString[] getReferencedFilePaths();
213
214    // These functions both reset the tracked repaint rects. They are inteded to be used in the following order:
215    //  startTrackingRepaints, repaintRectsAsText, stopTrackingRepaints.
216    [RaisesException, TypeChecking=Interface] void startTrackingRepaints(Document document);
217    [RaisesException, TypeChecking=Interface] void stopTrackingRepaints(Document document);
218
219    // |node| should be Document, HTMLIFrameElement, or unspecified.
220    // If |node| is an HTMLIFrameElement, it assumes node.contentDocument is
221    // specified without security checks. Unspecified means this document.
222    [RaisesException] void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(optional Node node);
223
224    [RaisesException, TypeChecking=Interface] void forceFullRepaint(Document document);
225
226    // Returns a list of draggable/non-draggable regions in the document.
227    [RaisesException, TypeChecking=Interface] ClientRectList draggableRegions(Document document);
228    [RaisesException, TypeChecking=Interface] ClientRectList nonDraggableRegions(Document document);
229
230    // Returns a string with information about the mouse cursor used at the specified client location.
231    [RaisesException, TypeChecking=Interface] DOMString getCurrentCursorInfo(Document document);
232
233    [TypeChecking=Interface] DOMString markerTextForListItem(Element element);
234
235    SerializedScriptValue deserializeBuffer(ArrayBuffer buffer);
236    ArrayBuffer serializeObject(SerializedScriptValue obj);
237
238    void forceReload(boolean endToEnd);
239
240    [TypeChecking=Interface] DOMString getImageSourceURL(Element element);
241
242    [TypeChecking=Interface] boolean isSelectPopupVisible(Node node);
243    boolean selectPopupItemStyleIsRtl(Node select, long itemIndex);
244    long selectPopupItemStyleFontHeight(Node select, long itemIndex);
245
246    [RaisesException] ClientRect selectionBounds();
247
248    boolean loseSharedGraphicsContext3D();
249
250    [RaisesException, TypeChecking=Interface] void forceCompositingUpdate(Document document);
251
252    void setZoomFactor(float factor);
253
254    [RaisesException, TypeChecking=Interface] void setShouldRevealPassword(Element element, boolean reveal);
255
256    [CallWith=ScriptState] Promise createResolvedPromise(any value);
257    [CallWith=ScriptState] Promise createRejectedPromise(any reason);
258    [CallWith=ScriptState] Promise addOneToPromise(Promise promise);
259    [CallWith=ScriptState, RaisesException] Promise promiseCheck(long arg1, boolean arg2, Dictionary arg3, DOMString arg4, DOMString[] arg5);
260    [CallWith=ScriptState] Promise promiseCheckWithoutExceptionState(Dictionary arg1, DOMString arg2, DOMString... variadic);
261    [CallWith=ScriptState] Promise promiseCheckRange([EnforceRange] octet arg1);
262
263    void setValueForUser(Element element, DOMString value);
264
265    DOMString textSurroundingNode(Node node, long x, long y, unsigned long maxLength);
266
267    void setFocused(boolean focused);
268
269    [TypeChecking=Interface] boolean ignoreLayoutWithPendingStylesheets(Document document);
270
271    // These functions are for testing NetInfo. You must call setNetworkStateNotifierTestOnly(true)
272    // before calling setNetworkConnectionInfo.
273    void setNetworkStateNotifierTestOnly(boolean testOnly);
274    [RaisesException] void setNetworkConnectionInfo(DOMString type);
275
276    // This function is for testing HitRegions on Canvas2D.
277    unsigned long countHitRegions(CanvasRenderingContext2D context);
278
279    DOMString serializeNavigationMarkup();
280    void hideAllTransitionElements();
281
282    [RaisesException, TypeChecking=Interface] void forcePluginPlaceholder(HTMLElement plugin, DOMString htmlSource);
283    [RaisesException, TypeChecking=Interface] void forcePluginPlaceholder(HTMLElement plugin, Dictionary options);
284
285    DictionaryTest dictionaryTest();
286};
287