aboutsummaryrefslogtreecommitdiff
path: root/dev/database-vm.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-03-14 18:41:15 -0400
committerGitHub <noreply@github.com>2021-03-14 18:41:15 -0400
commit07df1e011794f5a77f7fb7da5cd9ea353a8747e2 (patch)
tree98a679d4ef07629b8f0121e244038c557c972bd8 /dev/database-vm.js
parent52a4d874eada5be121e15d73d1d10e9a8d84bdb8 (diff)
Fix dictionary image support (#1526)
* Fix content security policy for images * Add createBlobFromBase64Content to MediaUtil * Update MediaLoader to use MediaUtil * Use blob URLs when importing dictionaries * Update VM's URL to support createObjectURL and revokeObjectURL * Fix test
Diffstat (limited to 'dev/database-vm.js')
-rw-r--r--dev/database-vm.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/dev/database-vm.js b/dev/database-vm.js
index e43daf2f..b682bca3 100644
--- a/dev/database-vm.js
+++ b/dev/database-vm.js
@@ -76,6 +76,13 @@ class Image {
}
}
+class Blob {
+ constructor(array, options) {
+ this._array = array;
+ this._options = options;
+ }
+}
+
async function fetch(url2) {
const filePath = url.fileURLToPath(url2);
await Promise.resolve();
@@ -89,15 +96,21 @@ async function fetch(url2) {
};
}
+function atob(data) {
+ return Buffer.from(data, 'base64').toString('ascii');
+}
+
class DatabaseVM extends VM {
constructor() {
super({
chrome,
Image,
+ Blob,
fetch,
indexedDB: global.indexedDB,
IDBKeyRange: global.IDBKeyRange,
- JSZip
+ JSZip,
+ atob
});
this.context.window = this.context;
this.indexedDB = global.indexedDB;