| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 BindMethod("execCommand", &LayoutTestController::execCommand); | 106 BindMethod("execCommand", &LayoutTestController::execCommand); |
| 107 BindMethod("isCommandEnabled", &LayoutTestController::isCommandEnabled); | 107 BindMethod("isCommandEnabled", &LayoutTestController::isCommandEnabled); |
| 108 BindMethod("setPopupBlockingEnabled", &LayoutTestController::setPopupBlockingE
nabled); | 108 BindMethod("setPopupBlockingEnabled", &LayoutTestController::setPopupBlockingE
nabled); |
| 109 BindMethod("setStopProvisionalFrameLoads", &LayoutTestController::setStopProvi
sionalFrameLoads); | 109 BindMethod("setStopProvisionalFrameLoads", &LayoutTestController::setStopProvi
sionalFrameLoads); |
| 110 BindMethod("setSmartInsertDeleteEnabled", &LayoutTestController::setSmartInser
tDeleteEnabled); | 110 BindMethod("setSmartInsertDeleteEnabled", &LayoutTestController::setSmartInser
tDeleteEnabled); |
| 111 BindMethod("setSelectTrailingWhitespaceEnabled", &LayoutTestController::setSel
ectTrailingWhitespaceEnabled); | 111 BindMethod("setSelectTrailingWhitespaceEnabled", &LayoutTestController::setSel
ectTrailingWhitespaceEnabled); |
| 112 BindMethod("pauseAnimationAtTimeOnElementWithId", &LayoutTestController::pause
AnimationAtTimeOnElementWithId); | 112 BindMethod("pauseAnimationAtTimeOnElementWithId", &LayoutTestController::pause
AnimationAtTimeOnElementWithId); |
| 113 BindMethod("pauseTransitionAtTimeOnElementWithId", &LayoutTestController::paus
eTransitionAtTimeOnElementWithId); | 113 BindMethod("pauseTransitionAtTimeOnElementWithId", &LayoutTestController::paus
eTransitionAtTimeOnElementWithId); |
| 114 BindMethod("elementDoesAutoCompleteForElementWithId", &LayoutTestController::e
lementDoesAutoCompleteForElementWithId); | 114 BindMethod("elementDoesAutoCompleteForElementWithId", &LayoutTestController::e
lementDoesAutoCompleteForElementWithId); |
| 115 BindMethod("numberOfActiveAnimations", &LayoutTestController::numberOfActiveAn
imations); | 115 BindMethod("numberOfActiveAnimations", &LayoutTestController::numberOfActiveAn
imations); |
| 116 BindMethod("setCustomPolicyDelegate", &LayoutTestController::setCustomPolicyDe
legate); |
| 117 BindMethod("waitForPolicyDelegate", &LayoutTestController::waitForPolicyDelega
te); |
| 116 | 118 |
| 117 // The following are stubs. | 119 // The following are stubs. |
| 118 BindMethod("dumpAsWebArchive", &LayoutTestController::dumpAsWebArchive); | 120 BindMethod("dumpAsWebArchive", &LayoutTestController::dumpAsWebArchive); |
| 119 BindMethod("setMainFrameIsFirstResponder", &LayoutTestController::setMainFrame
IsFirstResponder); | 121 BindMethod("setMainFrameIsFirstResponder", &LayoutTestController::setMainFrame
IsFirstResponder); |
| 120 BindMethod("dumpSelectionRect", &LayoutTestController::dumpSelectionRect); | 122 BindMethod("dumpSelectionRect", &LayoutTestController::dumpSelectionRect); |
| 121 BindMethod("display", &LayoutTestController::display); | 123 BindMethod("display", &LayoutTestController::display); |
| 122 BindMethod("testRepaint", &LayoutTestController::testRepaint); | 124 BindMethod("testRepaint", &LayoutTestController::testRepaint); |
| 123 BindMethod("repaintSweepHorizontally", &LayoutTestController::repaintSweepHori
zontally); | 125 BindMethod("repaintSweepHorizontally", &LayoutTestController::repaintSweepHori
zontally); |
| 124 BindMethod("clearBackForwardList", &LayoutTestController::clearBackForwardList
); | 126 BindMethod("clearBackForwardList", &LayoutTestController::clearBackForwardList
); |
| 125 BindMethod("keepWebHistory", &LayoutTestController::keepWebHistory); | 127 BindMethod("keepWebHistory", &LayoutTestController::keepWebHistory); |
| 126 BindMethod("storeWebScriptObject", &LayoutTestController::storeWebScriptObject
); | 128 BindMethod("storeWebScriptObject", &LayoutTestController::storeWebScriptObject
); |
| 127 BindMethod("accessStoredWebScriptObject", &LayoutTestController::accessStoredW
ebScriptObject); | 129 BindMethod("accessStoredWebScriptObject", &LayoutTestController::accessStoredW
ebScriptObject); |
| 128 BindMethod("objCClassNameOf", &LayoutTestController::objCClassNameOf); | 130 BindMethod("objCClassNameOf", &LayoutTestController::objCClassNameOf); |
| 129 BindMethod("addDisallowedURL", &LayoutTestController::addDisallowedURL); | 131 BindMethod("addDisallowedURL", &LayoutTestController::addDisallowedURL); |
| 130 BindMethod("setCallCloseOnWebViews", &LayoutTestController::setCallCloseOnWebV
iews); | 132 BindMethod("setCallCloseOnWebViews", &LayoutTestController::setCallCloseOnWebV
iews); |
| 131 BindMethod("setPrivateBrowsingEnabled", &LayoutTestController::setPrivateBrows
ingEnabled); | 133 BindMethod("setPrivateBrowsingEnabled", &LayoutTestController::setPrivateBrows
ingEnabled); |
| 132 BindMethod("setUseDashboardCompatibilityMode", &LayoutTestController::setUseDa
shboardCompatibilityMode); | 134 BindMethod("setUseDashboardCompatibilityMode", &LayoutTestController::setUseDa
shboardCompatibilityMode); |
| 133 BindMethod("setCustomPolicyDelegate", &LayoutTestController::setCustomPolicyDe
legate); | |
| 134 | 135 |
| 135 // This typo (missing 'i') is intentional as it matches the typo in the layout
test | 136 // This typo (missing 'i') is intentional as it matches the typo in the layout
test |
| 136 // see: LayoutTests/fast/canvas/fill-stroke-clip-reset-path.html. | 137 // see: LayoutTests/fast/canvas/fill-stroke-clip-reset-path.html. |
| 137 // If Apple ever fixes this, we'll need to update it. | 138 // If Apple ever fixes this, we'll need to update it. |
| 138 BindMethod("setUseDashboardCompatiblityMode", &LayoutTestController::setUseDas
hboardCompatibilityMode); | 139 BindMethod("setUseDashboardCompatiblityMode", &LayoutTestController::setUseDas
hboardCompatibilityMode); |
| 139 | 140 |
| 140 // The fallback method is called when an unknown method is invoked. | 141 // The fallback method is called when an unknown method is invoked. |
| 141 BindFallbackMethod(&LayoutTestController::fallbackMethod); | 142 BindFallbackMethod(&LayoutTestController::fallbackMethod); |
| 142 | 143 |
| 143 // Shared properties. | 144 // Shared properties. |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 void LayoutTestController::LocationChangeDone() { | 448 void LayoutTestController::LocationChangeDone() { |
| 448 webHistoryItemCount_.Set(shell_->navigation_controller()->GetEntryCount()); | 449 webHistoryItemCount_.Set(shell_->navigation_controller()->GetEntryCount()); |
| 449 | 450 |
| 450 // no more new work after the first complete load. | 451 // no more new work after the first complete load. |
| 451 work_queue_.set_frozen(true); | 452 work_queue_.set_frozen(true); |
| 452 | 453 |
| 453 if (!wait_until_done_) | 454 if (!wait_until_done_) |
| 454 work_queue_.ProcessWorkSoon(); | 455 work_queue_.ProcessWorkSoon(); |
| 455 } | 456 } |
| 456 | 457 |
| 458 void LayoutTestController::PolicyDelegateDone() { |
| 459 if (!shell_->layout_test_mode()) |
| 460 return; |
| 461 |
| 462 DCHECK(wait_until_done_); |
| 463 shell_->TestFinished(); |
| 464 wait_until_done_ = false; |
| 465 } |
| 466 |
| 457 void LayoutTestController::setCanOpenWindows( | 467 void LayoutTestController::setCanOpenWindows( |
| 458 const CppArgumentList& args, CppVariant* result) { | 468 const CppArgumentList& args, CppVariant* result) { |
| 459 can_open_windows_ = true; | 469 can_open_windows_ = true; |
| 460 result->SetNull(); | 470 result->SetNull(); |
| 461 } | 471 } |
| 462 | 472 |
| 463 void LayoutTestController::setTabKeyCyclesThroughElements( | 473 void LayoutTestController::setTabKeyCyclesThroughElements( |
| 464 const CppArgumentList& args, CppVariant* result) { | 474 const CppArgumentList& args, CppVariant* result) { |
| 465 if (args.size() > 0 && args[0].isBool()) { | 475 if (args.size() > 0 && args[0].isBool()) { |
| 466 shell_->webView()->SetTabKeyCyclesThroughElements(args[0].ToBoolean()); | 476 shell_->webView()->SetTabKeyCyclesThroughElements(args[0].ToBoolean()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 563 |
| 554 void LayoutTestController::setUseDashboardCompatibilityMode( | 564 void LayoutTestController::setUseDashboardCompatibilityMode( |
| 555 const CppArgumentList& args, CppVariant* result) { | 565 const CppArgumentList& args, CppVariant* result) { |
| 556 // We have no need to support Dashboard Compatibility Mode (mac-only) | 566 // We have no need to support Dashboard Compatibility Mode (mac-only) |
| 557 result->SetNull(); | 567 result->SetNull(); |
| 558 } | 568 } |
| 559 | 569 |
| 560 void LayoutTestController::setCustomPolicyDelegate( | 570 void LayoutTestController::setCustomPolicyDelegate( |
| 561 const CppArgumentList& args, CppVariant* result) { | 571 const CppArgumentList& args, CppVariant* result) { |
| 562 if (args.size() > 0 && args[0].isBool()) { | 572 if (args.size() > 0 && args[0].isBool()) { |
| 563 shell_->delegate()->SetCustomPolicyDelegate(args[0].value.boolValue); | 573 bool enable = args[0].value.boolValue; |
| 574 bool permissive = false; |
| 575 if (args.size() > 1 && args[1].isBool()) |
| 576 permissive = args[1].value.boolValue; |
| 577 shell_->delegate()->SetCustomPolicyDelegate(enable, permissive); |
| 564 } | 578 } |
| 565 | 579 |
| 566 result->SetNull(); | 580 result->SetNull(); |
| 567 } | 581 } |
| 568 | 582 |
| 583 void LayoutTestController::waitForPolicyDelegate( |
| 584 const CppArgumentList& args, CppVariant* result) { |
| 585 shell_->delegate()->WaitForPolicyDelegate(); |
| 586 wait_until_done_ = true; |
| 587 result->SetNull(); |
| 588 } |
| 589 |
| 569 void LayoutTestController::pathToLocalResource( | 590 void LayoutTestController::pathToLocalResource( |
| 570 const CppArgumentList& args, CppVariant* result) { | 591 const CppArgumentList& args, CppVariant* result) { |
| 571 result->SetNull(); | 592 result->SetNull(); |
| 572 if (args.size() <= 0 || !args[0].isString()) | 593 if (args.size() <= 0 || !args[0].isString()) |
| 573 return; | 594 return; |
| 574 | 595 |
| 575 std::string url = args[0].ToString(); | 596 std::string url = args[0].ToString(); |
| 576 if (StartsWithASCII(url, "/tmp/", true)) { | 597 if (StartsWithASCII(url, "/tmp/", true)) { |
| 577 // We want a temp file. | 598 // We want a temp file. |
| 578 std::wstring path; | 599 std::wstring path; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 void LayoutTestController::fallbackMethod( | 767 void LayoutTestController::fallbackMethod( |
| 747 const CppArgumentList& args, CppVariant* result) { | 768 const CppArgumentList& args, CppVariant* result) { |
| 748 std::wstring message(L"JavaScript ERROR: unknown method called on LayoutTestCo
ntroller"); | 769 std::wstring message(L"JavaScript ERROR: unknown method called on LayoutTestCo
ntroller"); |
| 749 if (!shell_->layout_test_mode()) { | 770 if (!shell_->layout_test_mode()) { |
| 750 logging::LogMessage("CONSOLE:", 0).stream() << message; | 771 logging::LogMessage("CONSOLE:", 0).stream() << message; |
| 751 } else { | 772 } else { |
| 752 printf("CONSOLE MESSAGE: %S\n", message.c_str()); | 773 printf("CONSOLE MESSAGE: %S\n", message.c_str()); |
| 753 } | 774 } |
| 754 result->SetNull(); | 775 result->SetNull(); |
| 755 } | 776 } |
| OLD | NEW |