Bug 1458235 - Fix various cases where Assert.ok or Assert.equal have been called wrongly. r?Gijs
MozReview-Commit-ID: Br3lKpKNVQJ
--- a/browser/modules/test/browser/head.js
+++ b/browser/modules/test/browser/head.js
@@ -48,17 +48,17 @@ function waitForCondition(condition, nex
* @param {String|Boolean|Number} expectedValue
* The expected value for the provided key in the scalar.
*/
function checkKeyedScalar(scalars, scalarName, key, expectedValue) {
Assert.ok(scalarName in scalars,
scalarName + " must be recorded.");
Assert.ok(key in scalars[scalarName],
scalarName + " must contain the '" + key + "' key.");
- Assert.ok(scalars[scalarName][key], expectedValue,
+ Assert.equal(scalars[scalarName][key], expectedValue,
scalarName + "['" + key + "'] must contain the expected value");
}
/**
* An helper that checks the value of a scalar if it's expected to be > 0,
* otherwise makes sure that the scalar it's not reported.
*
* @param {Object} scalars
--- a/js/xpconnect/tests/unit/test_allowWaivers.js
+++ b/js/xpconnect/tests/unit/test_allowWaivers.js
@@ -10,17 +10,17 @@ function checkWaivers(from, allowed) {
Assert.equal(from.eval('!!test.wrappedJSObject'), allowed);
Assert.equal(from.eval('XPCNativeWrapper.unwrap(test) !== test'), allowed);
// Make a sandbox with the same principal as |from|, but without any waiver
// restrictions, and make sure that the waiver does not transfer.
var friend = new Cu.Sandbox(Cu.getObjectPrincipal(from));
friend.test = from.test;
friend.eval('var waived = test.wrappedJSObject;');
- Assert.ok(friend.eval('waived.f()'), 42);
+ Assert.equal(friend.eval('waived.f()'), 42);
friend.from = from;
friend.eval('from.waived = waived');
Assert.equal(from.eval('!!waived.f'), allowed);
}
function run_test() {
checkWaivers(new Cu.Sandbox('http://example.com'), true);
checkWaivers(new Cu.Sandbox('http://example.com', {allowWaivers: false}), false);
--- a/js/xpconnect/tests/unit/test_exportFunction.js
+++ b/js/xpconnect/tests/unit/test_exportFunction.js
@@ -143,10 +143,10 @@ function run_test() {
Cu.evalInSandbox("(" + function () {
imported2(this, 42, tobecloned, native, mixed);
}.toSource() + ")()", subsb);
Cu.evalInSandbox("(" + function() {
checkIfCalled();
}.toSource() + ")()", epsb);
- Assert.ok(wasCalled, true);
+ Assert.ok(wasCalled);
}
--- a/netwerk/cookie/test/unit/test_bug1321912.js
+++ b/netwerk/cookie/test/unit/test_bug1321912.js
@@ -47,17 +47,17 @@ conn.executeSimpleSQL("INSERT INTO moz_c
"'foo.com', '.foo.com', 'foo', 'bar=baz', '/', " +
now + ", " + now + ", " + now + ", 1, 1)");
// Now start the cookie service, and then check the fields in the table.
// Get sessionEnumerator to wait for the initialization in cookie thread
const enumerator = Cc["@mozilla.org/cookieService;1"].
getService(Ci.nsICookieManager).sessionEnumerator;
-Assert.ok(conn.schemaVersion, 8);
+Assert.equal(conn.schemaVersion, 9);
let stmt = conn.createStatement("SELECT sql FROM sqlite_master " +
"WHERE type = 'table' AND " +
" name = 'moz_cookies'");
try {
Assert.ok(stmt.executeStep());
let sql = stmt.getString(0);
Assert.equal(sql.indexOf("appId"), -1);
} finally {
--- a/netwerk/test/httpserver/test/test_host.js
+++ b/netwerk/test/httpserver/test/test_host.js
@@ -104,17 +104,17 @@ function run_test_2()
Assert.ok(!id.has("http", "127.0.0.1", FAKE_PORT_ONE));
Assert.ok(!id.has("http", "localhost", FAKE_PORT_ONE));
srv.start(FAKE_PORT_TWO);
// We should have picked up http://localhost:8889 as our primary location now
// that we've restarted.
Assert.equal(id.primaryScheme, "http");
- Assert.equal(id.primaryHost, "localhost", FAKE_PORT_TWO);
+ Assert.equal(id.primaryHost, "localhost");
Assert.equal(id.primaryPort, FAKE_PORT_TWO);
Assert.ok(!id.has("http", "localhost", FAKE_PORT_ONE));
Assert.ok(!id.has("http", "127.0.0.1", FAKE_PORT_ONE));
Assert.ok(id.has("http", "localhost", FAKE_PORT_TWO));
Assert.ok(id.has("http", "127.0.0.1", FAKE_PORT_TWO));
// Now we're going to see what happens when we shut down with a primary
// location that wasn't a default. That location should persist, and the
--- a/services/sync/tests/unit/test_prefs_store.js
+++ b/services/sync/tests/unit/test_prefs_store.js
@@ -34,17 +34,17 @@ add_task(async function run_test() {
let prefs = new Preferences();
try {
_("The GUID corresponds to XUL App ID.");
let allIDs = await store.getAllIDs();
let ids = Object.keys(allIDs);
Assert.equal(ids.length, 1);
Assert.equal(ids[0], PREFS_GUID);
- Assert.ok(allIDs[PREFS_GUID], true);
+ Assert.ok(allIDs[PREFS_GUID]);
Assert.ok((await store.itemExists(PREFS_GUID)));
Assert.equal(false, (await store.itemExists("random-gibberish")));
_("Unknown prefs record is created as deleted.");
let record = await store.createRecord("random-gibberish", "prefs");
Assert.ok(record.deleted);
--- a/widget/tests/unit/test_taskbar_jumplistitems.js
+++ b/widget/tests/unit/test_taskbar_jumplistitems.js
@@ -177,17 +177,17 @@ function test_shortcuts()
}
async function test_jumplist()
{
// Jump lists can't register links unless the application is the default
// protocol handler for the protocol of the link, so we skip off testing
// those in these tests. We'll init the jump list for the xpc shell harness,
// add a task item, and commit it.
-
+
// not compiled in
if (Ci.nsIWinTaskbar == null)
return;
var taskbar = Cc["@mozilla.org/windows-taskbar;1"]
.getService(Ci.nsIWinTaskbar);
var builder = taskbar.createJumpListBuilder();
@@ -195,17 +195,17 @@ async function test_jumplist()
Assert.notEqual(builder, null);
// Win7 and up only
try {
var sysInfo = Cc["@mozilla.org/system-info;1"].
getService(Ci.nsIPropertyBag2);
var ver = parseFloat(sysInfo.getProperty("version"));
if (ver < 6.1) {
- Assert.ok(!builder.available, false);
+ Assert.ok(!builder.available);
return;
}
} catch (ex) { }
Assert.ok(taskbar.available);
builder.deleteActiveList();