blob: 4a35f0e1d67daa72c6eeddc26c9e7814bfcdeec2 [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
8#include <deque>
9#include <set>
10#include <string>
benwells0c0d3f12015-05-25 01:03:1711#include <vector>
[email protected]97f9a7952014-03-14 11:50:3312
13#include "base/memory/scoped_ptr.h"
14#include "base/memory/weak_ptr.h"
jochen746754c52015-06-05 16:40:4115#include "components/test_runner/test_runner_export.h"
jochen73e711c2015-06-03 10:01:4616#include "components/test_runner/web_task.h"
17#include "components/test_runner/web_test_runner.h"
[email protected]97f9a7952014-03-14 11:50:3318#include "v8/include/v8.h"
19
[email protected]945babb2014-07-30 14:25:3220class GURL;
[email protected]eec9e78e2014-06-16 21:38:4821class SkBitmap;
22
[email protected]97f9a7952014-03-14 11:50:3323namespace blink {
mlamouri007f9d72015-02-27 16:27:2524class WebContentSettingsClient;
[email protected]97f9a7952014-03-14 11:50:3325class WebFrame;
mcasas43ff56ff2015-10-08 05:24:3726class WebMediaStream;
[email protected]97f9a7952014-03-14 11:50:3327class WebString;
28class WebView;
kenneth.r.christiansen1a4946d2014-09-25 16:11:0629class WebURLResponse;
[email protected]97f9a7952014-03-14 11:50:3330}
31
32namespace gin {
33class ArrayBufferView;
34class Arguments;
35}
36
jochenf5f31752015-06-03 12:06:3437namespace test_runner {
[email protected]97f9a7952014-03-14 11:50:3338
[email protected]97d3fe82014-04-05 02:40:0039class InvokeCallbackTask;
[email protected]79ecada2014-05-04 05:16:1640class TestInterfaces;
mlamouri007f9d72015-02-27 16:27:2541class WebContentSettings;
[email protected]79ecada2014-05-04 05:16:1642class WebTestDelegate;
[email protected]a2ec0bc2014-04-23 08:18:2743class WebTestProxyBase;
[email protected]97f9a7952014-03-14 11:50:3344
[email protected]79ecada2014-05-04 05:16:1645class TestRunner : public WebTestRunner,
[email protected]97f9a7952014-03-14 11:50:3346 public base::SupportsWeakPtr<TestRunner> {
47 public:
[email protected]79ecada2014-05-04 05:16:1648 explicit TestRunner(TestInterfaces*);
[email protected]97f9a7952014-03-14 11:50:3349 virtual ~TestRunner();
50
51 void Install(blink::WebFrame* frame);
52
[email protected]79ecada2014-05-04 05:16:1653 void SetDelegate(WebTestDelegate*);
[email protected]a2ec0bc2014-04-23 08:18:2754 void SetWebView(blink::WebView*, WebTestProxyBase*);
[email protected]97f9a7952014-03-14 11:50:3355
56 void Reset();
57
[email protected]a1640e42014-05-14 13:43:3258 WebTaskList* mutable_task_list() { return &task_list_; }
[email protected]97f9a7952014-03-14 11:50:3359
60 void SetTestIsRunning(bool);
61 bool TestIsRunning() const { return test_is_running_; }
62
63 bool UseMockTheme() const { return use_mock_theme_; }
64
[email protected]97d3fe82014-04-05 02:40:0065 void InvokeCallback(scoped_ptr<InvokeCallbackTask> callback);
66
[email protected]97f9a7952014-03-14 11:50:3367 // WebTestRunner implementation.
dchenge933b3e2014-10-21 11:44:0968 bool ShouldGeneratePixelResults() override;
jochen746754c52015-06-05 16:40:4169 bool ShouldStayOnPageAfterHandlingBeforeUnload() const override;
dchenge933b3e2014-10-21 11:44:0970 bool ShouldDumpAsAudio() const override;
71 void GetAudioData(std::vector<unsigned char>* buffer_view) const override;
72 bool ShouldDumpBackForwardList() const override;
mlamouri007f9d72015-02-27 16:27:2573 blink::WebContentSettingsClient* GetWebContentSettings() const override;
[email protected]97f9a7952014-03-14 11:50:3374
75 // Methods used by WebTestProxyBase.
76 bool shouldDumpSelectionRect() const;
[email protected]97f9a7952014-03-14 11:50:3377 bool isPrinting() const;
78 bool shouldDumpAsText();
79 bool shouldDumpAsTextWithPixelResults();
[email protected]f24836a2014-05-06 01:02:4480 bool shouldDumpAsCustomText() const;
81 std:: string customDumpText() const;
[email protected]97f9a7952014-03-14 11:50:3382 bool shouldDumpAsMarkup();
83 bool shouldDumpChildFrameScrollPositions() const;
[email protected]fdc433c02014-06-02 19:27:1484 bool shouldDumpChildFramesAsMarkup() const;
[email protected]97f9a7952014-03-14 11:50:3385 bool shouldDumpChildFramesAsText() const;
abhishek.a21ca9b5602014-09-19 07:33:3386 void ShowDevTools(const std::string& settings,
[email protected]06c253012014-04-16 18:35:3387 const std::string& frontend_url);
abhishek.a21ca9b5602014-09-19 07:33:3388 void ClearDevToolsLocalStorage();
[email protected]97f9a7952014-03-14 11:50:3389 void setShouldDumpAsText(bool);
90 void setShouldDumpAsMarkup(bool);
ki.stfu939799a42015-09-28 04:41:2091 void setCustomTextOutput(const std::string& text);
[email protected]97f9a7952014-03-14 11:50:3392 void setShouldGeneratePixelResults(bool);
93 void setShouldDumpFrameLoadCallbacks(bool);
94 void setShouldDumpPingLoaderCallbacks(bool);
95 void setShouldEnableViewSource(bool);
96 bool shouldDumpEditingCallbacks() const;
97 bool shouldDumpFrameLoadCallbacks() const;
98 bool shouldDumpPingLoaderCallbacks() const;
99 bool shouldDumpUserGestureInFrameLoadCallbacks() const;
100 bool shouldDumpTitleChanges() const;
101 bool shouldDumpIconChanges() const;
102 bool shouldDumpCreateView() const;
103 bool canOpenWindows() const;
104 bool shouldDumpResourceLoadCallbacks() const;
105 bool shouldDumpResourceRequestCallbacks() const;
106 bool shouldDumpResourceResponseMIMETypes() const;
107 bool shouldDumpStatusCallbacks() const;
108 bool shouldDumpProgressFinishedCallback() const;
109 bool shouldDumpSpellCheckCallbacks() const;
[email protected]a79cb9912014-04-26 22:07:33110 bool shouldWaitUntilExternalURLLoad() const;
[email protected]97f9a7952014-03-14 11:50:33111 const std::set<std::string>* httpHeadersToClear() const;
112 void setTopLoadingFrame(blink::WebFrame*, bool);
113 blink::WebFrame* topLoadingFrame() const;
114 void policyDelegateDone();
115 bool policyDelegateEnabled() const;
116 bool policyDelegateIsPermissive() const;
117 bool policyDelegateShouldNotifyDone() const;
118 bool shouldInterceptPostMessage() const;
119 bool shouldDumpResourcePriorities() const;
[email protected]97f9a7952014-03-14 11:50:33120 bool RequestPointerLock();
121 void RequestPointerUnlock();
122 bool isPointerLocked();
123 void setToolTipText(const blink::WebString&);
jackhou656fc852015-02-13 09:04:17124 bool shouldDumpDragImage();
jochenc3a98da12015-03-10 13:59:58125 bool shouldDumpNavigationPolicy() const;
[email protected]97f9a7952014-03-14 11:50:33126
127 bool midiAccessorResult();
128
129 // A single item in the work queue.
130 class WorkItem {
131 public:
132 virtual ~WorkItem() {}
133
134 // Returns true if this started a load.
[email protected]79ecada2014-05-04 05:16:16135 virtual bool Run(WebTestDelegate*, blink::WebView*) = 0;
[email protected]97f9a7952014-03-14 11:50:33136 };
137
138 private:
139 friend class InvokeCallbackTask;
140 friend class TestRunnerBindings;
141 friend class WorkQueue;
142
143 // Helper class for managing events queued by methods like queueLoad or
144 // queueScript.
145 class WorkQueue {
146 public:
147 explicit WorkQueue(TestRunner* controller);
148 virtual ~WorkQueue();
149 void ProcessWorkSoon();
150
151 // Reset the state of the class between tests.
152 void Reset();
153
154 void AddWork(WorkItem*);
155
156 void set_frozen(bool frozen) { frozen_ = frozen; }
157 bool is_empty() { return queue_.empty(); }
[email protected]a1640e42014-05-14 13:43:32158 WebTaskList* mutable_task_list() { return &task_list_; }
[email protected]97f9a7952014-03-14 11:50:33159
160 private:
161 void ProcessWork();
162
[email protected]79ecada2014-05-04 05:16:16163 class WorkQueueTask : public WebMethodTask<WorkQueue> {
[email protected]97f9a7952014-03-14 11:50:33164 public:
[email protected]79ecada2014-05-04 05:16:16165 WorkQueueTask(WorkQueue* object) : WebMethodTask<WorkQueue>(object) {}
[email protected]97f9a7952014-03-14 11:50:33166
dchenge933b3e2014-10-21 11:44:09167 void RunIfValid() override;
[email protected]97f9a7952014-03-14 11:50:33168 };
169
[email protected]79ecada2014-05-04 05:16:16170 WebTaskList task_list_;
[email protected]97f9a7952014-03-14 11:50:33171 std::deque<WorkItem*> queue_;
172 bool frozen_;
173 TestRunner* controller_;
174 };
175
176 ///////////////////////////////////////////////////////////////////////////
177 // Methods dealing with the test logic
178
179 // By default, tests end when page load is complete. These methods are used
180 // to delay the completion of the test until notifyDone is called.
181 void NotifyDone();
182 void WaitUntilDone();
183
184 // Methods for adding actions to the work queue. Used in conjunction with
185 // waitUntilDone/notifyDone above.
186 void QueueBackNavigation(int how_far_back);
187 void QueueForwardNavigation(int how_far_forward);
188 void QueueReload();
189 void QueueLoadingScript(const std::string& script);
190 void QueueNonLoadingScript(const std::string& script);
191 void QueueLoad(const std::string& url, const std::string& target);
192 void QueueLoadHTMLString(gin::Arguments* args);
193
194 // Causes navigation actions just printout the intended navigation instead
195 // of taking you to the page. This is used for cases like mailto, where you
196 // don't actually want to open the mail program.
197 void SetCustomPolicyDelegate(gin::Arguments* args);
198
199 // Delays completion of the test until the policy delegate runs.
200 void WaitForPolicyDelegate();
201
202 // Functions for dealing with windows. By default we block all new windows.
203 int WindowCount();
204 void SetCloseRemainingWindowsWhenComplete(bool close_remaining_windows);
205 void ResetTestHelperControllers();
206
207 ///////////////////////////////////////////////////////////////////////////
208 // Methods implemented entirely in terms of chromium's public WebKit API
209
210 // Method that controls whether pressing Tab key cycles through page elements
211 // or inserts a '\t' char in text area
212 void SetTabKeyCyclesThroughElements(bool tab_key_cycles_through_elements);
213
214 // Executes an internal command (superset of document.execCommand() commands).
215 void ExecCommand(gin::Arguments* args);
216
217 // Checks if an internal command is currently available.
218 bool IsCommandEnabled(const std::string& command);
219
220 bool CallShouldCloseOnWebView();
221 void SetDomainRelaxationForbiddenForURLScheme(bool forbidden,
222 const std::string& scheme);
deepak.s750d68f2015-04-30 07:32:41223 v8::Local<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue(
[email protected]97f9a7952014-03-14 11:50:33224 int world_id, const std::string& script);
225 void EvaluateScriptInIsolatedWorld(int world_id, const std::string& script);
226 void SetIsolatedWorldSecurityOrigin(int world_id,
deepak.s750d68f2015-04-30 07:32:41227 v8::Local<v8::Value> origin);
[email protected]97f9a7952014-03-14 11:50:33228 void SetIsolatedWorldContentSecurityPolicy(int world_id,
229 const std::string& policy);
230
231 // Allows layout tests to manage origins' whitelisting.
232 void AddOriginAccessWhitelistEntry(const std::string& source_origin,
233 const std::string& destination_protocol,
234 const std::string& destination_host,
235 bool allow_destination_subdomains);
236 void RemoveOriginAccessWhitelistEntry(const std::string& source_origin,
237 const std::string& destination_protocol,
238 const std::string& destination_host,
239 bool allow_destination_subdomains);
240
241 // Returns true if the current page box has custom page size style for
242 // printing.
243 bool HasCustomPageSizeStyle(int page_index);
244
245 // Forces the selection colors for testing under Linux.
246 void ForceRedSelectionColors();
247
dcheng9000dbd2015-04-03 05:39:40248 // Add |source_code| as an injected stylesheet to the active document of the
249 // window of the current V8 context.
250 void InsertStyleSheet(const std::string& source_code);
251
[email protected]97f9a7952014-03-14 11:50:33252 bool FindString(const std::string& search_text,
253 const std::vector<std::string>& options_array);
254
255 std::string SelectionAsMarkup();
256
257 // Enables or disables subpixel positioning (i.e. fractional X positions for
258 // glyphs) in text rendering on Linux. Since this method changes global
259 // settings, tests that call it must use their own custom font family for
260 // all text that they render. If not, an already-cached style will be used,
261 // resulting in the changed setting being ignored.
262 void SetTextSubpixelPositioning(bool value);
263
264 // Switch the visibility of the page.
265 void SetPageVisibility(const std::string& new_visibility);
266
267 // Changes the direction of the focused element.
268 void SetTextDirection(const std::string& direction_name);
269
270 // After this function is called, all window-sizing machinery is
271 // short-circuited inside the renderer. This mode is necessary for
272 // some tests that were written before browsers had multi-process architecture
273 // and rely on window resizes to happen synchronously.
274 // The function has "unfortunate" it its name because we must strive to remove
275 // all tests that rely on this... well, unfortunate behavior. See
276 // http://crbug.com/309760 for the plan.
277 void UseUnfortunateSynchronousResizeMode();
278
279 bool EnableAutoResizeMode(int min_width,
280 int min_height,
281 int max_width,
282 int max_height);
283 bool DisableAutoResizeMode(int new_width, int new_height);
284
[email protected]2ad7e622014-06-30 17:44:21285 void SetMockDeviceLight(double value);
286 void ResetDeviceLight();
[email protected]97f9a7952014-03-14 11:50:33287 // Device Motion / Device Orientation related functions
288 void SetMockDeviceMotion(bool has_acceleration_x, double acceleration_x,
289 bool has_acceleration_y, double acceleration_y,
290 bool has_acceleration_z, double acceleration_z,
291 bool has_acceleration_including_gravity_x,
292 double acceleration_including_gravity_x,
293 bool has_acceleration_including_gravity_y,
294 double acceleration_including_gravity_y,
295 bool has_acceleration_including_gravity_z,
296 double acceleration_including_gravity_z,
297 bool has_rotation_rate_alpha,
298 double rotation_rate_alpha,
299 bool has_rotation_rate_beta,
300 double rotation_rate_beta,
301 bool has_rotation_rate_gamma,
302 double rotation_rate_gamma,
303 double interval);
304 void SetMockDeviceOrientation(bool has_alpha, double alpha,
305 bool has_beta, double beta,
306 bool has_gamma, double gamma,
307 bool has_absolute, bool absolute);
308
[email protected]e0bc2cb2014-03-20 17:34:24309 void SetMockScreenOrientation(const std::string& orientation);
310
[email protected]de7c9e72014-06-03 22:30:26311 void DidChangeBatteryStatus(bool charging,
312 double chargingTime,
313 double dischargingTime,
314 double level);
315 void ResetBatteryStatus();
316
[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
341 ///////////////////////////////////////////////////////////////////////////
342 // Methods that modify the state of TestRunner
343
344 // This function sets a flag that tells the test_shell to print a line of
345 // descriptive text for each editing command. It takes no arguments, and
346 // ignores any that may be present.
347 void DumpEditingCallbacks();
348
349 // This function sets a flag that tells the test_shell to dump pages as
350 // plain text, rather than as a text representation of the renderer's state.
351 // The pixel results will not be generated for this test.
352 void DumpAsText();
353
354 // This function sets a flag that tells the test_shell to dump pages as
[email protected]fdc433c02014-06-02 19:27:14355 // the DOM contents, rather than as a text representation of the renderer's
356 // state. The pixel results will not be generated for this test.
357 void DumpAsMarkup();
358
359 // This function sets a flag that tells the test_shell to dump pages as
[email protected]97f9a7952014-03-14 11:50:33360 // plain text, rather than as a text representation of the renderer's state.
361 // It will also generate a pixel dump for the test.
362 void DumpAsTextWithPixelResults();
363
364 // This function sets a flag that tells the test_shell to print out the
365 // scroll offsets of the child frames. It ignores all.
366 void DumpChildFrameScrollPositions();
367
368 // This function sets a flag that tells the test_shell to recursively
369 // dump all frames as plain text if the DumpAsText flag is set.
370 // It takes no arguments, and ignores any that may be present.
371 void DumpChildFramesAsText();
372
[email protected]fdc433c02014-06-02 19:27:14373 // This function sets a flag that tells the test_shell to recursively
374 // dump all frames as the DOM contents if the DumpAsMarkup flag is set.
375 // It takes no arguments, and ignores any that may be present.
376 void DumpChildFramesAsMarkup();
377
[email protected]97f9a7952014-03-14 11:50:33378 // This function sets a flag that tells the test_shell to print out the
379 // information about icon changes notifications from WebKit.
380 void DumpIconChanges();
381
382 // Deals with Web Audio WAV file data.
383 void SetAudioData(const gin::ArrayBufferView& view);
384
385 // This function sets a flag that tells the test_shell to print a line of
386 // descriptive text for each frame load callback. It takes no arguments, and
387 // ignores any that may be present.
388 void DumpFrameLoadCallbacks();
389
390 // This function sets a flag that tells the test_shell to print a line of
391 // descriptive text for each PingLoader dispatch. It takes no arguments, and
392 // ignores any that may be present.
393 void DumpPingLoaderCallbacks();
394
395 // This function sets a flag that tells the test_shell to print a line of
396 // user gesture status text for some frame load callbacks. It takes no
397 // arguments, and ignores any that may be present.
398 void DumpUserGestureInFrameLoadCallbacks();
399
400 void DumpTitleChanges();
401
402 // This function sets a flag that tells the test_shell to dump all calls to
403 // WebViewClient::createView().
404 // It takes no arguments, and ignores any that may be present.
405 void DumpCreateView();
406
407 void SetCanOpenWindows();
408
409 // This function sets a flag that tells the test_shell to dump a descriptive
410 // line for each resource load callback. It takes no arguments, and ignores
411 // any that may be present.
412 void DumpResourceLoadCallbacks();
413
414 // This function sets a flag that tells the test_shell to print a line of
415 // descriptive text for each element that requested a resource. It takes no
416 // arguments, and ignores any that may be present.
417 void DumpResourceRequestCallbacks();
418
419 // This function sets a flag that tells the test_shell to dump the MIME type
420 // for each resource that was loaded. It takes no arguments, and ignores any
421 // that may be present.
422 void DumpResourceResponseMIMETypes();
423
mlamouri007f9d72015-02-27 16:27:25424 // WebContentSettingsClient related.
[email protected]97f9a7952014-03-14 11:50:33425 void SetImagesAllowed(bool allowed);
[email protected]e19024b92014-06-10 11:10:37426 void SetMediaAllowed(bool allowed);
[email protected]97f9a7952014-03-14 11:50:33427 void SetScriptsAllowed(bool allowed);
428 void SetStorageAllowed(bool allowed);
429 void SetPluginsAllowed(bool allowed);
430 void SetAllowDisplayOfInsecureContent(bool allowed);
431 void SetAllowRunningOfInsecureContent(bool allowed);
432 void DumpPermissionClientCallbacks();
433
434 // This function sets a flag that tells the test_shell to dump all calls
435 // to window.status().
436 // It takes no arguments, and ignores any that may be present.
437 void DumpWindowStatusChanges();
438
439 // This function sets a flag that tells the test_shell to print a line of
440 // descriptive text for the progress finished callback. It takes no
441 // arguments, and ignores any that may be present.
442 void DumpProgressFinishedCallback();
443
444 // This function sets a flag that tells the test_shell to dump all
445 // the lines of descriptive text about spellcheck execution.
446 void DumpSpellCheckCallbacks();
447
448 // This function sets a flag that tells the test_shell to print out a text
449 // representation of the back/forward list. It ignores all arguments.
450 void DumpBackForwardList();
451
452 void DumpSelectionRect();
[email protected]97f9a7952014-03-14 11:50:33453
454 // Causes layout to happen as if targetted to printed pages.
455 void SetPrinting();
456
[email protected]52846102014-06-24 04:26:44457 // Clears the state from SetPrinting().
458 void ClearPrinting();
459
[email protected]97f9a7952014-03-14 11:50:33460 void SetShouldStayOnPageAfterHandlingBeforeUnload(bool value);
461
462 // Causes WillSendRequest to clear certain headers.
463 void SetWillSendRequestClearHeader(const std::string& header);
464
465 // This function sets a flag that tells the test_shell to dump a descriptive
466 // line for each resource load's priority and any time that priority
467 // changes. It takes no arguments, and ignores any that may be present.
468 void DumpResourceRequestPriorities();
469
470 // Sets a flag to enable the mock theme.
471 void SetUseMockTheme(bool use);
472
[email protected]a79cb9912014-04-26 22:07:33473 // Sets a flag that causes the test to be marked as completed when the
474 // WebFrameClient receives a loadURLExternally() call.
475 void WaitUntilExternalURLLoad();
476
jackhou656fc852015-02-13 09:04:17477 // This function sets a flag which tells the WebTestProxy to dump the drag
478 // image when the next drag-and-drop is initiated. It is equivalent to
479 // DumpAsTextWithPixelResults but the pixel results will be the drag image
480 // instead of a snapshot of the page.
481 void DumpDragImage();
482
jochenc3a98da12015-03-10 13:59:58483 // Sets a flag that tells the WebTestProxy to dump the default navigation
484 // policy passed to the decidePolicyForNavigation callback.
485 void DumpNavigationPolicy();
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
[email protected]71e652302014-05-09 14:20:13525 // Change the device color profile while running a layout test.
526 void SetColorProfile(const std::string& name,
deepak.s750d68f2015-04-30 07:32:41527 v8::Local<v8::Function> callback);
[email protected]71e652302014-05-09 14:20:13528
jyasskin8057c002015-09-10 19:09:53529 // Change the bluetooth test data while running a layout test and resets the
530 // chooser to accept the first device.
scheib834f26902014-11-05 23:57:26531 void SetBluetoothMockDataSet(const std::string& name);
532
jyasskin8057c002015-09-10 19:09:53533 // Makes the Bluetooth chooser record its input and wait for instructions from
534 // the test program on how to proceed.
535 void SetBluetoothManualChooser();
536
jyasskina5cef8f2015-09-22 16:20:26537 // Calls |callback| with a DOMString[] representing the events recorded since
538 // the last call to this function.
539 void GetBluetoothManualChooserEvents(v8::Local<v8::Function> callback);
jyasskin8057c002015-09-10 19:09:53540
541 // Calls the BluetoothChooser::EventHandler with the arguments here. Valid
542 // event strings are:
543 // * "cancel" - simulates the user canceling the chooser.
544 // * "select" - simulates the user selecting a device whose device ID is in
545 // |argument|.
546 void SendBluetoothManualChooserEvent(const std::string& event,
547 const std::string& argument);
548
mek340dd9d2014-12-11 02:10:46549 // Enables mock geofencing service while running a layout test.
550 // |service_available| indicates if the mock service should mock geofencing
551 // being available or not.
552 void SetGeofencingMockProvider(bool service_available);
553
554 // Disables mock geofencing service while running a layout test.
555 void ClearGeofencingMockProvider();
556
557 // Set the mock geofencing position while running a layout test.
558 void SetGeofencingMockPosition(double latitude, double longitude);
559
mlamourid5098d02015-04-21 12:17:30560 // Sets the permission's |name| to |value| for a given {origin, embedder}
561 // tuple.
562 void SetPermission(const std::string& name,
563 const std::string& value,
564 const GURL& origin,
565 const GURL& embedding_origin);
566
benwells0c0d3f12015-05-25 01:03:17567 // Causes the beforeinstallprompt event to be sent to the renderer.
568 void DispatchBeforeInstallPromptEvent(
569 int request_id,
570 const std::vector<std::string>& event_platforms,
571 v8::Local<v8::Function> callback);
572
573 // Resolve the beforeinstallprompt event with the matching request id.
574 void ResolveBeforeInstallPromptPromise(int request_id,
575 const std::string& platform);
576
[email protected]97f9a7952014-03-14 11:50:33577 // Calls setlocale(LC_ALL, ...) for a specified locale.
578 // Resets between tests.
579 void SetPOSIXLocale(const std::string& locale);
580
581 // MIDI function to control permission handling.
582 void SetMIDIAccessorResult(bool result);
[email protected]97f9a7952014-03-14 11:50:33583
peterd98157d2014-11-20 13:15:01584 // Simulates a click on a Web Notification.
johnme96d50122015-08-07 15:33:21585 void SimulateWebNotificationClick(const std::string& title, int action_index);
[email protected]97f9a7952014-03-14 11:50:33586
[email protected]56e365d42014-05-02 22:18:24587 // Speech recognition related functions.
[email protected]97f9a7952014-03-14 11:50:33588 void AddMockSpeechRecognitionResult(const std::string& transcript,
589 double confidence);
590 void SetMockSpeechRecognitionError(const std::string& error,
591 const std::string& message);
592 bool WasMockSpeechRecognitionAborted();
593
mkwst41667ab2014-09-16 06:52:43594 // Credential Manager mock functions
595 // TODO(mkwst): Support FederatedCredential.
596 void AddMockCredentialManagerResponse(const std::string& id,
597 const std::string& name,
598 const std::string& avatar,
599 const std::string& password);
600
[email protected]97f9a7952014-03-14 11:50:33601 // WebPageOverlay related functions. Permits the adding and removing of only
602 // one opaque overlay.
603 void AddWebPageOverlay();
604 void RemoveWebPageOverlay();
605
wangxianzhu372112e2015-05-06 23:01:57606 void LayoutAndPaintAsync();
607 void LayoutAndPaintAsyncThen(v8::Local<v8::Function> callback);
[email protected]97f9a7952014-03-14 11:50:33608
wangxianzhu372112e2015-05-06 23:01:57609 // Similar to LayoutAndPaintAsyncThen(), but pass parameters of the captured
[email protected]52846102014-06-24 04:26:44610 // snapshot (width, height, snapshot) to the callback. The snapshot is in
611 // uint8 RGBA format.
deepak.s750d68f2015-04-30 07:32:41612 void CapturePixelsAsyncThen(v8::Local<v8::Function> callback);
[email protected]9285cdc2014-07-18 15:42:25613 // Similar to CapturePixelsAsyncThen(). Copies to the clipboard the image
614 // located at a particular point in the WebView (if there is such an image),
615 // reads back its pixels, and provides the snapshot to the callback. If there
616 // is no image at that point, calls the callback with (0, 0, empty_snapshot).
617 void CopyImageAtAndCapturePixelsAsyncThen(
deepak.s750d68f2015-04-30 07:32:41618 int x, int y, const v8::Local<v8::Function> callback);
[email protected]eec9e78e2014-06-16 21:38:48619
deepak.s750d68f2015-04-30 07:32:41620 void GetManifestThen(v8::Local<v8::Function> callback);
kenneth.r.christiansen1a4946d2014-09-25 16:11:06621
[email protected]97f9a7952014-03-14 11:50:33622 ///////////////////////////////////////////////////////////////////////////
623 // Internal helpers
[email protected]eec9e78e2014-06-16 21:38:48624
kenneth.r.christiansen1a4946d2014-09-25 16:11:06625 void GetManifestCallback(scoped_ptr<InvokeCallbackTask> task,
626 const blink::WebURLResponse& response,
627 const std::string& data);
[email protected]eec9e78e2014-06-16 21:38:48628 void CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task,
629 const SkBitmap& snapshot);
benwells0c0d3f12015-05-25 01:03:17630 void DispatchBeforeInstallPromptCallback(scoped_ptr<InvokeCallbackTask> task,
631 bool canceled);
jyasskina5cef8f2015-09-22 16:20:26632 void GetBluetoothManualChooserEventsCallback(
633 scoped_ptr<InvokeCallbackTask> task,
634 const std::vector<std::string>& events);
[email protected]eec9e78e2014-06-16 21:38:48635
[email protected]97f9a7952014-03-14 11:50:33636 void CheckResponseMimeType();
637 void CompleteNotifyDone();
638
639 void DidAcquirePointerLockInternal();
640 void DidNotAcquirePointerLockInternal();
641 void DidLosePointerLockInternal();
642
643 // In the Mac code, this is called to trigger the end of a test after the
644 // page has finished loading. From here, we can generate the dump for the
645 // test.
646 void LocationChangeDone();
647
siva.gunturi3ccb61442014-11-14 01:55:13648 // Sets a flag causing the next call to WebGLRenderingContext::create to fail.
649 void ForceNextWebGLContextCreationToFail();
650
bajonesf6f00b002015-05-28 00:01:43651 // Sets a flag causing the next call to DrawingBuffer::create to fail.
652 void ForceNextDrawingBufferCreationToFail();
653
[email protected]97f9a7952014-03-14 11:50:33654 bool test_is_running_;
655
656 // When reset is called, go through and close all but the main test shell
657 // window. By default, set to true but toggled to false using
658 // setCloseRemainingWindowsWhenComplete().
659 bool close_remaining_windows_;
660
661 // If true, don't dump output until notifyDone is called.
662 bool wait_until_done_;
663
[email protected]a79cb9912014-04-26 22:07:33664 // If true, ends the test when a URL is loaded externally via
665 // WebFrameClient::loadURLExternally().
666 bool wait_until_external_url_load_;
667
[email protected]97f9a7952014-03-14 11:50:33668 // Causes navigation actions just printout the intended navigation instead
669 // of taking you to the page. This is used for cases like mailto, where you
670 // don't actually want to open the mail program.
671 bool policy_delegate_enabled_;
672
673 // Toggles the behavior of the policy delegate. If true, then navigations
674 // will be allowed. Otherwise, they will be ignored (dropped).
675 bool policy_delegate_is_permissive_;
676
677 // If true, the policy delegate will signal layout test completion.
678 bool policy_delegate_should_notify_done_;
679
680 WorkQueue work_queue_;
681
[email protected]97f9a7952014-03-14 11:50:33682 // Bound variable to return the name of this platform (chromium).
683 std::string platform_name_;
684
685 // Bound variable to store the last tooltip text
686 std::string tooltip_text_;
687
688 // Bound variable to disable notifyDone calls. This is used in GC leak
689 // tests, where existing LayoutTests are loaded within an iframe. The GC
690 // test harness will set this flag to ignore the notifyDone calls from the
691 // target LayoutTest.
692 bool disable_notify_done_;
693
694 // Bound variable counting the number of top URLs visited.
695 int web_history_item_count_;
696
697 // Bound variable to set whether postMessages should be intercepted or not
698 bool intercept_post_message_;
699
700 // If true, the test_shell will write a descriptive line for each editing
701 // command.
702 bool dump_editting_callbacks_;
703
704 // If true, the test_shell will generate pixel results in DumpAsText mode
705 bool generate_pixel_results_;
706
707 // If true, the test_shell will produce a plain text dump rather than a
708 // text representation of the renderer.
709 bool dump_as_text_;
710
711 // If true and if dump_as_text_ is true, the test_shell will recursively
712 // dump all frames as plain text.
713 bool dump_child_frames_as_text_;
714
715 // If true, the test_shell will produce a dump of the DOM rather than a text
716 // representation of the renderer.
717 bool dump_as_markup_;
718
[email protected]fdc433c02014-06-02 19:27:14719 // If true and if dump_as_markup_ is true, the test_shell will recursively
720 // produce a dump of the DOM rather than a text representation of the
721 // renderer.
722 bool dump_child_frames_as_markup_;
723
[email protected]97f9a7952014-03-14 11:50:33724 // If true, the test_shell will print out the child frame scroll offsets as
725 // well.
726 bool dump_child_frame_scroll_positions_;
727
728 // If true, the test_shell will print out the icon change notifications.
729 bool dump_icon_changes_;
730
731 // If true, the test_shell will output a base64 encoded WAVE file.
732 bool dump_as_audio_;
733
734 // If true, the test_shell will output a descriptive line for each frame
735 // load callback.
736 bool dump_frame_load_callbacks_;
737
738 // If true, the test_shell will output a descriptive line for each
739 // PingLoader dispatched.
740 bool dump_ping_loader_callbacks_;
741
742 // If true, the test_shell will output a line of the user gesture status
743 // text for some frame load callbacks.
744 bool dump_user_gesture_in_frame_load_callbacks_;
745
746 // If true, output a message when the page title is changed.
747 bool dump_title_changes_;
748
749 // If true, output a descriptive line each time WebViewClient::createView
750 // is invoked.
751 bool dump_create_view_;
752
753 // If true, new windows can be opened via javascript or by plugins. By
754 // default, set to false and can be toggled to true using
755 // setCanOpenWindows().
756 bool can_open_windows_;
757
758 // If true, the test_shell will output a descriptive line for each resource
759 // load callback.
760 bool dump_resource_load_callbacks_;
761
762 // If true, the test_shell will output a descriptive line for each resource
763 // request callback.
764 bool dump_resource_request_callbacks_;
765
766 // If true, the test_shell will output the MIME type for each resource that
767 // was loaded.
jbroman37b021e2015-05-08 17:30:25768 bool dump_resource_response_mime_types_;
[email protected]97f9a7952014-03-14 11:50:33769
770 // If true, the test_shell will dump all changes to window.status.
771 bool dump_window_status_changes_;
772
773 // If true, the test_shell will output a descriptive line for the progress
774 // finished callback.
775 bool dump_progress_finished_callback_;
776
777 // If true, the test_shell will output descriptive test for spellcheck
778 // execution.
779 bool dump_spell_check_callbacks_;
780
781 // If true, the test_shell will produce a dump of the back forward list as
782 // well.
783 bool dump_back_forward_list_;
784
785 // If true, the test_shell will draw the bounds of the current selection rect
786 // taking possible transforms of the selection rect into account.
787 bool dump_selection_rect_;
788
jackhou656fc852015-02-13 09:04:17789 // If true, the test_shell will dump the drag image as pixel results.
790 bool dump_drag_image_;
791
jochenc3a98da12015-03-10 13:59:58792 // If true, content_shell will dump the default navigation policy passed to
793 // WebFrameClient::decidePolicyForNavigation.
794 bool dump_navigation_policy_;
795
[email protected]97f9a7952014-03-14 11:50:33796 // If true, pixel dump will be produced as a series of 1px-tall, view-wide
797 // individual paints over the height of the view.
798 bool test_repaint_;
799
800 // If true and test_repaint_ is true as well, pixel dump will be produced as
801 // a series of 1px-wide, view-tall paints across the width of the view.
802 bool sweep_horizontally_;
803
804 // If true, layout is to target printed pages.
805 bool is_printing_;
806
807 // If false, MockWebMIDIAccessor fails on startSession() for testing.
808 bool midi_accessor_result_;
809
810 bool should_stay_on_page_after_handling_before_unload_;
811
812 bool should_dump_resource_priorities_;
813
[email protected]f24836a2014-05-06 01:02:44814 bool has_custom_text_output_;
815 std::string custom_text_output_;
816
[email protected]97f9a7952014-03-14 11:50:33817 std::set<std::string> http_headers_to_clear_;
818
819 // WAV audio data is stored here.
820 std::vector<unsigned char> audio_data_;
821
822 // Used for test timeouts.
[email protected]79ecada2014-05-04 05:16:16823 WebTaskList task_list_;
[email protected]97f9a7952014-03-14 11:50:33824
[email protected]79ecada2014-05-04 05:16:16825 TestInterfaces* test_interfaces_;
826 WebTestDelegate* delegate_;
[email protected]97f9a7952014-03-14 11:50:33827 blink::WebView* web_view_;
[email protected]a2ec0bc2014-04-23 08:18:27828 WebTestProxyBase* proxy_;
[email protected]97f9a7952014-03-14 11:50:33829
830 // This is non-0 IFF a load is in progress.
831 blink::WebFrame* top_loading_frame_;
832
mlamouri007f9d72015-02-27 16:27:25833 // WebContentSettingsClient mock object.
834 scoped_ptr<WebContentSettings> web_content_settings_;
[email protected]97f9a7952014-03-14 11:50:33835
[email protected]97f9a7952014-03-14 11:50:33836 bool pointer_locked_;
837 enum {
838 PointerLockWillSucceed,
839 PointerLockWillRespondAsync,
840 PointerLockWillFailSync,
841 } pointer_lock_planned_result_;
842 bool use_mock_theme_;
843
844 base::WeakPtrFactory<TestRunner> weak_factory_;
845
846 DISALLOW_COPY_AND_ASSIGN(TestRunner);
847};
848
jochenf5f31752015-06-03 12:06:34849} // namespace test_runner
[email protected]97f9a7952014-03-14 11:50:33850
jochen73e711c2015-06-03 10:01:46851#endif // COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_