зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1410360 - reselect original tab after closing about:devtools;r=ochameau
MozReview-Commit-ID: 3bInaF7Zeg9 --HG-- extra : rebase_source : d31509b2264a82d091cfdeacf8e889635f4a65b8
This commit is contained in:
Родитель
c166f24405
Коммит
097acc3d05
|
@ -21,6 +21,7 @@ const MESSAGES = {
|
|||
// we have to use http in order to have working searchParams.
|
||||
let url = new URL(window.location.href.replace("about:", "http://"));
|
||||
let reason = url.searchParams.get("reason");
|
||||
let tabid = parseInt(url.searchParams.get("tabid"), 10);
|
||||
|
||||
function getToolboxShortcut() {
|
||||
const bundleUrl = "chrome://devtools-shim/locale/key-shortcuts.properties";
|
||||
|
@ -75,6 +76,25 @@ window.addEventListener("load", function () {
|
|||
updatePage();
|
||||
}, { once: true });
|
||||
|
||||
window.addEventListener("beforeunload", function () {
|
||||
// Focus the tab that triggered the DevTools onboarding.
|
||||
if (document.visibilityState != "visible") {
|
||||
// Only try to focus the correct tab if the current tab is the about:devtools page.
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve the original tab if it is still available.
|
||||
let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
let { gBrowser } = browserWindow;
|
||||
let originalBrowser = gBrowser.getBrowserForOuterWindowID(tabid);
|
||||
let originalTab = gBrowser.getTabForBrowser(originalBrowser);
|
||||
|
||||
if (originalTab) {
|
||||
// If the original tab was found, select it.
|
||||
gBrowser.selectedTab = originalTab;
|
||||
}
|
||||
}, {once: true});
|
||||
|
||||
window.addEventListener("unload", function () {
|
||||
let installButton = document.getElementById("install");
|
||||
installButton.removeEventListener("click", onInstallButtonClick);
|
||||
|
|
|
@ -545,8 +545,19 @@ DevToolsStartup.prototype = {
|
|||
}
|
||||
|
||||
let url = "about:devtools";
|
||||
|
||||
let params = [];
|
||||
if (reason) {
|
||||
url += "?reason=" + encodeURIComponent(reason);
|
||||
params.push("reason=" + encodeURIComponent(reason));
|
||||
}
|
||||
|
||||
let selectedBrowser = gBrowser.selectedBrowser;
|
||||
if (selectedBrowser) {
|
||||
params.push("tabid=" + selectedBrowser.outerWindowID);
|
||||
}
|
||||
|
||||
if (params.length > 0) {
|
||||
url += "?" + params.join("&");
|
||||
}
|
||||
|
||||
// Set relatedToCurrent: true to open the tab next to the current one.
|
||||
|
|
Загрузка…
Ссылка в новой задаче