Upstream version 7.36.149.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/v8/ExceptionStatePlaceholder.h"
31 #include "bindings/v8/ScriptPromise.h"
32 #include "bindings/v8/ScriptValue.h"
33 #include "core/css/CSSComputedStyleDeclaration.h"
34 #include "core/dom/ContextLifecycleObserver.h"
35 #include "core/dom/NodeList.h"
36 #include "core/page/scrolling/ScrollingCoordinator.h"
37 #include "platform/heap/Handle.h"
38 #include "wtf/ArrayBuffer.h"
39 #include "wtf/PassRefPtr.h"
40 #include "wtf/RefCounted.h"
41 #include "wtf/text/WTFString.h"
42
43 namespace WebCore {
44
45 class ClientRect;
46 class ClientRectList;
47 class DOMPoint;
48 class DOMStringList;
49 class DOMWindow;
50 class Document;
51 class DocumentMarker;
52 class Element;
53 class ExceptionState;
54 class ExecutionContext;
55 class GCObservation;
56 class HTMLMediaElement;
57 class InternalProfilers;
58 class InternalRuntimeFlags;
59 class InternalSettings;
60 class LayerRectList;
61 class LocalFrame;
62 class MallocStatistics;
63 class Node;
64 class Page;
65 class PagePopupController;
66 class Range;
67 class SerializedScriptValue;
68 class ShadowRoot;
69 class TypeConversions;
70
71 class Internals FINAL : public RefCountedWillBeGarbageCollectedFinalized<Internals>, public ContextLifecycleObserver {
72 public:
73     static PassRefPtrWillBeRawPtr<Internals> create(Document*);
74     virtual ~Internals();
75
76     static void resetToConsistentState(Page*);
77
78     String elementRenderTreeAsText(Element*, ExceptionState&);
79
80     String address(Node*);
81
82     PassRefPtrWillBeRawPtr<GCObservation> observeGC(ScriptValue);
83
84     bool isPreloaded(const String& url);
85     bool isLoadingFromMemoryCache(const String& url);
86
87     void crash();
88
89     void setStyleResolverStatsEnabled(bool);
90     String styleResolverStatsReport(ExceptionState&) const;
91     String styleResolverStatsTotalsReport(ExceptionState&) const;
92
93     bool isSharingStyle(Element*, Element*, ExceptionState&) const;
94
95     size_t numberOfScopedHTMLStyleChildren(const Node*, ExceptionState&) const;
96     PassRefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleIncludingVisitedInfo(Node*, ExceptionState&) const;
97
98     ShadowRoot* shadowRoot(Element* host, ExceptionState&);
99     ShadowRoot* youngestShadowRoot(Element* host, ExceptionState&);
100     ShadowRoot* oldestShadowRoot(Element* host, ExceptionState&);
101     ShadowRoot* youngerShadowRoot(Node* shadow, ExceptionState&);
102     String shadowRootType(const Node*, ExceptionState&) const;
103     bool hasShadowInsertionPoint(const Node*, ExceptionState&) const;
104     bool hasContentElement(const Node*, ExceptionState&) const;
105     size_t countElementShadow(const Node*, ExceptionState&) const;
106     const AtomicString& shadowPseudoId(Element*, ExceptionState&);
107     void setShadowPseudoId(Element*, const AtomicString&, ExceptionState&);
108
109     // CSS Animation / Transition testing.
110     unsigned numberOfActiveAnimations() const;
111     void pauseAnimations(double pauseTime, ExceptionState&);
112
113     bool isValidContentSelect(Element* insertionPoint, ExceptionState&);
114     Node* treeScopeRootNode(Node*, ExceptionState&);
115     Node* parentTreeScope(Node*, ExceptionState&);
116     bool hasSelectorForIdInShadow(Element* host, const AtomicString& idValue, ExceptionState&);
117     bool hasSelectorForClassInShadow(Element* host, const AtomicString& className, ExceptionState&);
118     bool hasSelectorForAttributeInShadow(Element* host, const AtomicString& attributeName, ExceptionState&);
119     bool hasSelectorForPseudoClassInShadow(Element* host, const String& pseudoClass, ExceptionState&);
120     unsigned short compareTreeScopePosition(const Node*, const Node*, ExceptionState&) const;
121
122     // FIXME: Rename these functions if walker is prefered.
123     Node* nextSiblingByWalker(Node*, ExceptionState&);
124     Node* firstChildByWalker(Node*, ExceptionState&);
125     Node* lastChildByWalker(Node*, ExceptionState&);
126     Node* nextNodeByWalker(Node*, ExceptionState&);
127     Node* previousNodeByWalker(Node*, ExceptionState&);
128
129     unsigned updateStyleAndReturnAffectedElementCount(ExceptionState&) const;
130     unsigned needsLayoutCount(ExceptionState&) const;
131
132     String visiblePlaceholder(Element*);
133     void selectColorInColorChooser(Element*, const String& colorValue);
134     bool hasAutofocusRequest(Document*);
135     bool hasAutofocusRequest();
136     Vector<String> formControlStateOfHistoryItem(ExceptionState&);
137     void setFormControlStateOfHistoryItem(const Vector<String>&, ExceptionState&);
138     void setEnableMockPagePopup(bool, ExceptionState&);
139     PassRefPtrWillBeRawPtr<PagePopupController> pagePopupController();
140
141     PassRefPtrWillBeRawPtr<ClientRect> unscaledViewportRect(ExceptionState&);
142
143     PassRefPtrWillBeRawPtr<ClientRect> absoluteCaretBounds(ExceptionState&);
144
145     PassRefPtrWillBeRawPtr<ClientRect> boundingBox(Element*, ExceptionState&);
146
147     unsigned markerCountForNode(Node*, const String&, ExceptionState&);
148     unsigned activeMarkerCountForNode(Node*, ExceptionState&);
149     PassRefPtrWillBeRawPtr<Range> markerRangeForNode(Node*, const String& markerType, unsigned index, ExceptionState&);
150     String markerDescriptionForNode(Node*, const String& markerType, unsigned index, ExceptionState&);
151     void addTextMatchMarker(const Range*, bool isActive);
152     void setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool, ExceptionState&);
153     void setMarkedTextMatchesAreHighlighted(Document*, bool, ExceptionState&);
154
155     void setScrollViewPosition(Document*, long x, long y, ExceptionState&);
156     String viewportAsText(Document*, float devicePixelRatio, int availableWidth, int availableHeight, ExceptionState&);
157
158     bool wasLastChangeUserEdit(Element* textField, ExceptionState&);
159     bool elementShouldAutoComplete(Element* inputElement, ExceptionState&);
160     String suggestedValue(Element*, ExceptionState&);
161     void setSuggestedValue(Element*, const String&, ExceptionState&);
162     void setEditingValue(Element* inputElement, const String&, ExceptionState&);
163     void setAutofilled(Element*, bool enabled, ExceptionState&);
164     void scrollElementToRect(Element*, long x, long y, long w, long h, ExceptionState&);
165
166     PassRefPtrWillBeRawPtr<Range> rangeFromLocationAndLength(Element* scope, int rangeLocation, int rangeLength, ExceptionState&);
167     unsigned locationFromRange(Element* scope, const Range*, ExceptionState&);
168     unsigned lengthFromRange(Element* scope, const Range*, ExceptionState&);
169     String rangeAsText(const Range*, ExceptionState&);
170
171     PassRefPtrWillBeRawPtr<DOMPoint> touchPositionAdjustedToBestClickableNode(long x, long y, long width, long height, Document*, ExceptionState&);
172     Node* touchNodeAdjustedToBestClickableNode(long x, long y, long width, long height, Document*, ExceptionState&);
173     PassRefPtrWillBeRawPtr<DOMPoint> touchPositionAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document*, ExceptionState&);
174     Node* touchNodeAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document*, ExceptionState&);
175     PassRefPtrWillBeRawPtr<ClientRect> bestZoomableAreaForTouchPoint(long x, long y, long width, long height, Document*, ExceptionState&);
176
177     int lastSpellCheckRequestSequence(Document*, ExceptionState&);
178     int lastSpellCheckProcessedSequence(Document*, ExceptionState&);
179
180     Vector<AtomicString> userPreferredLanguages() const;
181     void setUserPreferredLanguages(const Vector<String>&);
182
183     unsigned activeDOMObjectCount(Document*, ExceptionState&);
184     unsigned wheelEventHandlerCount(Document*, ExceptionState&);
185     unsigned scrollEventHandlerCount(Document*, ExceptionState&);
186     unsigned touchEventHandlerCount(Document*, ExceptionState&);
187     PassRefPtrWillBeRawPtr<LayerRectList> touchEventTargetLayerRects(Document*, ExceptionState&);
188
189     // This is used to test rect based hit testing like what's done on touch screens.
190     PassRefPtr<NodeList> nodesFromRect(Document*, int x, int y, unsigned topPadding, unsigned rightPadding,
191         unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowShadowContent, bool allowChildFrameContent, ExceptionState&) const;
192
193     void emitInspectorDidBeginFrame(int frameId = 0);
194     void emitInspectorDidCancelFrame();
195
196     bool hasSpellingMarker(Document*, int from, int length, ExceptionState&);
197     bool hasGrammarMarker(Document*, int from, int length, ExceptionState&);
198     void setContinuousSpellCheckingEnabled(bool enabled, ExceptionState&);
199
200     bool isOverwriteModeEnabled(Document*, ExceptionState&);
201     void toggleOverwriteModeEnabled(Document*, ExceptionState&);
202
203     unsigned numberOfScrollableAreas(Document*, ExceptionState&);
204
205     bool isPageBoxVisible(Document*, int pageNumber, ExceptionState&);
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     PassRefPtr<NodeList> paintOrderListBeforePromote(Element*, ExceptionState&);
222     PassRefPtr<NodeList> paintOrderListAfterPromote(Element*, ExceptionState&);
223
224     bool scrollsWithRespectTo(Element*, Element*, ExceptionState&);
225     bool isUnclippedDescendant(Element*, ExceptionState&);
226
227     void setNeedsCompositedScrolling(Element*, unsigned value, ExceptionState&);
228
229     String repaintRectsAsText(Document*, ExceptionState&) const;
230     PassRefPtrWillBeRawPtr<ClientRectList> repaintRects(Element*, ExceptionState&) const;
231
232     String scrollingStateTreeAsText(Document*, ExceptionState&) const;
233     String mainThreadScrollingReasons(Document*, ExceptionState&) const;
234     PassRefPtrWillBeRawPtr<ClientRectList> nonFastScrollableRects(Document*, ExceptionState&) const;
235
236     void garbageCollectDocumentResources(Document*, ExceptionState&) const;
237     void evictAllResources() const;
238
239     void allowRoundingHacks() const;
240
241     unsigned numberOfLiveNodes() const;
242     unsigned numberOfLiveDocuments() const;
243     String dumpRefCountedInstanceCounts() const;
244     Vector<String> consoleMessageArgumentCounts(Document*) const;
245     PassRefPtrWillBeRawPtr<DOMWindow> openDummyInspectorFrontend(const String& url);
246     void closeDummyInspectorFrontend();
247     Vector<unsigned long> setMemoryCacheCapacities(unsigned long minDeadBytes, unsigned long maxDeadBytes, unsigned long totalBytes);
248     void setInspectorResourcesDataSizeLimits(int maximumResourcesContentSize, int maximumSingleResourceContentSize, ExceptionState&);
249
250     String counterValue(Element*);
251
252     int pageNumber(Element*, float pageWidth = 800, float pageHeight = 600);
253     Vector<String> shortcutIconURLs(Document*) const;
254     Vector<String> allIconURLs(Document*) const;
255
256     int numberOfPages(float pageWidthInPixels = 800, float pageHeightInPixels = 600);
257     String pageProperty(String, int, ExceptionState& = ASSERT_NO_EXCEPTION) const;
258     String pageSizeAndMarginsInPixels(int, int, int, int, int, int, int, ExceptionState& = ASSERT_NO_EXCEPTION) const;
259
260     void setDeviceScaleFactor(float scaleFactor, ExceptionState&);
261
262     void setIsCursorVisible(Document*, bool, ExceptionState&);
263
264     void webkitWillEnterFullScreenForElement(Document*, Element*);
265     void webkitDidEnterFullScreenForElement(Document*, Element*);
266     void webkitWillExitFullScreenForElement(Document*, Element*);
267     void webkitDidExitFullScreenForElement(Document*, Element*);
268
269     void mediaPlayerRequestFullscreen(HTMLMediaElement*);
270
271     void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme);
272     void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme);
273
274     PassRefPtrWillBeRawPtr<MallocStatistics> mallocStatistics() const;
275     PassRefPtrWillBeRawPtr<TypeConversions> typeConversions() const;
276
277     Vector<String> getReferencedFilePaths() const;
278
279     void startTrackingRepaints(Document*, ExceptionState&);
280     void stopTrackingRepaints(Document*, ExceptionState&);
281     void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(ExceptionState&);
282     void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*, ExceptionState&);
283
284     PassRefPtrWillBeRawPtr<ClientRectList> draggableRegions(Document*, ExceptionState&);
285     PassRefPtrWillBeRawPtr<ClientRectList> nonDraggableRegions(Document*, ExceptionState&);
286
287     PassRefPtr<ArrayBuffer> serializeObject(PassRefPtr<SerializedScriptValue>) const;
288     PassRefPtr<SerializedScriptValue> deserializeBuffer(PassRefPtr<ArrayBuffer>) const;
289
290     String getCurrentCursorInfo(Document*, ExceptionState&);
291
292     String markerTextForListItem(Element*, ExceptionState&);
293
294     void forceReload(bool endToEnd);
295
296     String getImageSourceURL(Element*, ExceptionState&);
297
298     bool isSelectPopupVisible(Node*);
299
300     PassRefPtrWillBeRawPtr<ClientRect> selectionBounds(ExceptionState&);
301     String baseURL(Document*, ExceptionState&);
302
303     bool loseSharedGraphicsContext3D();
304
305     void forceCompositingUpdate(Document*, ExceptionState&);
306
307     bool isCompositorFramePending(Document*, ExceptionState&);
308
309     void setZoomFactor(float);
310
311     void setShouldRevealPassword(Element*, bool, ExceptionState&);
312
313     ScriptPromise createPromise(ScriptState*);
314     ScriptPromise createResolvedPromise(ScriptState*, ScriptValue);
315     ScriptPromise createRejectedPromise(ScriptState*, ScriptValue);
316     ScriptPromise addOneToPromise(ExecutionContext*, ScriptPromise);
317
318     void trace(Visitor*);
319
320     void setValueForUser(Element*, const String&);
321
322     String textSurroundingNode(Node*, int x, int y, unsigned long maxLength);
323
324 private:
325     explicit Internals(Document*);
326     Document* contextDocument() const;
327     LocalFrame* frame() const;
328     Vector<String> iconURLs(Document*, int iconTypesMask) const;
329     PassRefPtrWillBeRawPtr<ClientRectList> annotatedRegions(Document*, bool draggable, ExceptionState&);
330
331     DocumentMarker* markerAt(Node*, const String& markerType, unsigned index, ExceptionState&);
332     RefPtrWillBeMember<InternalRuntimeFlags> m_runtimeFlags;
333     RefPtrWillBeMember<InternalProfilers> m_profilers;
334 };
335
336 } // namespace WebCore
337
338 #endif