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

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

Issue 10850010: Make session restore understand that tabs have multiple SessionStorageNamespaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: attempt to fix unittsets. Created 8 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/sessions/session_restore.cc » ('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) 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/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/automation/automation_util.h" 6 #include "chrome/browser/automation/automation_util.h"
7 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/extensions/extension_host.h" 9 #include "chrome/browser/extensions/extension_host.h"
9 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_commands.h" 13 #include "chrome/browser/ui/browser_commands.h"
13 #include "chrome/browser/ui/browser_tabstrip.h" 14 #include "chrome/browser/ui/browser_tabstrip.h"
15 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents.h" 16 #include "chrome/browser/ui/tab_contents/tab_contents.h"
17 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
17 #include "chrome/test/base/ui_test_utils.h" 20 #include "chrome/test/base/ui_test_utils.h"
21 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/render_process_host.h" 22 #include "content/public/browser/render_process_host.h"
19 #include "content/public/browser/render_view_host.h" 23 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/site_instance.h" 24 #include "content/public/browser/site_instance.h"
21 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
22 #include "content/public/test/browser_test_utils.h" 26 #include "content/public/test/browser_test_utils.h"
23 #include "net/base/mock_host_resolver.h" 27 #include "net/base/mock_host_resolver.h"
28 #include "content/public/test/test_navigation_observer.h"
24 29
25 using content::ExecuteJavaScript; 30 using content::ExecuteJavaScript;
26 using content::ExecuteJavaScriptAndExtractString; 31 using content::ExecuteJavaScriptAndExtractString;
27 using content::NavigationController; 32 using content::NavigationController;
28 using content::WebContents; 33 using content::WebContents;
29 using content::RenderViewHost; 34 using content::RenderViewHost;
30 35
31 namespace { 36 namespace {
32 37
33 std::wstring WrapForJavascriptAndExtract( 38 std::wstring WrapForJavascriptAndExtract(
(...skipping 18 matching lines...) Expand all
52 Profile* profile = 57 Profile* profile =
53 Profile::FromBrowserContext(contents->GetBrowserContext()); 58 Profile::FromBrowserContext(contents->GetBrowserContext());
54 ExtensionService* service = profile->GetExtensionService(); 59 ExtensionService* service = profile->GetExtensionService();
55 if (service) { 60 if (service) {
56 installed_app = service->GetInstalledAppForRenderer( 61 installed_app = service->GetInstalledAppForRenderer(
57 contents->GetRenderProcessHost()->GetID()); 62 contents->GetRenderProcessHost()->GetID());
58 } 63 }
59 return installed_app; 64 return installed_app;
60 } 65 }
61 66
67 void CloseBrowserSynchronously() {
68 content::WindowedNotificationObserver observer(
69 chrome::NOTIFICATION_BROWSER_CLOSED,
70 content::NotificationService::AllSources());
71 browser()->window()->Close();
72 #if defined(OS_MACOSX)
73 // BrowserWindowController depends on the auto release pool being recycled
74 // in the message loop to delete itself, which frees the Browser object
75 // which fires this event.
76 AutoreleasePool()->Recycle();
77 #endif
78 observer.Wait();
79 }
80
81 Browser* QuitBrowserAndRestore(int expected_tab_count) {
82 Profile* profile = browser()->profile();
83
84 // Close the browser.
85 g_browser_process->AddRefModule();
86 CloseBrowserSynchronously();
87
88 // Create a new window, which should trigger session restore.
89 ui_test_utils::BrowserAddedObserver window_observer;
90 content::TestNavigationObserver navigation_observer(
91 content::NotificationService::AllSources(), NULL, expected_tab_count);
92 chrome::NewEmptyWindow(profile);
93 Browser* new_browser = window_observer.WaitForSingleNewBrowser();
94 navigation_observer.Wait();
95 g_browser_process->ReleaseModule();
96 set_browser(new_browser);
97
98 return new_browser;
99 }
100
62 private: 101 private:
63 virtual void SetUpCommandLine(CommandLine* command_line) { 102 virtual void SetUpCommandLine(CommandLine* command_line) {
64 ExtensionBrowserTest::SetUpCommandLine(command_line); 103 ExtensionBrowserTest::SetUpCommandLine(command_line);
65 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); 104 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
66 } 105 }
67 }; 106 };
68 107
69 } // namespace 108 } // namespace
70 109
71 // Tests that cookies set within an isolated app are not visible to normal 110 // Tests that cookies set within an isolated app are not visible to normal
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 L"", kRetrieveSessionStorage.c_str(), &result)); 400 L"", kRetrieveSessionStorage.c_str(), &result));
362 EXPECT_EQ("ss_app2", result); 401 EXPECT_EQ("ss_app2", result);
363 402
364 ui_test_utils::NavigateToURLWithDisposition( 403 ui_test_utils::NavigateToURLWithDisposition(
365 browser(), base_url.Resolve("non_app/main.html"), 404 browser(), base_url.Resolve("non_app/main.html"),
366 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 405 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
367 ASSERT_TRUE(ExecuteJavaScriptAndExtractString( 406 ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
368 chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(), 407 chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(),
369 L"", kRetrieveSessionStorage.c_str(), &result)); 408 L"", kRetrieveSessionStorage.c_str(), &result));
370 EXPECT_EQ("ss_normal", result); 409 EXPECT_EQ("ss_normal", result);
410
411 // TODO(ajwong): Whack the browser and resart.
412 QuitBrowserAndRestore(1);
413
414 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1")));
415 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app2")));
416
417 ui_test_utils::NavigateToURLWithDisposition(
418 browser(), base_url.Resolve("app1/main.html"),
419 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
420 ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
421 chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(),
422 L"", kRetrieveSessionStorage.c_str(), &result));
423 EXPECT_EQ("ss_app1", result);
424
425 ui_test_utils::NavigateToURLWithDisposition(
426 browser(), base_url.Resolve("app2/main.html"),
427 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
428 ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
429 chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(),
430 L"", kRetrieveSessionStorage.c_str(), &result));
431 EXPECT_EQ("ss_app2", result);
432
433 ui_test_utils::NavigateToURLWithDisposition(
434 browser(), base_url.Resolve("non_app/main.html"),
435 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
436 ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
437 chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(),
438 L"", kRetrieveSessionStorage.c_str(), &result));
439 EXPECT_EQ("ss_normal", result);
371 } 440 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sessions/session_restore.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698