summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/content-security-policy/script-src/inlineTests.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/content-security-policy/script-src/inlineTests.js')
-rw-r--r--testing/web-platform/tests/content-security-policy/script-src/inlineTests.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/testing/web-platform/tests/content-security-policy/script-src/inlineTests.js b/testing/web-platform/tests/content-security-policy/script-src/inlineTests.js
new file mode 100644
index 0000000000..3c0712b449
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/script-src/inlineTests.js
@@ -0,0 +1,22 @@
+var t1 = async_test("Inline script block");
+var t2 = async_test("Inline event handler");
+
+onload = function() {t1.done(); t2.done();};
+
+var t_spv = async_test("Should fire policy violation events");
+var block_event_fired = false;
+var handler_event_fired = false;
+window.addEventListener("securitypolicyviolation", t_spv.step_func(function(e) {
+ if (e.violatedDirective == "script-src-elem") {
+ assert_false(block_event_fired);
+ block_event_fired = true;
+ } else if (e.violatedDirective == "script-src-attr") {
+ assert_false(handler_event_fired);
+ handler_event_fired = true;
+ } else {
+ assert_unreached("Unexpected directive broken");
+ }
+ if (block_event_fired && handler_event_fired) {
+ t_spv.done();
+ }
+}));