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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/sessions/session_restore.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/isolated_app_browsertest.cc
diff --git a/chrome/browser/extensions/isolated_app_browsertest.cc b/chrome/browser/extensions/isolated_app_browsertest.cc
index a4d0cf5c5d4b949dbb3969221aa9eb3f3f1c1327..47bb6247cb97162c2cd39067c4c1b57312b33c12 100644
--- a/chrome/browser/extensions/isolated_app_browsertest.cc
+++ b/chrome/browser/extensions/isolated_app_browsertest.cc
@@ -4,6 +4,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/automation/automation_util.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -11,16 +12,20 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_tabstrip.h"
+#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
+#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
#include "net/base/mock_host_resolver.h"
+#include "content/public/test/test_navigation_observer.h"
using content::ExecuteJavaScript;
using content::ExecuteJavaScriptAndExtractString;
@@ -59,6 +64,40 @@ class IsolatedAppTest : public ExtensionBrowserTest {
return installed_app;
}
+ void CloseBrowserSynchronously() {
+ content::WindowedNotificationObserver observer(
+ chrome::NOTIFICATION_BROWSER_CLOSED,
+ content::NotificationService::AllSources());
+ browser()->window()->Close();
+#if defined(OS_MACOSX)
+ // BrowserWindowController depends on the auto release pool being recycled
+ // in the message loop to delete itself, which frees the Browser object
+ // which fires this event.
+ AutoreleasePool()->Recycle();
+#endif
+ observer.Wait();
+ }
+
+ Browser* QuitBrowserAndRestore(int expected_tab_count) {
+ Profile* profile = browser()->profile();
+
+ // Close the browser.
+ g_browser_process->AddRefModule();
+ CloseBrowserSynchronously();
+
+ // Create a new window, which should trigger session restore.
+ ui_test_utils::BrowserAddedObserver window_observer;
+ content::TestNavigationObserver navigation_observer(
+ content::NotificationService::AllSources(), NULL, expected_tab_count);
+ chrome::NewEmptyWindow(profile);
+ Browser* new_browser = window_observer.WaitForSingleNewBrowser();
+ navigation_observer.Wait();
+ g_browser_process->ReleaseModule();
+ set_browser(new_browser);
+
+ return new_browser;
+ }
+
private:
virtual void SetUpCommandLine(CommandLine* command_line) {
ExtensionBrowserTest::SetUpCommandLine(command_line);
@@ -368,4 +407,34 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, SessionStorage) {
chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(),
L"", kRetrieveSessionStorage.c_str(), &result));
EXPECT_EQ("ss_normal", result);
+
+ // TODO(ajwong): Whack the browser and resart.
+ QuitBrowserAndRestore(1);
+
+ ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1")));
+ ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app2")));
+
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), base_url.Resolve("app1/main.html"),
+ CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
+ chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(),
+ L"", kRetrieveSessionStorage.c_str(), &result));
+ EXPECT_EQ("ss_app1", result);
+
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), base_url.Resolve("app2/main.html"),
+ CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
+ chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(),
+ L"", kRetrieveSessionStorage.c_str(), &result));
+ EXPECT_EQ("ss_app2", result);
+
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), base_url.Resolve("non_app/main.html"),
+ CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ ASSERT_TRUE(ExecuteJavaScriptAndExtractString(
+ chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(),
+ L"", kRetrieveSessionStorage.c_str(), &result));
+ EXPECT_EQ("ss_normal", result);
}
« 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