| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // This file contains the definition for LayoutTestController. | 5 // This file contains the definition for LayoutTestController. |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "webkit/tools/test_shell/layout_test_controller.h" | 9 #include "webkit/tools/test_shell/layout_test_controller.h" |
| 10 | 10 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 BindMethod("keepWebHistory", &LayoutTestController::keepWebHistory); | 127 BindMethod("keepWebHistory", &LayoutTestController::keepWebHistory); |
| 128 BindMethod("storeWebScriptObject", &LayoutTestController::storeWebScriptObject
); | 128 BindMethod("storeWebScriptObject", &LayoutTestController::storeWebScriptObject
); |
| 129 BindMethod("accessStoredWebScriptObject", &LayoutTestController::accessStoredW
ebScriptObject); | 129 BindMethod("accessStoredWebScriptObject", &LayoutTestController::accessStoredW
ebScriptObject); |
| 130 BindMethod("objCClassNameOf", &LayoutTestController::objCClassNameOf); | 130 BindMethod("objCClassNameOf", &LayoutTestController::objCClassNameOf); |
| 131 BindMethod("addDisallowedURL", &LayoutTestController::addDisallowedURL); | 131 BindMethod("addDisallowedURL", &LayoutTestController::addDisallowedURL); |
| 132 BindMethod("setCallCloseOnWebViews", &LayoutTestController::setCallCloseOnWebV
iews); | 132 BindMethod("setCallCloseOnWebViews", &LayoutTestController::setCallCloseOnWebV
iews); |
| 133 BindMethod("setPrivateBrowsingEnabled", &LayoutTestController::setPrivateBrows
ingEnabled); | 133 BindMethod("setPrivateBrowsingEnabled", &LayoutTestController::setPrivateBrows
ingEnabled); |
| 134 BindMethod("setUseDashboardCompatibilityMode", &LayoutTestController::setUseDa
shboardCompatibilityMode); | 134 BindMethod("setUseDashboardCompatibilityMode", &LayoutTestController::setUseDa
shboardCompatibilityMode); |
| 135 | 135 |
| 136 BindMethod("setXSSAuditorEnabled", &LayoutTestController::setXSSAuditorEnabled
); | 136 BindMethod("setXSSAuditorEnabled", &LayoutTestController::setXSSAuditorEnabled
); |
| 137 BindMethod("queueScriptInIsolatedWorld", &LayoutTestController::queueScriptInI
solatedWorld); |
| 137 | 138 |
| 138 // The fallback method is called when an unknown method is invoked. | 139 // The fallback method is called when an unknown method is invoked. |
| 139 BindFallbackMethod(&LayoutTestController::fallbackMethod); | 140 BindFallbackMethod(&LayoutTestController::fallbackMethod); |
| 140 | 141 |
| 141 // Shared properties. | 142 // Shared properties. |
| 142 // globalFlag is used by a number of layout tests in | 143 // globalFlag is used by a number of layout tests in |
| 143 // LayoutTests\http\tests\security\dataURL. | 144 // LayoutTests\http\tests\security\dataURL. |
| 144 BindProperty("globalFlag", &globalFlag_); | 145 BindProperty("globalFlag", &globalFlag_); |
| 145 // webHistoryItemCount is used by tests in LayoutTests\http\tests\history | 146 // webHistoryItemCount is used by tests in LayoutTests\http\tests\history |
| 146 BindProperty("webHistoryItemCount", &webHistoryItemCount_); | 147 BindProperty("webHistoryItemCount", &webHistoryItemCount_); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 WorkItemNonLoadingScript(const string& script) : script_(script) {} | 339 WorkItemNonLoadingScript(const string& script) : script_(script) {} |
| 339 bool Run(TestShell* shell) { | 340 bool Run(TestShell* shell) { |
| 340 shell->webView()->GetMainFrame()->ExecuteScript( | 341 shell->webView()->GetMainFrame()->ExecuteScript( |
| 341 WebScriptSource(WebString::fromUTF8(script_))); | 342 WebScriptSource(WebString::fromUTF8(script_))); |
| 342 return false; | 343 return false; |
| 343 } | 344 } |
| 344 private: | 345 private: |
| 345 string script_; | 346 string script_; |
| 346 }; | 347 }; |
| 347 | 348 |
| 349 class WorkItemIsolatedWorldScript : public LayoutTestController::WorkItem { |
| 350 public: |
| 351 WorkItemIsolatedWorldScript(const string& script) : script_(script) {} |
| 352 bool Run(TestShell* shell) { |
| 353 WebScriptSource source(WebString::fromUTF8(script_)); |
| 354 shell->webView()->GetMainFrame()->ExecuteScriptInNewContext(&source, 1); |
| 355 return false; |
| 356 } |
| 357 private: |
| 358 string script_; |
| 359 }; |
| 360 |
| 348 void LayoutTestController::queueLoadingScript( | 361 void LayoutTestController::queueLoadingScript( |
| 349 const CppArgumentList& args, CppVariant* result) { | 362 const CppArgumentList& args, CppVariant* result) { |
| 350 if (args.size() > 0 && args[0].isString()) | 363 if (args.size() > 0 && args[0].isString()) |
| 351 work_queue_.AddWork(new WorkItemLoadingScript(args[0].ToString())); | 364 work_queue_.AddWork(new WorkItemLoadingScript(args[0].ToString())); |
| 352 result->SetNull(); | 365 result->SetNull(); |
| 353 } | 366 } |
| 354 | 367 |
| 355 void LayoutTestController::queueNonLoadingScript( | 368 void LayoutTestController::queueNonLoadingScript( |
| 356 const CppArgumentList& args, CppVariant* result) { | 369 const CppArgumentList& args, CppVariant* result) { |
| 357 if (args.size() > 0 && args[0].isString()) | 370 if (args.size() > 0 && args[0].isString()) |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 void LayoutTestController::setXSSAuditorEnabled( | 777 void LayoutTestController::setXSSAuditorEnabled( |
| 765 const CppArgumentList& args, CppVariant* result) { | 778 const CppArgumentList& args, CppVariant* result) { |
| 766 if (args.size() > 0 && args[0].isBool()) { | 779 if (args.size() > 0 && args[0].isBool()) { |
| 767 WebPreferences* preferences = shell_->GetWebPreferences(); | 780 WebPreferences* preferences = shell_->GetWebPreferences(); |
| 768 preferences->xss_auditor_enabled = args[0].value.boolValue; | 781 preferences->xss_auditor_enabled = args[0].value.boolValue; |
| 769 shell_->webView()->SetPreferences(*preferences); | 782 shell_->webView()->SetPreferences(*preferences); |
| 770 } | 783 } |
| 771 result->SetNull(); | 784 result->SetNull(); |
| 772 } | 785 } |
| 773 | 786 |
| 787 void LayoutTestController::queueScriptInIsolatedWorld( |
| 788 const CppArgumentList& args, CppVariant* result) { |
| 789 if (args.size() > 0 && args[0].isString()) |
| 790 work_queue_.AddWork(new WorkItemIsolatedWorldScript(args[0].ToString())); |
| 791 result->SetNull(); |
| 792 } |
| 793 |
| 774 void LayoutTestController::fallbackMethod( | 794 void LayoutTestController::fallbackMethod( |
| 775 const CppArgumentList& args, CppVariant* result) { | 795 const CppArgumentList& args, CppVariant* result) { |
| 776 std::wstring message(L"JavaScript ERROR: unknown method called on LayoutTestCo
ntroller"); | 796 std::wstring message(L"JavaScript ERROR: unknown method called on LayoutTestCo
ntroller"); |
| 777 if (!shell_->layout_test_mode()) { | 797 if (!shell_->layout_test_mode()) { |
| 778 logging::LogMessage("CONSOLE:", 0).stream() << message; | 798 logging::LogMessage("CONSOLE:", 0).stream() << message; |
| 779 } else { | 799 } else { |
| 780 printf("CONSOLE MESSAGE: %S\n", message.c_str()); | 800 printf("CONSOLE MESSAGE: %S\n", message.c_str()); |
| 781 } | 801 } |
| 782 result->SetNull(); | 802 result->SetNull(); |
| 783 } | 803 } |
| OLD | NEW |