Chromium Code Reviews| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 } | 156 } |
| 155 | 157 |
| 156 // Make sure that the foo webui handler does not get created when we try to | 158 // 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. | 159 // load it inside the iframe of the login ui. |
| 158 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, NoWebUIInIframe) { | 160 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, NoWebUIInIframe) { |
| 159 GURL url = signin::GetPromoURL(signin::SOURCE_START_PAGE, false). | 161 GURL url = signin::GetPromoURL(signin::SOURCE_START_PAGE, false). |
| 160 Resolve("?source=0&frameUrl=chrome://foo"); | 162 Resolve("?source=0&frameUrl=chrome://foo"); |
| 161 EXPECT_CALL(foo_provider(), NewWebUI(_, _)).Times(0); | 163 EXPECT_CALL(foo_provider(), NewWebUI(_, _)).Times(0); |
| 162 ui_test_utils::NavigateToURL(browser(), url); | 164 ui_test_utils::NavigateToURL(browser(), url); |
| 163 } | 165 } |
| 166 | |
| 167 // Make sure that the gaia iframe cannot trigger top-frame navigation. | |
| 168 IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, | |
| 169 TopFrameNavigationDisallowed) { | |
| 170 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 171 | |
| 172 // Loads into gaia iframe a web page that attempts to deframe on load. | |
| 173 GURL deframe_url(embedded_test_server()->GetURL("/login/deframe.html")); | |
| 174 GURL url(net::AppendOrReplaceQueryParameter( | |
| 175 signin::GetPromoURL(signin::SOURCE_START_PAGE, false), | |
| 176 "frameUrl", deframe_url.spec())); | |
| 177 | |
| 178 ui_test_utils::NavigateToURL(browser(), url); | |
|
xiyuan
2014/04/17 01:15:29
NavigateToURL waits for one LOAD_STOP notification
guohui
2014/04/17 12:43:26
it does, but the iframe is initially set to blank
| |
| 179 content::WebContents* contents = | |
| 180 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 181 EXPECT_EQ(url, contents->GetURL()); | |
|
Charlie Reis
2014/04/17 01:20:20
GetLastCommittedURL()
guohui
2014/04/17 12:43:26
GetLastCommittedURL returns the committed url, but
| |
| 182 | |
| 183 content::NavigationController& controller = contents->GetController(); | |
| 184 EXPECT_TRUE(controller.GetPendingEntry() == NULL); | |
|
Charlie Reis
2014/04/17 01:20:20
This doesn't seem like a sufficient check to me.
guohui
2014/04/17 12:43:26
After i added the WaitForUIReady call above, both
| |
| 185 } | |
| OLD | NEW |