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