diff --git a/docs/_writing-tests/testharness-api.md b/docs/_writing-tests/testharness-api.md index 737804741bde0f7..92a9536b69030fd 100644 --- a/docs/_writing-tests/testharness-api.md +++ b/docs/_writing-tests/testharness-api.md @@ -700,6 +700,11 @@ Relies on `===`, distinguishes between `-0` and `+0`, and has a specific check f asserts that `expected` is an Array, and `actual` is equal to one of the members i.e. `expected.indexOf(actual) != -1` +### `assert_object_equals(actual, expected, description)` +asserts that `actual` is an object and not null and that all enumerable +properties on `actual` are own properties on `expected` with the same values, +recursing if the value is an object and not null. + ### `assert_array_equals(actual, expected, description)` asserts that `actual` and `expected` have the same length and the value of each indexed property in `actual` is the strictly equal diff --git a/resources/testharness.js b/resources/testharness.js index d4bf2920616fe3f..54379c665a85ae4 100644 --- a/resources/testharness.js +++ b/resources/testharness.js @@ -997,6 +997,9 @@ policies and contribution forms [3]. function assert_object_equals(actual, expected, description) { + assert(typeof actual === "object" && actual !== null, "assert_object_equals", description, + "value is ${actual}, expected object", + {actual: actual}); //This needs to be improved a great deal function check_equal(actual, expected, stack) {