[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 1 | // Copyright 2014 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. |
| 4 | |
jochen | 73e711c | 2015-06-03 10:01:46 | [diff] [blame] | 5 | #ifndef COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_ |
| 6 | #define COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_ |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 7 | |
avi | 5dd91f8 | 2015-12-25 22:30:46 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 10 | #include <deque> |
dcheng | 82beb4f | 2016-04-26 00:35:02 | [diff] [blame] | 11 | #include <memory> |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 12 | #include <set> |
| 13 | #include <string> |
benwells | 0c0d3f1 | 2015-05-25 01:03:17 | [diff] [blame] | 14 | #include <vector> |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 15 | |
avi | 5dd91f8 | 2015-12-25 22:30:46 | [diff] [blame] | 16 | #include "base/macros.h" |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 17 | #include "base/memory/weak_ptr.h" |
lukasza | 083b4f1 | 2016-03-24 16:51:43 | [diff] [blame] | 18 | #include "components/test_runner/layout_test_runtime_flags.h" |
jochen | 746754c5 | 2015-06-05 16:40:41 | [diff] [blame] | 19 | #include "components/test_runner/test_runner_export.h" |
jochen | 73e711c | 2015-06-03 10:01:46 | [diff] [blame] | 20 | #include "components/test_runner/web_test_runner.h" |
lukasza | 1b546c1 | 2016-04-04 16:19:20 | [diff] [blame] | 21 | #include "third_party/WebKit/public/platform/WebImage.h" |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 22 | #include "v8/include/v8.h" |
| 23 | |
[email protected] | 945babb | 2014-07-30 14:25:32 | [diff] [blame] | 24 | class GURL; |
[email protected] | eec9e78e | 2014-06-16 21:38:48 | [diff] [blame] | 25 | class SkBitmap; |
| 26 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 27 | namespace blink { |
mlamouri | 007f9d7 | 2015-02-27 16:27:25 | [diff] [blame] | 28 | class WebContentSettingsClient; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 29 | class WebFrame; |
lukasza | b2ad050 | 2016-04-27 15:51:42 | [diff] [blame^] | 30 | class WebLocalFrame; |
mcasas | 43ff56ff | 2015-10-08 05:24:37 | [diff] [blame] | 31 | class WebMediaStream; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 32 | class WebString; |
| 33 | class WebView; |
kenneth.r.christiansen | 1a4946d | 2014-09-25 16:11:06 | [diff] [blame] | 34 | class WebURLResponse; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | namespace gin { |
| 38 | class ArrayBufferView; |
| 39 | class Arguments; |
| 40 | } |
| 41 | |
jochen | f5f3175 | 2015-06-03 12:06:34 | [diff] [blame] | 42 | namespace test_runner { |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 43 | |
[email protected] | 97d3fe8b | 2014-04-05 02:40:00 | [diff] [blame] | 44 | class InvokeCallbackTask; |
lukasza | 2135323 | 2016-04-12 19:52:11 | [diff] [blame] | 45 | class MockContentSettingsClient; |
lukasza | 5c2279c | 2016-04-05 16:44:47 | [diff] [blame] | 46 | class MockCredentialManagerClient; |
lukasza | 6a113ae1 | 2016-03-17 22:41:20 | [diff] [blame] | 47 | class MockScreenOrientationClient; |
lukasza | 01da260 | 2016-04-05 14:51:26 | [diff] [blame] | 48 | class MockWebSpeechRecognizer; |
lukasza | fd12460 | 2016-04-01 16:53:30 | [diff] [blame] | 49 | class MockWebUserMediaClient; |
lukasza | 5c2279c | 2016-04-05 16:44:47 | [diff] [blame] | 50 | class SpellCheckClient; |
[email protected] | 79ecada | 2014-05-04 05:16:16 | [diff] [blame] | 51 | class TestInterfaces; |
lukasza | b2ad050 | 2016-04-27 15:51:42 | [diff] [blame^] | 52 | class TestRunnerForSpecificView; |
[email protected] | 79ecada | 2014-05-04 05:16:16 | [diff] [blame] | 53 | class WebTestDelegate; |
[email protected] | a2ec0bc | 2014-04-23 08:18:27 | [diff] [blame] | 54 | class WebTestProxyBase; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 55 | |
lukasza | b2ad050 | 2016-04-27 15:51:42 | [diff] [blame^] | 56 | // TestRunner class currently has dual purpose: |
| 57 | // 1. It implements |testRunner| javascript bindings for "global" / "ambient". |
| 58 | // Examples: |
| 59 | // - testRunner.dumpAsText (test flag affecting test behavior) |
| 60 | // - testRunner.setAllowDisplayOfInsecureContent (test flag affecting product |
| 61 | // behavior) |
| 62 | // - testRunner.setTextSubpixelPositioning (directly interacts with product). |
| 63 | // Note that "per-view" (non-"global") bindings are handled by |
| 64 | // instances of TestRunnerForSpecificView class. |
| 65 | // 2. It manages global test state. Example: |
| 66 | // - Tracking topLoadingFrame that can finish the test when it loads. |
| 67 | // - WorkQueue holding load requests from the TestInterfaces |
| 68 | // - LayoutTestRuntimeFlags |
lukasza | c935882 | 2016-04-07 14:43:46 | [diff] [blame] | 69 | class TestRunner : public WebTestRunner { |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 70 | public: |
[email protected] | 79ecada | 2014-05-04 05:16:16 | [diff] [blame] | 71 | explicit TestRunner(TestInterfaces*); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 72 | virtual ~TestRunner(); |
| 73 | |
lukasza | b2ad050 | 2016-04-27 15:51:42 | [diff] [blame^] | 74 | void Install(blink::WebLocalFrame* frame, |
| 75 | base::WeakPtr<TestRunnerForSpecificView> view_test_runner); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 76 | |
[email protected] | 79ecada | 2014-05-04 05:16:16 | [diff] [blame] | 77 | void SetDelegate(WebTestDelegate*); |
lukasza | f41da4b | 2016-04-14 22:33:20 | [diff] [blame] | 78 | void SetWebView(blink::WebView*); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 79 | |
| 80 | void Reset(); |
| 81 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 82 | void SetTestIsRunning(bool); |
| 83 | bool TestIsRunning() const { return test_is_running_; } |
| 84 | |
| 85 | bool UseMockTheme() const { return use_mock_theme_; } |
| 86 | |
| 87 | // WebTestRunner implementation. |
dcheng | e933b3e | 2014-10-21 11:44:09 | [diff] [blame] | 88 | bool ShouldGeneratePixelResults() override; |
| 89 | bool ShouldDumpAsAudio() const override; |
| 90 | void GetAudioData(std::vector<unsigned char>* buffer_view) const override; |
lukasza | ef264fc5 | 2016-03-17 22:49:19 | [diff] [blame] | 91 | bool IsRecursiveLayoutDumpRequested() override; |
| 92 | std::string DumpLayout(blink::WebLocalFrame* frame) override; |
lukasza | 1b546c1 | 2016-04-04 16:19:20 | [diff] [blame] | 93 | void DumpPixelsAsync( |
| 94 | blink::WebView* web_view, |
| 95 | const base::Callback<void(const SkBitmap&)>& callback) override; |
lukasza | 083b4f1 | 2016-03-24 16:51:43 | [diff] [blame] | 96 | void ReplicateLayoutTestRuntimeFlagsChanges( |
lukasza | c9cbe71 | 2016-03-14 14:06:43 | [diff] [blame] | 97 | const base::DictionaryValue& changed_values) override; |
lukasza | a896046 | 2016-01-27 22:27:33 | [diff] [blame] | 98 | bool HasCustomTextDump(std::string* custom_text_dump) const override; |
dcheng | e933b3e | 2014-10-21 11:44:09 | [diff] [blame] | 99 | bool ShouldDumpBackForwardList() const override; |
mlamouri | 007f9d7 | 2015-02-27 16:27:25 | [diff] [blame] | 100 | blink::WebContentSettingsClient* GetWebContentSettings() const override; |
lukasza | 5c2279c | 2016-04-05 16:44:47 | [diff] [blame] | 101 | void InitializeWebViewWithMocks(blink::WebView* web_view) override; |
lukasza | 95416be14 | 2016-04-14 15:06:33 | [diff] [blame] | 102 | void SetFocus(blink::WebView* web_view, bool focus) override; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 103 | |
lukasza | 01da260 | 2016-04-05 14:51:26 | [diff] [blame] | 104 | // Methods used by WebViewTestClient and WebFrameTestClient. |
| 105 | void OnAnimationScheduled(blink::WebView* view); |
| 106 | void OnAnimationBegun(blink::WebView* view); |
lukasza | a0b624a | 2016-04-04 15:00:49 | [diff] [blame] | 107 | std::string GetAcceptLanguages() const; |
lukasza | e26c3d6 | 2016-03-14 23:30:59 | [diff] [blame] | 108 | bool shouldStayOnPageAfterHandlingBeforeUnload() const; |
lukasza | 6a113ae1 | 2016-03-17 22:41:20 | [diff] [blame] | 109 | MockScreenOrientationClient* getMockScreenOrientationClient(); |
lukasza | fd12460 | 2016-04-01 16:53:30 | [diff] [blame] | 110 | MockWebUserMediaClient* getMockWebUserMediaClient(); |
lukasza | 01da260 | 2016-04-05 14:51:26 | [diff] [blame] | 111 | MockWebSpeechRecognizer* getMockWebSpeechRecognizer(); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 112 | bool isPrinting() const; |
[email protected] | f24836a | 2014-05-06 01:02:44 | [diff] [blame] | 113 | bool shouldDumpAsCustomText() const; |
| 114 | std:: string customDumpText() const; |
abhishek.a21 | ca9b560 | 2014-09-19 07:33:33 | [diff] [blame] | 115 | void ShowDevTools(const std::string& settings, |
[email protected] | 06c25301 | 2014-04-16 18:35:33 | [diff] [blame] | 116 | const std::string& frontend_url); |
abhishek.a21 | ca9b560 | 2014-09-19 07:33:33 | [diff] [blame] | 117 | void ClearDevToolsLocalStorage(); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 118 | void setShouldDumpAsText(bool); |
| 119 | void setShouldDumpAsMarkup(bool); |
ki.stfu | 939799a4 | 2015-09-28 04:41:20 | [diff] [blame] | 120 | void setCustomTextOutput(const std::string& text); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 121 | void setShouldGeneratePixelResults(bool); |
| 122 | void setShouldDumpFrameLoadCallbacks(bool); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 123 | void setShouldEnableViewSource(bool); |
| 124 | bool shouldDumpEditingCallbacks() const; |
| 125 | bool shouldDumpFrameLoadCallbacks() const; |
| 126 | bool shouldDumpPingLoaderCallbacks() const; |
| 127 | bool shouldDumpUserGestureInFrameLoadCallbacks() const; |
| 128 | bool shouldDumpTitleChanges() const; |
| 129 | bool shouldDumpIconChanges() const; |
| 130 | bool shouldDumpCreateView() const; |
| 131 | bool canOpenWindows() const; |
| 132 | bool shouldDumpResourceLoadCallbacks() const; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 133 | bool shouldDumpResourceResponseMIMETypes() const; |
| 134 | bool shouldDumpStatusCallbacks() const; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 135 | bool shouldDumpSpellCheckCallbacks() const; |
[email protected] | a79cb991 | 2014-04-26 22:07:33 | [diff] [blame] | 136 | bool shouldWaitUntilExternalURLLoad() const; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 137 | const std::set<std::string>* httpHeadersToClear() const; |
| 138 | void setTopLoadingFrame(blink::WebFrame*, bool); |
| 139 | blink::WebFrame* topLoadingFrame() const; |
| 140 | void policyDelegateDone(); |
| 141 | bool policyDelegateEnabled() const; |
| 142 | bool policyDelegateIsPermissive() const; |
| 143 | bool policyDelegateShouldNotifyDone() const; |
| 144 | bool shouldInterceptPostMessage() const; |
| 145 | bool shouldDumpResourcePriorities() const; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 146 | void setToolTipText(const blink::WebString&); |
lukasza | 1b546c1 | 2016-04-04 16:19:20 | [diff] [blame] | 147 | void setDragImage(const blink::WebImage& drag_image); |
jochen | c3a98da1 | 2015-03-10 13:59:58 | [diff] [blame] | 148 | bool shouldDumpNavigationPolicy() const; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 149 | |
| 150 | bool midiAccessorResult(); |
| 151 | |
lukasza | fd12460 | 2016-04-01 16:53:30 | [diff] [blame] | 152 | // Methods used by MockColorChooser: |
| 153 | void DidOpenChooser(); |
| 154 | void DidCloseChooser(); |
| 155 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 156 | // A single item in the work queue. |
| 157 | class WorkItem { |
| 158 | public: |
| 159 | virtual ~WorkItem() {} |
| 160 | |
| 161 | // Returns true if this started a load. |
[email protected] | 79ecada | 2014-05-04 05:16:16 | [diff] [blame] | 162 | virtual bool Run(WebTestDelegate*, blink::WebView*) = 0; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 163 | }; |
| 164 | |
| 165 | private: |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 166 | friend class TestRunnerBindings; |
| 167 | friend class WorkQueue; |
| 168 | |
| 169 | // Helper class for managing events queued by methods like queueLoad or |
| 170 | // queueScript. |
| 171 | class WorkQueue { |
| 172 | public: |
| 173 | explicit WorkQueue(TestRunner* controller); |
| 174 | virtual ~WorkQueue(); |
| 175 | void ProcessWorkSoon(); |
| 176 | |
| 177 | // Reset the state of the class between tests. |
| 178 | void Reset(); |
| 179 | |
| 180 | void AddWork(WorkItem*); |
| 181 | |
| 182 | void set_frozen(bool frozen) { frozen_ = frozen; } |
| 183 | bool is_empty() { return queue_.empty(); } |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 184 | |
| 185 | private: |
| 186 | void ProcessWork(); |
| 187 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 188 | std::deque<WorkItem*> queue_; |
| 189 | bool frozen_; |
| 190 | TestRunner* controller_; |
lukasza | c935882 | 2016-04-07 14:43:46 | [diff] [blame] | 191 | |
| 192 | base::WeakPtrFactory<WorkQueue> weak_factory_; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 193 | }; |
| 194 | |
| 195 | /////////////////////////////////////////////////////////////////////////// |
| 196 | // Methods dealing with the test logic |
| 197 | |
| 198 | // By default, tests end when page load is complete. These methods are used |
| 199 | // to delay the completion of the test until notifyDone is called. |
| 200 | void NotifyDone(); |
| 201 | void WaitUntilDone(); |
| 202 | |
| 203 | // Methods for adding actions to the work queue. Used in conjunction with |
| 204 | // waitUntilDone/notifyDone above. |
| 205 | void QueueBackNavigation(int how_far_back); |
| 206 | void QueueForwardNavigation(int how_far_forward); |
| 207 | void QueueReload(); |
| 208 | void QueueLoadingScript(const std::string& script); |
| 209 | void QueueNonLoadingScript(const std::string& script); |
| 210 | void QueueLoad(const std::string& url, const std::string& target); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 211 | |
| 212 | // Causes navigation actions just printout the intended navigation instead |
| 213 | // of taking you to the page. This is used for cases like mailto, where you |
| 214 | // don't actually want to open the mail program. |
| 215 | void SetCustomPolicyDelegate(gin::Arguments* args); |
| 216 | |
| 217 | // Delays completion of the test until the policy delegate runs. |
| 218 | void WaitForPolicyDelegate(); |
| 219 | |
| 220 | // Functions for dealing with windows. By default we block all new windows. |
| 221 | int WindowCount(); |
| 222 | void SetCloseRemainingWindowsWhenComplete(bool close_remaining_windows); |
| 223 | void ResetTestHelperControllers(); |
| 224 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 225 | // Allows layout tests to manage origins' whitelisting. |
| 226 | void AddOriginAccessWhitelistEntry(const std::string& source_origin, |
| 227 | const std::string& destination_protocol, |
| 228 | const std::string& destination_host, |
| 229 | bool allow_destination_subdomains); |
| 230 | void RemoveOriginAccessWhitelistEntry(const std::string& source_origin, |
| 231 | const std::string& destination_protocol, |
| 232 | const std::string& destination_host, |
| 233 | bool allow_destination_subdomains); |
| 234 | |
dcheng | 9000dbd | 2015-04-03 05:39:40 | [diff] [blame] | 235 | // Add |source_code| as an injected stylesheet to the active document of the |
| 236 | // window of the current V8 context. |
| 237 | void InsertStyleSheet(const std::string& source_code); |
| 238 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 239 | // Enables or disables subpixel positioning (i.e. fractional X positions for |
| 240 | // glyphs) in text rendering on Linux. Since this method changes global |
| 241 | // settings, tests that call it must use their own custom font family for |
| 242 | // all text that they render. If not, an already-cached style will be used, |
| 243 | // resulting in the changed setting being ignored. |
| 244 | void SetTextSubpixelPositioning(bool value); |
| 245 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 246 | // After this function is called, all window-sizing machinery is |
| 247 | // short-circuited inside the renderer. This mode is necessary for |
| 248 | // some tests that were written before browsers had multi-process architecture |
| 249 | // and rely on window resizes to happen synchronously. |
| 250 | // The function has "unfortunate" it its name because we must strive to remove |
| 251 | // all tests that rely on this... well, unfortunate behavior. See |
| 252 | // http://crbug.com/309760 for the plan. |
| 253 | void UseUnfortunateSynchronousResizeMode(); |
| 254 | |
| 255 | bool EnableAutoResizeMode(int min_width, |
| 256 | int min_height, |
| 257 | int max_width, |
| 258 | int max_height); |
| 259 | bool DisableAutoResizeMode(int new_width, int new_height); |
| 260 | |
[email protected] | 2ad7e62 | 2014-06-30 17:44:21 | [diff] [blame] | 261 | void SetMockDeviceLight(double value); |
| 262 | void ResetDeviceLight(); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 263 | // Device Motion / Device Orientation related functions |
| 264 | void SetMockDeviceMotion(bool has_acceleration_x, double acceleration_x, |
| 265 | bool has_acceleration_y, double acceleration_y, |
| 266 | bool has_acceleration_z, double acceleration_z, |
| 267 | bool has_acceleration_including_gravity_x, |
| 268 | double acceleration_including_gravity_x, |
| 269 | bool has_acceleration_including_gravity_y, |
| 270 | double acceleration_including_gravity_y, |
| 271 | bool has_acceleration_including_gravity_z, |
| 272 | double acceleration_including_gravity_z, |
| 273 | bool has_rotation_rate_alpha, |
| 274 | double rotation_rate_alpha, |
| 275 | bool has_rotation_rate_beta, |
| 276 | double rotation_rate_beta, |
| 277 | bool has_rotation_rate_gamma, |
| 278 | double rotation_rate_gamma, |
| 279 | double interval); |
| 280 | void SetMockDeviceOrientation(bool has_alpha, double alpha, |
| 281 | bool has_beta, double beta, |
| 282 | bool has_gamma, double gamma, |
philipj | 9790645 | 2016-03-02 14:46:22 | [diff] [blame] | 283 | bool absolute); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 284 | |
[email protected] | e0bc2cb | 2014-03-20 17:34:24 | [diff] [blame] | 285 | void SetMockScreenOrientation(const std::string& orientation); |
dgozman | 3c16f7f | 2016-02-26 01:21:18 | [diff] [blame] | 286 | void DisableMockScreenOrientation(); |
[email protected] | e0bc2cb | 2014-03-20 17:34:24 | [diff] [blame] | 287 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 288 | /////////////////////////////////////////////////////////////////////////// |
| 289 | // Methods modifying WebPreferences. |
| 290 | |
| 291 | // Set the WebPreference that controls webkit's popup blocking. |
| 292 | void SetPopupBlockingEnabled(bool block_popups); |
| 293 | |
| 294 | void SetJavaScriptCanAccessClipboard(bool can_access); |
| 295 | void SetXSSAuditorEnabled(bool enabled); |
| 296 | void SetAllowUniversalAccessFromFileURLs(bool allow); |
| 297 | void SetAllowFileAccessFromFileURLs(bool allow); |
ki.stfu | 939799a4 | 2015-09-28 04:41:20 | [diff] [blame] | 298 | void OverridePreference(const std::string& key, v8::Local<v8::Value> value); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 299 | |
[email protected] | ebd5ea5 | 2014-05-28 14:51:15 | [diff] [blame] | 300 | // Modify accept_languages in RendererPreferences. |
| 301 | void SetAcceptLanguages(const std::string& accept_languages); |
| 302 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 303 | // Enable or disable plugins. |
| 304 | void SetPluginsEnabled(bool enabled); |
| 305 | |
lukasza | 01da260 | 2016-04-05 14:51:26 | [diff] [blame] | 306 | // Returns |true| if an animation has been scheduled in one or more WebViews |
| 307 | // participating in the layout test. |
| 308 | bool GetAnimationScheduled() const; |
chrishtr | aea6066d | 2016-02-19 04:49:12 | [diff] [blame] | 309 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 310 | /////////////////////////////////////////////////////////////////////////// |
| 311 | // Methods that modify the state of TestRunner |
| 312 | |
| 313 | // This function sets a flag that tells the test_shell to print a line of |
| 314 | // descriptive text for each editing command. It takes no arguments, and |
| 315 | // ignores any that may be present. |
| 316 | void DumpEditingCallbacks(); |
| 317 | |
| 318 | // This function sets a flag that tells the test_shell to dump pages as |
| 319 | // plain text, rather than as a text representation of the renderer's state. |
| 320 | // The pixel results will not be generated for this test. |
| 321 | void DumpAsText(); |
| 322 | |
| 323 | // This function sets a flag that tells the test_shell to dump pages as |
[email protected] | fdc433c0 | 2014-06-02 19:27:14 | [diff] [blame] | 324 | // the DOM contents, rather than as a text representation of the renderer's |
| 325 | // state. The pixel results will not be generated for this test. |
| 326 | void DumpAsMarkup(); |
| 327 | |
| 328 | // This function sets a flag that tells the test_shell to dump pages as |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 329 | // plain text, rather than as a text representation of the renderer's state. |
| 330 | // It will also generate a pixel dump for the test. |
| 331 | void DumpAsTextWithPixelResults(); |
| 332 | |
| 333 | // This function sets a flag that tells the test_shell to print out the |
| 334 | // scroll offsets of the child frames. It ignores all. |
| 335 | void DumpChildFrameScrollPositions(); |
| 336 | |
| 337 | // This function sets a flag that tells the test_shell to recursively |
| 338 | // dump all frames as plain text if the DumpAsText flag is set. |
| 339 | // It takes no arguments, and ignores any that may be present. |
| 340 | void DumpChildFramesAsText(); |
| 341 | |
[email protected] | fdc433c0 | 2014-06-02 19:27:14 | [diff] [blame] | 342 | // This function sets a flag that tells the test_shell to recursively |
| 343 | // dump all frames as the DOM contents if the DumpAsMarkup flag is set. |
| 344 | // It takes no arguments, and ignores any that may be present. |
| 345 | void DumpChildFramesAsMarkup(); |
| 346 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 347 | // This function sets a flag that tells the test_shell to print out the |
| 348 | // information about icon changes notifications from WebKit. |
| 349 | void DumpIconChanges(); |
| 350 | |
| 351 | // Deals with Web Audio WAV file data. |
| 352 | void SetAudioData(const gin::ArrayBufferView& view); |
| 353 | |
| 354 | // This function sets a flag that tells the test_shell to print a line of |
| 355 | // descriptive text for each frame load callback. It takes no arguments, and |
| 356 | // ignores any that may be present. |
| 357 | void DumpFrameLoadCallbacks(); |
| 358 | |
| 359 | // This function sets a flag that tells the test_shell to print a line of |
| 360 | // descriptive text for each PingLoader dispatch. It takes no arguments, and |
| 361 | // ignores any that may be present. |
| 362 | void DumpPingLoaderCallbacks(); |
| 363 | |
| 364 | // This function sets a flag that tells the test_shell to print a line of |
| 365 | // user gesture status text for some frame load callbacks. It takes no |
| 366 | // arguments, and ignores any that may be present. |
| 367 | void DumpUserGestureInFrameLoadCallbacks(); |
| 368 | |
| 369 | void DumpTitleChanges(); |
| 370 | |
| 371 | // This function sets a flag that tells the test_shell to dump all calls to |
| 372 | // WebViewClient::createView(). |
| 373 | // It takes no arguments, and ignores any that may be present. |
| 374 | void DumpCreateView(); |
| 375 | |
| 376 | void SetCanOpenWindows(); |
| 377 | |
| 378 | // This function sets a flag that tells the test_shell to dump a descriptive |
| 379 | // line for each resource load callback. It takes no arguments, and ignores |
| 380 | // any that may be present. |
| 381 | void DumpResourceLoadCallbacks(); |
| 382 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 383 | // This function sets a flag that tells the test_shell to dump the MIME type |
| 384 | // for each resource that was loaded. It takes no arguments, and ignores any |
| 385 | // that may be present. |
| 386 | void DumpResourceResponseMIMETypes(); |
| 387 | |
mlamouri | 007f9d7 | 2015-02-27 16:27:25 | [diff] [blame] | 388 | // WebContentSettingsClient related. |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 389 | void SetImagesAllowed(bool allowed); |
[email protected] | e19024b9 | 2014-06-10 11:10:37 | [diff] [blame] | 390 | void SetMediaAllowed(bool allowed); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 391 | void SetScriptsAllowed(bool allowed); |
| 392 | void SetStorageAllowed(bool allowed); |
| 393 | void SetPluginsAllowed(bool allowed); |
| 394 | void SetAllowDisplayOfInsecureContent(bool allowed); |
| 395 | void SetAllowRunningOfInsecureContent(bool allowed); |
| 396 | void DumpPermissionClientCallbacks(); |
| 397 | |
| 398 | // This function sets a flag that tells the test_shell to dump all calls |
| 399 | // to window.status(). |
| 400 | // It takes no arguments, and ignores any that may be present. |
| 401 | void DumpWindowStatusChanges(); |
| 402 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 403 | // This function sets a flag that tells the test_shell to dump all |
| 404 | // the lines of descriptive text about spellcheck execution. |
| 405 | void DumpSpellCheckCallbacks(); |
| 406 | |
| 407 | // This function sets a flag that tells the test_shell to print out a text |
| 408 | // representation of the back/forward list. It ignores all arguments. |
| 409 | void DumpBackForwardList(); |
| 410 | |
| 411 | void DumpSelectionRect(); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 412 | |
| 413 | // Causes layout to happen as if targetted to printed pages. |
| 414 | void SetPrinting(); |
| 415 | |
[email protected] | 5284610 | 2014-06-24 04:26:44 | [diff] [blame] | 416 | // Clears the state from SetPrinting(). |
| 417 | void ClearPrinting(); |
| 418 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 419 | void SetShouldStayOnPageAfterHandlingBeforeUnload(bool value); |
| 420 | |
| 421 | // Causes WillSendRequest to clear certain headers. |
| 422 | void SetWillSendRequestClearHeader(const std::string& header); |
| 423 | |
| 424 | // This function sets a flag that tells the test_shell to dump a descriptive |
| 425 | // line for each resource load's priority and any time that priority |
| 426 | // changes. It takes no arguments, and ignores any that may be present. |
| 427 | void DumpResourceRequestPriorities(); |
| 428 | |
| 429 | // Sets a flag to enable the mock theme. |
| 430 | void SetUseMockTheme(bool use); |
| 431 | |
[email protected] | a79cb991 | 2014-04-26 22:07:33 | [diff] [blame] | 432 | // Sets a flag that causes the test to be marked as completed when the |
| 433 | // WebFrameClient receives a loadURLExternally() call. |
| 434 | void WaitUntilExternalURLLoad(); |
| 435 | |
lukasza | 1b546c1 | 2016-04-04 16:19:20 | [diff] [blame] | 436 | // This function sets a flag to dump the drag image when the next drag&drop is |
| 437 | // initiated. It is equivalent to DumpAsTextWithPixelResults but the pixel |
| 438 | // results will be the drag image instead of a snapshot of the page. |
jackhou | 656fc85 | 2015-02-13 09:04:17 | [diff] [blame] | 439 | void DumpDragImage(); |
| 440 | |
jochen | c3a98da1 | 2015-03-10 13:59:58 | [diff] [blame] | 441 | // Sets a flag that tells the WebTestProxy to dump the default navigation |
| 442 | // policy passed to the decidePolicyForNavigation callback. |
| 443 | void DumpNavigationPolicy(); |
| 444 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 445 | /////////////////////////////////////////////////////////////////////////// |
| 446 | // Methods interacting with the WebTestProxy |
| 447 | |
| 448 | /////////////////////////////////////////////////////////////////////////// |
| 449 | // Methods forwarding to the WebTestDelegate |
| 450 | |
| 451 | // Shows DevTools window. |
[email protected] | 06c25301 | 2014-04-16 18:35:33 | [diff] [blame] | 452 | void ShowWebInspector(const std::string& str, |
| 453 | const std::string& frontend_url); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 454 | void CloseWebInspector(); |
| 455 | |
| 456 | // Inspect chooser state |
| 457 | bool IsChooserShown(); |
| 458 | |
| 459 | // Allows layout tests to exec scripts at WebInspector side. |
| 460 | void EvaluateInWebInspector(int call_id, const std::string& script); |
sergeyv | 0cd842b4 | 2015-10-09 16:07:11 | [diff] [blame] | 461 | // Allows layout tests to evaluate scripts in InspectorOverlay page. |
| 462 | // Script may have an output represented as a string, return values of other |
| 463 | // types would be ignored. |
| 464 | std::string EvaluateInWebInspectorOverlay(const std::string& script); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 465 | |
| 466 | // Clears all databases. |
| 467 | void ClearAllDatabases(); |
| 468 | // Sets the default quota for all origins |
| 469 | void SetDatabaseQuota(int quota); |
| 470 | |
| 471 | // Changes the cookie policy from the default to allow all cookies. |
| 472 | void SetAlwaysAcceptCookies(bool accept); |
| 473 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 474 | // Converts a URL starting with file:///tmp/ to the local mapping. |
| 475 | std::string PathToLocalResource(const std::string& path); |
| 476 | |
mek | 340dd9d | 2014-12-11 02:10:46 | [diff] [blame] | 477 | // Enables mock geofencing service while running a layout test. |
| 478 | // |service_available| indicates if the mock service should mock geofencing |
| 479 | // being available or not. |
| 480 | void SetGeofencingMockProvider(bool service_available); |
| 481 | |
| 482 | // Disables mock geofencing service while running a layout test. |
| 483 | void ClearGeofencingMockProvider(); |
| 484 | |
| 485 | // Set the mock geofencing position while running a layout test. |
| 486 | void SetGeofencingMockPosition(double latitude, double longitude); |
| 487 | |
mlamouri | d5098d0 | 2015-04-21 12:17:30 | [diff] [blame] | 488 | // Sets the permission's |name| to |value| for a given {origin, embedder} |
| 489 | // tuple. |
| 490 | void SetPermission(const std::string& name, |
| 491 | const std::string& value, |
| 492 | const GURL& origin, |
| 493 | const GURL& embedding_origin); |
| 494 | |
benwells | 0c0d3f1 | 2015-05-25 01:03:17 | [diff] [blame] | 495 | // Resolve the beforeinstallprompt event with the matching request id. |
| 496 | void ResolveBeforeInstallPromptPromise(int request_id, |
| 497 | const std::string& platform); |
| 498 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 499 | // Calls setlocale(LC_ALL, ...) for a specified locale. |
| 500 | // Resets between tests. |
| 501 | void SetPOSIXLocale(const std::string& locale); |
| 502 | |
| 503 | // MIDI function to control permission handling. |
| 504 | void SetMIDIAccessorResult(bool result); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 505 | |
peter | d98157d | 2014-11-20 13:15:01 | [diff] [blame] | 506 | // Simulates a click on a Web Notification. |
johnme | 96d5012 | 2015-08-07 15:33:21 | [diff] [blame] | 507 | void SimulateWebNotificationClick(const std::string& title, int action_index); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 508 | |
nsatragno | 24bd34b | 2016-02-09 10:30:02 | [diff] [blame] | 509 | // Simulates closing a Web Notification. |
| 510 | void SimulateWebNotificationClose(const std::string& title, bool by_user); |
| 511 | |
[email protected] | 56e365d4 | 2014-05-02 22:18:24 | [diff] [blame] | 512 | // Speech recognition related functions. |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 513 | void AddMockSpeechRecognitionResult(const std::string& transcript, |
| 514 | double confidence); |
| 515 | void SetMockSpeechRecognitionError(const std::string& error, |
| 516 | const std::string& message); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 517 | |
mkwst | 41667ab | 2014-09-16 06:52:43 | [diff] [blame] | 518 | // Credential Manager mock functions |
| 519 | // TODO(mkwst): Support FederatedCredential. |
| 520 | void AddMockCredentialManagerResponse(const std::string& id, |
| 521 | const std::string& name, |
| 522 | const std::string& avatar, |
| 523 | const std::string& password); |
mkwst | 008acce6 | 2016-03-11 13:02:01 | [diff] [blame] | 524 | void AddMockCredentialManagerError(const std::string& error); |
mkwst | 41667ab | 2014-09-16 06:52:43 | [diff] [blame] | 525 | |
lukasza | 083b4f1 | 2016-03-24 16:51:43 | [diff] [blame] | 526 | // Takes care of notifying the delegate after a change to layout test runtime |
| 527 | // flags. |
| 528 | void OnLayoutTestRuntimeFlagsChanged(); |
lukasza | c9cbe71 | 2016-03-14 14:06:43 | [diff] [blame] | 529 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 530 | /////////////////////////////////////////////////////////////////////////// |
| 531 | // Internal helpers |
[email protected] | eec9e78e | 2014-06-16 21:38:48 | [diff] [blame] | 532 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 533 | void CheckResponseMimeType(); |
| 534 | void CompleteNotifyDone(); |
| 535 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 536 | // In the Mac code, this is called to trigger the end of a test after the |
| 537 | // page has finished loading. From here, we can generate the dump for the |
| 538 | // test. |
| 539 | void LocationChangeDone(); |
| 540 | |
| 541 | bool test_is_running_; |
| 542 | |
| 543 | // When reset is called, go through and close all but the main test shell |
| 544 | // window. By default, set to true but toggled to false using |
| 545 | // setCloseRemainingWindowsWhenComplete(). |
| 546 | bool close_remaining_windows_; |
| 547 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 548 | WorkQueue work_queue_; |
| 549 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 550 | // Bound variable to return the name of this platform (chromium). |
| 551 | std::string platform_name_; |
| 552 | |
| 553 | // Bound variable to store the last tooltip text |
| 554 | std::string tooltip_text_; |
| 555 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 556 | // Bound variable counting the number of top URLs visited. |
| 557 | int web_history_item_count_; |
| 558 | |
lukasza | 9b9d70e | 2016-02-25 23:45:44 | [diff] [blame] | 559 | // Flags controlling what content gets dumped as a layout text result. |
lukasza | 083b4f1 | 2016-03-24 16:51:43 | [diff] [blame] | 560 | LayoutTestRuntimeFlags layout_test_runtime_flags_; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 561 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 562 | // If true, the test_shell will output a base64 encoded WAVE file. |
| 563 | bool dump_as_audio_; |
| 564 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 565 | // If true, output a descriptive line each time WebViewClient::createView |
| 566 | // is invoked. |
| 567 | bool dump_create_view_; |
| 568 | |
| 569 | // If true, new windows can be opened via javascript or by plugins. By |
| 570 | // default, set to false and can be toggled to true using |
| 571 | // setCanOpenWindows(). |
| 572 | bool can_open_windows_; |
| 573 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 574 | // If true, the test_shell will dump all changes to window.status. |
| 575 | bool dump_window_status_changes_; |
| 576 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 577 | // If true, the test_shell will output descriptive test for spellcheck |
| 578 | // execution. |
| 579 | bool dump_spell_check_callbacks_; |
| 580 | |
| 581 | // If true, the test_shell will produce a dump of the back forward list as |
| 582 | // well. |
| 583 | bool dump_back_forward_list_; |
| 584 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 585 | // If true, pixel dump will be produced as a series of 1px-tall, view-wide |
| 586 | // individual paints over the height of the view. |
| 587 | bool test_repaint_; |
| 588 | |
| 589 | // If true and test_repaint_ is true as well, pixel dump will be produced as |
| 590 | // a series of 1px-wide, view-tall paints across the width of the view. |
| 591 | bool sweep_horizontally_; |
| 592 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 593 | // If false, MockWebMIDIAccessor fails on startSession() for testing. |
| 594 | bool midi_accessor_result_; |
| 595 | |
[email protected] | f24836a | 2014-05-06 01:02:44 | [diff] [blame] | 596 | bool has_custom_text_output_; |
| 597 | std::string custom_text_output_; |
| 598 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 599 | std::set<std::string> http_headers_to_clear_; |
| 600 | |
| 601 | // WAV audio data is stored here. |
| 602 | std::vector<unsigned char> audio_data_; |
| 603 | |
[email protected] | 79ecada | 2014-05-04 05:16:16 | [diff] [blame] | 604 | TestInterfaces* test_interfaces_; |
| 605 | WebTestDelegate* delegate_; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 606 | blink::WebView* web_view_; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 607 | |
| 608 | // This is non-0 IFF a load is in progress. |
| 609 | blink::WebFrame* top_loading_frame_; |
| 610 | |
mlamouri | 007f9d7 | 2015-02-27 16:27:25 | [diff] [blame] | 611 | // WebContentSettingsClient mock object. |
dcheng | 82beb4f | 2016-04-26 00:35:02 | [diff] [blame] | 612 | std::unique_ptr<MockContentSettingsClient> mock_content_settings_client_; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 613 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 614 | bool use_mock_theme_; |
| 615 | |
dcheng | 82beb4f | 2016-04-26 00:35:02 | [diff] [blame] | 616 | std::unique_ptr<MockCredentialManagerClient> credential_manager_client_; |
| 617 | std::unique_ptr<MockScreenOrientationClient> mock_screen_orientation_client_; |
| 618 | std::unique_ptr<MockWebSpeechRecognizer> speech_recognizer_; |
| 619 | std::unique_ptr<MockWebUserMediaClient> user_media_client_; |
| 620 | std::unique_ptr<SpellCheckClient> spellcheck_; |
lukasza | fd12460 | 2016-04-01 16:53:30 | [diff] [blame] | 621 | |
| 622 | // Number of currently active color choosers. |
| 623 | int chooser_count_; |
lukasza | 6a113ae1 | 2016-03-17 22:41:20 | [diff] [blame] | 624 | |
lukasza | 1b546c1 | 2016-04-04 16:19:20 | [diff] [blame] | 625 | // Captured drag image. |
| 626 | blink::WebImage drag_image_; |
| 627 | |
lukasza | 95416be14 | 2016-04-14 15:06:33 | [diff] [blame] | 628 | // View that was focused by a previous call to TestRunner::SetFocus method. |
| 629 | // Note - this can be a dangling pointer to an already destroyed WebView (this |
| 630 | // is ok, because this is taken care of in WebTestDelegate::SetFocus). |
| 631 | blink::WebView* previously_focused_view_; |
| 632 | |
lukasza | 01da260 | 2016-04-05 14:51:26 | [diff] [blame] | 633 | std::set<blink::WebView*> views_with_scheduled_animations_; |
| 634 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 635 | base::WeakPtrFactory<TestRunner> weak_factory_; |
| 636 | |
| 637 | DISALLOW_COPY_AND_ASSIGN(TestRunner); |
| 638 | }; |
| 639 | |
lukasza | b2ad050 | 2016-04-27 15:51:42 | [diff] [blame^] | 640 | // TestRunnerForSpecificView implements part of |testRunner| javascript bindings |
| 641 | // that work with a view where the javascript call originated from. Examples: |
| 642 | // - testRunner.capturePixelsAsyncThen |
| 643 | // - testRunner.setPageVisibility |
| 644 | // Note that "global" bindings are handled by TestRunner class. |
| 645 | // TODO(lukasza): Move this class to a separate compilation unit. |
| 646 | class TestRunnerForSpecificView { |
| 647 | public: |
| 648 | explicit TestRunnerForSpecificView(WebTestProxyBase* web_test_proxy_base); |
| 649 | ~TestRunnerForSpecificView(); |
| 650 | |
| 651 | // Installs view-specific bindings (handled by |this|) and *also* global |
| 652 | // TestRunner bindings (both kinds of bindings are exposed via a single |
| 653 | // |testRunner| object in javascript). |
| 654 | void Install(blink::WebLocalFrame* frame); |
| 655 | |
| 656 | void Reset(); |
| 657 | |
| 658 | // Pointer lock methods used by WebViewTestClient. |
| 659 | bool RequestPointerLock(); |
| 660 | void RequestPointerUnlock(); |
| 661 | bool isPointerLocked(); |
| 662 | |
| 663 | private: |
| 664 | friend class TestRunnerBindings; |
| 665 | |
| 666 | // Helpers for working with base and V8 callbacks. |
| 667 | void PostTask(const base::Closure& callback); |
| 668 | void PostDelayedTask(long long delay, const base::Closure& callback); |
| 669 | void PostV8Callback(const v8::Local<v8::Function>& callback); |
| 670 | void PostV8CallbackWithArgs(v8::UniquePersistent<v8::Function> callback, |
| 671 | int argc, |
| 672 | v8::Local<v8::Value> argv[]); |
| 673 | void InvokeV8Callback(const v8::UniquePersistent<v8::Function>& callback); |
| 674 | void InvokeV8CallbackWithArgs( |
| 675 | const v8::UniquePersistent<v8::Function>& callback, |
| 676 | const std::vector<v8::UniquePersistent<v8::Value>>& args); |
| 677 | base::Closure CreateClosureThatPostsV8Callback( |
| 678 | const v8::Local<v8::Function>& callback); |
| 679 | |
| 680 | void LayoutAndPaintAsync(); |
| 681 | void LayoutAndPaintAsyncThen(v8::Local<v8::Function> callback); |
| 682 | |
| 683 | // Similar to LayoutAndPaintAsyncThen(), but pass parameters of the captured |
| 684 | // snapshot (width, height, snapshot) to the callback. The snapshot is in |
| 685 | // uint8_t RGBA format. |
| 686 | void CapturePixelsAsyncThen(v8::Local<v8::Function> callback); |
| 687 | void CapturePixelsCallback(v8::UniquePersistent<v8::Function> callback, |
| 688 | const SkBitmap& snapshot); |
| 689 | |
| 690 | // Similar to CapturePixelsAsyncThen(). Copies to the clipboard the image |
| 691 | // located at a particular point in the WebView (if there is such an image), |
| 692 | // reads back its pixels, and provides the snapshot to the callback. If there |
| 693 | // is no image at that point, calls the callback with (0, 0, empty_snapshot). |
| 694 | void CopyImageAtAndCapturePixelsAsyncThen( |
| 695 | int x, |
| 696 | int y, |
| 697 | const v8::Local<v8::Function> callback); |
| 698 | |
| 699 | void GetManifestThen(v8::Local<v8::Function> callback); |
| 700 | void GetManifestCallback(v8::UniquePersistent<v8::Function> callback, |
| 701 | const blink::WebURLResponse& response, |
| 702 | const std::string& data); |
| 703 | |
| 704 | // Calls |callback| with a DOMString[] representing the events recorded since |
| 705 | // the last call to this function. |
| 706 | void GetBluetoothManualChooserEvents(v8::Local<v8::Function> callback); |
| 707 | void GetBluetoothManualChooserEventsCallback( |
| 708 | v8::UniquePersistent<v8::Function> callback, |
| 709 | const std::vector<std::string>& events); |
| 710 | |
| 711 | // Change the bluetooth test data while running a layout test. |
| 712 | void SetBluetoothFakeAdapter(const std::string& adapter_name, |
| 713 | v8::Local<v8::Function> callback); |
| 714 | |
| 715 | // If |enable| is true, makes the Bluetooth chooser record its input and wait |
| 716 | // for instructions from the test program on how to proceed. Otherwise falls |
| 717 | // back to the browser's default chooser. |
| 718 | void SetBluetoothManualChooser(bool enable); |
| 719 | |
| 720 | // Calls the BluetoothChooser::EventHandler with the arguments here. Valid |
| 721 | // event strings are: |
| 722 | // * "cancel" - simulates the user canceling the chooser. |
| 723 | // * "select" - simulates the user selecting a device whose device ID is in |
| 724 | // |argument|. |
| 725 | void SendBluetoothManualChooserEvent(const std::string& event, |
| 726 | const std::string& argument); |
| 727 | |
| 728 | // Used to set the device scale factor. |
| 729 | void SetBackingScaleFactor(double value, v8::Local<v8::Function> callback); |
| 730 | |
| 731 | // Enable zoom-for-dsf option. |
| 732 | // TODO(oshima): Remove this once all platforms migrated. |
| 733 | void EnableUseZoomForDSF(v8::Local<v8::Function> callback); |
| 734 | |
| 735 | // Change the device color profile while running a layout test. |
| 736 | void SetColorProfile(const std::string& name, |
| 737 | v8::Local<v8::Function> callback); |
| 738 | |
| 739 | // Causes the beforeinstallprompt event to be sent to the renderer. |
| 740 | void DispatchBeforeInstallPromptEvent( |
| 741 | int request_id, |
| 742 | const std::vector<std::string>& event_platforms, |
| 743 | v8::Local<v8::Function> callback); |
| 744 | void DispatchBeforeInstallPromptCallback( |
| 745 | v8::UniquePersistent<v8::Function> callback, |
| 746 | bool canceled); |
| 747 | |
| 748 | // Immediately run all pending idle tasks, including all pending |
| 749 | // requestIdleCallback calls. Invoke the callback when all |
| 750 | // idle tasks are complete. |
| 751 | void RunIdleTasks(v8::Local<v8::Function> callback); |
| 752 | |
| 753 | // Method that controls whether pressing Tab key cycles through page elements |
| 754 | // or inserts a '\t' char in text area |
| 755 | void SetTabKeyCyclesThroughElements(bool tab_key_cycles_through_elements); |
| 756 | |
| 757 | // Executes an internal command (superset of document.execCommand() commands). |
| 758 | void ExecCommand(gin::Arguments* args); |
| 759 | |
| 760 | // Checks if an internal command is currently available. |
| 761 | bool IsCommandEnabled(const std::string& command); |
| 762 | |
| 763 | // Returns true if the current page box has custom page size style for |
| 764 | // printing. |
| 765 | bool HasCustomPageSizeStyle(int page_index); |
| 766 | |
| 767 | // Forces the selection colors for testing under Linux. |
| 768 | void ForceRedSelectionColors(); |
| 769 | |
| 770 | // Switch the visibility of the page. |
| 771 | void SetPageVisibility(const std::string& new_visibility); |
| 772 | |
| 773 | // Changes the direction of the focused element. |
| 774 | void SetTextDirection(const std::string& direction_name); |
| 775 | |
| 776 | // Dump current PageImportanceSignals for the page. |
| 777 | void DumpPageImportanceSignals(); |
| 778 | |
| 779 | // WebPageOverlay related functions. Permits the adding and removing of only |
| 780 | // one opaque overlay. |
| 781 | void AddWebPageOverlay(); |
| 782 | void RemoveWebPageOverlay(); |
| 783 | |
| 784 | // Sets a flag causing the next call to WebGLRenderingContext::create to fail. |
| 785 | void ForceNextWebGLContextCreationToFail(); |
| 786 | |
| 787 | // Sets a flag causing the next call to DrawingBuffer::create to fail. |
| 788 | void ForceNextDrawingBufferCreationToFail(); |
| 789 | |
| 790 | // Gives focus to the view associated with TestRunnerForSpecificView. |
| 791 | void SetWindowIsKey(bool value); |
| 792 | |
| 793 | // Pointer lock handling. |
| 794 | void DidAcquirePointerLock(); |
| 795 | void DidNotAcquirePointerLock(); |
| 796 | void DidLosePointerLock(); |
| 797 | void SetPointerLockWillFailSynchronously(); |
| 798 | void SetPointerLockWillRespondAsynchronously(); |
| 799 | void DidAcquirePointerLockInternal(); |
| 800 | void DidNotAcquirePointerLockInternal(); |
| 801 | void DidLosePointerLockInternal(); |
| 802 | bool pointer_locked_; |
| 803 | enum { |
| 804 | PointerLockWillSucceed, |
| 805 | PointerLockWillRespondAsync, |
| 806 | PointerLockWillFailSync, |
| 807 | } pointer_lock_planned_result_; |
| 808 | |
| 809 | bool CallShouldCloseOnWebView(); |
| 810 | void SetDomainRelaxationForbiddenForURLScheme(bool forbidden, |
| 811 | const std::string& scheme); |
| 812 | v8::Local<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue( |
| 813 | int world_id, |
| 814 | const std::string& script); |
| 815 | void EvaluateScriptInIsolatedWorld(int world_id, const std::string& script); |
| 816 | void SetIsolatedWorldSecurityOrigin(int world_id, |
| 817 | v8::Local<v8::Value> origin); |
| 818 | void SetIsolatedWorldContentSecurityPolicy(int world_id, |
| 819 | const std::string& policy); |
| 820 | bool FindString(const std::string& search_text, |
| 821 | const std::vector<std::string>& options_array); |
| 822 | std::string SelectionAsMarkup(); |
| 823 | void SetViewSourceForFrame(const std::string& name, bool enabled); |
| 824 | |
| 825 | // Helpers for accessing pointers exposed by |web_test_proxy_base_|. |
| 826 | blink::WebView* web_view(); |
| 827 | WebTestDelegate* delegate(); |
| 828 | WebTestProxyBase* web_test_proxy_base_; |
| 829 | |
| 830 | base::WeakPtrFactory<TestRunnerForSpecificView> weak_factory_; |
| 831 | |
| 832 | DISALLOW_COPY_AND_ASSIGN(TestRunnerForSpecificView); |
| 833 | }; |
| 834 | |
jochen | f5f3175 | 2015-06-03 12:06:34 | [diff] [blame] | 835 | } // namespace test_runner |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 836 | |
jochen | 73e711c | 2015-06-03 10:01:46 | [diff] [blame] | 837 | #endif // COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_ |