summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/content-security-policy/support/logTest.sub.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/content-security-policy/support/logTest.sub.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/content-security-policy/support/logTest.sub.js')
-rw-r--r--testing/web-platform/tests/content-security-policy/support/logTest.sub.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/testing/web-platform/tests/content-security-policy/support/logTest.sub.js b/testing/web-platform/tests/content-security-policy/support/logTest.sub.js
new file mode 100644
index 0000000000..29b8a271f5
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/support/logTest.sub.js
@@ -0,0 +1,41 @@
+// note, this template substitution is XSS, but no way to avoid it in this framework
+var expected_logs = {{GET[logs]}};
+var timeout = "{{GET[timeout]}}";
+if (timeout == "") {
+ timeout = 2;
+}
+
+if (expected_logs.length == 0) {
+ function log_assert(msg) {
+ test(function () { assert_unreached(msg) });
+ }
+} else {
+ var t_log = async_test('Expecting logs: {{GET[logs]}}');
+ step_timeout(function() {
+ if(t_log.phase != t_log.phases.COMPLETE){
+ t_log.step(function () { assert_unreached('Logging timeout, expected logs ' + expected_logs + ' not sent.') });
+ t_log.done();
+ }
+ }, timeout * 1000);
+ function log(msg) {
+ //cons/**/ole.log(msg);
+ t_log.step(function () {
+ if (msg.match(/^FAIL/i)) {
+ assert_unreached(msg);
+ t_log.done();
+ }
+ for (var i = 0; i < expected_logs.length; i++) {
+ if (expected_logs[i] == msg) {
+ assert_equals(expected_logs[i], msg);
+ expected_logs.splice(i, 1);
+ if (expected_logs.length == 0) {
+ t_log.done();
+ }
+ return;
+ }
+ }
+ assert_unreached('unexpected log: ' + msg);
+ t_log.done();
+ });
+ }
+}