Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/external/wpt/workers/Worker_Self_Origin.html |
| diff --git a/third_party/WebKit/LayoutTests/external/wpt/workers/Worker_Self_Origin.html b/third_party/WebKit/LayoutTests/external/wpt/workers/Worker_Self_Origin.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..61a8ceb6d0e4c23073c14386df01798e99b0745e |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/external/wpt/workers/Worker_Self_Origin.html |
| @@ -0,0 +1,45 @@ |
| +<!DOCTYPE html> |
|
Mike West
2017/02/20 12:21:06
That said, I think this is new: Andy, perhaps you
andypaicu
2017/02/20 13:09:27
tkent@ mentioned tests under html/ and this is und
tkent
2017/02/20 14:22:47
The worker specification, https://w3c.github.io/wo
|
| +<meta charset=utf-8> |
| +<title>Test workers self.origin</title> |
| +<script src="/resources/testharness.js"></script> |
| +<script src="/resources/testharnessreport.js"></script> |
| +<div id="log"></div> |
|
Mike West
2017/02/20 12:21:06
I don't think you're using this.
andypaicu
2017/02/20 13:09:27
There was something on the specs about having a co
|
| +<script> |
| +function assertOrigin_Worker(workerSource, expectedOrigin, testName) { |
|
Mike West
2017/02/20 12:21:06
Pick either CamelCase or hacker_case, but please d
andypaicu
2017/02/21 09:37:29
Done
|
| + async_test(function(t) { |
| + w = new Worker(workerSource); |
| + w.onmessage = t.step_func(function(e) { |
| + assert_equals(e.data, expectedOrigin); |
| + t.done(); |
| + }); |
| + }, testName + ' Worker'); |
| +} |
| + |
| +function assertOrigin_SharedWorker(workerSource, expectedOrigin, testName) { |
| + async_test(function(t) { |
| + w = new SharedWorker(workerSource); |
| + w.port.start(); |
| + w.port.onmessage = t.step_func(function(e) { |
| + assert_equals(e.data, expectedOrigin); |
| + t.done(); |
| + }); |
| + }, testName + ' SharedWorker'); |
| +} |
| + |
| +// Test same-origin workers |
| +assertOrigin_Worker("./support/WorkerSelfOriginWorker.js", self.origin, "Same Origin"); |
| +assertOrigin_SharedWorker("./support/WorkerSelfOriginSharedWorker.js", self.origin, "Same Origin"); |
| + |
| +// Test data url workers have opaque origin |
| +assertOrigin_Worker("data:application/javascript,postMessage(self.origin);", "null", "Data Url"); |
| +assertOrigin_SharedWorker("data:application/javascript,onconnect = function(e) { e.ports[0].postMessage(self.origin); }", "null", "Data Url"); |
| + |
| +// Test blow url workers |
|
Mike West
2017/02/20 12:21:05
s/blow/blob/
andypaicu
2017/02/21 09:37:29
Done
|
| +blob = new Blob(["postMessage(self.origin);"]); |
| +blobUrl = URL.createObjectURL(blob); |
| +assertOrigin_Worker(blobUrl, self.origin, "Blob Url"); |
| + |
| +blob = new Blob(["onconnect = function(e) { e.ports[0].postMessage(self.origin); }"]); |
| +blobUrl = URL.createObjectURL(blob); |
| +assertOrigin_SharedWorker(blobUrl, self.origin, "Blob Url"); |
| +</script> |