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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/workers/worker-allow-data-url.html

Issue 2685543002: Support data URLs in worker constructors (Closed)
Patch Set: Changes to allow data URL workers 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/workers/worker-allow-data-url.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/workers/worker-allow-data-url.html b/third_party/WebKit/LayoutTests/http/tests/workers/worker-allow-data-url.html
new file mode 100644
index 0000000000000000000000000000000000000000..1bbed27dcc38569dcfd060fdcaf7274ef785df42
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/workers/worker-allow-data-url.html
@@ -0,0 +1,45 @@
+<!doctype html>
Mike West 2017/02/08 13:15:44 Please update the test in //LayoutTests/external/w
andypaicu2 2017/02/10 10:25:37 Done
+<title>Test workers can be started with a data URL</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script>
+async_test(function(t) {
Mike West 2017/02/08 13:15:44 I think we can cut the repetition here by extracti
andypaicu2 2017/02/10 10:25:37 Done
+ w = new Worker('data:application/javascript,onmessage = function(e) {postMessage("PASS");}');
+ w.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data, 'PASS');
+ });
+ w.postMessage('Please Pass');
+}, 'Basic data Worker check');
+
+async_test(function(t) {
+ w = new Worker('DaTA:application/javascript,onmessage = function(e) {postMessage("PASS");}');
+ w.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data, 'PASS');
+ });
+ w.postMessage('Please Pass');
+}, 'Case-insensitive protocol Worker check');
+
+async_test(function(t) {
+ assert_throws(null, new Worker('data:application/javascript,postMessage(localStorage.testItem)'), 'Should not be able to access local storage');
+ t.done();
+}, 'Test access to local storage');
+
+async_test(function(t) {
+ assert_throws(null, new Worker('data:application/javascript,postMessage(indexedDB.open("bug270979"))'), 'Should not be able to access indexedDB');
+ t.done();
+}, 'Test access to indexedDB');
+
+async_test(function(t) {
+ w = new Worker('data:application/javascript,postMessage(location.origin)');
+ w.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data, 'null');
+ });
+}, 'Test worker origin');
+
+async_test(function(t) {
+ assert_throws('SecurityError',
+ function() { w = new Worker('http://example.test:8000/test.js'); },
+ 'Still can not create ordinary cross-origin worker');
+ t.done();
+}, 'Still can not create ordinary cross-origin worker');
+</script>

Powered by Google App Engine
This is Rietveld 408576698