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

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

Issue 2248873002: Convert WindowOpenDisposition to an enum class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 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
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/command_line.h" 5 #include "base/command_line.h"
6 #include "build/build_config.h" 6 #include "build/build_config.h"
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 const Extension* extension = GetSingleLoadedExtension(); 80 const Extension* extension = GetSingleLoadedExtension();
81 81
82 // Open two tabs in the app, one outside it. 82 // Open two tabs in the app, one outside it.
83 GURL base_url = GetTestBaseURL(app_name); 83 GURL base_url = GetTestBaseURL(app_name);
84 84
85 // Test both opening a URL in a new tab, and opening a tab and then 85 // Test both opening a URL in a new tab, and opening a tab and then
86 // navigating it. Either way, app tabs should be considered extension 86 // navigating it. Either way, app tabs should be considered extension
87 // processes, but they have no elevated privileges and thus should not 87 // processes, but they have no elevated privileges and thus should not
88 // have WebUI bindings. 88 // have WebUI bindings.
89 ui_test_utils::NavigateToURLWithDisposition( 89 ui_test_utils::NavigateToURLWithDisposition(
90 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, 90 browser(), base_url.Resolve("path1/empty.html"),
91 WindowOpenDisposition::NEW_FOREGROUND_TAB,
91 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 92 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
92 LOG(INFO) << "Nav 1."; 93 LOG(INFO) << "Nav 1.";
93 EXPECT_TRUE(process_map->Contains( 94 EXPECT_TRUE(process_map->Contains(
94 browser()->tab_strip_model()->GetWebContentsAt(1)-> 95 browser()->tab_strip_model()->GetWebContentsAt(1)->
95 GetRenderProcessHost()->GetID())); 96 GetRenderProcessHost()->GetID()));
96 EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(1)->GetWebUI()); 97 EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(1)->GetWebUI());
97 98
98 content::WindowedNotificationObserver tab_added_observer( 99 content::WindowedNotificationObserver tab_added_observer(
99 chrome::NOTIFICATION_TAB_ADDED, 100 chrome::NOTIFICATION_TAB_ADDED,
100 content::NotificationService::AllSources()); 101 content::NotificationService::AllSources());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 156
156 LOG(INFO) << "Loaded extension."; 157 LOG(INFO) << "Loaded extension.";
157 158
158 // Open two tabs in the app, one outside it. 159 // Open two tabs in the app, one outside it.
159 GURL base_url = GetTestBaseURL("app_process"); 160 GURL base_url = GetTestBaseURL("app_process");
160 161
161 // Test both opening a URL in a new tab, and opening a tab and then navigating 162 // Test both opening a URL in a new tab, and opening a tab and then navigating
162 // it. Either way, app tabs should be considered extension processes, but 163 // it. Either way, app tabs should be considered extension processes, but
163 // they have no elevated privileges and thus should not have WebUI bindings. 164 // they have no elevated privileges and thus should not have WebUI bindings.
164 ui_test_utils::NavigateToURLWithDisposition( 165 ui_test_utils::NavigateToURLWithDisposition(
165 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, 166 browser(), base_url.Resolve("path1/empty.html"),
167 WindowOpenDisposition::NEW_FOREGROUND_TAB,
166 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 168 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
167 EXPECT_TRUE(process_map->Contains( 169 EXPECT_TRUE(process_map->Contains(
168 browser()->tab_strip_model()->GetWebContentsAt(1)-> 170 browser()->tab_strip_model()->GetWebContentsAt(1)->
169 GetRenderProcessHost()->GetID())); 171 GetRenderProcessHost()->GetID()));
170 EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(1)->GetWebUI()); 172 EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(1)->GetWebUI());
171 LOG(INFO) << "Nav 1."; 173 LOG(INFO) << "Nav 1.";
172 174
173 ui_test_utils::NavigateToURLWithDisposition( 175 ui_test_utils::NavigateToURLWithDisposition(
174 browser(), base_url.Resolve("path2/empty.html"), NEW_FOREGROUND_TAB, 176 browser(), base_url.Resolve("path2/empty.html"),
177 WindowOpenDisposition::NEW_FOREGROUND_TAB,
175 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 178 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
176 EXPECT_TRUE(process_map->Contains( 179 EXPECT_TRUE(process_map->Contains(
177 browser()->tab_strip_model()->GetWebContentsAt(2)-> 180 browser()->tab_strip_model()->GetWebContentsAt(2)->
178 GetRenderProcessHost()->GetID())); 181 GetRenderProcessHost()->GetID()));
179 EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(2)->GetWebUI()); 182 EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(2)->GetWebUI());
180 LOG(INFO) << "Nav 2."; 183 LOG(INFO) << "Nav 2.";
181 184
182 content::WindowedNotificationObserver tab_added_observer( 185 content::WindowedNotificationObserver tab_added_observer(
183 chrome::NOTIFICATION_TAB_ADDED, 186 chrome::NOTIFICATION_TAB_ADDED,
184 content::NotificationService::AllSources()); 187 content::NotificationService::AllSources());
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 service->OnExtensionInstalled(extension.get(), 312 service->OnExtensionInstalled(extension.get(),
310 syncer::StringOrdinal::CreateInitialOrdinal(), 313 syncer::StringOrdinal::CreateInitialOrdinal(),
311 extensions::kInstallFlagInstallImmediately); 314 extensions::kInstallFlagInstallImmediately);
312 ASSERT_TRUE(extension.get()); 315 ASSERT_TRUE(extension.get());
313 ASSERT_TRUE(extension->from_bookmark()); 316 ASSERT_TRUE(extension->from_bookmark());
314 317
315 // Test both opening a URL in a new tab, and opening a tab and then navigating 318 // Test both opening a URL in a new tab, and opening a tab and then navigating
316 // it. Either way, bookmark app tabs should be considered normal processes 319 // it. Either way, bookmark app tabs should be considered normal processes
317 // with no elevated privileges and no WebUI bindings. 320 // with no elevated privileges and no WebUI bindings.
318 ui_test_utils::NavigateToURLWithDisposition( 321 ui_test_utils::NavigateToURLWithDisposition(
319 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, 322 browser(), base_url.Resolve("path1/empty.html"),
323 WindowOpenDisposition::NEW_FOREGROUND_TAB,
320 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 324 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
321 EXPECT_FALSE(process_map->Contains( 325 EXPECT_FALSE(process_map->Contains(
322 browser()->tab_strip_model()->GetWebContentsAt(1)-> 326 browser()->tab_strip_model()->GetWebContentsAt(1)->
323 GetRenderProcessHost()->GetID())); 327 GetRenderProcessHost()->GetID()));
324 EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(1)->GetWebUI()); 328 EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(1)->GetWebUI());
325 329
326 content::WindowedNotificationObserver tab_added_observer( 330 content::WindowedNotificationObserver tab_added_observer(
327 chrome::NOTIFICATION_TAB_ADDED, 331 chrome::NOTIFICATION_TAB_ADDED,
328 content::NotificationService::AllSources()); 332 content::NotificationService::AllSources());
329 chrome::NewTab(browser()); 333 chrome::NewTab(browser());
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 // Enable app and reload the page. 496 // Enable app and reload the page.
493 LOG(INFO) << "Enabling extension."; 497 LOG(INFO) << "Enabling extension.";
494 EnableExtension(app->id()); 498 EnableExtension(app->id());
495 LOG(INFO) << "Enabling extension - done."; 499 LOG(INFO) << "Enabling extension - done.";
496 content::WindowedNotificationObserver reload_observer( 500 content::WindowedNotificationObserver reload_observer(
497 content::NOTIFICATION_LOAD_STOP, 501 content::NOTIFICATION_LOAD_STOP,
498 content::Source<NavigationController>( 502 content::Source<NavigationController>(
499 &browser()->tab_strip_model()->GetActiveWebContents()-> 503 &browser()->tab_strip_model()->GetActiveWebContents()->
500 GetController())); 504 GetController()));
501 LOG(INFO) << "Reloading."; 505 LOG(INFO) << "Reloading.";
502 chrome::Reload(browser(), CURRENT_TAB); 506 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB);
503 reload_observer.Wait(); 507 reload_observer.Wait();
504 LOG(INFO) << "Reloading - done."; 508 LOG(INFO) << "Reloading - done.";
505 EXPECT_TRUE(process_map->Contains( 509 EXPECT_TRUE(process_map->Contains(
506 contents->GetRenderProcessHost()->GetID())); 510 contents->GetRenderProcessHost()->GetID()));
507 511
508 // Disable app and reload the page. 512 // Disable app and reload the page.
509 LOG(INFO) << "Disabling extension."; 513 LOG(INFO) << "Disabling extension.";
510 DisableExtension(app->id()); 514 DisableExtension(app->id());
511 LOG(INFO) << "Disabling extension - done."; 515 LOG(INFO) << "Disabling extension - done.";
512 content::WindowedNotificationObserver reload_observer2( 516 content::WindowedNotificationObserver reload_observer2(
513 content::NOTIFICATION_LOAD_STOP, 517 content::NOTIFICATION_LOAD_STOP,
514 content::Source<NavigationController>( 518 content::Source<NavigationController>(
515 &browser()->tab_strip_model()->GetActiveWebContents()-> 519 &browser()->tab_strip_model()->GetActiveWebContents()->
516 GetController())); 520 GetController()));
517 LOG(INFO) << "Reloading."; 521 LOG(INFO) << "Reloading.";
518 chrome::Reload(browser(), CURRENT_TAB); 522 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB);
519 reload_observer2.Wait(); 523 reload_observer2.Wait();
520 LOG(INFO) << "Reloading - done."; 524 LOG(INFO) << "Reloading - done.";
521 EXPECT_FALSE(process_map->Contains( 525 EXPECT_FALSE(process_map->Contains(
522 contents->GetRenderProcessHost()->GetID())); 526 contents->GetRenderProcessHost()->GetID()));
523 } 527 }
524 528
525 // Ensure that reloading a URL with JavaScript after installing or uninstalling 529 // Ensure that reloading a URL with JavaScript after installing or uninstalling
526 // it as an app correctly swaps the process. (http://crbug.com/80621) 530 // it as an app correctly swaps the process. (http://crbug.com/80621)
527 // 531 //
528 // Crashes on Windows and Mac. http://crbug.com/238670 532 // Crashes on Windows and Mac. http://crbug.com/238670
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 &is_installed)); 804 &is_installed));
801 ASSERT_TRUE(is_installed); 805 ASSERT_TRUE(is_installed);
802 806
803 // Crash the tab and reload it, chrome.app.isInstalled should still be true. 807 // Crash the tab and reload it, chrome.app.isInstalled should still be true.
804 content::CrashTab(browser()->tab_strip_model()->GetActiveWebContents()); 808 content::CrashTab(browser()->tab_strip_model()->GetActiveWebContents());
805 content::WindowedNotificationObserver observer( 809 content::WindowedNotificationObserver observer(
806 content::NOTIFICATION_LOAD_STOP, 810 content::NOTIFICATION_LOAD_STOP,
807 content::Source<NavigationController>( 811 content::Source<NavigationController>(
808 &browser()->tab_strip_model()->GetActiveWebContents()-> 812 &browser()->tab_strip_model()->GetActiveWebContents()->
809 GetController())); 813 GetController()));
810 chrome::Reload(browser(), CURRENT_TAB); 814 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB);
811 observer.Wait(); 815 observer.Wait();
812 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 816 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
813 contents, 817 contents,
814 "window.domAutomationController.send(chrome.app.isInstalled)", 818 "window.domAutomationController.send(chrome.app.isInstalled)",
815 &is_installed)); 819 &is_installed));
816 ASSERT_TRUE(is_installed); 820 ASSERT_TRUE(is_installed);
817 } 821 }
818 822
819 // Test that a cross-process navigation away from a hosted app stays in the same 823 // Test that a cross-process navigation away from a hosted app stays in the same
820 // BrowsingInstance, so that postMessage calls to the app's other windows still 824 // BrowsingInstance, so that postMessage calls to the app's other windows still
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 // Navigate the popup to another process outside the app. 856 // Navigate the popup to another process outside the app.
853 GURL non_app_url(base_url.Resolve("path3/empty.html")); 857 GURL non_app_url(base_url.Resolve("path3/empty.html"));
854 ui_test_utils::NavigateToURL(active_browser_list->get(1), non_app_url); 858 ui_test_utils::NavigateToURL(active_browser_list->get(1), non_app_url);
855 SiteInstance* new_instance = popup_contents->GetSiteInstance(); 859 SiteInstance* new_instance = popup_contents->GetSiteInstance();
856 EXPECT_NE(app_instance, new_instance); 860 EXPECT_NE(app_instance, new_instance);
857 861
858 // It should still be in the same BrowsingInstance, allowing postMessage to 862 // It should still be in the same BrowsingInstance, allowing postMessage to
859 // work. 863 // work.
860 EXPECT_TRUE(app_instance->IsRelatedSiteInstance(new_instance)); 864 EXPECT_TRUE(app_instance->IsRelatedSiteInstance(new_instance));
861 } 865 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/web_request/web_request_apitest.cc ('k') | chrome/browser/extensions/content_script_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698