test-ref-iframe.js (748B)
1 function setupIframe() { 2 var iframe = document.querySelector('iframe'); 3 var html = "<style id=style></style><div id=test></div><div id=ref></div><svg><circle id=svg /><circle id=svg_ref /></svg>"; 4 if (iframe.className === "limited-quirks") { 5 html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' + html; 6 } else if (iframe.className === "no-quirks") { 7 html = '<!DOCTYPE HTML>' + html; 8 } 9 window.quirks = iframe.className === "quirks"; 10 window.win = iframe.contentWindow; 11 win.document.open(); 12 win.document.write(html); 13 win.document.close(); 14 ['style', 'test', 'ref', 'svg', 'svg_ref'].forEach(function(id) { 15 win[id] = win.document.getElementById(id); 16 }); 17 }