OLD | NEW |
| (Empty) |
1 // Copyright 2013 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 | |
5 /* | |
6 * Copyright (C) 2010 Google Inc. All rights reserved. | |
7 * Copyright (C) 2010 Pawel Hajdan (phajdan.jr@chromium.org) | |
8 * Copyright (C) 2012 Apple Inc. All Rights Reserved. | |
9 * | |
10 * Redistribution and use in source and binary forms, with or without | |
11 * modification, are permitted provided that the following conditions are | |
12 * met: | |
13 * | |
14 * * Redistributions of source code must retain the above copyright | |
15 * notice, this list of conditions and the following disclaimer. | |
16 * * Redistributions in binary form must reproduce the above | |
17 * copyright notice, this list of conditions and the following disclaimer | |
18 * in the documentation and/or other materials provided with the | |
19 * distribution. | |
20 * * Neither the name of Google Inc. nor the names of its | |
21 * contributors may be used to endorse or promote products derived from | |
22 * this software without specific prior written permission. | |
23 * | |
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
35 */ | |
36 | |
37 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_TESTRUNNER_H_ | |
38 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_TESTRUNNER_H_ | |
39 | |
40 #include <deque> | |
41 #include <set> | |
42 #include <string> | |
43 | |
44 #include "base/memory/scoped_ptr.h" | |
45 #include "content/shell/renderer/test_runner/CppBoundClass.h" | |
46 #include "content/shell/renderer/test_runner/TestCommon.h" | |
47 #include "content/shell/renderer/test_runner/WebTask.h" | |
48 #include "content/shell/renderer/test_runner/WebTestRunner.h" | |
49 #include "third_party/WebKit/public/platform/WebCanvas.h" | |
50 #include "third_party/WebKit/public/platform/WebURL.h" | |
51 #include "third_party/WebKit/public/web/WebArrayBufferView.h" | |
52 #include "third_party/WebKit/public/web/WebPageOverlay.h" | |
53 #include "third_party/WebKit/public/web/WebTextDirection.h" | |
54 #include "third_party/skia/include/core/SkCanvas.h" | |
55 | |
56 namespace blink { | |
57 class WebArrayBufferView; | |
58 class WebNotificationPresenter; | |
59 class WebPageOverlay; | |
60 class WebPermissionClient; | |
61 class WebView; | |
62 } | |
63 | |
64 namespace content { | |
65 class NotificationPresenter; | |
66 } | |
67 | |
68 namespace WebTestRunner { | |
69 | |
70 class TestInterfaces; | |
71 class WebPermissions; | |
72 class WebTestDelegate; | |
73 class WebTestProxyBase; | |
74 | |
75 class TestRunner : public WebTestRunner, public CppBoundClass { | |
76 public: | |
77 explicit TestRunner(TestInterfaces*); | |
78 virtual ~TestRunner(); | |
79 | |
80 void setDelegate(WebTestDelegate*); | |
81 void setWebView(blink::WebView*, WebTestProxyBase*); | |
82 | |
83 void reset(); | |
84 | |
85 WebTaskList* taskList() { return &m_taskList; } | |
86 | |
87 void setTestIsRunning(bool); | |
88 bool testIsRunning() const { return m_testIsRunning; } | |
89 | |
90 bool useMockTheme() const { return m_useMockTheme; } | |
91 | |
92 // WebTestRunner implementation. | |
93 virtual bool shouldGeneratePixelResults() OVERRIDE; | |
94 virtual bool shouldDumpAsAudio() const OVERRIDE; | |
95 virtual const blink::WebArrayBufferView* audioData() const OVERRIDE; | |
96 virtual bool shouldDumpBackForwardList() const OVERRIDE; | |
97 virtual blink::WebPermissionClient* webPermissions() const OVERRIDE; | |
98 | |
99 // Methods used by WebTestProxyBase. | |
100 bool shouldDumpSelectionRect() const; | |
101 bool testRepaint() const; | |
102 bool sweepHorizontally() const; | |
103 bool isPrinting() const; | |
104 bool shouldDumpAsText(); | |
105 bool shouldDumpAsTextWithPixelResults(); | |
106 bool shouldDumpAsMarkup(); | |
107 bool shouldDumpChildFrameScrollPositions() const; | |
108 bool shouldDumpChildFramesAsText() const; | |
109 void showDevTools(const std::string& settings); | |
110 void clearDevToolsLocalStorage(); | |
111 void setShouldDumpAsText(bool); | |
112 void setShouldDumpAsMarkup(bool); | |
113 void setShouldGeneratePixelResults(bool); | |
114 void setShouldDumpFrameLoadCallbacks(bool); | |
115 void setShouldDumpPingLoaderCallbacks(bool); | |
116 void setShouldEnableViewSource(bool); | |
117 bool shouldDumpEditingCallbacks() const; | |
118 bool shouldDumpFrameLoadCallbacks() const; | |
119 bool shouldDumpPingLoaderCallbacks() const; | |
120 bool shouldDumpUserGestureInFrameLoadCallbacks() const; | |
121 bool shouldDumpTitleChanges() const; | |
122 bool shouldDumpIconChanges() const; | |
123 bool shouldDumpCreateView() const; | |
124 bool canOpenWindows() const; | |
125 bool shouldDumpResourceLoadCallbacks() const; | |
126 bool shouldDumpResourceRequestCallbacks() const; | |
127 bool shouldDumpResourceResponseMIMETypes() const; | |
128 bool shouldDumpStatusCallbacks() const; | |
129 bool shouldDumpProgressFinishedCallback() const; | |
130 bool shouldDumpSpellCheckCallbacks() const; | |
131 bool shouldStayOnPageAfterHandlingBeforeUnload() const; | |
132 const std::set<std::string>* httpHeadersToClear() const; | |
133 void setTopLoadingFrame(blink::WebFrame*, bool); | |
134 blink::WebFrame* topLoadingFrame() const; | |
135 void policyDelegateDone(); | |
136 bool policyDelegateEnabled() const; | |
137 bool policyDelegateIsPermissive() const; | |
138 bool policyDelegateShouldNotifyDone() const; | |
139 bool shouldInterceptPostMessage() const; | |
140 bool shouldDumpResourcePriorities() const; | |
141 blink::WebNotificationPresenter* notification_presenter() const; | |
142 bool requestPointerLock(); | |
143 void requestPointerUnlock(); | |
144 bool isPointerLocked(); | |
145 void setToolTipText(const blink::WebString&); | |
146 | |
147 bool midiAccessorResult(); | |
148 | |
149 // A single item in the work queue. | |
150 class WorkItem { | |
151 public: | |
152 virtual ~WorkItem() { } | |
153 | |
154 // Returns true if this started a load. | |
155 virtual bool run(WebTestDelegate*, blink::WebView*) = 0; | |
156 }; | |
157 | |
158 private: | |
159 friend class WorkQueue; | |
160 | |
161 // Helper class for managing events queued by methods like queueLoad or | |
162 // queueScript. | |
163 class WorkQueue { | |
164 public: | |
165 explicit WorkQueue(TestRunner* controller); | |
166 virtual ~WorkQueue(); | |
167 void processWorkSoon(); | |
168 | |
169 // Reset the state of the class between tests. | |
170 void reset(); | |
171 | |
172 void addWork(WorkItem*); | |
173 | |
174 void setFrozen(bool frozen) { m_frozen = frozen; } | |
175 bool isEmpty() { return m_queue.empty(); } | |
176 WebTaskList* taskList() { return &m_taskList; } | |
177 | |
178 private: | |
179 void processWork(); | |
180 class WorkQueueTask: public WebMethodTask<WorkQueue> { | |
181 public: | |
182 WorkQueueTask(WorkQueue* object): WebMethodTask<WorkQueue>(object) {
} | |
183 virtual void runIfValid() OVERRIDE; | |
184 }; | |
185 | |
186 WebTaskList m_taskList; | |
187 std::deque<WorkItem*> m_queue; | |
188 bool m_frozen; | |
189 TestRunner* m_controller; | |
190 }; | |
191 /////////////////////////////////////////////////////////////////////////// | |
192 // Methods dealing with the test logic | |
193 | |
194 // By default, tests end when page load is complete. These methods are used | |
195 // to delay the completion of the test until notifyDone is called. | |
196 void waitUntilDone(const CppArgumentList&, CppVariant*); | |
197 void notifyDone(const CppArgumentList&, CppVariant*); | |
198 | |
199 // Methods for adding actions to the work queue. Used in conjunction with | |
200 // waitUntilDone/notifyDone above. | |
201 void queueBackNavigation(const CppArgumentList&, CppVariant*); | |
202 void queueForwardNavigation(const CppArgumentList&, CppVariant*); | |
203 void queueReload(const CppArgumentList&, CppVariant*); | |
204 void queueLoadingScript(const CppArgumentList&, CppVariant*); | |
205 void queueNonLoadingScript(const CppArgumentList&, CppVariant*); | |
206 void queueLoad(const CppArgumentList&, CppVariant*); | |
207 void queueLoadHTMLString(const CppArgumentList&, CppVariant*); | |
208 | |
209 | |
210 // Causes navigation actions just printout the intended navigation instead | |
211 // of taking you to the page. This is used for cases like mailto, where you | |
212 // don't actually want to open the mail program. | |
213 void setCustomPolicyDelegate(const CppArgumentList&, CppVariant*); | |
214 | |
215 // Delays completion of the test until the policy delegate runs. | |
216 void waitForPolicyDelegate(const CppArgumentList&, CppVariant*); | |
217 | |
218 // Functions for dealing with windows. By default we block all new windows. | |
219 void windowCount(const CppArgumentList&, CppVariant*); | |
220 void setCloseRemainingWindowsWhenComplete(const CppArgumentList&, CppVariant
*); | |
221 | |
222 void resetTestHelperControllers(const CppArgumentList&, CppVariant*); | |
223 | |
224 /////////////////////////////////////////////////////////////////////////// | |
225 // Methods implemented entirely in terms of chromium's public WebKit API | |
226 | |
227 // Method that controls whether pressing Tab key cycles through page element
s | |
228 // or inserts a '\t' char in text area | |
229 void setTabKeyCyclesThroughElements(const CppArgumentList&, CppVariant*); | |
230 | |
231 // Executes an internal command (superset of document.execCommand() commands
). | |
232 void execCommand(const CppArgumentList&, CppVariant*); | |
233 | |
234 // Checks if an internal command is currently available. | |
235 void isCommandEnabled(const CppArgumentList&, CppVariant*); | |
236 | |
237 void callShouldCloseOnWebView(const CppArgumentList&, CppVariant*); | |
238 void setDomainRelaxationForbiddenForURLScheme(const CppArgumentList&, CppVar
iant*); | |
239 void evaluateScriptInIsolatedWorldAndReturnValue(const CppArgumentList&, Cpp
Variant*); | |
240 void evaluateScriptInIsolatedWorld(const CppArgumentList&, CppVariant*); | |
241 void setIsolatedWorldSecurityOrigin(const CppArgumentList&, CppVariant*); | |
242 void setIsolatedWorldContentSecurityPolicy(const CppArgumentList&, CppVarian
t*); | |
243 | |
244 // Allows layout tests to manage origins' whitelisting. | |
245 void addOriginAccessWhitelistEntry(const CppArgumentList&, CppVariant*); | |
246 void removeOriginAccessWhitelistEntry(const CppArgumentList&, CppVariant*); | |
247 | |
248 // Returns true if the current page box has custom page size style for | |
249 // printing. | |
250 void hasCustomPageSizeStyle(const CppArgumentList&, CppVariant*); | |
251 | |
252 // Forces the selection colors for testing under Linux. | |
253 void forceRedSelectionColors(const CppArgumentList&, CppVariant*); | |
254 | |
255 // Adds a style sheet to be injected into new documents. | |
256 void injectStyleSheet(const CppArgumentList&, CppVariant*); | |
257 | |
258 void startSpeechInput(const CppArgumentList&, CppVariant*); | |
259 | |
260 void findString(const CppArgumentList&, CppVariant*); | |
261 | |
262 // Expects the first argument to be an input element and the second argument
to be a string value. | |
263 // Forwards the setValueForUser() call to the element. | |
264 void setValueForUser(const CppArgumentList&, CppVariant*); | |
265 | |
266 void selectionAsMarkup(const CppArgumentList&, CppVariant*); | |
267 | |
268 // Enables or disables subpixel positioning (i.e. fractional X positions for | |
269 // glyphs) in text rendering on Linux. Since this method changes global | |
270 // settings, tests that call it must use their own custom font family for | |
271 // all text that they render. If not, an already-cached style will be used, | |
272 // resulting in the changed setting being ignored. | |
273 void setTextSubpixelPositioning(const CppArgumentList&, CppVariant*); | |
274 | |
275 // Switch the visibility of the page. | |
276 void setPageVisibility(const CppArgumentList&, CppVariant*); | |
277 | |
278 // Changes the direction of the focused element. | |
279 void setTextDirection(const CppArgumentList&, CppVariant*); | |
280 | |
281 // Retrieves the text surrounding a position in a text node. | |
282 // Expects the first argument to be a text node, the second and third to be | |
283 // point coordinates relative to the node and the fourth the maximum text | |
284 // length to retrieve. | |
285 void textSurroundingNode(const CppArgumentList&, CppVariant*); | |
286 | |
287 // After this function is called, all window-sizing machinery is | |
288 // short-circuited inside the renderer. This mode is necessary for | |
289 // some tests that were written before browsers had multi-process architectu
re | |
290 // and rely on window resizes to happen synchronously. | |
291 // The function has "unfortunate" it its name because we must strive to remo
ve all tests | |
292 // that rely on this... well, unfortunate behavior. See http://crbug.com/309
760 for the plan. | |
293 void useUnfortunateSynchronousResizeMode(const CppArgumentList&, CppVariant*
); | |
294 | |
295 void enableAutoResizeMode(const CppArgumentList&, CppVariant*); | |
296 void disableAutoResizeMode(const CppArgumentList&, CppVariant*); | |
297 | |
298 // Device Motion / Device Orientation related functions | |
299 void setMockDeviceMotion(const CppArgumentList&, CppVariant*); | |
300 void setMockDeviceOrientation(const CppArgumentList&, CppVariant*); | |
301 | |
302 void didAcquirePointerLock(const CppArgumentList&, CppVariant*); | |
303 void didNotAcquirePointerLock(const CppArgumentList&, CppVariant*); | |
304 void didLosePointerLock(const CppArgumentList&, CppVariant*); | |
305 void setPointerLockWillFailSynchronously(const CppArgumentList&, CppVariant*
); | |
306 void setPointerLockWillRespondAsynchronously(const CppArgumentList&, CppVari
ant*); | |
307 | |
308 /////////////////////////////////////////////////////////////////////////// | |
309 // Methods modifying WebPreferences. | |
310 | |
311 // Set the WebPreference that controls webkit's popup blocking. | |
312 void setPopupBlockingEnabled(const CppArgumentList&, CppVariant*); | |
313 | |
314 void setJavaScriptCanAccessClipboard(const CppArgumentList&, CppVariant*); | |
315 void setXSSAuditorEnabled(const CppArgumentList&, CppVariant*); | |
316 void setAllowUniversalAccessFromFileURLs(const CppArgumentList&, CppVariant*
); | |
317 void setAllowFileAccessFromFileURLs(const CppArgumentList&, CppVariant*); | |
318 void overridePreference(const CppArgumentList&, CppVariant*); | |
319 | |
320 // Enable or disable plugins. | |
321 void setPluginsEnabled(const CppArgumentList&, CppVariant*); | |
322 | |
323 /////////////////////////////////////////////////////////////////////////// | |
324 // Methods that modify the state of TestRunner | |
325 | |
326 // This function sets a flag that tells the test_shell to print a line of | |
327 // descriptive text for each editing command. It takes no arguments, and | |
328 // ignores any that may be present. | |
329 void dumpEditingCallbacks(const CppArgumentList&, CppVariant*); | |
330 | |
331 // This function sets a flag that tells the test_shell to dump pages as | |
332 // plain text, rather than as a text representation of the renderer's state. | |
333 // The pixel results will not be generated for this test. | |
334 void dumpAsText(const CppArgumentList&, CppVariant*); | |
335 | |
336 // This function sets a flag that tells the test_shell to dump pages as | |
337 // plain text, rather than as a text representation of the renderer's state. | |
338 // It will also generate a pixel dump for the test. | |
339 void dumpAsTextWithPixelResults(const CppArgumentList&, CppVariant*); | |
340 | |
341 // This function sets a flag that tells the test_shell to print out the | |
342 // scroll offsets of the child frames. It ignores all. | |
343 void dumpChildFrameScrollPositions(const CppArgumentList&, CppVariant*); | |
344 | |
345 // This function sets a flag that tells the test_shell to recursively | |
346 // dump all frames as plain text if the dumpAsText flag is set. | |
347 // It takes no arguments, and ignores any that may be present. | |
348 void dumpChildFramesAsText(const CppArgumentList&, CppVariant*); | |
349 | |
350 // This function sets a flag that tells the test_shell to print out the | |
351 // information about icon changes notifications from WebKit. | |
352 void dumpIconChanges(const CppArgumentList&, CppVariant*); | |
353 | |
354 // Deals with Web Audio WAV file data. | |
355 void setAudioData(const CppArgumentList&, CppVariant*); | |
356 | |
357 // This function sets a flag that tells the test_shell to print a line of | |
358 // descriptive text for each frame load callback. It takes no arguments, and | |
359 // ignores any that may be present. | |
360 void dumpFrameLoadCallbacks(const CppArgumentList&, CppVariant*); | |
361 | |
362 // This function sets a flag that tells the test_shell to print a line of | |
363 // descriptive text for each PingLoader dispatch. It takes no arguments, and | |
364 // ignores any that may be present. | |
365 void dumpPingLoaderCallbacks(const CppArgumentList&, CppVariant*); | |
366 | |
367 // This function sets a flag that tells the test_shell to print a line of | |
368 // user gesture status text for some frame load callbacks. It takes no | |
369 // arguments, and ignores any that may be present. | |
370 void dumpUserGestureInFrameLoadCallbacks(const CppArgumentList&, CppVariant*
); | |
371 | |
372 void dumpTitleChanges(const CppArgumentList&, CppVariant*); | |
373 | |
374 // This function sets a flag that tells the test_shell to dump all calls to | |
375 // WebViewClient::createView(). | |
376 // It takes no arguments, and ignores any that may be present. | |
377 void dumpCreateView(const CppArgumentList&, CppVariant*); | |
378 | |
379 void setCanOpenWindows(const CppArgumentList&, CppVariant*); | |
380 | |
381 // This function sets a flag that tells the test_shell to dump a descriptive | |
382 // line for each resource load callback. It takes no arguments, and ignores | |
383 // any that may be present. | |
384 void dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant*); | |
385 | |
386 // This function sets a flag that tells the test_shell to print a line of | |
387 // descriptive text for each element that requested a resource. It takes no | |
388 // arguments, and ignores any that may be present. | |
389 void dumpResourceRequestCallbacks(const CppArgumentList&, CppVariant*); | |
390 | |
391 // This function sets a flag that tells the test_shell to dump the MIME type | |
392 // for each resource that was loaded. It takes no arguments, and ignores any | |
393 // that may be present. | |
394 void dumpResourceResponseMIMETypes(const CppArgumentList&, CppVariant*); | |
395 | |
396 // WebPermissionClient related. | |
397 void setImagesAllowed(const CppArgumentList&, CppVariant*); | |
398 void setScriptsAllowed(const CppArgumentList&, CppVariant*); | |
399 void setStorageAllowed(const CppArgumentList&, CppVariant*); | |
400 void setPluginsAllowed(const CppArgumentList&, CppVariant*); | |
401 void setAllowDisplayOfInsecureContent(const CppArgumentList&, CppVariant*); | |
402 void setAllowRunningOfInsecureContent(const CppArgumentList&, CppVariant*); | |
403 void dumpPermissionClientCallbacks(const CppArgumentList&, CppVariant*); | |
404 | |
405 // This function sets a flag that tells the test_shell to dump all calls | |
406 // to window.status(). | |
407 // It takes no arguments, and ignores any that may be present. | |
408 void dumpWindowStatusChanges(const CppArgumentList&, CppVariant*); | |
409 | |
410 // This function sets a flag that tells the test_shell to print a line of | |
411 // descriptive text for the progress finished callback. It takes no | |
412 // arguments, and ignores any that may be present. | |
413 void dumpProgressFinishedCallback(const CppArgumentList&, CppVariant*); | |
414 | |
415 // This function sets a flag that tells the test_shell to dump all | |
416 // the lines of descriptive text about spellcheck execution. | |
417 void dumpSpellCheckCallbacks(const CppArgumentList&, CppVariant*); | |
418 | |
419 // This function sets a flag that tells the test_shell to print out a text | |
420 // representation of the back/forward list. It ignores all arguments. | |
421 void dumpBackForwardList(const CppArgumentList&, CppVariant*); | |
422 | |
423 void dumpSelectionRect(const CppArgumentList&, CppVariant*); | |
424 void testRepaint(const CppArgumentList&, CppVariant*); | |
425 void repaintSweepHorizontally(const CppArgumentList&, CppVariant*); | |
426 | |
427 // Causes layout to happen as if targetted to printed pages. | |
428 void setPrinting(const CppArgumentList&, CppVariant*); | |
429 | |
430 void setShouldStayOnPageAfterHandlingBeforeUnload(const CppArgumentList&, Cp
pVariant*); | |
431 | |
432 // Causes WillSendRequest to clear certain headers. | |
433 void setWillSendRequestClearHeader(const CppArgumentList&, CppVariant*); | |
434 | |
435 // This function sets a flag that tells the test_shell to dump a descriptive | |
436 // line for each resource load's priority and any time that priority | |
437 // changes. It takes no arguments, and ignores any that may be present. | |
438 void dumpResourceRequestPriorities(const CppArgumentList&, CppVariant*); | |
439 | |
440 // Sets a flag to enable the mock theme. | |
441 void setUseMockTheme(const CppArgumentList&, CppVariant*); | |
442 | |
443 /////////////////////////////////////////////////////////////////////////// | |
444 // Methods interacting with the WebTestProxy | |
445 | |
446 /////////////////////////////////////////////////////////////////////////// | |
447 // Methods forwarding to the WebTestDelegate | |
448 | |
449 // Shows DevTools window. | |
450 void showWebInspector(const CppArgumentList&, CppVariant*); | |
451 void closeWebInspector(const CppArgumentList&, CppVariant*); | |
452 | |
453 // Inspect chooser state | |
454 void isChooserShown(const CppArgumentList&, CppVariant*); | |
455 | |
456 // Allows layout tests to exec scripts at WebInspector side. | |
457 void evaluateInWebInspector(const CppArgumentList&, CppVariant*); | |
458 | |
459 // Clears all databases. | |
460 void clearAllDatabases(const CppArgumentList&, CppVariant*); | |
461 // Sets the default quota for all origins | |
462 void setDatabaseQuota(const CppArgumentList&, CppVariant*); | |
463 | |
464 // Changes the cookie policy from the default to allow all cookies. | |
465 void setAlwaysAcceptCookies(const CppArgumentList&, CppVariant*); | |
466 | |
467 // Gives focus to the window. | |
468 void setWindowIsKey(const CppArgumentList&, CppVariant*); | |
469 | |
470 // Converts a URL starting with file:///tmp/ to the local mapping. | |
471 void pathToLocalResource(const CppArgumentList&, CppVariant*); | |
472 | |
473 // Used to set the device scale factor. | |
474 void setBackingScaleFactor(const CppArgumentList&, CppVariant*); | |
475 | |
476 // Calls setlocale(LC_ALL, ...) for a specified locale. | |
477 // Resets between tests. | |
478 void setPOSIXLocale(const CppArgumentList&, CppVariant*); | |
479 | |
480 // MIDI function to control permission handling. | |
481 void setMIDIAccessorResult(const CppArgumentList&, CppVariant*); | |
482 void setMIDISysExPermission(const CppArgumentList&, CppVariant*); | |
483 | |
484 // Grants permission for desktop notifications to an origin | |
485 void grantWebNotificationPermission(const CppArgumentList&, CppVariant*); | |
486 // Simulates a click on a desktop notification. | |
487 void simulateWebNotificationClick(const CppArgumentList&, CppVariant*); | |
488 | |
489 // Speech input related functions. | |
490 void addMockSpeechInputResult(const CppArgumentList&, CppVariant*); | |
491 void setMockSpeechInputDumpRect(const CppArgumentList&, CppVariant*); | |
492 void addMockSpeechRecognitionResult(const CppArgumentList&, CppVariant*); | |
493 void setMockSpeechRecognitionError(const CppArgumentList&, CppVariant*); | |
494 void wasMockSpeechRecognitionAborted(const CppArgumentList&, CppVariant*); | |
495 | |
496 // WebPageOverlay related functions. Permits the adding and removing of only | |
497 // one opaque overlay. | |
498 void addWebPageOverlay(const CppArgumentList&, CppVariant*); | |
499 void removeWebPageOverlay(const CppArgumentList&, CppVariant*); | |
500 | |
501 void display(const CppArgumentList&, CppVariant*); | |
502 void displayInvalidatedRegion(const CppArgumentList&, CppVariant*); | |
503 | |
504 ////////////////////////////////////////////////////////////////////////// | |
505 // Fallback and stub methods | |
506 | |
507 // The fallback method is called when a nonexistent method is called on | |
508 // the layout test controller object. | |
509 // It is usefull to catch typos in the JavaScript code (a few layout tests | |
510 // do have typos in them) and it allows the script to continue running in | |
511 // that case (as the Mac does). | |
512 void fallbackMethod(const CppArgumentList&, CppVariant*); | |
513 | |
514 // Stub for not implemented methods. | |
515 void notImplemented(const CppArgumentList&, CppVariant*); | |
516 | |
517 /////////////////////////////////////////////////////////////////////////// | |
518 // Internal helpers | |
519 void checkResponseMimeType(); | |
520 void completeNotifyDone(); | |
521 class HostMethodTask : public WebMethodTask<TestRunner> { | |
522 public: | |
523 typedef void (TestRunner::*CallbackMethodType)(); | |
524 HostMethodTask(TestRunner* object, CallbackMethodType callback); | |
525 | |
526 virtual void runIfValid() OVERRIDE; | |
527 | |
528 private: | |
529 CallbackMethodType m_callback; | |
530 }; | |
531 class TestPageOverlay : public blink::WebPageOverlay { | |
532 public: | |
533 explicit TestPageOverlay(blink::WebView*); | |
534 virtual void paintPageOverlay(blink::WebCanvas*) OVERRIDE; | |
535 virtual ~TestPageOverlay(); | |
536 private: | |
537 blink::WebView* m_webView; | |
538 }; | |
539 void didAcquirePointerLockInternal(); | |
540 void didNotAcquirePointerLockInternal(); | |
541 void didLosePointerLockInternal(); | |
542 | |
543 bool cppVariantToBool(const CppVariant&); | |
544 int32_t cppVariantToInt32(const CppVariant&); | |
545 blink::WebString cppVariantToWebString(const CppVariant&); | |
546 | |
547 void printErrorMessage(const std::string&); | |
548 | |
549 // In the Mac code, this is called to trigger the end of a test after the | |
550 // page has finished loading. From here, we can generate the dump for the | |
551 // test. | |
552 void locationChangeDone(); | |
553 | |
554 bool m_testIsRunning; | |
555 | |
556 // When reset is called, go through and close all but the main test shell | |
557 // window. By default, set to true but toggled to false using | |
558 // setCloseRemainingWindowsWhenComplete(). | |
559 bool m_closeRemainingWindows; | |
560 | |
561 // If true, don't dump output until notifyDone is called. | |
562 bool m_waitUntilDone; | |
563 | |
564 // Causes navigation actions just printout the intended navigation instead | |
565 // of taking you to the page. This is used for cases like mailto, where you | |
566 // don't actually want to open the mail program. | |
567 bool m_policyDelegateEnabled; | |
568 | |
569 // Toggles the behavior of the policy delegate. If true, then navigations | |
570 // will be allowed. Otherwise, they will be ignored (dropped). | |
571 bool m_policyDelegateIsPermissive; | |
572 | |
573 // If true, the policy delegate will signal layout test completion. | |
574 bool m_policyDelegateShouldNotifyDone; | |
575 | |
576 WorkQueue m_workQueue; | |
577 | |
578 // globalFlag is used by a number of layout tests in http/tests/security/dat
aURL. | |
579 CppVariant m_globalFlag; | |
580 | |
581 // Bound variable to return the name of this platform (chromium). | |
582 CppVariant m_platformName; | |
583 | |
584 // Bound variable counting the number of top URLs visited. | |
585 CppVariant m_webHistoryItemCount; | |
586 | |
587 // Bound variable to set whether postMessages should be intercepted or not | |
588 CppVariant m_interceptPostMessage; | |
589 | |
590 // Bound variable to store the last tooltip text | |
591 CppVariant m_tooltipText; | |
592 | |
593 // Bound variable to disable notifyDone calls. This is used in GC leak | |
594 // tests, where existing LayoutTests are loaded within an iframe. The GC | |
595 // test harness will set this flag to ignore the notifyDone calls from the | |
596 // target LayoutTest. | |
597 CppVariant m_disableNotifyDone; | |
598 | |
599 // If true, the test_shell will write a descriptive line for each editing | |
600 // command. | |
601 bool m_dumpEditingCallbacks; | |
602 | |
603 // If true, the test_shell will generate pixel results in dumpAsText mode | |
604 bool m_generatePixelResults; | |
605 | |
606 // If true, the test_shell will produce a plain text dump rather than a | |
607 // text representation of the renderer. | |
608 bool m_dumpAsText; | |
609 | |
610 // If true and if dump_as_text_ is true, the test_shell will recursively | |
611 // dump all frames as plain text. | |
612 bool m_dumpChildFramesAsText; | |
613 | |
614 // If true, the test_shell will produce a dump of the DOM rather than a text | |
615 // representation of the renderer. | |
616 bool m_dumpAsMarkup; | |
617 | |
618 // If true, the test_shell will print out the child frame scroll offsets as | |
619 // well. | |
620 bool m_dumpChildFrameScrollPositions; | |
621 | |
622 // If true, the test_shell will print out the icon change notifications. | |
623 bool m_dumpIconChanges; | |
624 | |
625 // If true, the test_shell will output a base64 encoded WAVE file. | |
626 bool m_dumpAsAudio; | |
627 | |
628 // If true, the test_shell will output a descriptive line for each frame | |
629 // load callback. | |
630 bool m_dumpFrameLoadCallbacks; | |
631 | |
632 // If true, the test_shell will output a descriptive line for each | |
633 // PingLoader dispatched. | |
634 bool m_dumpPingLoaderCallbacks; | |
635 | |
636 // If true, the test_shell will output a line of the user gesture status | |
637 // text for some frame load callbacks. | |
638 bool m_dumpUserGestureInFrameLoadCallbacks; | |
639 | |
640 // If true, output a message when the page title is changed. | |
641 bool m_dumpTitleChanges; | |
642 | |
643 // If true, output a descriptive line each time WebViewClient::createView | |
644 // is invoked. | |
645 bool m_dumpCreateView; | |
646 | |
647 // If true, new windows can be opened via javascript or by plugins. By | |
648 // default, set to false and can be toggled to true using | |
649 // setCanOpenWindows(). | |
650 bool m_canOpenWindows; | |
651 | |
652 // If true, the test_shell will output a descriptive line for each resource | |
653 // load callback. | |
654 bool m_dumpResourceLoadCallbacks; | |
655 | |
656 // If true, the test_shell will output a descriptive line for each resource | |
657 // request callback. | |
658 bool m_dumpResourceRequestCallbacks; | |
659 | |
660 // If true, the test_shell will output the MIME type for each resource that | |
661 // was loaded. | |
662 bool m_dumpResourceResponseMIMETypes; | |
663 | |
664 // If true, the test_shell will dump all changes to window.status. | |
665 bool m_dumpWindowStatusChanges; | |
666 | |
667 // If true, the test_shell will output a descriptive line for the progress | |
668 // finished callback. | |
669 bool m_dumpProgressFinishedCallback; | |
670 | |
671 // If true, the test_shell will output descriptive test for spellcheck | |
672 // execution. | |
673 bool m_dumpSpellCheckCallbacks; | |
674 | |
675 // If true, the test_shell will produce a dump of the back forward list as | |
676 // well. | |
677 bool m_dumpBackForwardList; | |
678 | |
679 // If true, the test_shell will draw the bounds of the current selection rec
t | |
680 // taking possible transforms of the selection rect into account. | |
681 bool m_dumpSelectionRect; | |
682 | |
683 // If true, pixel dump will be produced as a series of 1px-tall, view-wide | |
684 // individual paints over the height of the view. | |
685 bool m_testRepaint; | |
686 | |
687 // If true and test_repaint_ is true as well, pixel dump will be produced as | |
688 // a series of 1px-wide, view-tall paints across the width of the view. | |
689 bool m_sweepHorizontally; | |
690 | |
691 // If true, layout is to target printed pages. | |
692 bool m_isPrinting; | |
693 | |
694 // If false, MockWebMIDIAccessor fails on startSession() for testing. | |
695 bool m_midiAccessorResult; | |
696 | |
697 bool m_shouldStayOnPageAfterHandlingBeforeUnload; | |
698 | |
699 bool m_shouldDumpResourcePriorities; | |
700 | |
701 std::set<std::string> m_httpHeadersToClear; | |
702 | |
703 // WAV audio data is stored here. | |
704 blink::WebArrayBufferView m_audioData; | |
705 | |
706 // Used for test timeouts. | |
707 WebTaskList m_taskList; | |
708 | |
709 TestInterfaces* m_testInterfaces; | |
710 WebTestDelegate* m_delegate; | |
711 blink::WebView* m_webView; | |
712 TestPageOverlay* m_pageOverlay; | |
713 WebTestProxyBase* m_proxy; | |
714 | |
715 // This is non-0 IFF a load is in progress. | |
716 blink::WebFrame* m_topLoadingFrame; | |
717 | |
718 // WebPermissionClient mock object. | |
719 scoped_ptr<WebPermissions> m_webPermissions; | |
720 | |
721 scoped_ptr<content::NotificationPresenter> notification_presenter_; | |
722 | |
723 bool m_pointerLocked; | |
724 enum { | |
725 PointerLockWillSucceed, | |
726 PointerLockWillRespondAsync, | |
727 PointerLockWillFailSync, | |
728 } m_pointerLockPlannedResult; | |
729 bool m_useMockTheme; | |
730 }; | |
731 | |
732 } | |
733 | |
734 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_TESTRUNNER_H_ | |
OLD | NEW |