www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 1266c9f1e61b66035caa6188014c6ab7059fc233
parent 6ad195521b1e53a2f34faeef6226ce0a47410bab
Author: Dan Stillman <dstillman@zotero.org>
Date:   Wed, 31 Aug 2016 02:50:02 -0400

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...?)

Diffstat:
Mchrome/content/zotero/tools/testTranslators/translatorTester.js | 23+++++++++++++++++++++++
1 file changed, 23 insertions(+), 0 deletions(-)

diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js @@ -40,6 +40,8 @@ Zotero_TranslatorTesters = new function() { * Runs all tests */ this.runAllTests = function (numConcurrentTests, skipTranslators, resultsCallback) { + waitForDialog(); + if(!Zotero) { Zotero = Components.classes["@zotero.org/Zotero;1"] .getService(Components.interfaces.nsISupports).wrappedJSObject; @@ -109,6 +111,27 @@ Zotero_TranslatorTesters = new function() { 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); + } } /**