From 8b5464e12b4e283a4bf206319a8507a2b890161e Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 9 Jun 2011 11:51:05 -0700 Subject: [PATCH] Backing out revisions 33bcd05554f3, d8b5c9736831, 59c84742872f, f5a456d99df9, d580181e5434, 61e1aa1afa09, a1b563094e5a to fix Moth orange. --- browser/base/content/browser-tabview.js | 41 ++----- browser/base/content/tabview/drag.js | 13 +++ browser/base/content/tabview/groupitems.js | 39 +++---- browser/base/content/tabview/items.js | 8 +- browser/base/content/tabview/storage.js | 9 -- browser/base/content/tabview/tabitems.js | 7 +- browser/base/content/tabview/ui.js | 106 ++++++++---------- browser/base/content/test/tabview/Makefile.in | 4 - .../test/tabview/browser_tabview_bug587276.js | 37 +++--- .../test/tabview/browser_tabview_bug595020.js | 37 ------ .../test/tabview/browser_tabview_bug607108.js | 33 ------ .../test/tabview/browser_tabview_bug622872.js | 7 +- .../test/tabview/browser_tabview_bug630102.js | 72 +++++++----- .../test/tabview/browser_tabview_bug633190.js | 86 -------------- .../test/tabview/browser_tabview_bug649319.js | 88 --------------- .../test/tabview/browser_tabview_bug655269.js | 20 ---- .../sessionstore/src/nsSessionStore.js | 9 +- .../sessionstore/test/browser/Makefile.in | 1 - .../test/browser/browser_659591.js | 32 ------ 19 files changed, 153 insertions(+), 496 deletions(-) delete mode 100644 browser/base/content/test/tabview/browser_tabview_bug595020.js delete mode 100644 browser/base/content/test/tabview/browser_tabview_bug607108.js delete mode 100644 browser/base/content/test/tabview/browser_tabview_bug633190.js delete mode 100644 browser/base/content/test/tabview/browser_tabview_bug649319.js delete mode 100644 browser/base/content/test/tabview/browser_tabview_bug655269.js delete mode 100644 browser/components/sessionstore/test/browser/browser_659591.js diff --git a/browser/base/content/browser-tabview.js b/browser/base/content/browser-tabview.js index 51405019f07..3aebdf4554f 100644 --- a/browser/base/content/browser-tabview.js +++ b/browser/base/content/browser-tabview.js @@ -40,18 +40,15 @@ let TabView = { _deck: null, _iframe: null, _window: null, - _initialized: false, _browserKeyHandlerInitialized: false, _isFrameLoading: false, _initFrameCallbacks: [], - _lastSessionGroupName: null, PREF_BRANCH: "browser.panorama.", PREF_FIRST_RUN: "browser.panorama.experienced_first_run", PREF_STARTUP_PAGE: "browser.startup.page", PREF_RESTORE_ENABLED_ONCE: "browser.panorama.session_restore_enabled_once", - GROUPS_IDENTIFIER: "tabview-groups", VISIBILITY_IDENTIFIER: "tabview-visibility", - LAST_SESSION_GROUP_NAME_IDENTIFIER: "tabview-last-session-group-name", + GROUPS_IDENTIFIER: "tabview-groups", // ---------- get windowTitle() { @@ -92,9 +89,6 @@ let TabView = { // ---------- init: function TabView_init() { - if (this._initialized) - return; - if (this.firstUseExperienced) { if ((gBrowser.tabs.length - gBrowser.visibleTabs.length) > 0) this._setBrowserKeyHandlers(); @@ -126,16 +120,10 @@ let TabView = { }; gBrowser.tabContainer.addEventListener( "TabShow", this._tabShowEventListener, true); - - // grab the last used group title - this._lastSessionGroupName = sessionstore.getWindowValue(window, - this.LAST_SESSION_GROUP_NAME_IDENTIFIER); } } Services.prefs.addObserver(this.PREF_BRANCH, this, false); - - this._initialized = true; }, // ---------- @@ -150,17 +138,12 @@ let TabView = { // ---------- // Uninitializes TabView. uninit: function TabView_uninit() { - if (!this._initialized) - return; - Services.prefs.removeObserver(this.PREF_BRANCH, this); if (this._tabShowEventListener) { gBrowser.tabContainer.removeEventListener( "TabShow", this._tabShowEventListener, true); } - - this._initialized = false; }, // ---------- @@ -253,28 +236,18 @@ let TabView = { }, getActiveGroupName: function TabView_getActiveGroupName() { - if (!this._window) - return this._lastSessionGroupName; - // We get the active group this way, instead of querying // GroupItems.getActiveGroupItem() because the tabSelect event // will not have happened by the time the browser tries to // update the title. - let groupItem = null; let activeTab = window.gBrowser.selectedTab; - let activeTabItem = activeTab._tabViewTabItem; - - if (activeTab.pinned) { - // It's an app tab, so it won't have a .tabItem. However, its .parent - // will already be set as the active group. - groupItem = this._window.GroupItems.getActiveGroupItem(); - } else if (activeTabItem) { - groupItem = activeTabItem.parent; + if (activeTab._tabViewTabItem && activeTab._tabViewTabItem.parent){ + let groupName = activeTab._tabViewTabItem.parent.getTitle(); + if (groupName) + return groupName; } - - // groupItem may still be null, if the active tab is an orphan. - return groupItem ? groupItem.getTitle() : ""; - }, + return null; + }, // ---------- updateContextMenu: function(tab, popup) { diff --git a/browser/base/content/tabview/drag.js b/browser/base/content/tabview/drag.js index f40fcac87eb..30eb30b7490 100644 --- a/browser/base/content/tabview/drag.js +++ b/browser/base/content/tabview/drag.js @@ -85,6 +85,19 @@ function Drag(item, event, isFauxDrag) { this.safeWindowBounds = Items.getSafeWindowBounds(); Trenches.activateOthersTrenches(this.el); + + if (!isFauxDrag) { + // When a tab drag starts, make it the focused tab. + if (this.item.isAGroupItem) { + var tab = UI.getActiveTab(); + if (!tab || tab.parent != this.item) { + if (this.item._children.length) + UI.setActive(this.item._children[0]); + } + } else if (this.item.isATabItem) { + UI.setActive(this.item); + } + } }; Drag.prototype = { diff --git a/browser/base/content/tabview/groupitems.js b/browser/base/content/tabview/groupitems.js index 2fb68fa300d..c55ed4fa389 100644 --- a/browser/base/content/tabview/groupitems.js +++ b/browser/base/content/tabview/groupitems.js @@ -64,7 +64,6 @@ // bounds - a ; otherwise based on the locations of the provided elements // container - a DOM element to use as the container for this groupItem; otherwise will create // title - the title for the groupItem; otherwise blank -// focusTitle - focus the title's input field after creation // dontPush - true if this groupItem shouldn't push away or snap on creation; default is false // immediately - true if we want all placement immediately, not with animation function GroupItem(listOfEls, options) { @@ -219,13 +218,12 @@ function GroupItem(listOfEls, options) { if (!same) return; - if (!self.isDragging) - self.focusTitle(); + if (!self.isDragging) { + self.$titleShield.hide(); + (self.$title)[0].focus(); + } }); - if (options.focusTitle) - this.focusTitle(); - // ___ Stack Expander this.$expander = iQ("
") .addClass("stackExpander") @@ -406,14 +404,6 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), { this.$titleShield.css(css); }, - // ---------- - // Function: focusTitle - // Hide the title's shield and focus the underlying input field. - focusTitle: function GroupItem_focusTitle() { - this.$titleShield.hide(); - this.$title[0].focus(); - }, - // ---------- // Function: adjustAppTabTray // Used to adjust the appTabTray size, to split the appTabIcons across @@ -786,7 +776,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), { return (groupItem != self && !groupItem.getChildren().length); }); let group = (emptyGroups.length ? emptyGroups[0] : GroupItems.newGroup()); - group.newTab(null, { closedLastTab: true }); + group.newTab(); } this.destroy(); @@ -1024,7 +1014,8 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), { if (typeof item.setResizable == 'function') item.setResizable(false, options.immediately); - if (item == UI.getActiveTab() || !this._activeTab) + // if it is visually active, set it as the active tab. + if (iQ(item.container).hasClass("focus")) this.setActiveTab(item); // if it matches the selected tab or no active tab and the browser @@ -1791,16 +1782,14 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), { // ---------- // Function: newTab // Creates a new tab within this groupItem. - // Parameters: - // url - the new tab should open this url as well - // options - the options object - // closedLastTab - boolean indicates the last tab has just been closed - newTab: function GroupItem_newTab(url, options) { - if (options && options.closedLastTab) - UI.closedLastTabInTabView = true; - + newTab: function GroupItem_newTab(url) { UI.setActive(this, { dontSetActiveTabInGroup: true }); - gBrowser.loadOneTab(url || "about:blank", { inBackground: false }); + let newTab = gBrowser.loadOneTab(url || "about:blank", {inBackground: true}); + + // TabItems will have handled the new tab and added the tabItem property. + // We don't have to check if it's an app tab (and therefore wouldn't have a + // TabItem), since we've just created it. + newTab._tabViewTabItem.zoomIn(!url); }, // ---------- diff --git a/browser/base/content/tabview/items.js b/browser/base/content/tabview/items.js index 99add3765c3..7702d1d05ce 100644 --- a/browser/base/content/tabview/items.js +++ b/browser/base/content/tabview/items.js @@ -151,9 +151,10 @@ Item.prototype = { this.dragOptions = { cancelClass: 'close stackExpander', start: function(e, ui) { - UI.setActive(this); - if (this.isAGroupItem) + if (this.isAGroupItem) { + UI.setActive(this); this._unfreezeItemSize(); + } // if we start dragging a tab within a group, start with dropSpace on. else if (this.parent != null) this.parent._dropSpaceActive = true; @@ -200,7 +201,8 @@ Item.prototype = { minWidth: 90, minHeight: 90, start: function(e,ui) { - UI.setActive(this); + if (this.isAGroupItem) + UI.setActive(this); resize.info = new Drag(this, e); }, resize: function(e,ui) { diff --git a/browser/base/content/tabview/storage.js b/browser/base/content/tabview/storage.js index 2fdc448b11b..6a97f7ddb88 100644 --- a/browser/base/content/tabview/storage.js +++ b/browser/base/content/tabview/storage.js @@ -220,15 +220,6 @@ let Storage = { win, win.TabView.VISIBILITY_IDENTIFIER, data); }, - // ---------- - // Function: saveActiveGroupName - // Saves the active group's name for the given window. - saveActiveGroupName: function Storage_saveActiveGroupName(win) { - let groupName = win.TabView.getActiveGroupName(); - this._sessionStore.setWindowValue( - win, win.TabView.LAST_SESSION_GROUP_NAME_IDENTIFIER, groupName); - }, - // ---------- // Function: saveData // Generic routine for saving data to a window. diff --git a/browser/base/content/tabview/tabitems.js b/browser/base/content/tabview/tabitems.js index c090a1a4f9f..50d17934008 100644 --- a/browser/base/content/tabview/tabitems.js +++ b/browser/base/content/tabview/tabitems.js @@ -379,7 +379,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), { } } else { // create tab by double click is handled in UI_init(). - if (!UI.creatingNewOrphanTab) + if (!TabItems.creatingNewOrphanTab) GroupItems.newTab(self, {immediately: true}); } @@ -563,7 +563,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), { }); group = (emptyGroups.length ? emptyGroups[0] : GroupItems.newGroup()); } - group.newTab(null, { closedLastTab: true }); + group.newTab(); } // when "TabClose" event is fired, the browser tab is about to close and our // item "close" is fired before the browser tab actually get closed. @@ -665,8 +665,6 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), { } if (self.parent && self.parent.expanded) self.parent.collapse(); - - self._sendToSubscribers("zoomedIn"); } let animateZoom = gPrefBranch.getBoolPref("animate_zoom"); @@ -805,6 +803,7 @@ let TabItems = { _lastUpdateTime: Date.now(), _eventListeners: [], _pauseUpdateForTest: false, + creatingNewOrphanTab: false, tempCanvas: null, _reconnectingPaused: false, tabItemPadding: {}, diff --git a/browser/base/content/tabview/ui.js b/browser/base/content/tabview/ui.js index 4542215690f..4f4d3dce89a 100644 --- a/browser/base/content/tabview/ui.js +++ b/browser/base/content/tabview/ui.js @@ -128,7 +128,8 @@ let UI = { _storageBusyCount: 0, // Variable: isDOMWindowClosing - // Tells wether the parent window is about to close + // Tells wether we already received the "domwindowclosed" event and the parent + // windows is about to close. isDOMWindowClosing: false, // Variable: _browserKeys @@ -139,14 +140,6 @@ let UI = { // Used to prevent keypress being handled after quitting search mode. ignoreKeypressForSearch: false, - // Variable: creatingNewOrphanTab - // Used to keep track of whether we are creating a new oprhan tab or not. - creatingNewOrphanTab: false, - - // Variable: _lastOpenedTab - // Used to keep track of the last opened tab. - _lastOpenedTab: null, - // ---------- // Function: toString // Prints [UI] for debug use @@ -204,21 +197,20 @@ let UI = { (self._lastClickPositions.y - self.DBLCLICK_OFFSET) <= e.clientY && (self._lastClickPositions.y + self.DBLCLICK_OFFSET) >= e.clientY) { self.setActive(null); - self.creatingNewOrphanTab = true; + TabItems.creatingNewOrphanTab = true; + + let newTab = + gBrowser.loadOneTab("about:blank", { inBackground: true }); let box = new Rect(e.clientX - Math.floor(TabItems.tabWidth/2), e.clientY - Math.floor(TabItems.tabHeight/2), TabItems.tabWidth, TabItems.tabHeight); - let newTab = - gBrowser.loadOneTab("about:blank", { inBackground: false }); - newTab._tabViewTabItem.setBounds(box, true); newTab._tabViewTabItem.pushAway(true); self.setActive(newTab._tabViewTabItem); - self.creatingNewOrphanTab = false; - // the bounds of tab item is set and we can zoom in now. + TabItems.creatingNewOrphanTab = false; newTab._tabViewTabItem.zoomIn(true); self._lastClick = 0; @@ -265,19 +257,21 @@ let UI = { self._resize(); }); - // ___ setup event listener to save canvas images - gWindow.addEventListener("SSWindowClosing", function onWindowClosing() { - gWindow.removeEventListener("SSWindowClosing", onWindowClosing, false); - - self.isDOMWindowClosing = true; - - if (self.isTabViewVisible()) - GroupItems.removeHiddenGroups(); - - Storage.saveActiveGroupName(gWindow); - TabItems.saveAll(true); - self._save(); - }, false); + // ___ setup observer to save canvas images + function domWinClosedObserver(subject, topic, data) { + if (topic == "domwindowclosed" && subject == gWindow) { + self.isDOMWindowClosing = true; + if (self.isTabViewVisible()) + GroupItems.removeHiddenGroups(); + TabItems.saveAll(true); + self._save(); + } + } + Services.obs.addObserver( + domWinClosedObserver, "domwindowclosed", false); + this._cleanupFunctions.push(function() { + Services.obs.removeObserver(domWinClosedObserver, "domwindowclosed"); + }); // ___ Done this._frameInitialized = true; @@ -736,8 +730,6 @@ let UI = { // if it's an app tab, add it to all the group items if (tab.pinned) GroupItems.addAppTab(tab); - else if (self.isTabViewVisible()) - self._lastOpenedTab = tab; }; // TabClose @@ -872,40 +864,30 @@ let UI = { // Function: onTabSelect // Called when the user switches from one tab to another outside of the TabView UI. onTabSelect: function UI_onTabSelect(tab) { + let currentTab = this._currentTab; this._currentTab = tab; - if (this.isTabViewVisible()) { - if (!this.restoredClosedTab && this._lastOpenedTab == tab && - tab._tabViewTabItem) { - if (!this.creatingNewOrphanTab) - tab._tabViewTabItem.zoomIn(true); - this._lastOpenedTab = null; - return; - } - if (this._closedLastVisibleTab || - (this._closedSelectedTabInTabView && !this.closedLastTabInTabView) || - this.restoredClosedTab) { - if (this.restoredClosedTab) { - // when the tab view UI is being displayed, update the thumb for the - // restored closed tab after the page load - tab.linkedBrowser.addEventListener("load", function (event) { - tab.linkedBrowser.removeEventListener("load", arguments.callee, true); - TabItems._update(tab); - }, true); - } - this._closedLastVisibleTab = false; - this._closedSelectedTabInTabView = false; - this.closedLastTabInTabView = false; - this.restoredClosedTab = false; - return; + // if the last visible tab has just been closed, don't show the chrome UI. + if (this.isTabViewVisible() && + (this._closedLastVisibleTab || this._closedSelectedTabInTabView || + this.restoredClosedTab)) { + if (this.restoredClosedTab) { + // when the tab view UI is being displayed, update the thumb for the + // restored closed tab after the page load + tab.linkedBrowser.addEventListener("load", function (event) { + tab.linkedBrowser.removeEventListener("load", arguments.callee, true); + TabItems._update(tab); + }, true); } + this._closedLastVisibleTab = false; + this._closedSelectedTabInTabView = false; + this.restoredClosedTab = false; + return; } // reset these vars, just in case. this._closedLastVisibleTab = false; this._closedSelectedTabInTabView = false; - this.closedLastTabInTabView = false; this.restoredClosedTab = false; - this._lastOpenedTab = null; // if TabView is visible but we didn't just close the last tab or // selected tab, show chrome. @@ -917,7 +899,12 @@ let UI = { if (this._currentTab != tab) return; + let oldItem = null; let newItem = null; + + if (currentTab && currentTab._tabViewTabItem) + oldItem = currentTab._tabViewTabItem; + // update the tab bar for the new tab's group if (tab && tab._tabViewTabItem) { if (!TabItems.reconnectingPaused()) { @@ -1337,8 +1324,7 @@ let UI = { insideTabs.push(tab); } - let opts = {bounds: bounds, focusTitle: true}; - let groupItem = new GroupItem(insideTabs, opts); + var groupItem = new GroupItem(insideTabs,{bounds:bounds}); self.setActive(groupItem); phantom.remove(); dragOutInfo = null; @@ -1515,14 +1501,14 @@ let UI = { return (!groupItem.hidden && groupItem.getChildren().length > 0); }); // no pinned tabs, no visible groups and no orphaned tabs: open a new - // group, a blank tab and return + // group. open a blank tab and return if (!unhiddenGroups.length && !GroupItems.getOrphanedTabs().length) { let emptyGroups = GroupItems.groupItems.filter(function (groupItem) { return (!groupItem.hidden && !groupItem.getChildren().length); }); let group = (emptyGroups.length ? emptyGroups[0] : GroupItems.newGroup()); if (!gBrowser._numPinnedTabs) { - group.newTab(null, { closedLastTab: true }); + group.newTab(); return; } } diff --git a/browser/base/content/test/tabview/Makefile.in b/browser/base/content/test/tabview/Makefile.in index 13db3eecf23..bd4d04cf4e8 100644 --- a/browser/base/content/test/tabview/Makefile.in +++ b/browser/base/content/test/tabview/Makefile.in @@ -59,7 +59,6 @@ _BROWSER_FILES = \ browser_tabview_bug590606.js \ browser_tabview_bug591706.js \ browser_tabview_bug594958.js \ - browser_tabview_bug595020.js \ browser_tabview_bug595191.js \ browser_tabview_bug595436.js \ browser_tabview_bug595518.js \ @@ -85,7 +84,6 @@ _BROWSER_FILES = \ browser_tabview_bug604699.js \ browser_tabview_bug606657.js \ browser_tabview_bug606905.js \ - browser_tabview_bug607108.js \ browser_tabview_bug608037.js \ browser_tabview_bug608184.js \ browser_tabview_bug608158.js \ @@ -142,11 +140,9 @@ _BROWSER_FILES = \ browser_tabview_bug648882.js \ browser_tabview_bug649006.js \ browser_tabview_bug649307.js \ - browser_tabview_bug649319.js \ browser_tabview_bug650573.js \ browser_tabview_bug651311.js \ browser_tabview_bug654941.js \ - browser_tabview_bug655269.js \ browser_tabview_bug656778.js \ browser_tabview_bug656913.js \ browser_tabview_dragdrop.js \ diff --git a/browser/base/content/test/tabview/browser_tabview_bug587276.js b/browser/base/content/test/tabview/browser_tabview_bug587276.js index defed5a2e39..9c6e2866c06 100644 --- a/browser/base/content/test/tabview/browser_tabview_bug587276.js +++ b/browser/base/content/test/tabview/browser_tabview_bug587276.js @@ -36,23 +36,20 @@ function test3() { ok(!contentWindow.isSearchEnabled(), "The search is disabled") is(gBrowser.tabs.length, 1, "There is one tab before cmd/ctrl + t is pressed"); - - whenTabViewIsHidden(function() { - is(gBrowser.tabs.length, 2, "There are two tabs after cmd/ctrl + t is pressed"); - - gBrowser.tabs[0].linkedBrowser.loadURI("about:robots"); - gBrowser.tabs[1].linkedBrowser.loadURI("http://example.com/"); - - afterAllTabsLoaded(function () { - showTabView(test4); - }); - }); EventUtils.synthesizeKey("t", { accelKey: true }, contentWindow); + is(gBrowser.tabs.length, 2, "There are two tabs after cmd/ctrl + t is pressed"); + + gBrowser.tabs[0].linkedBrowser.loadURI("about:robots"); + gBrowser.tabs[1].linkedBrowser.loadURI("http://example.com/"); + + afterAllTabsLoaded(function () { + showTabView(test4); + }); } function test4() { is(gBrowser.tabs.length, 2, "There are two tabs"); - + let onTabClose = function() { gBrowser.tabContainer.removeEventListener("TabClose", onTabClose, true); executeSoon(function() { @@ -62,7 +59,7 @@ function test4() { is(gBrowser.tabs.length, 2, "There are two tabs after restoring one"); gBrowser.tabs[0].linkedBrowser.loadURI("about:blank"); - gBrowser.selectedTab = gBrowser.tabs[0]; + gBrowser.removeTab(gBrowser.tabs[1]); test8(); }); }; @@ -72,14 +69,14 @@ function test4() { // below key combination shouldn't trigger actions in tabview UI function test8() { - showTabView(function() { - is(gBrowser.tabs.length, 2, "There are two tabs before cmd/ctrl + w is pressed"); - EventUtils.synthesizeKey("w", { accelKey: true }, contentWindow); - is(gBrowser.tabs.length, 2, "There are two tabs after cmd/ctrl + w is pressed"); + let newTab = gBrowser.loadOneTab("about:blank", { inBackground: true }); - gBrowser.removeTab(gBrowser.tabs[1]); - test9(); - }); + is(gBrowser.tabs.length, 2, "There are two tabs before cmd/ctrl + w is pressed"); + EventUtils.synthesizeKey("w", { accelKey: true }, contentWindow); + is(gBrowser.tabs.length, 2, "There are two tabs after cmd/ctrl + w is pressed"); + + gBrowser.removeTab(newTab); + test9(); } function test9() { diff --git a/browser/base/content/test/tabview/browser_tabview_bug595020.js b/browser/base/content/test/tabview/browser_tabview_bug595020.js deleted file mode 100644 index a7a94fd621d..00000000000 --- a/browser/base/content/test/tabview/browser_tabview_bug595020.js +++ /dev/null @@ -1,37 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); - -let stateStartup = {windows:[ - {tabs:[{entries:[{url:"about:home"}]}], extData:{"tabview-last-session-group-name":"title"}} -]}; - -function test() { - let assertWindowTitle = function (win, title) { - let browser = win.gBrowser.tabs[0].linkedBrowser; - let winTitle = win.gBrowser.getWindowTitleForBrowser(browser); - is(winTitle.indexOf(title), 0, "title starts with '" + title + "'"); - }; - - let testGroupNameChange = function (win) { - showTabView(function () { - let cw = win.TabView.getContentWindow(); - let groupItem = cw.GroupItems.groupItems[0]; - groupItem.setTitle("new-title"); - - hideTabView(function () { - assertWindowTitle(win, "new-title"); - waitForFocus(finish); - }, win); - }, win); - }; - - waitForExplicitFinish(); - - newWindowWithState(stateStartup, function (win) { - registerCleanupFunction(function () win.close()); - assertWindowTitle(win, "title"); - testGroupNameChange(win); - }); -} diff --git a/browser/base/content/test/tabview/browser_tabview_bug607108.js b/browser/base/content/test/tabview/browser_tabview_bug607108.js deleted file mode 100644 index 8cbb25c6ce6..00000000000 --- a/browser/base/content/test/tabview/browser_tabview_bug607108.js +++ /dev/null @@ -1,33 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -function test() { - waitForExplicitFinish(); - - newWindowWithTabView(function (win) { - registerCleanupFunction(function () win.close()); - - let cw = win.TabView.getContentWindow(); - let content = cw.document.getElementById("content"); - - let groupItems = cw.GroupItems.groupItems; - is(groupItems.length, 1, "there is one groupItem"); - groupItems[0].setSize(150, 150, true); - - waitForFocus(function () { - // drag to create a new group - EventUtils.synthesizeMouse(content, 200, 50, {type: "mousedown"}, cw); - EventUtils.synthesizeMouse(content, 400, 250, {type: "mousemove"}, cw); - EventUtils.synthesizeMouse(content, 200, 50, {type: "mouseup"}, cw); - - // enter a title for the new group - EventUtils.synthesizeKey("t", {}, cw); - EventUtils.synthesizeKey("VK_RETURN", {}, cw); - - is(groupItems.length, 2, "there are two groupItems"); - is(groupItems[1].getTitle(), "t", "new groupItem's title is correct"); - - waitForFocus(finish); - }, cw); - }); -} diff --git a/browser/base/content/test/tabview/browser_tabview_bug622872.js b/browser/base/content/test/tabview/browser_tabview_bug622872.js index 094dc7e4cd7..f10c5cb6957 100644 --- a/browser/base/content/test/tabview/browser_tabview_bug622872.js +++ b/browser/base/content/test/tabview/browser_tabview_bug622872.js @@ -64,8 +64,11 @@ function part1(win) { ok(!contentWindow.UI.getActiveOrphanTab(), "There is no active orphan tab."); ok(win.TabView.isVisible(), "Tab View is visible."); - - whenTabViewIsHidden(part4, win); + + win.gBrowser.tabContainer.addEventListener("TabSelect", function() { + win.gBrowser.tabContainer.removeEventListener("TabSelect", arguments.callee, false); + executeSoon(part4); + }, false); win.document.getElementById("cmd_newNavigatorTab").doCommand(); } diff --git a/browser/base/content/test/tabview/browser_tabview_bug630102.js b/browser/base/content/test/tabview/browser_tabview_bug630102.js index fe2d64fc2e0..e2a91b0d8c9 100644 --- a/browser/base/content/test/tabview/browser_tabview_bug630102.js +++ b/browser/base/content/test/tabview/browser_tabview_bug630102.js @@ -2,51 +2,63 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ function test() { - let win, contentWindow, originalTab, newTab1, newTab2; + waitForExplicitFinish(); + + let originalTab = gBrowser.visibleTabs[0]; + let newTab1 = gBrowser.addTab("about:blank", { skipAnimation: true }); + let newTab2 = gBrowser.addTab("about:blank", { skipAnimation: true }); + + gBrowser.pinTab(newTab1); + + let contentWindow; + + let partOne = function() { + window.removeEventListener("tabviewshown", partOne, false); + + contentWindow = document.getElementById("tab-view").contentWindow; + is(contentWindow.GroupItems.groupItems.length, 1, "There is only one group item"); - let partOne = function () { let groupItem = contentWindow.GroupItems.groupItems[0]; let tabItems = groupItem.getChildren(); is(tabItems.length, 2, "There are two tab items in that group item"); is(tabItems[0].tab, originalTab, "The first tab item is linked to the first tab"); is(tabItems[1].tab, newTab2, "The second tab item is linked to the second tab"); - hideTabView(partTwo, win); + window.addEventListener("tabviewhidden", partTwo, false); + TabView.toggle(); }; - let partTwo = function () { - win.gBrowser.unpinTab(newTab1); - showTabView(partThree, win); + let partTwo = function() { + window.removeEventListener("tabviewhidden", partTwo, false); + + gBrowser.unpinTab(newTab1); + + window.addEventListener("tabviewshown", partThree, false); + TabView.toggle(); }; - let partThree = function () { + let partThree = function() { + window.removeEventListener("tabviewshown", partThree, false); + let tabItems = contentWindow.GroupItems.groupItems[0].getChildren(); is(tabItems.length, 3, "There are three tab items in that group item"); - is(tabItems[0].tab, win.gBrowser.tabs[0], "The first tab item is linked to the first tab"); - is(tabItems[1].tab, win.gBrowser.tabs[1], "The second tab item is linked to the second tab"); - is(tabItems[2].tab, win.gBrowser.tabs[2], "The third tab item is linked to the third tab"); + is(tabItems[0].tab, gBrowser.visibleTabs[0], "The first tab item is linked to the first tab"); + is(tabItems[1].tab, gBrowser.visibleTabs[1], "The second tab item is linked to the second tab"); + is(tabItems[2].tab, gBrowser.visibleTabs[2], "The third tab item is linked to the third tab"); + + window.addEventListener("tabviewhidden", endGame, false); + TabView.toggle(); + }; + + let endGame = function() { + window.removeEventListener("tabviewhidden", endGame, false); + + gBrowser.removeTab(newTab1); + gBrowser.removeTab(newTab2); finish(); }; - let onLoad = function (tvwin) { - win = tvwin; - registerCleanupFunction(function () win.close()); - - for (let i = 0; i < 2; i++) - win.gBrowser.loadOneTab("about:blank", {inBackground: true}); - - [originalTab, newTab1, newTab2] = win.gBrowser.tabs; - win.gBrowser.pinTab(newTab1); - }; - - let onShow = function () { - contentWindow = win.TabView.getContentWindow(); - is(contentWindow.GroupItems.groupItems.length, 1, "There is only one group item"); - - partOne(); - }; - - waitForExplicitFinish(); - newWindowWithTabView(onShow, onLoad); + window.addEventListener("tabviewshown", partOne, false); + TabView.toggle(); } diff --git a/browser/base/content/test/tabview/browser_tabview_bug633190.js b/browser/base/content/test/tabview/browser_tabview_bug633190.js deleted file mode 100644 index f7b9c0fdd1d..00000000000 --- a/browser/base/content/test/tabview/browser_tabview_bug633190.js +++ /dev/null @@ -1,86 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -let origTab = gBrowser.visibleTabs[0]; -let contentWindow; - -function test() { - waitForExplicitFinish(); - - test1(); -} - -// Open a new tab when the active tab item belongs to a group item. -function test1() { - registerCleanupFunction(function () TabView.hide()); - - showTabView(function() { - ok(origTab._tabViewTabItem.parent, "The original tab belongs to a group"); - - contentWindow = TabView.getContentWindow(); - contentWindow.UI.setActive(origTab._tabViewTabItem); - - testCreateTabAndThen(test2); - }); -} - -// Open a new tab when the active tab item is nothing. -function test2() { - showTabView(function() { - contentWindow.UI.setActive(null, { onlyRemoveActiveTab: true }); - - testCreateTabAndThen(test3); - }); -} - -// Open a new tab when the active tab item is an orphan tab. -function test3() { - showTabView(function() { - let groupItem = origTab._tabViewTabItem.parent; - let tabItems = groupItem.getChildren(); - is(tabItems.length, 3, "There are 3 tab items in the group"); - - let lastTabItem = tabItems[tabItems.length - 1]; - groupItem.remove(lastTabItem); - - let orphanedTabs = contentWindow.GroupItems.getOrphanedTabs(); - is(orphanedTabs.length, 1, "There should be 1 orphan tab"); - is(orphanedTabs[0], lastTabItem, "The tab item is the same as the orphan tab"); - - contentWindow.UI.setActive(lastTabItem); - - testCreateTabAndThen(function() { - hideTabView(finish); - }); - }); -} - -function testCreateTabAndThen(callback) { - ok(TabView.isVisible(), "Tab View is visible"); - - // detect tab open and zoomed in event. - let onTabOpen = function(event) { - gBrowser.tabContainer.removeEventListener("TabOpen", onTabOpen, false); - - // ensure that the default tabview listener is called before so the - // tab._tabViewTabItem exists - executeSoon(function() { - let tab = event.target; - tabItem = tab._tabViewTabItem; - ok(tabItem, "Tab item is available after tab open"); - - registerCleanupFunction(function () gBrowser.removeTab(tab)) - - tabItem.addSubscriber(tabItem, "zoomedIn", function() { - tabItem.removeSubscriber(tabItem, "zoomedIn"); - - is(gBrowser.selectedTab, tab, - "The selected tab is the same as the newly opened tab"); - executeSoon(callback); - }); - }); - } - gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen, false); - // use the menu item (the same as pressing cmd/ctrl + t) - document.getElementById("menu_newNavigatorTab").doCommand(); -} diff --git a/browser/base/content/test/tabview/browser_tabview_bug649319.js b/browser/base/content/test/tabview/browser_tabview_bug649319.js deleted file mode 100644 index fe69bcbd9ef..00000000000 --- a/browser/base/content/test/tabview/browser_tabview_bug649319.js +++ /dev/null @@ -1,88 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -function test() { - waitForExplicitFinish(); - - newWindowWithTabView(function (win) { - registerCleanupFunction(function () win.close()); - waitForFocus(function () testScenarios(win)); - }); -} - -function testScenarios(win) { - let simulateDragDrop = function (target) { - EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); - EventUtils.synthesizeMouse(target, 40, 20, {type: "mousemove"}, cw); - EventUtils.synthesizeMouse(target, 80, 20, {type: "mouseup"}, cw); - } - - let dragOutOfGroup = function (target) { - EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); - EventUtils.synthesizeMouse(target, 600, 5, {type: "mousemove"}, cw); - EventUtils.synthesizeMouse(target, 600, 5, {type: "mouseup"}, cw); - } - - let dragIntoGroup = function (target) { - EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); - EventUtils.synthesizeMouse(target, -200, 5, {type: "mousemove"}, cw); - EventUtils.synthesizeMouse(target, -200, 5, {type: "mouseup"}, cw); - } - - let assertActiveOrphan = function (tabItem) { - ok(!cw.GroupItems.getActiveGroupItem(), "no groupItem is active"); - is(cw.UI.getActiveTab(), tabItem, "orphan tab is active"); - is(cw.UI.getActiveOrphanTab(), tabItem, "orphan tab is active"); - } - - let cw = win.TabView.getContentWindow(); - let groupItem = cw.GroupItems.groupItems[0]; - let groupItem2 = createGroupItemWithBlankTabs(win, 400, 300, 20, 4); - - // move group - cw.UI.setActive(groupItem); - simulateDragDrop(groupItem2.container); - is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active"); - is(cw.UI.getActiveTab(), groupItem2.getChild(0), "second groupItem's first tab is active"); - - // resize group - cw.UI.setActive(groupItem); - let tabItem = groupItem2.getChild(2); - groupItem2.setActiveTab(tabItem); - simulateDragDrop(groupItem2.$resizer[0]); - is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active"); - is(cw.UI.getActiveTab(), tabItem, "second groupItem's third tab is active"); - - // create orphan - tabItem = groupItem2.getChild(0); - dragOutOfGroup(tabItem.container); - - // move orphan - cw.UI.setActive(groupItem2); - simulateDragDrop(tabItem.container); - assertActiveOrphan(tabItem); - - // resize orphan - cw.UI.setActive(groupItem2); - let $resizer = cw.iQ('.iq-resizable-handle', tabItem.container); - simulateDragDrop($resizer[0]); - assertActiveOrphan(tabItem); - - // drag back into group - dragIntoGroup(tabItem.container); - cw.UI.setActive(groupItem); - cw.UI.setActive(groupItem2); - is(cw.UI.getActiveTab(), tabItem, "the dropped tab is active"); - - // hide + unhide groupItem - hideGroupItem(groupItem2, function () { - is(cw.GroupItems.getActiveGroupItem(), groupItem, "first groupItem is active"); - - unhideGroupItem(groupItem2, function () { - is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active"); - is(cw.UI.getActiveTab(), tabItem, "the dropped tab is active"); - - finish(); - }); - }); -} diff --git a/browser/base/content/test/tabview/browser_tabview_bug655269.js b/browser/base/content/test/tabview/browser_tabview_bug655269.js deleted file mode 100644 index 7b94f3a00db..00000000000 --- a/browser/base/content/test/tabview/browser_tabview_bug655269.js +++ /dev/null @@ -1,20 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -function test() { - waitForExplicitFinish(); - - newWindowWithTabView(function (win) { - let cw = win.TabView.getContentWindow(); - let tabItem = win.gBrowser.tabs[0]._tabViewTabItem; - - tabItem.addSubscriber(tabItem, "savedCachedImageData", function () { - tabItem.removeSubscriber(tabItem, "savedCachedImageData"); - - ok(cw.UI.isDOMWindowClosing, "dom window is closing"); - waitForFocus(finish); - }); - - win.close(); - }); -} diff --git a/browser/components/sessionstore/src/nsSessionStore.js b/browser/components/sessionstore/src/nsSessionStore.js index 3206158062c..7e668808368 100644 --- a/browser/components/sessionstore/src/nsSessionStore.js +++ b/browser/components/sessionstore/src/nsSessionStore.js @@ -869,14 +869,7 @@ SessionStoreService.prototype = { if (!aWindow.__SSi || !this._windows[aWindow.__SSi]) { return; } - - // notify that the session store will stop tracking this window so that - // extensions can store any data about this window in session store before - // that's not possible anymore - let event = aWindow.document.createEvent("Events"); - event.initEvent("SSWindowClosing", true, false); - aWindow.dispatchEvent(event); - + if (this.windowToFocus && this.windowToFocus == aWindow) { delete this.windowToFocus; } diff --git a/browser/components/sessionstore/test/browser/Makefile.in b/browser/components/sessionstore/test/browser/Makefile.in index d212898ac0a..b25e7fe0596 100644 --- a/browser/components/sessionstore/test/browser/Makefile.in +++ b/browser/components/sessionstore/test/browser/Makefile.in @@ -147,7 +147,6 @@ _BROWSER_TEST_FILES = \ browser_628270.js \ browser_635418.js \ browser_636279.js \ - browser_659591.js \ $(NULL) ifneq ($(OS_ARCH),Darwin) diff --git a/browser/components/sessionstore/test/browser/browser_659591.js b/browser/components/sessionstore/test/browser/browser_659591.js deleted file mode 100644 index 3608ea793c4..00000000000 --- a/browser/components/sessionstore/test/browser/browser_659591.js +++ /dev/null @@ -1,32 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -function test() { - waitForExplicitFinish(); - - let eventReceived = false; - - registerCleanupFunction(function () { - ok(eventReceived, "SSWindowClosing event received"); - }); - - newWindow(function (win) { - win.addEventListener("SSWindowClosing", function onWindowClosing() { - win.removeEventListener("SSWindowClosing", onWindowClosing, false); - eventReceived = true; - waitForFocus(finish); - }, false); - - win.close(); - }); -} - -function newWindow(callback) { - let opts = "chrome,all,dialog=no,height=800,width=800"; - let win = window.openDialog(getBrowserURL(), "_blank", opts); - - win.addEventListener("load", function onLoad() { - win.removeEventListener("load", onLoad, false); - executeSoon(function () callback(win)); - }, false); -}