blob: ac2ebd935dc57b3d32cf7d54b82bfe1b11ac8f5f [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"
jkarlin3bddb7d2016-09-21 18:44:1621#include "third_party/WebKit/public/platform/WebEffectiveConnectionType.h"
lukasza1b546c12016-04-04 16:19:2022#include "third_party/WebKit/public/platform/WebImage.h"
[email protected]97f9a7952014-03-14 11:50:3323#include "v8/include/v8.h"
24
[email protected]945babb2014-07-30 14:25:3225class GURL;
[email protected]eec9e78e2014-06-16 21:38:4826class SkBitmap;
27
[email protected]97f9a7952014-03-14 11:50:3328namespace blink {
mlamouri007f9d72015-02-27 16:27:2529class WebContentSettingsClient;
[email protected]97f9a7952014-03-14 11:50:3330class WebFrame;
lukaszab2ad0502016-04-27 15:51:4231class WebLocalFrame;
[email protected]97f9a7952014-03-14 11:50:3332class WebString;
33class WebView;
lukaszadf92022f2016-05-03 16:42:3134class WebWidget;
[email protected]97f9a7952014-03-14 11:50:3335}
36
37namespace gin {
38class ArrayBufferView;
39class Arguments;
40}
41
jochenf5f31752015-06-03 12:06:3442namespace test_runner {
[email protected]97f9a7952014-03-14 11:50:3343
lukasza21353232016-04-12 19:52:1144class MockContentSettingsClient;
lukasza5c2279c2016-04-05 16:44:4745class MockCredentialManagerClient;
lukasza6a113ae12016-03-17 22:41:2046class MockScreenOrientationClient;
lukasza01da2602016-04-05 14:51:2647class MockWebSpeechRecognizer;
lukaszafd124602016-04-01 16:53:3048class MockWebUserMediaClient;
lukasza5c2279c2016-04-05 16:44:4749class SpellCheckClient;
[email protected]79ecada2014-05-04 05:16:1650class TestInterfaces;
lukaszab2ad0502016-04-27 15:51:4251class TestRunnerForSpecificView;
[email protected]79ecada2014-05-04 05:16:1652class WebTestDelegate;
[email protected]97f9a7952014-03-14 11:50:3353
lukaszab2ad0502016-04-27 15:51:4254// TestRunner class currently has dual purpose:
55// 1. It implements |testRunner| javascript bindings for "global" / "ambient".
56// Examples:
57// - testRunner.dumpAsText (test flag affecting test behavior)
carlosk5f1c5172016-09-08 18:59:3158// - testRunner.setAllowRunningOfInsecureContent (test flag affecting product
lukaszab2ad0502016-04-27 15:51:4259// behavior)
60// - testRunner.setTextSubpixelPositioning (directly interacts with product).
61// Note that "per-view" (non-"global") bindings are handled by
62// instances of TestRunnerForSpecificView class.
63// 2. It manages global test state. Example:
64// - Tracking topLoadingFrame that can finish the test when it loads.
65// - WorkQueue holding load requests from the TestInterfaces
66// - LayoutTestRuntimeFlags
lukaszac9358822016-04-07 14:43:4667class TestRunner : public WebTestRunner {
[email protected]97f9a7952014-03-14 11:50:3368 public:
[email protected]79ecada2014-05-04 05:16:1669 explicit TestRunner(TestInterfaces*);
[email protected]97f9a7952014-03-14 11:50:3370 virtual ~TestRunner();
71
lukaszab2ad0502016-04-27 15:51:4272 void Install(blink::WebLocalFrame* frame,
73 base::WeakPtr<TestRunnerForSpecificView> view_test_runner);
[email protected]97f9a7952014-03-14 11:50:3374
[email protected]79ecada2014-05-04 05:16:1675 void SetDelegate(WebTestDelegate*);
lukasza8973c522016-04-27 16:32:2876 void SetMainView(blink::WebView*);
[email protected]97f9a7952014-03-14 11:50:3377
78 void Reset();
79
[email protected]97f9a7952014-03-14 11:50:3380 void SetTestIsRunning(bool);
81 bool TestIsRunning() const { return test_is_running_; }
82
83 bool UseMockTheme() const { return use_mock_theme_; }
84
85 // WebTestRunner implementation.
dchenge933b3e2014-10-21 11:44:0986 bool ShouldGeneratePixelResults() override;
87 bool ShouldDumpAsAudio() const override;
88 void GetAudioData(std::vector<unsigned char>* buffer_view) const override;
lukaszaef264fc52016-03-17 22:49:1989 bool IsRecursiveLayoutDumpRequested() override;
90 std::string DumpLayout(blink::WebLocalFrame* frame) override;
lukasza1b546c12016-04-04 16:19:2091 void DumpPixelsAsync(
92 blink::WebView* web_view,
93 const base::Callback<void(const SkBitmap&)>& callback) override;
lukasza083b4f12016-03-24 16:51:4394 void ReplicateLayoutTestRuntimeFlagsChanges(
lukaszac9cbe712016-03-14 14:06:4395 const base::DictionaryValue& changed_values) override;
lukaszaa8960462016-01-27 22:27:3396 bool HasCustomTextDump(std::string* custom_text_dump) const override;
dchenge933b3e2014-10-21 11:44:0997 bool ShouldDumpBackForwardList() const override;
mlamouri007f9d72015-02-27 16:27:2598 blink::WebContentSettingsClient* GetWebContentSettings() const override;
lukasza5c2279c2016-04-05 16:44:4799 void InitializeWebViewWithMocks(blink::WebView* web_view) override;
lukasza95416be142016-04-14 15:06:33100 void SetFocus(blink::WebView* web_view, bool focus) override;
[email protected]97f9a7952014-03-14 11:50:33101
lukasza01da2602016-04-05 14:51:26102 // Methods used by WebViewTestClient and WebFrameTestClient.
blundell987cb782016-08-17 17:25:37103 void OnNavigationBegin(blink::WebFrame* frame);
104 void OnNavigationEnd() { will_navigate_ = false; }
lukaszadf92022f2016-05-03 16:42:31105 void OnAnimationScheduled(blink::WebWidget* widget);
106 void OnAnimationBegun(blink::WebWidget* widget);
lukaszaa0b624a2016-04-04 15:00:49107 std::string GetAcceptLanguages() const;
lukaszae26c3d62016-03-14 23:30:59108 bool shouldStayOnPageAfterHandlingBeforeUnload() const;
lukasza6a113ae12016-03-17 22:41:20109 MockScreenOrientationClient* getMockScreenOrientationClient();
lukaszafd124602016-04-01 16:53:30110 MockWebUserMediaClient* getMockWebUserMediaClient();
lukasza01da2602016-04-05 14:51:26111 MockWebSpeechRecognizer* getMockWebSpeechRecognizer();
[email protected]97f9a7952014-03-14 11:50:33112 bool isPrinting() const;
[email protected]f24836a2014-05-06 01:02:44113 bool shouldDumpAsCustomText() const;
114 std:: string customDumpText() const;
abhishek.a21ca9b5602014-09-19 07:33:33115 void ShowDevTools(const std::string& settings,
[email protected]06c253012014-04-16 18:35:33116 const std::string& frontend_url);
abhishek.a21ca9b5602014-09-19 07:33:33117 void ClearDevToolsLocalStorage();
[email protected]97f9a7952014-03-14 11:50:33118 void setShouldDumpAsText(bool);
119 void setShouldDumpAsMarkup(bool);
ki.stfu939799a42015-09-28 04:41:20120 void setCustomTextOutput(const std::string& text);
[email protected]97f9a7952014-03-14 11:50:33121 void setShouldGeneratePixelResults(bool);
122 void setShouldDumpFrameLoadCallbacks(bool);
[email protected]97f9a7952014-03-14 11:50:33123 void setShouldEnableViewSource(bool);
124 bool shouldDumpEditingCallbacks() const;
125 bool shouldDumpFrameLoadCallbacks() const;
126 bool shouldDumpPingLoaderCallbacks() const;
127 bool shouldDumpUserGestureInFrameLoadCallbacks() const;
128 bool shouldDumpTitleChanges() const;
129 bool shouldDumpIconChanges() const;
130 bool shouldDumpCreateView() const;
131 bool canOpenWindows() const;
132 bool shouldDumpResourceLoadCallbacks() const;
[email protected]97f9a7952014-03-14 11:50:33133 bool shouldDumpResourceResponseMIMETypes() const;
134 bool shouldDumpStatusCallbacks() const;
[email protected]97f9a7952014-03-14 11:50:33135 bool shouldDumpSpellCheckCallbacks() const;
[email protected]a79cb9912014-04-26 22:07:33136 bool shouldWaitUntilExternalURLLoad() const;
[email protected]97f9a7952014-03-14 11:50:33137 const std::set<std::string>* httpHeadersToClear() const;
tkent2edc979d2016-05-27 04:58:25138 bool is_web_platform_tests_mode() const {
139 return is_web_platform_tests_mode_;
140 }
141 void set_is_web_platform_tests_mode() { is_web_platform_tests_mode_ = true; }
lukasza10cd8762016-04-27 20:03:02142
143 // To be called when |frame| starts loading - TestRunner will check if
144 // there is currently no top-loading-frame being tracked and if so, then it
145 // will return true and start tracking |frame| as the top-loading-frame.
146 bool tryToSetTopLoadingFrame(blink::WebFrame* frame);
147
148 // To be called when |frame| finishes loading - TestRunner will check if
149 // |frame| is currently tracked as the top-loading-frame, and if yes, then it
150 // will return true, stop top-loading-frame tracking, and potentially finish
151 // the test (unless testRunner.waitUntilDone() was called and/or there are
152 // pending load requests in WorkQueue).
153 bool tryToClearTopLoadingFrame(blink::WebFrame*);
154
[email protected]97f9a7952014-03-14 11:50:33155 blink::WebFrame* topLoadingFrame() const;
156 void policyDelegateDone();
157 bool policyDelegateEnabled() const;
158 bool policyDelegateIsPermissive() const;
159 bool policyDelegateShouldNotifyDone() const;
[email protected]97f9a7952014-03-14 11:50:33160 void setToolTipText(const blink::WebString&);
lukasza1b546c12016-04-04 16:19:20161 void setDragImage(const blink::WebImage& drag_image);
jochenc3a98da12015-03-10 13:59:58162 bool shouldDumpNavigationPolicy() const;
[email protected]97f9a7952014-03-14 11:50:33163
164 bool midiAccessorResult();
165
lukaszafd124602016-04-01 16:53:30166 // Methods used by MockColorChooser:
167 void DidOpenChooser();
168 void DidCloseChooser();
169
caseqcb2227832016-05-24 18:52:04170 bool ShouldDumpConsoleMessages() const;
171
jkarlin3bddb7d2016-09-21 18:44:16172 blink::WebEffectiveConnectionType effective_connection_type() const {
173 return effective_connection_type_;
174 }
175
[email protected]97f9a7952014-03-14 11:50:33176 // A single item in the work queue.
177 class WorkItem {
178 public:
179 virtual ~WorkItem() {}
180
181 // Returns true if this started a load.
[email protected]79ecada2014-05-04 05:16:16182 virtual bool Run(WebTestDelegate*, blink::WebView*) = 0;
[email protected]97f9a7952014-03-14 11:50:33183 };
184
185 private:
[email protected]97f9a7952014-03-14 11:50:33186 friend class TestRunnerBindings;
187 friend class WorkQueue;
188
189 // Helper class for managing events queued by methods like queueLoad or
190 // queueScript.
191 class WorkQueue {
192 public:
193 explicit WorkQueue(TestRunner* controller);
194 virtual ~WorkQueue();
195 void ProcessWorkSoon();
196
197 // Reset the state of the class between tests.
198 void Reset();
199
200 void AddWork(WorkItem*);
201
202 void set_frozen(bool frozen) { frozen_ = frozen; }
203 bool is_empty() { return queue_.empty(); }
[email protected]97f9a7952014-03-14 11:50:33204
205 private:
206 void ProcessWork();
207
[email protected]97f9a7952014-03-14 11:50:33208 std::deque<WorkItem*> queue_;
209 bool frozen_;
210 TestRunner* controller_;
lukaszac9358822016-04-07 14:43:46211
212 base::WeakPtrFactory<WorkQueue> weak_factory_;
[email protected]97f9a7952014-03-14 11:50:33213 };
214
215 ///////////////////////////////////////////////////////////////////////////
216 // Methods dealing with the test logic
217
218 // By default, tests end when page load is complete. These methods are used
219 // to delay the completion of the test until notifyDone is called.
220 void NotifyDone();
221 void WaitUntilDone();
222
223 // Methods for adding actions to the work queue. Used in conjunction with
224 // waitUntilDone/notifyDone above.
225 void QueueBackNavigation(int how_far_back);
226 void QueueForwardNavigation(int how_far_forward);
227 void QueueReload();
228 void QueueLoadingScript(const std::string& script);
229 void QueueNonLoadingScript(const std::string& script);
230 void QueueLoad(const std::string& url, const std::string& target);
[email protected]97f9a7952014-03-14 11:50:33231
232 // Causes navigation actions just printout the intended navigation instead
233 // of taking you to the page. This is used for cases like mailto, where you
234 // don't actually want to open the mail program.
235 void SetCustomPolicyDelegate(gin::Arguments* args);
236
237 // Delays completion of the test until the policy delegate runs.
238 void WaitForPolicyDelegate();
239
240 // Functions for dealing with windows. By default we block all new windows.
241 int WindowCount();
242 void SetCloseRemainingWindowsWhenComplete(bool close_remaining_windows);
243 void ResetTestHelperControllers();
244
[email protected]97f9a7952014-03-14 11:50:33245 // Allows layout tests to manage origins' whitelisting.
246 void AddOriginAccessWhitelistEntry(const std::string& source_origin,
247 const std::string& destination_protocol,
248 const std::string& destination_host,
249 bool allow_destination_subdomains);
250 void RemoveOriginAccessWhitelistEntry(const std::string& source_origin,
251 const std::string& destination_protocol,
252 const std::string& destination_host,
253 bool allow_destination_subdomains);
254
dcheng9000dbd2015-04-03 05:39:40255 // Add |source_code| as an injected stylesheet to the active document of the
256 // window of the current V8 context.
257 void InsertStyleSheet(const std::string& source_code);
258
[email protected]97f9a7952014-03-14 11:50:33259 // Enables or disables subpixel positioning (i.e. fractional X positions for
260 // glyphs) in text rendering on Linux. Since this method changes global
261 // settings, tests that call it must use their own custom font family for
262 // all text that they render. If not, an already-cached style will be used,
263 // resulting in the changed setting being ignored.
264 void SetTextSubpixelPositioning(bool value);
265
[email protected]97f9a7952014-03-14 11:50:33266 // After this function is called, all window-sizing machinery is
267 // short-circuited inside the renderer. This mode is necessary for
268 // some tests that were written before browsers had multi-process architecture
269 // and rely on window resizes to happen synchronously.
270 // The function has "unfortunate" it its name because we must strive to remove
271 // all tests that rely on this... well, unfortunate behavior. See
272 // http://crbug.com/309760 for the plan.
273 void UseUnfortunateSynchronousResizeMode();
274
275 bool EnableAutoResizeMode(int min_width,
276 int min_height,
277 int max_width,
278 int max_height);
279 bool DisableAutoResizeMode(int new_width, int new_height);
280
[email protected]2ad7e622014-06-30 17:44:21281 void SetMockDeviceLight(double value);
282 void ResetDeviceLight();
[email protected]97f9a7952014-03-14 11:50:33283 // Device Motion / Device Orientation related functions
284 void SetMockDeviceMotion(bool has_acceleration_x, double acceleration_x,
285 bool has_acceleration_y, double acceleration_y,
286 bool has_acceleration_z, double acceleration_z,
287 bool has_acceleration_including_gravity_x,
288 double acceleration_including_gravity_x,
289 bool has_acceleration_including_gravity_y,
290 double acceleration_including_gravity_y,
291 bool has_acceleration_including_gravity_z,
292 double acceleration_including_gravity_z,
293 bool has_rotation_rate_alpha,
294 double rotation_rate_alpha,
295 bool has_rotation_rate_beta,
296 double rotation_rate_beta,
297 bool has_rotation_rate_gamma,
298 double rotation_rate_gamma,
299 double interval);
300 void SetMockDeviceOrientation(bool has_alpha, double alpha,
301 bool has_beta, double beta,
302 bool has_gamma, double gamma,
philipj97906452016-03-02 14:46:22303 bool absolute);
[email protected]97f9a7952014-03-14 11:50:33304
[email protected]e0bc2cb2014-03-20 17:34:24305 void SetMockScreenOrientation(const std::string& orientation);
dgozman3c16f7f2016-02-26 01:21:18306 void DisableMockScreenOrientation();
[email protected]e0bc2cb2014-03-20 17:34:24307
[email protected]97f9a7952014-03-14 11:50:33308 ///////////////////////////////////////////////////////////////////////////
309 // Methods modifying WebPreferences.
310
311 // Set the WebPreference that controls webkit's popup blocking.
312 void SetPopupBlockingEnabled(bool block_popups);
313
314 void SetJavaScriptCanAccessClipboard(bool can_access);
315 void SetXSSAuditorEnabled(bool enabled);
316 void SetAllowUniversalAccessFromFileURLs(bool allow);
317 void SetAllowFileAccessFromFileURLs(bool allow);
ki.stfu939799a42015-09-28 04:41:20318 void OverridePreference(const std::string& key, v8::Local<v8::Value> value);
[email protected]97f9a7952014-03-14 11:50:33319
[email protected]ebd5ea52014-05-28 14:51:15320 // Modify accept_languages in RendererPreferences.
321 void SetAcceptLanguages(const std::string& accept_languages);
322
[email protected]97f9a7952014-03-14 11:50:33323 // Enable or disable plugins.
324 void SetPluginsEnabled(bool enabled);
325
lukasza01da2602016-04-05 14:51:26326 // Returns |true| if an animation has been scheduled in one or more WebViews
327 // participating in the layout test.
328 bool GetAnimationScheduled() const;
chrishtraea6066d2016-02-19 04:49:12329
[email protected]97f9a7952014-03-14 11:50:33330 ///////////////////////////////////////////////////////////////////////////
331 // Methods that modify the state of TestRunner
332
333 // This function sets a flag that tells the test_shell to print a line of
334 // descriptive text for each editing command. It takes no arguments, and
335 // ignores any that may be present.
336 void DumpEditingCallbacks();
337
338 // This function sets a flag that tells the test_shell to dump pages as
339 // plain text, rather than as a text representation of the renderer's state.
340 // The pixel results will not be generated for this test.
341 void DumpAsText();
342
343 // This function sets a flag that tells the test_shell to dump pages as
[email protected]fdc433c02014-06-02 19:27:14344 // the DOM contents, rather than as a text representation of the renderer's
345 // state. The pixel results will not be generated for this test.
346 void DumpAsMarkup();
347
348 // This function sets a flag that tells the test_shell to dump pages as
[email protected]97f9a7952014-03-14 11:50:33349 // plain text, rather than as a text representation of the renderer's state.
350 // It will also generate a pixel dump for the test.
351 void DumpAsTextWithPixelResults();
352
353 // This function sets a flag that tells the test_shell to print out the
354 // scroll offsets of the child frames. It ignores all.
355 void DumpChildFrameScrollPositions();
356
357 // This function sets a flag that tells the test_shell to recursively
358 // dump all frames as plain text if the DumpAsText flag is set.
359 // It takes no arguments, and ignores any that may be present.
360 void DumpChildFramesAsText();
361
[email protected]fdc433c02014-06-02 19:27:14362 // This function sets a flag that tells the test_shell to recursively
363 // dump all frames as the DOM contents if the DumpAsMarkup flag is set.
364 // It takes no arguments, and ignores any that may be present.
365 void DumpChildFramesAsMarkup();
366
[email protected]97f9a7952014-03-14 11:50:33367 // This function sets a flag that tells the test_shell to print out the
368 // information about icon changes notifications from WebKit.
369 void DumpIconChanges();
370
371 // Deals with Web Audio WAV file data.
372 void SetAudioData(const gin::ArrayBufferView& view);
373
374 // This function sets a flag that tells the test_shell to print a line of
375 // descriptive text for each frame load callback. It takes no arguments, and
376 // ignores any that may be present.
377 void DumpFrameLoadCallbacks();
378
379 // This function sets a flag that tells the test_shell to print a line of
380 // descriptive text for each PingLoader dispatch. It takes no arguments, and
381 // ignores any that may be present.
382 void DumpPingLoaderCallbacks();
383
384 // This function sets a flag that tells the test_shell to print a line of
385 // user gesture status text for some frame load callbacks. It takes no
386 // arguments, and ignores any that may be present.
387 void DumpUserGestureInFrameLoadCallbacks();
388
389 void DumpTitleChanges();
390
391 // This function sets a flag that tells the test_shell to dump all calls to
392 // WebViewClient::createView().
393 // It takes no arguments, and ignores any that may be present.
394 void DumpCreateView();
395
396 void SetCanOpenWindows();
397
398 // This function sets a flag that tells the test_shell to dump a descriptive
399 // line for each resource load callback. It takes no arguments, and ignores
400 // any that may be present.
401 void DumpResourceLoadCallbacks();
402
[email protected]97f9a7952014-03-14 11:50:33403 // This function sets a flag that tells the test_shell to dump the MIME type
404 // for each resource that was loaded. It takes no arguments, and ignores any
405 // that may be present.
406 void DumpResourceResponseMIMETypes();
407
mlamouri007f9d72015-02-27 16:27:25408 // WebContentSettingsClient related.
[email protected]97f9a7952014-03-14 11:50:33409 void SetImagesAllowed(bool allowed);
410 void SetScriptsAllowed(bool allowed);
411 void SetStorageAllowed(bool allowed);
412 void SetPluginsAllowed(bool allowed);
[email protected]97f9a7952014-03-14 11:50:33413 void SetAllowRunningOfInsecureContent(bool allowed);
mlamouri426f2862016-04-29 18:35:01414 void SetAutoplayAllowed(bool allowed);
[email protected]97f9a7952014-03-14 11:50:33415 void DumpPermissionClientCallbacks();
416
engedy9ae04242016-06-08 13:31:18417 // Sets up a mock DocumentSubresourceFilter to disallow subsequent subresource
418 // loads within the current document with the given path |suffixes|. The
419 // filter is created and injected even if |suffixes| is empty. If |suffixes|
420 // contains the empty string, all subresource loads will be disallowed.
421 void SetDisallowedSubresourcePathSuffixes(
422 const std::vector<std::string>& suffixes);
423
[email protected]97f9a7952014-03-14 11:50:33424 // This function sets a flag that tells the test_shell to dump all calls
425 // to window.status().
426 // It takes no arguments, and ignores any that may be present.
427 void DumpWindowStatusChanges();
428
[email protected]97f9a7952014-03-14 11:50:33429 // This function sets a flag that tells the test_shell to dump all
430 // the lines of descriptive text about spellcheck execution.
431 void DumpSpellCheckCallbacks();
432
433 // This function sets a flag that tells the test_shell to print out a text
434 // representation of the back/forward list. It ignores all arguments.
435 void DumpBackForwardList();
436
437 void DumpSelectionRect();
[email protected]97f9a7952014-03-14 11:50:33438
439 // Causes layout to happen as if targetted to printed pages.
440 void SetPrinting();
441
[email protected]52846102014-06-24 04:26:44442 // Clears the state from SetPrinting().
443 void ClearPrinting();
444
[email protected]97f9a7952014-03-14 11:50:33445 void SetShouldStayOnPageAfterHandlingBeforeUnload(bool value);
446
447 // Causes WillSendRequest to clear certain headers.
448 void SetWillSendRequestClearHeader(const std::string& header);
449
[email protected]97f9a7952014-03-14 11:50:33450 // Sets a flag to enable the mock theme.
451 void SetUseMockTheme(bool use);
452
[email protected]a79cb9912014-04-26 22:07:33453 // Sets a flag that causes the test to be marked as completed when the
454 // WebFrameClient receives a loadURLExternally() call.
455 void WaitUntilExternalURLLoad();
456
lukasza1b546c12016-04-04 16:19:20457 // This function sets a flag to dump the drag image when the next drag&drop is
458 // initiated. It is equivalent to DumpAsTextWithPixelResults but the pixel
459 // results will be the drag image instead of a snapshot of the page.
jackhou656fc852015-02-13 09:04:17460 void DumpDragImage();
461
lfg05e41372016-07-22 15:38:10462 // Sets a flag that tells the WebViewTestProxy to dump the default navigation
jochenc3a98da12015-03-10 13:59:58463 // policy passed to the decidePolicyForNavigation callback.
464 void DumpNavigationPolicy();
465
caseqcb2227832016-05-24 18:52:04466 // Controls whether console messages produced by the page are dumped
467 // to test output.
468 void SetDumpConsoleMessages(bool value);
469
jkarlin3bddb7d2016-09-21 18:44:16470 // Overrides the NetworkQualityEstimator's estimated network type. If |type|
471 // is TypeUnknown the NQE's value is used. Be sure to call this with
472 // TypeUnknown at the end of your test if you use this.
473 void SetEffectiveConnectionType(
474 blink::WebEffectiveConnectionType connection_type);
475
xiaochengh2fa3e762016-08-24 11:27:04476 // Controls whether the mock spell checker is enabled.
477 void SetMockSpellCheckerEnabled(bool enabled);
478
[email protected]97f9a7952014-03-14 11:50:33479 ///////////////////////////////////////////////////////////////////////////
lfg05e41372016-07-22 15:38:10480 // Methods interacting with the WebViewTestProxy
[email protected]97f9a7952014-03-14 11:50:33481
482 ///////////////////////////////////////////////////////////////////////////
483 // Methods forwarding to the WebTestDelegate
484
485 // Shows DevTools window.
[email protected]06c253012014-04-16 18:35:33486 void ShowWebInspector(const std::string& str,
487 const std::string& frontend_url);
[email protected]97f9a7952014-03-14 11:50:33488 void CloseWebInspector();
489
490 // Inspect chooser state
491 bool IsChooserShown();
492
493 // Allows layout tests to exec scripts at WebInspector side.
494 void EvaluateInWebInspector(int call_id, const std::string& script);
sergeyv0cd842b42015-10-09 16:07:11495 // Allows layout tests to evaluate scripts in InspectorOverlay page.
496 // Script may have an output represented as a string, return values of other
497 // types would be ignored.
498 std::string EvaluateInWebInspectorOverlay(const std::string& script);
[email protected]97f9a7952014-03-14 11:50:33499
500 // Clears all databases.
501 void ClearAllDatabases();
502 // Sets the default quota for all origins
503 void SetDatabaseQuota(int quota);
504
tyoshinoa6b91462016-07-11 09:15:09505 // Sets the cookie policy to:
506 // - allow all cookies when |block| is false
507 // - block only third-party cookies when |block| is true
508 void SetBlockThirdPartyCookies(bool block);
[email protected]97f9a7952014-03-14 11:50:33509
[email protected]97f9a7952014-03-14 11:50:33510 // Converts a URL starting with file:///tmp/ to the local mapping.
511 std::string PathToLocalResource(const std::string& path);
512
mlamourid5098d02015-04-21 12:17:30513 // Sets the permission's |name| to |value| for a given {origin, embedder}
514 // tuple.
515 void SetPermission(const std::string& name,
516 const std::string& value,
517 const GURL& origin,
518 const GURL& embedding_origin);
519
benwells0c0d3f12015-05-25 01:03:17520 // Resolve the beforeinstallprompt event with the matching request id.
521 void ResolveBeforeInstallPromptPromise(int request_id,
522 const std::string& platform);
523
[email protected]97f9a7952014-03-14 11:50:33524 // Calls setlocale(LC_ALL, ...) for a specified locale.
525 // Resets between tests.
526 void SetPOSIXLocale(const std::string& locale);
527
528 // MIDI function to control permission handling.
529 void SetMIDIAccessorResult(bool result);
[email protected]97f9a7952014-03-14 11:50:33530
peterd98157d2014-11-20 13:15:01531 // Simulates a click on a Web Notification.
johnme96d50122015-08-07 15:33:21532 void SimulateWebNotificationClick(const std::string& title, int action_index);
[email protected]97f9a7952014-03-14 11:50:33533
nsatragno24bd34b2016-02-09 10:30:02534 // Simulates closing a Web Notification.
535 void SimulateWebNotificationClose(const std::string& title, bool by_user);
536
[email protected]56e365d42014-05-02 22:18:24537 // Speech recognition related functions.
[email protected]97f9a7952014-03-14 11:50:33538 void AddMockSpeechRecognitionResult(const std::string& transcript,
539 double confidence);
540 void SetMockSpeechRecognitionError(const std::string& error,
541 const std::string& message);
[email protected]97f9a7952014-03-14 11:50:33542
mkwst41667ab2014-09-16 06:52:43543 // Credential Manager mock functions
544 // TODO(mkwst): Support FederatedCredential.
tyoshino5138b3b92016-09-27 09:11:50545 void SetMockCredentialManagerResponse(const std::string& id,
mkwst41667ab2014-09-16 06:52:43546 const std::string& name,
547 const std::string& avatar,
548 const std::string& password);
tyoshino5138b3b92016-09-27 09:11:50549 void ClearMockCredentialManagerResponse();
550 void SetMockCredentialManagerError(const std::string& error);
mkwst41667ab2014-09-16 06:52:43551
lukasza083b4f12016-03-24 16:51:43552 // Takes care of notifying the delegate after a change to layout test runtime
553 // flags.
554 void OnLayoutTestRuntimeFlagsChanged();
lukaszac9cbe712016-03-14 14:06:43555
[email protected]97f9a7952014-03-14 11:50:33556 ///////////////////////////////////////////////////////////////////////////
557 // Internal helpers
[email protected]eec9e78e2014-06-16 21:38:48558
lukasza10cd8762016-04-27 20:03:02559 bool IsFramePartOfMainTestWindow(blink::WebFrame*) const;
560
[email protected]97f9a7952014-03-14 11:50:33561 void CheckResponseMimeType();
[email protected]97f9a7952014-03-14 11:50:33562
[email protected]97f9a7952014-03-14 11:50:33563 // In the Mac code, this is called to trigger the end of a test after the
564 // page has finished loading. From here, we can generate the dump for the
565 // test.
566 void LocationChangeDone();
567
568 bool test_is_running_;
569
570 // When reset is called, go through and close all but the main test shell
571 // window. By default, set to true but toggled to false using
572 // setCloseRemainingWindowsWhenComplete().
573 bool close_remaining_windows_;
574
[email protected]97f9a7952014-03-14 11:50:33575 WorkQueue work_queue_;
576
[email protected]97f9a7952014-03-14 11:50:33577 // Bound variable to return the name of this platform (chromium).
578 std::string platform_name_;
579
580 // Bound variable to store the last tooltip text
581 std::string tooltip_text_;
582
[email protected]97f9a7952014-03-14 11:50:33583 // Bound variable counting the number of top URLs visited.
584 int web_history_item_count_;
585
lukasza9b9d70e2016-02-25 23:45:44586 // Flags controlling what content gets dumped as a layout text result.
lukasza083b4f12016-03-24 16:51:43587 LayoutTestRuntimeFlags layout_test_runtime_flags_;
[email protected]97f9a7952014-03-14 11:50:33588
[email protected]97f9a7952014-03-14 11:50:33589 // If true, the test_shell will output a base64 encoded WAVE file.
590 bool dump_as_audio_;
591
[email protected]97f9a7952014-03-14 11:50:33592 // If true, the test_shell will produce a dump of the back forward list as
593 // well.
594 bool dump_back_forward_list_;
595
[email protected]97f9a7952014-03-14 11:50:33596 // If true, pixel dump will be produced as a series of 1px-tall, view-wide
597 // individual paints over the height of the view.
598 bool test_repaint_;
599
600 // If true and test_repaint_ is true as well, pixel dump will be produced as
601 // a series of 1px-wide, view-tall paints across the width of the view.
602 bool sweep_horizontally_;
603
[email protected]97f9a7952014-03-14 11:50:33604 // If false, MockWebMIDIAccessor fails on startSession() for testing.
605 bool midi_accessor_result_;
606
[email protected]f24836a2014-05-06 01:02:44607 bool has_custom_text_output_;
608 std::string custom_text_output_;
609
[email protected]97f9a7952014-03-14 11:50:33610 std::set<std::string> http_headers_to_clear_;
611
612 // WAV audio data is stored here.
613 std::vector<unsigned char> audio_data_;
614
[email protected]79ecada2014-05-04 05:16:16615 TestInterfaces* test_interfaces_;
616 WebTestDelegate* delegate_;
lukasza8973c522016-04-27 16:32:28617 blink::WebView* main_view_;
[email protected]97f9a7952014-03-14 11:50:33618
619 // This is non-0 IFF a load is in progress.
620 blink::WebFrame* top_loading_frame_;
621
mlamouri007f9d72015-02-27 16:27:25622 // WebContentSettingsClient mock object.
dcheng82beb4f2016-04-26 00:35:02623 std::unique_ptr<MockContentSettingsClient> mock_content_settings_client_;
[email protected]97f9a7952014-03-14 11:50:33624
[email protected]97f9a7952014-03-14 11:50:33625 bool use_mock_theme_;
626
blundell987cb782016-08-17 17:25:37627 // This is true in the period between the start of a navigation and when the
628 // provisional load for that navigation is started. Note that when
629 // browser-side navigation is enabled there is an arbitrary gap between these
630 // two events.
631 bool will_navigate_;
632
dcheng82beb4f2016-04-26 00:35:02633 std::unique_ptr<MockCredentialManagerClient> credential_manager_client_;
634 std::unique_ptr<MockScreenOrientationClient> mock_screen_orientation_client_;
635 std::unique_ptr<MockWebSpeechRecognizer> speech_recognizer_;
636 std::unique_ptr<MockWebUserMediaClient> user_media_client_;
637 std::unique_ptr<SpellCheckClient> spellcheck_;
lukaszafd124602016-04-01 16:53:30638
639 // Number of currently active color choosers.
640 int chooser_count_;
lukasza6a113ae12016-03-17 22:41:20641
lukasza1b546c12016-04-04 16:19:20642 // Captured drag image.
643 blink::WebImage drag_image_;
644
lukasza95416be142016-04-14 15:06:33645 // View that was focused by a previous call to TestRunner::SetFocus method.
646 // Note - this can be a dangling pointer to an already destroyed WebView (this
647 // is ok, because this is taken care of in WebTestDelegate::SetFocus).
648 blink::WebView* previously_focused_view_;
649
lukaszadf92022f2016-05-03 16:42:31650 std::set<blink::WebWidget*> widgets_with_scheduled_animations_;
lukasza01da2602016-04-05 14:51:26651
tkent2edc979d2016-05-27 04:58:25652 // True if we run a test in LayoutTests/imported/{csswg-test,wpt}/.
653 bool is_web_platform_tests_mode_;
tkent003403482016-05-26 08:18:41654
jkarlin3bddb7d2016-09-21 18:44:16655 // An effective connection type settable by layout tests.
656 blink::WebEffectiveConnectionType effective_connection_type_;
657
[email protected]97f9a7952014-03-14 11:50:33658 base::WeakPtrFactory<TestRunner> weak_factory_;
659
660 DISALLOW_COPY_AND_ASSIGN(TestRunner);
661};
662
jochenf5f31752015-06-03 12:06:34663} // namespace test_runner
[email protected]97f9a7952014-03-14 11:50:33664
jochen73e711c2015-06-03 10:01:46665#endif // COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_