Merge backout of revisions 33bcd05554f3, d8b5c9736831, 59c84742872f, f5a456d99df9, d580181e5434, 61e1aa1afa09, a1b563094e5a to fix Moth orange

This commit is contained in:
Boris Zbarsky 2011-06-09 11:53:28 -07:00
Родитель 0929e820a8 9e48dd0491
Коммит b0c300fcac
19 изменённых файлов: 153 добавлений и 496 удалений

Просмотреть файл

@ -40,18 +40,15 @@ let TabView = {
_deck: null, _deck: null,
_iframe: null, _iframe: null,
_window: null, _window: null,
_initialized: false,
_browserKeyHandlerInitialized: false, _browserKeyHandlerInitialized: false,
_isFrameLoading: false, _isFrameLoading: false,
_initFrameCallbacks: [], _initFrameCallbacks: [],
_lastSessionGroupName: null,
PREF_BRANCH: "browser.panorama.", PREF_BRANCH: "browser.panorama.",
PREF_FIRST_RUN: "browser.panorama.experienced_first_run", PREF_FIRST_RUN: "browser.panorama.experienced_first_run",
PREF_STARTUP_PAGE: "browser.startup.page", PREF_STARTUP_PAGE: "browser.startup.page",
PREF_RESTORE_ENABLED_ONCE: "browser.panorama.session_restore_enabled_once", PREF_RESTORE_ENABLED_ONCE: "browser.panorama.session_restore_enabled_once",
GROUPS_IDENTIFIER: "tabview-groups",
VISIBILITY_IDENTIFIER: "tabview-visibility", VISIBILITY_IDENTIFIER: "tabview-visibility",
LAST_SESSION_GROUP_NAME_IDENTIFIER: "tabview-last-session-group-name", GROUPS_IDENTIFIER: "tabview-groups",
// ---------- // ----------
get windowTitle() { get windowTitle() {
@ -92,9 +89,6 @@ let TabView = {
// ---------- // ----------
init: function TabView_init() { init: function TabView_init() {
if (this._initialized)
return;
if (this.firstUseExperienced) { if (this.firstUseExperienced) {
if ((gBrowser.tabs.length - gBrowser.visibleTabs.length) > 0) if ((gBrowser.tabs.length - gBrowser.visibleTabs.length) > 0)
this._setBrowserKeyHandlers(); this._setBrowserKeyHandlers();
@ -126,16 +120,10 @@ let TabView = {
}; };
gBrowser.tabContainer.addEventListener( gBrowser.tabContainer.addEventListener(
"TabShow", this._tabShowEventListener, true); "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); Services.prefs.addObserver(this.PREF_BRANCH, this, false);
this._initialized = true;
}, },
// ---------- // ----------
@ -150,17 +138,12 @@ let TabView = {
// ---------- // ----------
// Uninitializes TabView. // Uninitializes TabView.
uninit: function TabView_uninit() { uninit: function TabView_uninit() {
if (!this._initialized)
return;
Services.prefs.removeObserver(this.PREF_BRANCH, this); Services.prefs.removeObserver(this.PREF_BRANCH, this);
if (this._tabShowEventListener) { if (this._tabShowEventListener) {
gBrowser.tabContainer.removeEventListener( gBrowser.tabContainer.removeEventListener(
"TabShow", this._tabShowEventListener, true); "TabShow", this._tabShowEventListener, true);
} }
this._initialized = false;
}, },
// ---------- // ----------
@ -253,27 +236,17 @@ let TabView = {
}, },
getActiveGroupName: function TabView_getActiveGroupName() { getActiveGroupName: function TabView_getActiveGroupName() {
if (!this._window)
return this._lastSessionGroupName;
// We get the active group this way, instead of querying // We get the active group this way, instead of querying
// GroupItems.getActiveGroupItem() because the tabSelect event // GroupItems.getActiveGroupItem() because the tabSelect event
// will not have happened by the time the browser tries to // will not have happened by the time the browser tries to
// update the title. // update the title.
let groupItem = null;
let activeTab = window.gBrowser.selectedTab; let activeTab = window.gBrowser.selectedTab;
let activeTabItem = activeTab._tabViewTabItem; if (activeTab._tabViewTabItem && activeTab._tabViewTabItem.parent){
let groupName = activeTab._tabViewTabItem.parent.getTitle();
if (activeTab.pinned) { if (groupName)
// It's an app tab, so it won't have a .tabItem. However, its .parent return groupName;
// will already be set as the active group.
groupItem = this._window.GroupItems.getActiveGroupItem();
} else if (activeTabItem) {
groupItem = activeTabItem.parent;
} }
return null;
// groupItem may still be null, if the active tab is an orphan.
return groupItem ? groupItem.getTitle() : "";
}, },
// ---------- // ----------

Просмотреть файл

@ -85,6 +85,19 @@ function Drag(item, event, isFauxDrag) {
this.safeWindowBounds = Items.getSafeWindowBounds(); this.safeWindowBounds = Items.getSafeWindowBounds();
Trenches.activateOthersTrenches(this.el); 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 = { Drag.prototype = {

Просмотреть файл

@ -64,7 +64,6 @@
// bounds - a <Rect>; otherwise based on the locations of the provided elements // bounds - a <Rect>; otherwise based on the locations of the provided elements
// container - a DOM element to use as the container for this groupItem; otherwise will create // container - a DOM element to use as the container for this groupItem; otherwise will create
// title - the title for the groupItem; otherwise blank // 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 // 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 // immediately - true if we want all placement immediately, not with animation
function GroupItem(listOfEls, options) { function GroupItem(listOfEls, options) {
@ -219,13 +218,12 @@ function GroupItem(listOfEls, options) {
if (!same) if (!same)
return; return;
if (!self.isDragging) if (!self.isDragging) {
self.focusTitle(); self.$titleShield.hide();
(self.$title)[0].focus();
}
}); });
if (options.focusTitle)
this.focusTitle();
// ___ Stack Expander // ___ Stack Expander
this.$expander = iQ("<div/>") this.$expander = iQ("<div/>")
.addClass("stackExpander") .addClass("stackExpander")
@ -406,14 +404,6 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
this.$titleShield.css(css); 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 // Function: adjustAppTabTray
// Used to adjust the appTabTray size, to split the appTabIcons across // 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); return (groupItem != self && !groupItem.getChildren().length);
}); });
let group = (emptyGroups.length ? emptyGroups[0] : GroupItems.newGroup()); let group = (emptyGroups.length ? emptyGroups[0] : GroupItems.newGroup());
group.newTab(null, { closedLastTab: true }); group.newTab();
} }
this.destroy(); this.destroy();
@ -1024,7 +1014,8 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
if (typeof item.setResizable == 'function') if (typeof item.setResizable == 'function')
item.setResizable(false, options.immediately); 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); this.setActiveTab(item);
// if it matches the selected tab or no active tab and the browser // 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 // Function: newTab
// Creates a new tab within this groupItem. // Creates a new tab within this groupItem.
// Parameters: newTab: function GroupItem_newTab(url) {
// 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;
UI.setActive(this, { dontSetActiveTabInGroup: true }); 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);
}, },
// ---------- // ----------

Просмотреть файл

@ -151,9 +151,10 @@ Item.prototype = {
this.dragOptions = { this.dragOptions = {
cancelClass: 'close stackExpander', cancelClass: 'close stackExpander',
start: function(e, ui) { start: function(e, ui) {
UI.setActive(this); if (this.isAGroupItem) {
if (this.isAGroupItem) UI.setActive(this);
this._unfreezeItemSize(); this._unfreezeItemSize();
}
// if we start dragging a tab within a group, start with dropSpace on. // if we start dragging a tab within a group, start with dropSpace on.
else if (this.parent != null) else if (this.parent != null)
this.parent._dropSpaceActive = true; this.parent._dropSpaceActive = true;
@ -200,7 +201,8 @@ Item.prototype = {
minWidth: 90, minWidth: 90,
minHeight: 90, minHeight: 90,
start: function(e,ui) { start: function(e,ui) {
UI.setActive(this); if (this.isAGroupItem)
UI.setActive(this);
resize.info = new Drag(this, e); resize.info = new Drag(this, e);
}, },
resize: function(e,ui) { resize: function(e,ui) {

Просмотреть файл

@ -220,15 +220,6 @@ let Storage = {
win, win.TabView.VISIBILITY_IDENTIFIER, data); 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 // Function: saveData
// Generic routine for saving data to a window. // Generic routine for saving data to a window.

Просмотреть файл

@ -379,7 +379,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
} }
} else { } else {
// create tab by double click is handled in UI_init(). // create tab by double click is handled in UI_init().
if (!UI.creatingNewOrphanTab) if (!TabItems.creatingNewOrphanTab)
GroupItems.newTab(self, {immediately: true}); 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 = (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 // 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. // 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) if (self.parent && self.parent.expanded)
self.parent.collapse(); self.parent.collapse();
self._sendToSubscribers("zoomedIn");
} }
let animateZoom = gPrefBranch.getBoolPref("animate_zoom"); let animateZoom = gPrefBranch.getBoolPref("animate_zoom");
@ -805,6 +803,7 @@ let TabItems = {
_lastUpdateTime: Date.now(), _lastUpdateTime: Date.now(),
_eventListeners: [], _eventListeners: [],
_pauseUpdateForTest: false, _pauseUpdateForTest: false,
creatingNewOrphanTab: false,
tempCanvas: null, tempCanvas: null,
_reconnectingPaused: false, _reconnectingPaused: false,
tabItemPadding: {}, tabItemPadding: {},

Просмотреть файл

@ -128,7 +128,8 @@ let UI = {
_storageBusyCount: 0, _storageBusyCount: 0,
// Variable: isDOMWindowClosing // 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, isDOMWindowClosing: false,
// Variable: _browserKeys // Variable: _browserKeys
@ -139,14 +140,6 @@ let UI = {
// Used to prevent keypress being handled after quitting search mode. // Used to prevent keypress being handled after quitting search mode.
ignoreKeypressForSearch: false, 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 // Function: toString
// Prints [UI] for debug use // 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._lastClickPositions.y + self.DBLCLICK_OFFSET) >= e.clientY) { (self._lastClickPositions.y + self.DBLCLICK_OFFSET) >= e.clientY) {
self.setActive(null); self.setActive(null);
self.creatingNewOrphanTab = true; TabItems.creatingNewOrphanTab = true;
let newTab =
gBrowser.loadOneTab("about:blank", { inBackground: true });
let box = let box =
new Rect(e.clientX - Math.floor(TabItems.tabWidth/2), new Rect(e.clientX - Math.floor(TabItems.tabWidth/2),
e.clientY - Math.floor(TabItems.tabHeight/2), e.clientY - Math.floor(TabItems.tabHeight/2),
TabItems.tabWidth, TabItems.tabHeight); TabItems.tabWidth, TabItems.tabHeight);
let newTab =
gBrowser.loadOneTab("about:blank", { inBackground: false });
newTab._tabViewTabItem.setBounds(box, true); newTab._tabViewTabItem.setBounds(box, true);
newTab._tabViewTabItem.pushAway(true); newTab._tabViewTabItem.pushAway(true);
self.setActive(newTab._tabViewTabItem); self.setActive(newTab._tabViewTabItem);
self.creatingNewOrphanTab = false; TabItems.creatingNewOrphanTab = false;
// the bounds of tab item is set and we can zoom in now.
newTab._tabViewTabItem.zoomIn(true); newTab._tabViewTabItem.zoomIn(true);
self._lastClick = 0; self._lastClick = 0;
@ -265,19 +257,21 @@ let UI = {
self._resize(); self._resize();
}); });
// ___ setup event listener to save canvas images // ___ setup observer to save canvas images
gWindow.addEventListener("SSWindowClosing", function onWindowClosing() { function domWinClosedObserver(subject, topic, data) {
gWindow.removeEventListener("SSWindowClosing", onWindowClosing, false); if (topic == "domwindowclosed" && subject == gWindow) {
self.isDOMWindowClosing = true;
self.isDOMWindowClosing = true; if (self.isTabViewVisible())
GroupItems.removeHiddenGroups();
if (self.isTabViewVisible()) TabItems.saveAll(true);
GroupItems.removeHiddenGroups(); self._save();
}
Storage.saveActiveGroupName(gWindow); }
TabItems.saveAll(true); Services.obs.addObserver(
self._save(); domWinClosedObserver, "domwindowclosed", false);
}, false); this._cleanupFunctions.push(function() {
Services.obs.removeObserver(domWinClosedObserver, "domwindowclosed");
});
// ___ Done // ___ Done
this._frameInitialized = true; this._frameInitialized = true;
@ -736,8 +730,6 @@ let UI = {
// if it's an app tab, add it to all the group items // if it's an app tab, add it to all the group items
if (tab.pinned) if (tab.pinned)
GroupItems.addAppTab(tab); GroupItems.addAppTab(tab);
else if (self.isTabViewVisible())
self._lastOpenedTab = tab;
}; };
// TabClose // TabClose
@ -872,40 +864,30 @@ let UI = {
// Function: onTabSelect // Function: onTabSelect
// Called when the user switches from one tab to another outside of the TabView UI. // Called when the user switches from one tab to another outside of the TabView UI.
onTabSelect: function UI_onTabSelect(tab) { onTabSelect: function UI_onTabSelect(tab) {
let currentTab = this._currentTab;
this._currentTab = tab; this._currentTab = tab;
if (this.isTabViewVisible()) { // if the last visible tab has just been closed, don't show the chrome UI.
if (!this.restoredClosedTab && this._lastOpenedTab == tab && if (this.isTabViewVisible() &&
tab._tabViewTabItem) { (this._closedLastVisibleTab || this._closedSelectedTabInTabView ||
if (!this.creatingNewOrphanTab) this.restoredClosedTab)) {
tab._tabViewTabItem.zoomIn(true); if (this.restoredClosedTab) {
this._lastOpenedTab = null; // when the tab view UI is being displayed, update the thumb for the
return; // restored closed tab after the page load
} tab.linkedBrowser.addEventListener("load", function (event) {
if (this._closedLastVisibleTab || tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
(this._closedSelectedTabInTabView && !this.closedLastTabInTabView) || TabItems._update(tab);
this.restoredClosedTab) { }, true);
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;
} }
this._closedLastVisibleTab = false;
this._closedSelectedTabInTabView = false;
this.restoredClosedTab = false;
return;
} }
// reset these vars, just in case. // reset these vars, just in case.
this._closedLastVisibleTab = false; this._closedLastVisibleTab = false;
this._closedSelectedTabInTabView = false; this._closedSelectedTabInTabView = false;
this.closedLastTabInTabView = false;
this.restoredClosedTab = false; this.restoredClosedTab = false;
this._lastOpenedTab = null;
// if TabView is visible but we didn't just close the last tab or // if TabView is visible but we didn't just close the last tab or
// selected tab, show chrome. // selected tab, show chrome.
@ -917,7 +899,12 @@ let UI = {
if (this._currentTab != tab) if (this._currentTab != tab)
return; return;
let oldItem = null;
let newItem = null; let newItem = null;
if (currentTab && currentTab._tabViewTabItem)
oldItem = currentTab._tabViewTabItem;
// update the tab bar for the new tab's group // update the tab bar for the new tab's group
if (tab && tab._tabViewTabItem) { if (tab && tab._tabViewTabItem) {
if (!TabItems.reconnectingPaused()) { if (!TabItems.reconnectingPaused()) {
@ -1337,8 +1324,7 @@ let UI = {
insideTabs.push(tab); insideTabs.push(tab);
} }
let opts = {bounds: bounds, focusTitle: true}; var groupItem = new GroupItem(insideTabs,{bounds:bounds});
let groupItem = new GroupItem(insideTabs, opts);
self.setActive(groupItem); self.setActive(groupItem);
phantom.remove(); phantom.remove();
dragOutInfo = null; dragOutInfo = null;
@ -1515,14 +1501,14 @@ let UI = {
return (!groupItem.hidden && groupItem.getChildren().length > 0); return (!groupItem.hidden && groupItem.getChildren().length > 0);
}); });
// no pinned tabs, no visible groups and no orphaned tabs: open a new // 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) { if (!unhiddenGroups.length && !GroupItems.getOrphanedTabs().length) {
let emptyGroups = GroupItems.groupItems.filter(function (groupItem) { let emptyGroups = GroupItems.groupItems.filter(function (groupItem) {
return (!groupItem.hidden && !groupItem.getChildren().length); return (!groupItem.hidden && !groupItem.getChildren().length);
}); });
let group = (emptyGroups.length ? emptyGroups[0] : GroupItems.newGroup()); let group = (emptyGroups.length ? emptyGroups[0] : GroupItems.newGroup());
if (!gBrowser._numPinnedTabs) { if (!gBrowser._numPinnedTabs) {
group.newTab(null, { closedLastTab: true }); group.newTab();
return; return;
} }
} }

Просмотреть файл

@ -59,7 +59,6 @@ _BROWSER_FILES = \
browser_tabview_bug590606.js \ browser_tabview_bug590606.js \
browser_tabview_bug591706.js \ browser_tabview_bug591706.js \
browser_tabview_bug594958.js \ browser_tabview_bug594958.js \
browser_tabview_bug595020.js \
browser_tabview_bug595191.js \ browser_tabview_bug595191.js \
browser_tabview_bug595436.js \ browser_tabview_bug595436.js \
browser_tabview_bug595518.js \ browser_tabview_bug595518.js \
@ -85,7 +84,6 @@ _BROWSER_FILES = \
browser_tabview_bug604699.js \ browser_tabview_bug604699.js \
browser_tabview_bug606657.js \ browser_tabview_bug606657.js \
browser_tabview_bug606905.js \ browser_tabview_bug606905.js \
browser_tabview_bug607108.js \
browser_tabview_bug608037.js \ browser_tabview_bug608037.js \
browser_tabview_bug608184.js \ browser_tabview_bug608184.js \
browser_tabview_bug608158.js \ browser_tabview_bug608158.js \
@ -142,11 +140,9 @@ _BROWSER_FILES = \
browser_tabview_bug648882.js \ browser_tabview_bug648882.js \
browser_tabview_bug649006.js \ browser_tabview_bug649006.js \
browser_tabview_bug649307.js \ browser_tabview_bug649307.js \
browser_tabview_bug649319.js \
browser_tabview_bug650573.js \ browser_tabview_bug650573.js \
browser_tabview_bug651311.js \ browser_tabview_bug651311.js \
browser_tabview_bug654941.js \ browser_tabview_bug654941.js \
browser_tabview_bug655269.js \
browser_tabview_bug656778.js \ browser_tabview_bug656778.js \
browser_tabview_bug656913.js \ browser_tabview_bug656913.js \
browser_tabview_dragdrop.js \ browser_tabview_dragdrop.js \

Просмотреть файл

@ -36,18 +36,15 @@ function test3() {
ok(!contentWindow.isSearchEnabled(), "The search is disabled") ok(!contentWindow.isSearchEnabled(), "The search is disabled")
is(gBrowser.tabs.length, 1, "There is one tab before cmd/ctrl + t is pressed"); 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); 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() { function test4() {
@ -62,7 +59,7 @@ function test4() {
is(gBrowser.tabs.length, 2, "There are two tabs after restoring one"); is(gBrowser.tabs.length, 2, "There are two tabs after restoring one");
gBrowser.tabs[0].linkedBrowser.loadURI("about:blank"); gBrowser.tabs[0].linkedBrowser.loadURI("about:blank");
gBrowser.selectedTab = gBrowser.tabs[0]; gBrowser.removeTab(gBrowser.tabs[1]);
test8(); test8();
}); });
}; };
@ -72,14 +69,14 @@ function test4() {
// below key combination shouldn't trigger actions in tabview UI // below key combination shouldn't trigger actions in tabview UI
function test8() { function test8() {
showTabView(function() { let newTab = gBrowser.loadOneTab("about:blank", { inBackground: true });
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(gBrowser.tabs[1]); is(gBrowser.tabs.length, 2, "There are two tabs before cmd/ctrl + w is pressed");
test9(); 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() { function test9() {

Просмотреть файл

@ -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);
});
}

Просмотреть файл

@ -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);
});
}

Просмотреть файл

@ -65,7 +65,10 @@ function part1(win) {
ok(!contentWindow.UI.getActiveOrphanTab(), "There is no active orphan tab."); ok(!contentWindow.UI.getActiveOrphanTab(), "There is no active orphan tab.");
ok(win.TabView.isVisible(), "Tab View is visible."); 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(); win.document.getElementById("cmd_newNavigatorTab").doCommand();
} }

Просмотреть файл

@ -2,51 +2,63 @@
http://creativecommons.org/publicdomain/zero/1.0/ */ http://creativecommons.org/publicdomain/zero/1.0/ */
function test() { 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 groupItem = contentWindow.GroupItems.groupItems[0];
let tabItems = groupItem.getChildren(); let tabItems = groupItem.getChildren();
is(tabItems.length, 2, "There are two tab items in that group item"); 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[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"); 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 () { let partTwo = function() {
win.gBrowser.unpinTab(newTab1); window.removeEventListener("tabviewhidden", partTwo, false);
showTabView(partThree, win);
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(); let tabItems = contentWindow.GroupItems.groupItems[0].getChildren();
is(tabItems.length, 3, "There are three tab items in that group item"); 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[0].tab, gBrowser.visibleTabs[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[1].tab, gBrowser.visibleTabs[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[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(); finish();
}; };
let onLoad = function (tvwin) { window.addEventListener("tabviewshown", partOne, false);
win = tvwin; TabView.toggle();
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);
} }

Просмотреть файл

@ -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();
}

Просмотреть файл

@ -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();
});
});
}

Просмотреть файл

@ -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();
});
}

Просмотреть файл

@ -870,13 +870,6 @@ SessionStoreService.prototype = {
return; 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) { if (this.windowToFocus && this.windowToFocus == aWindow) {
delete this.windowToFocus; delete this.windowToFocus;
} }

Просмотреть файл

@ -147,7 +147,6 @@ _BROWSER_TEST_FILES = \
browser_628270.js \ browser_628270.js \
browser_635418.js \ browser_635418.js \
browser_636279.js \ browser_636279.js \
browser_659591.js \
$(NULL) $(NULL)
ifneq ($(OS_ARCH),Darwin) ifneq ($(OS_ARCH),Darwin)

Просмотреть файл

@ -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);
}