sandboxed-iframe-fetch-event-iframe.py (652B)
1 import os.path 2 3 from wptserve.utils import isomorphic_decode 4 5 def main(request, response): 6 header = [(b'Content-Type', b'text/html')] 7 if b'test' in request.GET: 8 with open(os.path.join(os.path.dirname(isomorphic_decode(__file__)), u'sample.js'), u'r') as f: 9 body = f.read() 10 return (header, body) 11 12 if b'sandbox' in request.GET: 13 header.append((b'Content-Security-Policy', 14 b'sandbox %s' % request.GET[b'sandbox'])) 15 with open(os.path.join(os.path.dirname(isomorphic_decode(__file__)), 16 u'sandboxed-iframe-fetch-event-iframe.html'), u'r') as f: 17 body = f.read() 18 return (header, body)