Commit 8fdab620 authored by msarda's avatar msarda Committed by Commit bot

Fix loading success.html at the end of chrome://chrome-signin flow

This CL lists success.html as an webview accessible resource for
the sign-in extension.

This CL adds an exception for sign-in extension when for loading
webview accessible resources.

BUG=709117
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2831183003
Cr-Commit-Position: refs/heads/master@{#467739}
parent 04181130
......@@ -865,6 +865,33 @@ IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest, NoWebUIInIframe) {
ui_test_utils::NavigateToURL(browser(), url);
}
// Make sure that "success.html" can be loaded by chrome://chrome-signin.
// http://crbug.com/709117
IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest,
LoadSuccessContinueURL) {
ui_test_utils::NavigateToURL(browser(), GetSigninPromoURL());
WaitUntilUIReady(browser());
const std::string success_url =
GaiaUrls::GetInstance()->signin_completed_continue_url().spec();
const char* kLoadSuccessPageScript =
"var handler = function(e) {"
" if (e.url == '%s') {"
" window.domAutomationController.send('success_page_loaded');"
" }"
"};"
"var extension_webview = inline.login.getAuthExtHost().webview_;"
"extension_webview.addEventListener('loadcommit', handler);"
"extension_webview.src = '%s';";
std::string script = base::StringPrintf(
kLoadSuccessPageScript, success_url.c_str(), success_url.c_str());
std::string message;
ASSERT_TRUE(content::ExecuteScriptAndExtractString(
browser()->tab_strip_model()->GetActiveWebContents(), script, &message));
EXPECT_EQ("success_page_loaded", message);
}
// Make sure that the gaia iframe cannot trigger top-frame navigation.
// TODO(guohui): flaky on trybot crbug/364759.
IN_PROC_BROWSER_TEST_F(InlineLoginUISafeIframeBrowserTest,
......
......@@ -153,6 +153,22 @@ bool AllowCrossRendererResourceLoadHelper(bool is_guest,
ui::PageTransition page_transition,
bool* allowed) {
if (is_guest) {
// Exceptionally, the resource at path "/success.html" that belongs to the
// sign-in extension (loaded by chrome://chrome-signin) is accessible to
// WebViews that are not owned by that extension.
// This exception is required as in order to mark the end of the the sign-in
// flow, Gaia redirects to the following continue URL:
// "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/success.html".
//
// TODO(http://crbug.com/688565) Remove this check once the sign-in
// extension is deprecated and removed.
bool is_signin_extension =
extension && extension->id() == "mfffpogegjflfpflabcdkioaeobkgjik";
if (is_signin_extension && resource_path == "/success.html") {
*allowed = true;
return true;
}
// An extension's resources should only be accessible to WebViews owned by
// that extension.
if (owner_extension != extension) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment