Automatically close rogue dialog boxes
A few sites (e.g., Gallica) were causing alerts to pop up in Standalone during testing, which breaks testing, so accept them automatically. (Hopefully these don't happen during manual translation...?)
This commit is contained in:
parent
6ad195521b
commit
1266c9f1e6
1 changed files with 23 additions and 0 deletions
|
@ -40,6 +40,8 @@ Zotero_TranslatorTesters = new function() {
|
||||||
* Runs all tests
|
* Runs all tests
|
||||||
*/
|
*/
|
||||||
this.runAllTests = function (numConcurrentTests, skipTranslators, resultsCallback) {
|
this.runAllTests = function (numConcurrentTests, skipTranslators, resultsCallback) {
|
||||||
|
waitForDialog();
|
||||||
|
|
||||||
if(!Zotero) {
|
if(!Zotero) {
|
||||||
Zotero = Components.classes["@zotero.org/Zotero;1"]
|
Zotero = Components.classes["@zotero.org/Zotero;1"]
|
||||||
.getService(Components.interfaces.nsISupports).wrappedJSObject;
|
.getService(Components.interfaces.nsISupports).wrappedJSObject;
|
||||||
|
@ -109,6 +111,27 @@ Zotero_TranslatorTesters = new function() {
|
||||||
runNextTester();
|
runNextTester();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function waitForDialog() {
|
||||||
|
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||||
|
var loadobserver = function (ev) {
|
||||||
|
ev.originalTarget.removeEventListener("load", loadobserver, false);
|
||||||
|
if (ev.target.location == "chrome://global/content/commonDialog.xul") {
|
||||||
|
let win = ev.target.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||||
|
.getInterface(Components.interfaces.nsIDOMWindow);
|
||||||
|
Zotero.debug("Closing rogue dialog box!\n\n" + win.document.documentElement.textContent, 2);
|
||||||
|
win.document.documentElement.getButton('accept').click();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var winobserver = {
|
||||||
|
observe: function (subject, topic, data) {
|
||||||
|
if (topic != "domwindowopened") return;
|
||||||
|
var win = subject.QueryInterface(Components.interfaces.nsIDOMWindow);
|
||||||
|
win.addEventListener("load", loadobserver, false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Services.ww.registerNotification(winobserver);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue