Chromium Code Reviews| 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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "webkit/api/public/WebFrame.h" | 17 #include "webkit/api/public/WebFrame.h" |
| 18 #include "webkit/api/public/WebScriptSource.h" | 18 #include "webkit/api/public/WebScriptSource.h" |
| 19 #include "webkit/api/public/WebSettings.h" | |
| 20 #include "webkit/glue/dom_operations.h" | 19 #include "webkit/glue/dom_operations.h" |
| 21 #include "webkit/glue/webpreferences.h" | 20 #include "webkit/glue/webpreferences.h" |
| 22 #include "webkit/glue/webview.h" | 21 #include "webkit/glue/webview.h" |
| 23 #include "webkit/tools/test_shell/test_navigation_controller.h" | 22 #include "webkit/tools/test_shell/test_navigation_controller.h" |
| 24 #include "webkit/tools/test_shell/test_shell.h" | 23 #include "webkit/tools/test_shell/test_shell.h" |
| 25 | 24 |
| 26 using std::string; | 25 using std::string; |
| 27 using std::wstring; | 26 using std::wstring; |
| 28 | 27 |
| 29 using WebKit::WebScriptSource; | 28 using WebKit::WebScriptSource; |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 std::string command = args[0].ToString(); | 549 std::string command = args[0].ToString(); |
| 551 bool rv = shell_->webView()->GetFocusedFrame()->isCommandEnabled( | 550 bool rv = shell_->webView()->GetFocusedFrame()->isCommandEnabled( |
| 552 WebString::fromUTF8(command)); | 551 WebString::fromUTF8(command)); |
| 553 result->Set(rv); | 552 result->Set(rv); |
| 554 } | 553 } |
| 555 | 554 |
| 556 void LayoutTestController::setPopupBlockingEnabled( | 555 void LayoutTestController::setPopupBlockingEnabled( |
| 557 const CppArgumentList& args, CppVariant* result) { | 556 const CppArgumentList& args, CppVariant* result) { |
| 558 if (args.size() > 0 && args[0].isBool()) { | 557 if (args.size() > 0 && args[0].isBool()) { |
| 559 bool block_popups = args[0].ToBoolean(); | 558 bool block_popups = args[0].ToBoolean(); |
| 560 shell_->webView()->GetSettings()->setJavaScriptCanOpenWindowsAutomatically( | 559 WebPreferences* prefs = shell_->GetWebPreferences(); |
| 561 !block_popups); | 560 prefs->javascript_can_open_windows_automatically = !block_popups; |
| 561 prefs->Apply(shell_->webView()); | |
| 562 } | 562 } |
| 563 result->SetNull(); | 563 result->SetNull(); |
| 564 } | 564 } |
| 565 | 565 |
| 566 void LayoutTestController::setUseDashboardCompatibilityMode( | 566 void LayoutTestController::setUseDashboardCompatibilityMode( |
| 567 const CppArgumentList& args, CppVariant* result) { | 567 const CppArgumentList& args, CppVariant* result) { |
| 568 // We have no need to support Dashboard Compatibility Mode (mac-only) | 568 // We have no need to support Dashboard Compatibility Mode (mac-only) |
| 569 result->SetNull(); | 569 result->SetNull(); |
| 570 } | 570 } |
| 571 | 571 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 698 shell_->webView(), element_id)); | 698 shell_->webView(), element_id)); |
| 699 } | 699 } |
| 700 | 700 |
| 701 void LayoutTestController::numberOfActiveAnimations(const CppArgumentList& args, | 701 void LayoutTestController::numberOfActiveAnimations(const CppArgumentList& args, |
| 702 CppVariant* result) { | 702 CppVariant* result) { |
| 703 result->Set(webkit_glue::NumberOfActiveAnimations(shell_->webView())); | 703 result->Set(webkit_glue::NumberOfActiveAnimations(shell_->webView())); |
| 704 } | 704 } |
| 705 | 705 |
| 706 void LayoutTestController::disableImageLoading(const CppArgumentList& args, | 706 void LayoutTestController::disableImageLoading(const CppArgumentList& args, |
| 707 CppVariant* result) { | 707 CppVariant* result) { |
| 708 shell_->webView()->GetSettings()->setLoadsImagesAutomatically(false); | 708 WebPreferences* prefs = shell_->GetWebPreferences(); |
|
darin (slow to review)
2009/08/18 18:02:47
nit: 2 space indent
| |
| 709 prefs->loads_images_automatically = false; | |
| 710 prefs->Apply(shell_->webView()); | |
| 709 result->SetNull(); | 711 result->SetNull(); |
| 710 } | 712 } |
| 711 | 713 |
| 712 void LayoutTestController::setIconDatabaseEnabled(const CppArgumentList& args, | 714 void LayoutTestController::setIconDatabaseEnabled(const CppArgumentList& args, |
| 713 CppVariant* result) { | 715 CppVariant* result) { |
| 714 // We don't use the WebKit icon database. | 716 // We don't use the WebKit icon database. |
| 715 result->SetNull(); | 717 result->SetNull(); |
| 716 } | 718 } |
| 717 | 719 |
| 718 // | 720 // |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 result->SetNull(); | 784 result->SetNull(); |
| 783 } | 785 } |
| 784 void LayoutTestController::setPrivateBrowsingEnabled( | 786 void LayoutTestController::setPrivateBrowsingEnabled( |
| 785 const CppArgumentList& args, CppVariant* result) { | 787 const CppArgumentList& args, CppVariant* result) { |
| 786 result->SetNull(); | 788 result->SetNull(); |
| 787 } | 789 } |
| 788 | 790 |
| 789 void LayoutTestController::setXSSAuditorEnabled( | 791 void LayoutTestController::setXSSAuditorEnabled( |
| 790 const CppArgumentList& args, CppVariant* result) { | 792 const CppArgumentList& args, CppVariant* result) { |
| 791 if (args.size() > 0 && args[0].isBool()) { | 793 if (args.size() > 0 && args[0].isBool()) { |
| 792 bool enabled = args[0].value.boolValue; | 794 WebPreferences* prefs = shell_->GetWebPreferences(); |
| 793 shell_->webView()->GetSettings()->setXSSAuditorEnabled(enabled); | 795 prefs->xss_auditor_enabled = args[0].value.boolValue; |
| 796 prefs->Apply(shell_->webView()); | |
| 794 } | 797 } |
| 795 result->SetNull(); | 798 result->SetNull(); |
| 796 } | 799 } |
| 797 | 800 |
| 798 void LayoutTestController::evaluateScriptInIsolatedWorld( | 801 void LayoutTestController::evaluateScriptInIsolatedWorld( |
| 799 const CppArgumentList& args, CppVariant* result) { | 802 const CppArgumentList& args, CppVariant* result) { |
| 800 if (args.size() > 0 && args[0].isString()) { | 803 if (args.size() > 0 && args[0].isString()) { |
| 801 WebScriptSource source(WebString::fromUTF8(args[0].ToString())); | 804 WebScriptSource source(WebString::fromUTF8(args[0].ToString())); |
| 802 shell_->webView()->GetMainFrame()->executeScriptInNewWorld(&source, 1, 1); | 805 shell_->webView()->GetMainFrame()->executeScriptInNewWorld(&source, 1, 1); |
| 803 } | 806 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 914 void LayoutTestController::fallbackMethod( | 917 void LayoutTestController::fallbackMethod( |
| 915 const CppArgumentList& args, CppVariant* result) { | 918 const CppArgumentList& args, CppVariant* result) { |
| 916 std::wstring message(L"JavaScript ERROR: unknown method called on LayoutTestCo ntroller"); | 919 std::wstring message(L"JavaScript ERROR: unknown method called on LayoutTestCo ntroller"); |
| 917 if (!shell_->layout_test_mode()) { | 920 if (!shell_->layout_test_mode()) { |
| 918 logging::LogMessage("CONSOLE:", 0).stream() << message; | 921 logging::LogMessage("CONSOLE:", 0).stream() << message; |
| 919 } else { | 922 } else { |
| 920 printf("CONSOLE MESSAGE: %S\n", message.c_str()); | 923 printf("CONSOLE MESSAGE: %S\n", message.c_str()); |
| 921 } | 924 } |
| 922 result->SetNull(); | 925 result->SetNull(); |
| 923 } | 926 } |
| OLD | NEW |