From fbd0b96f494b4a6b3293a98486e8c40081e30390 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 5 Jul 2018 22:49:47 +0300 Subject: [PATCH] fixup 7f5a5fec: give iframe time to run our content script --- popup/search-results.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/popup/search-results.js b/popup/search-results.js index 2e2250f6..a6636d43 100755 --- a/popup/search-results.js +++ b/popup/search-results.js @@ -788,10 +788,7 @@ window.addEventListener('showStyles:done', function _() { const data = {url, resolve, reject, timeout}; usoFrameQueue.set(id, data); usoFrame.contentWindow.postMessage({xhr: {id, url}}, '*'); - }) : - setupFrame() - .then(() => new Promise(setTimeout)) - .then(() => downloadInFrame(url)); + }) : setupFrame().then(() => downloadInFrame(url)); } function setupFrame() { @@ -847,6 +844,9 @@ window.addEventListener('showStyles:done', function _() { const done = event => { chrome.webRequest.onHeadersReceived.removeListener(stripHeaders); (event.type === 'load' ? resolve : reject)(); + usoFrameQueue.forEach(({url}, id) => { + usoFrame.contentWindow.postMessage({xhr: {id, url}}, '*'); + }); }; usoFrame.addEventListener('load', done, {once: true}); usoFrame.addEventListener('error', done, {once: true});