Skip to content

Commit

Permalink
Update our copy of the Closure compiler and library to the most recent
Browse files Browse the repository at this point in the history
versions. This required cleaning up a few types and invalid casts in
our code base.
  • Loading branch information
jleyba committed Jun 14, 2013
1 parent 074c96d commit 1d77ff7
Show file tree
Hide file tree
Showing 529 changed files with 89,744 additions and 16,463 deletions.
2 changes: 1 addition & 1 deletion javascript/atoms/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ bot.Device.prototype.toggleRadioButtonOrCheckbox_ = function(wasSelected) {
* @protected
*/
bot.Device.findAncestorForm = function(node) {
return (/** @type {Element} */ goog.dom.getAncestor(
return /** @type {Element} */ (goog.dom.getAncestor(
node, bot.Device.isForm_, /*includeNode=*/true));
};

Expand Down
12 changes: 6 additions & 6 deletions javascript/atoms/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ bot.dom.isEnabled = function(el) {
el.parentNode.nodeType == goog.dom.NodeType.ELEMENT &&
goog.dom.TagName.OPTGROUP == tagName ||
goog.dom.TagName.OPTION == tagName) {
return bot.dom.isEnabled((/**@type{!Element}*/el.parentNode));
return bot.dom.isEnabled(/**@type{!Element}*/ (el.parentNode));
}

// Is there an ancestor of the current element that is a disabled fieldset
Expand Down Expand Up @@ -466,7 +466,7 @@ bot.dom.getParentElement = function(node) {
elem.nodeType != goog.dom.NodeType.DOCUMENT_FRAGMENT) {
elem = elem.parentNode;
}
return (/** @type {Element} */ bot.dom.isElement(elem) ? elem : null);
return /** @type {Element} */ (bot.dom.isElement(elem) ? elem : null);
};


Expand Down Expand Up @@ -655,7 +655,7 @@ bot.dom.isShown = function(elem, opt_ignoreOpacity) {
/** @type {!Element} */ (n), 'usemap') == '#' + elem.name;
});
}
return !!mapImage && bot.dom.isShown((/** @type {!Element} */ mapImage),
return !!mapImage && bot.dom.isShown(/** @type {!Element} */ (mapImage),
opt_ignoreOpacity);
}

Expand Down Expand Up @@ -884,7 +884,7 @@ bot.dom.getVisibleText = function(elem) {
*/
bot.dom.appendVisibleTextLinesFromElement_ = function(elem, lines) {
function currLine() {
return (/** @type {string|undefined} */ goog.array.peek(lines)) || '';
return /** @type {string|undefined} */ (goog.array.peek(lines)) || '';
}

// TODO(gdennis): Add case here for textual form elements.
Expand Down Expand Up @@ -931,11 +931,11 @@ bot.dom.appendVisibleTextLinesFromElement_ = function(elem, lines) {

goog.array.forEach(elem.childNodes, function(node) {
if (node.nodeType == goog.dom.NodeType.TEXT && shown) {
var textNode = (/** @type {!Text} */ node);
var textNode = /** @type {!Text} */ (node);
bot.dom.appendVisibleTextLinesFromTextNode_(textNode, lines,
whitespace, textTransform);
} else if (bot.dom.isElement(node)) {
var castElem = (/** @type {!Element} */ node);
var castElem = /** @type {!Element} */ (node);
bot.dom.appendVisibleTextLinesFromElement_(castElem, lines);
}
});
Expand Down
10 changes: 5 additions & 5 deletions javascript/atoms/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ bot.events.MouseEventFactory_.prototype.create = function(target, opt_args) {
'Browser does not support a mouse pixel scroll event.');
}

var args = (/** @type {!bot.events.MouseArgs} */ opt_args);
var args = /** @type {!bot.events.MouseArgs} */ (opt_args);
var doc = goog.dom.getOwnerDocument(target);
var event;

Expand Down Expand Up @@ -404,7 +404,7 @@ goog.inherits(bot.events.KeyboardEventFactory_, bot.events.EventFactory_);
* @override
*/
bot.events.KeyboardEventFactory_.prototype.create = function(target, opt_args) {
var args = (/** @type {!bot.events.KeyboardArgs} */ opt_args);
var args = /** @type {!bot.events.KeyboardArgs} */ (opt_args);
var doc = goog.dom.getOwnerDocument(target);
var event;

Expand Down Expand Up @@ -467,7 +467,7 @@ bot.events.TouchEventFactory_.prototype.create = function(target, opt_args) {
'Browser does not support firing touch events.');
}

var args = (/** @type {!bot.events.TouchArgs} */ opt_args);
var args = /** @type {!bot.events.TouchArgs} */ (opt_args);
var doc = goog.dom.getOwnerDocument(target);
var view = goog.dom.getWindow(doc);

Expand Down Expand Up @@ -576,7 +576,7 @@ bot.events.MSGestureEventFactory_.prototype.create = function(target,
'Browser does not support MSGesture events.');
}

var args = (/** @type {!bot.events.MSGestureArgs} */ opt_args);
var args = /** @type {!bot.events.MSGestureArgs} */ (opt_args);
var doc = goog.dom.getOwnerDocument(target);
var view = goog.dom.getWindow(doc);
var event = doc.createEvent('MSGestureEvent');
Expand Down Expand Up @@ -623,7 +623,7 @@ bot.events.MSPointerEventFactory_.prototype.create = function(target,
'Browser does not support MSPointer events.');
}

var args = (/** @type {!bot.events.MSPointerArgs} */ opt_args);
var args = /** @type {!bot.events.MSPointerArgs} */ (opt_args);
var doc = goog.dom.getOwnerDocument(target);
var view = goog.dom.getWindow(doc);
var event = doc.createEvent('MSPointerEvent');
Expand Down
26 changes: 13 additions & 13 deletions javascript/atoms/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,42 +87,42 @@ bot.inject.wrapValue = function(value) {
return value.toString();

case 'array':
return goog.array.map((/**@type {goog.array.ArrayLike}*/value),
return goog.array.map(/**@type {goog.array.ArrayLike}*/(value),
bot.inject.wrapValue);

case 'object':
// Since {*} expands to {Object|boolean|number|string|undefined}, the
// JSCompiler complains that it is too broad a type for the remainder of
// this block where {!Object} is expected. Downcast to prevent generating
// a ton of compiler warnings.
value = (/**@type {!Object}*/value);
var obj = /**@type {!Object}*/ (value);

// Sniff out DOM elements. We're using duck-typing instead of an
// instanceof check since the instanceof might not always work
// (e.g. if the value originated from another Firefox component)
if (goog.object.containsKey(value, 'nodeType') &&
(value['nodeType'] == goog.dom.NodeType.ELEMENT ||
value['nodeType'] == goog.dom.NodeType.DOCUMENT)) {
if (goog.object.containsKey(obj, 'nodeType') &&
(obj['nodeType'] == goog.dom.NodeType.ELEMENT ||
obj['nodeType'] == goog.dom.NodeType.DOCUMENT)) {
var ret = {};
ret[bot.inject.ELEMENT_KEY] =
bot.inject.cache.addElement((/**@type {!Element}*/value));
bot.inject.cache.addElement(/**@type {!Element}*/(obj));
return ret;
}

// Check if this is a Window
if (goog.object.containsKey(value, 'document')) {
if (goog.object.containsKey(obj, 'document')) {
var ret = {};
ret[bot.inject.WINDOW_KEY] =
bot.inject.cache.addElement((/**@type{!Window}*/value));
bot.inject.cache.addElement(/**@type{!Window}*/(obj));
return ret;
}

if (goog.isArrayLike(value)) {
return goog.array.map((/**@type {goog.array.ArrayLike}*/value),
if (goog.isArrayLike(obj)) {
return goog.array.map(/**@type {goog.array.ArrayLike}*/(obj),
bot.inject.wrapValue);
}

var filtered = goog.object.filter(value, function(val, key) {
var filtered = goog.object.filter(obj, function(val, key) {
return goog.isNumber(key) || goog.isString(key);
});
return goog.object.map(filtered, bot.inject.wrapValue);
Expand All @@ -143,7 +143,7 @@ bot.inject.wrapValue = function(value) {
*/
bot.inject.unwrapValue_ = function(value, opt_doc) {
if (goog.isArray(value)) {
return goog.array.map((/**@type {goog.array.ArrayLike}*/value),
return goog.array.map(/**@type {goog.array.ArrayLike}*/(value),
function(v) { return bot.inject.unwrapValue_(v, opt_doc); });
} else if (goog.isObject(value)) {
if (typeof value == 'function') {
Expand Down Expand Up @@ -232,7 +232,7 @@ bot.inject.executeScript = function(fn, args, opt_stringify, opt_window) {
var ret;
try {
fn = bot.inject.recompileFunction_(fn, win);
var unwrappedArgs = (/**@type {Object}*/bot.inject.unwrapValue_(args,
var unwrappedArgs = /**@type {Object}*/ (bot.inject.unwrapValue_(args,
win.document));
ret = bot.inject.wrapResponse(fn.apply(null, unwrappedArgs));
} catch (ex) {
Expand Down
2 changes: 1 addition & 1 deletion javascript/atoms/locators/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bot.locators.css.single = function(target, root) {
var element = root.querySelector(target);

return element && element.nodeType == goog.dom.NodeType.ELEMENT ?
(/**@type {Element}*/element) : null;
/**@type {Element}*/(element) : null;
};


Expand Down
2 changes: 1 addition & 1 deletion javascript/atoms/locators/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ bot.locators.id.single = function(target, root) {
return bot.dom.getAttribute(element, 'id') == target &&
goog.dom.contains(root, element);
});
return (/**@type{Element}*/element);
return /**@type{Element}*/(element);
};


Expand Down
2 changes: 1 addition & 1 deletion javascript/atoms/locators/link_text.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bot.locators.linkText.single_ = function(target, root, opt_isPartial) {
var text = bot.dom.getVisibleText(element);
return (opt_isPartial && text.indexOf(target) != -1) || text == target;
});
return (/**@type{Element}*/element);
return /**@type{Element}*/(element);
};


Expand Down
2 changes: 1 addition & 1 deletion javascript/atoms/locators/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bot.locators.name.single = function(target, root) {
var element = goog.array.find(allElements, function(element) {
return bot.dom.getAttribute(element, 'name') == target;
});
return (/**@type{Element}*/element);
return /**@type{Element}*/(element);
};


Expand Down
6 changes: 3 additions & 3 deletions javascript/atoms/locators/xpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ bot.locators.xpath.evaluate_ = function(node, path, resultType) {
var resolver = doc.createNSResolver ?
doc.createNSResolver(doc.documentElement) :
bot.locators.xpath.DEFAULT_RESOLVER_;
if (goog.userAgent.IE && !goog.userAgent.isVersion(7)) {
if (goog.userAgent.IE && !goog.userAgent.isVersionOrHigher(7)) {
// IE6, and only IE6, has an issue where calling a custom function
// directly attached to the document object does not correctly propagate
// thrown errors. So in that case *only* we will use apply().
Expand Down Expand Up @@ -168,7 +168,7 @@ bot.locators.xpath.single = function(target, root) {
if (!goog.isNull(node)) {
bot.locators.xpath.checkElement_(node, target);
}
return (/** @type {Element} */node);
return /** @type {Element} */(node);
};


Expand Down Expand Up @@ -210,5 +210,5 @@ bot.locators.xpath.many = function(target, root) {
goog.array.forEach(nodes, function(n) {
bot.locators.xpath.checkElement_(n, target);
});
return (/** @type {!goog.array.ArrayLike} */nodes);
return /** @type {!goog.array.ArrayLike} */(nodes);
};
2 changes: 1 addition & 1 deletion javascript/atoms/mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ bot.Mouse = function(opt_state, opt_modifiersState, opt_eventEmitter) {

try {
if (bot.dom.isElement(opt_state.element)) {
this.setElement((/** @type {!Element} */opt_state.element));
this.setElement(/** @type {!Element} */ (opt_state.element));
}
} catch (ignored) {
this.buttonPressed_ = null;
Expand Down
6 changes: 3 additions & 3 deletions javascript/atoms/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bot.response.isResponseObject = function(value) {
*/
bot.response.createResponse = function(value) {
if (bot.response.isResponseObject(value)) {
return (/** @type {!bot.response.ResponseObject} */value);
return /** @type {!bot.response.ResponseObject} */ (value);
}
return {
'status': bot.ErrorCode.SUCCESS,
Expand All @@ -65,13 +65,13 @@ bot.response.createResponse = function(value) {
*/
bot.response.createErrorResponse = function(error) {
if (bot.response.isResponseObject(error)) {
return (/** @type {!bot.response.ResponseObject} */error);
return /** @type {!bot.response.ResponseObject} */ (error);
}

var statusCode = error && goog.isNumber(error.code) ? error.code :
bot.ErrorCode.UNKNOWN_ERROR;
return {
'status': (/** @type {bot.ErrorCode} */statusCode),
'status': /** @type {bot.ErrorCode} */ (statusCode),
'value': {
'message': (error && error.message || error) + ''
}
Expand Down
2 changes: 1 addition & 1 deletion javascript/atoms/userAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ bot.userAgent.isEngineVersion = function(version) {
return goog.string.compareVersions(
/** @type {number} */ (goog.userAgent.DOCUMENT_MODE), version) >= 0;
} else {
return goog.userAgent.isVersion(version);
return goog.userAgent.isVersionOrHigher(version);
}
};

Expand Down
2 changes: 1 addition & 1 deletion javascript/firefox-driver/js/firefoxDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ FirefoxDriver = function(server, enableNativeEvents, win) {
return (opt_isPartial && text.indexOf(target) != -1) ||
text == target;
});
return (/**@type{Element}*/element);
return /**@type{Element}*/ (element);
},
many: function(target, root, opt_isPartial) {
var elements = cssSelectorFunction.many('a', root);
Expand Down
1 change: 1 addition & 0 deletions javascript/remote/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ goog.addDependency(
// dependency graph.
[
'goog.debug.ErrorHandler',
'goog.events.EventWrapper',
'goog.testing.JsUnitException'
],
// And symbols we require, which is always empty here.
Expand Down
4 changes: 2 additions & 2 deletions javascript/remote/ui/banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ goog.inherits(remote.ui.Banner, goog.ui.Component);

/**
* Key for the {@link goog.events.EventType.RESIZE} event listener.
* @private {?number}
* @private {goog.events.Key}
*/
remote.ui.Banner.prototype.onResizeKey_ = null;

Expand Down Expand Up @@ -70,7 +70,7 @@ remote.ui.Banner.prototype.createDom = function() {

/** @param {boolean} visible Whether this component should be visible. */
remote.ui.Banner.prototype.setVisible = function(visible) {
goog.style.showElement(this.getElement(), visible);
goog.style.setElementShown(this.getElement(), visible);
this.reposition_();
};

Expand Down
2 changes: 1 addition & 1 deletion javascript/remote/ui/sessioncontainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ remote.ui.SessionContainer.prototype.onCreateSession_ = function() {
* @private
*/
remote.ui.SessionContainer.prototype.onSessionSelect_ = function() {
var tab = (/** @type {!remote.ui.SessionContainer.SessionTab_} */
var tab = /** @type {!remote.ui.SessionContainer.SessionTab_} */ (
this.tabBar_.getSelectedTab());
this.view_.update(tab ? tab.session_ : null);
};
Expand Down
8 changes: 4 additions & 4 deletions javascript/remote/ui/sessionview.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ remote.ui.SessionView.prototype.createDom = function() {
capabilities = dom.createDom(goog.dom.TagName.SPAN,
'session-capabilities', 'Capabilities'));
this.controlBlock_.addElement(
(/** @type {!Element} */this.screenshotButton_.getElement()));
/** @type {!Element} */ (this.screenshotButton_.getElement()));
this.controlBlock_.addElement(
(/** @type {!Element} */this.deleteSessionButton_.getElement()));
/** @type {!Element} */ (this.deleteSessionButton_.getElement()));

this.viewElement_ = dom.createDom(goog.dom.TagName.DIV, 'goog-tab-content',
this.controlBlock_.getElement(), this.todoBlock_);
Expand Down Expand Up @@ -204,8 +204,8 @@ remote.ui.SessionView.prototype.addControlElement = function(element) {
*/
remote.ui.SessionView.prototype.update = function(session) {
var hasSession = !!session;
goog.style.showElement(this.emptyViewElement_, !hasSession);
goog.style.showElement(this.viewElement_, hasSession);
goog.style.setElementShown(this.emptyViewElement_, !hasSession);
goog.style.setElementShown(this.viewElement_, hasSession);

if (session) {
goog.dom.setTextContent(this.sessionIdSpan_, session.getId());
Expand Down
2 changes: 1 addition & 1 deletion javascript/safari-driver/inject/page/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ safaridriver.inject.page.script.executeScript_ = function(command) {
// TODO: clean-up bot.inject.executeScript so it doesn't pull in so many
// extra dependencies.
var fn = new Function(command.getParameter('script'));
var args = (/** @type {!Array.<*>} */command.getParameter('args'));
var args = /** @type {!Array.<*>} */ (command.getParameter('args'));
args = /** @type {!Array} */ (safaridriver.inject.Encoder.decode(args));
return fn.apply(window, args);
};
Expand Down
4 changes: 2 additions & 2 deletions javascript/safari-driver/message/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ safaridriver.message.Message.prototype.send = function(target) {
/** @type {!SafariContentBrowserTabProxy} */ (target));
}

(/** @type {!(SafariContentBrowserTabProxy|SafariWebPageProxy)} */ (
target)).dispatchMessage(this.getType(), this.data_);
/** @type {!(SafariContentBrowserTabProxy|SafariWebPageProxy)} */ (
target).dispatchMessage(this.getType(), this.data_);
}
};

Expand Down
2 changes: 1 addition & 1 deletion javascript/selenium-atoms/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ core.events.fireAt = function(locator, eventName, opt_coordString) {
metaKey: false,
relatedTarget: null
};
bot.events.fire(element, type, (/** @type {!bot.events.MouseArgs} */args));
bot.events.fire(element, type, /** @type {!bot.events.MouseArgs} */ (args));
};


Expand Down
4 changes: 2 additions & 2 deletions javascript/selenium-atoms/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ core.inject.ELEMENT_ID_PREFIX = 'stored=';
*/
core.inject.removeElementIdPrefix_ = function(value) {
if (goog.isArray(value)) {
return goog.array.map((/**@type {goog.array.ArrayLike}*/value),
return goog.array.map(/**@type {goog.array.ArrayLike}*/ (value),
core.inject.removeElementIdPrefix_ );
} else if (value && goog.isObject(value) && !goog.isFunction(value)) {
if (goog.object.containsKey(value, bot.inject.ELEMENT_KEY)) {
Expand All @@ -194,7 +194,7 @@ core.inject.removeElementIdPrefix_ = function(value) {
*/
core.inject.addElementIdPrefix_ = function(value) {
if (goog.isArray(value)) {
return goog.array.map((/**@type {goog.array.ArrayLike}*/value),
return goog.array.map(/**@type {goog.array.ArrayLike}*/ (value),
core.inject.addElementIdPrefix_ );
} else if (value && goog.isObject(value) && !goog.isFunction(value)) {
if (goog.object.containsKey(value, bot.inject.ELEMENT_KEY)) {
Expand Down
Loading

0 comments on commit 1d77ff7

Please sign in to comment.