Fix firefox iframe timing issue, fixes #25
This commit is contained in:
@@ -44,17 +44,23 @@ var layoutTestUtils = (function() {
|
||||
};
|
||||
}
|
||||
|
||||
function renderIframe() {
|
||||
var iframe = document.createElement('iframe');
|
||||
document.body.appendChild(iframe);
|
||||
return iframe;
|
||||
}
|
||||
|
||||
var cachedIframe;
|
||||
function getIframe() {
|
||||
if (cachedIframe) {
|
||||
return cachedIframe;
|
||||
}
|
||||
var iframe = document.createElement('iframe');
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
var doc = iframe.contentDocument;
|
||||
|
||||
if(doc.readyState === 'complete') {
|
||||
var style = document.createElement('style');
|
||||
style.innerText = (function() {/*
|
||||
style.textContent = (function() {/*
|
||||
body, div {
|
||||
box-sizing: border-box;
|
||||
border: 0 solid black;
|
||||
@@ -83,8 +89,15 @@ var layoutTestUtils = (function() {
|
||||
doc.head.appendChild(style);
|
||||
cachedIframe = iframe;
|
||||
return iframe;
|
||||
} else {
|
||||
setTimeout(getIframe, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
var iframe = renderIframe();
|
||||
getIframe();
|
||||
}
|
||||
|
||||
if (typeof computeLayout === 'function') {
|
||||
var realComputeLayout = computeLayout;
|
||||
|
Reference in New Issue
Block a user