зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1620025 - Improve source front management. r=ochameau
Differential Revision: https://phabricator.services.mozilla.com/D65803 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
67bc5d7367
Коммит
332ec2ba27
|
@ -806,6 +806,14 @@ DevToolsClient.prototype = {
|
||||||
get transport() {
|
get transport() {
|
||||||
return this._transport;
|
return this._transport;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
dumpPools() {
|
||||||
|
for (const pool of this._pools) {
|
||||||
|
console.log(`%c${pool.actorID}`, "font-weight: bold;", [
|
||||||
|
...pool.__poolMap.keys(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
EventEmitter.decorate(DevToolsClient.prototype);
|
EventEmitter.decorate(DevToolsClient.prototype);
|
||||||
|
|
|
@ -48,6 +48,7 @@ class ThreadFront extends FrontClassWithSpec(threadSpec) {
|
||||||
this.before("paused", this._beforePaused);
|
this.before("paused", this._beforePaused);
|
||||||
this.before("resumed", this._beforeResumed);
|
this.before("resumed", this._beforeResumed);
|
||||||
this.before("detached", this._beforeDetached);
|
this.before("detached", this._beforeDetached);
|
||||||
|
this.targetFront.on("will-navigate", this._onWillNavigate.bind(this));
|
||||||
// Attribute name from which to retrieve the actorID out of the target actor's form
|
// Attribute name from which to retrieve the actorID out of the target actor's form
|
||||||
this.formAttributeName = "threadActor";
|
this.formAttributeName = "threadActor";
|
||||||
}
|
}
|
||||||
|
@ -262,14 +263,6 @@ class ThreadFront extends FrontClassWithSpec(threadSpec) {
|
||||||
this[gripCacheName] = {};
|
this[gripCacheName] = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
_clearFrameFronts() {
|
|
||||||
for (const front of this.poolChildren()) {
|
|
||||||
if (front instanceof FrameFront) {
|
|
||||||
this.unmanage(front);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidate pause-lifetime grip clients and clear the list of current grip
|
* Invalidate pause-lifetime grip clients and clear the list of current grip
|
||||||
* clients.
|
* clients.
|
||||||
|
@ -294,14 +287,18 @@ class ThreadFront extends FrontClassWithSpec(threadSpec) {
|
||||||
_beforeResumed() {
|
_beforeResumed() {
|
||||||
this._state = "attached";
|
this._state = "attached";
|
||||||
this._onThreadState(null);
|
this._onThreadState(null);
|
||||||
this._clearFrameFronts();
|
this.unmanageChildren(FrameFront);
|
||||||
}
|
}
|
||||||
|
|
||||||
_beforeDetached(packet) {
|
_beforeDetached(packet) {
|
||||||
this._state = "detached";
|
this._state = "detached";
|
||||||
this._onThreadState(packet);
|
this._onThreadState(packet);
|
||||||
this._clearThreadGrips();
|
this._clearThreadGrips();
|
||||||
this._clearFrameFronts();
|
this.unmanageChildren(FrameFront);
|
||||||
|
}
|
||||||
|
|
||||||
|
_onWillNavigate() {
|
||||||
|
this.unmanageChildren(SourceFront);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -84,6 +84,14 @@ class Pool extends EventEmitter {
|
||||||
this._poolMap.set(actor.actorID, actor);
|
this._poolMap.set(actor.actorID, actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unmanageChildren(FrontType) {
|
||||||
|
for (const front of this.poolChildren()) {
|
||||||
|
if (!FrontType || front instanceof FrontType) {
|
||||||
|
this.unmanage(front);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove an actor as a child of this pool.
|
* Remove an actor as a child of this pool.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -378,6 +378,11 @@ function expectRootChildren(size) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function childrenOfType(pool, type) {
|
||||||
|
const children = [...rootFront.poolChildren()];
|
||||||
|
return children.filter(child => child instanceof type);
|
||||||
|
}
|
||||||
|
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
DevToolsServer.createRootActor = conn => {
|
DevToolsServer.createRootActor = conn => {
|
||||||
return RootActor(conn);
|
return RootActor(conn);
|
||||||
|
@ -404,6 +409,7 @@ add_task(async function() {
|
||||||
await testManyChildren(trace);
|
await testManyChildren(trace);
|
||||||
await testGenerator(trace);
|
await testGenerator(trace);
|
||||||
await testPolymorphism(trace);
|
await testPolymorphism(trace);
|
||||||
|
await testUnmanageChildren(trace);
|
||||||
|
|
||||||
await client.close();
|
await client.close();
|
||||||
});
|
});
|
||||||
|
@ -712,3 +718,17 @@ async function testPolymorphism(trace) {
|
||||||
rootFront.requestPolymorphism(0, rootFront);
|
rootFront.requestPolymorphism(0, rootFront);
|
||||||
}, /Was expecting one of these actors 'childActor,otherChildActor' but instead got an actor of type: 'root'/);
|
}, /Was expecting one of these actors 'childActor,otherChildActor' but instead got an actor of type: 'root'/);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function testUnmanageChildren(trace) {
|
||||||
|
// There is already one front of type OtherChildFront
|
||||||
|
Assert.equal(childrenOfType(rootFront, OtherChildFront).length, 1);
|
||||||
|
|
||||||
|
// Create another front of type OtherChildFront
|
||||||
|
const front = await rootFront.getPolymorphism(1);
|
||||||
|
Assert.ok(front instanceof OtherChildFront);
|
||||||
|
Assert.equal(childrenOfType(rootFront, OtherChildFront).length, 2);
|
||||||
|
|
||||||
|
// Remove all fronts of type OtherChildFront
|
||||||
|
rootFront.unmanageChildren(OtherChildFront);
|
||||||
|
Assert.equal(childrenOfType(rootFront, OtherChildFront).length, 0);
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче