Bug 1579090 - Fix server and shared tests that were failing because of the webConsoleFront changes. r=ochameau.

Differential Revision: https://phabricator.services.mozilla.com/D54507

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicolas Chevobbe 2019-12-04 09:02:47 +00:00
Родитель b2e044ccd4
Коммит 757afcf029
26 изменённых файлов: 389 добавлений и 422 удалений

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

@ -31,28 +31,28 @@ window.onload = async function() {
async function testNotInTreeElementNode(webConsoleFront) {
info("Testing isConnected property on a ElementNode not in the DOM tree");
const {result} = await webConsoleFront.evaluateJSAsync("document.createElement(\"div\")");
is(result.preview.isConnected, false,
is(result.getGrip().preview.isConnected, false,
"isConnected is false since we only created the element");
}
async function testInTreeElementNode(webConsoleFront) {
info("Testing isConnected property on a ElementNode in the DOM tree");
const {result} = await webConsoleFront.evaluateJSAsync("document.body");
is(result.preview.isConnected, true,
is(result.getGrip().preview.isConnected, true,
"isConnected is true as expected, since the element was retrieved from the DOM tree");
}
async function testNotInTreeTextNode(webConsoleFront) {
info("Testing isConnected property on a TextNode not in the DOM tree");
const {result} = await webConsoleFront.evaluateJSAsync("document.createTextNode(\"Hello\")");
is(result.preview.isConnected, false,
is(result.getGrip().preview.isConnected, false,
"isConnected is false since we only created the element");
}
async function testInTreeTextNode(webConsoleFront) {
info("Testing isConnected property on a TextNode in the DOM tree");
const {result} = await webConsoleFront.evaluateJSAsync("document.body.firstChild");
is(result.preview.isConnected, true,
is(result.getGrip().preview.isConnected, true,
"isConnected is true as expected, since the element was retrieved from the DOM tree");
}

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

@ -39,23 +39,30 @@ function test_pause_frame() {
Assert.notEqual(parentEnv, undefined);
const objClient = gThreadFront.pauseGrip(parentEnv.object);
const response = await objClient.getPrototypeAndProperties();
Assert.equal(response.ownProperties.Object.value.type, "object");
Assert.equal(response.ownProperties.Object.value.class, "Function");
Assert.ok(!!response.ownProperties.Object.value.actor);
Assert.equal(response.ownProperties.Object.value.getGrip().type, "object");
Assert.equal(
response.ownProperties.Object.value.getGrip().class,
"Function"
);
Assert.ok(!!response.ownProperties.Object.value.actorID);
await gThreadFront.resume();
threadFrontTestFinished();
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
function stopMe(number, bool, string, null_, undef, object) {
var a = 1;
var b = true;
var c = { a: "a" };
eval("");
debugger;
}
stopMe(42, true, "nasu", null, undefined, { foo: "bar" });
} + ")()");
gDebuggee.eval(
"(" +
function() {
function stopMe(number, bool, string, null_, undef, object) {
var a = 1;
var b = true;
var c = { a: "a" };
eval("");
debugger;
}
stopMe(42, true, "nasu", null, undefined, { foo: "bar" });
} +
")()"
);
}

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

@ -43,25 +43,29 @@ function test_pause_frame() {
const objClient = gThreadFront.pauseGrip(env.object);
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);
Assert.equal(response.ownProperties.cos.value.getGrip().type, "object");
Assert.equal(response.ownProperties.cos.value.getGrip().class, "Function");
Assert.ok(!!response.ownProperties.cos.value.actorID);
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);
} + ")()");
gDebuggee.eval(
"(" +
function() {
function stopMe(number) {
var a;
var r = number;
with (Math) {
a = PI * r * r;
debugger;
}
}
stopMe(10);
} +
")()"
);
/* eslint-enable */
}

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

@ -40,9 +40,9 @@ function test_pause_frame() {
const parentClient = gThreadFront.pauseGrip(parentEnv.object);
response = await parentClient.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);
Assert.equal(response.ownProperties.cos.value.getGrip().type, "object");
Assert.equal(response.ownProperties.cos.value.getGrip().class, "Function");
Assert.ok(!!response.ownProperties.cos.value.actorID);
parentEnv = parentEnv.parent;
Assert.notEqual(parentEnv, undefined);
@ -63,19 +63,24 @@ function test_pause_frame() {
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
function stopMe(number) {
var a, obj = { one: 1, two: 2 };
var r = number;
with (Math) {
a = PI * r * r;
with (obj) {
var foo = two * PI;
debugger;
gDebuggee.eval(
"(" +
function() {
function stopMe(number) {
var a,
obj = { one: 1, two: 2 };
var r = number;
with (Math) {
a = PI * r * r;
with (obj) {
var foo = two * PI;
debugger;
}
}
}
}
}
stopMe(10);
} + ")()");
stopMe(10);
} +
")()"
);
/* eslint-enable */
}

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

@ -30,9 +30,9 @@ function test_pause_frame() {
const objClient = gThreadFront.pauseGrip(env.object);
let 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);
Assert.equal(response.ownProperties.cos.value.getGrip().type, "object");
Assert.equal(response.ownProperties.cos.value.getGrip().class, "Function");
Assert.ok(!!response.ownProperties.cos.value.actorID);
// Skip the global lexical scope.
const parentEnv = env.parent.parent;
@ -42,9 +42,12 @@ function test_pause_frame() {
response = await parentClient.getPrototypeAndProperties();
Assert.equal(response.ownProperties.a.value, Math.PI * 100);
Assert.equal(response.ownProperties.r.value, 10);
Assert.equal(response.ownProperties.Object.value.type, "object");
Assert.equal(response.ownProperties.Object.value.class, "Function");
Assert.ok(!!response.ownProperties.Object.value.actor);
Assert.equal(response.ownProperties.Object.value.getGrip().type, "object");
Assert.equal(
response.ownProperties.Object.value.getGrip().class,
"Function"
);
Assert.ok(!!response.ownProperties.Object.value.actorID);
await gThreadFront.resume();
threadFrontTestFinished();

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

@ -17,15 +17,15 @@ add_task(
Assert.equal(args[0].class, "Object");
const objClient = threadFront.pauseGrip(args[0]);
let response = await objClient.getPrototype();
const objectFront = threadFront.pauseGrip(args[0]);
const response = await objectFront.getPrototype();
Assert.ok(response.prototype != undefined);
const protoClient = threadFront.pauseGrip(response.prototype);
response = await protoClient.getOwnPropertyNames();
Assert.equal(response.ownPropertyNames.length, 2);
Assert.equal(response.ownPropertyNames[0], "b");
Assert.equal(response.ownPropertyNames[1], "c");
const protoFront = response.prototype;
const { ownPropertyNames } = await protoFront.getOwnPropertyNames();
Assert.equal(ownPropertyNames.length, 2);
Assert.equal(ownPropertyNames[0], "b");
Assert.equal(ownPropertyNames[1], "c");
await threadFront.resume();
resolve();

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

@ -17,29 +17,31 @@ add_task(
Assert.equal(args[0].class, "Object");
const objClient = threadFront.pauseGrip(args[0]);
let response = await objClient.getPrototypeAndProperties();
Assert.equal(response.ownProperties.x.configurable, true);
Assert.equal(response.ownProperties.x.enumerable, true);
Assert.equal(response.ownProperties.x.writable, true);
Assert.equal(response.ownProperties.x.value, 10);
const objectFront = threadFront.pauseGrip(args[0]);
const {
ownProperties,
prototype,
} = await objectFront.getPrototypeAndProperties();
Assert.equal(ownProperties.x.configurable, true);
Assert.equal(ownProperties.x.enumerable, true);
Assert.equal(ownProperties.x.writable, true);
Assert.equal(ownProperties.x.value, 10);
Assert.equal(response.ownProperties.y.configurable, true);
Assert.equal(response.ownProperties.y.enumerable, true);
Assert.equal(response.ownProperties.y.writable, true);
Assert.equal(response.ownProperties.y.value, "kaiju");
Assert.equal(ownProperties.y.configurable, true);
Assert.equal(ownProperties.y.enumerable, true);
Assert.equal(ownProperties.y.writable, true);
Assert.equal(ownProperties.y.value, "kaiju");
Assert.equal(response.ownProperties.a.configurable, true);
Assert.equal(response.ownProperties.a.enumerable, true);
Assert.equal(response.ownProperties.a.get.type, "object");
Assert.equal(response.ownProperties.a.get.class, "Function");
Assert.equal(response.ownProperties.a.set.type, "undefined");
Assert.equal(ownProperties.a.configurable, true);
Assert.equal(ownProperties.a.enumerable, true);
Assert.equal(ownProperties.a.get.getGrip().type, "object");
Assert.equal(ownProperties.a.get.getGrip().class, "Function");
Assert.equal(ownProperties.a.set.type, "undefined");
Assert.ok(response.prototype != undefined);
Assert.ok(prototype != undefined);
const protoClient = threadFront.pauseGrip(response.prototype);
response = await protoClient.getOwnPropertyNames();
Assert.ok(response.ownPropertyNames.toString != undefined);
const { ownPropertyNames } = await prototype.getOwnPropertyNames();
Assert.ok(ownPropertyNames.toString != undefined);
await threadFront.resume();
resolve();

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

@ -27,33 +27,25 @@ function test_object_grip() {
Assert.equal(person.value.class, "Object");
const personClient = gThreadFront.pauseGrip(person.value);
let response = await personClient.getPrototypeAndProperties();
Assert.equal(response.ownProperties.getName.value.class, "Function");
const personFront = gThreadFront.pauseGrip(person.value);
const { ownProperties } = await personFront.getPrototypeAndProperties();
Assert.equal(ownProperties.getName.value.getGrip().class, "Function");
Assert.equal(ownProperties.getAge.value.getGrip().class, "Function");
Assert.equal(ownProperties.getFoo.value.getGrip().class, "Function");
Assert.equal(response.ownProperties.getAge.value.class, "Function");
const getNameFront = ownProperties.getName.value;
const getAgeFront = ownProperties.getAge.value;
const getFooFront = ownProperties.getFoo.value;
Assert.equal(response.ownProperties.getFoo.value.class, "Function");
const getNameClient = gThreadFront.pauseGrip(
response.ownProperties.getName.value
);
const getAgeClient = gThreadFront.pauseGrip(
response.ownProperties.getAge.value
);
const getFooClient = gThreadFront.pauseGrip(
response.ownProperties.getFoo.value
);
response = await getNameClient.getScope();
let response = await getNameFront.getScope();
let bindings = await response.scope.bindings();
Assert.equal(bindings.arguments[0].name.value, "Bob");
response = await getAgeClient.getScope();
response = await getAgeFront.getScope();
bindings = await response.scope.bindings();
Assert.equal(bindings.arguments[1].age.value, 58);
response = await getFooClient.getScope();
response = await getFooFront.getScope();
bindings = await response.scope.bindings();
Assert.equal(bindings.variables.foo.value, 10);
@ -62,17 +54,28 @@ function test_object_grip() {
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
var PersonFactory = function (name, age) {
var foo = 10;
return {
getName: function () { return name; },
getAge: function () { return age; },
getFoo: function () { foo = Date.now(); return foo; }
};
};
var person = new PersonFactory("Bob", 58);
debugger;
} + ")()");
gDebuggee.eval(
"(" +
function() {
var PersonFactory = function(name, age) {
var foo = 10;
return {
getName: function() {
return name;
},
getAge: function() {
return age;
},
getFoo: function() {
foo = Date.now();
return foo;
},
};
};
var person = new PersonFactory("Bob", 58);
debugger;
} +
")()"
);
/* eslint-enable */
}

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

@ -207,9 +207,13 @@ function check_proxy_slots(debuggee, testOptions, grip, proxySlots) {
);
} else if (global === debuggee) {
const { proxyTarget, proxyHandler } = proxySlots;
strictEqual(proxyTarget.type, "object", "There is a [[ProxyTarget]] grip.");
strictEqual(
proxyHandler.type,
proxyTarget.getGrip().type,
"object",
"There is a [[ProxyTarget]] grip."
);
strictEqual(
proxyHandler.getGrip().type,
"object",
"There is a [[ProxyHandler]] grip."
);
@ -253,12 +257,16 @@ function check_prototype(
if (isOpaque && !globalIsInvisible && !createdInDebuggee) {
// The object is or inherits from a proxy with opaque security wrappers.
// The debuggee sees `Object.prototype` when retrieving the prototype.
strictEqual(proto.class, "Object", "The prototype has a Object class.");
strictEqual(
proto.getGrip().class,
"Object",
"The prototype has a Object class."
);
} else if (isProxy && isOpaque && globalIsInvisible) {
// The object is a proxy with opaque security wrappers in an invisible global.
// The debuggee sees an inaccessible `Object.prototype` when retrieving the prototype.
strictEqual(
proto.class,
proto.getGrip().class,
"InvisibleToDebugger: Object",
"The prototype has an InvisibleToDebugger class."
);
@ -271,7 +279,7 @@ function check_prototype(
check_proxy_grip(
debuggee,
{ global, isOpaque, subsumes, globalIsInvisible },
proto
proto.getGrip()
);
} else {
// The debuggee is not allowed to access the object. It sees a null prototype.

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

@ -15,14 +15,14 @@ add_task(
threadFront.once("paused", async function(packet) {
const [grip] = packet.frame.arguments;
const objClient = threadFront.pauseGrip(grip);
const objectFront = threadFront.pauseGrip(grip);
// Checks the result of enumProperties.
let response = await objClient.enumProperties({});
let response = await objectFront.enumProperties({});
await check_enum_properties(response);
// Checks the result of enumSymbols.
response = await objClient.enumSymbols();
response = await objectFront.enumSymbols();
await check_enum_symbols(response);
await threadFront.resume();
@ -138,7 +138,7 @@ add_task(
const iteratorSymbol = ownSymbols[12];
equal(iteratorSymbol.name, "Symbol(Symbol.iterator)");
equal(iteratorSymbol.descriptor.value.class, "Function");
equal(iteratorSymbol.descriptor.value.getGrip().class, "Function");
info("Check iterator.all response");
const allResponse = await iterator.all();

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

@ -393,10 +393,11 @@ function check_symbol(descr, data, isUnsafe) {
}
function check_prototype(proto, data, isUnsafe) {
const protoGrip = proto && proto.getGrip ? proto.getGrip() : proto;
if (isUnsafe) {
deepEqual(proto.type, data.protoType, "Got the right prototype type.");
deepEqual(protoGrip.type, data.protoType, "Got the right prototype type.");
} else {
check_grip(proto, data, true);
check_grip(protoGrip, data, true);
}
}

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

@ -10,7 +10,7 @@ registerCleanupFunction(() => {
});
add_task(
threadFrontTest(async ({ threadFront, debuggee, client }) => {
threadFrontTest(async ({ threadFront, debuggee }) => {
debuggee.eval(
function stopMe(arg1) {
debugger;
@ -40,21 +40,25 @@ async function test_object_grip(debuggee, threadFront) {
},
});
`,
async objClient => {
const obj1 = (await objClient.getPropertyValue("obj1", null)).value
.return;
const obj2 = (await objClient.getPropertyValue("obj2", null)).value
.return;
async objectFront => {
const obj1 = (await objectFront.getPropertyValue(
"obj1",
null
)).value.return.getGrip();
const obj2 = (await objectFront.getPropertyValue(
"obj2",
null
)).value.return.getGrip();
const context = threadFront.pauseGrip(
(await objClient.getPropertyValue("context", null)).value.return
);
const sum = threadFront.pauseGrip(
(await objClient.getPropertyValue("sum", null)).value.return
);
const error = threadFront.pauseGrip(
(await objClient.getPropertyValue("error", null)).value.return
);
info(`Retrieve "context" function reference`);
const context = (await objectFront.getPropertyValue("context", null))
.value.return;
info(`Retrieve "sum" function reference`);
const sum = (await objectFront.getPropertyValue("sum", null)).value
.return;
info(`Retrieve "error" function reference`);
const error = (await objectFront.getPropertyValue("error", null)).value
.return;
assert_response(await context.apply(obj1, [obj1]), {
return: "correct context",

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

@ -41,11 +41,10 @@ async function test_object_grip(debuggee, threadFront) {
return arg1;
}
);
const objClient = threadFront.pauseGrip(obj);
const objectFront = threadFront.pauseGrip(obj);
const method = threadFront.pauseGrip(
(await objClient.getPropertyValue("method", null)).value.return
);
const method = (await objectFront.getPropertyValue("method", null)).value
.return;
// Ensure that we actually paused at the `debugger;` line.
await Promise.all([

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

@ -39,11 +39,10 @@ async function test_object_grip(debuggee, threadFront) {
return arg1;
}
);
const objClient = threadFront.pauseGrip(obj);
const objectFront = threadFront.pauseGrip(obj);
const method = threadFront.pauseGrip(
(await objClient.getPropertyValue("method", null)).value.return
);
const method = (await objectFront.getPropertyValue("method", null)).value
.return;
try {
await method.apply(obj, []);

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

@ -18,9 +18,13 @@ add_task(
const { proxyTarget, proxyHandler } = await objClient.getProxySlots();
strictEqual(grip.class, "Proxy", "Its a proxy grip.");
strictEqual(proxyTarget.class, "Proxy", "The target is also a proxy.");
strictEqual(
proxyHandler.class,
proxyTarget.getGrip().class,
"Proxy",
"The target is also a proxy."
);
strictEqual(
proxyHandler.getGrip().class,
"Proxy",
"The handler is also a proxy."
);

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

@ -49,7 +49,7 @@ async function test_object_grip(debuggee, threadFront) {
};
stopMe(obj);
`,
async objClient => {
async objFront => {
const expectedValues = {
stringProp: {
return: "a value",
@ -62,14 +62,16 @@ async function test_object_grip(debuggee, threadFront) {
},
objectNormal: {
return: {
type: "object",
class: "Object",
ownPropertyLength: 1,
preview: {
kind: "Object",
ownProperties: {
prop: {
value: 4,
_grip: {
type: "object",
class: "Object",
ownPropertyLength: 1,
preview: {
kind: "Object",
ownProperties: {
prop: {
value: 4,
},
},
},
},
@ -77,14 +79,16 @@ async function test_object_grip(debuggee, threadFront) {
},
objectAbrupt: {
throw: {
type: "object",
class: "Object",
ownPropertyLength: 1,
preview: {
kind: "Object",
ownProperties: {
prop: {
value: 4,
_grip: {
type: "object",
class: "Object",
ownPropertyLength: 1,
preview: {
kind: "Object",
ownProperties: {
prop: {
value: 4,
},
},
},
},
@ -95,16 +99,17 @@ async function test_object_grip(debuggee, threadFront) {
},
method: {
return: {
type: "object",
class: "Function",
name: "method",
_grip: {
type: "object",
class: "Function",
name: "method",
},
},
},
};
for (const [key, expected] of Object.entries(expectedValues)) {
const { value } = await objClient.getPropertyValue(key, null);
const { value } = await objFront.getPropertyValue(key, null);
assert_completion(value, expected);
}
}

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

@ -31,8 +31,8 @@ function test_pause_frame() {
Assert.equal(args[0].class, "Object");
Assert.ok(!!objActor);
const objClient = gThreadFront.pauseGrip(args[0]);
Assert.ok(objClient.valid);
const objectFront = gThreadFront.pauseGrip(args[0]);
Assert.ok(objectFront.valid);
// Make a bogus request to the grip actor. Should get
// unrecognized-packet-type (and not no-such-actor).
@ -44,7 +44,7 @@ function test_pause_frame() {
ok(true, "bogusRequest thrown");
Assert.ok(!!e.match(/unrecognizedPacketType/));
}
Assert.ok(objClient.valid);
Assert.ok(objectFront.valid);
gThreadFront.resume().then(async function() {
// Now that we've resumed, should get no-such-actor for the
@ -57,7 +57,7 @@ function test_pause_frame() {
ok(true, "bogusRequest thrown");
Assert.ok(!!e.match(/noSuchActor/));
}
Assert.ok(!objClient.valid);
Assert.ok(!objectFront.valid);
threadFrontTestFinished();
});
});

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

@ -39,9 +39,19 @@ function test_thread_lifetime() {
// Verify that the promoted actor is returned again.
Assert.equal(pauseGrip.actor, packet.frame.arguments[0].actor);
// Now that we've resumed, release the thread-lifetime grip.
const objFront = new ObjectFront(gClient, pauseGrip);
const objFront = new ObjectFront(
gThreadFront.conn,
gThreadFront.targetFront,
gThreadFront,
pauseGrip
);
await objFront.release();
const objFront2 = new ObjectFront(gClient, pauseGrip);
const objFront2 = new ObjectFront(
gThreadFront.conn,
gThreadFront.targetFront,
gThreadFront,
pauseGrip
);
try {
await objFront2

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

@ -38,7 +38,7 @@ async function testSetWatchpoint({ threadFront, debuggee, targetFront }) {
stopMe({a: { b: 1 }})`,
debuggee,
"1.8",
"test_watchpoint-01.js",
"test_watchpoint-01.js"
);
/* eslint-disable */
}
@ -57,8 +57,8 @@ async function testSetWatchpoint({ threadFront, debuggee, targetFront }) {
const objClient = threadFront.pauseGrip(obj);
await objClient.addWatchpoint("a", "obj.a", "set");
let result = await evaluateJS("obj.a");
Assert.equal(result.preview.ownProperties.b.value, 1)
let result = await evaluateJS("obj.a");
Assert.equal(result.getGrip().preview.ownProperties.b.value, 1);
result = await evaluateJS("obj.a.b");
Assert.equal(result, 1);
@ -80,11 +80,11 @@ async function testGetWatchpoint({ threadFront, debuggee }) {
function stopMe(obj) { // 2
debugger; // 3
obj.a + 4; // 4
} //
} //
stopMe({a: 1})`,
debuggee,
"1.8",
"test_watchpoint-01.js",
"test_watchpoint-01.js"
);
/* eslint-disable */
}
@ -103,7 +103,7 @@ async function testGetWatchpoint({ threadFront, debuggee }) {
const objClient = threadFront.pauseGrip(obj);
await objClient.addWatchpoint("a", "obj.a", "get");
info('Test that watchpoint triggers pause on get.');
info("Test that watchpoint triggers pause on get.");
const packet2 = await resumeAndWaitForPause(threadFront);
Assert.equal(packet2.frame.where.line, 4);
Assert.equal(packet2.why.type, "getWatchpoint");
@ -121,11 +121,11 @@ async function testRemoveWatchpoint({ threadFront, debuggee }) {
debugger; // 3
obj.a = 2; // 4
debugger; // 5
} //
stopMe({a: 1})`,
} //
stopMe({a: 1})`,
debuggee,
"1.8",
"test_watchpoint-01.js",
"test_watchpoint-01.js"
);
/* eslint-disable */
}
@ -134,7 +134,7 @@ async function testRemoveWatchpoint({ threadFront, debuggee }) {
() => evaluateTestCode(debuggee),
threadFront
);
//Test that we paused on the debugger statement.
Assert.equal(packet.frame.where.line, 3);
@ -145,9 +145,9 @@ async function testRemoveWatchpoint({ threadFront, debuggee }) {
await objClient.addWatchpoint("a", "obj.a", "set");
await objClient.removeWatchpoint("a");
//Test that we do not pause on set.
//Test that we do not pause on set.
const packet2 = await resumeAndWaitForPause(threadFront);
Assert.equal(packet2.frame.where.line, 5);
await resume(threadFront);
}
}

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

@ -88,9 +88,11 @@ async function wrapCommand(webConsoleFront) {
await evaluateJSAndCheckResult(webConsoleFront, "keys({foo: 'bar'})", {
result: {
class: "Array",
preview: {
items: ["foo"],
_grip: {
class: "Array",
preview: {
items: ["foo"],
},
},
},
});
@ -188,8 +190,10 @@ async function unregisterAfterOverridingTwice(webConsoleFront) {
);
await evaluateJSAndCheckResult(webConsoleFront, "keys({});", {
result: {
class: "Array",
preview: { items: [] },
_grip: {
class: "Array",
preview: { items: [] },
},
},
});
}

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

@ -1,71 +1,52 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf8">
<title>Test for Bug 819670 - Web console object inspection does not handle native getters throwing very well</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="common.js"></script>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
</head>
<body>
<p>Test for Bug 819670 - Web console object inspection does not handle native getters throwing very well</p>
<head>
<meta charset="utf8">
<title>Test for Bug 819670 - Web console object inspection does not handle native getters throwing very well</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="common.js"></script>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
</head>
<body>
<p>Test for Bug 819670 - Web console object inspection does not handle native getters throwing very well</p>
<script class="testbody" type="text/javascript">
"use strict";
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForExplicitFinish();
addEventListener("load", startTest);
function startTest()
{
removeEventListener("load", startTest);
attachConsoleToTab([], onAttach);
}
async function startTest() {
removeEventListener("load", startTest);
const {state} = await attachConsoleToTab([]);
const evaluationResponse = await state.webConsoleFront.evaluateJSAsync("document.__proto__");
checkObject(evaluationResponse, {
input: "document.__proto__",
result: {
type: "object",
actor: /[a-z]/
}
});
function onAttach(aState, aResponse)
{
onEvaluate = onEvaluate.bind(null, aState);
aState.webConsoleFront.evaluateJSAsync("document.__proto__").then(onEvaluate);
}
ok(!evaluationResponse.exception, "no eval exception");
ok(!evaluationResponse.helperResult, "no helper result");
function onEvaluate(aState, aResponse)
{
checkObject(aResponse, {
input: "document.__proto__",
result: {
type: "object",
actor: /[a-z]/,
},
});
const response = await evaluationResponse.result.getPrototypeAndProperties();
ok(! response.error, "no response error");
ok(!aResponse.exception, "no eval exception");
ok(!aResponse.helperResult, "no helper result");
const props = response.ownProperties;
ok(props, "response properties available");
onInspect = onInspect.bind(null, aState);
const client = new ObjectFront(aState.dbgClient, aResponse.result);
client.getPrototypeAndProperties().then(onInspect);
}
if (props) {
// eslint-disable-next-line no-proto
const expectedProps = Object.getOwnPropertyNames(document.__proto__);
isDeeply(Object.keys(props), expectedProps, "Same own properties.");
}
function onInspect(aState, aResponse)
{
ok(!aResponse.error, "no response error");
// eslint-disable-next-line no-proto
const expectedProps = Object.getOwnPropertyNames(document.__proto__);
const props = aResponse.ownProperties;
ok(props, "response properties available");
if (props) {
isDeeply(Object.keys(props), expectedProps, "Same own properties.");
}
closeDebugger(aState, function() {
SimpleTest.finish();
});
}
addEventListener("load", startTest);
</script>
</body>
await closeDebugger(state);
SimpleTest.finish();
}
</script>
</body>
</html>

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

@ -160,7 +160,7 @@ async function doEvalLongString() {
async function doEvalWithBinding() {
const response = await evaluateJS("document;");
const documentActor = response.result.actor;
const documentActor = response.result.actorID;
info("running a command with _self as document using selectedObjectActor");
const selectedObjectSame = await evaluateJS("_self === document", {
@ -180,7 +180,7 @@ async function doEvalWithBindingFrame() {
const response = await evaluateJS(
"document.querySelector('iframe').contentWindow.fooFrame"
);
const iframeObjectActor = response.result.actor;
const iframeObjectActor = response.result.actorID;
ok(iframeObjectActor, "There is an actor associated with the response");
await evaluateJS("this.temp1 = _self;", {

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

@ -66,7 +66,7 @@ const checkObjectResult = async function () {
class: "Object",
actor: /[a-z]/,
});
checkObject(response.result.preview.ownProperties, {
checkObject(response.result.getGrip().preview.ownProperties, {
bar: {
value: 1
}
@ -78,7 +78,7 @@ const checkObjectResult = async function () {
class: "Object",
actor: /[a-z]/,
});
checkObject(response.result.preview.ownProperties, {
checkObject(response.result.getGrip().preview.ownProperties, {
bar: {
value: 1
}
@ -92,7 +92,7 @@ const checkObjectResult = async function () {
class: "Object",
actor: /[a-z]/,
});
checkObject(response.result.preview.ownProperties, {
checkObject(response.result.getGrip().preview.ownProperties, {
bar: {
value: 2
}

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

@ -16,52 +16,36 @@
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
true]]});
SpecialPowers.pushPrefEnv({
"set": [["security.allow_eval_with_system_principal", true]]
});
let expectedProps = [];
function startTest() {
async function startTest() {
removeEventListener("load", startTest);
attachConsoleToTab(["ConsoleAPI"], onAttach);
}
function onAttach(state, response) {
onConsoleCall = onConsoleCall.bind(null, state);
state.webConsoleFront.on("consoleAPICall", onConsoleCall);
const longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 3)).join("\u0629");
createTestGlobalVariable(longString);
// Here we put the objects in the correct window, to avoid having them all
// wrapped by proxies for cross-compartment access.
const {state} = await attachConsoleToTab(["ConsoleAPI"]);
const onConsoleApiCall = state.webConsoleFront.once("consoleAPICall");
top.console.log("hello", top.wrappedJSObject.foobarObject);
const {message} = await onConsoleApiCall;
const foobarObject = top.Object.create(null);
foobarObject.tamarbuta = longString;
foobarObject.foo = 1;
foobarObject.foobar = "hello";
foobarObject.omg = null;
foobarObject.testfoo = false;
foobarObject.notInspectable = top.Object.create(null);
foobarObject.omgfn = new top.Function("return 'myResult'");
foobarObject.abArray = new top.Array("a", "b");
foobarObject.foobaz = top.document;
top.Object.defineProperty(foobarObject, "getterAndSetter", {
enumerable: true,
get: new top.Function("return 'foo';"),
set: new top.Function("1+2"),
info("checking the console API call packet");
checkConsoleAPICall(message, {
level: "log",
filename: /test_object_actor/,
functionName: "startTest",
arguments: ["hello", {
type: "object",
actor: /[a-z]/,
}],
});
foobarObject.longStringObj = top.Object.create(null);
foobarObject.longStringObj.toSource = new top.Function("'" + longString + "'");
foobarObject.longStringObj.toString = new top.Function("'" + longString + "'");
foobarObject.longStringObj.boom = "explode";
info("inspecting object properties");
const {ownProperties} = await message.arguments[1].getPrototypeAndProperties();
top.wrappedJSObject.foobarObject = foobarObject;
top.console.log("hello", top.wrappedJSObject.foobarObject);
expectedProps = {
const expectedProps = {
"abArray": {
value: {
type: "object",
@ -133,42 +117,40 @@ function onAttach(state, response) {
value: false,
},
};
}
function onConsoleCall(state, aPacket) {
info("checking the console API call packet");
checkConsoleAPICall(aPacket.message, {
level: "log",
filename: /test_object_actor/,
functionName: "onAttach",
arguments: ["hello", {
type: "object",
actor: /[a-z]/,
}],
});
state.webConsoleFront.off("consoleAPICall", onConsoleCall);
info("inspecting object properties");
const args = aPacket.message.arguments;
onProperties = onProperties.bind(null, state);
const client = new ObjectFront(state.dbgClient, args[1]);
client.getPrototypeAndProperties().then(onProperties);
}
function onProperties(state, response) {
const props = response.ownProperties;
is(Object.keys(props).length, Object.keys(expectedProps).length,
is(Object.keys(ownProperties).length, Object.keys(expectedProps).length,
"number of enumerable properties");
checkObject(props, expectedProps);
checkObject(ownProperties, expectedProps);
expectedProps = [];
await closeDebugger(state);
SimpleTest.finish();
}
closeDebugger(state, function() {
SimpleTest.finish();
function createTestGlobalVariable(longString) {
// Here we put the objects in the correct window, to avoid having them all
// wrapped by proxies for cross-compartment access.
const foobarObject = top.Object.create(null);
foobarObject.tamarbuta = longString;
foobarObject.foo = 1;
foobarObject.foobar = "hello";
foobarObject.omg = null;
foobarObject.testfoo = false;
foobarObject.notInspectable = top.Object.create(null);
foobarObject.omgfn = new top.Function("return 'myResult'");
foobarObject.abArray = new top.Array("a", "b");
foobarObject.foobaz = top.document;
top.Object.defineProperty(foobarObject, "getterAndSetter", {
enumerable: true,
get: new top.Function("return 'foo';"),
set: new top.Function("1+2"),
});
foobarObject.longStringObj = top.Object.create(null);
foobarObject.longStringObj.toSource = new top.Function("'" + longString + "'");
foobarObject.longStringObj.toString = new top.Function("'" + longString + "'");
foobarObject.longStringObj.boom = "explode";
top.wrappedJSObject.foobarObject = foobarObject;
}
addEventListener("load", startTest);

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

@ -16,24 +16,30 @@
SimpleTest.waitForExplicitFinish();
let expectedProps = [];
let expectedSafeGetters = [];
function startTest()
{
async function startTest() {
removeEventListener("load", startTest);
const {state} = await attachConsoleToTab(["ConsoleAPI"]);
attachConsoleToTab(["ConsoleAPI"], onAttach);
}
function onAttach(aState, aResponse)
{
onConsoleCall = onConsoleCall.bind(null, aState);
aState.webConsoleFront.on("consoleAPICall", onConsoleCall);
const onConsoleAPICall = state.webConsoleFront.once("consoleAPICall");
top.console.log("hello", document);
const {message} = await onConsoleAPICall;
expectedProps = {
info("checking the console API call packet");
checkConsoleAPICall(message, {
level: "log",
filename: /test_object_actor/,
functionName: "startTest",
arguments: ["hello", {
type: "object",
actor: /[a-z]/,
}],
});
info("inspecting object properties");
const args = message.arguments;
const {ownProperties, safeGetterValues} = await args[1].getPrototypeAndProperties();
const expectedProps = {
"location": {
get: {
type: "object",
@ -42,62 +48,26 @@ function onAttach(aState, aResponse)
},
},
};
ok(Object.keys(ownProperties).length >= Object.keys(expectedProps).length,
"number of properties");
expectedSafeGetters = {
info("check ownProperties");
checkObject(ownProperties, expectedProps);
info("check safeGetterValues");
checkObject(safeGetterValues, {
"title": {
getterValue: /native getters in object actors/,
getterPrototypeLevel: 2,
},
"styleSheets": {
getterValue: /\[object Object\]/,
getterValue: /Front for obj\//,
getterPrototypeLevel: 2,
},
};
}
function onConsoleCall(aState, aPacket)
{
info("checking the console API call packet");
checkConsoleAPICall(aPacket.message, {
level: "log",
filename: /test_object_actor/,
functionName: "onAttach",
arguments: ["hello", {
type: "object",
actor: /[a-z]/,
}],
});
aState.webConsoleFront.off("consoleAPICall", onConsoleCall);
info("inspecting object properties");
const args = aPacket.message.arguments;
onProperties = onProperties.bind(null, aState);
const client = new ObjectFront(aState.dbgClient, args[1]);
client.getPrototypeAndProperties().then(onProperties);
}
function onProperties(aState, aResponse)
{
const props = aResponse.ownProperties;
const keys = Object.keys(props);
info(keys.length + " ownProperties: " + keys);
ok(keys.length >= Object.keys(expectedProps).length, "number of properties");
info("check ownProperties");
checkObject(props, expectedProps);
info("check safeGetterValues");
checkObject(aResponse.safeGetterValues, expectedSafeGetters);
expectedProps = [];
expectedSafeGetters = [];
closeDebugger(aState, function() {
SimpleTest.finish();
});
await closeDebugger(state);
SimpleTest.finish();
}
addEventListener("load", startTest);

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

@ -17,60 +17,36 @@
SimpleTest.waitForExplicitFinish();
function startTest()
{
async function startTest() {
removeEventListener("load", startTest);
const {state} = await attachConsoleToTab(["ConsoleAPI"]);
attachConsoleToTab(["ConsoleAPI"], onAttach);
}
function onAttach(aState, aResponse)
{
onConsoleCall = onConsoleCall.bind(null, aState);
aState.webConsoleFront.on("consoleAPICall", onConsoleCall);
const onConsoleApiCall = state.webConsoleFront.once("consoleAPICall");
const docAsProto = Object.create(document);
top.console.log("hello", docAsProto);
}
const {message} = await onConsoleApiCall;
function onConsoleCall(aState, aPacket)
{
info("checking the console API call packet");
checkConsoleAPICall(aPacket.message, {
checkConsoleAPICall(message, {
level: "log",
filename: /test_object_actor/,
functionName: "onAttach",
functionName: "startTest",
arguments: ["hello", {
type: "object",
actor: /[a-z]/,
}],
});
aState.webConsoleFront.off("consoleAPICall", onConsoleCall);
info("inspecting object properties");
const args = aPacket.message.arguments;
onProperties = onProperties.bind(null, aState);
const args = message.arguments;
const client = new ObjectFront(aState.dbgClient, args[1]);
client.getPrototypeAndProperties().then(onProperties);
}
const {ownProperties, safeGetterValues} = await args[1].getPrototypeAndProperties();
function onProperties(aState, aResponse)
{
const props = aResponse.ownProperties;
let keys = Object.keys(props);
info(keys.length + " ownProperties: " + keys);
is(Object.keys(ownProperties).length, 0, "number of properties");
is(Object.keys(safeGetterValues).length, 0, "number of safe getters");
is(keys.length, 0, "number of properties");
keys = Object.keys(aResponse.safeGetterValues);
is(keys.length, 0, "number of safe getters");
closeDebugger(aState, function() {
SimpleTest.finish();
});
await closeDebugger(state);
SimpleTest.finish();
}
addEventListener("load", startTest);