Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / testing / Internals.h
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 #ifndef Internals_h
28 #define Internals_h
29
30 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
31 #include "bindings/core/v8/ScriptPromise.h"
32 #include "bindings/core/v8/ScriptValue.h"
33 #include "bindings/core/v8/ScriptWrappable.h"
34 #include "core/css/CSSComputedStyleDeclaration.h"
35 #include "core/dom/ContextLifecycleObserver.h"
36 #include "core/page/scrolling/ScrollingCoordinator.h"
37 #include "platform/heap/Handle.h"
38 #include "wtf/PassRefPtr.h"
39 #include "wtf/RefCounted.h"
40 #include "wtf/text/WTFString.h"
41
42 namespace blink {
43
44 class CanvasRenderingContext2D;
45 class ClientRect;
46 class ClientRectList;
47 class DOMArrayBuffer;
48 class DOMPoint;
49 class DOMStringList;
50 class DictionaryTest;
51 class Document;
52 class DocumentFragment;
53 class DocumentMarker;
54 class Element;
55 class ExceptionState;
56 class ExecutionContext;
57 class GCObservation;
58 class HTMLElement;
59 class HTMLMediaElement;
60 class InternalProfilers;
61 class InternalRuntimeFlags;
62 class InternalSettings;
63 class Iterator;
64 class LayerRectList;
65 class LocalDOMWindow;
66 class LocalFrame;
67 class Node;
68 class Page;
69 class PagePopupController;
70 class PrivateScriptTest;
71 class Range;
72 class SerializedScriptValue;
73 class ShadowRoot;
74 class TypeConversions;
75 class UnionTypesTest;
76 template <typename NodeType> class StaticNodeTypeList;
77 typedef StaticNodeTypeList<Node> StaticNodeList;
78
79 class Internals final : public GarbageCollectedFinalized<Internals>, public ScriptWrappable, public ContextLifecycleObserver {
80     DEFINE_WRAPPERTYPEINFO();
81 public:
82     static Internals* create(Document*);
83     virtual ~Internals();
84
85     static void resetToConsistentState(Page*);
86
87     String elementRenderTreeAsText(Element*, ExceptionState&);
88
89     String address(Node*);
90
91     GCObservation* observeGC(ScriptValue);
92
93     bool isPreloaded(const String& url);
94     bool isLoadingFromMemoryCache(const String& url);
95
96     bool isSharingStyle(Element*, Element*) const;
97
98     PassRefPtrWillBeRawPtr<CSSStyleDeclaration> computedStyleIncludingVisitedInfo(Node*) const;
99
100     PassRefPtrWillBeRawPtr<ShadowRoot> createUserAgentShadowRoot(Element* host);
101
102     ShadowRoot* shadowRoot(Element* host);
103     ShadowRoot* youngestShadowRoot(Element* host);
104     ShadowRoot* oldestShadowRoot(Element* host);
105     ShadowRoot* youngerShadowRoot(Node* shadow, ExceptionState&);
106     String shadowRootType(const Node*, ExceptionState&) const;
107     bool hasShadowInsertionPoint(const Node*, ExceptionState&) const;
108     bool hasContentElement(const Node*, ExceptionState&) const;
109     size_t countElementShadow(const Node*, ExceptionState&) const;
110     const AtomicString& shadowPseudoId(Element*);
111
112     // CSS Animation / Transition testing.
113     void pauseAnimations(double pauseTime, ExceptionState&);
114
115     bool isValidContentSelect(Element* insertionPoint, ExceptionState&);
116     Node* treeScopeRootNode(Node*);
117     Node* parentTreeScope(Node*);
118     bool hasSelectorForIdInShadow(Element* host, const AtomicString& idValue, ExceptionState&);
119     bool hasSelectorForClassInShadow(Element* host, const AtomicString& className, ExceptionState&);
120     bool hasSelectorForAttributeInShadow(Element* host, const AtomicString& attributeName, ExceptionState&);
121     bool hasSelectorForPseudoClassInShadow(Element* host, const String& pseudoClass, ExceptionState&);
122     unsigned short compareTreeScopePosition(const Node*, const Node*, ExceptionState&) const;
123
124     // FIXME: Rename these functions if walker is preferred.
125     Node* nextSiblingByWalker(Node*);
126     Node* firstChildByWalker(Node*);
127     Node* lastChildByWalker(Node*);
128     Node* nextNodeByWalker(Node*);
129     Node* previousNodeByWalker(Node*);
130
131     unsigned updateStyleAndReturnAffectedElementCount(ExceptionState&) const;
132     unsigned needsLayoutCount(ExceptionState&) const;
133     unsigned hitTestCount(Document*, ExceptionState&) const;
134
135     String visiblePlaceholder(Element*);
136     void selectColorInColorChooser(Element*, const String& colorValue);
137     void endColorChooser(Element*);
138     bool hasAutofocusRequest(Document*);
139     bool hasAutofocusRequest();
140     Vector<String> formControlStateOfHistoryItem(ExceptionState&);
141     void setFormControlStateOfHistoryItem(const Vector<String>&, ExceptionState&);
142     void setEnableMockPagePopup(bool, ExceptionState&);
143     PassRefPtrWillBeRawPtr<PagePopupController> pagePopupController();
144     LocalDOMWindow* pagePopupWindow() const;
145
146     PassRefPtrWillBeRawPtr<ClientRect> absoluteCaretBounds(ExceptionState&);
147
148     PassRefPtrWillBeRawPtr<ClientRect> boundingBox(Element*);
149
150     unsigned markerCountForNode(Node*, const String&, ExceptionState&);
151     unsigned activeMarkerCountForNode(Node*);
152     PassRefPtrWillBeRawPtr<Range> markerRangeForNode(Node*, const String& markerType, unsigned index, ExceptionState&);
153     String markerDescriptionForNode(Node*, const String& markerType, unsigned index, ExceptionState&);
154     void addTextMatchMarker(const Range*, bool isActive);
155     void setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool);
156     void setMarkedTextMatchesAreHighlighted(Document*, bool);
157
158     void setFrameViewPosition(Document*, long x, long y, ExceptionState&);
159     String viewportAsText(Document*, float devicePixelRatio, int availableWidth, int availableHeight, ExceptionState&);
160
161     bool wasLastChangeUserEdit(Element* textField, ExceptionState&);
162     bool elementShouldAutoComplete(Element* inputElement, ExceptionState&);
163     String suggestedValue(Element*, ExceptionState&);
164     void setSuggestedValue(Element*, const String&, ExceptionState&);
165     void setEditingValue(Element* inputElement, const String&, ExceptionState&);
166     void setAutofilled(Element*, bool enabled, ExceptionState&);
167     void scrollElementToRect(Element*, long x, long y, long w, long h, ExceptionState&);
168
169     PassRefPtrWillBeRawPtr<Range> rangeFromLocationAndLength(Element* scope, int rangeLocation, int rangeLength);
170     unsigned locationFromRange(Element* scope, const Range*);
171     unsigned lengthFromRange(Element* scope, const Range*);
172     String rangeAsText(const Range*);
173
174     DOMPoint* touchPositionAdjustedToBestClickableNode(long x, long y, long width, long height, Document*, ExceptionState&);
175     Node* touchNodeAdjustedToBestClickableNode(long x, long y, long width, long height, Document*, ExceptionState&);
176     DOMPoint* touchPositionAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document*, ExceptionState&);
177     Node* touchNodeAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document*, ExceptionState&);
178     PassRefPtrWillBeRawPtr<ClientRect> bestZoomableAreaForTouchPoint(long x, long y, long width, long height, Document*, ExceptionState&);
179
180     int lastSpellCheckRequestSequence(Document*, ExceptionState&);
181     int lastSpellCheckProcessedSequence(Document*, ExceptionState&);
182
183     Vector<AtomicString> userPreferredLanguages() const;
184     void setUserPreferredLanguages(const Vector<String>&);
185
186     unsigned activeDOMObjectCount(Document*);
187     unsigned wheelEventHandlerCount(Document*);
188     unsigned scrollEventHandlerCount(Document*);
189     unsigned touchEventHandlerCount(Document*);
190     LayerRectList* touchEventTargetLayerRects(Document*, ExceptionState&);
191
192     // This is used to test rect based hit testing like what's done on touch screens.
193     PassRefPtrWillBeRawPtr<StaticNodeList> nodesFromRect(Document*, int x, int y, unsigned topPadding, unsigned rightPadding,
194         unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowChildFrameContent, ExceptionState&) const;
195
196     bool hasSpellingMarker(Document*, int from, int length);
197     bool hasGrammarMarker(Document*, int from, int length);
198     void setContinuousSpellCheckingEnabled(bool);
199
200     bool isOverwriteModeEnabled(Document*);
201     void toggleOverwriteModeEnabled(Document*);
202
203     unsigned numberOfScrollableAreas(Document*);
204
205     bool isPageBoxVisible(Document*, int pageNumber);
206
207     static const char* internalsId;
208
209     InternalSettings* settings() const;
210     InternalRuntimeFlags* runtimeFlags() const;
211     InternalProfilers* profilers();
212     unsigned workerThreadCount() const;
213
214     void setDeviceProximity(Document*, const String& eventType, double value, double min, double max, ExceptionState&);
215
216     String layerTreeAsText(Document*, unsigned flags, ExceptionState&) const;
217     String layerTreeAsText(Document*, ExceptionState&) const;
218     String elementLayerTreeAsText(Element*, unsigned flags, ExceptionState&) const;
219     String elementLayerTreeAsText(Element*, ExceptionState&) const;
220
221     bool scrollsWithRespectTo(Element*, Element*, ExceptionState&);
222
223     String scrollingStateTreeAsText(Document*) const;
224     String mainThreadScrollingReasons(Document*, ExceptionState&) const;
225     PassRefPtrWillBeRawPtr<ClientRectList> nonFastScrollableRects(Document*, ExceptionState&) const;
226
227     void garbageCollectDocumentResources(Document*) const;
228     void evictAllResources() const;
229
230     unsigned numberOfLiveNodes() const;
231     unsigned numberOfLiveDocuments() const;
232     String dumpRefCountedInstanceCounts() const;
233     Vector<String> consoleMessageArgumentCounts(Document*) const;
234     PassRefPtrWillBeRawPtr<LocalDOMWindow> openDummyInspectorFrontend(const String& url);
235     void closeDummyInspectorFrontend();
236     Vector<unsigned long> setMemoryCacheCapacities(unsigned long minDeadBytes, unsigned long maxDeadBytes, unsigned long totalBytes);
237     void setInspectorResourcesDataSizeLimits(int maximumResourcesContentSize, int maximumSingleResourceContentSize, ExceptionState&);
238     String inspectorHighlightJSON(Node*, ExceptionState&);
239
240     String counterValue(Element*);
241
242     int pageNumber(Element*, float pageWidth = 800, float pageHeight = 600);
243     Vector<String> shortcutIconURLs(Document*) const;
244     Vector<String> allIconURLs(Document*) const;
245
246     int numberOfPages(float pageWidthInPixels = 800, float pageHeightInPixels = 600);
247     String pageProperty(String, int, ExceptionState& = ASSERT_NO_EXCEPTION) const;
248     String pageSizeAndMarginsInPixels(int, int, int, int, int, int, int, ExceptionState& = ASSERT_NO_EXCEPTION) const;
249
250     void setDeviceScaleFactor(float scaleFactor, ExceptionState&);
251
252     void setIsCursorVisible(Document*, bool, ExceptionState&);
253
254     void mediaPlayerRequestFullscreen(HTMLMediaElement*);
255     double effectiveMediaVolume(HTMLMediaElement*);
256
257     void mediaPlayerRemoteRouteAvailabilityChanged(HTMLMediaElement*, bool);
258     void mediaPlayerPlayingRemotelyChanged(HTMLMediaElement*, bool);
259
260     void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme);
261     void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme);
262
263     TypeConversions* typeConversions() const;
264     PrivateScriptTest* privateScriptTest() const;
265     DictionaryTest* dictionaryTest() const;
266     UnionTypesTest* unionTypesTest() const;
267
268     Vector<String> getReferencedFilePaths() const;
269
270     void startTrackingRepaints(Document*, ExceptionState&);
271     void stopTrackingRepaints(Document*, ExceptionState&);
272     void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(ExceptionState&);
273     void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*, ExceptionState&);
274     void forceFullRepaint(Document*, ExceptionState&);
275
276     PassRefPtrWillBeRawPtr<ClientRectList> draggableRegions(Document*, ExceptionState&);
277     PassRefPtrWillBeRawPtr<ClientRectList> nonDraggableRegions(Document*, ExceptionState&);
278
279     PassRefPtr<DOMArrayBuffer> serializeObject(PassRefPtr<SerializedScriptValue>) const;
280     PassRefPtr<SerializedScriptValue> deserializeBuffer(PassRefPtr<DOMArrayBuffer>) const;
281
282     String getCurrentCursorInfo(Document*, ExceptionState&);
283
284     String markerTextForListItem(Element*);
285
286     void forceReload(bool endToEnd);
287
288     String getImageSourceURL(Element*);
289
290     bool isSelectPopupVisible(Node*);
291     bool selectPopupItemStyleIsRtl(Node*, int);
292     int selectPopupItemStyleFontHeight(Node*, int);
293
294     PassRefPtrWillBeRawPtr<ClientRect> selectionBounds(ExceptionState&);
295
296     bool loseSharedGraphicsContext3D();
297
298     void forceCompositingUpdate(Document*, ExceptionState&);
299
300     void setZoomFactor(float);
301
302     void setShouldRevealPassword(Element*, bool, ExceptionState&);
303
304     ScriptPromise createResolvedPromise(ScriptState*, ScriptValue);
305     ScriptPromise createRejectedPromise(ScriptState*, ScriptValue);
306     ScriptPromise addOneToPromise(ScriptState*, ScriptPromise);
307     ScriptPromise promiseCheck(ScriptState*, long, bool, const Dictionary&, const String&, const Vector<String>&, ExceptionState&);
308     ScriptPromise promiseCheckWithoutExceptionState(ScriptState*, const Dictionary&, const String&, const Vector<String>&);
309     ScriptPromise promiseCheckRange(ScriptState*, long);
310     ScriptPromise promiseCheckOverload(ScriptState*, Location*);
311     ScriptPromise promiseCheckOverload(ScriptState*, Document*);
312     ScriptPromise promiseCheckOverload(ScriptState*, Location*, long, long);
313
314     void trace(Visitor*);
315
316     void setValueForUser(Element*, const String&);
317
318     String textSurroundingNode(Node*, int x, int y, unsigned long maxLength);
319
320     void setFocused(bool);
321
322     bool ignoreLayoutWithPendingStylesheets(Document*);
323
324     void setNetworkStateNotifierTestOnly(bool);
325     // Test must call setNetworkStateNotifierTestOnly(true) before calling setNetworkConnectionInfo.
326     void setNetworkConnectionInfo(const String&, ExceptionState&);
327     String serializeNavigationMarkup();
328     void hideAllTransitionElements();
329
330     unsigned countHitRegions(CanvasRenderingContext2D*);
331
332     void forcePluginPlaceholder(HTMLElement* plugin, PassRefPtrWillBeRawPtr<DocumentFragment>, ExceptionState&);
333     void forcePluginPlaceholder(HTMLElement* plugin, const Dictionary& options, ExceptionState&);
334
335     Iterator* iterator(ScriptState*, ExceptionState&);
336
337 private:
338     explicit Internals(Document*);
339     Document* contextDocument() const;
340     LocalFrame* frame() const;
341     Vector<String> iconURLs(Document*, int iconTypesMask) const;
342     PassRefPtrWillBeRawPtr<ClientRectList> annotatedRegions(Document*, bool draggable, ExceptionState&);
343
344     DocumentMarker* markerAt(Node*, const String& markerType, unsigned index, ExceptionState&);
345     Member<InternalRuntimeFlags> m_runtimeFlags;
346     Member<InternalProfilers> m_profilers;
347 };
348
349 } // namespace blink
350
351 #endif // Internals_h