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

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt/workers/constructors/Worker/same-origin.html

Issue 2418853003: Worker: Import "imported/wpt/workers" tests (Retry) (Closed)
Patch Set: rebase Created 4 years, 2 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/imported/wpt/workers/constructors/Worker/same-origin.html
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/workers/constructors/Worker/same-origin.html b/third_party/WebKit/LayoutTests/imported/wpt/workers/constructors/Worker/same-origin.html
new file mode 100644
index 0000000000000000000000000000000000000000..9b0148da3a258abf5780c2fc8c2114e3193fd201
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/wpt/workers/constructors/Worker/same-origin.html
@@ -0,0 +1,63 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>same-origin checks; the script is in a script element</title>
+<link rel=help href="http://www.whatwg.org/html/#dom-worker">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+// Needed to prevent a race condition if a worker throws an exception that may or may
+// not propogate to the window before the tests finish
+setup({allow_uncaught_exception: true});
+
+function testSharedWorkerHelper(t, script) {
+ try {
+ var worker = new SharedWorker(script, '');
+ worker.onerror = t.step_func_done(function(e) {
+ assert_true(e instanceof ErrorEvent);
+ });
+ } catch (e) {
+ t.step_func_done(function(e) { assert_true(true); });
+ }
+}
+
+test(function() {
+ assert_throws("SecurityError", function() { new Worker('unsupported:'); });
+}, "unsupported_scheme");
+
+async_test(function() {
+ var worker = new Worker('data:,postMessage(1);');
+ worker.onmessage = this.step_func_done(function(e) {
+ assert_equals(e.data, 1);
+ });
+}, "data_url");
+
+async_test(function(t) {
+ testSharedWorkerHelper(t, 'about:blank');
+}, "about_blank");
+
+async_test(function(t) {
+ testSharedWorkerHelper(t, 'http://www.example.invalid/');
+}, "example_invalid");
+
+async_test(function(t) {
+ testSharedWorkerHelper(t, location.protocol+'//'+location.hostname+':81/');
+}, "port_81");
+
+async_test(function(t) {
+ testSharedWorkerHelper(t, 'https://'+location.hostname+':80/');
+}, "https_port_80");
+
+async_test(function(t) {
+ testSharedWorkerHelper(t, 'https://'+location.hostname+':8000/');
+}, "https_port_8000");
+
+async_test(function(t) {
+ testSharedWorkerHelper(t, 'http://'+location.hostname+':8012/');
+}, "http_post_8012");
+
+async_test(function(t) {
+ testSharedWorkerHelper(t,'javascript:""');
+}, "javascript_url");
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698