|
| 1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 2 | +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 3 | +<head> |
| 4 | + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 5 | + <meta name="viewport" content="width=500"> |
| 6 | + <title>screen iframe</title> |
| 7 | + <link rel="stylesheet" type="text/css" href="testindex.css"> |
| 8 | + <script src="testglobals.js"></script> |
| 9 | + <script src="testgeneric.js"></script> |
| 10 | + <script src="testmain.js"></script> |
| 11 | + <!-- custom --> |
| 12 | + <style> |
| 13 | + table {width: 480px;} |
| 14 | + </style> |
| 15 | +</head> |
| 16 | + |
| 17 | +<body> |
| 18 | + |
| 19 | + <table> |
| 20 | + <tr><td><h2>TorZillaPrint</h2></td></tr> |
| 21 | + <tr><td class="blurb"><a class="return" href="../index.html">return to TZP index</a></td></tr> |
| 22 | + </table> |
| 23 | + |
| 24 | + <table id="tb1"> |
| 25 | + <col width="40%"><col width="60%"> |
| 26 | + <thead><tr><th colspan="2"> |
| 27 | + <div class="nav-title">screen iframe |
| 28 | + <div class="nav-up"><span class="c perf" id="perf"></span></div> |
| 29 | + </div> |
| 30 | + </th></tr></thead> |
| 31 | + |
| 32 | + <tr><td colspan="2" class="center">top level document</td></tr> |
| 33 | + <tr><td>screen</td><td class="c mono spaces" id="doc0"></td></tr> |
| 34 | + <tr><td>available screen</td><td class="c mono spaces" id="doc1"></td></tr> |
| 35 | + <tr><td>outer</td><td class="c mono spaces" id="doc2"></td></tr> |
| 36 | + <tr><td>inner</td><td class="c mono spaces" id="doc3"></td></tr> |
| 37 | + |
| 38 | + <tr><td colspan="2" class="center">a nested iframe</td></tr> |
| 39 | + <tr><td>screen</td><td class="c mono spaces" id="nest0"></td></tr> |
| 40 | + <tr><td>available screen</td><td class="c mono spaces" id="nest1"></td></tr> |
| 41 | + <tr><td>outer</td><td class="c mono spaces" id="nest2"></td></tr> |
| 42 | + <tr><td>inner</td><td class="c mono spaces" id="nest3"></td></tr> |
| 43 | + |
| 44 | + </table> |
| 45 | + <br> |
| 46 | + |
| 47 | +<script> |
| 48 | +'use strict'; |
| 49 | + |
| 50 | +function run() { |
| 51 | + //let t0 = performance.now() |
| 52 | + |
| 53 | + const getNestediFrameWindow = () => { |
| 54 | + const numberOfIframes = window.length |
| 55 | + const div = document.createElement('div') |
| 56 | + //div.setAttribute('style', 'display:none') // this line causes RFP to return zero |
| 57 | + document.body.appendChild(div) |
| 58 | + const id = 'parent-nest' |
| 59 | + const ghost = ` |
| 60 | + style=" |
| 61 | + height: 100vh; |
| 62 | + width: 100vw; |
| 63 | + position: absolute; |
| 64 | + left: -10000px; |
| 65 | + visibility: hidden; |
| 66 | + " |
| 67 | + ` |
| 68 | + div.innerHTML = ` |
| 69 | + <div ${ghost} id="${id}"> |
| 70 | + <iframe ${ghost}></iframe> |
| 71 | + </div> |
| 72 | + ` |
| 73 | + const el = document.getElementById(id) |
| 74 | + return { |
| 75 | + parent: !!el, |
| 76 | + iframeWindow: window[numberOfIframes], |
| 77 | + remove: () => el.parentNode.removeChild(el) |
| 78 | + } |
| 79 | + } |
| 80 | + |
| 81 | + dom.doc0 = screen.width +" x "+ screen.height |
| 82 | + dom.doc1 = screen.availWidth +" x "+ screen.availHeight |
| 83 | + dom.doc2 = window.outerWidth +" x "+ window.outerHeight |
| 84 | + dom.doc3 = window.innerWidth +" x "+ window.innerHeight |
| 85 | + |
| 86 | + const nest = getNestediFrameWindow() |
| 87 | + dom.nest0 = nest.iframeWindow.screen.width +" x "+ nest.iframeWindow.screen.height |
| 88 | + dom.nest1 = nest.iframeWindow.screen.availWidth +" x "+ nest.iframeWindow.screen.availHeight |
| 89 | + dom.nest2 = nest.iframeWindow.window.outerWidth +" x "+ nest.iframeWindow.window.outerHeight |
| 90 | + dom.nest3 = nest.iframeWindow.window.innerWidth +" x "+ nest.iframeWindow.window.innerHeight |
| 91 | + |
| 92 | + if (nest.parent) { |
| 93 | + nest.remove() |
| 94 | + } |
| 95 | + |
| 96 | + // perf |
| 97 | + //dom.perf.innerHTML = Math.round(performance.now() - t0) +" ms" |
| 98 | + |
| 99 | +} |
| 100 | + |
| 101 | +run() |
| 102 | + |
| 103 | +</script> |
| 104 | +</body> |
| 105 | +</html> |
0 commit comments