mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-09 12:51:09 +02:00
By and large, this change accomplishes two things: 1. Run db.close() in finally clauses so that even if db access fails, we close our connections. It also tries to avoid waiting on other, non-DB operations before calling close, to avoid the DB connection needlessly hanging around. 2. Intercept all async database operations from the remote settings client to kinto and ensuring they complete before the end of `profile-before-change`. Any operations started after Services.startup.isShuttingDown (so after quit/restart is initiated by the user) will throw. Operations started beforehand are put in a set of operations, and remove themselves once complete. We AsyncShutdown block on that set of operations completing. Differential Revision: https://phabricator.services.mozilla.com/D66995 --HG-- extra : moz-landing-system : lando
83 lines
2.1 KiB
JavaScript
83 lines
2.1 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
add_test(async _ => {
|
|
ok(
|
|
Services.cookies,
|
|
"Force the cookie service to be initialized to avoid issues later. " +
|
|
"See https://bugzilla.mozilla.org/show_bug.cgi?id=1621759#c3"
|
|
);
|
|
Services.prefs.setBoolPref("browser.safebrowsing.passwords.enabled", true);
|
|
|
|
let classifier = Cc["@mozilla.org/url-classifier/dbservice;1"].getService(
|
|
Ci.nsIURIClassifier
|
|
);
|
|
ok(!!classifier, "We have the URI-Classifier");
|
|
|
|
var tests = [
|
|
{ name: "a", expectedResult: false },
|
|
{ name: "tracking-annotation", expectedResult: true },
|
|
{ name: "tracking-protection", expectedResult: true },
|
|
{ name: "login-reputation", expectedResult: true },
|
|
];
|
|
|
|
tests.forEach(test => {
|
|
let feature;
|
|
try {
|
|
feature = classifier.getFeatureByName(test.name);
|
|
} catch (e) {}
|
|
|
|
equal(
|
|
!!feature,
|
|
test.expectedResult,
|
|
"Exceptected result for: " + test.name
|
|
);
|
|
if (feature) {
|
|
equal(feature.name, test.name, "Feature name matches");
|
|
}
|
|
});
|
|
|
|
let uri = Services.io.newURI("https://example.com");
|
|
|
|
let feature = classifier.getFeatureByName("tracking-protection");
|
|
|
|
let results = await new Promise(resolve => {
|
|
classifier.asyncClassifyLocalWithFeatures(
|
|
uri,
|
|
[feature],
|
|
Ci.nsIUrlClassifierFeature.blacklist,
|
|
r => {
|
|
resolve(r);
|
|
}
|
|
);
|
|
});
|
|
equal(results.length, 0, "No tracker");
|
|
|
|
Services.prefs.setCharPref(
|
|
"urlclassifier.trackingTable.testEntries",
|
|
"example.com"
|
|
);
|
|
|
|
feature = classifier.getFeatureByName("tracking-protection");
|
|
|
|
results = await new Promise(resolve => {
|
|
classifier.asyncClassifyLocalWithFeatures(
|
|
uri,
|
|
[feature],
|
|
Ci.nsIUrlClassifierFeature.blacklist,
|
|
r => {
|
|
resolve(r);
|
|
}
|
|
);
|
|
});
|
|
equal(results.length, 1, "Tracker");
|
|
let result = results[0];
|
|
equal(result.feature.name, "tracking-protection", "Correct feature");
|
|
equal(result.list, "tracking-blacklist-pref", "Correct list");
|
|
|
|
Services.prefs.clearUserPref("browser.safebrowsing.password.enabled");
|
|
run_next_test();
|
|
});
|