Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Test workers can be started with a data URL</title> | 2 <title>Test workers can be started with a data URL</title> |
| 3 <script src="/resources/testharness.js"></script> | 3 <script src="/resources/testharness.js"></script> |
| 4 <script src="/resources/testharnessreport.js"></script> | 4 <script src="/resources/testharnessreport.js"></script> |
| 5 <div id="log"></div> | 5 <div id="log"></div> |
| 6 <script> | 6 <script> |
| 7 // Helper assert functions -START- | 7 // Helper assert functions -START- |
| 8 function assert_worker_sends_pass(test_desc, mime_type, worker_code) { | 8 function assert_worker_sends_pass(test_desc, mime_type, worker_code) { |
| 9 async_test(function(t) { | 9 async_test(function(t) { |
| 10 var w = new Worker(`data:${mime_type},${worker_code}`); | 10 var w = new Worker(`data:${mime_type},${worker_code}`); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 | 35 |
| 36 // Any MIME type | 36 // Any MIME type |
| 37 assert_worker_sends_pass('application/javascript MIME allowed', 'application/jav ascript', 'self.postMessage("PASS")'); | 37 assert_worker_sends_pass('application/javascript MIME allowed', 'application/jav ascript', 'self.postMessage("PASS")'); |
| 38 assert_worker_sends_pass('text/plain MIME allowed', 'text/plain', 'self.postMess age("PASS")'); | 38 assert_worker_sends_pass('text/plain MIME allowed', 'text/plain', 'self.postMess age("PASS")'); |
| 39 assert_worker_sends_pass('empty MIME allowed', '', 'self.postMessage("PASS")'); | 39 assert_worker_sends_pass('empty MIME allowed', '', 'self.postMessage("PASS")'); |
| 40 | 40 |
| 41 // Communications goes both ways | 41 // Communications goes both ways |
| 42 assert_worker_sends_pass('communication goes both ways', 'application/javascript ', 'onmessage = function(e) { self.postMessage("PASS"); }'); | 42 assert_worker_sends_pass('communication goes both ways', 'application/javascript ', 'onmessage = function(e) { self.postMessage("PASS"); }'); |
| 43 | 43 |
| 44 // 'data:' workers are cross-origin | 44 // 'data:' workers are cross-origin |
| 45 assert_worker_throws('indexedDB inaccessible', 'self.indexedDB.open("someDBName" )'); | 45 assert_worker_throws('indexedDB inaccessible', 'self.indexedDB.open("someDBName" )'); |
|
jochen (gone - plz use gerrit)
2017/02/15 08:50:41
once https://github.com/w3c/IndexedDB/pull/150 lan
andypaicu2
2017/02/15 09:10:54
Added a comment on this test
| |
| 46 assert_worker_throws('localStorage inaccessible', 'self.localStorage.testItem'); | |
| 47 assert_worker_sends_pass('cross-origin worker', '', 'fetch("/").then(() => self. postMessage("FAIL"), () => self.postMessage("PASS"))'); | 46 assert_worker_sends_pass('cross-origin worker', '', 'fetch("/").then(() => self. postMessage("FAIL"), () => self.postMessage("PASS"))'); |
| 47 assert_worker_throws('websql inaccessible', 'self.openDatabase("someDBName", "1. 0", "someDBName", 1);'); | |
| 48 | 48 |
| 49 // 'data:' workers have opaque origin | 49 // 'data:' workers have opaque origin |
| 50 assert_worker_sends_pass('worker has opaque origin', 'application/javascript', ' if (self.location.origin == "null") postMessage("PASS"); else postMessage("FAIL" );'); | 50 assert_worker_sends_pass('worker has opaque origin', 'application/javascript', ' if (self.location.origin == "null") postMessage("PASS"); else postMessage("FAIL" );'); |
| 51 | 51 |
| 52 // invalid javascript will trigger an ErrorEvent | 52 // invalid javascript will trigger an ErrorEvent |
| 53 assert_worker_construction_fails('invalid javascript produces error', 'applicati on/javascript', '}x=3'); | 53 assert_worker_construction_fails('invalid javascript produces error', 'applicati on/javascript', '}x=3'); |
| 54 | 54 |
| 55 // Actual tests -END- | 55 // Actual tests -END- |
| 56 </script> | 56 </script> |
| OLD | NEW |