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

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

Issue 11734018: Revert 174880 due to compilation error in pdf_browsertest.cc (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1374/src/
Patch Set: Created 7 years, 11 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 (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 "chrome/browser/extensions/extension_apitest.h" 5 #include "chrome/browser/extensions/extension_apitest.h"
6 #include "chrome/browser/extensions/extension_host.h" 6 #include "chrome/browser/extensions/extension_host.h"
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/extension_system.h" 8 #include "chrome/browser/extensions/extension_system.h"
9 #include "chrome/browser/extensions/process_map.h" 9 #include "chrome/browser/extensions/process_map.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 chrome::GetWebContentsAt(browser(), 3)->GetRenderProcessHost()); 218 chrome::GetWebContentsAt(browser(), 3)->GetRenderProcessHost());
219 219
220 // If one of the popup tabs navigates back to the app, window.opener should 220 // If one of the popup tabs navigates back to the app, window.opener should
221 // be valid. 221 // be valid.
222 NavigateInRenderer(chrome::GetWebContentsAt(browser(), 6), app_url); 222 NavigateInRenderer(chrome::GetWebContentsAt(browser(), 6), app_url);
223 LOG(INFO) << "NavigateTabHelper 3."; 223 LOG(INFO) << "NavigateTabHelper 3.";
224 EXPECT_EQ(tab->GetRenderProcessHost(), 224 EXPECT_EQ(tab->GetRenderProcessHost(),
225 chrome::GetWebContentsAt(browser(), 6)->GetRenderProcessHost()); 225 chrome::GetWebContentsAt(browser(), 6)->GetRenderProcessHost());
226 bool windowOpenerValid = false; 226 bool windowOpenerValid = false;
227 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 227 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
228 chrome::GetWebContentsAt(browser(), 6)->GetRenderViewHost(), 228 chrome::GetWebContentsAt(browser(), 6)->GetRenderViewHost(), L"",
229 "", 229 L"window.domAutomationController.send(window.opener != null)",
230 "window.domAutomationController.send(window.opener != null)",
231 &windowOpenerValid)); 230 &windowOpenerValid));
232 ASSERT_TRUE(windowOpenerValid); 231 ASSERT_TRUE(windowOpenerValid);
233 232
234 LOG(INFO) << "End of test."; 233 LOG(INFO) << "End of test.";
235 } 234 }
236 235
237 // Test that hosted apps without the background permission use a process per app 236 // Test that hosted apps without the background permission use a process per app
238 // instance model, such that separate instances are in separate processes. 237 // instance model, such that separate instances are in separate processes.
239 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessInstances) { 238 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessInstances) {
240 TestAppInstancesHelper("app_process_instances"); 239 TestAppInstancesHelper("app_process_instances");
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 EXPECT_FALSE(process_map->Contains( 428 EXPECT_FALSE(process_map->Contains(
430 contents->GetRenderProcessHost()->GetID())); 429 contents->GetRenderProcessHost()->GetID()));
431 430
432 // Enable app and reload via JavaScript. 431 // Enable app and reload via JavaScript.
433 EnableExtension(app->id()); 432 EnableExtension(app->id());
434 content::WindowedNotificationObserver js_reload_observer( 433 content::WindowedNotificationObserver js_reload_observer(
435 content::NOTIFICATION_LOAD_STOP, 434 content::NOTIFICATION_LOAD_STOP,
436 content::Source<NavigationController>( 435 content::Source<NavigationController>(
437 &chrome::GetActiveWebContents(browser())->GetController())); 436 &chrome::GetActiveWebContents(browser())->GetController()));
438 ASSERT_TRUE(content::ExecuteJavaScript(contents->GetRenderViewHost(), 437 ASSERT_TRUE(content::ExecuteJavaScript(contents->GetRenderViewHost(),
439 "", "location.reload();")); 438 L"", L"location.reload();"));
440 js_reload_observer.Wait(); 439 js_reload_observer.Wait();
441 EXPECT_TRUE(process_map->Contains( 440 EXPECT_TRUE(process_map->Contains(
442 contents->GetRenderProcessHost()->GetID())); 441 contents->GetRenderProcessHost()->GetID()));
443 442
444 // Disable app and reload via JavaScript. 443 // Disable app and reload via JavaScript.
445 DisableExtension(app->id()); 444 DisableExtension(app->id());
446 content::WindowedNotificationObserver js_reload_observer2( 445 content::WindowedNotificationObserver js_reload_observer2(
447 content::NOTIFICATION_LOAD_STOP, 446 content::NOTIFICATION_LOAD_STOP,
448 content::Source<NavigationController>( 447 content::Source<NavigationController>(
449 &chrome::GetActiveWebContents(browser())->GetController())); 448 &chrome::GetActiveWebContents(browser())->GetController()));
450 ASSERT_TRUE(content::ExecuteJavaScript(contents->GetRenderViewHost(), 449 ASSERT_TRUE(content::ExecuteJavaScript(contents->GetRenderViewHost(),
451 "", "location = location;")); 450 L"", L"location = location;"));
452 js_reload_observer2.Wait(); 451 js_reload_observer2.Wait();
453 EXPECT_FALSE(process_map->Contains( 452 EXPECT_FALSE(process_map->Contains(
454 contents->GetRenderProcessHost()->GetID())); 453 contents->GetRenderProcessHost()->GetID()));
455 } 454 }
456 455
457 // Tests that if we have a non-app process (path3/container.html) that has an 456 // Tests that if we have a non-app process (path3/container.html) that has an
458 // iframe with a URL in the app's extent (path1/iframe.html), then opening a 457 // iframe with a URL in the app's extent (path1/iframe.html), then opening a
459 // link from that iframe to a new window to a URL in the app's extent (path1/ 458 // link from that iframe to a new window to a URL in the app's extent (path1/
460 // empty.html) results in the new window being in an app process. See 459 // empty.html) results in the new window being in an app process. See
461 // http://crbug.com/89272 for more details. 460 // http://crbug.com/89272 for more details.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 549
551 // Wait for app tab to be created and loaded. 550 // Wait for app tab to be created and loaded.
552 test_navigation_observer.WaitForObservation( 551 test_navigation_observer.WaitForObservation(
553 base::Bind(&content::RunMessageLoop), 552 base::Bind(&content::RunMessageLoop),
554 base::Bind(&MessageLoop::Quit, 553 base::Bind(&MessageLoop::Quit,
555 base::Unretained(MessageLoopForUI::current()))); 554 base::Unretained(MessageLoopForUI::current())));
556 555
557 // App has loaded, and chrome.app.isInstalled should be true. 556 // App has loaded, and chrome.app.isInstalled should be true.
558 bool is_installed = false; 557 bool is_installed = false;
559 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 558 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
560 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), 559 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"",
561 "", 560 L"window.domAutomationController.send(chrome.app.isInstalled)",
562 "window.domAutomationController.send(chrome.app.isInstalled)",
563 &is_installed)); 561 &is_installed));
564 ASSERT_TRUE(is_installed); 562 ASSERT_TRUE(is_installed);
565 } 563 }
566 564
567 // Tests that if we have an app process (path1/container.html) with a non-app 565 // Tests that if we have an app process (path1/container.html) with a non-app
568 // iframe (path3/iframe.html), then opening a link from that iframe to a new 566 // iframe (path3/iframe.html), then opening a link from that iframe to a new
569 // window to a same-origin non-app URL (path3/empty.html) should keep the window 567 // window to a same-origin non-app URL (path3/empty.html) should keep the window
570 // in the app process. 568 // in the app process.
571 // This is in contrast to OpenAppFromIframe, since here the popup will not be 569 // This is in contrast to OpenAppFromIframe, since here the popup will not be
572 // missing special permissions and should be scriptable from the iframe. 570 // missing special permissions and should be scriptable from the iframe.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 618
621 GURL base_url = GetTestBaseURL("app_process"); 619 GURL base_url = GetTestBaseURL("app_process");
622 620
623 // Load the app, chrome.app.isInstalled should be true. 621 // Load the app, chrome.app.isInstalled should be true.
624 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); 622 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html"));
625 WebContents* contents = chrome::GetWebContentsAt(browser(), 0); 623 WebContents* contents = chrome::GetWebContentsAt(browser(), 0);
626 EXPECT_TRUE(process_map->Contains( 624 EXPECT_TRUE(process_map->Contains(
627 contents->GetRenderProcessHost()->GetID())); 625 contents->GetRenderProcessHost()->GetID()));
628 bool is_installed = false; 626 bool is_installed = false;
629 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 627 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
630 contents->GetRenderViewHost(), 628 contents->GetRenderViewHost(), L"",
631 "", 629 L"window.domAutomationController.send(chrome.app.isInstalled)",
632 "window.domAutomationController.send(chrome.app.isInstalled)",
633 &is_installed)); 630 &is_installed));
634 ASSERT_TRUE(is_installed); 631 ASSERT_TRUE(is_installed);
635 632
636 // Crash the tab and reload it, chrome.app.isInstalled should still be true. 633 // Crash the tab and reload it, chrome.app.isInstalled should still be true.
637 content::CrashTab(chrome::GetActiveWebContents(browser())); 634 content::CrashTab(chrome::GetActiveWebContents(browser()));
638 content::WindowedNotificationObserver observer( 635 content::WindowedNotificationObserver observer(
639 content::NOTIFICATION_LOAD_STOP, 636 content::NOTIFICATION_LOAD_STOP,
640 content::Source<NavigationController>( 637 content::Source<NavigationController>(
641 &chrome::GetActiveWebContents(browser())->GetController())); 638 &chrome::GetActiveWebContents(browser())->GetController()));
642 chrome::Reload(browser(), CURRENT_TAB); 639 chrome::Reload(browser(), CURRENT_TAB);
643 observer.Wait(); 640 observer.Wait();
644 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 641 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
645 contents->GetRenderViewHost(), 642 contents->GetRenderViewHost(), L"",
646 "", 643 L"window.domAutomationController.send(chrome.app.isInstalled)",
647 "window.domAutomationController.send(chrome.app.isInstalled)",
648 &is_installed)); 644 &is_installed));
649 ASSERT_TRUE(is_installed); 645 ASSERT_TRUE(is_installed);
650 } 646 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698