| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/signin/signin_promo.h" | 5 #include "chrome/browser/signin/signin_promo.h" |
| 6 #include "chrome/browser/ui/browser.h" | 6 #include "chrome/browser/ui/browser.h" |
| 7 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 7 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| 11 #include "chrome/test/base/test_chrome_web_ui_controller_factory.h" | 11 #include "chrome/test/base/test_chrome_web_ui_controller_factory.h" |
| 12 #include "chrome/test/base/testing_browser_process.h" | 12 #include "chrome/test/base/testing_browser_process.h" |
| 13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
| 14 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
| 15 #include "content/public/browser/session_storage_namespace.h" | 15 #include "content/public/browser/session_storage_namespace.h" |
| 16 #include "content/public/browser/storage_partition.h" | 16 #include "content/public/browser/storage_partition.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/browser/web_ui_controller.h" | 18 #include "content/public/browser/web_ui_controller.h" |
| 19 #include "content/public/common/url_constants.h" | 19 #include "content/public/common/url_constants.h" |
| 20 #include "content/public/test/browser_test_utils.h" | 20 #include "content/public/test/browser_test_utils.h" |
| 21 #include "net/base/url_util.h" |
| 22 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 21 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 25 |
| 24 using ::testing::_; | 26 using ::testing::_; |
| 25 | 27 |
| 26 namespace { | 28 namespace { |
| 27 | 29 |
| 28 struct ContentInfo { | 30 struct ContentInfo { |
| 29 ContentInfo(int pid, content::StoragePartition* storage_partition) { | 31 ContentInfo(int pid, content::StoragePartition* storage_partition) { |
| 30 this->pid = pid; | 32 this->pid = pid; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 CURRENT_TAB); | 118 CURRENT_TAB); |
| 117 | 119 |
| 118 ASSERT_EQ(info1.pid, info2.pid); | 120 ASSERT_EQ(info1.pid, info2.pid); |
| 119 ASSERT_NE(info1.pid, info3.pid); | 121 ASSERT_NE(info1.pid, info3.pid); |
| 120 } | 122 } |
| 121 | 123 |
| 122 class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest { | 124 class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest { |
| 123 public: | 125 public: |
| 124 FooWebUIProvider& foo_provider() { return foo_provider_; } | 126 FooWebUIProvider& foo_provider() { return foo_provider_; } |
| 125 | 127 |
| 128 void WaitUntilUIReady() { |
| 129 ASSERT_TRUE(content::ExecuteScript( |
| 130 browser()->tab_strip_model()->GetActiveWebContents(), |
| 131 "if (!inline.login.getAuthExtHost())" |
| 132 " inline.login.initialize();" |
| 133 "var handler = function() {" |
| 134 " window.domAutomationController.setAutomationId(0);" |
| 135 " window.domAutomationController.send('ready');" |
| 136 "};" |
| 137 "if (inline.login.isAuthReady())" |
| 138 " handler();" |
| 139 "else" |
| 140 " inline.login.getAuthExtHost().addEventListener('ready', handler);")); |
| 141 |
| 142 content::DOMMessageQueue message_queue; |
| 143 std::string message; |
| 144 // TODO(guohui): this timeouts on trybot sometimes. |
| 145 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
| 146 EXPECT_EQ("\"ready\"", message); |
| 147 } |
| 148 |
| 126 private: | 149 private: |
| 127 virtual void SetUpOnMainThread() OVERRIDE { | 150 virtual void SetUpOnMainThread() OVERRIDE { |
| 128 content::WebUIControllerFactory::UnregisterFactoryForTesting( | 151 content::WebUIControllerFactory::UnregisterFactoryForTesting( |
| 129 ChromeWebUIControllerFactory::GetInstance()); | 152 ChromeWebUIControllerFactory::GetInstance()); |
| 130 test_factory_.reset(new TestChromeWebUIControllerFactory); | 153 test_factory_.reset(new TestChromeWebUIControllerFactory); |
| 131 content::WebUIControllerFactory::RegisterFactory(test_factory_.get()); | 154 content::WebUIControllerFactory::RegisterFactory(test_factory_.get()); |
| 132 test_factory_->AddFactoryOverride( | 155 test_factory_->AddFactoryOverride( |
| 133 GURL(kFooWebUIURL).host(), &foo_provider_); | 156 GURL(kFooWebUIURL).host(), &foo_provider_); |
| 134 } | 157 } |
| 135 | 158 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 154 } | 177 } |
| 155 | 178 |
| 156 // Make sure that the foo webui handler does not get created when we try to | 179 // Make sure that the foo webui handler does not get created when we try to |
| 157 // load it inside the iframe of the login ui. | 180 // load it inside the iframe of the login ui. |
| 158 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, NoWebUIInIframe) { | 181 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, NoWebUIInIframe) { |
| 159 GURL url = signin::GetPromoURL(signin::SOURCE_START_PAGE, false). | 182 GURL url = signin::GetPromoURL(signin::SOURCE_START_PAGE, false). |
| 160 Resolve("?source=0&frameUrl=chrome://foo"); | 183 Resolve("?source=0&frameUrl=chrome://foo"); |
| 161 EXPECT_CALL(foo_provider(), NewWebUI(_, _)).Times(0); | 184 EXPECT_CALL(foo_provider(), NewWebUI(_, _)).Times(0); |
| 162 ui_test_utils::NavigateToURL(browser(), url); | 185 ui_test_utils::NavigateToURL(browser(), url); |
| 163 } | 186 } |
| 187 |
| 188 // Make sure that the gaia iframe cannot trigger top-frame navigation. |
| 189 // TODO(guohui): flaky on trybot crbug/364759. |
| 190 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, |
| 191 DISABLED_TopFrameNavigationDisallowed) { |
| 192 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 193 // Loads into gaia iframe a web page that attempts to deframe on load. |
| 194 GURL deframe_url(embedded_test_server()->GetURL("/login/deframe.html")); |
| 195 GURL url(net::AppendOrReplaceQueryParameter( |
| 196 signin::GetPromoURL(signin::SOURCE_START_PAGE, false), |
| 197 "frameUrl", deframe_url.spec())); |
| 198 ui_test_utils::NavigateToURL(browser(), url); |
| 199 WaitUntilUIReady(); |
| 200 |
| 201 content::WebContents* contents = |
| 202 browser()->tab_strip_model()->GetActiveWebContents(); |
| 203 EXPECT_EQ(url, contents->GetVisibleURL()); |
| 204 |
| 205 content::NavigationController& controller = contents->GetController(); |
| 206 EXPECT_TRUE(controller.GetPendingEntry() == NULL); |
| 207 } |
| OLD | NEW |