Don't break gmail chat iframe by iframeObserver

Apparently some same-domain (!) iframes fail to load when their "contentDocument" is accessed (!)
This commit is contained in:
tophf 2015-08-04 21:54:56 +03:00
parent ad12fb1091
commit 92c2e743d6

View File

@ -216,6 +216,13 @@ function initObserver() {
getDynamicIFrames(document).forEach(addDocumentStylesToIFrame); getDynamicIFrames(document).forEach(addDocumentStylesToIFrame);
return; return;
} }
// move the check out of current execution context
// because some same-domain (!) iframes fail to load when their "contentDocument" is accessed (!)
// namely gmail's old chat iframe talkgadget.google.com
setTimeout(process.bind(null, mutations), 0);
});
function process(mutations) {
for (var m = 0, ml = mutations.length; m < ml; m++) { for (var m = 0, ml = mutations.length; m < ml; m++) {
var mutation = mutations[m]; var mutation = mutations[m];
if (mutation.type === "childList") { if (mutation.type === "childList") {
@ -227,7 +234,7 @@ function initObserver() {
} }
} }
} }
}); }
iframeObserver.start = function() { iframeObserver.start = function() {
// will be ignored by browser if already observing // will be ignored by browser if already observing