Bug 1462056: Bump schema version to migrate legacy dictionaries to WebExtension loader format. r=aswan

Legacy dictionaries are now loaded using the WebExtension dictionary loader,
and require more database metadata in order to be loaded. This patch bumps the
schema version, and tests that existing unpacked legacy dictionaries are
migrated, and work as expected.

MozReview-Commit-ID: 8uI4dlF9vgB

--HG--
extra : rebase_source : ec41f5a4f5f3643c59aff6bff3f0961637599ced
This commit is contained in:
Kris Maglione 2018-05-18 14:43:52 -07:00
parent b79ba931bf
commit bdc3174614
3 changed files with 61 additions and 4 deletions

View File

@ -974,7 +974,7 @@ var AddonTestUtils = {
let dirPath = dir;
for (let subDir of path) {
dirPath = OS.Path.join(dirPath, subDir);
await OS.Path.makeDir(dirPath, {ignoreExisting: true});
await OS.File.makeDir(dirPath, {ignoreExisting: true});
}
if (typeof data == "string")

View File

@ -122,7 +122,7 @@ const TOOLKIT_ID = "toolkit@mozilla.org";
const XPI_SIGNATURE_CHECK_PERIOD = 24 * 60 * 60;
XPCOMUtils.defineConstant(this, "DB_SCHEMA", 25);
XPCOMUtils.defineConstant(this, "DB_SCHEMA", 26);
const NOTIFICATION_TOOLBOX_CONNECTION_CHANGE = "toolbox-connection-change";

View File

@ -71,9 +71,9 @@ add_task(async function test_validation() {
addon2.uninstall();
});
add_task(async function test_registration() {
const WORD = "Flehgragh";
const WORD = "Flehgragh";
add_task(async function test_registration() {
spellCheck.dictionary = "en-US";
ok(!spellCheck.check(WORD), "Word should not pass check before add-on loads");
@ -104,3 +104,60 @@ SFX A 0 en [^elr]
ok(!spellCheck.check(WORD), "Word should not pass check after add-on unloads");
});
// Tests that existing unpacked dictionaries are migrated to
// WebExtension dictionaries on schema bump.
add_task(async function test_migration() {
let profileDir = gProfD.clone();
profileDir.append("extensions");
await promiseShutdownManager();
const ID = "en-US@dictionaries.mozilla.org";
await promiseWriteInstallRDFToDir({
id: ID,
type: "64",
version: "1.0",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "61",
maxVersion: "61.*"}],
}, profileDir, ID, {
"dictionaries/en-US.dic": `1\n${WORD}\n`,
"dictionaries/en-US.aff": "",
});
await promiseStartupManager();
ok(spellCheck.check(WORD), "Word should pass check after initial load");
var {XPIDatabase, XPIProvider, XPIStates} = ChromeUtils.import("resource://gre/modules/addons/XPIProvider.jsm", null);
let addon = await XPIDatabase.getVisibleAddonForID(ID);
let state = XPIStates.findAddon(ID);
// Mangle the add-on state to match what an unpacked dictionary looked
// like in older versions.
XPIDatabase.setAddonProperties(addon, {
startupData: null,
type: "dictionary",
});
state.type = "dictionary";
state.startupData = null;
XPIStates.save();
// Dictionary add-ons usually do not unregister dictionaries at app
// shutdown, so force them to here.
XPIProvider.activeAddons.get(ID).scope.shutdown(0);
await promiseShutdownManager();
ok(!spellCheck.check(WORD), "Word should not pass check while add-on manager is shut down");
// Drop the schema version to the last one that supported legacy
// dictionaries.
Services.prefs.setIntPref("extensions.databaseSchema", 25);
await promiseStartupManager();
ok(spellCheck.check(WORD), "Word should pass check while add-on load is loaded");
});