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

Unified Diff: chrome/browser/ui/extensions/hosted_app_browsertest.cc

Issue 2891633002: Add a test for subframes redirecting to hosted app URLs. (Closed)
Patch Set: Created 3 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/extensions/hosted_app_browsertest.cc
diff --git a/chrome/browser/ui/extensions/hosted_app_browsertest.cc b/chrome/browser/ui/extensions/hosted_app_browsertest.cc
index 6e3c531d73a7c858b41f65ee023f2442e20626a6..12792d2357778d477c5245aebcf5d0bc78b2f495 100644
--- a/chrome/browser/ui/extensions/hosted_app_browsertest.cc
+++ b/chrome/browser/ui/extensions/hosted_app_browsertest.cc
@@ -99,6 +99,11 @@ class HostedAppTest : public ExtensionBrowserTest {
ASSERT_TRUE(app_browser_ != browser());
}
+ void SetUpOnMainThread() override {
+ ExtensionBrowserTest::SetUpOnMainThread();
+ host_resolver()->AddRule("*", "127.0.0.1");
+ }
+
Browser* app_browser_;
private:
@@ -198,6 +203,52 @@ IN_PROC_BROWSER_TEST_F(HostedAppTest,
app_browser_, "http://www.foo.com/blah", true);
}
+// Check that a subframe on a regular web page can navigate to a URL that
+// redirects to a hosted app. https://crbug.com/721949.
+IN_PROC_BROWSER_TEST_F(HostedAppTest, SubframeRedirectsToHostedApp) {
+ ASSERT_TRUE(embedded_test_server()->Start());
+
+ // Set up an app which covers app.com URLs.
+ GURL app_url = embedded_test_server()->GetURL("app.com", "/title1.html");
+ extensions::TestExtensionDir test_app_dir;
+ test_app_dir.WriteManifest(base::StringPrintf(
+ R"( { "name": "Hosted App",
+ "version": "1",
+ "manifest_version": 2,
+ "app": {
+ "launch": {
+ "web_url": "%s"
+ },
+ "urls": ["*://app.com/"]
+ }
+ } )",
+ app_url.spec().c_str()));
+ SetupApp(test_app_dir.UnpackedPath(), false);
+
+ // Navigate a regular tab to a page with a subframe.
+ GURL url = embedded_test_server()->GetURL("foo.com", "/iframe.html");
+ content::WebContents* tab =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ ui_test_utils::NavigateToURL(browser(), url);
+
+ // Navigate the subframe to a URL that redirects to a URL in the hosted app's
+ // web extent.
+ GURL redirect_url = embedded_test_server()->GetURL(
+ "bar.com", "/server-redirect?" + app_url.spec());
+ EXPECT_TRUE(NavigateIframeToURL(tab, "test", redirect_url));
+
+ // Ensure that the frame navigated successfully and that it has correct
+ // content.
+ content::RenderFrameHost* subframe =
+ content::ChildFrameAt(tab->GetMainFrame(), 0);
+ EXPECT_EQ(app_url, subframe->GetLastCommittedURL());
+ std::string result;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ subframe, "window.domAutomationController.send(document.body.innerText);",
+ &result));
+ EXPECT_EQ("This page has no title.", result);
+}
+
class HostedAppVsTdiTest : public HostedAppTest {
public:
HostedAppVsTdiTest() {}
@@ -206,7 +257,6 @@ class HostedAppVsTdiTest : public HostedAppTest {
void SetUpOnMainThread() override {
scoped_feature_list_.InitAndEnableFeature(features::kTopDocumentIsolation);
HostedAppTest::SetUpOnMainThread();
- host_resolver()->AddRule("*", "127.0.0.1");
ASSERT_TRUE(embedded_test_server()->Start());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698