mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
Bug 1446222 - Move DevTools frame startup to new dir. r=jdescottes
Move and rename the server's frame script that starts DevTools in remote frames from `child.js` to `startup/frame.js`. `connectToChild` also becomes the more generic `connectToFrame`. A few b2g-isms like "app" are also removed. These code paths will likely change more as Site Isolation work continues, but for now, we have this light cleanup to gather startup-related paths together. MozReview-Commit-ID: El8a0OE99gZ --HG-- rename : devtools/server/child.js => devtools/server/startup/frame.js rename : devtools/server/tests/mochitest/test_connectToChild.html => devtools/server/tests/mochitest/test_connectToFrame.html extra : rebase_source : 2735c53587257b215d720204cf7c4581088eba42
This commit is contained in:
parent
c6636c8067
commit
1c5534b4d8
@ -407,7 +407,7 @@ TabTarget.prototype = {
|
||||
DebuggerServer.init();
|
||||
|
||||
// When connecting to a local tab, we only need the root actor.
|
||||
// Then we are going to call DebuggerServer.connectToChild and talk
|
||||
// Then we are going to call DebuggerServer.connectToFrame and talk
|
||||
// directly with actors living in the child process.
|
||||
// We also need browser actors for actor registry which enabled addons
|
||||
// to register custom actors.
|
||||
|
@ -448,7 +448,7 @@ MessageManagerTunnel.prototype = {
|
||||
|
||||
OUTER_TO_INNER_FRAME_SCRIPTS: [
|
||||
// DevTools server for OOP frames
|
||||
"resource://devtools/server/child.js"
|
||||
"resource://devtools/server/startup/frame.js"
|
||||
],
|
||||
|
||||
get outer() {
|
||||
|
@ -721,7 +721,7 @@ BrowserTabActor.prototype = {
|
||||
}
|
||||
this.exit();
|
||||
};
|
||||
let connect = DebuggerServer.connectToChild(this._conn, this._browser, onDestroy);
|
||||
let connect = DebuggerServer.connectToFrame(this._conn, this._browser, onDestroy);
|
||||
let form = await connect;
|
||||
|
||||
this._form = form;
|
||||
|
@ -161,7 +161,7 @@ ProxyChildActor.prototype = {
|
||||
|
||||
this._browser = await ExtensionParent.DebugUtils.getExtensionProcessBrowser(this);
|
||||
|
||||
this._form = await DebuggerServer.connectToChild(this._conn, this._browser, onDestroy,
|
||||
this._form = await DebuggerServer.connectToFrame(this._conn, this._browser, onDestroy,
|
||||
{addonId: this.addonId});
|
||||
|
||||
this._childActorID = this._form.actor;
|
||||
|
@ -47,7 +47,7 @@ const FALLBACK_DOC_MESSAGE = "Your addon does not have any document opened yet."
|
||||
* The connection to the client.
|
||||
* @param {nsIMessageSender} chromeGlobal.
|
||||
* The chromeGlobal where this actor has been injected by the
|
||||
* DebuggerServer.connectToChild method.
|
||||
* DebuggerServer.connectToFrame method.
|
||||
* @param {string} prefix
|
||||
* the custom RDP prefix to use.
|
||||
* @param {string} addonId
|
||||
|
@ -973,12 +973,13 @@ var DebuggerServer = {
|
||||
_childMessageManagers: new Set(),
|
||||
|
||||
/**
|
||||
* Connect to a child process.
|
||||
* Start a DevTools server in a remote frame's process and add it as a child server for
|
||||
* an active connection.
|
||||
*
|
||||
* @param object connection
|
||||
* The debugger server connection to use.
|
||||
* @param nsIDOMElement frame
|
||||
* The browser element that holds the child process.
|
||||
* The frame element with remote content to connect to.
|
||||
* @param function [onDestroy]
|
||||
* Optional function to invoke when the child process closes
|
||||
* or the connection shuts down. (Need to forget about the
|
||||
@ -987,12 +988,12 @@ var DebuggerServer = {
|
||||
* A promise object that is resolved once the connection is
|
||||
* established.
|
||||
*/
|
||||
connectToChild(connection, frame, onDestroy, {addonId} = {}) {
|
||||
connectToFrame(connection, frame, onDestroy, {addonId} = {}) {
|
||||
return new Promise(resolve => {
|
||||
// Get messageManager from XUL browser (which might be a specialized tunnel for RDM)
|
||||
// or else fallback to asking the frameLoader itself.
|
||||
let mm = frame.messageManager || frame.frameLoader.messageManager;
|
||||
mm.loadFrameScript("resource://devtools/server/child.js", false);
|
||||
mm.loadFrameScript("resource://devtools/server/startup/frame.js", false);
|
||||
|
||||
let trackMessageManager = () => {
|
||||
frame.addEventListener("DevTools:BrowserSwap", onBrowserSwap);
|
||||
@ -1021,7 +1022,7 @@ var DebuggerServer = {
|
||||
// between e10s parent and child processes
|
||||
let parentModules = [];
|
||||
let onSetupInParent = function(msg) {
|
||||
// We may have multiple connectToChild instance running for the same tab
|
||||
// We may have multiple connectToFrame instance running for the same tab
|
||||
// and need to filter the messages.
|
||||
if (msg.json.prefix != connPrefix) {
|
||||
return false;
|
||||
@ -1067,7 +1068,7 @@ var DebuggerServer = {
|
||||
|
||||
connection.setForwarding(prefix, childTransport);
|
||||
|
||||
dumpn("establishing forwarding for app with prefix " + prefix);
|
||||
dumpn(`Start forwarding for frame with prefix ${prefix}`);
|
||||
|
||||
actor = msg.json.actor;
|
||||
resolve(actor);
|
||||
@ -1129,14 +1130,14 @@ var DebuggerServer = {
|
||||
// Nothing to do
|
||||
}
|
||||
} else {
|
||||
// Otherwise, the app has been closed before the actor
|
||||
// Otherwise, the frame has been closed before the actor
|
||||
// had a chance to be created, so we are not able to create
|
||||
// the actor.
|
||||
resolve(null);
|
||||
}
|
||||
if (actor) {
|
||||
// The ContentActor within the child process doesn't necessary
|
||||
// have time to uninitialize itself when the app is closed/killed.
|
||||
// have time to uninitialize itself when the frame is closed/killed.
|
||||
// So ensure telling the client that the related actor is detached.
|
||||
connection.send({ from: actor.actor, type: "tabDetached" });
|
||||
actor = null;
|
||||
|
@ -10,6 +10,7 @@ DIRS += [
|
||||
'actors',
|
||||
'performance',
|
||||
'socket',
|
||||
'startup',
|
||||
]
|
||||
|
||||
BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini']
|
||||
@ -17,7 +18,6 @@ MOCHITEST_CHROME_MANIFESTS += ['tests/mochitest/chrome.ini']
|
||||
XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
|
||||
|
||||
DevToolsModules(
|
||||
'child.js',
|
||||
'content-process-debugger-server.js',
|
||||
'content-server.jsm',
|
||||
'main.js',
|
||||
|
@ -6,6 +6,12 @@
|
||||
|
||||
/* global addEventListener, addMessageListener, removeMessageListener, sendAsyncMessage */
|
||||
|
||||
/*
|
||||
* Frame script that listens for requests to start a `DebuggerServer` for a frame in a
|
||||
* content process. Loaded into content process frames by the main process during
|
||||
* `DebuggerServer.connectToFrame`.
|
||||
*/
|
||||
|
||||
try {
|
||||
var chromeGlobal = this;
|
||||
|
||||
@ -128,5 +134,5 @@ try {
|
||||
});
|
||||
})();
|
||||
} catch (e) {
|
||||
dump(`Exception in app child process: ${e}\n`);
|
||||
dump(`Exception in DevTools frame startup: ${e}\n`);
|
||||
}
|
9
devtools/server/startup/moz.build
Normal file
9
devtools/server/startup/moz.build
Normal file
@ -0,0 +1,9 @@
|
||||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DevToolsModules(
|
||||
'frame.js',
|
||||
)
|
@ -31,7 +31,7 @@ support-files =
|
||||
webextension-helpers.js
|
||||
[test_animation_actor-lifetime.html]
|
||||
[test_connection-manager.html]
|
||||
[test_connectToChild.html]
|
||||
[test_connectToFrame.html]
|
||||
[test_css-logic.html]
|
||||
[test_css-logic-media-queries.html]
|
||||
[test_css-logic-specificity.html]
|
||||
|
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Bug 966991 - Test DebuggerServer.connectToChild
|
||||
Bug 966991 - Test DebuggerServer.connectToFrame
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
@ -78,7 +78,7 @@ function runTests() {
|
||||
let transport = DebuggerServer.connectPipe();
|
||||
let conn = transport._serverConnection;
|
||||
let client = new DebuggerClient(transport);
|
||||
DebuggerServer.connectToChild(conn, iframe).then(actor => {
|
||||
DebuggerServer.connectToFrame(conn, iframe).then(actor => {
|
||||
ok(actor.testActor, "Got the test actor");
|
||||
|
||||
// Ensure sending at least one request to our actor,
|
||||
@ -107,7 +107,7 @@ function runTests() {
|
||||
let transport = DebuggerServer.connectPipe();
|
||||
let conn = transport._serverConnection;
|
||||
let client = new DebuggerClient(transport);
|
||||
DebuggerServer.connectToChild(conn, iframe).then(actor => {
|
||||
DebuggerServer.connectToFrame(conn, iframe).then(actor => {
|
||||
ok(actor.testActor, "Got a test actor for the second connection");
|
||||
isnot(actor.testActor, firstActor,
|
||||
"We get different actor instances between two connections");
|
@ -80,7 +80,7 @@ function runTests() {
|
||||
Services.obs.addObserver(onParent, "test:setupParent");
|
||||
|
||||
// Instanciate e10s machinery and call setupInChild
|
||||
DebuggerServer.connectToChild(conn, iframe).then(actor => {
|
||||
DebuggerServer.connectToFrame(conn, iframe).then(actor => {
|
||||
DebuggerServer.setupInChild({
|
||||
module: "chrome://mochitests/content/chrome/devtools/server/tests/mochitest/setup-in-child.js",
|
||||
setupChild: "setupChild",
|
||||
|
Loading…
Reference in New Issue
Block a user