gecko-dev/devtools/server/tests/unit/test_framebindings-03.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 строки
1.8 KiB
JavaScript
Исходник Обычный вид История

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* strict mode code may not contain 'with' statements */
/* eslint-disable strict */
/**
* Check a |with| frame actor's bindings.
*/
var gDebuggee;
var gThreadFront;
add_task(
threadFrontTest(
async ({ threadFront, debuggee }) => {
gThreadFront = threadFront;
gDebuggee = debuggee;
test_pause_frame();
},
{ waitForFinish: true }
)
);
function test_pause_frame() {
Bug 1588997 - Convert ObjectClient to protocol.js front. r=nchevobbe. - Converted the ObjectClient into an protocoljs Front - Converted the SymbolIteratorClient into a protocoljs Front and moved it to devtools/shared/fronts - Converted the PropertyIteratorClient into a protocoljs Front and moved it to devtools/shared/fronts - Converted the EnvironmentClient into a protocoljs Front and moved it to devtools/shared/fronts - Modified calls to `DebuggerClient.release()` so that it tries to call the ObjectFront's release method first, and falls back on `DebuggerClient.release()` if there's no object front - Changed reps so that it instantiates only one ObjectClient per grip - Changed tests so that they expect what the Front's request method resolves to where applicable (i.e. ObjectFront.allocationStack resolves to allocationStack, not a packet object with an allocationStack property) - Changed callbacks provided to ObjectClient methods to be chained to the ObjectFront methods (e.g. ObjectClient.getScope(callback) changed to ObjectFront.getScope().callback()) - Changed tests to use async/await (test_framebindings-x.js, test_functiongrips-x.js, test_objectgrips-x.js) - Changed tests to expect protocoljs to throw an error string instead of an error object (test_objectgrips-fn-apply-03.js, test_threadlifetime-02.js, test_pauselifetime-03.js) Differential Revision: https://phabricator.services.mozilla.com/D48182 --HG-- rename : devtools/shared/client/environment-client.js => devtools/shared/fronts/environment.js rename : devtools/shared/client/property-iterator-client.js => devtools/shared/fronts/property-iterator.js rename : devtools/shared/client/symbol-iterator-client.js => devtools/shared/fronts/symbol-iterator.js extra : moz-landing-system : lando
2019-10-17 19:06:25 +03:00
gThreadFront.once("paused", async function(packet) {
const env = packet.frame.environment;
Assert.notEqual(env, undefined);
const parentEnv = env.parent;
Assert.notEqual(parentEnv, undefined);
const bindings = parentEnv.bindings;
const args = bindings.arguments;
const vars = bindings.variables;
Assert.equal(args.length, 1);
Assert.equal(args[0].number.value, 10);
Assert.equal(vars.r.value, 10);
Assert.equal(vars.a.value, Math.PI * 100);
Assert.equal(vars.arguments.value.class, "Arguments");
Assert.ok(!!vars.arguments.value.actor);
const objClient = gThreadFront.pauseGrip(env.object);
Bug 1588997 - Convert ObjectClient to protocol.js front. r=nchevobbe. - Converted the ObjectClient into an protocoljs Front - Converted the SymbolIteratorClient into a protocoljs Front and moved it to devtools/shared/fronts - Converted the PropertyIteratorClient into a protocoljs Front and moved it to devtools/shared/fronts - Converted the EnvironmentClient into a protocoljs Front and moved it to devtools/shared/fronts - Modified calls to `DebuggerClient.release()` so that it tries to call the ObjectFront's release method first, and falls back on `DebuggerClient.release()` if there's no object front - Changed reps so that it instantiates only one ObjectClient per grip - Changed tests so that they expect what the Front's request method resolves to where applicable (i.e. ObjectFront.allocationStack resolves to allocationStack, not a packet object with an allocationStack property) - Changed callbacks provided to ObjectClient methods to be chained to the ObjectFront methods (e.g. ObjectClient.getScope(callback) changed to ObjectFront.getScope().callback()) - Changed tests to use async/await (test_framebindings-x.js, test_functiongrips-x.js, test_objectgrips-x.js) - Changed tests to expect protocoljs to throw an error string instead of an error object (test_objectgrips-fn-apply-03.js, test_threadlifetime-02.js, test_pauselifetime-03.js) Differential Revision: https://phabricator.services.mozilla.com/D48182 --HG-- rename : devtools/shared/client/environment-client.js => devtools/shared/fronts/environment.js rename : devtools/shared/client/property-iterator-client.js => devtools/shared/fronts/property-iterator.js rename : devtools/shared/client/symbol-iterator-client.js => devtools/shared/fronts/symbol-iterator.js extra : moz-landing-system : lando
2019-10-17 19:06:25 +03:00
const response = await objClient.getPrototypeAndProperties();
Assert.equal(response.ownProperties.PI.value, Math.PI);
Assert.equal(response.ownProperties.cos.value.type, "object");
Assert.equal(response.ownProperties.cos.value.class, "Function");
Assert.ok(!!response.ownProperties.cos.value.actor);
Bug 1588997 - Convert ObjectClient to protocol.js front. r=nchevobbe. - Converted the ObjectClient into an protocoljs Front - Converted the SymbolIteratorClient into a protocoljs Front and moved it to devtools/shared/fronts - Converted the PropertyIteratorClient into a protocoljs Front and moved it to devtools/shared/fronts - Converted the EnvironmentClient into a protocoljs Front and moved it to devtools/shared/fronts - Modified calls to `DebuggerClient.release()` so that it tries to call the ObjectFront's release method first, and falls back on `DebuggerClient.release()` if there's no object front - Changed reps so that it instantiates only one ObjectClient per grip - Changed tests so that they expect what the Front's request method resolves to where applicable (i.e. ObjectFront.allocationStack resolves to allocationStack, not a packet object with an allocationStack property) - Changed callbacks provided to ObjectClient methods to be chained to the ObjectFront methods (e.g. ObjectClient.getScope(callback) changed to ObjectFront.getScope().callback()) - Changed tests to use async/await (test_framebindings-x.js, test_functiongrips-x.js, test_objectgrips-x.js) - Changed tests to expect protocoljs to throw an error string instead of an error object (test_objectgrips-fn-apply-03.js, test_threadlifetime-02.js, test_pauselifetime-03.js) Differential Revision: https://phabricator.services.mozilla.com/D48182 --HG-- rename : devtools/shared/client/environment-client.js => devtools/shared/fronts/environment.js rename : devtools/shared/client/property-iterator-client.js => devtools/shared/fronts/property-iterator.js rename : devtools/shared/client/symbol-iterator-client.js => devtools/shared/fronts/symbol-iterator.js extra : moz-landing-system : lando
2019-10-17 19:06:25 +03:00
await gThreadFront.resume();
threadFrontTestFinished();
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
function stopMe(number) {
var a;
var r = number;
with (Math) {
a = PI * r * r;
debugger;
}
}
stopMe(10);
} + ")()");
/* eslint-enable */
}