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.
8 * This variable is checked in SelectFileDialogExtensionBrowserTest.
11 window.JSErrorCount = 0;
14 * Counts uncaught exceptions.
16 window.onerror = function() { window.JSErrorCount++; };
19 * Wraps the function to use it as a callback.
21 * - Capture the stack trace in case of error.
24 * @param {Object} thisObject Object to be used as this.
25 * @return {function} Wapped function.
27 Function.prototype.wrap = function(thisObject) {
29 var liveStack = (new Error('Stack trace before async call')).stack;
30 if (thisObject === undefined)
33 return function wrappedCallback() {
35 return func.apply(thisObject, arguments);
37 console.error('Exception happens in callback.', liveStack);
39 window.JSErrorCount++;