| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/browser/prefs/pref_service.h" | 7 #include "content/browser/mock_content_browser_client.h" |
| 8 #include "chrome/common/pref_names.h" | |
| 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | |
| 10 #include "chrome/test/base/testing_pref_service.h" | |
| 11 #include "chrome/test/base/testing_profile.h" | |
| 12 #include "content/browser/renderer_host/render_view_host.h" | 8 #include "content/browser/renderer_host/render_view_host.h" |
| 13 #include "content/browser/renderer_host/render_widget_host_view.h" | 9 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 10 #include "content/browser/renderer_host/test_render_view_host.h" |
| 14 #include "content/browser/site_instance.h" | 11 #include "content/browser/site_instance.h" |
| 15 #include "content/browser/tab_contents/interstitial_page.h" | 12 #include "content/browser/tab_contents/interstitial_page.h" |
| 16 #include "content/browser/tab_contents/navigation_details.h" | 13 #include "content/browser/tab_contents/navigation_details.h" |
| 17 #include "content/browser/tab_contents/navigation_entry.h" | 14 #include "content/browser/tab_contents/navigation_entry.h" |
| 18 #include "content/browser/tab_contents/test_tab_contents.h" | 15 #include "content/browser/tab_contents/test_tab_contents.h" |
| 16 #include "content/browser/webui/empty_web_ui_factory.h" |
| 19 #include "content/common/view_messages.h" | 17 #include "content/common/view_messages.h" |
| 20 #include "content/public/browser/notification_details.h" | 18 #include "content/public/browser/notification_details.h" |
| 21 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
| 22 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
| 23 #include "content/public/common/bindings_policy.h" | 21 #include "content/public/common/bindings_policy.h" |
| 24 #include "content/public/common/content_constants.h" | 22 #include "content/public/common/content_constants.h" |
| 25 #include "content/public/common/url_constants.h" | 23 #include "content/public/common/url_constants.h" |
| 26 #include "content/test/test_browser_thread.h" | 24 #include "content/test/test_browser_thread.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 28 #include "ui/base/message_box_flags.h" | 26 #include "ui/base/message_box_flags.h" |
| 29 #include "webkit/glue/webkit_glue.h" | 27 #include "webkit/glue/webkit_glue.h" |
| 30 | 28 |
| 31 using content::BrowserThread; | 29 using content::BrowserThread; |
| 32 using webkit_glue::PasswordForm; | 30 using webkit_glue::PasswordForm; |
| 33 | 31 |
| 32 namespace { |
| 33 |
| 34 class TabContentsTestWebUI : public WebUI { |
| 35 public: |
| 36 explicit TabContentsTestWebUI(TabContents* source) |
| 37 : WebUI(source) { |
| 38 } |
| 39 virtual ~TabContentsTestWebUI() { |
| 40 } |
| 41 }; |
| 42 |
| 43 class TabContentsTestWebUIFactory : public content::EmptyWebUIFactory { |
| 44 public: |
| 45 virtual WebUI* CreateWebUIForURL(TabContents* source, |
| 46 const GURL& url) const OVERRIDE { |
| 47 if (!HasWebUIScheme(url)) |
| 48 return NULL; |
| 49 |
| 50 return new TabContentsTestWebUI(source); |
| 51 } |
| 52 |
| 53 virtual bool UseWebUIForURL(content::BrowserContext* browser_context, |
| 54 const GURL& url) const OVERRIDE { |
| 55 return HasWebUIScheme(url); |
| 56 } |
| 57 |
| 58 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { |
| 59 return url.SchemeIs("tabcontentstest"); |
| 60 } |
| 61 |
| 62 virtual bool IsURLAcceptableForWebUI(content::BrowserContext* browser_context, |
| 63 const GURL& url) const { |
| 64 return HasWebUIScheme(url); |
| 65 } |
| 66 |
| 67 }; |
| 68 |
| 69 class TabContentsTestBrowserClient : public content::MockContentBrowserClient { |
| 70 public: |
| 71 TabContentsTestBrowserClient() { |
| 72 } |
| 73 |
| 74 virtual content::WebUIFactory* GetWebUIFactory() OVERRIDE { |
| 75 return &factory_; |
| 76 } |
| 77 |
| 78 private: |
| 79 TabContentsTestWebUIFactory factory_; |
| 80 }; |
| 81 |
| 34 class TestInterstitialPage : public InterstitialPage { | 82 class TestInterstitialPage : public InterstitialPage { |
| 35 public: | 83 public: |
| 36 enum InterstitialState { | 84 enum InterstitialState { |
| 37 UNDECIDED = 0, // No decision taken yet. | 85 UNDECIDED = 0, // No decision taken yet. |
| 38 OKED, // Proceed was called. | 86 OKED, // Proceed was called. |
| 39 CANCELED // DontProceed was called. | 87 CANCELED // DontProceed was called. |
| 40 }; | 88 }; |
| 41 | 89 |
| 42 class Delegate { | 90 class Delegate { |
| 43 public: | 91 public: |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 207 |
| 160 virtual void TestInterstitialPageDeleted(TestInterstitialPage* interstitial) { | 208 virtual void TestInterstitialPageDeleted(TestInterstitialPage* interstitial) { |
| 161 DCHECK(interstitial_page_ == interstitial); | 209 DCHECK(interstitial_page_ == interstitial); |
| 162 interstitial_page_ = NULL; | 210 interstitial_page_ = NULL; |
| 163 } | 211 } |
| 164 | 212 |
| 165 private: | 213 private: |
| 166 TestInterstitialPage* interstitial_page_; | 214 TestInterstitialPage* interstitial_page_; |
| 167 }; | 215 }; |
| 168 | 216 |
| 169 class TabContentsTest : public ChromeRenderViewHostTestHarness { | 217 class TabContentsTest : public RenderViewHostTestHarness { |
| 170 public: | 218 public: |
| 171 TabContentsTest() : ui_thread_(BrowserThread::UI, &message_loop_) { | 219 TabContentsTest() |
| 220 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 221 old_browser_client_(NULL) { |
| 222 } |
| 223 |
| 224 virtual void SetUp() { |
| 225 old_browser_client_ = content::GetContentClient()->browser(); |
| 226 content::GetContentClient()->set_browser(&browser_client_); |
| 227 RenderViewHostTestHarness::SetUp(); |
| 228 } |
| 229 |
| 230 virtual void TearDown() { |
| 231 content::GetContentClient()->set_browser(old_browser_client_); |
| 232 RenderViewHostTestHarness::TearDown(); |
| 172 } | 233 } |
| 173 | 234 |
| 174 private: | 235 private: |
| 175 // Supply our own profile so we use the correct profile data. The test harness | 236 TabContentsTestBrowserClient browser_client_; |
| 176 // is not supposed to overwrite a profile if it's already created. | 237 content::TestBrowserThread ui_thread_; |
| 177 virtual void SetUp() { | 238 content::ContentBrowserClient* old_browser_client_; |
| 178 ChromeRenderViewHostTestHarness::SetUp(); | 239 }; |
| 179 | 240 |
| 180 // Set some (WebKit) user preferences. | 241 } // namespace |
| 181 TestingPrefService* pref_services = profile()->GetTestingPrefService(); | |
| 182 #if defined(TOOLKIT_USES_GTK) | |
| 183 pref_services->SetUserPref(prefs::kUsesSystemTheme, | |
| 184 Value::CreateBooleanValue(false)); | |
| 185 #endif | |
| 186 pref_services->SetUserPref(prefs::kDefaultCharset, | |
| 187 Value::CreateStringValue("utf8")); | |
| 188 pref_services->SetUserPref(prefs::kWebKitDefaultFontSize, | |
| 189 Value::CreateIntegerValue(20)); | |
| 190 pref_services->SetUserPref(prefs::kWebKitTextAreasAreResizable, | |
| 191 Value::CreateBooleanValue(false)); | |
| 192 pref_services->SetUserPref(prefs::kWebKitUsesUniversalDetector, | |
| 193 Value::CreateBooleanValue(true)); | |
| 194 pref_services->SetUserPref("webkit.webprefs.foo", | |
| 195 Value::CreateStringValue("bar")); | |
| 196 } | |
| 197 | |
| 198 content::TestBrowserThread ui_thread_; | |
| 199 }; | |
| 200 | 242 |
| 201 // Test to make sure that title updates get stripped of whitespace. | 243 // Test to make sure that title updates get stripped of whitespace. |
| 202 TEST_F(TabContentsTest, UpdateTitle) { | 244 TEST_F(TabContentsTest, UpdateTitle) { |
| 203 ViewHostMsg_FrameNavigate_Params params; | 245 ViewHostMsg_FrameNavigate_Params params; |
| 204 InitNavigateParams(¶ms, 0, GURL(chrome::kAboutBlankURL), | 246 InitNavigateParams(¶ms, 0, GURL(chrome::kAboutBlankURL), |
| 205 content::PAGE_TRANSITION_TYPED); | 247 content::PAGE_TRANSITION_TYPED); |
| 206 | 248 |
| 207 content::LoadCommittedDetails details; | 249 content::LoadCommittedDetails details; |
| 208 controller().RendererDidNavigate(params, &details); | 250 controller().RendererDidNavigate(params, &details); |
| 209 | 251 |
| 210 contents()->UpdateTitle(rvh(), 0, ASCIIToUTF16(" Lots O' Whitespace\n"), | 252 contents()->UpdateTitle(rvh(), 0, ASCIIToUTF16(" Lots O' Whitespace\n"), |
| 211 base::i18n::LEFT_TO_RIGHT); | 253 base::i18n::LEFT_TO_RIGHT); |
| 212 EXPECT_EQ(ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); | 254 EXPECT_EQ(ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); |
| 213 } | 255 } |
| 214 | 256 |
| 215 // Test view source mode for the new tabs page. | 257 // Test view source mode for a webui page. |
| 216 TEST_F(TabContentsTest, NTPViewSource) { | 258 TEST_F(TabContentsTest, NTPViewSource) { |
| 217 const char kUrl[] = "view-source:chrome://newtab"; | 259 const char kUrl[] = "view-source:tabcontentstest://blah"; |
| 218 const GURL kGURL(kUrl); | 260 const GURL kGURL(kUrl); |
| 219 | 261 |
| 220 process()->sink().ClearMessages(); | 262 process()->sink().ClearMessages(); |
| 221 | 263 |
| 222 controller().LoadURL( | 264 controller().LoadURL( |
| 223 kGURL, content::Referrer(), content::PAGE_TRANSITION_TYPED, | 265 kGURL, content::Referrer(), content::PAGE_TRANSITION_TYPED, |
| 224 std::string()); | 266 std::string()); |
| 225 rvh()->delegate()->RenderViewCreated(rvh()); | 267 rvh()->delegate()->RenderViewCreated(rvh()); |
| 226 // Did we get the expected message? | 268 // Did we get the expected message? |
| 227 EXPECT_TRUE(process()->sink().GetFirstMessageMatching( | 269 EXPECT_TRUE(process()->sink().GetFirstMessageMatching( |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 TestRenderViewHost* orig_rvh = rvh(); | 442 TestRenderViewHost* orig_rvh = rvh(); |
| 401 SiteInstance* instance1 = contents()->GetSiteInstance(); | 443 SiteInstance* instance1 = contents()->GetSiteInstance(); |
| 402 | 444 |
| 403 // Navigate to URL. First URL should use first RenderViewHost. | 445 // Navigate to URL. First URL should use first RenderViewHost. |
| 404 const GURL url("http://www.google.com"); | 446 const GURL url("http://www.google.com"); |
| 405 controller().LoadURL( | 447 controller().LoadURL( |
| 406 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 448 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
| 407 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); | 449 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); |
| 408 | 450 |
| 409 // Open a new tab with the same SiteInstance, navigated to the same site. | 451 // Open a new tab with the same SiteInstance, navigated to the same site. |
| 410 TestTabContents contents2(profile(), instance1); | 452 TestTabContents contents2(browser_context_.get(), instance1); |
| 411 contents2.transition_cross_site = true; | 453 contents2.transition_cross_site = true; |
| 412 contents2.controller().LoadURL(url, content::Referrer(), | 454 contents2.controller().LoadURL(url, content::Referrer(), |
| 413 content::PAGE_TRANSITION_TYPED, | 455 content::PAGE_TRANSITION_TYPED, |
| 414 std::string()); | 456 std::string()); |
| 415 // Need this page id to be 2 since the site instance is the same (which is the | 457 // Need this page id to be 2 since the site instance is the same (which is the |
| 416 // scope of page IDs) and we want to consider this a new page. | 458 // scope of page IDs) and we want to consider this a new page. |
| 417 contents2.TestDidNavigate( | 459 contents2.TestDidNavigate( |
| 418 contents2.render_view_host(), 2, url, content::PAGE_TRANSITION_TYPED); | 460 contents2.render_view_host(), 2, url, content::PAGE_TRANSITION_TYPED); |
| 419 | 461 |
| 420 // Navigate first tab to a new site | 462 // Navigate first tab to a new site |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 SiteInstance* instance1 = contents()->GetSiteInstance(); | 503 SiteInstance* instance1 = contents()->GetSiteInstance(); |
| 462 | 504 |
| 463 // Navigate to URL. | 505 // Navigate to URL. |
| 464 const GURL url("http://www.google.com"); | 506 const GURL url("http://www.google.com"); |
| 465 controller().LoadURL( | 507 controller().LoadURL( |
| 466 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 508 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
| 467 contents()->TestDidNavigate( | 509 contents()->TestDidNavigate( |
| 468 orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); | 510 orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); |
| 469 | 511 |
| 470 // Open a related tab to a second site. | 512 // Open a related tab to a second site. |
| 471 TestTabContents contents2(profile(), instance1); | 513 TestTabContents contents2(browser_context_.get(), instance1); |
| 472 contents2.transition_cross_site = true; | 514 contents2.transition_cross_site = true; |
| 473 const GURL url2("http://www.yahoo.com"); | 515 const GURL url2("http://www.yahoo.com"); |
| 474 contents2.controller().LoadURL(url2, content::Referrer(), | 516 contents2.controller().LoadURL(url2, content::Referrer(), |
| 475 content::PAGE_TRANSITION_TYPED, | 517 content::PAGE_TRANSITION_TYPED, |
| 476 std::string()); | 518 std::string()); |
| 477 // The first RVH in contents2 isn't live yet, so we shortcut the cross site | 519 // The first RVH in contents2 isn't live yet, so we shortcut the cross site |
| 478 // pending. | 520 // pending. |
| 479 TestRenderViewHost* rvh2 = static_cast<TestRenderViewHost*>( | 521 TestRenderViewHost* rvh2 = static_cast<TestRenderViewHost*>( |
| 480 contents2.render_view_host()); | 522 contents2.render_view_host()); |
| 481 EXPECT_FALSE(contents2.cross_navigation_pending()); | 523 EXPECT_FALSE(contents2.cross_navigation_pending()); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 SiteInstance* instance2 = contents()->GetSiteInstance(); | 627 SiteInstance* instance2 = contents()->GetSiteInstance(); |
| 586 EXPECT_FALSE(contents()->cross_navigation_pending()); | 628 EXPECT_FALSE(contents()->cross_navigation_pending()); |
| 587 EXPECT_EQ(orig_rvh, rvh()); | 629 EXPECT_EQ(orig_rvh, rvh()); |
| 588 EXPECT_EQ(instance1, instance2); | 630 EXPECT_EQ(instance1, instance2); |
| 589 EXPECT_TRUE(contents()->pending_rvh() == NULL); | 631 EXPECT_TRUE(contents()->pending_rvh() == NULL); |
| 590 } | 632 } |
| 591 | 633 |
| 592 TEST_F(TabContentsTest, CrossSiteNavigationBackPreempted) { | 634 TEST_F(TabContentsTest, CrossSiteNavigationBackPreempted) { |
| 593 contents()->transition_cross_site = true; | 635 contents()->transition_cross_site = true; |
| 594 | 636 |
| 595 // Start with NTP, which gets a new RVH with WebUI bindings. | 637 // Start with a web ui page, which gets a new RVH with WebUI bindings. |
| 596 const GURL url1("chrome://newtab"); | 638 const GURL url1("tabcontentstest://blah"); |
| 597 controller().LoadURL( | 639 controller().LoadURL( |
| 598 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 640 url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
| 599 TestRenderViewHost* ntp_rvh = rvh(); | 641 TestRenderViewHost* ntp_rvh = rvh(); |
| 600 contents()->TestDidNavigate(ntp_rvh, 1, url1, content::PAGE_TRANSITION_TYPED); | 642 contents()->TestDidNavigate(ntp_rvh, 1, url1, content::PAGE_TRANSITION_TYPED); |
| 601 NavigationEntry* entry1 = controller().GetLastCommittedEntry(); | 643 NavigationEntry* entry1 = controller().GetLastCommittedEntry(); |
| 602 SiteInstance* instance1 = contents()->GetSiteInstance(); | 644 SiteInstance* instance1 = contents()->GetSiteInstance(); |
| 603 | 645 |
| 604 EXPECT_FALSE(contents()->cross_navigation_pending()); | 646 EXPECT_FALSE(contents()->cross_navigation_pending()); |
| 605 EXPECT_EQ(ntp_rvh, contents()->render_view_host()); | 647 EXPECT_EQ(ntp_rvh, contents()->render_view_host()); |
| 606 EXPECT_EQ(url1, entry1->url()); | 648 EXPECT_EQ(url1, entry1->url()); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 } | 757 } |
| 716 | 758 |
| 717 // Test that a cross-site navigation is not preempted if the previous | 759 // Test that a cross-site navigation is not preempted if the previous |
| 718 // renderer sends a FrameNavigate message just before being told to stop. | 760 // renderer sends a FrameNavigate message just before being told to stop. |
| 719 // We should only preempt the cross-site navigation if the previous renderer | 761 // We should only preempt the cross-site navigation if the previous renderer |
| 720 // has started a new navigation. See http://crbug.com/79176. | 762 // has started a new navigation. See http://crbug.com/79176. |
| 721 TEST_F(TabContentsTest, CrossSiteNotPreemptedDuringBeforeUnload) { | 763 TEST_F(TabContentsTest, CrossSiteNotPreemptedDuringBeforeUnload) { |
| 722 contents()->transition_cross_site = true; | 764 contents()->transition_cross_site = true; |
| 723 | 765 |
| 724 // Navigate to NTP URL. | 766 // Navigate to NTP URL. |
| 725 const GURL url("chrome://newtab"); | 767 const GURL url("tabcontentstest://blah"); |
| 726 controller().LoadURL( | 768 controller().LoadURL( |
| 727 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 769 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
| 728 TestRenderViewHost* orig_rvh = rvh(); | 770 TestRenderViewHost* orig_rvh = rvh(); |
| 729 EXPECT_FALSE(contents()->cross_navigation_pending()); | 771 EXPECT_FALSE(contents()->cross_navigation_pending()); |
| 730 | 772 |
| 731 // Navigate to new site, with the beforeunload request in flight. | 773 // Navigate to new site, with the beforeunload request in flight. |
| 732 const GURL url2("http://www.yahoo.com"); | 774 const GURL url2("http://www.yahoo.com"); |
| 733 controller().LoadURL( | 775 controller().LoadURL( |
| 734 url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 776 url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
| 735 TestRenderViewHost* pending_rvh = contents()->pending_rvh(); | 777 TestRenderViewHost* pending_rvh = contents()->pending_rvh(); |
| 736 EXPECT_TRUE(contents()->cross_navigation_pending()); | 778 EXPECT_TRUE(contents()->cross_navigation_pending()); |
| 737 EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack()); | 779 EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack()); |
| 738 | 780 |
| 739 // Suppose the first navigation tries to commit now, with a | 781 // Suppose the first navigation tries to commit now, with a |
| 740 // ViewMsg_Stop in flight. This should not cancel the pending navigation, | 782 // ViewMsg_Stop in flight. This should not cancel the pending navigation, |
| 741 // but it should act as if the beforeunload ack arrived. | 783 // but it should act as if the beforeunload ack arrived. |
| 742 orig_rvh->SendNavigate(1, GURL("chrome://newtab")); | 784 orig_rvh->SendNavigate(1, GURL("tabcontentstest://blah")); |
| 743 EXPECT_TRUE(contents()->cross_navigation_pending()); | 785 EXPECT_TRUE(contents()->cross_navigation_pending()); |
| 744 EXPECT_EQ(orig_rvh, contents()->render_view_host()); | 786 EXPECT_EQ(orig_rvh, contents()->render_view_host()); |
| 745 EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack()); | 787 EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack()); |
| 746 | 788 |
| 747 // The pending navigation should be able to commit successfully. | 789 // The pending navigation should be able to commit successfully. |
| 748 contents()->TestDidNavigate( | 790 contents()->TestDidNavigate( |
| 749 pending_rvh, 1, url2, content::PAGE_TRANSITION_TYPED); | 791 pending_rvh, 1, url2, content::PAGE_TRANSITION_TYPED); |
| 750 EXPECT_FALSE(contents()->cross_navigation_pending()); | 792 EXPECT_FALSE(contents()->cross_navigation_pending()); |
| 751 EXPECT_EQ(pending_rvh, contents()->render_view_host()); | 793 EXPECT_EQ(pending_rvh, contents()->render_view_host()); |
| 752 } | 794 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 // Currently, this results in two DidNavigate events. | 934 // Currently, this results in two DidNavigate events. |
| 893 const GURL url(chrome::kAboutBlankURL); | 935 const GURL url(chrome::kAboutBlankURL); |
| 894 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); | 936 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); |
| 895 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); | 937 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); |
| 896 | 938 |
| 897 // Should have a content state here. | 939 // Should have a content state here. |
| 898 NavigationEntry* entry = controller().GetLastCommittedEntry(); | 940 NavigationEntry* entry = controller().GetLastCommittedEntry(); |
| 899 EXPECT_FALSE(entry->content_state().empty()); | 941 EXPECT_FALSE(entry->content_state().empty()); |
| 900 } | 942 } |
| 901 | 943 |
| 902 // Tests to see that webkit preferences are properly loaded and copied over | |
| 903 // to a WebPreferences object. | |
| 904 TEST_F(TabContentsTest, WebKitPrefs) { | |
| 905 WebPreferences webkit_prefs = contents()->TestGetWebkitPrefs(); | |
| 906 | |
| 907 // These values have been overridden by the profile preferences. | |
| 908 EXPECT_EQ("UTF-8", webkit_prefs.default_encoding); | |
| 909 EXPECT_EQ(20, webkit_prefs.default_font_size); | |
| 910 EXPECT_FALSE(webkit_prefs.text_areas_are_resizable); | |
| 911 EXPECT_TRUE(webkit_prefs.uses_universal_detector); | |
| 912 | |
| 913 // These should still be the default values. | |
| 914 #if defined(OS_MACOSX) | |
| 915 const char kDefaultFont[] = "Times"; | |
| 916 #elif defined(OS_CHROMEOS) | |
| 917 const char kDefaultFont[] = "Tinos"; | |
| 918 #else | |
| 919 const char kDefaultFont[] = "Times New Roman"; | |
| 920 #endif | |
| 921 EXPECT_EQ(ASCIIToUTF16(kDefaultFont), webkit_prefs.standard_font_family); | |
| 922 EXPECT_TRUE(webkit_prefs.javascript_enabled); | |
| 923 } | |
| 924 | |
| 925 //////////////////////////////////////////////////////////////////////////////// | 944 //////////////////////////////////////////////////////////////////////////////// |
| 926 // Interstitial Tests | 945 // Interstitial Tests |
| 927 //////////////////////////////////////////////////////////////////////////////// | 946 //////////////////////////////////////////////////////////////////////////////// |
| 928 | 947 |
| 929 // Test navigating to a page (with the navigation initiated from the browser, | 948 // Test navigating to a page (with the navigation initiated from the browser, |
| 930 // as when a URL is typed in the location bar) that shows an interstitial and | 949 // as when a URL is typed in the location bar) that shows an interstitial and |
| 931 // creates a new navigation entry, then hiding it without proceeding. | 950 // creates a new navigation entry, then hiding it without proceeding. |
| 932 TEST_F(TabContentsTest, | 951 TEST_F(TabContentsTest, |
| 933 ShowInterstitialFromBrowserWithNewNavigationDontProceed) { | 952 ShowInterstitialFromBrowserWithNewNavigationDontProceed) { |
| 934 // Navigate to a page. | 953 // Navigate to a page. |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1768 | 1787 |
| 1769 // It should have a transient entry. | 1788 // It should have a transient entry. |
| 1770 EXPECT_TRUE(other_controller.GetTransientEntry()); | 1789 EXPECT_TRUE(other_controller.GetTransientEntry()); |
| 1771 | 1790 |
| 1772 // And the interstitial should be showing. | 1791 // And the interstitial should be showing. |
| 1773 EXPECT_TRUE(other_contents->showing_interstitial_page()); | 1792 EXPECT_TRUE(other_contents->showing_interstitial_page()); |
| 1774 | 1793 |
| 1775 // And the interstitial should do a reload on don't proceed. | 1794 // And the interstitial should do a reload on don't proceed. |
| 1776 EXPECT_TRUE(other_contents->interstitial_page()->reload_on_dont_proceed()); | 1795 EXPECT_TRUE(other_contents->interstitial_page()->reload_on_dont_proceed()); |
| 1777 } | 1796 } |
| OLD | NEW |