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

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

Issue 1164873003: Show origin for hosted apps that navigate away from their start origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
Index: chrome/browser/ui/extensions/hosted_app_browsertest.cc
diff --git a/chrome/browser/ui/extensions/bookmark_app_browsertest.cc b/chrome/browser/ui/extensions/hosted_app_browsertest.cc
similarity index 80%
rename from chrome/browser/ui/extensions/bookmark_app_browsertest.cc
rename to chrome/browser/ui/extensions/hosted_app_browsertest.cc
index 186029b026c89fdaefa84bdb1f604276ca44cee4..8f21fc0ce74480f0ff30a4039cde6eb0430f68bb 100644
--- a/chrome/browser/ui/extensions/bookmark_app_browsertest.cc
+++ b/chrome/browser/ui/extensions/hosted_app_browsertest.cc
@@ -14,7 +14,7 @@
#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/extensions/app_launch_params.h"
#include "chrome/browser/ui/extensions/application_launch.h"
-#include "chrome/browser/ui/extensions/bookmark_app_browser_controller.h"
+#include "chrome/browser/ui/extensions/hosted_app_browser_controller.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_switches.h"
@@ -28,7 +28,7 @@
using content::WebContents;
using extensions::Extension;
-typedef ExtensionBrowserTest BookmarkAppTest;
+typedef ExtensionBrowserTest HostedAppTest;
namespace {
@@ -40,13 +40,13 @@ void NavigateAndCheckForLocationBar(Browser* browser,
GURL url(url_string);
ui_test_utils::NavigateToURL(browser, url);
EXPECT_EQ(expected_visibility,
- browser->bookmark_app_controller()->ShouldShowLocationBar());
+ browser->hosted_app_controller()->ShouldShowLocationBar());
}
} // namespace
// Check that the location bar is shown correctly for HTTP bookmark apps.
-IN_PROC_BROWSER_TEST_F(BookmarkAppTest,
+IN_PROC_BROWSER_TEST_F(HostedAppTest,
ShouldShowLocationBarForHTTPBookmarkApp) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableNewBookmarkApps);
@@ -91,7 +91,7 @@ IN_PROC_BROWSER_TEST_F(BookmarkAppTest,
http_app_browser, "http://www.example.com/blah", false);
// Navigate to the https version of the site; the location bar should
- // be hidden for both browsers.
+ // be hidden.
NavigateAndCheckForLocationBar(
http_app_browser, "https://www.example.com/blah", false);
@@ -105,7 +105,7 @@ IN_PROC_BROWSER_TEST_F(BookmarkAppTest,
}
// Check that the location bar is shown correctly for HTTPS bookmark apps.
-IN_PROC_BROWSER_TEST_F(BookmarkAppTest,
+IN_PROC_BROWSER_TEST_F(HostedAppTest,
ShouldShowLocationBarForHTTPSBookmarkApp) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableNewBookmarkApps);
@@ -164,10 +164,64 @@ IN_PROC_BROWSER_TEST_F(BookmarkAppTest,
https_app_browser, "https://www.example.com/blah", false);
}
+// Check that the location bar is shown correctly for normal hosted apps.
+IN_PROC_BROWSER_TEST_F(HostedAppTest,
+ ShouldShowLocationBarForHostedApp) {
+ ASSERT_TRUE(test_server()->Start());
+
+ // Load a hosted app.
+ const Extension* hosted_app = InstallExtension(
+ test_data_dir_.AppendASCII("app/"), 1, extensions::Manifest::INTERNAL);
+ ASSERT_TRUE(hosted_app);
+
+ // Launch it in a window.
+ WebContents* app_window = OpenApplication(AppLaunchParams(
+ browser()->profile(), hosted_app,
+ extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW,
+ extensions::SOURCE_TEST));
+ ASSERT_TRUE(app_window);
+
+ // Find the new browser.
+ Browser* app_browser = NULL;
+ for (chrome::BrowserIterator it; !it.done(); it.Next()) {
+ std::string app_id =
+ web_app::GetExtensionIdFromApplicationName((*it)->app_name());
+ if (*it == browser()) {
+ continue;
+ } else if (app_id == hosted_app->id()) {
+ app_browser = *it;
+ }
+ }
+ ASSERT_TRUE(app_browser);
+ ASSERT_TRUE(app_browser != browser());
+
+ // Navigate to the app's launch page; the location bar should be hidden.
+ NavigateAndCheckForLocationBar(
+ app_browser, "http://www.example.com/empty.html", false);
+
+ // Navigate to another page on the same origin; the location bar should still
+ // hidden.
+ NavigateAndCheckForLocationBar(
+ app_browser, "http://www.example.com/blah", false);
+
felt 2015/06/04 19:21:34 maybe check the subdomain properties you care abou
benwells 2015/06/05 01:20:44 Done.
+ // Navigate to the https version of the site; the location bar should
+ // be hidden.
+ NavigateAndCheckForLocationBar(
+ app_browser, "https://www.example.com/blah", false);
+
+ // Navigate to different origin; the location bar should now be visible.
+ NavigateAndCheckForLocationBar(
+ app_browser, "http://www.foo.com/blah", true);
+
+ // Navigate back to the app's origin; the location bar should now be hidden.
+ NavigateAndCheckForLocationBar(
+ app_browser, "http://www.example.com/blah", false);
+}
+
// Open a normal browser window, a hosted app window, a legacy packaged app
// window and a dev tools window, and check that the web app frame feature is
// supported correctly.
-IN_PROC_BROWSER_TEST_F(BookmarkAppTest, ShouldUseWebAppFrame) {
+IN_PROC_BROWSER_TEST_F(HostedAppTest, ShouldUseWebAppFrame) {
ASSERT_TRUE(test_server()->Start());
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableWebAppFrame);

Powered by Google App Engine
This is Rietveld 408576698