2013-03-12 20:33:40 +00:00
|
|
|
/**
|
|
|
|
* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
*/
|
2012-09-15 18:51:55 +00:00
|
|
|
msg = null;
|
2013-03-12 20:33:40 +00:00
|
|
|
var errors = 5;
|
2012-09-15 18:51:55 +00:00
|
|
|
|
|
|
|
onerror = function(event) {
|
|
|
|
ok(true, msg);
|
|
|
|
if (!--errors) SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
msg = "No Eval allowed";
|
|
|
|
worker = new Worker("csp_worker.js");
|
|
|
|
worker.postMessage(0);
|
|
|
|
worker.onmessage = function(event) {
|
|
|
|
ok(false, "Eval succeeded!");
|
|
|
|
}
|
|
|
|
|
|
|
|
msg = "No Eval allowed 2";
|
|
|
|
worker = new Worker("csp_worker.js");
|
|
|
|
worker.postMessage(4);
|
|
|
|
worker.onmessage = function(event) {
|
|
|
|
ok(false, "Eval succeeded!");
|
|
|
|
}
|
|
|
|
|
|
|
|
msg = "ImportScripts data:";
|
|
|
|
worker = new Worker("csp_worker.js");
|
|
|
|
worker.postMessage(-1);
|
|
|
|
worker.onmessage = function(event) {
|
|
|
|
ok(false, "Eval succeeded!");
|
|
|
|
}
|
|
|
|
|
|
|
|
msg = "ImportScripts javascript:";
|
|
|
|
worker = new Worker("csp_worker.js");
|
|
|
|
worker.postMessage(-2);
|
|
|
|
worker.onmessage = function(event) {
|
|
|
|
ok(false, "Eval succeeded!");
|
|
|
|
}
|
|
|
|
|
|
|
|
msg = "Loading data:something";
|
2013-03-12 20:33:40 +00:00
|
|
|
try {
|
|
|
|
worker = new Worker("data:application/javascript;base64,ZHVtcCgnaGVsbG8gd29ybGQnKQo=");
|
|
|
|
ok(false, "Should have thrown!");
|
|
|
|
} catch (e) {
|
|
|
|
ok(true, "Threw as expected.");
|
|
|
|
}
|
2012-09-15 18:51:55 +00:00
|
|
|
|
2013-03-12 20:33:40 +00:00
|
|
|
worker = new Worker("javascript:dump(123);");
|
2012-09-15 18:51:55 +00:00
|
|
|
SimpleTest.waitForExplicitFinish();
|