зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1421992 - Hand written cleanup patch to make tests pass after removing obsolete xpcshell functions. r=Gijs,ochameau a=Aryx
This commit is contained in:
Родитель
0f55cd45be
Коммит
22c55eb7b7
|
@ -41,12 +41,12 @@ add_task(async function test_isAddressField_isCreditCardField() {
|
|||
|
||||
for (let fieldName of Object.keys(TEST_CASES)) {
|
||||
info("Starting testcase: " + fieldName);
|
||||
let info = TEST_CASES[fieldName];
|
||||
let field = TEST_CASES[fieldName];
|
||||
Assert.equal(FormAutofillUtils.isAddressField(fieldName),
|
||||
info.isAddressField,
|
||||
field.isAddressField,
|
||||
"isAddressField");
|
||||
Assert.equal(FormAutofillUtils.isCreditCardField(fieldName),
|
||||
info.isCreditCardField,
|
||||
field.isCreditCardField,
|
||||
"isCreditCardField");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -12,21 +12,6 @@
|
|||
// Common utility functions for working with Redux stores. The file is meant
|
||||
// to be safe to load in both mochitest and xpcshell environments.
|
||||
|
||||
/**
|
||||
* A logging function that can be used from xpcshell and browser mochitest
|
||||
* environments.
|
||||
*/
|
||||
function commonLog(message) {
|
||||
let log;
|
||||
if (Services && Services.appinfo && Services.appinfo.name &&
|
||||
Services.appinfo.name == "Firefox") {
|
||||
log = info;
|
||||
} else {
|
||||
log = do_print;
|
||||
}
|
||||
log(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait until the store has reached a state that matches the predicate.
|
||||
* @param Store store
|
||||
|
@ -41,10 +26,10 @@ function waitUntilState(store, predicate) {
|
|||
let deferred = defer();
|
||||
let unsubscribe = store.subscribe(check);
|
||||
|
||||
commonLog(`Waiting for state predicate "${predicate}"`);
|
||||
info(`Waiting for state predicate "${predicate}"`);
|
||||
function check() {
|
||||
if (predicate(store.getState())) {
|
||||
commonLog(`Found state predicate "${predicate}"`);
|
||||
info(`Found state predicate "${predicate}"`);
|
||||
unsubscribe();
|
||||
deferred.resolve();
|
||||
}
|
||||
|
@ -71,11 +56,11 @@ function waitUntilAction(store, actionType) {
|
|||
let history = store.history;
|
||||
let index = history.length;
|
||||
|
||||
commonLog(`Waiting for action "${actionType}"`);
|
||||
info(`Waiting for action "${actionType}"`);
|
||||
function check() {
|
||||
let action = history[index++];
|
||||
if (action && action.type === actionType) {
|
||||
commonLog(`Found action "${actionType}"`);
|
||||
info(`Found action "${actionType}"`);
|
||||
unsubscribe();
|
||||
deferred.resolve(store.getState());
|
||||
}
|
||||
|
|
|
@ -132,8 +132,8 @@ function testParseTimingFunction() {
|
|||
"correct with comments and whitespace");
|
||||
}
|
||||
|
||||
function do_check_throws(cb, info) {
|
||||
info(info);
|
||||
function do_check_throws(cb, details) {
|
||||
info(details);
|
||||
|
||||
let hasThrown = false;
|
||||
try {
|
||||
|
|
|
@ -10,11 +10,11 @@ const { console } = Cu.import("resource://gre/modules/Console.jsm", {});
|
|||
this.validator = require("devtools/client/shared/vendor/stringvalidator/validator");
|
||||
|
||||
function describe(suite, testFunc) {
|
||||
do_print(`\n Test suite: ${suite}`.toUpperCase());
|
||||
info(`\n Test suite: ${suite}`.toUpperCase());
|
||||
testFunc();
|
||||
}
|
||||
|
||||
function it(description, testFunc) {
|
||||
do_print(`\n - ${description}:\n`.toUpperCase());
|
||||
info(`\n - ${description}:\n`.toUpperCase());
|
||||
testFunc();
|
||||
}
|
||||
|
|
|
@ -593,45 +593,6 @@ StubTransport.prototype.ready = function () {};
|
|||
StubTransport.prototype.send = function () {};
|
||||
StubTransport.prototype.close = function () {};
|
||||
|
||||
function executeSoon(func) {
|
||||
Services.tm.dispatchToMainThread({
|
||||
run: DevToolsUtils.makeInfallible(func)
|
||||
});
|
||||
}
|
||||
|
||||
// The do_check_* family of functions expect their last argument to be an
|
||||
// optional stack object. Unfortunately, most tests actually pass a in a string
|
||||
// containing an error message instead, which causes error reporting to break if
|
||||
// strict warnings as errors is turned on. To avoid this, we wrap these
|
||||
// functions here below to ensure the correct number of arguments is passed.
|
||||
//
|
||||
// TODO: Remove this once bug 906232 is resolved
|
||||
//
|
||||
var do_check_true_old = do_check_true;
|
||||
var do_check_true = function (condition) {
|
||||
do_check_true_old(condition);
|
||||
};
|
||||
|
||||
var do_check_false_old = do_check_false;
|
||||
var do_check_false = function (condition) {
|
||||
do_check_false_old(condition);
|
||||
};
|
||||
|
||||
var do_check_eq_old = do_check_eq;
|
||||
var do_check_eq = function (left, right) {
|
||||
do_check_eq_old(left, right);
|
||||
};
|
||||
|
||||
var do_check_neq_old = do_check_neq;
|
||||
var do_check_neq = function (left, right) {
|
||||
do_check_neq_old(left, right);
|
||||
};
|
||||
|
||||
var do_check_matches_old = do_check_matches;
|
||||
var do_check_matches = function (pattern, value) {
|
||||
do_check_matches_old(pattern, value);
|
||||
};
|
||||
|
||||
// Create async version of the object where calling each method
|
||||
// is equivalent of calling it with asyncall. Mainly useful for
|
||||
// destructuring objects with methods that take callbacks.
|
||||
|
@ -650,7 +611,7 @@ const Test = task => () => {
|
|||
run_next_test();
|
||||
};
|
||||
|
||||
const assert = do_check_true;
|
||||
const assert = Assert.ok.bind(Assert);
|
||||
|
||||
/**
|
||||
* Create a promise that is resolved on the next occurence of the given event.
|
||||
|
|
|
@ -96,7 +96,7 @@ function tryActors(reachables, completed) {
|
|||
}
|
||||
|
||||
if (--count == 0) {
|
||||
do_execute_soon(completed, "tryActors callback " + completed.name);
|
||||
executeSoon(completed, "tryActors callback " + completed.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ function addTestingFunctionsToGlobal(global) {
|
|||
`
|
||||
);
|
||||
if (!global.print) {
|
||||
global.print = do_print;
|
||||
global.print = info;
|
||||
}
|
||||
if (!global.newGlobal) {
|
||||
global.newGlobal = newGlobal;
|
||||
|
|
|
@ -560,7 +560,7 @@ function do_single_test_run() {
|
|||
expectKeywordLookup = expectKeywordLookup && (!affectedByDNSForSingleHosts || !gSingleWordHostLookup);
|
||||
|
||||
for (let flags of flagInputs) {
|
||||
let info;
|
||||
let URIInfo;
|
||||
let fixupURIOnly = null;
|
||||
try {
|
||||
fixupURIOnly = urifixup.createFixupURI(testInput, flags);
|
||||
|
@ -570,7 +570,7 @@ function do_single_test_run() {
|
|||
}
|
||||
|
||||
try {
|
||||
info = urifixup.getFixupURIInfo(testInput, flags);
|
||||
URIInfo = urifixup.getFixupURIInfo(testInput, flags);
|
||||
} catch (ex) {
|
||||
// Both APIs should return an error in the same cases.
|
||||
info("Caught exception: " + ex);
|
||||
|
@ -583,51 +583,51 @@ function do_single_test_run() {
|
|||
" (host lookup for single words: " + (gSingleWordHostLookup ? "yes" : "no") + ")");
|
||||
|
||||
// Both APIs should then also be using the same spec.
|
||||
Assert.equal(!!fixupURIOnly, !!info.preferredURI);
|
||||
Assert.equal(!!fixupURIOnly, !!URIInfo.preferredURI);
|
||||
if (fixupURIOnly)
|
||||
Assert.equal(fixupURIOnly.spec, info.preferredURI.spec);
|
||||
Assert.equal(fixupURIOnly.spec, URIInfo.preferredURI.spec);
|
||||
|
||||
let isFileURL = expectedFixedURI && expectedFixedURI.startsWith("file");
|
||||
|
||||
// Check the fixedURI:
|
||||
let makeAlternativeURI = flags & urifixup.FIXUP_FLAGS_MAKE_ALTERNATE_URI;
|
||||
if (makeAlternativeURI && alternativeURI != null) {
|
||||
Assert.equal(info.fixedURI.spec, alternativeURI);
|
||||
Assert.equal(URIInfo.fixedURI.spec, alternativeURI);
|
||||
} else {
|
||||
Assert.equal(info.fixedURI && info.fixedURI.spec, expectedFixedURI);
|
||||
Assert.equal(URIInfo.fixedURI && URIInfo.fixedURI.spec, expectedFixedURI);
|
||||
}
|
||||
|
||||
// Check booleans on input:
|
||||
let couldDoKeywordLookup = flags & urifixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP;
|
||||
Assert.equal(!!info.keywordProviderName, couldDoKeywordLookup && expectKeywordLookup);
|
||||
Assert.equal(info.fixupChangedProtocol, expectProtocolChange);
|
||||
Assert.equal(info.fixupCreatedAlternateURI, makeAlternativeURI && alternativeURI != null);
|
||||
Assert.equal(!!URIInfo.keywordProviderName, couldDoKeywordLookup && expectKeywordLookup);
|
||||
Assert.equal(URIInfo.fixupChangedProtocol, expectProtocolChange);
|
||||
Assert.equal(URIInfo.fixupCreatedAlternateURI, makeAlternativeURI && alternativeURI != null);
|
||||
|
||||
// Check the preferred URI
|
||||
if (couldDoKeywordLookup) {
|
||||
if (expectKeywordLookup) {
|
||||
if (!inWhitelist) {
|
||||
let urlparamInput = encodeURIComponent(sanitize(testInput)).replace(/%20/g, "+");
|
||||
// If the input starts with `?`, then info.preferredURI.spec will omit it
|
||||
// If the input starts with `?`, then URIInfo.preferredURI.spec will omit it
|
||||
// In order to test this behaviour, remove `?` only if it is the first character
|
||||
if (urlparamInput.startsWith("%3F")) {
|
||||
urlparamInput = urlparamInput.replace("%3F", "");
|
||||
}
|
||||
let searchURL = kSearchEngineURL.replace("{searchTerms}", urlparamInput);
|
||||
let spec = info.preferredURI.spec.replace(/%27/g, "'");
|
||||
let spec = URIInfo.preferredURI.spec.replace(/%27/g, "'");
|
||||
Assert.equal(spec, searchURL);
|
||||
} else {
|
||||
Assert.equal(info.preferredURI, null);
|
||||
Assert.equal(URIInfo.preferredURI, null);
|
||||
}
|
||||
} else {
|
||||
Assert.equal(info.preferredURI.spec, info.fixedURI.spec);
|
||||
Assert.equal(URIInfo.preferredURI.spec, URIInfo.fixedURI.spec);
|
||||
}
|
||||
} else {
|
||||
// In these cases, we should never be doing a keyword lookup and
|
||||
// the fixed URI should be preferred:
|
||||
Assert.equal(info.preferredURI.spec, info.fixedURI.spec);
|
||||
Assert.equal(URIInfo.preferredURI.spec, URIInfo.fixedURI.spec);
|
||||
}
|
||||
Assert.equal(sanitize(testInput), info.originalInput);
|
||||
Assert.equal(sanitize(testInput), URIInfo.originalInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ add_task(async function() {
|
|||
webNav.loadURI("data:text/html,", webNav.LOAD_FLAGS_NONE, null, null, null);
|
||||
|
||||
// Return to the event loop so the load can begin.
|
||||
await new Promise(do_execute_soon);
|
||||
await new Promise(executeSoon);
|
||||
|
||||
// This causes a failed assertion rather than an exception on debug
|
||||
// builds.
|
||||
|
|
|
@ -88,8 +88,7 @@ function test(func, msg) {
|
|||
|
||||
function run_test() {
|
||||
tests.forEach(function(t) {
|
||||
do_print("test group: " + t.msg,
|
||||
{source_file: t.filename});
|
||||
info(`test group: ${t.msg}, {source_file: ${t.filename}}`);
|
||||
t.func();
|
||||
});
|
||||
};
|
||||
|
|
|
@ -28,18 +28,10 @@ function isnot(a, b, msg) {
|
|||
Assert.notEqual(a, b, Components.stack.caller);
|
||||
}
|
||||
|
||||
function executeSoon(fun) {
|
||||
executeSoon(fun);
|
||||
}
|
||||
|
||||
function todo(condition, name, diag) {
|
||||
todo_check_true(condition, Components.stack.caller);
|
||||
}
|
||||
|
||||
function info(name, message) {
|
||||
info(name);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
runTest();
|
||||
}
|
||||
|
|
|
@ -19,11 +19,6 @@ function ok(cond, msg)
|
|||
Assert.ok(!!cond, Components.stack.caller);
|
||||
}
|
||||
|
||||
function info(name, message)
|
||||
{
|
||||
info(name);
|
||||
}
|
||||
|
||||
function run_test()
|
||||
{
|
||||
runTest();
|
||||
|
|
|
@ -12,7 +12,7 @@ function addTestingFunctionsToGlobal(global) {
|
|||
for (let k in testingFunctions) {
|
||||
global[k] = testingFunctions[k];
|
||||
}
|
||||
global.print = do_print;
|
||||
global.print = info;
|
||||
global.newGlobal = newGlobal;
|
||||
addDebuggerToGlobal(global);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ function run_test() {
|
|||
var Cu = Components.utils;
|
||||
var sb = new Cu.Sandbox('http://www.example.com',
|
||||
{ wantGlobalProperties: ["URLSearchParams"] });
|
||||
sb.do_check_eq = do_check_eq;
|
||||
Cu.evalInSandbox('do_check_eq(new URLSearchParams("one=1&two=2").get("one"), "1");',
|
||||
sb.equal = equal;
|
||||
Cu.evalInSandbox('equal(new URLSearchParams("one=1&two=2").get("one"), "1");',
|
||||
sb);
|
||||
Cu.importGlobalProperties(["URLSearchParams"]);
|
||||
Assert.equal(new URLSearchParams("one=1&two=2").get("one"), "1");
|
||||
|
|
|
@ -7,6 +7,6 @@ function run_test() {
|
|||
s.a = [];
|
||||
s.Cu = Components.utils;
|
||||
s.C = Components;
|
||||
s.do_check_neq = do_check_neq;
|
||||
Components.utils.evalInSandbox("do_check_neq(Cu.import, undefined);", s);
|
||||
s.notEqual = notEqual;
|
||||
Components.utils.evalInSandbox("notEqual(Cu.import, undefined);", s);
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@ function run_test() {
|
|||
sb.ok = ok;
|
||||
Cu.evalInSandbox('ok(this.crypto);', sb);
|
||||
Cu.evalInSandbox('ok(this.crypto.subtle);', sb);
|
||||
sb.do_check_eq = do_check_eq;
|
||||
sb.equal = equal;
|
||||
let innerPromise = new Promise(r => (sb.test_done = r));
|
||||
Cu.evalInSandbox('crypto.subtle.digest("SHA-256", ' +
|
||||
' new TextEncoder("utf-8").encode("abc"))' +
|
||||
' .then(h => do_check_eq(new Uint16Array(h)[0], 30906))' +
|
||||
' .then(h => equal(new Uint16Array(h)[0], 30906))' +
|
||||
' .then(test_done);', sb);
|
||||
|
||||
Cu.importGlobalProperties(["crypto"]);
|
||||
|
|
|
@ -2,8 +2,8 @@ function run_test() {
|
|||
var Cu = Components.utils;
|
||||
var sb = new Cu.Sandbox('http://www.example.com',
|
||||
{ wantGlobalProperties: ["CSS"] });
|
||||
sb.do_check_eq = do_check_eq;
|
||||
Cu.evalInSandbox('do_check_eq(CSS.escape("$"), "\\\\$");',
|
||||
sb.equal = equal;
|
||||
Cu.evalInSandbox('equal(CSS.escape("$"), "\\\\$");',
|
||||
sb);
|
||||
Cu.importGlobalProperties(["CSS"]);
|
||||
Assert.equal(CSS.escape("$"), "\\$");
|
||||
|
|
|
@ -5,8 +5,8 @@ function run_test() {
|
|||
var Cu = Components.utils;
|
||||
var sb = new Cu.Sandbox('http://www.example.com',
|
||||
{ wantGlobalProperties: ["FileReader"] });
|
||||
sb.do_check_true = do_check_true;
|
||||
Cu.evalInSandbox('do_check_true((new FileReader()) instanceof FileReader);',
|
||||
sb.ok = ok;
|
||||
Cu.evalInSandbox('ok((new FileReader()) instanceof FileReader);',
|
||||
sb);
|
||||
Cu.importGlobalProperties(["FileReader"]);
|
||||
Assert.ok((new FileReader()) instanceof FileReader);
|
||||
|
|
|
@ -19,11 +19,10 @@ function run_test() {
|
|||
|
||||
Assert.ok(!Cu.isProxy(sb));
|
||||
|
||||
sb.do_check_true = do_check_true;
|
||||
sb.do_check_false = do_check_false;
|
||||
sb.ok = ok;
|
||||
sb.p = p;
|
||||
Cu.evalInSandbox('do_check_true(isProxy(p));' +
|
||||
'do_check_false(isProxy({}));' +
|
||||
'do_check_false(isProxy(42));',
|
||||
Cu.evalInSandbox('ok(isProxy(p));' +
|
||||
'ok(!isProxy({}));' +
|
||||
'ok(!isProxy(42));',
|
||||
sb);
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ add_task(async function() {
|
|||
let Cu = Components.utils;
|
||||
let sb = new Cu.Sandbox('http://www.example.com',
|
||||
{ wantGlobalProperties: ["MessageChannel"] });
|
||||
sb.do_check_true = do_check_true;
|
||||
Cu.evalInSandbox('do_check_true((new MessageChannel()) instanceof MessageChannel);',
|
||||
sb.ok = ok;
|
||||
Cu.evalInSandbox('ok((new MessageChannel()) instanceof MessageChannel);',
|
||||
sb);
|
||||
Cu.evalInSandbox('do_check_true((new MessageChannel()).port1 instanceof MessagePort);',
|
||||
Cu.evalInSandbox('ok((new MessageChannel()).port1 instanceof MessagePort);',
|
||||
sb);
|
||||
|
||||
Cu.importGlobalProperties(["MessageChannel"]);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
function run_test() {
|
||||
var Cu = Components.utils;
|
||||
sb = new Cu.Sandbox('http://www.example.com');
|
||||
sb.do_check_eq = do_check_eq;
|
||||
Cu.evalInSandbox('do_check_eq(typeof new Promise(function(resolve){resolve();}), "object");',
|
||||
sb.equal = equal;
|
||||
Cu.evalInSandbox('equal(typeof new Promise(function(resolve){resolve();}), "object");',
|
||||
sb);
|
||||
Assert.equal(typeof new Promise(function(resolve){resolve();}), "object");
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ function run_test() {
|
|||
var Cu = Components.utils;
|
||||
sb = new Cu.Sandbox('http://www.example.com',
|
||||
{ wantGlobalProperties: ["atob", "btoa"] });
|
||||
sb.do_check_eq = do_check_eq;
|
||||
sb.equal = equal;
|
||||
Cu.evalInSandbox('var dummy = "Dummy test.";' +
|
||||
'do_check_eq(dummy, atob(btoa(dummy)));' +
|
||||
'do_check_eq(btoa("budapest"), "YnVkYXBlc3Q=");',
|
||||
'equal(dummy, atob(btoa(dummy)));' +
|
||||
'equal(btoa("budapest"), "YnVkYXBlc3Q=");',
|
||||
sb);
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ function run_test() {
|
|||
var Cu = Components.utils;
|
||||
sb = new Cu.Sandbox('http://www.example.com',
|
||||
{ wantGlobalProperties: ["TextDecoder", "TextEncoder"] });
|
||||
sb.do_check_eq = do_check_eq;
|
||||
Cu.evalInSandbox('do_check_eq(new TextDecoder().encoding, "utf-8");' +
|
||||
'do_check_eq(new TextEncoder().encoding, "utf-8");',
|
||||
sb.equal = equal;
|
||||
Cu.evalInSandbox('equal(new TextDecoder().encoding, "utf-8");' +
|
||||
'equal(new TextEncoder().encoding, "utf-8");',
|
||||
sb);
|
||||
Cu.importGlobalProperties(["TextDecoder", "TextEncoder"]);
|
||||
Assert.equal(new TextDecoder().encoding, "utf-8");
|
||||
|
|
|
@ -2,8 +2,8 @@ function run_test() {
|
|||
var Cu = Components.utils;
|
||||
var sb = new Cu.Sandbox('http://www.example.com',
|
||||
{ wantGlobalProperties: ["URL"] });
|
||||
sb.do_check_eq = do_check_eq;
|
||||
Cu.evalInSandbox('do_check_eq(new URL("http://www.example.com").host, "www.example.com");',
|
||||
sb.equal = equal;
|
||||
Cu.evalInSandbox('equal(new URL("http://www.example.com").host, "www.example.com");',
|
||||
sb);
|
||||
Cu.importGlobalProperties(["URL"]);
|
||||
Assert.equal(new URL("http://www.example.com").host, "www.example.com");
|
||||
|
|
|
@ -322,11 +322,11 @@ function run_test() {
|
|||
|
||||
// former prefs should have been replaced/lost
|
||||
do_check_throws(function() {
|
||||
do_check_eq(pb.getBoolPref("ReadPref.bool"));}, Cr.NS_ERROR_UNEXPECTED);
|
||||
pb.getBoolPref("ReadPref.bool");}, Cr.NS_ERROR_UNEXPECTED);
|
||||
do_check_throws(function() {
|
||||
do_check_eq(pb.getIntPref("ReadPref.int"));}, Cr.NS_ERROR_UNEXPECTED);
|
||||
pb.getIntPref("ReadPref.int");}, Cr.NS_ERROR_UNEXPECTED);
|
||||
do_check_throws(function() {
|
||||
do_check_eq(pb.getCharPref("ReadPref.char"));}, Cr.NS_ERROR_UNEXPECTED);
|
||||
pb.getCharPref("ReadPref.char");}, Cr.NS_ERROR_UNEXPECTED);
|
||||
|
||||
// loaded prefs should read ok.
|
||||
pb = ps.getBranch("testPref.");
|
||||
|
|
|
@ -250,12 +250,8 @@ function do_info(text, stack) {
|
|||
// when we ignore the ref.
|
||||
//
|
||||
// The third argument is optional. If the client passes a third argument
|
||||
// (e.g. todo_check_true), we'll use that in lieu of do_check_true.
|
||||
function do_check_uri_eq(aURI1, aURI2, aCheckTrueFunc) {
|
||||
if (!aCheckTrueFunc) {
|
||||
aCheckTrueFunc = do_check_true;
|
||||
}
|
||||
|
||||
// (e.g. todo_check_true), we'll use that in lieu of ok.
|
||||
function do_check_uri_eq(aURI1, aURI2, aCheckTrueFunc = ok) {
|
||||
do_info("(uri equals check: '" + aURI1.spec + "' == '" + aURI2.spec + "')");
|
||||
aCheckTrueFunc(aURI1.equals(aURI2));
|
||||
do_info("(uri equals check: '" + aURI2.spec + "' == '" + aURI1.spec + "')");
|
||||
|
@ -264,7 +260,7 @@ function do_check_uri_eq(aURI1, aURI2, aCheckTrueFunc) {
|
|||
// (Only take the extra step of testing 'equalsExceptRef' when we expect the
|
||||
// URIs to really be equal. In 'todo' cases, the URIs may or may not be
|
||||
// equal when refs are ignored - there's no way of knowing in general.)
|
||||
if (aCheckTrueFunc == do_check_true) {
|
||||
if (aCheckTrueFunc == ok) {
|
||||
do_check_uri_eqExceptRef(aURI1, aURI2, aCheckTrueFunc);
|
||||
}
|
||||
}
|
||||
|
@ -272,12 +268,8 @@ function do_check_uri_eq(aURI1, aURI2, aCheckTrueFunc) {
|
|||
// Checks that the URIs satisfy equalsExceptRef(), in both possible orderings.
|
||||
//
|
||||
// The third argument is optional. If the client passes a third argument
|
||||
// (e.g. todo_check_true), we'll use that in lieu of do_check_true.
|
||||
function do_check_uri_eqExceptRef(aURI1, aURI2, aCheckTrueFunc) {
|
||||
if (!aCheckTrueFunc) {
|
||||
aCheckTrueFunc = do_check_true;
|
||||
}
|
||||
|
||||
// (e.g. todo_check_true), we'll use that in lieu of ok.
|
||||
function do_check_uri_eqExceptRef(aURI1, aURI2, aCheckTrueFunc = ok) {
|
||||
do_info("(uri equalsExceptRef check: '" +
|
||||
aURI1.spec + "' == '" + aURI2.spec + "')");
|
||||
aCheckTrueFunc(aURI1.equalsExceptRef(aURI2));
|
||||
|
|
|
@ -366,12 +366,8 @@ function do_info(text, stack) {
|
|||
// when we ignore the ref.
|
||||
//
|
||||
// The third argument is optional. If the client passes a third argument
|
||||
// (e.g. todo_check_true), we'll use that in lieu of do_check_true.
|
||||
function do_check_uri_eq(aURI1, aURI2, aCheckTrueFunc) {
|
||||
if (!aCheckTrueFunc) {
|
||||
aCheckTrueFunc = do_check_true;
|
||||
}
|
||||
|
||||
// (e.g. todo_check_true), we'll use that in lieu of ok.
|
||||
function do_check_uri_eq(aURI1, aURI2, aCheckTrueFunc = ok) {
|
||||
do_info("(uri equals check: '" + aURI1.spec + "' == '" + aURI2.spec + "')");
|
||||
aCheckTrueFunc(aURI1.equals(aURI2));
|
||||
do_info("(uri equals check: '" + aURI2.spec + "' == '" + aURI1.spec + "')");
|
||||
|
@ -380,7 +376,7 @@ function do_check_uri_eq(aURI1, aURI2, aCheckTrueFunc) {
|
|||
// (Only take the extra step of testing 'equalsExceptRef' when we expect the
|
||||
// URIs to really be equal. In 'todo' cases, the URIs may or may not be
|
||||
// equal when refs are ignored - there's no way of knowing in general.)
|
||||
if (aCheckTrueFunc == do_check_true) {
|
||||
if (aCheckTrueFunc == ok) {
|
||||
do_check_uri_eqExceptRef(aURI1, aURI2, aCheckTrueFunc);
|
||||
}
|
||||
}
|
||||
|
@ -388,12 +384,8 @@ function do_check_uri_eq(aURI1, aURI2, aCheckTrueFunc) {
|
|||
// Checks that the URIs satisfy equalsExceptRef(), in both possible orderings.
|
||||
//
|
||||
// The third argument is optional. If the client passes a third argument
|
||||
// (e.g. todo_check_true), we'll use that in lieu of do_check_true.
|
||||
function do_check_uri_eqExceptRef(aURI1, aURI2, aCheckTrueFunc) {
|
||||
if (!aCheckTrueFunc) {
|
||||
aCheckTrueFunc = do_check_true;
|
||||
}
|
||||
|
||||
// (e.g. todo_check_true), we'll use that in lieu of ok.
|
||||
function do_check_uri_eqExceptRef(aURI1, aURI2, aCheckTrueFunc = ok) {
|
||||
do_info("(uri equalsExceptRef check: '" +
|
||||
aURI1.spec + "' == '" + aURI2.spec + "')");
|
||||
aCheckTrueFunc(aURI1.equalsExceptRef(aURI2));
|
||||
|
|
|
@ -666,8 +666,8 @@ add_task(async function test_clone_copies_pragmas() {
|
|||
PRAGMAS.forEach(function(pragma) {
|
||||
let stmt = db2.createStatement("PRAGMA " + pragma.name);
|
||||
Assert.ok(stmt.executeStep());
|
||||
let validate = pragma.copied ? do_check_eq : do_check_neq;
|
||||
validate(pragma.value, stmt.getInt32(0));
|
||||
let validate = pragma.copied ? "equal" : "notEqual";
|
||||
Assert[validate](pragma.value, stmt.getInt32(0));
|
||||
stmt.finalize();
|
||||
});
|
||||
|
||||
|
@ -708,8 +708,8 @@ add_task(async function test_readonly_clone_copies_pragmas() {
|
|||
PRAGMAS.forEach(function(pragma) {
|
||||
let stmt = db2.createStatement("PRAGMA " + pragma.name);
|
||||
Assert.ok(stmt.executeStep());
|
||||
let validate = pragma.copied ? do_check_eq : do_check_neq;
|
||||
validate(pragma.value, stmt.getInt32(0));
|
||||
let validate = pragma.copied ? "equal" : "notEqual";
|
||||
Assert[validate](pragma.value, stmt.getInt32(0));
|
||||
stmt.finalize();
|
||||
});
|
||||
|
||||
|
|
|
@ -23,37 +23,35 @@ function do_throw(message, stack) {
|
|||
throw message;
|
||||
}
|
||||
|
||||
function do_check_neq(left, right, stack) {
|
||||
var Assert = {
|
||||
notEqual(left, right, stack) {
|
||||
if (left == right) {
|
||||
var text = "do_check_neq failed";
|
||||
var text = "Assert.notEqual failed";
|
||||
try {
|
||||
text += ": " + left + " == " + right;
|
||||
} catch (e) {
|
||||
}
|
||||
do_throw(text, stack);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
function do_check_eq(left, right, stack) {
|
||||
equal(left, right, stack) {
|
||||
if (left != right) {
|
||||
var text = "do_check_eq failed";
|
||||
var text = "Assert.equal failed";
|
||||
try {
|
||||
text += ": " + left + " != " + right;
|
||||
} catch (e) {
|
||||
}
|
||||
do_throw(text, stack);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
function do_check_true(condition, stack) {
|
||||
Assert.equal(condition, true, stack);
|
||||
ok(condition, stack) {
|
||||
this.equal(condition, true, stack);
|
||||
}
|
||||
};
|
||||
|
||||
function do_check_false(condition, stack) {
|
||||
Assert.equal(condition, false, stack);
|
||||
}
|
||||
|
||||
function do_print(text) {
|
||||
function info(text) {
|
||||
dump("INFO: " + text + "\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -1929,14 +1929,14 @@ function run_FunctionType_tests() {
|
|||
createInstance(Components.interfaces.nsIPrincipal);
|
||||
var s = new Components.utils.Sandbox(sp);
|
||||
s.ctypes = ctypes;
|
||||
s.do_check_eq = do_check_eq;
|
||||
s.do_check_true = do_check_true;
|
||||
s.equal = equal;
|
||||
s.ok = ok;
|
||||
Components.utils.evalInSandbox("var f5_t = ctypes.FunctionType(ctypes.default_abi, ctypes.int, [ctypes.int]);", s);
|
||||
Components.utils.evalInSandbox("do_check_eq(f5_t.toSource(), 'ctypes.FunctionType(ctypes.default_abi, ctypes.int, [ctypes.int])');", s);
|
||||
Components.utils.evalInSandbox("do_check_eq(f5_t.name, 'int(int)');", s);
|
||||
Components.utils.evalInSandbox("equal(f5_t.toSource(), 'ctypes.FunctionType(ctypes.default_abi, ctypes.int, [ctypes.int])');", s);
|
||||
Components.utils.evalInSandbox("equal(f5_t.name, 'int(int)');", s);
|
||||
Components.utils.evalInSandbox("function f5(aArg) { return 5; };", s);
|
||||
Components.utils.evalInSandbox("var f = f5_t.ptr(f5);", s);
|
||||
Components.utils.evalInSandbox("do_check_true(f(6) == 5);", s);
|
||||
Components.utils.evalInSandbox("ok(f(6) == 5);", s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2520,7 +2520,7 @@ function run_function_tests(library) {
|
|||
"ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t, [ctypes.char.ptr]).ptr");
|
||||
/* disabled temporarily per bug 598225.
|
||||
do_check_throws(function() { test_ansi_len.value = null; }, Error);
|
||||
do_check_eq(ptrValue(test_ansi_len), ptrValue(ptr));
|
||||
Assert.equal(ptrValue(test_ansi_len), ptrValue(ptr));
|
||||
*/
|
||||
|
||||
// Test that the library.declare(name, functionType) form works.
|
||||
|
@ -2529,7 +2529,7 @@ function run_function_tests(library) {
|
|||
Assert.equal(ptrValue(test_ansi_len), ptrValue(test_ansi_len_2));
|
||||
/* disabled temporarily per bug 598225.
|
||||
do_check_throws(function() { test_ansi_len_2.value = null; }, Error);
|
||||
do_check_eq(ptrValue(test_ansi_len_2), ptrValue(ptr));
|
||||
Assert.equal(ptrValue(test_ansi_len_2), ptrValue(ptr));
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ class ExtensionWrapper {
|
|||
this.messageQueue = new Set();
|
||||
|
||||
|
||||
this.testScope.do_register_cleanup(() => {
|
||||
this.testScope.registerCleanupFunction(() => {
|
||||
this.clearMessageQueues();
|
||||
|
||||
if (this.state == "pending" || this.state == "running") {
|
||||
|
@ -234,7 +234,7 @@ class ExtensionWrapper {
|
|||
extension.on("test-done", this.handleResult);
|
||||
extension.on("test-message", this.handleMessage);
|
||||
|
||||
this.testScope.do_print(`Extension attached`);
|
||||
this.testScope.info(`Extension attached`);
|
||||
}
|
||||
|
||||
clearMessageQueues() {
|
||||
|
@ -260,7 +260,7 @@ class ExtensionWrapper {
|
|||
break;
|
||||
|
||||
case "test-log":
|
||||
this.testScope.do_print(msg);
|
||||
this.testScope.info(msg);
|
||||
break;
|
||||
|
||||
case "test-result":
|
||||
|
@ -645,7 +645,7 @@ var ExtensionTestUtils = {
|
|||
Services.dirsvc.registerProvider(dirProvider);
|
||||
|
||||
|
||||
scope.do_register_cleanup(() => {
|
||||
scope.registerCleanupFunction(() => {
|
||||
tmpD.remove(true);
|
||||
Services.dirsvc.unregisterProvider(dirProvider);
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ add_task(async function test_experiments_api() {
|
|||
apiAddon.uninstall();
|
||||
|
||||
boringAddon.userDisabled = true;
|
||||
await new Promise(do_execute_soon);
|
||||
await new Promise(executeSoon);
|
||||
|
||||
equal(addon.appDisabled, true, "Add-on should be app-disabled after its dependency is removed.");
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ async function test_i18n_css(options = {}) {
|
|||
let contentPage = await ExtensionTestUtils.loadContentPage(`${BASE_URL}/file_sample.html`);
|
||||
|
||||
// workaround for extension may not be ready for applying foo.css
|
||||
await new Promise(do_execute_soon);
|
||||
await new Promise(executeSoon);
|
||||
|
||||
let maxWidth = await ContentTask.spawn(contentPage.browser, {}, async function() {
|
||||
/* globals content */
|
||||
|
|
|
@ -4,7 +4,7 @@ importScripts("resource://gre/modules/workers/require.js");
|
|||
importScripts("resource://gre/modules/osfile.jsm");
|
||||
|
||||
|
||||
function do_print(x) {
|
||||
function info(x) {
|
||||
// self.postMessage({kind: "do_print", args: [x]});
|
||||
dump("TEST-INFO: " + x + "\n");
|
||||
}
|
||||
|
|
|
@ -54,8 +54,7 @@ function* step() {
|
|||
|
||||
history.isURIVisited(uri, function(aURI2, aIsVisited2) {
|
||||
Assert.ok(uri.equals(aURI2));
|
||||
let checker = SCHEMES[scheme] ? do_check_true : do_check_false;
|
||||
checker(aIsVisited2);
|
||||
Assert.ok(SCHEMES[scheme] ? aIsVisited2 : !aIsVisited2);
|
||||
|
||||
PlacesTestUtils.clearHistory().then(function() {
|
||||
history.isURIVisited(uri, function(aURI3, aIsVisited3) {
|
||||
|
|
|
@ -121,7 +121,7 @@ add_task(async function test_addVisitAndCheckGuid() {
|
|||
// add a visit and test page guid and non-existing bookmark guids.
|
||||
let sourceURI = uri("http://test4.com/");
|
||||
await PlacesTestUtils.addVisits({ uri: sourceURI });
|
||||
do_check_eq(await PlacesUtils.bookmarks.fetch({ url: sourceURI }, null));
|
||||
Assert.equal(await PlacesUtils.bookmarks.fetch({ url: sourceURI }, null));
|
||||
|
||||
let options = histsvc.getNewQueryOptions();
|
||||
let query = histsvc.getNewQuery();
|
||||
|
|
|
@ -30,12 +30,12 @@ function setup_crash() {
|
|||
|
||||
function after_crash(mdump, extra) {
|
||||
info("after crash: " + extra.AsyncShutdownTimeout);
|
||||
let info = JSON.parse(extra.AsyncShutdownTimeout);
|
||||
Assert.equal(info.phase, "testing-async-shutdown-crash");
|
||||
Assert.equal(info.conditions[0].name, "A blocker that is never satisfied");
|
||||
let data = JSON.parse(extra.AsyncShutdownTimeout);
|
||||
Assert.equal(data.phase, "testing-async-shutdown-crash");
|
||||
Assert.equal(data.conditions[0].name, "A blocker that is never satisfied");
|
||||
// This test spawns subprocesses by using argument "-e" of xpcshell, so
|
||||
// this is the filename known to xpcshell.
|
||||
Assert.equal(info.conditions[0].filename, "-e");
|
||||
Assert.equal(data.conditions[0].filename, "-e");
|
||||
}
|
||||
|
||||
// Test that AsyncShutdown + OS.File reports errors correctly, in a case in which
|
||||
|
@ -58,10 +58,10 @@ function setup_osfile_crash_noerror() {
|
|||
|
||||
function after_osfile_crash_noerror(mdump, extra) {
|
||||
info("after OS.File crash: " + extra.AsyncShutdownTimeout);
|
||||
let info = JSON.parse(extra.AsyncShutdownTimeout);
|
||||
let state = info.conditions[0].state;
|
||||
let data = JSON.parse(extra.AsyncShutdownTimeout);
|
||||
let state = data.conditions[0].state;
|
||||
info("Keys: " + Object.keys(state).join(", "));
|
||||
Assert.equal(info.phase, "profile-before-change");
|
||||
Assert.equal(data.phase, "profile-before-change");
|
||||
Assert.ok(state.launched);
|
||||
Assert.ok(!state.shutdown);
|
||||
Assert.ok(state.worker);
|
||||
|
@ -89,10 +89,10 @@ function setup_osfile_crash_exn() {
|
|||
|
||||
function after_osfile_crash_exn(mdump, extra) {
|
||||
info("after OS.File crash: " + extra.AsyncShutdownTimeout);
|
||||
let info = JSON.parse(extra.AsyncShutdownTimeout);
|
||||
let state = info.conditions[0].state;
|
||||
let data = JSON.parse(extra.AsyncShutdownTimeout);
|
||||
let state = data.conditions[0].state;
|
||||
info("Keys: " + Object.keys(state).join(", "));
|
||||
Assert.equal(info.phase, "profile-before-change");
|
||||
Assert.equal(data.phase, "profile-before-change");
|
||||
Assert.ok(!state.shutdown);
|
||||
Assert.ok(state.worker);
|
||||
Assert.ok(!!state.latestSent);
|
||||
|
|
|
@ -80,8 +80,7 @@ function check_cookie_exists(aDomain, aExists) {
|
|||
name: COOKIE_NAME,
|
||||
path: COOKIE_PATH
|
||||
};
|
||||
let checker = aExists ? do_check_true : do_check_false;
|
||||
checker(Services.cookies.cookieExists(cookie));
|
||||
Assert.equal(aExists, Services.cookies.cookieExists(cookie));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,8 +104,7 @@ function add_disabled_host(aHost) {
|
|||
* True if the host should be disabled, false otherwise.
|
||||
*/
|
||||
function check_disabled_host(aHost, aIsDisabled) {
|
||||
let checker = aIsDisabled ? do_check_false : do_check_true;
|
||||
checker(Services.logins.getLoginSavingEnabled(aHost));
|
||||
Assert.equal(!aIsDisabled, Services.logins.getLoginSavingEnabled(aHost));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -165,8 +163,8 @@ function check_permission_exists(aURI, aExists) {
|
|||
let principal = Services.scriptSecurityManager.createCodebasePrincipal(aURI, {});
|
||||
|
||||
let perm = Services.perms.testExactPermissionFromPrincipal(principal, PERMISSION_TYPE);
|
||||
let checker = aExists ? do_check_eq : do_check_neq;
|
||||
checker(perm, PERMISSION_VALUE);
|
||||
let checker = aExists ? "equal" : "notEqual";
|
||||
Assert[checker](perm, PERMISSION_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -956,7 +956,7 @@ function wait_for_uncaught(aMustAppear, aTimeout = undefined) {
|
|||
remaining.add(k);
|
||||
}
|
||||
let deferred = Promise.defer();
|
||||
let print = do_print;
|
||||
let print = info;
|
||||
let observer = function({message, stack}) {
|
||||
let data = message + stack;
|
||||
print("Observing " + message + ", looking for " + aMustAppear.join(", "));
|
||||
|
|
|
@ -299,7 +299,7 @@ var AddonTestUtils = {
|
|||
}
|
||||
}
|
||||
|
||||
testScope.do_register_cleanup(() => {
|
||||
testScope.registerCleanupFunction(() => {
|
||||
this.cleanupTempXPIs();
|
||||
|
||||
// Check that the temporary directory is empty
|
||||
|
@ -316,7 +316,7 @@ var AddonTestUtils = {
|
|||
try {
|
||||
appDirForAddons.remove(true);
|
||||
} catch (ex) {
|
||||
testScope.do_print(`Got exception removing addon app dir: ${ex}`);
|
||||
testScope.info(`Got exception removing addon app dir: ${ex}`);
|
||||
}
|
||||
|
||||
// ensure no leftover files in the system addon upgrade location
|
||||
|
|
|
@ -1297,7 +1297,7 @@ function saveJSON(aData, aFile) {
|
|||
*/
|
||||
function callback_soon(aFunction) {
|
||||
return function(...args) {
|
||||
do_execute_soon(function() {
|
||||
executeSoon(function() {
|
||||
aFunction.apply(null, args);
|
||||
}, aFunction.name ? "delayed callback " + aFunction.name : "delayed callback");
|
||||
};
|
||||
|
|
|
@ -346,7 +346,7 @@ function check_test_4(install) {
|
|||
Assert.equal(install.version, "3.0");
|
||||
Assert.equal(install.name, "Real Test 3");
|
||||
Assert.equal(install.state, AddonManager.STATE_DOWNLOADED);
|
||||
do_check_neq(install.existingAddon);
|
||||
Assert.ok(install.existingAddon);
|
||||
Assert.equal(install.existingAddon.id, "addon2@tests.mozilla.org");
|
||||
Assert.equal(install.addon.install, install);
|
||||
Assert.ok(hasFlag(install.addon.operationsRequiringRestart,
|
||||
|
|
|
@ -328,7 +328,7 @@ function check_test_4(install) {
|
|||
Assert.equal(install.version, "3.0");
|
||||
Assert.equal(install.name, "Real Test 3");
|
||||
Assert.equal(install.state, AddonManager.STATE_DOWNLOADED);
|
||||
do_check_neq(install.existingAddon);
|
||||
Assert.ok(install.existingAddon);
|
||||
Assert.equal(install.existingAddon.id, "addon2@tests.mozilla.org");
|
||||
Assert.equal(install.addon.install, install);
|
||||
Assert.ok(hasFlag(install.addon.operationsRequiringRestart,
|
||||
|
|
|
@ -1189,7 +1189,7 @@ for (let test of testParams) {
|
|||
|
||||
shutdownManager();
|
||||
|
||||
await new Promise(do_execute_soon);
|
||||
await new Promise(executeSoon);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1031,7 +1031,7 @@ for (let test of testParams) {
|
|||
|
||||
shutdownManager();
|
||||
|
||||
await new Promise(do_execute_soon);
|
||||
await new Promise(executeSoon);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ const FILE_IN_USE_TIMEOUT_MS = 1000;
|
|||
|
||||
const PIPE_TO_NULL = IS_WIN ? ">nul" : "> /dev/null 2>&1";
|
||||
|
||||
const LOG_FUNCTION = do_print;
|
||||
const LOG_FUNCTION = info;
|
||||
|
||||
const gHTTPHandlerPath = "updates.xml";
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче