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

Side by Side Diff: chrome/browser/extensions/web_view_browsertest.cc

Issue 17447005: <webview>: Move back, forward, canGoBack, canGoForward, go from content to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@filter_listener
Patch Set: Merge against latest changes in other CL Created 7 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/strings/stringprintf.h" 5 #include "base/strings/stringprintf.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/automation/automation_util.h" 7 #include "chrome/browser/automation/automation_util.h"
8 #include "chrome/browser/extensions/extension_test_message_listener.h" 8 #include "chrome/browser/extensions/extension_test_message_listener.h"
9 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 9 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
10 #include "chrome/browser/prerender/prerender_link_manager.h" 10 #include "chrome/browser/prerender/prerender_link_manager.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 const char* title) { 345 const char* title) {
346 string16 expected_title(ASCIIToUTF16(title)); 346 string16 expected_title(ASCIIToUTF16(title));
347 string16 error_title(ASCIIToUTF16("error")); 347 string16 error_title(ASCIIToUTF16("error"));
348 348
349 content::TitleWatcher title_watcher(web_contents, expected_title); 349 content::TitleWatcher title_watcher(web_contents, expected_title);
350 title_watcher.AlsoWaitForTitle(error_title); 350 title_watcher.AlsoWaitForTitle(error_title);
351 EXPECT_TRUE(content::ExecuteScript(web_contents, script)); 351 EXPECT_TRUE(content::ExecuteScript(web_contents, script));
352 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 352 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
353 } 353 }
354 354
355 void GeolocationTestHelper(const std::string& test_name, 355 void TestHelper(const std::string& test_type,
356 const std::string& app_location) { 356 const std::string& test_name,
357 const std::string& app_location) {
357 ASSERT_TRUE(StartTestServer()); // For serving guest pages. 358 ASSERT_TRUE(StartTestServer()); // For serving guest pages.
358 ExtensionTestMessageListener launched_listener("Launched", false); 359 ExtensionTestMessageListener launched_listener("Launched", false);
359 LoadAndLaunchPlatformApp(app_location.c_str()); 360 LoadAndLaunchPlatformApp(app_location.c_str());
360 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 361 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
361 362
362 content::WebContents* embedder_web_contents = 363 content::WebContents* embedder_web_contents =
363 GetFirstShellWindowWebContents(); 364 GetFirstShellWindowWebContents();
364 ASSERT_TRUE(embedder_web_contents); 365 ASSERT_TRUE(embedder_web_contents);
365 366
366 ExtensionTestMessageListener done_listener("DoneGeolocationTest.PASSED", 367 ExtensionTestMessageListener done_listener(
367 false); 368 base::StringPrintf("Done%sTest.PASSED", test_type.c_str()), false);
lazyboy 2013/06/22 04:29:15 Instead of sending test_type, i'd suggest passing
Fady Samuel 2013/06/25 15:46:12 Done.
368 done_listener.AlsoListenForFailureMessage("DoneGeolocationTest.FAILED"); 369 done_listener.AlsoListenForFailureMessage(
370 base::StringPrintf("Done%sTest.FAILED", test_type.c_str()));
369 EXPECT_TRUE(content::ExecuteScript( 371 EXPECT_TRUE(content::ExecuteScript(
370 embedder_web_contents, 372 embedder_web_contents,
371 base::StringPrintf("runGeolocationTest('%s')", 373 base::StringPrintf("run%sTest('%s')",
374 test_type.c_str(),
372 test_name.c_str()))); 375 test_name.c_str())));
373 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); 376 ASSERT_TRUE(done_listener.WaitUntilSatisfied());
374 } 377 }
375 378
376 content::WebContents* LoadGuest(const std::string& guest_path, 379 content::WebContents* LoadGuest(const std::string& guest_path,
377 const std::string& app_path) { 380 const std::string& app_path) {
378 GURL::Replacements replace_host; 381 GURL::Replacements replace_host;
379 std::string host_str("localhost"); // Must stay in scope with replace_host. 382 std::string host_str("localhost"); // Must stay in scope with replace_host.
380 replace_host.SetHostStr(host_str); 383 replace_host.SetHostStr(host_str);
381 384
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 ExtensionTestMessageListener second_loaded_listener("guest-loaded", false); 984 ExtensionTestMessageListener second_loaded_listener("guest-loaded", false);
982 LoadAndLaunchPlatformApp("web_view/teardown"); 985 LoadAndLaunchPlatformApp("web_view/teardown");
983 ASSERT_TRUE(second_loaded_listener.WaitUntilSatisfied()); 986 ASSERT_TRUE(second_loaded_listener.WaitUntilSatisfied());
984 } 987 }
985 988
986 // In following GeolocationAPIEmbedderHasNoAccess* tests, embedder (i.e. the 989 // In following GeolocationAPIEmbedderHasNoAccess* tests, embedder (i.e. the
987 // platform app) does not have geolocation permission for this test. 990 // platform app) does not have geolocation permission for this test.
988 // No matter what the API does, geolocation permission would be denied. 991 // No matter what the API does, geolocation permission would be denied.
989 // Note that the test name prefix must be "GeolocationAPI". 992 // Note that the test name prefix must be "GeolocationAPI".
990 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasNoAccessAllow) { 993 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasNoAccessAllow) {
991 GeolocationTestHelper("testDenyDenies", 994 TestHelper("Geolocation", "testDenyDenies",
992 "web_view/geolocation/embedder_has_no_permission"); 995 "web_view/geolocation/embedder_has_no_permission");
993 } 996 }
994 997
995 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasNoAccessDeny) { 998 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasNoAccessDeny) {
996 GeolocationTestHelper("testDenyDenies", 999 TestHelper("Geolocation", "testDenyDenies",
997 "web_view/geolocation/embedder_has_no_permission"); 1000 "web_view/geolocation/embedder_has_no_permission");
998 } 1001 }
999 1002
1000 // In following GeolocationAPIEmbedderHasAccess* tests, embedder (i.e. the 1003 // In following GeolocationAPIEmbedderHasAccess* tests, embedder (i.e. the
1001 // platform app) has geolocation permission 1004 // platform app) has geolocation permission
1002 // 1005 //
1003 // Note that these test names must be "GeolocationAPI" prefixed (b/c we mock out 1006 // Note that these test names must be "GeolocationAPI" prefixed (b/c we mock out
1004 // geolocation in this case). 1007 // geolocation in this case).
1005 // 1008 //
1006 // Also note that these are run separately because OverrideGeolocation() doesn't 1009 // Also note that these are run separately because OverrideGeolocation() doesn't
1007 // mock out geolocation for multiple navigator.geolocation calls properly and 1010 // mock out geolocation for multiple navigator.geolocation calls properly and
1008 // the tests become flaky. 1011 // the tests become flaky.
1009 // GeolocationAPI* test 1 of 3. 1012 // GeolocationAPI* test 1 of 3.
1010 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasAccessAllow) { 1013 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasAccessAllow) {
1011 GeolocationTestHelper("testAllow", 1014 TestHelper("Geolocation", "testAllow",
1012 "web_view/geolocation/embedder_has_permission"); 1015 "web_view/geolocation/embedder_has_permission");
1013 } 1016 }
1014 1017
1015 // GeolocationAPI* test 2 of 3. 1018 // GeolocationAPI* test 2 of 3.
1016 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasAccessDeny) { 1019 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasAccessDeny) {
1017 GeolocationTestHelper("testDeny", 1020 TestHelper("Geolocation", "testDeny",
1018 "web_view/geolocation/embedder_has_permission"); 1021 "web_view/geolocation/embedder_has_permission");
1019 } 1022 }
1020 1023
1021 // GeolocationAPI* test 3 of 3. 1024 // GeolocationAPI* test 3 of 3.
1022 IN_PROC_BROWSER_TEST_F(WebViewTest, 1025 IN_PROC_BROWSER_TEST_F(WebViewTest,
1023 GeolocationAPIEmbedderHasAccessMultipleBridgeIdAllow) { 1026 GeolocationAPIEmbedderHasAccessMultipleBridgeIdAllow) {
1024 GeolocationTestHelper("testMultipleBridgeIdAllow", 1027 TestHelper("Geolocation", "testMultipleBridgeIdAllow",
1025 "web_view/geolocation/embedder_has_permission"); 1028 "web_view/geolocation/embedder_has_permission");
1026 } 1029 }
1027 1030
1028 // Tests that 1031 // Tests that
1029 // BrowserPluginGeolocationPermissionContext::CancelGeolocationPermissionRequest 1032 // BrowserPluginGeolocationPermissionContext::CancelGeolocationPermissionRequest
1030 // is handled correctly (and does not crash). 1033 // is handled correctly (and does not crash).
1031 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPICancelGeolocation) { 1034 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPICancelGeolocation) {
1032 ASSERT_TRUE(StartTestServer()); // For serving guest pages. 1035 ASSERT_TRUE(StartTestServer()); // For serving guest pages.
1033 ASSERT_TRUE(RunPlatformAppTest( 1036 ASSERT_TRUE(RunPlatformAppTest(
1034 "platform_apps/web_view/geolocation/cancel_request")) << message_; 1037 "platform_apps/web_view/geolocation/cancel_request")) << message_;
1035 } 1038 }
1036 1039
1040 IN_PROC_BROWSER_TEST_F(WebViewTest, Navigation) {
1041 TestHelper("Navigation", "testNavigation", "web_view/navigation");
1042 }
1043
1037 IN_PROC_BROWSER_TEST_F(WebViewTest, ConsoleMessage) { 1044 IN_PROC_BROWSER_TEST_F(WebViewTest, ConsoleMessage) {
1038 ASSERT_TRUE(StartTestServer()); // For serving guest pages. 1045 ASSERT_TRUE(StartTestServer()); // For serving guest pages.
1039 ASSERT_TRUE(RunPlatformAppTestWithArg( 1046 ASSERT_TRUE(RunPlatformAppTestWithArg(
1040 "platform_apps/web_view/common", "console_messages")) 1047 "platform_apps/web_view/common", "console_messages"))
1041 << message_; 1048 << message_;
1042 } 1049 }
1043 1050
1044 IN_PROC_BROWSER_TEST_F(WebViewTest, DownloadPermission) { 1051 IN_PROC_BROWSER_TEST_F(WebViewTest, DownloadPermission) {
1045 ASSERT_TRUE(StartTestServer()); // For serving guest pages. 1052 ASSERT_TRUE(StartTestServer()); // For serving guest pages.
1046 content::WebContents* guest_web_contents = 1053 content::WebContents* guest_web_contents =
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 // Now load an app with <webview>. 1100 // Now load an app with <webview>.
1094 ExtensionTestMessageListener done_listener("DoneTest", false); 1101 ExtensionTestMessageListener done_listener("DoneTest", false);
1095 LoadAndLaunchPlatformApp("web_view/content_script_whitelisted"); 1102 LoadAndLaunchPlatformApp("web_view/content_script_whitelisted");
1096 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); 1103 ASSERT_TRUE(done_listener.WaitUntilSatisfied());
1097 } 1104 }
1098 1105
1099 IN_PROC_BROWSER_TEST_F(WebViewTest, SetPropertyOnDocumentReady) { 1106 IN_PROC_BROWSER_TEST_F(WebViewTest, SetPropertyOnDocumentReady) {
1100 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/document_ready")) 1107 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/document_ready"))
1101 << message_; 1108 << message_;
1102 } 1109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698