зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1821621 - Convert toolkit/components/kvstore to ES modules r=Standard8,extension-reviewers,robwu
Differential Revision: https://phabricator.services.mozilla.com/D172233
This commit is contained in:
Родитель
bf793882d2
Коммит
644c56f50a
|
@ -15,12 +15,8 @@ const lazy = {};
|
|||
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
|
||||
KeyValueService: "resource://gre/modules/kvstore.sys.mjs",
|
||||
});
|
||||
ChromeUtils.defineModuleGetter(
|
||||
lazy,
|
||||
"KeyValueService",
|
||||
"resource://gre/modules/kvstore.jsm"
|
||||
);
|
||||
|
||||
const kMessages = [
|
||||
"Notification:Save",
|
||||
|
|
|
@ -2,12 +2,10 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
const lazy = {};
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
KeyValueService: "resource://gre/modules/kvstore.jsm",
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
KeyValueService: "resource://gre/modules/kvstore.sys.mjs",
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,6 +17,7 @@ const lazy = {};
|
|||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
|
||||
JSONFile: "resource://gre/modules/JSONFile.sys.mjs",
|
||||
KeyValueService: "resource://gre/modules/kvstore.sys.mjs",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
|
@ -29,12 +30,6 @@ XPCOMUtils.defineLazyGetter(
|
|||
() => lazy.ExtensionParent.StartupCache
|
||||
);
|
||||
|
||||
ChromeUtils.defineModuleGetter(
|
||||
lazy,
|
||||
"KeyValueService",
|
||||
"resource://gre/modules/kvstore.jsm"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(
|
||||
lazy,
|
||||
"Management",
|
||||
|
|
|
@ -13,20 +13,13 @@ const { ExtensionParent } = ChromeUtils.import(
|
|||
"resource://gre/modules/ExtensionParent.jsm"
|
||||
);
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
);
|
||||
|
||||
const { StartupCache } = ExtensionParent;
|
||||
|
||||
const lazy = {};
|
||||
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
KeyValueService: "resource://gre/modules/kvstore.jsm",
|
||||
KeyValueService: "resource://gre/modules/kvstore.sys.mjs",
|
||||
});
|
||||
|
||||
class Store {
|
||||
|
|
|
@ -13,8 +13,8 @@ const { FileTestUtils } = ChromeUtils.importESModule(
|
|||
const { FileUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/FileUtils.sys.mjs"
|
||||
);
|
||||
const { KeyValueService } = ChromeUtils.import(
|
||||
"resource://gre/modules/kvstore.jsm"
|
||||
const { KeyValueService } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/kvstore.sys.mjs"
|
||||
);
|
||||
|
||||
add_setup(async () => {
|
||||
|
|
|
@ -2,14 +2,10 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const gKeyValueService = Cc["@mozilla.org/key-value-service;1"].getService(
|
||||
Ci.nsIKeyValueService
|
||||
);
|
||||
|
||||
const EXPORTED_SYMBOLS = ["KeyValueService"];
|
||||
|
||||
function promisify(fn, ...args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fn({ resolve, reject }, ...args);
|
||||
|
@ -30,7 +26,7 @@ function promisify(fn, ...args) {
|
|||
* for key/value storage.
|
||||
*/
|
||||
|
||||
class KeyValueService {
|
||||
export class KeyValueService {
|
||||
static async getOrCreate(dir, name) {
|
||||
return new KeyValueDatabase(
|
||||
await promisify(gKeyValueService.getOrCreate, dir, name)
|
|
@ -8,7 +8,7 @@ with Files("**"):
|
|||
BUG_COMPONENT = ("Toolkit", "Storage")
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
"kvstore.jsm",
|
||||
"kvstore.sys.mjs",
|
||||
]
|
||||
|
||||
XPCSHELL_TESTS_MANIFESTS += ["test/xpcshell/xpcshell.ini"]
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { KeyValueService } = ChromeUtils.import(
|
||||
"resource://gre/modules/kvstore.jsm"
|
||||
const { KeyValueService } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/kvstore.sys.mjs"
|
||||
);
|
||||
|
||||
(async function() {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { KeyValueService } = ChromeUtils.import(
|
||||
"resource://gre/modules/kvstore.jsm"
|
||||
const { KeyValueService } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/kvstore.sys.mjs"
|
||||
);
|
||||
|
||||
function run_test() {
|
||||
|
|
|
@ -1026,8 +1026,8 @@ var snapshotFormatters = {
|
|||
let button = $("enumerate-database-button");
|
||||
if (button) {
|
||||
button.addEventListener("click", function(event) {
|
||||
let { KeyValueService } = ChromeUtils.import(
|
||||
"resource://gre/modules/kvstore.jsm"
|
||||
let { KeyValueService } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/kvstore.sys.mjs"
|
||||
);
|
||||
let currProfDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
currProfDir.append("mediacapabilities");
|
||||
|
|
Загрузка…
Ссылка в новой задаче