2013-03-08 02:27:21 +04:00
|
|
|
<!--
|
|
|
|
Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
-->
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test for DOM Worker Threads</title>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
"use strict";
|
|
|
|
|
2015-11-17 01:41:03 +03:00
|
|
|
function nextTest() {
|
|
|
|
(function(){
|
|
|
|
function workerfunc() {
|
|
|
|
var subworker = new Worker("about:blank");
|
|
|
|
subworker.onerror = function(e) {
|
|
|
|
e.preventDefault();
|
2017-01-28 17:40:08 +03:00
|
|
|
postMessage("ERROR");
|
2015-11-17 01:41:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
var b = new Blob([workerfunc+'workerfunc();']);
|
|
|
|
var u = URL.createObjectURL(b);
|
|
|
|
function callworker(i) {
|
2018-06-13 20:03:55 +03:00
|
|
|
var w = new Worker(u);
|
|
|
|
URL.revokeObjectURL(u);
|
2015-11-17 01:41:03 +03:00
|
|
|
w.onmessage = function(e) {
|
2018-06-13 20:03:55 +03:00
|
|
|
is(i, 0, 'Message received');
|
2017-01-28 17:40:08 +03:00
|
|
|
is(e.data, "ERROR",
|
2016-02-26 23:23:13 +03:00
|
|
|
"Should catch the error when loading inner script");
|
2015-11-17 01:41:03 +03:00
|
|
|
if (++i < 2) callworker(i);
|
|
|
|
else SimpleTest.finish();
|
|
|
|
};
|
2018-06-13 20:03:55 +03:00
|
|
|
w.onerror = function(e) {
|
|
|
|
is(i, 1, 'OnError received');
|
|
|
|
SimpleTest.finish();
|
2016-02-26 23:23:13 +03:00
|
|
|
}
|
2015-11-17 01:41:03 +03:00
|
|
|
}
|
|
|
|
callworker(0);
|
|
|
|
})();
|
|
|
|
}
|
|
|
|
|
2013-03-08 02:27:21 +04:00
|
|
|
try {
|
|
|
|
var worker = new Worker("about:blank");
|
2015-11-17 01:41:03 +03:00
|
|
|
worker.onerror = function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
nextTest();
|
|
|
|
}
|
2013-03-08 02:27:21 +04:00
|
|
|
|
|
|
|
worker.onmessage = function(event) {
|
|
|
|
ok(false, "Shouldn't get a message!");
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
} catch (e) {
|
2015-11-17 01:41:03 +03:00
|
|
|
ok(false, "This should not happen.");
|
2013-03-08 02:27:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|