|
82 | 82 | https://ext-code-test.com/html-sandbox/html-sandbox.html |
83 | 83 | --> |
84 | 84 | <div id=hldr> |
85 | | - <iframe src='https://sandbox-ext-code-com-1024713184986.us-central1.run.app/html-sandbox/html-sandbox.html' |
86 | | - sandbox='allow-scripts allow-same-origin allow-forms allow-downloads allow-pointer-lock allow-popups-to-escape-sandbox' |
87 | | - allow='clipboard-write; clipboard-read; camera; microphone; geolocation; accelerometer; gyroscope; magnetometer; payment; usb; serial; bluetooth; |
88 | | - xr-spatial-tracking; autoplay; encrypted-media; picture-in-picture; screen-wake-lock; web-share' |
89 | | - ></iframe> |
| 85 | + <iframe></iframe> |
90 | 86 | <div id=glass></div> |
91 | 87 | </div> |
92 | 88 |
|
|
134 | 130 |
|
135 | 131 |
|
136 | 132 | var sandbox_url; |
137 | | - |
138 | | - |
| 133 | + var iframe_src = 'https://sandbox-ext-code-com-1024713184986.us-central1.run.app/html-sandbox/html-sandbox.html' |
| 134 | + var iframe_sandbox = 'allow-scripts allow-same-origin allow-forms allow-downloads allow-pointer-lock allow-popups-to-escape-sandbox' |
| 135 | + var iframe_allow = `clipboard-write; clipboard-read; camera; microphone; geolocation; accelerometer; gyroscope; magnetometer; payment; usb; serial; bluetooth; |
| 136 | + xr-spatial-tracking; autoplay; encrypted-media; picture-in-picture; screen-wake-lock; web-share`; |
| 137 | + |
| 138 | + |
| 139 | + |
139 | 140 | var btn = {}; |
140 | 141 | btn.console = {}; |
141 | 142 | obj.on = {}; |
|
167 | 168 |
|
168 | 169 | var hdr = $(shadow,'#hdr'); |
169 | 170 |
|
| 171 | + chk.isolate = $.chkbox(hdr,'#isolate'); |
| 172 | + chk.isolate.checked = window.crossOriginIsolated; |
| 173 | + |
170 | 174 | chk['allow-scripts'] = $.chkbox(hdr,'#allow-scripts'); |
171 | 175 | chk['allow-modals'] = $.chkbox(hdr,'#allow-modals'); |
172 | 176 | chk['allow-popups'] = $.chkbox(hdr,'#allow-popups'); |
173 | | - chk['isolate'] = $.chkbox(hdr,'#isolate',btn.isolate); |
174 | 177 |
|
175 | 178 | chk['console-show'] = $.chkbox(hdr,'#console-show',btn.console.show); |
176 | 179 | chk['console-echo'] = $.chkbox(hdr,'#console-echo'); |
|
201 | 204 |
|
202 | 205 | }//kill |
203 | 206 |
|
204 | | - |
| 207 | +/* |
205 | 208 | btn.isolate = function(chk){ |
206 | 209 | |
207 | 210 | var url = new URL(sandbox_url); |
|
213 | 216 | } |
214 | 217 | |
215 | 218 | }//isolate |
216 | | - |
217 | | - |
| 219 | +*/ |
| 220 | + |
| 221 | + |
218 | 222 | btn.console.show = function(chk){ |
219 | 223 |
|
220 | 224 | if(chk.checked){ |
|
289 | 293 | } |
290 | 294 |
|
291 | 295 | var attr = [...tokens].join(' '); |
292 | | - //console.log(attr); |
| 296 | + debug(attr); |
293 | 297 | iframe.setAttribute('sandbox',attr); |
294 | 298 |
|
295 | 299 | }//sandbox |
296 | 300 |
|
297 | 301 |
|
298 | | - obj.srcdoc = function(html){ |
299 | | - |
300 | | - iframe.remove(); |
301 | | - iframe = iframe.cloneNode(); |
302 | | - |
303 | | - build.sandbox(); |
304 | | - |
305 | | - hldr.append(iframe); |
306 | | - |
307 | | - |
308 | | - if(!chk['console-persist'].checked){ |
309 | | - webconsole.clear(); |
310 | | - if(chk['console-echo'].checked){ |
311 | | - console.clear(); |
312 | | - } |
313 | | - } |
314 | | - |
315 | | - iframe.srcdoc = html; |
316 | | - |
317 | | - }//srcdoc |
318 | | - |
319 | | - |
320 | 302 | obj.sandbox = function(html){ |
321 | 303 | debug('sandbox'); |
322 | 304 | iframe.remove(); |
323 | 305 | iframe = iframe.cloneNode(); |
324 | 306 | debug(sandbox_url); |
325 | 307 | build.sandbox(); |
326 | | - iframe.src = sandbox_url; |
| 308 | + |
| 309 | + iframe.setAttribute('allow',iframe_allow); |
| 310 | + debug(iframe_allow); |
| 311 | + var src = iframe.src; |
| 312 | + if(chk.isolate.checked){ |
| 313 | + src += '?isolate'; |
| 314 | + } |
| 315 | + iframe.src = src; |
| 316 | + debug(src); |
327 | 317 | iframe.onload = onload; |
328 | 318 | hldr.append(iframe); |
329 | 319 |
|
| 320 | + |
330 | 321 | function onload(){ |
331 | 322 | debug('onload'); |
332 | 323 | iframe.onload = null; |
|
341 | 332 | var echo = chk['console-echo'].checked; |
342 | 333 | iframe.contentWindow.postMessage({type:'run',html,echo},'*'); |
343 | 334 |
|
344 | | - //var blob=new Blob([html],{type:'text/html'}); |
345 | | - //var url=URL.createObjectURL(blob); |
346 | | - //iframe.src=url; |
347 | | - |
348 | 335 | }//onload |
349 | 336 |
|
350 | 337 | }//sandbox |
351 | 338 |
|
352 | 339 |
|
353 | | - obj.blob = function(html){ |
| 340 | +/* |
| 341 | + obj.srcdoc = function(html){ |
354 | 342 | |
| 343 | + iframe.remove(); |
| 344 | + iframe = iframe.cloneNode(); |
| 345 | + |
| 346 | + build.sandbox(); |
| 347 | + |
| 348 | + hldr.append(iframe); |
| 349 | + |
| 350 | + |
| 351 | + if(!chk['console-persist'].checked){ |
| 352 | + webconsole.clear(); |
| 353 | + if(chk['console-echo'].checked){ |
| 354 | + console.clear(); |
| 355 | + } |
| 356 | + } |
| 357 | + |
| 358 | + iframe.srcdoc = html; |
| 359 | + |
| 360 | + }//srcdoc |
| 361 | +*/ |
| 362 | + |
| 363 | + |
| 364 | +/* |
| 365 | + obj.blob = function(html){ |
355 | 366 | |
| 367 | + var blob=new Blob([html],{type:'text/html'}); |
| 368 | + var url=URL.createObjectURL(blob); |
| 369 | + iframe.src=url; |
| 370 | + |
356 | 371 | }//blob |
357 | | - |
358 | | - |
| 372 | +*/ |
| 373 | + |
359 | 374 | obj.kill = function(){return kill()} //d |
360 | 375 |
|
361 | 376 | function kill(){ |
|
0 commit comments