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

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

Issue 10920084: don't display platform app resources in normal browser windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self review Created 8 years, 2 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 | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/ui/browser_navigator.cc » ('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/bind.h" 5 #include "base/bind.h"
6 #include "base/test/test_timeouts.h" 6 #include "base/test/test_timeouts.h"
7 #include "base/threading/platform_thread.h" 7 #include "base/threading/platform_thread.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/automation/automation_util.h" 10 #include "chrome/browser/automation/automation_util.h"
11 #include "chrome/browser/tab_contents/render_view_context_menu.h" 11 #include "chrome/browser/tab_contents/render_view_context_menu.h"
12 #include "chrome/browser/extensions/extension_browsertest.h" 12 #include "chrome/browser/extensions/extension_browsertest.h"
13 #include "chrome/browser/extensions/extension_test_message_listener.h" 13 #include "chrome/browser/extensions/extension_test_message_listener.h"
14 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 14 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
15 #include "chrome/browser/extensions/platform_app_launcher.h" 15 #include "chrome/browser/extensions/platform_app_launcher.h"
16 #include "chrome/browser/extensions/shell_window_registry.h" 16 #include "chrome/browser/extensions/shell_window_registry.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_tabstrip.h" 18 #include "chrome/browser/ui/browser_tabstrip.h"
19 #include "chrome/browser/ui/extensions/application_launch.h" 19 #include "chrome/browser/ui/extensions/application_launch.h"
20 #include "chrome/browser/ui/extensions/shell_window.h" 20 #include "chrome/browser/ui/extensions/shell_window.h"
21 #include "chrome/common/chrome_notification_types.h" 21 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/url_constants.h"
22 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
23 #include "content/public/browser/render_process_host.h" 24 #include "content/public/browser/render_process_host.h"
24 #include "content/public/browser/web_intents_dispatcher.h" 25 #include "content/public/browser/web_intents_dispatcher.h"
25 #include "googleurl/src/gurl.h" 26 #include "googleurl/src/gurl.h"
26 #include "webkit/glue/web_intent_data.h" 27 #include "webkit/glue/web_intent_data.h"
27 28
28 using content::WebContents; 29 using content::WebContents;
29 30
30 namespace extensions { 31 namespace extensions {
31 32
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 MessageLoopForUI::current()->Quit(); 93 MessageLoopForUI::current()->Quit();
93 } 94 }
94 95
95 webkit_glue::WebIntentData data_; 96 webkit_glue::WebIntentData data_;
96 bool replied_; 97 bool replied_;
97 bool waiting_; 98 bool waiting_;
98 content::WebIntentsDispatcher* intents_dispatcher_; 99 content::WebIntentsDispatcher* intents_dispatcher_;
99 base::WeakPtrFactory<LaunchReplyHandler> weak_ptr_factory_; 100 base::WeakPtrFactory<LaunchReplyHandler> weak_ptr_factory_;
100 }; 101 };
101 102
103 // This class keeps track of tabs as they are added to the browser. It will be
104 // "done" (i.e. won't block on Wait()) once |observations| tabs have been added.
105 class TabsAddedNotificationObserver :
Lei Zhang 2012/09/28 18:50:31 nit: I think the linter will be happier if you put
106 public content::WindowedNotificationObserver {
107 public:
108 explicit TabsAddedNotificationObserver(size_t observations)
109 : content::WindowedNotificationObserver(
110 chrome::NOTIFICATION_TAB_ADDED,
111 content::NotificationService::AllSources()),
112 observations_(observations) {
113 }
114
115 virtual void Observe(int type,
116 const content::NotificationSource& source,
117 const content::NotificationDetails& details) OVERRIDE {
118 observed_tabs_.push_back(
119 content::Details<WebContents>(details).ptr());
120 if (observed_tabs_.size() == observations_)
121 content::WindowedNotificationObserver::Observe(type, source, details);
122 }
123
124 const std::vector<content::WebContents*>& tabs() { return observed_tabs_; }
125
126 private:
127 size_t observations_;
128 std::vector<content::WebContents*> observed_tabs_;
129
130 DISALLOW_COPY_AND_ASSIGN(TabsAddedNotificationObserver);
131 };
132
102 const char kTestFilePath[] = "platform_apps/launch_files/test.txt"; 133 const char kTestFilePath[] = "platform_apps/launch_files/test.txt";
103 134
104 } // namespace 135 } // namespace
105 136
106 // Tests that CreateShellWindow doesn't crash if you close it straight away. 137 // Tests that CreateShellWindow doesn't crash if you close it straight away.
107 // LauncherPlatformAppBrowserTest relies on this behaviour, but is only run for 138 // LauncherPlatformAppBrowserTest relies on this behaviour, but is only run for
108 // ash, so we test that it works here. 139 // ash, so we test that it works here.
109 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, CreateAndCloseShellWindow) { 140 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, CreateAndCloseShellWindow) {
110 const Extension* extension = LoadAndLaunchPlatformApp("minimal"); 141 const Extension* extension = LoadAndLaunchPlatformApp("minimal");
111 ShellWindow* window = CreateShellWindow(extension); 142 ShellWindow* window = CreateShellWindow(extension);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 342
312 // Execute the menu item 343 // Execute the menu item
313 ExtensionTestMessageListener onclicked_listener("onClicked fired for id1", 344 ExtensionTestMessageListener onclicked_listener("onClicked fired for id1",
314 false); 345 false);
315 menu->ExecuteCommand(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST); 346 menu->ExecuteCommand(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST);
316 347
317 ASSERT_TRUE(onclicked_listener.WaitUntilSatisfied()); 348 ASSERT_TRUE(onclicked_listener.WaitUntilSatisfied());
318 } 349 }
319 350
320 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) { 351 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) {
352 TabsAddedNotificationObserver observer(2);
353
321 ASSERT_TRUE(StartTestServer()); 354 ASSERT_TRUE(StartTestServer());
322 ASSERT_TRUE(RunPlatformAppTest("platform_apps/navigation")) << message_; 355 ASSERT_TRUE(RunPlatformAppTest("platform_apps/navigation")) << message_;
356
357 observer.Wait();
358 ASSERT_EQ(2U, observer.tabs().size());
359 EXPECT_EQ(chrome::kExtensionInvalidRequestURL,
360 observer.tabs()[0]->GetURL().spec());
361 EXPECT_EQ("http://chromium.org/",
362 observer.tabs()[1]->GetURL().spec());
323 } 363 }
324 364
325 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Iframes) { 365 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Iframes) {
326 ASSERT_TRUE(StartTestServer()); 366 ASSERT_TRUE(StartTestServer());
327 ASSERT_TRUE(RunPlatformAppTest("platform_apps/iframes")) << message_; 367 ASSERT_TRUE(RunPlatformAppTest("platform_apps/iframes")) << message_;
328 } 368 }
329 369
330 // Tests that localStorage and WebSQL are disabled for platform apps. 370 // Tests that localStorage and WebSQL are disabled for platform apps.
331 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowStorage) { 371 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowStorage) {
332 ASSERT_TRUE(RunPlatformAppTest("platform_apps/storage")) << message_; 372 ASSERT_TRUE(RunPlatformAppTest("platform_apps/storage")) << message_;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 639
600 // Tell javascript to open a third window. 640 // Tell javascript to open a third window.
601 page3_listener.Reply("continue"); 641 page3_listener.Reply("continue");
602 642
603 // Wait for javascript to verify that the third window got the restored size 643 // Wait for javascript to verify that the third window got the restored size
604 // and explicitly specified coordinates. 644 // and explicitly specified coordinates.
605 ASSERT_TRUE(done3_listener.WaitUntilSatisfied()); 645 ASSERT_TRUE(done3_listener.WaitUntilSatisfied());
606 } 646 }
607 647
608 } // namespace extensions 648 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/ui/browser_navigator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698