Bug 1607754 - Only load about:blank in the devtools frame when switching hosts r=ochameau

Depends on D58238

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Julian Descottes 2020-01-20 13:11:25 +00:00
Родитель 02ba7ec7fb
Коммит 8289090415
2 изменённых файлов: 9 добавлений и 19 удалений

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

@ -11,6 +11,7 @@ const L10N = new LocalizationHelper(
);
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
const Telemetry = require("devtools/client/shared/telemetry");
const { DOMHelpers } = require("devtools/shared/dom-helpers");
// The min-width of toolbox and browser toolbox.
const WIDTH_CHEVRON_AND_MEATBALL = 50;
@ -235,6 +236,14 @@ ToolboxHostManager.prototype = {
const iframe = this.host.frame;
const newHost = this.createHost(hostType);
const newIframe = await newHost.create();
// Load a blank document in the host frame. The new iframe must have a valid
// document before using swapFrameLoaders().
await new Promise(resolve => {
newIframe.setAttribute("src", "about:blank");
DOMHelpers.onceDOMReady(newIframe.contentWindow, resolve);
});
// change toolbox document's parent to the new host
newIframe.swapFrameLoaders(iframe);

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

@ -7,7 +7,6 @@
const EventEmitter = require("devtools/shared/event-emitter");
const promise = require("promise");
const Services = require("Services");
const { DOMHelpers } = require("devtools/shared/dom-helpers");
loader.lazyRequireGetter(
this,
@ -82,7 +81,6 @@ BottomHost.prototype = {
this._browserContainer.appendChild(this.frame);
focusTab(this.hostTab);
await createBlankDocument(this.frame);
this.emit("ready", this.frame);
return this.frame;
@ -170,7 +168,6 @@ class SidebarHost {
}
focusTab(this.hostTab);
await createBlankDocument(this.frame);
this.emit("ready", this.frame);
return this.frame;
@ -279,8 +276,6 @@ WindowHost.prototype = {
// CSS transitions when switching from docked to window hosts.
// Added in Bug 832920, should be reviewed in Bug 1542468.
this.frame.setAttribute("forceOwnRefreshDriver", "");
this.frame.setAttribute("src", "about:blank");
resolve(this.frame);
};
@ -351,7 +346,6 @@ BrowserToolboxHost.prototype = {
this.doc.body.appendChild(this.frame);
await createBlankDocument(this.frame);
this.emit("ready", this.frame);
return this.frame;
@ -427,19 +421,6 @@ function createDevToolsFrame(doc, className) {
return frame;
}
/**
* Load a blank document in the host frame.
* This is mandatory if the host is created for switching hosts. In that case,
* the new host's frame needs to have a valid document before we can swap the
* content of the previous host.
*/
function createBlankDocument(frame) {
return new Promise(resolve => {
frame.setAttribute("src", "about:blank");
DOMHelpers.onceDOMReady(frame.contentWindow, resolve);
});
}
exports.Hosts = {
bottom: BottomHost,
left: LeftHost,