зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1302702 - Shorter extension urls in addon debugger window title and frames list selector. r=ochameau
MozReview-Commit-ID: zMdiVPyBUR --HG-- extra : rebase_source : aec19e2edba5c44b5bdf4c0bf7dd6924e058cf70
This commit is contained in:
Родитель
06558b719f
Коммит
4a08259610
|
@ -370,6 +370,25 @@ TabTarget.prototype = {
|
|||
return !this.window;
|
||||
},
|
||||
|
||||
getExtensionPathName(url) {
|
||||
// Return the url if the target is not a webextension.
|
||||
if (!this.isWebExtension) {
|
||||
throw new Error("Target is not a WebExtension");
|
||||
}
|
||||
|
||||
try {
|
||||
const parsedURL = new URL(url);
|
||||
// Only moz-extension URL should be shortened into the URL pathname.
|
||||
if (parsedURL.protocol !== "moz-extension:") {
|
||||
return url;
|
||||
}
|
||||
return parsedURL.pathname;
|
||||
} catch (e) {
|
||||
// Return the url if unable to resolve the pathname.
|
||||
return url;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds remote protocol capabilities to the target, so that it can be used
|
||||
* for tools that support the Remote Debugging Protocol even for local
|
||||
|
@ -514,8 +533,11 @@ TabTarget.prototype = {
|
|||
event.nativeConsoleAPI = packet.nativeConsoleAPI;
|
||||
event.isFrameSwitching = packet.isFrameSwitching;
|
||||
|
||||
if (!packet.isFrameSwitching) {
|
||||
// Update the title and url unless this is a frame switch.
|
||||
// Keep the title unmodified when a developer toolbox switches frame
|
||||
// for a tab (Bug 1261687), but always update the title when the target
|
||||
// is a WebExtension (where the addon name is always included in the title
|
||||
// and the url is supposed to be updated every time the selected frame changes).
|
||||
if (!packet.isFrameSwitching || this.isWebExtension) {
|
||||
this._url = packet.url;
|
||||
this._title = packet.title;
|
||||
}
|
||||
|
|
|
@ -1813,8 +1813,10 @@ Toolbox.prototype = {
|
|||
_refreshHostTitle: function () {
|
||||
let title;
|
||||
if (this.target.name && this.target.name != this.target.url) {
|
||||
const url = this.target.isWebExtension ?
|
||||
this.target.getExtensionPathName(this.target.url) : this.target.url;
|
||||
title = L10N.getFormatStr("toolbox.titleTemplate2", this.target.name,
|
||||
this.target.url);
|
||||
url);
|
||||
} else {
|
||||
title = L10N.getFormatStr("toolbox.titleTemplate1", this.target.url);
|
||||
}
|
||||
|
@ -1885,9 +1887,16 @@ Toolbox.prototype = {
|
|||
// A frame is checked if it's the selected one.
|
||||
let checked = frame.id == this.selectedFrameId;
|
||||
|
||||
let label = frame.url;
|
||||
|
||||
if (this.target.isWebExtension) {
|
||||
// Show a shorter url for extensions page.
|
||||
label = this.target.getExtensionPathName(frame.url);
|
||||
}
|
||||
|
||||
// Create menu item.
|
||||
menu.append(new MenuItem({
|
||||
label: frame.url,
|
||||
label,
|
||||
type: "radio",
|
||||
checked,
|
||||
click: () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче