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

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

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

Powered by Google App Engine
This is Rietveld 408576698