Chromium Code Reviews| Index: chrome/browser/resources/extensions/extension_error_overlay.js |
| diff --git a/chrome/browser/resources/extensions/extension_error_overlay.js b/chrome/browser/resources/extensions/extension_error_overlay.js |
| index 537b6892b55bb24eeae734063ce2dd8c0d0cabd8..5d898f739b3b4cf33907d0af4ea14dd974a7ebf2 100644 |
| --- a/chrome/browser/resources/extensions/extension_error_overlay.js |
| +++ b/chrome/browser/resources/extensions/extension_error_overlay.js |
| @@ -2,6 +2,35 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +/** |
| + * The type of the stack trace object object. The definition is based on |
|
Dan Beam
2014/08/22 21:57:13
object object -> object
Vitaly Pavlenko
2014/08/23 00:59:03
Done.
|
| + * extensions/browser/extension_error.cc:RuntimeError::ToValue(). |
| + * @typedef {{columnNumber: number, |
| + * functionName: string, |
| + * lineNumber: number, |
| + * url: string}} |
| + */ |
| +var BackendStackTraceObject; |
|
Dan Beam
2014/08/22 21:57:13
StackTrace
Vitaly Pavlenko
2014/08/23 00:59:03
Done.
|
| + |
| +/** |
| + * The type of the extension error trace object. The definition is based on |
| + * extensions/browser/extension_error.cc:RuntimeError::ToValue(). |
| + * @typedef {{canInspect: (boolean|undefined), |
| + * contextUrl: (string|undefined), |
| + * extensionId: string, |
| + * fromIncognito: boolean, |
| + * level: number, |
| + * manifestKey: string, |
| + * manifestSpecific: string, |
| + * message: string, |
| + * renderProcessId: (number|undefined), |
| + * renderViewId: (number|undefined), |
| + * source: string, |
| + * stackTrace: (Array.<BackendStackTraceObject>|undefined), |
| + * type: number}} |
| + */ |
| +var BackendExtensionErrorObject; |
|
Dan Beam
2014/08/22 21:57:13
RuntimeError
Vitaly Pavlenko
2014/08/23 00:59:03
Done.
|
| + |
| cr.define('extensions', function() { |
| 'use strict'; |
| @@ -85,24 +114,24 @@ cr.define('extensions', function() { |
| /** |
| * The underlying error whose details are being displayed. |
| - * @type {Object} |
| + * @type {?BackendExtensionErrorObject} |
| * @private |
| */ |
| - error_: undefined, |
| + error_: null, |
| /** |
| * The URL associated with this extension, i.e. chrome-extension://<id>/. |
| - * @type {string} |
| + * @type {?string} |
| * @private |
| */ |
| - extensionUrl_: undefined, |
| + extensionUrl_: null, |
| /** |
| * The node of the stack trace which is currently active. |
| - * @type {HTMLElement} |
| + * @type {?HTMLElement} |
| * @private |
| */ |
| - currentFrameNode_: undefined, |
| + currentFrameNode_: null, |
| /** |
| * Initialize the RuntimeErrorContent for the first time. |
| @@ -113,8 +142,8 @@ cr.define('extensions', function() { |
| * @type {HTMLElement} |
| * @private |
| */ |
| - this.stackTrace_ = |
| - this.querySelector('.extension-error-overlay-stack-trace-list'); |
| + this.stackTrace_ = /** @type {HTMLElement} */( |
| + this.querySelector('.extension-error-overlay-stack-trace-list')); |
| assert(this.stackTrace_); |
| /** |
| @@ -122,14 +151,15 @@ cr.define('extensions', function() { |
| * @type {HTMLElement} |
| * @private |
| */ |
| - this.contextUrl_ = |
| - this.querySelector('.extension-error-overlay-context-url'); |
| + this.contextUrl_ = /** @type {HTMLElement} */( |
| + this.querySelector('.extension-error-overlay-context-url')); |
| assert(this.contextUrl_); |
| }, |
| /** |
| * Sets the error for the content. |
| - * @param {Object} error The error whose content should be displayed. |
| + * @param {BackendExtensionErrorObject} error The error whose content should |
| + * be displayed. |
| * @param {string} extensionUrl The URL associated with this extension. |
| */ |
| setError: function(error, extensionUrl) { |
| @@ -145,9 +175,9 @@ cr.define('extensions', function() { |
| * Wipe content associated with a specific error. |
| */ |
| clearError: function() { |
| - this.error_ = undefined; |
| - this.extensionUrl_ = undefined; |
| - this.currentFrameNode_ = undefined; |
| + this.error_ = null; |
| + this.extensionUrl_ = null; |
| + this.currentFrameNode_ = null; |
| clearElement(this.stackTrace_); |
| this.stackTrace_.hidden = true; |
| }, |
| @@ -155,7 +185,7 @@ cr.define('extensions', function() { |
| /** |
| * Makes |frame| active and deactivates the previously active frame (if |
| * there was one). |
| - * @param {HTMLElement} frame The frame to activate. |
| + * @param {HTMLElement} frameNode The frame to activate. |
| * @private |
| */ |
| setActiveFrame_: function(frameNode) { |
| @@ -189,8 +219,8 @@ cr.define('extensions', function() { |
| // The description is a human-readable summation of the frame, in the |
| // form "<relative_url>:<line_number> (function)", e.g. |
| // "myfile.js:25 (myFunction)". |
| - var description = getRelativeUrl(frame.url, this.extensionUrl_) + |
| - ':' + frame.lineNumber; |
| + var description = getRelativeUrl(frame.url, |
| + assert(this.extensionUrl_)) + ':' + frame.lineNumber; |
| if (frame.functionName) { |
| var functionName = frame.functionName == '(anonymous function)' ? |
| loadTimeData.getString('extensionErrorOverlayAnonymousFunction') : |
| @@ -204,9 +234,6 @@ cr.define('extensions', function() { |
| // code with the line highlighted, and link the "Open DevTools" button |
| // with that frame. |
| frameNode.addEventListener('click', function(frame, frameNode, e) { |
| - if (this.currStackFrame_ == frameNode) |
| - return; |
| - |
| this.setActiveFrame_(frameNode); |
| // Request the file source with the section highlighted; this will |
| @@ -228,7 +255,8 @@ cr.define('extensions', function() { |
| // internal frames.) |
| if (this.stackTrace_.children.length > 0) { |
| this.stackTrace_.hidden = false; |
| - this.setActiveFrame_(this.stackTrace_.firstChild); |
| + this.setActiveFrame_(assertInstanceof(this.stackTrace_.firstChild, |
| + HTMLElement)); |
| } |
| }, |
| @@ -344,10 +372,10 @@ cr.define('extensions', function() { |
| ExtensionErrorOverlay.prototype = { |
| /** |
| * The underlying error whose details are being displayed. |
| - * @type {Object} |
| + * @type {?BackendExtensionErrorObject} |
| * @private |
| */ |
| - error_: undefined, |
| + error_: null, |
| /** |
| * Initialize the page. |
| @@ -370,12 +398,13 @@ cr.define('extensions', function() { |
| * @type {HTMLDivElement} |
| * @private |
| */ |
| - this.overlayDiv_ = $('extension-error-overlay'); |
| + this.overlayDiv_ = /** @type {HTMLDivElement} */( |
| + $('extension-error-overlay')); |
| /** |
| * The portion of the overlay which shows the code relating to the error |
| * and the corresponding line numbers. |
| - * @type {ExtensionCode} |
| + * @type {extensions.ExtensionCode} |
| * @private |
| */ |
| this.codeDiv_ = |
| @@ -383,7 +412,6 @@ cr.define('extensions', function() { |
| /** |
| * The function to show or hide the ExtensionErrorOverlay. |
| - * @type {function} |
| * @param {boolean} isVisible Whether the overlay should be visible. |
| */ |
| this.setVisible = function(isVisible) { |
| @@ -398,7 +426,8 @@ cr.define('extensions', function() { |
| * @type {HTMLButtonElement} |
| * @private |
| */ |
| - this.openDevtoolsButton_ = $('extension-error-overlay-devtools-button'); |
| + this.openDevtoolsButton_ = /** @type {HTMLButtonElement} */( |
| + $('extension-error-overlay-devtools-button')); |
| this.openDevtoolsButton_.addEventListener('click', function() { |
| this.runtimeErrorContent_.openDevtools(); |
| }.bind(this)); |
| @@ -429,7 +458,7 @@ cr.define('extensions', function() { |
| this.runtimeErrorContent_.clearError(); |
| } |
| - this.error_ = undefined; |
| + this.error_ = null; |
| }, |
| /** |
| @@ -437,7 +466,8 @@ cr.define('extensions', function() { |
| * overlay, and, if possible, will populate the code section of the overlay |
| * with the relevant file, load the stack trace, and generate links for |
| * opening devtools (the latter two only happen for runtime errors). |
| - * @param {Object} error The error to show in the overlay. |
| + * @param {BackendExtensionErrorObject} error The error to show in the |
| + * overlay. |
| * @param {string} extensionUrl The URL of the extension, in the form |
| * "chrome-extension://<extension_id>". |
| */ |
| @@ -478,7 +508,8 @@ cr.define('extensions', function() { |
| /** |
| * Set the code to be displayed in the code portion of the overlay. |
| * @see ExtensionErrorOverlay.requestFileSourceResponse(). |
| - * @param {?Object} code The code to be displayed. If |code| is null, then |
| + * @param {?ExtensionHighlight} code The code to be displayed. If |code| is |
| + * null, then |
| * a "Could not display code" message will be displayed instead. |
| */ |
| setCode: function(code) { |
| @@ -495,11 +526,10 @@ cr.define('extensions', function() { |
| /** |
| * Called by the ExtensionErrorHandler responding to the request for a file's |
| * source. Populate the content area of the overlay and display the overlay. |
| - * @param {Object?} result An object with four strings - the title, |
| - * beforeHighlight, afterHighlight, and highlight. The three 'highlight' |
| - * strings represent three portions of the file's content to display - the |
| - * portion which is most relevant and should be emphasized (highlight), |
| - * and the parts both before and after this portion. These may be empty. |
| + * @param {?ExtensionHighlight} result The three 'highlight' strings represent |
| + * three portions of the file's content to display - the portion which is |
| + * most relevant and should be emphasized (highlight), and the parts both |
| + * before and after this portion. These may be empty. |
| */ |
| ExtensionErrorOverlay.requestFileSourceResponse = function(result) { |
| var overlay = extensions.ExtensionErrorOverlay.getInstance(); |