Bug 615271 - Ghost tab in the undo panel when opening a local page [r=mfinkle]

This commit is contained in:
Vivien Nicolas 2010-12-09 10:08:56 -05:00
Родитель 6f95372eb3
Коммит ff0348d29a
3 изменённых файлов: 43 добавлений и 9 удалений

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

@ -534,6 +534,7 @@ var Browser = {
if (hasLocal != useLocal) {
let oldTab = this.selectedTab;
if (currentURI == "about:blank" && !browser.canGoBack && !browser.canGoForward) {
oldTab.chromeTab.ignoreUndo = true;
this.closeTab(oldTab);
oldTab = null;
}
@ -672,11 +673,13 @@ var Browser = {
return newTab;
},
closeTab: function(tab) {
if (tab instanceof XULElement)
tab = this.getTabFromChrome(tab);
closeTab: function(aTab) {
let tab = aTab;
if (aTab instanceof XULElement)
tab = this.getTabFromChrome(aTab);
if (!tab)
// checking the length is a workaround for bug 615404
if (!tab || this._tabs.length < 2)
return;
// Make sure we leave the toolbar in an unlocked state

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

@ -19,6 +19,7 @@
</content>
<implementation>
<field name="ignoreUndo">false</field>
<field name="thumbnail">document.getAnonymousElementByAttribute(this, "anonid", "thumbnail");</field>
<field name="_container">this.parentNode.parentNode;</field>
<method name="_onClick">
@ -35,7 +36,6 @@
<method name="_onClose">
<body>
<![CDATA[
let callbackFunc = this._container.getAttribute(this.hasAttribute("reload") ? "onclosereloadtab" : "onclosetab");
let closeFn = new Function("event", callbackFunc);
closeFn.call(this);
@ -129,7 +129,9 @@
this._closedTab = null;
}
if (!closedTab || closedTab != aTab) {
if (aTab.ignoreUndo) {
this.children.removeChild(aTab);
} else if (!closedTab || closedTab != aTab) {
if (aTab.thumbnail && !aTab.thumbnail.hasAttribute("empty")) {
// duplicate the old thumbnail to the new one because moving the
// tab in the dom clear the canvas

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

@ -5,6 +5,8 @@ let testURL_03 = chromeRoot + "browser_blank_01.html#tab3";
let new_tab_01;
let new_tab_02;
let new_tab_03;
let new_tab_04;
let new_tab_05;
//------------------------------------------------------------------------------
// Entry point (must be named "test")
@ -86,6 +88,31 @@ function tab_switch_04() {
is(new_tab_03.owner, null, "Closing tab 01 nulls tab3 owner");
is(Browser.selectedTab.notification, Elements.browsers.selectedPanel, "Deck has correct browser");
// Add a tab then close it
new_tab_04 = Browser.addTab("about:home", true);
new_tab_04.browser.addEventListener("load", function() {
new_tab_04.browser.removeEventListener("load", arguments.callee, true);
Browser.closeTab(new_tab_04);
tab_undo();
}, true);
}
function tab_undo() {
let undoBox = document.getElementById("tabs")._tabsUndo;
ok(undoBox.firstChild, "It should be a tab in the undo box");
undoBox.firstChild._onUndo();
new_tab_04 = Browser.selectedTab;
new_tab_05 = Browser.addTab("about:blank", true);
tab_on_undo();
}
function tab_on_undo() {
let undoBox = document.getElementById("tabs")._tabsUndo;
is(undoBox.firstChild, null, "It should be no tab in the undo box");
Browser.loadURI("about:firstrun");
is(undoBox.firstChild, null, "It should be no tab in the undo box when opening a new local page");
done();
}
@ -94,6 +121,8 @@ function done() {
Browser.closeTab(new_tab_01);
Browser.closeTab(new_tab_02);
Browser.closeTab(new_tab_03);
Browser.closeTab(new_tab_04);
Browser.closeTab(new_tab_05);
// For some reason, this test is causing the sidebar to appear.
// Clean up the UI for later tests (see bug 598962).