[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 | |
danakj | 89f4708 | 2020-09-02 17:53:43 | [diff] [blame] | 5 | #ifndef CONTENT_WEB_TEST_RENDERER_TEST_RUNNER_H_ |
| 6 | #define CONTENT_WEB_TEST_RENDERER_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 | |
dcheng | 82beb4f | 2016-04-26 00:35:02 | [diff] [blame] | 10 | #include <memory> |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 11 | #include <set> |
| 12 | #include <string> |
benwells | 0c0d3f1 | 2015-05-25 01:03:17 | [diff] [blame] | 13 | #include <vector> |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 14 | |
danakj | 754eaff | 2020-03-31 17:46:58 | [diff] [blame] | 15 | #include "base/callback_forward.h" |
Brett Wilson | cc8623d | 2017-09-12 03:28:10 | [diff] [blame] | 16 | #include "base/containers/circular_deque.h" |
danakj | aa87f009 | 2020-07-07 17:13:43 | [diff] [blame] | 17 | #include "base/containers/flat_set.h" |
Marijn Kruisselbrink | f526891 | 2020-01-15 22:07:12 | [diff] [blame] | 18 | #include "base/files/file_path.h" |
avi | 5dd91f8 | 2015-12-25 22:30:46 | [diff] [blame] | 19 | #include "base/macros.h" |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 20 | #include "base/memory/weak_ptr.h" |
Peter Beverloo | 988ef96 | 2017-09-12 15:49:17 | [diff] [blame] | 21 | #include "base/optional.h" |
| 22 | #include "base/strings/string16.h" |
danakj | 89f4708 | 2020-09-02 17:53:43 | [diff] [blame] | 23 | #include "content/web_test/common/web_test.mojom.h" |
| 24 | #include "content/web_test/common/web_test_bluetooth_fake_adapter_setter.mojom.h" |
Hitoshi Yoshida | 25a31d5 | 2020-10-29 08:00:33 | [diff] [blame] | 25 | #include "content/web_test/common/web_test_constants.h" |
danakj | 89f4708 | 2020-09-02 17:53:43 | [diff] [blame] | 26 | #include "content/web_test/renderer/fake_screen_orientation_impl.h" |
| 27 | #include "content/web_test/renderer/gamepad_controller.h" |
| 28 | #include "content/web_test/renderer/layout_dump.h" |
| 29 | #include "content/web_test/renderer/web_test_content_settings_client.h" |
| 30 | #include "content/web_test/renderer/web_test_runtime_flags.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 31 | #include "third_party/blink/public/platform/web_effective_connection_type.h" |
danakj | 7c5a96c | 2020-07-03 15:58:36 | [diff] [blame] | 32 | #include "third_party/blink/public/platform/web_url.h" |
Fredrik Söderquist | b2b39eb9 | 2019-11-18 16:16:50 | [diff] [blame] | 33 | #include "third_party/skia/include/core/SkBitmap.h" |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 34 | #include "v8/include/v8.h" |
| 35 | |
danakj | 754eaff | 2020-03-31 17:46:58 | [diff] [blame] | 36 | class SkBitmap; |
| 37 | |
| 38 | namespace base { |
| 39 | class DictionaryValue; |
| 40 | } |
[email protected] | eec9e78e | 2014-06-16 21:38:48 | [diff] [blame] | 41 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 42 | namespace blink { |
mlamouri | 007f9d7 | 2015-02-27 16:27:25 | [diff] [blame] | 43 | class WebContentSettingsClient; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 44 | class WebFrame; |
Dave Tapuska | 4d52486 | 2020-12-01 19:43:41 | [diff] [blame^] | 45 | class WebFrameWidget; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 46 | class WebString; |
| 47 | class WebView; |
danakj | b009206 | 2020-05-04 19:53:06 | [diff] [blame] | 48 | } // namespace blink |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 49 | |
| 50 | namespace gin { |
| 51 | class ArrayBufferView; |
| 52 | class Arguments; |
danakj | b009206 | 2020-05-04 19:53:06 | [diff] [blame] | 53 | } // namespace gin |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 54 | |
danakj | 741848a | 2020-04-07 22:48:06 | [diff] [blame] | 55 | namespace content { |
danakj | b5ae2605 | 2020-04-23 17:20:22 | [diff] [blame] | 56 | class RenderFrame; |
danakj | 552c1cc9 | 2020-07-14 22:34:10 | [diff] [blame] | 57 | class RenderView; |
Yuki Shiino | c955c4c | 2020-07-06 04:38:15 | [diff] [blame] | 58 | class SpellCheckClient; |
danakj | 552c1cc9 | 2020-07-14 22:34:10 | [diff] [blame] | 59 | class TestRunnerBindings; |
danakj | 4cfe700 | 2020-05-13 23:04:39 | [diff] [blame] | 60 | class WebFrameTestProxy; |
danakj | 629826b | 2020-05-13 22:44:59 | [diff] [blame] | 61 | class WebViewTestProxy; |
danakj | 552c1cc9 | 2020-07-14 22:34:10 | [diff] [blame] | 62 | struct TestPreferences; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 63 | |
lukasza | b2ad050 | 2016-04-27 15:51:42 | [diff] [blame] | 64 | // TestRunner class currently has dual purpose: |
danakj | 2d792165 | 2019-09-11 17:20:12 | [diff] [blame] | 65 | // 1. It implements TestRunner javascript bindings for "global" / "ambient". |
lukasza | b2ad050 | 2016-04-27 15:51:42 | [diff] [blame] | 66 | // Examples: |
danakj | 2d792165 | 2019-09-11 17:20:12 | [diff] [blame] | 67 | // - TestRunner.DumpAsText (test flag affecting test behavior) |
| 68 | // - TestRunner.SetAllowRunningOfInsecureContent (test flag affecting product |
lukasza | b2ad050 | 2016-04-27 15:51:42 | [diff] [blame] | 69 | // behavior) |
danakj | 2d792165 | 2019-09-11 17:20:12 | [diff] [blame] | 70 | // - TestRunner.SetTextSubpixelPositioning (directly interacts with product). |
lukasza | b2ad050 | 2016-04-27 15:51:42 | [diff] [blame] | 71 | // 2. It manages global test state. Example: |
| 72 | // - Tracking topLoadingFrame that can finish the test when it loads. |
danakj | 1985c8f | 2020-07-09 18:28:16 | [diff] [blame] | 73 | // - WorkQueue holding load requests from web tests. |
Kent Tamura | 21d1de6 | 2018-12-10 04:45:20 | [diff] [blame] | 74 | // - WebTestRuntimeFlags |
danakj | 9f2d350 | 2020-04-07 21:20:21 | [diff] [blame] | 75 | class TestRunner { |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 76 | public: |
danakj | 1985c8f | 2020-07-09 18:28:16 | [diff] [blame] | 77 | TestRunner(); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 78 | virtual ~TestRunner(); |
| 79 | |
Yuki Shiino | c955c4c | 2020-07-06 04:38:15 | [diff] [blame] | 80 | void Install(WebFrameTestProxy* frame, SpellCheckClient* spell_check); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 81 | |
danakj | 12c09b6 | 2020-07-11 04:17:05 | [diff] [blame] | 82 | // Resets global TestRunner state for the next test. |
| 83 | void Reset(); |
danakj | aa87f009 | 2020-07-07 17:13:43 | [diff] [blame] | 84 | |
danakj | 629826b | 2020-05-13 22:44:59 | [diff] [blame] | 85 | // Resets state on the |web_view_test_proxy| for the next test. |
| 86 | void ResetWebView(WebViewTestProxy* web_view_test_proxy); |
Dave Tapuska | 4d52486 | 2020-12-01 19:43:41 | [diff] [blame^] | 87 | // Resets state on the |web_frame_widget| for the next test. |
| 88 | void ResetWebFrameWidget(blink::WebFrameWidget* web_frame_widget); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 89 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 90 | void SetTestIsRunning(bool); |
| 91 | bool TestIsRunning() const { return test_is_running_; } |
| 92 | |
danakj | 3130f12 | 2019-07-16 17:49:47 | [diff] [blame] | 93 | // Finishes the test if it is ready. This should be called before running |
| 94 | // tasks that will change state, so that the test can capture the current |
| 95 | // state. Specifically, should run before the BeginMainFrame step which does |
| 96 | // layout and animation etc. |
| 97 | // This does *not* run as part of loading finishing because that happens in |
| 98 | // the middle of blink call stacks that have inconsistent state. |
| 99 | void FinishTestIfReady(); |
danakj | 4b0ef92 | 2020-08-28 14:34:57 | [diff] [blame] | 100 | // Notification that another renderer has explicitly asked the test to end. |
| 101 | void TestFinishedFromSecondaryRenderer(); |
danakj | 3130f12 | 2019-07-16 17:49:47 | [diff] [blame] | 102 | |
danakj | 529c064 | 2020-08-28 18:02:18 | [diff] [blame] | 103 | // Performs a reset at the end of a test, in order to prepare for the next |
| 104 | // test. This includes a navigation to about:blank, which we hear about |
| 105 | // through DidCommitNavigationInMainFrame(). |
| 106 | void ResetRendererAfterWebTest(base::OnceClosure done_callback); |
| 107 | // Listener for navigations in order to hear about the navigation to |
| 108 | // about:blank done for ResetRendererAfterWebTest(). |
| 109 | void DidCommitNavigationInMainFrame(WebFrameTestProxy* main_frame); |
| 110 | |
danakj | aa87f009 | 2020-07-07 17:13:43 | [diff] [blame] | 111 | // Track the set of all main frames in the process, which is also the set of |
| 112 | // windows rooted in this process. |
| 113 | void AddMainFrame(WebFrameTestProxy* frame); |
| 114 | void RemoveMainFrame(WebFrameTestProxy* frame); |
| 115 | |
danakj | 1985c8f | 2020-07-09 18:28:16 | [diff] [blame] | 116 | // Track the set of all RenderViews in the process, which includes cross-site |
| 117 | // frames/windows accessible from this process but homed in a different |
| 118 | // renderer and parts of any windows' frame trees that share the same site. |
| 119 | void AddRenderView(WebViewTestProxy* view); |
| 120 | void RemoveRenderView(WebViewTestProxy* view); |
| 121 | |
danakj | 754eaff | 2020-03-31 17:46:58 | [diff] [blame] | 122 | // Returns a mock WebContentSettings that is used for web tests. An |
| 123 | // embedder should use this for all WebViews it creates. |
danakj | aa87f009 | 2020-07-07 17:13:43 | [diff] [blame] | 124 | blink::WebContentSettingsClient* GetWebContentSettings(); |
danakj | 754eaff | 2020-03-31 17:46:58 | [diff] [blame] | 125 | |
danakj | 27e4ebe | 2020-04-15 18:48:27 | [diff] [blame] | 126 | // Returns true if the test output should be an audio file, rather than text |
| 127 | // or pixel results. |
danakj | 754eaff | 2020-03-31 17:46:58 | [diff] [blame] | 128 | bool ShouldDumpAsAudio() const; |
danakj | 27e4ebe | 2020-04-15 18:48:27 | [diff] [blame] | 129 | // Gets the audio test output for when audio test results are requested by |
| 130 | // the current test. |
danakj | c50c5e2 | 2020-07-09 17:06:14 | [diff] [blame] | 131 | const std::vector<uint8_t>& GetAudioData() const; |
danakj | 754eaff | 2020-03-31 17:46:58 | [diff] [blame] | 132 | |
| 133 | // Reports if tests requested a recursive layout dump of all frames |
| 134 | // (i.e. by calling testRunner.dumpChildFramesAsText() from javascript). |
| 135 | bool IsRecursiveLayoutDumpRequested(); |
| 136 | |
danakj | 754eaff | 2020-03-31 17:46:58 | [diff] [blame] | 137 | // Returns true if the selection window should be painted onto captured |
| 138 | // pixels. |
| 139 | bool ShouldDumpSelectionRect() const; |
| 140 | |
| 141 | // Returns false if the browser should capture the pixel output, true if it |
danakj | e9f67451 | 2020-07-07 19:23:06 | [diff] [blame] | 142 | // can be done locally in the renderer via DumpPixelsInRenderer(). |
danakj | 754eaff | 2020-03-31 17:46:58 | [diff] [blame] | 143 | bool CanDumpPixelsFromRenderer() const; |
| 144 | |
| 145 | // Snapshots the content of |render_view| using the mode requested by the |
| 146 | // current test and calls |callback| with the result. Caller needs to ensure |
| 147 | // that |render_view| stays alive until |callback| is called. |
danakj | e9f67451 | 2020-07-07 19:23:06 | [diff] [blame] | 148 | SkBitmap DumpPixelsInRenderer(content::RenderView* render_view); |
danakj | 754eaff | 2020-03-31 17:46:58 | [diff] [blame] | 149 | |
| 150 | // Replicates changes to web test runtime flags (i.e. changes that happened in |
danakj | 529c064 | 2020-08-28 18:02:18 | [diff] [blame] | 151 | // another renderer). See also `OnWebTestRuntimeFlagsChanged()`. |
Kent Tamura | 679c7c4 | 2018-12-05 03:21:10 | [diff] [blame] | 152 | void ReplicateWebTestRuntimeFlagsChanges( |
danakj | 754eaff | 2020-03-31 17:46:58 | [diff] [blame] | 153 | const base::DictionaryValue& changed_values); |
| 154 | |
| 155 | // If custom text dump is present (i.e. if testRunner.setCustomTextOutput has |
| 156 | // been called from javascript), then returns |true| and populates the |
| 157 | // |custom_text_dump| argument. Otherwise returns |false|. |
| 158 | bool HasCustomTextDump(std::string* custom_text_dump) const; |
| 159 | |
| 160 | // Returns true if the history should be included in text results generated at |
| 161 | // the end of the test. |
| 162 | bool ShouldDumpBackForwardList() const; |
| 163 | |
| 164 | // Returns true if pixel results should be generated at the end of the test. |
| 165 | bool ShouldGeneratePixelResults(); |
| 166 | |
danakj | 049cb6a | 2020-07-11 03:11:34 | [diff] [blame] | 167 | TextResultType ShouldGenerateTextResults(); |
| 168 | |
danakj | 674bf1c0 | 2020-05-01 18:37:51 | [diff] [blame] | 169 | // Activate the window holding the given main frame, and set focus on the |
| 170 | // frame's widget. |
| 171 | void FocusWindow(RenderFrame* main_frame, bool focus); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 172 | |
lukasza | 01da260 | 2016-04-05 14:51:26 | [diff] [blame] | 173 | // Methods used by WebViewTestClient and WebFrameTestClient. |
lukasza | a0b624a | 2016-04-04 15:00:49 | [diff] [blame] | 174 | std::string GetAcceptLanguages() const; |
danakj | 2d792165 | 2019-09-11 17:20:12 | [diff] [blame] | 175 | bool ShouldStayOnPageAfterHandlingBeforeUnload() const; |
danakj | 2d792165 | 2019-09-11 17:20:12 | [diff] [blame] | 176 | bool ShouldDumpAsCustomText() const; |
| 177 | std::string CustomDumpText() const; |
abhishek.a21 | ca9b560 | 2014-09-19 07:33:33 | [diff] [blame] | 178 | void ShowDevTools(const std::string& settings, |
[email protected] | 06c25301 | 2014-04-16 18:35:33 | [diff] [blame] | 179 | const std::string& frontend_url); |
danakj | 2d792165 | 2019-09-11 17:20:12 | [diff] [blame] | 180 | void SetShouldDumpAsLayout(bool); |
| 181 | void SetCustomTextOutput(const std::string& text); |
| 182 | void SetShouldGeneratePixelResults(bool); |
| 183 | void SetShouldDumpFrameLoadCallbacks(bool); |
danakj | 2d792165 | 2019-09-11 17:20:12 | [diff] [blame] | 184 | bool ShouldDumpEditingCallbacks() const; |
| 185 | bool ShouldDumpFrameLoadCallbacks() const; |
| 186 | bool ShouldDumpPingLoaderCallbacks() const; |
| 187 | bool ShouldDumpUserGestureInFrameLoadCallbacks() const; |
| 188 | bool ShouldDumpTitleChanges() const; |
| 189 | bool ShouldDumpIconChanges() const; |
| 190 | bool ShouldDumpCreateView() const; |
| 191 | bool CanOpenWindows() const; |
danakj | 2d792165 | 2019-09-11 17:20:12 | [diff] [blame] | 192 | bool ShouldWaitUntilExternalURLLoad() const; |
| 193 | const std::set<std::string>* HttpHeadersToClear() const; |
Dominic Farolino | aee9c1b8 | 2019-12-18 03:20:10 | [diff] [blame] | 194 | bool ClearReferrer() const; |
danakj | 29382fc | 2020-04-20 18:00:09 | [diff] [blame] | 195 | bool IsWebPlatformTestsMode() const; |
| 196 | void SetIsWebPlatformTestsMode(); |
Mason Freed | b085562 | 2018-10-02 17:49:47 | [diff] [blame] | 197 | bool animation_requires_raster() const { return animation_requires_raster_; } |
| 198 | void SetAnimationRequiresRaster(bool do_raster); |
lukasza | 10cd876 | 2016-04-27 20:03:02 | [diff] [blame] | 199 | |
arthursonzogni | d409c25 | 2019-03-14 09:22:22 | [diff] [blame] | 200 | // Add |frame| to the set of loading frames. |
| 201 | // |
| 202 | // Note: Only one renderer process is really tracking the loading frames. This |
| 203 | // is the first to observe one. Both local and remote frames are tracked |
| 204 | // by this process. |
| 205 | void AddLoadingFrame(blink::WebFrame* frame); |
lukasza | 10cd876 | 2016-04-27 20:03:02 | [diff] [blame] | 206 | |
arthursonzogni | d409c25 | 2019-03-14 09:22:22 | [diff] [blame] | 207 | // Remove |frame| from the set of loading frames. |
| 208 | // |
| 209 | // When there are no more loading frames, this potentially finishes the test, |
danakj | 2d792165 | 2019-09-11 17:20:12 | [diff] [blame] | 210 | // unless TestRunner.WaitUntilDone() was called and/or there are pending load |
arthursonzogni | d409c25 | 2019-03-14 09:22:22 | [diff] [blame] | 211 | // requests in WorkQueue. |
| 212 | void RemoveLoadingFrame(blink::WebFrame* frame); |
lukasza | 10cd876 | 2016-04-27 20:03:02 | [diff] [blame] | 213 | |
Hitoshi Yoshida | 0d0156c | 2020-10-29 17:36:15 | [diff] [blame] | 214 | // Called when a main frame has been navigated away. |
| 215 | void OnFrameDeactivated(WebFrameTestProxy* frame); |
| 216 | |
| 217 | // Called when a main frame has been restored from backward/forward cache. |
| 218 | void OnFrameReactivated(WebFrameTestProxy* frame); |
| 219 | |
danakj | 2d792165 | 2019-09-11 17:20:12 | [diff] [blame] | 220 | void PolicyDelegateDone(); |
| 221 | bool PolicyDelegateEnabled() const; |
| 222 | bool PolicyDelegateIsPermissive() const; |
| 223 | bool PolicyDelegateShouldNotifyDone() const; |
| 224 | void SetToolTipText(const blink::WebString&); |
| 225 | void SetDragImage(const SkBitmap& drag_image); |
| 226 | bool ShouldDumpNavigationPolicy() const; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 227 | |
caseq | cb222783 | 2016-05-24 18:52:04 | [diff] [blame] | 228 | bool ShouldDumpConsoleMessages() const; |
Yoichi Osato | ebf845ac7 | 2018-08-30 08:13:50 | [diff] [blame] | 229 | // Controls whether console messages produced by the page are dumped |
| 230 | // to test output. |
| 231 | void SetDumpConsoleMessages(bool value); |
| 232 | |
danakj | 7c5a96c | 2020-07-03 15:58:36 | [diff] [blame] | 233 | // The following trigger navigations on the main WebView. |
| 234 | void GoToOffset(int offset); |
| 235 | void Reload(); |
| 236 | void LoadURLForFrame(const GURL& url, const std::string& frame_name); |
| 237 | |
| 238 | // Add a message to the text dump for the web test. |
| 239 | void PrintMessage(const std::string& message); |
| 240 | // Add a message to stderr (not saved to expected output files, for debugging |
| 241 | // only). |
| 242 | void PrintMessageToStderr(const std::string& message); |
| 243 | |
| 244 | // Register a new isolated filesystem with the given files, and return the |
| 245 | // new filesystem id. |
| 246 | blink::WebString RegisterIsolatedFileSystem( |
| 247 | const std::vector<base::FilePath>& file_paths); |
| 248 | |
Hitoshi Yoshida | 25a31d5 | 2020-10-29 08:00:33 | [diff] [blame] | 249 | void ProcessWorkItem(mojom::WorkItemPtr work_item); |
| 250 | void ReplicateWorkQueueStates(const base::DictionaryValue& changed_values); |
| 251 | |
jkarlin | 3bddb7d | 2016-09-21 18:44:16 | [diff] [blame] | 252 | blink::WebEffectiveConnectionType effective_connection_type() const { |
| 253 | return effective_connection_type_; |
| 254 | } |
| 255 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 256 | private: |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 257 | friend class TestRunnerBindings; |
| 258 | friend class WorkQueue; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 259 | |
danakj | 2d792165 | 2019-09-11 17:20:12 | [diff] [blame] | 260 | // Helper class for managing events queued by methods like QueueLoad or |
| 261 | // QueueScript. |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 262 | class WorkQueue { |
Hitoshi Yoshida | 25a31d5 | 2020-10-29 08:00:33 | [diff] [blame] | 263 | static constexpr const char* kKeyFrozen = "frozen"; |
| 264 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 265 | public: |
| 266 | explicit WorkQueue(TestRunner* controller); |
Hitoshi Yoshida | 25a31d5 | 2020-10-29 08:00:33 | [diff] [blame] | 267 | ~WorkQueue() = default; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 268 | |
| 269 | // Reset the state of the class between tests. |
| 270 | void Reset(); |
| 271 | |
Hitoshi Yoshida | 25a31d5 | 2020-10-29 08:00:33 | [diff] [blame] | 272 | void AddWork(mojom::WorkItemPtr work_item); |
| 273 | void RequestWork(); |
| 274 | void ProcessWorkItem(mojom::WorkItemPtr work_item); |
| 275 | void ReplicateStates(const base::DictionaryValue& values); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 276 | |
Hitoshi Yoshida | 25a31d5 | 2020-10-29 08:00:33 | [diff] [blame] | 277 | // Takes care of notifying the browser after a change to the state. |
| 278 | void OnStatesChanged(); |
danakj | 3130f12 | 2019-07-16 17:49:47 | [diff] [blame] | 279 | |
Hitoshi Yoshida | 25a31d5 | 2020-10-29 08:00:33 | [diff] [blame] | 280 | void set_loading(bool value) { loading_ = value; } |
| 281 | |
| 282 | void set_frozen(bool value) { states_.SetBoolean(kKeyFrozen, value); } |
| 283 | void set_has_items(bool value) { |
| 284 | states_.SetBoolean(kDictKeyWorkQueueHasItems, value); |
| 285 | } |
| 286 | bool has_items() const { return GetStateValue(kDictKeyWorkQueueHasItems); } |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 287 | |
| 288 | private: |
Hitoshi Yoshida | 25a31d5 | 2020-10-29 08:00:33 | [diff] [blame] | 289 | bool ProcessWorkItemInternal(mojom::WorkItemPtr work_item); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 290 | |
Hitoshi Yoshida | 25a31d5 | 2020-10-29 08:00:33 | [diff] [blame] | 291 | bool is_frozen() const { return GetStateValue(kKeyFrozen); } |
| 292 | |
| 293 | bool GetStateValue(const char* key) const { |
| 294 | base::Optional<bool> value = states_.current_values().FindBoolPath(key); |
| 295 | DCHECK(value.has_value()); |
| 296 | return value.value(); |
| 297 | } |
| 298 | |
| 299 | bool loading_ = true; |
| 300 | // Collection of flags to be synced with the browser process. |
| 301 | TrackedDictionary states_; |
| 302 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 303 | TestRunner* controller_; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 304 | }; |
| 305 | |
danakj | e283442 | 2020-07-10 21:18:58 | [diff] [blame] | 306 | // If the main test window's main frame is hosted in this renderer process, |
| 307 | // then this will return it. Otherwise, it is in another process and this |
| 308 | // returns null. |
| 309 | WebFrameTestProxy* FindInProcessMainWindowMainFrame(); |
| 310 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 311 | /////////////////////////////////////////////////////////////////////////// |
| 312 | // Methods dealing with the test logic |
| 313 | |
| 314 | // By default, tests end when page load is complete. These methods are used |
danakj | 2d792165 | 2019-09-11 17:20:12 | [diff] [blame] | 315 | // to delay the completion of the test until NotifyDone is called. |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 316 | void WaitUntilDone(); |
danakj | 654fd75 | 2020-07-10 16:52:09 | [diff] [blame] | 317 | void NotifyDone(); |
| 318 | |
| 319 | // When there are no conditions left to wait for, this is called to cause the |
| 320 | // test to end, collect results, and inform the browser. |
| 321 | void FinishTest(); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 322 | |
| 323 | // Methods for adding actions to the work queue. Used in conjunction with |
danakj | 2d792165 | 2019-09-11 17:20:12 | [diff] [blame] | 324 | // WaitUntilDone/NotifyDone above. |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 325 | void QueueBackNavigation(int how_far_back); |
| 326 | void QueueForwardNavigation(int how_far_forward); |
| 327 | void QueueReload(); |
Hitoshi Yoshida | a629c87 | 2020-10-22 16:33:33 | [diff] [blame] | 328 | void QueueLoadingScript(const std::string& script); |
| 329 | void QueueNonLoadingScript(const std::string& script); |
danakj | 12c09b6 | 2020-07-11 04:17:05 | [diff] [blame] | 330 | void QueueLoad(const GURL& current_url, |
| 331 | const std::string& relative_url, |
| 332 | const std::string& target); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 333 | |
danakj | cdff34e4 | 2020-05-04 21:42:48 | [diff] [blame] | 334 | // Called from the TestRunnerBindings to inform that the test has modified |
| 335 | // the TestPreferences. This will update the WebkitPreferences in the renderer |
| 336 | // and the browser. |
| 337 | void OnTestPreferencesChanged(const TestPreferences& test_prefs, |
| 338 | RenderFrame* frame); |
| 339 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 340 | // Causes navigation actions just printout the intended navigation instead |
| 341 | // of taking you to the page. This is used for cases like mailto, where you |
| 342 | // don't actually want to open the mail program. |
| 343 | void SetCustomPolicyDelegate(gin::Arguments* args); |
| 344 | |
| 345 | // Delays completion of the test until the policy delegate runs. |
| 346 | void WaitForPolicyDelegate(); |
| 347 | |
danakj | aa87f009 | 2020-07-07 17:13:43 | [diff] [blame] | 348 | // This is the count of windows which have their main frame in this renderer |
| 349 | // process. A cross-origin window would not appear in this count. |
| 350 | int InProcessWindowCount(); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 351 | |
Kent Tamura | 21d1de6 | 2018-12-10 04:45:20 | [diff] [blame] | 352 | // Allows web tests to manage origins' allow list. |
Takashi Toyoshima | 66e7d0d | 2018-08-28 09:20:10 | [diff] [blame] | 353 | void AddOriginAccessAllowListEntry(const std::string& source_origin, |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 354 | const std::string& destination_protocol, |
| 355 | const std::string& destination_host, |
| 356 | bool allow_destination_subdomains); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 357 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 358 | // Enables or disables subpixel positioning (i.e. fractional X positions for |
| 359 | // glyphs) in text rendering on Linux. Since this method changes global |
| 360 | // settings, tests that call it must use their own custom font family for |
| 361 | // all text that they render. If not, an already-cached style will be used, |
| 362 | // resulting in the changed setting being ignored. |
| 363 | void SetTextSubpixelPositioning(bool value); |
| 364 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 365 | // After this function is called, all window-sizing machinery is |
| 366 | // short-circuited inside the renderer. This mode is necessary for |
| 367 | // some tests that were written before browsers had multi-process architecture |
| 368 | // and rely on window resizes to happen synchronously. |
| 369 | // The function has "unfortunate" it its name because we must strive to remove |
| 370 | // all tests that rely on this... well, unfortunate behavior. See |
| 371 | // http://crbug.com/309760 for the plan. |
| 372 | void UseUnfortunateSynchronousResizeMode(); |
| 373 | |
Dave Tapuska | 442a74f | 2020-08-20 15:50:46 | [diff] [blame] | 374 | // Set the mock orientation on |view| to |orientation|. |
| 375 | void SetMockScreenOrientation(WebViewTestProxy* view, |
| 376 | const std::string& orientation); |
| 377 | // Disable any mock orientation on |view| that is set. |
| 378 | void DisableMockScreenOrientation(WebViewTestProxy* view); |
[email protected] | e0bc2cb | 2014-03-20 17:34:24 | [diff] [blame] | 379 | |
Mario Sanchez Prada | 0bd8b8c | 2020-10-21 17:49:23 | [diff] [blame] | 380 | // Modify accept_languages in blink::RendererPreferences. |
[email protected] | ebd5ea5 | 2014-05-28 14:51:15 | [diff] [blame] | 381 | void SetAcceptLanguages(const std::string& accept_languages); |
| 382 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 383 | /////////////////////////////////////////////////////////////////////////// |
| 384 | // Methods that modify the state of TestRunner |
| 385 | |
Xianzhu Wang | 8d64fc3 | 2018-10-15 02:26:53 | [diff] [blame] | 386 | // This function sets a flag that tells the test runner to print a line of |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 387 | // descriptive text for each editing command. It takes no arguments, and |
| 388 | // ignores any that may be present. |
| 389 | void DumpEditingCallbacks(); |
| 390 | |
Xianzhu Wang | 6e84f099 | 2018-10-23 23:07:55 | [diff] [blame] | 391 | // This function sets a flag that tells the test runner to dump pages as |
| 392 | // plain text. The pixel results will not be generated for this test. |
| 393 | // It has higher priority than DumpAsMarkup() and DumpAsLayout(). |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 394 | void DumpAsText(); |
| 395 | |
Xianzhu Wang | 8d64fc3 | 2018-10-15 02:26:53 | [diff] [blame] | 396 | // This function sets a flag that tells the test runner to dump pages as |
[email protected] | fdc433c0 | 2014-06-02 19:27:14 | [diff] [blame] | 397 | // the DOM contents, rather than as a text representation of the renderer's |
Xianzhu Wang | 6e84f099 | 2018-10-23 23:07:55 | [diff] [blame] | 398 | // state. The pixel results will not be generated for this test. It has |
| 399 | // higher priority than DumpAsLayout(), but lower than DumpAsText(). |
[email protected] | fdc433c0 | 2014-06-02 19:27:14 | [diff] [blame] | 400 | void DumpAsMarkup(); |
| 401 | |
Xianzhu Wang | 6e84f099 | 2018-10-23 23:07:55 | [diff] [blame] | 402 | // This function sets a flag that tells the test runner to dump pages as |
| 403 | // plain text. It will also generate a pixel dump for the test. |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 404 | void DumpAsTextWithPixelResults(); |
| 405 | |
Xianzhu Wang | 6e84f099 | 2018-10-23 23:07:55 | [diff] [blame] | 406 | // This function sets a flag that tells the test runner to dump pages as |
| 407 | // text representation of the layout. The pixel results will not be generated |
| 408 | // for this test. It has lower priority than DumpAsText() and DumpAsMarkup(). |
| 409 | void DumpAsLayout(); |
| 410 | |
| 411 | // This function sets a flag that tells the test runner to dump pages as |
| 412 | // text representation of the layout. It will also generate a pixel dump for |
| 413 | // the test. |
| 414 | void DumpAsLayoutWithPixelResults(); |
| 415 | |
Xianzhu Wang | 8d64fc3 | 2018-10-15 02:26:53 | [diff] [blame] | 416 | // This function sets a flag that tells the test runner to recursively dump |
Xianzhu Wang | 6e84f099 | 2018-10-23 23:07:55 | [diff] [blame] | 417 | // all frames as text, markup or layout depending on which of DumpAsText, |
| 418 | // DumpAsMarkup and DumpAsLayout is effective. |
Xianzhu Wang | 8d64fc3 | 2018-10-15 02:26:53 | [diff] [blame] | 419 | void DumpChildFrames(); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 420 | |
Xianzhu Wang | 8d64fc3 | 2018-10-15 02:26:53 | [diff] [blame] | 421 | // This function sets a flag that tells the test runner to print out the |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 422 | // information about icon changes notifications from WebKit. |
| 423 | void DumpIconChanges(); |
| 424 | |
| 425 | // Deals with Web Audio WAV file data. |
| 426 | void SetAudioData(const gin::ArrayBufferView& view); |
| 427 | |
Xianzhu Wang | 8d64fc3 | 2018-10-15 02:26:53 | [diff] [blame] | 428 | // This function sets a flag that tells the test runner to print a line of |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 429 | // descriptive text for each frame load callback. It takes no arguments, and |
| 430 | // ignores any that may be present. |
| 431 | void DumpFrameLoadCallbacks(); |
| 432 | |
Xianzhu Wang | 8d64fc3 | 2018-10-15 02:26:53 | [diff] [blame] | 433 | // This function sets a flag that tells the test runner to print a line of |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 434 | // descriptive text for each PingLoader dispatch. It takes no arguments, and |
| 435 | // ignores any that may be present. |
| 436 | void DumpPingLoaderCallbacks(); |
| 437 | |
Xianzhu Wang | 8d64fc3 | 2018-10-15 02:26:53 | [diff] [blame] | 438 | // This function sets a flag that tells the test runner to print a line of |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 439 | // user gesture status text for some frame load callbacks. It takes no |
| 440 | // arguments, and ignores any that may be present. |
| 441 | void DumpUserGestureInFrameLoadCallbacks(); |
| 442 | |
| 443 | void DumpTitleChanges(); |
| 444 | |
Xianzhu Wang | 8d64fc3 | 2018-10-15 02:26:53 | [diff] [blame] | 445 | // This function sets a flag that tells the test runner to dump all calls to |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 446 | // WebViewClient::createView(). |
| 447 | // It takes no arguments, and ignores any that may be present. |
| 448 | void DumpCreateView(); |
| 449 | |
| 450 | void SetCanOpenWindows(); |
| 451 | |
Xianzhu Wang | 8d64fc3 | 2018-10-15 02:26:53 | [diff] [blame] | 452 | // This function sets a flag that tells the test runner to dump the MIME type |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 453 | // for each resource that was loaded. It takes no arguments, and ignores any |
| 454 | // that may be present. |
| 455 | void DumpResourceResponseMIMETypes(); |
| 456 | |
mlamouri | 007f9d7 | 2015-02-27 16:27:25 | [diff] [blame] | 457 | // WebContentSettingsClient related. |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 458 | void SetImagesAllowed(bool allowed); |
| 459 | void SetScriptsAllowed(bool allowed); |
| 460 | void SetStorageAllowed(bool allowed); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 461 | void SetAllowRunningOfInsecureContent(bool allowed); |
| 462 | void DumpPermissionClientCallbacks(); |
| 463 | |
Xianzhu Wang | 8d64fc3 | 2018-10-15 02:26:53 | [diff] [blame] | 464 | // This function sets a flag that tells the test runner to print out a text |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 465 | // representation of the back/forward list. It ignores all arguments. |
| 466 | void DumpBackForwardList(); |
| 467 | |
| 468 | void DumpSelectionRect(); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 469 | |
| 470 | // Causes layout to happen as if targetted to printed pages. |
| 471 | void SetPrinting(); |
Xianzhu Wang | dbb84fc | 2018-02-03 00:33:35 | [diff] [blame] | 472 | void SetPrintingForFrame(const std::string& frame_name); |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 473 | |
| 474 | void SetShouldStayOnPageAfterHandlingBeforeUnload(bool value); |
| 475 | |
| 476 | // Causes WillSendRequest to clear certain headers. |
Dominic Farolino | aee9c1b8 | 2019-12-18 03:20:10 | [diff] [blame] | 477 | // Note: This cannot be used to clear the request's `Referer` header, as this |
| 478 | // header is computed later given its referrer string member. To clear it, use |
| 479 | // SetWillSendRequestClearReferrer() below. |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 480 | void SetWillSendRequestClearHeader(const std::string& header); |
| 481 | |
Dominic Farolino | aee9c1b8 | 2019-12-18 03:20:10 | [diff] [blame] | 482 | // Causes WillSendRequest to clear the request's referrer string and set its |
| 483 | // referrer policy to the default. |
| 484 | void SetWillSendRequestClearReferrer(); |
| 485 | |
[email protected] | a79cb991 | 2014-04-26 22:07:33 | [diff] [blame] | 486 | // Sets a flag that causes the test to be marked as completed when the |
danakj | 2d792165 | 2019-09-11 17:20:12 | [diff] [blame] | 487 | // WebLocalFrameClient receives a LoadURLExternally() call. |
[email protected] | a79cb991 | 2014-04-26 22:07:33 | [diff] [blame] | 488 | void WaitUntilExternalURLLoad(); |
| 489 | |
lukasza | 1b546c1 | 2016-04-04 16:19:20 | [diff] [blame] | 490 | // This function sets a flag to dump the drag image when the next drag&drop is |
| 491 | // initiated. It is equivalent to DumpAsTextWithPixelResults but the pixel |
| 492 | // results will be the drag image instead of a snapshot of the page. |
jackhou | 656fc85 | 2015-02-13 09:04:17 | [diff] [blame] | 493 | void DumpDragImage(); |
| 494 | |
lfg | 05e4137 | 2016-07-22 15:38:10 | [diff] [blame] | 495 | // Sets a flag that tells the WebViewTestProxy to dump the default navigation |
danakj | 2d792165 | 2019-09-11 17:20:12 | [diff] [blame] | 496 | // policy passed to the DecidePolicyForNavigation callback. |
jochen | c3a98da1 | 2015-03-10 13:59:58 | [diff] [blame] | 497 | void DumpNavigationPolicy(); |
| 498 | |
tkent | 217ff885 | 2016-11-14 04:43:49 | [diff] [blame] | 499 | // Controls whether JavaScript dialogs such as alert() are dumped to test |
| 500 | // output. |
| 501 | void SetDumpJavaScriptDialogs(bool value); |
| 502 | |
jkarlin | 3bddb7d | 2016-09-21 18:44:16 | [diff] [blame] | 503 | // Overrides the NetworkQualityEstimator's estimated network type. If |type| |
| 504 | // is TypeUnknown the NQE's value is used. Be sure to call this with |
| 505 | // TypeUnknown at the end of your test if you use this. |
| 506 | void SetEffectiveConnectionType( |
| 507 | blink::WebEffectiveConnectionType connection_type); |
| 508 | |
danakj | 7c5a96c | 2020-07-03 15:58:36 | [diff] [blame] | 509 | // Takes care of notifying the browser after a change to web test runtime |
lukasza | 083b4f1 | 2016-03-24 16:51:43 | [diff] [blame] | 510 | // flags. |
Kent Tamura | 2eab5b1 | 2018-12-07 04:31:23 | [diff] [blame] | 511 | void OnWebTestRuntimeFlagsChanged(); |
lukasza | c9cbe71 | 2016-03-14 14:06:43 | [diff] [blame] | 512 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 513 | /////////////////////////////////////////////////////////////////////////// |
| 514 | // Internal helpers |
[email protected] | eec9e78e | 2014-06-16 21:38:48 | [diff] [blame] | 515 | |
danakj | 7c5a96c | 2020-07-03 15:58:36 | [diff] [blame] | 516 | mojo::AssociatedRemote<mojom::WebTestControlHost>& |
| 517 | GetWebTestControlHostRemote(); |
| 518 | void HandleWebTestControlHostDisconnected(); |
| 519 | mojo::AssociatedRemote<mojom::WebTestControlHost> |
| 520 | web_test_control_host_remote_; |
| 521 | |
danakj | aa87f009 | 2020-07-07 17:13:43 | [diff] [blame] | 522 | mojom::WebTestBluetoothFakeAdapterSetter& GetBluetoothFakeAdapterSetter(); |
| 523 | void HandleBluetoothFakeAdapterSetterDisconnected(); |
| 524 | mojo::Remote<mojom::WebTestBluetoothFakeAdapterSetter> |
| 525 | bluetooth_fake_adapter_setter_; |
| 526 | |
danakj | 3130f12 | 2019-07-16 17:49:47 | [diff] [blame] | 527 | bool test_is_running_ = false; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 528 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 529 | WorkQueue work_queue_; |
| 530 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 531 | // Bound variable to return the name of this platform (chromium). |
| 532 | std::string platform_name_; |
| 533 | |
lukasza | 9b9d70e | 2016-02-25 23:45:44 | [diff] [blame] | 534 | // Flags controlling what content gets dumped as a layout text result. |
Kent Tamura | 2eab5b1 | 2018-12-07 04:31:23 | [diff] [blame] | 535 | WebTestRuntimeFlags web_test_runtime_flags_; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 536 | |
Xianzhu Wang | 8d64fc3 | 2018-10-15 02:26:53 | [diff] [blame] | 537 | // If true, the test runner will output a base64 encoded WAVE file. |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 538 | bool dump_as_audio_; |
| 539 | |
Xianzhu Wang | 8d64fc3 | 2018-10-15 02:26:53 | [diff] [blame] | 540 | // If true, the test runner will produce a dump of the back forward list as |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 541 | // well. |
| 542 | bool dump_back_forward_list_; |
| 543 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 544 | // If true, pixel dump will be produced as a series of 1px-tall, view-wide |
| 545 | // individual paints over the height of the view. |
| 546 | bool test_repaint_; |
| 547 | |
| 548 | // If true and test_repaint_ is true as well, pixel dump will be produced as |
| 549 | // a series of 1px-wide, view-tall paints across the width of the view. |
| 550 | bool sweep_horizontally_; |
| 551 | |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 552 | std::set<std::string> http_headers_to_clear_; |
Dominic Farolino | aee9c1b8 | 2019-12-18 03:20:10 | [diff] [blame] | 553 | bool clear_referrer_ = false; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 554 | |
| 555 | // WAV audio data is stored here. |
danakj | c50c5e2 | 2020-07-09 17:06:14 | [diff] [blame] | 556 | std::vector<uint8_t> audio_data_; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 557 | |
danakj | aa87f009 | 2020-07-07 17:13:43 | [diff] [blame] | 558 | base::flat_set<WebFrameTestProxy*> main_frames_; |
danakj | 1985c8f | 2020-07-09 18:28:16 | [diff] [blame] | 559 | // The set of all render views in this renderer process. This may include |
| 560 | // cross-site windows accessible from this process, or parts of same-site |
| 561 | // windows opened from any renderer process. |
| 562 | base::flat_set<WebViewTestProxy*> render_views_; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 563 | |
arthursonzogni | d409c25 | 2019-03-14 09:22:22 | [diff] [blame] | 564 | // This is non empty when a load is in progress. |
| 565 | std::vector<blink::WebFrame*> loading_frames_; |
danakj | 654fd75 | 2020-07-10 16:52:09 | [diff] [blame] | 566 | // We do not want the test to end until the main frame finishes loading. This |
| 567 | // starts as true at the beginning of the test, and will be set to false once |
| 568 | // we run out of frames to load at any time. |
| 569 | bool main_frame_loaded_ = false; |
danakj | 3130f12 | 2019-07-16 17:49:47 | [diff] [blame] | 570 | // When a loading task is started, this bool is set until all loading_frames_ |
| 571 | // are completed and removed. This bool becomes true earlier than |
danakj | 654fd75 | 2020-07-10 16:52:09 | [diff] [blame] | 572 | // loading_frames_ becomes non-empty. |
| 573 | bool frame_will_start_load_ = true; |
danakj | 3130f12 | 2019-07-16 17:49:47 | [diff] [blame] | 574 | // When NotifyDone() occurs, if loading is still working, it is delayed, and |
| 575 | // this bool tracks that NotifyDone() was called. This differentiates from a |
| 576 | // test that was not waiting for NotifyDone() at all. |
| 577 | bool did_notify_done_ = false; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 578 | |
danakj | 1a887ad | 2020-09-01 22:16:01 | [diff] [blame] | 579 | WebTestContentSettingsClient test_content_settings_client_; |
| 580 | FakeScreenOrientationImpl fake_screen_orientation_impl_; |
danakj | aa87f009 | 2020-07-07 17:13:43 | [diff] [blame] | 581 | GamepadController gamepad_controller_; |
lukasza | fd12460 | 2016-04-01 16:53:30 | [diff] [blame] | 582 | |
lukasza | 1b546c1 | 2016-04-04 16:19:20 | [diff] [blame] | 583 | // Captured drag image. |
danakj | 0c75ad8 | 2018-07-10 19:50:12 | [diff] [blame] | 584 | SkBitmap drag_image_; |
lukasza | 1b546c1 | 2016-04-04 16:19:20 | [diff] [blame] | 585 | |
Mason Freed | b085562 | 2018-10-02 17:49:47 | [diff] [blame] | 586 | // True if rasterization should be performed during tests that examine |
| 587 | // fling-style animations. This includes middle-click auto-scroll behaviors. |
| 588 | // This does not include most "ordinary" animations, such as CSS animations. |
danakj | 3130f12 | 2019-07-16 17:49:47 | [diff] [blame] | 589 | bool animation_requires_raster_ = false; |
Mason Freed | b085562 | 2018-10-02 17:49:47 | [diff] [blame] | 590 | |
Kent Tamura | 21d1de6 | 2018-12-10 04:45:20 | [diff] [blame] | 591 | // An effective connection type settable by web tests. |
danakj | 3130f12 | 2019-07-16 17:49:47 | [diff] [blame] | 592 | blink::WebEffectiveConnectionType effective_connection_type_ = |
| 593 | blink::WebEffectiveConnectionType::kTypeUnknown; |
jkarlin | 3bddb7d | 2016-09-21 18:44:16 | [diff] [blame] | 594 | |
danakj | 529c064 | 2020-08-28 18:02:18 | [diff] [blame] | 595 | // Set to ack callback when the browser asks the renderer to reset at the end |
| 596 | // of a test. Part of reset involves performing a navigation to about:blank |
| 597 | // and this tracks that the navigation is in progress, and is called to inform |
| 598 | // the browser that the reset is complete. |
| 599 | base::OnceClosure waiting_for_reset_navigation_to_about_blank_; |
| 600 | |
Jeremy Roman | 3bca4bf | 2019-07-11 03:41:25 | [diff] [blame] | 601 | base::WeakPtrFactory<TestRunner> weak_factory_{this}; |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 602 | |
| 603 | DISALLOW_COPY_AND_ASSIGN(TestRunner); |
| 604 | }; |
| 605 | |
danakj | 741848a | 2020-04-07 22:48:06 | [diff] [blame] | 606 | } // namespace content |
[email protected] | 97f9a795 | 2014-03-14 11:50:33 | [diff] [blame] | 607 | |
danakj | 89f4708 | 2020-09-02 17:53:43 | [diff] [blame] | 608 | #endif // CONTENT_WEB_TEST_RENDERER_TEST_RUNNER_H_ |