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