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