Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1211)

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/content-security-policy/support/logTest.sub.js

Issue 2695813009: Import wpt@503f5b5f78ec4e87d144f78609f363f0ed0ea8db (Closed)
Patch Set: Skip some tests Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/external/wpt/content-security-policy/support/logTest.sub.js
diff --git a/third_party/WebKit/LayoutTests/external/wpt/content-security-policy/support/logTest.sub.js b/third_party/WebKit/LayoutTests/external/wpt/content-security-policy/support/logTest.sub.js
new file mode 100644
index 0000000000000000000000000000000000000000..f712252cef531182cc4780210529301bb5475e16
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/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_true(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();
+ });
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698