Bug 1529247 - remove unused releaseMany method from thread client and actor; r=ochameau

There is one spot I am unsure about, and that is the test:
devtools/server/tests/unit/test_threadlifetime-06.js -- should this be kept or do we want to remove
it as well?

Differential Revision: https://phabricator.services.mozilla.com/D21674

--HG--
extra : moz-landing-system : lando
This commit is contained in:
yulia 2019-03-12 14:06:35 +00:00
Родитель b7cd62739d
Коммит 408d434de2
7 изменённых файлов: 2 добавлений и 303 удалений

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

@ -101,7 +101,7 @@ If an actor receives a packet whose type it does not recognize, it sends an erro
where *message* provides details to help debugger developers understand what went wrong: what kind of actor actor is; the packet received; and so on.
If an actor receives a packet which is missing needed parameters (say, a `"releaseMany"` packet with no `"actors"` parameter), it sends an error reply of the form:
If an actor receives a packet which is missing needed parameters (say, an `"autocomplete"` packet with no `"text"` parameter), it sends an error reply of the form:
```
{ "from":actor, "error":"missingParameter", "message":message }
@ -549,14 +549,6 @@ This closes the grip actor. The `"release"` packet may only be sent to thread-li
{ "from":<gripActor>, "error":"notReleasable", "message":<message> }
```
where *message* includes whatever further information would be useful to the debugger developers.
The client can release many thread-lifetime grips in a single operation by sending the thread actor a request of the form:
```
{ "to":<thread>, "type":"releaseMany", "actors":[ <gripActor>, ... ] }
```
where each *gripActor* is the name of a child of *thread* that should be freed. The thread actor will reply, simply:
```

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

@ -205,7 +205,7 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
/**
* Clean up listeners, debuggees and clear actor pools associated with
* the lifetime of this actor. This does not destroy the thread actor,
* it resets it. This is used in methods `onReleaseMany` `onDetatch` and
* it resets it. This is used in methods `onDetatch` and
* `exit`. The actor is truely destroyed in the `exit method`.
*/
destroy: function() {
@ -1112,34 +1112,6 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
return { frames: frames.filter(x => !!x) };
},
onReleaseMany: function(request) {
if (!request.actors) {
return { error: "missingParameter",
message: "no actors were specified" };
}
let res;
for (const actorID of request.actors) {
const actor = this.threadLifetimePool.get(actorID);
if (!actor) {
if (!res) {
res = { error: "notReleasable",
message: "Only thread-lifetime actors can be released." };
}
continue;
}
// We can still have old-style actors (e.g. object/long-string) in the pool, so we
// need to check onRelease existence.
if (actor.onRelease) {
actor.onRelease();
} else if (actor.destroy) {
actor.destroy();
}
}
return res ? res : {};
},
onSources: function(request) {
for (const source of this.dbg.findSources()) {
this._addSource(source);
@ -1772,7 +1744,6 @@ Object.assign(ThreadActor.prototype.requestTypes, {
"clientEvaluate": ThreadActor.prototype.onClientEvaluate,
"frames": ThreadActor.prototype.onFrames,
"interrupt": ThreadActor.prototype.onInterrupt,
"releaseMany": ThreadActor.prototype.onReleaseMany,
"sources": ThreadActor.prototype.onSources,
"threadGrips": ThreadActor.prototype.onThreadGrips,
"skipBreakpoints": ThreadActor.prototype.onSkipBreakpoints,

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

@ -1,86 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check that thread-lifetime grips last past a resume.
*/
var gDebuggee;
var gClient;
var gThreadClient;
function run_test() {
Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
registerCleanupFunction(() => {
Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
});
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-grips");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function() {
attachTestTabAndResume(gClient, "test-grips",
function(response, targetFront, threadClient) {
gThreadClient = threadClient;
test_thread_lifetime();
});
});
do_test_pending();
}
function test_thread_lifetime() {
// Get three thread-lifetime grips.
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const grips = [];
const handler = function(response) {
if (response.error) {
Assert.equal(response.error, "");
finishClient(gClient);
}
grips.push(response.from);
if (grips.length == 3) {
test_release_many(grips);
}
};
for (let i = 0; i < 3; i++) {
gClient.request({ to: packet.frame.arguments[i].actor, type: "threadGrip" },
handler);
}
});
gDebuggee.eval("(" + function() {
function stopMe(arg1, arg2, arg3) {
debugger;
}
stopMe({obj: 1}, {obj: 2}, {obj: 3});
} + ")()");
}
function test_release_many(grips) {
// Release the first two grips, leave the third alive.
const release = [grips[0], grips[1]];
gThreadClient.releaseMany(release, function(response) {
// First two actors should return a noSuchActor error, because
// they're gone now.
gClient.request({ to: grips[0], type: "bogusRequest" }, function(response) {
Assert.equal(response.error, "noSuchActor");
gClient.request({ to: grips[1], type: "bogusRequest" }, function(response) {
Assert.equal(response.error, "noSuchActor");
// Last actor should return unrecognizedPacketType, because it's still
// alive.
gClient.request({ to: grips[2], type: "bogusRequest" }, function(response) {
Assert.equal(response.error, "unrecognizedPacketType");
gThreadClient.resume(function() {
finishClient(gClient);
});
});
});
});
});
}

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

@ -1,85 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Make sure that releasing a pause-lifetime actorin a releaseMany returns an
* error, but releases all the thread-lifetime actors.
*/
var gDebuggee;
var gClient;
var gThreadClient;
var gPauseGrip;
function run_test() {
Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
registerCleanupFunction(() => {
Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
});
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-grips");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function() {
attachTestTabAndResume(gClient, "test-grips",
function(response, targetFront, threadClient) {
gThreadClient = threadClient;
test_thread_lifetime();
});
});
do_test_pending();
}
function arg_grips(frameArgs, onResponse) {
const grips = [];
const handler = function(response) {
if (response.error) {
grips.push(response.error);
} else {
grips.push(response.from);
}
if (grips.length == frameArgs.length) {
onResponse(grips);
}
};
for (let i = 0; i < frameArgs.length; i++) {
gClient.request({ to: frameArgs[i].actor, type: "threadGrip" },
handler);
}
}
function test_thread_lifetime() {
// Get two thread-lifetime grips.
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const frameArgs = [ packet.frame.arguments[0], packet.frame.arguments[1] ];
gPauseGrip = packet.frame.arguments[2];
arg_grips(frameArgs, function(grips) {
release_grips(frameArgs, grips);
});
});
gDebuggee.eval("(" + function() {
function stopMe(arg1, arg2, arg3) {
debugger;
}
stopMe({obj: 1}, {obj: 2}, {obj: 3});
} + ")()");
}
function release_grips(frameArgs, threadGrips) {
// Release all actors with releaseMany...
const release = [threadGrips[0], threadGrips[1], gPauseGrip.actor];
gThreadClient.releaseMany(release, function(response) {
Assert.equal(response.error, "notReleasable");
// Now ask for thread grips again, they should not exist.
arg_grips(frameArgs, function(newGrips) {
for (let i = 0; i < newGrips.length; i++) {
Assert.equal(newGrips[i], "noSuchActor");
}
gThreadClient.resume(function() {
finishClient(gClient);
});
});
});
}

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

@ -1,77 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check that promoting multiple pause-lifetime actors to thread-lifetime actors
* works as expected.
*/
var gDebuggee;
var gClient;
var gThreadClient;
function run_test() {
Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
registerCleanupFunction(() => {
Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
});
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-grips");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function() {
attachTestTabAndResume(gClient, "test-grips",
function(response, targetFront, threadClient) {
gThreadClient = threadClient;
test_thread_lifetime();
});
});
do_test_pending();
}
function test_thread_lifetime() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const actors = [];
let last;
for (const grip of packet.frame.arguments) {
actors.push(grip.actor);
last = grip.actor;
}
// Create thread-lifetime actors for these objects.
gThreadClient.threadGrips(actors, function(response) {
// Successful promotion won't return an error.
Assert.equal(response.error, undefined);
gThreadClient.addOneTimeListener("paused", function(event, packet) {
// Verify that the promoted actors are returned again.
actors.forEach(function(actor, i) {
Assert.equal(actor, packet.frame.arguments[i].actor);
});
// Now that we've resumed, release the thread-lifetime grips.
gThreadClient.releaseMany(actors, function(response) {
// Successful release won't return an error.
Assert.equal(response.error, undefined);
gClient.request({ to: last, type: "bogusRequest" }, function(response) {
Assert.equal(response.error, "noSuchActor");
gThreadClient.resume(function(response) {
finishClient(gClient);
});
});
});
});
gThreadClient.resume();
});
});
gDebuggee.eval("(" + function() {
function stopMe(arg1, arg2, arg3) {
debugger;
debugger;
}
stopMe({obj: 1}, {obj: 2}, {obj: 3});
} + ")()");
}

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

@ -74,10 +74,7 @@ support-files =
[test_pauselifetime-04.js]
[test_threadlifetime-01.js]
[test_threadlifetime-02.js]
[test_threadlifetime-03.js]
[test_threadlifetime-04.js]
[test_threadlifetime-05.js]
[test_threadlifetime-06.js]
[test_functiongrips-01.js]
[test_front_destroy.js]
[test_nativewrappers.js]

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

@ -345,19 +345,6 @@ ThreadClient.prototype = {
},
}),
/**
* Release multiple thread-lifetime object actors. If any pause-lifetime
* actors are included in the request, a |notReleasable| error will return,
* but all the thread-lifetime ones will have been released.
*
* @param array actors
* An array with actor IDs to release.
*/
releaseMany: DebuggerClient.requester({
type: "releaseMany",
actors: arg(0),
}),
/**
* Promote multiple pause-lifetime object actors to thread-lifetime ones.
*