Bug 1470455 - Add the 'expected' arguments to throws/rejects for devtools. r?jdescottes
MozReview-Commit-ID: 3HmVFhiA2FZ
--- a/devtools/client/shared/test/unit/test_suggestion-picker.js
+++ b/devtools/client/shared/test/unit/test_suggestion-picker.js
@@ -133,17 +133,17 @@ function ensureMostRelevantIndexProvided
const mostRelevantIndex = findMostRelevantCssPropertyIndex(items);
strictEqual(mostRelevantIndex, expectedIndex);
}
}
function ensureErrorThrownWithInvalidArguments() {
info("Running ensureErrorThrownWithInvalidTypeArgument()");
- const expectedError = "Please provide valid items and sortedItems arrays.";
+ const expectedError = /Please provide valid items and sortedItems arrays\./;
// No arguments passed.
- throws(() => findMostRelevantIndex(), expectedError);
+ Assert.throws(() => findMostRelevantIndex(), expectedError);
// Invalid arguments passed.
- throws(() => findMostRelevantIndex([]), expectedError);
- throws(() => findMostRelevantIndex(null, []), expectedError);
- throws(() => findMostRelevantIndex([], "string"), expectedError);
- throws(() => findMostRelevantIndex("string", []), expectedError);
+ Assert.throws(() => findMostRelevantIndex([]), expectedError);
+ Assert.throws(() => findMostRelevantIndex(null, []), expectedError);
+ Assert.throws(() => findMostRelevantIndex([], "string"), expectedError);
+ Assert.throws(() => findMostRelevantIndex("string", []), expectedError);
}
--- a/devtools/shared/heapsnapshot/tests/unit/test_SaveHeapSnapshot.js
+++ b/devtools/shared/heapsnapshot/tests/unit/test_SaveHeapSnapshot.js
@@ -13,50 +13,62 @@ function run_test() {
testBadParameters();
testGoodParameters();
do_test_finished();
}
function testBadParameters() {
- throws(() => ChromeUtils.saveHeapSnapshot(),
- "Should throw if arguments aren't passed in.");
+ Assert.throws(() => ChromeUtils.saveHeapSnapshot(),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Should throw if arguments aren't passed in.");
- throws(() => ChromeUtils.saveHeapSnapshot(null),
- "Should throw if boundaries isn't an object.");
+ Assert.throws(() => ChromeUtils.saveHeapSnapshot(null),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Should throw if boundaries isn't an object.");
- throws(() => ChromeUtils.saveHeapSnapshot({}),
- "Should throw if the boundaries object doesn't have any properties.");
+ Assert.throws(() => ChromeUtils.saveHeapSnapshot({}),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Should throw if the boundaries object doesn't have any properties.");
- throws(() => ChromeUtils.saveHeapSnapshot({ runtime: true,
- globals: [this] }),
- "Should throw if the boundaries object has more than one property.");
+ Assert.throws(() => ChromeUtils.saveHeapSnapshot({ runtime: true,
+ globals: [this] }),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Should throw if the boundaries object has more than one property.");
- throws(() => ChromeUtils.saveHeapSnapshot({ debugger: {} }),
- "Should throw if the debuggees object is not a Debugger object");
+ Assert.throws(() => ChromeUtils.saveHeapSnapshot({ debugger: {} }),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Should throw if the debuggees object is not a Debugger object");
- throws(() => ChromeUtils.saveHeapSnapshot({ globals: [{}] }),
- "Should throw if the globals array contains non-global objects.");
+ Assert.throws(() => ChromeUtils.saveHeapSnapshot({ globals: [{}] }),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Should throw if the globals array contains non-global objects.");
- throws(() => ChromeUtils.saveHeapSnapshot({ runtime: false }),
- "Should throw if runtime is supplied and is not true.");
+ Assert.throws(() => ChromeUtils.saveHeapSnapshot({ runtime: false }),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Should throw if runtime is supplied and is not true.");
- throws(() => ChromeUtils.saveHeapSnapshot({ globals: null }),
- "Should throw if globals is not an object.");
+ Assert.throws(() => ChromeUtils.saveHeapSnapshot({ globals: null }),
+ /TypeError:.*can't be converted to a sequence/,
+ "Should throw if globals is not an object.");
- throws(() => ChromeUtils.saveHeapSnapshot({ globals: {} }),
- "Should throw if globals is not an array.");
+ Assert.throws(() => ChromeUtils.saveHeapSnapshot({ globals: {} }),
+ /TypeError:.*can't be converted to a sequence/,
+ "Should throw if globals is not an array.");
- throws(() => ChromeUtils.saveHeapSnapshot({ debugger: Debugger.prototype }),
- "Should throw if debugger is the Debugger.prototype object.");
+ Assert.throws(() => ChromeUtils.saveHeapSnapshot({ debugger: Debugger.prototype }),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Should throw if debugger is the Debugger.prototype object.");
- throws(() => ChromeUtils.saveHeapSnapshot({ get globals() {
+ Assert.throws(() => ChromeUtils.saveHeapSnapshot({ get globals() {
return [this];
- } }), "Should throw if boundaries property is a getter.");
+ } }),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Should throw if boundaries property is a getter.");
}
const makeNewSandbox = () =>
Cu.Sandbox(CC("@mozilla.org/systemprincipal;1", "nsIPrincipal")());
function testGoodParameters() {
const sandbox = makeNewSandbox();
let dbg = new Debugger(sandbox);