OLD | NEW |
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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
36 #include "chrome/common/url_constants.h" | 36 #include "chrome/common/url_constants.h" |
37 #include "chrome/test/base/ui_test_utils.h" | 37 #include "chrome/test/base/ui_test_utils.h" |
38 #include "components/user_prefs/pref_registry_syncable.h" | 38 #include "components/user_prefs/pref_registry_syncable.h" |
39 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 39 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
40 #include "content/public/browser/devtools_agent_host.h" | 40 #include "content/public/browser/devtools_agent_host.h" |
41 #include "content/public/browser/render_process_host.h" | 41 #include "content/public/browser/render_process_host.h" |
42 #include "content/public/browser/render_widget_host_view.h" | 42 #include "content/public/browser/render_widget_host_view.h" |
43 #include "content/public/browser/web_contents_view.h" | 43 #include "content/public/browser/web_contents_view.h" |
44 #include "content/public/test/test_utils.h" | 44 #include "content/public/test/test_utils.h" |
| 45 #include "net/test/embedded_test_server/embedded_test_server.h" |
45 #include "googleurl/src/gurl.h" | 46 #include "googleurl/src/gurl.h" |
46 | 47 |
47 using content::WebContents; | 48 using content::WebContents; |
48 using web_modal::WebContentsModalDialogManager; | 49 using web_modal::WebContentsModalDialogManager; |
49 | 50 |
50 namespace extensions { | 51 namespace extensions { |
51 | 52 |
52 namespace { | 53 namespace { |
53 | 54 |
54 // Non-abstract RenderViewContextMenu class. | 55 // Non-abstract RenderViewContextMenu class. |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 ExtensionTestMessageListener onclicked_listener("onClicked fired for id1", | 297 ExtensionTestMessageListener onclicked_listener("onClicked fired for id1", |
297 false); | 298 false); |
298 menu->ExecuteCommand(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST, 0); | 299 menu->ExecuteCommand(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST, 0); |
299 | 300 |
300 ASSERT_TRUE(onclicked_listener.WaitUntilSatisfied()); | 301 ASSERT_TRUE(onclicked_listener.WaitUntilSatisfied()); |
301 } | 302 } |
302 | 303 |
303 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) { | 304 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) { |
304 TabsAddedNotificationObserver observer(2); | 305 TabsAddedNotificationObserver observer(2); |
305 | 306 |
306 ASSERT_TRUE(StartTestServer()); | 307 ASSERT_TRUE(StartEmbeddedTestServer()); |
307 ASSERT_TRUE(RunPlatformAppTest("platform_apps/navigation")) << message_; | 308 ASSERT_TRUE(RunPlatformAppTest("platform_apps/navigation")) << message_; |
308 | 309 |
309 observer.Wait(); | 310 observer.Wait(); |
310 ASSERT_EQ(2U, observer.tabs().size()); | 311 ASSERT_EQ(2U, observer.tabs().size()); |
311 EXPECT_EQ(std::string(chrome::kExtensionInvalidRequestURL), | 312 EXPECT_EQ(std::string(chrome::kExtensionInvalidRequestURL), |
312 observer.tabs()[0]->GetURL().spec()); | 313 observer.tabs()[0]->GetURL().spec()); |
313 EXPECT_EQ("http://chromium.org/", | 314 EXPECT_EQ("http://chromium.org/", |
314 observer.tabs()[1]->GetURL().spec()); | 315 observer.tabs()[1]->GetURL().spec()); |
315 } | 316 } |
316 | 317 |
317 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Iframes) { | 318 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Iframes) { |
318 ASSERT_TRUE(StartTestServer()); | 319 ASSERT_TRUE(StartEmbeddedTestServer()); |
319 ASSERT_TRUE(RunPlatformAppTest("platform_apps/iframes")) << message_; | 320 ASSERT_TRUE(RunPlatformAppTest("platform_apps/iframes")) << message_; |
320 } | 321 } |
321 | 322 |
322 // Tests that localStorage and WebSQL are disabled for platform apps. | 323 // Tests that localStorage and WebSQL are disabled for platform apps. |
323 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowStorage) { | 324 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowStorage) { |
324 ASSERT_TRUE(RunPlatformAppTest("platform_apps/storage")) << message_; | 325 ASSERT_TRUE(RunPlatformAppTest("platform_apps/storage")) << message_; |
325 } | 326 } |
326 | 327 |
327 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Restrictions) { | 328 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Restrictions) { |
328 ASSERT_TRUE(RunPlatformAppTest("platform_apps/restrictions")) << message_; | 329 ASSERT_TRUE(RunPlatformAppTest("platform_apps/restrictions")) << message_; |
329 } | 330 } |
330 | 331 |
331 // Tests that platform apps can use the chrome.app.window.* API. | 332 // Tests that platform apps can use the chrome.app.window.* API. |
332 // It is flaky: http://crbug.com/223467 | 333 // It is flaky: http://crbug.com/223467 |
333 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DISABLED_WindowsApi) { | 334 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DISABLED_WindowsApi) { |
334 ASSERT_TRUE(RunPlatformAppTest("platform_apps/windows_api")) << message_; | 335 ASSERT_TRUE(RunPlatformAppTest("platform_apps/windows_api")) << message_; |
335 } | 336 } |
336 | 337 |
337 // Tests that extensions can't use platform-app-only APIs. | 338 // Tests that extensions can't use platform-app-only APIs. |
338 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, PlatformAppsOnly) { | 339 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, PlatformAppsOnly) { |
339 ASSERT_TRUE(RunExtensionTestIgnoreManifestWarnings( | 340 ASSERT_TRUE(RunExtensionTestIgnoreManifestWarnings( |
340 "platform_apps/apps_only")) << message_; | 341 "platform_apps/apps_only")) << message_; |
341 } | 342 } |
342 | 343 |
343 // Tests that platform apps have isolated storage by default. | 344 // Tests that platform apps have isolated storage by default. |
344 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Isolation) { | 345 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Isolation) { |
345 ASSERT_TRUE(StartTestServer()); | 346 ASSERT_TRUE(StartEmbeddedTestServer()); |
346 | 347 |
347 // Load a (non-app) page under the "localhost" origin that sets a cookie. | 348 // Load a (non-app) page under the "localhost" origin that sets a cookie. |
348 GURL set_cookie_url = test_server()->GetURL( | 349 GURL set_cookie_url = embedded_test_server()->GetURL( |
349 "files/extensions/platform_apps/isolation/set_cookie.html"); | 350 "/extensions/platform_apps/isolation/set_cookie.html"); |
350 GURL::Replacements replace_host; | 351 GURL::Replacements replace_host; |
351 std::string host_str("localhost"); // Must stay in scope with replace_host. | 352 std::string host_str("localhost"); // Must stay in scope with replace_host. |
352 replace_host.SetHostStr(host_str); | 353 replace_host.SetHostStr(host_str); |
353 set_cookie_url = set_cookie_url.ReplaceComponents(replace_host); | 354 set_cookie_url = set_cookie_url.ReplaceComponents(replace_host); |
354 | 355 |
355 ui_test_utils::NavigateToURLWithDisposition( | 356 ui_test_utils::NavigateToURLWithDisposition( |
356 browser(), set_cookie_url, | 357 browser(), set_cookie_url, |
357 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 358 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
358 | 359 |
359 // Make sure the cookie is set. | 360 // Make sure the cookie is set. |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 // function to get the native file system path of a file they are launched with. | 601 // function to get the native file system path of a file they are launched with. |
601 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, GetDisplayPath) { | 602 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, GetDisplayPath) { |
602 SetCommandLineArg(kTestFilePath); | 603 SetCommandLineArg(kTestFilePath); |
603 ASSERT_TRUE(RunPlatformAppTest("platform_apps/get_display_path")) | 604 ASSERT_TRUE(RunPlatformAppTest("platform_apps/get_display_path")) |
604 << message_; | 605 << message_; |
605 } | 606 } |
606 | 607 |
607 #endif // defined(OS_CHROMEOS) | 608 #endif // defined(OS_CHROMEOS) |
608 | 609 |
609 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) { | 610 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) { |
610 ASSERT_TRUE(StartTestServer()); | 611 ASSERT_TRUE(StartEmbeddedTestServer()); |
611 content::WindowedNotificationObserver observer( | 612 content::WindowedNotificationObserver observer( |
612 chrome::NOTIFICATION_TAB_ADDED, | 613 chrome::NOTIFICATION_TAB_ADDED, |
613 content::Source<content::WebContentsDelegate>(browser())); | 614 content::Source<content::WebContentsDelegate>(browser())); |
614 LoadAndLaunchPlatformApp("open_link"); | 615 LoadAndLaunchPlatformApp("open_link"); |
615 observer.Wait(); | 616 observer.Wait(); |
616 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 617 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
617 } | 618 } |
618 | 619 |
619 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) { | 620 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) { |
620 ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_; | 621 ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_; |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 | 1077 |
1077 while (!ContainsKey(opener_app_ids_, file_manager->id())) { | 1078 while (!ContainsKey(opener_app_ids_, file_manager->id())) { |
1078 content::RunAllPendingInMessageLoop(); | 1079 content::RunAllPendingInMessageLoop(); |
1079 } | 1080 } |
1080 } | 1081 } |
1081 | 1082 |
1082 #endif // defined(OS_CHROMEOS) | 1083 #endif // defined(OS_CHROMEOS) |
1083 | 1084 |
1084 | 1085 |
1085 } // namespace extensions | 1086 } // namespace extensions |
OLD | NEW |