OLD | NEW |
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_service.h" | 8 #include "chrome/browser/extensions/extension_service.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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 DisableExtension(app->id()); | 409 DisableExtension(app->id()); |
410 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); | 410 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); |
411 EXPECT_FALSE(process_map->Contains( | 411 EXPECT_FALSE(process_map->Contains( |
412 contents->render_view_host()->process()->GetID())); | 412 contents->render_view_host()->process()->GetID())); |
413 | 413 |
414 // Enable app and reload the page. | 414 // Enable app and reload the page. |
415 EnableExtension(app->id()); | 415 EnableExtension(app->id()); |
416 ui_test_utils::WindowedNotificationObserver reload_observer( | 416 ui_test_utils::WindowedNotificationObserver reload_observer( |
417 content::NOTIFICATION_LOAD_STOP, | 417 content::NOTIFICATION_LOAD_STOP, |
418 content::Source<NavigationController>( | 418 content::Source<NavigationController>( |
419 &browser()->GetSelectedTabContentsWrapper()->controller())); | 419 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> |
| 420 controller())); |
420 browser()->Reload(CURRENT_TAB); | 421 browser()->Reload(CURRENT_TAB); |
421 reload_observer.Wait(); | 422 reload_observer.Wait(); |
422 EXPECT_TRUE(process_map->Contains( | 423 EXPECT_TRUE(process_map->Contains( |
423 contents->render_view_host()->process()->GetID())); | 424 contents->render_view_host()->process()->GetID())); |
424 | 425 |
425 // Disable app and reload the page. | 426 // Disable app and reload the page. |
426 DisableExtension(app->id()); | 427 DisableExtension(app->id()); |
427 ui_test_utils::WindowedNotificationObserver reload_observer2( | 428 ui_test_utils::WindowedNotificationObserver reload_observer2( |
428 content::NOTIFICATION_LOAD_STOP, | 429 content::NOTIFICATION_LOAD_STOP, |
429 content::Source<NavigationController>( | 430 content::Source<NavigationController>( |
430 &browser()->GetSelectedTabContentsWrapper()->controller())); | 431 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> |
| 432 controller())); |
431 browser()->Reload(CURRENT_TAB); | 433 browser()->Reload(CURRENT_TAB); |
432 reload_observer2.Wait(); | 434 reload_observer2.Wait(); |
433 EXPECT_FALSE(process_map->Contains( | 435 EXPECT_FALSE(process_map->Contains( |
434 contents->render_view_host()->process()->GetID())); | 436 contents->render_view_host()->process()->GetID())); |
435 | 437 |
436 // Enable app and reload via JavaScript. | 438 // Enable app and reload via JavaScript. |
437 EnableExtension(app->id()); | 439 EnableExtension(app->id()); |
438 ui_test_utils::WindowedNotificationObserver js_reload_observer( | 440 ui_test_utils::WindowedNotificationObserver js_reload_observer( |
439 content::NOTIFICATION_LOAD_STOP, | 441 content::NOTIFICATION_LOAD_STOP, |
440 content::Source<NavigationController>( | 442 content::Source<NavigationController>( |
441 &browser()->GetSelectedTabContentsWrapper()->controller())); | 443 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> |
| 444 controller())); |
442 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(contents->render_view_host(), | 445 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(contents->render_view_host(), |
443 L"", L"location.reload();")); | 446 L"", L"location.reload();")); |
444 js_reload_observer.Wait(); | 447 js_reload_observer.Wait(); |
445 EXPECT_TRUE(process_map->Contains( | 448 EXPECT_TRUE(process_map->Contains( |
446 contents->render_view_host()->process()->GetID())); | 449 contents->render_view_host()->process()->GetID())); |
447 | 450 |
448 // Disable app and reload via JavaScript. | 451 // Disable app and reload via JavaScript. |
449 DisableExtension(app->id()); | 452 DisableExtension(app->id()); |
450 ui_test_utils::WindowedNotificationObserver js_reload_observer2( | 453 ui_test_utils::WindowedNotificationObserver js_reload_observer2( |
451 content::NOTIFICATION_LOAD_STOP, | 454 content::NOTIFICATION_LOAD_STOP, |
452 content::Source<NavigationController>( | 455 content::Source<NavigationController>( |
453 &browser()->GetSelectedTabContentsWrapper()->controller())); | 456 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> |
| 457 controller())); |
454 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(contents->render_view_host(), | 458 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(contents->render_view_host(), |
455 L"", L"location.reload();")); | 459 L"", L"location.reload();")); |
456 js_reload_observer2.Wait(); | 460 js_reload_observer2.Wait(); |
457 EXPECT_FALSE(process_map->Contains( | 461 EXPECT_FALSE(process_map->Contains( |
458 contents->render_view_host()->process()->GetID())); | 462 contents->render_view_host()->process()->GetID())); |
459 } | 463 } |
460 | 464 |
461 // Tests that if we have a non-app process (path3/container.html) that has an | 465 // Tests that if we have a non-app process (path3/container.html) that has an |
462 // iframe with a URL in the app's extent (path1/iframe.html), then opening a | 466 // iframe with a URL in the app's extent (path1/iframe.html), then opening a |
463 // link from that iframe to a new window to a URL in the app's extent (path1/ | 467 // link from that iframe to a new window to a URL in the app's extent (path1/ |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 contents->render_view_host(), L"", | 596 contents->render_view_host(), L"", |
593 L"window.domAutomationController.send(chrome.app.isInstalled)", | 597 L"window.domAutomationController.send(chrome.app.isInstalled)", |
594 &is_installed)); | 598 &is_installed)); |
595 ASSERT_TRUE(is_installed); | 599 ASSERT_TRUE(is_installed); |
596 | 600 |
597 // Crash the tab and reload it, chrome.app.isInstalled should still be true. | 601 // Crash the tab and reload it, chrome.app.isInstalled should still be true. |
598 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); | 602 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); |
599 ui_test_utils::WindowedNotificationObserver observer( | 603 ui_test_utils::WindowedNotificationObserver observer( |
600 content::NOTIFICATION_LOAD_STOP, | 604 content::NOTIFICATION_LOAD_STOP, |
601 content::Source<NavigationController>( | 605 content::Source<NavigationController>( |
602 &browser()->GetSelectedTabContentsWrapper()->controller())); | 606 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> |
| 607 controller())); |
603 browser()->Reload(CURRENT_TAB); | 608 browser()->Reload(CURRENT_TAB); |
604 observer.Wait(); | 609 observer.Wait(); |
605 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 610 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
606 contents->render_view_host(), L"", | 611 contents->render_view_host(), L"", |
607 L"window.domAutomationController.send(chrome.app.isInstalled)", | 612 L"window.domAutomationController.send(chrome.app.isInstalled)", |
608 &is_installed)); | 613 &is_installed)); |
609 ASSERT_TRUE(is_installed); | 614 ASSERT_TRUE(is_installed); |
610 } | 615 } |
OLD | NEW |