From a065e04d529da1d847b5062a12c46d916408bf32 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 21:46:22 -0500 Subject: update based on https://github.com/mdn/yari/issues/2028 --- .../using_indexeddb_in_chrome/index.html | 27 ---------------------- 1 file changed, 27 deletions(-) delete mode 100644 files/zh-cn/web/api/indexeddb_api/using_indexeddb_in_chrome/index.html (limited to 'files/zh-cn/web/api/indexeddb_api') diff --git a/files/zh-cn/web/api/indexeddb_api/using_indexeddb_in_chrome/index.html b/files/zh-cn/web/api/indexeddb_api/using_indexeddb_in_chrome/index.html deleted file mode 100644 index d9d9aa2cbf..0000000000 --- a/files/zh-cn/web/api/indexeddb_api/using_indexeddb_in_chrome/index.html +++ /dev/null @@ -1,27 +0,0 @@ ---- -title: Using IndexedDB in chrome -slug: Web/API/IndexedDB_API/Using_IndexedDB_in_chrome -translation_of: Mozilla/Tech/XPCOM/Using_IndexedDB_in_chrome ---- -

indexedDB API 通常被用来在用户的浏览器端存储来自JavaScript的数据。(点击 Using IndexedDB 复习)。然而,使用system-privileged JavaScript的 Components.utils.importGlobalProperties() 函数也能获取这些API:

- -
Components.utils.importGlobalProperties(["indexedDB"]);
-
-// From here on, it's like using IndexedDB from content
-var req = indexedDB.open("my-database");
-// ...
- -

如果你要创建一个 sandbox ,并且打算在sandbox中使用indexedDB,那么在 Sandbox 的构造函数中使用 wantGlobalProperties配置项:

- -
var options = {
-  "wantGlobalProperties": ["indexedDB"]
-}
-var principal = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
-var sandbox = Components.utils.Sandbox(principal, options);
-
-// The sandbox will have access to indexedDB
-var sandboxScript = 'var req = indexedDB.open("my-database");';
-Components.utils.evalInSandbox(sandboxScript, sandbox);
-
- -

在Firefox 33之前,你可能要使用nsIIndexedDatabaseManager的initWindowless方法,从chrome的代码中方法获取indexedDB。这种方法在Firefox 33时,已经被移除。

-- cgit v1.2.3-54-g00ecf