Scaffold: Improve cookie handling
- Use cookies from browser pane when running detectWeb or doWeb - Use cookies from document when running or updating tests This should fix various cases where translators can't be properly developed or tested in Scaffold (e.g., [1]). [1] https://github.com/zotero/translators/pull/2296#issuecomment-739116620
This commit is contained in:
parent
01646f1f8f
commit
558ad20ce6
2 changed files with 18 additions and 0 deletions
|
@ -514,6 +514,13 @@ var Scaffold = new function() {
|
|||
return;
|
||||
}
|
||||
translate.setDocument(input);
|
||||
|
||||
// Use cookies from browser pane
|
||||
translate.setCookieSandbox(new Zotero.CookieSandbox(
|
||||
null,
|
||||
_getDocumentURL(input),
|
||||
input.cookie
|
||||
));
|
||||
} else if (functionToRun == "detectImport" || functionToRun == "doImport") {
|
||||
var translate = new Zotero.Translate.Import();
|
||||
translate.setString(input);
|
||||
|
|
|
@ -425,6 +425,9 @@ Zotero_TranslatorTester.prototype.fetchPageAndRunTest = function (test, testDone
|
|||
+ " second(s) for page content to settle");
|
||||
}
|
||||
setTimeout(() => {
|
||||
// Use cookies from document in translator HTTP requests
|
||||
this._cookieSandbox = new Zotero.CookieSandbox(null, test.url, doc.cookie);
|
||||
|
||||
this.runTest(test, doc, function (obj, test, status, message) {
|
||||
Zotero.Browser.deleteHiddenBrowser(browser);
|
||||
testDoneCallback(obj, test, status, message);
|
||||
|
@ -639,6 +642,14 @@ Zotero_TranslatorTester.prototype.newTest = function(doc, testReadyCallback) {
|
|||
translate.setTranslatorProvider(this.translatorProvider);
|
||||
}
|
||||
translate.setDocument(doc);
|
||||
// Use cookies from document
|
||||
if (doc.cookie) {
|
||||
translate.setCookieSandbox(new Zotero.CookieSandbox(
|
||||
null,
|
||||
doc.location.href,
|
||||
doc.cookie
|
||||
));
|
||||
}
|
||||
translate.setTranslator(this.translator);
|
||||
translate.setHandler("debug", this._debug);
|
||||
translate.setHandler("select", function(obj, items, callback) {
|
||||
|
|
Loading…
Reference in a new issue