From b4b33c07de05e66b3a644aca742c34ad1cede3a0 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 2 Feb 2020 23:42:46 -0500 Subject: [PATCH] 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. --- test/content/support.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/content/support.js b/test/content/support.js index 25019a1566..6d4379b05b 100644 --- a/test/content/support.js +++ b/test/content/support.js @@ -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); + }); }); }