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

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: Created 7 years, 5 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_name,
356 const std::string& app_location) { 356 const std::string& test_passed_msg,
357 const std::string& test_failed_msg,
358 const std::string& app_location) {
357 ASSERT_TRUE(StartTestServer()); // For serving guest pages. 359 ASSERT_TRUE(StartTestServer()); // For serving guest pages.
358 ExtensionTestMessageListener launched_listener("Launched", false); 360 ExtensionTestMessageListener launched_listener("Launched", false);
359 LoadAndLaunchPlatformApp(app_location.c_str()); 361 LoadAndLaunchPlatformApp(app_location.c_str());
360 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 362 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
361 363
362 content::WebContents* embedder_web_contents = 364 content::WebContents* embedder_web_contents =
363 GetFirstShellWindowWebContents(); 365 GetFirstShellWindowWebContents();
364 ASSERT_TRUE(embedder_web_contents); 366 ASSERT_TRUE(embedder_web_contents);
365 367
366 ExtensionTestMessageListener done_listener("DoneGeolocationTest.PASSED", 368 ExtensionTestMessageListener done_listener(test_passed_msg, false);
367 false); 369 done_listener.AlsoListenForFailureMessage(test_failed_msg);
368 done_listener.AlsoListenForFailureMessage("DoneGeolocationTest.FAILED");
369 EXPECT_TRUE(content::ExecuteScript( 370 EXPECT_TRUE(content::ExecuteScript(
370 embedder_web_contents, 371 embedder_web_contents,
371 base::StringPrintf("runGeolocationTest('%s')", 372 base::StringPrintf("runTest('%s')", test_name.c_str())));
372 test_name.c_str())));
373 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); 373 ASSERT_TRUE(done_listener.WaitUntilSatisfied());
374 } 374 }
375 375
376 content::WebContents* LoadGuest(const std::string& guest_path, 376 content::WebContents* LoadGuest(const std::string& guest_path,
377 const std::string& app_path) { 377 const std::string& app_path) {
378 GURL::Replacements replace_host; 378 GURL::Replacements replace_host;
379 std::string host_str("localhost"); // Must stay in scope with replace_host. 379 std::string host_str("localhost"); // Must stay in scope with replace_host.
380 replace_host.SetHostStr(host_str); 380 replace_host.SetHostStr(host_str);
381 381
382 GURL guest_url = test_server()->GetURL(guest_path); 382 GURL guest_url = test_server()->GetURL(guest_path);
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 ExtensionTestMessageListener second_loaded_listener("guest-loaded", false); 981 ExtensionTestMessageListener second_loaded_listener("guest-loaded", false);
982 LoadAndLaunchPlatformApp("web_view/teardown"); 982 LoadAndLaunchPlatformApp("web_view/teardown");
983 ASSERT_TRUE(second_loaded_listener.WaitUntilSatisfied()); 983 ASSERT_TRUE(second_loaded_listener.WaitUntilSatisfied());
984 } 984 }
985 985
986 // In following GeolocationAPIEmbedderHasNoAccess* tests, embedder (i.e. the 986 // In following GeolocationAPIEmbedderHasNoAccess* tests, embedder (i.e. the
987 // platform app) does not have geolocation permission for this test. 987 // platform app) does not have geolocation permission for this test.
988 // No matter what the API does, geolocation permission would be denied. 988 // No matter what the API does, geolocation permission would be denied.
989 // Note that the test name prefix must be "GeolocationAPI". 989 // Note that the test name prefix must be "GeolocationAPI".
990 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasNoAccessAllow) { 990 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasNoAccessAllow) {
991 GeolocationTestHelper("testDenyDenies", 991 TestHelper("testDenyDenies",
992 "web_view/geolocation/embedder_has_no_permission"); 992 "DoneGeolocationTest.PASSED",
993 "DoneGeolocationTest.FAILED",
994 "web_view/geolocation/embedder_has_no_permission");
993 } 995 }
994 996
995 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasNoAccessDeny) { 997 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasNoAccessDeny) {
996 GeolocationTestHelper("testDenyDenies", 998 TestHelper("testDenyDenies",
997 "web_view/geolocation/embedder_has_no_permission"); 999 "DoneGeolocationTest.PASSED",
1000 "DoneGeolocationTest.FAILED",
1001 "web_view/geolocation/embedder_has_no_permission");
998 } 1002 }
999 1003
1000 // In following GeolocationAPIEmbedderHasAccess* tests, embedder (i.e. the 1004 // In following GeolocationAPIEmbedderHasAccess* tests, embedder (i.e. the
1001 // platform app) has geolocation permission 1005 // platform app) has geolocation permission
1002 // 1006 //
1003 // Note that these test names must be "GeolocationAPI" prefixed (b/c we mock out 1007 // Note that these test names must be "GeolocationAPI" prefixed (b/c we mock out
1004 // geolocation in this case). 1008 // geolocation in this case).
1005 // 1009 //
1006 // Also note that these are run separately because OverrideGeolocation() doesn't 1010 // Also note that these are run separately because OverrideGeolocation() doesn't
1007 // mock out geolocation for multiple navigator.geolocation calls properly and 1011 // mock out geolocation for multiple navigator.geolocation calls properly and
1008 // the tests become flaky. 1012 // the tests become flaky.
1009 // GeolocationAPI* test 1 of 3. 1013 // GeolocationAPI* test 1 of 3.
1010 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasAccessAllow) { 1014 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasAccessAllow) {
1011 GeolocationTestHelper("testAllow", 1015 TestHelper("testAllow",
1012 "web_view/geolocation/embedder_has_permission"); 1016 "DoneGeolocationTest.PASSED",
1017 "DoneGeolocationTest.FAILED",
1018 "web_view/geolocation/embedder_has_permission");
1013 } 1019 }
1014 1020
1015 // GeolocationAPI* test 2 of 3. 1021 // GeolocationAPI* test 2 of 3.
1016 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasAccessDeny) { 1022 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasAccessDeny) {
1017 GeolocationTestHelper("testDeny", 1023 TestHelper("testDeny",
1018 "web_view/geolocation/embedder_has_permission"); 1024 "DoneGeolocationTest.PASSED",
1025 "DoneGeolocationTest.FAILED",
1026 "web_view/geolocation/embedder_has_permission");
1019 } 1027 }
1020 1028
1021 // GeolocationAPI* test 3 of 3. 1029 // GeolocationAPI* test 3 of 3.
1022 IN_PROC_BROWSER_TEST_F(WebViewTest, 1030 IN_PROC_BROWSER_TEST_F(WebViewTest,
1023 GeolocationAPIEmbedderHasAccessMultipleBridgeIdAllow) { 1031 GeolocationAPIEmbedderHasAccessMultipleBridgeIdAllow) {
1024 GeolocationTestHelper("testMultipleBridgeIdAllow", 1032 TestHelper("testMultipleBridgeIdAllow",
1025 "web_view/geolocation/embedder_has_permission"); 1033 "DoneGeolocationTest.PASSED",
1034 "DoneGeolocationTest.FAILED",
1035 "web_view/geolocation/embedder_has_permission");
1026 } 1036 }
1027 1037
1028 // Tests that 1038 // Tests that
1029 // BrowserPluginGeolocationPermissionContext::CancelGeolocationPermissionRequest 1039 // BrowserPluginGeolocationPermissionContext::CancelGeolocationPermissionRequest
1030 // is handled correctly (and does not crash). 1040 // is handled correctly (and does not crash).
1031 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPICancelGeolocation) { 1041 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPICancelGeolocation) {
1032 ASSERT_TRUE(StartTestServer()); // For serving guest pages. 1042 ASSERT_TRUE(StartTestServer()); // For serving guest pages.
1033 ASSERT_TRUE(RunPlatformAppTest( 1043 ASSERT_TRUE(RunPlatformAppTest(
1034 "platform_apps/web_view/geolocation/cancel_request")) << message_; 1044 "platform_apps/web_view/geolocation/cancel_request")) << message_;
1035 } 1045 }
1036 1046
1047 IN_PROC_BROWSER_TEST_F(WebViewTest, Navigation) {
1048 TestHelper("testNavigation",
1049 "DoneNavigationTest.PASSED",
1050 "DoneNavigationTest.FAILED",
1051 "web_view/navigation");
1052 }
1053
1037 IN_PROC_BROWSER_TEST_F(WebViewTest, ConsoleMessage) { 1054 IN_PROC_BROWSER_TEST_F(WebViewTest, ConsoleMessage) {
1038 ASSERT_TRUE(StartTestServer()); // For serving guest pages. 1055 ASSERT_TRUE(StartTestServer()); // For serving guest pages.
1039 ASSERT_TRUE(RunPlatformAppTestWithArg( 1056 ASSERT_TRUE(RunPlatformAppTestWithArg(
1040 "platform_apps/web_view/common", "console_messages")) 1057 "platform_apps/web_view/common", "console_messages"))
1041 << message_; 1058 << message_;
1042 } 1059 }
1043 1060
1044 IN_PROC_BROWSER_TEST_F(WebViewTest, DownloadPermission) { 1061 IN_PROC_BROWSER_TEST_F(WebViewTest, DownloadPermission) {
1045 ASSERT_TRUE(StartTestServer()); // For serving guest pages. 1062 ASSERT_TRUE(StartTestServer()); // For serving guest pages.
1046 content::WebContents* guest_web_contents = 1063 content::WebContents* guest_web_contents =
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 // Now load an app with <webview>. 1110 // Now load an app with <webview>.
1094 ExtensionTestMessageListener done_listener("DoneTest", false); 1111 ExtensionTestMessageListener done_listener("DoneTest", false);
1095 LoadAndLaunchPlatformApp("web_view/content_script_whitelisted"); 1112 LoadAndLaunchPlatformApp("web_view/content_script_whitelisted");
1096 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); 1113 ASSERT_TRUE(done_listener.WaitUntilSatisfied());
1097 } 1114 }
1098 1115
1099 IN_PROC_BROWSER_TEST_F(WebViewTest, SetPropertyOnDocumentReady) { 1116 IN_PROC_BROWSER_TEST_F(WebViewTest, SetPropertyOnDocumentReady) {
1100 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/document_ready")) 1117 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/document_ready"))
1101 << message_; 1118 << message_;
1102 } 1119 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_function_histogram_value.h ('k') | chrome/browser/webview/webview_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698