Loosen up heuristics for detecting account creation forms.
[chromium-blink-merge.git] / chrome_frame / test / ui_test.cc
blobb9a5c97a4a8e00b70385344eba1ebce2efb1faa5
1 // Copyright (c) 2012 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 #include <mshtmcid.h>
6 #include <string>
8 #include "base/test/test_file_util.h"
9 #include "base/utf_string_conversions.h"
10 #include "base/win/scoped_bstr.h"
11 #include "base/win/scoped_variant.h"
12 #include "base/win/windows_version.h"
13 #include "chrome/common/url_constants.h"
14 #include "chrome_frame/test/chrome_frame_test_utils.h"
15 #include "chrome_frame/test/chrome_frame_ui_test_utils.h"
16 #include "chrome_frame/test/mock_ie_event_sink_actions.h"
17 #include "chrome_frame/test/mock_ie_event_sink_test.h"
19 #include "testing/gmock_mutant.h"
21 using testing::_;
22 using testing::InSequence;
23 using testing::StrCaseEq;
24 using testing::StrEq;
26 namespace chrome_frame_test {
28 // This parameterized test fixture uses the MockIEEventSink and is used by
29 // UI-related tests.
30 class FullTabUITest : public MockIEEventSinkTest,
31 public testing::TestWithParam<CFInvocation> {
32 public:
33 FullTabUITest() {}
35 virtual void SetUp() {
36 // These are UI-related tests, so we do not care about the exact requests
37 // and navigations that occur.
38 server_mock_.ExpectAndServeAnyRequests(GetParam());
39 ie_mock_.ExpectAnyNavigations();
43 // Instantiate each test case for the IE case and for CF meta tag case.
44 // It does not seem too useful to also run the CF http header case since these
45 // are UI, not navigation tests.
46 INSTANTIATE_TEST_CASE_P(IE, FullTabUITest,
47 testing::Values(CFInvocation::None()));
48 INSTANTIATE_TEST_CASE_P(CF, FullTabUITest,
49 testing::Values(CFInvocation::MetaTag()));
51 // Tests keyboard input.
52 TEST_P(FullTabUITest, KeyboardInput) {
53 if (!GetParam().invokes_cf()) {
54 LOG(ERROR) << "Test not implemented for this configuration.";
55 return;
57 std::wstring key_event_url = GetTestUrl(L"keyevent.html");
59 const char* input = "Chrome";
60 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), StrEq(key_event_url)))
61 .WillOnce(PostCharMessagesToRenderer(&ie_mock_, input));
63 EXPECT_CALL(ie_mock_, OnMessage(StrCaseEq(UTF8ToWide(input)), _, _))
64 .WillOnce(CloseBrowserMock(&ie_mock_));
66 LaunchIEAndNavigate(key_event_url);
69 // Tests keyboard shortcuts for back and forward.
70 // http://code.google.com/p/chromium/issues/detail?id=114058
71 TEST_P(FullTabUITest, DISABLED_KeyboardBackForward) {
72 if (IsWorkstationLocked()) {
73 LOG(ERROR) << "This test cannot be run in a locked workstation.";
74 return;
77 std::wstring page1 = GetSimplePageUrl();
78 std::wstring page2 = GetLinkPageUrl();
79 bool in_cf = GetParam().invokes_cf();
80 InSequence expect_in_sequence_for_scope;
82 // This test performs the following steps.
83 // 1. Launches IE and navigates to page1
84 // 2. It then navigates to page2
85 // 3. Sends the VK_BACK keystroke to IE, which should navigate back to
86 // page 1
87 // 4. Sends the Shift + VK_BACK keystroke to IE which should navigate
88 // forward to page2
89 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page1)))
90 .WillOnce(Navigate(&ie_mock_, page2));
92 short bkspace = VkKeyScanA(VK_BACK); // NOLINT
93 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page2)))
94 .WillOnce(testing::DoAll(
95 SetFocusToRenderer(&ie_mock_),
96 DelaySendScanCode(&loop_,
97 base::TimeDelta::FromSeconds(1),
98 bkspace,
99 simulate_input::NONE)));
101 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page1)))
102 .WillOnce(testing::DoAll(
103 SetFocusToRenderer(&ie_mock_),
104 DelaySendScanCode(&loop_,
105 base::TimeDelta::FromSeconds(1),
106 bkspace,
107 simulate_input::SHIFT)));
109 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page2)))
110 .WillOnce(CloseBrowserMock(&ie_mock_));
112 LaunchIENavigateAndLoop(page1, kChromeFrameVeryLongNavigationTimeout);
115 // Tests new window behavior with ctrl+N.
116 // Flaky due to DelaySendChar; see http://crbug.com/124244.
117 TEST_P(FullTabUITest, FLAKY_CtrlN) {
118 if (IsWorkstationLocked()) {
119 LOG(ERROR) << "This test cannot be run in a locked workstation.";
120 return;
123 bool is_cf = GetParam().invokes_cf();
124 if (!is_cf) {
125 LOG(ERROR) << "Test not implemented for this configuration.";
126 return;
128 // Ideally we want to use a ie_mock_ to watch for finer grained
129 // events for New Window, but for Crl+N we don't get any
130 // OnNewWindowX notifications. :(
131 MockWindowObserver win_observer_mock;
133 const char* kNewWindowTitlePattern = "*Internet Explorer*";
134 EXPECT_CALL(ie_mock_, OnLoad(is_cf, StrEq(GetSimplePageUrl())))
135 .WillOnce(testing::DoAll(
136 WatchWindow(&win_observer_mock, kNewWindowTitlePattern, ""),
137 SetFocusToRenderer(&ie_mock_),
138 DelaySendChar(&loop_,
139 base::TimeDelta::FromSeconds(1),
140 'n',
141 simulate_input::CONTROL)));
143 // Watch for new window. It appears that the window close message cannot be
144 // reliably delivered immediately upon receipt of the window open event.
145 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
146 .Times(testing::AtMost(2))
147 .WillOnce(CloseBrowserMock(&ie_mock_))
148 .WillOnce(testing::Return());
150 EXPECT_CALL(win_observer_mock, OnWindowClose(_))
151 .Times(testing::AtMost(2));
153 LaunchIENavigateAndLoop(GetSimplePageUrl(),
154 kChromeFrameVeryLongNavigationTimeout);
157 // Test that Ctrl+F opens the Find dialog.
158 // Flaky due to DelaySendChar; see http://crbug.com/124244.
159 TEST_P(FullTabUITest, FLAKY_CtrlF) {
160 if (IsWorkstationLocked()) {
161 LOG(ERROR) << "This test cannot be run in a locked workstation.";
162 return;
165 bool is_cf = GetParam().invokes_cf();
166 if (!is_cf) {
167 LOG(ERROR) << "Test not implemented for this configuration.";
168 return;
170 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
171 MockWindowObserver win_observer_mock;
172 InSequence expect_in_sequence_for_scope;
174 const char* kFindDialogCaption = "Find";
175 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(GetSimplePageUrl())))
176 .WillOnce(testing::DoAll(
177 WatchWindow(&win_observer_mock, kFindDialogCaption, ""),
178 SetFocusToRenderer(&ie_mock_),
179 DelaySendChar(&loop_,
180 base::TimeDelta::FromMilliseconds(1500),
181 'f',
182 simulate_input::CONTROL)));
184 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
185 .WillOnce(CloseBrowserMock(&ie_mock_));
187 LaunchIENavigateAndLoop(GetSimplePageUrl(),
188 kChromeFrameVeryLongNavigationTimeout);
191 // Test that ctrl+r does cause a refresh.
192 // Flaky due to DelaySendChar; see http://crbug.com/124244.
193 TEST_P(FullTabUITest, FLAKY_CtrlR) {
194 if (IsWorkstationLocked()) {
195 LOG(ERROR) << "This test cannot be run in a locked workstation.";
196 return;
199 EXPECT_CALL(server_mock_, Get(_, UrlPathEq(GetSimplePageUrl()), _))
200 .Times(testing::AtMost(2))
201 .WillRepeatedly(SendResponse(&server_mock_, GetParam()));
203 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(),
204 StrEq(GetSimplePageUrl())))
205 .Times(testing::AtMost(2))
206 .WillOnce(testing::DoAll(
207 SetFocusToRenderer(&ie_mock_),
208 DelaySendChar(&loop_,
209 base::TimeDelta::FromSeconds(1),
210 'r',
211 simulate_input::CONTROL),
212 DelayCloseBrowserMock(
213 &loop_, base::TimeDelta::FromSeconds(4), &ie_mock_)))
214 .WillRepeatedly(testing::Return());
216 LaunchIENavigateAndLoop(GetSimplePageUrl(),
217 kChromeFrameVeryLongNavigationTimeout);
220 // Test window close with ctrl+w.
221 // Flaky due to DelaySendChar; see http://crbug.com/124244.
222 TEST_P(FullTabUITest, FLAKY_CtrlW) {
223 if (IsWorkstationLocked()) {
224 LOG(ERROR) << "This test cannot be run in a locked workstation.";
225 return;
228 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(),
229 StrEq(GetSimplePageUrl())))
230 .WillOnce(testing::DoAll(
231 SetFocusToRenderer(&ie_mock_),
232 DelaySendChar(&loop_,
233 base::TimeDelta::FromSeconds(1),
234 'w',
235 simulate_input::CONTROL)));
237 LaunchIENavigateAndLoop(GetSimplePageUrl(),
238 kChromeFrameVeryLongNavigationTimeout);
241 // Test address bar navigation with Alt+d and URL.
242 // Flaky due to TypeUrlInAddressBar; see http://crbug.com/124244.
243 TEST_P(FullTabUITest, FLAKY_AltD) {
244 if (IsWorkstationLocked()) {
245 LOG(ERROR) << "This test cannot be run in a locked workstation.";
246 return;
249 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(),
250 StrEq(GetSimplePageUrl())))
251 .WillOnce(testing::DoAll(
252 SetFocusToRenderer(&ie_mock_),
253 TypeUrlInAddressBar(&loop_,
254 GetLinkPageUrl(),
255 base::TimeDelta::FromMilliseconds(1500))));
257 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(),
258 StrEq(GetLinkPageUrl())))
259 .WillOnce(CloseBrowserMock(&ie_mock_));
261 LaunchIENavigateAndLoop(GetSimplePageUrl(),
262 kChromeFrameVeryLongNavigationTimeout);
265 // Tests that the renderer has focus after navigation.
266 // Flaky, see http://crbug.com/90791 .
267 TEST_P(FullTabUITest, DISABLED_RendererHasFocus) {
268 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(),
269 StrEq(GetSimplePageUrl())))
270 .WillOnce(testing::DoAll(
271 ExpectRendererHasFocus(&ie_mock_),
272 CloseBrowserMock(&ie_mock_)));
274 LaunchIEAndNavigate(GetSimplePageUrl());
277 // Tests that view source works.
278 TEST_P(FullTabUITest, ViewSource) {
279 // Please see http://code.google.com/p/chromium/issues/detail?id=60987
280 // for more information on why this test is disabled for Vista with IE7.
281 if (base::win::GetVersion() == base::win::VERSION_VISTA &&
282 GetInstalledIEVersion() == IE_7) {
283 LOG(INFO) << "Not running test on Vista with IE7";
284 return;
287 bool in_cf = GetParam().invokes_cf();
288 if (!in_cf) {
289 LOG(ERROR) << "Test not implemented for this configuration.";
290 return;
292 MockIEEventSink view_source_mock;
293 view_source_mock.ExpectAnyNavigations();
294 InSequence expect_in_sequence_for_scope;
296 // After navigation invoke view soruce action using IWebBrowser2::ExecWB
297 VARIANT empty = base::win::ScopedVariant::kEmptyVariant;
298 EXPECT_CALL(ie_mock_, OnLoad(in_cf,
299 StrEq(GetSimplePageUrl())))
300 .WillOnce(DelayExecCommand(
301 &ie_mock_, &loop_, base::TimeDelta(), &CGID_MSHTML,
302 static_cast<OLECMDID>(IDM_VIEWSOURCE),
303 OLECMDEXECOPT_DONTPROMPTUSER, &empty, &empty));
305 // Expect notification for view-source window, handle new window event
306 // and attach a new ie_mock_ to the received web browser
307 std::wstring view_source_url;
308 view_source_url += UTF8ToWide(chrome::kViewSourceScheme);
309 view_source_url += L":";
310 view_source_url += GetSimplePageUrl();
311 std::wstring url_in_new_window = kChromeProtocolPrefix;
312 url_in_new_window += view_source_url;
314 ie_mock_.ExpectNewWindow(&view_source_mock);
315 // For some reason this happens occasionally at least on XP IE7.
316 EXPECT_CALL(view_source_mock, OnLoad(IN_IE, StrEq(url_in_new_window)))
317 .Times(testing::AtMost(1));
318 EXPECT_CALL(view_source_mock, OnLoad(in_cf, StrEq(view_source_url)))
319 .WillOnce(testing::DoAll(
320 VerifyAddressBarUrlWithGcf(&view_source_mock),
321 CloseBrowserMock(&view_source_mock)));
323 EXPECT_CALL(view_source_mock, OnQuit())
324 .Times(testing::AtMost(1))
325 .WillOnce(CloseBrowserMock(&ie_mock_));
327 LaunchIEAndNavigate(GetSimplePageUrl());
330 void NavigateToCurrentUrl(MockIEEventSink* mock) {
331 IWebBrowser2* browser = mock->event_sink()->web_browser2();
332 DCHECK(browser);
333 base::win::ScopedBstr bstr;
334 HRESULT hr = browser->get_LocationURL(bstr.Receive());
335 EXPECT_HRESULT_SUCCEEDED(hr);
336 if (SUCCEEDED(hr)) {
337 DCHECK(bstr.Length());
338 VARIANT empty = base::win::ScopedVariant::kEmptyVariant;
339 hr = browser->Navigate(bstr, &empty, &empty, &empty, &empty);
340 EXPECT_HRESULT_SUCCEEDED(hr);
344 // Tests that Chrome gets re-instantiated after crash if we reload via
345 // the address bar or via a new navigation.
346 TEST_P(FullTabUITest, TabCrashReload) {
347 using testing::DoAll;
349 if (!GetParam().invokes_cf()) {
350 LOG(ERROR) << "Test needs CF.";
351 return;
354 MockPropertyNotifySinkListener prop_listener;
355 InSequence expect_in_sequence_for_scope;
357 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl())))
358 .WillOnce(DoAll(
359 ExpectRendererHasFocus(&ie_mock_),
360 ExpectDocumentReadystate(&ie_mock_, READYSTATE_COMPLETE),
361 ConnectDocPropNotifySink(&ie_mock_, &prop_listener),
362 KillChromeFrameProcesses()));
364 EXPECT_CALL(prop_listener, OnChanged(DISPID_READYSTATE))
365 .WillOnce(DoAll(
366 ExpectDocumentReadystate(&ie_mock_, READYSTATE_UNINITIALIZED),
367 DelayNavigateToCurrentUrl(
368 &ie_mock_, &loop_, base::TimeDelta::FromMilliseconds(10))));
370 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl())))
371 .WillOnce(CloseBrowserMock(&ie_mock_));
373 LaunchIEAndNavigate(GetSimplePageUrl());
376 // Tests if Chrome gets restarted after a crash by just refreshing the document.
377 // DISABLED as per bug http://crbug.com/99317 (one of the failures is a
378 // timeout, which marking as FLAKY or FAILS won't mask).
379 TEST_P(FullTabUITest, DISABLED_TabCrashRefresh) {
380 using testing::DoAll;
382 if (!GetParam().invokes_cf()) {
383 LOG(ERROR) << "Test needs CF.";
384 return;
387 MockPropertyNotifySinkListener prop_listener;
388 InSequence expect_in_sequence_for_scope;
390 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl())))
391 .WillOnce(DoAll(
392 ExpectRendererHasFocus(&ie_mock_),
393 ExpectDocumentReadystate(&ie_mock_, READYSTATE_COMPLETE),
394 ConnectDocPropNotifySink(&ie_mock_, &prop_listener),
395 KillChromeFrameProcesses()));
397 VARIANT empty = base::win::ScopedVariant::kEmptyVariant;
398 EXPECT_CALL(prop_listener, OnChanged(/*DISPID_READYSTATE*/_))
399 .WillOnce(DoAll(
400 DisconnectDocPropNotifySink(&prop_listener),
401 ExpectDocumentReadystate(&ie_mock_, READYSTATE_UNINITIALIZED),
402 DelayExecCommand(
403 &ie_mock_, &loop_, base::TimeDelta::FromMilliseconds(10),
404 static_cast<GUID*>(NULL), OLECMDID_REFRESH, 0, &empty, &empty)));
406 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl())))
407 .WillOnce(CloseBrowserMock(&ie_mock_));
409 LaunchIEAndNavigate(GetSimplePageUrl());
412 // Test that window.print() on a page results in the native Windows print dialog
413 // appearing rather than Chrome's in-page print preview.
414 TEST_P(FullTabUITest, WindowPrintOpensNativePrintDialog) {
415 std::wstring window_print_url(GetTestUrl(L"window_print.html"));
416 std::wstring window_print_title(L"window.print");
418 const bool is_cf = GetParam().invokes_cf();
419 MockWindowObserver win_observer_mock;
421 // When the page is loaded, start watching for the Print dialog to appear.
422 EXPECT_CALL(ie_mock_, OnLoad(is_cf, StrEq(window_print_url)))
423 .WillOnce(WatchWindow(&win_observer_mock, "Print", ""));
425 // When the print dialog opens, close it.
426 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
427 .WillOnce(DoCloseWindow());
429 // When the print dialog closes, close the browser.
430 EXPECT_CALL(win_observer_mock, OnWindowClose(_))
431 .WillOnce(CloseBrowserMock(&ie_mock_));
433 // Launch IE and navigate to the window_print.html page, which will
434 // window.print() immediately after loading.
435 LaunchIEAndNavigate(window_print_url);
438 // Test fixture for tests related to the context menu UI. Since the context
439 // menus for CF and IE are different, these tests are not parameterized.
440 class ContextMenuTest : public MockIEEventSinkTest, public testing::Test {
441 public:
442 ContextMenuTest(): kTextFieldInitValue(L"SomeInitializedTextValue") {}
444 virtual void SetUp() {
445 context_menu_page_url = GetTestUrl(L"context_menu.html");
446 context_menu_page_title = L"context menu";
447 // Clear clipboard to make sure there is no effect from previous tests.
448 SetClipboardText(L"");
449 // These are UI-related tests, so we do not care about the exact
450 // navigations that occur.
451 ie_mock_.ExpectAnyNavigations();
452 EXPECT_CALL(ie_mock_, OnLoad(_, _)).Times(testing::AnyNumber());
453 EXPECT_CALL(acc_observer_, OnAccDocLoad(_)).Times(testing::AnyNumber());
456 // Common helper function for "Save xxx As" tests.
457 void DoSaveAsTest(const wchar_t* role, const wchar_t* menu_item_name,
458 const wchar_t* file_ext) {
459 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
460 MockWindowObserver win_observer_mock;
461 InSequence expect_in_sequence_for_scope;
463 // Open 'Save As' dialog.
464 const char* kSaveDlgCaption = "Save As";
465 EXPECT_CALL(acc_observer_,
466 OnAccDocLoad(TabContentsTitleEq(L"Save As download test")))
467 .WillOnce(testing::DoAll(
468 WatchWindow(&win_observer_mock, kSaveDlgCaption, ""),
469 AccRightClick(AccObjectMatcher(L"", role))));
470 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
471 .WillOnce(AccLeftClick(AccObjectMatcher(menu_item_name)));
473 // Get safe download name using temporary file.
474 FilePath temp_file_path;
475 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path));
476 ASSERT_TRUE(file_util::DieFileDie(temp_file_path, false));
477 temp_file_path = temp_file_path.ReplaceExtension(file_ext);
479 AccObjectMatcher file_name_box(L"File name:", L"editable text");
480 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
481 .WillOnce(testing::DoAll(
482 AccSendCharMessage(file_name_box, L'a'),
483 AccSetValue(file_name_box, temp_file_path.value()),
484 AccDoDefaultAction(AccObjectMatcher(L"Save", L"push button"))));
486 EXPECT_CALL(win_observer_mock, OnWindowClose(_))
487 .WillOnce(CloseWhenFileSaved(&ie_mock_, temp_file_path, 8000));
489 LaunchIENavigateAndLoop(GetTestUrl(L"save_as_context_menu.html"),
490 kChromeFrameVeryLongNavigationTimeout);
491 ASSERT_TRUE(file_util::DieFileDie(temp_file_path, false));
494 protected:
495 // Html page that holds a text field for context menu testing.
496 std::wstring context_menu_page_url;
497 // Title of said html page.
498 std::wstring context_menu_page_title;
499 // This is the text value used to test cut/copy/paste etc.
500 const std::wstring kTextFieldInitValue;
502 testing::NiceMock<MockAccEventObserver> acc_observer_;
505 // Test reloading from the context menu.
506 TEST_F(ContextMenuTest, CFReload) {
507 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
508 InSequence expect_in_sequence_for_scope;
510 EXPECT_CALL(acc_observer_,
511 OnAccDocLoad(TabContentsTitleEq(GetSimplePageTitle())))
512 .WillOnce(OpenContextMenuAsync());
513 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
514 .WillOnce(AccLeftClick(AccObjectMatcher(L"Reload")));
516 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(GetSimplePageUrl())))
517 .WillOnce(CloseBrowserMock(&ie_mock_));
519 LaunchIEAndNavigate(GetSimplePageUrl());
522 // Test view source from the context menu.
523 TEST_F(ContextMenuTest, CFViewSource) {
524 // Please see http://code.google.com/p/chromium/issues/detail?id=60987
525 // for more information on why this test is disabled for Vista with IE7.
526 if (base::win::GetVersion() == base::win::VERSION_VISTA &&
527 GetInstalledIEVersion() == IE_7) {
528 LOG(INFO) << "Not running test on Vista with IE7";
529 return;
531 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
532 MockIEEventSink view_source_mock;
533 view_source_mock.ExpectAnyNavigations();
534 InSequence expect_in_sequence_for_scope;
536 // View the page source.
537 EXPECT_CALL(acc_observer_,
538 OnAccDocLoad(TabContentsTitleEq(GetSimplePageTitle())))
539 .WillOnce(OpenContextMenuAsync());
540 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
541 .WillOnce(AccLeftClick(AccObjectMatcher(L"View page source")));
543 // Expect notification for view-source window, handle new window event
544 // and attach a new ie_mock_ to the received web browser
545 std::wstring view_source_url;
546 view_source_url += UTF8ToWide(chrome::kViewSourceScheme);
547 view_source_url += L":";
548 view_source_url += GetSimplePageUrl();
549 std::wstring url_in_new_window = kChromeProtocolPrefix;
550 url_in_new_window += view_source_url;
552 ie_mock_.ExpectNewWindow(&view_source_mock);
553 // For some reason this happens occasionally at least on XP IE7 and Win7 IE8.
554 EXPECT_CALL(view_source_mock, OnLoad(IN_IE, StrEq(url_in_new_window)))
555 .Times(testing::AtMost(1));
556 EXPECT_CALL(view_source_mock, OnLoad(IN_CF, StrEq(view_source_url)))
557 .WillOnce(testing::DoAll(
558 VerifyAddressBarUrlWithGcf(&view_source_mock),
559 CloseBrowserMock(&view_source_mock)));
560 EXPECT_CALL(view_source_mock, OnQuit())
561 .Times(testing::AtMost(1))
562 .WillOnce(CloseBrowserMock(&ie_mock_));
564 LaunchIEAndNavigate(GetSimplePageUrl());
567 TEST_F(ContextMenuTest, DISABLED_CFPageInfo) {
568 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
569 MockWindowObserver win_observer_mock;
570 InSequence expect_in_sequence_for_scope;
572 // View page information.
573 EXPECT_CALL(acc_observer_,
574 OnAccDocLoad(TabContentsTitleEq(GetSimplePageTitle())))
575 .WillOnce(testing::DoAll(
576 WatchWindow(&win_observer_mock, "", "Chrome_WidgetWin_*"),
577 OpenContextMenuAsync()));
578 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
579 .WillOnce(AccLeftClick(AccObjectMatcher(L"View page info")));
581 EXPECT_CALL(win_observer_mock, OnWindowOpen(_)).Times(1);
582 // Expect page info dialog to pop up. Dismiss the dialog with 'Esc' key
583 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
584 .WillOnce(DoCloseWindow());
586 EXPECT_CALL(win_observer_mock, OnWindowClose(_)).Times(1);
587 EXPECT_CALL(win_observer_mock, OnWindowClose(_))
588 .WillOnce(CloseBrowserMock(&ie_mock_));
590 LaunchIEAndNavigate(GetSimplePageUrl());
593 TEST_F(ContextMenuTest, CFInspector) {
594 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
595 MockWindowObserver win_observer_mock;
596 InSequence expect_in_sequence_for_scope;
598 // Open developer tools.
599 // Devtools begins life with "Untitled" caption and it changes
600 // later to the 'Developer Tools - <url> form.
601 const char* kPageInfoCaptionPattern = "Untitled*";
602 EXPECT_CALL(acc_observer_,
603 OnAccDocLoad(TabContentsTitleEq(GetSimplePageTitle())))
604 .WillOnce(testing::DoAll(
605 WatchWindow(&win_observer_mock, kPageInfoCaptionPattern, ""),
606 OpenContextMenuAsync()));
607 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
608 .WillOnce(AccLeftClick(AccObjectMatcher(L"Inspect element")));
610 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
611 .WillOnce(DelayDoCloseWindow(5000)); // wait to catch possible crash
612 EXPECT_CALL(win_observer_mock, OnWindowClose(_))
613 .WillOnce(CloseBrowserMock(&ie_mock_));
615 LaunchIENavigateAndLoop(GetSimplePageUrl(),
616 kChromeFrameVeryLongNavigationTimeout);
619 // http://code.google.com/p/chromium/issues/detail?id=83114
620 TEST_F(ContextMenuTest, DISABLED_CFSavePageAs) {
621 // Please see http://code.google.com/p/chromium/issues/detail?id=60987
622 // for more information on why this test is disabled for Vista with IE7.
623 if (base::win::GetVersion() == base::win::VERSION_VISTA &&
624 GetInstalledIEVersion() == IE_7) {
625 LOG(INFO) << "Not running test on Vista with IE7";
626 return;
628 ASSERT_NO_FATAL_FAILURE(DoSaveAsTest(L"", L"Save as...", L".html"));
631 // http://code.google.com/p/chromium/issues/detail?id=83114
632 TEST_F(ContextMenuTest, DISABLED_CFSaveLinkAs) {
633 // Please see http://code.google.com/p/chromium/issues/detail?id=60987
634 // for more information on why this test is disabled for Vista with IE7.
635 if (base::win::GetVersion() == base::win::VERSION_VISTA &&
636 GetInstalledIEVersion() == IE_7) {
637 LOG(INFO) << "Not running test on Vista with IE7";
638 return;
640 ASSERT_NO_FATAL_FAILURE(DoSaveAsTest(L"link", L"Save link as...", L".zip"));
643 // This tests that the about:version page can be opened via the CF context menu.
644 TEST_F(ContextMenuTest, CFAboutVersionLoads) {
645 // Please see http://code.google.com/p/chromium/issues/detail?id=60987
646 // for more information on why this test is disabled for Vista with IE7.
647 if (base::win::GetVersion() == base::win::VERSION_VISTA &&
648 GetInstalledIEVersion() == IE_7) {
649 LOG(INFO) << "Not running test on Vista with IE7";
650 return;
652 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
653 const wchar_t* kAboutVersionUrl = L"gcf:about:version";
654 const wchar_t* kAboutVersionWithoutProtoUrl = L"about:version";
655 MockIEEventSink new_window_mock;
656 new_window_mock.ExpectAnyNavigations();
657 InSequence expect_in_sequence_for_scope;
659 EXPECT_CALL(acc_observer_,
660 OnAccDocLoad(TabContentsTitleEq(GetSimplePageTitle())))
661 .WillOnce(OpenContextMenuAsync());
662 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
663 .WillOnce(AccLeftClick(AccObjectMatcher(L"About*")));
665 ie_mock_.ExpectNewWindow(&new_window_mock);
666 // For some reason this happens occasionally at least on Win7 IE8.
667 EXPECT_CALL(new_window_mock, OnLoad(IN_IE, StrEq(kAboutVersionUrl)))
668 .Times(testing::AtMost(1));
669 EXPECT_CALL(new_window_mock,
670 OnLoad(IN_CF, StrEq(kAboutVersionWithoutProtoUrl)))
671 .WillOnce(testing::DoAll(
672 VerifyAddressBarUrlWithGcf(&new_window_mock),
673 CloseBrowserMock(&new_window_mock)));
675 EXPECT_CALL(new_window_mock, OnQuit())
676 .Times(testing::AtMost(1))
677 .WillOnce(CloseBrowserMock(&ie_mock_));
679 LaunchIEAndNavigate(GetSimplePageUrl());
682 TEST_F(ContextMenuTest, IEOpen) {
683 server_mock_.ExpectAndServeAnyRequests(CFInvocation::None());
684 InSequence expect_in_sequence_for_scope;
686 // Open the link through the context menu.
687 EXPECT_CALL(acc_observer_,
688 OnAccDocLoad(TabContentsTitleEq(GetLinkPageTitle())))
689 .WillOnce(AccRightClick(AccObjectMatcher(L"", L"link")));
690 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
691 .WillOnce(AccLeftClick(AccObjectMatcher(L"Open")));
693 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(GetSimplePageUrl())))
694 .WillOnce(testing::DoAll(
695 VerifyAddressBarUrl(&ie_mock_),
696 CloseBrowserMock(&ie_mock_)));
698 LaunchIEAndNavigate(GetLinkPageUrl());
701 TEST_F(ContextMenuTest, IEOpenInNewWindow) {
702 // See crbug.com/64794.
703 if (GetInstalledIEVersion() == IE_7) {
704 LOG(INFO) << "Not running test with IE7";
705 return;
707 server_mock_.ExpectAndServeAnyRequests(CFInvocation::None());
708 MockIEEventSink new_window_mock;
709 new_window_mock.ExpectAnyNavigations();
710 InSequence expect_in_sequence_for_scope;
712 // Open the link in a new window.
713 EXPECT_CALL(acc_observer_,
714 OnAccDocLoad(TabContentsTitleEq(GetLinkPageTitle())))
715 .WillOnce(AccRightClick(AccObjectMatcher(L"", L"link")));
716 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
717 .WillOnce(AccLeftClick(AccObjectMatcher(L"Open in New Window")));
719 ie_mock_.ExpectNewWindow(&new_window_mock);
720 EXPECT_CALL(new_window_mock, OnLoad(IN_IE, StrEq(GetSimplePageUrl())))
721 // TODO(kkania): Verifying the address bar is flaky with this, at least
722 // on XP ie6. Fix.
723 .WillOnce(CloseBrowserMock(&new_window_mock));
725 EXPECT_CALL(new_window_mock, OnQuit())
726 .Times(testing::AtMost(1))
727 .WillOnce(CloseBrowserMock(&ie_mock_));
729 LaunchIEAndNavigate(GetLinkPageUrl());
732 // Test Back/Forward from context menu.
733 TEST_F(ContextMenuTest, IEBackForward) {
734 server_mock_.ExpectAndServeAnyRequests(CFInvocation::None());
735 std::wstring page1 = GetLinkPageUrl();
736 std::wstring title1 = GetLinkPageTitle();
737 std::wstring page2 = GetSimplePageUrl();
738 std::wstring title2 = GetSimplePageTitle();
739 InSequence expect_in_sequence_for_scope;
741 // Navigate to second page.
742 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title1)))
743 .WillOnce(Navigate(&ie_mock_, page2));
745 // Go back.
746 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title2)))
747 .WillOnce(testing::DoAll(
748 VerifyPageLoad(&ie_mock_, IN_IE, page2),
749 OpenContextMenuAsync()));
750 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
751 .WillOnce(AccLeftClick(AccObjectMatcher(L"Back")));
753 // Go forward.
754 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title1)))
755 .WillOnce(testing::DoAll(
756 VerifyPageLoad(&ie_mock_, IN_IE, page1),
757 OpenContextMenuAsync()));
758 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
759 .WillOnce(AccLeftClick(AccObjectMatcher(L"Forward")));
761 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(page2)))
762 .WillOnce(CloseBrowserMock(&ie_mock_));
764 LaunchIEAndNavigate(page1);
767 // Test CF link context menu - Open link in new window.
768 // Failing intermittently on IE6/7. See crbug.com/64794.
769 TEST_F(ContextMenuTest, DISABLED_CFOpenLinkInNewWindow) {
770 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
771 MockIEEventSink new_window_mock;
772 new_window_mock.ExpectAnyNavigations();
774 // Invoke 'Open link in new window' context menu item.
775 EXPECT_CALL(acc_observer_,
776 OnAccDocLoad(TabContentsTitleEq(GetLinkPageTitle())))
777 .Times(testing::AtMost(2))
778 .WillOnce(AccRightClick(AccObjectMatcher(L"", L"link")))
779 .WillOnce(testing::Return());
780 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
781 .WillOnce(AccLeftClick(AccObjectMatcher(L"Open link in new window*")));
783 ie_mock_.ExpectNewWindow(&new_window_mock);
784 EXPECT_CALL(new_window_mock, OnLoad(IN_CF, StrEq(GetSimplePageUrl())))
785 .WillOnce(CloseBrowserMock(&new_window_mock));
786 EXPECT_CALL(new_window_mock, OnQuit())
787 .WillOnce(CloseBrowserMock(&ie_mock_));
789 LaunchIEAndNavigate(GetLinkPageUrl());
792 // Test CF link context menu - Copy link address.
793 TEST_F(ContextMenuTest, CFCopyLinkAddress) {
794 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
796 // Invoke 'Copy link address' context menu item.
797 EXPECT_CALL(acc_observer_,
798 OnAccDocLoad(TabContentsTitleEq(GetLinkPageTitle())))
799 .WillOnce(AccRightClick(AccObjectMatcher(L"", L"link")));
800 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
801 .WillOnce(testing::DoAll(
802 AccLeftClick(AccObjectMatcher(L"Copy link address*")),
803 CloseBrowserMock(&ie_mock_)));
805 LaunchIEAndNavigate(GetLinkPageUrl());
807 EXPECT_STREQ(GetSimplePageUrl().c_str(), GetClipboardText().c_str());
810 // Test CF text field context menu - cut.
811 // Times out sporadically http://crbug.com/119660.
812 TEST_F(ContextMenuTest, FLAKY_CFTxtFieldCut) {
813 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
814 AccObjectMatcher txtfield_matcher(L"", L"editable text");
816 // Invoke "Cut" context menu item of text field.
817 EXPECT_CALL(acc_observer_,
818 OnAccDocLoad(TabContentsTitleEq(context_menu_page_title)))
819 .WillOnce(testing::DoAll(
820 AccRightClick(txtfield_matcher),
821 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher)));
822 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
823 .WillOnce(AccLeftClick(AccObjectMatcher(L"Cut*")));
825 // Verify that text field is empty after cut operation.
826 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"")))
827 .WillOnce(CloseBrowserMock(&ie_mock_));
829 LaunchIEAndNavigate(context_menu_page_url);
830 // Verify that the text value has been cut to clipboard.
831 EXPECT_STREQ(kTextFieldInitValue.c_str(), GetClipboardText().c_str());
834 // Test CF text field context menu - copy.
835 // Times out sporadically http://crbug.com/119660.
836 TEST_F(ContextMenuTest, FLAKY_CFTxtFieldCopy) {
837 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
838 AccObjectMatcher txtfield_matcher(L"", L"editable text");
840 // Invoke "Copy" context menu item of text field.
841 EXPECT_CALL(acc_observer_,
842 OnAccDocLoad(TabContentsTitleEq(context_menu_page_title)))
843 .WillOnce(testing::DoAll(
844 AccRightClick(txtfield_matcher),
845 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher)));
846 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
847 .WillOnce(testing::DoAll(
848 AccLeftClick(AccObjectMatcher(L"Copy*")),
849 CloseBrowserMock(&ie_mock_)));
851 // Verify that there is no change on text field value after copy operation.
852 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, _))
853 .Times(testing::AtMost(0));
855 LaunchIEAndNavigate(context_menu_page_url);
856 // Verify that the text value has been copied to clipboard.
857 EXPECT_STREQ(kTextFieldInitValue.c_str(), GetClipboardText().c_str());
860 // Test CF text field context menu - paste.
861 // Times out sporadically http://crbug.com/119660.
862 TEST_F(ContextMenuTest, FLAKY_CFTxtFieldPaste) {
863 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
864 AccObjectMatcher txtfield_matcher(L"", L"editable text");
866 // Invoke "Paste" context menu item of text field.
867 EXPECT_CALL(acc_observer_,
868 OnAccDocLoad(TabContentsTitleEq(context_menu_page_title)))
869 .WillOnce(testing::DoAll(
870 AccRightClick(txtfield_matcher),
871 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher)));
872 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
873 .WillOnce(AccLeftClick(AccObjectMatcher(L"Paste*")));
874 // Verify that value has been pasted to text field.
875 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(kTextFieldInitValue)))
876 .WillOnce(CloseBrowserMock(&ie_mock_));
878 // Set some text value to clipboard, this is to emulate the 'copy' action.
879 SetClipboardText(kTextFieldInitValue);
881 LaunchIEAndNavigate(context_menu_page_url);
884 // Test CF text field context menu - delete.
885 // Times out sporadically http://crbug.com/119660.
886 TEST_F(ContextMenuTest, FLAKY_CFTxtFieldDelete) {
887 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
888 AccObjectMatcher txtfield_matcher(L"", L"editable text");
890 // Invoke 'Delete' context menu item of text field.
891 EXPECT_CALL(acc_observer_,
892 OnAccDocLoad(TabContentsTitleEq(context_menu_page_title)))
893 .WillOnce(testing::DoAll(
894 AccRightClick(txtfield_matcher),
895 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher)));
896 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
897 .WillOnce(AccLeftClick(AccObjectMatcher(L"Delete*")));
898 // Verify that value has been deleted from text field.
899 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"")))
900 .WillOnce(CloseBrowserMock(&ie_mock_));
902 LaunchIEAndNavigate(context_menu_page_url);
905 // Test CF text field context menu - select all.
906 TEST_F(ContextMenuTest, CFTxtFieldSelectAll) {
907 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
909 // Invoke 'Select all' context menu item of text field.
910 EXPECT_CALL(acc_observer_,
911 OnAccDocLoad(TabContentsTitleEq(context_menu_page_title)))
912 .WillOnce(AccRightClick(AccObjectMatcher(L"", L"editable text")));
913 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
914 .WillOnce(testing::DoAll(
915 AccLeftClick(AccObjectMatcher(L"Select all*")),
916 PostMessageToCF(&ie_mock_, L"selectall")));
917 // Client side script verifies that the text field value has been selected,
918 // then send 'OK' message.
919 EXPECT_CALL(ie_mock_, OnMessage(testing::StrCaseEq(L"OK"), _, _))
920 .WillOnce(CloseBrowserMock(&ie_mock_));
922 LaunchIEAndNavigate(context_menu_page_url + L"?action=selectall");
925 // Test CF text field context menu - undo.
926 // Times out sporadically http://crbug.com/119660.
927 TEST_F(ContextMenuTest, FLAKY_CFTxtFieldUndo) {
928 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
929 AccObjectMatcher txtfield_matcher(L"", L"editable text");
931 // Change the value of text field to 'A'.
932 EXPECT_CALL(acc_observer_,
933 OnAccDocLoad(TabContentsTitleEq(context_menu_page_title)))
934 .WillOnce(testing::DoAll(
935 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
936 AccSendCharMessage(txtfield_matcher, L'A')));
937 // Bring up the context menu once the value has changed.
938 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"A")))
939 .WillOnce(AccRightClick(txtfield_matcher));
940 // Then select "Undo".
941 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
942 .WillOnce(testing::DoAll(
943 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
944 AccLeftClick(AccObjectMatcher(L"Undo*"))));
946 // Verify that value has been reset to initial value after undo operation.
947 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(kTextFieldInitValue)))
948 .WillOnce(CloseBrowserMock(&ie_mock_));
950 LaunchIEAndNavigate(context_menu_page_url);
953 // Test CF text field context menu - redo.
954 // Times out sporadically http://crbug.com/119660.
955 TEST_F(ContextMenuTest, FLAKY_CFTxtFieldRedo) {
956 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
957 AccObjectMatcher txtfield_matcher(L"", L"editable text");
958 InSequence expect_in_sequence_for_scope;
960 // Change text field from its initial value to 'A'.
961 EXPECT_CALL(acc_observer_,
962 OnAccDocLoad(TabContentsTitleEq(context_menu_page_title)))
963 .WillOnce(testing::DoAll(
964 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
965 AccSendCharMessage(txtfield_matcher, L'A')));
966 // Bring up the context menu.
967 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"A")))
968 .WillOnce(AccRightClick(txtfield_matcher));
969 // Select "Undo"
970 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
971 .WillOnce(testing::DoAll(
972 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
973 AccLeftClick(AccObjectMatcher(L"Undo*"))));
975 // After undo operation is done, bring up the context menu again.
976 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(kTextFieldInitValue)))
977 .WillOnce(AccRightClick(txtfield_matcher));
978 // Select "Redo"
979 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
980 .WillOnce(testing::DoAll(
981 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
982 AccLeftClick(AccObjectMatcher(L"Redo*"))));
984 // Verify that text field value is reset to its changed value 'A' and exit.
985 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"A")))
986 .WillOnce(CloseBrowserMock(&ie_mock_));
988 LaunchIEAndNavigate(context_menu_page_url);
991 // Disabled because it seems to hang, causing the test process to timeout and
992 // be killed; see http://crbug.com/121097.
993 TEST_F(ContextMenuTest, DISABLED_CFBackForward) {
994 std::wstring page1 = GetLinkPageUrl();
995 std::wstring title1 = GetLinkPageTitle();
996 std::wstring page2 = GetSimplePageUrl();
997 std::wstring title2 = GetSimplePageTitle();
998 std::wstring page3 = GetTestUrl(L"anchor.html");
999 std::wstring title3 = GetAnchorPageTitle();
1001 server_mock_.ExpectAndServeRequestWithCardinality(
1002 CFInvocation::MetaTag(), page1, testing::Exactly(2));
1004 server_mock_.ExpectAndServeRequestWithCardinality(
1005 CFInvocation::None(), page2, testing::Exactly(3));
1007 server_mock_.ExpectAndServeRequestWithCardinality(
1008 CFInvocation::MetaTag(), page3, testing::Exactly(2));
1010 InSequence expect_in_sequence_for_scope;
1012 // Navigate to second page.
1013 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title1)))
1014 .WillOnce(testing::DoAll(
1015 VerifyPageLoad(&ie_mock_, IN_CF, page1),
1016 Navigate(&ie_mock_, page2)));
1018 // Navigate to third page.
1019 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title2)))
1020 .WillOnce(testing::DoAll(
1021 VerifyPageLoad(&ie_mock_, IN_IE, page2),
1022 Navigate(&ie_mock_, page3)));
1024 // Go back.
1025 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title3)))
1026 .WillOnce(testing::DoAll(
1027 VerifyPageLoad(&ie_mock_, IN_CF, page3),
1028 OpenContextMenuAsync()));
1030 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
1031 .WillOnce(AccLeftClick(AccObjectMatcher(L"Back")));
1033 // Go back
1034 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title2)))
1035 .WillOnce(testing::DoAll(
1036 VerifyPageLoad(&ie_mock_, IN_IE, page2),
1037 OpenContextMenuAsync()));
1039 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
1040 .WillOnce(AccLeftClick(AccObjectMatcher(L"Back")));
1042 // Go forward.
1043 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title1)))
1044 .WillOnce(testing::DoAll(
1045 VerifyPageLoad(&ie_mock_, IN_CF, page1),
1046 OpenContextMenuAsync()));
1048 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
1049 .WillOnce(AccLeftClick(AccObjectMatcher(L"Forward")));
1051 // Go forward.
1052 EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title2)))
1053 .WillOnce(testing::DoAll(
1054 VerifyPageLoad(&ie_mock_, IN_IE, page2),
1055 OpenContextMenuAsync()));
1057 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
1058 .WillOnce(AccLeftClick(AccObjectMatcher(L"Forward")));
1060 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(page3)))
1061 .WillOnce(CloseBrowserMock(&ie_mock_));
1063 LaunchIENavigateAndLoop(page1, kChromeFrameVeryLongNavigationTimeout);
1066 } // namespace chrome_frame_test