mirror of
https://github.com/servo/servo.git
synced 2025-08-16 19:05:33 +01:00
Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255
This commit is contained in:
parent
b2a5225831
commit
1a81b18b9f
12321 changed files with 544385 additions and 6 deletions
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> MessageChannel: port message queue is initially disabled </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var channel = new MessageChannel();
|
||||
channel.port2.addEventListener("message", t.unreached_func(), true);
|
||||
channel.port1.postMessage("ping");
|
||||
setTimeout(t.step_func_done(), 100);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> MessageChannel: port.onmessage enables message queue </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var channel = new MessageChannel();
|
||||
channel.port2.onmessage = t.step_func_done();
|
||||
channel.port1.postMessage("ping");
|
||||
setTimeout(t.unreached_func(), 100);
|
||||
});
|
||||
</script>
|
8
tests/wpt/web-platform-tests/workers/README.md
Normal file
8
tests/wpt/web-platform-tests/workers/README.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
This directory contains the Web Workers test suite.
|
||||
|
||||
To run this test suite within a browser, go to: <http://w3c-test.org/web-platform-tests/master/workers/>.
|
||||
|
||||
The latest Editor's Draft of Web Workers is: <http://dev.w3.org/html5/workers/>.
|
||||
|
||||
The latest W3C Technical Report of Web Workers is <http://www.w3.org/TR/workers/>.
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerGlobalScope onerror event handler argument: col </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/ErrorEvent.js');
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(typeof e.data.colno, "number");
|
||||
});
|
||||
worker.postMessage("Error Message");
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerGlobalScope onerror event handler argument: location </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/ErrorEvent.js');
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
var href = location.href;
|
||||
var expected = href.substring(0, href.lastIndexOf('/')) + '/support/ErrorEvent.js';
|
||||
assert_equals(e.data.filename, expected);
|
||||
});
|
||||
worker.postMessage("Error Message");
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerGlobalScope onerror event handler argument: line </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/ErrorEvent.js');
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.lineno, 3);
|
||||
});
|
||||
worker.postMessage("Error Message");
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerGlobalScope onerror event handler argument: message </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var message = 'Error Message';
|
||||
var worker = new Worker('./support/ErrorEvent.js');
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_greater_than(e.data.message.indexOf(message), -1);
|
||||
});
|
||||
worker.postMessage(message);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerGlobalScope close(): clear events queue </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/WorkerClose.js');
|
||||
worker.onmessage = t.step_func(function(e) {
|
||||
assert_equals(e.data, "ping");
|
||||
worker.onmessage = t.unreached_func("Unexpected message event");
|
||||
worker.postMessage("pong");
|
||||
setTimeout(t.step_func_done(), 100);
|
||||
});
|
||||
worker.postMessage("ping");
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerGlobalScope API: importScripts() </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker("./support/ImportScripts.js");
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data, "Pass");
|
||||
});
|
||||
worker.postMessage("ping");
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> importScripts() with non-existent script file </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker("./support/ImportScriptsNetworkErr.js");
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data, "Pass");
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerGlobalScope API: setInterval() </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var result = [];
|
||||
var worker = new Worker('./support/Timer.js');
|
||||
worker.onmessage = t.step_func(function(e) {
|
||||
result.push(e.data);
|
||||
if (result.length == 3) {
|
||||
assert_array_equals(result, ["hello", "worker", "worker"]);
|
||||
worker.onmessage = t.unreached_func('Unexpected message event');
|
||||
setTimeout(t.step_func_done(), 100);
|
||||
}
|
||||
});
|
||||
worker.postMessage("IntervalHandler");
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerGlobalScope API: setTimeout() </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var result = [];
|
||||
var worker = new Worker('./support/Timer.js');
|
||||
worker.onmessage = t.step_func(function(e) {
|
||||
result.push(e.data);
|
||||
if (result.length == 3) {
|
||||
assert_array_equals(result, ["hello", "worker", "worker"]);
|
||||
worker.onmessage = t.unreached_func('Unexpected message event');
|
||||
setTimeout(t.step_func_done(), 100);
|
||||
}
|
||||
});
|
||||
worker.postMessage("TimeoutHandler");
|
||||
});
|
||||
</script>
|
15
tests/wpt/web-platform-tests/workers/WorkerLocation.htm
Normal file
15
tests/wpt/web-platform-tests/workers/WorkerLocation.htm
Normal file
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerLocation object </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/WorkerLocation.js');
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
var href = window.location.href;
|
||||
var ExpectedResult = href.substring(0, href.lastIndexOf('/')) + '/support/WorkerLocation.js';
|
||||
assert_equals(e.data.location, ExpectedResult);
|
||||
});
|
||||
});
|
||||
</script>
|
13
tests/wpt/web-platform-tests/workers/WorkerLocation_hash.htm
Normal file
13
tests/wpt/web-platform-tests/workers/WorkerLocation_hash.htm
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerLocation URL decomposition IDL attribute: hash </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker("./support/WorkerLocation.js#HashString");
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.hash, "#HashString");
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerLocation.hash with url encoding string </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker("./support/WorkerLocation.js#question%3f");
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.hash, "#question%3f");
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerLocation.hash with no <fragment> component </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/WorkerLocation.js');
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.hash, "");
|
||||
});
|
||||
});
|
||||
</script>
|
13
tests/wpt/web-platform-tests/workers/WorkerLocation_host.htm
Normal file
13
tests/wpt/web-platform-tests/workers/WorkerLocation_host.htm
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerLocation URL decomposition IDL attribute: host </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/WorkerLocation.js');
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.host, location.host);
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerLocation URL decomposition IDL attribute: hostname </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/WorkerLocation.js');
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.hostname, location.hostname);
|
||||
});
|
||||
});
|
||||
</script>
|
15
tests/wpt/web-platform-tests/workers/WorkerLocation_href.htm
Normal file
15
tests/wpt/web-platform-tests/workers/WorkerLocation_href.htm
Normal file
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerLocation href attribute </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker("./support/WorkerLocation.js?srch%20#hash");
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
var href = location.href;
|
||||
var expected = href.substring(0, href.lastIndexOf('/')) + "/support/WorkerLocation.js?srch%20#hash";
|
||||
assert_equals(e.data.href, expected);
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerLocation URL decomposition IDL attribute: pathname </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/WorkerLocation.js');
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
var pathname = location.pathname;
|
||||
var expected = pathname.substring(0, pathname.lastIndexOf('/')) + '/support/WorkerLocation.js';
|
||||
assert_equals(e.data.pathname, expected);
|
||||
});
|
||||
});
|
||||
</script>
|
13
tests/wpt/web-platform-tests/workers/WorkerLocation_port.htm
Normal file
13
tests/wpt/web-platform-tests/workers/WorkerLocation_port.htm
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerLocation URL decomposition IDL attribute: port </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/WorkerLocation.js');
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.port, location.port);
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerLocation URL decomposition IDL attribute: protocol </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/WorkerLocation.js');
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.protocol, location.protocol);
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerLocation URL decomposition IDL attribute: search </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/WorkerLocation.js?SearchString');
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.search, '?SearchString');
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerLocation.search with empty <query> </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker("./support/WorkerLocation.js?");
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.search, "");
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerLocation.search with <fragment> in <query> </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/WorkerLocation.js?test#');
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.search, "?test");
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerLocation.search with no <query> component </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/WorkerLocation.js');
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.search, "");
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerNavigator appName </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker("./support/WorkerNavigator.js");
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.appName, navigator.appName);
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerNavigator appVersion </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker("./support/WorkerNavigator.js");
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.appVersion, navigator.appVersion);
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerNavigator.onLine </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker("./support/WorkerNavigator.js");
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.onLine, navigator.onLine);
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerNavigator.platform </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker("./support/WorkerNavigator.js");
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.platform, navigator.platform);
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<title> WorkerNavigator.userAgent </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker("./support/WorkerNavigator.js");
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data.userAgent, navigator.userAgent);
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<title> AbstractWorker ErrorEvent.filename </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/ErrorEvent.js');
|
||||
worker.onerror = t.step_func_done(function(e) {
|
||||
var href = location.href;
|
||||
var expected = href.substring(0, href.lastIndexOf('/')) + '/support/ErrorEvent.js';
|
||||
assert_equals(e.filename, expected);
|
||||
});
|
||||
worker.postMessage("Error Message");
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<title> AbstractWorker ErrorEvent.lineno </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/ErrorEvent.js');
|
||||
worker.onerror = t.step_func_done(function(e) {
|
||||
assert_equals(e.lineno, 3);
|
||||
});
|
||||
worker.postMessage("Error Message");
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<title> AbstractWorker ErrorEvent.message </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var message = 'Error Message';
|
||||
var worker = new Worker('./support/ErrorEvent.js');
|
||||
worker.onerror = t.step_func_done(function(e) {
|
||||
assert_greater_than(e.message.indexOf(message), -1);
|
||||
});
|
||||
worker.postMessage(message);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<title> AbstractWorker ErrorEvent.type </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/ErrorEvent.js');
|
||||
worker.onerror = t.step_func_done(function(e) {
|
||||
assert_class_string(e, 'ErrorEvent');
|
||||
assert_equals(e.type, 'error');
|
||||
});
|
||||
worker.postMessage("Error Message");
|
||||
});
|
||||
</script>
|
31
tests/wpt/web-platform-tests/workers/Worker_basic.htm
Normal file
31
tests/wpt/web-platform-tests/workers/Worker_basic.htm
Normal file
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html>
|
||||
<title> Web Workers Basic Tests </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
function create_worker() {
|
||||
return new Worker('./support/WorkerBasic.js');
|
||||
}
|
||||
|
||||
test(function() {
|
||||
var worker = create_worker();
|
||||
assert_class_string(worker, "Worker");
|
||||
}, "Worker constructor");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = create_worker();
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data, "Pass");
|
||||
});
|
||||
worker.postMessage("start");
|
||||
}, "MessageEvent.data");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = create_worker();
|
||||
worker.addEventListener("message", t.step_func_done(function(e) {
|
||||
assert_equals(e.type, "message");
|
||||
}), true);
|
||||
worker.postMessage("start");
|
||||
}, "MessageEvent.type");
|
||||
</script>
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<title> Worker cross-origin URL </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
test(function() {
|
||||
assert_throws("SECURITY_ERR", function() {
|
||||
new Worker("ftp://example.org/support/WorkerBasic.js");
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<title> ErrorEvent and Worker.dispatchEvent() </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var event = "error";
|
||||
var filename = './support/ErrorEvent.js';
|
||||
var message = 'Hello Worker';
|
||||
var lineno = 5;
|
||||
var colno = 6;
|
||||
var error = new Error("test");
|
||||
var worker = new Worker(filename);
|
||||
worker.addEventListener(event, t.step_func_done(function(e) {
|
||||
assert_equals(e.type, event, 'type');
|
||||
assert_equals(e.message, message, 'message');
|
||||
assert_equals(e.filename, filename, 'filename');
|
||||
assert_equals(e.lineno, lineno, 'lineno');
|
||||
assert_equals(e.colno, colno, 'colno');
|
||||
assert_equals(e.error, error, 'error');
|
||||
}), true);
|
||||
var e = new ErrorEvent(event, {bubbles:true, cancelable:true, message:message, filename:filename, lineno:lineno, colno:colno, error:error});
|
||||
worker.dispatchEvent(e);
|
||||
});
|
||||
|
||||
test(function() {
|
||||
assert_throws("NotSupportedError", function() {
|
||||
document.createEvent("ErrorEvent");
|
||||
}, "should not be supported");
|
||||
}, "document.createEvent('ErrorEvent')");
|
||||
|
||||
test(function() {
|
||||
var e = new ErrorEvent("error");
|
||||
assert_false("initErrorEvent" in e, "should not be supported");
|
||||
}, "initErrorEvent");
|
||||
</script>
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<title> Worker constructor with script inside text file </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var worker = new Worker('./support/WorkerText.txt');
|
||||
worker.onmessage = t.step_func_done(function(e) {
|
||||
assert_equals(e.data, "Pass");
|
||||
});
|
||||
worker.postMessage("start");
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<title> AbstractWorker terminate(): clear event queue </title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var testResult;
|
||||
var worker = new Worker('./support/WorkerTerminate.js');
|
||||
worker.onmessage = function(e) {
|
||||
testResult = e.data;
|
||||
if (testResult >= 10000) {
|
||||
worker.terminate();
|
||||
worker.onmessage = t.unreached_func('Unexpected message event');
|
||||
setTimeout(t.step_func_done(function() {
|
||||
assert_equals(testResult, 10000);
|
||||
}), 100);
|
||||
}
|
||||
};
|
||||
worker.postMessage("ping");
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,3 @@
|
|||
onconnect = function(e) {
|
||||
e.ports[0].postMessage(['1', self.name]);
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<!--
|
||||
onconnect = function(e) {
|
||||
e.ports[0].postMessage([e.data === '', e instanceof MessageEvent, e.ports.length == 1]);
|
||||
};
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>connect event</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var worker = new SharedWorker('#');
|
||||
worker.port.addEventListener('message', this.step_func(function(e) {
|
||||
assert_true(e.data[0], "e.data === ''");
|
||||
assert_true(e.data[1], "e instanceof MessageEvent");
|
||||
assert_true(e.data[2], "e.ports.length == 1");
|
||||
this.done();
|
||||
}), false);
|
||||
worker.port.start();
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,17 @@
|
|||
<!--
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>creating a dummy shared worker with name "foo"</title>
|
||||
<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
var worker = new SharedWorker('#', 'foo');
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,17 @@
|
|||
<!--
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>creating a dummy shared worker</title>
|
||||
<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
var worker = new SharedWorker('#');
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,17 @@
|
|||
<!--
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>creating a dummy shared worker with explicit name ""</title>
|
||||
<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
var worker = new SharedWorker('#', '');
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,34 @@
|
|||
<!--
|
||||
var expected = 'self location close onerror importScripts navigator addEventListener removeEventListener dispatchEvent name applicationCache onconnect setTimeout clearTimeout setInterval clearInterval'.split(' ');
|
||||
var log = '';
|
||||
for (var i = 0; i < expected.length; ++i) {
|
||||
if (!(expected[i] in self))
|
||||
log += expected[i] + ' did not exist\n';
|
||||
}
|
||||
onconnect = function(e) {
|
||||
e.ports[0].postMessage(log);
|
||||
};
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>members of SharedWorkerGlobalScope</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var worker = new SharedWorker('#');
|
||||
worker.port.addEventListener('message', this.step_func(function(e) {
|
||||
assert_equals(e.data, '');
|
||||
this.done();
|
||||
}), false);
|
||||
worker.port.start();
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<!--
|
||||
var prt;
|
||||
function handleCall(e) {
|
||||
var log = [];
|
||||
for (var i = 0; i < e.data.length; ++i) {
|
||||
if (!(e.data[i] in self))
|
||||
log.push(e.data[i]);
|
||||
}
|
||||
prt.postMessage('These were missing: '+log.join(', '));
|
||||
}
|
||||
onconnect = function(e) {
|
||||
prt = e.ports[0];
|
||||
prt.onmessage = handleCall;
|
||||
};
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>expected interface objects/constructors</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var expected = 'XMLHttpRequest WebSocket EventSource MessageChannel Worker SharedWorker ApplicationCache'.split(' ');
|
||||
var supported = [];
|
||||
for (var i = 0; i < expected.length; ++i) {
|
||||
if (expected[i] in window)
|
||||
supported.push(expected[i]);
|
||||
}
|
||||
var worker = new SharedWorker('#');
|
||||
worker.port.start();
|
||||
worker.port.postMessage(supported);
|
||||
worker.port.addEventListener('message', this.step_func(function(e) {
|
||||
assert_equals(e.data, '');
|
||||
this.done();
|
||||
}), false);
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,24 @@
|
|||
<!--
|
||||
onconnect = function(e) {
|
||||
e.ports[0].postMessage(self.name);
|
||||
}
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>self.name</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var worker = new SharedWorker('#', 'hello');
|
||||
worker.port.addEventListener('message', this.step_func(function(e) {
|
||||
assert_equals(e.data, 'hello');
|
||||
this.done();
|
||||
}), false);
|
||||
worker.port.start();
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,20 @@
|
|||
<!--
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>no arguments</title>
|
||||
<link rel=help href="http://www.whatwg.org/html/#sharedworker">
|
||||
<link rel=help href="http://dev.w3.org/2006/webapi/WebIDL/#es-interface-call">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
assert_throws(new TypeError(), function() {
|
||||
var worker = new SharedWorker();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,3 @@
|
|||
onconnect = function(e) {
|
||||
e.ports[0].postMessage(['null', self.name]);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<!--
|
||||
onconnect = function(e) {
|
||||
e.ports[0].postMessage(['FAIL', self.name]);
|
||||
}
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>null as arguments</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var worker = new SharedWorker(null, null);
|
||||
worker.port.addEventListener('message', this.step_func(function(e) {
|
||||
assert_equals(e.data[0], 'null', 'first arg');
|
||||
assert_equals(e.data[1], 'null', 'second arg');
|
||||
this.done();
|
||||
}), false);
|
||||
worker.port.start();
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,25 @@
|
|||
<!--
|
||||
onconnect = function(e) {
|
||||
e.ports[0].postMessage(['FAIL', self.name]);
|
||||
}
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>1 as arguments</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var worker = new SharedWorker(1, 1);
|
||||
worker.port.addEventListener('message', this.step_func(function(e) {
|
||||
assert_equals(e.data[0], '1', 'first arg');
|
||||
assert_equals(e.data[1], '1', 'second arg');
|
||||
this.done();
|
||||
}), false);
|
||||
worker.port.start();
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,23 @@
|
|||
<!--
|
||||
onconnect = function(e) {
|
||||
e.ports[0].postMessage(true);
|
||||
}
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>worker.port.onmessage</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var worker = new SharedWorker('#', '');
|
||||
worker.port.onmessage = this.step_func(function(e) {
|
||||
assert_true(e.data);
|
||||
this.done();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,26 @@
|
|||
<!--
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>worker.port</title>
|
||||
<link rel=help href="http://www.whatwg.org/html/#sharedworker">
|
||||
<link rel=help href="http://www.whatwg.org/html/#messageport">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
var worker = new SharedWorker('#', '');
|
||||
assert_true('port' in worker, "port");
|
||||
assert_true('postMessage' in worker.port, "postMessage");
|
||||
assert_true('start' in worker.port, "start");
|
||||
assert_true('close' in worker.port, "close");
|
||||
assert_true('onmessage' in worker.port, "onmessage");
|
||||
assert_true('addEventListener' in worker.port, "addEventListener");
|
||||
assert_true('removeEventListener' in worker.port, "removeEventListener");
|
||||
assert_true('dispatchEvent' in worker.port, "dispatchEvent");
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,21 @@
|
|||
<!--
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>setting worker.port</title>
|
||||
<link rel=help href="http://www.whatwg.org/html/#sharedworker">
|
||||
<link rel=help href="http://dev.w3.org/2006/webapi/WebIDL/#dfn-attribute-setter">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
var worker = new SharedWorker('#', '');
|
||||
var x = worker.port;
|
||||
worker.port = 1;
|
||||
assert_equals(worker.port, x);
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,48 @@
|
|||
<!--
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>same-origin checks</title>
|
||||
<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker">
|
||||
<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});
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker('unsupported:', ''); });
|
||||
}, "unsupported_scheme");
|
||||
async_test(function() {
|
||||
var worker = new SharedWorker('data:,onconnect = function(e) { e.ports[0].postMessage(1); }', '');
|
||||
worker.port.onmessage = this.step_func_done(function(e) {
|
||||
assert_equals(e.data, 1);
|
||||
});
|
||||
}, "data_url");
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker('javascript:""', ''); });
|
||||
}, "javascript_url");
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker('about:blank', ''); });
|
||||
}, "about_blank");
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker('http://www.opera.com/', ''); });
|
||||
}, "opera_com");
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker(location.protocol+'//'+location.hostname+':81/', ''); });
|
||||
}, "port_81");
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker('https://'+location.hostname+':80/', ''); });
|
||||
}, "https_port_80");
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker('https://'+location.hostname+':8000/', ''); });
|
||||
}, "https_port_8000");
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new SharedWorker('http://'+location.hostname+':8012/', ''); });
|
||||
}, "http_port_8012");
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,59 @@
|
|||
<!--
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>setting members of worker.port</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
setup(function() {
|
||||
window.worker = new SharedWorker('#', '');
|
||||
});
|
||||
test(function() {
|
||||
worker.port.postMessage = 1;
|
||||
assert_equals(worker.port.postMessage, 1);
|
||||
}, 'postMessage');
|
||||
test(function() {
|
||||
worker.port.start = 1;
|
||||
assert_equals(worker.port.start, 1);
|
||||
}, 'start');
|
||||
test(function() {
|
||||
worker.port.close = 1;
|
||||
assert_equals(worker.port.close, 1);
|
||||
}, 'close');
|
||||
test(function() {
|
||||
var f = function(){};
|
||||
worker.port.onmessage = f;
|
||||
assert_equals(worker.port.onmessage, f, 'function(){}');
|
||||
worker.port.onmessage = 1;
|
||||
assert_equals(worker.port.onmessage, null, '1');
|
||||
worker.port.onmessage = f;
|
||||
worker.port.onmessage = ';';
|
||||
assert_equals(worker.port.onmessage, null, '";"');
|
||||
worker.port.onmessage = f;
|
||||
worker.port.onmessage = {handleEvent:function(){}};
|
||||
assert_equals(worker.port.onmessage, null, '{handleEvent:function(){}}');
|
||||
worker.port.onmessage = f;
|
||||
worker.port.onmessage = null;
|
||||
assert_equals(worker.port.onmessage, null, 'null');
|
||||
worker.port.onmessage = f;
|
||||
worker.port.onmessage = undefined;
|
||||
assert_equals(worker.port.onmessage, null, 'undefined');
|
||||
}, 'onmessage');
|
||||
test(function() {
|
||||
worker.port.addEventListener = 1;
|
||||
assert_equals(worker.port.addEventListener, 1);
|
||||
}, 'addEventListener');
|
||||
test(function() {
|
||||
worker.port.removeEventListener = 1;
|
||||
assert_equals(worker.port.removeEventListener, 1);
|
||||
}, 'removeEventListener');
|
||||
test(function() {
|
||||
worker.port.despatchEvent = 1;
|
||||
assert_equals(worker.port.despatchEvent, 1);
|
||||
}, 'despatchEvent');
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,3 @@
|
|||
onconnect = function(e) {
|
||||
e.ports[0].postMessage(['undefined', self.name]);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<!--
|
||||
onconnect = function(e) {
|
||||
e.ports[0].postMessage(['FAIL', self.name]);
|
||||
}
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>undefined as arguments</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var worker = new SharedWorker(undefined, undefined);
|
||||
worker.port.addEventListener('message', this.step_func(function(e) {
|
||||
assert_equals(e.data[0], 'undefined', 'first arg');
|
||||
assert_equals(e.data[1], 'undefined', 'second arg');
|
||||
this.done();
|
||||
}), false);
|
||||
worker.port.start();
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,30 @@
|
|||
<!--
|
||||
var unexpected = 'open print stop getComputedStyle getSelection releaseEvents captureEvents alert confirm prompt addEventStream removeEventStream back forward attachEvent detachEvent navigate DOMParser XMLSerializer XPathEvaluator XSLTProcessor opera Image Option frames Audio SVGUnitTypes SVGZoomAndPan java netscape sun Packages ByteArray closed defaultStatus document event frameElement history innerHeight innerWidth opener outerHeight outerWidth pageXOffset pageYOffset parent screen screenLeft screenTop screenX screenY status top window length'.split(' '); // iterated window in opera and removed expected ones
|
||||
var log = '';
|
||||
for (var i = 0; i < unexpected.length; ++i) {
|
||||
if (unexpected[i] in self)
|
||||
log += unexpected[i] + ' ';
|
||||
}
|
||||
onconnect = function(e) {
|
||||
e.ports[0].postMessage(log);
|
||||
};
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>unexpected members/interface objects/constructors</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var worker = new SharedWorker('#');
|
||||
worker.port.addEventListener('message', this.step_func(function(e) {
|
||||
assert_equals(e.data, '');
|
||||
this.done();
|
||||
}), false);
|
||||
worker.port.start();
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,19 @@
|
|||
<!--
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>resolving broken url</title>
|
||||
<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
assert_throws("SyntaxError", function() {
|
||||
var worker = new SharedWorker('http://foo bar');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1 @@
|
|||
postMessage('1');
|
|
@ -0,0 +1,41 @@
|
|||
<!--
|
||||
for (;) // should cause onerror to be invoked, but onerror is null, so
|
||||
// the error is "not handled". should fire an ErrorEvent on the
|
||||
// worker.
|
||||
break;
|
||||
postMessage(1); // shouldn't do anything since the script doesn't compile
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>AbstractWorker.onerror</title>
|
||||
<link rel=help href="http://www.whatwg.org/html/#runtime-script-errors-0">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test();
|
||||
t.step(function() {
|
||||
var worker = new Worker('#');
|
||||
worker.onerror = function(a, b, c) {
|
||||
t.step(function() {
|
||||
assert_equals('' + a, '[object ErrorEvent]');
|
||||
assert_true("message" in a, 'ErrorEvent.message');
|
||||
assert_equals(typeof a.message, "string", 'ErrorEvent.message');
|
||||
assert_equals(a.filename, document.URL + '#', 'ErrorEvent.filename');
|
||||
assert_true("lineno" in a, 'ErrorEvent.lineno');
|
||||
assert_equals(typeof a.lineno, "number", 'ErrorEvent.lineno');
|
||||
assert_equals(b, undefined, 'unexpected second argument to onerror');
|
||||
assert_equals(c, undefined, 'unexpected third argument to onerror');
|
||||
});
|
||||
t.done();
|
||||
}
|
||||
worker.onmessage = function(e) {
|
||||
t.step(function() {
|
||||
assert_unreached('onmessage was invoked but worker script shouldn\'t have compiled');
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,34 @@
|
|||
<!--
|
||||
var expected = [
|
||||
'postMessage', 'onmessage', /* DedicatedWorkerGlobalScope */
|
||||
'self', 'location', 'close', 'onerror', 'onoffline', 'ononline', /* WorkerGlobalScope */
|
||||
'addEventListener', 'removeEventListener', 'dispatchEvent', /* EventListener */
|
||||
'importScripts', 'navigator', /* WorkerUtils */
|
||||
'setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', /* WindowTimers */
|
||||
'btoa', 'atob' /* WindowBase64 */
|
||||
];
|
||||
for (var i = 0; i < expected.length; ++i) {
|
||||
if (!(expected[i] in self)) {
|
||||
postMessage(expected[i] + ' did not exist');
|
||||
}
|
||||
}
|
||||
postMessage('done');
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>members of DedicatedWorkerGlobalScope</title>
|
||||
<link rel=help href="http://www.whatwg.org/html/#dom-worker">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../workers.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test();
|
||||
t.step(function() {
|
||||
var worker = new Worker('#');
|
||||
listenForMessages(t, worker);
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,23 @@
|
|||
<!--
|
||||
postMessage('FAIL');
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>1 as argument</title>
|
||||
<link rel=help href="http://www.whatwg.org/html/#dom-worker">
|
||||
<link rel=help href="http://dev.w3.org/2006/webapi/WebIDL/#es-DOMString">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test();
|
||||
t.step(function() {
|
||||
var worker = new Worker(1);
|
||||
worker.addEventListener('message', t.step_func_done(function(e) {
|
||||
assert_equals(e.data, '1')
|
||||
}), false);
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,23 @@
|
|||
<!--
|
||||
postMessage('FAIL');
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>null as argument</title>
|
||||
<link rel=help href="http://www.whatwg.org/html/#dom-worker">
|
||||
<link rel=help href="http://dev.w3.org/2006/webapi/WebIDL/#es-DOMString">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test();
|
||||
t.step(function() {
|
||||
var worker = new Worker(null);
|
||||
worker.addEventListener('message', t.step_func_done(function(e) {
|
||||
assert_equals(e.data, 'null')
|
||||
}), false);
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,23 @@
|
|||
<!--
|
||||
postMessage('FAIL');
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>undefined as argument</title>
|
||||
<link rel=help href="http://www.whatwg.org/html/#dom-worker">
|
||||
<link rel=help href="http://dev.w3.org/2006/webapi/WebIDL/#es-DOMString">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test();
|
||||
t.step(function() {
|
||||
var worker = new Worker(undefined);
|
||||
worker.addEventListener('message', t.step_func_done(function(e) {
|
||||
assert_equals(e.data, 'undefined')
|
||||
}), false);
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,30 @@
|
|||
<!--
|
||||
onmessage = function(e) {
|
||||
for (var i = 0; i < e.data.length; ++i) {
|
||||
if (!(e.data[i] in self)) {
|
||||
postMessage(e.data[i] + ' did not exist');
|
||||
}
|
||||
}
|
||||
postMessage('done');
|
||||
}
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>expected interface objects/constructors</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../workers.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test();
|
||||
t.step(function() {
|
||||
var expected = ['XMLHttpRequest', 'WebSocket', 'EventSource', 'MessageChannel', 'Worker', 'SharedWorker'];
|
||||
var supported = expected.filter(function(iface) { return iface in window; });
|
||||
var worker = new Worker('#');
|
||||
listenForMessages(t, worker);
|
||||
worker.postMessage(supported);
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,13 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>without arguments</title>
|
||||
<link rel=help href="http://dev.w3.org/2006/webapi/WebIDL/#es-interface-call">
|
||||
<link rel=help href="http://www.whatwg.org/html/#dedicated-workers-and-the-worker-interface">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
assert_throws(new TypeError(), function() { new Worker(); });
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1 @@
|
|||
postMessage('null');
|
|
@ -0,0 +1,22 @@
|
|||
<!--
|
||||
postMessage('ok');
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>resolve the empty string</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test();
|
||||
t.step(function() {
|
||||
var worker = new Worker('');
|
||||
worker.addEventListener('message', t.step_func_done(function(e) {
|
||||
assert_equals(e.data, 'ok');
|
||||
}), false);
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,51 @@
|
|||
<!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});
|
||||
|
||||
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");
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new Worker('about:blank'); });
|
||||
}, "about_blank");
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new Worker('http://www.example.invalid/'); });
|
||||
}, "example_invalid");
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new Worker(location.protocol+'//'+location.hostname+':81/'); });
|
||||
}, "port_81");
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new Worker('https://'+location.hostname+':80/'); });
|
||||
}, "https_port_80");
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new Worker('https://'+location.hostname+':8000/'); });
|
||||
}, "https_port_8000");
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new Worker('http://'+location.hostname+':8012/'); });
|
||||
}, "http_post_8012");
|
||||
|
||||
test(function() {
|
||||
assert_throws("SecurityError", function() { new Worker('javascript:""'); });
|
||||
}, "javascript_url");
|
||||
</script>
|
|
@ -0,0 +1,45 @@
|
|||
<!--
|
||||
(function f() {
|
||||
postMessage(1);
|
||||
setTimeout(f, 0);
|
||||
})();
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>terminate()</title>
|
||||
<link rel=help href="http://www.whatwg.org/html/#dom-worker-terminate">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../workers.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test();
|
||||
t.step(function() {
|
||||
var worker = new Worker('#');
|
||||
var i = 0;
|
||||
var expected;
|
||||
|
||||
worker.onmessage = t.step_func(function() {
|
||||
i++;
|
||||
});
|
||||
|
||||
setTimeout(t.step_func(function() {
|
||||
expected = i;
|
||||
start_time = Date.now();
|
||||
//Hang the main thread for a bit to give the worker the chance to post some more messages
|
||||
while(Date.now() - start_time < 500) {
|
||||
//pass
|
||||
}
|
||||
worker.terminate();
|
||||
|
||||
setTimeout(t.step_func(function() {
|
||||
assert_equals(i, expected);
|
||||
t.done();
|
||||
}), 100);
|
||||
|
||||
}), 100);
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1 @@
|
|||
postMessage('undefined');
|
|
@ -0,0 +1,26 @@
|
|||
<!--
|
||||
var unexpected = ['open', 'print', 'stop', 'getComputedStyle', 'getSelection', 'releaseEvents', 'captureEvents', 'alert', 'confirm', 'prompt', 'addEventStream', 'removeEventStream', 'back', 'forward', 'attachEvent', 'detachEvent', 'navigate', 'DOMParser', 'XMLSerializer', 'XPathEvaluator', 'XSLTProcessor', 'opera', 'Image', 'Option', 'frames', 'Audio', 'SVGUnitTypes', 'SVGZoomAndPan', 'java', 'netscape', 'sun', 'Packages', 'ByteArray', 'closed', 'defaultStatus', 'document', 'event', 'frameElement', 'history', 'innerHeight', 'innerWidth', 'name', 'opener', 'outerHeight', 'outerWidth', 'pageXOffset', 'pageYOffset', 'parent', 'screen', 'screenLeft', 'screenTop', 'screenX', 'screenY', 'status', 'top', 'window', 'length']; // iterated window in opera and removed expected ones
|
||||
for (var i = 0; i < unexpected.length; ++i) {
|
||||
if (unexpected[i] in self) {
|
||||
postMessage(unexpected[i] + ' existed');
|
||||
}
|
||||
}
|
||||
postMessage('done');
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>unexpected members/interface objects/constructors</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../workers.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test();
|
||||
t.step(function() {
|
||||
var worker = new Worker('#');
|
||||
listenForMessages(t, worker);
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,12 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>unresolvable url</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>
|
||||
test(function() {
|
||||
assert_throws("SyntaxError", function() { new Worker('http://invalid url/'); });
|
||||
});
|
||||
</script>
|
116
tests/wpt/web-platform-tests/workers/interfaces.idl
Normal file
116
tests/wpt/web-platform-tests/workers/interfaces.idl
Normal file
|
@ -0,0 +1,116 @@
|
|||
// -----------------------------------------------------------------------------
|
||||
// URL
|
||||
// -----------------------------------------------------------------------------
|
||||
[NoInterfaceObject/*,
|
||||
Exposed=(Window,Worker)*/]
|
||||
interface URLUtilsReadOnly {
|
||||
stringifier readonly attribute USVString href;
|
||||
readonly attribute USVString origin;
|
||||
|
||||
readonly attribute USVString protocol;
|
||||
readonly attribute USVString host;
|
||||
readonly attribute USVString hostname;
|
||||
readonly attribute USVString port;
|
||||
readonly attribute USVString pathname;
|
||||
readonly attribute USVString search;
|
||||
readonly attribute USVString hash;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// DOM
|
||||
// -----------------------------------------------------------------------------
|
||||
//[Exposed=Window,Worker]
|
||||
interface EventTarget {
|
||||
void addEventListener(DOMString type, EventListener? callback, optional boolean capture = false);
|
||||
void removeEventListener(DOMString type, EventListener? callback, optional boolean capture = false);
|
||||
boolean dispatchEvent(Event event);
|
||||
};
|
||||
|
||||
callback interface EventListener {
|
||||
void handleEvent(Event event);
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// HTML
|
||||
// -----------------------------------------------------------------------------
|
||||
[TreatNonCallableAsNull]
|
||||
callback EventHandlerNonNull = any (Event event);
|
||||
typedef EventHandlerNonNull? EventHandler;
|
||||
|
||||
[TreatNonCallableAsNull]
|
||||
callback OnErrorEventHandlerNonNull = any ((Event or DOMString) event, optional DOMString source, optional unsigned long lineno, optional unsigned long column, optional any error);
|
||||
typedef OnErrorEventHandlerNonNull? OnErrorEventHandler;
|
||||
|
||||
//[Exposed=Worker]
|
||||
interface WorkerGlobalScope : EventTarget {
|
||||
readonly attribute WorkerGlobalScope self;
|
||||
readonly attribute WorkerLocation location;
|
||||
|
||||
void close();
|
||||
attribute OnErrorEventHandler onerror;
|
||||
attribute EventHandler onlanguagechange;
|
||||
attribute EventHandler onoffline;
|
||||
attribute EventHandler ononline;
|
||||
};
|
||||
|
||||
[Global/*=(Worker,DedicatedWorker),Exposed=DedicatedWorker*/]
|
||||
/*sealed*/ interface DedicatedWorkerGlobalScope : WorkerGlobalScope {
|
||||
void postMessage(any message, optional sequence<Transferable> transfer);
|
||||
attribute EventHandler onmessage;
|
||||
};
|
||||
|
||||
//[Exposed=Worker]
|
||||
partial interface WorkerGlobalScope { // not obsolete
|
||||
void importScripts(DOMString... urls);
|
||||
readonly attribute WorkerNavigator navigator;
|
||||
};
|
||||
WorkerGlobalScope implements WindowTimers;
|
||||
WorkerGlobalScope implements WindowBase64;
|
||||
|
||||
[NoInterfaceObject/*, Exposed=(Window,Worker)*/]
|
||||
interface WindowTimers {
|
||||
long setTimeout(Function handler, optional long timeout = 0, any... arguments);
|
||||
long setTimeout(DOMString handler, optional long timeout = 0, any... arguments);
|
||||
void clearTimeout(optional long handle = 0);
|
||||
long setInterval(Function handler, optional long timeout = 0, any... arguments);
|
||||
long setInterval(DOMString handler, optional long timeout = 0, any... arguments);
|
||||
void clearInterval(optional long handle = 0);
|
||||
};
|
||||
|
||||
[NoInterfaceObject/*, Exposed=(Window,Worker)*/]
|
||||
interface WindowBase64 {
|
||||
DOMString btoa(DOMString btoa);
|
||||
DOMString atob(DOMString atob);
|
||||
};
|
||||
|
||||
//[Exposed=Worker]
|
||||
interface WorkerNavigator {};
|
||||
WorkerNavigator implements NavigatorID;
|
||||
WorkerNavigator implements NavigatorLanguage;
|
||||
WorkerNavigator implements NavigatorOnLine;
|
||||
|
||||
[NoInterfaceObject/*, Exposed=(Window,Worker)*/]
|
||||
interface NavigatorID {
|
||||
readonly attribute DOMString appCodeName; // constant "Mozilla"
|
||||
readonly attribute DOMString appName;
|
||||
readonly attribute DOMString appVersion;
|
||||
readonly attribute DOMString platform;
|
||||
readonly attribute DOMString product; // constant "Gecko"
|
||||
boolean taintEnabled(); // constant false
|
||||
readonly attribute DOMString userAgent;
|
||||
};
|
||||
|
||||
[NoInterfaceObject/*, Exposed=(Window,Worker)*/]
|
||||
interface NavigatorLanguage {
|
||||
readonly attribute DOMString? language;
|
||||
readonly attribute DOMString[] languages;
|
||||
};
|
||||
|
||||
[NoInterfaceObject/*, Exposed=(Window,Worker)*/]
|
||||
interface NavigatorOnLine {
|
||||
readonly attribute boolean onLine;
|
||||
};
|
||||
|
||||
//[Exposed=Worker]
|
||||
interface WorkerLocation { };
|
||||
WorkerLocation implements URLUtilsReadOnly;
|
20
tests/wpt/web-platform-tests/workers/interfaces.worker.js
Normal file
20
tests/wpt/web-platform-tests/workers/interfaces.worker.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
"use strict";
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/resources/WebIDLParser.js", "/resources/idlharness.js");
|
||||
|
||||
var request = new XMLHttpRequest();
|
||||
request.onload = function() {
|
||||
var idlArray = new IdlArray();
|
||||
var idls = request.responseText;
|
||||
idlArray.add_idls(idls);
|
||||
idlArray.add_objects({
|
||||
DedicatedWorkerGlobalScope: ['self'],
|
||||
WorkerNavigator: ['self.navigator'],
|
||||
WorkerLocation: ['self.location'],
|
||||
});
|
||||
idlArray.test();
|
||||
done();
|
||||
};
|
||||
request.open("GET", "interfaces.idl");
|
||||
request.send();
|
|
@ -0,0 +1,21 @@
|
|||
importScripts("/resources/testharness.js");
|
||||
|
||||
test(function() {
|
||||
var i = 0;
|
||||
addEventListener("message", this.step_func(function listener(evt) {
|
||||
++i;
|
||||
removeEventListener("message", listener, true);
|
||||
}), true);
|
||||
self.dispatchEvent(new Event("message"));
|
||||
self.dispatchEvent(new Event("message"));
|
||||
assert_equals(i, 1);
|
||||
}, "removeEventListener");
|
||||
|
||||
test(function() {
|
||||
addEventListener("message", this.step_func(function(evt) {
|
||||
assert_equals(evt.target, self);
|
||||
}), true);
|
||||
self.dispatchEvent(new Event("message"));
|
||||
}, "target");
|
||||
|
||||
done();
|
|
@ -0,0 +1,40 @@
|
|||
importScripts("/resources/testharness.js");
|
||||
|
||||
test(function() {
|
||||
self.onmessage = 1;
|
||||
assert_equals(self.onmessage, null,
|
||||
"attribute should return null after being set to a primitive");
|
||||
}, "Setting onmessage to 1");
|
||||
|
||||
test(function() {
|
||||
var object = {
|
||||
handleEvent: this.unreached_func()
|
||||
};
|
||||
self.onmessage = object;
|
||||
assert_equals(self.onmessage, object,
|
||||
"attribute should return the object it was set to.");
|
||||
|
||||
self.dispatchEvent(new Event("message"));
|
||||
}, "Setting onmessage to an object");
|
||||
|
||||
test(function() {
|
||||
var triggered = false;
|
||||
var f = function(e) { triggered = true; };
|
||||
self.onmessage = f;
|
||||
assert_equals(self.onmessage, f,
|
||||
"attribute should return the function it was set to.");
|
||||
|
||||
self.dispatchEvent(new Event("message"));
|
||||
assert_true(triggered, "event handler should have been triggered");
|
||||
}, "Setting onmessage to a function");
|
||||
|
||||
|
||||
test(function() {
|
||||
assert_not_equals(self.onmessage, null,
|
||||
"attribute should not return null after being set to a function");
|
||||
self.onmessage = 1;
|
||||
assert_equals(self.onmessage, null,
|
||||
"attribute should return null after being set to a primitive");
|
||||
}, "Setting onmessage to 1 (again)");
|
||||
|
||||
done();
|
|
@ -0,0 +1,25 @@
|
|||
<!--
|
||||
onmessage = function(e) {
|
||||
postMessage(e.ports instanceof Array && e.ports.length === 0);
|
||||
}
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>e.ports in dedicated worker</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var worker = new Worker('#');
|
||||
worker.postMessage(1);
|
||||
worker.onmessage = this.step_func(function(e) {
|
||||
assert_true(e.data);
|
||||
this.done();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<!--
|
||||
onmessage = function(e) {
|
||||
function processPixels(imagedata) {
|
||||
var pixeldata = imagedata.data;
|
||||
for (var i = 0; i < pixeldata.length; i = i+4) {
|
||||
pixeldata[i] = 128;
|
||||
}
|
||||
postMessage(imagedata);
|
||||
}
|
||||
processPixels(e.data[0]);
|
||||
}
|
||||
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>posting an imagedata (from a cloned canvas) in an array</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var worker = new Worker('#');
|
||||
var canvas = document.createElement('canvas');
|
||||
var clone = canvas.cloneNode(true);
|
||||
var ctx = clone.getContext('2d');
|
||||
var imagedata = ctx.getImageData(0, 0, 300, 150);
|
||||
worker.postMessage([imagedata]);
|
||||
worker.onmessage = this.step_func(function(e) {
|
||||
var pixeldata = e.data.data;
|
||||
for (var i = 0; i < pixeldata.length; i++) {
|
||||
assert_equals(pixeldata[i], (i % 4 == 0) ? 128 : 0);
|
||||
}
|
||||
this.done();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>'message' event properties</title>
|
||||
<link rel=help href="http://www.whatwg.org/html/#dom-dedicatedworkerglobalscope-postmessage">
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test("Properties of the 'message' event").step(function() {
|
||||
var worker = new Worker("message-event.js");
|
||||
worker.onmessage = this.step_func_done(function (evt) {
|
||||
assert_class_string(evt, "MessageEvent");
|
||||
assert_equals(evt.type, "message");
|
||||
assert_false(evt.bubbles, "bubbles should be false");
|
||||
assert_false(evt.cancelable, "cancelable should be false");
|
||||
assert_equals(evt.data, "test");
|
||||
assert_equals(evt.origin, "", "origin");
|
||||
assert_equals(evt.lastEventId, "", "lastEventId");
|
||||
assert_equals(evt.source, null, "source");
|
||||
assert_array_equals(evt.ports, [], "ports");
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1 @@
|
|||
postMessage("test");
|
|
@ -0,0 +1,8 @@
|
|||
importScripts("/resources/testharness.js");
|
||||
|
||||
test(function() {
|
||||
var rv = postMessage(1);
|
||||
assert_equals(rv, undefined);
|
||||
}, "return value of postMessage");
|
||||
|
||||
done();
|
|
@ -0,0 +1,26 @@
|
|||
<!--
|
||||
try {
|
||||
postMessage(false, [null]);
|
||||
} catch(e) {
|
||||
postMessage(e instanceof TypeError);
|
||||
}
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>Using [null] in postMessage's second argument</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var worker = new Worker('#');
|
||||
worker.onmessage = this.step_func(function(e) {
|
||||
assert_true(e.data);
|
||||
this.done();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<!--
|
||||
try {
|
||||
postMessage(1, null);
|
||||
} catch(e) {
|
||||
postMessage(e instanceof TypeError);
|
||||
}
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>Using null in postMessage's second argument</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var worker = new Worker('#');
|
||||
worker.onmessage = this.step_func(function(e) {
|
||||
assert_true(e.data);
|
||||
this.done();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,25 @@
|
|||
<!--
|
||||
try {
|
||||
postMessage(1, undefined);
|
||||
} catch(e) {
|
||||
postMessage(''+e);
|
||||
}
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>Using undefined in postMessage's second argument</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var worker = new Worker('#');
|
||||
worker.onmessage = this.step_func(function(e) {
|
||||
assert_equals(e.data, 1);
|
||||
this.done();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,24 @@
|
|||
<!--
|
||||
var x = postMessage;
|
||||
postMessage = 1;
|
||||
x(postMessage == 1);
|
||||
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>setting postMessage</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var worker = new Worker('#');
|
||||
worker.onmessage = this.step_func(function(e) {
|
||||
assert_true(e.data);
|
||||
this.done();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,30 @@
|
|||
<!--
|
||||
onmessage = function(e) {
|
||||
var imagedata = e.data;
|
||||
imagedata.data[0] = 128;
|
||||
postMessage(imagedata);
|
||||
}
|
||||
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>structured clone of ImageData</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
(async_test()).step(function() {
|
||||
var worker = new Worker('#');
|
||||
var ctx = document.createElement('canvas').getContext('2d');
|
||||
var imagedata = ctx.getImageData(0, 0, 300, 150);
|
||||
worker.postMessage(imagedata);
|
||||
worker.onmessage = this.step_func(function(e) {
|
||||
assert_equals(''+e.data, '[object ImageData]');
|
||||
assert_equals(e.data.data[0], 128);
|
||||
this.done();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,58 @@
|
|||
<!--
|
||||
var err = new Error('foo');
|
||||
var date = new Date();
|
||||
// commented out bits are either tested elsewhere or not supported yet. or uncloneable.
|
||||
var tests = [undefined, null, false, true, 1, NaN, Infinity, 'foo', date, /foo/, /* ImageData, File, FileData, FileList,*/ null/*self*/,
|
||||
[undefined, null, false, true, 1, NaN, Infinity, 'foo', /*date, /foo/,*/ null/*self*/, /*[], {},*/ null/*err*/],
|
||||
{a:undefined, b:null, c:false, d:true, e:1, f:NaN, g:Infinity, h:'foo', /*i:date, j:/foo/,*/ k:null/*self*/, /*l:[], m:{},*/ n:null/*err*/},
|
||||
null/*err*/];
|
||||
for (var i = 0; i < tests.length; ++i) {
|
||||
try {
|
||||
postMessage(tests[i]);
|
||||
} catch(e) {
|
||||
postMessage(''+e);
|
||||
}
|
||||
}
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>structured clone of message</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var wrapper_test = async_test();
|
||||
var tests = [
|
||||
{test:async_test('undefined'), check:function(e) { assert_equals(e.data, undefined); }},
|
||||
{test:async_test('null'), check:function(e) { assert_equals(e.data, null); }},
|
||||
{test:async_test('false'), check:function(e) { assert_false(e.data); }},
|
||||
{test:async_test('true'), check:function(e) { assert_true(e.data); }},
|
||||
{test:async_test('1'), check:function(e) { assert_equals(e.data, 1); }},
|
||||
{test:async_test('NaN'), check:function(e) { assert_equals(e.data, NaN); }},
|
||||
{test:async_test('Infinity'), check:function(e) { assert_equals(e.data, Infinity); }},
|
||||
{test:async_test('string'), check:function(e) { assert_equals(e.data, 'foo'); }},
|
||||
{test:async_test('date'), check:function(e) { assert_equals(e.data instanceof Date, true); }},
|
||||
{test:async_test('regexp'), check:function(e) { assert_equals('' + e.data, '/foo/'); assert_equals(e.data instanceof RegExp, true, 'e.data instanceof RegExp'); }},
|
||||
{test:async_test('self'), check:function(e) { assert_equals(e.data, null); }},
|
||||
{test:async_test('array'), check:function(e) { assert_array_equals(e.data, [undefined, null, false, true, 1, NaN, Infinity, 'foo', null, null]); }},
|
||||
{test:async_test('object'), check:function(e) { assert_object_equals(e.data, {a:undefined, b:null, c:false, d:true, e:1, f:NaN, g:Infinity, h:'foo', k:null, n:null}); }},
|
||||
{test:async_test('error'), check:function(e) { assert_equals(e.data, null, 'new Error()'); }},
|
||||
{test:wrapper_test, check:function(e) { assert_unreached(); }}
|
||||
];
|
||||
// make wrapper_test pass after 500ms
|
||||
setTimeout(tests[tests.length-1].test.step_func(function() {
|
||||
this.done();
|
||||
}), 500);
|
||||
|
||||
wrapper_test.step(function() {
|
||||
var worker = new Worker('#');
|
||||
var i = 0;
|
||||
worker.onmessage = function(e) {
|
||||
tests[i].test.step(function() { tests[i].check(e); this.done(); });
|
||||
i++;
|
||||
};
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,34 @@
|
|||
<!--
|
||||
addEventListener('connect', function(e) {
|
||||
var passed;
|
||||
switch (location.hash) {
|
||||
case '#1': passed = name == ''; break;
|
||||
case '#2': passed = name == 'a'; break;
|
||||
case '#3': passed = name == '0'; break;
|
||||
}
|
||||
e.ports[0].postMessage(passed);
|
||||
}, false);
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>getting name</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var tests = [['#1', ''], ['#2', 'a'], ['#3', -0]];
|
||||
tests.forEach(function(t) {
|
||||
async_test(function() {
|
||||
var w = new SharedWorker(t[0], t[1]);
|
||||
w.port.onmessage = this.step_func(function(e) {
|
||||
assert_true(e.data);
|
||||
this.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<!--
|
||||
addEventListener('connect', function(e) {
|
||||
name = 1;
|
||||
e.ports[0].postMessage(name);
|
||||
}, false);
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>setting name</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(function() {
|
||||
var w1 = new SharedWorker('#1', 'x');
|
||||
w1.port.addEventListener('message', this.step_func(function(e) {
|
||||
assert_equals(e.data, 'x');
|
||||
this.done();
|
||||
}), false);
|
||||
w1.port.start();
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,39 @@
|
|||
<!--
|
||||
var results = [];
|
||||
try {
|
||||
self.onconnect = 1;
|
||||
results.push(String(onconnect));
|
||||
} catch(e) {
|
||||
results.push(''+e);
|
||||
}
|
||||
try {
|
||||
self.onconnect = {handleEvent:function(){}};
|
||||
results.push(String(onconnect));
|
||||
} catch(e) {
|
||||
results.push(''+e);
|
||||
}
|
||||
var f = function(e) {
|
||||
results.push(e.data);
|
||||
e.ports[0].postMessage(results);
|
||||
};
|
||||
onconnect = f;
|
||||
results.push(typeof onconnect);
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>onconnect</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(function() {
|
||||
var w1 = new SharedWorker('#', '');
|
||||
w1.port.addEventListener('message', this.step_func(function(e) {
|
||||
assert_array_equals(e.data, ['null', 'null', 'function', '']);
|
||||
}), false);
|
||||
w1.port.start();
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,37 @@
|
|||
<!--
|
||||
onmessage = function(e) {
|
||||
postMessage(1);
|
||||
throw new Error();
|
||||
}
|
||||
close();
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>close() and incoming message</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(function() {
|
||||
var gotMessage = false;
|
||||
var gotError = false;
|
||||
var worker = new Worker('#');
|
||||
worker.onmessage = function(e) {
|
||||
gotMessage = true;
|
||||
};
|
||||
worker.onerror = function(e) {
|
||||
gotError = true;
|
||||
};
|
||||
worker.postMessage(1);
|
||||
setTimeout(this.step_func(function() {
|
||||
assert_false(gotMessage, 'got message');
|
||||
assert_true(gotError, 'got error');
|
||||
this.done();
|
||||
}), 500);
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<!--
|
||||
postMessage(1);
|
||||
close();
|
||||
postMessage(2);
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>close() and sending messages</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(function() {
|
||||
var worker = new Worker('#');
|
||||
var i = 0;
|
||||
worker.onmessage = this.step_func(function(e) {
|
||||
i++;
|
||||
assert_equals(e.data, i);
|
||||
if (i == 2) {
|
||||
this.done();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
|
@ -0,0 +1,42 @@
|
|||
<!--
|
||||
var interval1 = setInterval(function() {
|
||||
clearInterval(interval1);
|
||||
postMessage(1);
|
||||
throw new Error();
|
||||
}, 10);
|
||||
close();
|
||||
var interval2 = setInterval(function() {
|
||||
clearInterval(interval2);
|
||||
postMessage(1);
|
||||
throw new Error();
|
||||
}, 10);
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>close() and setInterval</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(function() {
|
||||
var gotMessage = false;
|
||||
var gotError = false;
|
||||
var worker = new Worker('#');
|
||||
worker.onmessage = function(e) {
|
||||
gotMessage = true;
|
||||
};
|
||||
worker.onerror = function(e) {
|
||||
gotError = true;
|
||||
};
|
||||
setTimeout(this.step_func(function() {
|
||||
assert_false(gotMessage, 'got message');
|
||||
assert_true(gotError, 'got error');
|
||||
this.done();
|
||||
}), 500);
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
||||
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<!--
|
||||
function x() {
|
||||
postMessage(1);
|
||||
throw new Error();
|
||||
}
|
||||
setTimeout(x, 0);
|
||||
close();
|
||||
setTimeout(x, 0);
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>close() and setTimeout</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
async_test(function() {
|
||||
var gotMessage = false;
|
||||
var gotError = false;
|
||||
var worker = new Worker('#');
|
||||
worker.onmessage = function(e) {
|
||||
gotMessage = true;
|
||||
};
|
||||
worker.onerror = function(e) {
|
||||
gotError = true;
|
||||
};
|
||||
setTimeout(this.step_func(function() {
|
||||
assert_false(gotMessage, 'got message');
|
||||
assert_true(gotError, 'got error');
|
||||
this.done();
|
||||
}), 500);
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
def main(request, response):
|
||||
response.status = 302
|
||||
response.headers.append("Location", "post-location-members.js?a")
|
|
@ -0,0 +1,31 @@
|
|||
<!--
|
||||
postMessage([null, location.href, location.protocol, location.host,
|
||||
location.hostname, location.port, location.pathname,
|
||||
location.search, location.hash]);
|
||||
/*
|
||||
-->
|
||||
<!doctype html>
|
||||
<title>members of WorkerLocation</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(function() {
|
||||
var worker = new Worker('#');
|
||||
worker.onmessage = this.step_func(function(e) {
|
||||
assert_equals(e.data[0], null);
|
||||
assert_equals(e.data[1], location.href + '#', 'href');
|
||||
assert_equals(e.data[2], location.protocol, 'protocol');
|
||||
assert_equals(e.data[3], location.host, 'host');
|
||||
assert_equals(e.data[4], location.hostname, 'hostname');
|
||||
assert_equals(e.data[5], location.port, 'port');
|
||||
assert_equals(e.data[6], location.pathname, 'pathname');
|
||||
assert_equals(e.data[7], location.search, 'search');
|
||||
assert_equals(e.data[8], '', 'hash');
|
||||
this.done();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
*/
|
||||
//-->
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue