diff options
-rw-r--r-- | chrome_frame/chrome_frame_automation.cc | 5 | ||||
-rw-r--r-- | chrome_frame/chrome_launcher.cc | 3 | ||||
-rw-r--r-- | chrome_frame/test/data/window_print.html | 6 | ||||
-rw-r--r-- | chrome_frame/test/ui_test.cc | 26 |
4 files changed, 39 insertions, 1 deletions
diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc index a816e9a..c7f144f 100644 --- a/chrome_frame/chrome_frame_automation.cc +++ b/chrome_frame/chrome_frame_automation.cc @@ -270,6 +270,11 @@ void AutomationProxyCacheEntry::CreateProxy(ChromeFrameLaunchParams* params, command_line->AppendSwitch(switches::kDisablePopupBlocking); +#if defined(GOOGLE_CHROME_BUILD) + // Chrome Frame should use the native print dialog. + command_line->AppendSwitch(switches::kDisablePrintPreview); +#endif + // Disable the "Whoa! Chrome has crashed." dialog, because that isn't very // useful for Chrome Frame users. #ifndef NDEBUG diff --git a/chrome_frame/chrome_launcher.cc b/chrome_frame/chrome_launcher.cc index d89fd8a..e943c7f 100644 --- a/chrome_frame/chrome_launcher.cc +++ b/chrome_frame/chrome_launcher.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -23,6 +23,7 @@ const wchar_t* kAllowedSwitches[] = { L"chrome-version", L"disable-background-mode", L"disable-popup-blocking", + L"disable-print-preview", L"disable-renderer-accessibility", L"enable-experimental-extension-apis", L"force-renderer-accessibility", diff --git a/chrome_frame/test/data/window_print.html b/chrome_frame/test/data/window_print.html new file mode 100644 index 0000000..e93f0e4 --- /dev/null +++ b/chrome_frame/test/data/window_print.html @@ -0,0 +1,6 @@ +<html> + <head><title>window.print</title></head> + <body onload='window.setTimeout("window.print();", 0);'> + <p>The native print dialog should appear.</p> + </body> +</html> diff --git a/chrome_frame/test/ui_test.cc b/chrome_frame/test/ui_test.cc index 86fc302..8446ab6 100644 --- a/chrome_frame/test/ui_test.cc +++ b/chrome_frame/test/ui_test.cc @@ -380,6 +380,32 @@ TEST_P(FullTabUITest, DISABLED_TabCrashRefresh) { LaunchIEAndNavigate(GetSimplePageUrl()); } +// Test that window.print() on a page results in the native Windows print dialog +// appearing rather than Chrome's in-page print preview. +TEST_P(FullTabUITest, WindowPrintOpensNativePrintDialog) { + std::wstring window_print_url(GetTestUrl(L"window_print.html")); + std::wstring window_print_title(L"window.print"); + + const bool is_cf = GetParam().invokes_cf(); + MockWindowObserver win_observer_mock; + + // When the page is loaded, start watching for the Print dialog to appear. + EXPECT_CALL(ie_mock_, OnLoad(is_cf, StrEq(window_print_url))) + .WillOnce(WatchWindow(&win_observer_mock, "Print", "")); + + // When the print dialog opens, close it. + EXPECT_CALL(win_observer_mock, OnWindowOpen(_)) + .WillOnce(DoCloseWindow()); + + // When the print dialog closes, close the browser. + EXPECT_CALL(win_observer_mock, OnWindowClose(_)) + .WillOnce(CloseBrowserMock(&ie_mock_)); + + // Launch IE and navigate to the window_print.html page, which will + // window.print() immediately after loading. + LaunchIEAndNavigate(window_print_url); +} + // Test fixture for tests related to the context menu UI. Since the context // menus for CF and IE are different, these tests are not parameterized. class ContextMenuTest : public MockIEEventSinkTest, public testing::Test { |