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

Unified Diff: chrome/browser/apps/guest_view/web_view_browsertest.cc

Issue 890183002: Allow Signin page to open other chrome:// URLs if login content in <webview> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 5 years, 10 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 | chrome/test/data/extensions/platform_apps/web_view/simple/main.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/apps/guest_view/web_view_browsertest.cc
diff --git a/chrome/browser/apps/guest_view/web_view_browsertest.cc b/chrome/browser/apps/guest_view/web_view_browsertest.cc
index a7ef8be795ec7260c255e11b463a2f9916d3ed6a..bec47cb357e88a5a1774efada048abe70e5b2199 100644
--- a/chrome/browser/apps/guest_view/web_view_browsertest.cc
+++ b/chrome/browser/apps/guest_view/web_view_browsertest.cc
@@ -5,6 +5,7 @@
#include "base/path_service.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/apps/app_browsertest_util.h"
#include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/browser/prerender/prerender_link_manager.h"
@@ -1831,6 +1832,86 @@ void WebViewTest::MediaAccessAPIAllowTestHelper(const std::string& test_name) {
mock->WaitForRequestMediaPermission();
}
+IN_PROC_BROWSER_TEST_F(WebViewTest, OpenURLFromTab_CurrentTab_Abort) {
+ LoadAppWithGuest("web_view/simple");
+
+ // Verify that OpenURLFromTab with a window disposition of CURRENT_TAB will
+ // navigate the current <webview>.
+ ExtensionTestMessageListener load_listener("WebViewTest.LOADSTOP", false);
+
+ // Navigating to a file URL is forbidden inside a <webview>.
+ content::OpenURLParams params(GURL("file://foo"),
+ content::Referrer(),
+ CURRENT_TAB,
+ ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
+ true /* is_renderer_initiated */);
+ GetGuestWebContents()->GetDelegate()->OpenURLFromTab(
+ GetGuestWebContents(), params);
+
+ ASSERT_TRUE(load_listener.WaitUntilSatisfied());
+
+ // Verify that the <webview> ends up at about:blank.
+ EXPECT_EQ(GURL(url::kAboutBlankURL),
+ GetGuestWebContents()->GetLastCommittedURL());
+}
+
+IN_PROC_BROWSER_TEST_F(WebViewTest, OpenURLFromTab_NewWindow_Abort) {
+ LoadAppWithGuest("web_view/simple");
+
+ // Verify that OpenURLFromTab with a window disposition of NEW_BACKGROUND_TAB
+ // will trigger the <webview>'s New Window API.
+ ExtensionTestMessageListener new_window_listener(
+ "WebViewTest.NEWWINDOW", false);
+
+ // Navigating to a file URL is forbidden inside a <webview>.
+ content::OpenURLParams params(GURL("file://foo"),
+ content::Referrer(),
+ NEW_BACKGROUND_TAB,
+ ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
+ true /* is_renderer_initiated */);
+ GetGuestWebContents()->GetDelegate()->OpenURLFromTab(
+ GetGuestWebContents(), params);
+
+ ASSERT_TRUE(new_window_listener.WaitUntilSatisfied());
+
+ // Verify that a new guest was created.
+ content::WebContents* new_guest_web_contents =
+ GetGuestViewManager()->GetLastGuestCreated();
+ EXPECT_NE(GetGuestWebContents(), new_guest_web_contents);
+
+ // Verify that the new <webview> guest ends up at about:blank.
+ EXPECT_EQ(GURL(url::kAboutBlankURL),
+ new_guest_web_contents->GetLastCommittedURL());
+}
+
+// This test executes the context menu command 'LanguageSettings' which will
+// load chrome://settings/languages in a browser window. This is a browser-
+// initiated operation and so we expect this to succeed if the embedder is
+// allowed to perform the operation.
+IN_PROC_BROWSER_TEST_F(WebViewTest, ContextMenuLanguageSettings) {
+ LoadAppWithGuest("web_view/context_menus/basic");
+
+ content::WebContents* guest_web_contents = GetGuestWebContents();
+ content::WebContents* embedder = GetEmbedderWebContents();
+ ASSERT_TRUE(embedder);
+
+ // Create and build our test context menu.
+ content::WebContentsAddedObserver web_contents_added_observer;
+
+ GURL page_url("http://www.google.com");
+ scoped_ptr<TestRenderViewContextMenu> menu(TestRenderViewContextMenu::Create(
+ guest_web_contents, page_url, GURL(), GURL()));
+ menu->ExecuteCommand(IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS, 0);
+
+ content::WebContents* new_contents =
+ web_contents_added_observer.GetWebContents();
+
+ // Verify that a new WebContents has been created that is at the Language
+ // Settings page.
+ EXPECT_EQ(GURL("chrome://settings/languages"),
+ new_contents->GetVisibleURL());
+}
+
IN_PROC_BROWSER_TEST_F(WebViewTest, ContextMenusAPI_Basic) {
LoadAppWithGuest("web_view/context_menus/basic");
@@ -1956,7 +2037,7 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, ChromeVoxInjection) {
#endif
IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_TearDownTest) {
const extensions::Extension* extension =
- LoadAndLaunchPlatformApp("web_view/teardown", "guest-loaded");
+ LoadAndLaunchPlatformApp("web_view/simple", "WebViewTest.LAUNCHED");
extensions::AppWindow* window = NULL;
if (!GetAppWindowCount())
window = CreateAppWindow(extension);
@@ -1965,7 +2046,7 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_TearDownTest) {
CloseAppWindow(window);
// Load the app again.
- LoadAndLaunchPlatformApp("web_view/teardown", "guest-loaded");
+ LoadAndLaunchPlatformApp("web_view/simple", "WebViewTest.LAUNCHED");
}
// In following GeolocationAPIEmbedderHasNoAccess* tests, embedder (i.e. the
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/simple/main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698