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 "chrome/browser/prefs/pref_service.h" |
8 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
10 #include "chrome/test/base/testing_pref_service.h" | 10 #include "chrome/test/base/testing_pref_service.h" |
11 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
12 #include "content/browser/renderer_host/render_view_host.h" | 12 #include "content/browser/renderer_host/render_view_host.h" |
13 #include "content/browser/renderer_host/render_widget_host_view.h" | 13 #include "content/browser/renderer_host/render_widget_host_view.h" |
14 #include "content/browser/site_instance.h" | 14 #include "content/browser/site_instance.h" |
15 #include "content/browser/tab_contents/interstitial_page.h" | 15 #include "content/browser/tab_contents/interstitial_page.h" |
16 #include "content/browser/tab_contents/navigation_details.h" | 16 #include "content/browser/tab_contents/navigation_details.h" |
17 #include "content/browser/tab_contents/navigation_entry.h" | 17 #include "content/browser/tab_contents/navigation_entry.h" |
18 #include "content/browser/tab_contents/test_tab_contents.h" | 18 #include "content/browser/tab_contents/test_tab_contents.h" |
19 #include "content/common/view_messages.h" | 19 #include "content/common/view_messages.h" |
20 #include "content/public/browser/notification_details.h" | 20 #include "content/public/browser/notification_details.h" |
21 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
22 #include "content/public/browser/notification_source.h" | 22 #include "content/public/browser/notification_source.h" |
23 #include "content/public/common/bindings_policy.h" | 23 #include "content/public/common/bindings_policy.h" |
24 #include "content/public/common/content_constants.h" | 24 #include "content/public/common/content_constants.h" |
25 #include "content/public/common/url_constants.h" | 25 #include "content/public/common/url_constants.h" |
26 #include "content/test/test_browser_thread.h" | 26 #include "content/test/test_browser_thread.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
28 #include "ui/base/message_box_flags.h" | |
29 #include "webkit/glue/webkit_glue.h" | 28 #include "webkit/glue/webkit_glue.h" |
30 | 29 |
31 using content::BrowserThread; | 30 using content::BrowserThread; |
32 using webkit_glue::PasswordForm; | 31 using webkit_glue::PasswordForm; |
33 | 32 |
34 class TestInterstitialPage : public InterstitialPage { | 33 class TestInterstitialPage : public InterstitialPage { |
35 public: | 34 public: |
36 enum InterstitialState { | 35 enum InterstitialState { |
37 UNDECIDED = 0, // No decision taken yet. | 36 UNDECIDED = 0, // No decision taken yet. |
38 OKED, // Proceed was called. | 37 OKED, // Proceed was called. |
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1670 TestInterstitialPageStateGuard state_guard(interstitial); | 1669 TestInterstitialPageStateGuard state_guard(interstitial); |
1671 interstitial->Show(); | 1670 interstitial->Show(); |
1672 interstitial->TestDidNavigate(1, kGURL); | 1671 interstitial->TestDidNavigate(1, kGURL); |
1673 | 1672 |
1674 // While the interstitial is showing, let's simulate the hidden page | 1673 // While the interstitial is showing, let's simulate the hidden page |
1675 // attempting to show a JS message. | 1674 // attempting to show a JS message. |
1676 IPC::Message* dummy_message = new IPC::Message; | 1675 IPC::Message* dummy_message = new IPC::Message; |
1677 bool did_suppress_message = false; | 1676 bool did_suppress_message = false; |
1678 contents()->RunJavaScriptMessage(contents()->render_view_host(), | 1677 contents()->RunJavaScriptMessage(contents()->render_view_host(), |
1679 ASCIIToUTF16("This is an informative message"), ASCIIToUTF16("OK"), | 1678 ASCIIToUTF16("This is an informative message"), ASCIIToUTF16("OK"), |
1680 kGURL, ui::MessageBoxFlags::kIsJavascriptAlert, dummy_message, | 1679 kGURL, ui::JAVASCRIPT_MESSAGE_TYPE_ALERT, dummy_message, |
1681 &did_suppress_message); | 1680 &did_suppress_message); |
1682 EXPECT_TRUE(did_suppress_message); | 1681 EXPECT_TRUE(did_suppress_message); |
1683 } | 1682 } |
1684 | 1683 |
1685 // Makes sure that if the source passed to CopyStateFromAndPrune has an | 1684 // Makes sure that if the source passed to CopyStateFromAndPrune has an |
1686 // interstitial it isn't copied over to the destination. | 1685 // interstitial it isn't copied over to the destination. |
1687 TEST_F(TabContentsTest, CopyStateFromAndPruneSourceInterstitial) { | 1686 TEST_F(TabContentsTest, CopyStateFromAndPruneSourceInterstitial) { |
1688 // Navigate to a page. | 1687 // Navigate to a page. |
1689 GURL url1("http://www.google.com"); | 1688 GURL url1("http://www.google.com"); |
1690 rvh()->SendNavigate(1, url1); | 1689 rvh()->SendNavigate(1, url1); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1768 | 1767 |
1769 // It should have a transient entry. | 1768 // It should have a transient entry. |
1770 EXPECT_TRUE(other_controller.GetTransientEntry()); | 1769 EXPECT_TRUE(other_controller.GetTransientEntry()); |
1771 | 1770 |
1772 // And the interstitial should be showing. | 1771 // And the interstitial should be showing. |
1773 EXPECT_TRUE(other_contents->showing_interstitial_page()); | 1772 EXPECT_TRUE(other_contents->showing_interstitial_page()); |
1774 | 1773 |
1775 // And the interstitial should do a reload on don't proceed. | 1774 // And the interstitial should do a reload on don't proceed. |
1776 EXPECT_TRUE(other_contents->interstitial_page()->reload_on_dont_proceed()); | 1775 EXPECT_TRUE(other_contents->interstitial_page()->reload_on_dont_proceed()); |
1777 } | 1776 } |
OLD | NEW |