| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "chrome/common/chrome_switches.h" | 7 #include "chrome/common/chrome_switches.h" |
| 8 #include "chrome/common/print_messages.h" | 8 #include "chrome/common/print_messages.h" |
| 9 #include "chrome/renderer/printing/mock_printer.h" | 9 #include "chrome/renderer/printing/mock_printer.h" |
| 10 #include "chrome/renderer/printing/print_web_view_helper.h" | 10 #include "chrome/renderer/printing/print_web_view_helper.h" |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 // printing, and the comment below by sverrir suggests that it doesn't do much | 328 // printing, and the comment below by sverrir suggests that it doesn't do much |
| 329 // for us anyway. | 329 // for us anyway. |
| 330 TEST_F(PrintWebViewHelperTest, PrintWithIframe) { | 330 TEST_F(PrintWebViewHelperTest, PrintWithIframe) { |
| 331 // Document that populates an iframe. | 331 // Document that populates an iframe. |
| 332 const char html[] = | 332 const char html[] = |
| 333 "<html><body>Lorem Ipsum:" | 333 "<html><body>Lorem Ipsum:" |
| 334 "<iframe name=\"sub1\" id=\"sub1\"></iframe><script>" | 334 "<iframe name=\"sub1\" id=\"sub1\"></iframe><script>" |
| 335 " document.write(frames['sub1'].name);" | 335 " document.write(frames['sub1'].name);" |
| 336 " frames['sub1'].document.write(" | 336 " frames['sub1'].document.write(" |
| 337 " '<p>Cras tempus ante eu felis semper luctus!</p>');" | 337 " '<p>Cras tempus ante eu felis semper luctus!</p>');" |
| 338 " frames['sub1'].document.close();" |
| 338 "</script></body></html>"; | 339 "</script></body></html>"; |
| 339 | 340 |
| 340 LoadHTML(html); | 341 LoadHTML(html); |
| 341 | 342 |
| 342 // Find the frame and set it as the focused one. This should mean that that | 343 // Find the frame and set it as the focused one. This should mean that that |
| 343 // the printout should only contain the contents of that frame. | 344 // the printout should only contain the contents of that frame. |
| 344 WebFrame* sub1_frame = | 345 WebFrame* sub1_frame = |
| 345 view_->GetWebView()->findFrameByName(WebString::fromUTF8("sub1")); | 346 view_->GetWebView()->findFrameByName(WebString::fromUTF8("sub1")); |
| 346 ASSERT_TRUE(sub1_frame); | 347 ASSERT_TRUE(sub1_frame); |
| 347 view_->GetWebView()->setFocusedFrame(sub1_frame); | 348 view_->GetWebView()->setFocusedFrame(sub1_frame); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 EXPECT_EQ(margin_bottom, param.a.margin_bottom); | 557 EXPECT_EQ(margin_bottom, param.a.margin_bottom); |
| 557 EXPECT_EQ(page_has_print_css, param.c); | 558 EXPECT_EQ(page_has_print_css, param.c); |
| 558 } | 559 } |
| 559 } | 560 } |
| 560 | 561 |
| 561 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperPreviewTest); | 562 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperPreviewTest); |
| 562 }; | 563 }; |
| 563 | 564 |
| 564 #if defined(ENABLE_FULL_PRINTING) | 565 #if defined(ENABLE_FULL_PRINTING) |
| 565 TEST_F(PrintWebViewHelperPreviewTest, BlockScriptInitiatedPrinting) { | 566 TEST_F(PrintWebViewHelperPreviewTest, BlockScriptInitiatedPrinting) { |
| 567 LoadHTML(kHelloWorldHTML); |
| 566 PrintWebViewHelper* print_web_view_helper = PrintWebViewHelper::Get(view_); | 568 PrintWebViewHelper* print_web_view_helper = PrintWebViewHelper::Get(view_); |
| 567 print_web_view_helper->SetScriptedPrintBlocked(true); | 569 print_web_view_helper->SetScriptedPrintBlocked(true); |
| 568 PrintWithJavaScript(); | 570 PrintWithJavaScript(); |
| 569 VerifyPreviewRequest(false); | 571 VerifyPreviewRequest(false); |
| 570 | 572 |
| 571 print_web_view_helper->SetScriptedPrintBlocked(false); | 573 print_web_view_helper->SetScriptedPrintBlocked(false); |
| 572 PrintWithJavaScript(); | 574 PrintWithJavaScript(); |
| 573 VerifyPreviewRequest(true); | 575 VerifyPreviewRequest(true); |
| 574 } | 576 } |
| 575 | 577 |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 CreatePrintSettingsDictionary(&dict); | 990 CreatePrintSettingsDictionary(&dict); |
| 989 OnPrintForPrintPreview(dict); | 991 OnPrintForPrintPreview(dict); |
| 990 | 992 |
| 991 VerifyPrintFailed(true); | 993 VerifyPrintFailed(true); |
| 992 VerifyPagesPrinted(false); | 994 VerifyPagesPrinted(false); |
| 993 } | 995 } |
| 994 | 996 |
| 995 #endif // !defined(OS_CHROMEOS) | 997 #endif // !defined(OS_CHROMEOS) |
| 996 | 998 |
| 997 } // namespace printing | 999 } // namespace printing |
| OLD | NEW |