0

After we updated our client Angular version from 1.2.8 to 1.3.5 (or tried other 1.3.x versions for that matter), one of the SUT web pages, begun to fail in rendering (the webpage not rendered at all), with the error:

[ERROR - 2015-03-22T08:28:04.332Z] Session [5b8fa230-d06d-11e4-b704-1530b0109512] - page.onError - msg: Error: Requested keys of a value that is not an object. at keys ([native code]) at extend (http://localhost:9920/services/our-product/bower_components/angular/angular.js:411:29) at setSettings (http://localhost:9920/services/our-product/scripts/scripts.min.js:2:51263) at a (http://localhost:9920/services/our-product/scripts/scripts.min.js:2:25657)

In human language: the method Object.keys() failed, and it's called from angular.extend() method.

We using PhantomJsDriver 1.2.0 version, we begun with PhantomJs 1.9.7 and tried to solve it with updating to 2.0 version without success.

Johnny
  • 14,397
  • 15
  • 77
  • 118
  • This may be an incompatibility with PhantomJS, because the engine of version 1.x is more than 4 years old. Try updating to PhantomJS 2 (you will need to compile it yourself on linux). – Artjom B. Mar 23 '15 at 09:46
  • @ArtjomB. tried to do it, no success. – Johnny Mar 23 '15 at 09:50

1 Answers1

1

Found the cause for it.

Object.keys() return array of object properties, and it must receive object as an argument, such as: Object.keys(obj). Object.keys() wasn't used in previous versions of Angular.extend, and introduced in one of the 1.3.x versions.

What cause the problem? Our server side, in one point, sends empty object as a string, instead of the proper empty object definition:

"personData": "{}",

instead of:

"personData": {},

Therefore, Object.keys() failed to parse it, it haven't received proper object. Thus the failure in rendering. And because the Object.keys() introduced only in Angular 1.3.x, previously it haven't caused any issues.

The funny thing is that Chrome, for example, succeed in "understanding" that it's an empty object, but, PhantomJsDriver, isn't. And it leads to another interesting point - this issue was reproduced also in Safari, and the reason to it is the same JS rendering engine PhantomJs and Safari sharing - WebKit

Johnny
  • 14,397
  • 15
  • 77
  • 118