wait for next paint in about:blank frames, fixes #1165

This commit is contained in:
tophf 2021-02-05 10:35:02 +03:00
parent 784a1018f8
commit 50959354ec

View File

@ -65,11 +65,15 @@
} else { } else {
const SYM_ID = 'styles'; const SYM_ID = 'styles';
const SYM = Symbol.for(SYM_ID); const SYM = Symbol.for(SYM_ID);
const parentStyles = isFrameAboutBlank &&
tryCatch(() => parent[parent.Symbol.for(SYM_ID)]);
const styles = const styles =
window[SYM] || window[SYM] ||
(isFrameAboutBlank /* about:blank iframes are often used by sites for file upload or background tasks
? tryCatch(() => parent[parent.Symbol.for(SYM_ID)]) * and they may break if unexpected DOM stuff is present at `load` event
: chrome.app && !chrome.tabs && tryCatch(getStylesViaXhr)) || * so we'll add the styles in the next tick */
parentStyles && await new Promise(requestAnimationFrame) && parentStyles ||
chrome.app && !chrome.tabs && tryCatch(getStylesViaXhr) ||
await API.styles.getSectionsByUrl(matchUrl, null, true); await API.styles.getSectionsByUrl(matchUrl, null, true);
hasStyles = !styles.disableAll; hasStyles = !styles.disableAll;
if (hasStyles) { if (hasStyles) {