Skip to content

Commit

Permalink
Check forhasOwnProperty in for-in loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Apr 14, 2016
1 parent 6954e99 commit 79088c5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions notebook/tests/base/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,19 @@ casper.notebook_test(function () {
});
that.evaluate(function (obj) {
for(var k in obj){
IPython.keyboard_manager.command_shortcuts.add_shortcut(k, function(){console.log(obj[k]);});
if ({}.hasOwnProperty.call(obj, k)) {
IPython.keyboard_manager.command_shortcuts.add_shortcut(k, function(){console.log(obj[k]);});
}
}
}, shortcuts_test);

var longer_first = false;
var longer_last = false;
for(var m in that.msgs){
longer_first = longer_first||(that.msgs[m].match(/you are overriting/)!= null);
longer_last = longer_last ||(that.msgs[m].match(/will be shadowed/) != null);
if ({}.hasOwnProperty.call(that.msgs, m)) {
longer_first = longer_first||(that.msgs[m].match(/you are overriting/)!= null);
longer_last = longer_last ||(that.msgs[m].match(/will be shadowed/) != null);
}
}
this.test.assert(longer_first, 'no warning if registering shorter shortut');
this.test.assert(longer_last , 'no warning if registering longer shortut');
Expand Down

0 comments on commit 79088c5

Please sign in to comment.