Bug 1193583 - Rename Debugger.evalInGlobal to executeInGlobal. (r=jorendorff)

--HG--
rename : js/src/jit-test/tests/debug/Object-evalInGlobal-01.js => js/src/jit-test/tests/debug/Object-executeInGlobal-01.js
rename : js/src/jit-test/tests/debug/Object-evalInGlobal-07.js => js/src/jit-test/tests/debug/Object-executeInGlobal-07.js
rename : js/src/jit-test/tests/debug/Object-evalInGlobal-08.js => js/src/jit-test/tests/debug/Object-executeInGlobal-08.js
rename : js/src/jit-test/tests/debug/Object-evalInGlobal-10.js => js/src/jit-test/tests/debug/Object-executeInGlobal-10.js
rename : toolkit/devtools/server/tests/mochitest/test_evalInGlobal-outerized_this.html => toolkit/devtools/server/tests/mochitest/test_executeInGlobal-outerized_this.html
This commit is contained in:
Shu-yu Guo 2015-08-30 15:08:19 -07:00
Родитель 1194a532eb
Коммит b17f71092a
37 изменённых файлов: 208 добавлений и 209 удалений

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

@ -142,7 +142,7 @@ function printCommand(rest) {
// This is the real deal.
var cv = saveExcursion(
() => focusedFrame == null
? debuggeeGlobalWrapper.evalInGlobalWithBindings(rest, debuggeeValues)
? debuggeeGlobalWrapper.executeInGlobalWithBindings(rest, debuggeeValues)
: focusedFrame.evalWithBindings(rest, debuggeeValues));
if (cv === null) {
if (!dbg.enabled)

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

@ -382,7 +382,7 @@ code), the call throws a [`Debugger.DebuggeeWouldRun`][wouldrun] exception.
the referent is not callable, throw a `TypeError`. This function
follows the [invocation function conventions][inv fr].
<code>evalInGlobal(<i>code</i>, [<i>options</i>])</code>
<code>executeInGlobal(<i>code</i>, [<i>options</i>])</code>
: If the referent is a global object, evaluate <i>code</i> in that global
environment, and return a [completion value][cv] describing how it completed.
<i>Code</i> is a string. All extant handler methods, breakpoints,
@ -393,15 +393,15 @@ code), the call throws a [`Debugger.DebuggeeWouldRun`][wouldrun] exception.
<i>Code</i> is interpreted as strict mode code when it contains a Use
Strict Directive.
If <i>code</i> is not strict mode code, then variable declarations in
<i>code</i> affect the referent global object. (In the terms used by the
ECMAScript specification, the `VariableEnvironment` of the execution
context for the eval code is the referent.)
This evaluation is semantically equivalent to executing statements at the
global level, not an indirect eval. Regardless of <i>code</i> being strict
mode code, variable declarations in <i>code</i> affect the referent global
object.
The <i>options</i> argument is as for [`Debugger.Frame.prototype.eval`][fr eval].
<code>evalInGlobalWithBindings(<i>code</i>, <i>bindings</i>, [<i>options</i>])</code>
: Like `evalInGlobal`, but evaluate <i>code</i> using the referent as the
<code>executeInGlobalWithBindings(<i>code</i>, <i>bindings</i>, [<i>options</i>])</code>
: Like `executeInGlobal`, but evaluate <i>code</i> using the referent as the
variable object, but with a lexical environment extended with bindings
from the object <i>bindings</i>. For each own enumerable property of
<i>bindings</i> named <i>name</i> whose value is <i>value</i>, include a
@ -416,14 +416,12 @@ code), the call throws a [`Debugger.DebuggeeWouldRun`][wouldrun] exception.
debuggee values, and do so without mutating any existing debuggee
environment.
Note that, like `evalInGlobal`, if the code passed to
`evalInGlobalWithBindings` is not strict mode code, then any
declarations it contains affect the referent global object, even as
<i>code</i> is evaluated in an environment extended according to
<i>bindings</i>. (In the terms used by the ECMAScript specification, the
`VariableEnvironment` of the execution context for non-strict eval code
is the referent, and the <i>bindings</i> appear in a new declarative
environment, which is the eval code's `LexicalEnvironment`.)
Note that, like `executeInGlobal`, any declarations it contains affect the
referent global object, even as <i>code</i> is evaluated in an environment
extended according to <i>bindings</i>. (In the terms used by the ECMAScript
specification, the `VariableEnvironment` of the execution context for
<i>code</i> is the referent, and the <i>bindings</i> appear in a new
declarative environment, which is the eval code's `LexicalEnvironment`.)
The <i>options</i> argument is as for [`Debugger.Frame.prototype.eval`][fr eval].

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

@ -1,4 +1,4 @@
// Bug 744731 - findScripts() finds active debugger evalInGlobal scripts.
// Bug 744731 - findScripts() finds active debugger executeInGlobal scripts.
var g = newGlobal();
var dbg = new Debugger;
@ -8,5 +8,5 @@ dbg.onDebuggerStatement = function (frame) {
hits++;
assertEq(dbg.findScripts().indexOf(dbg.getNewestFrame().script) !== -1, true);
};
gw.evalInGlobal("debugger;");
gw.executeInGlobal("debugger;");
assertEq(hits, 1);

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

@ -7,9 +7,9 @@ dbg.onNewGlobalObject = function (global) {
var gw = dbg.addDebuggee(global);
gw.defineProperty('x', { value: -1 });
// Check that the global's magic lazy properties are working.
assertEq(gw.evalInGlobalWithBindings('Math.atan2(y,x)', { y: 0 }).return, Math.PI);
assertEq(gw.executeInGlobalWithBindings('Math.atan2(y,x)', { y: 0 }).return, Math.PI);
// Check that the global's prototype is hooked up.
assertEq(gw.evalInGlobalWithBindings('x.toString()', { x: gw }).return, "[object global]");
assertEq(gw.executeInGlobalWithBindings('x.toString()', { x: gw }).return, "[object global]");
};
newGlobal();

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

@ -14,7 +14,7 @@ dbg.onDebuggerStatement = function handleDebugger(frame) {
};
g.eval("function g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
g.eval("var it = g();");
var rv = gw.evalInGlobal("it.next();");
var rv = gw.executeInGlobal("it.next();");
assertEq(rv.throw, "fit");
dbg.enabled = false;

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

@ -13,7 +13,7 @@ dbg.onDebuggerStatement = function handleDebugger(frame) {
};
g.eval("function g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
g.eval("var it = g();");
assertEq(gw.evalInGlobal("it.next();"), null);
assertEq(gw.executeInGlobal("it.next();"), null);
dbg.enabled = false;
assertEq(g.it.next(), 1);

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

@ -45,7 +45,7 @@ var frames = [];
// We start off the test via Debugger.Frame.prototype.eval, so if we end
// with a termination, we still catch it, instead of aborting the whole
// test. (Debugger.Object.prototype.evalInGlobal would simplify this...)
// test. (Debugger.Object.prototype.executeInGlobal would simplify this...)
var dbg0 = new Debugger(g);
dbg0.onEnterFrame = function handleOriginalEnter(frame) {
dbg0.log += '(';

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

@ -13,7 +13,7 @@ dbg.onDebuggerStatement = function handleDebugger(frame) {
};
g.eval("function* g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
g.eval("var it = g();");
var rv = gw.evalInGlobal("it.next();");
var rv = gw.executeInGlobal("it.next();");
assertEq(rv.throw, "fit");
dbg.enabled = false;

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

@ -15,7 +15,7 @@ dbg.onDebuggerStatement = function handleDebugger(frame) {
};
g.eval("function* g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
g.eval("var it = g();");
assertEq(gw.evalInGlobal("it.next();"), null);
assertEq(gw.executeInGlobal("it.next();"), null);
dbg.enabled = false;
assertIteratorNext(g.it, 1);

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

@ -3,13 +3,13 @@
var g = newGlobal();
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
var arrw = gw.evalInGlobal("var arr = []; arr;").return;
var pushw = gw.evalInGlobal("var push = arr.push.bind(arr); push;").return;
var arrw = gw.executeInGlobal("var arr = []; arr;").return;
var pushw = gw.executeInGlobal("var push = arr.push.bind(arr); push;").return;
assertEq(pushw.isBoundFunction, true);
assertEq(pushw.boundThis, arrw);
assertEq(pushw.boundArguments.length, 0);
var arr2 = gw.evalInGlobal("var arr2 = []; arr2").return;
var arr2 = gw.executeInGlobal("var arr2 = []; arr2").return;
assertEq(pushw.call(arr2, "tuesday").return, 1);
g.eval("assertEq(arr.length, 1);");
g.eval("assertEq(arr[0], 'tuesday');");

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

@ -6,19 +6,19 @@
var g = newGlobal();
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
var fw = gw.evalInGlobal("function f() {}; f").return;
var fw = gw.executeInGlobal("function f() {}; f").return;
assertEq(fw.isBoundFunction, false);
assertEq(fw.boundThis, undefined);
assertEq(fw.boundArguments, undefined);
assertEq(fw.boundTargetFunction, undefined);
var nw = gw.evalInGlobal("var n = Math.max; n").return;
var nw = gw.executeInGlobal("var n = Math.max; n").return;
assertEq(nw.isBoundFunction, false);
assertEq(nw.boundThis, undefined);
assertEq(nw.boundArguments, undefined);
assertEq(nw.boundTargetFunction, undefined);
var ow = gw.evalInGlobal("var o = {}; o").return;
var ow = gw.executeInGlobal("var o = {}; o").return;
assertEq(ow.isBoundFunction, false);
assertEq(ow.boundThis, undefined);
assertEq(ow.boundArguments, undefined);

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

@ -5,7 +5,7 @@ var g = newGlobal();
var dbg = new Debugger();
var gw = dbg.addDebuggee(g);
var expr = "function f() { return this; }; var bf = f.bind(1, 2).bind(3, 4); bf";
var bfw = gw.evalInGlobal(expr).return;
var bfw = gw.executeInGlobal(expr).return;
assertEq(bfw.isBoundFunction, true);
assertEq(bfw.boundThis, 3);

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

@ -1,20 +0,0 @@
// Debugger.Object.prototype.evalInGlobal argument validation
load(libdir + 'asserts.js');
var g = newGlobal();
var dbg = new Debugger();
var gw = dbg.addDebuggee(g);
var gobj = gw.makeDebuggeeValue(g.eval("({})"));
assertThrowsInstanceOf(function () { gw.evalInGlobal(); }, TypeError);
assertThrowsInstanceOf(function () { gw.evalInGlobal(10); }, TypeError);
assertThrowsInstanceOf(function () { gobj.evalInGlobal('42'); }, TypeError);
assertEq(gw.evalInGlobal('42').return, 42);
assertThrowsInstanceOf(function () { gw.evalInGlobalWithBindings(); }, TypeError);
assertThrowsInstanceOf(function () { gw.evalInGlobalWithBindings('42'); }, TypeError);
assertThrowsInstanceOf(function () { gw.evalInGlobalWithBindings(10, 1729); }, TypeError);
assertThrowsInstanceOf(function () { gw.evalInGlobalWithBindings('42', 1729); }, TypeError);
assertThrowsInstanceOf(function () { gobj.evalInGlobalWithBindings('42', {}); }, TypeError);
assertEq(gw.evalInGlobalWithBindings('42', {}).return, 42);

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

@ -1,19 +0,0 @@
// Debugger.Object.prototype.evalInGlobal: closures capturing the global
var g = newGlobal();
var h = newGlobal();
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
var hw = dbg.addDebuggee(h);
g.x = "W H O K I L L";
h.x = "No Color";
var c1 = gw.evalInGlobal('(function () { return x; })').return;
var c2 = hw.evalInGlobal('(function () { return x; })').return;
var c3 = gw.evalInGlobalWithBindings('(function () { return x + y; })', { y:" In Rainbows" }).return;
var c4 = hw.evalInGlobalWithBindings('(function () { return x + y; })', { y:" In Rainbows" }).return;
assertEq(c1.call(null).return, "W H O K I L L");
assertEq(c2.call(null).return, "No Color");
assertEq(c3.call(null).return, "W H O K I L L In Rainbows");
assertEq(c4.call(null).return, "No Color In Rainbows");

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

@ -1,55 +0,0 @@
// Debugger.Object.prototype.evalInGlobal: nested evals
var g = newGlobal();
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
assertEq(gw.evalInGlobal("eval('\"Awake\"');").return, "Awake");
// Evaluating non-strict-mode code uses the given global as its variable
// environment.
g.x = "Swing Lo Magellan";
g.y = "The Milk-Eyed Mender";
assertEq(gw.evalInGlobal("eval('var x = \"A Brief History of Love\"');\n"
+ "var y = 'Merriweather Post Pavilion';"
+ "x;").return,
"A Brief History of Love");
assertEq(g.x, "A Brief History of Love");
assertEq(g.y, "Merriweather Post Pavilion");
// As above, but notice that we still create bindings on the global, even
// when we've interposed a new environment via 'withBindings'.
g.x = "Swing Lo Magellan";
g.y = "The Milk-Eyed Mender";
assertEq(gw.evalInGlobalWithBindings("eval('var x = d1;'); var y = d2; x;",
{ d1: "A Brief History of Love",
d2: "Merriweather Post Pavilion" }).return,
"A Brief History of Love");
assertEq(g.x, "A Brief History of Love");
assertEq(g.y, "Merriweather Post Pavilion");
// Strict mode code variants of the above:
// Evaluating strict-mode code uses a fresh call object as its variable environment.
// Also, calls to eval from strict-mode code run the eval code in a fresh
// call object.
g.x = "Swing Lo Magellan";
g.y = "The Milk-Eyed Mender";
assertEq(gw.evalInGlobal("\'use strict\';\n"
+ "eval('var x = \"A Brief History of Love\"');\n"
+ "var y = \"Merriweather Post Pavilion\";"
+ "x;").return,
"Swing Lo Magellan");
assertEq(g.x, "Swing Lo Magellan");
assertEq(g.y, "The Milk-Eyed Mender");
// Introducing a bindings object shouldn't change this behavior.
g.x = "Swing Lo Magellan";
g.y = "The Milk-Eyed Mender";
assertEq(gw.evalInGlobalWithBindings("'use strict'; eval('var x = d1;'); var y = d2; x;",
{ d1: "A Brief History of Love",
d2: "Merriweather Post Pavilion" }).return,
"Swing Lo Magellan");
assertEq(g.x, "Swing Lo Magellan");
assertEq(g.y, "The Milk-Eyed Mender");

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

@ -1,22 +0,0 @@
// Debugger.Object.prototype.evalInGlobal throws when asked to evaluate in a CCW of a global.
load(libdir + 'asserts.js');
var dbg = new Debugger();
var g1 = newGlobal();
var dg1 = dbg.addDebuggee(g1);
var g2 = newGlobal();
var dg2 = dbg.addDebuggee(g2);
// Generate a Debugger.Object viewing g2 from g1's compartment.
var dg1wg2 = dg1.makeDebuggeeValue(g2);
assertEq(dg1wg2.global, dg1);
assertEq(dg1wg2.unwrap(), dg2);
assertThrowsInstanceOf(function () { dg1wg2.evalInGlobal('1'); }, TypeError);
assertThrowsInstanceOf(function () { dg1wg2.evalInGlobalWithBindings('x', { x: 1 }); }, TypeError);
// These, however, should not throw.
assertEq(dg1wg2.unwrap().evalInGlobal('1729').return, 1729);
assertEq(dg1wg2.unwrap().evalInGlobalWithBindings('x', { x: 1729 }).return, 1729);

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

@ -1,8 +0,0 @@
// Debugger.Object.prototype.evalInGlobal sets 'this' to the global.
var dbg = new Debugger;
var g1 = newGlobal();
var g1w = dbg.addDebuggee(g1);
assertEq(g1w.evalInGlobal('this').return, g1w);
assertEq(g1w.evalInGlobalWithBindings('this', { x:42 }).return, g1w);

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

@ -1,9 +0,0 @@
// The frame created for evalInGlobal is never marked as a 'FUNCTION' frame.
(function () {
var g = newGlobal();
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
gw.evalInGlobalWithBindings("eval('Math')",{}).return
})();

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

@ -1,4 +1,4 @@
// Debugger.Object.prototype.evalInGlobal basics
// Debugger.Object.prototype.executeInGlobal basics
var g = newGlobal();
var h = newGlobal();
@ -9,5 +9,5 @@ var hw = dbg.addDebuggee(h);
g.y = "Bitte Orca";
h.y = "Visiter";
var y = "W H O K I L L";
assertEq(gw.evalInGlobal('y').return, "Bitte Orca");
assertEq(hw.evalInGlobal('y').return, "Visiter");
assertEq(gw.executeInGlobal('y').return, "Bitte Orca");
assertEq(hw.executeInGlobal('y').return, "Visiter");

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

@ -0,0 +1,20 @@
// Debugger.Object.prototype.executeInGlobal argument validation
load(libdir + 'asserts.js');
var g = newGlobal();
var dbg = new Debugger();
var gw = dbg.addDebuggee(g);
var gobj = gw.makeDebuggeeValue(g.eval("({})"));
assertThrowsInstanceOf(function () { gw.executeInGlobal(); }, TypeError);
assertThrowsInstanceOf(function () { gw.executeInGlobal(10); }, TypeError);
assertThrowsInstanceOf(function () { gobj.executeInGlobal('42'); }, TypeError);
assertEq(gw.executeInGlobal('42').return, 42);
assertThrowsInstanceOf(function () { gw.executeInGlobalWithBindings(); }, TypeError);
assertThrowsInstanceOf(function () { gw.executeInGlobalWithBindings('42'); }, TypeError);
assertThrowsInstanceOf(function () { gw.executeInGlobalWithBindings(10, 1729); }, TypeError);
assertThrowsInstanceOf(function () { gw.executeInGlobalWithBindings('42', 1729); }, TypeError);
assertThrowsInstanceOf(function () { gobj.executeInGlobalWithBindings('42', {}); }, TypeError);
assertEq(gw.executeInGlobalWithBindings('42', {}).return, 42);

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

@ -0,0 +1,19 @@
// Debugger.Object.prototype.executeInGlobal: closures capturing the global
var g = newGlobal();
var h = newGlobal();
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
var hw = dbg.addDebuggee(h);
g.x = "W H O K I L L";
h.x = "No Color";
var c1 = gw.executeInGlobal('(function () { return x; })').return;
var c2 = hw.executeInGlobal('(function () { return x; })').return;
var c3 = gw.executeInGlobalWithBindings('(function () { return x + y; })', { y:" In Rainbows" }).return;
var c4 = hw.executeInGlobalWithBindings('(function () { return x + y; })', { y:" In Rainbows" }).return;
assertEq(c1.call(null).return, "W H O K I L L");
assertEq(c2.call(null).return, "No Color");
assertEq(c3.call(null).return, "W H O K I L L In Rainbows");
assertEq(c4.call(null).return, "No Color In Rainbows");

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

@ -0,0 +1,55 @@
// Debugger.Object.prototype.executeInGlobal: nested evals
var g = newGlobal();
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
assertEq(gw.executeInGlobal("eval('\"Awake\"');").return, "Awake");
// Evaluating non-strict-mode code uses the given global as its variable
// environment.
g.x = "Swing Lo Magellan";
g.y = "The Milk-Eyed Mender";
assertEq(gw.executeInGlobal("eval('var x = \"A Brief History of Love\"');\n"
+ "var y = 'Merriweather Post Pavilion';"
+ "x;").return,
"A Brief History of Love");
assertEq(g.x, "A Brief History of Love");
assertEq(g.y, "Merriweather Post Pavilion");
// As above, but notice that we still create bindings on the global, even
// when we've interposed a new environment via 'withBindings'.
g.x = "Swing Lo Magellan";
g.y = "The Milk-Eyed Mender";
assertEq(gw.executeInGlobalWithBindings("eval('var x = d1;'); var y = d2; x;",
{ d1: "A Brief History of Love",
d2: "Merriweather Post Pavilion" }).return,
"A Brief History of Love");
assertEq(g.x, "A Brief History of Love");
assertEq(g.y, "Merriweather Post Pavilion");
// Strict mode code variants of the above:
// Strict mode still lets us create bindings on the global as this is
// equivalent to executing statements at the global level. But note that
// setting strict mode means that nested evals get their own call objects.
g.x = "Swing Lo Magellan";
g.y = "The Milk-Eyed Mender";
assertEq(gw.executeInGlobal("\'use strict\';\n"
+ "eval('var x = \"A Brief History of Love\"');\n"
+ "var y = \"Merriweather Post Pavilion\";"
+ "x;").return,
"Swing Lo Magellan");
assertEq(g.x, "Swing Lo Magellan");
assertEq(g.y, "Merriweather Post Pavilion");
// Introducing a bindings object shouldn't change this behavior.
g.x = "Swing Lo Magellan";
g.y = "The Milk-Eyed Mender";
assertEq(gw.executeInGlobalWithBindings("'use strict'; eval('var x = d1;'); var y = d2; x;",
{ d1: "A Brief History of Love",
d2: "Merriweather Post Pavilion" }).return,
"Swing Lo Magellan");
assertEq(g.x, "Swing Lo Magellan");
assertEq(g.y, "Merriweather Post Pavilion");

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

@ -0,0 +1,22 @@
// Debugger.Object.prototype.executeInGlobal throws when asked to evaluate in a CCW of a global.
load(libdir + 'asserts.js');
var dbg = new Debugger();
var g1 = newGlobal();
var dg1 = dbg.addDebuggee(g1);
var g2 = newGlobal();
var dg2 = dbg.addDebuggee(g2);
// Generate a Debugger.Object viewing g2 from g1's compartment.
var dg1wg2 = dg1.makeDebuggeeValue(g2);
assertEq(dg1wg2.global, dg1);
assertEq(dg1wg2.unwrap(), dg2);
assertThrowsInstanceOf(function () { dg1wg2.executeInGlobal('1'); }, TypeError);
assertThrowsInstanceOf(function () { dg1wg2.executeInGlobalWithBindings('x', { x: 1 }); }, TypeError);
// These, however, should not throw.
assertEq(dg1wg2.unwrap().executeInGlobal('1729').return, 1729);
assertEq(dg1wg2.unwrap().executeInGlobalWithBindings('x', { x: 1729 }).return, 1729);

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

@ -0,0 +1,8 @@
// Debugger.Object.prototype.executeInGlobal sets 'this' to the global.
var dbg = new Debugger;
var g1 = newGlobal();
var g1w = dbg.addDebuggee(g1);
assertEq(g1w.executeInGlobal('this').return, g1w);
assertEq(g1w.executeInGlobalWithBindings('this', { x:42 }).return, g1w);

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

@ -1,4 +1,4 @@
// evalInGlobal correctly handles optional custom url option
// executeInGlobal correctly handles optional custom url option
var g = newGlobal();
var dbg = new Debugger(g);
var debuggee = dbg.getDebuggees()[0];
@ -11,7 +11,7 @@ function testUrl (options, expected) {
assertEq(script.url, expected);
count--;
};
debuggee.evalInGlobal("", options);
debuggee.executeInGlobal("", options);
}

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

@ -1,4 +1,4 @@
// evalInGlobal correctly handles optional lineNumber option
// executeInGlobal correctly handles optional lineNumber option
var g = newGlobal();
var dbg = new Debugger(g);
var debuggee = dbg.getDebuggees()[0];
@ -11,7 +11,7 @@ function testLineNumber (options, expected) {
assertEq(script.startLine, expected);
count--;
};
debuggee.evalInGlobal("", options);
debuggee.executeInGlobal("", options);
}

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

@ -0,0 +1,9 @@
// The frame created for executeInGlobal is never marked as a 'FUNCTION' frame.
(function () {
var g = newGlobal();
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
gw.executeInGlobalWithBindings("eval('Math')",{}).return
})();

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

@ -1,13 +1,13 @@
var g = newGlobal();r
var g = newGlobal();
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
// executeInGlobal should be able to introduce and persist lexical bindings.
assertEq(gw.evalInGlobal(`let x = 42; x;`).return, 42);
assertEq(gw.evalInGlobal(`x;`).return, 42);
assertEq(gw.executeInGlobal(`let x = 42; x;`).return, 42);
assertEq(gw.executeInGlobal(`x;`).return, 42);
// By contrast, Debugger.Frame.eval is like direct eval, and shouldn't be able
// to introduce new lexical bindings.
dbg.onDebuggerStatement = function (frame) { frame.eval(`let y = 84;`); };
g.eval(`debugger;`);
assertEq(gw.evalInGlobal(`y;`).return, undefined);
assertEq(!!gw.executeInGlobal(`y;`).throw, true);

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

@ -7,7 +7,7 @@ var hits = 0;
function checkIsArrow(shouldBe, expr) {
print(expr);
assertEq(gDO.evalInGlobal(expr).return.isArrowFunction, shouldBe);
assertEq(gDO.executeInGlobal(expr).return.isArrowFunction, shouldBe);
}
checkIsArrow(true, '() => { }');

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

@ -87,7 +87,7 @@ dbg.onDebuggerStatement = function (frame) {
introducer = frame.script;
};
log = '';
var fDO = gDO.evalInGlobal('debugger; Function("origami;")', { lineNumber: 1685 }).return;
var fDO = gDO.executeInGlobal('debugger; Function("origami;")', { lineNumber: 1685 }).return;
var source = fDO.script.source;
assertEq(log, 'F2');
assertEq(source.introductionScript, introducer);

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

@ -100,21 +100,21 @@ log = '';
g.eval('debugger;');
assertEq(log, 'oi');
// Debugger.Object.evalInGlobal
// Debugger.Object.executeInGlobal
dbg.onDebuggerStatement = function (frame) {
log += 'd';
assertEq(frame.script.source.introductionType, "debugger eval");
};
log = '';
gDO.evalInGlobal('debugger;');
gDO.executeInGlobal('debugger;');
assertEq(log, 'd');
// Debugger.Object.evalInGlobalWithBindings
// Debugger.Object.executeInGlobalWithBindings
dbg.onDebuggerStatement = function (frame) {
log += 'd';
assertEq(frame.script.source.introductionType, "debugger eval");
};
log = '';
gDO.evalInGlobalWithBindings('debugger;', { x: 42 });
gDO.executeInGlobalWithBindings('debugger;', { x: 42 });
assertEq(log, 'd');

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

@ -2,6 +2,6 @@ var g = newGlobal();
var dbg = new Debugger();
var gw = dbg.addDebuggee(g);
dbg.onDebuggerStatement = function (f) {
gw.evalInGlobal("eval('var x = \"A Brief History of Love\"');\n")
gw.executeInGlobal("eval('var x = \"A Brief History of Love\"');\n")
};
g.eval('debugger');

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

@ -7434,29 +7434,30 @@ RequireGlobalObject(JSContext* cx, HandleValue dbgobj, HandleObject referent)
}
static bool
DebuggerObject_evalInGlobal(JSContext* cx, unsigned argc, Value* vp)
DebuggerObject_executeInGlobal(JSContext* cx, unsigned argc, Value* vp)
{
THIS_DEBUGOBJECT_OWNER_REFERENT(cx, argc, vp, "evalInGlobal", args, dbg, referent);
if (!args.requireAtLeast(cx, "Debugger.Object.prototype.evalInGlobal", 1))
THIS_DEBUGOBJECT_OWNER_REFERENT(cx, argc, vp, "executeInGlobal", args, dbg, referent);
if (!args.requireAtLeast(cx, "Debugger.Object.prototype.executeInGlobal", 1))
return false;
if (!RequireGlobalObject(cx, args.thisv(), referent))
return false;
return DebuggerGenericEval(cx, "Debugger.Object.prototype.evalInGlobal",
return DebuggerGenericEval(cx, "Debugger.Object.prototype.executeInGlobal",
args[0], EvalWithDefaultBindings, JS::UndefinedHandleValue,
args.get(1), args.rval(), dbg, referent, nullptr);
}
static bool
DebuggerObject_evalInGlobalWithBindings(JSContext* cx, unsigned argc, Value* vp)
DebuggerObject_executeInGlobalWithBindings(JSContext* cx, unsigned argc, Value* vp)
{
THIS_DEBUGOBJECT_OWNER_REFERENT(cx, argc, vp, "evalInGlobalWithBindings", args, dbg, referent);
if (!args.requireAtLeast(cx, "Debugger.Object.prototype.evalInGlobalWithBindings", 2))
THIS_DEBUGOBJECT_OWNER_REFERENT(cx, argc, vp, "executeInGlobalWithBindings", args, dbg,
referent);
if (!args.requireAtLeast(cx, "Debugger.Object.prototype.executeInGlobalWithBindings", 2))
return false;
if (!RequireGlobalObject(cx, args.thisv(), referent))
return false;
return DebuggerGenericEval(cx, "Debugger.Object.prototype.evalInGlobalWithBindings",
return DebuggerGenericEval(cx, "Debugger.Object.prototype.executeInGlobalWithBindings",
args[0], EvalHasExtraBindings, args[1], args.get(2),
args.rval(), dbg, referent, nullptr);
}
@ -7536,8 +7537,8 @@ static const JSFunctionSpec DebuggerObject_methods[] = {
JS_FN("apply", DebuggerObject_apply, 0, 0),
JS_FN("call", DebuggerObject_call, 0, 0),
JS_FN("makeDebuggeeValue", DebuggerObject_makeDebuggeeValue, 1, 0),
JS_FN("evalInGlobal", DebuggerObject_evalInGlobal, 1, 0),
JS_FN("evalInGlobalWithBindings", DebuggerObject_evalInGlobalWithBindings, 2, 0),
JS_FN("executeInGlobal", DebuggerObject_executeInGlobal, 1, 0),
JS_FN("executeInGlobalWithBindings", DebuggerObject_executeInGlobalWithBindings, 2, 0),
JS_FN("unwrap", DebuggerObject_unwrap, 0, 0),
JS_FN("unsafeDereference", DebuggerObject_unsafeDereference, 0, 0),
JS_FS_END

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

@ -1060,7 +1060,7 @@ WebConsoleActor.prototype =
* provide the "bindObjectActor" mechanism: the Web Console tells the
* ObjectActor ID for which it desires to evaluate an expression. The
* Debugger.Object pointed at by the actor ID is bound such that it is
* available during expression evaluation (evalInGlobalWithBindings()).
* available during expression evaluation (executeInGlobalWithBindings()).
*
* Example:
* _self['foobar'] = 'test'
@ -1218,7 +1218,7 @@ WebConsoleActor.prototype =
result = frame.evalWithBindings(aString, bindings, evalOptions);
}
else {
result = dbgWindow.evalInGlobalWithBindings(aString, bindings, evalOptions);
result = dbgWindow.executeInGlobalWithBindings(aString, bindings, evalOptions);
}
let helperResult = helpers.helperResult;

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

@ -37,7 +37,7 @@ skip-if = buildapp == 'mulet'
[test_director.html]
[test_director_connectToChild.html]
skip-if = buildapp == 'mulet'
[test_evalInGlobal-outerized_this.html]
[test_executeInGlobal-outerized_this.html]
[test_framerate_01.html]
skip-if = buildapp == 'mulet'
[test_framerate_02.html]

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

@ -3,7 +3,7 @@
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=837060
When we use Debugger.Object.prototype.evalInGlobal, the 'this' value seen
When we use Debugger.Object.prototype.executeInGlobal, the 'this' value seen
by the evaluated code should be the WindowProxy, not the inner window
object.
-->
@ -38,24 +38,24 @@ window.onload = function () {
ok(page1DO.unsafeDereference() === page2DO.unsafeDereference(),
"unwrapping page1DO and page2DO outerizes both, yielding the same outer window");
is(page1DO.evalInGlobal('me').return, 'page 1', "page1DO continues to refer to original page");
is(page2DO.evalInGlobal('me').return, 'page 2', "page2DO refers to current page");
is(page1DO.executeInGlobal('me').return, 'page 1', "page1DO continues to refer to original page");
is(page2DO.executeInGlobal('me').return, 'page 2', "page2DO refers to current page");
is(page1DO.evalInGlobal('this === window').return, true,
"page 1: Debugger.Object.prototype.evalInGlobal should outerize 'this'");
is(page1DO.evalInGlobalWithBindings('this === window', {x:2}).return, true,
"page 1: Debugger.Object.prototype.evalInGlobal should outerize 'this'");
is(page1DO.executeInGlobal('this === window').return, true,
"page 1: Debugger.Object.prototype.executeInGlobal should outerize 'this'");
is(page1DO.executeInGlobalWithBindings('this === window', {x:2}).return, true,
"page 1: Debugger.Object.prototype.executeInGlobal should outerize 'this'");
is(page2DO.evalInGlobal('this === window').return, true,
"page 2: Debugger.Object.prototype.evalInGlobal should outerize 'this'");
is(page2DO.evalInGlobalWithBindings('this === window', {x:2}).return, true,
"page 2: Debugger.Object.prototype.evalInGlobal should outerize 'this'");
is(page2DO.executeInGlobal('this === window').return, true,
"page 2: Debugger.Object.prototype.executeInGlobal should outerize 'this'");
is(page2DO.executeInGlobalWithBindings('this === window', {x:2}).return, true,
"page 2: Debugger.Object.prototype.executeInGlobal should outerize 'this'");
// Debugger doesn't let one use outer windows as globals. You have to innerize.
var outerDO = page1DO.makeDebuggeeValue(page1DO.unsafeDereference());
ok(outerDO !== page1DO, "outer window gets its own D.O, distinct from page 1's global");
ok(outerDO !== page2DO, "outer window gets its own D.O, distinct from page 2's global");
SimpleTest.doesThrow(function () { outerDO.evalInGlobal('me'); },
SimpleTest.doesThrow(function () { outerDO.executeInGlobal('me'); },
"outer window D.Os can't be used as globals");
SimpleTest.finish();

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

@ -224,7 +224,7 @@ WebConsoleClient.prototype = {
* you to bind |_self| to the D.O of the given OA, during string
* evaluation.
*
* See: Debugger.Object.evalInGlobalWithBindings() for information
* See: Debugger.Object.executeInGlobalWithBindings() for information
* about bindings.
*
* Use case: the variable view needs to update objects and it does so