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

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/content-security-policy/support/alertAssert.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/alertAssert.sub.js
diff --git a/third_party/WebKit/LayoutTests/external/wpt/content-security-policy/support/alertAssert.sub.js b/third_party/WebKit/LayoutTests/external/wpt/content-security-policy/support/alertAssert.sub.js
new file mode 100644
index 0000000000000000000000000000000000000000..ee9e54ea79fa1e56e62b3d2198910ae085c437be
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/content-security-policy/support/alertAssert.sub.js
@@ -0,0 +1,43 @@
+// note, this template substitution is XSS, but no way to avoid it in this framework
+var expected_alerts = {{GET[alerts]}};
+var timeout= "{{GET[timeout]}}";
+if (timeout == "") {
+ timeout = 2;
+}
+
+if(expected_alerts.length == 0) {
+ function alert_assert(msg) {
+ test(function () { assert_unreached(msg) });
+ }
+} else {
+ var t_alert = async_test('Expecting alerts: {{GET[alerts]}}');
+ step_timeout(function() {
+ if(t_alert.phase != t_alert.phases.COMPLETE) {
+ t_alert.step(function() { assert_unreached('Alert timeout, expected alerts ' + expected_alerts + ' not fired.') });
+ t_alert.done();
+ }
+ }, timeout * 1000);
+ var alert_assert = function (msg) {
+ t_alert.step(function () {
+ if(msg && msg instanceof Error) {
+ msg = msg.message;
+ }
+ if (msg && msg.match(/^FAIL/i)) {
+ assert_unreached(msg);
+ t_alert.done();
+ }
+ for (var i = 0; i < expected_alerts.length; i++) {
+ if (expected_alerts[i] == msg) {
+ assert_true(expected_alerts[i] == msg);
+ expected_alerts.splice(i, 1);
+ if (expected_alerts.length == 0) {
+ t_alert.done();
+ }
+ return;
+ }
+ }
+ assert_unreached('unexpected alert: ' + msg);
+ t_log.done();
+ });
+ }.bind(this);
+}

Powered by Google App Engine
This is Rietveld 408576698