| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
| 7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/extensions/extension_webnavigation_api.h" | 8 #include "chrome/browser/extensions/extension_webnavigation_api.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/test/ui_test_utils.h" | 12 #include "chrome/test/ui_test_utils.h" |
| 13 #include "content/browser/tab_contents/tab_contents.h" | 13 #include "content/browser/tab_contents/tab_contents.h" |
| 14 #include "net/base/mock_host_resolver.h" |
| 14 | 15 |
| 15 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigation) { | 16 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigation) { |
| 16 CommandLine::ForCurrentProcess()->AppendSwitch( | 17 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 17 switches::kEnableExperimentalExtensionApis); | 18 switches::kEnableExperimentalExtensionApis); |
| 18 | 19 |
| 19 FrameNavigationState::set_allow_extension_scheme(true); | 20 FrameNavigationState::set_allow_extension_scheme(true); |
| 20 | 21 |
| 21 ASSERT_TRUE( | 22 ASSERT_TRUE( |
| 22 RunExtensionSubtest("webnavigation", "test_api.html")) << message_; | 23 RunExtensionSubtest("webnavigation", "test_api.html")) << message_; |
| 23 } | 24 } |
| 24 | 25 |
| 25 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationClientRedirect) { | 26 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationClientRedirect) { |
| 26 CommandLine::ForCurrentProcess()->AppendSwitch( | 27 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 27 switches::kEnableExperimentalExtensionApis); | 28 switches::kEnableExperimentalExtensionApis); |
| 28 | 29 |
| 29 FrameNavigationState::set_allow_extension_scheme(true); | 30 FrameNavigationState::set_allow_extension_scheme(true); |
| 30 | 31 |
| 31 ASSERT_TRUE( | 32 ASSERT_TRUE( |
| 32 RunExtensionSubtest("webnavigation", "test_clientRedirect.html")) | 33 RunExtensionSubtest("webnavigation", "test_clientRedirect.html")) |
| 33 << message_; | 34 << message_; |
| 34 } | 35 } |
| 35 | 36 |
| 37 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationServerRedirect) { |
| 38 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 39 switches::kEnableExperimentalExtensionApis); |
| 40 |
| 41 FrameNavigationState::set_allow_extension_scheme(true); |
| 42 host_resolver()->AddRule("*", "127.0.0.1"); |
| 43 ASSERT_TRUE(StartTestServer()); |
| 44 |
| 45 ASSERT_TRUE( |
| 46 RunExtensionSubtest("webnavigation", "test_serverRedirect.html")) |
| 47 << message_; |
| 48 } |
| 49 |
| 36 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationForwardBack) { | 50 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationForwardBack) { |
| 37 CommandLine::ForCurrentProcess()->AppendSwitch( | 51 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 38 switches::kEnableExperimentalExtensionApis); | 52 switches::kEnableExperimentalExtensionApis); |
| 39 | 53 |
| 40 FrameNavigationState::set_allow_extension_scheme(true); | 54 FrameNavigationState::set_allow_extension_scheme(true); |
| 41 | 55 |
| 42 ASSERT_TRUE( | 56 ASSERT_TRUE( |
| 43 RunExtensionSubtest("webnavigation", "test_forwardBack.html")) | 57 RunExtensionSubtest("webnavigation", "test_forwardBack.html")) |
| 44 << message_; | 58 << message_; |
| 45 } | 59 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 GURL url = extension->GetResourceURL("userAction/a.html"); | 127 GURL url = extension->GetResourceURL("userAction/a.html"); |
| 114 | 128 |
| 115 ui_test_utils::NavigateToURL(browser(), url); | 129 ui_test_utils::NavigateToURL(browser(), url); |
| 116 | 130 |
| 117 url = extension->GetResourceURL("userAction/b.html"); | 131 url = extension->GetResourceURL("userAction/b.html"); |
| 118 // This corresponds to "Open link in new tab". | 132 // This corresponds to "Open link in new tab". |
| 119 browser()->GetSelectedTabContents()->OpenURL( | 133 browser()->GetSelectedTabContents()->OpenURL( |
| 120 url, GURL(), NEW_BACKGROUND_TAB, PageTransition::LINK); | 134 url, GURL(), NEW_BACKGROUND_TAB, PageTransition::LINK); |
| 121 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 135 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 122 } | 136 } |
| OLD | NEW |