зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1502069 - isTabEmpty should be a property on the tab rather than a global function. r=dao
Differential Revision: https://phabricator.services.mozilla.com/D9926 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
109fda93b5
Коммит
e7f2c79ef9
|
@ -7175,7 +7175,7 @@ function BrowserOpenAddonsMgr(aView) {
|
||||||
|
|
||||||
// This must be a new load, else the ping/pong would have
|
// This must be a new load, else the ping/pong would have
|
||||||
// found the window above.
|
// found the window above.
|
||||||
let whereToOpen = (window.gBrowser && isTabEmpty(gBrowser.selectedTab)) ?
|
let whereToOpen = (window.gBrowser && gBrowser.selectedTab.isEmpty) ?
|
||||||
"current" :
|
"current" :
|
||||||
"tab";
|
"tab";
|
||||||
openTrustedLinkIn("about:addons", whereToOpen);
|
openTrustedLinkIn("about:addons", whereToOpen);
|
||||||
|
@ -7225,7 +7225,7 @@ function AddKeywordForSearchField() {
|
||||||
function undoCloseTab(aIndex) {
|
function undoCloseTab(aIndex) {
|
||||||
// wallpaper patch to prevent an unnecessary blank tab (bug 343895)
|
// wallpaper patch to prevent an unnecessary blank tab (bug 343895)
|
||||||
var blankTabToRemove = null;
|
var blankTabToRemove = null;
|
||||||
if (gBrowser.tabs.length == 1 && isTabEmpty(gBrowser.selectedTab))
|
if (gBrowser.tabs.length == 1 && gBrowser.selectedTab.isEmpty)
|
||||||
blankTabToRemove = gBrowser.selectedTab;
|
blankTabToRemove = gBrowser.selectedTab;
|
||||||
|
|
||||||
var tab = null;
|
var tab = null;
|
||||||
|
@ -7253,30 +7253,6 @@ function undoCloseWindow(aIndex) {
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Determines if a tab is "empty", usually used in the context of determining
|
|
||||||
* if it's ok to close the tab.
|
|
||||||
*/
|
|
||||||
function isTabEmpty(aTab) {
|
|
||||||
if (aTab.hasAttribute("busy"))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (aTab.hasAttribute("customizemode"))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
let browser = aTab.linkedBrowser;
|
|
||||||
if (!isBlankPageURL(browser.currentURI.spec))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!checkEmptyPageOrigin(browser))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (browser.canGoForward || browser.canGoBack)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether a page can be considered as 'empty', that its URI
|
* Check whether a page can be considered as 'empty', that its URI
|
||||||
* reflects its origin, and that if it's loaded in a tab, that tab
|
* reflects its origin, and that if it's loaded in a tab, that tab
|
||||||
|
@ -7655,7 +7631,7 @@ function switchToTabHavingURI(aURI, aOpenNew, aOpenParams = {}) {
|
||||||
|
|
||||||
// No opened tab has that url.
|
// No opened tab has that url.
|
||||||
if (aOpenNew) {
|
if (aOpenNew) {
|
||||||
if (isBrowserWindow && isTabEmpty(gBrowser.selectedTab))
|
if (isBrowserWindow && gBrowser.selectedTab.isEmpty)
|
||||||
openTrustedLinkIn(aURI.spec, "current", aOpenParams);
|
openTrustedLinkIn(aURI.spec, "current", aOpenParams);
|
||||||
else
|
else
|
||||||
openTrustedLinkIn(aURI.spec, "tab", aOpenParams);
|
openTrustedLinkIn(aURI.spec, "tab", aOpenParams);
|
||||||
|
|
|
@ -1118,7 +1118,7 @@ window._gBrowser = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!window.fullScreen || isTabEmpty(newTab)) {
|
if (!window.fullScreen || newTab.isEmpty) {
|
||||||
focusAndSelectUrlBar();
|
focusAndSelectUrlBar();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -5008,7 +5008,7 @@ class TabProgressListener {
|
||||||
|
|
||||||
if (aWebProgress.isTopLevel) {
|
if (aWebProgress.isTopLevel) {
|
||||||
let isSuccessful = Components.isSuccessCode(aStatus);
|
let isSuccessful = Components.isSuccessCode(aStatus);
|
||||||
if (!isSuccessful && !isTabEmpty(this.mTab)) {
|
if (!isSuccessful && !this.mTab.isEmpty) {
|
||||||
// Restore the current document's location in case the
|
// Restore the current document's location in case the
|
||||||
// request was stopped (possibly from a content script)
|
// request was stopped (possibly from a content script)
|
||||||
// before the location changed.
|
// before the location changed.
|
||||||
|
|
|
@ -2059,6 +2059,30 @@
|
||||||
</getter>
|
</getter>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
|
<property name="isEmpty" readonly="true">
|
||||||
|
<getter>
|
||||||
|
// Determines if a tab is "empty", usually used in the context of determining
|
||||||
|
// if it's ok to close the tab.
|
||||||
|
if (this.hasAttribute("busy"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (this.hasAttribute("customizemode"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
let browser = this.linkedBrowser;
|
||||||
|
if (!isBlankPageURL(browser.currentURI.spec))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!checkEmptyPageOrigin(browser))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (browser.canGoForward || browser.canGoBack)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
</getter>
|
||||||
|
</property>
|
||||||
|
|
||||||
<property name="lastAccessed">
|
<property name="lastAccessed">
|
||||||
<getter>
|
<getter>
|
||||||
return this._lastAccessed == Infinity ? Date.now() : this._lastAccessed;
|
return this._lastAccessed == Infinity ? Date.now() : this._lastAccessed;
|
||||||
|
|
|
@ -50,7 +50,7 @@ add_task(async function checkPrefTurnsOffCanonize() {
|
||||||
|
|
||||||
let tabsToClose = [];
|
let tabsToClose = [];
|
||||||
// Ensure we don't end up loading something in the current tab becuase it's empty:
|
// Ensure we don't end up loading something in the current tab becuase it's empty:
|
||||||
if (isTabEmpty(gBrowser.selectedTab)) {
|
if (gBrowser.selectedTab.isEmpty) {
|
||||||
tabsToClose.push(await BrowserTestUtils.openNewForegroundTab({gBrowser, opening: "about:mozilla"}));
|
tabsToClose.push(await BrowserTestUtils.openNewForegroundTab({gBrowser, opening: "about:mozilla"}));
|
||||||
}
|
}
|
||||||
let initialTabURL = gBrowser.selectedBrowser.currentURI.spec;
|
let initialTabURL = gBrowser.selectedBrowser.currentURI.spec;
|
||||||
|
|
|
@ -620,7 +620,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
}
|
}
|
||||||
reuseEmpty = true;
|
reuseEmpty = true;
|
||||||
}
|
}
|
||||||
if (where == "tab" && reuseEmpty && isTabEmpty(gBrowser.selectedTab)) {
|
if (where == "tab" && reuseEmpty && gBrowser.selectedTab.isEmpty) {
|
||||||
where = "current";
|
where = "current";
|
||||||
}
|
}
|
||||||
return where;
|
return where;
|
||||||
|
@ -736,7 +736,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
};
|
};
|
||||||
|
|
||||||
if (switchToTabHavingURI(url, false, loadOpts) &&
|
if (switchToTabHavingURI(url, false, loadOpts) &&
|
||||||
isTabEmpty(prevTab)) {
|
prevTab.isEmpty) {
|
||||||
gBrowser.removeTab(prevTab);
|
gBrowser.removeTab(prevTab);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -677,7 +677,7 @@ var PlacesUIUtils = {
|
||||||
if (where == "current" && !aNode.uri.startsWith("javascript:")) {
|
if (where == "current" && !aNode.uri.startsWith("javascript:")) {
|
||||||
where = "tab";
|
where = "tab";
|
||||||
}
|
}
|
||||||
if (where == "tab" && browserWindow.isTabEmpty(browserWindow.gBrowser.selectedTab)) {
|
if (where == "tab" && browserWindow.gBrowser.selectedTab.isEmpty) {
|
||||||
where = "current";
|
where = "current";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ var Pocket = {
|
||||||
let win = event.view;
|
let win = event.view;
|
||||||
let where = win.whereToOpenLink(event);
|
let where = win.whereToOpenLink(event);
|
||||||
// Never override the current tab unless it's blank:
|
// Never override the current tab unless it's blank:
|
||||||
if (where == "current" && !win.isTabEmpty(win.gBrowser.selectedTab)) {
|
if (where == "current" && !win.gBrowser.selectedTab.isEmpty) {
|
||||||
where = "tab";
|
where = "tab";
|
||||||
}
|
}
|
||||||
win.openTrustedLinkIn(this.listURL, where);
|
win.openTrustedLinkIn(this.listURL, where);
|
||||||
|
|
|
@ -857,7 +857,7 @@ class MozSearchOneOffs extends MozXULElement {
|
||||||
} else {
|
} else {
|
||||||
var newTabPref = Services.prefs.getBoolPref("browser.search.openintab");
|
var newTabPref = Services.prefs.getBoolPref("browser.search.openintab");
|
||||||
if ((aEvent instanceof KeyboardEvent && aEvent.altKey) ^ newTabPref &&
|
if ((aEvent instanceof KeyboardEvent && aEvent.altKey) ^ newTabPref &&
|
||||||
!isTabEmpty(gBrowser.selectedTab)) {
|
!gBrowser.selectedTab.isEmpty) {
|
||||||
where = "tab";
|
where = "tab";
|
||||||
}
|
}
|
||||||
if (aEvent instanceof MouseEvent &&
|
if (aEvent instanceof MouseEvent &&
|
||||||
|
|
|
@ -273,7 +273,7 @@ class MozSearchbar extends MozXULElement {
|
||||||
} else {
|
} else {
|
||||||
var newTabPref = Services.prefs.getBoolPref("browser.search.openintab");
|
var newTabPref = Services.prefs.getBoolPref("browser.search.openintab");
|
||||||
if (((aEvent instanceof KeyboardEvent && aEvent.altKey) ^ newTabPref) &&
|
if (((aEvent instanceof KeyboardEvent && aEvent.altKey) ^ newTabPref) &&
|
||||||
!isTabEmpty(gBrowser.selectedTab)) {
|
!gBrowser.selectedTab.isEmpty) {
|
||||||
where = "tab";
|
where = "tab";
|
||||||
}
|
}
|
||||||
if ((aEvent instanceof MouseEvent) &&
|
if ((aEvent instanceof MouseEvent) &&
|
||||||
|
|
|
@ -215,7 +215,7 @@ class UrlbarController {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.window.switchToTabHavingURI(url, false, loadOpts) &&
|
if (this.window.switchToTabHavingURI(url, false, loadOpts) &&
|
||||||
this.window.isTabEmpty(prevTab)) {
|
prevTab.isEmpty) {
|
||||||
this.window.gBrowser.removeTab(prevTab);
|
this.window.gBrowser.removeTab(prevTab);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -381,7 +381,7 @@ class UrlbarController {
|
||||||
}
|
}
|
||||||
if (where == "tab" &&
|
if (where == "tab" &&
|
||||||
reuseEmpty &&
|
reuseEmpty &&
|
||||||
this.window.isTabEmpty(this.window.gBrowser.selectedTab)) {
|
this.window.gBrowser.selectedTab.isEmpty) {
|
||||||
where = "current";
|
where = "current";
|
||||||
}
|
}
|
||||||
return where;
|
return where;
|
||||||
|
|
|
@ -52,7 +52,7 @@ add_task(function test_handleEnteredText_url() {
|
||||||
|
|
||||||
add_task(function test_resultSelected_switchtab() {
|
add_task(function test_resultSelected_switchtab() {
|
||||||
sandbox.stub(window, "switchToTabHavingURI").returns(true);
|
sandbox.stub(window, "switchToTabHavingURI").returns(true);
|
||||||
sandbox.stub(window, "isTabEmpty").returns(false);
|
sandbox.stub(window.gBrowser.selectedTab, "isEmpty").returns(false);
|
||||||
sandbox.stub(window.gBrowser, "removeTab");
|
sandbox.stub(window.gBrowser, "removeTab");
|
||||||
|
|
||||||
const event = new MouseEvent("click", {button: 0});
|
const event = new MouseEvent("click", {button: 0});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче