Bug 1709267 - [devtools] Remove unused "target" query parameter from toolbox location. r=jdescottes

This wasn't used except for a test and wasn't working with server side targets.
Making this compatible with SST wasn't trivial, so I went for removing this.

Differential Revision: https://phabricator.services.mozilla.com/D130919
This commit is contained in:
Alexandre Poirot 2021-11-22 18:57:32 +00:00
Родитель 003720c295
Коммит 32ab65debf
3 изменённых файлов: 6 добавлений и 116 удалений

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

@ -133,7 +133,6 @@ run-if = e10s
[browser_toolbox_selectionchanged_event.js]
[browser_toolbox_show_toolbox_tool_ready.js]
[browser_toolbox_split_console.js]
[browser_toolbox_target.js]
[browser_toolbox_tabsswitch_shortcuts.js]
[browser_toolbox_telemetry_activate_splitconsole.js]
[browser_toolbox_telemetry_close.js]

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

@ -1,62 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Test about:devtools-toolbox?target which allows opening a toolbox in an
// iframe while defining which document to debug by setting a `target`
// attribute refering to the document to debug.
const { Toolbox } = require("devtools/client/framework/toolbox");
add_task(async function() {
// iframe loads the document to debug
const iframe = document.createXULElement("browser");
iframe.setAttribute("type", "content");
document.documentElement.appendChild(iframe);
let onLoad = once(iframe, "load", true);
iframe.setAttribute("src", "data:text/html,document to debug");
await onLoad;
is(iframe.contentWindow.document.body.innerHTML, "document to debug");
// toolbox loads the toolbox document
const toolboxIframe = document.createXULElement("iframe");
document.documentElement.appendChild(toolboxIframe);
// Important step to define which target to debug
toolboxIframe.target = iframe;
const onToolboxReady = gDevTools.once("toolbox-ready");
onLoad = once(toolboxIframe, "load", true);
toolboxIframe.setAttribute("src", "about:devtools-toolbox?target");
await onLoad;
// Also wait for toolbox-ready, as toolbox document load isn't enough, there
// is plenty of asynchronous steps during toolbox load
info("Waiting for toolbox-ready");
const toolbox = await onToolboxReady;
const { client } = toolbox.descriptorFront;
is(
toolbox.hostType,
Toolbox.HostType.PAGE,
"Host type of this toolbox shuld be Toolbox.HostType.PAGE"
);
const onToolboxDestroyed = gDevTools.once("toolbox-destroyed");
info("Removing the iframes");
toolboxIframe.remove();
// And wait for toolbox-destroyed as toolbox unload is also full of
// asynchronous operation that outlast unload event
info("Waiting for toolbox-destroyed");
await onToolboxDestroyed;
info("Toolbox destroyed");
// The descriptor involved with this special case won't close
// the client, so we have to do it manually from this test.
await client.close();
iframe.remove();
});

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

@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-env browser */
/* globals XPCNativeWrapper */
"use strict";
@ -94,17 +93,12 @@ async function initToolbox(url, host) {
const tool = url.searchParams.get("tool");
try {
let descriptor;
if (url.searchParams.has("target")) {
descriptor = await _createTestOnlyDescriptor(host);
} else {
descriptor = await descriptorFromURL(url);
const toolbox = gDevTools.getToolboxForDescriptor(descriptor);
if (toolbox && toolbox.isDestroying()) {
// If a toolbox already exists for the descriptor, wait for current
// toolbox destroy to be finished.
await toolbox.destroy();
}
const descriptor = await descriptorFromURL(url);
const toolbox = gDevTools.getToolboxForDescriptor(descriptor);
if (toolbox && toolbox.isDestroying()) {
// If a toolbox already exists for the descriptor, wait for current
// toolbox destroy to be finished.
await toolbox.destroy();
}
// Display an error page if we are connected to a remote target and we lose it
@ -129,47 +123,6 @@ async function initToolbox(url, host) {
}
}
/**
* Attach toolbox to a given browser iframe (<xul:browser> or <html:iframe
* mozbrowser>) whose reference is set on the host iframe.
*
* Note that there is no real usage of it. It is only used by the test found at
* devtools/client/framework/test/browser_toolbox_target.js.
*/
async function _createTestOnlyDescriptor(host) {
const { DevToolsServer } = require("devtools/server/devtools-server");
const { DevToolsClient } = require("devtools/client/devtools-client");
// `iframe` is the targeted document to debug
let iframe = host.wrappedJSObject ? host.wrappedJSObject.target : host.target;
if (!iframe) {
throw new Error("Unable to find the targeted iframe to debug");
}
// Need to use a xray to have attributes and behavior expected by
// devtools codebase
iframe = XPCNativeWrapper(iframe);
// Fake a xul:tab object as we don't have one.
// linkedBrowser is the only one attribute being queried by client.getTab
const tab = { linkedBrowser: iframe };
DevToolsServer.init();
DevToolsServer.registerAllActors();
const client = new DevToolsClient(DevToolsServer.connectPipe());
await client.connect();
// Creates a target for a given browser iframe.
const descriptor = await client.mainRoot.getTab({ tab });
// XXX: Normally we don't need to fetch the target anymore, but the test
// listens to an early event `toolbox-ready` which will kick in before
// the rest of `initToolbox` can be done.
await descriptor.getTarget();
return descriptor;
}
// Only use this method to attach the toolbox if some query parameters are given
if (url.search.length > 1) {
initToolbox(url, host);