зеркало из https://github.com/mozilla/gecko-dev.git
Bug 615271 - Ghost tab in the undo panel when opening a local page [r=mfinkle]
This commit is contained in:
Родитель
6f95372eb3
Коммит
ff0348d29a
|
@ -534,6 +534,7 @@ var Browser = {
|
||||||
if (hasLocal != useLocal) {
|
if (hasLocal != useLocal) {
|
||||||
let oldTab = this.selectedTab;
|
let oldTab = this.selectedTab;
|
||||||
if (currentURI == "about:blank" && !browser.canGoBack && !browser.canGoForward) {
|
if (currentURI == "about:blank" && !browser.canGoBack && !browser.canGoForward) {
|
||||||
|
oldTab.chromeTab.ignoreUndo = true;
|
||||||
this.closeTab(oldTab);
|
this.closeTab(oldTab);
|
||||||
oldTab = null;
|
oldTab = null;
|
||||||
}
|
}
|
||||||
|
@ -672,11 +673,13 @@ var Browser = {
|
||||||
return newTab;
|
return newTab;
|
||||||
},
|
},
|
||||||
|
|
||||||
closeTab: function(tab) {
|
closeTab: function(aTab) {
|
||||||
if (tab instanceof XULElement)
|
let tab = aTab;
|
||||||
tab = this.getTabFromChrome(tab);
|
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;
|
return;
|
||||||
|
|
||||||
// Make sure we leave the toolbar in an unlocked state
|
// Make sure we leave the toolbar in an unlocked state
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
</content>
|
</content>
|
||||||
|
|
||||||
<implementation>
|
<implementation>
|
||||||
|
<field name="ignoreUndo">false</field>
|
||||||
<field name="thumbnail">document.getAnonymousElementByAttribute(this, "anonid", "thumbnail");</field>
|
<field name="thumbnail">document.getAnonymousElementByAttribute(this, "anonid", "thumbnail");</field>
|
||||||
<field name="_container">this.parentNode.parentNode;</field>
|
<field name="_container">this.parentNode.parentNode;</field>
|
||||||
<method name="_onClick">
|
<method name="_onClick">
|
||||||
|
@ -35,7 +36,6 @@
|
||||||
<method name="_onClose">
|
<method name="_onClose">
|
||||||
<body>
|
<body>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
|
||||||
let callbackFunc = this._container.getAttribute(this.hasAttribute("reload") ? "onclosereloadtab" : "onclosetab");
|
let callbackFunc = this._container.getAttribute(this.hasAttribute("reload") ? "onclosereloadtab" : "onclosetab");
|
||||||
let closeFn = new Function("event", callbackFunc);
|
let closeFn = new Function("event", callbackFunc);
|
||||||
closeFn.call(this);
|
closeFn.call(this);
|
||||||
|
@ -129,7 +129,9 @@
|
||||||
this._closedTab = null;
|
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")) {
|
if (aTab.thumbnail && !aTab.thumbnail.hasAttribute("empty")) {
|
||||||
// duplicate the old thumbnail to the new one because moving the
|
// duplicate the old thumbnail to the new one because moving the
|
||||||
// tab in the dom clear the canvas
|
// 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_01;
|
||||||
let new_tab_02;
|
let new_tab_02;
|
||||||
let new_tab_03;
|
let new_tab_03;
|
||||||
|
let new_tab_04;
|
||||||
|
let new_tab_05;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Entry point (must be named "test")
|
// 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(new_tab_03.owner, null, "Closing tab 01 nulls tab3 owner");
|
||||||
is(Browser.selectedTab.notification, Elements.browsers.selectedPanel, "Deck has correct browser");
|
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();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +121,8 @@ function done() {
|
||||||
Browser.closeTab(new_tab_01);
|
Browser.closeTab(new_tab_01);
|
||||||
Browser.closeTab(new_tab_02);
|
Browser.closeTab(new_tab_02);
|
||||||
Browser.closeTab(new_tab_03);
|
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.
|
// For some reason, this test is causing the sidebar to appear.
|
||||||
// Clean up the UI for later tests (see bug 598962).
|
// Clean up the UI for later tests (see bug 598962).
|
||||||
|
|
Загрузка…
Ссылка в новой задаче