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

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

Issue 13712002: Fix Guest geolocation API, we were using |bridge_id| and |request_id| interchangeably which is wron… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync. Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/geolocation/cancel_request/embedder.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 (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/stringprintf.h" 5 #include "base/stringprintf.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/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) {
356 ASSERT_TRUE(StartTestServer()); // For serving guest pages.
357 ExtensionTestMessageListener launched_listener("Launched", false);
358 LoadAndLaunchPlatformApp("web_view/geolocation/embedder_has_permission");
359 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
360
361 content::WebContents* embedder_web_contents =
362 GetFirstShellWindowWebContents();
363 ASSERT_TRUE(embedder_web_contents);
364
365 ExtensionTestMessageListener done_listener("DoneGeolocationTest", false);
366 EXPECT_TRUE(content::ExecuteScript(
367 embedder_web_contents,
368 base::StringPrintf("runGeolocationTest('%s')",
369 test_name.c_str())));
370 done_listener.WaitUntilSatisfied();
371 bool has_test_passed;
372 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
373 embedder_web_contents,
374 "window.domAutomationController.send(hasTestPassed());",
375 &has_test_passed));
376 ASSERT_TRUE(has_test_passed);
377 }
378
355 scoped_ptr<content::FakeSpeechRecognitionManager> 379 scoped_ptr<content::FakeSpeechRecognitionManager>
356 fake_speech_recognition_manager_; 380 fake_speech_recognition_manager_;
357 }; 381 };
358 382
359 // http://crbug.com/176122: This test is flaky on Windows. 383 // http://crbug.com/176122: This test is flaky on Windows.
360 #if defined(OS_WIN) 384 #if defined(OS_WIN)
361 #define MAYBE_Shim DISABLED_Shim 385 #define MAYBE_Shim DISABLED_Shim
362 #else 386 #else
363 #define MAYBE_Shim Shim 387 #define MAYBE_Shim Shim
364 #endif 388 #endif
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 // Embedder does not have geolocation permission for this test. 924 // Embedder does not have geolocation permission for this test.
901 // No matter what the API does, geolocation permission would be denied. 925 // No matter what the API does, geolocation permission would be denied.
902 // Note that the test name prefix must be "GeolocationAPI". 926 // Note that the test name prefix must be "GeolocationAPI".
903 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasNoAccess) { 927 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasNoAccess) {
904 ASSERT_TRUE(StartTestServer()); // For serving guest pages. 928 ASSERT_TRUE(StartTestServer()); // For serving guest pages.
905 ASSERT_TRUE(RunPlatformAppTest( 929 ASSERT_TRUE(RunPlatformAppTest(
906 "platform_apps/web_view/geolocation/embedder_has_no_permission")) 930 "platform_apps/web_view/geolocation/embedder_has_no_permission"))
907 << message_; 931 << message_;
908 } 932 }
909 933
910 // Embedder has geolocation permission for this test. 934 // In following GeolocationAPIEmbedderHasAccess* tests, embedder (i.e. the
911 // Note that the test name prefix must be "GeolocationAPI". 935 // platform app) has geolocation permission
912 IN_PROC_BROWSER_TEST_F(WebViewTest, DISABLED_GeolocationAPIEmbedderHasAccess) { 936 //
937 // Note that these test names must be "GeolocationAPI" prefixed (b/c we mock out
938 // geolocation in this case).
939 //
940 // Also note that these are run separately because OverrideGeolocation() doesn't
941 // mock out geolocation for multiple navigator.geolocation calls properly and
942 // the tests become flaky.
943 // GeolocationAPI* test 1 of 3.
944 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasAccessAllow) {
945 GeolocationTestHelper("testAllow");
946 }
947
948 // GeolocationAPI* test 2 of 3.
949 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPIEmbedderHasAccessDeny) {
950 GeolocationTestHelper("testDeny");
951 }
952
953 // GeolocationAPI* test 3 of 3.
954 IN_PROC_BROWSER_TEST_F(WebViewTest,
955 GeolocationAPIEmbedderHasAccessMultipleBridgeIdAllow) {
956 GeolocationTestHelper("testMultipleBridgeIdAllow");
957 }
958
959 // Tests that
960 // BrowserPluginGeolocationPermissionContext::CancelGeolocationPermissionRequest
961 // is handled correctly (and does not crash).
962 IN_PROC_BROWSER_TEST_F(WebViewTest, GeolocationAPICancelGeolocation) {
913 ASSERT_TRUE(StartTestServer()); // For serving guest pages. 963 ASSERT_TRUE(StartTestServer()); // For serving guest pages.
914 ASSERT_TRUE(RunPlatformAppTest( 964 ASSERT_TRUE(RunPlatformAppTest(
915 "platform_apps/web_view/geolocation/embedder_has_permission")) 965 "platform_apps/web_view/geolocation/cancel_request")) << message_;
916 << message_;
917 } 966 }
918 967
919 // Disabled on win debug bots due to flaky timeouts. 968 // Disabled on win debug bots due to flaky timeouts.
920 // See http://crbug.com/222618 . 969 // See http://crbug.com/222618 .
921 #if defined(OS_WIN) && !defined(NDEBUG) 970 #if defined(OS_WIN) && !defined(NDEBUG)
922 #define MAYBE_NewWindow DISABLED_NewWindow 971 #define MAYBE_NewWindow DISABLED_NewWindow
923 #else 972 #else
924 #define MAYBE_NewWindow NewWindow 973 #define MAYBE_NewWindow NewWindow
925 #endif 974 #endif
926 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_NewWindow) { 975 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_NewWindow) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 EXPECT_TRUE(content::ExecuteScript(guest_web_contents, 1015 EXPECT_TRUE(content::ExecuteScript(guest_web_contents,
967 "startDownload('download-link-2')")); 1016 "startDownload('download-link-2')"));
968 mock_delegate->WaitForCanDownload(true); // Expect to allow. 1017 mock_delegate->WaitForCanDownload(true); // Expect to allow.
969 mock_delegate->Reset(); 1018 mock_delegate->Reset();
970 1019
971 // 3. Guest requests a download that its embedder ignores, this implies deny. 1020 // 3. Guest requests a download that its embedder ignores, this implies deny.
972 EXPECT_TRUE(content::ExecuteScript(guest_web_contents, 1021 EXPECT_TRUE(content::ExecuteScript(guest_web_contents,
973 "startDownload('download-link-3')")); 1022 "startDownload('download-link-3')"));
974 mock_delegate->WaitForCanDownload(false); // Expect to not allow. 1023 mock_delegate->WaitForCanDownload(false); // Expect to not allow.
975 } 1024 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/geolocation/cancel_request/embedder.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698