Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Unified Diff: chrome/browser/resources/uber/uber.js

Issue 418663002: Typecheck JS files for chrome://help before doing import transition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@json_to_pydict
Patch Set: Fixed previous comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/uber/uber.js
diff --git a/chrome/browser/resources/uber/uber.js b/chrome/browser/resources/uber/uber.js
index 488310f8a305a894e2bb133128402b786029e83e..bc7f0d7a1b4bd314213a471c783b50285fb0c698 100644
--- a/chrome/browser/resources/uber/uber.js
+++ b/chrome/browser/resources/uber/uber.js
@@ -149,6 +149,7 @@ cr.define('uber', function() {
* @param {Event} e The posted object.
*/
function handleWindowMessage(e) {
+ e = /** @type{!MessageEvent.<!{method: string, params: *}>} */(e);
if (e.data.method === 'beginInterceptingEvents') {
backgroundNavigation();
} else if (e.data.method === 'stopInterceptingEvents') {
@@ -167,9 +168,9 @@ cr.define('uber', function() {
} else if (e.data.method === 'navigationControlsLoaded') {
onNavigationControlsLoaded();
} else if (e.data.method === 'adjustToScroll') {
- adjustToScroll(e.data.params);
+ adjustToScroll(/** @type {number} */(e.data.params));
} else if (e.data.method === 'mouseWheel') {
- forwardMouseWheel(e.data.params);
+ forwardMouseWheel(/** @type {Object} */(e.data.params));
} else {
console.error('Received unexpected message', e.data);
}
@@ -211,12 +212,14 @@ cr.define('uber', function() {
/**
* Get an iframe based on the origin of a received post message.
* @param {string} origin The origin of a post message.
- * @return {!HTMLElement} The frame associated to |origin| or null.
+ * @return {!Element} The frame associated to |origin| or null.
*/
function getIframeFromOrigin(origin) {
assert(origin.substr(-1) != '/', 'invalid origin given');
var query = '.iframe-container > iframe[src^="' + origin + '/"]';
- return document.querySelector(query);
+ var element = document.querySelector(query);
+ assert(element, 'expected an element');
Dan Beam 2014/07/24 04:27:54 why don't we just update assert() to something lik
Vitaly Pavlenko 2014/07/24 18:54:29 Acknowledged.
+ return /** @type {!Element} */ (element);
}
/**
@@ -313,7 +316,7 @@ cr.define('uber', function() {
/**
* Selects and navigates a subpage. This is called from uber-frame.
* @param {string} pageId Should match an id of one of the iframe containers.
- * @param {integer} historyOption Indicates whether we should push or replace
+ * @param {number} historyOption Indicates whether we should push or replace
* browser history.
* @param {string} path A sub-page path.
*/
@@ -371,8 +374,11 @@ cr.define('uber', function() {
if (container.dataset.title)
document.title = container.dataset.title;
- $('favicon').href = 'chrome://theme/' + container.dataset.favicon;
- $('favicon2x').href = 'chrome://theme/' + container.dataset.favicon + '@2x';
+ assert('favicon' in container.dataset);
+
+ var dataset = /** @type {{favicon: string}} */ (container.dataset);
+ $('favicon').href = 'chrome://theme/' + dataset.favicon;
+ $('favicon2x').href = 'chrome://theme/' + dataset.favicon + '@2x';
updateNavigationControls();
}
« no previous file with comments | « no previous file | chrome/browser/resources/uber/uber_utils.js » ('j') | chrome/browser/resources/uber/uber_utils.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698