From 1c1a9f280473375f1b9b8264b6bf1b2b4bf2bae2 Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 27 Jun 2017 12:55:47 +0300 Subject: [PATCH] fixup e199e1b3 for non-e10s FF: moar timeouts! --- .eslintrc | 1 + backup/fileSaveLoad.js | 14 ++++++++------ messaging.js | 7 +++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.eslintrc b/.eslintrc index 8256da07..077ef42c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -37,6 +37,7 @@ globals: saveStyleSafe: false sessionStorageHash: false download: false + doTimeout: false # localization.js template: false t: false diff --git a/backup/fileSaveLoad.js b/backup/fileSaveLoad.js index 5bf027a5..e8fd7de4 100644 --- a/backup/fileSaveLoad.js +++ b/backup/fileSaveLoad.js @@ -329,14 +329,16 @@ $('#file-all-styles').onclick = () => { tag: 'iframe', style: 'width: 0; height: 0; position: fixed; opacity: 0;'.replace(/;/g, '!important;'), })); - setTimeout(() => { + doTimeout().then(() => { link = iframe.contentDocument.importNode(link, true); iframe.contentDocument.body.appendChild(link); - link.dispatchEvent(new MouseEvent('click')); - setTimeout(() => { - URL.revokeObjectURL(objectURL); - iframe.remove(); - }, 1000); + }) + .then(doTimeout) + .then(() => link.dispatchEvent(new MouseEvent('click'))) + .then(doTimeout(1000)) + .then(() => { + URL.revokeObjectURL(objectURL); + iframe.remove(); }); } }); diff --git a/messaging.js b/messaging.js index cdee9fe0..f7ffeea6 100644 --- a/messaging.js +++ b/messaging.js @@ -359,3 +359,10 @@ function download(url) { xhr.send(query); }); } + + +function doTimeout(ms = 0, ...args) { + return ms > 0 + ? () => new Promise(resolve => setTimeout(resolve, ms, ...args)) + : new Promise(resolve => setTimeout(resolve, 0, ...args)); +}