зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1265728 - Decouple PromisesFront from PromisesActor; r=ejpbruel
This commit is contained in:
Родитель
91da791a55
Коммит
b91e39033c
|
@ -10,7 +10,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const TAB_URL = EXAMPLE_URL + "doc_promise-get-allocation-stack.html";
|
const TAB_URL = EXAMPLE_URL + "doc_promise-get-allocation-stack.html";
|
||||||
const { PromisesFront } = require("devtools/server/actors/promises");
|
const { PromisesFront } = require("devtools/shared/fronts/promises");
|
||||||
var events = require("sdk/event/core");
|
var events = require("sdk/event/core");
|
||||||
|
|
||||||
function test() {
|
function test() {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const SOURCE_URL = "browser_dbg_promises-chrome-allocation-stack.js";
|
const SOURCE_URL = "browser_dbg_promises-chrome-allocation-stack.js";
|
||||||
const { PromisesFront } = require("devtools/server/actors/promises");
|
const PromisesFront = require("devtools/shared/fronts/promises");
|
||||||
var events = require("sdk/event/core");
|
var events = require("sdk/event/core");
|
||||||
|
|
||||||
const STACK_DATA = [
|
const STACK_DATA = [
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const TAB_URL = EXAMPLE_URL + "doc_promise-get-fulfillment-stack.html";
|
const TAB_URL = EXAMPLE_URL + "doc_promise-get-fulfillment-stack.html";
|
||||||
const { PromisesFront } = require("devtools/server/actors/promises");
|
const { PromisesFront } = require("devtools/shared/fronts/promises");
|
||||||
var events = require("sdk/event/core");
|
var events = require("sdk/event/core");
|
||||||
|
|
||||||
const TEST_DATA = [
|
const TEST_DATA = [
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const TAB_URL = EXAMPLE_URL + "doc_promise-get-rejection-stack.html";
|
const TAB_URL = EXAMPLE_URL + "doc_promise-get-rejection-stack.html";
|
||||||
const { PromisesFront } = require("devtools/server/actors/promises");
|
const { PromisesFront } = require("devtools/shared/fronts/promises");
|
||||||
var events = require("sdk/event/core");
|
var events = require("sdk/event/core");
|
||||||
|
|
||||||
const TEST_DATA = [
|
const TEST_DATA = [
|
||||||
|
|
|
@ -5,40 +5,17 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const protocol = require("devtools/shared/protocol");
|
const protocol = require("devtools/shared/protocol");
|
||||||
const { method, RetVal, Arg, types } = protocol;
|
const { promisesSpec } = require("devtools/shared/specs/promises");
|
||||||
const { expectState, ActorPool } = require("devtools/server/actors/common");
|
const { expectState, ActorPool } = require("devtools/server/actors/common");
|
||||||
const { ObjectActor,
|
const { ObjectActor, createValueGrip } = require("devtools/server/actors/object");
|
||||||
createValueGrip } = require("devtools/server/actors/object");
|
|
||||||
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
||||||
loader.lazyRequireGetter(this, "events", "sdk/event/core");
|
loader.lazyRequireGetter(this, "events", "sdk/event/core");
|
||||||
|
|
||||||
// Teach protocol.js how to deal with legacy actor types
|
|
||||||
types.addType("ObjectActor", {
|
|
||||||
write: actor => actor.grip(),
|
|
||||||
read: grip => grip
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Promises Actor provides support for getting the list of live promises and
|
* The Promises Actor provides support for getting the list of live promises and
|
||||||
* observing changes to their settlement state.
|
* observing changes to their settlement state.
|
||||||
*/
|
*/
|
||||||
var PromisesActor = protocol.ActorClass({
|
var PromisesActor = protocol.ActorClassWithSpec(promisesSpec, {
|
||||||
typeName: "promises",
|
|
||||||
|
|
||||||
events: {
|
|
||||||
// Event emitted for new promises allocated in debuggee and bufferred by
|
|
||||||
// sending the list of promise objects in a batch.
|
|
||||||
"new-promises": {
|
|
||||||
type: "new-promises",
|
|
||||||
data: Arg(0, "array:ObjectActor"),
|
|
||||||
},
|
|
||||||
// Event emitted for promise settlements.
|
|
||||||
"promises-settled": {
|
|
||||||
type: "promises-settled",
|
|
||||||
data: Arg(0, "array:ObjectActor")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param conn DebuggerServerConnection.
|
* @param conn DebuggerServerConnection.
|
||||||
* @param parent TabActor|RootActor
|
* @param parent TabActor|RootActor
|
||||||
|
@ -78,7 +55,7 @@ var PromisesActor = protocol.ActorClass({
|
||||||
/**
|
/**
|
||||||
* Attach to the PromisesActor.
|
* Attach to the PromisesActor.
|
||||||
*/
|
*/
|
||||||
attach: method(expectState("detached", function () {
|
attach: expectState("detached", function () {
|
||||||
this.dbg.addDebuggees();
|
this.dbg.addDebuggees();
|
||||||
|
|
||||||
this._navigationLifetimePool = this._createActorPool();
|
this._navigationLifetimePool = this._createActorPool();
|
||||||
|
@ -98,15 +75,12 @@ var PromisesActor = protocol.ActorClass({
|
||||||
events.on(this.parent, "window-ready", this._onWindowReady);
|
events.on(this.parent, "window-ready", this._onWindowReady);
|
||||||
|
|
||||||
this.state = "attached";
|
this.state = "attached";
|
||||||
}, "attaching to the PromisesActor"), {
|
}, "attaching to the PromisesActor"),
|
||||||
request: {},
|
|
||||||
response: {}
|
|
||||||
}),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detach from the PromisesActor upon Debugger closing.
|
* Detach from the PromisesActor upon Debugger closing.
|
||||||
*/
|
*/
|
||||||
detach: method(expectState("attached", function () {
|
detach: expectState("attached", function () {
|
||||||
this.dbg.removeAllDebuggees();
|
this.dbg.removeAllDebuggees();
|
||||||
this.dbg.enabled = false;
|
this.dbg.enabled = false;
|
||||||
this._dbg = null;
|
this._dbg = null;
|
||||||
|
@ -121,9 +95,6 @@ var PromisesActor = protocol.ActorClass({
|
||||||
events.off(this.parent, "window-ready", this._onWindowReady);
|
events.off(this.parent, "window-ready", this._onWindowReady);
|
||||||
|
|
||||||
this.state = "detached";
|
this.state = "detached";
|
||||||
}, "detaching from the PromisesActor"), {
|
|
||||||
request: {},
|
|
||||||
response: {}
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
_createActorPool: function () {
|
_createActorPool: function () {
|
||||||
|
@ -179,7 +150,7 @@ var PromisesActor = protocol.ActorClass({
|
||||||
/**
|
/**
|
||||||
* Get a list of ObjectActors for all live Promise Objects.
|
* Get a list of ObjectActors for all live Promise Objects.
|
||||||
*/
|
*/
|
||||||
listPromises: method(function () {
|
listPromises: function () {
|
||||||
let promises = this.dbg.findObjects({ class: "Promise" });
|
let promises = this.dbg.findObjects({ class: "Promise" });
|
||||||
|
|
||||||
this.dbg.onNewPromise = this._makePromiseEventHandler(this._newPromises,
|
this.dbg.onNewPromise = this._makePromiseEventHandler(this._newPromises,
|
||||||
|
@ -188,13 +159,7 @@ var PromisesActor = protocol.ActorClass({
|
||||||
this._promisesSettled, "promises-settled");
|
this._promisesSettled, "promises-settled");
|
||||||
|
|
||||||
return promises.map(p => this._createObjectActorForPromise(p));
|
return promises.map(p => this._createObjectActorForPromise(p));
|
||||||
}, {
|
},
|
||||||
request: {
|
|
||||||
},
|
|
||||||
response: {
|
|
||||||
promises: RetVal("array:ObjectActor")
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an event handler for onNewPromise that will add the new
|
* Creates an event handler for onNewPromise that will add the new
|
||||||
|
@ -233,15 +198,3 @@ var PromisesActor = protocol.ActorClass({
|
||||||
});
|
});
|
||||||
|
|
||||||
exports.PromisesActor = PromisesActor;
|
exports.PromisesActor = PromisesActor;
|
||||||
|
|
||||||
exports.PromisesFront = protocol.FrontClass(PromisesActor, {
|
|
||||||
initialize: function (client, form) {
|
|
||||||
protocol.Front.prototype.initialize.call(this, client, form);
|
|
||||||
this.actorID = form.promisesActor;
|
|
||||||
this.manage(this);
|
|
||||||
},
|
|
||||||
|
|
||||||
destroy: function () {
|
|
||||||
protocol.Front.prototype.destroy.call(this);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* states.
|
* states.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { PromisesFront } = require("devtools/server/actors/promises");
|
const { PromisesFront } = require("devtools/shared/fronts/promises");
|
||||||
|
|
||||||
add_task(function* () {
|
add_task(function* () {
|
||||||
let client = yield startTestDebuggerServer("promises-actor-test");
|
let client = yield startTestDebuggerServer("promises-actor-test");
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const { PromisesFront } = require("devtools/server/actors/promises");
|
const { PromisesFront } = require("devtools/shared/fronts/promises");
|
||||||
const SECRET = "MyLittleSecret";
|
const SECRET = "MyLittleSecret";
|
||||||
|
|
||||||
add_task(function* () {
|
add_task(function* () {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const { PromisesFront } = require("devtools/server/actors/promises");
|
const { PromisesFront } = require("devtools/shared/fronts/promises");
|
||||||
|
|
||||||
var events = require("sdk/event/core");
|
var events = require("sdk/event/core");
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
Cu.import("resource://testing-common/PromiseTestUtils.jsm", this);
|
Cu.import("resource://testing-common/PromiseTestUtils.jsm", this);
|
||||||
|
|
||||||
const { PromisesFront } = require("devtools/server/actors/promises");
|
const { PromisesFront } = require("devtools/shared/fronts/promises");
|
||||||
|
|
||||||
var events = require("sdk/event/core");
|
var events = require("sdk/event/core");
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const { PromisesFront } = require("devtools/server/actors/promises");
|
const { PromisesFront } = require("devtools/shared/fronts/promises");
|
||||||
|
|
||||||
var events = require("sdk/event/core");
|
var events = require("sdk/event/core");
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const { PromisesFront } = require("devtools/server/actors/promises");
|
const { PromisesFront } = require("devtools/shared/fronts/promises");
|
||||||
|
|
||||||
var events = require("sdk/event/core");
|
var events = require("sdk/event/core");
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const { PromisesFront } = require("devtools/server/actors/promises");
|
const { PromisesFront } = require("devtools/shared/fronts/promises");
|
||||||
|
|
||||||
var events = require("sdk/event/core");
|
var events = require("sdk/event/core");
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const { PromisesFront } = require("devtools/server/actors/promises");
|
const { PromisesFront } = require("devtools/shared/fronts/promises");
|
||||||
const { setTimeout } = require("sdk/timers");
|
const { setTimeout } = require("sdk/timers");
|
||||||
|
|
||||||
var events = require("sdk/event/core");
|
var events = require("sdk/event/core");
|
||||||
|
|
|
@ -15,6 +15,7 @@ DevToolsModules(
|
||||||
'highlighters.js',
|
'highlighters.js',
|
||||||
'inspector.js',
|
'inspector.js',
|
||||||
'preference.js',
|
'preference.js',
|
||||||
|
'promises.js',
|
||||||
'settings.js',
|
'settings.js',
|
||||||
'storage.js',
|
'storage.js',
|
||||||
'styles.js',
|
'styles.js',
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/* 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/. */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const {
|
||||||
|
Front,
|
||||||
|
FrontClassWithSpec,
|
||||||
|
} = require("devtools/shared/protocol");
|
||||||
|
const { promisesSpec } = require("devtools/shared/specs/promises");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PromisesFront, the front for the PromisesActor.
|
||||||
|
*/
|
||||||
|
const PromisesFront = FrontClassWithSpec(promisesSpec, {
|
||||||
|
initialize: function (client, form) {
|
||||||
|
Front.prototype.initialize.call(this, client, form);
|
||||||
|
this.actorID = form.promisesActor;
|
||||||
|
this.manage(this);
|
||||||
|
},
|
||||||
|
|
||||||
|
destroy: function () {
|
||||||
|
Front.prototype.destroy.call(this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
exports.PromisesFront = PromisesFront;
|
|
@ -20,6 +20,7 @@ DevToolsModules(
|
||||||
'inspector.js',
|
'inspector.js',
|
||||||
'node.js',
|
'node.js',
|
||||||
'preference.js',
|
'preference.js',
|
||||||
|
'promises.js',
|
||||||
'script.js',
|
'script.js',
|
||||||
'settings.js',
|
'settings.js',
|
||||||
'source.js',
|
'source.js',
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/* 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/. */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const {
|
||||||
|
Arg,
|
||||||
|
RetVal,
|
||||||
|
generateActorSpec,
|
||||||
|
types
|
||||||
|
} = require("devtools/shared/protocol");
|
||||||
|
|
||||||
|
// Teach protocol.js how to deal with legacy actor types
|
||||||
|
types.addType("ObjectActor", {
|
||||||
|
write: actor => actor.grip(),
|
||||||
|
read: grip => grip
|
||||||
|
});
|
||||||
|
|
||||||
|
const promisesSpec = generateActorSpec({
|
||||||
|
typeName: "promises",
|
||||||
|
|
||||||
|
events: {
|
||||||
|
// Event emitted for new promises allocated in debuggee and bufferred by
|
||||||
|
// sending the list of promise objects in a batch.
|
||||||
|
"new-promises": {
|
||||||
|
type: "new-promises",
|
||||||
|
data: Arg(0, "array:ObjectActor"),
|
||||||
|
},
|
||||||
|
// Event emitted for promise settlements.
|
||||||
|
"promises-settled": {
|
||||||
|
type: "promises-settled",
|
||||||
|
data: Arg(0, "array:ObjectActor")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
attach: {
|
||||||
|
request: {},
|
||||||
|
response: {},
|
||||||
|
},
|
||||||
|
|
||||||
|
detach: {
|
||||||
|
request: {},
|
||||||
|
response: {},
|
||||||
|
},
|
||||||
|
|
||||||
|
listPromises: {
|
||||||
|
request: {},
|
||||||
|
response: {
|
||||||
|
promises: RetVal("array:ObjectActor"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
exports.promisesSpec = promisesSpec;
|
Загрузка…
Ссылка в новой задаче