blob: 77c31364c8db3ddb3be64f6d8a32371c98ee7890 [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"
lukasza1b546c12016-04-04 16:19:2021#include "third_party/WebKit/public/platform/WebImage.h"
[email protected]97f9a7952014-03-14 11:50:3322#include "v8/include/v8.h"
23
[email protected]945babb2014-07-30 14:25:3224class GURL;
[email protected]eec9e78e2014-06-16 21:38:4825class SkBitmap;
26
[email protected]97f9a7952014-03-14 11:50:3327namespace blink {
mlamouri007f9d72015-02-27 16:27:2528class WebContentSettingsClient;
[email protected]97f9a7952014-03-14 11:50:3329class WebFrame;
lukaszab2ad0502016-04-27 15:51:4230class WebLocalFrame;
[email protected]97f9a7952014-03-14 11:50:3331class WebString;
32class WebView;
lukaszadf92022f2016-05-03 16:42:3133class WebWidget;
[email protected]97f9a7952014-03-14 11:50:3334}
35
36namespace gin {
37class ArrayBufferView;
38class Arguments;
39}
40
jochenf5f31752015-06-03 12:06:3441namespace test_runner {
[email protected]97f9a7952014-03-14 11:50:3342
lukasza21353232016-04-12 19:52:1143class MockContentSettingsClient;
lukasza5c2279c2016-04-05 16:44:4744class MockCredentialManagerClient;
lukasza6a113ae12016-03-17 22:41:2045class MockScreenOrientationClient;
lukasza01da2602016-04-05 14:51:2646class MockWebSpeechRecognizer;
lukaszafd124602016-04-01 16:53:3047class MockWebUserMediaClient;
lukasza5c2279c2016-04-05 16:44:4748class SpellCheckClient;
[email protected]79ecada2014-05-04 05:16:1649class TestInterfaces;
lukaszab2ad0502016-04-27 15:51:4250class TestRunnerForSpecificView;
[email protected]79ecada2014-05-04 05:16:1651class WebTestDelegate;
[email protected]97f9a7952014-03-14 11:50:3352
lukaszab2ad0502016-04-27 15:51:4253// TestRunner class currently has dual purpose:
54// 1. It implements |testRunner| javascript bindings for "global" / "ambient".
55// Examples:
56// - testRunner.dumpAsText (test flag affecting test behavior)
57// - testRunner.setAllowDisplayOfInsecureContent (test flag affecting product
58// behavior)
59// - testRunner.setTextSubpixelPositioning (directly interacts with product).
60// Note that "per-view" (non-"global") bindings are handled by
61// instances of TestRunnerForSpecificView class.
62// 2. It manages global test state. Example:
63// - Tracking topLoadingFrame that can finish the test when it loads.
64// - WorkQueue holding load requests from the TestInterfaces
65// - LayoutTestRuntimeFlags
lukaszac9358822016-04-07 14:43:4666class TestRunner : public WebTestRunner {
[email protected]97f9a7952014-03-14 11:50:3367 public:
[email protected]79ecada2014-05-04 05:16:1668 explicit TestRunner(TestInterfaces*);
[email protected]97f9a7952014-03-14 11:50:3369 virtual ~TestRunner();
70
lukaszab2ad0502016-04-27 15:51:4271 void Install(blink::WebLocalFrame* frame,
72 base::WeakPtr<TestRunnerForSpecificView> view_test_runner);
[email protected]97f9a7952014-03-14 11:50:3373
[email protected]79ecada2014-05-04 05:16:1674 void SetDelegate(WebTestDelegate*);
lukasza8973c522016-04-27 16:32:2875 void SetMainView(blink::WebView*);
[email protected]97f9a7952014-03-14 11:50:3376
77 void Reset();
78
[email protected]97f9a7952014-03-14 11:50:3379 void SetTestIsRunning(bool);
80 bool TestIsRunning() const { return test_is_running_; }
81
82 bool UseMockTheme() const { return use_mock_theme_; }
83
84 // WebTestRunner implementation.
dchenge933b3e2014-10-21 11:44:0985 bool ShouldGeneratePixelResults() override;
86 bool ShouldDumpAsAudio() const override;
87 void GetAudioData(std::vector<unsigned char>* buffer_view) const override;
lukaszaef264fc52016-03-17 22:49:1988 bool IsRecursiveLayoutDumpRequested() override;
89 std::string DumpLayout(blink::WebLocalFrame* frame) override;
lukasza1b546c12016-04-04 16:19:2090 void DumpPixelsAsync(
91 blink::WebView* web_view,
92 const base::Callback<void(const SkBitmap&)>& callback) override;
lukasza083b4f12016-03-24 16:51:4393 void ReplicateLayoutTestRuntimeFlagsChanges(
lukaszac9cbe712016-03-14 14:06:4394 const base::DictionaryValue& changed_values) override;
lukaszaa8960462016-01-27 22:27:3395 bool HasCustomTextDump(std::string* custom_text_dump) const override;
dchenge933b3e2014-10-21 11:44:0996 bool ShouldDumpBackForwardList() const override;
mlamouri007f9d72015-02-27 16:27:2597 blink::WebContentSettingsClient* GetWebContentSettings() const override;
lukasza5c2279c2016-04-05 16:44:4798 void InitializeWebViewWithMocks(blink::WebView* web_view) override;
lukasza95416be142016-04-14 15:06:3399 void SetFocus(blink::WebView* web_view, bool focus) override;
[email protected]97f9a7952014-03-14 11:50:33100
lukasza01da2602016-04-05 14:51:26101 // Methods used by WebViewTestClient and WebFrameTestClient.
lukaszadf92022f2016-05-03 16:42:31102 void OnAnimationScheduled(blink::WebWidget* widget);
103 void OnAnimationBegun(blink::WebWidget* widget);
lukaszaa0b624a2016-04-04 15:00:49104 std::string GetAcceptLanguages() const;
lukaszae26c3d62016-03-14 23:30:59105 bool shouldStayOnPageAfterHandlingBeforeUnload() const;
lukasza6a113ae12016-03-17 22:41:20106 MockScreenOrientationClient* getMockScreenOrientationClient();
lukaszafd124602016-04-01 16:53:30107 MockWebUserMediaClient* getMockWebUserMediaClient();
lukasza01da2602016-04-05 14:51:26108 MockWebSpeechRecognizer* getMockWebSpeechRecognizer();
[email protected]97f9a7952014-03-14 11:50:33109 bool isPrinting() const;
[email protected]f24836a2014-05-06 01:02:44110 bool shouldDumpAsCustomText() const;
111 std:: string customDumpText() const;
abhishek.a21ca9b5602014-09-19 07:33:33112 void ShowDevTools(const std::string& settings,
[email protected]06c253012014-04-16 18:35:33113 const std::string& frontend_url);
abhishek.a21ca9b5602014-09-19 07:33:33114 void ClearDevToolsLocalStorage();
[email protected]97f9a7952014-03-14 11:50:33115 void setShouldDumpAsText(bool);
116 void setShouldDumpAsMarkup(bool);
ki.stfu939799a42015-09-28 04:41:20117 void setCustomTextOutput(const std::string& text);
[email protected]97f9a7952014-03-14 11:50:33118 void setShouldGeneratePixelResults(bool);
119 void setShouldDumpFrameLoadCallbacks(bool);
[email protected]97f9a7952014-03-14 11:50:33120 void setShouldEnableViewSource(bool);
121 bool shouldDumpEditingCallbacks() const;
122 bool shouldDumpFrameLoadCallbacks() const;
123 bool shouldDumpPingLoaderCallbacks() const;
124 bool shouldDumpUserGestureInFrameLoadCallbacks() const;
125 bool shouldDumpTitleChanges() const;
126 bool shouldDumpIconChanges() const;
127 bool shouldDumpCreateView() const;
128 bool canOpenWindows() const;
129 bool shouldDumpResourceLoadCallbacks() const;
[email protected]97f9a7952014-03-14 11:50:33130 bool shouldDumpResourceResponseMIMETypes() const;
131 bool shouldDumpStatusCallbacks() const;
[email protected]97f9a7952014-03-14 11:50:33132 bool shouldDumpSpellCheckCallbacks() const;
[email protected]a79cb9912014-04-26 22:07:33133 bool shouldWaitUntilExternalURLLoad() const;
[email protected]97f9a7952014-03-14 11:50:33134 const std::set<std::string>* httpHeadersToClear() const;
lukasza10cd8762016-04-27 20:03:02135
136 // To be called when |frame| starts loading - TestRunner will check if
137 // there is currently no top-loading-frame being tracked and if so, then it
138 // will return true and start tracking |frame| as the top-loading-frame.
139 bool tryToSetTopLoadingFrame(blink::WebFrame* frame);
140
141 // To be called when |frame| finishes loading - TestRunner will check if
142 // |frame| is currently tracked as the top-loading-frame, and if yes, then it
143 // will return true, stop top-loading-frame tracking, and potentially finish
144 // the test (unless testRunner.waitUntilDone() was called and/or there are
145 // pending load requests in WorkQueue).
146 bool tryToClearTopLoadingFrame(blink::WebFrame*);
147
[email protected]97f9a7952014-03-14 11:50:33148 blink::WebFrame* topLoadingFrame() const;
149 void policyDelegateDone();
150 bool policyDelegateEnabled() const;
151 bool policyDelegateIsPermissive() const;
152 bool policyDelegateShouldNotifyDone() const;
[email protected]97f9a7952014-03-14 11:50:33153 bool shouldDumpResourcePriorities() const;
[email protected]97f9a7952014-03-14 11:50:33154 void setToolTipText(const blink::WebString&);
lukasza1b546c12016-04-04 16:19:20155 void setDragImage(const blink::WebImage& drag_image);
jochenc3a98da12015-03-10 13:59:58156 bool shouldDumpNavigationPolicy() const;
[email protected]97f9a7952014-03-14 11:50:33157
158 bool midiAccessorResult();
159
lukaszafd124602016-04-01 16:53:30160 // Methods used by MockColorChooser:
161 void DidOpenChooser();
162 void DidCloseChooser();
163
caseqcb2227832016-05-24 18:52:04164 bool ShouldDumpConsoleMessages() const;
165
[email protected]97f9a7952014-03-14 11:50:33166 // A single item in the work queue.
167 class WorkItem {
168 public:
169 virtual ~WorkItem() {}
170
171 // Returns true if this started a load.
[email protected]79ecada2014-05-04 05:16:16172 virtual bool Run(WebTestDelegate*, blink::WebView*) = 0;
[email protected]97f9a7952014-03-14 11:50:33173 };
174
175 private:
[email protected]97f9a7952014-03-14 11:50:33176 friend class TestRunnerBindings;
177 friend class WorkQueue;
178
179 // Helper class for managing events queued by methods like queueLoad or
180 // queueScript.
181 class WorkQueue {
182 public:
183 explicit WorkQueue(TestRunner* controller);
184 virtual ~WorkQueue();
185 void ProcessWorkSoon();
186
187 // Reset the state of the class between tests.
188 void Reset();
189
190 void AddWork(WorkItem*);
191
192 void set_frozen(bool frozen) { frozen_ = frozen; }
193 bool is_empty() { return queue_.empty(); }
[email protected]97f9a7952014-03-14 11:50:33194
195 private:
196 void ProcessWork();
197
[email protected]97f9a7952014-03-14 11:50:33198 std::deque<WorkItem*> queue_;
199 bool frozen_;
200 TestRunner* controller_;
lukaszac9358822016-04-07 14:43:46201
202 base::WeakPtrFactory<WorkQueue> weak_factory_;
[email protected]97f9a7952014-03-14 11:50:33203 };
204
205 ///////////////////////////////////////////////////////////////////////////
206 // Methods dealing with the test logic
207
208 // By default, tests end when page load is complete. These methods are used
209 // to delay the completion of the test until notifyDone is called.
210 void NotifyDone();
211 void WaitUntilDone();
212
213 // Methods for adding actions to the work queue. Used in conjunction with
214 // waitUntilDone/notifyDone above.
215 void QueueBackNavigation(int how_far_back);
216 void QueueForwardNavigation(int how_far_forward);
217 void QueueReload();
218 void QueueLoadingScript(const std::string& script);
219 void QueueNonLoadingScript(const std::string& script);
220 void QueueLoad(const std::string& url, const std::string& target);
[email protected]97f9a7952014-03-14 11:50:33221
222 // Causes navigation actions just printout the intended navigation instead
223 // of taking you to the page. This is used for cases like mailto, where you
224 // don't actually want to open the mail program.
225 void SetCustomPolicyDelegate(gin::Arguments* args);
226
227 // Delays completion of the test until the policy delegate runs.
228 void WaitForPolicyDelegate();
229
230 // Functions for dealing with windows. By default we block all new windows.
231 int WindowCount();
232 void SetCloseRemainingWindowsWhenComplete(bool close_remaining_windows);
233 void ResetTestHelperControllers();
234
[email protected]97f9a7952014-03-14 11:50:33235 // Allows layout tests to manage origins' whitelisting.
236 void AddOriginAccessWhitelistEntry(const std::string& source_origin,
237 const std::string& destination_protocol,
238 const std::string& destination_host,
239 bool allow_destination_subdomains);
240 void RemoveOriginAccessWhitelistEntry(const std::string& source_origin,
241 const std::string& destination_protocol,
242 const std::string& destination_host,
243 bool allow_destination_subdomains);
244
dcheng9000dbd2015-04-03 05:39:40245 // Add |source_code| as an injected stylesheet to the active document of the
246 // window of the current V8 context.
247 void InsertStyleSheet(const std::string& source_code);
248
[email protected]97f9a7952014-03-14 11:50:33249 // Enables or disables subpixel positioning (i.e. fractional X positions for
250 // glyphs) in text rendering on Linux. Since this method changes global
251 // settings, tests that call it must use their own custom font family for
252 // all text that they render. If not, an already-cached style will be used,
253 // resulting in the changed setting being ignored.
254 void SetTextSubpixelPositioning(bool value);
255
[email protected]97f9a7952014-03-14 11:50:33256 // After this function is called, all window-sizing machinery is
257 // short-circuited inside the renderer. This mode is necessary for
258 // some tests that were written before browsers had multi-process architecture
259 // and rely on window resizes to happen synchronously.
260 // The function has "unfortunate" it its name because we must strive to remove
261 // all tests that rely on this... well, unfortunate behavior. See
262 // http://crbug.com/309760 for the plan.
263 void UseUnfortunateSynchronousResizeMode();
264
265 bool EnableAutoResizeMode(int min_width,
266 int min_height,
267 int max_width,
268 int max_height);
269 bool DisableAutoResizeMode(int new_width, int new_height);
270
[email protected]2ad7e622014-06-30 17:44:21271 void SetMockDeviceLight(double value);
272 void ResetDeviceLight();
[email protected]97f9a7952014-03-14 11:50:33273 // Device Motion / Device Orientation related functions
274 void SetMockDeviceMotion(bool has_acceleration_x, double acceleration_x,
275 bool has_acceleration_y, double acceleration_y,
276 bool has_acceleration_z, double acceleration_z,
277 bool has_acceleration_including_gravity_x,
278 double acceleration_including_gravity_x,
279 bool has_acceleration_including_gravity_y,
280 double acceleration_including_gravity_y,
281 bool has_acceleration_including_gravity_z,
282 double acceleration_including_gravity_z,
283 bool has_rotation_rate_alpha,
284 double rotation_rate_alpha,
285 bool has_rotation_rate_beta,
286 double rotation_rate_beta,
287 bool has_rotation_rate_gamma,
288 double rotation_rate_gamma,
289 double interval);
290 void SetMockDeviceOrientation(bool has_alpha, double alpha,
291 bool has_beta, double beta,
292 bool has_gamma, double gamma,
philipj97906452016-03-02 14:46:22293 bool absolute);
[email protected]97f9a7952014-03-14 11:50:33294
[email protected]e0bc2cb2014-03-20 17:34:24295 void SetMockScreenOrientation(const std::string& orientation);
dgozman3c16f7f2016-02-26 01:21:18296 void DisableMockScreenOrientation();
[email protected]e0bc2cb2014-03-20 17:34:24297
[email protected]97f9a7952014-03-14 11:50:33298 ///////////////////////////////////////////////////////////////////////////
299 // Methods modifying WebPreferences.
300
301 // Set the WebPreference that controls webkit's popup blocking.
302 void SetPopupBlockingEnabled(bool block_popups);
303
304 void SetJavaScriptCanAccessClipboard(bool can_access);
305 void SetXSSAuditorEnabled(bool enabled);
306 void SetAllowUniversalAccessFromFileURLs(bool allow);
307 void SetAllowFileAccessFromFileURLs(bool allow);
ki.stfu939799a42015-09-28 04:41:20308 void OverridePreference(const std::string& key, v8::Local<v8::Value> value);
[email protected]97f9a7952014-03-14 11:50:33309
[email protected]ebd5ea52014-05-28 14:51:15310 // Modify accept_languages in RendererPreferences.
311 void SetAcceptLanguages(const std::string& accept_languages);
312
[email protected]97f9a7952014-03-14 11:50:33313 // Enable or disable plugins.
314 void SetPluginsEnabled(bool enabled);
315
lukasza01da2602016-04-05 14:51:26316 // Returns |true| if an animation has been scheduled in one or more WebViews
317 // participating in the layout test.
318 bool GetAnimationScheduled() const;
chrishtraea6066d2016-02-19 04:49:12319
[email protected]97f9a7952014-03-14 11:50:33320 ///////////////////////////////////////////////////////////////////////////
321 // Methods that modify the state of TestRunner
322
323 // This function sets a flag that tells the test_shell to print a line of
324 // descriptive text for each editing command. It takes no arguments, and
325 // ignores any that may be present.
326 void DumpEditingCallbacks();
327
328 // This function sets a flag that tells the test_shell to dump pages as
329 // plain text, rather than as a text representation of the renderer's state.
330 // The pixel results will not be generated for this test.
331 void DumpAsText();
332
333 // This function sets a flag that tells the test_shell to dump pages as
[email protected]fdc433c02014-06-02 19:27:14334 // the DOM contents, rather than as a text representation of the renderer's
335 // state. The pixel results will not be generated for this test.
336 void DumpAsMarkup();
337
338 // This function sets a flag that tells the test_shell to dump pages as
[email protected]97f9a7952014-03-14 11:50:33339 // plain text, rather than as a text representation of the renderer's state.
340 // It will also generate a pixel dump for the test.
341 void DumpAsTextWithPixelResults();
342
343 // This function sets a flag that tells the test_shell to print out the
344 // scroll offsets of the child frames. It ignores all.
345 void DumpChildFrameScrollPositions();
346
347 // This function sets a flag that tells the test_shell to recursively
348 // dump all frames as plain text if the DumpAsText flag is set.
349 // It takes no arguments, and ignores any that may be present.
350 void DumpChildFramesAsText();
351
[email protected]fdc433c02014-06-02 19:27:14352 // This function sets a flag that tells the test_shell to recursively
353 // dump all frames as the DOM contents if the DumpAsMarkup flag is set.
354 // It takes no arguments, and ignores any that may be present.
355 void DumpChildFramesAsMarkup();
356
[email protected]97f9a7952014-03-14 11:50:33357 // This function sets a flag that tells the test_shell to print out the
358 // information about icon changes notifications from WebKit.
359 void DumpIconChanges();
360
361 // Deals with Web Audio WAV file data.
362 void SetAudioData(const gin::ArrayBufferView& view);
363
364 // This function sets a flag that tells the test_shell to print a line of
365 // descriptive text for each frame load callback. It takes no arguments, and
366 // ignores any that may be present.
367 void DumpFrameLoadCallbacks();
368
369 // This function sets a flag that tells the test_shell to print a line of
370 // descriptive text for each PingLoader dispatch. It takes no arguments, and
371 // ignores any that may be present.
372 void DumpPingLoaderCallbacks();
373
374 // This function sets a flag that tells the test_shell to print a line of
375 // user gesture status text for some frame load callbacks. It takes no
376 // arguments, and ignores any that may be present.
377 void DumpUserGestureInFrameLoadCallbacks();
378
379 void DumpTitleChanges();
380
381 // This function sets a flag that tells the test_shell to dump all calls to
382 // WebViewClient::createView().
383 // It takes no arguments, and ignores any that may be present.
384 void DumpCreateView();
385
386 void SetCanOpenWindows();
387
388 // This function sets a flag that tells the test_shell to dump a descriptive
389 // line for each resource load callback. It takes no arguments, and ignores
390 // any that may be present.
391 void DumpResourceLoadCallbacks();
392
[email protected]97f9a7952014-03-14 11:50:33393 // This function sets a flag that tells the test_shell to dump the MIME type
394 // for each resource that was loaded. It takes no arguments, and ignores any
395 // that may be present.
396 void DumpResourceResponseMIMETypes();
397
mlamouri007f9d72015-02-27 16:27:25398 // WebContentSettingsClient related.
[email protected]97f9a7952014-03-14 11:50:33399 void SetImagesAllowed(bool allowed);
[email protected]97f9a7952014-03-14 11:50:33400 void SetScriptsAllowed(bool allowed);
401 void SetStorageAllowed(bool allowed);
402 void SetPluginsAllowed(bool allowed);
403 void SetAllowDisplayOfInsecureContent(bool allowed);
404 void SetAllowRunningOfInsecureContent(bool allowed);
mlamouri426f2862016-04-29 18:35:01405 void SetAutoplayAllowed(bool allowed);
[email protected]97f9a7952014-03-14 11:50:33406 void DumpPermissionClientCallbacks();
407
408 // This function sets a flag that tells the test_shell to dump all calls
409 // to window.status().
410 // It takes no arguments, and ignores any that may be present.
411 void DumpWindowStatusChanges();
412
[email protected]97f9a7952014-03-14 11:50:33413 // This function sets a flag that tells the test_shell to dump all
414 // the lines of descriptive text about spellcheck execution.
415 void DumpSpellCheckCallbacks();
416
417 // This function sets a flag that tells the test_shell to print out a text
418 // representation of the back/forward list. It ignores all arguments.
419 void DumpBackForwardList();
420
421 void DumpSelectionRect();
[email protected]97f9a7952014-03-14 11:50:33422
423 // Causes layout to happen as if targetted to printed pages.
424 void SetPrinting();
425
[email protected]52846102014-06-24 04:26:44426 // Clears the state from SetPrinting().
427 void ClearPrinting();
428
[email protected]97f9a7952014-03-14 11:50:33429 void SetShouldStayOnPageAfterHandlingBeforeUnload(bool value);
430
431 // Causes WillSendRequest to clear certain headers.
432 void SetWillSendRequestClearHeader(const std::string& header);
433
434 // This function sets a flag that tells the test_shell to dump a descriptive
435 // line for each resource load's priority and any time that priority
436 // changes. It takes no arguments, and ignores any that may be present.
437 void DumpResourceRequestPriorities();
438
439 // Sets a flag to enable the mock theme.
440 void SetUseMockTheme(bool use);
441
[email protected]a79cb9912014-04-26 22:07:33442 // Sets a flag that causes the test to be marked as completed when the
443 // WebFrameClient receives a loadURLExternally() call.
444 void WaitUntilExternalURLLoad();
445
lukasza1b546c12016-04-04 16:19:20446 // This function sets a flag to dump the drag image when the next drag&drop is
447 // initiated. It is equivalent to DumpAsTextWithPixelResults but the pixel
448 // results will be the drag image instead of a snapshot of the page.
jackhou656fc852015-02-13 09:04:17449 void DumpDragImage();
450
jochenc3a98da12015-03-10 13:59:58451 // Sets a flag that tells the WebTestProxy to dump the default navigation
452 // policy passed to the decidePolicyForNavigation callback.
453 void DumpNavigationPolicy();
454
caseqcb2227832016-05-24 18:52:04455 // Controls whether console messages produced by the page are dumped
456 // to test output.
457 void SetDumpConsoleMessages(bool value);
458
[email protected]97f9a7952014-03-14 11:50:33459 ///////////////////////////////////////////////////////////////////////////
460 // Methods interacting with the WebTestProxy
461
462 ///////////////////////////////////////////////////////////////////////////
463 // Methods forwarding to the WebTestDelegate
464
465 // Shows DevTools window.
[email protected]06c253012014-04-16 18:35:33466 void ShowWebInspector(const std::string& str,
467 const std::string& frontend_url);
[email protected]97f9a7952014-03-14 11:50:33468 void CloseWebInspector();
469
470 // Inspect chooser state
471 bool IsChooserShown();
472
473 // Allows layout tests to exec scripts at WebInspector side.
474 void EvaluateInWebInspector(int call_id, const std::string& script);
sergeyv0cd842b42015-10-09 16:07:11475 // Allows layout tests to evaluate scripts in InspectorOverlay page.
476 // Script may have an output represented as a string, return values of other
477 // types would be ignored.
478 std::string EvaluateInWebInspectorOverlay(const std::string& script);
[email protected]97f9a7952014-03-14 11:50:33479
480 // Clears all databases.
481 void ClearAllDatabases();
482 // Sets the default quota for all origins
483 void SetDatabaseQuota(int quota);
484
485 // Changes the cookie policy from the default to allow all cookies.
486 void SetAlwaysAcceptCookies(bool accept);
487
[email protected]97f9a7952014-03-14 11:50:33488 // Converts a URL starting with file:///tmp/ to the local mapping.
489 std::string PathToLocalResource(const std::string& path);
490
mlamourid5098d02015-04-21 12:17:30491 // Sets the permission's |name| to |value| for a given {origin, embedder}
492 // tuple.
493 void SetPermission(const std::string& name,
494 const std::string& value,
495 const GURL& origin,
496 const GURL& embedding_origin);
497
benwells0c0d3f12015-05-25 01:03:17498 // Resolve the beforeinstallprompt event with the matching request id.
499 void ResolveBeforeInstallPromptPromise(int request_id,
500 const std::string& platform);
501
[email protected]97f9a7952014-03-14 11:50:33502 // Calls setlocale(LC_ALL, ...) for a specified locale.
503 // Resets between tests.
504 void SetPOSIXLocale(const std::string& locale);
505
506 // MIDI function to control permission handling.
507 void SetMIDIAccessorResult(bool result);
[email protected]97f9a7952014-03-14 11:50:33508
peterd98157d2014-11-20 13:15:01509 // Simulates a click on a Web Notification.
johnme96d50122015-08-07 15:33:21510 void SimulateWebNotificationClick(const std::string& title, int action_index);
[email protected]97f9a7952014-03-14 11:50:33511
nsatragno24bd34b2016-02-09 10:30:02512 // Simulates closing a Web Notification.
513 void SimulateWebNotificationClose(const std::string& title, bool by_user);
514
[email protected]56e365d42014-05-02 22:18:24515 // Speech recognition related functions.
[email protected]97f9a7952014-03-14 11:50:33516 void AddMockSpeechRecognitionResult(const std::string& transcript,
517 double confidence);
518 void SetMockSpeechRecognitionError(const std::string& error,
519 const std::string& message);
[email protected]97f9a7952014-03-14 11:50:33520
mkwst41667ab2014-09-16 06:52:43521 // Credential Manager mock functions
522 // TODO(mkwst): Support FederatedCredential.
523 void AddMockCredentialManagerResponse(const std::string& id,
524 const std::string& name,
525 const std::string& avatar,
526 const std::string& password);
mkwst008acce62016-03-11 13:02:01527 void AddMockCredentialManagerError(const std::string& error);
mkwst41667ab2014-09-16 06:52:43528
lukasza083b4f12016-03-24 16:51:43529 // Takes care of notifying the delegate after a change to layout test runtime
530 // flags.
531 void OnLayoutTestRuntimeFlagsChanged();
lukaszac9cbe712016-03-14 14:06:43532
[email protected]97f9a7952014-03-14 11:50:33533 ///////////////////////////////////////////////////////////////////////////
534 // Internal helpers
[email protected]eec9e78e2014-06-16 21:38:48535
lukasza10cd8762016-04-27 20:03:02536 bool IsFramePartOfMainTestWindow(blink::WebFrame*) const;
537
[email protected]97f9a7952014-03-14 11:50:33538 void CheckResponseMimeType();
539 void CompleteNotifyDone();
540
[email protected]97f9a7952014-03-14 11:50:33541 // In the Mac code, this is called to trigger the end of a test after the
542 // page has finished loading. From here, we can generate the dump for the
543 // test.
544 void LocationChangeDone();
545
546 bool test_is_running_;
547
548 // When reset is called, go through and close all but the main test shell
549 // window. By default, set to true but toggled to false using
550 // setCloseRemainingWindowsWhenComplete().
551 bool close_remaining_windows_;
552
[email protected]97f9a7952014-03-14 11:50:33553 WorkQueue work_queue_;
554
[email protected]97f9a7952014-03-14 11:50:33555 // Bound variable to return the name of this platform (chromium).
556 std::string platform_name_;
557
558 // Bound variable to store the last tooltip text
559 std::string tooltip_text_;
560
[email protected]97f9a7952014-03-14 11:50:33561 // Bound variable counting the number of top URLs visited.
562 int web_history_item_count_;
563
lukasza9b9d70e2016-02-25 23:45:44564 // Flags controlling what content gets dumped as a layout text result.
lukasza083b4f12016-03-24 16:51:43565 LayoutTestRuntimeFlags layout_test_runtime_flags_;
[email protected]97f9a7952014-03-14 11:50:33566
[email protected]97f9a7952014-03-14 11:50:33567 // If true, the test_shell will output a base64 encoded WAVE file.
568 bool dump_as_audio_;
569
[email protected]97f9a7952014-03-14 11:50:33570 // If true, output a descriptive line each time WebViewClient::createView
571 // is invoked.
572 bool dump_create_view_;
573
574 // If true, new windows can be opened via javascript or by plugins. By
575 // default, set to false and can be toggled to true using
576 // setCanOpenWindows().
577 bool can_open_windows_;
578
[email protected]97f9a7952014-03-14 11:50:33579 // If true, the test_shell will dump all changes to window.status.
580 bool dump_window_status_changes_;
581
[email protected]97f9a7952014-03-14 11:50:33582 // If true, the test_shell will output descriptive test for spellcheck
583 // execution.
584 bool dump_spell_check_callbacks_;
585
586 // If true, the test_shell will produce a dump of the back forward list as
587 // well.
588 bool dump_back_forward_list_;
589
[email protected]97f9a7952014-03-14 11:50:33590 // If true, pixel dump will be produced as a series of 1px-tall, view-wide
591 // individual paints over the height of the view.
592 bool test_repaint_;
593
594 // If true and test_repaint_ is true as well, pixel dump will be produced as
595 // a series of 1px-wide, view-tall paints across the width of the view.
596 bool sweep_horizontally_;
597
[email protected]97f9a7952014-03-14 11:50:33598 // If false, MockWebMIDIAccessor fails on startSession() for testing.
599 bool midi_accessor_result_;
600
[email protected]f24836a2014-05-06 01:02:44601 bool has_custom_text_output_;
602 std::string custom_text_output_;
603
[email protected]97f9a7952014-03-14 11:50:33604 std::set<std::string> http_headers_to_clear_;
605
606 // WAV audio data is stored here.
607 std::vector<unsigned char> audio_data_;
608
[email protected]79ecada2014-05-04 05:16:16609 TestInterfaces* test_interfaces_;
610 WebTestDelegate* delegate_;
lukasza8973c522016-04-27 16:32:28611 blink::WebView* main_view_;
[email protected]97f9a7952014-03-14 11:50:33612
613 // This is non-0 IFF a load is in progress.
614 blink::WebFrame* top_loading_frame_;
615
mlamouri007f9d72015-02-27 16:27:25616 // WebContentSettingsClient mock object.
dcheng82beb4f2016-04-26 00:35:02617 std::unique_ptr<MockContentSettingsClient> mock_content_settings_client_;
[email protected]97f9a7952014-03-14 11:50:33618
[email protected]97f9a7952014-03-14 11:50:33619 bool use_mock_theme_;
620
dcheng82beb4f2016-04-26 00:35:02621 std::unique_ptr<MockCredentialManagerClient> credential_manager_client_;
622 std::unique_ptr<MockScreenOrientationClient> mock_screen_orientation_client_;
623 std::unique_ptr<MockWebSpeechRecognizer> speech_recognizer_;
624 std::unique_ptr<MockWebUserMediaClient> user_media_client_;
625 std::unique_ptr<SpellCheckClient> spellcheck_;
lukaszafd124602016-04-01 16:53:30626
627 // Number of currently active color choosers.
628 int chooser_count_;
lukasza6a113ae12016-03-17 22:41:20629
lukasza1b546c12016-04-04 16:19:20630 // Captured drag image.
631 blink::WebImage drag_image_;
632
lukasza95416be142016-04-14 15:06:33633 // View that was focused by a previous call to TestRunner::SetFocus method.
634 // Note - this can be a dangling pointer to an already destroyed WebView (this
635 // is ok, because this is taken care of in WebTestDelegate::SetFocus).
636 blink::WebView* previously_focused_view_;
637
lukaszadf92022f2016-05-03 16:42:31638 std::set<blink::WebWidget*> widgets_with_scheduled_animations_;
lukasza01da2602016-04-05 14:51:26639
[email protected]97f9a7952014-03-14 11:50:33640 base::WeakPtrFactory<TestRunner> weak_factory_;
641
642 DISALLOW_COPY_AND_ASSIGN(TestRunner);
643};
644
jochenf5f31752015-06-03 12:06:34645} // namespace test_runner
[email protected]97f9a7952014-03-14 11:50:33646
jochen73e711c2015-06-03 10:01:46647#endif // COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_