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