Bug 616511 - browser_sessionstore.js is failing and browser_select.js leave the content navigator bar opened [r=mfinkle]
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -1845,17 +1845,19 @@ var FormHelperUI = {
// Listen for form assistant messages from content
messageManager.addMessageListener("FormAssist:Show", this);
messageManager.addMessageListener("FormAssist:Hide", this);
messageManager.addMessageListener("FormAssist:Update", this);
messageManager.addMessageListener("FormAssist:AutoComplete", this);
// Listen for events where form assistant should be closed or updated
- document.getElementById("tabs").addEventListener("TabSelect", this, true);
+ let tabs = document.getElementById("tabs");
+ tabs.addEventListener("TabSelect", this, true);
+ tabs.addEventListener("TabClose", this, true);
Elements.browsers.addEventListener("URLChanged", this, true);
window.addEventListener("resize", this, true);
// Listen for modal dialog to show/hide the UI
messageManager.addMessageListener("DOMWillOpenModalDialog", this);
messageManager.addMessageListener("DOMModalDialogClosed", this);
Services.obs.addObserver(this, "softkb-change", false);
@@ -1910,16 +1912,17 @@ var FormHelperUI = {
},
handleEvent: function formHelperHandleEvent(aEvent) {
if (!this._open)
return;
switch (aEvent.type) {
case "TabSelect":
+ case "TabClose":
case "URLChanged":
this.hide();
break;
case "resize":
setTimeout(function(self) {
SelectHelperUI.resize();
self._container.contentHasChanged();
--- a/mobile/chrome/tests/browser_select.js
+++ b/mobile/chrome/tests/browser_select.js
@@ -30,22 +30,25 @@ function onPageReady() {
ContentTouchHandler.tapSingle(rect.left + 1, rect.top + 1);
waitFor(onUIReady, function() { return document.getElementById("select-container").hidden == false; });
}
function onUIReady() {
let selectui = document.getElementById("select-container");
is(selectui.hidden, false, "Select UI should be open");
+ is(Elements.contentNavigator.hidden, false, "Content Navigator should be visible");
let doneButton = document.getElementById("select-buttons-done");
doneButton.click();
// Close our tab when finished
Browser.closeTab(new_tab);
+ is(Elements.contentNavigator.hidden, true, "Content Navigator should be hidden");
+ is(selectui.hidden, true, "Select UI should be hidden");
// We must finialize the tests
finish();
}
function browserViewToClientRect(rect) {
let container = document.getElementById("browsers");
let containerBCR = container.getBoundingClientRect();
--- a/mobile/chrome/tests/browser_sessionstore.js
+++ b/mobile/chrome/tests/browser_sessionstore.js
@@ -41,63 +41,73 @@ function runNextTest() {
//------------------------------------------------------------------------------
// Case: Loading a page and test setting tab values
gTests.push({
desc: "Loading a page and test setting tab values",
_currentTab: null,
run: function() {
- Browser.addTab("about:blank", true);
this._currentTab = Browser.addTab(testURL, true);
- // Need to wait until the page is loaded
+ // Need to wait until the page is loaded and then wait till the tab has
+ // the right data store into __SS_data/__SS_extdata.
messageManager.addMessageListener("pageshow",
function(aMessage) {
if (gCurrentTest._currentTab.browser.currentURI.spec != "about:blank") {
messageManager.removeMessageListener(aMessage.name, arguments.callee);
- gCurrentTest.onPageReady();
+ waitFor(gCurrentTest.onPageReady, function() {
+ return Browser.selectedBrowser.__SS_data.entries[0].url != "about:blank";
+ });
}
});
},
onPageReady: function() {
// Add some data
ss.setTabValue(gCurrentTest._currentTab.chromeTab, "test1", "hello");
is(ss.getTabValue(gCurrentTest._currentTab.chromeTab, "test1"), "hello", "Set/Get tab value matches");
// Close tab and then undo the close
gCurrentTest.numTabs = Browser.tabs.length;
- gCurrentTest.numClosed = ss.getClosedTabCount(window);
+
+ let tabs = document.getElementById("tabs");
+ tabs.addEventListener("TabClose", function() {
+ tabs.removeEventListener("TabClose", arguments.callee, false);
+ setTimeout(function() { gCurrentTest.onTabClose(); }, 0);
+ }, false);
Browser.closeTab(gCurrentTest._currentTab);
+ gCurrentTest.numClosed = ss.getClosedTabCount(window);
+ },
+ onTabClose: function() {
isnot(Browser.tabs.length, gCurrentTest.numTabs, "Tab was closed");
- // XXX The behavior is different depending if the tests is launch alone or with the testsuite
- todo_isnot(ss.getClosedTabCount(window), gCurrentTest.numClosed, "Tab was stored");
+ is(ss.getClosedTabCount(window), gCurrentTest.numClosed, "Tab was stored");
// SessionStore works with chrome tab elements, not JS tab objects.
// Map the _currentTab from chrome to JS
gCurrentTest._currentTab = Browser.getTabFromChrome(ss.undoCloseTab(window, 0));
+ gCurrentTest.numClosed = ss.getClosedTabCount(window);
// Need to wait until the page is loaded
messageManager.addMessageListener("pageshow",
function(aMessage) {
if (gCurrentTest._currentTab.browser.currentURI.spec != "about:blank") {
messageManager.removeMessageListener(aMessage.name, arguments.callee);
- gCurrentTest.onPageUndo();
+ setTimeout(function() { gCurrentTest.onPageUndo(); }, 0);
}
});
},
onPageUndo: function() {
is(Browser.tabs.length, gCurrentTest.numTabs, "Tab was reopened");
// XXX The behavior is different depending if the tests is launch alone or with the testsuite
- todo_is(ss.getClosedTabCount(window), gCurrentTest.numClosed, "Tab was removed from store");
+ is(ss.getClosedTabCount(window), gCurrentTest.numClosed, "Tab was removed from store");
is(ss.getTabValue(gCurrentTest._currentTab.chromeTab, "test1"), "hello", "Set/Get tab value matches after un-close");
ss.deleteTabValue(gCurrentTest._currentTab.chromeTab, "test1");
is(ss.getTabValue(gCurrentTest._currentTab.chromeTab, "test1"), "", "Set/Get tab value matches after removing value");
// Shutdown
Browser.closeTab(gCurrentTest._currentTab);
--- a/mobile/components/SessionStore.js
+++ b/mobile/components/SessionStore.js
@@ -176,20 +176,16 @@ SessionStore.prototype = {
this.saveState();
break;
}
},
handleEvent: function ss_handleEvent(aEvent) {
let window = aEvent.currentTarget.ownerDocument.defaultView;
switch (aEvent.type) {
- case "load":
- case "pageshow":
- this.onTabLoad(window, aEvent.currentTarget, aEvent);
- break;
case "TabOpen":
case "TabClose": {
let browser = aEvent.originalTarget.linkedBrowser;
if (aEvent.type == "TabOpen") {
this.onTabAdd(window, browser);
}
else {
this.onTabClose(window, browser);
@@ -202,21 +198,17 @@ SessionStore.prototype = {
this.onTabSelect(window, browser);
break;
}
}
},
receiveMessage: function ss_receiveMessage(aMessage) {
let window = aMessage.target.ownerDocument.defaultView;
- switch (aMessage.name) {
- case "pageshow":
- this.onTabLoad(window, aMessage.target, aMessage);
- break;
- }
+ this.onTabLoad(window, aMessage.target, aMessage);
},
onWindowOpen: function ss_onWindowOpen(aWindow) {
// Return if window has already been initialized
if (aWindow && aWindow.__SSID && this._windows[aWindow.__SSID])
return;
// Ignore non-browser windows and windows opened while shutting down