Bug 1521440: Avoid to move to about:blank after destroying. r=ochameau,jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D17795

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Daisuke Akatsuka 2019-01-31 18:08:19 +00:00
Родитель 91c1df13da
Коммит 0c01c764aa
6 изменённых файлов: 53 добавлений и 7 удалений

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

@ -104,6 +104,7 @@ ToolboxHostManager.prototype = {
this.hostType === Toolbox.HostType.RIGHT) {
this.host.frame.minWidth = WIDTH_CHEVRON_AND_MEATBALL_AND_CLOSE * zoomValue;
} else if (this.hostType === Toolbox.HostType.WINDOW ||
this.hostType === Toolbox.HostType.PAGE ||
this.hostType === Toolbox.HostType.CUSTOM) {
this.host.frame.minWidth = WIDTH_CHEVRON_AND_MEATBALL * zoomValue;
}
@ -215,7 +216,8 @@ ToolboxHostManager.prototype = {
this.destroyHost();
if (this.hostType != Toolbox.HostType.CUSTOM) {
if (this.hostType !== Toolbox.HostType.CUSTOM &&
this.hostType !== Toolbox.HostType.PAGE) {
Services.prefs.setCharPref(PREVIOUS_HOST, this.hostType);
}
@ -227,7 +229,8 @@ ToolboxHostManager.prototype = {
this.setMinWidthWithZoom();
if (hostType != Toolbox.HostType.CUSTOM) {
if (hostType !== Toolbox.HostType.CUSTOM &&
hostType !== Toolbox.HostType.PAGE) {
Services.prefs.setCharPref(LAST_HOST, hostType);
}

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

@ -370,6 +370,35 @@ CustomHost.prototype = {
},
};
/**
* Host object for the toolbox as a page.
* This is typically used by `about:debugging`, when opening toolbox in a new tab,
* via `about:devtools-toolbox` URLs.
* The `iframe` ends up being the tab's browser element.
*/
function PageHost(hostTab, options) {
this.frame = options.customIframe;
}
PageHost.prototype = {
type: "page",
create: function() {
return promise.resolve(this.frame);
},
// Do nothing.
raise: function() {},
// Do nothing.
setTitle: function(title) {},
// Do nothing.
destroy: function() {
return promise.resolve(null);
},
};
/**
* Switch to the given tab in a browser and focus the browser window
*/
@ -385,5 +414,5 @@ exports.Hosts = {
"right": RightHost,
"window": WindowHost,
"custom": CustomHost,
"page": PageHost,
};

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

@ -77,7 +77,7 @@ if (url.search.length > 1) {
target = await targetFromURL(url);
}
const options = { customIframe: host };
await gDevTools.showToolbox(target, tool, Toolbox.HostType.CUSTOM, options);
await gDevTools.showToolbox(target, tool, Toolbox.HostType.PAGE, options);
})().catch(error => {
console.error("Exception while loading the toolbox", error);
});

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

@ -220,6 +220,9 @@ Toolbox.HostType = {
LEFT: "left",
WINDOW: "window",
CUSTOM: "custom",
// This is typically used by `about:debugging`, when opening toolbox in a new tab,
// via `about:devtools-toolbox` URLs.
PAGE: "page",
};
Toolbox.prototype = {
@ -435,7 +438,9 @@ Toolbox.prototype = {
if (isToolboxURL) {
// Update the URL so that onceDOMReady watch for the right url.
this._URL = this.win.location.href;
}
if (this.hostType === Toolbox.HostType.PAGE) {
// Displays DebugTargetInfo which shows the basic information of debug target,
// if `about:devtools-toolbox` URL opens directly.
// DebugTargetInfo requires this._deviceDescription to be populated
@ -727,6 +732,7 @@ Toolbox.prototype = {
case Toolbox.HostType.WINDOW: return 2;
case Toolbox.HostType.CUSTOM: return 3;
case Toolbox.HostType.LEFT: return 4;
case Toolbox.HostType.PAGE: return 5;
default: return 9;
}
},
@ -738,6 +744,7 @@ Toolbox.prototype = {
case Toolbox.HostType.LEFT: return "left";
case Toolbox.HostType.RIGHT: return "right";
case Toolbox.HostType.WINDOW: return "window";
case Toolbox.HostType.PAGE: return "page";
case Toolbox.HostType.CUSTOM: return "other";
default: return "bottom";
}
@ -1105,6 +1112,7 @@ Toolbox.prototype = {
for (const type in Toolbox.HostType) {
const position = Toolbox.HostType[type];
if (position == Toolbox.HostType.CUSTOM ||
position == Toolbox.HostType.PAGE ||
(!sideEnabled &&
(position == Toolbox.HostType.LEFT || position == Toolbox.HostType.RIGHT))) {
continue;
@ -2981,7 +2989,13 @@ Toolbox.prototype = {
// target attribute to be still
// defined.
try {
win.location.replace("about:blank");
// If this toolbox displayed as a page, avoid to move to `about:blank`.
// For example in case of reloading, when the thread of processing of
// destroying the toolbox arrives at here after starting reloading process,
// although we should display same page, `about:blank` will display.
if (this.hostType !== Toolbox.HostType.PAGE) {
win.location.replace("about:blank");
}
} catch (e) {
// Do nothing;
}

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

@ -281,7 +281,7 @@ devtools.main:
release_channel_collection: opt-out
expiry_version: never
extra_keys:
host: "Toolbox host (positioning): bottom, side, window or other."
host: "Toolbox host (positioning): bottom, left, right, window, page or other."
width: Toolbox width rounded up to the nearest 50px.
session_id: The start time of the session in milliseconds since epoch (Unix Timestamp) e.g. 1396381378123.
add_breakpoint:

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

@ -10493,7 +10493,7 @@
"bug_numbers": [1205845, 1389995],
"n_values": 9,
"releaseChannelCollection": "opt-out",
"description": "Records DevTools toolbox host each time the toolbox is opened and when the host is changed (0:Bottom, 1:Side, 2:Window, 3:Custom, 9:Unknown)."
"description": "Records DevTools toolbox host each time the toolbox is opened and when the host is changed (0:Bottom, 1:RIGHT, 2:WINDOW, 3:CUSTOM, 4:LEFT, 5:PAGE, 9:Unknown)."
},
"DEVTOOLS_NUMBER_OF_CSS_GRIDS_IN_A_PAGE": {
"record_in_processes": ["main", "content"],