echo-policy-nested.html (1266B)
1 <!DOCTYPE html> 2 <body> 3 <script> 4 // This document will contain an iframe which will either host echo-policy.py, 5 // or will host another copy of this document, with the nesting level reduced 6 // by one. This way, an arbitrary nesting depth can be achieved, with the 7 // final inner-most frame reporting back the advertised required policy. 8 9 // The 'id' URL parameter will be passed to the nested document. 10 // The 'level' URL paramater will be reduced by 1 and passed to the nested 11 // document if it was at least 1. (If it was 0, then echo-policy.py will be 12 // nested instead, and the level parameter will not be passed.) 13 14 // This document is served with a Document Policy header that should satisfy 15 // any requests that include a required policy for the 16 // 'lossless-images-max-bpp' feature. 17 const params = new URLSearchParams(window.location.search); 18 const id = params.get('id'); 19 const level = params.get('level'); 20 21 const iframe = document.createElement('iframe'); 22 var hostname; 23 if (level >= 1) { 24 params.set('level',level-1); 25 hostname = document.location.pathname + "?" + params.toString(); 26 } else { 27 params.delete('level'); 28 hostname = "/document-policy/echo-policy.py?" + params.toString(); 29 } 30 iframe.src = hostname; 31 document.body.appendChild(iframe); 32 </script>