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

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

Issue 8372036: Ensure forced process swaps use the correct page_id and SiteInstance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a test Created 9 years, 1 month 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 | « no previous file | chrome/test/data/extensions/api_test/app_process/path1/simple.html » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/extensions/extension_apitest.h" 6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/extensions/extension_host.h" 7 #include "chrome/browser/extensions/extension_host.h"
8 #include "chrome/browser/extensions/extension_process_manager.h" 8 #include "chrome/browser/extensions/extension_process_manager.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 content::NOTIFICATION_LOAD_STOP, 362 content::NOTIFICATION_LOAD_STOP,
363 content::Source<NavigationController>( 363 content::Source<NavigationController>(
364 &browser()->GetSelectedTabContentsWrapper()->controller())); 364 &browser()->GetSelectedTabContentsWrapper()->controller()));
365 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(contents->render_view_host(), 365 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(contents->render_view_host(),
366 L"", L"location.reload();")); 366 L"", L"location.reload();"));
367 js_reload_observer2.Wait(); 367 js_reload_observer2.Wait();
368 EXPECT_FALSE(extension_process_manager->IsExtensionProcess( 368 EXPECT_FALSE(extension_process_manager->IsExtensionProcess(
369 contents->render_view_host()->process()->id())); 369 contents->render_view_host()->process()->id()));
370 } 370 }
371 371
372 // Ensure that page_ids are handled correctly when we force a process swap
373 // for an installed or uninstalled app. (http://crbug.com/102408)
374 IN_PROC_BROWSER_TEST_F(AppApiTest, BackToAppProcess) {
375 ExtensionProcessManager* extension_process_manager =
376 browser()->profile()->GetExtensionProcessManager();
377
378 host_resolver()->AddRule("*", "127.0.0.1");
379 ASSERT_TRUE(test_server()->Start());
380
381 // The app under test acts on URLs whose host is "localhost",
382 // so the URLs we navigate to must have host "localhost".
383 GURL base_url = GetTestBaseURL("app_process");
384
385 // Load an app URL before loading the app.
386 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html"));
387 TabContents* contents = browser()->GetTabContentsAt(0);
388 EXPECT_FALSE(extension_process_manager->IsExtensionProcess(
389 contents->render_view_host()->process()->id()));
390 int orig_page_id = contents->controller().GetLastCommittedEntry()->page_id();
391
392 // Navigate to a second app URL before loading the app.
393 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html"));
394 EXPECT_FALSE(extension_process_manager->IsExtensionProcess(
395 contents->render_view_host()->process()->id()));
396 EXPECT_EQ(orig_page_id + 1,
397 contents->controller().GetLastCommittedEntry()->page_id());
398
399 // Load app and go back. We expect a process swap, but we also expect the
400 // same page_id to be used and the SiteInstance to be updated.
401 const Extension* app =
402 LoadExtension(test_data_dir_.AppendASCII("app_process"));
403 ASSERT_TRUE(app);
404 ui_test_utils::WindowedNotificationObserver back_observer(
405 content::NOTIFICATION_LOAD_STOP,
406 content::Source<NavigationController>(
407 &browser()->GetSelectedTabContentsWrapper()->controller()));
408 browser()->GoBack(CURRENT_TAB);
409 back_observer.Wait();
410 EXPECT_TRUE(extension_process_manager->IsExtensionProcess(
411 contents->render_view_host()->process()->id()));
412 EXPECT_EQ(orig_page_id,
413 contents->controller().GetLastCommittedEntry()->page_id());
414
415 // Now navigate to a different app URL via the renderer process.
416 // The NavigationController should recognize it as a new navigation.
417 NavigateTabHelper(contents, base_url.Resolve("path1/simple.html"));
418 EXPECT_TRUE(extension_process_manager->IsExtensionProcess(
419 contents->render_view_host()->process()->id()));
420 EXPECT_EQ(orig_page_id + 2,
421 contents->controller().GetLastCommittedEntry()->page_id());
422 }
423
372 424
373 // Tests that if we have a non-app process (path3/container.html) that has an 425 // Tests that if we have a non-app process (path3/container.html) that has an
374 // iframe with a URL in the app's extent (path1/iframe.html), then opening a 426 // iframe with a URL in the app's extent (path1/iframe.html), then opening a
375 // link from that iframe to a new window to a URL in the app's extent (path1/ 427 // link from that iframe to a new window to a URL in the app's extent (path1/
376 // empty.html) results in the new window being in an app process. See 428 // empty.html) results in the new window being in an app process. See
377 // http://crbug.com/89272 for more details. 429 // http://crbug.com/89272 for more details.
378 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) { 430 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) {
379 CommandLine::ForCurrentProcess()->AppendSwitch( 431 CommandLine::ForCurrentProcess()->AppendSwitch(
380 switches::kDisablePopupBlocking); 432 switches::kDisablePopupBlocking);
381 433
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 content::Source<NavigationController>( 565 content::Source<NavigationController>(
514 &browser()->GetSelectedTabContentsWrapper()->controller())); 566 &browser()->GetSelectedTabContentsWrapper()->controller()));
515 browser()->Reload(CURRENT_TAB); 567 browser()->Reload(CURRENT_TAB);
516 observer.Wait(); 568 observer.Wait();
517 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 569 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
518 contents->render_view_host(), L"", 570 contents->render_view_host(), L"",
519 L"window.domAutomationController.send(chrome.app.isInstalled)", 571 L"window.domAutomationController.send(chrome.app.isInstalled)",
520 &is_installed)); 572 &is_installed));
521 ASSERT_TRUE(is_installed); 573 ASSERT_TRUE(is_installed);
522 } 574 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/app_process/path1/simple.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698