Chromium Code Reviews| Index: chrome/renderer/print_web_view_helper_browsertest.cc |
| diff --git a/chrome/renderer/print_web_view_helper_browsertest.cc b/chrome/renderer/print_web_view_helper_browsertest.cc |
| index 75a21ecef104de2e8d7cb3989c59a9f70ba88279..52384381b4dac38ab0bfe977dda45a20e9b98c9c 100644 |
| --- a/chrome/renderer/print_web_view_helper_browsertest.cc |
| +++ b/chrome/renderer/print_web_view_helper_browsertest.cc |
| @@ -38,6 +38,13 @@ const char kLongPageHTML[] = |
| const char kPrintPreviewHTML[] = |
| "<body><p id=\"pdf-viewer\">Hello World!</p></body>"; |
| +// A web page with a @media print listener. The first callback makes |
| +// body two pages tall; each subsequent callback adds one more page. |
| +const char kMediaQueryHTML[] = |
| + "<body>Hello World!<script>var n = 1; var mediaQuery = " |
| + "window.matchMedia('print'); mediaQuery.addListener(function(e) { " |
| + "document.body.style.height = (++n * 840) + 'px';});</script></body>"; |
| + |
| void CreatePrintSettingsDictionary(DictionaryValue* dict) { |
| dict->SetBoolean(printing::kSettingLandscape, false); |
| dict->SetBoolean(printing::kSettingCollate, false); |
| @@ -148,6 +155,14 @@ TEST_F(PrintWebViewHelperTest, PrintWithJavascript) { |
| VerifyPagesPrinted(true); |
| } |
| +// Tests that printing pages calls @media print callbacks once. |
| +TEST_F(PrintWebViewHelperTest, PrintWithMediaQuery) { |
| + LoadHTML(kMediaQueryHTML); |
| + PrintWebViewHelper::Get(view_)->OnPrintPages(); |
|
vandebo (ex-Chrome)
2011/10/24 20:53:47
Does this test fail without your changes? I'm not
dominicc (has gone to gerrit)
2011/10/25 04:44:39
It does, at least on my Mac. Should I split this i
vandebo (ex-Chrome)
2011/10/25 17:03:11
That's not necessary, I just wasn't sure if callin
|
| + |
| + VerifyPageCount(2); |
| +} |
| + |
| // Tests that the renderer blocks window.print() calls if they occur too |
| // frequently. |
| TEST_F(PrintWebViewHelperTest, BlockScriptInitiatedPrinting) { |