Index: ui/webui/resources/js/assert.js |
diff --git a/ui/webui/resources/js/assert.js b/ui/webui/resources/js/assert.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bae2910705bd3eb77270c46cf7ec1fb6dbac82a0 |
--- /dev/null |
+++ b/ui/webui/resources/js/assert.js |
@@ -0,0 +1,24 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+/** |
+ * @fileoverview Assertion support. |
+ */ |
+ |
+/** |
+ * Simple common assertion API |
+ * @param {*} condition The condition to test. Note that this may be used to |
+ * test whether a value is defined or not, and we don't want to force a |
+ * cast to Boolean. |
+ * @param {string=} opt_message A message to use in any error. |
+ */ |
+function assert(condition, opt_message) { |
+ 'use strict'; |
+ if (!condition) { |
+ var msg = 'Assertion failed'; |
+ if (opt_message) |
+ msg = msg + ': ' + opt_message; |
+ throw new Error(msg); |
+ } |
+} |