mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-28 13:40:17 -10:00
75 lines
2.4 KiB
JavaScript
75 lines
2.4 KiB
JavaScript
/* 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 evals against different frames.
|
|
*/
|
|
|
|
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-stack");
|
|
gClient = new DebuggerClient(DebuggerServer.connectPipe());
|
|
gClient.connect().then(function() {
|
|
attachTestTabAndResume(gClient, "test-stack",
|
|
function(response, targetFront, threadClient) {
|
|
gThreadClient = threadClient;
|
|
test_different_frames_eval();
|
|
});
|
|
});
|
|
do_test_pending();
|
|
}
|
|
|
|
function test_different_frames_eval() {
|
|
gThreadClient.addOneTimeListener("paused", function(event, packet) {
|
|
gThreadClient.getFrames(0, 2, function(response) {
|
|
const frame0 = response.frames[0];
|
|
const frame1 = response.frames[1];
|
|
|
|
// Eval against the top frame...
|
|
gThreadClient.eval(frame0.actor, "arg", function(response) {
|
|
Assert.equal(response.type, "resumed");
|
|
gThreadClient.addOneTimeListener("paused", function(event, packet) {
|
|
// 'arg' should have been evaluated in frame0
|
|
Assert.equal(packet.type, "paused");
|
|
Assert.equal(packet.why.type, "clientEvaluated");
|
|
Assert.equal(packet.why.frameFinished.return, "arg0");
|
|
|
|
// Now eval against the second frame.
|
|
gThreadClient.eval(frame1.actor, "arg", function(response) {
|
|
gThreadClient.addOneTimeListener("paused", function(event, packet) {
|
|
// 'arg' should have been evaluated in frame1
|
|
Assert.equal(packet.type, "paused");
|
|
Assert.equal(packet.why.frameFinished.return, "arg1");
|
|
|
|
gThreadClient.resume(function() {
|
|
finishClient(gClient);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
gDebuggee.eval("(" + function() {
|
|
function frame0(arg) {
|
|
debugger;
|
|
}
|
|
function frame1(arg) {
|
|
frame0("arg0");
|
|
}
|
|
frame1("arg1");
|
|
} + ")()");
|
|
}
|