Reverting 9366.
[chromium-blink-merge.git] / webkit / tools / test_shell / layout_test_controller.cc
blob47700e2960b994b592f79f44253a21d7dbb58530
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
3 // found in the LICENSE file.
5 // This file contains the definition for LayoutTestController.
7 #include <vector>
9 #include "webkit/tools/test_shell/layout_test_controller.h"
11 #include "base/basictypes.h"
12 #include "base/file_util.h"
13 #include "base/logging.h"
14 #include "base/message_loop.h"
15 #include "base/path_service.h"
16 #include "base/string_util.h"
17 #include "webkit/glue/dom_operations.h"
18 #include "webkit/glue/webframe.h"
19 #include "webkit/glue/webpreferences.h"
20 #include "webkit/glue/webview.h"
21 #include "webkit/tools/test_shell/test_navigation_controller.h"
22 #include "webkit/tools/test_shell/test_shell.h"
24 using std::string;
25 using std::wstring;
27 #if defined(OS_WIN)
28 namespace {
30 // Stops the test from running and prints a brief warning to stdout. Called
31 // when the timer for loading a layout test expires.
32 VOID CALLBACK TestTimeout(HWND hwnd, UINT msg, UINT_PTR timer_id, DWORD ms) {
33 puts("#TEST_TIMED_OUT\n");
34 reinterpret_cast<TestShell*>(timer_id)->TestFinished();
35 // Print a warning to be caught by the layout-test script.
39 #endif
41 TestShell* LayoutTestController::shell_ = NULL;
42 bool LayoutTestController::dump_as_text_ = false;
43 bool LayoutTestController::dump_editing_callbacks_ = false;
44 bool LayoutTestController::dump_frame_load_callbacks_ = false;
45 bool LayoutTestController::dump_resource_load_callbacks_ = false;
46 bool LayoutTestController::dump_back_forward_list_ = false;
47 bool LayoutTestController::dump_child_frame_scroll_positions_ = false;
48 bool LayoutTestController::dump_child_frames_as_text_ = false;
49 bool LayoutTestController::dump_title_changes_ = false;
50 bool LayoutTestController::accepts_editing_ = true;
51 bool LayoutTestController::wait_until_done_ = false;
52 bool LayoutTestController::can_open_windows_ = false;
53 bool LayoutTestController::close_remaining_windows_ = true;
54 bool LayoutTestController::should_add_file_to_pasteboard_ = false;
55 bool LayoutTestController::stop_provisional_frame_loads_ = false;
56 LayoutTestController::WorkQueue LayoutTestController::work_queue_;
57 CppVariant LayoutTestController::globalFlag_;
58 CppVariant LayoutTestController::webHistoryItemCount_;
60 LayoutTestController::LayoutTestController(TestShell* shell) {
61 // Set static shell_ variable since we can't do it in an initializer list.
62 // We also need to be careful not to assign shell_ to new windows which are
63 // temporary.
64 if (NULL == shell_)
65 shell_ = shell;
67 // Initialize the map that associates methods of this class with the names
68 // they will use when called by JavaScript. The actual binding of those
69 // names to their methods will be done by calling BindToJavaScript() (defined
70 // by CppBoundClass, the parent to LayoutTestController).
71 BindMethod("dumpAsText", &LayoutTestController::dumpAsText);
72 BindMethod("dumpChildFrameScrollPositions", &LayoutTestController::dumpChildFrameScrollPositions);
73 BindMethod("dumpChildFramesAsText", &LayoutTestController::dumpChildFramesAsText);
74 BindMethod("dumpEditingCallbacks", &LayoutTestController::dumpEditingCallbacks);
75 BindMethod("dumpBackForwardList", &LayoutTestController::dumpBackForwardList);
76 BindMethod("dumpFrameLoadCallbacks", &LayoutTestController::dumpFrameLoadCallbacks);
77 BindMethod("dumpResourceLoadCallbacks", &LayoutTestController::dumpResourceLoadCallbacks);
78 BindMethod("dumpTitleChanges", &LayoutTestController::dumpTitleChanges);
79 BindMethod("setAcceptsEditing", &LayoutTestController::setAcceptsEditing);
80 BindMethod("waitUntilDone", &LayoutTestController::waitUntilDone);
81 BindMethod("notifyDone", &LayoutTestController::notifyDone);
82 BindMethod("queueReload", &LayoutTestController::queueReload);
83 BindMethod("queueScript", &LayoutTestController::queueScript);
84 BindMethod("queueLoad", &LayoutTestController::queueLoad);
85 BindMethod("queueBackNavigation", &LayoutTestController::queueBackNavigation);
86 BindMethod("queueForwardNavigation", &LayoutTestController::queueForwardNavigation);
87 BindMethod("windowCount", &LayoutTestController::windowCount);
88 BindMethod("setCanOpenWindows", &LayoutTestController::setCanOpenWindows);
89 BindMethod("setCloseRemainingWindowsWhenComplete", &LayoutTestController::setCloseRemainingWindowsWhenComplete);
90 BindMethod("objCIdentityIsEqual", &LayoutTestController::objCIdentityIsEqual);
91 BindMethod("setWindowIsKey", &LayoutTestController::setWindowIsKey);
92 BindMethod("setTabKeyCyclesThroughElements", &LayoutTestController::setTabKeyCyclesThroughElements);
93 BindMethod("setUserStyleSheetLocation", &LayoutTestController::setUserStyleSheetLocation);
94 BindMethod("setUserStyleSheetEnabled", &LayoutTestController::setUserStyleSheetEnabled);
95 BindMethod("pathToLocalResource", &LayoutTestController::pathToLocalResource);
96 BindMethod("addFileToPasteboardOnDrag", &LayoutTestController::addFileToPasteboardOnDrag);
97 BindMethod("execCommand", &LayoutTestController::execCommand);
98 BindMethod("isCommandEnabled", &LayoutTestController::isCommandEnabled);
99 BindMethod("setPopupBlockingEnabled", &LayoutTestController::setPopupBlockingEnabled);
100 BindMethod("setStopProvisionalFrameLoads", &LayoutTestController::setStopProvisionalFrameLoads);
101 BindMethod("setSmartInsertDeleteEnabled", &LayoutTestController::setSmartInsertDeleteEnabled);
102 BindMethod("setSelectTrailingWhitespaceEnabled", &LayoutTestController::setSelectTrailingWhitespaceEnabled);
103 BindMethod("pauseAnimationAtTimeOnElementWithId", &LayoutTestController::pauseAnimationAtTimeOnElementWithId);
104 BindMethod("pauseTransitionAtTimeOnElementWithId", &LayoutTestController::pauseTransitionAtTimeOnElementWithId);
105 BindMethod("elementDoesAutoCompleteForElementWithId", &LayoutTestController::elementDoesAutoCompleteForElementWithId);
106 BindMethod("numberOfActiveAnimations", &LayoutTestController::numberOfActiveAnimations);
108 // The following are stubs.
109 BindMethod("dumpAsWebArchive", &LayoutTestController::dumpAsWebArchive);
110 BindMethod("setMainFrameIsFirstResponder", &LayoutTestController::setMainFrameIsFirstResponder);
111 BindMethod("dumpSelectionRect", &LayoutTestController::dumpSelectionRect);
112 BindMethod("display", &LayoutTestController::display);
113 BindMethod("testRepaint", &LayoutTestController::testRepaint);
114 BindMethod("repaintSweepHorizontally", &LayoutTestController::repaintSweepHorizontally);
115 BindMethod("clearBackForwardList", &LayoutTestController::clearBackForwardList);
116 BindMethod("keepWebHistory", &LayoutTestController::keepWebHistory);
117 BindMethod("storeWebScriptObject", &LayoutTestController::storeWebScriptObject);
118 BindMethod("accessStoredWebScriptObject", &LayoutTestController::accessStoredWebScriptObject);
119 BindMethod("objCClassNameOf", &LayoutTestController::objCClassNameOf);
120 BindMethod("addDisallowedURL", &LayoutTestController::addDisallowedURL);
121 BindMethod("setCallCloseOnWebViews", &LayoutTestController::setCallCloseOnWebViews);
122 BindMethod("setPrivateBrowsingEnabled", &LayoutTestController::setPrivateBrowsingEnabled);
123 BindMethod("setUseDashboardCompatibilityMode", &LayoutTestController::setUseDashboardCompatibilityMode);
124 BindMethod("setCustomPolicyDelegate", &LayoutTestController::setCustomPolicyDelegate);
126 // This typo (missing 'i') is intentional as it matches the typo in the layout test
127 // see: LayoutTests/fast/canvas/fill-stroke-clip-reset-path.html.
128 // If Apple ever fixes this, we'll need to update it.
129 BindMethod("setUseDashboardCompatiblityMode", &LayoutTestController::setUseDashboardCompatibilityMode);
131 // The fallback method is called when an unknown method is invoked.
132 BindFallbackMethod(&LayoutTestController::fallbackMethod);
134 // Shared properties.
135 // globalFlag is used by a number of layout tests in
136 // LayoutTests\http\tests\security\dataURL.
137 BindProperty("globalFlag", &globalFlag_);
138 // webHistoryItemCount is used by tests in LayoutTests\http\tests\history
139 BindProperty("webHistoryItemCount", &webHistoryItemCount_);
142 LayoutTestController::WorkQueue::~WorkQueue() {
143 Reset();
146 void LayoutTestController::WorkQueue::ProcessWorkSoon() {
147 if (shell_->delegate()->top_loading_frame())
148 return;
150 if (!queue_.empty()) {
151 // We delay processing queued work to avoid recursion problems.
152 timer_.Start(base::TimeDelta(), this, &WorkQueue::ProcessWork);
153 } else if (!wait_until_done_) {
154 shell_->TestFinished();
158 void LayoutTestController::WorkQueue::ProcessWork() {
159 // Quit doing work once a load is in progress.
160 while (!queue_.empty() && !shell_->delegate()->top_loading_frame()) {
161 queue_.front()->Run(shell_);
162 delete queue_.front();
163 queue_.pop();
166 if (!shell_->delegate()->top_loading_frame() && !wait_until_done_) {
167 shell_->TestFinished();
171 void LayoutTestController::WorkQueue::Reset() {
172 frozen_ = false;
173 while (!queue_.empty()) {
174 delete queue_.front();
175 queue_.pop();
179 void LayoutTestController::WorkQueue::AddWork(WorkItem* work) {
180 if (frozen_) {
181 delete work;
182 return;
184 queue_.push(work);
187 void LayoutTestController::dumpAsText(const CppArgumentList& args,
188 CppVariant* result) {
189 dump_as_text_ = true;
190 result->SetNull();
193 void LayoutTestController::dumpEditingCallbacks(
194 const CppArgumentList& args, CppVariant* result) {
195 dump_editing_callbacks_ = true;
196 result->SetNull();
199 void LayoutTestController::dumpBackForwardList(
200 const CppArgumentList& args, CppVariant* result) {
201 dump_back_forward_list_ = true;
202 result->SetNull();
205 void LayoutTestController::dumpFrameLoadCallbacks(
206 const CppArgumentList& args, CppVariant* result) {
207 dump_frame_load_callbacks_ = true;
208 result->SetNull();
211 void LayoutTestController::dumpResourceLoadCallbacks(
212 const CppArgumentList& args, CppVariant* result) {
213 dump_resource_load_callbacks_ = true;
214 result->SetNull();
217 void LayoutTestController::dumpChildFrameScrollPositions(
218 const CppArgumentList& args, CppVariant* result) {
219 dump_child_frame_scroll_positions_ = true;
220 result->SetNull();
223 void LayoutTestController::dumpChildFramesAsText(
224 const CppArgumentList& args, CppVariant* result) {
225 dump_child_frames_as_text_ = true;
226 result->SetNull();
229 void LayoutTestController::dumpTitleChanges(
230 const CppArgumentList& args, CppVariant* result) {
231 dump_title_changes_ = true;
232 result->SetNull();
235 void LayoutTestController::setAcceptsEditing(
236 const CppArgumentList& args, CppVariant* result) {
237 if (args.size() > 0 && args[0].isBool())
238 accepts_editing_ = args[0].value.boolValue;
239 result->SetNull();
242 void LayoutTestController::waitUntilDone(
243 const CppArgumentList& args, CppVariant* result) {
244 #if defined(OS_WIN)
245 // Set a timer in case something hangs. We use a custom timer rather than
246 // the one managed by the message loop so we can kill it when the load
247 // finishes successfully.
248 if (!::IsDebuggerPresent()) {
249 UINT_PTR timer_id = reinterpret_cast<UINT_PTR>(shell_);
250 SetTimer(shell_->mainWnd(), timer_id, shell_->GetLayoutTestTimeout(),
251 &TestTimeout);
253 #else
254 // TODO(port): implement timer here
255 #endif
256 wait_until_done_ = true;
257 result->SetNull();
260 void LayoutTestController::notifyDone(
261 const CppArgumentList& args, CppVariant* result) {
262 if (shell_->layout_test_mode() && wait_until_done_ &&
263 !shell_->delegate()->top_loading_frame() && work_queue_.empty()) {
264 shell_->TestFinished();
266 wait_until_done_ = false;
267 result->SetNull();
270 class WorkItemBackForward : public LayoutTestController::WorkItem {
271 public:
272 WorkItemBackForward(int distance) : distance_(distance) {}
273 void Run(TestShell* shell) {
274 shell->GoBackOrForward(distance_);
276 private:
277 int distance_;
280 void LayoutTestController::queueBackNavigation(
281 const CppArgumentList& args, CppVariant* result) {
282 if (args.size() > 0 && args[0].isNumber())
283 work_queue_.AddWork(new WorkItemBackForward(-args[0].ToInt32()));
284 result->SetNull();
287 void LayoutTestController::queueForwardNavigation(
288 const CppArgumentList& args, CppVariant* result) {
289 if (args.size() > 0 && args[0].isNumber())
290 work_queue_.AddWork(new WorkItemBackForward(args[0].ToInt32()));
291 result->SetNull();
294 class WorkItemReload : public LayoutTestController::WorkItem {
295 public:
296 void Run(TestShell* shell) {
297 shell->Reload();
301 void LayoutTestController::queueReload(
302 const CppArgumentList& args, CppVariant* result) {
303 work_queue_.AddWork(new WorkItemReload);
304 result->SetNull();
307 class WorkItemScript : public LayoutTestController::WorkItem {
308 public:
309 WorkItemScript(const string& script) : script_(script) {}
310 void Run(TestShell* shell) {
311 wstring url = L"javascript:" + UTF8ToWide(script_);
312 shell->LoadURL(url.c_str());
314 private:
315 string script_;
318 void LayoutTestController::queueScript(
319 const CppArgumentList& args, CppVariant* result) {
320 if (args.size() > 0 && args[0].isString())
321 work_queue_.AddWork(new WorkItemScript(args[0].ToString()));
322 result->SetNull();
325 class WorkItemLoad : public LayoutTestController::WorkItem {
326 public:
327 WorkItemLoad(const GURL& url, const string& target)
328 : url_(url), target_(target) {}
329 void Run(TestShell* shell) {
330 shell->LoadURLForFrame(UTF8ToWide(url_.spec()).c_str(),
331 UTF8ToWide(target_).c_str());
333 private:
334 GURL url_;
335 string target_;
338 void LayoutTestController::queueLoad(
339 const CppArgumentList& args, CppVariant* result) {
340 if (args.size() > 0 && args[0].isString()) {
341 GURL current_url = shell_->webView()->GetMainFrame()->GetURL();
342 GURL full_url = current_url.Resolve(args[0].ToString());
344 string target = "";
345 if (args.size() > 1 && args[1].isString())
346 target = args[1].ToString();
348 work_queue_.AddWork(new WorkItemLoad(full_url, target));
350 result->SetNull();
353 void LayoutTestController::objCIdentityIsEqual(
354 const CppArgumentList& args, CppVariant* result) {
355 if (args.size() < 2) {
356 // This is the best we can do to return an error.
357 result->SetNull();
358 return;
360 result->Set(args[0].isEqual(args[1]));
363 void LayoutTestController::Reset() {
364 if (shell_) {
365 shell_->webView()->ResetZoom();
366 shell_->webView()->SetTabKeyCyclesThroughElements(true);
368 dump_as_text_ = false;
369 dump_editing_callbacks_ = false;
370 dump_frame_load_callbacks_ = false;
371 dump_resource_load_callbacks_ = false;
372 dump_back_forward_list_ = false;
373 dump_child_frame_scroll_positions_ = false;
374 dump_child_frames_as_text_ = false;
375 dump_title_changes_ = false;
376 accepts_editing_ = true;
377 wait_until_done_ = false;
378 can_open_windows_ = false;
379 should_add_file_to_pasteboard_ = false;
380 stop_provisional_frame_loads_ = false;
381 globalFlag_.Set(false);
382 webHistoryItemCount_.Set(0);
384 if (close_remaining_windows_) {
385 // Iterate through the window list and close everything except the original
386 // shell. We don't want to delete elements as we're iterating, so we copy
387 // to a temp vector first.
388 WindowList* windows = TestShell::windowList();
389 std::vector<gfx::NativeWindow> windows_to_delete;
390 for (WindowList::iterator i = windows->begin(); i != windows->end(); ++i) {
391 if (*i != shell_->mainWnd())
392 windows_to_delete.push_back(*i);
394 DCHECK(windows_to_delete.size() + 1 == windows->size());
395 for (size_t i = 0; i < windows_to_delete.size(); ++i) {
396 TestShell::DestroyWindow(windows_to_delete[i]);
398 DCHECK(windows->size() == 1);
399 } else {
400 // Reset the value
401 close_remaining_windows_ = true;
403 work_queue_.Reset();
406 void LayoutTestController::LocationChangeDone() {
407 webHistoryItemCount_.Set(shell_->navigation_controller()->GetEntryCount());
409 // no more new work after the first complete load.
410 work_queue_.set_frozen(true);
412 if (!wait_until_done_)
413 work_queue_.ProcessWorkSoon();
416 void LayoutTestController::setCanOpenWindows(
417 const CppArgumentList& args, CppVariant* result) {
418 can_open_windows_ = true;
419 result->SetNull();
422 void LayoutTestController::setTabKeyCyclesThroughElements(
423 const CppArgumentList& args, CppVariant* result) {
424 if (args.size() > 0 && args[0].isBool()) {
425 shell_->webView()->SetTabKeyCyclesThroughElements(args[0].ToBoolean());
427 result->SetNull();
430 void LayoutTestController::windowCount(
431 const CppArgumentList& args, CppVariant* result) {
432 int num_windows = static_cast<int>(TestShell::windowList()->size());
433 result->Set(num_windows);
436 void LayoutTestController::setCloseRemainingWindowsWhenComplete(
437 const CppArgumentList& args, CppVariant* result) {
438 if (args.size() > 0 && args[0].isBool()) {
439 close_remaining_windows_ = args[0].value.boolValue;
441 result->SetNull();
444 void LayoutTestController::setWindowIsKey(
445 const CppArgumentList& args, CppVariant* result) {
446 if (args.size() > 0 && args[0].isBool()) {
447 shell_->SetFocus(shell_->webViewHost(), args[0].value.boolValue);
449 result->SetNull();
452 void LayoutTestController::setUserStyleSheetEnabled(
453 const CppArgumentList& args, CppVariant* result) {
454 if (args.size() > 0 && args[0].isBool()) {
455 shell_->delegate()->SetUserStyleSheetEnabled(args[0].value.boolValue);
458 result->SetNull();
461 void LayoutTestController::setUserStyleSheetLocation(
462 const CppArgumentList& args, CppVariant* result) {
463 if (args.size() > 0 && args[0].isString()) {
464 GURL location(TestShell::RewriteLocalUrl(args[0].ToString()));
465 shell_->delegate()->SetUserStyleSheetLocation(location);
468 result->SetNull();
471 void LayoutTestController::execCommand(
472 const CppArgumentList& args, CppVariant* result) {
473 if (args.size() > 0 && args[0].isString()) {
474 std::string command = args[0].ToString();
475 std::string value("");
477 // Ignore the second parameter (which is userInterface)
478 // since this command emulates a manual action.
479 if (args.size() >= 3 && args[2].isString())
480 value = args[2].ToString();
482 // Note: webkit's version does not return the boolean, so neither do we.
483 shell_->webView()->GetFocusedFrame()->ExecuteCoreCommandByName(command,
484 value);
486 result->SetNull();
489 void LayoutTestController::isCommandEnabled(
490 const CppArgumentList& args, CppVariant* result) {
491 if (args.size() <= 0 || !args[0].isString()) {
492 result->SetNull();
493 return;
496 std::string command = args[0].ToString();
497 bool rv = shell_->webView()->GetFocusedFrame()->IsCoreCommandEnabled(command);
498 result->Set(rv);
501 void LayoutTestController::setPopupBlockingEnabled(
502 const CppArgumentList& args, CppVariant* result) {
503 if (args.size() > 0 && args[0].isBool()) {
504 bool block_popups = args[0].ToBoolean();
505 WebPreferences* prefs = shell_->GetWebPreferences();
506 prefs->javascript_can_open_windows_automatically = !block_popups;
508 shell_->webView()->SetPreferences(*prefs);
510 result->SetNull();
513 void LayoutTestController::setUseDashboardCompatibilityMode(
514 const CppArgumentList& args, CppVariant* result) {
515 // We have no need to support Dashboard Compatibility Mode (mac-only)
516 result->SetNull();
519 void LayoutTestController::setCustomPolicyDelegate(
520 const CppArgumentList& args, CppVariant* result) {
521 if (args.size() > 0 && args[0].isBool()) {
522 shell_->delegate()->SetCustomPolicyDelegate(args[0].value.boolValue);
525 result->SetNull();
528 void LayoutTestController::pathToLocalResource(
529 const CppArgumentList& args, CppVariant* result) {
530 result->SetNull();
531 if (args.size() <= 0 || !args[0].isString())
532 return;
534 std::string url = args[0].ToString();
535 if (StartsWithASCII(url, "/tmp/", true)) {
536 // We want a temp file.
537 std::wstring path;
538 PathService::Get(base::DIR_TEMP, &path);
539 file_util::AppendToPath(&path, UTF8ToWide(url.substr(5)));
540 result->Set(WideToUTF8(path));
541 return;
544 // Some layout tests use file://// which we resolve as a UNC path. Normalize
545 // them to just file:///.
546 while (StartsWithASCII(url, "file:////", false)) {
547 url = url.substr(0, 8) + url.substr(9);
549 GURL location(TestShell::RewriteLocalUrl(url));
550 result->Set(location.spec());
553 void LayoutTestController::addFileToPasteboardOnDrag(
554 const CppArgumentList& args, CppVariant* result) {
555 result->SetNull();
556 should_add_file_to_pasteboard_ = true;
559 void LayoutTestController::setStopProvisionalFrameLoads(
560 const CppArgumentList& args, CppVariant* result) {
561 result->SetNull();
562 stop_provisional_frame_loads_ = true;
565 void LayoutTestController::setSmartInsertDeleteEnabled(
566 const CppArgumentList& args, CppVariant* result) {
567 if (args.size() > 0 && args[0].isBool()) {
568 shell_->delegate()->SetSmartInsertDeleteEnabled(args[0].value.boolValue);
571 result->SetNull();
574 void LayoutTestController::setSelectTrailingWhitespaceEnabled(
575 const CppArgumentList& args, CppVariant* result) {
576 if (args.size() > 0 && args[0].isBool()) {
577 shell_->delegate()->SetSelectTrailingWhitespaceEnabled(
578 args[0].value.boolValue);
581 result->SetNull();
584 void LayoutTestController::pauseAnimationAtTimeOnElementWithId(
585 const CppArgumentList& args,
586 CppVariant* result) {
587 if (args.size() > 2 && args[0].isString() && args[1].isNumber() &&
588 args[2].isString()) {
589 std::string animation_name = args[0].ToString();
590 double time = args[1].ToDouble();
591 std::string element_id = args[2].ToString();
593 result->Set(
594 webkit_glue::PauseAnimationAtTimeOnElementWithId(
595 shell_->webView(), animation_name, time, element_id));
596 } else {
597 result->Set(false);
601 void LayoutTestController::pauseTransitionAtTimeOnElementWithId(
602 const CppArgumentList& args,
603 CppVariant* result) {
604 if (args.size() > 2 && args[0].isString() && args[1].isNumber() &&
605 args[2].isString()) {
606 std::string property_name = args[0].ToString();
607 double time = args[1].ToDouble();
608 std::string element_id = args[2].ToString();
610 result->Set(webkit_glue::PauseTransitionAtTimeOnElementWithId(
611 shell_->webView(), property_name, time, element_id));
612 } else {
613 result->Set(false);
617 void LayoutTestController::elementDoesAutoCompleteForElementWithId(
618 const CppArgumentList& args,
619 CppVariant* result) {
620 if (args.size() != 1 || !args[0].isString()) {
621 result->Set(false);
622 return;
624 std::string element_id = args[0].ToString();
625 result->Set(webkit_glue::ElementDoesAutoCompleteForElementWithId(
626 shell_->webView(), element_id));
629 void LayoutTestController::numberOfActiveAnimations(const CppArgumentList& args,
630 CppVariant* result) {
631 result->Set(webkit_glue::NumberOfActiveAnimations(shell_->webView()));
635 // Unimplemented stubs
638 void LayoutTestController::dumpAsWebArchive(
639 const CppArgumentList& args, CppVariant* result) {
640 result->SetNull();
643 void LayoutTestController::setMainFrameIsFirstResponder(
644 const CppArgumentList& args, CppVariant* result) {
645 result->SetNull();
648 void LayoutTestController::dumpSelectionRect(
649 const CppArgumentList& args, CppVariant* result) {
650 result->SetNull();
653 void LayoutTestController::display(
654 const CppArgumentList& args, CppVariant* result) {
655 result->SetNull();
658 void LayoutTestController::testRepaint(
659 const CppArgumentList& args, CppVariant* result) {
660 result->SetNull();
663 void LayoutTestController::repaintSweepHorizontally(
664 const CppArgumentList& args, CppVariant* result) {
665 result->SetNull();
668 void LayoutTestController::clearBackForwardList(
669 const CppArgumentList& args, CppVariant* result) {
670 result->SetNull();
673 void LayoutTestController::keepWebHistory(
674 const CppArgumentList& args, CppVariant* result) {
675 result->SetNull();
678 void LayoutTestController::storeWebScriptObject(
679 const CppArgumentList& args, CppVariant* result) {
680 result->SetNull();
683 void LayoutTestController::accessStoredWebScriptObject(
684 const CppArgumentList& args, CppVariant* result) {
685 result->SetNull();
688 void LayoutTestController::objCClassNameOf(
689 const CppArgumentList& args, CppVariant* result) {
690 result->SetNull();
692 void LayoutTestController::addDisallowedURL(
693 const CppArgumentList& args, CppVariant* result) {
694 result->SetNull();
696 void LayoutTestController::setCallCloseOnWebViews(
697 const CppArgumentList& args, CppVariant* result) {
698 result->SetNull();
700 void LayoutTestController::setPrivateBrowsingEnabled(
701 const CppArgumentList& args, CppVariant* result) {
702 result->SetNull();
705 void LayoutTestController::fallbackMethod(
706 const CppArgumentList& args, CppVariant* result) {
707 std::wstring message(L"JavaScript ERROR: unknown method called on LayoutTestController");
708 if (!shell_->layout_test_mode()) {
709 logging::LogMessage("CONSOLE:", 0).stream() << message;
710 } else {
711 printf("CONSOLE MESSAGE: %S\n", message.c_str());
713 result->SetNull();