--- a/mobile/android/tests/browser/chrome/test_session_zombification.html
+++ b/mobile/android/tests/browser/chrome/test_session_zombification.html
@@ -91,16 +91,91 @@ https://bugzilla.mozilla.org/show_bug.cg
// Switch back to the test tab and wait for it to reload
BrowserApp.selectTab(tabTest);
yield promiseBrowserEvent(tabTest.browser, "DOMContentLoaded");
// Check that the test tab has loaded the correct url
is(tabTest.browser.currentURI.spec, url2, "Test tab is showing the second URL.");
});
+ add_task(function* test_sessionStoreKeepAsZombie() {
+ chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
+ let BrowserApp = chromeWin.BrowserApp;
+ let observerService = Services.obs;
+
+ SimpleTest.registerCleanupFunction(function() {
+ BrowserApp.closeTab(tabBlank);
+ BrowserApp.closeTab(tabTest);
+ });
+
+ // Add a new tab with some content
+ tabTest = BrowserApp.addTab(url1 , { selected: true, parentId: BrowserApp.selectedTab.id });
+ yield promiseBrowserEvent(tabTest.browser, "DOMContentLoaded");
+
+ // Add a new tab with a blank page
+ tabBlank = BrowserApp.addTab("about:blank", { selected: true, parentId: BrowserApp.selectedTab.id });
+ yield promiseTabEvent(BrowserApp.deck, "TabSelect");
+ is(BrowserApp.selectedTab, tabBlank, "Test tab is in background.");
+
+ // Zombify the backgrounded test tab
+ MemoryObserver.zombify(tabTest);
+
+ // Check that the test tab is actually zombified
+ ok(tabTest.browser.__SS_restore, "Test tab is set for delay loading.");
+ is(tabTest.browser.currentURI.spec, "about:blank", "Test tab is zombified.");
+
+ // Tell the session store that it shouldn't restore that tab on selecting
+ observerService.notifyObservers(null, "Tab:KeepZombified", tabTest.id);
+
+ // Switch back to the test tab and check that it remains zombified
+ BrowserApp.selectTab(tabTest);
+ yield promiseTabEvent(BrowserApp.deck, "TabSelect");
+ is(BrowserApp.selectedTab, tabTest, "Test tab is selected.");
+ ok(tabTest.browser.__SS_restore, "Test tab is still set for delay loading.");
+
+ // Switch to the other tab and back again
+ BrowserApp.selectTab(tabBlank);
+ yield promiseTabEvent(BrowserApp.deck, "TabSelect");
+ is(BrowserApp.selectedTab, tabBlank, "Test tab is in background.");
+ BrowserApp.selectTab(tabTest);
+
+ // "Tab:KeepZombified should be good for one TabSelect only
+ yield promiseBrowserEvent(tabTest.browser, "DOMContentLoaded");
+ is(BrowserApp.selectedTab, tabTest, "Test tab is selected.");
+
+ // Check that the test tab is no longer a zombie and has loaded the correct url
+ ok(!tabTest.browser.__SS_restore, "Test tab is no longer set for delay loading.");
+ is(tabTest.browser.currentURI.spec, url1, "Test tab is showing the test URL.");
+
+ // Zombify the test tab again
+ BrowserApp.selectTab(tabBlank);
+ yield promiseTabEvent(BrowserApp.deck, "TabSelect");
+ is(BrowserApp.selectedTab, tabBlank, "Test tab is in background.");
+ MemoryObserver.zombify(tabTest);
+ ok(tabTest.browser.__SS_restore, "Test tab is set for delay loading.");
+ is(tabTest.browser.currentURI.spec, "about:blank", "Test tab is zombified.");
+
+ // Tell the session store that it shouldn't restore that tab on selecting
+ observerService.notifyObservers(null, "Tab:KeepZombified", tabTest.id);
+
+ // Switch back to the test tab and check that it remains zombified
+ BrowserApp.selectTab(tabTest);
+ yield promiseTabEvent(BrowserApp.deck, "TabSelect");
+ is(BrowserApp.selectedTab, tabTest, "Test tab is selected.");
+ ok(tabTest.browser.__SS_restore, "Test tab is still set for delay loading.");
+
+ // Fake an "application-foreground" notification
+ observerService.notifyObservers(null, "application-foreground", null);
+
+ // The test tab should now start reloading
+ yield promiseBrowserEvent(tabTest.browser, "DOMContentLoaded");
+ ok(!tabTest.browser.__SS_restore, "Test tab is no longer set for delay loading.");
+ is(tabTest.browser.currentURI.spec, url1, "Test tab is showing the test URL.");
+ });
+
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1044556">Mozilla Bug 1044556</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>