Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5947)

Unified Diff: chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc

Issue 239143009: Disallow top-level navigation in gaia iframe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: undo cros change Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/inline_login/inline_login.js ('k') | chrome/test/data/login/deframe.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc
diff --git a/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc b/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc
index 35469d9ad32cbf9777c14e4624349fde28691e29..420394f3c8fd98879f5ca4ea7a1c7533542c0f7b 100644
--- a/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc
@@ -18,6 +18,8 @@
#include "content/public/browser/web_ui_controller.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test_utils.h"
+#include "net/base/url_util.h"
+#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -123,6 +125,25 @@ class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest {
public:
FooWebUIProvider& foo_provider() { return foo_provider_; }
+ void WaitUntilUIReady() {
+ // TODO(guohui): fix the logic below for CrOS.
+#if !defined(OS_CHROMEOS)
+ ASSERT_TRUE(content::ExecuteScript(
+ browser()->tab_strip_model()->GetActiveWebContents(),
+ "if (!inline.login.getAuthExtHost())"
+ " inline.login.initialize();"
+ "inline.login.getAuthExtHost().addEventListener('ready', function() {"
+ " window.domAutomationController.setAutomationId(0);"
+ " window.domAutomationController.send('ready');"
+ "});"));
+
+ content::DOMMessageQueue message_queue;
+ std::string message;
+ ASSERT_TRUE(message_queue.WaitForMessage(&message));
xiyuan 2014/04/17 15:04:15 This is could timeout when 'ready' event is alread
guohui 2014/04/17 15:08:31 it seems on cros ready event is fired upon receivi
guohui 2014/04/17 15:28:49 as clarified over chat, xiyuan is right, on deskto
+ EXPECT_EQ("\"ready\"", message);
+#endif // OS_CHROMEOS
+ }
+
private:
virtual void SetUpOnMainThread() OVERRIDE {
content::WebUIControllerFactory::UnregisterFactoryForTesting(
@@ -160,4 +181,25 @@ IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, NoWebUIInIframe) {
Resolve("?source=0&frameUrl=chrome://foo");
EXPECT_CALL(foo_provider(), NewWebUI(_, _)).Times(0);
ui_test_utils::NavigateToURL(browser(), url);
+ WaitUntilUIReady();
+}
+
+// Make sure that the gaia iframe cannot trigger top-frame navigation.
+IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest,
+ TopFrameNavigationDisallowed) {
+ ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+ // Loads into gaia iframe a web page that attempts to deframe on load.
+ GURL deframe_url(embedded_test_server()->GetURL("/login/deframe.html"));
+ GURL url(net::AppendOrReplaceQueryParameter(
+ signin::GetPromoURL(signin::SOURCE_START_PAGE, false),
+ "frameUrl", deframe_url.spec()));
+ ui_test_utils::NavigateToURL(browser(), url);
+ WaitUntilUIReady();
+
+ content::WebContents* contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ EXPECT_EQ(url, contents->GetVisibleURL());
+
+ content::NavigationController& controller = contents->GetController();
+ EXPECT_TRUE(controller.GetPendingEntry() == NULL);
}
« no previous file with comments | « chrome/browser/resources/inline_login/inline_login.js ('k') | chrome/test/data/login/deframe.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698