[safe-browsing] Database full hash matches like prefix match.
[chromium-blink-merge.git] / content / shell / renderer / test_runner / WebTestDelegate.h
blobfa4ef3300bfeeff2d566841f2caa1168f3fb2bd2
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTDELEGATE_H_
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTDELEGATE_H_
8 #include <string>
10 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
11 #include "third_party/WebKit/public/platform/WebString.h"
12 #include "third_party/WebKit/public/platform/WebURL.h"
13 #include "third_party/WebKit/public/platform/WebVector.h"
15 #define WEBTESTRUNNER_NEW_HISTORY_CAPTURE
17 namespace blink {
18 class WebDeviceMotionData;
19 class WebDeviceOrientationData;
20 class WebFrame;
21 class WebGamepad;
22 class WebGamepads;
23 class WebHistoryItem;
24 struct WebRect;
25 struct WebSize;
26 struct WebURLError;
29 namespace content {
30 class WebTestProxyBase;
31 struct TestPreferences;
34 namespace WebTestRunner {
36 class WebTask;
38 class WebTestDelegate {
39 public:
40 // Set and clear the edit command to execute on the next call to
41 // WebViewClient::handleCurrentKeyboardEvent().
42 virtual void clearEditCommand() = 0;
43 virtual void setEditCommand(const std::string& name, const std::string& value) = 0;
45 // Set the gamepads to return from Platform::sampleGamepads().
46 virtual void setGamepadData(const blink::WebGamepads&) = 0;
48 // Notifies blink about a new gamepad.
49 virtual void didConnectGamepad(int index, const blink::WebGamepad&) = 0;
51 // Notifies blink that a gamepad has been disconnected.
52 virtual void didDisconnectGamepad(int index, const blink::WebGamepad&) = 0;
54 // Set data to return when registering via Platform::setDeviceMotionListener().
55 virtual void setDeviceMotionData(const blink::WebDeviceMotionData&) = 0;
56 // Set data to return when registering via Platform::setDeviceOrientationListener().
57 virtual void setDeviceOrientationData(const blink::WebDeviceOrientationData&) = 0;
59 // Set orientation to set when registering via Platform::setScreenOrientationListener().
60 virtual void setScreenOrientation(const blink::WebScreenOrientationType&) = 0;
62 // Add a message to the text dump for the layout test.
63 virtual void printMessage(const std::string& message) = 0;
65 // The delegate takes ownership of the WebTask objects and is responsible
66 // for deleting them.
67 virtual void postTask(WebTask*) = 0;
68 virtual void postDelayedTask(WebTask*, long long ms) = 0;
70 // Register a new isolated filesystem with the given files, and return the
71 // new filesystem id.
72 virtual blink::WebString registerIsolatedFileSystem(const blink::WebVector<blink::WebString>& absoluteFilenames) = 0;
74 // Gets the current time in milliseconds since the UNIX epoch.
75 virtual long long getCurrentTimeInMillisecond() = 0;
77 // Convert the provided relative path into an absolute path.
78 virtual blink::WebString getAbsoluteWebStringFromUTF8Path(const std::string& path) = 0;
80 // Reads in the given file and returns its contents as data URL.
81 virtual blink::WebURL localFileToDataURL(const blink::WebURL&) = 0;
83 // Replaces file:///tmp/LayoutTests/ with the actual path to the
84 // LayoutTests directory.
85 virtual blink::WebURL rewriteLayoutTestsURL(const std::string& utf8URL) = 0;
87 // Manages the settings to used for layout tests.
88 virtual content::TestPreferences* preferences() = 0;
89 virtual void applyPreferences() = 0;
91 // Enables or disables synchronous resize mode. When enabled, all window-sizing machinery is
92 // short-circuited inside the renderer. This mode is necessary for some tests that were written
93 // before browsers had multi-process architecture and rely on window resizes to happen synchronously.
94 // The function has "unfortunate" it its name because we must strive to remove all tests
95 // that rely on this... well, unfortunate behavior. See http://crbug.com/309760 for the plan.
96 virtual void useUnfortunateSynchronousResizeMode(bool) = 0;
98 // Controls auto resize mode.
99 virtual void enableAutoResizeMode(const blink::WebSize& minSize, const blink::WebSize& maxSize) = 0;
100 virtual void disableAutoResizeMode(const blink::WebSize&) = 0;
102 // Clears DevTools' localStorage when an inspector test is started.
103 virtual void clearDevToolsLocalStorage() = 0;
105 // Opens and closes the inspector.
106 virtual void showDevTools(const std::string& settings,
107 const std::string& frontend_url) = 0;
108 virtual void closeDevTools() = 0;
110 // Evaluate the given script in the DevTools agent.
111 virtual void evaluateInWebInspector(long callID, const std::string& script) = 0;
113 // Controls WebSQL databases.
114 virtual void clearAllDatabases() = 0;
115 virtual void setDatabaseQuota(int) = 0;
117 // Controls the device scale factor of the main WebView for hidpi tests.
118 virtual void setDeviceScaleFactor(float) = 0;
120 // Controls which WebView should be focused.
121 virtual void setFocus(content::WebTestProxyBase*, bool) = 0;
123 // Controls whether all cookies should be accepted or writing cookies in a
124 // third-party context is blocked.
125 virtual void setAcceptAllCookies(bool) = 0;
127 // The same as rewriteLayoutTestsURL unless the resource is a path starting
128 // with /tmp/, then return a file URL to a temporary file.
129 virtual std::string pathToLocalResource(const std::string& resource) = 0;
131 // Sets the POSIX locale of the current process.
132 virtual void setLocale(const std::string&) = 0;
134 // Invoked when the test finished.
135 virtual void testFinished() = 0;
137 // Invoked when the embedder should close all but the main WebView.
138 virtual void closeRemainingWindows() = 0;
140 virtual void deleteAllCookies() = 0;
142 // Returns the length of the back/forward history of the main WebView.
143 virtual int navigationEntryCount() = 0;
145 // The following trigger navigations on the main WebViwe.
146 virtual void goToOffset(int offset) = 0;
147 virtual void reload() = 0;
148 virtual void loadURLForFrame(const blink::WebURL&, const std::string& frameName) = 0;
150 // Returns true if resource requests to external URLs should be permitted.
151 virtual bool allowExternalPages() = 0;
153 // Returns a text dump the back/forward history for the WebView associated
154 // with the given WebTestProxyBase.
155 virtual std::string dumpHistoryForWindow(content::WebTestProxyBase*) = 0;
160 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTDELEGATE_H_