|
13 | 13 | {display:flex} |
14 | 14 |
|
15 | 15 | .radio |
16 | | - {border:1px solid lightgray;padding:2px 10px;border-radius:5px} |
| 16 | + {border:1px solid lightgray;padding:2px 10px;border-radius:5px;cursor:pointer} |
17 | 17 |
|
18 | 18 | #hldr |
19 | 19 | {flex:1;box-sizing:border-box;position:relative} |
|
26 | 26 |
|
27 | 27 | <div id=hdr> |
28 | 28 | <span id=allow-scripts class=radio> |
29 | | - <input type=checkbox> |
| 29 | + <input type=checkbox checked> |
30 | 30 | allow-scripts |
31 | 31 | </span> |
| 32 | + <span id=allow-modals class=radio> |
| 33 | + <input type=checkbox checked> |
| 34 | + allow-modals |
| 35 | + </span> |
| 36 | + <span id=allow-popups class=radio> |
| 37 | + <input type=checkbox checked> |
| 38 | + allow-popups |
| 39 | + </span> |
| 40 | + |
32 | 41 | <div style='flex:1'></div> |
33 | 42 | <button id=kill style='margin-right:20px'>kill</button> |
34 | 43 | </div> |
35 | 44 |
|
36 | 45 | <div id=hldr> |
37 | | - <iframe sandbox='allow-scripts allow-forms allow-popups allow-modals allow-downloads allow-pointer-lock allow-same-origin'></iframe> |
| 46 | + <iframe sandbox='allow-forms allow-downloads allow-pointer-lock allow-popups-to-escape-sandbox allow-same-origin'></iframe> |
38 | 47 | <div id=glass></div> |
39 | 48 | </div> |
40 | 49 |
|
|
69 | 78 |
|
70 | 79 | var hldr; |
71 | 80 | var iframe; |
| 81 | + var def_sandbox; |
72 | 82 | var glass; |
73 | 83 |
|
74 | 84 |
|
|
95 | 105 |
|
96 | 106 | var hdr = $(shadow,'#hdr'); |
97 | 107 | chk['allow-scripts'] = $.chkbox(hdr,'#allow-scripts'); |
98 | | - console.log(chk); |
| 108 | + chk['allow-modals'] = $.chkbox(hdr,'#allow-modals'); |
| 109 | + chk['allow-popups'] = $.chkbox(hdr,'#allow-popups'); |
| 110 | + |
99 | 111 | $(hdr,'#kill').onclick = btn.kill; |
100 | 112 |
|
101 | 113 |
|
102 | 114 | hldr = $(shadow,'#hldr'); |
103 | 115 | iframe = $(shadow,'iframe'); |
| 116 | + def_sandbox = iframe.getAttribute('sandbox'); |
104 | 117 | glass = $(shadow,'#glass'); |
105 | 118 |
|
106 | 119 |
|
|
147 | 160 |
|
148 | 161 | obj.srcdoc = function(html){ |
149 | 162 |
|
150 | | - var attr = iframe.getAttribute('sandbox'); |
| 163 | + var attr = def_sandbox; |
| 164 | + console.log(attr); |
151 | 165 | var tokens = new Set(attr.split(/\s+/).filter(Boolean)); |
| 166 | + |
152 | 167 | if(chk['allow-scripts'].checked){ |
153 | 168 | tokens.add('allow-scripts'); |
154 | 169 | } |
| 170 | + if(chk['allow-modals'].checked){ |
| 171 | + tokens.add('allow-modals'); |
| 172 | + } |
| 173 | + if(chk['allow-popups'].checked){ |
| 174 | + tokens.add('allow-popups'); |
| 175 | + } |
| 176 | + |
155 | 177 | var attr = [...tokens].join(' '); |
156 | | - console.log(attr); |
| 178 | + console.log(attr); |
157 | 179 | iframe.setAttribute('sandbox',attr); |
158 | 180 |
|
159 | 181 | iframe.srcdoc = html; |
|
0 commit comments