summaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-13 23:33:11 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-14 11:12:39 -0500
commit0bbba8fcc7b673d3164f70a9f030f45b9b2b1f58 (patch)
treebcce6880f474afa1aac81f10f3ec3e77a6666535 /ext/bg
parentddaf44ba7bfa8399ddc5e7f7025229f9aa03c700 (diff)
Isolate values returned across window contexts
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/util.js39
1 files changed, 20 insertions, 19 deletions
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index 96d549c9..42480c37 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -35,6 +35,7 @@ function utilIsolate(value) {
function utilFunctionIsolate(func) {
return function (...args) {
try {
+ args = args.map((v) => utilIsolate(v));
return func.call(this, ...args);
} catch (e) {
try {
@@ -99,49 +100,49 @@ function utilBackend() {
return chrome.extension.getBackgroundPage().yomichan_backend;
}
-function utilAnkiGetModelNames() {
- return utilBackend().anki.getModelNames();
+async function utilAnkiGetModelNames() {
+ return utilIsolate(await utilBackend().anki.getModelNames());
}
-function utilAnkiGetDeckNames() {
- return utilBackend().anki.getDeckNames();
+async function utilAnkiGetDeckNames() {
+ return utilIsolate(await utilBackend().anki.getDeckNames());
}
-function utilDatabaseGetDictionaryInfo() {
- return utilBackend().translator.database.getDictionaryInfo();
+async function utilDatabaseGetDictionaryInfo() {
+ return utilIsolate(await utilBackend().translator.database.getDictionaryInfo());
}
-function utilDatabaseGetDictionaryCounts(dictionaryNames, getTotal) {
- return utilBackend().translator.database.getDictionaryCounts(
+async function utilDatabaseGetDictionaryCounts(dictionaryNames, getTotal) {
+ return utilIsolate(await utilBackend().translator.database.getDictionaryCounts(
utilBackgroundIsolate(dictionaryNames),
utilBackgroundIsolate(getTotal)
- );
+ ));
}
-function utilAnkiGetModelFieldNames(modelName) {
- return utilBackend().anki.getModelFieldNames(
+async function utilAnkiGetModelFieldNames(modelName) {
+ return utilIsolate(await utilBackend().anki.getModelFieldNames(
utilBackgroundIsolate(modelName)
- );
+ ));
}
-function utilDatabasePurge() {
- return utilBackend().translator.purgeDatabase();
+async function utilDatabasePurge() {
+ return utilIsolate(await utilBackend().translator.purgeDatabase());
}
-function utilDatabaseDeleteDictionary(dictionaryName, onProgress) {
- return utilBackend().translator.database.deleteDictionary(
+async function utilDatabaseDeleteDictionary(dictionaryName, onProgress) {
+ return utilIsolate(await utilBackend().translator.database.deleteDictionary(
utilBackgroundIsolate(dictionaryName),
utilBackgroundFunctionIsolate(onProgress)
- );
+ ));
}
async function utilDatabaseImport(data, onProgress, details) {
data = await utilReadFile(data);
- return utilBackend().translator.database.importDictionary(
+ return utilIsolate(await utilBackend().translator.database.importDictionary(
utilBackgroundIsolate(data),
utilBackgroundFunctionIsolate(onProgress),
utilBackgroundIsolate(details)
- );
+ ));
}
function utilReadFile(file) {