Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/workers/data-url-shared.html

Issue 2697003002: Fix incorrect tests for storage APIs in data: URL workers (Closed)
Patch Set: Added comment for the indexedDB test. Improved Web Sql Database test name. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/external/wpt/workers/data-url.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>data URL shared worker</title> 2 <title>data URL shared worker</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 function assert_worker_sends_pass(test_desc, mime_type, worker_code) { 7 function assert_worker_sends_pass(test_desc, mime_type, worker_code) {
8 async_test(function(t) { 8 async_test(function(t) {
9 var w = new SharedWorker(`data:${mime_type},onconnect = function(e) { port = e.ports[0]; ${worker_code}}`); 9 var w = new SharedWorker(`data:${mime_type},onconnect = function(e) { port = e.ports[0]; ${worker_code}}`);
10 w.port.onmessage = t.step_func_done(function(e) { 10 w.port.onmessage = t.step_func_done(function(e) {
11 assert_equals(e.data, 'PASS'); 11 assert_equals(e.data, 'PASS');
12 }); 12 });
13 w.port.postMessage('SEND_PASS'); 13 w.port.postMessage('SEND_PASS');
14 }, test_desc); 14 }, test_desc);
15 } 15 }
16 16
17 function assert_worker_throws(test_desc, worker_code, before_connect_worker_code ) { 17 function assert_worker_throws(test_desc, worker_code, before_connect_worker_code ) {
18 assert_worker_sends_pass(test_desc, '', `try { ${worker_code}; port.postMessag e("FAIL"); } catch (e) { port.postMessage("PASS"); }`, before_connect_worker_cod e); 18 assert_worker_sends_pass(test_desc, '', `try { ${worker_code}; port.postMessag e("FAIL"); } catch (e) { port.postMessage("PASS"); }`, before_connect_worker_cod e);
19 } 19 }
20 20
21 // Any MIME type allowed 21 // Any MIME type allowed
22 assert_worker_sends_pass('application/javascript MIME allowed', 'application/jav ascript', 'port.postMessage("PASS")'); 22 assert_worker_sends_pass('application/javascript MIME allowed', 'application/jav ascript', 'port.postMessage("PASS")');
23 assert_worker_sends_pass('text/plain MIME allowed', 'text/plain', 'port.postMess age("PASS")'); 23 assert_worker_sends_pass('text/plain MIME allowed', 'text/plain', 'port.postMess age("PASS")');
24 assert_worker_sends_pass('empty MIME allowed', '', 'port.postMessage("PASS")'); 24 assert_worker_sends_pass('empty MIME allowed', '', 'port.postMessage("PASS")');
25 25
26 // Communications goes both ways 26 // Communications goes both ways
27 assert_worker_sends_pass('communication goes both ways', 'application/javascript ', 'port.onmessage = function(e) { port.postMessage("PASS"); }'); 27 assert_worker_sends_pass('communication goes both ways', 'application/javascript ', 'port.onmessage = function(e) { port.postMessage("PASS"); }');
28 28
29 // test access to storage APIs
30 // once https://github.com/w3c/IndexedDB/pull/150 lands, this is spec conforming
31 assert_worker_throws('indexedDB inaccessible', 'self.indexedDB.open("someDBName" )');
32 assert_worker_throws('Web SQL Database inaccessible', 'self.openDatabase("someDB Name", "1.0", "someDBName", 1);');
33
29 // 'data:' workers are cross-origin 34 // 'data:' workers are cross-origin
30 assert_worker_throws('indexedDB inaccessible', 'self.indexedDB.open("someDBName" )');
31 assert_worker_throws('localStorage inaccessible', 'self.localStorage.testItem');
32 assert_worker_sends_pass('cross-origin worker', '', 'fetch("/").then(() => port. postMessage("FAIL"), () => port.postMessage("PASS"))'); 35 assert_worker_sends_pass('cross-origin worker', '', 'fetch("/").then(() => port. postMessage("FAIL"), () => port.postMessage("PASS"))');
33
34 // 'data:' workers have opaque origin 36 // 'data:' workers have opaque origin
35 assert_worker_sends_pass('worker has opaque origin', 'application/javascript', ' if (self.location.origin == "null") port.postMessage("PASS"); else port.postMess age("FAIL");'); 37 assert_worker_sends_pass('worker has opaque origin', 'application/javascript', ' if (self.location.origin == "null") port.postMessage("PASS"); else port.postMess age("FAIL");');
36 </script> 38 </script>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/external/wpt/workers/data-url.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698