Add a delay after the first browser initialization during tests
The window-loading process is different in Firefox, and running a test that creates items while the window is still loading can cause things to fail.
This commit is contained in:
parent
eec0f00784
commit
b4b33c07de
1 changed files with 11 additions and 1 deletions
|
@ -4,6 +4,7 @@ chai.use(chaiAsPromised);
|
|||
var sqlDateTimeRe = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
|
||||
var isoDateTimeRe = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;
|
||||
var zoteroObjectKeyRe = /^[23456789ABCDEFGHIJKLMNPQRSTUVWXYZ]{8}$/; // based on Zotero.Utilities::generateObjectKey()
|
||||
var browserWindowInitialized = false;
|
||||
|
||||
/**
|
||||
* Waits for a DOM event on the specified node. Returns a promise
|
||||
|
@ -49,7 +50,16 @@ function loadWindow(winurl, argument) {
|
|||
function loadBrowserWindow() {
|
||||
var win = window.openDialog("chrome://browser/content/browser.xul", "", "all,height=700,width=1000");
|
||||
return waitForDOMEvent(win, "load").then(function() {
|
||||
return win;
|
||||
return new Zotero.Promise((resolve) => {
|
||||
if (!browserWindowInitialized) {
|
||||
setTimeout(function () {
|
||||
browserWindowInitialized = true;
|
||||
resolve(win);
|
||||
}, 1000);
|
||||
return;
|
||||
}
|
||||
resolve(win);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue