Skip to content

Instantly share code, notes, and snippets.

@jasonLaster
Created May 23, 2017 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonLaster/6c8f1d13383a57bd8d106bdb8546d226 to your computer and use it in GitHub Desktop.
Save jasonLaster/6c8f1d13383a57bd8d106bdb8546d226 to your computer and use it in GitHub Desktop.
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
var gDebuggee;
var gClient;
var gThreadClient;
// Test that objects defined in an outer scope are available in the object pool
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-closures");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-closures",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_object_grip();
});
});
do_test_pending();
}
function test_object_grip() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let arr = packet.frame.environment.parent.parent.bindings.variables.arr
const arrActorId = arr.value.actor
let arrClient = gThreadClient.pauseGrip(arr.value);
arrClient.getPrototypeAndProperties(response => {
// dump(`arr properties ${JSON.stringify(response)}\n`)
gThreadClient.resume(() => {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let arr = packet.frame.environment.bindings.variables.arr
// NOTE: arr has the same actor id as before
do_check_eq(arrActorId, arr.value.actor)
let arrClient = gThreadClient.pauseGrip(arr.value);
arrClient.getPrototypeAndProperties(response => {
// dump(`arr properties ${JSON.stringify(response)}\n`)
// NOTE: that the actor is no longer in the pool
do_check_eq(response.error, "noSuchActor")
gThreadClient.resume(() => finishClient(gClient))
});
});
});
});
});
/* eslint-disable */
gDebuggee.eval( `(function() {
var arr = [];
var i = 0;
(function () {
(function() {
arr.push(i++);
debugger;
})()
})()
debugger;
})()`);
/* eslint-enable */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment