forked from mirrors/gecko-dev
Bug 1222047 - Manage device and preference fronts via client.mainRoot.getFront. r=yulia
Summary: Depends On D3317 Tags: #secure-revision Bug #: 1222047 Differential Revision: https://phabricator.services.mozilla.com/D3318 MozReview-Commit-ID: 3jaFZbXVLuw
This commit is contained in:
parent
6f0326bd3a
commit
fb4cd85e35
13 changed files with 45 additions and 113 deletions
|
|
@ -366,7 +366,7 @@ async function checkServerSupportsListWorkers() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const deviceFront = await (0, _frontsDevice.getDeviceFront)(debuggerClient, root);
|
const deviceFront = await debuggerClient.mainRoot.getFront("device");
|
||||||
const description = await deviceFront.getDescription();
|
const description = await deviceFront.getDescription();
|
||||||
const isFennec = description.apptype === "mobile/android";
|
const isFennec = description.apptype === "mobile/android";
|
||||||
|
|
||||||
|
|
@ -438,4 +438,4 @@ const clientCommands = {
|
||||||
setSkipPausing
|
setSkipPausing
|
||||||
};
|
};
|
||||||
exports.setupCommands = setupCommands;
|
exports.setupCommands = setupCommands;
|
||||||
exports.clientCommands = clientCommands;
|
exports.clientCommands = clientCommands;
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,6 @@ loader.lazyRequireGetter(this, "flags",
|
||||||
"devtools/shared/flags");
|
"devtools/shared/flags");
|
||||||
loader.lazyRequireGetter(this, "createPerformanceFront",
|
loader.lazyRequireGetter(this, "createPerformanceFront",
|
||||||
"devtools/shared/fronts/performance", true);
|
"devtools/shared/fronts/performance", true);
|
||||||
loader.lazyRequireGetter(this, "getPreferenceFront",
|
|
||||||
"devtools/shared/fronts/preference", true);
|
|
||||||
loader.lazyRequireGetter(this, "KeyShortcuts",
|
loader.lazyRequireGetter(this, "KeyShortcuts",
|
||||||
"devtools/client/shared/key-shortcuts");
|
"devtools/client/shared/key-shortcuts");
|
||||||
loader.lazyRequireGetter(this, "ZoomKeys",
|
loader.lazyRequireGetter(this, "ZoomKeys",
|
||||||
|
|
@ -65,8 +63,6 @@ loader.lazyRequireGetter(this, "viewSource",
|
||||||
"devtools/client/shared/view-source");
|
"devtools/client/shared/view-source");
|
||||||
loader.lazyRequireGetter(this, "buildHarLog",
|
loader.lazyRequireGetter(this, "buildHarLog",
|
||||||
"devtools/client/netmonitor/src/har/har-builder-utils", true);
|
"devtools/client/netmonitor/src/har/har-builder-utils", true);
|
||||||
loader.lazyRequireGetter(this, "getKnownDeviceFront",
|
|
||||||
"devtools/shared/fronts/device", true);
|
|
||||||
loader.lazyRequireGetter(this, "NetMonitorAPI",
|
loader.lazyRequireGetter(this, "NetMonitorAPI",
|
||||||
"devtools/client/netmonitor/src/api", true);
|
"devtools/client/netmonitor/src/api", true);
|
||||||
loader.lazyRequireGetter(this, "sortPanelDefinitions",
|
loader.lazyRequireGetter(this, "sortPanelDefinitions",
|
||||||
|
|
@ -2217,16 +2213,7 @@ Toolbox.prototype = {
|
||||||
* client. See the definition of the preference actor for more information.
|
* client. See the definition of the preference actor for more information.
|
||||||
*/
|
*/
|
||||||
get preferenceFront() {
|
get preferenceFront() {
|
||||||
if (this._preferenceFront) {
|
return this.target.client.mainRoot.getFront("preference");
|
||||||
return Promise.resolve(this._preferenceFront);
|
|
||||||
}
|
|
||||||
return this.isOpen.then(() => {
|
|
||||||
return this.target.root.then(rootForm => {
|
|
||||||
const front = getPreferenceFront(this.target.client, rootForm);
|
|
||||||
this._preferenceFront = front;
|
|
||||||
return front;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Is the disable auto-hide of pop-ups feature available in this context?
|
// Is the disable auto-hide of pop-ups feature available in this context?
|
||||||
|
|
@ -2932,16 +2919,8 @@ Toolbox.prototype = {
|
||||||
// Destroy the profiler connection
|
// Destroy the profiler connection
|
||||||
outstanding.push(this.destroyPerformance());
|
outstanding.push(this.destroyPerformance());
|
||||||
|
|
||||||
// Destroy the preference front
|
// Reset preferences set by the toolbox
|
||||||
outstanding.push(this.destroyPreference());
|
outstanding.push(this.resetPreference());
|
||||||
|
|
||||||
// Destroy the device front for the current client if any.
|
|
||||||
// A given DeviceFront instance can cached and shared between different panels, so
|
|
||||||
// destroying it is the responsibility of the toolbox.
|
|
||||||
const deviceFront = getKnownDeviceFront(this.target.client);
|
|
||||||
if (deviceFront) {
|
|
||||||
deviceFront.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detach the thread
|
// Detach the thread
|
||||||
detachThread(this._threadClient);
|
detachThread(this._threadClient);
|
||||||
|
|
@ -3126,9 +3105,9 @@ Toolbox.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy the preferences actor when the toolbox is unloaded.
|
* Reset preferences set by the toolbox.
|
||||||
*/
|
*/
|
||||||
async destroyPreference() {
|
async resetPreference() {
|
||||||
if (!this._preferenceFront) {
|
if (!this._preferenceFront) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -3139,7 +3118,6 @@ Toolbox.prototype = {
|
||||||
await this._preferenceFront.clearUserPref(DISABLE_AUTOHIDE_PREF);
|
await this._preferenceFront.clearUserPref(DISABLE_AUTOHIDE_PREF);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._preferenceFront.destroy();
|
|
||||||
this._preferenceFront = null;
|
this._preferenceFront = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const { PerfFront } = require("devtools/shared/fronts/perf");
|
const { PerfFront } = require("devtools/shared/fronts/perf");
|
||||||
const { getPreferenceFront } = require("devtools/shared/fronts/preference");
|
|
||||||
loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
|
loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
|
||||||
|
|
||||||
class PerformancePanel {
|
class PerformancePanel {
|
||||||
|
|
@ -32,7 +31,7 @@ class PerformancePanel {
|
||||||
|
|
||||||
const rootForm = await this.target.root;
|
const rootForm = await this.target.root;
|
||||||
const perfFront = new PerfFront(this.target.client, rootForm);
|
const perfFront = new PerfFront(this.target.client, rootForm);
|
||||||
const preferenceFront = getPreferenceFront(this.target.client, rootForm);
|
const preferenceFront = this.target.client.mainRoot.getFront("preference");
|
||||||
|
|
||||||
this.isReady = true;
|
this.isReady = true;
|
||||||
this.emit("ready");
|
this.emit("ready");
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@ const {AppProjects} = require("devtools/client/webide/modules/app-projects");
|
||||||
const TabStore = require("devtools/client/webide/modules/tab-store");
|
const TabStore = require("devtools/client/webide/modules/tab-store");
|
||||||
const {AppValidator} = require("devtools/client/webide/modules/app-validator");
|
const {AppValidator} = require("devtools/client/webide/modules/app-validator");
|
||||||
const {ConnectionManager, Connection} = require("devtools/shared/client/connection-manager");
|
const {ConnectionManager, Connection} = require("devtools/shared/client/connection-manager");
|
||||||
const {getDeviceFront} = require("devtools/shared/fronts/device");
|
|
||||||
const {getPreferenceFront} = require("devtools/shared/fronts/preference");
|
|
||||||
const {RuntimeScanners} = require("devtools/client/webide/modules/runtimes");
|
const {RuntimeScanners} = require("devtools/client/webide/modules/runtimes");
|
||||||
const {RuntimeTypes} = require("devtools/client/webide/modules/runtime-types");
|
const {RuntimeTypes} = require("devtools/client/webide/modules/runtime-types");
|
||||||
const {NetUtil} = require("resource://gre/modules/NetUtil.jsm");
|
const {NetUtil} = require("resource://gre/modules/NetUtil.jsm");
|
||||||
|
|
@ -141,7 +139,7 @@ var AppManager = exports.AppManager = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onConnectionChanged: function() {
|
onConnectionChanged: async function() {
|
||||||
console.log("Connection status changed: " + this.connection.status);
|
console.log("Connection status changed: " + this.connection.status);
|
||||||
|
|
||||||
if (this.connection.status == Connection.Status.DISCONNECTED) {
|
if (this.connection.status == Connection.Status.DISCONNECTED) {
|
||||||
|
|
@ -150,12 +148,21 @@ var AppManager = exports.AppManager = {
|
||||||
|
|
||||||
if (!this.connected) {
|
if (!this.connected) {
|
||||||
this._listTabsResponse = null;
|
this._listTabsResponse = null;
|
||||||
|
this.deviceFront = null;
|
||||||
|
this.preferenceFront = null;
|
||||||
} else {
|
} else {
|
||||||
this.connection.client.listTabs().then((response) => {
|
const response = await this.connection.client.listTabs();
|
||||||
this._listTabsResponse = response;
|
// RootClient.getRoot request was introduced in FF59, but RootClient.getFront
|
||||||
this._recordRuntimeInfo();
|
// expects it to work. Override its root form with the listTabs results (which is
|
||||||
this.update("runtime-global-actors");
|
// an equivalent) in orfer to fix RootClient.getFront.
|
||||||
|
Object.defineProperty(this.connection.client.mainRoot, "rootForm", {
|
||||||
|
value: response
|
||||||
});
|
});
|
||||||
|
this._listTabsResponse = response;
|
||||||
|
this.deviceFront = await this.connection.client.mainRoot.getFront("device");
|
||||||
|
this.preferenceFront = await this.connection.client.mainRoot.getFront("preference");
|
||||||
|
this._recordRuntimeInfo();
|
||||||
|
this.update("runtime-global-actors");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update("connection");
|
this.update("connection");
|
||||||
|
|
@ -509,20 +516,6 @@ var AppManager = exports.AppManager = {
|
||||||
return this._listTabsResponse;
|
return this._listTabsResponse;
|
||||||
},
|
},
|
||||||
|
|
||||||
get deviceFront() {
|
|
||||||
if (!this._listTabsResponse) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return getDeviceFront(this.connection.client, this._listTabsResponse);
|
|
||||||
},
|
|
||||||
|
|
||||||
get preferenceFront() {
|
|
||||||
if (!this._listTabsResponse) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return getPreferenceFront(this.connection.client, this._listTabsResponse);
|
|
||||||
},
|
|
||||||
|
|
||||||
disconnectRuntime: function() {
|
disconnectRuntime: function() {
|
||||||
if (!this.connected) {
|
if (!this.connected) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,13 @@
|
||||||
const docRuntime = getRuntimeDocument(win);
|
const docRuntime = getRuntimeDocument(win);
|
||||||
win.AppManager.update("runtime-list");
|
win.AppManager.update("runtime-list");
|
||||||
|
|
||||||
|
const onGlobalActors = waitForUpdate(win, "runtime-global-actors");
|
||||||
|
const onRuntimeTargets = waitForUpdate(win, "runtime-targets");
|
||||||
connectToLocal(win, docRuntime);
|
connectToLocal(win, docRuntime);
|
||||||
|
await onGlobalActors;
|
||||||
|
await onRuntimeTargets;
|
||||||
|
|
||||||
// Select main process
|
// Select main process
|
||||||
await waitForUpdate(win, "runtime-targets");
|
|
||||||
SimpleTest.executeSoon(() => {
|
SimpleTest.executeSoon(() => {
|
||||||
docProject.querySelectorAll("#project-panel-runtimeapps .panel-item")[0].click();
|
docProject.querySelectorAll("#project-panel-runtimeapps .panel-item")[0].click();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -136,11 +136,13 @@
|
||||||
ok(!isStopActive(), "stop button is disabled");
|
ok(!isStopActive(), "stop button is disabled");
|
||||||
|
|
||||||
connectionsChanged = waitForConnectionChange("opened", 2);
|
connectionsChanged = waitForConnectionChange("opened", 2);
|
||||||
|
const onGlobalActors = waitForUpdate(win, "runtime-global-actors");
|
||||||
|
const onRuntimeTargets = waitForUpdate(win, "runtime-targets");
|
||||||
docRuntime.querySelectorAll(".runtime-panel-item-other")[1].click();
|
docRuntime.querySelectorAll(".runtime-panel-item-other")[1].click();
|
||||||
|
|
||||||
await waitForUpdate(win, "runtime-targets");
|
|
||||||
|
|
||||||
await connectionsChanged;
|
await connectionsChanged;
|
||||||
|
await onGlobalActors;
|
||||||
|
await onRuntimeTargets;
|
||||||
|
|
||||||
is(Object.keys(DebuggerServer._connections).length, 2, "Locally connected");
|
is(Object.keys(DebuggerServer._connections).length, 2, "Locally connected");
|
||||||
|
|
||||||
ok(win.AppManager.isMainProcessDebuggable(), "Main process available");
|
ok(win.AppManager.isMainProcessDebuggable(), "Main process available");
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,14 @@ window.onload = function() {
|
||||||
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
const {getDeviceFront} = require("devtools/shared/fronts/device");
|
|
||||||
|
|
||||||
DebuggerServer.init();
|
DebuggerServer.init();
|
||||||
DebuggerServer.registerAllActors();
|
DebuggerServer.registerAllActors();
|
||||||
|
|
||||||
const client = new DebuggerClient(DebuggerServer.connectPipe());
|
const client = new DebuggerClient(DebuggerServer.connectPipe());
|
||||||
client.connect().then(function onConnect() {
|
client.connect().then(function onConnect() {
|
||||||
client.listTabs().then(function onListTabs(response) {
|
client.listTabs().then(function onListTabs(response) {
|
||||||
const d = getDeviceFront(client, response);
|
return client.mainRoot.getFront("device");
|
||||||
|
}).then(function(d) {
|
||||||
let desc;
|
let desc;
|
||||||
const appInfo = Services.appinfo;
|
const appInfo = Services.appinfo;
|
||||||
const utils = window.windowUtils;
|
const utils = window.windowUtils;
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,14 @@ function runTests() {
|
||||||
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
const {getPreferenceFront} = require("devtools/shared/fronts/preference");
|
|
||||||
|
|
||||||
DebuggerServer.init();
|
DebuggerServer.init();
|
||||||
DebuggerServer.registerAllActors();
|
DebuggerServer.registerAllActors();
|
||||||
|
|
||||||
const client = new DebuggerClient(DebuggerServer.connectPipe());
|
const client = new DebuggerClient(DebuggerServer.connectPipe());
|
||||||
client.connect().then(function onConnect() {
|
client.connect().then(function onConnect() {
|
||||||
client.listTabs().then(function onListTabs(response) {
|
client.listTabs().then(function onListTabs(response) {
|
||||||
const p = getPreferenceFront(client, response);
|
return client.mainRoot.getFront("preference");
|
||||||
|
}).then(function(p) {
|
||||||
const prefs = {};
|
const prefs = {};
|
||||||
|
|
||||||
const localPref = {
|
const localPref = {
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@
|
||||||
// Test the xpcshell-test debug support. Ideally we should have this test
|
// Test the xpcshell-test debug support. Ideally we should have this test
|
||||||
// next to the xpcshell support code, but that's tricky...
|
// next to the xpcshell support code, but that's tricky...
|
||||||
|
|
||||||
const {getDeviceFront} = require("devtools/shared/fronts/device");
|
|
||||||
|
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
const testFile = do_get_file("xpcshell_debugging_script.js");
|
const testFile = do_get_file("xpcshell_debugging_script.js");
|
||||||
|
|
||||||
|
|
@ -23,8 +21,7 @@ add_task(async function() {
|
||||||
await client.connect();
|
await client.connect();
|
||||||
|
|
||||||
// Ensure that global actors are available. Just test the device actor.
|
// Ensure that global actors are available. Just test the device actor.
|
||||||
const rootForm = await client.mainRoot.getRoot();
|
const deviceFront = await client.mainRoot.getFront("device");
|
||||||
const deviceFront = await getDeviceFront(client, rootForm);
|
|
||||||
const desc = await deviceFront.getDescription();
|
const desc = await deviceFront.getDescription();
|
||||||
equal(desc.geckobuildid, Services.appinfo.platformBuildID, "device actor works");
|
equal(desc.geckobuildid, Services.appinfo.platformBuildID, "device actor works");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ const {
|
||||||
loader.lazyRequireGetter(this, "Authentication", "devtools/shared/security/auth");
|
loader.lazyRequireGetter(this, "Authentication", "devtools/shared/security/auth");
|
||||||
loader.lazyRequireGetter(this, "DebuggerSocket", "devtools/shared/security/socket", true);
|
loader.lazyRequireGetter(this, "DebuggerSocket", "devtools/shared/security/socket", true);
|
||||||
loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
|
loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
|
||||||
loader.lazyRequireGetter(this, "getDeviceFront", "devtools/shared/fronts/device", true);
|
|
||||||
|
|
||||||
loader.lazyRequireGetter(this, "WebConsoleClient", "devtools/shared/webconsole/client", true);
|
loader.lazyRequireGetter(this, "WebConsoleClient", "devtools/shared/webconsole/client", true);
|
||||||
loader.lazyRequireGetter(this, "AddonClient", "devtools/shared/client/addon-client");
|
loader.lazyRequireGetter(this, "AddonClient", "devtools/shared/client/addon-client");
|
||||||
|
|
@ -204,9 +203,7 @@ DebuggerClient.prototype = {
|
||||||
async checkRuntimeVersion(listTabsForm) {
|
async checkRuntimeVersion(listTabsForm) {
|
||||||
let incompatible = null;
|
let incompatible = null;
|
||||||
|
|
||||||
// Instead of requiring to pass `listTabsForm` here,
|
const deviceFront = await this.mainRoot.getFront("device");
|
||||||
// we can call getRoot() instead, but only once Firefox ESR59 is released
|
|
||||||
const deviceFront = await getDeviceFront(this, listTabsForm);
|
|
||||||
const desc = await deviceFront.getDescription();
|
const desc = await deviceFront.getDescription();
|
||||||
|
|
||||||
// 1) Check for Firefox too recent on device.
|
// 1) Check for Firefox too recent on device.
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@ function RootClient(client, greeting) {
|
||||||
this.traits = greeting.traits;
|
this.traits = greeting.traits;
|
||||||
|
|
||||||
// Cache root form as this will always be the same value.
|
// Cache root form as this will always be the same value.
|
||||||
|
//
|
||||||
|
// Note that rootForm is overloaded by DebuggerClient.checkRuntimeVersion
|
||||||
|
// in order to support <FF59 that doesn't support getRoot request.
|
||||||
Object.defineProperty(this, "rootForm", {
|
Object.defineProperty(this, "rootForm", {
|
||||||
get() {
|
get() {
|
||||||
delete this.rootForm;
|
delete this.rootForm;
|
||||||
|
|
@ -277,6 +280,9 @@ RootClient.prototype = {
|
||||||
/*
|
/*
|
||||||
* This function returns a protocol.js Front for any root actor.
|
* This function returns a protocol.js Front for any root actor.
|
||||||
* i.e. the one directly served from RootActor.listTabs or getRoot.
|
* i.e. the one directly served from RootActor.listTabs or getRoot.
|
||||||
|
*
|
||||||
|
* @param String typeName
|
||||||
|
* The type name used in protocol.js's spec for this actor.
|
||||||
*/
|
*/
|
||||||
async getFront(typeName) {
|
async getFront(typeName) {
|
||||||
let front = this.fronts.get(typeName);
|
let front = this.fronts.get(typeName);
|
||||||
|
|
|
||||||
|
|
@ -36,29 +36,4 @@ const DeviceFront = protocol.FrontClassWithSpec(deviceSpec, {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const _knownDeviceFronts = new WeakMap();
|
exports.DeviceFront = DeviceFront;
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the device front already created for the provided client, if available.
|
|
||||||
*/
|
|
||||||
exports.getKnownDeviceFront = function(client) {
|
|
||||||
return _knownDeviceFronts.get(client);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only one DeviceFront is created for a given client, afterwards the instance is cached
|
|
||||||
* and returned immediately.
|
|
||||||
*/
|
|
||||||
exports.getDeviceFront = function(client, form) {
|
|
||||||
if (!form.deviceActor) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_knownDeviceFronts.has(client)) {
|
|
||||||
return _knownDeviceFronts.get(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
const front = new DeviceFront(client, form);
|
|
||||||
_knownDeviceFronts.set(client, front);
|
|
||||||
return front;
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -14,18 +14,4 @@ const PreferenceFront = protocol.FrontClassWithSpec(preferenceSpec, {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const _knownPreferenceFronts = new WeakMap();
|
exports.PreferenceFront = PreferenceFront;
|
||||||
|
|
||||||
exports.getPreferenceFront = function(client, form) {
|
|
||||||
if (!form.preferenceActor) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_knownPreferenceFronts.has(client)) {
|
|
||||||
return _knownPreferenceFronts.get(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
const front = new PreferenceFront(client, form);
|
|
||||||
_knownPreferenceFronts.set(client, front);
|
|
||||||
return front;
|
|
||||||
};
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue