Bug 1371733 - Propagate error message of assert.object; r?whimboo
The err argument to assert.object is currently being dropped, which
means we loose the specialised and the custom error message.
This patch propagates the error message like we do for all other
assertions in this module.
MozReview-Commit-ID: GwuBSbqKfk1
--- a/testing/marionette/assert.js
+++ b/testing/marionette/assert.js
@@ -298,17 +298,17 @@ assert.string = function (obj, msg = "")
*/
assert.object = function (obj, msg = "") {
msg = msg || error.pprint`Expected ${obj} to be an object`;
return assert.that(o => {
// unable to use instanceof because LHS and RHS may come from
// different globals
let s = Object.prototype.toString.call(o);
return s == "[object Object]" || s == "[object nsJSIID]";
- })(obj);
+ }, msg)(obj);
};
/**
* Asserts that |prop| is in |obj|.
*
* @param {?} prop
* Own property to test if is in |obj|.
* @param {?} obj
--- a/testing/marionette/test_assert.js
+++ b/testing/marionette/test_assert.js
@@ -131,16 +131,18 @@ add_test(function test_contentBrowser()
add_test(function test_object() {
assert.object({});
assert.object(new Object());
for (let typ of [42, "foo", true, null, undefined]) {
Assert.throws(() => assert.object(typ), InvalidArgumentError);
}
+ Assert.throws(() => assert.object(null, "custom"), /custom/);
+
run_next_test();
});
add_test(function test_in() {
assert.in("foo", {foo: 42});
for (let typ of [{}, 42, true, null, undefined]) {
Assert.throws(() => assert.in("foo", typ), InvalidArgumentError);
}