Skip to content

Commit

Permalink
Merge pull request mozilla#2671 from yurydelendik/chrome
Browse files Browse the repository at this point in the history
Workaround for Chrome's issue 174023
  • Loading branch information
mduan committed Feb 4, 2013
2 parents bf8b10c + 133d5cf commit 2260458
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,9 @@ var FontLoader = {
}
request.complete();
// cleanup
document.body.removeChild(frame);
if (frame) {
document.body.removeChild(frame);
}
window.removeEventListener('message', fontLoaderMessage, false);
},
false);
Expand All @@ -657,6 +659,17 @@ var FontLoader = {
src += '<p style="font-family:\'' + names[i] + '\'">Hi</p>';
}
src += '</body></html>';

var MAX_IFRAME_SRC_LENGTH = 1000000, IFRAME_TIMEOUT = 2000;
// Chrome fails for long src attributes (see issue 174023)
if (src.length > MAX_IFRAME_SRC_LENGTH) {
// ... waiting for some fixed period of time instead
window.setTimeout(function() {
window.postMessage(requestId, '*');
}, IFRAME_TIMEOUT);
return;
}

var frame = document.createElement('iframe');
frame.src = 'data:text/html,' + src;
frame.setAttribute('style',
Expand Down

0 comments on commit 2260458

Please sign in to comment.