blob: d4f3ed99bc7f7a72978c139e7c76dced2b670da3 [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>
11#include <set>
12#include <string>
benwells0c0d3f12015-05-25 01:03:1713#include <vector>
[email protected]97f9a7952014-03-14 11:50:3314
avi5dd91f82015-12-25 22:30:4615#include "base/macros.h"
[email protected]97f9a7952014-03-14 11:50:3316#include "base/memory/scoped_ptr.h"
17#include "base/memory/weak_ptr.h"
lukasza9b9d70e2016-02-25 23:45:4418#include "components/test_runner/layout_dump_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_task.h"
21#include "components/test_runner/web_test_runner.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;
mcasas43ff56ff2015-10-08 05:24:3730class WebMediaStream;
[email protected]97f9a7952014-03-14 11:50:3331class WebString;
32class WebView;
kenneth.r.christiansen1a4946d2014-09-25 16:11:0633class WebURLResponse;
[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
[email protected]97d3fe8b2014-04-05 02:40:0043class InvokeCallbackTask;
lukasza6a113ae12016-03-17 22:41:2044class MockScreenOrientationClient;
[email protected]79ecada2014-05-04 05:16:1645class TestInterfaces;
mlamouri007f9d72015-02-27 16:27:2546class WebContentSettings;
[email protected]79ecada2014-05-04 05:16:1647class WebTestDelegate;
[email protected]a2ec0bc2014-04-23 08:18:2748class WebTestProxyBase;
[email protected]97f9a7952014-03-14 11:50:3349
[email protected]79ecada2014-05-04 05:16:1650class TestRunner : public WebTestRunner,
[email protected]97f9a7952014-03-14 11:50:3351 public base::SupportsWeakPtr<TestRunner> {
52 public:
[email protected]79ecada2014-05-04 05:16:1653 explicit TestRunner(TestInterfaces*);
[email protected]97f9a7952014-03-14 11:50:3354 virtual ~TestRunner();
55
56 void Install(blink::WebFrame* frame);
57
[email protected]79ecada2014-05-04 05:16:1658 void SetDelegate(WebTestDelegate*);
[email protected]a2ec0bc2014-04-23 08:18:2759 void SetWebView(blink::WebView*, WebTestProxyBase*);
[email protected]97f9a7952014-03-14 11:50:3360
61 void Reset();
62
[email protected]a1640e42014-05-14 13:43:3263 WebTaskList* mutable_task_list() { return &task_list_; }
[email protected]97f9a7952014-03-14 11:50:3364
65 void SetTestIsRunning(bool);
66 bool TestIsRunning() const { return test_is_running_; }
67
68 bool UseMockTheme() const { return use_mock_theme_; }
69
[email protected]97d3fe8b2014-04-05 02:40:0070 void InvokeCallback(scoped_ptr<InvokeCallbackTask> callback);
71
[email protected]97f9a7952014-03-14 11:50:3372 // WebTestRunner implementation.
dchenge933b3e2014-10-21 11:44:0973 bool ShouldGeneratePixelResults() override;
dchenge933b3e2014-10-21 11:44:0974 bool ShouldDumpAsAudio() const override;
75 void GetAudioData(std::vector<unsigned char>* buffer_view) const override;
lukaszaef264fc52016-03-17 22:49:1976 bool IsRecursiveLayoutDumpRequested() override;
77 std::string DumpLayout(blink::WebLocalFrame* frame) override;
lukaszac9cbe712016-03-14 14:06:4378 void ReplicateLayoutDumpFlagsChanges(
79 const base::DictionaryValue& changed_values) override;
lukaszaa8960462016-01-27 22:27:3380 bool HasCustomTextDump(std::string* custom_text_dump) const override;
dchenge933b3e2014-10-21 11:44:0981 bool ShouldDumpBackForwardList() const override;
mlamouri007f9d72015-02-27 16:27:2582 blink::WebContentSettingsClient* GetWebContentSettings() const override;
[email protected]97f9a7952014-03-14 11:50:3383
84 // Methods used by WebTestProxyBase.
lukaszae26c3d62016-03-14 23:30:5985 bool shouldStayOnPageAfterHandlingBeforeUnload() const;
lukasza6a113ae12016-03-17 22:41:2086 MockScreenOrientationClient* getMockScreenOrientationClient();
[email protected]97f9a7952014-03-14 11:50:3387 bool shouldDumpSelectionRect() const;
[email protected]97f9a7952014-03-14 11:50:3388 bool isPrinting() const;
[email protected]97f9a7952014-03-14 11:50:3389 bool shouldDumpAsTextWithPixelResults();
[email protected]f24836a2014-05-06 01:02:4490 bool shouldDumpAsCustomText() const;
91 std:: string customDumpText() const;
abhishek.a21ca9b5602014-09-19 07:33:3392 void ShowDevTools(const std::string& settings,
[email protected]06c253012014-04-16 18:35:3393 const std::string& frontend_url);
abhishek.a21ca9b5602014-09-19 07:33:3394 void ClearDevToolsLocalStorage();
[email protected]97f9a7952014-03-14 11:50:3395 void setShouldDumpAsText(bool);
96 void setShouldDumpAsMarkup(bool);
ki.stfu939799a42015-09-28 04:41:2097 void setCustomTextOutput(const std::string& text);
[email protected]97f9a7952014-03-14 11:50:3398 void setShouldGeneratePixelResults(bool);
99 void setShouldDumpFrameLoadCallbacks(bool);
100 void setShouldDumpPingLoaderCallbacks(bool);
101 void setShouldEnableViewSource(bool);
102 bool shouldDumpEditingCallbacks() const;
103 bool shouldDumpFrameLoadCallbacks() const;
104 bool shouldDumpPingLoaderCallbacks() const;
105 bool shouldDumpUserGestureInFrameLoadCallbacks() const;
106 bool shouldDumpTitleChanges() const;
107 bool shouldDumpIconChanges() const;
108 bool shouldDumpCreateView() const;
109 bool canOpenWindows() const;
110 bool shouldDumpResourceLoadCallbacks() const;
111 bool shouldDumpResourceRequestCallbacks() const;
112 bool shouldDumpResourceResponseMIMETypes() const;
113 bool shouldDumpStatusCallbacks() const;
[email protected]97f9a7952014-03-14 11:50:33114 bool shouldDumpSpellCheckCallbacks() const;
[email protected]a79cb9912014-04-26 22:07:33115 bool shouldWaitUntilExternalURLLoad() const;
[email protected]97f9a7952014-03-14 11:50:33116 const std::set<std::string>* httpHeadersToClear() const;
117 void setTopLoadingFrame(blink::WebFrame*, bool);
118 blink::WebFrame* topLoadingFrame() const;
119 void policyDelegateDone();
120 bool policyDelegateEnabled() const;
121 bool policyDelegateIsPermissive() const;
122 bool policyDelegateShouldNotifyDone() const;
123 bool shouldInterceptPostMessage() const;
124 bool shouldDumpResourcePriorities() const;
[email protected]97f9a7952014-03-14 11:50:33125 bool RequestPointerLock();
126 void RequestPointerUnlock();
127 bool isPointerLocked();
128 void setToolTipText(const blink::WebString&);
jackhou656fc852015-02-13 09:04:17129 bool shouldDumpDragImage();
jochenc3a98da12015-03-10 13:59:58130 bool shouldDumpNavigationPolicy() const;
[email protected]97f9a7952014-03-14 11:50:33131
132 bool midiAccessorResult();
133
134 // A single item in the work queue.
135 class WorkItem {
136 public:
137 virtual ~WorkItem() {}
138
139 // Returns true if this started a load.
[email protected]79ecada2014-05-04 05:16:16140 virtual bool Run(WebTestDelegate*, blink::WebView*) = 0;
[email protected]97f9a7952014-03-14 11:50:33141 };
142
143 private:
144 friend class InvokeCallbackTask;
145 friend class TestRunnerBindings;
146 friend class WorkQueue;
147
148 // Helper class for managing events queued by methods like queueLoad or
149 // queueScript.
150 class WorkQueue {
151 public:
152 explicit WorkQueue(TestRunner* controller);
153 virtual ~WorkQueue();
154 void ProcessWorkSoon();
155
156 // Reset the state of the class between tests.
157 void Reset();
158
159 void AddWork(WorkItem*);
160
161 void set_frozen(bool frozen) { frozen_ = frozen; }
162 bool is_empty() { return queue_.empty(); }
[email protected]a1640e42014-05-14 13:43:32163 WebTaskList* mutable_task_list() { return &task_list_; }
[email protected]97f9a7952014-03-14 11:50:33164
165 private:
166 void ProcessWork();
167
[email protected]79ecada2014-05-04 05:16:16168 class WorkQueueTask : public WebMethodTask<WorkQueue> {
[email protected]97f9a7952014-03-14 11:50:33169 public:
[email protected]79ecada2014-05-04 05:16:16170 WorkQueueTask(WorkQueue* object) : WebMethodTask<WorkQueue>(object) {}
[email protected]97f9a7952014-03-14 11:50:33171
dchenge933b3e2014-10-21 11:44:09172 void RunIfValid() override;
[email protected]97f9a7952014-03-14 11:50:33173 };
174
[email protected]79ecada2014-05-04 05:16:16175 WebTaskList task_list_;
[email protected]97f9a7952014-03-14 11:50:33176 std::deque<WorkItem*> queue_;
177 bool frozen_;
178 TestRunner* controller_;
179 };
180
181 ///////////////////////////////////////////////////////////////////////////
182 // Methods dealing with the test logic
183
184 // By default, tests end when page load is complete. These methods are used
185 // to delay the completion of the test until notifyDone is called.
186 void NotifyDone();
187 void WaitUntilDone();
188
189 // Methods for adding actions to the work queue. Used in conjunction with
190 // waitUntilDone/notifyDone above.
191 void QueueBackNavigation(int how_far_back);
192 void QueueForwardNavigation(int how_far_forward);
193 void QueueReload();
194 void QueueLoadingScript(const std::string& script);
195 void QueueNonLoadingScript(const std::string& script);
196 void QueueLoad(const std::string& url, const std::string& target);
197 void QueueLoadHTMLString(gin::Arguments* args);
198
199 // Causes navigation actions just printout the intended navigation instead
200 // of taking you to the page. This is used for cases like mailto, where you
201 // don't actually want to open the mail program.
202 void SetCustomPolicyDelegate(gin::Arguments* args);
203
204 // Delays completion of the test until the policy delegate runs.
205 void WaitForPolicyDelegate();
206
207 // Functions for dealing with windows. By default we block all new windows.
208 int WindowCount();
209 void SetCloseRemainingWindowsWhenComplete(bool close_remaining_windows);
210 void ResetTestHelperControllers();
211
212 ///////////////////////////////////////////////////////////////////////////
213 // Methods implemented entirely in terms of chromium's public WebKit API
214
215 // Method that controls whether pressing Tab key cycles through page elements
216 // or inserts a '\t' char in text area
217 void SetTabKeyCyclesThroughElements(bool tab_key_cycles_through_elements);
218
219 // Executes an internal command (superset of document.execCommand() commands).
220 void ExecCommand(gin::Arguments* args);
221
222 // Checks if an internal command is currently available.
223 bool IsCommandEnabled(const std::string& command);
224
225 bool CallShouldCloseOnWebView();
226 void SetDomainRelaxationForbiddenForURLScheme(bool forbidden,
227 const std::string& scheme);
deepak.s750d68f2015-04-30 07:32:41228 v8::Local<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue(
[email protected]97f9a7952014-03-14 11:50:33229 int world_id, const std::string& script);
230 void EvaluateScriptInIsolatedWorld(int world_id, const std::string& script);
231 void SetIsolatedWorldSecurityOrigin(int world_id,
deepak.s750d68f2015-04-30 07:32:41232 v8::Local<v8::Value> origin);
[email protected]97f9a7952014-03-14 11:50:33233 void SetIsolatedWorldContentSecurityPolicy(int world_id,
234 const std::string& policy);
235
236 // Allows layout tests to manage origins' whitelisting.
237 void AddOriginAccessWhitelistEntry(const std::string& source_origin,
238 const std::string& destination_protocol,
239 const std::string& destination_host,
240 bool allow_destination_subdomains);
241 void RemoveOriginAccessWhitelistEntry(const std::string& source_origin,
242 const std::string& destination_protocol,
243 const std::string& destination_host,
244 bool allow_destination_subdomains);
245
246 // Returns true if the current page box has custom page size style for
247 // printing.
248 bool HasCustomPageSizeStyle(int page_index);
249
250 // Forces the selection colors for testing under Linux.
251 void ForceRedSelectionColors();
252
dcheng9000dbd2015-04-03 05:39:40253 // Add |source_code| as an injected stylesheet to the active document of the
254 // window of the current V8 context.
255 void InsertStyleSheet(const std::string& source_code);
256
[email protected]97f9a7952014-03-14 11:50:33257 bool FindString(const std::string& search_text,
258 const std::vector<std::string>& options_array);
259
260 std::string SelectionAsMarkup();
261
262 // Enables or disables subpixel positioning (i.e. fractional X positions for
263 // glyphs) in text rendering on Linux. Since this method changes global
264 // settings, tests that call it must use their own custom font family for
265 // all text that they render. If not, an already-cached style will be used,
266 // resulting in the changed setting being ignored.
267 void SetTextSubpixelPositioning(bool value);
268
269 // Switch the visibility of the page.
270 void SetPageVisibility(const std::string& new_visibility);
271
272 // Changes the direction of the focused element.
273 void SetTextDirection(const std::string& direction_name);
274
275 // After this function is called, all window-sizing machinery is
276 // short-circuited inside the renderer. This mode is necessary for
277 // some tests that were written before browsers had multi-process architecture
278 // and rely on window resizes to happen synchronously.
279 // The function has "unfortunate" it its name because we must strive to remove
280 // all tests that rely on this... well, unfortunate behavior. See
281 // http://crbug.com/309760 for the plan.
282 void UseUnfortunateSynchronousResizeMode();
283
284 bool EnableAutoResizeMode(int min_width,
285 int min_height,
286 int max_width,
287 int max_height);
288 bool DisableAutoResizeMode(int new_width, int new_height);
289
[email protected]2ad7e622014-06-30 17:44:21290 void SetMockDeviceLight(double value);
291 void ResetDeviceLight();
[email protected]97f9a7952014-03-14 11:50:33292 // Device Motion / Device Orientation related functions
293 void SetMockDeviceMotion(bool has_acceleration_x, double acceleration_x,
294 bool has_acceleration_y, double acceleration_y,
295 bool has_acceleration_z, double acceleration_z,
296 bool has_acceleration_including_gravity_x,
297 double acceleration_including_gravity_x,
298 bool has_acceleration_including_gravity_y,
299 double acceleration_including_gravity_y,
300 bool has_acceleration_including_gravity_z,
301 double acceleration_including_gravity_z,
302 bool has_rotation_rate_alpha,
303 double rotation_rate_alpha,
304 bool has_rotation_rate_beta,
305 double rotation_rate_beta,
306 bool has_rotation_rate_gamma,
307 double rotation_rate_gamma,
308 double interval);
309 void SetMockDeviceOrientation(bool has_alpha, double alpha,
310 bool has_beta, double beta,
311 bool has_gamma, double gamma,
philipj97906452016-03-02 14:46:22312 bool absolute);
[email protected]97f9a7952014-03-14 11:50:33313
[email protected]e0bc2cb2014-03-20 17:34:24314 void SetMockScreenOrientation(const std::string& orientation);
dgozman3c16f7f2016-02-26 01:21:18315 void DisableMockScreenOrientation();
[email protected]e0bc2cb2014-03-20 17:34:24316
[email protected]97f9a7952014-03-14 11:50:33317 void DidAcquirePointerLock();
318 void DidNotAcquirePointerLock();
319 void DidLosePointerLock();
320 void SetPointerLockWillFailSynchronously();
321 void SetPointerLockWillRespondAsynchronously();
322
323 ///////////////////////////////////////////////////////////////////////////
324 // Methods modifying WebPreferences.
325
326 // Set the WebPreference that controls webkit's popup blocking.
327 void SetPopupBlockingEnabled(bool block_popups);
328
329 void SetJavaScriptCanAccessClipboard(bool can_access);
330 void SetXSSAuditorEnabled(bool enabled);
331 void SetAllowUniversalAccessFromFileURLs(bool allow);
332 void SetAllowFileAccessFromFileURLs(bool allow);
ki.stfu939799a42015-09-28 04:41:20333 void OverridePreference(const std::string& key, v8::Local<v8::Value> value);
[email protected]97f9a7952014-03-14 11:50:33334
[email protected]ebd5ea52014-05-28 14:51:15335 // Modify accept_languages in RendererPreferences.
336 void SetAcceptLanguages(const std::string& accept_languages);
337
[email protected]97f9a7952014-03-14 11:50:33338 // Enable or disable plugins.
339 void SetPluginsEnabled(bool enabled);
340
chrishtraea6066d2016-02-19 04:49:12341 bool AnimationScheduled();
342
[email protected]97f9a7952014-03-14 11:50:33343 ///////////////////////////////////////////////////////////////////////////
344 // Methods that modify the state of TestRunner
345
346 // This function sets a flag that tells the test_shell to print a line of
347 // descriptive text for each editing command. It takes no arguments, and
348 // ignores any that may be present.
349 void DumpEditingCallbacks();
350
351 // This function sets a flag that tells the test_shell to dump pages as
352 // plain text, rather than as a text representation of the renderer's state.
353 // The pixel results will not be generated for this test.
354 void DumpAsText();
355
356 // This function sets a flag that tells the test_shell to dump pages as
[email protected]fdc433c02014-06-02 19:27:14357 // the DOM contents, rather than as a text representation of the renderer's
358 // state. The pixel results will not be generated for this test.
359 void DumpAsMarkup();
360
361 // This function sets a flag that tells the test_shell to dump pages as
[email protected]97f9a7952014-03-14 11:50:33362 // plain text, rather than as a text representation of the renderer's state.
363 // It will also generate a pixel dump for the test.
364 void DumpAsTextWithPixelResults();
365
366 // This function sets a flag that tells the test_shell to print out the
367 // scroll offsets of the child frames. It ignores all.
368 void DumpChildFrameScrollPositions();
369
370 // This function sets a flag that tells the test_shell to recursively
371 // dump all frames as plain text if the DumpAsText flag is set.
372 // It takes no arguments, and ignores any that may be present.
373 void DumpChildFramesAsText();
374
[email protected]fdc433c02014-06-02 19:27:14375 // This function sets a flag that tells the test_shell to recursively
376 // dump all frames as the DOM contents if the DumpAsMarkup flag is set.
377 // It takes no arguments, and ignores any that may be present.
378 void DumpChildFramesAsMarkup();
379
[email protected]97f9a7952014-03-14 11:50:33380 // This function sets a flag that tells the test_shell to print out the
381 // information about icon changes notifications from WebKit.
382 void DumpIconChanges();
383
384 // Deals with Web Audio WAV file data.
385 void SetAudioData(const gin::ArrayBufferView& view);
386
387 // This function sets a flag that tells the test_shell to print a line of
388 // descriptive text for each frame load callback. It takes no arguments, and
389 // ignores any that may be present.
390 void DumpFrameLoadCallbacks();
391
392 // This function sets a flag that tells the test_shell to print a line of
393 // descriptive text for each PingLoader dispatch. It takes no arguments, and
394 // ignores any that may be present.
395 void DumpPingLoaderCallbacks();
396
397 // This function sets a flag that tells the test_shell to print a line of
398 // user gesture status text for some frame load callbacks. It takes no
399 // arguments, and ignores any that may be present.
400 void DumpUserGestureInFrameLoadCallbacks();
401
402 void DumpTitleChanges();
403
404 // This function sets a flag that tells the test_shell to dump all calls to
405 // WebViewClient::createView().
406 // It takes no arguments, and ignores any that may be present.
407 void DumpCreateView();
408
409 void SetCanOpenWindows();
410
411 // This function sets a flag that tells the test_shell to dump a descriptive
412 // line for each resource load callback. It takes no arguments, and ignores
413 // any that may be present.
414 void DumpResourceLoadCallbacks();
415
416 // This function sets a flag that tells the test_shell to print a line of
417 // descriptive text for each element that requested a resource. It takes no
418 // arguments, and ignores any that may be present.
419 void DumpResourceRequestCallbacks();
420
421 // This function sets a flag that tells the test_shell to dump the MIME type
422 // for each resource that was loaded. It takes no arguments, and ignores any
423 // that may be present.
424 void DumpResourceResponseMIMETypes();
425
mlamouri007f9d72015-02-27 16:27:25426 // WebContentSettingsClient related.
[email protected]97f9a7952014-03-14 11:50:33427 void SetImagesAllowed(bool allowed);
[email protected]e19024b92014-06-10 11:10:37428 void SetMediaAllowed(bool allowed);
[email protected]97f9a7952014-03-14 11:50:33429 void SetScriptsAllowed(bool allowed);
430 void SetStorageAllowed(bool allowed);
431 void SetPluginsAllowed(bool allowed);
432 void SetAllowDisplayOfInsecureContent(bool allowed);
433 void SetAllowRunningOfInsecureContent(bool allowed);
434 void DumpPermissionClientCallbacks();
435
436 // This function sets a flag that tells the test_shell to dump all calls
437 // to window.status().
438 // It takes no arguments, and ignores any that may be present.
439 void DumpWindowStatusChanges();
440
[email protected]97f9a7952014-03-14 11:50:33441 // This function sets a flag that tells the test_shell to dump all
442 // the lines of descriptive text about spellcheck execution.
443 void DumpSpellCheckCallbacks();
444
445 // This function sets a flag that tells the test_shell to print out a text
446 // representation of the back/forward list. It ignores all arguments.
447 void DumpBackForwardList();
448
449 void DumpSelectionRect();
[email protected]97f9a7952014-03-14 11:50:33450
451 // Causes layout to happen as if targetted to printed pages.
452 void SetPrinting();
453
[email protected]52846102014-06-24 04:26:44454 // Clears the state from SetPrinting().
455 void ClearPrinting();
456
[email protected]97f9a7952014-03-14 11:50:33457 void SetShouldStayOnPageAfterHandlingBeforeUnload(bool value);
458
459 // Causes WillSendRequest to clear certain headers.
460 void SetWillSendRequestClearHeader(const std::string& header);
461
462 // This function sets a flag that tells the test_shell to dump a descriptive
463 // line for each resource load's priority and any time that priority
464 // changes. It takes no arguments, and ignores any that may be present.
465 void DumpResourceRequestPriorities();
466
467 // Sets a flag to enable the mock theme.
468 void SetUseMockTheme(bool use);
469
[email protected]a79cb9912014-04-26 22:07:33470 // Sets a flag that causes the test to be marked as completed when the
471 // WebFrameClient receives a loadURLExternally() call.
472 void WaitUntilExternalURLLoad();
473
jackhou656fc852015-02-13 09:04:17474 // This function sets a flag which tells the WebTestProxy to dump the drag
475 // image when the next drag-and-drop is initiated. It is equivalent to
476 // DumpAsTextWithPixelResults but the pixel results will be the drag image
477 // instead of a snapshot of the page.
478 void DumpDragImage();
479
jochenc3a98da12015-03-10 13:59:58480 // Sets a flag that tells the WebTestProxy to dump the default navigation
481 // policy passed to the decidePolicyForNavigation callback.
482 void DumpNavigationPolicy();
483
kouhei503bf4e2015-11-05 04:59:04484 // Dump current PageImportanceSignals for the page.
485 void DumpPageImportanceSignals();
486
[email protected]97f9a7952014-03-14 11:50:33487 ///////////////////////////////////////////////////////////////////////////
488 // Methods interacting with the WebTestProxy
489
490 ///////////////////////////////////////////////////////////////////////////
491 // Methods forwarding to the WebTestDelegate
492
493 // Shows DevTools window.
[email protected]06c253012014-04-16 18:35:33494 void ShowWebInspector(const std::string& str,
495 const std::string& frontend_url);
[email protected]97f9a7952014-03-14 11:50:33496 void CloseWebInspector();
497
498 // Inspect chooser state
499 bool IsChooserShown();
500
501 // Allows layout tests to exec scripts at WebInspector side.
502 void EvaluateInWebInspector(int call_id, const std::string& script);
sergeyv0cd842b42015-10-09 16:07:11503 // Allows layout tests to evaluate scripts in InspectorOverlay page.
504 // Script may have an output represented as a string, return values of other
505 // types would be ignored.
506 std::string EvaluateInWebInspectorOverlay(const std::string& script);
[email protected]97f9a7952014-03-14 11:50:33507
508 // Clears all databases.
509 void ClearAllDatabases();
510 // Sets the default quota for all origins
511 void SetDatabaseQuota(int quota);
512
513 // Changes the cookie policy from the default to allow all cookies.
514 void SetAlwaysAcceptCookies(bool accept);
515
516 // Gives focus to the window.
517 void SetWindowIsKey(bool value);
518
519 // Converts a URL starting with file:///tmp/ to the local mapping.
520 std::string PathToLocalResource(const std::string& path);
521
522 // Used to set the device scale factor.
deepak.s750d68f2015-04-30 07:32:41523 void SetBackingScaleFactor(double value, v8::Local<v8::Function> callback);
[email protected]97f9a7952014-03-14 11:50:33524
oshima841bbae2015-12-18 08:14:29525 // Enable zoom-for-dsf option.
526 // TODO(oshima): Remove this once all platforms migrated.
527 void EnableUseZoomForDSF(v8::Local<v8::Function> callback);
528
[email protected]71e652302014-05-09 14:20:13529 // Change the device color profile while running a layout test.
530 void SetColorProfile(const std::string& name,
deepak.s750d68f2015-04-30 07:32:41531 v8::Local<v8::Function> callback);
[email protected]71e652302014-05-09 14:20:13532
jyasskin8057c002015-09-10 19:09:53533 // Change the bluetooth test data while running a layout test and resets the
534 // chooser to accept the first device.
scheib834f26902014-11-05 23:57:26535 void SetBluetoothMockDataSet(const std::string& name);
536
jyasskin8057c002015-09-10 19:09:53537 // Makes the Bluetooth chooser record its input and wait for instructions from
538 // the test program on how to proceed.
539 void SetBluetoothManualChooser();
540
jyasskina5cef8f2015-09-22 16:20:26541 // Calls |callback| with a DOMString[] representing the events recorded since
542 // the last call to this function.
543 void GetBluetoothManualChooserEvents(v8::Local<v8::Function> callback);
jyasskin8057c002015-09-10 19:09:53544
545 // Calls the BluetoothChooser::EventHandler with the arguments here. Valid
546 // event strings are:
547 // * "cancel" - simulates the user canceling the chooser.
548 // * "select" - simulates the user selecting a device whose device ID is in
549 // |argument|.
550 void SendBluetoothManualChooserEvent(const std::string& event,
551 const std::string& argument);
552
mek340dd9d2014-12-11 02:10:46553 // Enables mock geofencing service while running a layout test.
554 // |service_available| indicates if the mock service should mock geofencing
555 // being available or not.
556 void SetGeofencingMockProvider(bool service_available);
557
558 // Disables mock geofencing service while running a layout test.
559 void ClearGeofencingMockProvider();
560
561 // Set the mock geofencing position while running a layout test.
562 void SetGeofencingMockPosition(double latitude, double longitude);
563
mlamourid5098d02015-04-21 12:17:30564 // Sets the permission's |name| to |value| for a given {origin, embedder}
565 // tuple.
566 void SetPermission(const std::string& name,
567 const std::string& value,
568 const GURL& origin,
569 const GURL& embedding_origin);
570
benwells0c0d3f12015-05-25 01:03:17571 // Causes the beforeinstallprompt event to be sent to the renderer.
572 void DispatchBeforeInstallPromptEvent(
573 int request_id,
574 const std::vector<std::string>& event_platforms,
575 v8::Local<v8::Function> callback);
576
577 // Resolve the beforeinstallprompt event with the matching request id.
578 void ResolveBeforeInstallPromptPromise(int request_id,
579 const std::string& platform);
580
[email protected]97f9a7952014-03-14 11:50:33581 // Calls setlocale(LC_ALL, ...) for a specified locale.
582 // Resets between tests.
583 void SetPOSIXLocale(const std::string& locale);
584
585 // MIDI function to control permission handling.
586 void SetMIDIAccessorResult(bool result);
[email protected]97f9a7952014-03-14 11:50:33587
peterd98157d2014-11-20 13:15:01588 // Simulates a click on a Web Notification.
johnme96d50122015-08-07 15:33:21589 void SimulateWebNotificationClick(const std::string& title, int action_index);
[email protected]97f9a7952014-03-14 11:50:33590
nsatragno24bd34b2016-02-09 10:30:02591 // Simulates closing a Web Notification.
592 void SimulateWebNotificationClose(const std::string& title, bool by_user);
593
[email protected]56e365d42014-05-02 22:18:24594 // Speech recognition related functions.
[email protected]97f9a7952014-03-14 11:50:33595 void AddMockSpeechRecognitionResult(const std::string& transcript,
596 double confidence);
597 void SetMockSpeechRecognitionError(const std::string& error,
598 const std::string& message);
599 bool WasMockSpeechRecognitionAborted();
600
mkwst41667ab2014-09-16 06:52:43601 // Credential Manager mock functions
602 // TODO(mkwst): Support FederatedCredential.
603 void AddMockCredentialManagerResponse(const std::string& id,
604 const std::string& name,
605 const std::string& avatar,
606 const std::string& password);
mkwst008acce62016-03-11 13:02:01607 void AddMockCredentialManagerError(const std::string& error);
mkwst41667ab2014-09-16 06:52:43608
[email protected]97f9a7952014-03-14 11:50:33609 // WebPageOverlay related functions. Permits the adding and removing of only
610 // one opaque overlay.
611 void AddWebPageOverlay();
612 void RemoveWebPageOverlay();
613
wangxianzhu372112e2015-05-06 23:01:57614 void LayoutAndPaintAsync();
615 void LayoutAndPaintAsyncThen(v8::Local<v8::Function> callback);
[email protected]97f9a7952014-03-14 11:50:33616
wangxianzhu372112e2015-05-06 23:01:57617 // Similar to LayoutAndPaintAsyncThen(), but pass parameters of the captured
[email protected]52846102014-06-24 04:26:44618 // snapshot (width, height, snapshot) to the callback. The snapshot is in
avi5dd91f82015-12-25 22:30:46619 // uint8_t RGBA format.
deepak.s750d68f2015-04-30 07:32:41620 void CapturePixelsAsyncThen(v8::Local<v8::Function> callback);
[email protected]9285cdc2014-07-18 15:42:25621 // Similar to CapturePixelsAsyncThen(). Copies to the clipboard the image
622 // located at a particular point in the WebView (if there is such an image),
623 // reads back its pixels, and provides the snapshot to the callback. If there
624 // is no image at that point, calls the callback with (0, 0, empty_snapshot).
625 void CopyImageAtAndCapturePixelsAsyncThen(
deepak.s750d68f2015-04-30 07:32:41626 int x, int y, const v8::Local<v8::Function> callback);
[email protected]eec9e78e2014-06-16 21:38:48627
deepak.s750d68f2015-04-30 07:32:41628 void GetManifestThen(v8::Local<v8::Function> callback);
kenneth.r.christiansen1a4946d2014-09-25 16:11:06629
lukaszac9cbe712016-03-14 14:06:43630 // Takes care of notifying the delegate after a change to layout dump flags.
631 void OnLayoutDumpFlagsChanged();
632
[email protected]97f9a7952014-03-14 11:50:33633 ///////////////////////////////////////////////////////////////////////////
634 // Internal helpers
[email protected]eec9e78e2014-06-16 21:38:48635
kenneth.r.christiansen1a4946d2014-09-25 16:11:06636 void GetManifestCallback(scoped_ptr<InvokeCallbackTask> task,
637 const blink::WebURLResponse& response,
638 const std::string& data);
[email protected]eec9e78e2014-06-16 21:38:48639 void CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task,
640 const SkBitmap& snapshot);
benwells0c0d3f12015-05-25 01:03:17641 void DispatchBeforeInstallPromptCallback(scoped_ptr<InvokeCallbackTask> task,
642 bool canceled);
jyasskina5cef8f2015-09-22 16:20:26643 void GetBluetoothManualChooserEventsCallback(
644 scoped_ptr<InvokeCallbackTask> task,
645 const std::vector<std::string>& events);
[email protected]eec9e78e2014-06-16 21:38:48646
[email protected]97f9a7952014-03-14 11:50:33647 void CheckResponseMimeType();
648 void CompleteNotifyDone();
649
650 void DidAcquirePointerLockInternal();
651 void DidNotAcquirePointerLockInternal();
652 void DidLosePointerLockInternal();
653
654 // In the Mac code, this is called to trigger the end of a test after the
655 // page has finished loading. From here, we can generate the dump for the
656 // test.
657 void LocationChangeDone();
658
siva.gunturi3ccb61442014-11-14 01:55:13659 // Sets a flag causing the next call to WebGLRenderingContext::create to fail.
660 void ForceNextWebGLContextCreationToFail();
661
bajonesf6f00b002015-05-28 00:01:43662 // Sets a flag causing the next call to DrawingBuffer::create to fail.
663 void ForceNextDrawingBufferCreationToFail();
664
[email protected]97f9a7952014-03-14 11:50:33665 bool test_is_running_;
666
667 // When reset is called, go through and close all but the main test shell
668 // window. By default, set to true but toggled to false using
669 // setCloseRemainingWindowsWhenComplete().
670 bool close_remaining_windows_;
671
[email protected]a79cb9912014-04-26 22:07:33672 // If true, ends the test when a URL is loaded externally via
673 // WebFrameClient::loadURLExternally().
674 bool wait_until_external_url_load_;
675
[email protected]97f9a7952014-03-14 11:50:33676 // Causes navigation actions just printout the intended navigation instead
677 // of taking you to the page. This is used for cases like mailto, where you
678 // don't actually want to open the mail program.
679 bool policy_delegate_enabled_;
680
681 // Toggles the behavior of the policy delegate. If true, then navigations
682 // will be allowed. Otherwise, they will be ignored (dropped).
683 bool policy_delegate_is_permissive_;
684
685 // If true, the policy delegate will signal layout test completion.
686 bool policy_delegate_should_notify_done_;
687
688 WorkQueue work_queue_;
689
[email protected]97f9a7952014-03-14 11:50:33690 // Bound variable to return the name of this platform (chromium).
691 std::string platform_name_;
692
693 // Bound variable to store the last tooltip text
694 std::string tooltip_text_;
695
[email protected]97f9a7952014-03-14 11:50:33696 // Bound variable counting the number of top URLs visited.
697 int web_history_item_count_;
698
699 // Bound variable to set whether postMessages should be intercepted or not
700 bool intercept_post_message_;
701
702 // If true, the test_shell will write a descriptive line for each editing
703 // command.
704 bool dump_editting_callbacks_;
705
lukasza9b9d70e2016-02-25 23:45:44706 // Flags controlling what content gets dumped as a layout text result.
707 LayoutDumpFlags layout_dump_flags_;
[email protected]97f9a7952014-03-14 11:50:33708
709 // If true, the test_shell will print out the icon change notifications.
710 bool dump_icon_changes_;
711
712 // If true, the test_shell will output a base64 encoded WAVE file.
713 bool dump_as_audio_;
714
715 // If true, the test_shell will output a descriptive line for each frame
716 // load callback.
717 bool dump_frame_load_callbacks_;
718
719 // If true, the test_shell will output a descriptive line for each
720 // PingLoader dispatched.
721 bool dump_ping_loader_callbacks_;
722
723 // If true, the test_shell will output a line of the user gesture status
724 // text for some frame load callbacks.
725 bool dump_user_gesture_in_frame_load_callbacks_;
726
727 // If true, output a message when the page title is changed.
728 bool dump_title_changes_;
729
730 // If true, output a descriptive line each time WebViewClient::createView
731 // is invoked.
732 bool dump_create_view_;
733
734 // If true, new windows can be opened via javascript or by plugins. By
735 // default, set to false and can be toggled to true using
736 // setCanOpenWindows().
737 bool can_open_windows_;
738
739 // If true, the test_shell will output a descriptive line for each resource
740 // load callback.
741 bool dump_resource_load_callbacks_;
742
743 // If true, the test_shell will output a descriptive line for each resource
744 // request callback.
745 bool dump_resource_request_callbacks_;
746
747 // If true, the test_shell will output the MIME type for each resource that
748 // was loaded.
jbroman37b021e2015-05-08 17:30:25749 bool dump_resource_response_mime_types_;
[email protected]97f9a7952014-03-14 11:50:33750
751 // If true, the test_shell will dump all changes to window.status.
752 bool dump_window_status_changes_;
753
[email protected]97f9a7952014-03-14 11:50:33754 // If true, the test_shell will output descriptive test for spellcheck
755 // execution.
756 bool dump_spell_check_callbacks_;
757
758 // If true, the test_shell will produce a dump of the back forward list as
759 // well.
760 bool dump_back_forward_list_;
761
762 // If true, the test_shell will draw the bounds of the current selection rect
763 // taking possible transforms of the selection rect into account.
764 bool dump_selection_rect_;
765
jackhou656fc852015-02-13 09:04:17766 // If true, the test_shell will dump the drag image as pixel results.
767 bool dump_drag_image_;
768
jochenc3a98da12015-03-10 13:59:58769 // If true, content_shell will dump the default navigation policy passed to
770 // WebFrameClient::decidePolicyForNavigation.
771 bool dump_navigation_policy_;
772
[email protected]97f9a7952014-03-14 11:50:33773 // If true, pixel dump will be produced as a series of 1px-tall, view-wide
774 // individual paints over the height of the view.
775 bool test_repaint_;
776
777 // If true and test_repaint_ is true as well, pixel dump will be produced as
778 // a series of 1px-wide, view-tall paints across the width of the view.
779 bool sweep_horizontally_;
780
[email protected]97f9a7952014-03-14 11:50:33781 // If false, MockWebMIDIAccessor fails on startSession() for testing.
782 bool midi_accessor_result_;
783
784 bool should_stay_on_page_after_handling_before_unload_;
785
786 bool should_dump_resource_priorities_;
787
[email protected]f24836a2014-05-06 01:02:44788 bool has_custom_text_output_;
789 std::string custom_text_output_;
790
[email protected]97f9a7952014-03-14 11:50:33791 std::set<std::string> http_headers_to_clear_;
792
793 // WAV audio data is stored here.
794 std::vector<unsigned char> audio_data_;
795
796 // Used for test timeouts.
[email protected]79ecada2014-05-04 05:16:16797 WebTaskList task_list_;
[email protected]97f9a7952014-03-14 11:50:33798
[email protected]79ecada2014-05-04 05:16:16799 TestInterfaces* test_interfaces_;
800 WebTestDelegate* delegate_;
[email protected]97f9a7952014-03-14 11:50:33801 blink::WebView* web_view_;
[email protected]a2ec0bc2014-04-23 08:18:27802 WebTestProxyBase* proxy_;
[email protected]97f9a7952014-03-14 11:50:33803
804 // This is non-0 IFF a load is in progress.
805 blink::WebFrame* top_loading_frame_;
806
mlamouri007f9d72015-02-27 16:27:25807 // WebContentSettingsClient mock object.
808 scoped_ptr<WebContentSettings> web_content_settings_;
[email protected]97f9a7952014-03-14 11:50:33809
[email protected]97f9a7952014-03-14 11:50:33810 bool pointer_locked_;
811 enum {
812 PointerLockWillSucceed,
813 PointerLockWillRespondAsync,
814 PointerLockWillFailSync,
815 } pointer_lock_planned_result_;
816 bool use_mock_theme_;
817
lukasza6a113ae12016-03-17 22:41:20818 scoped_ptr<MockScreenOrientationClient> mock_screen_orientation_client_;
819
[email protected]97f9a7952014-03-14 11:50:33820 base::WeakPtrFactory<TestRunner> weak_factory_;
821
822 DISALLOW_COPY_AND_ASSIGN(TestRunner);
823};
824
jochenf5f31752015-06-03 12:06:34825} // namespace test_runner
[email protected]97f9a7952014-03-14 11:50:33826
jochen73e711c2015-06-03 10:01:46827#endif // COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_