Replace hidden browser usage in translateTest with a DOMParser doc

This commit is contained in:
Adomas Venčkauskas 2018-08-27 16:12:32 +03:00
parent 2095f38ea5
commit 87c4eec3ef

View file

@ -17,10 +17,10 @@ function saveItemsThroughTranslator(translatorType, items) {
} }
let translate = new Zotero.Translate[tyname](); let translate = new Zotero.Translate[tyname]();
let browser;
if (translatorType == "web") { if (translatorType == "web") {
browser = Zotero.Browser.createHiddenBrowser(); let doc = Zotero.HTTP.wrapDocument(new DOMParser().parseFromString('<html></html>', 'text/html'),
translate.setDocument(browser.contentDocument); `http://localhost/`);
translate.setDocument(doc);
} else if (translatorType == "import") { } else if (translatorType == "import") {
translate.setString(""); translate.setString("");
} }
@ -35,10 +35,7 @@ function saveItemsThroughTranslator(translatorType, items) {
" item.complete();\n"+ " item.complete();\n"+
" }\n"+ " }\n"+
"}")); "}"));
return translate.translate().then(function(items) { return translate.translate();
if (browser) Zotero.Browser.deleteHiddenBrowser(browser);
return items;
});
} }
/** /**