| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string.h> | 5 #include <string.h> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/guid.h" | 9 #include "base/guid.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 content::WebContents* contents_after_nav = | 219 content::WebContents* contents_after_nav = |
| 220 browser()->tab_strip_model()->GetActiveWebContents(); | 220 browser()->tab_strip_model()->GetActiveWebContents(); |
| 221 ASSERT_TRUE(contents_after_nav != NULL); | 221 ASSERT_TRUE(contents_after_nav != NULL); |
| 222 EXPECT_EQ(url, contents_after_nav->GetLastCommittedURL()); | 222 EXPECT_EQ(url, contents_after_nav->GetLastCommittedURL()); |
| 223 const content::RenderViewHost* render_view_host = | 223 const content::RenderViewHost* render_view_host = |
| 224 contents_after_nav->GetRenderViewHost(); | 224 contents_after_nav->GetRenderViewHost(); |
| 225 EXPECT_EQ(0, render_view_host->GetEnabledBindings()); | 225 EXPECT_EQ(0, render_view_host->GetEnabledBindings()); |
| 226 EXPECT_EQ(expected_mime_type, contents_after_nav->GetContentsMimeType()); | 226 EXPECT_EQ(expected_mime_type, contents_after_nav->GetContentsMimeType()); |
| 227 } | 227 } |
| 228 | 228 |
| 229 #if defined(OS_LINUX) |
| 230 // Flaky on Ubuntu-12.04 bots: https://crbug.com/604362 |
| 231 #define MAYBE_TestBadUrlErrorPage DISABLED_TestBadUrlErrorPage |
| 232 #else |
| 233 #define MAYBE_TestBadUrlErrorPage TestBadUrlErrorPage |
| 234 #endif |
| 229 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, | 235 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, |
| 230 TestBadUrlErrorPage) { | 236 MAYBE_TestBadUrlErrorPage) { |
| 231 GURL url("chrome-distiller://bad"); | 237 GURL url("chrome-distiller://bad"); |
| 232 | 238 |
| 233 // Navigate to a distiller URL. | 239 // Navigate to a distiller URL. |
| 234 ui_test_utils::NavigateToURL(browser(), url); | 240 ui_test_utils::NavigateToURL(browser(), url); |
| 235 content::WebContents* contents = | 241 content::WebContents* contents = |
| 236 browser()->tab_strip_model()->GetActiveWebContents(); | 242 browser()->tab_strip_model()->GetActiveWebContents(); |
| 237 | 243 |
| 238 // Wait for the page load to complete as the first page completes the root | 244 // Wait for the page load to complete as the first page completes the root |
| 239 // document. | 245 // document. |
| 240 content::WaitForLoadStop(contents); | 246 content::WaitForLoadStop(contents); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 259 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, | 265 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, |
| 260 NoWebUIBindingsDisplayCSS) { | 266 NoWebUIBindingsDisplayCSS) { |
| 261 expect_distillation_ = false; | 267 expect_distillation_ = false; |
| 262 expect_distiller_page_ = false; | 268 expect_distiller_page_ = false; |
| 263 // Navigate to a URL which the source should respond to with CSS. | 269 // Navigate to a URL which the source should respond to with CSS. |
| 264 std::string url_without_scheme = std::string("://foobar/") + kViewerCssPath; | 270 std::string url_without_scheme = std::string("://foobar/") + kViewerCssPath; |
| 265 GURL url(kDomDistillerScheme + url_without_scheme); | 271 GURL url(kDomDistillerScheme + url_without_scheme); |
| 266 ViewSingleDistilledPage(url, "text/css"); | 272 ViewSingleDistilledPage(url, "text/css"); |
| 267 } | 273 } |
| 268 | 274 |
| 275 |
| 276 #if defined(OS_LINUX) |
| 277 // Flaky on Ubuntu-12.04 bots: https://crbug.com/604362 |
| 278 #define MAYBE_EmptyURLShouldNotCrash DISABLED_EmptyURLShouldNotCrash |
| 279 #else |
| 280 #define MAYBE_EmptyURLShouldNotCrash EmptyURLShouldNotCrash |
| 281 #endif |
| 269 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, | 282 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, |
| 270 EmptyURLShouldNotCrash) { | 283 MAYBE_EmptyURLShouldNotCrash) { |
| 271 // This is a bogus URL, so no distillation will happen. | 284 // This is a bogus URL, so no distillation will happen. |
| 272 expect_distillation_ = false; | 285 expect_distillation_ = false; |
| 273 expect_distiller_page_ = false; | 286 expect_distiller_page_ = false; |
| 274 const GURL url(std::string(kDomDistillerScheme) + "://bogus/"); | 287 const GURL url(std::string(kDomDistillerScheme) + "://bogus/"); |
| 275 ViewSingleDistilledPage(url, "text/html"); | 288 ViewSingleDistilledPage(url, "text/html"); |
| 276 } | 289 } |
| 277 | 290 |
| 278 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, | 291 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, |
| 279 InvalidURLShouldNotCrash) { | 292 InvalidURLShouldNotCrash) { |
| 280 // This is a bogus URL, so no distillation will happen. | 293 // This is a bogus URL, so no distillation will happen. |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 508 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 496 contents, kGetContent , &result)); | 509 contents, kGetContent , &result)); |
| 497 EXPECT_THAT(result, HasSubstr("Page 1 content")); | 510 EXPECT_THAT(result, HasSubstr("Page 1 content")); |
| 498 EXPECT_THAT(result, HasSubstr("Page 2 content")); | 511 EXPECT_THAT(result, HasSubstr("Page 2 content")); |
| 499 } | 512 } |
| 500 | 513 |
| 501 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, PrefChange) { | 514 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, PrefChange) { |
| 502 PrefTest(false); | 515 PrefTest(false); |
| 503 } | 516 } |
| 504 | 517 |
| 505 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, PrefChangeError) { | 518 #if defined(OS_LINUX) |
| 519 // Flaky on Ubuntu-12.04 bots: https://crbug.com/604362 |
| 520 #define MAYBE_PrefChangeError DISABLED_PrefChangeError |
| 521 #else |
| 522 #define MAYBE_PrefChangeError PrefChangeError |
| 523 #endif |
| 524 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, |
| 525 MAYBE_PrefChangeError) { |
| 506 PrefTest(true); | 526 PrefTest(true); |
| 507 } | 527 } |
| 508 | 528 |
| 529 |
| 509 void DomDistillerViewerSourceBrowserTest::PrefTest(bool is_error_page) { | 530 void DomDistillerViewerSourceBrowserTest::PrefTest(bool is_error_page) { |
| 510 GURL url; | 531 GURL url; |
| 511 if (is_error_page) { | 532 if (is_error_page) { |
| 512 expect_distillation_ = false; | 533 expect_distillation_ = false; |
| 513 expect_distiller_page_ = false; | 534 expect_distiller_page_ = false; |
| 514 url = GURL("chrome-distiller://bad"); | 535 url = GURL("chrome-distiller://bad"); |
| 515 } else { | 536 } else { |
| 516 expect_distillation_ = true; | 537 expect_distillation_ = true; |
| 517 expect_distiller_page_ = true; | 538 expect_distiller_page_ = true; |
| 518 GURL view_url("http://www.example.com/1"); | 539 GURL view_url("http://www.example.com/1"); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 EXPECT_EQ("dark serif", result); | 632 EXPECT_EQ("dark serif", result); |
| 612 EXPECT_EQ(kDarkToolbarThemeColor, contents->GetThemeColor()); | 633 EXPECT_EQ(kDarkToolbarThemeColor, contents->GetThemeColor()); |
| 613 | 634 |
| 614 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 635 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 615 contents, kGetFontSize, &result)); | 636 contents, kGetFontSize, &result)); |
| 616 base::StringToDouble(result, &fontSize); | 637 base::StringToDouble(result, &fontSize); |
| 617 ASSERT_FLOAT_EQ(kScale, fontSize/oldFontSize); | 638 ASSERT_FLOAT_EQ(kScale, fontSize/oldFontSize); |
| 618 } | 639 } |
| 619 | 640 |
| 620 } // namespace dom_distiller | 641 } // namespace dom_distiller |
| OLD | NEW |