OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "app/message_box_flags.h" | |
8 #include "base/logging.h" | 7 #include "base/logging.h" |
9 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/browser_thread.h" | 9 #include "chrome/browser/browser_thread.h" |
11 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
12 #include "chrome/browser/prefs/pref_value_store.h" | 11 #include "chrome/browser/prefs/pref_value_store.h" |
13 #include "chrome/browser/renderer_host/render_view_host.h" | 12 #include "chrome/browser/renderer_host/render_view_host.h" |
14 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 13 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
15 #include "chrome/browser/renderer_host/site_instance.h" | 14 #include "chrome/browser/renderer_host/site_instance.h" |
16 #include "chrome/browser/renderer_host/test/test_render_view_host.h" | 15 #include "chrome/browser/renderer_host/test/test_render_view_host.h" |
17 #include "chrome/browser/tab_contents/interstitial_page.h" | 16 #include "chrome/browser/tab_contents/interstitial_page.h" |
18 #include "chrome/browser/tab_contents/navigation_controller.h" | 17 #include "chrome/browser/tab_contents/navigation_controller.h" |
19 #include "chrome/browser/tab_contents/navigation_entry.h" | 18 #include "chrome/browser/tab_contents/navigation_entry.h" |
20 #include "chrome/browser/tab_contents/test_tab_contents.h" | 19 #include "chrome/browser/tab_contents/test_tab_contents.h" |
21 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
22 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
23 #include "chrome/common/render_messages.h" | 22 #include "chrome/common/render_messages.h" |
24 #include "chrome/common/render_messages_params.h" | 23 #include "chrome/common/render_messages_params.h" |
25 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
26 #include "chrome/test/testing_pref_service.h" | 25 #include "chrome/test/testing_pref_service.h" |
27 #include "chrome/test/testing_profile.h" | 26 #include "chrome/test/testing_profile.h" |
28 #include "ipc/ipc_channel.h" | 27 #include "ipc/ipc_channel.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "ui/base/message_box_flags.h" |
30 | 30 |
31 using webkit_glue::PasswordForm; | 31 using webkit_glue::PasswordForm; |
32 | 32 |
33 static void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, | 33 static void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, |
34 int page_id, | 34 int page_id, |
35 const GURL& url) { | 35 const GURL& url) { |
36 params->page_id = page_id; | 36 params->page_id = page_id; |
37 params->url = url; | 37 params->url = url; |
38 params->referrer = GURL(); | 38 params->referrer = GURL(); |
39 params->transition = PageTransition::TYPED; | 39 params->transition = PageTransition::TYPED; |
(...skipping 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); | 1517 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); |
1518 TestInterstitialPageStateGuard state_guard(interstitial); | 1518 TestInterstitialPageStateGuard state_guard(interstitial); |
1519 interstitial->Show(); | 1519 interstitial->Show(); |
1520 interstitial->TestDidNavigate(1, kGURL); | 1520 interstitial->TestDidNavigate(1, kGURL); |
1521 | 1521 |
1522 // While the interstitial is showing, let's simulate the hidden page | 1522 // While the interstitial is showing, let's simulate the hidden page |
1523 // attempting to show a JS message. | 1523 // attempting to show a JS message. |
1524 IPC::Message* dummy_message = new IPC::Message; | 1524 IPC::Message* dummy_message = new IPC::Message; |
1525 bool did_suppress_message = false; | 1525 bool did_suppress_message = false; |
1526 contents()->RunJavaScriptMessage(L"This is an informative message", L"OK", | 1526 contents()->RunJavaScriptMessage(L"This is an informative message", L"OK", |
1527 kGURL, MessageBoxFlags::kIsJavascriptAlert, dummy_message, | 1527 kGURL, ui::MessageBoxFlags::kIsJavascriptAlert, dummy_message, |
1528 &did_suppress_message); | 1528 &did_suppress_message); |
1529 EXPECT_TRUE(did_suppress_message); | 1529 EXPECT_TRUE(did_suppress_message); |
1530 } | 1530 } |
1531 | 1531 |
1532 // Makes sure that if the source passed to CopyStateFromAndPrune has an | 1532 // Makes sure that if the source passed to CopyStateFromAndPrune has an |
1533 // interstitial it isn't copied over to the destination. | 1533 // interstitial it isn't copied over to the destination. |
1534 TEST_F(TabContentsTest, CopyStateFromAndPruneSourceInterstitial) { | 1534 TEST_F(TabContentsTest, CopyStateFromAndPruneSourceInterstitial) { |
1535 // Navigate to a page. | 1535 // Navigate to a page. |
1536 GURL url1("http://www.google.com"); | 1536 GURL url1("http://www.google.com"); |
1537 rvh()->SendNavigate(1, url1); | 1537 rvh()->SendNavigate(1, url1); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1610 | 1610 |
1611 // It should have a transient entry. | 1611 // It should have a transient entry. |
1612 EXPECT_TRUE(other_controller.GetTransientEntry()); | 1612 EXPECT_TRUE(other_controller.GetTransientEntry()); |
1613 | 1613 |
1614 // And the interstitial should be showing. | 1614 // And the interstitial should be showing. |
1615 EXPECT_TRUE(other_contents->showing_interstitial_page()); | 1615 EXPECT_TRUE(other_contents->showing_interstitial_page()); |
1616 | 1616 |
1617 // And the interstitial should do a reload on don't proceed. | 1617 // And the interstitial should do a reload on don't proceed. |
1618 EXPECT_TRUE(other_contents->interstitial_page()->reload_on_dont_proceed()); | 1618 EXPECT_TRUE(other_contents->interstitial_page()->reload_on_dont_proceed()); |
1619 } | 1619 } |
OLD | NEW |