Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ui / file_manager / file_manager / common / js / error_util.js
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 'use strict';
6
7 /**
8  * This variable is checked in SelectFileDialogExtensionBrowserTest.
9  * @type {number}
10  */
11 window.JSErrorCount = 0;
12
13 /**
14  * Count uncaught exceptions.
15  */
16 window.onerror = function() { window.JSErrorCount++; };
17
18 // Overrides console.error() to count errors.
19 /**
20  * @param {...Object} var_args Message to be logged.
21  */
22 console.error = (function() {
23   var orig = console.error;
24   return function() {
25     window.JSErrorCount++;
26     return orig.apply(this, arguments);
27   };
28 })();
29
30 // Overrides console.assert() to count errors.
31 /**
32  * @param {boolean} condition If false, log a message and stack trace.
33  * @param {...Object} var_args Objects to.
34  */
35 console.assert = (function() {
36   var orig = console.assert;
37   return function(condition) {
38     if (!condition)
39       window.JSErrorCount++;
40     return orig.apply(this, arguments);
41   };
42 })();