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

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: Added a test 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
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // This class intercepts media access request from the embedder. The request 173 // This class intercepts media access request from the embedder. The request
173 // should be triggered only if the embedder API (from tests) allows the request 174 // should be triggered only if the embedder API (from tests) allows the request
174 // in Javascript. 175 // in Javascript.
175 // We do not issue the actual media request; the fact that the request reached 176 // We do not issue the actual media request; the fact that the request reached
176 // embedder's WebContents is good enough for our tests. This is also to make 177 // embedder's WebContents is good enough for our tests. This is also to make
177 // the test run successfully on trybots. 178 // the test run successfully on trybots.
178 class MockWebContentsDelegate : public content::WebContentsDelegate { 179 class MockWebContentsDelegate : public content::WebContentsDelegate {
179 public: 180 public:
180 MockWebContentsDelegate() 181 MockWebContentsDelegate()
181 : requested_(false), 182 : requested_(false),
182 checked_(false) {} 183 checked_(false),
184 open_url_from_tab_(false) {}
183 ~MockWebContentsDelegate() override {} 185 ~MockWebContentsDelegate() override {}
184 186
185 void RequestMediaAccessPermission( 187 void RequestMediaAccessPermission(
186 content::WebContents* web_contents, 188 content::WebContents* web_contents,
187 const content::MediaStreamRequest& request, 189 const content::MediaStreamRequest& request,
188 const content::MediaResponseCallback& callback) override { 190 const content::MediaResponseCallback& callback) override {
189 requested_ = true; 191 requested_ = true;
190 if (request_message_loop_runner_.get()) 192 if (request_message_loop_runner_.get())
191 request_message_loop_runner_->Quit(); 193 request_message_loop_runner_->Quit();
192 } 194 }
193 195
194 bool CheckMediaAccessPermission(content::WebContents* web_contents, 196 bool CheckMediaAccessPermission(content::WebContents* web_contents,
195 const GURL& security_origin, 197 const GURL& security_origin,
196 content::MediaStreamType type) override { 198 content::MediaStreamType type) override {
197 checked_ = true; 199 checked_ = true;
198 if (check_message_loop_runner_.get()) 200 if (check_message_loop_runner_.get())
199 check_message_loop_runner_->Quit(); 201 check_message_loop_runner_->Quit();
200 return true; 202 return true;
201 } 203 }
202 204
205 content::WebContents* OpenURLFromTab(
206 content::WebContents* source,
207 const content::OpenURLParams& params) override {
208 open_url_from_tab_ = true;
209 if (open_url_message_loop_runner_.get())
210 open_url_message_loop_runner_->Quit();
211 return NULL;
212 }
213
203 void WaitForRequestMediaPermission() { 214 void WaitForRequestMediaPermission() {
204 if (requested_) 215 if (requested_)
205 return; 216 return;
206 request_message_loop_runner_ = new content::MessageLoopRunner; 217 request_message_loop_runner_ = new content::MessageLoopRunner;
207 request_message_loop_runner_->Run(); 218 request_message_loop_runner_->Run();
208 } 219 }
209 220
210 void WaitForCheckMediaPermission() { 221 void WaitForCheckMediaPermission() {
211 if (checked_) 222 if (checked_)
212 return; 223 return;
213 check_message_loop_runner_ = new content::MessageLoopRunner; 224 check_message_loop_runner_ = new content::MessageLoopRunner;
214 check_message_loop_runner_->Run(); 225 check_message_loop_runner_->Run();
215 } 226 }
216 227
228 void WaitForOpenURLFromTab() {
229 if (open_url_from_tab_)
230 return;
231 open_url_message_loop_runner_ = new content::MessageLoopRunner;
232 open_url_message_loop_runner_->Run();
233 }
234
217 private: 235 private:
218 bool requested_; 236 bool requested_;
219 bool checked_; 237 bool checked_;
238 bool open_url_from_tab_;
220 scoped_refptr<content::MessageLoopRunner> request_message_loop_runner_; 239 scoped_refptr<content::MessageLoopRunner> request_message_loop_runner_;
221 scoped_refptr<content::MessageLoopRunner> check_message_loop_runner_; 240 scoped_refptr<content::MessageLoopRunner> check_message_loop_runner_;
241 scoped_refptr<content::MessageLoopRunner> open_url_message_loop_runner_;
222 242
223 DISALLOW_COPY_AND_ASSIGN(MockWebContentsDelegate); 243 DISALLOW_COPY_AND_ASSIGN(MockWebContentsDelegate);
224 }; 244 };
225 245
226 // This class intercepts download request from the guest. 246 // This class intercepts download request from the guest.
227 class MockDownloadWebContentsDelegate : public content::WebContentsDelegate { 247 class MockDownloadWebContentsDelegate : public content::WebContentsDelegate {
228 public: 248 public:
229 explicit MockDownloadWebContentsDelegate( 249 explicit MockDownloadWebContentsDelegate(
230 content::WebContentsDelegate* orig_delegate) 250 content::WebContentsDelegate* orig_delegate)
231 : orig_delegate_(orig_delegate), 251 : orig_delegate_(orig_delegate),
(...skipping 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 EXPECT_TRUE( 1844 EXPECT_TRUE(
1825 content::ExecuteScript( 1845 content::ExecuteScript(
1826 embedder_web_contents, 1846 embedder_web_contents,
1827 base::StringPrintf("startAllowTest('%s')", 1847 base::StringPrintf("startAllowTest('%s')",
1828 test_name.c_str()))); 1848 test_name.c_str())));
1829 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); 1849 ASSERT_TRUE(done_listener.WaitUntilSatisfied());
1830 1850
1831 mock->WaitForRequestMediaPermission(); 1851 mock->WaitForRequestMediaPermission();
1832 } 1852 }
1833 1853
1854 IN_PROC_BROWSER_TEST_F(WebViewTest, ContextMenuLanguageSettings) {
1855 LoadAppWithGuest("web_view/context_menus/basic");
1856
1857 content::WebContents* guest_web_contents = GetGuestWebContents();
1858 content::WebContents* embedder = GetEmbedderWebContents();
1859 ASSERT_TRUE(embedder);
1860 scoped_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate());
1861 embedder->SetDelegate(mock.get());
1862
1863 // Create and build our test context menu.
1864 GURL page_url("http://www.google.com");
1865 scoped_ptr<TestRenderViewContextMenu> menu(TestRenderViewContextMenu::Create(
1866 guest_web_contents, page_url, GURL(), GURL()));
1867 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS, 0);
1868
1869 mock->WaitForOpenURLFromTab();
1870 }
1871
1834 IN_PROC_BROWSER_TEST_F(WebViewTest, ContextMenusAPI_Basic) { 1872 IN_PROC_BROWSER_TEST_F(WebViewTest, ContextMenusAPI_Basic) {
1835 LoadAppWithGuest("web_view/context_menus/basic"); 1873 LoadAppWithGuest("web_view/context_menus/basic");
1836 1874
1837 content::WebContents* guest_web_contents = GetGuestWebContents(); 1875 content::WebContents* guest_web_contents = GetGuestWebContents();
1838 content::WebContents* embedder = GetEmbedderWebContents(); 1876 content::WebContents* embedder = GetEmbedderWebContents();
1839 ASSERT_TRUE(embedder); 1877 ASSERT_TRUE(embedder);
1840 1878
1841 // 1. Basic property test. 1879 // 1. Basic property test.
1842 ExecuteScriptWaitForTitle(embedder, "checkProperties()", "ITEM_CHECKED"); 1880 ExecuteScriptWaitForTitle(embedder, "checkProperties()", "ITEM_CHECKED");
1843 1881
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
2475 // http://crbug.com/403325 2513 // http://crbug.com/403325
2476 #define MAYBE_WebViewInBackgroundPage \ 2514 #define MAYBE_WebViewInBackgroundPage \
2477 DISABLED_WebViewInBackgroundPage 2515 DISABLED_WebViewInBackgroundPage
2478 #else 2516 #else
2479 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage 2517 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage
2480 #endif 2518 #endif
2481 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) { 2519 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) {
2482 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background")) 2520 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background"))
2483 << message_; 2521 << message_;
2484 } 2522 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698