blob: 5f93c52fb356ef0063d0ceff6d96c96a3ba03e54 [file] [log] [blame]
[email protected]97f9a7952014-03-14 11:50:331// 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
jochen73e711c2015-06-03 10:01:465#ifndef COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_
6#define COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_
[email protected]97f9a7952014-03-14 11:50:337
avi5dd91f82015-12-25 22:30:468#include <stdint.h>
9
[email protected]97f9a7952014-03-14 11:50:3310#include <deque>
dcheng82beb4f2016-04-26 00:35:0211#include <memory>
[email protected]97f9a7952014-03-14 11:50:3312#include <set>
13#include <string>
benwells0c0d3f12015-05-25 01:03:1714#include <vector>
[email protected]97f9a7952014-03-14 11:50:3315
avi5dd91f82015-12-25 22:30:4616#include "base/macros.h"
[email protected]97f9a7952014-03-14 11:50:3317#include "base/memory/weak_ptr.h"
lukasza083b4f12016-03-24 16:51:4318#include "components/test_runner/layout_test_runtime_flags.h"
jochen746754c52015-06-05 16:40:4119#include "components/test_runner/test_runner_export.h"
jochen73e711c2015-06-03 10:01:4620#include "components/test_runner/web_test_runner.h"
toyoshim729663f2016-10-17 08:54:1321#include "media/midi/midi_service.mojom.h"
jkarlin3bddb7d2016-09-21 18:44:1622#include "third_party/WebKit/public/platform/WebEffectiveConnectionType.h"
lukasza1b546c12016-04-04 16:19:2023#include "third_party/WebKit/public/platform/WebImage.h"
[email protected]97f9a7952014-03-14 11:50:3324#include "v8/include/v8.h"
25
[email protected]945babb2014-07-30 14:25:3226class GURL;
[email protected]eec9e78e2014-06-16 21:38:4827class SkBitmap;
28
awdff8bdbe82016-10-14 09:42:3229namespace base {
30class NullableString16;
31}
32
[email protected]97f9a7952014-03-14 11:50:3333namespace blink {
mlamouri007f9d72015-02-27 16:27:2534class WebContentSettingsClient;
[email protected]97f9a7952014-03-14 11:50:3335class WebFrame;
lukaszab2ad0502016-04-27 15:51:4236class WebLocalFrame;
[email protected]97f9a7952014-03-14 11:50:3337class WebString;
38class WebView;
lukaszadf92022f2016-05-03 16:42:3139class WebWidget;
[email protected]97f9a7952014-03-14 11:50:3340}
41
42namespace gin {
43class ArrayBufferView;
44class Arguments;
45}
46
jochenf5f31752015-06-03 12:06:3447namespace test_runner {
[email protected]97f9a7952014-03-14 11:50:3348
lukasza21353232016-04-12 19:52:1149class MockContentSettingsClient;
lukasza5c2279c2016-04-05 16:44:4750class MockCredentialManagerClient;
lukasza6a113ae12016-03-17 22:41:2051class MockScreenOrientationClient;
lukasza01da2602016-04-05 14:51:2652class MockWebSpeechRecognizer;
lukaszafd124602016-04-01 16:53:3053class MockWebUserMediaClient;
lukasza5c2279c2016-04-05 16:44:4754class SpellCheckClient;
[email protected]79ecada2014-05-04 05:16:1655class TestInterfaces;
lukaszab2ad0502016-04-27 15:51:4256class TestRunnerForSpecificView;
[email protected]79ecada2014-05-04 05:16:1657class WebTestDelegate;
[email protected]97f9a7952014-03-14 11:50:3358
lukaszab2ad0502016-04-27 15:51:4259// TestRunner class currently has dual purpose:
60// 1. It implements |testRunner| javascript bindings for "global" / "ambient".
61// Examples:
62// - testRunner.dumpAsText (test flag affecting test behavior)
carlosk5f1c5172016-09-08 18:59:3163// - testRunner.setAllowRunningOfInsecureContent (test flag affecting product
lukaszab2ad0502016-04-27 15:51:4264// behavior)
65// - testRunner.setTextSubpixelPositioning (directly interacts with product).
66// Note that "per-view" (non-"global") bindings are handled by
67// instances of TestRunnerForSpecificView class.
68// 2. It manages global test state. Example:
69// - Tracking topLoadingFrame that can finish the test when it loads.
70// - WorkQueue holding load requests from the TestInterfaces
71// - LayoutTestRuntimeFlags
lukaszac9358822016-04-07 14:43:4672class TestRunner : public WebTestRunner {
[email protected]97f9a7952014-03-14 11:50:3373 public:
[email protected]79ecada2014-05-04 05:16:1674 explicit TestRunner(TestInterfaces*);
[email protected]97f9a7952014-03-14 11:50:3375 virtual ~TestRunner();
76
lukaszab2ad0502016-04-27 15:51:4277 void Install(blink::WebLocalFrame* frame,
78 base::WeakPtr<TestRunnerForSpecificView> view_test_runner);
[email protected]97f9a7952014-03-14 11:50:3379
[email protected]79ecada2014-05-04 05:16:1680 void SetDelegate(WebTestDelegate*);
lukasza8973c522016-04-27 16:32:2881 void SetMainView(blink::WebView*);
[email protected]97f9a7952014-03-14 11:50:3382
83 void Reset();
84
[email protected]97f9a7952014-03-14 11:50:3385 void SetTestIsRunning(bool);
86 bool TestIsRunning() const { return test_is_running_; }
87
88 bool UseMockTheme() const { return use_mock_theme_; }
89
90 // WebTestRunner implementation.
dchenge933b3e2014-10-21 11:44:0991 bool ShouldGeneratePixelResults() override;
92 bool ShouldDumpAsAudio() const override;
93 void GetAudioData(std::vector<unsigned char>* buffer_view) const override;
lukaszaef264fc52016-03-17 22:49:1994 bool IsRecursiveLayoutDumpRequested() override;
95 std::string DumpLayout(blink::WebLocalFrame* frame) override;
lukasza1b546c12016-04-04 16:19:2096 void DumpPixelsAsync(
97 blink::WebView* web_view,
98 const base::Callback<void(const SkBitmap&)>& callback) override;
lukasza083b4f12016-03-24 16:51:4399 void ReplicateLayoutTestRuntimeFlagsChanges(
lukaszac9cbe712016-03-14 14:06:43100 const base::DictionaryValue& changed_values) override;
lukaszaa8960462016-01-27 22:27:33101 bool HasCustomTextDump(std::string* custom_text_dump) const override;
dchenge933b3e2014-10-21 11:44:09102 bool ShouldDumpBackForwardList() const override;
mlamouri007f9d72015-02-27 16:27:25103 blink::WebContentSettingsClient* GetWebContentSettings() const override;
lukasza5c2279c2016-04-05 16:44:47104 void InitializeWebViewWithMocks(blink::WebView* web_view) override;
lukasza95416be142016-04-14 15:06:33105 void SetFocus(blink::WebView* web_view, bool focus) override;
[email protected]97f9a7952014-03-14 11:50:33106
lukasza01da2602016-04-05 14:51:26107 // Methods used by WebViewTestClient and WebFrameTestClient.
blundell987cb782016-08-17 17:25:37108 void OnNavigationBegin(blink::WebFrame* frame);
109 void OnNavigationEnd() { will_navigate_ = false; }
lukaszadf92022f2016-05-03 16:42:31110 void OnAnimationScheduled(blink::WebWidget* widget);
111 void OnAnimationBegun(blink::WebWidget* widget);
lukaszaa0b624a2016-04-04 15:00:49112 std::string GetAcceptLanguages() const;
lukaszae26c3d62016-03-14 23:30:59113 bool shouldStayOnPageAfterHandlingBeforeUnload() const;
lukasza6a113ae12016-03-17 22:41:20114 MockScreenOrientationClient* getMockScreenOrientationClient();
lukaszafd124602016-04-01 16:53:30115 MockWebUserMediaClient* getMockWebUserMediaClient();
lukasza01da2602016-04-05 14:51:26116 MockWebSpeechRecognizer* getMockWebSpeechRecognizer();
[email protected]97f9a7952014-03-14 11:50:33117 bool isPrinting() const;
[email protected]f24836a2014-05-06 01:02:44118 bool shouldDumpAsCustomText() const;
119 std:: string customDumpText() const;
abhishek.a21ca9b5602014-09-19 07:33:33120 void ShowDevTools(const std::string& settings,
[email protected]06c253012014-04-16 18:35:33121 const std::string& frontend_url);
abhishek.a21ca9b5602014-09-19 07:33:33122 void ClearDevToolsLocalStorage();
[email protected]97f9a7952014-03-14 11:50:33123 void setShouldDumpAsText(bool);
124 void setShouldDumpAsMarkup(bool);
ki.stfu939799a42015-09-28 04:41:20125 void setCustomTextOutput(const std::string& text);
[email protected]97f9a7952014-03-14 11:50:33126 void setShouldGeneratePixelResults(bool);
127 void setShouldDumpFrameLoadCallbacks(bool);
[email protected]97f9a7952014-03-14 11:50:33128 void setShouldEnableViewSource(bool);
129 bool shouldDumpEditingCallbacks() const;
130 bool shouldDumpFrameLoadCallbacks() const;
131 bool shouldDumpPingLoaderCallbacks() const;
132 bool shouldDumpUserGestureInFrameLoadCallbacks() const;
133 bool shouldDumpTitleChanges() const;
134 bool shouldDumpIconChanges() const;
135 bool shouldDumpCreateView() const;
136 bool canOpenWindows() const;
137 bool shouldDumpResourceLoadCallbacks() const;
[email protected]97f9a7952014-03-14 11:50:33138 bool shouldDumpResourceResponseMIMETypes() const;
139 bool shouldDumpStatusCallbacks() const;
[email protected]97f9a7952014-03-14 11:50:33140 bool shouldDumpSpellCheckCallbacks() const;
[email protected]a79cb9912014-04-26 22:07:33141 bool shouldWaitUntilExternalURLLoad() const;
[email protected]97f9a7952014-03-14 11:50:33142 const std::set<std::string>* httpHeadersToClear() const;
tkent2edc979d2016-05-27 04:58:25143 bool is_web_platform_tests_mode() const {
144 return is_web_platform_tests_mode_;
145 }
146 void set_is_web_platform_tests_mode() { is_web_platform_tests_mode_ = true; }
lukasza10cd8762016-04-27 20:03:02147
148 // To be called when |frame| starts loading - TestRunner will check if
149 // there is currently no top-loading-frame being tracked and if so, then it
150 // will return true and start tracking |frame| as the top-loading-frame.
151 bool tryToSetTopLoadingFrame(blink::WebFrame* frame);
152
153 // To be called when |frame| finishes loading - TestRunner will check if
154 // |frame| is currently tracked as the top-loading-frame, and if yes, then it
155 // will return true, stop top-loading-frame tracking, and potentially finish
156 // the test (unless testRunner.waitUntilDone() was called and/or there are
157 // pending load requests in WorkQueue).
158 bool tryToClearTopLoadingFrame(blink::WebFrame*);
159
[email protected]97f9a7952014-03-14 11:50:33160 blink::WebFrame* topLoadingFrame() const;
161 void policyDelegateDone();
162 bool policyDelegateEnabled() const;
163 bool policyDelegateIsPermissive() const;
164 bool policyDelegateShouldNotifyDone() const;
[email protected]97f9a7952014-03-14 11:50:33165 void setToolTipText(const blink::WebString&);
lukasza1b546c12016-04-04 16:19:20166 void setDragImage(const blink::WebImage& drag_image);
jochenc3a98da12015-03-10 13:59:58167 bool shouldDumpNavigationPolicy() const;
[email protected]97f9a7952014-03-14 11:50:33168
toyoshim729663f2016-10-17 08:54:13169 midi::mojom::Result midiAccessorResult();
[email protected]97f9a7952014-03-14 11:50:33170
lukaszafd124602016-04-01 16:53:30171 // Methods used by MockColorChooser:
172 void DidOpenChooser();
173 void DidCloseChooser();
174
caseqcb2227832016-05-24 18:52:04175 bool ShouldDumpConsoleMessages() const;
tkent217ff8852016-11-14 04:43:49176 bool ShouldDumpJavaScriptDialogs() const;
caseqcb2227832016-05-24 18:52:04177
jkarlin3bddb7d2016-09-21 18:44:16178 blink::WebEffectiveConnectionType effective_connection_type() const {
179 return effective_connection_type_;
180 }
181
[email protected]97f9a7952014-03-14 11:50:33182 // A single item in the work queue.
183 class WorkItem {
184 public:
185 virtual ~WorkItem() {}
186
187 // Returns true if this started a load.
[email protected]79ecada2014-05-04 05:16:16188 virtual bool Run(WebTestDelegate*, blink::WebView*) = 0;
[email protected]97f9a7952014-03-14 11:50:33189 };
190
191 private:
[email protected]97f9a7952014-03-14 11:50:33192 friend class TestRunnerBindings;
193 friend class WorkQueue;
194
195 // Helper class for managing events queued by methods like queueLoad or
196 // queueScript.
197 class WorkQueue {
198 public:
199 explicit WorkQueue(TestRunner* controller);
200 virtual ~WorkQueue();
201 void ProcessWorkSoon();
202
203 // Reset the state of the class between tests.
204 void Reset();
205
206 void AddWork(WorkItem*);
207
208 void set_frozen(bool frozen) { frozen_ = frozen; }
209 bool is_empty() { return queue_.empty(); }
[email protected]97f9a7952014-03-14 11:50:33210
211 private:
212 void ProcessWork();
213
[email protected]97f9a7952014-03-14 11:50:33214 std::deque<WorkItem*> queue_;
215 bool frozen_;
216 TestRunner* controller_;
lukaszac9358822016-04-07 14:43:46217
218 base::WeakPtrFactory<WorkQueue> weak_factory_;
[email protected]97f9a7952014-03-14 11:50:33219 };
220
221 ///////////////////////////////////////////////////////////////////////////
222 // Methods dealing with the test logic
223
224 // By default, tests end when page load is complete. These methods are used
225 // to delay the completion of the test until notifyDone is called.
226 void NotifyDone();
227 void WaitUntilDone();
228
229 // Methods for adding actions to the work queue. Used in conjunction with
230 // waitUntilDone/notifyDone above.
231 void QueueBackNavigation(int how_far_back);
232 void QueueForwardNavigation(int how_far_forward);
233 void QueueReload();
234 void QueueLoadingScript(const std::string& script);
235 void QueueNonLoadingScript(const std::string& script);
236 void QueueLoad(const std::string& url, const std::string& target);
[email protected]97f9a7952014-03-14 11:50:33237
238 // Causes navigation actions just printout the intended navigation instead
239 // of taking you to the page. This is used for cases like mailto, where you
240 // don't actually want to open the mail program.
241 void SetCustomPolicyDelegate(gin::Arguments* args);
242
243 // Delays completion of the test until the policy delegate runs.
244 void WaitForPolicyDelegate();
245
246 // Functions for dealing with windows. By default we block all new windows.
247 int WindowCount();
248 void SetCloseRemainingWindowsWhenComplete(bool close_remaining_windows);
249 void ResetTestHelperControllers();
250
[email protected]97f9a7952014-03-14 11:50:33251 // Allows layout tests to manage origins' whitelisting.
252 void AddOriginAccessWhitelistEntry(const std::string& source_origin,
253 const std::string& destination_protocol,
254 const std::string& destination_host,
255 bool allow_destination_subdomains);
256 void RemoveOriginAccessWhitelistEntry(const std::string& source_origin,
257 const std::string& destination_protocol,
258 const std::string& destination_host,
259 bool allow_destination_subdomains);
260
dcheng9000dbd2015-04-03 05:39:40261 // Add |source_code| as an injected stylesheet to the active document of the
262 // window of the current V8 context.
263 void InsertStyleSheet(const std::string& source_code);
264
[email protected]97f9a7952014-03-14 11:50:33265 // Enables or disables subpixel positioning (i.e. fractional X positions for
266 // glyphs) in text rendering on Linux. Since this method changes global
267 // settings, tests that call it must use their own custom font family for
268 // all text that they render. If not, an already-cached style will be used,
269 // resulting in the changed setting being ignored.
270 void SetTextSubpixelPositioning(bool value);
271
[email protected]97f9a7952014-03-14 11:50:33272 // After this function is called, all window-sizing machinery is
273 // short-circuited inside the renderer. This mode is necessary for
274 // some tests that were written before browsers had multi-process architecture
275 // and rely on window resizes to happen synchronously.
276 // The function has "unfortunate" it its name because we must strive to remove
277 // all tests that rely on this... well, unfortunate behavior. See
278 // http://crbug.com/309760 for the plan.
279 void UseUnfortunateSynchronousResizeMode();
280
281 bool EnableAutoResizeMode(int min_width,
282 int min_height,
283 int max_width,
284 int max_height);
285 bool DisableAutoResizeMode(int new_width, int new_height);
286
[email protected]2ad7e622014-06-30 17:44:21287 void SetMockDeviceLight(double value);
288 void ResetDeviceLight();
[email protected]97f9a7952014-03-14 11:50:33289 // Device Motion / Device Orientation related functions
290 void SetMockDeviceMotion(bool has_acceleration_x, double acceleration_x,
291 bool has_acceleration_y, double acceleration_y,
292 bool has_acceleration_z, double acceleration_z,
293 bool has_acceleration_including_gravity_x,
294 double acceleration_including_gravity_x,
295 bool has_acceleration_including_gravity_y,
296 double acceleration_including_gravity_y,
297 bool has_acceleration_including_gravity_z,
298 double acceleration_including_gravity_z,
299 bool has_rotation_rate_alpha,
300 double rotation_rate_alpha,
301 bool has_rotation_rate_beta,
302 double rotation_rate_beta,
303 bool has_rotation_rate_gamma,
304 double rotation_rate_gamma,
305 double interval);
306 void SetMockDeviceOrientation(bool has_alpha, double alpha,
307 bool has_beta, double beta,
308 bool has_gamma, double gamma,
philipj97906452016-03-02 14:46:22309 bool absolute);
[email protected]97f9a7952014-03-14 11:50:33310
[email protected]e0bc2cb2014-03-20 17:34:24311 void SetMockScreenOrientation(const std::string& orientation);
dgozman3c16f7f2016-02-26 01:21:18312 void DisableMockScreenOrientation();
[email protected]e0bc2cb2014-03-20 17:34:24313
[email protected]97f9a7952014-03-14 11:50:33314 ///////////////////////////////////////////////////////////////////////////
315 // Methods modifying WebPreferences.
316
317 // Set the WebPreference that controls webkit's popup blocking.
318 void SetPopupBlockingEnabled(bool block_popups);
319
320 void SetJavaScriptCanAccessClipboard(bool can_access);
321 void SetXSSAuditorEnabled(bool enabled);
322 void SetAllowUniversalAccessFromFileURLs(bool allow);
323 void SetAllowFileAccessFromFileURLs(bool allow);
ki.stfu939799a42015-09-28 04:41:20324 void OverridePreference(const std::string& key, v8::Local<v8::Value> value);
[email protected]97f9a7952014-03-14 11:50:33325
[email protected]ebd5ea52014-05-28 14:51:15326 // Modify accept_languages in RendererPreferences.
327 void SetAcceptLanguages(const std::string& accept_languages);
328
[email protected]97f9a7952014-03-14 11:50:33329 // Enable or disable plugins.
330 void SetPluginsEnabled(bool enabled);
331
lukasza01da2602016-04-05 14:51:26332 // Returns |true| if an animation has been scheduled in one or more WebViews
333 // participating in the layout test.
334 bool GetAnimationScheduled() const;
chrishtraea6066d2016-02-19 04:49:12335
[email protected]97f9a7952014-03-14 11:50:33336 ///////////////////////////////////////////////////////////////////////////
337 // Methods that modify the state of TestRunner
338
339 // This function sets a flag that tells the test_shell to print a line of
340 // descriptive text for each editing command. It takes no arguments, and
341 // ignores any that may be present.
342 void DumpEditingCallbacks();
343
344 // This function sets a flag that tells the test_shell to dump pages as
345 // plain text, rather than as a text representation of the renderer's state.
346 // The pixel results will not be generated for this test.
347 void DumpAsText();
348
349 // This function sets a flag that tells the test_shell to dump pages as
[email protected]fdc433c02014-06-02 19:27:14350 // the DOM contents, rather than as a text representation of the renderer's
351 // state. The pixel results will not be generated for this test.
352 void DumpAsMarkup();
353
354 // This function sets a flag that tells the test_shell to dump pages as
[email protected]97f9a7952014-03-14 11:50:33355 // plain text, rather than as a text representation of the renderer's state.
356 // It will also generate a pixel dump for the test.
357 void DumpAsTextWithPixelResults();
358
359 // This function sets a flag that tells the test_shell to print out the
360 // scroll offsets of the child frames. It ignores all.
361 void DumpChildFrameScrollPositions();
362
363 // This function sets a flag that tells the test_shell to recursively
364 // dump all frames as plain text if the DumpAsText flag is set.
365 // It takes no arguments, and ignores any that may be present.
366 void DumpChildFramesAsText();
367
[email protected]fdc433c02014-06-02 19:27:14368 // This function sets a flag that tells the test_shell to recursively
369 // dump all frames as the DOM contents if the DumpAsMarkup flag is set.
370 // It takes no arguments, and ignores any that may be present.
371 void DumpChildFramesAsMarkup();
372
[email protected]97f9a7952014-03-14 11:50:33373 // This function sets a flag that tells the test_shell to print out the
374 // information about icon changes notifications from WebKit.
375 void DumpIconChanges();
376
377 // Deals with Web Audio WAV file data.
378 void SetAudioData(const gin::ArrayBufferView& view);
379
380 // This function sets a flag that tells the test_shell to print a line of
381 // descriptive text for each frame load callback. It takes no arguments, and
382 // ignores any that may be present.
383 void DumpFrameLoadCallbacks();
384
385 // This function sets a flag that tells the test_shell to print a line of
386 // descriptive text for each PingLoader dispatch. It takes no arguments, and
387 // ignores any that may be present.
388 void DumpPingLoaderCallbacks();
389
390 // This function sets a flag that tells the test_shell to print a line of
391 // user gesture status text for some frame load callbacks. It takes no
392 // arguments, and ignores any that may be present.
393 void DumpUserGestureInFrameLoadCallbacks();
394
395 void DumpTitleChanges();
396
397 // This function sets a flag that tells the test_shell to dump all calls to
398 // WebViewClient::createView().
399 // It takes no arguments, and ignores any that may be present.
400 void DumpCreateView();
401
402 void SetCanOpenWindows();
403
404 // This function sets a flag that tells the test_shell to dump a descriptive
405 // line for each resource load callback. It takes no arguments, and ignores
406 // any that may be present.
407 void DumpResourceLoadCallbacks();
408
[email protected]97f9a7952014-03-14 11:50:33409 // This function sets a flag that tells the test_shell to dump the MIME type
410 // for each resource that was loaded. It takes no arguments, and ignores any
411 // that may be present.
412 void DumpResourceResponseMIMETypes();
413
mlamouri007f9d72015-02-27 16:27:25414 // WebContentSettingsClient related.
[email protected]97f9a7952014-03-14 11:50:33415 void SetImagesAllowed(bool allowed);
416 void SetScriptsAllowed(bool allowed);
417 void SetStorageAllowed(bool allowed);
418 void SetPluginsAllowed(bool allowed);
[email protected]97f9a7952014-03-14 11:50:33419 void SetAllowRunningOfInsecureContent(bool allowed);
mlamouri426f2862016-04-29 18:35:01420 void SetAutoplayAllowed(bool allowed);
[email protected]97f9a7952014-03-14 11:50:33421 void DumpPermissionClientCallbacks();
422
engedy9ae04242016-06-08 13:31:18423 // Sets up a mock DocumentSubresourceFilter to disallow subsequent subresource
424 // loads within the current document with the given path |suffixes|. The
425 // filter is created and injected even if |suffixes| is empty. If |suffixes|
426 // contains the empty string, all subresource loads will be disallowed.
427 void SetDisallowedSubresourcePathSuffixes(
428 const std::vector<std::string>& suffixes);
429
[email protected]97f9a7952014-03-14 11:50:33430 // This function sets a flag that tells the test_shell to dump all calls
431 // to window.status().
432 // It takes no arguments, and ignores any that may be present.
433 void DumpWindowStatusChanges();
434
[email protected]97f9a7952014-03-14 11:50:33435 // This function sets a flag that tells the test_shell to dump all
436 // the lines of descriptive text about spellcheck execution.
437 void DumpSpellCheckCallbacks();
438
439 // This function sets a flag that tells the test_shell to print out a text
440 // representation of the back/forward list. It ignores all arguments.
441 void DumpBackForwardList();
442
443 void DumpSelectionRect();
[email protected]97f9a7952014-03-14 11:50:33444
445 // Causes layout to happen as if targetted to printed pages.
446 void SetPrinting();
447
[email protected]52846102014-06-24 04:26:44448 // Clears the state from SetPrinting().
449 void ClearPrinting();
450
[email protected]97f9a7952014-03-14 11:50:33451 void SetShouldStayOnPageAfterHandlingBeforeUnload(bool value);
452
453 // Causes WillSendRequest to clear certain headers.
454 void SetWillSendRequestClearHeader(const std::string& header);
455
[email protected]97f9a7952014-03-14 11:50:33456 // Sets a flag to enable the mock theme.
457 void SetUseMockTheme(bool use);
458
[email protected]a79cb9912014-04-26 22:07:33459 // Sets a flag that causes the test to be marked as completed when the
460 // WebFrameClient receives a loadURLExternally() call.
461 void WaitUntilExternalURLLoad();
462
lukasza1b546c12016-04-04 16:19:20463 // This function sets a flag to dump the drag image when the next drag&drop is
464 // initiated. It is equivalent to DumpAsTextWithPixelResults but the pixel
465 // results will be the drag image instead of a snapshot of the page.
jackhou656fc852015-02-13 09:04:17466 void DumpDragImage();
467
lfg05e41372016-07-22 15:38:10468 // Sets a flag that tells the WebViewTestProxy to dump the default navigation
jochenc3a98da12015-03-10 13:59:58469 // policy passed to the decidePolicyForNavigation callback.
470 void DumpNavigationPolicy();
471
caseqcb2227832016-05-24 18:52:04472 // Controls whether console messages produced by the page are dumped
473 // to test output.
474 void SetDumpConsoleMessages(bool value);
475
tkent217ff8852016-11-14 04:43:49476 // Controls whether JavaScript dialogs such as alert() are dumped to test
477 // output.
478 void SetDumpJavaScriptDialogs(bool value);
479
jkarlin3bddb7d2016-09-21 18:44:16480 // Overrides the NetworkQualityEstimator's estimated network type. If |type|
481 // is TypeUnknown the NQE's value is used. Be sure to call this with
482 // TypeUnknown at the end of your test if you use this.
483 void SetEffectiveConnectionType(
484 blink::WebEffectiveConnectionType connection_type);
485
xiaochengh2fa3e762016-08-24 11:27:04486 // Controls whether the mock spell checker is enabled.
487 void SetMockSpellCheckerEnabled(bool enabled);
488
[email protected]97f9a7952014-03-14 11:50:33489 ///////////////////////////////////////////////////////////////////////////
lfg05e41372016-07-22 15:38:10490 // Methods interacting with the WebViewTestProxy
[email protected]97f9a7952014-03-14 11:50:33491
492 ///////////////////////////////////////////////////////////////////////////
493 // Methods forwarding to the WebTestDelegate
494
495 // Shows DevTools window.
[email protected]06c253012014-04-16 18:35:33496 void ShowWebInspector(const std::string& str,
497 const std::string& frontend_url);
[email protected]97f9a7952014-03-14 11:50:33498 void CloseWebInspector();
499
500 // Inspect chooser state
501 bool IsChooserShown();
502
503 // Allows layout tests to exec scripts at WebInspector side.
504 void EvaluateInWebInspector(int call_id, const std::string& script);
sergeyv0cd842b42015-10-09 16:07:11505 // Allows layout tests to evaluate scripts in InspectorOverlay page.
506 // Script may have an output represented as a string, return values of other
507 // types would be ignored.
508 std::string EvaluateInWebInspectorOverlay(const std::string& script);
[email protected]97f9a7952014-03-14 11:50:33509
510 // Clears all databases.
511 void ClearAllDatabases();
512 // Sets the default quota for all origins
513 void SetDatabaseQuota(int quota);
514
tyoshinoa6b91462016-07-11 09:15:09515 // Sets the cookie policy to:
516 // - allow all cookies when |block| is false
517 // - block only third-party cookies when |block| is true
518 void SetBlockThirdPartyCookies(bool block);
[email protected]97f9a7952014-03-14 11:50:33519
[email protected]97f9a7952014-03-14 11:50:33520 // Converts a URL starting with file:///tmp/ to the local mapping.
521 std::string PathToLocalResource(const std::string& path);
522
mlamourid5098d02015-04-21 12:17:30523 // Sets the permission's |name| to |value| for a given {origin, embedder}
524 // tuple.
525 void SetPermission(const std::string& name,
526 const std::string& value,
527 const GURL& origin,
528 const GURL& embedding_origin);
529
dominickn09f7b572016-10-28 01:44:15530 // Resolve the in-flight beforeinstallprompt event.
531 void ResolveBeforeInstallPromptPromise(const std::string& platform);
benwells0c0d3f12015-05-25 01:03:17532
[email protected]97f9a7952014-03-14 11:50:33533 // Calls setlocale(LC_ALL, ...) for a specified locale.
534 // Resets between tests.
535 void SetPOSIXLocale(const std::string& locale);
536
537 // MIDI function to control permission handling.
toyoshim729663f2016-10-17 08:54:13538 void SetMIDIAccessorResult(midi::mojom::Result result);
[email protected]97f9a7952014-03-14 11:50:33539
peterd98157d2014-11-20 13:15:01540 // Simulates a click on a Web Notification.
awdff8bdbe82016-10-14 09:42:32541 void SimulateWebNotificationClick(const std::string& title,
542 int action_index,
543 const base::NullableString16& reply);
[email protected]97f9a7952014-03-14 11:50:33544
nsatragno24bd34b2016-02-09 10:30:02545 // Simulates closing a Web Notification.
546 void SimulateWebNotificationClose(const std::string& title, bool by_user);
547
[email protected]56e365d42014-05-02 22:18:24548 // Speech recognition related functions.
[email protected]97f9a7952014-03-14 11:50:33549 void AddMockSpeechRecognitionResult(const std::string& transcript,
550 double confidence);
551 void SetMockSpeechRecognitionError(const std::string& error,
552 const std::string& message);
[email protected]97f9a7952014-03-14 11:50:33553
mkwst41667ab2014-09-16 06:52:43554 // Credential Manager mock functions
555 // TODO(mkwst): Support FederatedCredential.
tyoshino5138b3b92016-09-27 09:11:50556 void SetMockCredentialManagerResponse(const std::string& id,
mkwst41667ab2014-09-16 06:52:43557 const std::string& name,
558 const std::string& avatar,
559 const std::string& password);
tyoshino5138b3b92016-09-27 09:11:50560 void ClearMockCredentialManagerResponse();
561 void SetMockCredentialManagerError(const std::string& error);
mkwst41667ab2014-09-16 06:52:43562
lukasza083b4f12016-03-24 16:51:43563 // Takes care of notifying the delegate after a change to layout test runtime
564 // flags.
565 void OnLayoutTestRuntimeFlagsChanged();
lukaszac9cbe712016-03-14 14:06:43566
[email protected]97f9a7952014-03-14 11:50:33567 ///////////////////////////////////////////////////////////////////////////
568 // Internal helpers
[email protected]eec9e78e2014-06-16 21:38:48569
lukasza10cd8762016-04-27 20:03:02570 bool IsFramePartOfMainTestWindow(blink::WebFrame*) const;
571
[email protected]97f9a7952014-03-14 11:50:33572 void CheckResponseMimeType();
[email protected]97f9a7952014-03-14 11:50:33573
[email protected]97f9a7952014-03-14 11:50:33574 // In the Mac code, this is called to trigger the end of a test after the
575 // page has finished loading. From here, we can generate the dump for the
576 // test.
577 void LocationChangeDone();
578
579 bool test_is_running_;
580
581 // When reset is called, go through and close all but the main test shell
582 // window. By default, set to true but toggled to false using
583 // setCloseRemainingWindowsWhenComplete().
584 bool close_remaining_windows_;
585
[email protected]97f9a7952014-03-14 11:50:33586 WorkQueue work_queue_;
587
[email protected]97f9a7952014-03-14 11:50:33588 // Bound variable to return the name of this platform (chromium).
589 std::string platform_name_;
590
591 // Bound variable to store the last tooltip text
592 std::string tooltip_text_;
593
[email protected]97f9a7952014-03-14 11:50:33594 // Bound variable counting the number of top URLs visited.
595 int web_history_item_count_;
596
lukasza9b9d70e2016-02-25 23:45:44597 // Flags controlling what content gets dumped as a layout text result.
lukasza083b4f12016-03-24 16:51:43598 LayoutTestRuntimeFlags layout_test_runtime_flags_;
[email protected]97f9a7952014-03-14 11:50:33599
[email protected]97f9a7952014-03-14 11:50:33600 // If true, the test_shell will output a base64 encoded WAVE file.
601 bool dump_as_audio_;
602
[email protected]97f9a7952014-03-14 11:50:33603 // If true, the test_shell will produce a dump of the back forward list as
604 // well.
605 bool dump_back_forward_list_;
606
[email protected]97f9a7952014-03-14 11:50:33607 // If true, pixel dump will be produced as a series of 1px-tall, view-wide
608 // individual paints over the height of the view.
609 bool test_repaint_;
610
611 // If true and test_repaint_ is true as well, pixel dump will be produced as
612 // a series of 1px-wide, view-tall paints across the width of the view.
613 bool sweep_horizontally_;
614
toyoshim729663f2016-10-17 08:54:13615 // startSession() result of MockWebMIDIAccessor for testing.
616 midi::mojom::Result midi_accessor_result_;
[email protected]97f9a7952014-03-14 11:50:33617
[email protected]f24836a2014-05-06 01:02:44618 bool has_custom_text_output_;
619 std::string custom_text_output_;
620
[email protected]97f9a7952014-03-14 11:50:33621 std::set<std::string> http_headers_to_clear_;
622
623 // WAV audio data is stored here.
624 std::vector<unsigned char> audio_data_;
625
[email protected]79ecada2014-05-04 05:16:16626 TestInterfaces* test_interfaces_;
627 WebTestDelegate* delegate_;
lukasza8973c522016-04-27 16:32:28628 blink::WebView* main_view_;
[email protected]97f9a7952014-03-14 11:50:33629
630 // This is non-0 IFF a load is in progress.
631 blink::WebFrame* top_loading_frame_;
632
mlamouri007f9d72015-02-27 16:27:25633 // WebContentSettingsClient mock object.
dcheng82beb4f2016-04-26 00:35:02634 std::unique_ptr<MockContentSettingsClient> mock_content_settings_client_;
[email protected]97f9a7952014-03-14 11:50:33635
[email protected]97f9a7952014-03-14 11:50:33636 bool use_mock_theme_;
637
blundell987cb782016-08-17 17:25:37638 // This is true in the period between the start of a navigation and when the
639 // provisional load for that navigation is started. Note that when
640 // browser-side navigation is enabled there is an arbitrary gap between these
641 // two events.
642 bool will_navigate_;
643
dcheng82beb4f2016-04-26 00:35:02644 std::unique_ptr<MockCredentialManagerClient> credential_manager_client_;
645 std::unique_ptr<MockScreenOrientationClient> mock_screen_orientation_client_;
646 std::unique_ptr<MockWebSpeechRecognizer> speech_recognizer_;
647 std::unique_ptr<MockWebUserMediaClient> user_media_client_;
648 std::unique_ptr<SpellCheckClient> spellcheck_;
lukaszafd124602016-04-01 16:53:30649
650 // Number of currently active color choosers.
651 int chooser_count_;
lukasza6a113ae12016-03-17 22:41:20652
lukasza1b546c12016-04-04 16:19:20653 // Captured drag image.
654 blink::WebImage drag_image_;
655
lukasza95416be142016-04-14 15:06:33656 // View that was focused by a previous call to TestRunner::SetFocus method.
657 // Note - this can be a dangling pointer to an already destroyed WebView (this
658 // is ok, because this is taken care of in WebTestDelegate::SetFocus).
659 blink::WebView* previously_focused_view_;
660
lukaszadf92022f2016-05-03 16:42:31661 std::set<blink::WebWidget*> widgets_with_scheduled_animations_;
lukasza01da2602016-04-05 14:51:26662
tkent2edc979d2016-05-27 04:58:25663 // True if we run a test in LayoutTests/imported/{csswg-test,wpt}/.
664 bool is_web_platform_tests_mode_;
tkent003403482016-05-26 08:18:41665
jkarlin3bddb7d2016-09-21 18:44:16666 // An effective connection type settable by layout tests.
667 blink::WebEffectiveConnectionType effective_connection_type_;
668
[email protected]97f9a7952014-03-14 11:50:33669 base::WeakPtrFactory<TestRunner> weak_factory_;
670
671 DISALLOW_COPY_AND_ASSIGN(TestRunner);
672};
673
jochenf5f31752015-06-03 12:06:34674} // namespace test_runner
[email protected]97f9a7952014-03-14 11:50:33675
jochen73e711c2015-06-03 10:01:46676#endif // COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_