Bug 1367052 - Debugger Server prematurely removes out of scope variables. r=fitzgen

This commit is contained in:
Jason Laster 2017-05-25 12:33:00 -04:00
Родитель 4bf8607f84
Коммит ad0a595b53
5 изменённых файлов: 149 добавлений и 0 удалений

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

@ -27,6 +27,15 @@ let EnvironmentActor = ActorClassWithSpec(environmentSpec, {
this.threadActor = threadActor;
},
/**
* When the Environment Actor is destroyed it removes the
* Debugger.Environment.actor field so that environment does not
* reference a destroyed actor.
*/
destroy: function () {
this.obj.actor = null;
},
/**
* Return an environment form for use in a protocol message.
*/

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

@ -231,6 +231,14 @@ function setBreakpoint(sourceClient, location) {
return sourceClient.setBreakpoint(location);
}
function getPrototypeAndProperties(objClient) {
dump("getting prototype and properties.\n");
return new Promise(resolve => {
objClient.getPrototypeAndProperties(response => resolve(response));
});
}
function dumpn(msg) {
dump("DBG-TEST: " + msg + "\n");
}
@ -694,6 +702,16 @@ function executeOnNextTickAndWaitForPause(action, client) {
return paused;
}
function evalCallback(debuggeeGlobal, func) {
Components.utils.evalInSandbox(
"(" + func + ")()",
debuggeeGlobal,
"1.8",
"test.js",
1
);
}
/**
* Interrupt JS execution for the specified thread.
*

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

@ -0,0 +1,61 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Test out of scope objects with synchronous functions.
*/
var gDebuggee;
var gClient;
var gThreadClient;
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-object-grip");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-object-grip",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
testObjectGroup();
});
});
do_test_pending();
}
function evalCode() {
evalCallback(gDebuggee, function runTest() {
let ugh = [];
let i = 0;
(function () {
(function () {
ugh.push(i++);
debugger;
})();
})();
debugger;
});
}
const testObjectGroup = Task.async(function* () {
let packet = yield executeOnNextTickAndWaitForPause(evalCode, gClient);
const ugh = packet.frame.environment.parent.parent.bindings.variables.ugh;
const ughClient = yield gThreadClient.pauseGrip(ugh.value);
packet = yield getPrototypeAndProperties(ughClient);
packet = yield resumeAndWaitForPause(gClient, gThreadClient);
const ugh2 = packet.frame.environment.bindings.variables.ugh;
const ugh2Client = gThreadClient.pauseGrip(ugh2.value);
packet = yield getPrototypeAndProperties(ugh2Client);
do_check_eq(packet.ownProperties.length.value, 1);
yield resume(gThreadClient);
finishClient(gClient);
});

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

@ -0,0 +1,59 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Test out of scope objects with async functions.
*/
var gDebuggee;
var gClient;
var gThreadClient;
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-object-grip");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-object-grip",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
testObjectGroup();
});
});
do_test_pending();
}
function evalCode() {
evalCallback(gDebuggee, function runTest() {
let ugh = [];
let i = 0;
function foo() {
ugh.push(i++);
debugger;
}
Promise.resolve().then(foo).then(foo);
});
}
const testObjectGroup = Task.async(function* () {
let packet = yield executeOnNextTickAndWaitForPause(evalCode, gClient);
const ugh = packet.frame.environment.parent.bindings.variables.ugh;
const ughClient = yield gThreadClient.pauseGrip(ugh.value);
packet = yield getPrototypeAndProperties(ughClient);
packet = yield resumeAndWaitForPause(gClient, gThreadClient);
const ugh2 = packet.frame.environment.parent.bindings.variables.ugh;
const ugh2Client = gThreadClient.pauseGrip(ugh2.value);
packet = yield getPrototypeAndProperties(ugh2Client);
do_check_eq(packet.ownProperties.length.value, 2);
yield resume(gThreadClient);
finishClient(gClient);
});

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

@ -169,6 +169,8 @@ reason = only ran on B2G
[test_objectgrips-11.js]
[test_objectgrips-12.js]
[test_objectgrips-13.js]
[test_objectgrips-14.js]
[test_objectgrips-15.js]
[test_promise_state-01.js]
[test_promise_state-02.js]
[test_promise_state-03.js]