зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1435296 Address xpcshell test failures from increasing timer precision r=baku
See the comment on "Address test failures caused by bumping timer precision to 2 ms" for more details. MozReview-Commit-ID: LrsucEPdZIo --HG-- extra : rebase_source : 8147c034f7dc93f678eebc80b0afabf55729d804
This commit is contained in:
Родитель
f928a0f4b2
Коммит
c4edd2fe5c
|
@ -83,6 +83,20 @@ add_task(async function testCache() {
|
|||
});
|
||||
|
||||
add_task(async function testCookies() {
|
||||
// Above in setUpCookies we create an 'old' cookies, wait 10ms, then log a timestamp.
|
||||
// Here we ask the browser to delete all cookies after the timestamp, with the intention
|
||||
// that the 'old' cookie is not removed. The issue arises when the timer precision is
|
||||
// low enough such that the timestamp that gets logged is the same as the 'old' cookie.
|
||||
// We hardcode a precision value to ensure that there is time between the 'old' cookie
|
||||
// and the timestamp generation.
|
||||
Services.prefs.setBoolPref("privacy.reduceTimerPrecision", true);
|
||||
Services.prefs.setIntPref("privacy.resistFingerprinting.reduceTimerPrecision.microseconds", 2000);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref("privacy.reduceTimerPrecision");
|
||||
Services.prefs.clearUserPref("privacy.resistFingerprinting.reduceTimerPrecision.microseconds");
|
||||
});
|
||||
|
||||
function background() {
|
||||
browser.test.onMessage.addListener(async (msg, options) => {
|
||||
if (msg == "removeCookies") {
|
||||
|
|
|
@ -254,6 +254,9 @@ const MERGE_TESTCASES = [
|
|||
},
|
||||
];
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "Preferences",
|
||||
"resource://gre/modules/Preferences.jsm");
|
||||
|
||||
let do_check_record_matches = (recordWithMeta, record) => {
|
||||
for (let key in record) {
|
||||
Assert.equal(recordWithMeta[key], record[key]);
|
||||
|
@ -369,6 +372,16 @@ add_task(async function test_add() {
|
|||
});
|
||||
|
||||
add_task(async function test_update() {
|
||||
// Test assumes that when an entry is saved a second time, it's last modified date will
|
||||
// be different from the first. With high values of precision reduction, we execute too
|
||||
// fast for that to be true.
|
||||
let timerPrecision = Preferences.get("privacy.reduceTimerPrecision");
|
||||
Preferences.set("privacy.reduceTimerPrecision", false);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Preferences.set("privacy.reduceTimerPrecision", timerPrecision);
|
||||
});
|
||||
|
||||
let profileStorage = await initProfileStorage(TEST_STORE_FILE_NAME,
|
||||
[TEST_ADDRESS_1, TEST_ADDRESS_2]);
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
"use strict";
|
||||
|
||||
const {FormAutofillStorage} = ChromeUtils.import("resource://formautofill/FormAutofillStorage.jsm", {});
|
||||
ChromeUtils.defineModuleGetter(this, "Preferences",
|
||||
"resource://gre/modules/Preferences.jsm");
|
||||
|
||||
const TEST_STORE_FILE_NAME = "test-credit-card.json";
|
||||
const COLLECTION_NAME = "creditCards";
|
||||
|
@ -290,6 +292,16 @@ add_task(async function test_add() {
|
|||
});
|
||||
|
||||
add_task(async function test_update() {
|
||||
// Test assumes that when an entry is saved a second time, it's last modified date will
|
||||
// be different from the first. With high values of precision reduction, we execute too
|
||||
// fast for that to be true.
|
||||
let timerPrecision = Preferences.get("privacy.reduceTimerPrecision");
|
||||
Preferences.set("privacy.reduceTimerPrecision", false);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Preferences.set("privacy.reduceTimerPrecision", timerPrecision);
|
||||
});
|
||||
|
||||
let path = getTempFile(TEST_STORE_FILE_NAME).path;
|
||||
await prepareTestCreditCards(path);
|
||||
|
||||
|
|
|
@ -11,7 +11,17 @@ const { PromisesFront } = require("devtools/shared/fronts/promises");
|
|||
|
||||
var EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "Preferences",
|
||||
"resource://gre/modules/Preferences.jsm");
|
||||
|
||||
add_task(function* () {
|
||||
let timerPrecision = Preferences.get("privacy.reduceTimerPrecision");
|
||||
Preferences.set("privacy.reduceTimerPrecision", false);
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
Preferences.set("privacy.reduceTimerPrecision", timerPrecision);
|
||||
});
|
||||
|
||||
let client = yield startTestDebuggerServer("promises-object-test");
|
||||
let chromeActors = yield getChromeActors(client);
|
||||
|
||||
|
@ -63,7 +73,8 @@ function* testPromiseCreationTimestamp(client, form, makePromise) {
|
|||
let creationTimestamp = grip.promiseState.creationTimestamp;
|
||||
|
||||
ok(start - 1 <= creationTimestamp && creationTimestamp <= end + 1,
|
||||
"Expect promise creation timestamp to be within elapsed time range.");
|
||||
"Expect promise creation timestamp to be within elapsed time range: " +
|
||||
(start - 1) + " <= " + creationTimestamp + " <= " + (end + 1));
|
||||
|
||||
yield front.detach();
|
||||
// Appease eslint
|
||||
|
|
|
@ -80,6 +80,21 @@ function run_test() {
|
|||
|
||||
let testGenerator = testSteps();
|
||||
function *testSteps() {
|
||||
/*
|
||||
* In this test, we have a relatively low timeout of 200ms and an assertion that
|
||||
* the timer works properly by checking that the time was greater than 200ms.
|
||||
* With a timer precision of 100ms (for example) we will clamp downwards to 200
|
||||
* and cause the assertion to fail. To resolve this, we hardcode a precision of
|
||||
* 20ms.
|
||||
*/
|
||||
Services.prefs.setBoolPref("privacy.reduceTimerPrecision", true);
|
||||
Services.prefs.setIntPref("privacy.resistFingerprinting.reduceTimerPrecision.microseconds", 20000);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref("privacy.reduceTimerPrecision");
|
||||
Services.prefs.clearUserPref("privacy.resistFingerprinting.reduceTimerPrecision.microseconds");
|
||||
});
|
||||
|
||||
// Initial request. Stores the response in the cache.
|
||||
var channel = make_channel("http://localhost:" + PORT + "/rcwn");
|
||||
channel.asyncOpen2(new ChannelListener(checkContent, null));
|
||||
|
|
|
@ -260,6 +260,16 @@ add_test(function fetchAndCacheProfile_alreadyCached() {
|
|||
// Check that a new profile request within PROFILE_FRESHNESS_THRESHOLD of the
|
||||
// last one doesn't kick off a new request to check the cached copy is fresh.
|
||||
add_task(async function fetchAndCacheProfileAfterThreshold() {
|
||||
/*
|
||||
* This test was observed to cause a timeout for... any timer precision reduction.
|
||||
* Even 1 us. Exact reason is still undiagnosed.
|
||||
*/
|
||||
Services.prefs.setBoolPref("privacy.reduceTimerPrecision", false);
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
Services.prefs.clearUserPref("privacy.reduceTimerPrecision");
|
||||
});
|
||||
|
||||
let numFetches = 0;
|
||||
let client = mockClient(mockFxa());
|
||||
client.fetchProfile = async function() {
|
||||
|
|
|
@ -11,6 +11,7 @@ ChromeUtils.import("resource://services-sync/addonsreconciler.js");
|
|||
ChromeUtils.import("resource://services-sync/engines/addons.js");
|
||||
ChromeUtils.import("resource://services-sync/service.js");
|
||||
ChromeUtils.import("resource://services-sync/util.js");
|
||||
ChromeUtils.defineModuleGetter(this, "Preferences", "resource://gre/modules/Preferences.jsm");
|
||||
|
||||
const prefs = new Preferences();
|
||||
prefs.set("extensions.getAddons.get.url",
|
||||
|
@ -90,6 +91,13 @@ add_task(async function test_find_dupe() {
|
|||
});
|
||||
|
||||
add_task(async function test_get_changed_ids() {
|
||||
let timerPrecision = Preferences.get("privacy.reduceTimerPrecision");
|
||||
Preferences.set("privacy.reduceTimerPrecision", false);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Preferences.set("privacy.reduceTimerPrecision", timerPrecision);
|
||||
});
|
||||
|
||||
_("Ensure getChangedIDs() has the appropriate behavior.");
|
||||
|
||||
_("Ensure getChangedIDs() returns an empty object by default.");
|
||||
|
|
|
@ -86,10 +86,12 @@ add_task(async function test_search() {
|
|||
|
||||
Services.prefs.setIntPref("browser.download.folderList", 2);
|
||||
Services.prefs.setComplexValue("browser.download.dir", nsIFile, downloadDir);
|
||||
Services.prefs.setBoolPref("privacy.reduceTimerPrecision", false);
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
Services.prefs.clearUserPref("browser.download.folderList");
|
||||
Services.prefs.clearUserPref("browser.download.dir");
|
||||
Services.prefs.clearUserPref("privacy.reduceTimerPrecision");
|
||||
await cleanupDir(downloadDir);
|
||||
await clearDownloads();
|
||||
});
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "Preferences",
|
||||
"resource://gre/modules/Preferences.jsm");
|
||||
|
||||
add_task(async function insert_separator_notification() {
|
||||
let observer = expectNotifications();
|
||||
let bm = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_SEPARATOR,
|
||||
|
@ -108,6 +111,13 @@ add_task(async function insert_bookmark_tag_notification() {
|
|||
});
|
||||
|
||||
add_task(async function update_bookmark_lastModified() {
|
||||
let timerPrecision = Preferences.get("privacy.reduceTimerPrecision");
|
||||
Preferences.set("privacy.reduceTimerPrecision", false);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Preferences.set("privacy.reduceTimerPrecision", timerPrecision);
|
||||
});
|
||||
|
||||
let bm = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
url: new URL("http://lastmod.example.com/") });
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
ChromeUtils.defineModuleGetter(this, "Preferences",
|
||||
"resource://gre/modules/Preferences.jsm");
|
||||
|
||||
const URI1 = NetUtil.newURI("http://test1.mozilla.org/");
|
||||
const URI2 = NetUtil.newURI("http://test2.mozilla.org/");
|
||||
const URI3 = NetUtil.newURI("http://test3.mozilla.org/");
|
||||
|
@ -80,6 +83,13 @@ add_task(function test_invalid_input() {
|
|||
});
|
||||
|
||||
add_task(async function test_addBookmarkAndKeyword() {
|
||||
let timerPrecision = Preferences.get("privacy.reduceTimerPrecision");
|
||||
Preferences.set("privacy.reduceTimerPrecision", false);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Preferences.set("privacy.reduceTimerPrecision", timerPrecision);
|
||||
});
|
||||
|
||||
await check_keyword(URI1, null);
|
||||
let fc = await foreign_count(URI1);
|
||||
let observer = expectNotifications();
|
||||
|
@ -128,6 +138,13 @@ add_task(async function test_addBookmarkToURIHavingKeyword() {
|
|||
});
|
||||
|
||||
add_task(async function test_sameKeywordDifferentURI() {
|
||||
let timerPrecision = Preferences.get("privacy.reduceTimerPrecision");
|
||||
Preferences.set("privacy.reduceTimerPrecision", false);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Preferences.set("privacy.reduceTimerPrecision", timerPrecision);
|
||||
});
|
||||
|
||||
let fc1 = await foreign_count(URI1);
|
||||
let fc2 = await foreign_count(URI2);
|
||||
let observer = expectNotifications();
|
||||
|
|
|
@ -12,6 +12,9 @@ const rootGuid = PlacesUtils.bookmarks.rootGuid;
|
|||
const menuGuid = PlacesUtils.bookmarks.menuGuid;
|
||||
|
||||
Components.utils.importGlobalProperties(["URL"]);
|
||||
ChromeUtils.defineModuleGetter(this, "Preferences",
|
||||
"resource://gre/modules/Preferences.jsm");
|
||||
|
||||
|
||||
// Create and add bookmarks observer.
|
||||
var observer = {
|
||||
|
@ -1589,6 +1592,13 @@ add_task(async function test_copy() {
|
|||
await PT.clearTransactionsHistory();
|
||||
}
|
||||
|
||||
let timerPrecision = Preferences.get("privacy.reduceTimerPrecision");
|
||||
Preferences.set("privacy.reduceTimerPrecision", false);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Preferences.set("privacy.reduceTimerPrecision", timerPrecision);
|
||||
});
|
||||
|
||||
// Test duplicating leafs (bookmark, separator, empty folder)
|
||||
PT.NewBookmark({ url: new URL("http://test.item.duplicate"),
|
||||
parentGuid: rootGuid,
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
"use strict";
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "Preferences",
|
||||
"resource://gre/modules/Preferences.jsm");
|
||||
|
||||
async function check_keyword(aExpectExists, aHref, aKeyword, aPostData = null) {
|
||||
// Check case-insensitivity.
|
||||
aKeyword = aKeyword.toUpperCase();
|
||||
|
@ -175,6 +178,13 @@ add_task(async function test_addKeyword() {
|
|||
});
|
||||
|
||||
add_task(async function test_addBookmarkAndKeyword() {
|
||||
let timerPrecision = Preferences.get("privacy.reduceTimerPrecision");
|
||||
Preferences.set("privacy.reduceTimerPrecision", false);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Preferences.set("privacy.reduceTimerPrecision", timerPrecision);
|
||||
});
|
||||
|
||||
await check_keyword(false, "http://example.com/", "keyword");
|
||||
let fc = await foreign_count("http://example.com/");
|
||||
let bookmark = await PlacesUtils.bookmarks.insert({ url: "http://example.com/",
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
ChromeUtils.import("resource://gre/modules/ObjectUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/PlacesSyncUtils.jsm");
|
||||
ChromeUtils.import("resource://testing-common/httpd.js");
|
||||
ChromeUtils.defineModuleGetter(this, "Preferences",
|
||||
"resource://gre/modules/Preferences.jsm");
|
||||
Cu.importGlobalProperties(["URLSearchParams"]);
|
||||
|
||||
const DESCRIPTION_ANNO = "bookmarkProperties/description";
|
||||
|
@ -2809,6 +2811,13 @@ add_task(async function test_remove_partial() {
|
|||
});
|
||||
|
||||
add_task(async function test_migrateOldTrackerEntries() {
|
||||
let timerPrecision = Preferences.get("privacy.reduceTimerPrecision");
|
||||
Preferences.set("privacy.reduceTimerPrecision", false);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Preferences.set("privacy.reduceTimerPrecision", timerPrecision);
|
||||
});
|
||||
|
||||
let unknownBmk = await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.menuGuid,
|
||||
url: "http://getfirefox.com",
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "setTimeout", "resource://gre/modules/Timer.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "Preferences", "resource://gre/modules/Preferences.jsm");
|
||||
|
||||
const TestObserver = {
|
||||
observed: [],
|
||||
|
@ -134,6 +135,13 @@ add_task(async function removeEntriesForName() {
|
|||
});
|
||||
|
||||
add_task(async function removeEntriesByTimeframe() {
|
||||
let timerPrecision = Preferences.get("privacy.reduceTimerPrecision");
|
||||
Preferences.set("privacy.reduceTimerPrecision", false);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Preferences.set("privacy.reduceTimerPrecision", timerPrecision);
|
||||
});
|
||||
|
||||
await promiseAddEntry(entry1[0], entry1[1]);
|
||||
await promiseAddEntry(entry2[0], entry2[1]);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче