OLD | NEW |
(Empty) | |
| 1 // 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 |
| 5 #include "content/shell/renderer/test_runner/test_runner.h" |
| 6 |
| 7 #include <limits> |
| 8 |
| 9 #include "content/shell/common/test_runner/WebPreferences.h" |
| 10 #include "content/shell/renderer/test_runner/MockWebSpeechInputController.h" |
| 11 #include "content/shell/renderer/test_runner/MockWebSpeechRecognizer.h" |
| 12 #include "content/shell/renderer/test_runner/TestInterfaces.h" |
| 13 #include "content/shell/renderer/test_runner/WebPermissions.h" |
| 14 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
| 15 #include "content/shell/renderer/test_runner/WebTestProxy.h" |
| 16 #include "content/shell/renderer/test_runner/notification_presenter.h" |
| 17 #include "gin/arguments.h" |
| 18 #include "gin/array_buffer.h" |
| 19 #include "gin/handle.h" |
| 20 #include "gin/object_template_builder.h" |
| 21 #include "gin/wrappable.h" |
| 22 #include "third_party/WebKit/public/platform/WebCanvas.h" |
| 23 #include "third_party/WebKit/public/platform/WebData.h" |
| 24 #include "third_party/WebKit/public/platform/WebDeviceMotionData.h" |
| 25 #include "third_party/WebKit/public/platform/WebDeviceOrientationData.h" |
| 26 #include "third_party/WebKit/public/platform/WebPoint.h" |
| 27 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 28 #include "third_party/WebKit/public/web/WebBindings.h" |
| 29 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 30 #include "third_party/WebKit/public/web/WebDocument.h" |
| 31 #include "third_party/WebKit/public/web/WebFindOptions.h" |
| 32 #include "third_party/WebKit/public/web/WebFrame.h" |
| 33 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 34 #include "third_party/WebKit/public/web/WebKit.h" |
| 35 #include "third_party/WebKit/public/web/WebMIDIClientMock.h" |
| 36 #include "third_party/WebKit/public/web/WebPageOverlay.h" |
| 37 #include "third_party/WebKit/public/web/WebScriptSource.h" |
| 38 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| 39 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
| 40 #include "third_party/WebKit/public/web/WebSettings.h" |
| 41 #include "third_party/WebKit/public/web/WebSurroundingText.h" |
| 42 #include "third_party/WebKit/public/web/WebView.h" |
| 43 #include "third_party/skia/include/core/SkCanvas.h" |
| 44 |
| 45 #if defined(__linux__) || defined(ANDROID) |
| 46 #include "third_party/WebKit/public/web/linux/WebFontRendering.h" |
| 47 #endif |
| 48 |
| 49 using namespace blink; |
| 50 using namespace WebTestRunner; |
| 51 |
| 52 namespace { |
| 53 |
| 54 WebString V8StringToWebString(v8::Handle<v8::String> v8_str) { |
| 55 int length = v8_str->Utf8Length() + 1; |
| 56 scoped_ptr<char[]> chars(new char[length]); |
| 57 v8_str->WriteUtf8(chars.get(), length); |
| 58 return WebString::fromUTF8(chars.get()); |
| 59 } |
| 60 |
| 61 class HostMethodTask : |
| 62 public ::WebTestRunner::WebMethodTask<content::TestRunner> { |
| 63 public: |
| 64 typedef void (content::TestRunner::*CallbackMethodType)(); |
| 65 HostMethodTask(content::TestRunner* object, CallbackMethodType callback) |
| 66 : WebMethodTask<content::TestRunner>(object), callback_(callback) {} |
| 67 |
| 68 virtual void runIfValid() OVERRIDE { |
| 69 (m_object->*callback_)(); |
| 70 } |
| 71 |
| 72 private: |
| 73 CallbackMethodType callback_; |
| 74 }; |
| 75 |
| 76 } // namespace |
| 77 |
| 78 namespace content { |
| 79 |
| 80 class InvokeCallbackTask : public WebMethodTask<content::TestRunner> { |
| 81 public: |
| 82 InvokeCallbackTask(content::TestRunner* object, |
| 83 v8::Handle<v8::Function> callback) |
| 84 : WebMethodTask<content::TestRunner>(object), |
| 85 callback_(blink::mainThreadIsolate(), callback) {} |
| 86 |
| 87 virtual void runIfValid() OVERRIDE { |
| 88 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 89 v8::HandleScope handle_scope(isolate); |
| 90 WebFrame* frame = m_object->web_view_->mainFrame(); |
| 91 |
| 92 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); |
| 93 if (context.IsEmpty()) |
| 94 return; |
| 95 |
| 96 v8::Context::Scope context_scope(context); |
| 97 |
| 98 frame->callFunctionEvenIfScriptDisabled( |
| 99 v8::Local<v8::Function>::New(isolate, callback_), |
| 100 context->Global(), |
| 101 0, |
| 102 NULL); |
| 103 } |
| 104 |
| 105 private: |
| 106 v8::Persistent<v8::Function> callback_; |
| 107 }; |
| 108 |
| 109 class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> { |
| 110 public: |
| 111 static gin::WrapperInfo kWrapperInfo; |
| 112 |
| 113 static void Install(base::WeakPtr<TestRunner> controller, |
| 114 WebFrame* frame); |
| 115 |
| 116 private: |
| 117 explicit TestRunnerBindings( |
| 118 base::WeakPtr<TestRunner> controller); |
| 119 virtual ~TestRunnerBindings(); |
| 120 |
| 121 // gin::Wrappable: |
| 122 virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
| 123 v8::Isolate* isolate) OVERRIDE; |
| 124 |
| 125 void NotifyDone(); |
| 126 void WaitUntilDone(); |
| 127 void QueueBackNavigation(int how_far_back); |
| 128 void QueueForwardNavigation(int how_far_forward); |
| 129 void QueueReload(); |
| 130 void QueueLoadingScript(const std::string& script); |
| 131 void QueueNonLoadingScript(const std::string& script); |
| 132 void QueueLoad(gin::Arguments* args); |
| 133 void QueueLoadHTMLString(gin::Arguments* args); |
| 134 void SetCustomPolicyDelegate(gin::Arguments* args); |
| 135 void WaitForPolicyDelegate(); |
| 136 int WindowCount(); |
| 137 void SetCloseRemainingWindowsWhenComplete(gin::Arguments* args); |
| 138 void ResetTestHelperControllers(); |
| 139 void SetTabKeyCyclesThroughElements(bool tab_key_cycles_through_elements); |
| 140 void ExecCommand(gin::Arguments* args); |
| 141 bool IsCommandEnabled(const std::string& command); |
| 142 bool CallShouldCloseOnWebView(); |
| 143 void SetDomainRelaxationForbiddenForURLScheme(bool forbidden, |
| 144 const std::string& scheme); |
| 145 v8::Handle<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue( |
| 146 int world_id, const std::string& script); |
| 147 void EvaluateScriptInIsolatedWorld(int world_id, const std::string& script); |
| 148 void SetIsolatedWorldSecurityOrigin(int world_id, |
| 149 v8::Handle<v8::Value> origin); |
| 150 void SetIsolatedWorldContentSecurityPolicy(int world_id, |
| 151 const std::string& policy); |
| 152 void AddOriginAccessWhitelistEntry(const std::string& source_origin, |
| 153 const std::string& destination_protocol, |
| 154 const std::string& destination_host, |
| 155 bool allow_destination_subdomains); |
| 156 void RemoveOriginAccessWhitelistEntry(const std::string& source_origin, |
| 157 const std::string& destination_protocol, |
| 158 const std::string& destination_host, |
| 159 bool allow_destination_subdomains); |
| 160 bool HasCustomPageSizeStyle(int page_index); |
| 161 void ForceRedSelectionColors(); |
| 162 void InjectStyleSheet(const std::string& source_code, bool all_frames); |
| 163 bool FindString(const std::string& search_text, |
| 164 const std::vector<std::string>& options_array); |
| 165 std::string SelectionAsMarkup(); |
| 166 void SetTextSubpixelPositioning(bool value); |
| 167 void SetPageVisibility(const std::string& new_visibility); |
| 168 void SetTextDirection(const std::string& direction_name); |
| 169 void UseUnfortunateSynchronousResizeMode(); |
| 170 bool EnableAutoResizeMode(int min_width, |
| 171 int min_height, |
| 172 int max_width, |
| 173 int max_height); |
| 174 bool DisableAutoResizeMode(int new_width, int new_height); |
| 175 void SetMockDeviceMotion(gin::Arguments* args); |
| 176 void SetMockDeviceOrientation(gin::Arguments* args); |
| 177 void DidAcquirePointerLock(); |
| 178 void DidNotAcquirePointerLock(); |
| 179 void DidLosePointerLock(); |
| 180 void SetPointerLockWillFailSynchronously(); |
| 181 void SetPointerLockWillRespondAsynchronously(); |
| 182 void SetPopupBlockingEnabled(bool block_popups); |
| 183 void SetJavaScriptCanAccessClipboard(bool can_access); |
| 184 void SetXSSAuditorEnabled(bool enabled); |
| 185 void SetAllowUniversalAccessFromFileURLs(bool allow); |
| 186 void SetAllowFileAccessFromFileURLs(bool allow); |
| 187 void OverridePreference(const std::string key, v8::Handle<v8::Value> value); |
| 188 void SetPluginsEnabled(bool enabled); |
| 189 void DumpEditingCallbacks(); |
| 190 void DumpAsText(); |
| 191 void DumpAsTextWithPixelResults(); |
| 192 void DumpChildFrameScrollPositions(); |
| 193 void DumpChildFramesAsText(); |
| 194 void DumpIconChanges(); |
| 195 void SetAudioData(const gin::ArrayBufferView& view); |
| 196 void DumpFrameLoadCallbacks(); |
| 197 void DumpPingLoaderCallbacks(); |
| 198 void DumpUserGestureInFrameLoadCallbacks(); |
| 199 void DumpTitleChanges(); |
| 200 void DumpCreateView(); |
| 201 void SetCanOpenWindows(); |
| 202 void DumpResourceLoadCallbacks(); |
| 203 void DumpResourceRequestCallbacks(); |
| 204 void DumpResourceResponseMIMETypes(); |
| 205 void SetImagesAllowed(bool allowed); |
| 206 void SetScriptsAllowed(bool allowed); |
| 207 void SetStorageAllowed(bool allowed); |
| 208 void SetPluginsAllowed(bool allowed); |
| 209 void SetAllowDisplayOfInsecureContent(bool allowed); |
| 210 void SetAllowRunningOfInsecureContent(bool allowed); |
| 211 void DumpPermissionClientCallbacks(); |
| 212 void DumpWindowStatusChanges(); |
| 213 void DumpProgressFinishedCallback(); |
| 214 void DumpSpellCheckCallbacks(); |
| 215 void DumpBackForwardList(); |
| 216 void DumpSelectionRect(); |
| 217 void TestRepaint(); |
| 218 void RepaintSweepHorizontally(); |
| 219 void SetPrinting(); |
| 220 void SetShouldStayOnPageAfterHandlingBeforeUnload(bool value); |
| 221 void SetWillSendRequestClearHeader(const std::string& header); |
| 222 void DumpResourceRequestPriorities(); |
| 223 void SetUseMockTheme(bool use); |
| 224 void ShowWebInspector(gin::Arguments* args); |
| 225 void CloseWebInspector(); |
| 226 bool IsChooserShown(); |
| 227 void EvaluateInWebInspector(int call_id, const std::string& script); |
| 228 void ClearAllDatabases(); |
| 229 void SetDatabaseQuota(int quota); |
| 230 void SetAlwaysAcceptCookies(bool accept); |
| 231 void SetWindowIsKey(bool value); |
| 232 std::string PathToLocalResource(const std::string& path); |
| 233 void SetBackingScaleFactor(double value, v8::Handle<v8::Function> callback); |
| 234 void SetPOSIXLocale(const std::string& locale); |
| 235 void SetMIDIAccessorResult(bool result); |
| 236 void SetMIDISysExPermission(bool value); |
| 237 void GrantWebNotificationPermission(gin::Arguments* args); |
| 238 bool SimulateWebNotificationClick(const std::string& value); |
| 239 void AddMockSpeechInputResult(const std::string& result, |
| 240 double confidence, |
| 241 const std::string& language); |
| 242 void SetMockSpeechInputDumpRect(bool value); |
| 243 void AddMockSpeechRecognitionResult(const std::string& transcript, |
| 244 double confidence); |
| 245 void SetMockSpeechRecognitionError(const std::string& error, |
| 246 const std::string& message); |
| 247 bool WasMockSpeechRecognitionAborted(); |
| 248 void AddWebPageOverlay(); |
| 249 void RemoveWebPageOverlay(); |
| 250 void Display(); |
| 251 void DisplayInvalidatedRegion(); |
| 252 |
| 253 bool GlobalFlag(); |
| 254 void SetGlobalFlag(bool value); |
| 255 std::string PlatformName(); |
| 256 std::string TooltipText(); |
| 257 bool DisableNotifyDone(); |
| 258 int WebHistoryItemCount(); |
| 259 bool InterceptPostMessage(); |
| 260 void SetInterceptPostMessage(bool value); |
| 261 |
| 262 void NotImplemented(const gin::Arguments& args); |
| 263 |
| 264 base::WeakPtr<TestRunner> runner_; |
| 265 |
| 266 DISALLOW_COPY_AND_ASSIGN(TestRunnerBindings); |
| 267 }; |
| 268 |
| 269 gin::WrapperInfo TestRunnerBindings::kWrapperInfo = { |
| 270 gin::kEmbedderNativeGin}; |
| 271 |
| 272 // static |
| 273 void TestRunnerBindings::Install(base::WeakPtr<TestRunner> runner, |
| 274 WebFrame* frame) { |
| 275 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 276 v8::HandleScope handle_scope(isolate); |
| 277 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); |
| 278 if (context.IsEmpty()) |
| 279 return; |
| 280 |
| 281 v8::Context::Scope context_scope(context); |
| 282 |
| 283 gin::Handle<TestRunnerBindings> bindings = |
| 284 gin::CreateHandle(isolate, new TestRunnerBindings(runner)); |
| 285 v8::Handle<v8::Object> global = context->Global(); |
| 286 v8::Handle<v8::Value> v8_bindings = bindings.ToV8(); |
| 287 global->Set(gin::StringToV8(isolate, "testRunner"), v8_bindings); |
| 288 global->Set(gin::StringToV8(isolate, "layoutTestController"), v8_bindings); |
| 289 } |
| 290 |
| 291 TestRunnerBindings::TestRunnerBindings(base::WeakPtr<TestRunner> runner) |
| 292 : runner_(runner) {} |
| 293 |
| 294 TestRunnerBindings::~TestRunnerBindings() {} |
| 295 |
| 296 gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder( |
| 297 v8::Isolate* isolate) { |
| 298 return gin::Wrappable<TestRunnerBindings>::GetObjectTemplateBuilder( |
| 299 isolate) |
| 300 // Methods controlling test execution. |
| 301 .SetMethod("notifyDone", &TestRunnerBindings::NotifyDone) |
| 302 .SetMethod("waitUntilDone", &TestRunnerBindings::WaitUntilDone) |
| 303 .SetMethod("queueBackNavigation", |
| 304 &TestRunnerBindings::QueueBackNavigation) |
| 305 .SetMethod("queueForwardNavigation", |
| 306 &TestRunnerBindings::QueueForwardNavigation) |
| 307 .SetMethod("queueReload", &TestRunnerBindings::QueueReload) |
| 308 .SetMethod("queueLoadingScript", &TestRunnerBindings::QueueLoadingScript) |
| 309 .SetMethod("queueNonLoadingScript", |
| 310 &TestRunnerBindings::QueueNonLoadingScript) |
| 311 .SetMethod("queueLoad", &TestRunnerBindings::QueueLoad) |
| 312 .SetMethod("queueLoadHTMLString", |
| 313 &TestRunnerBindings::QueueLoadHTMLString) |
| 314 .SetMethod("setCustomPolicyDelegate", |
| 315 &TestRunnerBindings::SetCustomPolicyDelegate) |
| 316 .SetMethod("waitForPolicyDelegate", |
| 317 &TestRunnerBindings::WaitForPolicyDelegate) |
| 318 .SetMethod("windowCount", &TestRunnerBindings::WindowCount) |
| 319 .SetMethod("setCloseRemainingWindowsWhenComplete", |
| 320 &TestRunnerBindings::SetCloseRemainingWindowsWhenComplete) |
| 321 .SetMethod("resetTestHelperControllers", |
| 322 &TestRunnerBindings::ResetTestHelperControllers) |
| 323 .SetMethod("setTabKeyCyclesThroughElements", |
| 324 &TestRunnerBindings::SetTabKeyCyclesThroughElements) |
| 325 .SetMethod("execCommand", &TestRunnerBindings::ExecCommand) |
| 326 .SetMethod("isCommandEnabled", &TestRunnerBindings::IsCommandEnabled) |
| 327 .SetMethod("callShouldCloseOnWebView", |
| 328 &TestRunnerBindings::CallShouldCloseOnWebView) |
| 329 .SetMethod("setDomainRelaxationForbiddenForURLScheme", |
| 330 &TestRunnerBindings::SetDomainRelaxationForbiddenForURLScheme) |
| 331 .SetMethod("evaluateScriptInIsolatedWorldAndReturnValue", |
| 332 &TestRunnerBindings:: |
| 333 EvaluateScriptInIsolatedWorldAndReturnValue) |
| 334 .SetMethod("evaluateScriptInIsolatedWorld", |
| 335 &TestRunnerBindings::EvaluateScriptInIsolatedWorld) |
| 336 .SetMethod("setIsolatedWorldSecurityOrigin", |
| 337 &TestRunnerBindings::SetIsolatedWorldSecurityOrigin) |
| 338 .SetMethod("setIsolatedWorldContentSecurityPolicy", |
| 339 &TestRunnerBindings::SetIsolatedWorldContentSecurityPolicy) |
| 340 .SetMethod("addOriginAccessWhitelistEntry", |
| 341 &TestRunnerBindings::AddOriginAccessWhitelistEntry) |
| 342 .SetMethod("removeOriginAccessWhitelistEntry", |
| 343 &TestRunnerBindings::RemoveOriginAccessWhitelistEntry) |
| 344 .SetMethod("hasCustomPageSizeStyle", |
| 345 &TestRunnerBindings::HasCustomPageSizeStyle) |
| 346 .SetMethod("forceRedSelectionColors", |
| 347 &TestRunnerBindings::ForceRedSelectionColors) |
| 348 .SetMethod("injectStyleSheet", &TestRunnerBindings::InjectStyleSheet) |
| 349 .SetMethod("findString", &TestRunnerBindings::FindString) |
| 350 .SetMethod("selectionAsMarkup", &TestRunnerBindings::SelectionAsMarkup) |
| 351 .SetMethod("setTextSubpixelPositioning", |
| 352 &TestRunnerBindings::SetTextSubpixelPositioning) |
| 353 .SetMethod("setPageVisibility", &TestRunnerBindings::SetPageVisibility) |
| 354 .SetMethod("setTextDirection", &TestRunnerBindings::SetTextDirection) |
| 355 .SetMethod("useUnfortunateSynchronousResizeMode", |
| 356 &TestRunnerBindings::UseUnfortunateSynchronousResizeMode) |
| 357 .SetMethod("enableAutoResizeMode", |
| 358 &TestRunnerBindings::EnableAutoResizeMode) |
| 359 .SetMethod("disableAutoResizeMode", |
| 360 &TestRunnerBindings::DisableAutoResizeMode) |
| 361 .SetMethod("setMockDeviceMotion", |
| 362 &TestRunnerBindings::SetMockDeviceMotion) |
| 363 .SetMethod("setMockDeviceOrientation", |
| 364 &TestRunnerBindings::SetMockDeviceOrientation) |
| 365 .SetMethod("didAcquirePointerLock", |
| 366 &TestRunnerBindings::DidAcquirePointerLock) |
| 367 .SetMethod("didNotAcquirePointerLock", |
| 368 &TestRunnerBindings::DidNotAcquirePointerLock) |
| 369 .SetMethod("didLosePointerLock", &TestRunnerBindings::DidLosePointerLock) |
| 370 .SetMethod("setPointerLockWillFailSynchronously", |
| 371 &TestRunnerBindings::SetPointerLockWillFailSynchronously) |
| 372 .SetMethod("setPointerLockWillRespondAsynchronously", |
| 373 &TestRunnerBindings::SetPointerLockWillRespondAsynchronously) |
| 374 .SetMethod("setPopupBlockingEnabled", |
| 375 &TestRunnerBindings::SetPopupBlockingEnabled) |
| 376 .SetMethod("setJavaScriptCanAccessClipboard", |
| 377 &TestRunnerBindings::SetJavaScriptCanAccessClipboard) |
| 378 .SetMethod("setXSSAuditorEnabled", |
| 379 &TestRunnerBindings::SetXSSAuditorEnabled) |
| 380 .SetMethod("setAllowUniversalAccessFromFileURLs", |
| 381 &TestRunnerBindings::SetAllowUniversalAccessFromFileURLs) |
| 382 .SetMethod("setAllowFileAccessFromFileURLs", |
| 383 &TestRunnerBindings::SetAllowFileAccessFromFileURLs) |
| 384 .SetMethod("overridePreference", &TestRunnerBindings::OverridePreference) |
| 385 .SetMethod("setPluginsEnabled", &TestRunnerBindings::SetPluginsEnabled) |
| 386 .SetMethod("dumpEditingCallbacks", |
| 387 &TestRunnerBindings::DumpEditingCallbacks) |
| 388 .SetMethod("dumpAsText", &TestRunnerBindings::DumpAsText) |
| 389 .SetMethod("dumpAsTextWithPixelResults", |
| 390 &TestRunnerBindings::DumpAsTextWithPixelResults) |
| 391 .SetMethod("dumpChildFrameScrollPositions", |
| 392 &TestRunnerBindings::DumpChildFrameScrollPositions) |
| 393 .SetMethod("dumpChildFramesAsText", |
| 394 &TestRunnerBindings::DumpChildFramesAsText) |
| 395 .SetMethod("dumpIconChanges", &TestRunnerBindings::DumpIconChanges) |
| 396 .SetMethod("setAudioData", &TestRunnerBindings::SetAudioData) |
| 397 .SetMethod("dumpFrameLoadCallbacks", |
| 398 &TestRunnerBindings::DumpFrameLoadCallbacks) |
| 399 .SetMethod("dumpPingLoaderCallbacks", |
| 400 &TestRunnerBindings::DumpPingLoaderCallbacks) |
| 401 .SetMethod("dumpUserGestureInFrameLoadCallbacks", |
| 402 &TestRunnerBindings::DumpUserGestureInFrameLoadCallbacks) |
| 403 .SetMethod("dumpTitleChanges", &TestRunnerBindings::DumpTitleChanges) |
| 404 .SetMethod("dumpCreateView", &TestRunnerBindings::DumpCreateView) |
| 405 .SetMethod("setCanOpenWindows", &TestRunnerBindings::SetCanOpenWindows) |
| 406 .SetMethod("dumpResourceLoadCallbacks", |
| 407 &TestRunnerBindings::DumpResourceLoadCallbacks) |
| 408 .SetMethod("dumpResourceRequestCallbacks", |
| 409 &TestRunnerBindings::DumpResourceRequestCallbacks) |
| 410 .SetMethod("dumpResourceResponseMIMETypes", |
| 411 &TestRunnerBindings::DumpResourceResponseMIMETypes) |
| 412 .SetMethod("setImagesAllowed", &TestRunnerBindings::SetImagesAllowed) |
| 413 .SetMethod("setScriptsAllowed", &TestRunnerBindings::SetScriptsAllowed) |
| 414 .SetMethod("setStorageAllowed", &TestRunnerBindings::SetStorageAllowed) |
| 415 .SetMethod("setPluginsAllowed", &TestRunnerBindings::SetPluginsAllowed) |
| 416 .SetMethod("setAllowDisplayOfInsecureContent", |
| 417 &TestRunnerBindings::SetAllowDisplayOfInsecureContent) |
| 418 .SetMethod("setAllowRunningOfInsecureContent", |
| 419 &TestRunnerBindings::SetAllowRunningOfInsecureContent) |
| 420 .SetMethod("dumpPermissionClientCallbacks", |
| 421 &TestRunnerBindings::DumpPermissionClientCallbacks) |
| 422 .SetMethod("dumpWindowStatusChanges", |
| 423 &TestRunnerBindings::DumpWindowStatusChanges) |
| 424 .SetMethod("dumpProgressFinishedCallback", |
| 425 &TestRunnerBindings::DumpProgressFinishedCallback) |
| 426 .SetMethod("dumpSpellCheckCallbacks", |
| 427 &TestRunnerBindings::DumpSpellCheckCallbacks) |
| 428 .SetMethod("dumpBackForwardList", |
| 429 &TestRunnerBindings::DumpBackForwardList) |
| 430 .SetMethod("dumpSelectionRect", &TestRunnerBindings::DumpSelectionRect) |
| 431 .SetMethod("testRepaint", &TestRunnerBindings::TestRepaint) |
| 432 .SetMethod("repaintSweepHorizontally", |
| 433 &TestRunnerBindings::RepaintSweepHorizontally) |
| 434 .SetMethod("setPrinting", &TestRunnerBindings::SetPrinting) |
| 435 .SetMethod("setShouldStayOnPageAfterHandlingBeforeUnload", |
| 436 &TestRunnerBindings:: |
| 437 SetShouldStayOnPageAfterHandlingBeforeUnload) |
| 438 .SetMethod("setWillSendRequestClearHeader", |
| 439 &TestRunnerBindings::SetWillSendRequestClearHeader) |
| 440 .SetMethod("dumpResourceRequestPriorities", |
| 441 &TestRunnerBindings::DumpResourceRequestPriorities) |
| 442 .SetMethod("setUseMockTheme", &TestRunnerBindings::SetUseMockTheme) |
| 443 .SetMethod("showWebInspector", &TestRunnerBindings::ShowWebInspector) |
| 444 .SetMethod("closeWebInspector", &TestRunnerBindings::CloseWebInspector) |
| 445 .SetMethod("isChooserShown", &TestRunnerBindings::IsChooserShown) |
| 446 .SetMethod("evaluateInWebInspector", |
| 447 &TestRunnerBindings::EvaluateInWebInspector) |
| 448 .SetMethod("clearAllDatabases", &TestRunnerBindings::ClearAllDatabases) |
| 449 .SetMethod("setDatabaseQuota", &TestRunnerBindings::SetDatabaseQuota) |
| 450 .SetMethod("setAlwaysAcceptCookies", |
| 451 &TestRunnerBindings::SetAlwaysAcceptCookies) |
| 452 .SetMethod("setWindowIsKey", &TestRunnerBindings::SetWindowIsKey) |
| 453 .SetMethod("pathToLocalResource", |
| 454 &TestRunnerBindings::PathToLocalResource) |
| 455 .SetMethod("setBackingScaleFactor", |
| 456 &TestRunnerBindings::SetBackingScaleFactor) |
| 457 .SetMethod("setPOSIXLocale", &TestRunnerBindings::SetPOSIXLocale) |
| 458 .SetMethod("setMIDIAccessorResult", |
| 459 &TestRunnerBindings::SetMIDIAccessorResult) |
| 460 .SetMethod("setMIDISysExPermission", |
| 461 &TestRunnerBindings::SetMIDISysExPermission) |
| 462 .SetMethod("grantWebNotificationPermission", |
| 463 &TestRunnerBindings::GrantWebNotificationPermission) |
| 464 .SetMethod("simulateWebNotificationClick", |
| 465 &TestRunnerBindings::SimulateWebNotificationClick) |
| 466 .SetMethod("addMockSpeechInputResult", |
| 467 &TestRunnerBindings::AddMockSpeechInputResult) |
| 468 .SetMethod("setMockSpeechInputDumpRect", |
| 469 &TestRunnerBindings::SetMockSpeechInputDumpRect) |
| 470 .SetMethod("addMockSpeechRecognitionResult", |
| 471 &TestRunnerBindings::AddMockSpeechRecognitionResult) |
| 472 .SetMethod("setMockSpeechRecognitionError", |
| 473 &TestRunnerBindings::SetMockSpeechRecognitionError) |
| 474 .SetMethod("wasMockSpeechRecognitionAborted", |
| 475 &TestRunnerBindings::WasMockSpeechRecognitionAborted) |
| 476 .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay) |
| 477 .SetMethod("removeWebPageOverlay", |
| 478 &TestRunnerBindings::RemoveWebPageOverlay) |
| 479 .SetMethod("display", &TestRunnerBindings::Display) |
| 480 .SetMethod("displayInvalidatedRegion", |
| 481 &TestRunnerBindings::DisplayInvalidatedRegion) |
| 482 |
| 483 // Properties. |
| 484 .SetProperty("globalFlag", &TestRunnerBindings::GlobalFlag, |
| 485 &TestRunnerBindings::SetGlobalFlag) |
| 486 .SetProperty("platformName", &TestRunnerBindings::PlatformName) |
| 487 .SetProperty("tooltipText", &TestRunnerBindings::TooltipText) |
| 488 .SetProperty("disableNotifyDone", &TestRunnerBindings::DisableNotifyDone) |
| 489 // webHistoryItemCount is used by tests in LayoutTests\http\tests\history |
| 490 .SetProperty("webHistoryItemCount", |
| 491 &TestRunnerBindings::WebHistoryItemCount) |
| 492 .SetProperty("interceptPostMessage", |
| 493 &TestRunnerBindings::InterceptPostMessage, |
| 494 &TestRunnerBindings::SetInterceptPostMessage) |
| 495 |
| 496 // The following are stubs. |
| 497 .SetMethod("dumpDatabaseCallbacks", &TestRunnerBindings::NotImplemented) |
| 498 .SetMethod("setIconDatabaseEnabled", &TestRunnerBindings::NotImplemented) |
| 499 .SetMethod("setScrollbarPolicy", &TestRunnerBindings::NotImplemented) |
| 500 .SetMethod("clearAllApplicationCaches", |
| 501 &TestRunnerBindings::NotImplemented) |
| 502 .SetMethod("clearApplicationCacheForOrigin", |
| 503 &TestRunnerBindings::NotImplemented) |
| 504 .SetMethod("clearBackForwardList", &TestRunnerBindings::NotImplemented) |
| 505 .SetMethod("keepWebHistory", &TestRunnerBindings::NotImplemented) |
| 506 .SetMethod("setApplicationCacheOriginQuota", |
| 507 &TestRunnerBindings::NotImplemented) |
| 508 .SetMethod("setCallCloseOnWebViews", &TestRunnerBindings::NotImplemented) |
| 509 .SetMethod("setMainFrameIsFirstResponder", |
| 510 &TestRunnerBindings::NotImplemented) |
| 511 .SetMethod("setUseDashboardCompatibilityMode", |
| 512 &TestRunnerBindings::NotImplemented) |
| 513 .SetMethod("deleteAllLocalStorage", &TestRunnerBindings::NotImplemented) |
| 514 .SetMethod("localStorageDiskUsageForOrigin", |
| 515 &TestRunnerBindings::NotImplemented) |
| 516 .SetMethod("originsWithLocalStorage", &TestRunnerBindings::NotImplemented) |
| 517 .SetMethod("deleteLocalStorageForOrigin", |
| 518 &TestRunnerBindings::NotImplemented) |
| 519 .SetMethod("observeStorageTrackerNotifications", |
| 520 &TestRunnerBindings::NotImplemented) |
| 521 .SetMethod("syncLocalStorage", &TestRunnerBindings::NotImplemented) |
| 522 .SetMethod("addDisallowedURL", &TestRunnerBindings::NotImplemented) |
| 523 .SetMethod("applicationCacheDiskUsageForOrigin", |
| 524 &TestRunnerBindings::NotImplemented) |
| 525 .SetMethod("abortModal", &TestRunnerBindings::NotImplemented) |
| 526 |
| 527 // Aliases. |
| 528 // Used at fast/dom/assign-to-window-status.html |
| 529 .SetMethod("dumpStatusCallbacks", |
| 530 &TestRunnerBindings::DumpWindowStatusChanges); |
| 531 |
| 532 } |
| 533 |
| 534 void TestRunnerBindings::NotifyDone() { |
| 535 if (runner_) |
| 536 runner_->NotifyDone(); |
| 537 } |
| 538 |
| 539 void TestRunnerBindings::WaitUntilDone() { |
| 540 if (runner_) |
| 541 runner_->WaitUntilDone(); |
| 542 } |
| 543 |
| 544 void TestRunnerBindings::QueueBackNavigation(int how_far_back) { |
| 545 if (runner_) |
| 546 runner_->QueueBackNavigation(how_far_back); |
| 547 } |
| 548 |
| 549 void TestRunnerBindings::QueueForwardNavigation(int how_far_forward) { |
| 550 if (runner_) |
| 551 runner_->QueueForwardNavigation(how_far_forward); |
| 552 } |
| 553 |
| 554 void TestRunnerBindings::QueueReload() { |
| 555 if (runner_) |
| 556 runner_->QueueReload(); |
| 557 } |
| 558 |
| 559 void TestRunnerBindings::QueueLoadingScript(const std::string& script) { |
| 560 if (runner_) |
| 561 runner_->QueueLoadingScript(script); |
| 562 } |
| 563 |
| 564 void TestRunnerBindings::QueueNonLoadingScript(const std::string& script) { |
| 565 if (runner_) |
| 566 runner_->QueueNonLoadingScript(script); |
| 567 } |
| 568 |
| 569 void TestRunnerBindings::QueueLoad(gin::Arguments* args) { |
| 570 if (runner_) { |
| 571 std::string url; |
| 572 std::string target; |
| 573 args->GetNext(&url); |
| 574 args->GetNext(&target); |
| 575 runner_->QueueLoad(url, target); |
| 576 } |
| 577 } |
| 578 |
| 579 void TestRunnerBindings::QueueLoadHTMLString(gin::Arguments* args) { |
| 580 if (runner_) |
| 581 runner_->QueueLoadHTMLString(args); |
| 582 } |
| 583 |
| 584 void TestRunnerBindings::SetCustomPolicyDelegate(gin::Arguments* args) { |
| 585 if (runner_) |
| 586 runner_->SetCustomPolicyDelegate(args); |
| 587 } |
| 588 |
| 589 void TestRunnerBindings::WaitForPolicyDelegate() { |
| 590 if (runner_) |
| 591 runner_->WaitForPolicyDelegate(); |
| 592 } |
| 593 |
| 594 int TestRunnerBindings::WindowCount() { |
| 595 if (runner_) |
| 596 return runner_->WindowCount(); |
| 597 return 0; |
| 598 } |
| 599 |
| 600 void TestRunnerBindings::SetCloseRemainingWindowsWhenComplete( |
| 601 gin::Arguments* args) { |
| 602 if (!runner_) |
| 603 return; |
| 604 |
| 605 // In the original implementation, nothing happens if the argument is |
| 606 // ommitted. |
| 607 bool close_remaining_windows = false; |
| 608 if (args->GetNext(&close_remaining_windows)) |
| 609 runner_->SetCloseRemainingWindowsWhenComplete(close_remaining_windows); |
| 610 } |
| 611 |
| 612 void TestRunnerBindings::ResetTestHelperControllers() { |
| 613 if (runner_) |
| 614 runner_->ResetTestHelperControllers(); |
| 615 } |
| 616 |
| 617 void TestRunnerBindings::SetTabKeyCyclesThroughElements( |
| 618 bool tab_key_cycles_through_elements) { |
| 619 if (runner_) |
| 620 runner_->SetTabKeyCyclesThroughElements(tab_key_cycles_through_elements); |
| 621 } |
| 622 |
| 623 void TestRunnerBindings::ExecCommand(gin::Arguments* args) { |
| 624 if (runner_) |
| 625 runner_->ExecCommand(args); |
| 626 } |
| 627 |
| 628 bool TestRunnerBindings::IsCommandEnabled(const std::string& command) { |
| 629 if (runner_) |
| 630 return runner_->IsCommandEnabled(command); |
| 631 return false; |
| 632 } |
| 633 |
| 634 bool TestRunnerBindings::CallShouldCloseOnWebView() { |
| 635 if (runner_) |
| 636 return runner_->CallShouldCloseOnWebView(); |
| 637 return false; |
| 638 } |
| 639 |
| 640 void TestRunnerBindings::SetDomainRelaxationForbiddenForURLScheme( |
| 641 bool forbidden, const std::string& scheme) { |
| 642 if (runner_) |
| 643 runner_->SetDomainRelaxationForbiddenForURLScheme(forbidden, scheme); |
| 644 } |
| 645 |
| 646 v8::Handle<v8::Value> |
| 647 TestRunnerBindings::EvaluateScriptInIsolatedWorldAndReturnValue( |
| 648 int world_id, const std::string& script) { |
| 649 if (!runner_) |
| 650 return v8::Handle<v8::Value>(); |
| 651 return runner_->EvaluateScriptInIsolatedWorldAndReturnValue(world_id, |
| 652 script); |
| 653 } |
| 654 |
| 655 void TestRunnerBindings::EvaluateScriptInIsolatedWorld( |
| 656 int world_id, const std::string& script) { |
| 657 if (runner_) |
| 658 runner_->EvaluateScriptInIsolatedWorld(world_id, script); |
| 659 } |
| 660 |
| 661 void TestRunnerBindings::SetIsolatedWorldSecurityOrigin( |
| 662 int world_id, v8::Handle<v8::Value> origin) { |
| 663 if (runner_) |
| 664 runner_->SetIsolatedWorldSecurityOrigin(world_id, origin); |
| 665 } |
| 666 |
| 667 void TestRunnerBindings::SetIsolatedWorldContentSecurityPolicy( |
| 668 int world_id, const std::string& policy) { |
| 669 if (runner_) |
| 670 runner_->SetIsolatedWorldContentSecurityPolicy(world_id, policy); |
| 671 } |
| 672 |
| 673 void TestRunnerBindings::AddOriginAccessWhitelistEntry( |
| 674 const std::string& source_origin, |
| 675 const std::string& destination_protocol, |
| 676 const std::string& destination_host, |
| 677 bool allow_destination_subdomains) { |
| 678 if (runner_) { |
| 679 runner_->AddOriginAccessWhitelistEntry(source_origin, |
| 680 destination_protocol, |
| 681 destination_host, |
| 682 allow_destination_subdomains); |
| 683 } |
| 684 } |
| 685 |
| 686 void TestRunnerBindings::RemoveOriginAccessWhitelistEntry( |
| 687 const std::string& source_origin, |
| 688 const std::string& destination_protocol, |
| 689 const std::string& destination_host, |
| 690 bool allow_destination_subdomains) { |
| 691 if (runner_) { |
| 692 runner_->RemoveOriginAccessWhitelistEntry(source_origin, |
| 693 destination_protocol, |
| 694 destination_host, |
| 695 allow_destination_subdomains); |
| 696 } |
| 697 } |
| 698 |
| 699 bool TestRunnerBindings::HasCustomPageSizeStyle(int page_index) { |
| 700 if (runner_) |
| 701 return runner_->HasCustomPageSizeStyle(page_index); |
| 702 return false; |
| 703 } |
| 704 |
| 705 void TestRunnerBindings::ForceRedSelectionColors() { |
| 706 if (runner_) |
| 707 runner_->ForceRedSelectionColors(); |
| 708 } |
| 709 |
| 710 void TestRunnerBindings::InjectStyleSheet(const std::string& source_code, |
| 711 bool all_frames) { |
| 712 if (runner_) |
| 713 runner_->InjectStyleSheet(source_code, all_frames); |
| 714 } |
| 715 |
| 716 bool TestRunnerBindings::FindString( |
| 717 const std::string& search_text, |
| 718 const std::vector<std::string>& options_array) { |
| 719 if (runner_) |
| 720 return runner_->FindString(search_text, options_array); |
| 721 return false; |
| 722 } |
| 723 |
| 724 std::string TestRunnerBindings::SelectionAsMarkup() { |
| 725 if (runner_) |
| 726 return runner_->SelectionAsMarkup(); |
| 727 return std::string(); |
| 728 } |
| 729 |
| 730 void TestRunnerBindings::SetTextSubpixelPositioning(bool value) { |
| 731 if (runner_) |
| 732 runner_->SetTextSubpixelPositioning(value); |
| 733 } |
| 734 |
| 735 void TestRunnerBindings::SetPageVisibility(const std::string& new_visibility) { |
| 736 if (runner_) |
| 737 runner_->SetPageVisibility(new_visibility); |
| 738 } |
| 739 |
| 740 void TestRunnerBindings::SetTextDirection(const std::string& direction_name) { |
| 741 if (runner_) |
| 742 runner_->SetTextDirection(direction_name); |
| 743 } |
| 744 |
| 745 void TestRunnerBindings::UseUnfortunateSynchronousResizeMode() { |
| 746 if (runner_) |
| 747 runner_->UseUnfortunateSynchronousResizeMode(); |
| 748 } |
| 749 |
| 750 bool TestRunnerBindings::EnableAutoResizeMode(int min_width, |
| 751 int min_height, |
| 752 int max_width, |
| 753 int max_height) { |
| 754 if (runner_) { |
| 755 return runner_->EnableAutoResizeMode(min_width, min_height, |
| 756 max_width, max_height); |
| 757 } |
| 758 return false; |
| 759 } |
| 760 |
| 761 bool TestRunnerBindings::DisableAutoResizeMode(int new_width, int new_height) { |
| 762 if (runner_) |
| 763 return runner_->DisableAutoResizeMode(new_width, new_height); |
| 764 return false; |
| 765 } |
| 766 |
| 767 void TestRunnerBindings::SetMockDeviceMotion(gin::Arguments* args) { |
| 768 if (!runner_) |
| 769 return; |
| 770 |
| 771 bool has_acceleration_x; |
| 772 double acceleration_x; |
| 773 bool has_acceleration_y; |
| 774 double acceleration_y; |
| 775 bool has_acceleration_z; |
| 776 double acceleration_z; |
| 777 bool has_acceleration_including_gravity_x; |
| 778 double acceleration_including_gravity_x; |
| 779 bool has_acceleration_including_gravity_y; |
| 780 double acceleration_including_gravity_y; |
| 781 bool has_acceleration_including_gravity_z; |
| 782 double acceleration_including_gravity_z; |
| 783 bool has_rotation_rate_alpha; |
| 784 double rotation_rate_alpha; |
| 785 bool has_rotation_rate_beta; |
| 786 double rotation_rate_beta; |
| 787 bool has_rotation_rate_gamma; |
| 788 double rotation_rate_gamma; |
| 789 double interval; |
| 790 |
| 791 args->GetNext(&has_acceleration_x); |
| 792 args->GetNext(& acceleration_x); |
| 793 args->GetNext(&has_acceleration_y); |
| 794 args->GetNext(& acceleration_y); |
| 795 args->GetNext(&has_acceleration_z); |
| 796 args->GetNext(& acceleration_z); |
| 797 args->GetNext(&has_acceleration_including_gravity_x); |
| 798 args->GetNext(& acceleration_including_gravity_x); |
| 799 args->GetNext(&has_acceleration_including_gravity_y); |
| 800 args->GetNext(& acceleration_including_gravity_y); |
| 801 args->GetNext(&has_acceleration_including_gravity_z); |
| 802 args->GetNext(& acceleration_including_gravity_z); |
| 803 args->GetNext(&has_rotation_rate_alpha); |
| 804 args->GetNext(& rotation_rate_alpha); |
| 805 args->GetNext(&has_rotation_rate_beta); |
| 806 args->GetNext(& rotation_rate_beta); |
| 807 args->GetNext(&has_rotation_rate_gamma); |
| 808 args->GetNext(& rotation_rate_gamma); |
| 809 args->GetNext(& interval); |
| 810 |
| 811 runner_->SetMockDeviceMotion(has_acceleration_x, acceleration_x, |
| 812 has_acceleration_y, acceleration_y, |
| 813 has_acceleration_z, acceleration_z, |
| 814 has_acceleration_including_gravity_x, |
| 815 acceleration_including_gravity_x, |
| 816 has_acceleration_including_gravity_y, |
| 817 acceleration_including_gravity_y, |
| 818 has_acceleration_including_gravity_z, |
| 819 acceleration_including_gravity_z, |
| 820 has_rotation_rate_alpha, |
| 821 rotation_rate_alpha, |
| 822 has_rotation_rate_beta, |
| 823 rotation_rate_beta, |
| 824 has_rotation_rate_gamma, |
| 825 rotation_rate_gamma, |
| 826 interval); |
| 827 } |
| 828 |
| 829 void TestRunnerBindings::SetMockDeviceOrientation(gin::Arguments* args) { |
| 830 if (!runner_) |
| 831 return; |
| 832 |
| 833 bool has_alpha; |
| 834 double alpha; |
| 835 bool has_beta; |
| 836 double beta; |
| 837 bool has_gamma; |
| 838 double gamma; |
| 839 bool has_absolute; |
| 840 bool absolute; |
| 841 |
| 842 args->GetNext(&has_alpha); |
| 843 args->GetNext(&alpha); |
| 844 args->GetNext(&has_beta); |
| 845 args->GetNext(&beta); |
| 846 args->GetNext(&has_gamma); |
| 847 args->GetNext(&gamma); |
| 848 args->GetNext(&has_absolute); |
| 849 args->GetNext(&absolute); |
| 850 |
| 851 runner_->SetMockDeviceOrientation(has_alpha, alpha, |
| 852 has_beta, beta, |
| 853 has_gamma, gamma, |
| 854 has_absolute, absolute); |
| 855 } |
| 856 |
| 857 void TestRunnerBindings::DidAcquirePointerLock() { |
| 858 if (runner_) |
| 859 runner_->DidAcquirePointerLock(); |
| 860 } |
| 861 |
| 862 void TestRunnerBindings::DidNotAcquirePointerLock() { |
| 863 if (runner_) |
| 864 runner_->DidNotAcquirePointerLock(); |
| 865 } |
| 866 |
| 867 void TestRunnerBindings::DidLosePointerLock() { |
| 868 if (runner_) |
| 869 runner_->DidLosePointerLock(); |
| 870 } |
| 871 |
| 872 void TestRunnerBindings::SetPointerLockWillFailSynchronously() { |
| 873 if (runner_) |
| 874 runner_->SetPointerLockWillFailSynchronously(); |
| 875 } |
| 876 |
| 877 void TestRunnerBindings::SetPointerLockWillRespondAsynchronously() { |
| 878 if (runner_) |
| 879 runner_->SetPointerLockWillRespondAsynchronously(); |
| 880 } |
| 881 |
| 882 void TestRunnerBindings::SetPopupBlockingEnabled(bool block_popups) { |
| 883 if (runner_) |
| 884 runner_->SetPopupBlockingEnabled(block_popups); |
| 885 } |
| 886 |
| 887 void TestRunnerBindings::SetJavaScriptCanAccessClipboard(bool can_access) { |
| 888 if (runner_) |
| 889 runner_->SetJavaScriptCanAccessClipboard(can_access); |
| 890 } |
| 891 |
| 892 void TestRunnerBindings::SetXSSAuditorEnabled(bool enabled) { |
| 893 if (runner_) |
| 894 runner_->SetXSSAuditorEnabled(enabled); |
| 895 } |
| 896 |
| 897 void TestRunnerBindings::SetAllowUniversalAccessFromFileURLs(bool allow) { |
| 898 if (runner_) |
| 899 runner_->SetAllowUniversalAccessFromFileURLs(allow); |
| 900 } |
| 901 |
| 902 void TestRunnerBindings::SetAllowFileAccessFromFileURLs(bool allow) { |
| 903 if (runner_) |
| 904 runner_->SetAllowFileAccessFromFileURLs(allow); |
| 905 } |
| 906 |
| 907 void TestRunnerBindings::OverridePreference(const std::string key, |
| 908 v8::Handle<v8::Value> value) { |
| 909 if (runner_) |
| 910 runner_->OverridePreference(key, value); |
| 911 } |
| 912 |
| 913 void TestRunnerBindings::SetPluginsEnabled(bool enabled) { |
| 914 if (runner_) |
| 915 runner_->SetPluginsEnabled(enabled); |
| 916 } |
| 917 |
| 918 void TestRunnerBindings::DumpEditingCallbacks() { |
| 919 if (runner_) |
| 920 runner_->DumpEditingCallbacks(); |
| 921 } |
| 922 |
| 923 void TestRunnerBindings::DumpAsText() { |
| 924 if (runner_) |
| 925 runner_->DumpAsText(); |
| 926 } |
| 927 |
| 928 void TestRunnerBindings::DumpAsTextWithPixelResults() { |
| 929 if (runner_) |
| 930 runner_->DumpAsTextWithPixelResults(); |
| 931 } |
| 932 |
| 933 void TestRunnerBindings::DumpChildFrameScrollPositions() { |
| 934 if (runner_) |
| 935 runner_->DumpChildFrameScrollPositions(); |
| 936 } |
| 937 |
| 938 void TestRunnerBindings::DumpChildFramesAsText() { |
| 939 if (runner_) |
| 940 runner_->DumpChildFramesAsText(); |
| 941 } |
| 942 |
| 943 void TestRunnerBindings::DumpIconChanges() { |
| 944 if (runner_) |
| 945 runner_->DumpIconChanges(); |
| 946 } |
| 947 |
| 948 void TestRunnerBindings::SetAudioData(const gin::ArrayBufferView& view) { |
| 949 if (runner_) |
| 950 runner_->SetAudioData(view); |
| 951 } |
| 952 |
| 953 void TestRunnerBindings::DumpFrameLoadCallbacks() { |
| 954 if (runner_) |
| 955 runner_->DumpFrameLoadCallbacks(); |
| 956 } |
| 957 |
| 958 void TestRunnerBindings::DumpPingLoaderCallbacks() { |
| 959 if (runner_) |
| 960 runner_->DumpPingLoaderCallbacks(); |
| 961 } |
| 962 |
| 963 void TestRunnerBindings::DumpUserGestureInFrameLoadCallbacks() { |
| 964 if (runner_) |
| 965 runner_->DumpUserGestureInFrameLoadCallbacks(); |
| 966 } |
| 967 |
| 968 void TestRunnerBindings::DumpTitleChanges() { |
| 969 if (runner_) |
| 970 runner_->DumpTitleChanges(); |
| 971 } |
| 972 |
| 973 void TestRunnerBindings::DumpCreateView() { |
| 974 if (runner_) |
| 975 runner_->DumpCreateView(); |
| 976 } |
| 977 |
| 978 void TestRunnerBindings::SetCanOpenWindows() { |
| 979 if (runner_) |
| 980 runner_->SetCanOpenWindows(); |
| 981 } |
| 982 |
| 983 void TestRunnerBindings::DumpResourceLoadCallbacks() { |
| 984 if (runner_) |
| 985 runner_->DumpResourceLoadCallbacks(); |
| 986 } |
| 987 |
| 988 void TestRunnerBindings::DumpResourceRequestCallbacks() { |
| 989 if (runner_) |
| 990 runner_->DumpResourceRequestCallbacks(); |
| 991 } |
| 992 |
| 993 void TestRunnerBindings::DumpResourceResponseMIMETypes() { |
| 994 if (runner_) |
| 995 runner_->DumpResourceResponseMIMETypes(); |
| 996 } |
| 997 |
| 998 void TestRunnerBindings::SetImagesAllowed(bool allowed) { |
| 999 if (runner_) |
| 1000 runner_->SetImagesAllowed(allowed); |
| 1001 } |
| 1002 |
| 1003 void TestRunnerBindings::SetScriptsAllowed(bool allowed) { |
| 1004 if (runner_) |
| 1005 runner_->SetScriptsAllowed(allowed); |
| 1006 } |
| 1007 |
| 1008 void TestRunnerBindings::SetStorageAllowed(bool allowed) { |
| 1009 if (runner_) |
| 1010 runner_->SetStorageAllowed(allowed); |
| 1011 } |
| 1012 |
| 1013 void TestRunnerBindings::SetPluginsAllowed(bool allowed) { |
| 1014 if (runner_) |
| 1015 runner_->SetPluginsAllowed(allowed); |
| 1016 } |
| 1017 |
| 1018 void TestRunnerBindings::SetAllowDisplayOfInsecureContent(bool allowed) { |
| 1019 if (runner_) |
| 1020 runner_->SetAllowDisplayOfInsecureContent(allowed); |
| 1021 } |
| 1022 |
| 1023 void TestRunnerBindings::SetAllowRunningOfInsecureContent(bool allowed) { |
| 1024 if (runner_) |
| 1025 runner_->SetAllowRunningOfInsecureContent(allowed); |
| 1026 } |
| 1027 |
| 1028 void TestRunnerBindings::DumpPermissionClientCallbacks() { |
| 1029 if (runner_) |
| 1030 runner_->DumpPermissionClientCallbacks(); |
| 1031 } |
| 1032 |
| 1033 void TestRunnerBindings::DumpWindowStatusChanges() { |
| 1034 if (runner_) |
| 1035 runner_->DumpWindowStatusChanges(); |
| 1036 } |
| 1037 |
| 1038 void TestRunnerBindings::DumpProgressFinishedCallback() { |
| 1039 if (runner_) |
| 1040 runner_->DumpProgressFinishedCallback(); |
| 1041 } |
| 1042 |
| 1043 void TestRunnerBindings::DumpSpellCheckCallbacks() { |
| 1044 if (runner_) |
| 1045 runner_->DumpSpellCheckCallbacks(); |
| 1046 } |
| 1047 |
| 1048 void TestRunnerBindings::DumpBackForwardList() { |
| 1049 if (runner_) |
| 1050 runner_->DumpBackForwardList(); |
| 1051 } |
| 1052 |
| 1053 void TestRunnerBindings::DumpSelectionRect() { |
| 1054 if (runner_) |
| 1055 runner_->DumpSelectionRect(); |
| 1056 } |
| 1057 |
| 1058 void TestRunnerBindings::TestRepaint() { |
| 1059 if (runner_) |
| 1060 runner_->TestRepaint(); |
| 1061 } |
| 1062 |
| 1063 void TestRunnerBindings::RepaintSweepHorizontally() { |
| 1064 if (runner_) |
| 1065 runner_->RepaintSweepHorizontally(); |
| 1066 } |
| 1067 |
| 1068 void TestRunnerBindings::SetPrinting() { |
| 1069 if (runner_) |
| 1070 runner_->SetPrinting(); |
| 1071 } |
| 1072 |
| 1073 void TestRunnerBindings::SetShouldStayOnPageAfterHandlingBeforeUnload( |
| 1074 bool value) { |
| 1075 if (runner_) |
| 1076 runner_->SetShouldStayOnPageAfterHandlingBeforeUnload(value); |
| 1077 } |
| 1078 |
| 1079 void TestRunnerBindings::SetWillSendRequestClearHeader( |
| 1080 const std::string& header) { |
| 1081 if (runner_) |
| 1082 runner_->SetWillSendRequestClearHeader(header); |
| 1083 } |
| 1084 |
| 1085 void TestRunnerBindings::DumpResourceRequestPriorities() { |
| 1086 if (runner_) |
| 1087 runner_->DumpResourceRequestPriorities(); |
| 1088 } |
| 1089 |
| 1090 void TestRunnerBindings::SetUseMockTheme(bool use) { |
| 1091 if (runner_) |
| 1092 runner_->SetUseMockTheme(use); |
| 1093 } |
| 1094 |
| 1095 void TestRunnerBindings::ShowWebInspector(gin::Arguments* args) { |
| 1096 if (runner_) { |
| 1097 std::string str; |
| 1098 args->GetNext(&str); |
| 1099 runner_->ShowWebInspector(str); |
| 1100 } |
| 1101 } |
| 1102 |
| 1103 void TestRunnerBindings::CloseWebInspector() { |
| 1104 if (runner_) |
| 1105 runner_->CloseWebInspector(); |
| 1106 } |
| 1107 |
| 1108 bool TestRunnerBindings::IsChooserShown() { |
| 1109 if (runner_) |
| 1110 return runner_->IsChooserShown(); |
| 1111 return false; |
| 1112 } |
| 1113 |
| 1114 void TestRunnerBindings::EvaluateInWebInspector(int call_id, |
| 1115 const std::string& script) { |
| 1116 if (runner_) |
| 1117 runner_->EvaluateInWebInspector(call_id, script); |
| 1118 } |
| 1119 |
| 1120 void TestRunnerBindings::ClearAllDatabases() { |
| 1121 if (runner_) |
| 1122 runner_->ClearAllDatabases(); |
| 1123 } |
| 1124 |
| 1125 void TestRunnerBindings::SetDatabaseQuota(int quota) { |
| 1126 if (runner_) |
| 1127 runner_->SetDatabaseQuota(quota); |
| 1128 } |
| 1129 |
| 1130 void TestRunnerBindings::SetAlwaysAcceptCookies(bool accept) { |
| 1131 if (runner_) |
| 1132 runner_->SetAlwaysAcceptCookies(accept); |
| 1133 } |
| 1134 |
| 1135 void TestRunnerBindings::SetWindowIsKey(bool value) { |
| 1136 if (runner_) |
| 1137 runner_->SetWindowIsKey(value); |
| 1138 } |
| 1139 |
| 1140 std::string TestRunnerBindings::PathToLocalResource(const std::string& path) { |
| 1141 if (runner_) |
| 1142 return runner_->PathToLocalResource(path); |
| 1143 return std::string(); |
| 1144 } |
| 1145 |
| 1146 void TestRunnerBindings::SetBackingScaleFactor( |
| 1147 double value, v8::Handle<v8::Function> callback) { |
| 1148 if (runner_) |
| 1149 runner_->SetBackingScaleFactor(value, callback); |
| 1150 } |
| 1151 |
| 1152 void TestRunnerBindings::SetPOSIXLocale(const std::string& locale) { |
| 1153 if (runner_) |
| 1154 runner_->SetPOSIXLocale(locale); |
| 1155 } |
| 1156 |
| 1157 void TestRunnerBindings::SetMIDIAccessorResult(bool result) { |
| 1158 if (runner_) |
| 1159 runner_->SetMIDIAccessorResult(result); |
| 1160 } |
| 1161 |
| 1162 void TestRunnerBindings::SetMIDISysExPermission(bool value) { |
| 1163 if (runner_) |
| 1164 runner_->SetMIDISysExPermission(value); |
| 1165 } |
| 1166 |
| 1167 void TestRunnerBindings::GrantWebNotificationPermission(gin::Arguments* args) { |
| 1168 if (runner_) { |
| 1169 std::string origin; |
| 1170 bool permission_granted = true; |
| 1171 args->GetNext(&origin); |
| 1172 args->GetNext(&permission_granted); |
| 1173 return runner_->GrantWebNotificationPermission(origin, permission_granted); |
| 1174 } |
| 1175 } |
| 1176 |
| 1177 bool TestRunnerBindings::SimulateWebNotificationClick( |
| 1178 const std::string& value) { |
| 1179 if (runner_) |
| 1180 return runner_->SimulateWebNotificationClick(value); |
| 1181 return false; |
| 1182 } |
| 1183 |
| 1184 void TestRunnerBindings::AddMockSpeechInputResult(const std::string& result, |
| 1185 double confidence, |
| 1186 const std::string& language) { |
| 1187 if (runner_) |
| 1188 runner_->AddMockSpeechInputResult(result, confidence, language); |
| 1189 } |
| 1190 |
| 1191 void TestRunnerBindings::SetMockSpeechInputDumpRect(bool value) { |
| 1192 if (runner_) |
| 1193 runner_->SetMockSpeechInputDumpRect(value); |
| 1194 } |
| 1195 |
| 1196 void TestRunnerBindings::AddMockSpeechRecognitionResult( |
| 1197 const std::string& transcript, double confidence) { |
| 1198 if (runner_) |
| 1199 runner_->AddMockSpeechRecognitionResult(transcript, confidence); |
| 1200 } |
| 1201 |
| 1202 void TestRunnerBindings::SetMockSpeechRecognitionError( |
| 1203 const std::string& error, const std::string& message) { |
| 1204 if (runner_) |
| 1205 runner_->SetMockSpeechRecognitionError(error, message); |
| 1206 } |
| 1207 |
| 1208 bool TestRunnerBindings::WasMockSpeechRecognitionAborted() { |
| 1209 if (runner_) |
| 1210 return runner_->WasMockSpeechRecognitionAborted(); |
| 1211 return false; |
| 1212 } |
| 1213 |
| 1214 void TestRunnerBindings::AddWebPageOverlay() { |
| 1215 if (runner_) |
| 1216 runner_->AddWebPageOverlay(); |
| 1217 } |
| 1218 |
| 1219 void TestRunnerBindings::RemoveWebPageOverlay() { |
| 1220 if (runner_) |
| 1221 runner_->RemoveWebPageOverlay(); |
| 1222 } |
| 1223 |
| 1224 void TestRunnerBindings::Display() { |
| 1225 if (runner_) |
| 1226 runner_->Display(); |
| 1227 } |
| 1228 |
| 1229 void TestRunnerBindings::DisplayInvalidatedRegion() { |
| 1230 if (runner_) |
| 1231 runner_->DisplayInvalidatedRegion(); |
| 1232 } |
| 1233 |
| 1234 bool TestRunnerBindings::GlobalFlag() { |
| 1235 if (runner_) |
| 1236 return runner_->global_flag_; |
| 1237 return false; |
| 1238 } |
| 1239 |
| 1240 void TestRunnerBindings::SetGlobalFlag(bool value) { |
| 1241 if (runner_) |
| 1242 runner_->global_flag_ = value; |
| 1243 } |
| 1244 |
| 1245 std::string TestRunnerBindings::PlatformName() { |
| 1246 if (runner_) |
| 1247 return runner_->platform_name_; |
| 1248 return std::string(); |
| 1249 } |
| 1250 |
| 1251 std::string TestRunnerBindings::TooltipText() { |
| 1252 if (runner_) |
| 1253 return runner_->tooltip_text_; |
| 1254 return std::string(); |
| 1255 } |
| 1256 |
| 1257 bool TestRunnerBindings::DisableNotifyDone() { |
| 1258 if (runner_) |
| 1259 return runner_->disable_notify_done_; |
| 1260 return false; |
| 1261 } |
| 1262 |
| 1263 int TestRunnerBindings::WebHistoryItemCount() { |
| 1264 if (runner_) |
| 1265 return runner_->web_history_item_count_; |
| 1266 return false; |
| 1267 } |
| 1268 |
| 1269 bool TestRunnerBindings::InterceptPostMessage() { |
| 1270 if (runner_) |
| 1271 return runner_->intercept_post_message_; |
| 1272 return false; |
| 1273 } |
| 1274 |
| 1275 void TestRunnerBindings::SetInterceptPostMessage(bool value) { |
| 1276 if (runner_) |
| 1277 runner_->intercept_post_message_ = value; |
| 1278 } |
| 1279 |
| 1280 void TestRunnerBindings::NotImplemented(const gin::Arguments& args) { |
| 1281 } |
| 1282 |
| 1283 class TestPageOverlay : public WebPageOverlay { |
| 1284 public: |
| 1285 explicit TestPageOverlay(WebView* web_view) |
| 1286 : web_view_(web_view) { |
| 1287 } |
| 1288 virtual ~TestPageOverlay() {} |
| 1289 |
| 1290 virtual void paintPageOverlay(WebCanvas* canvas) OVERRIDE { |
| 1291 SkRect rect = SkRect::MakeWH(web_view_->size().width, |
| 1292 web_view_->size().height); |
| 1293 SkPaint paint; |
| 1294 paint.setColor(SK_ColorCYAN); |
| 1295 paint.setStyle(SkPaint::kFill_Style); |
| 1296 canvas->drawRect(rect, paint); |
| 1297 } |
| 1298 |
| 1299 private: |
| 1300 WebView* web_view_; |
| 1301 }; |
| 1302 |
| 1303 TestRunner::WorkQueue::WorkQueue(TestRunner* controller) |
| 1304 : frozen_(false) |
| 1305 , controller_(controller) {} |
| 1306 |
| 1307 TestRunner::WorkQueue::~WorkQueue() { |
| 1308 Reset(); |
| 1309 } |
| 1310 |
| 1311 void TestRunner::WorkQueue::ProcessWorkSoon() { |
| 1312 if (controller_->topLoadingFrame()) |
| 1313 return; |
| 1314 |
| 1315 if (!queue_.empty()) { |
| 1316 // We delay processing queued work to avoid recursion problems. |
| 1317 controller_->delegate_->postTask(new WorkQueueTask(this)); |
| 1318 } else if (!controller_->wait_until_done_) { |
| 1319 controller_->delegate_->testFinished(); |
| 1320 } |
| 1321 } |
| 1322 |
| 1323 void TestRunner::WorkQueue::Reset() { |
| 1324 frozen_ = false; |
| 1325 while (!queue_.empty()) { |
| 1326 delete queue_.front(); |
| 1327 queue_.pop_front(); |
| 1328 } |
| 1329 } |
| 1330 |
| 1331 void TestRunner::WorkQueue::AddWork(WorkItem* work) { |
| 1332 if (frozen_) { |
| 1333 delete work; |
| 1334 return; |
| 1335 } |
| 1336 queue_.push_back(work); |
| 1337 } |
| 1338 |
| 1339 void TestRunner::WorkQueue::ProcessWork() { |
| 1340 // Quit doing work once a load is in progress. |
| 1341 while (!queue_.empty()) { |
| 1342 bool startedLoad = queue_.front()->Run(controller_->delegate_, |
| 1343 controller_->web_view_); |
| 1344 delete queue_.front(); |
| 1345 queue_.pop_front(); |
| 1346 if (startedLoad) |
| 1347 return; |
| 1348 } |
| 1349 |
| 1350 if (!controller_->wait_until_done_ && !controller_->topLoadingFrame()) |
| 1351 controller_->delegate_->testFinished(); |
| 1352 } |
| 1353 |
| 1354 void TestRunner::WorkQueue::WorkQueueTask::runIfValid() { |
| 1355 m_object->ProcessWork(); |
| 1356 } |
| 1357 |
| 1358 TestRunner::TestRunner(TestInterfaces* interfaces) |
| 1359 : test_is_running_(false), |
| 1360 close_remaining_windows_(false), |
| 1361 work_queue_(this), |
| 1362 disable_notify_done_(false), |
| 1363 web_history_item_count_(0), |
| 1364 intercept_post_message_(false), |
| 1365 test_interfaces_(interfaces), |
| 1366 delegate_(NULL), |
| 1367 web_view_(NULL), |
| 1368 page_overlay_(NULL), |
| 1369 web_permissions_(new WebPermissions()), |
| 1370 notification_presenter_(new content::NotificationPresenter()), |
| 1371 weak_factory_(this) {} |
| 1372 |
| 1373 TestRunner::~TestRunner() {} |
| 1374 |
| 1375 void TestRunner::Install(WebFrame* frame) { |
| 1376 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); |
| 1377 } |
| 1378 |
| 1379 void TestRunner::SetDelegate(WebTestDelegate* delegate) { |
| 1380 delegate_ = delegate; |
| 1381 web_permissions_->setDelegate(delegate); |
| 1382 notification_presenter_->set_delegate(delegate); |
| 1383 } |
| 1384 |
| 1385 void TestRunner::SetWebView(WebView* webView, WebTestProxyBase* proxy) { |
| 1386 web_view_ = webView; |
| 1387 proxy_ = proxy; |
| 1388 } |
| 1389 |
| 1390 void TestRunner::Reset() { |
| 1391 if (web_view_) { |
| 1392 web_view_->setZoomLevel(0); |
| 1393 web_view_->setTextZoomFactor(1); |
| 1394 web_view_->setTabKeyCyclesThroughElements(true); |
| 1395 #if !defined(__APPLE__) && !defined(WIN32) // Actually, TOOLKIT_GTK |
| 1396 // (Constants copied because we can't depend on the header that defined |
| 1397 // them from this file.) |
| 1398 web_view_->setSelectionColors( |
| 1399 0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff323232); |
| 1400 #endif |
| 1401 web_view_->removeInjectedStyleSheets(); |
| 1402 web_view_->setVisibilityState(WebPageVisibilityStateVisible, true); |
| 1403 web_view_->mainFrame()->enableViewSourceMode(false); |
| 1404 |
| 1405 if (page_overlay_) { |
| 1406 web_view_->removePageOverlay(page_overlay_); |
| 1407 delete page_overlay_; |
| 1408 page_overlay_ = NULL; |
| 1409 } |
| 1410 } |
| 1411 |
| 1412 top_loading_frame_ = NULL; |
| 1413 wait_until_done_ = false; |
| 1414 policy_delegate_enabled_ = false; |
| 1415 policy_delegate_is_permissive_ = false; |
| 1416 policy_delegate_should_notify_done_ = false; |
| 1417 |
| 1418 WebSecurityPolicy::resetOriginAccessWhitelists(); |
| 1419 #if defined(__linux__) || defined(ANDROID) |
| 1420 WebFontRendering::setSubpixelPositioning(false); |
| 1421 #endif |
| 1422 |
| 1423 if (delegate_) { |
| 1424 // Reset the default quota for each origin to 5MB |
| 1425 delegate_->setDatabaseQuota(5 * 1024 * 1024); |
| 1426 delegate_->setDeviceScaleFactor(1); |
| 1427 delegate_->setAcceptAllCookies(false); |
| 1428 delegate_->setLocale(""); |
| 1429 delegate_->useUnfortunateSynchronousResizeMode(false); |
| 1430 delegate_->disableAutoResizeMode(WebSize()); |
| 1431 delegate_->deleteAllCookies(); |
| 1432 } |
| 1433 |
| 1434 dump_editting_callbacks_ = false; |
| 1435 dump_as_text_ = false; |
| 1436 dump_as_markup_ = false; |
| 1437 generate_pixel_results_ = true; |
| 1438 dump_child_frame_scroll_positions_ = false; |
| 1439 dump_child_frames_as_text_ = false; |
| 1440 dump_icon_changes_ = false; |
| 1441 dump_as_audio_ = false; |
| 1442 dump_frame_load_callbacks_ = false; |
| 1443 dump_ping_loader_callbacks_ = false; |
| 1444 dump_user_gesture_in_frame_load_callbacks_ = false; |
| 1445 dump_title_changes_ = false; |
| 1446 dump_create_view_ = false; |
| 1447 can_open_windows_ = false; |
| 1448 dump_resource_load_callbacks_ = false; |
| 1449 dump_resource_request_callbacks_ = false; |
| 1450 dump_resource_reqponse_mime_types_ = false; |
| 1451 dump_window_status_changes_ = false; |
| 1452 dump_progress_finished_callback_ = false; |
| 1453 dump_spell_check_callbacks_ = false; |
| 1454 dump_back_forward_list_ = false; |
| 1455 dump_selection_rect_ = false; |
| 1456 test_repaint_ = false; |
| 1457 sweep_horizontally_ = false; |
| 1458 is_printing_ = false; |
| 1459 midi_accessor_result_ = true; |
| 1460 should_stay_on_page_after_handling_before_unload_ = false; |
| 1461 should_dump_resource_priorities_ = false; |
| 1462 |
| 1463 http_headers_to_clear_.clear(); |
| 1464 |
| 1465 global_flag_ = false; |
| 1466 platform_name_ = "chromium"; |
| 1467 tooltip_text_ = std::string(); |
| 1468 disable_notify_done_ = false; |
| 1469 web_history_item_count_ = 0; |
| 1470 intercept_post_message_ = false; |
| 1471 |
| 1472 web_permissions_->reset(); |
| 1473 |
| 1474 notification_presenter_->Reset(); |
| 1475 use_mock_theme_ = true; |
| 1476 pointer_locked_ = false; |
| 1477 pointer_lock_planned_result_ = PointerLockWillSucceed; |
| 1478 |
| 1479 task_list_.revokeAll(); |
| 1480 work_queue_.Reset(); |
| 1481 |
| 1482 if (close_remaining_windows_ && delegate_) |
| 1483 delegate_->closeRemainingWindows(); |
| 1484 else |
| 1485 close_remaining_windows_ = true; |
| 1486 } |
| 1487 |
| 1488 void TestRunner::SetTestIsRunning(bool running) { |
| 1489 test_is_running_ = running; |
| 1490 } |
| 1491 |
| 1492 bool TestRunner::shouldDumpEditingCallbacks() const { |
| 1493 return dump_editting_callbacks_; |
| 1494 } |
| 1495 |
| 1496 bool TestRunner::shouldDumpAsText() { |
| 1497 CheckResponseMimeType(); |
| 1498 return dump_as_text_; |
| 1499 } |
| 1500 |
| 1501 void TestRunner::setShouldDumpAsText(bool value) { |
| 1502 dump_as_text_ = value; |
| 1503 } |
| 1504 |
| 1505 bool TestRunner::shouldDumpAsMarkup() { |
| 1506 return dump_as_markup_; |
| 1507 } |
| 1508 |
| 1509 void TestRunner::setShouldDumpAsMarkup(bool value) { |
| 1510 dump_as_markup_ = value; |
| 1511 } |
| 1512 |
| 1513 bool TestRunner::shouldGeneratePixelResults() { |
| 1514 CheckResponseMimeType(); |
| 1515 return generate_pixel_results_; |
| 1516 } |
| 1517 |
| 1518 void TestRunner::setShouldGeneratePixelResults(bool value) { |
| 1519 generate_pixel_results_ = value; |
| 1520 } |
| 1521 |
| 1522 bool TestRunner::shouldDumpChildFrameScrollPositions() const { |
| 1523 return dump_child_frame_scroll_positions_; |
| 1524 } |
| 1525 |
| 1526 bool TestRunner::shouldDumpChildFramesAsText() const { |
| 1527 return dump_child_frames_as_text_; |
| 1528 } |
| 1529 |
| 1530 bool TestRunner::shouldDumpAsAudio() const { |
| 1531 return dump_as_audio_; |
| 1532 } |
| 1533 |
| 1534 void TestRunner::getAudioData(std::vector<unsigned char>* bufferView) const { |
| 1535 *bufferView = audio_data_; |
| 1536 } |
| 1537 |
| 1538 bool TestRunner::shouldDumpFrameLoadCallbacks() const { |
| 1539 return test_is_running_ && dump_frame_load_callbacks_; |
| 1540 } |
| 1541 |
| 1542 void TestRunner::setShouldDumpFrameLoadCallbacks(bool value) { |
| 1543 dump_frame_load_callbacks_ = value; |
| 1544 } |
| 1545 |
| 1546 bool TestRunner::shouldDumpPingLoaderCallbacks() const { |
| 1547 return test_is_running_ && dump_ping_loader_callbacks_; |
| 1548 } |
| 1549 |
| 1550 void TestRunner::setShouldDumpPingLoaderCallbacks(bool value) { |
| 1551 dump_ping_loader_callbacks_ = value; |
| 1552 } |
| 1553 |
| 1554 void TestRunner::setShouldEnableViewSource(bool value) { |
| 1555 web_view_->mainFrame()->enableViewSourceMode(value); |
| 1556 } |
| 1557 |
| 1558 bool TestRunner::shouldDumpUserGestureInFrameLoadCallbacks() const { |
| 1559 return test_is_running_ && dump_user_gesture_in_frame_load_callbacks_; |
| 1560 } |
| 1561 |
| 1562 bool TestRunner::shouldDumpTitleChanges() const { |
| 1563 return dump_title_changes_; |
| 1564 } |
| 1565 |
| 1566 bool TestRunner::shouldDumpIconChanges() const { |
| 1567 return dump_icon_changes_; |
| 1568 } |
| 1569 |
| 1570 bool TestRunner::shouldDumpCreateView() const { |
| 1571 return dump_create_view_; |
| 1572 } |
| 1573 |
| 1574 bool TestRunner::canOpenWindows() const { |
| 1575 return can_open_windows_; |
| 1576 } |
| 1577 |
| 1578 bool TestRunner::shouldDumpResourceLoadCallbacks() const { |
| 1579 return test_is_running_ && dump_resource_load_callbacks_; |
| 1580 } |
| 1581 |
| 1582 bool TestRunner::shouldDumpResourceRequestCallbacks() const { |
| 1583 return test_is_running_ && dump_resource_request_callbacks_; |
| 1584 } |
| 1585 |
| 1586 bool TestRunner::shouldDumpResourceResponseMIMETypes() const { |
| 1587 return test_is_running_ && dump_resource_reqponse_mime_types_; |
| 1588 } |
| 1589 |
| 1590 WebPermissionClient* TestRunner::webPermissions() const { |
| 1591 return web_permissions_.get(); |
| 1592 } |
| 1593 |
| 1594 bool TestRunner::shouldDumpStatusCallbacks() const { |
| 1595 return dump_window_status_changes_; |
| 1596 } |
| 1597 |
| 1598 bool TestRunner::shouldDumpProgressFinishedCallback() const { |
| 1599 return dump_progress_finished_callback_; |
| 1600 } |
| 1601 |
| 1602 bool TestRunner::shouldDumpSpellCheckCallbacks() const { |
| 1603 return dump_spell_check_callbacks_; |
| 1604 } |
| 1605 |
| 1606 bool TestRunner::shouldDumpBackForwardList() const { |
| 1607 return dump_back_forward_list_; |
| 1608 } |
| 1609 |
| 1610 bool TestRunner::shouldDumpSelectionRect() const { |
| 1611 return dump_selection_rect_; |
| 1612 } |
| 1613 |
| 1614 bool TestRunner::testRepaint() const { |
| 1615 return test_repaint_; |
| 1616 } |
| 1617 |
| 1618 bool TestRunner::sweepHorizontally() const { |
| 1619 return sweep_horizontally_; |
| 1620 } |
| 1621 |
| 1622 bool TestRunner::isPrinting() const { |
| 1623 return is_printing_; |
| 1624 } |
| 1625 |
| 1626 bool TestRunner::shouldStayOnPageAfterHandlingBeforeUnload() const { |
| 1627 return should_stay_on_page_after_handling_before_unload_; |
| 1628 } |
| 1629 |
| 1630 const std::set<std::string>* TestRunner::httpHeadersToClear() const { |
| 1631 return &http_headers_to_clear_; |
| 1632 } |
| 1633 |
| 1634 void TestRunner::setTopLoadingFrame(WebFrame* frame, bool clear) { |
| 1635 if (frame->top()->view() != web_view_) |
| 1636 return; |
| 1637 if (!test_is_running_) |
| 1638 return; |
| 1639 if (clear) { |
| 1640 top_loading_frame_ = NULL; |
| 1641 LocationChangeDone(); |
| 1642 } else if (!top_loading_frame_) { |
| 1643 top_loading_frame_ = frame; |
| 1644 } |
| 1645 } |
| 1646 |
| 1647 WebFrame* TestRunner::topLoadingFrame() const { |
| 1648 return top_loading_frame_; |
| 1649 } |
| 1650 |
| 1651 void TestRunner::policyDelegateDone() { |
| 1652 BLINK_ASSERT(wait_until_done_); |
| 1653 delegate_->testFinished(); |
| 1654 wait_until_done_ = false; |
| 1655 } |
| 1656 |
| 1657 bool TestRunner::policyDelegateEnabled() const { |
| 1658 return policy_delegate_enabled_; |
| 1659 } |
| 1660 |
| 1661 bool TestRunner::policyDelegateIsPermissive() const { |
| 1662 return policy_delegate_is_permissive_; |
| 1663 } |
| 1664 |
| 1665 bool TestRunner::policyDelegateShouldNotifyDone() const { |
| 1666 return policy_delegate_should_notify_done_; |
| 1667 } |
| 1668 |
| 1669 bool TestRunner::shouldInterceptPostMessage() const { |
| 1670 return intercept_post_message_; |
| 1671 } |
| 1672 |
| 1673 bool TestRunner::shouldDumpResourcePriorities() const { |
| 1674 return should_dump_resource_priorities_; |
| 1675 } |
| 1676 |
| 1677 WebNotificationPresenter* TestRunner::notification_presenter() const { |
| 1678 return notification_presenter_.get(); |
| 1679 } |
| 1680 |
| 1681 bool TestRunner::RequestPointerLock() { |
| 1682 switch (pointer_lock_planned_result_) { |
| 1683 case PointerLockWillSucceed: |
| 1684 delegate_->postDelayedTask( |
| 1685 new HostMethodTask(this, &TestRunner::DidAcquirePointerLockInternal), |
| 1686 0); |
| 1687 return true; |
| 1688 case PointerLockWillRespondAsync: |
| 1689 BLINK_ASSERT(!pointer_locked_); |
| 1690 return true; |
| 1691 case PointerLockWillFailSync: |
| 1692 BLINK_ASSERT(!pointer_locked_); |
| 1693 return false; |
| 1694 default: |
| 1695 BLINK_ASSERT_NOT_REACHED(); |
| 1696 return false; |
| 1697 } |
| 1698 } |
| 1699 |
| 1700 void TestRunner::RequestPointerUnlock() { |
| 1701 delegate_->postDelayedTask( |
| 1702 new HostMethodTask(this, &TestRunner::DidLosePointerLockInternal), 0); |
| 1703 } |
| 1704 |
| 1705 bool TestRunner::isPointerLocked() { |
| 1706 return pointer_locked_; |
| 1707 } |
| 1708 |
| 1709 void TestRunner::setToolTipText(const WebString& text) { |
| 1710 tooltip_text_ = text.utf8(); |
| 1711 } |
| 1712 |
| 1713 bool TestRunner::midiAccessorResult() { |
| 1714 return midi_accessor_result_; |
| 1715 } |
| 1716 |
| 1717 void TestRunner::clearDevToolsLocalStorage() { |
| 1718 delegate_->clearDevToolsLocalStorage(); |
| 1719 } |
| 1720 |
| 1721 void TestRunner::showDevTools(const std::string& settings) { |
| 1722 delegate_->showDevTools(settings); |
| 1723 } |
| 1724 |
| 1725 class WorkItemBackForward : public TestRunner::WorkItem { |
| 1726 public: |
| 1727 WorkItemBackForward(int distance) : distance_(distance) {} |
| 1728 |
| 1729 virtual bool Run(WebTestDelegate* delegate, WebView*) OVERRIDE { |
| 1730 delegate->goToOffset(distance_); |
| 1731 return true; // FIXME: Did it really start a navigation? |
| 1732 } |
| 1733 |
| 1734 private: |
| 1735 int distance_; |
| 1736 }; |
| 1737 |
| 1738 void TestRunner::NotifyDone() { |
| 1739 if (disable_notify_done_) |
| 1740 return; |
| 1741 |
| 1742 // Test didn't timeout. Kill the timeout timer. |
| 1743 taskList()->revokeAll(); |
| 1744 |
| 1745 CompleteNotifyDone(); |
| 1746 } |
| 1747 |
| 1748 void TestRunner::WaitUntilDone() { |
| 1749 wait_until_done_ = true; |
| 1750 } |
| 1751 |
| 1752 void TestRunner::QueueBackNavigation(int how_far_back) { |
| 1753 work_queue_.AddWork(new WorkItemBackForward(-how_far_back)); |
| 1754 } |
| 1755 |
| 1756 void TestRunner::QueueForwardNavigation(int how_far_forward) { |
| 1757 work_queue_.AddWork(new WorkItemBackForward(how_far_forward)); |
| 1758 } |
| 1759 |
| 1760 class WorkItemReload : public TestRunner::WorkItem { |
| 1761 public: |
| 1762 virtual bool Run(WebTestDelegate* delegate, WebView*) OVERRIDE { |
| 1763 delegate->reload(); |
| 1764 return true; |
| 1765 } |
| 1766 }; |
| 1767 |
| 1768 void TestRunner::QueueReload() { |
| 1769 work_queue_.AddWork(new WorkItemReload()); |
| 1770 } |
| 1771 |
| 1772 class WorkItemLoadingScript : public TestRunner::WorkItem { |
| 1773 public: |
| 1774 WorkItemLoadingScript(const std::string& script) |
| 1775 : script_(script) {} |
| 1776 |
| 1777 virtual bool Run(WebTestDelegate*, WebView* web_view) OVERRIDE { |
| 1778 web_view->mainFrame()->executeScript( |
| 1779 WebScriptSource(WebString::fromUTF8(script_))); |
| 1780 return true; // FIXME: Did it really start a navigation? |
| 1781 } |
| 1782 |
| 1783 private: |
| 1784 std::string script_; |
| 1785 }; |
| 1786 |
| 1787 void TestRunner::QueueLoadingScript(const std::string& script) { |
| 1788 work_queue_.AddWork(new WorkItemLoadingScript(script)); |
| 1789 } |
| 1790 |
| 1791 class WorkItemNonLoadingScript : public TestRunner::WorkItem { |
| 1792 public: |
| 1793 WorkItemNonLoadingScript(const std::string& script) |
| 1794 : script_(script) {} |
| 1795 |
| 1796 virtual bool Run(WebTestDelegate*, WebView* web_view) OVERRIDE { |
| 1797 web_view->mainFrame()->executeScript( |
| 1798 WebScriptSource(WebString::fromUTF8(script_))); |
| 1799 return false; |
| 1800 } |
| 1801 |
| 1802 private: |
| 1803 std::string script_; |
| 1804 }; |
| 1805 |
| 1806 void TestRunner::QueueNonLoadingScript(const std::string& script) { |
| 1807 work_queue_.AddWork(new WorkItemNonLoadingScript(script)); |
| 1808 } |
| 1809 |
| 1810 class WorkItemLoad : public TestRunner::WorkItem { |
| 1811 public: |
| 1812 WorkItemLoad(const WebURL& url, const std::string& target) |
| 1813 : url_(url), target_(target) {} |
| 1814 |
| 1815 virtual bool Run(WebTestDelegate* delegate, WebView*) OVERRIDE { |
| 1816 delegate->loadURLForFrame(url_, target_); |
| 1817 return true; // FIXME: Did it really start a navigation? |
| 1818 } |
| 1819 |
| 1820 private: |
| 1821 WebURL url_; |
| 1822 std::string target_; |
| 1823 }; |
| 1824 |
| 1825 void TestRunner::QueueLoad(const std::string& url, const std::string& target) { |
| 1826 // FIXME: Implement WebURL::resolve() and avoid GURL. |
| 1827 GURL current_url = web_view_->mainFrame()->document().url(); |
| 1828 GURL full_url = current_url.Resolve(url); |
| 1829 work_queue_.AddWork(new WorkItemLoad(full_url, target)); |
| 1830 } |
| 1831 |
| 1832 class WorkItemLoadHTMLString : public TestRunner::WorkItem { |
| 1833 public: |
| 1834 WorkItemLoadHTMLString(const std::string& html, const WebURL& base_url) |
| 1835 : html_(html), base_url_(base_url) {} |
| 1836 |
| 1837 WorkItemLoadHTMLString(const std::string& html, const WebURL& base_url, |
| 1838 const WebURL& unreachable_url) |
| 1839 : html_(html), base_url_(base_url), unreachable_url_(unreachable_url) {} |
| 1840 |
| 1841 virtual bool Run(WebTestDelegate*, WebView* web_view) OVERRIDE { |
| 1842 web_view->mainFrame()->loadHTMLString( |
| 1843 WebData(html_.data(), html_.length()), |
| 1844 base_url_, unreachable_url_); |
| 1845 return true; |
| 1846 } |
| 1847 |
| 1848 private: |
| 1849 std::string html_; |
| 1850 WebURL base_url_; |
| 1851 WebURL unreachable_url_; |
| 1852 }; |
| 1853 |
| 1854 void TestRunner::QueueLoadHTMLString(gin::Arguments* args) { |
| 1855 std::string html; |
| 1856 args->GetNext(&html); |
| 1857 |
| 1858 std::string base_url_str; |
| 1859 args->GetNext(&base_url_str); |
| 1860 WebURL base_url = WebURL(GURL(base_url_str)); |
| 1861 |
| 1862 if (args->PeekNext()->IsString()) { |
| 1863 std::string unreachable_url_str; |
| 1864 args->GetNext(&unreachable_url_str); |
| 1865 WebURL unreachable_url = WebURL(GURL(unreachable_url_str)); |
| 1866 work_queue_.AddWork(new WorkItemLoadHTMLString(html, base_url, |
| 1867 unreachable_url)); |
| 1868 } else { |
| 1869 work_queue_.AddWork(new WorkItemLoadHTMLString(html, base_url)); |
| 1870 } |
| 1871 } |
| 1872 |
| 1873 void TestRunner::SetCustomPolicyDelegate(gin::Arguments* args) { |
| 1874 args->GetNext(&policy_delegate_enabled_); |
| 1875 if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsBoolean()) |
| 1876 args->GetNext(&policy_delegate_is_permissive_); |
| 1877 } |
| 1878 |
| 1879 void TestRunner::WaitForPolicyDelegate() { |
| 1880 policy_delegate_enabled_ = true; |
| 1881 policy_delegate_should_notify_done_ = true; |
| 1882 wait_until_done_ = true; |
| 1883 } |
| 1884 |
| 1885 int TestRunner::WindowCount() { |
| 1886 return test_interfaces_->windowList().size(); |
| 1887 } |
| 1888 |
| 1889 void TestRunner::SetCloseRemainingWindowsWhenComplete( |
| 1890 bool close_remaining_windows) { |
| 1891 close_remaining_windows_ = close_remaining_windows; |
| 1892 } |
| 1893 |
| 1894 void TestRunner::ResetTestHelperControllers() { |
| 1895 test_interfaces_->resetTestHelperControllers(); |
| 1896 } |
| 1897 |
| 1898 void TestRunner::SetTabKeyCyclesThroughElements( |
| 1899 bool tab_key_cycles_through_elements) { |
| 1900 web_view_->setTabKeyCyclesThroughElements(tab_key_cycles_through_elements); |
| 1901 } |
| 1902 |
| 1903 void TestRunner::ExecCommand(gin::Arguments* args) { |
| 1904 std::string command; |
| 1905 args->GetNext(&command); |
| 1906 |
| 1907 std::string value; |
| 1908 if (args->Length() >= 3) { |
| 1909 // Ignore the second parameter (which is userInterface) |
| 1910 // since this command emulates a manual action. |
| 1911 args->Skip(); |
| 1912 args->GetNext(&value); |
| 1913 } |
| 1914 |
| 1915 // Note: webkit's version does not return the boolean, so neither do we. |
| 1916 web_view_->focusedFrame()->executeCommand(WebString::fromUTF8(command), |
| 1917 WebString::fromUTF8(value)); |
| 1918 } |
| 1919 |
| 1920 bool TestRunner::IsCommandEnabled(const std::string& command) { |
| 1921 return web_view_->focusedFrame()->isCommandEnabled( |
| 1922 WebString::fromUTF8(command)); |
| 1923 } |
| 1924 |
| 1925 bool TestRunner::CallShouldCloseOnWebView() { |
| 1926 return web_view_->dispatchBeforeUnloadEvent(); |
| 1927 } |
| 1928 |
| 1929 void TestRunner::SetDomainRelaxationForbiddenForURLScheme( |
| 1930 bool forbidden, const std::string& scheme) { |
| 1931 web_view_->setDomainRelaxationForbidden(forbidden, |
| 1932 WebString::fromUTF8(scheme)); |
| 1933 } |
| 1934 |
| 1935 v8::Handle<v8::Value> TestRunner::EvaluateScriptInIsolatedWorldAndReturnValue( |
| 1936 int world_id, |
| 1937 const std::string& script) { |
| 1938 WebVector<v8::Local<v8::Value> > values; |
| 1939 WebScriptSource source(WebString::fromUTF8(script)); |
| 1940 // This relies on the iframe focusing itself when it loads. This is a bit |
| 1941 // sketchy, but it seems to be what other tests do. |
| 1942 web_view_->focusedFrame()->executeScriptInIsolatedWorld( |
| 1943 world_id, &source, 1, 1, &values); |
| 1944 // Since only one script was added, only one result is expected |
| 1945 if (values.size() == 1 && !values[0].IsEmpty()) |
| 1946 return values[0]; |
| 1947 return v8::Handle<v8::Value>(); |
| 1948 } |
| 1949 |
| 1950 void TestRunner::EvaluateScriptInIsolatedWorld(int world_id, |
| 1951 const std::string& script) { |
| 1952 WebScriptSource source(WebString::fromUTF8(script)); |
| 1953 web_view_->focusedFrame()->executeScriptInIsolatedWorld( |
| 1954 world_id, &source, 1, 1); |
| 1955 } |
| 1956 |
| 1957 void TestRunner::SetIsolatedWorldSecurityOrigin(int world_id, |
| 1958 v8::Handle<v8::Value> origin) { |
| 1959 if (!(origin->IsString() || !origin->IsNull())) |
| 1960 return; |
| 1961 |
| 1962 WebSecurityOrigin web_origin; |
| 1963 if (origin->IsString()) { |
| 1964 web_origin = WebSecurityOrigin::createFromString( |
| 1965 V8StringToWebString(origin->ToString())); |
| 1966 } |
| 1967 web_view_->focusedFrame()->setIsolatedWorldSecurityOrigin(world_id, |
| 1968 web_origin); |
| 1969 } |
| 1970 |
| 1971 void TestRunner::SetIsolatedWorldContentSecurityPolicy( |
| 1972 int world_id, |
| 1973 const std::string& policy) { |
| 1974 web_view_->focusedFrame()->setIsolatedWorldContentSecurityPolicy( |
| 1975 world_id, WebString::fromUTF8(policy)); |
| 1976 } |
| 1977 |
| 1978 void TestRunner::AddOriginAccessWhitelistEntry( |
| 1979 const std::string& source_origin, |
| 1980 const std::string& destination_protocol, |
| 1981 const std::string& destination_host, |
| 1982 bool allow_destination_subdomains) { |
| 1983 WebURL url((GURL(source_origin))); |
| 1984 if (!url.isValid()) |
| 1985 return; |
| 1986 |
| 1987 WebSecurityPolicy::addOriginAccessWhitelistEntry( |
| 1988 url, |
| 1989 WebString::fromUTF8(destination_protocol), |
| 1990 WebString::fromUTF8(destination_host), |
| 1991 allow_destination_subdomains); |
| 1992 } |
| 1993 |
| 1994 void TestRunner::RemoveOriginAccessWhitelistEntry( |
| 1995 const std::string& source_origin, |
| 1996 const std::string& destination_protocol, |
| 1997 const std::string& destination_host, |
| 1998 bool allow_destination_subdomains) { |
| 1999 WebURL url((GURL(source_origin))); |
| 2000 if (!url.isValid()) |
| 2001 return; |
| 2002 |
| 2003 WebSecurityPolicy::removeOriginAccessWhitelistEntry( |
| 2004 url, |
| 2005 WebString::fromUTF8(destination_protocol), |
| 2006 WebString::fromUTF8(destination_host), |
| 2007 allow_destination_subdomains); |
| 2008 } |
| 2009 |
| 2010 bool TestRunner::HasCustomPageSizeStyle(int page_index) { |
| 2011 WebFrame* frame = web_view_->mainFrame(); |
| 2012 if (!frame) |
| 2013 return false; |
| 2014 return frame->hasCustomPageSizeStyle(page_index); |
| 2015 } |
| 2016 |
| 2017 void TestRunner::ForceRedSelectionColors() { |
| 2018 web_view_->setSelectionColors(0xffee0000, 0xff00ee00, 0xff000000, 0xffc0c0c0); |
| 2019 } |
| 2020 |
| 2021 void TestRunner::InjectStyleSheet(const std::string& source_code, |
| 2022 bool all_frames) { |
| 2023 WebView::injectStyleSheet( |
| 2024 WebString::fromUTF8(source_code), |
| 2025 WebVector<WebString>(), |
| 2026 all_frames ? WebView::InjectStyleInAllFrames |
| 2027 : WebView::InjectStyleInTopFrameOnly); |
| 2028 } |
| 2029 |
| 2030 bool TestRunner::FindString(const std::string& search_text, |
| 2031 const std::vector<std::string>& options_array) { |
| 2032 WebFindOptions find_options; |
| 2033 bool wrap_around = false; |
| 2034 find_options.matchCase = true; |
| 2035 find_options.findNext = true; |
| 2036 |
| 2037 for (size_t i = 0; i < options_array.size(); ++i) { |
| 2038 const std::string& option = options_array[i]; |
| 2039 if (option == "CaseInsensitive") |
| 2040 find_options.matchCase = false; |
| 2041 else if (option == "Backwards") |
| 2042 find_options.forward = false; |
| 2043 else if (option == "StartInSelection") |
| 2044 find_options.findNext = false; |
| 2045 else if (option == "AtWordStarts") |
| 2046 find_options.wordStart = true; |
| 2047 else if (option == "TreatMedialCapitalAsWordStart") |
| 2048 find_options.medialCapitalAsWordStart = true; |
| 2049 else if (option == "WrapAround") |
| 2050 wrap_around = true; |
| 2051 } |
| 2052 |
| 2053 WebFrame* frame = web_view_->mainFrame(); |
| 2054 const bool find_result = frame->find(0, WebString::fromUTF8(search_text), |
| 2055 find_options, wrap_around, 0); |
| 2056 frame->stopFinding(false); |
| 2057 return find_result; |
| 2058 } |
| 2059 |
| 2060 std::string TestRunner::SelectionAsMarkup() { |
| 2061 return web_view_->mainFrame()->selectionAsMarkup().utf8(); |
| 2062 } |
| 2063 |
| 2064 void TestRunner::SetTextSubpixelPositioning(bool value) { |
| 2065 #if defined(__linux__) || defined(ANDROID) |
| 2066 // Since FontConfig doesn't provide a variable to control subpixel |
| 2067 // positioning, we'll fall back to setting it globally for all fonts. |
| 2068 WebFontRendering::setSubpixelPositioning(value); |
| 2069 #endif |
| 2070 } |
| 2071 |
| 2072 void TestRunner::SetPageVisibility(const std::string& new_visibility) { |
| 2073 if (new_visibility == "visible") |
| 2074 web_view_->setVisibilityState(WebPageVisibilityStateVisible, false); |
| 2075 else if (new_visibility == "hidden") |
| 2076 web_view_->setVisibilityState(WebPageVisibilityStateHidden, false); |
| 2077 else if (new_visibility == "prerender") |
| 2078 web_view_->setVisibilityState(WebPageVisibilityStatePrerender, false); |
| 2079 } |
| 2080 |
| 2081 void TestRunner::SetTextDirection(const std::string& direction_name) { |
| 2082 // Map a direction name to a WebTextDirection value. |
| 2083 WebTextDirection direction; |
| 2084 if (direction_name == "auto") |
| 2085 direction = WebTextDirectionDefault; |
| 2086 else if (direction_name == "rtl") |
| 2087 direction = WebTextDirectionRightToLeft; |
| 2088 else if (direction_name == "ltr") |
| 2089 direction = WebTextDirectionLeftToRight; |
| 2090 else |
| 2091 return; |
| 2092 |
| 2093 web_view_->setTextDirection(direction); |
| 2094 } |
| 2095 |
| 2096 void TestRunner::UseUnfortunateSynchronousResizeMode() { |
| 2097 delegate_->useUnfortunateSynchronousResizeMode(true); |
| 2098 } |
| 2099 |
| 2100 bool TestRunner::EnableAutoResizeMode(int min_width, |
| 2101 int min_height, |
| 2102 int max_width, |
| 2103 int max_height) { |
| 2104 WebSize min_size(min_width, min_height); |
| 2105 WebSize max_size(max_width, max_height); |
| 2106 delegate_->enableAutoResizeMode(min_size, max_size); |
| 2107 return true; |
| 2108 } |
| 2109 |
| 2110 bool TestRunner::DisableAutoResizeMode(int new_width, int new_height) { |
| 2111 WebSize new_size(new_width, new_height); |
| 2112 delegate_->disableAutoResizeMode(new_size); |
| 2113 return true; |
| 2114 } |
| 2115 |
| 2116 void TestRunner::SetMockDeviceMotion( |
| 2117 bool has_acceleration_x, double acceleration_x, |
| 2118 bool has_acceleration_y, double acceleration_y, |
| 2119 bool has_acceleration_z, double acceleration_z, |
| 2120 bool has_acceleration_including_gravity_x, |
| 2121 double acceleration_including_gravity_x, |
| 2122 bool has_acceleration_including_gravity_y, |
| 2123 double acceleration_including_gravity_y, |
| 2124 bool has_acceleration_including_gravity_z, |
| 2125 double acceleration_including_gravity_z, |
| 2126 bool has_rotation_rate_alpha, double rotation_rate_alpha, |
| 2127 bool has_rotation_rate_beta, double rotation_rate_beta, |
| 2128 bool has_rotation_rate_gamma, double rotation_rate_gamma, |
| 2129 double interval) { |
| 2130 WebDeviceMotionData motion; |
| 2131 |
| 2132 // acceleration |
| 2133 motion.hasAccelerationX = has_acceleration_x; |
| 2134 motion.accelerationX = acceleration_x; |
| 2135 motion.hasAccelerationY = has_acceleration_y; |
| 2136 motion.accelerationY = acceleration_y; |
| 2137 motion.hasAccelerationZ = has_acceleration_z; |
| 2138 motion.accelerationZ = acceleration_z; |
| 2139 |
| 2140 // accelerationIncludingGravity |
| 2141 motion.hasAccelerationIncludingGravityX = |
| 2142 has_acceleration_including_gravity_x; |
| 2143 motion.accelerationIncludingGravityX = acceleration_including_gravity_x; |
| 2144 motion.hasAccelerationIncludingGravityY = |
| 2145 has_acceleration_including_gravity_y; |
| 2146 motion.accelerationIncludingGravityY = acceleration_including_gravity_y; |
| 2147 motion.hasAccelerationIncludingGravityZ = |
| 2148 has_acceleration_including_gravity_z; |
| 2149 motion.accelerationIncludingGravityZ = acceleration_including_gravity_z; |
| 2150 |
| 2151 // rotationRate |
| 2152 motion.hasRotationRateAlpha = has_rotation_rate_alpha; |
| 2153 motion.rotationRateAlpha = rotation_rate_alpha; |
| 2154 motion.hasRotationRateBeta = has_rotation_rate_beta; |
| 2155 motion.rotationRateBeta = rotation_rate_beta; |
| 2156 motion.hasRotationRateGamma = has_rotation_rate_gamma; |
| 2157 motion.rotationRateGamma = rotation_rate_gamma; |
| 2158 |
| 2159 // interval |
| 2160 motion.interval = interval; |
| 2161 |
| 2162 delegate_->setDeviceMotionData(motion); |
| 2163 } |
| 2164 |
| 2165 void TestRunner::SetMockDeviceOrientation(bool has_alpha, double alpha, |
| 2166 bool has_beta, double beta, |
| 2167 bool has_gamma, double gamma, |
| 2168 bool has_absolute, bool absolute) { |
| 2169 WebDeviceOrientationData orientation; |
| 2170 |
| 2171 // alpha |
| 2172 orientation.hasAlpha = has_alpha; |
| 2173 orientation.alpha = alpha; |
| 2174 |
| 2175 // beta |
| 2176 orientation.hasBeta = has_beta; |
| 2177 orientation.beta = beta; |
| 2178 |
| 2179 // gamma |
| 2180 orientation.hasGamma = has_gamma; |
| 2181 orientation.gamma = gamma; |
| 2182 |
| 2183 // absolute |
| 2184 orientation.hasAbsolute = has_absolute; |
| 2185 orientation.absolute = absolute; |
| 2186 |
| 2187 delegate_->setDeviceOrientationData(orientation); |
| 2188 } |
| 2189 |
| 2190 void TestRunner::DidAcquirePointerLock() { |
| 2191 DidAcquirePointerLockInternal(); |
| 2192 } |
| 2193 |
| 2194 void TestRunner::DidNotAcquirePointerLock() { |
| 2195 DidNotAcquirePointerLockInternal(); |
| 2196 } |
| 2197 |
| 2198 void TestRunner::DidLosePointerLock() { |
| 2199 DidLosePointerLockInternal(); |
| 2200 } |
| 2201 |
| 2202 void TestRunner::SetPointerLockWillFailSynchronously() { |
| 2203 pointer_lock_planned_result_ = PointerLockWillFailSync; |
| 2204 } |
| 2205 |
| 2206 void TestRunner::SetPointerLockWillRespondAsynchronously() { |
| 2207 pointer_lock_planned_result_ = PointerLockWillRespondAsync; |
| 2208 } |
| 2209 |
| 2210 void TestRunner::SetPopupBlockingEnabled(bool block_popups) { |
| 2211 delegate_->preferences()->javaScriptCanOpenWindowsAutomatically = |
| 2212 !block_popups; |
| 2213 delegate_->applyPreferences(); |
| 2214 } |
| 2215 |
| 2216 void TestRunner::SetJavaScriptCanAccessClipboard(bool can_access) { |
| 2217 delegate_->preferences()->javaScriptCanAccessClipboard = can_access; |
| 2218 delegate_->applyPreferences(); |
| 2219 } |
| 2220 |
| 2221 void TestRunner::SetXSSAuditorEnabled(bool enabled) { |
| 2222 delegate_->preferences()->XSSAuditorEnabled = enabled; |
| 2223 delegate_->applyPreferences(); |
| 2224 } |
| 2225 |
| 2226 void TestRunner::SetAllowUniversalAccessFromFileURLs(bool allow) { |
| 2227 delegate_->preferences()->allowUniversalAccessFromFileURLs = allow; |
| 2228 delegate_->applyPreferences(); |
| 2229 } |
| 2230 |
| 2231 void TestRunner::SetAllowFileAccessFromFileURLs(bool allow) { |
| 2232 delegate_->preferences()->allowFileAccessFromFileURLs = allow; |
| 2233 delegate_->applyPreferences(); |
| 2234 } |
| 2235 |
| 2236 void TestRunner::OverridePreference(const std::string key, |
| 2237 v8::Handle<v8::Value> value) { |
| 2238 WebPreferences* prefs = delegate_->preferences(); |
| 2239 if (key == "WebKitDefaultFontSize") { |
| 2240 prefs->defaultFontSize = value->Int32Value(); |
| 2241 } else if (key == "WebKitMinimumFontSize") { |
| 2242 prefs->minimumFontSize = value->Int32Value(); |
| 2243 } else if (key == "WebKitDefaultTextEncodingName") { |
| 2244 prefs->defaultTextEncodingName = V8StringToWebString(value->ToString()); |
| 2245 } else if (key == "WebKitJavaScriptEnabled") { |
| 2246 prefs->javaScriptEnabled = value->BooleanValue(); |
| 2247 } else if (key == "WebKitSupportsMultipleWindows") { |
| 2248 prefs->supportsMultipleWindows = value->BooleanValue(); |
| 2249 } else if (key == "WebKitDisplayImagesKey") { |
| 2250 prefs->loadsImagesAutomatically = value->BooleanValue(); |
| 2251 } else if (key == "WebKitPluginsEnabled") { |
| 2252 prefs->pluginsEnabled = value->BooleanValue(); |
| 2253 } else if (key == "WebKitJavaEnabled") { |
| 2254 prefs->javaEnabled = value->BooleanValue(); |
| 2255 } else if (key == "WebKitOfflineWebApplicationCacheEnabled") { |
| 2256 prefs->offlineWebApplicationCacheEnabled = value->BooleanValue(); |
| 2257 } else if (key == "WebKitTabToLinksPreferenceKey") { |
| 2258 prefs->tabsToLinks = value->BooleanValue(); |
| 2259 } else if (key == "WebKitWebGLEnabled") { |
| 2260 prefs->experimentalWebGLEnabled = value->BooleanValue(); |
| 2261 } else if (key == "WebKitCSSRegionsEnabled") { |
| 2262 prefs->experimentalCSSRegionsEnabled = value->BooleanValue(); |
| 2263 } else if (key == "WebKitCSSGridLayoutEnabled") { |
| 2264 prefs->experimentalCSSGridLayoutEnabled = value->BooleanValue(); |
| 2265 } else if (key == "WebKitHyperlinkAuditingEnabled") { |
| 2266 prefs->hyperlinkAuditingEnabled = value->BooleanValue(); |
| 2267 } else if (key == "WebKitEnableCaretBrowsing") { |
| 2268 prefs->caretBrowsingEnabled = value->BooleanValue(); |
| 2269 } else if (key == "WebKitAllowDisplayingInsecureContent") { |
| 2270 prefs->allowDisplayOfInsecureContent = value->BooleanValue(); |
| 2271 } else if (key == "WebKitAllowRunningInsecureContent") { |
| 2272 prefs->allowRunningOfInsecureContent = value->BooleanValue(); |
| 2273 } else if (key == "WebKitShouldRespectImageOrientation") { |
| 2274 prefs->shouldRespectImageOrientation = value->BooleanValue(); |
| 2275 } else if (key == "WebKitWebAudioEnabled") { |
| 2276 BLINK_ASSERT(value->BooleanValue()); |
| 2277 } else { |
| 2278 std::string message("Invalid name for preference: "); |
| 2279 message.append(key); |
| 2280 delegate_->printMessage(std::string("CONSOLE MESSAGE: ") + message + "\n"); |
| 2281 } |
| 2282 delegate_->applyPreferences(); |
| 2283 } |
| 2284 |
| 2285 void TestRunner::SetPluginsEnabled(bool enabled) { |
| 2286 delegate_->preferences()->pluginsEnabled = enabled; |
| 2287 delegate_->applyPreferences(); |
| 2288 } |
| 2289 |
| 2290 void TestRunner::DumpEditingCallbacks() { |
| 2291 dump_editting_callbacks_ = true; |
| 2292 } |
| 2293 |
| 2294 void TestRunner::DumpAsText() { |
| 2295 dump_as_text_ = true; |
| 2296 generate_pixel_results_ = false; |
| 2297 } |
| 2298 |
| 2299 void TestRunner::DumpAsTextWithPixelResults() { |
| 2300 dump_as_text_ = true; |
| 2301 generate_pixel_results_ = true; |
| 2302 } |
| 2303 |
| 2304 void TestRunner::DumpChildFrameScrollPositions() { |
| 2305 dump_child_frame_scroll_positions_ = true; |
| 2306 } |
| 2307 |
| 2308 void TestRunner::DumpChildFramesAsText() { |
| 2309 dump_child_frames_as_text_ = true; |
| 2310 } |
| 2311 |
| 2312 void TestRunner::DumpIconChanges() { |
| 2313 dump_icon_changes_ = true; |
| 2314 } |
| 2315 |
| 2316 void TestRunner::SetAudioData(const gin::ArrayBufferView& view) { |
| 2317 unsigned char* bytes = static_cast<unsigned char*>(view.bytes()); |
| 2318 audio_data_.resize(view.num_bytes()); |
| 2319 std::copy(bytes, bytes + view.num_bytes(), audio_data_.begin()); |
| 2320 dump_as_audio_ = true; |
| 2321 } |
| 2322 |
| 2323 void TestRunner::DumpFrameLoadCallbacks() { |
| 2324 dump_frame_load_callbacks_ = true; |
| 2325 } |
| 2326 |
| 2327 void TestRunner::DumpPingLoaderCallbacks() { |
| 2328 dump_ping_loader_callbacks_ = true; |
| 2329 } |
| 2330 |
| 2331 void TestRunner::DumpUserGestureInFrameLoadCallbacks() { |
| 2332 dump_user_gesture_in_frame_load_callbacks_ = true; |
| 2333 } |
| 2334 |
| 2335 void TestRunner::DumpTitleChanges() { |
| 2336 dump_title_changes_ = true; |
| 2337 } |
| 2338 |
| 2339 void TestRunner::DumpCreateView() { |
| 2340 dump_create_view_ = true; |
| 2341 } |
| 2342 |
| 2343 void TestRunner::SetCanOpenWindows() { |
| 2344 can_open_windows_ = true; |
| 2345 } |
| 2346 |
| 2347 void TestRunner::DumpResourceLoadCallbacks() { |
| 2348 dump_resource_load_callbacks_ = true; |
| 2349 } |
| 2350 |
| 2351 void TestRunner::DumpResourceRequestCallbacks() { |
| 2352 dump_resource_request_callbacks_ = true; |
| 2353 } |
| 2354 |
| 2355 void TestRunner::DumpResourceResponseMIMETypes() { |
| 2356 dump_resource_reqponse_mime_types_ = true; |
| 2357 } |
| 2358 |
| 2359 void TestRunner::SetImagesAllowed(bool allowed) { |
| 2360 web_permissions_->setImagesAllowed(allowed); |
| 2361 } |
| 2362 |
| 2363 void TestRunner::SetScriptsAllowed(bool allowed) { |
| 2364 web_permissions_->setScriptsAllowed(allowed); |
| 2365 } |
| 2366 |
| 2367 void TestRunner::SetStorageAllowed(bool allowed) { |
| 2368 web_permissions_->setStorageAllowed(allowed); |
| 2369 } |
| 2370 |
| 2371 void TestRunner::SetPluginsAllowed(bool allowed) { |
| 2372 web_permissions_->setPluginsAllowed(allowed); |
| 2373 } |
| 2374 |
| 2375 void TestRunner::SetAllowDisplayOfInsecureContent(bool allowed) { |
| 2376 web_permissions_->setDisplayingInsecureContentAllowed(allowed); |
| 2377 } |
| 2378 |
| 2379 void TestRunner::SetAllowRunningOfInsecureContent(bool allowed) { |
| 2380 web_permissions_->setRunningInsecureContentAllowed(allowed); |
| 2381 } |
| 2382 |
| 2383 void TestRunner::DumpPermissionClientCallbacks() { |
| 2384 web_permissions_->setDumpCallbacks(true); |
| 2385 } |
| 2386 |
| 2387 void TestRunner::DumpWindowStatusChanges() { |
| 2388 dump_window_status_changes_ = true; |
| 2389 } |
| 2390 |
| 2391 void TestRunner::DumpProgressFinishedCallback() { |
| 2392 dump_progress_finished_callback_ = true; |
| 2393 } |
| 2394 |
| 2395 void TestRunner::DumpSpellCheckCallbacks() { |
| 2396 dump_spell_check_callbacks_ = true; |
| 2397 } |
| 2398 |
| 2399 void TestRunner::DumpBackForwardList() { |
| 2400 dump_back_forward_list_ = true; |
| 2401 } |
| 2402 |
| 2403 void TestRunner::DumpSelectionRect() { |
| 2404 dump_selection_rect_ = true; |
| 2405 } |
| 2406 |
| 2407 void TestRunner::TestRepaint() { |
| 2408 test_repaint_ = true; |
| 2409 } |
| 2410 |
| 2411 void TestRunner::RepaintSweepHorizontally() { |
| 2412 sweep_horizontally_ = true; |
| 2413 } |
| 2414 |
| 2415 void TestRunner::SetPrinting() { |
| 2416 is_printing_ = true; |
| 2417 } |
| 2418 |
| 2419 void TestRunner::SetShouldStayOnPageAfterHandlingBeforeUnload(bool value) { |
| 2420 should_stay_on_page_after_handling_before_unload_ = value; |
| 2421 } |
| 2422 |
| 2423 void TestRunner::SetWillSendRequestClearHeader(const std::string& header) { |
| 2424 if (!header.empty()) |
| 2425 http_headers_to_clear_.insert(header); |
| 2426 } |
| 2427 |
| 2428 void TestRunner::DumpResourceRequestPriorities() { |
| 2429 should_dump_resource_priorities_ = true; |
| 2430 } |
| 2431 |
| 2432 void TestRunner::SetUseMockTheme(bool use) { |
| 2433 use_mock_theme_ = use; |
| 2434 } |
| 2435 |
| 2436 void TestRunner::ShowWebInspector(const std::string& str) { |
| 2437 showDevTools(str); |
| 2438 } |
| 2439 |
| 2440 void TestRunner::CloseWebInspector() { |
| 2441 delegate_->closeDevTools(); |
| 2442 } |
| 2443 |
| 2444 bool TestRunner::IsChooserShown() { |
| 2445 return proxy_->isChooserShown(); |
| 2446 } |
| 2447 |
| 2448 void TestRunner::EvaluateInWebInspector(int call_id, |
| 2449 const std::string& script) { |
| 2450 delegate_->evaluateInWebInspector(call_id, script); |
| 2451 } |
| 2452 |
| 2453 void TestRunner::ClearAllDatabases() { |
| 2454 delegate_->clearAllDatabases(); |
| 2455 } |
| 2456 |
| 2457 void TestRunner::SetDatabaseQuota(int quota) { |
| 2458 delegate_->setDatabaseQuota(quota); |
| 2459 } |
| 2460 |
| 2461 void TestRunner::SetAlwaysAcceptCookies(bool accept) { |
| 2462 delegate_->setAcceptAllCookies(accept); |
| 2463 } |
| 2464 |
| 2465 void TestRunner::SetWindowIsKey(bool value) { |
| 2466 delegate_->setFocus(proxy_, value); |
| 2467 } |
| 2468 |
| 2469 std::string TestRunner::PathToLocalResource(const std::string& path) { |
| 2470 return delegate_->pathToLocalResource(path); |
| 2471 } |
| 2472 |
| 2473 void TestRunner::SetBackingScaleFactor(double value, |
| 2474 v8::Handle<v8::Function> callback) { |
| 2475 delegate_->setDeviceScaleFactor(value); |
| 2476 proxy_->discardBackingStore(); |
| 2477 delegate_->postTask(new InvokeCallbackTask(this, callback)); |
| 2478 } |
| 2479 |
| 2480 void TestRunner::SetPOSIXLocale(const std::string& locale) { |
| 2481 delegate_->setLocale(locale); |
| 2482 } |
| 2483 |
| 2484 void TestRunner::SetMIDIAccessorResult(bool result) { |
| 2485 midi_accessor_result_ = result; |
| 2486 } |
| 2487 |
| 2488 void TestRunner::SetMIDISysExPermission(bool value) { |
| 2489 const std::vector<WebTestProxyBase*>& windowList = |
| 2490 test_interfaces_->windowList(); |
| 2491 for (unsigned i = 0; i < windowList.size(); ++i) |
| 2492 windowList.at(i)->midiClientMock()->setSysExPermission(value); |
| 2493 } |
| 2494 |
| 2495 void TestRunner::GrantWebNotificationPermission(const std::string& origin, |
| 2496 bool permission_granted) { |
| 2497 notification_presenter_->GrantPermission(origin, permission_granted); |
| 2498 } |
| 2499 |
| 2500 bool TestRunner::SimulateWebNotificationClick(const std::string& value) { |
| 2501 return notification_presenter_->SimulateClick(value); |
| 2502 } |
| 2503 |
| 2504 void TestRunner::AddMockSpeechInputResult(const std::string& result, |
| 2505 double confidence, |
| 2506 const std::string& language) { |
| 2507 #if ENABLE_INPUT_SPEECH |
| 2508 proxy_->speechInputControllerMock()->addMockRecognitionResult( |
| 2509 WebString::fromUTF8(result), confidence, WebString::fromUTF8(language)); |
| 2510 #endif |
| 2511 } |
| 2512 |
| 2513 void TestRunner::SetMockSpeechInputDumpRect(bool value) { |
| 2514 #if ENABLE_INPUT_SPEECH |
| 2515 proxy_->speechInputControllerMock()->setDumpRect(value); |
| 2516 #endif |
| 2517 } |
| 2518 |
| 2519 void TestRunner::AddMockSpeechRecognitionResult(const std::string& transcript, |
| 2520 double confidence) { |
| 2521 proxy_->speechRecognizerMock()->addMockResult( |
| 2522 WebString::fromUTF8(transcript), confidence); |
| 2523 } |
| 2524 |
| 2525 void TestRunner::SetMockSpeechRecognitionError(const std::string& error, |
| 2526 const std::string& message) { |
| 2527 proxy_->speechRecognizerMock()->setError(WebString::fromUTF8(error), |
| 2528 WebString::fromUTF8(message)); |
| 2529 } |
| 2530 |
| 2531 bool TestRunner::WasMockSpeechRecognitionAborted() { |
| 2532 return proxy_->speechRecognizerMock()->wasAborted(); |
| 2533 } |
| 2534 |
| 2535 void TestRunner::AddWebPageOverlay() { |
| 2536 if (web_view_ && !page_overlay_) { |
| 2537 page_overlay_ = new TestPageOverlay(web_view_); |
| 2538 web_view_->addPageOverlay(page_overlay_, 0); |
| 2539 } |
| 2540 } |
| 2541 |
| 2542 void TestRunner::RemoveWebPageOverlay() { |
| 2543 if (web_view_ && page_overlay_) { |
| 2544 web_view_->removePageOverlay(page_overlay_); |
| 2545 delete page_overlay_; |
| 2546 page_overlay_ = NULL; |
| 2547 } |
| 2548 } |
| 2549 |
| 2550 void TestRunner::Display() { |
| 2551 proxy_->display(); |
| 2552 } |
| 2553 |
| 2554 void TestRunner::DisplayInvalidatedRegion() { |
| 2555 proxy_->displayInvalidatedRegion(); |
| 2556 } |
| 2557 |
| 2558 void TestRunner::LocationChangeDone() { |
| 2559 web_history_item_count_ = delegate_->navigationEntryCount(); |
| 2560 |
| 2561 // No more new work after the first complete load. |
| 2562 work_queue_.set_frozen(true); |
| 2563 |
| 2564 if (!wait_until_done_) |
| 2565 work_queue_.ProcessWorkSoon(); |
| 2566 } |
| 2567 |
| 2568 void TestRunner::CheckResponseMimeType() { |
| 2569 // Text output: the test page can request different types of output which we |
| 2570 // handle here. |
| 2571 if (!dump_as_text_) { |
| 2572 std::string mimeType = |
| 2573 web_view_->mainFrame()->dataSource()->response().mimeType().utf8(); |
| 2574 if (mimeType == "text/plain") { |
| 2575 dump_as_text_ = true; |
| 2576 generate_pixel_results_ = false; |
| 2577 } |
| 2578 } |
| 2579 } |
| 2580 |
| 2581 void TestRunner::CompleteNotifyDone() { |
| 2582 if (wait_until_done_ && !topLoadingFrame() && work_queue_.is_empty()) |
| 2583 delegate_->testFinished(); |
| 2584 wait_until_done_ = false; |
| 2585 } |
| 2586 |
| 2587 void TestRunner::DidAcquirePointerLockInternal() { |
| 2588 pointer_locked_ = true; |
| 2589 web_view_->didAcquirePointerLock(); |
| 2590 |
| 2591 // Reset planned result to default. |
| 2592 pointer_lock_planned_result_ = PointerLockWillSucceed; |
| 2593 } |
| 2594 |
| 2595 void TestRunner::DidNotAcquirePointerLockInternal() { |
| 2596 BLINK_ASSERT(!pointer_locked_); |
| 2597 pointer_locked_ = false; |
| 2598 web_view_->didNotAcquirePointerLock(); |
| 2599 |
| 2600 // Reset planned result to default. |
| 2601 pointer_lock_planned_result_ = PointerLockWillSucceed; |
| 2602 } |
| 2603 |
| 2604 void TestRunner::DidLosePointerLockInternal() { |
| 2605 bool was_locked = pointer_locked_; |
| 2606 pointer_locked_ = false; |
| 2607 if (was_locked) |
| 2608 web_view_->didLosePointerLock(); |
| 2609 } |
| 2610 |
| 2611 } // namespace content |
OLD | NEW |