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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/path_service.h" 5 #include "base/path_service.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/apps/app_browsertest_util.h" 9 #include "chrome/browser/apps/app_browsertest_util.h"
9 #include "chrome/browser/chrome_content_browser_client.h" 10 #include "chrome/browser/chrome_content_browser_client.h"
10 #include "chrome/browser/prerender/prerender_link_manager.h" 11 #include "chrome/browser/prerender/prerender_link_manager.h"
11 #include "chrome/browser/prerender/prerender_link_manager_factory.h" 12 #include "chrome/browser/prerender/prerender_link_manager_factory.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" 14 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
14 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti l.h" 15 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti l.h"
15 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" 16 #include "chrome/browser/task_manager/task_manager_browsertest_util.h"
16 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_dialogs.h" 18 #include "chrome/browser/ui/browser_dialogs.h"
(...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 EXPECT_TRUE( 1825 EXPECT_TRUE(
1825 content::ExecuteScript( 1826 content::ExecuteScript(
1826 embedder_web_contents, 1827 embedder_web_contents,
1827 base::StringPrintf("startAllowTest('%s')", 1828 base::StringPrintf("startAllowTest('%s')",
1828 test_name.c_str()))); 1829 test_name.c_str())));
1829 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); 1830 ASSERT_TRUE(done_listener.WaitUntilSatisfied());
1830 1831
1831 mock->WaitForRequestMediaPermission(); 1832 mock->WaitForRequestMediaPermission();
1832 } 1833 }
1833 1834
1835 IN_PROC_BROWSER_TEST_F(WebViewTest, OpenURLFromTab_CurrentTab_Abort) {
1836 LoadAppWithGuest("web_view/simple");
1837
1838 // Verify that OpenURLFromTab with a window disposition of CURRENT_TAB will
1839 // navigate the current <webview>.
1840 ExtensionTestMessageListener load_listener("WebViewTest.LOADSTOP", false);
1841
1842 // Navigating to a file URL is forbidden inside a <webview>.
1843 content::OpenURLParams params(GURL("file://foo"),
1844 content::Referrer(),
1845 CURRENT_TAB,
1846 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
1847 true /* is_renderer_initiated */);
1848 GetGuestWebContents()->GetDelegate()->OpenURLFromTab(
1849 GetGuestWebContents(), params);
1850
1851 ASSERT_TRUE(load_listener.WaitUntilSatisfied());
1852
1853 // Verify that the <webview> ends up at about:blank.
1854 EXPECT_EQ(GURL(url::kAboutBlankURL),
1855 GetGuestWebContents()->GetLastCommittedURL());
1856 }
1857
1858 IN_PROC_BROWSER_TEST_F(WebViewTest, OpenURLFromTab_NewWindow_Abort) {
1859 LoadAppWithGuest("web_view/simple");
1860
1861 // Verify that OpenURLFromTab with a window disposition of NEW_BACKGROUND_TAB
1862 // will trigger the <webview>'s New Window API.
1863 ExtensionTestMessageListener new_window_listener(
1864 "WebViewTest.NEWWINDOW", false);
1865
1866 // Navigating to a file URL is forbidden inside a <webview>.
1867 content::OpenURLParams params(GURL("file://foo"),
1868 content::Referrer(),
1869 NEW_BACKGROUND_TAB,
1870 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
1871 true /* is_renderer_initiated */);
1872 GetGuestWebContents()->GetDelegate()->OpenURLFromTab(
1873 GetGuestWebContents(), params);
1874
1875 ASSERT_TRUE(new_window_listener.WaitUntilSatisfied());
1876
1877 // Verify that a new guest was created.
1878 content::WebContents* new_guest_web_contents =
1879 GetGuestViewManager()->GetLastGuestCreated();
1880 EXPECT_NE(GetGuestWebContents(), new_guest_web_contents);
1881
1882 // Verify that the new <webview> guest ends up at about:blank.
1883 EXPECT_EQ(GURL(url::kAboutBlankURL),
1884 new_guest_web_contents->GetLastCommittedURL());
1885 }
1886
1887 // This test executes the context menu command 'LanguageSettings' which will
1888 // load chrome://settings/languages in a browser window. This is a browser-
1889 // initiated operation and so we expect this to succeed if the embedder is
1890 // allowed to perform the operation.
1891 IN_PROC_BROWSER_TEST_F(WebViewTest, ContextMenuLanguageSettings) {
1892 LoadAppWithGuest("web_view/context_menus/basic");
1893
1894 content::WebContents* guest_web_contents = GetGuestWebContents();
1895 content::WebContents* embedder = GetEmbedderWebContents();
1896 ASSERT_TRUE(embedder);
1897
1898 // Create and build our test context menu.
1899 content::WebContentsAddedObserver web_contents_added_observer;
1900
1901 GURL page_url("http://www.google.com");
1902 scoped_ptr<TestRenderViewContextMenu> menu(TestRenderViewContextMenu::Create(
1903 guest_web_contents, page_url, GURL(), GURL()));
1904 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS, 0);
1905
1906 content::WebContents* new_contents =
1907 web_contents_added_observer.GetWebContents();
1908
1909 // Verify that a new WebContents has been created that is at the Language
1910 // Settings page.
1911 EXPECT_EQ(GURL("chrome://settings/languages"),
1912 new_contents->GetVisibleURL());
1913 }
1914
1834 IN_PROC_BROWSER_TEST_F(WebViewTest, ContextMenusAPI_Basic) { 1915 IN_PROC_BROWSER_TEST_F(WebViewTest, ContextMenusAPI_Basic) {
1835 LoadAppWithGuest("web_view/context_menus/basic"); 1916 LoadAppWithGuest("web_view/context_menus/basic");
1836 1917
1837 content::WebContents* guest_web_contents = GetGuestWebContents(); 1918 content::WebContents* guest_web_contents = GetGuestWebContents();
1838 content::WebContents* embedder = GetEmbedderWebContents(); 1919 content::WebContents* embedder = GetEmbedderWebContents();
1839 ASSERT_TRUE(embedder); 1920 ASSERT_TRUE(embedder);
1840 1921
1841 // 1. Basic property test. 1922 // 1. Basic property test.
1842 ExecuteScriptWaitForTitle(embedder, "checkProperties()", "ITEM_CHECKED"); 1923 ExecuteScriptWaitForTitle(embedder, "checkProperties()", "ITEM_CHECKED");
1843 1924
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 #endif 2030 #endif
1950 2031
1951 // Flaky on Windows. http://crbug.com/303966 2032 // Flaky on Windows. http://crbug.com/303966
1952 #if defined(OS_WIN) 2033 #if defined(OS_WIN)
1953 #define MAYBE_TearDownTest DISABLED_TearDownTest 2034 #define MAYBE_TearDownTest DISABLED_TearDownTest
1954 #else 2035 #else
1955 #define MAYBE_TearDownTest TearDownTest 2036 #define MAYBE_TearDownTest TearDownTest
1956 #endif 2037 #endif
1957 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_TearDownTest) { 2038 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_TearDownTest) {
1958 const extensions::Extension* extension = 2039 const extensions::Extension* extension =
1959 LoadAndLaunchPlatformApp("web_view/teardown", "guest-loaded"); 2040 LoadAndLaunchPlatformApp("web_view/simple", "WebViewTest.LAUNCHED");
1960 extensions::AppWindow* window = NULL; 2041 extensions::AppWindow* window = NULL;
1961 if (!GetAppWindowCount()) 2042 if (!GetAppWindowCount())
1962 window = CreateAppWindow(extension); 2043 window = CreateAppWindow(extension);
1963 else 2044 else
1964 window = GetFirstAppWindow(); 2045 window = GetFirstAppWindow();
1965 CloseAppWindow(window); 2046 CloseAppWindow(window);
1966 2047
1967 // Load the app again. 2048 // Load the app again.
1968 LoadAndLaunchPlatformApp("web_view/teardown", "guest-loaded"); 2049 LoadAndLaunchPlatformApp("web_view/simple", "WebViewTest.LAUNCHED");
1969 } 2050 }
1970 2051
1971 // In following GeolocationAPIEmbedderHasNoAccess* tests, embedder (i.e. the 2052 // In following GeolocationAPIEmbedderHasNoAccess* tests, embedder (i.e. the
1972 // platform app) does not have geolocation permission for this test. 2053 // platform app) does not have geolocation permission for this test.
1973 // No matter what the API does, geolocation permission would be denied. 2054 // No matter what the API does, geolocation permission would be denied.
1974 // Note that the test name prefix must be "GeolocationAPI". 2055 // Note that the test name prefix must be "GeolocationAPI".
1975 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasNoAccessAllow) { 2056 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasNoAccessAllow) {
1976 TestHelper("testDenyDenies", 2057 TestHelper("testDenyDenies",
1977 "web_view/geolocation/embedder_has_no_permission", 2058 "web_view/geolocation/embedder_has_no_permission",
1978 NEEDS_TEST_SERVER); 2059 NEEDS_TEST_SERVER);
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
2475 // http://crbug.com/403325 2556 // http://crbug.com/403325
2476 #define MAYBE_WebViewInBackgroundPage \ 2557 #define MAYBE_WebViewInBackgroundPage \
2477 DISABLED_WebViewInBackgroundPage 2558 DISABLED_WebViewInBackgroundPage
2478 #else 2559 #else
2479 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage 2560 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage
2480 #endif 2561 #endif
2481 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) { 2562 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) {
2482 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background")) 2563 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background"))
2483 << message_; 2564 << message_;
2484 } 2565 }
OLDNEW
« 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