summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/content-security-policy/script-src/inlineTests.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/content-security-policy/script-src/inlineTests.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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();
+ }
+}));