Bug 1300647 - Part 2 - Test that the session store correctly handles the "Tab:KeepZombified" notification. r=ahunt
authorJan Henning <jh+bugzilla@buttercookie.de>
Sat, 10 Sep 2016 23:01:10 +0200
changeset 355148 8994c8040fc9d9168c6da72395ec636d1cdc6c2d
parent 355147 45c948de0bea73609bcdeef13f0b4a60bce18761
child 355149 9590f183073b871bc6b9577752e1479046b0fb81
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahunt
bugs1300647
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1300647 - Part 2 - Test that the session store correctly handles the "Tab:KeepZombified" notification. r=ahunt MozReview-Commit-ID: 2x9V4o5iPDg
mobile/android/tests/browser/chrome/test_session_zombification.html
--- 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>