summaryrefslogtreecommitdiffstats
path: root/remoting/webapp
diff options
context:
space:
mode:
authorlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 23:50:45 +0000
committerlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 23:50:45 +0000
commit05b76a01a1a3ad57ed55a8b5aff173c6ace262fa (patch)
tree2ecdbe887970ee923aaeacd0b7543b06924e5a63 /remoting/webapp
parentde860e038998941c597c729d7812497a3b841574 (diff)
downloadchromium_src-05b76a01a1a3ad57ed55a8b5aff173c6ace262fa.zip
chromium_src-05b76a01a1a3ad57ed55a8b5aff173c6ace262fa.tar.gz
chromium_src-05b76a01a1a3ad57ed55a8b5aff173c6ace262fa.tar.bz2
Remoting webapp: Use hasOwnProperty instead of if..in.. where needed
Cases such as "if 'someLiteralString' in myObj" are OK and not changed by this CL. But when the attribute being tested comes from external input, this CL fixes the test to use hasOwnProperty(), which is appropriate for simple enumerations and similar types such as window.localStorage. BUG=246380 R=jamiewalch@chromium.org Review URL: https://codereview.chromium.org/17322005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207117 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp')
-rw-r--r--remoting/webapp/client_plugin_async.js5
-rw-r--r--remoting/webapp/host_settings.js6
-rw-r--r--remoting/webapp/storage.js6
3 files changed, 9 insertions, 8 deletions
diff --git a/remoting/webapp/client_plugin_async.js b/remoting/webapp/client_plugin_async.js
index a4ac9eb..f457d15 100644
--- a/remoting/webapp/client_plugin_async.js
+++ b/remoting/webapp/client_plugin_async.js
@@ -203,7 +203,7 @@ remoting.ClientPluginAsync.prototype.handleMessage_ = function(messageStr) {
this.onDebugMessageHandler(message.data['message']);
} else if (message.method == 'onConnectionStatus') {
if (typeof message.data['state'] != 'string' ||
- !(message.data['state'] in remoting.ClientSession.State) ||
+ !remoting.ClientSession.State.hasOwnProperty(message.data['state']) ||
typeof message.data['error'] != 'string') {
console.error('Received invalid onConnectionState message: ' +
messageStr);
@@ -213,7 +213,8 @@ remoting.ClientPluginAsync.prototype.handleMessage_ = function(messageStr) {
/** @type {remoting.ClientSession.State} */
var state = remoting.ClientSession.State[message.data['state']];
var error;
- if (message.data['error'] in remoting.ClientSession.ConnectionError) {
+ if (remoting.ClientSession.ConnectionError.hasOwnProperty(
+ message.data['error'])) {
error = /** @type {remoting.ClientSession.ConnectionError} */
remoting.ClientSession.ConnectionError[message.data['error']];
} else {
diff --git a/remoting/webapp/host_settings.js b/remoting/webapp/host_settings.js
index 57e7731..65b5fdd 100644
--- a/remoting/webapp/host_settings.js
+++ b/remoting/webapp/host_settings.js
@@ -85,16 +85,16 @@ remoting.HostSettings.loadInternal_ = function(hostId, callback) {
if (typeof(result) != 'object') {
console.error("Error loading host settings: Not an object");
result = {};
- } else if (hostId in result &&
+ } else if (/** @type {Object} */ (result).hasOwnProperty(hostId) &&
typeof(result[hostId]) == 'object') {
- callback(result[hostId], /** @type {Object} */(result));
+ callback(result[hostId], result);
return;
}
} catch (err) {
var typedErr = /** @type {*} */ (err);
console.error('Error loading host settings:', typedErr);
}
- callback({}, /** @type {Object} */(result));
+ callback({}, /** @type {Object} */ (result));
};
remoting.storage.local.get(remoting.HostSettings.KEY_, onDone);
};
diff --git a/remoting/webapp/storage.js b/remoting/webapp/storage.js
index 63dd941..72c3ff6 100644
--- a/remoting/webapp/storage.js
+++ b/remoting/webapp/storage.js
@@ -59,7 +59,7 @@ remoting.MockStorage.prototype.get = function(items, callback) {
} else if (typeof(items) == 'string') {
// If the input is a string, return one or zero items, depending on
// whether or not the value is stored in localStorage.
- if (items in window.localStorage) {
+ if (window.localStorage.hasOwnProperty(items)) {
result[items] = window.localStorage.getItem(items);
}
@@ -69,7 +69,7 @@ remoting.MockStorage.prototype.get = function(items, callback) {
for (var index in items) {
/** @type {string} */
var item = items[index];
- if (item in window.localStorage) {
+ if (window.localStorage.hasOwnProperty(item)) {
result[item] = window.localStorage.getItem(item);
}
}
@@ -78,7 +78,7 @@ remoting.MockStorage.prototype.get = function(items, callback) {
// If the input is a dictionary, return the localStorage value for
// items that are stored, and the dictionary value otherwise.
for (var item in items) {
- if (item in window.localStorage) {
+ if (window.localStorage.hasOwnProperty(item)) {
result[item] = window.localStorage.getItem(item);
} else {
result[item] = items[item];