2013-03-13 00:33:40 +04:00
|
|
|
/**
|
|
|
|
* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
*/
|
2015-11-11 08:16:12 +03:00
|
|
|
var tests = 3;
|
2012-09-15 22:51:55 +04:00
|
|
|
|
2015-11-11 08:16:12 +03:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
2012-09-15 22:51:55 +04:00
|
|
|
|
2015-11-11 08:16:12 +03:00
|
|
|
testDone = function(event) {
|
|
|
|
if (!--tests) {
|
|
|
|
SimpleTest.finish();
|
2012-09-15 22:51:55 +04:00
|
|
|
}
|
2019-07-05 11:44:55 +03:00
|
|
|
};
|
2012-09-15 22:51:55 +04:00
|
|
|
|
2015-11-11 08:16:12 +03:00
|
|
|
// Workers don't inherit CSP
|
2012-09-15 22:51:55 +04:00
|
|
|
worker = new Worker("csp_worker.js");
|
2015-11-11 08:16:12 +03:00
|
|
|
worker.postMessage({ do: "eval" });
|
2012-09-15 22:51:55 +04:00
|
|
|
worker.onmessage = function(event) {
|
2015-11-11 08:16:12 +03:00
|
|
|
is(event.data, 42, "Eval succeeded!");
|
|
|
|
testDone();
|
2012-09-15 22:51:55 +04:00
|
|
|
};
|
|
|
|
|
2015-11-11 08:16:12 +03:00
|
|
|
// blob: workers *do* inherit CSP
|
|
|
|
xhr = new XMLHttpRequest();
|
|
|
|
xhr.open("GET", "csp_worker.js");
|
|
|
|
xhr.responseType = "blob";
|
|
|
|
xhr.send();
|
|
|
|
xhr.onload = e => {
|
|
|
|
uri = URL.createObjectURL(e.target.response);
|
|
|
|
worker = new Worker(uri);
|
|
|
|
worker.postMessage({ do: "eval" });
|
|
|
|
worker.onmessage = function(event) {
|
2018-07-05 09:21:04 +03:00
|
|
|
is(event.data, "EvalError: call to eval() blocked by CSP", "Eval threw");
|
2015-11-11 08:16:12 +03:00
|
|
|
testDone();
|
|
|
|
};
|
2012-09-15 22:51:55 +04:00
|
|
|
};
|
|
|
|
|
2015-11-11 08:16:12 +03:00
|
|
|
xhr = new XMLHttpRequest();
|
|
|
|
xhr.open("GET", "csp_worker.js");
|
|
|
|
xhr.responseType = "blob";
|
|
|
|
xhr.send();
|
|
|
|
xhr.onload = e => {
|
|
|
|
uri = URL.createObjectURL(e.target.response);
|
|
|
|
worker = new Worker(uri);
|
2019-09-02 14:22:27 +03:00
|
|
|
worker.postMessage({ do: "nest", uri, level: 3 });
|
2015-11-11 08:16:12 +03:00
|
|
|
worker.onmessage = function(event) {
|
2018-07-05 09:21:04 +03:00
|
|
|
is(
|
|
|
|
event.data,
|
|
|
|
"EvalError: call to eval() blocked by CSP",
|
|
|
|
"Eval threw in nested worker"
|
|
|
|
);
|
2015-11-11 08:16:12 +03:00
|
|
|
testDone();
|
|
|
|
};
|
2013-03-13 00:33:40 +04:00
|
|
|
};
|