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

Side by Side Diff: chrome/browser/apps/app_browsertest.cc

Issue 23847004: "Redirecting URLs to Packaged Apps" implementation: revised (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Limit interception to http:// and https:// Created 7 years, 3 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
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 "apps/launcher.h" 5 #include "apps/launcher.h"
6 #include "apps/native_app_window.h" 6 #include "apps/native_app_window.h"
7 #include "apps/shell_window.h" 7 #include "apps/shell_window.h"
8 #include "apps/shell_window_registry.h" 8 #include "apps/shell_window_registry.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) { 628 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) {
629 ASSERT_TRUE(StartEmbeddedTestServer()); 629 ASSERT_TRUE(StartEmbeddedTestServer());
630 content::WindowedNotificationObserver observer( 630 content::WindowedNotificationObserver observer(
631 chrome::NOTIFICATION_TAB_ADDED, 631 chrome::NOTIFICATION_TAB_ADDED,
632 content::Source<content::WebContentsDelegate>(browser())); 632 content::Source<content::WebContentsDelegate>(browser()));
633 LoadAndLaunchPlatformApp("open_link"); 633 LoadAndLaunchPlatformApp("open_link");
634 observer.Wait(); 634 observer.Wait();
635 ASSERT_EQ(2, browser()->tab_strip_model()->count()); 635 ASSERT_EQ(2, browser()->tab_strip_model()->count());
636 } 636 }
637 637
638
639 // Test that clicks on any type of links in a tab + window.open() launch
640 // an app that has a matching handler in url_handlers.
641 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
642 UrlHandlersNavigationsInTabIntercepted) {
not at google - send to devlin 2013/09/07 00:54:56 can you put these tests in a different file? This
sergeygs 2013/09/09 09:55:36 Done. If we start in this direction, it would be n
not at google - send to devlin 2013/09/09 19:01:13 Absolutely.
643 CommandLine::ForCurrentProcess()->AppendSwitch(
644 switches::kDisablePopupBlocking);
645
646 ASSERT_TRUE(StartEmbeddedTestServer());
647
648 InstallPlatformApp("url_handlers/handler");
649
650 const std::string href_root =
651 "/extensions/platform_apps/url_handlers/launching_tabs/";
652 const std::string hrefs[] = {
653 "click_link.html",
654 "click_blank_link.html",
655 "call_window_open.html",
656 };
not at google - send to devlin 2013/09/07 00:54:56 might as well use const char*s here rather than st
sergeygs 2013/09/09 09:55:36 Done.
657
658 for (size_t i = 0; i < sizeof(hrefs) / sizeof(*hrefs); ++i) {
not at google - send to devlin 2013/09/07 00:54:56 use arraysize(hrefs) or ARRAYSIZE_UNSAFE if that d
sergeygs 2013/09/09 09:55:36 Obsolete.
659 GURL url = embedded_test_server()->GetURL(href_root + hrefs[i]);
660
661 ui_test_utils::NavigateToURLWithDisposition(
662 browser(), url,
663 CURRENT_TAB,
664 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
665
666 ExtensionTestMessageListener handler_listener("Handler launched", false);
667 ASSERT_TRUE(handler_listener.WaitUntilSatisfied());
668 }
669
670 // The above navigations click on 2 links (regular and target blank) and call
671 // 1 window.open(), all of which should be intercepted and launch the
672 // handler app.
673 ASSERT_EQ(3U, GetShellWindowCount());
not at google - send to devlin 2013/09/07 00:54:56 asserting based on the number of shell windows ope
sergeygs 2013/09/09 09:55:36 chrome.test.sendMessage _is_ used here, see the en
not at google - send to devlin 2013/09/09 19:01:13 Ah, I see. Thanks.
674 }
675
676 // Test that a click on link in an app windows launches an app that has
677 // a matching handler in url_handlers.
678 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
679 UrlHandlersClickInAppIntercepted) {
680 ASSERT_TRUE(StartEmbeddedTestServer());
681
682 ExtensionTestMessageListener launcher_listener("Launcher launched", false);
683 ExtensionTestMessageListener handler_listener("Handler launched", false);
684
685 InstallPlatformApp("url_handlers/handler");
686 LoadAndLaunchPlatformApp("url_handlers/launcher");
687
688 ASSERT_TRUE(launcher_listener.WaitUntilSatisfied());
689 ASSERT_TRUE(handler_listener.WaitUntilSatisfied());
690
691 // The launcher clicks on a link, which gets intercepted and launches the
692 // handler.
693 ASSERT_EQ(2U, GetShellWindowCount());
694 }
695
696 // Test that a webview can navigate to URLs even when there are apps installed
697 // that have matching url_handlers.
698 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
699 UrlHandlersWebviewNavigationNotIntercepted) {
700 ASSERT_TRUE(StartEmbeddedTestServer());
701
702 ExtensionTestMessageListener handler_listener("Handler launched", false);
703
704 InstallPlatformApp("url_handlers/handler_with_webview");
705 LoadAndLaunchPlatformApp("url_handlers/launcher");
706
707 ASSERT_TRUE(handler_listener.WaitUntilSatisfied());
708 base::PlatformThread::Sleep(TestTimeouts::action_timeout());
709
710 // The launcher clicks on a link, which gets intercepted and launches the
711 // handler. The handler also redirects an embedded webview to the URL. The
712 // webview should just navigate without creating an endless loop of
713 // navigate-intercept-launch sequences with multiplying handler's windows.
714 // There should be 2 windows only: launcher's and handler's.
715 ASSERT_EQ(2U, GetShellWindowCount());
716 }
717
638 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) { 718 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) {
639 ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_; 719 ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_;
640 } 720 }
641 721
642 // Test that windows created with an id will remember and restore their 722 // Test that windows created with an id will remember and restore their
643 // geometry when opening new windows. 723 // geometry when opening new windows.
644 // Originally disabled due to flakiness (see http://crbug.com/155459) 724 // Originally disabled due to flakiness (see http://crbug.com/155459)
645 // but now because a regression breaks the test (http://crbug.com/160343). 725 // but now because a regression breaks the test (http://crbug.com/160343).
646 #if defined(TOOLKIT_GTK) 726 #if defined(TOOLKIT_GTK)
647 #define MAYBE_ShellWindowRestorePosition DISABLED_ShellWindowRestorePosition 727 #define MAYBE_ShellWindowRestorePosition DISABLED_ShellWindowRestorePosition
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 1191
1112 while (!ContainsKey(opener_app_ids_, file_manager->id())) { 1192 while (!ContainsKey(opener_app_ids_, file_manager->id())) {
1113 content::RunAllPendingInMessageLoop(); 1193 content::RunAllPendingInMessageLoop();
1114 } 1194 }
1115 } 1195 }
1116 1196
1117 #endif // defined(OS_CHROMEOS) 1197 #endif // defined(OS_CHROMEOS)
1118 1198
1119 1199
1120 } // namespace extensions 1200 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698