From e199e1b3c709beba238eca5b8a0fb16169237632 Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 25 Jun 2017 18:17:52 +0300 Subject: [PATCH] FF-e10s bug workaround: do export via iframe --- backup/fileSaveLoad.js | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/backup/fileSaveLoad.js b/backup/fileSaveLoad.js index d0c946a2..336273fa 100644 --- a/backup/fileSaveLoad.js +++ b/backup/fileSaveLoad.js @@ -302,12 +302,31 @@ $('#file-all-styles').onclick = () => { .then(res => res.blob()) .then(blob => { const objectURL = URL.createObjectURL(blob); - Object.assign(document.createElement('a'), { - download: generateFileName(), + let link = $element({ + tag:'a', href: objectURL, type: 'application/json', - }).dispatchEvent(new MouseEvent('click')); - setTimeout(() => URL.revokeObjectURL(objectURL)); + download: generateFileName(), + }); + // TODO: remove the fallback when FF multi-process bug is fixed + if (!FIREFOX) { + link.dispatchEvent(new MouseEvent('click')); + setTimeout(() => URL.revokeObjectURL(objectURL)); + } else { + const iframe = document.body.appendChild($element({ + tag: 'iframe', + style: 'width: 0; height: 0; position: fixed; opacity: 0;'.replace(/;/g, '!important;'), + })); + setTimeout(() => { + link = iframe.contentDocument.importNode(link, true); + iframe.contentDocument.body.appendChild(link); + link.dispatchEvent(new MouseEvent('click')); + setTimeout(() => { + URL.revokeObjectURL(objectURL); + iframe.remove(); + }, 1000); + }); + } }); function generateFileName() {