| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/shell/renderer/test_runner/test_runner.h" | 5 #include "content/shell/renderer/test_runner/test_runner.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/public/test/layouttest_support.h" | 10 #include "content/public/test/layouttest_support.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 #if defined(__linux__) || defined(ANDROID) | 58 #if defined(__linux__) || defined(ANDROID) |
| 59 #include "third_party/WebKit/public/web/linux/WebFontRendering.h" | 59 #include "third_party/WebKit/public/web/linux/WebFontRendering.h" |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 using namespace blink; | 62 using namespace blink; |
| 63 | 63 |
| 64 namespace content { | 64 namespace content { |
| 65 | 65 |
| 66 namespace { | 66 namespace { |
| 67 | 67 |
| 68 WebString V8StringToWebString(v8::Handle<v8::String> v8_str) { | 68 WebString V8StringToWebString(v8::Local<v8::String> v8_str) { |
| 69 int length = v8_str->Utf8Length() + 1; | 69 int length = v8_str->Utf8Length() + 1; |
| 70 scoped_ptr<char[]> chars(new char[length]); | 70 scoped_ptr<char[]> chars(new char[length]); |
| 71 v8_str->WriteUtf8(chars.get(), length); | 71 v8_str->WriteUtf8(chars.get(), length); |
| 72 return WebString::fromUTF8(chars.get()); | 72 return WebString::fromUTF8(chars.get()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 class HostMethodTask : public WebMethodTask<TestRunner> { | 75 class HostMethodTask : public WebMethodTask<TestRunner> { |
| 76 public: | 76 public: |
| 77 typedef void (TestRunner::*CallbackMethodType)(); | 77 typedef void (TestRunner::*CallbackMethodType)(); |
| 78 HostMethodTask(TestRunner* object, CallbackMethodType callback) | 78 HostMethodTask(TestRunner* object, CallbackMethodType callback) |
| 79 : WebMethodTask<TestRunner>(object), callback_(callback) {} | 79 : WebMethodTask<TestRunner>(object), callback_(callback) {} |
| 80 | 80 |
| 81 void RunIfValid() override { (object_->*callback_)(); } | 81 void RunIfValid() override { (object_->*callback_)(); } |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 CallbackMethodType callback_; | 84 CallbackMethodType callback_; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 } // namespace | 87 } // namespace |
| 88 | 88 |
| 89 class InvokeCallbackTask : public WebMethodTask<TestRunner> { | 89 class InvokeCallbackTask : public WebMethodTask<TestRunner> { |
| 90 public: | 90 public: |
| 91 InvokeCallbackTask(TestRunner* object, v8::Handle<v8::Function> callback) | 91 InvokeCallbackTask(TestRunner* object, v8::Local<v8::Function> callback) |
| 92 : WebMethodTask<TestRunner>(object), | 92 : WebMethodTask<TestRunner>(object), |
| 93 callback_(blink::mainThreadIsolate(), callback), | 93 callback_(blink::mainThreadIsolate(), callback), |
| 94 argc_(0) {} | 94 argc_(0) {} |
| 95 | 95 |
| 96 void RunIfValid() override { | 96 void RunIfValid() override { |
| 97 v8::Isolate* isolate = blink::mainThreadIsolate(); | 97 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 98 v8::HandleScope handle_scope(isolate); | 98 v8::HandleScope handle_scope(isolate); |
| 99 WebFrame* frame = object_->web_view_->mainFrame(); | 99 WebFrame* frame = object_->web_view_->mainFrame(); |
| 100 | 100 |
| 101 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); | 101 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); |
| 102 if (context.IsEmpty()) | 102 if (context.IsEmpty()) |
| 103 return; | 103 return; |
| 104 | 104 |
| 105 v8::Context::Scope context_scope(context); | 105 v8::Context::Scope context_scope(context); |
| 106 | 106 |
| 107 scoped_ptr<v8::Handle<v8::Value>[]> local_argv; | 107 scoped_ptr<v8::Local<v8::Value>[]> local_argv; |
| 108 if (argc_) { | 108 if (argc_) { |
| 109 local_argv.reset(new v8::Handle<v8::Value>[argc_]); | 109 local_argv.reset(new v8::Local<v8::Value>[argc_]); |
| 110 for (int i = 0; i < argc_; ++i) | 110 for (int i = 0; i < argc_; ++i) |
| 111 local_argv[i] = v8::Local<v8::Value>::New(isolate, argv_[i]); | 111 local_argv[i] = v8::Local<v8::Value>::New(isolate, argv_[i]); |
| 112 } | 112 } |
| 113 | 113 |
| 114 frame->callFunctionEvenIfScriptDisabled( | 114 frame->callFunctionEvenIfScriptDisabled( |
| 115 v8::Local<v8::Function>::New(isolate, callback_), | 115 v8::Local<v8::Function>::New(isolate, callback_), |
| 116 context->Global(), | 116 context->Global(), |
| 117 argc_, | 117 argc_, |
| 118 local_argv.get()); | 118 local_argv.get()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void SetArguments(int argc, v8::Handle<v8::Value> argv[]) { | 121 void SetArguments(int argc, v8::Local<v8::Value> argv[]) { |
| 122 v8::Isolate* isolate = blink::mainThreadIsolate(); | 122 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 123 argc_ = argc; | 123 argc_ = argc; |
| 124 argv_.reset(new v8::UniquePersistent<v8::Value>[argc]); | 124 argv_.reset(new v8::UniquePersistent<v8::Value>[argc]); |
| 125 for (int i = 0; i < argc; ++i) | 125 for (int i = 0; i < argc; ++i) |
| 126 argv_[i] = v8::UniquePersistent<v8::Value>(isolate, argv[i]); | 126 argv_[i] = v8::UniquePersistent<v8::Value>(isolate, argv[i]); |
| 127 } | 127 } |
| 128 | 128 |
| 129 private: | 129 private: |
| 130 v8::UniquePersistent<v8::Function> callback_; | 130 v8::UniquePersistent<v8::Function> callback_; |
| 131 int argc_; | 131 int argc_; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 162 void WaitForPolicyDelegate(); | 162 void WaitForPolicyDelegate(); |
| 163 int WindowCount(); | 163 int WindowCount(); |
| 164 void SetCloseRemainingWindowsWhenComplete(gin::Arguments* args); | 164 void SetCloseRemainingWindowsWhenComplete(gin::Arguments* args); |
| 165 void ResetTestHelperControllers(); | 165 void ResetTestHelperControllers(); |
| 166 void SetTabKeyCyclesThroughElements(bool tab_key_cycles_through_elements); | 166 void SetTabKeyCyclesThroughElements(bool tab_key_cycles_through_elements); |
| 167 void ExecCommand(gin::Arguments* args); | 167 void ExecCommand(gin::Arguments* args); |
| 168 bool IsCommandEnabled(const std::string& command); | 168 bool IsCommandEnabled(const std::string& command); |
| 169 bool CallShouldCloseOnWebView(); | 169 bool CallShouldCloseOnWebView(); |
| 170 void SetDomainRelaxationForbiddenForURLScheme(bool forbidden, | 170 void SetDomainRelaxationForbiddenForURLScheme(bool forbidden, |
| 171 const std::string& scheme); | 171 const std::string& scheme); |
| 172 v8::Handle<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue( | 172 v8::Local<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue( |
| 173 int world_id, const std::string& script); | 173 int world_id, const std::string& script); |
| 174 void EvaluateScriptInIsolatedWorld(int world_id, const std::string& script); | 174 void EvaluateScriptInIsolatedWorld(int world_id, const std::string& script); |
| 175 void SetIsolatedWorldSecurityOrigin(int world_id, | 175 void SetIsolatedWorldSecurityOrigin(int world_id, |
| 176 v8::Handle<v8::Value> origin); | 176 v8::Local<v8::Value> origin); |
| 177 void SetIsolatedWorldContentSecurityPolicy(int world_id, | 177 void SetIsolatedWorldContentSecurityPolicy(int world_id, |
| 178 const std::string& policy); | 178 const std::string& policy); |
| 179 void AddOriginAccessWhitelistEntry(const std::string& source_origin, | 179 void AddOriginAccessWhitelistEntry(const std::string& source_origin, |
| 180 const std::string& destination_protocol, | 180 const std::string& destination_protocol, |
| 181 const std::string& destination_host, | 181 const std::string& destination_host, |
| 182 bool allow_destination_subdomains); | 182 bool allow_destination_subdomains); |
| 183 void RemoveOriginAccessWhitelistEntry(const std::string& source_origin, | 183 void RemoveOriginAccessWhitelistEntry(const std::string& source_origin, |
| 184 const std::string& destination_protocol, | 184 const std::string& destination_protocol, |
| 185 const std::string& destination_host, | 185 const std::string& destination_host, |
| 186 bool allow_destination_subdomains); | 186 bool allow_destination_subdomains); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 212 void DidAcquirePointerLock(); | 212 void DidAcquirePointerLock(); |
| 213 void DidNotAcquirePointerLock(); | 213 void DidNotAcquirePointerLock(); |
| 214 void DidLosePointerLock(); | 214 void DidLosePointerLock(); |
| 215 void SetPointerLockWillFailSynchronously(); | 215 void SetPointerLockWillFailSynchronously(); |
| 216 void SetPointerLockWillRespondAsynchronously(); | 216 void SetPointerLockWillRespondAsynchronously(); |
| 217 void SetPopupBlockingEnabled(bool block_popups); | 217 void SetPopupBlockingEnabled(bool block_popups); |
| 218 void SetJavaScriptCanAccessClipboard(bool can_access); | 218 void SetJavaScriptCanAccessClipboard(bool can_access); |
| 219 void SetXSSAuditorEnabled(bool enabled); | 219 void SetXSSAuditorEnabled(bool enabled); |
| 220 void SetAllowUniversalAccessFromFileURLs(bool allow); | 220 void SetAllowUniversalAccessFromFileURLs(bool allow); |
| 221 void SetAllowFileAccessFromFileURLs(bool allow); | 221 void SetAllowFileAccessFromFileURLs(bool allow); |
| 222 void OverridePreference(const std::string key, v8::Handle<v8::Value> value); | 222 void OverridePreference(const std::string key, v8::Local<v8::Value> value); |
| 223 void SetAcceptLanguages(const std::string& accept_languages); | 223 void SetAcceptLanguages(const std::string& accept_languages); |
| 224 void SetPluginsEnabled(bool enabled); | 224 void SetPluginsEnabled(bool enabled); |
| 225 void DumpEditingCallbacks(); | 225 void DumpEditingCallbacks(); |
| 226 void DumpAsMarkup(); | 226 void DumpAsMarkup(); |
| 227 void DumpAsText(); | 227 void DumpAsText(); |
| 228 void DumpAsTextWithPixelResults(); | 228 void DumpAsTextWithPixelResults(); |
| 229 void DumpChildFrameScrollPositions(); | 229 void DumpChildFrameScrollPositions(); |
| 230 void DumpChildFramesAsMarkup(); | 230 void DumpChildFramesAsMarkup(); |
| 231 void DumpChildFramesAsText(); | 231 void DumpChildFramesAsText(); |
| 232 void DumpIconChanges(); | 232 void DumpIconChanges(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 void DumpNavigationPolicy(); | 264 void DumpNavigationPolicy(); |
| 265 void ShowWebInspector(gin::Arguments* args); | 265 void ShowWebInspector(gin::Arguments* args); |
| 266 void CloseWebInspector(); | 266 void CloseWebInspector(); |
| 267 bool IsChooserShown(); | 267 bool IsChooserShown(); |
| 268 void EvaluateInWebInspector(int call_id, const std::string& script); | 268 void EvaluateInWebInspector(int call_id, const std::string& script); |
| 269 void ClearAllDatabases(); | 269 void ClearAllDatabases(); |
| 270 void SetDatabaseQuota(int quota); | 270 void SetDatabaseQuota(int quota); |
| 271 void SetAlwaysAcceptCookies(bool accept); | 271 void SetAlwaysAcceptCookies(bool accept); |
| 272 void SetWindowIsKey(bool value); | 272 void SetWindowIsKey(bool value); |
| 273 std::string PathToLocalResource(const std::string& path); | 273 std::string PathToLocalResource(const std::string& path); |
| 274 void SetBackingScaleFactor(double value, v8::Handle<v8::Function> callback); | 274 void SetBackingScaleFactor(double value, v8::Local<v8::Function> callback); |
| 275 void SetColorProfile(const std::string& name, | 275 void SetColorProfile(const std::string& name, |
| 276 v8::Handle<v8::Function> callback); | 276 v8::Local<v8::Function> callback); |
| 277 void SetPOSIXLocale(const std::string& locale); | 277 void SetPOSIXLocale(const std::string& locale); |
| 278 void SetMIDIAccessorResult(bool result); | 278 void SetMIDIAccessorResult(bool result); |
| 279 void SimulateWebNotificationClick(const std::string& title); | 279 void SimulateWebNotificationClick(const std::string& title); |
| 280 void AddMockSpeechRecognitionResult(const std::string& transcript, | 280 void AddMockSpeechRecognitionResult(const std::string& transcript, |
| 281 double confidence); | 281 double confidence); |
| 282 void SetMockSpeechRecognitionError(const std::string& error, | 282 void SetMockSpeechRecognitionError(const std::string& error, |
| 283 const std::string& message); | 283 const std::string& message); |
| 284 bool WasMockSpeechRecognitionAborted(); | 284 bool WasMockSpeechRecognitionAborted(); |
| 285 void AddMockCredentialManagerResponse(const std::string& id, | 285 void AddMockCredentialManagerResponse(const std::string& id, |
| 286 const std::string& name, | 286 const std::string& name, |
| 287 const std::string& avatar, | 287 const std::string& avatar, |
| 288 const std::string& password); | 288 const std::string& password); |
| 289 void AddWebPageOverlay(); | 289 void AddWebPageOverlay(); |
| 290 void RemoveWebPageOverlay(); | 290 void RemoveWebPageOverlay(); |
| 291 void DisplayAsync(); | 291 void DisplayAsync(); |
| 292 void DisplayAsyncThen(v8::Handle<v8::Function> callback); | 292 void DisplayAsyncThen(v8::Local<v8::Function> callback); |
| 293 void GetManifestThen(v8::Handle<v8::Function> callback); | 293 void GetManifestThen(v8::Local<v8::Function> callback); |
| 294 void CapturePixelsAsyncThen(v8::Handle<v8::Function> callback); | 294 void CapturePixelsAsyncThen(v8::Local<v8::Function> callback); |
| 295 void CopyImageAtAndCapturePixelsAsyncThen(int x, | 295 void CopyImageAtAndCapturePixelsAsyncThen(int x, |
| 296 int y, | 296 int y, |
| 297 v8::Handle<v8::Function> callback); | 297 v8::Local<v8::Function> callback); |
| 298 void SetCustomTextOutput(std::string output); | 298 void SetCustomTextOutput(std::string output); |
| 299 void SetViewSourceForFrame(const std::string& name, bool enabled); | 299 void SetViewSourceForFrame(const std::string& name, bool enabled); |
| 300 void SetBluetoothMockDataSet(const std::string& dataset_name); | 300 void SetBluetoothMockDataSet(const std::string& dataset_name); |
| 301 void SetGeofencingMockProvider(bool service_available); | 301 void SetGeofencingMockProvider(bool service_available); |
| 302 void ClearGeofencingMockProvider(); | 302 void ClearGeofencingMockProvider(); |
| 303 void SetGeofencingMockPosition(double latitude, double longitude); | 303 void SetGeofencingMockPosition(double latitude, double longitude); |
| 304 void SetPermission(const std::string& name, | 304 void SetPermission(const std::string& name, |
| 305 const std::string& value, | 305 const std::string& value, |
| 306 const std::string& origin, | 306 const std::string& origin, |
| 307 const std::string& embedding_origin); | 307 const std::string& embedding_origin); |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 return runner_->CallShouldCloseOnWebView(); | 713 return runner_->CallShouldCloseOnWebView(); |
| 714 return false; | 714 return false; |
| 715 } | 715 } |
| 716 | 716 |
| 717 void TestRunnerBindings::SetDomainRelaxationForbiddenForURLScheme( | 717 void TestRunnerBindings::SetDomainRelaxationForbiddenForURLScheme( |
| 718 bool forbidden, const std::string& scheme) { | 718 bool forbidden, const std::string& scheme) { |
| 719 if (runner_) | 719 if (runner_) |
| 720 runner_->SetDomainRelaxationForbiddenForURLScheme(forbidden, scheme); | 720 runner_->SetDomainRelaxationForbiddenForURLScheme(forbidden, scheme); |
| 721 } | 721 } |
| 722 | 722 |
| 723 v8::Handle<v8::Value> | 723 v8::Local<v8::Value> |
| 724 TestRunnerBindings::EvaluateScriptInIsolatedWorldAndReturnValue( | 724 TestRunnerBindings::EvaluateScriptInIsolatedWorldAndReturnValue( |
| 725 int world_id, const std::string& script) { | 725 int world_id, const std::string& script) { |
| 726 if (!runner_) | 726 if (!runner_) |
| 727 return v8::Handle<v8::Value>(); | 727 return v8::Local<v8::Value>(); |
| 728 return runner_->EvaluateScriptInIsolatedWorldAndReturnValue(world_id, | 728 return runner_->EvaluateScriptInIsolatedWorldAndReturnValue(world_id, |
| 729 script); | 729 script); |
| 730 } | 730 } |
| 731 | 731 |
| 732 void TestRunnerBindings::EvaluateScriptInIsolatedWorld( | 732 void TestRunnerBindings::EvaluateScriptInIsolatedWorld( |
| 733 int world_id, const std::string& script) { | 733 int world_id, const std::string& script) { |
| 734 if (runner_) | 734 if (runner_) |
| 735 runner_->EvaluateScriptInIsolatedWorld(world_id, script); | 735 runner_->EvaluateScriptInIsolatedWorld(world_id, script); |
| 736 } | 736 } |
| 737 | 737 |
| 738 void TestRunnerBindings::SetIsolatedWorldSecurityOrigin( | 738 void TestRunnerBindings::SetIsolatedWorldSecurityOrigin( |
| 739 int world_id, v8::Handle<v8::Value> origin) { | 739 int world_id, v8::Local<v8::Value> origin) { |
| 740 if (runner_) | 740 if (runner_) |
| 741 runner_->SetIsolatedWorldSecurityOrigin(world_id, origin); | 741 runner_->SetIsolatedWorldSecurityOrigin(world_id, origin); |
| 742 } | 742 } |
| 743 | 743 |
| 744 void TestRunnerBindings::SetIsolatedWorldContentSecurityPolicy( | 744 void TestRunnerBindings::SetIsolatedWorldContentSecurityPolicy( |
| 745 int world_id, const std::string& policy) { | 745 int world_id, const std::string& policy) { |
| 746 if (runner_) | 746 if (runner_) |
| 747 runner_->SetIsolatedWorldContentSecurityPolicy(world_id, policy); | 747 runner_->SetIsolatedWorldContentSecurityPolicy(world_id, policy); |
| 748 } | 748 } |
| 749 | 749 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 if (runner_) | 1007 if (runner_) |
| 1008 runner_->SetAllowUniversalAccessFromFileURLs(allow); | 1008 runner_->SetAllowUniversalAccessFromFileURLs(allow); |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 void TestRunnerBindings::SetAllowFileAccessFromFileURLs(bool allow) { | 1011 void TestRunnerBindings::SetAllowFileAccessFromFileURLs(bool allow) { |
| 1012 if (runner_) | 1012 if (runner_) |
| 1013 runner_->SetAllowFileAccessFromFileURLs(allow); | 1013 runner_->SetAllowFileAccessFromFileURLs(allow); |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 void TestRunnerBindings::OverridePreference(const std::string key, | 1016 void TestRunnerBindings::OverridePreference(const std::string key, |
| 1017 v8::Handle<v8::Value> value) { | 1017 v8::Local<v8::Value> value) { |
| 1018 if (runner_) | 1018 if (runner_) |
| 1019 runner_->OverridePreference(key, value); | 1019 runner_->OverridePreference(key, value); |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 void TestRunnerBindings::SetAcceptLanguages( | 1022 void TestRunnerBindings::SetAcceptLanguages( |
| 1023 const std::string& accept_languages) { | 1023 const std::string& accept_languages) { |
| 1024 if (!runner_) | 1024 if (!runner_) |
| 1025 return; | 1025 return; |
| 1026 | 1026 |
| 1027 runner_->SetAcceptLanguages(accept_languages); | 1027 runner_->SetAcceptLanguages(accept_languages); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 runner_->SetWindowIsKey(value); | 1281 runner_->SetWindowIsKey(value); |
| 1282 } | 1282 } |
| 1283 | 1283 |
| 1284 std::string TestRunnerBindings::PathToLocalResource(const std::string& path) { | 1284 std::string TestRunnerBindings::PathToLocalResource(const std::string& path) { |
| 1285 if (runner_) | 1285 if (runner_) |
| 1286 return runner_->PathToLocalResource(path); | 1286 return runner_->PathToLocalResource(path); |
| 1287 return std::string(); | 1287 return std::string(); |
| 1288 } | 1288 } |
| 1289 | 1289 |
| 1290 void TestRunnerBindings::SetBackingScaleFactor( | 1290 void TestRunnerBindings::SetBackingScaleFactor( |
| 1291 double value, v8::Handle<v8::Function> callback) { | 1291 double value, v8::Local<v8::Function> callback) { |
| 1292 if (runner_) | 1292 if (runner_) |
| 1293 runner_->SetBackingScaleFactor(value, callback); | 1293 runner_->SetBackingScaleFactor(value, callback); |
| 1294 } | 1294 } |
| 1295 | 1295 |
| 1296 void TestRunnerBindings::SetColorProfile( | 1296 void TestRunnerBindings::SetColorProfile( |
| 1297 const std::string& name, v8::Handle<v8::Function> callback) { | 1297 const std::string& name, v8::Local<v8::Function> callback) { |
| 1298 if (runner_) | 1298 if (runner_) |
| 1299 runner_->SetColorProfile(name, callback); | 1299 runner_->SetColorProfile(name, callback); |
| 1300 } | 1300 } |
| 1301 | 1301 |
| 1302 void TestRunnerBindings::SetBluetoothMockDataSet(const std::string& name) { | 1302 void TestRunnerBindings::SetBluetoothMockDataSet(const std::string& name) { |
| 1303 if (runner_) | 1303 if (runner_) |
| 1304 runner_->SetBluetoothMockDataSet(name); | 1304 runner_->SetBluetoothMockDataSet(name); |
| 1305 } | 1305 } |
| 1306 | 1306 |
| 1307 void TestRunnerBindings::SetPOSIXLocale(const std::string& locale) { | 1307 void TestRunnerBindings::SetPOSIXLocale(const std::string& locale) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 void TestRunnerBindings::RemoveWebPageOverlay() { | 1355 void TestRunnerBindings::RemoveWebPageOverlay() { |
| 1356 if (runner_) | 1356 if (runner_) |
| 1357 runner_->RemoveWebPageOverlay(); | 1357 runner_->RemoveWebPageOverlay(); |
| 1358 } | 1358 } |
| 1359 | 1359 |
| 1360 void TestRunnerBindings::DisplayAsync() { | 1360 void TestRunnerBindings::DisplayAsync() { |
| 1361 if (runner_) | 1361 if (runner_) |
| 1362 runner_->DisplayAsync(); | 1362 runner_->DisplayAsync(); |
| 1363 } | 1363 } |
| 1364 | 1364 |
| 1365 void TestRunnerBindings::DisplayAsyncThen(v8::Handle<v8::Function> callback) { | 1365 void TestRunnerBindings::DisplayAsyncThen(v8::Local<v8::Function> callback) { |
| 1366 if (runner_) | 1366 if (runner_) |
| 1367 runner_->DisplayAsyncThen(callback); | 1367 runner_->DisplayAsyncThen(callback); |
| 1368 } | 1368 } |
| 1369 | 1369 |
| 1370 void TestRunnerBindings::GetManifestThen(v8::Handle<v8::Function> callback) { | 1370 void TestRunnerBindings::GetManifestThen(v8::Local<v8::Function> callback) { |
| 1371 if (runner_) | 1371 if (runner_) |
| 1372 runner_->GetManifestThen(callback); | 1372 runner_->GetManifestThen(callback); |
| 1373 } | 1373 } |
| 1374 | 1374 |
| 1375 void TestRunnerBindings::CapturePixelsAsyncThen( | 1375 void TestRunnerBindings::CapturePixelsAsyncThen( |
| 1376 v8::Handle<v8::Function> callback) { | 1376 v8::Local<v8::Function> callback) { |
| 1377 if (runner_) | 1377 if (runner_) |
| 1378 runner_->CapturePixelsAsyncThen(callback); | 1378 runner_->CapturePixelsAsyncThen(callback); |
| 1379 } | 1379 } |
| 1380 | 1380 |
| 1381 void TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen( | 1381 void TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen( |
| 1382 int x, int y, v8::Handle<v8::Function> callback) { | 1382 int x, int y, v8::Local<v8::Function> callback) { |
| 1383 if (runner_) | 1383 if (runner_) |
| 1384 runner_->CopyImageAtAndCapturePixelsAsyncThen(x, y, callback); | 1384 runner_->CopyImageAtAndCapturePixelsAsyncThen(x, y, callback); |
| 1385 } | 1385 } |
| 1386 | 1386 |
| 1387 void TestRunnerBindings::SetCustomTextOutput(std::string output) { | 1387 void TestRunnerBindings::SetCustomTextOutput(std::string output) { |
| 1388 runner_->setCustomTextOutput(output); | 1388 runner_->setCustomTextOutput(output); |
| 1389 } | 1389 } |
| 1390 | 1390 |
| 1391 void TestRunnerBindings::SetViewSourceForFrame(const std::string& name, | 1391 void TestRunnerBindings::SetViewSourceForFrame(const std::string& name, |
| 1392 bool enabled) { | 1392 bool enabled) { |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2140 bool TestRunner::CallShouldCloseOnWebView() { | 2140 bool TestRunner::CallShouldCloseOnWebView() { |
| 2141 return web_view_->mainFrame()->dispatchBeforeUnloadEvent(); | 2141 return web_view_->mainFrame()->dispatchBeforeUnloadEvent(); |
| 2142 } | 2142 } |
| 2143 | 2143 |
| 2144 void TestRunner::SetDomainRelaxationForbiddenForURLScheme( | 2144 void TestRunner::SetDomainRelaxationForbiddenForURLScheme( |
| 2145 bool forbidden, const std::string& scheme) { | 2145 bool forbidden, const std::string& scheme) { |
| 2146 web_view_->setDomainRelaxationForbidden(forbidden, | 2146 web_view_->setDomainRelaxationForbidden(forbidden, |
| 2147 WebString::fromUTF8(scheme)); | 2147 WebString::fromUTF8(scheme)); |
| 2148 } | 2148 } |
| 2149 | 2149 |
| 2150 v8::Handle<v8::Value> TestRunner::EvaluateScriptInIsolatedWorldAndReturnValue( | 2150 v8::Local<v8::Value> TestRunner::EvaluateScriptInIsolatedWorldAndReturnValue( |
| 2151 int world_id, | 2151 int world_id, |
| 2152 const std::string& script) { | 2152 const std::string& script) { |
| 2153 WebVector<v8::Local<v8::Value>> values; | 2153 WebVector<v8::Local<v8::Value>> values; |
| 2154 WebScriptSource source(WebString::fromUTF8(script)); | 2154 WebScriptSource source(WebString::fromUTF8(script)); |
| 2155 // This relies on the iframe focusing itself when it loads. This is a bit | 2155 // This relies on the iframe focusing itself when it loads. This is a bit |
| 2156 // sketchy, but it seems to be what other tests do. | 2156 // sketchy, but it seems to be what other tests do. |
| 2157 web_view_->focusedFrame()->executeScriptInIsolatedWorld( | 2157 web_view_->focusedFrame()->executeScriptInIsolatedWorld( |
| 2158 world_id, &source, 1, 1, &values); | 2158 world_id, &source, 1, 1, &values); |
| 2159 // Since only one script was added, only one result is expected | 2159 // Since only one script was added, only one result is expected |
| 2160 if (values.size() == 1 && !values[0].IsEmpty()) | 2160 if (values.size() == 1 && !values[0].IsEmpty()) |
| 2161 return values[0]; | 2161 return values[0]; |
| 2162 return v8::Handle<v8::Value>(); | 2162 return v8::Local<v8::Value>(); |
| 2163 } | 2163 } |
| 2164 | 2164 |
| 2165 void TestRunner::EvaluateScriptInIsolatedWorld(int world_id, | 2165 void TestRunner::EvaluateScriptInIsolatedWorld(int world_id, |
| 2166 const std::string& script) { | 2166 const std::string& script) { |
| 2167 WebScriptSource source(WebString::fromUTF8(script)); | 2167 WebScriptSource source(WebString::fromUTF8(script)); |
| 2168 web_view_->focusedFrame()->executeScriptInIsolatedWorld( | 2168 web_view_->focusedFrame()->executeScriptInIsolatedWorld( |
| 2169 world_id, &source, 1, 1); | 2169 world_id, &source, 1, 1); |
| 2170 } | 2170 } |
| 2171 | 2171 |
| 2172 void TestRunner::SetIsolatedWorldSecurityOrigin(int world_id, | 2172 void TestRunner::SetIsolatedWorldSecurityOrigin(int world_id, |
| 2173 v8::Handle<v8::Value> origin) { | 2173 v8::Local<v8::Value> origin) { |
| 2174 if (!(origin->IsString() || !origin->IsNull())) | 2174 if (!(origin->IsString() || !origin->IsNull())) |
| 2175 return; | 2175 return; |
| 2176 | 2176 |
| 2177 WebSecurityOrigin web_origin; | 2177 WebSecurityOrigin web_origin; |
| 2178 if (origin->IsString()) { | 2178 if (origin->IsString()) { |
| 2179 web_origin = WebSecurityOrigin::createFromString( | 2179 web_origin = WebSecurityOrigin::createFromString( |
| 2180 V8StringToWebString(origin.As<v8::String>())); | 2180 V8StringToWebString(origin.As<v8::String>())); |
| 2181 } | 2181 } |
| 2182 web_view_->focusedFrame()->setIsolatedWorldSecurityOrigin(world_id, | 2182 web_view_->focusedFrame()->setIsolatedWorldSecurityOrigin(world_id, |
| 2183 web_origin); | 2183 web_origin); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2478 delegate_->Preferences()->allow_universal_access_from_file_urls = allow; | 2478 delegate_->Preferences()->allow_universal_access_from_file_urls = allow; |
| 2479 delegate_->ApplyPreferences(); | 2479 delegate_->ApplyPreferences(); |
| 2480 } | 2480 } |
| 2481 | 2481 |
| 2482 void TestRunner::SetAllowFileAccessFromFileURLs(bool allow) { | 2482 void TestRunner::SetAllowFileAccessFromFileURLs(bool allow) { |
| 2483 delegate_->Preferences()->allow_file_access_from_file_urls = allow; | 2483 delegate_->Preferences()->allow_file_access_from_file_urls = allow; |
| 2484 delegate_->ApplyPreferences(); | 2484 delegate_->ApplyPreferences(); |
| 2485 } | 2485 } |
| 2486 | 2486 |
| 2487 void TestRunner::OverridePreference(const std::string key, | 2487 void TestRunner::OverridePreference(const std::string key, |
| 2488 v8::Handle<v8::Value> value) { | 2488 v8::Local<v8::Value> value) { |
| 2489 TestPreferences* prefs = delegate_->Preferences(); | 2489 TestPreferences* prefs = delegate_->Preferences(); |
| 2490 if (key == "WebKitDefaultFontSize") { | 2490 if (key == "WebKitDefaultFontSize") { |
| 2491 prefs->default_font_size = value->Int32Value(); | 2491 prefs->default_font_size = value->Int32Value(); |
| 2492 } else if (key == "WebKitMinimumFontSize") { | 2492 } else if (key == "WebKitMinimumFontSize") { |
| 2493 prefs->minimum_font_size = value->Int32Value(); | 2493 prefs->minimum_font_size = value->Int32Value(); |
| 2494 } else if (key == "WebKitDefaultTextEncodingName") { | 2494 } else if (key == "WebKitDefaultTextEncodingName") { |
| 2495 v8::Isolate* isolate = blink::mainThreadIsolate(); | 2495 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 2496 prefs->default_text_encoding_name = | 2496 prefs->default_text_encoding_name = |
| 2497 V8StringToWebString(value->ToString(isolate)); | 2497 V8StringToWebString(value->ToString(isolate)); |
| 2498 } else if (key == "WebKitJavaScriptEnabled") { | 2498 } else if (key == "WebKitJavaScriptEnabled") { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2752 | 2752 |
| 2753 void TestRunner::SetWindowIsKey(bool value) { | 2753 void TestRunner::SetWindowIsKey(bool value) { |
| 2754 delegate_->SetFocus(proxy_, value); | 2754 delegate_->SetFocus(proxy_, value); |
| 2755 } | 2755 } |
| 2756 | 2756 |
| 2757 std::string TestRunner::PathToLocalResource(const std::string& path) { | 2757 std::string TestRunner::PathToLocalResource(const std::string& path) { |
| 2758 return delegate_->PathToLocalResource(path); | 2758 return delegate_->PathToLocalResource(path); |
| 2759 } | 2759 } |
| 2760 | 2760 |
| 2761 void TestRunner::SetBackingScaleFactor(double value, | 2761 void TestRunner::SetBackingScaleFactor(double value, |
| 2762 v8::Handle<v8::Function> callback) { | 2762 v8::Local<v8::Function> callback) { |
| 2763 delegate_->SetDeviceScaleFactor(value); | 2763 delegate_->SetDeviceScaleFactor(value); |
| 2764 delegate_->PostTask(new InvokeCallbackTask(this, callback)); | 2764 delegate_->PostTask(new InvokeCallbackTask(this, callback)); |
| 2765 } | 2765 } |
| 2766 | 2766 |
| 2767 void TestRunner::SetColorProfile(const std::string& name, | 2767 void TestRunner::SetColorProfile(const std::string& name, |
| 2768 v8::Handle<v8::Function> callback) { | 2768 v8::Local<v8::Function> callback) { |
| 2769 delegate_->SetDeviceColorProfile(name); | 2769 delegate_->SetDeviceColorProfile(name); |
| 2770 delegate_->PostTask(new InvokeCallbackTask(this, callback)); | 2770 delegate_->PostTask(new InvokeCallbackTask(this, callback)); |
| 2771 } | 2771 } |
| 2772 | 2772 |
| 2773 void TestRunner::SetBluetoothMockDataSet(const std::string& name) { | 2773 void TestRunner::SetBluetoothMockDataSet(const std::string& name) { |
| 2774 delegate_->SetBluetoothMockDataSet(name); | 2774 delegate_->SetBluetoothMockDataSet(name); |
| 2775 } | 2775 } |
| 2776 | 2776 |
| 2777 void TestRunner::SetGeofencingMockProvider(bool service_available) { | 2777 void TestRunner::SetGeofencingMockProvider(bool service_available) { |
| 2778 delegate_->SetGeofencingMockProvider(service_available); | 2778 delegate_->SetGeofencingMockProvider(service_available); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2844 web_view_->removePageOverlay(page_overlay_); | 2844 web_view_->removePageOverlay(page_overlay_); |
| 2845 delete page_overlay_; | 2845 delete page_overlay_; |
| 2846 page_overlay_ = nullptr; | 2846 page_overlay_ = nullptr; |
| 2847 } | 2847 } |
| 2848 } | 2848 } |
| 2849 | 2849 |
| 2850 void TestRunner::DisplayAsync() { | 2850 void TestRunner::DisplayAsync() { |
| 2851 proxy_->DisplayAsyncThen(base::Closure()); | 2851 proxy_->DisplayAsyncThen(base::Closure()); |
| 2852 } | 2852 } |
| 2853 | 2853 |
| 2854 void TestRunner::DisplayAsyncThen(v8::Handle<v8::Function> callback) { | 2854 void TestRunner::DisplayAsyncThen(v8::Local<v8::Function> callback) { |
| 2855 scoped_ptr<InvokeCallbackTask> task( | 2855 scoped_ptr<InvokeCallbackTask> task( |
| 2856 new InvokeCallbackTask(this, callback)); | 2856 new InvokeCallbackTask(this, callback)); |
| 2857 proxy_->DisplayAsyncThen(base::Bind(&TestRunner::InvokeCallback, | 2857 proxy_->DisplayAsyncThen(base::Bind(&TestRunner::InvokeCallback, |
| 2858 weak_factory_.GetWeakPtr(), | 2858 weak_factory_.GetWeakPtr(), |
| 2859 base::Passed(&task))); | 2859 base::Passed(&task))); |
| 2860 } | 2860 } |
| 2861 | 2861 |
| 2862 void TestRunner::GetManifestThen(v8::Handle<v8::Function> callback) { | 2862 void TestRunner::GetManifestThen(v8::Local<v8::Function> callback) { |
| 2863 scoped_ptr<InvokeCallbackTask> task( | 2863 scoped_ptr<InvokeCallbackTask> task( |
| 2864 new InvokeCallbackTask(this, callback)); | 2864 new InvokeCallbackTask(this, callback)); |
| 2865 | 2865 |
| 2866 FetchManifest(web_view_, web_view_->mainFrame()->document().manifestURL(), | 2866 FetchManifest(web_view_, web_view_->mainFrame()->document().manifestURL(), |
| 2867 base::Bind(&TestRunner::GetManifestCallback, | 2867 base::Bind(&TestRunner::GetManifestCallback, |
| 2868 weak_factory_.GetWeakPtr(), | 2868 weak_factory_.GetWeakPtr(), |
| 2869 base::Passed(&task))); | 2869 base::Passed(&task))); |
| 2870 } | 2870 } |
| 2871 | 2871 |
| 2872 void TestRunner::CapturePixelsAsyncThen(v8::Handle<v8::Function> callback) { | 2872 void TestRunner::CapturePixelsAsyncThen(v8::Local<v8::Function> callback) { |
| 2873 scoped_ptr<InvokeCallbackTask> task( | 2873 scoped_ptr<InvokeCallbackTask> task( |
| 2874 new InvokeCallbackTask(this, callback)); | 2874 new InvokeCallbackTask(this, callback)); |
| 2875 proxy_->CapturePixelsAsync(base::Bind(&TestRunner::CapturePixelsCallback, | 2875 proxy_->CapturePixelsAsync(base::Bind(&TestRunner::CapturePixelsCallback, |
| 2876 weak_factory_.GetWeakPtr(), | 2876 weak_factory_.GetWeakPtr(), |
| 2877 base::Passed(&task))); | 2877 base::Passed(&task))); |
| 2878 } | 2878 } |
| 2879 | 2879 |
| 2880 void TestRunner::ForceNextWebGLContextCreationToFail() { | 2880 void TestRunner::ForceNextWebGLContextCreationToFail() { |
| 2881 if (web_view_) | 2881 if (web_view_) |
| 2882 web_view_->forceNextWebGLContextCreationToFail(); | 2882 web_view_->forceNextWebGLContextCreationToFail(); |
| 2883 } | 2883 } |
| 2884 | 2884 |
| 2885 void TestRunner::CopyImageAtAndCapturePixelsAsyncThen( | 2885 void TestRunner::CopyImageAtAndCapturePixelsAsyncThen( |
| 2886 int x, int y, v8::Handle<v8::Function> callback) { | 2886 int x, int y, v8::Local<v8::Function> callback) { |
| 2887 scoped_ptr<InvokeCallbackTask> task( | 2887 scoped_ptr<InvokeCallbackTask> task( |
| 2888 new InvokeCallbackTask(this, callback)); | 2888 new InvokeCallbackTask(this, callback)); |
| 2889 proxy_->CopyImageAtAndCapturePixels( | 2889 proxy_->CopyImageAtAndCapturePixels( |
| 2890 x, y, base::Bind(&TestRunner::CapturePixelsCallback, | 2890 x, y, base::Bind(&TestRunner::CapturePixelsCallback, |
| 2891 weak_factory_.GetWeakPtr(), | 2891 weak_factory_.GetWeakPtr(), |
| 2892 base::Passed(&task))); | 2892 base::Passed(&task))); |
| 2893 } | 2893 } |
| 2894 | 2894 |
| 2895 void TestRunner::GetManifestCallback(scoped_ptr<InvokeCallbackTask> task, | 2895 void TestRunner::GetManifestCallback(scoped_ptr<InvokeCallbackTask> task, |
| 2896 const blink::WebURLResponse& response, | 2896 const blink::WebURLResponse& response, |
| 2897 const std::string& data) { | 2897 const std::string& data) { |
| 2898 InvokeCallback(task.Pass()); | 2898 InvokeCallback(task.Pass()); |
| 2899 } | 2899 } |
| 2900 | 2900 |
| 2901 void TestRunner::CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task, | 2901 void TestRunner::CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task, |
| 2902 const SkBitmap& snapshot) { | 2902 const SkBitmap& snapshot) { |
| 2903 v8::Isolate* isolate = blink::mainThreadIsolate(); | 2903 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 2904 v8::HandleScope handle_scope(isolate); | 2904 v8::HandleScope handle_scope(isolate); |
| 2905 | 2905 |
| 2906 v8::Handle<v8::Context> context = | 2906 v8::Local<v8::Context> context = |
| 2907 web_view_->mainFrame()->mainWorldScriptContext(); | 2907 web_view_->mainFrame()->mainWorldScriptContext(); |
| 2908 if (context.IsEmpty()) | 2908 if (context.IsEmpty()) |
| 2909 return; | 2909 return; |
| 2910 | 2910 |
| 2911 v8::Context::Scope context_scope(context); | 2911 v8::Context::Scope context_scope(context); |
| 2912 v8::Handle<v8::Value> argv[3]; | 2912 v8::Local<v8::Value> argv[3]; |
| 2913 SkAutoLockPixels snapshot_lock(snapshot); | 2913 SkAutoLockPixels snapshot_lock(snapshot); |
| 2914 | 2914 |
| 2915 // Size can be 0 for cases where copyImageAt was called on position | 2915 // Size can be 0 for cases where copyImageAt was called on position |
| 2916 // that doesn't have an image. | 2916 // that doesn't have an image. |
| 2917 int width = snapshot.info().fWidth; | 2917 int width = snapshot.info().fWidth; |
| 2918 argv[0] = v8::Number::New(isolate, width); | 2918 argv[0] = v8::Number::New(isolate, width); |
| 2919 | 2919 |
| 2920 int height = snapshot.info().fHeight; | 2920 int height = snapshot.info().fHeight; |
| 2921 argv[1] = v8::Number::New(isolate, height); | 2921 argv[1] = v8::Number::New(isolate, height); |
| 2922 | 2922 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2989 } | 2989 } |
| 2990 | 2990 |
| 2991 void TestRunner::DidLosePointerLockInternal() { | 2991 void TestRunner::DidLosePointerLockInternal() { |
| 2992 bool was_locked = pointer_locked_; | 2992 bool was_locked = pointer_locked_; |
| 2993 pointer_locked_ = false; | 2993 pointer_locked_ = false; |
| 2994 if (was_locked) | 2994 if (was_locked) |
| 2995 web_view_->didLosePointerLock(); | 2995 web_view_->didLosePointerLock(); |
| 2996 } | 2996 } |
| 2997 | 2997 |
| 2998 } // namespace content | 2998 } // namespace content |
| OLD | NEW |