зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1856464) for causing failures in test_SpecialPowersSandbox.js
Backed out changeset 16e6c8b1d450 (bug 1856464) Backed out changeset 076438699342 (bug 1856464)
This commit is contained in:
Родитель
298dcb22d6
Коммит
ec92460813
|
@ -51,8 +51,6 @@ add_task(async function() {
|
|||
[true, "Hmm - 1 == 1", undefined],
|
||||
[true, "Yay. - true == true", undefined],
|
||||
[false, "Boo!. - false == true", "got false, expected true (operator ==)"],
|
||||
[false, "Missing expected exception Rej_bad", "got null, expected /./ (operator undefined)"],
|
||||
[true, "Rej_ok", undefined],
|
||||
];
|
||||
|
||||
// Test that a representative variety of assertions work as expected, and
|
||||
|
@ -68,8 +66,6 @@ add_task(async function() {
|
|||
Assert.equal(1, 1, "Hmm");
|
||||
Assert.ok(true, "Yay.");
|
||||
Assert.ok(false, "Boo!.");
|
||||
await Assert.rejects(Promise.resolve(), /./, "Rej_bad");
|
||||
await Assert.rejects(Promise.reject(new Error("k")), /k/, "Rej_ok");
|
||||
});
|
||||
},
|
||||
"SpecialPowers.spawn-subframe": () => {
|
||||
|
@ -82,13 +78,11 @@ add_task(async function() {
|
|||
subFrame.addEventListener("load", resolve, { once: true });
|
||||
});
|
||||
|
||||
await SpecialPowers.spawn(subFrame, [], async () => {
|
||||
await SpecialPowers.spawn(subFrame, [], () => {
|
||||
Assert.equal(1, 2, "Thing");
|
||||
Assert.equal(1, 1, "Hmm");
|
||||
Assert.ok(true, "Yay.");
|
||||
Assert.ok(false, "Boo!.");
|
||||
await Assert.rejects(Promise.resolve(), /./, "Rej_bad");
|
||||
await Assert.rejects(Promise.reject(new Error("k")), /k/, "Rej_ok");
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -98,22 +92,17 @@ add_task(async function() {
|
|||
Assert.equal(1, 1, "Hmm");
|
||||
Assert.ok(true, "Yay.");
|
||||
Assert.ok(false, "Boo!.");
|
||||
await Assert.rejects(Promise.resolve(), /./, "Rej_bad");
|
||||
await Assert.rejects(Promise.reject(new Error("k")), /k/, "Rej_ok");
|
||||
});
|
||||
},
|
||||
"SpecialPowers.loadChromeScript": async () => {
|
||||
let script = SpecialPowers.loadChromeScript(() => {
|
||||
/* eslint-env mozilla/chrome-script */
|
||||
const resultPromise = (async () => {
|
||||
Assert.equal(1, 2, "Thing");
|
||||
Assert.equal(1, 1, "Hmm");
|
||||
Assert.ok(true, "Yay.");
|
||||
Assert.ok(false, "Boo!.");
|
||||
await Assert.rejects(Promise.resolve(), /./, "Rej_bad");
|
||||
await Assert.rejects(Promise.reject(new Error("k")), /k/, "Rej_ok");
|
||||
})();
|
||||
this.addMessageListener("ping", () => resultPromise);
|
||||
this.addMessageListener("ping", () => "pong");
|
||||
|
||||
Assert.equal(1, 2, "Thing");
|
||||
Assert.equal(1, 1, "Hmm");
|
||||
Assert.ok(true, "Yay.");
|
||||
Assert.ok(false, "Boo!.");
|
||||
});
|
||||
|
||||
await script.sendQuery("ping");
|
||||
|
@ -129,18 +118,6 @@ add_task(async function() {
|
|||
let results = diags.map(diag => [diag.condition, diag.name, diag.diag]);
|
||||
|
||||
isDeeply(results, expected, "Got expected assertions");
|
||||
for (let { name: diagName, stack } of diags) {
|
||||
ok(stack, `Got stack for: ${diagName}`);
|
||||
let expectedFilenamePart = "/test_SpecialPowersSandbox.html:";
|
||||
if (name === "SpecialPowers.loadChromeScript") {
|
||||
// Unfortunately, the original file name is not included;
|
||||
// the function name or a dummy value is used instead.
|
||||
expectedFilenamePart = "loadChromeScript anonymous function>";
|
||||
}
|
||||
if (!stack.includes(expectedFilenamePart)) {
|
||||
ok(false, `Stack does not contain ${expectedFilenamePart}: ${stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -68,8 +68,6 @@ add_task(async function () {
|
|||
[true, "Hmm - 1 == 1"],
|
||||
[true, "Yay. - true == true"],
|
||||
[false, "Boo!. - false == true"],
|
||||
[false, "Missing expected exception Rej_bad"],
|
||||
[true, "Rej_ok"],
|
||||
];
|
||||
|
||||
// Test that a representative variety of assertions work as expected, and
|
||||
|
@ -85,8 +83,6 @@ add_task(async function () {
|
|||
Assert.equal(1, 1, "Hmm");
|
||||
Assert.ok(true, "Yay.");
|
||||
Assert.ok(false, "Boo!.");
|
||||
await Assert.rejects(Promise.resolve(), /./, "Rej_bad");
|
||||
await Assert.rejects(Promise.reject(new Error("k")), /k/, "Rej_ok");
|
||||
});
|
||||
},
|
||||
"SpecialPowers.spawn-subframe": () => {
|
||||
|
@ -99,13 +95,11 @@ add_task(async function () {
|
|||
subFrame.addEventListener("load", resolve, { once: true });
|
||||
});
|
||||
|
||||
await SpecialPowers.spawn(subFrame, [], async () => {
|
||||
await SpecialPowers.spawn(subFrame, [], () => {
|
||||
Assert.equal(1, 2, "Thing");
|
||||
Assert.equal(1, 1, "Hmm");
|
||||
Assert.ok(true, "Yay.");
|
||||
Assert.ok(false, "Boo!.");
|
||||
await Assert.rejects(Promise.resolve(), /./, "Rej_bad");
|
||||
await Assert.rejects(Promise.reject(new Error("k")), /k/, "Rej_ok");
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -115,22 +109,17 @@ add_task(async function () {
|
|||
Assert.equal(1, 1, "Hmm");
|
||||
Assert.ok(true, "Yay.");
|
||||
Assert.ok(false, "Boo!.");
|
||||
await Assert.rejects(Promise.resolve(), /./, "Rej_bad");
|
||||
await Assert.rejects(Promise.reject(new Error("k")), /k/, "Rej_ok");
|
||||
});
|
||||
},
|
||||
"SpecialPowers.loadChromeScript": async () => {
|
||||
let script = SpecialPowers.loadChromeScript(() => {
|
||||
/* eslint-env mozilla/chrome-script */
|
||||
const resultPromise = (async () => {
|
||||
Assert.equal(1, 2, "Thing");
|
||||
Assert.equal(1, 1, "Hmm");
|
||||
Assert.ok(true, "Yay.");
|
||||
Assert.ok(false, "Boo!.");
|
||||
await Assert.rejects(Promise.resolve(), /./, "Rej_bad");
|
||||
await Assert.rejects(Promise.reject(new Error("k")), /k/, "Rej_ok");
|
||||
})();
|
||||
this.addMessageListener("ping", () => resultPromise);
|
||||
this.addMessageListener("ping", () => "pong");
|
||||
|
||||
Assert.equal(1, 2, "Thing");
|
||||
Assert.equal(1, 1, "Hmm");
|
||||
Assert.ok(true, "Yay.");
|
||||
Assert.ok(false, "Boo!.");
|
||||
});
|
||||
|
||||
await script.sendQuery("ping");
|
||||
|
@ -146,17 +135,5 @@ add_task(async function () {
|
|||
let results = diags.map(diag => [diag.passed, diag.msg]);
|
||||
|
||||
deepEqual(results, expected, "Got expected assertions");
|
||||
for (let { msg, stack } of diags) {
|
||||
ok(stack, `Got stack for: ${msg}`);
|
||||
let expectedFilenamePart = "/test_SpecialPowersSandbox.js:";
|
||||
if (name === "SpecialPowers.loadChromeScript") {
|
||||
// Unfortunately, the original file name is not included;
|
||||
// the function name or a dummy value is used instead.
|
||||
expectedFilenamePart = "loadChromeScript anonymous function>:";
|
||||
}
|
||||
if (!stack.includes(expectedFilenamePart)) {
|
||||
ok(false, `Stack does not contain ${expectedFilenamePart}: ${stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -112,8 +112,7 @@ function getMessage(error, prefix = "") {
|
|||
* actual: actual,
|
||||
* expected: expected,
|
||||
* operator: operator,
|
||||
* truncate: truncate,
|
||||
* stack: stack, // Optional, defaults to the current stack.
|
||||
* truncate: truncate
|
||||
* });
|
||||
*
|
||||
*/
|
||||
|
@ -124,7 +123,7 @@ Assert.AssertionError = function (options) {
|
|||
this.operator = options.operator;
|
||||
this.message = getMessage(this, options.message, options.truncate);
|
||||
// The part of the stack that comes from this module is not interesting.
|
||||
let stack = options.stack || Components.stack;
|
||||
let stack = Components.stack;
|
||||
do {
|
||||
stack = stack.asyncCaller || stack.caller;
|
||||
} while (
|
||||
|
@ -206,9 +205,6 @@ Assert.prototype.setReporter = function (reporterFunc) {
|
|||
* Operation qualifier used by the assertion method (ex: '==').
|
||||
* @param {boolean} [truncate=true]
|
||||
* Whether or not ``actual`` and ``expected`` should be truncated when printing.
|
||||
* @param {nsIStackFrame} [stack]
|
||||
* The stack trace including the caller of the assertion method,
|
||||
* if this cannot be inferred automatically (e.g. due to async callbacks).
|
||||
*/
|
||||
Assert.prototype.report = function (
|
||||
failed,
|
||||
|
@ -216,8 +212,7 @@ Assert.prototype.report = function (
|
|||
expected,
|
||||
message,
|
||||
operator,
|
||||
truncate = true,
|
||||
stack = null // Defaults to Components.stack in AssertionError.
|
||||
truncate = true
|
||||
) {
|
||||
// Although not ideal, we allow a "null" message due to the way some of the extension tests
|
||||
// work.
|
||||
|
@ -233,7 +228,6 @@ Assert.prototype.report = function (
|
|||
expected,
|
||||
operator,
|
||||
truncate,
|
||||
stack,
|
||||
});
|
||||
if (!this._reporter) {
|
||||
// If no custom reporter is set, throw the error.
|
||||
|
@ -519,33 +513,22 @@ Assert.prototype.throws = function (block, expected, message) {
|
|||
*/
|
||||
Assert.prototype.rejects = function (promise, expected, message) {
|
||||
checkExpectedArgument(this, "rejects", expected);
|
||||
const operator = undefined; // Should we use "rejects" here?
|
||||
const stack = Components.stack;
|
||||
return new Promise((resolve, reject) => {
|
||||
return promise
|
||||
.then(
|
||||
() => {
|
||||
() =>
|
||||
this.report(
|
||||
true,
|
||||
null,
|
||||
expected,
|
||||
"Missing expected exception " + message,
|
||||
operator,
|
||||
true,
|
||||
stack
|
||||
);
|
||||
// this.report() above should raise an AssertionError. If _reporter
|
||||
// has been overridden and doesn't throw an error, just resolve.
|
||||
// Otherwise we'll have a never-resolving promise that got stuck.
|
||||
resolve();
|
||||
},
|
||||
"Missing expected exception " + message
|
||||
),
|
||||
err => {
|
||||
if (!expectedException(err, expected)) {
|
||||
// TODO bug 1480075: Should report error instead of rejecting.
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
this.report(false, err, expected, message, operator, truncate, stack);
|
||||
this.report(false, err, expected, message);
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
|
|
|
@ -467,12 +467,4 @@ add_task(async function test_rejects() {
|
|||
await assert.rejects(Promise.reject("oh no"), /oh no/, "rejected");
|
||||
// Wrong message.
|
||||
await checkRejectsFails("something else", /oh no/);
|
||||
|
||||
// A non-rejection should also be an assertion failure:
|
||||
try {
|
||||
await assert.rejects(Promise.resolve(), /./, "ReSoLvEd");
|
||||
ok(false, "should have rejected");
|
||||
} catch (ex) {
|
||||
deepEqual(ex.message, "Missing expected exception ReSoLvEd");
|
||||
}
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче