| Index: third_party/google_input_tools/third_party/closure_library/closure/goog/debug/debug.js
|
| diff --git a/third_party/google_input_tools/third_party/closure_library/closure/goog/debug/debug.js b/third_party/google_input_tools/third_party/closure_library/closure/goog/debug/debug.js
|
| index e6e28e13c387149812a39c615ae00c133b8e297c..ff153745d0135a9479cda36bbb395cbcfc8ba9c1 100644
|
| --- a/third_party/google_input_tools/third_party/closure_library/closure/goog/debug/debug.js
|
| +++ b/third_party/google_input_tools/third_party/closure_library/closure/goog/debug/debug.js
|
| @@ -21,7 +21,10 @@
|
| goog.provide('goog.debug');
|
|
|
| goog.require('goog.array');
|
| -goog.require('goog.string');
|
| +goog.require('goog.html.SafeHtml');
|
| +goog.require('goog.html.SafeUrl');
|
| +goog.require('goog.html.uncheckedconversions');
|
| +goog.require('goog.string.Const');
|
| goog.require('goog.structs.Set');
|
| goog.require('goog.userAgent');
|
|
|
| @@ -193,7 +196,7 @@ goog.debug.deepExpose = function(obj, opt_showFn) {
|
|
|
| /**
|
| * Recursively outputs a nested array as a string.
|
| - * @param {Array} arr The array.
|
| + * @param {Array<?>} arr The array.
|
| * @return {string} String representing nested array.
|
| */
|
| goog.debug.exposeArray = function(arr) {
|
| @@ -211,31 +214,70 @@ goog.debug.exposeArray = function(arr) {
|
|
|
| /**
|
| * Exposes an exception that has been caught by a try...catch and outputs the
|
| - * error with a stack trace.
|
| + * error as HTML with a stack trace.
|
| * @param {Object} err Error object or string.
|
| * @param {Function=} opt_fn Optional function to start stack trace from.
|
| - * @return {string} Details of exception.
|
| + * @return {string} Details of exception, as HTML.
|
| */
|
| goog.debug.exposeException = function(err, opt_fn) {
|
| + var html = goog.debug.exposeExceptionAsHtml(err, opt_fn);
|
| + return goog.html.SafeHtml.unwrap(html);
|
| +};
|
| +
|
| +
|
| +/**
|
| + * Exposes an exception that has been caught by a try...catch and outputs the
|
| + * error with a stack trace.
|
| + * @param {Object} err Error object or string.
|
| + * @param {Function=} opt_fn Optional function to start stack trace from.
|
| + * @return {!goog.html.SafeHtml} Details of exception.
|
| + */
|
| +goog.debug.exposeExceptionAsHtml = function(err, opt_fn) {
|
| /** @preserveTry */
|
| try {
|
| var e = goog.debug.normalizeErrorObject(err);
|
| -
|
| // Create the error message
|
| - var error = 'Message: ' + goog.string.htmlEscape(e.message) +
|
| - '\nUrl: <a href="view-source:' + e.fileName + '" target="_new">' +
|
| - e.fileName + '</a>\nLine: ' + e.lineNumber + '\n\nBrowser stack:\n' +
|
| - goog.string.htmlEscape(e.stack + '-> ') +
|
| - '[end]\n\nJS stack traversal:\n' + goog.string.htmlEscape(
|
| - goog.debug.getStacktrace(opt_fn) + '-> ');
|
| + var viewSourceUrl = goog.debug.createViewSourceUrl_(e.fileName);
|
| + var error = goog.html.SafeHtml.concat(
|
| + goog.html.SafeHtml.htmlEscapePreservingNewlinesAndSpaces(
|
| + 'Message: ' + e.message + '\nUrl: '),
|
| + goog.html.SafeHtml.create('a',
|
| + {href: viewSourceUrl, target: '_new'}, e.fileName),
|
| + goog.html.SafeHtml.htmlEscapePreservingNewlinesAndSpaces(
|
| + '\nLine: ' + e.lineNumber + '\n\nBrowser stack:\n' +
|
| + e.stack + '-> ' + '[end]\n\nJS stack traversal:\n' +
|
| + goog.debug.getStacktrace(opt_fn) + '-> '));
|
| return error;
|
| } catch (e2) {
|
| - return 'Exception trying to expose exception! You win, we lose. ' + e2;
|
| + return goog.html.SafeHtml.htmlEscapePreservingNewlinesAndSpaces(
|
| + 'Exception trying to expose exception! You win, we lose. ' + e2);
|
| }
|
| };
|
|
|
|
|
| /**
|
| + * @param {?string=} opt_fileName
|
| + * @return {!goog.html.SafeUrl} SafeUrl with view-source scheme, pointing at
|
| + * fileName.
|
| + * @private
|
| + */
|
| +goog.debug.createViewSourceUrl_ = function(opt_fileName) {
|
| + if (!goog.isDefAndNotNull(opt_fileName)) {
|
| + opt_fileName = '';
|
| + }
|
| + if (!/^https?:\/\//i.test(opt_fileName)) {
|
| + return goog.html.SafeUrl.fromConstant(
|
| + goog.string.Const.from('sanitizedviewsrc'));
|
| + }
|
| + var sanitizedFileName = goog.html.SafeUrl.sanitize(opt_fileName);
|
| + return goog.html.uncheckedconversions.
|
| + safeUrlFromStringKnownToSatisfyTypeContract(
|
| + goog.string.Const.from('view-source scheme plus HTTP/HTTPS URL'),
|
| + 'view-source:' + goog.html.SafeUrl.unwrap(sanitizedFileName));
|
| +};
|
| +
|
| +
|
| +/**
|
| * Normalizes the error/exception object between browsers.
|
| * @param {Object} err Raw error object.
|
| * @return {!Object} Normalized error object.
|
| @@ -440,7 +482,7 @@ goog.debug.getStacktrace = function(opt_fn) {
|
| /**
|
| * Private helper for getStacktrace().
|
| * @param {Function} fn Function to start getting the trace from.
|
| - * @param {Array} visited List of functions visited so far.
|
| + * @param {Array<!Function>} visited List of functions visited so far.
|
| * @return {string} Stack trace starting from function fn.
|
| * @suppress {es5Strict}
|
| * @private
|
| @@ -575,6 +617,27 @@ goog.debug.makeWhitespaceVisible = function(string) {
|
|
|
|
|
| /**
|
| + * Returns the type of a value. If a constructor is passed, and a suitable
|
| + * string cannot be found, 'unknown type name' will be returned.
|
| + *
|
| + * <p>Forked rather than moved from {@link goog.asserts.getType_}
|
| + * to avoid adding a dependency to goog.asserts.
|
| + * @param {*} value A constructor, object, or primitive.
|
| + * @return {string} The best display name for the value, or 'unknown type name'.
|
| + */
|
| +goog.debug.runtimeType = function(value) {
|
| + if (value instanceof Function) {
|
| + return value.displayName || value.name || 'unknown type name';
|
| + } else if (value instanceof Object) {
|
| + return value.constructor.displayName || value.constructor.name ||
|
| + Object.prototype.toString.call(value);
|
| + } else {
|
| + return value === null ? 'null' : typeof value;
|
| + }
|
| +};
|
| +
|
| +
|
| +/**
|
| * Hash map for storing function names that have already been looked up.
|
| * @type {Object}
|
| * @private
|
|
|