Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhantomJS JavaScript errors from gstatic, but not in browser

I recently ran our website through our PhantomJS testing suite and ran into JavaScript errors that I can't reproduce in my browser manually. These errors are found in the Google maps api and the text returned by Capybara is as follows:

TypeError: Unable to delete property.
TypeError: Unable to delete property.
   at :215
   at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:20 in cf
   at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:20 in cf
   at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:19
   at :214
   at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:20 in cf
   at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:20 in cf
   at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:21
   at :176
   at :31
   at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:26 in Yf
   at :178

Is this a known bug with Capybara, PhantomJS, or the Google maps API? Could the problem be caused by the user agent string in PhantomJS?

like image 762
user3934630 Avatar asked Dec 11 '14 17:12

user3934630


2 Answers

I'm using Cucumber / Poltergeist and I hacked around this in by creating the following extension:

/features/support/env.rb

Capybara::Poltergeist::Driver.new(app, 
  :extensions => ["features/support/ignore_gmaps_errors.js"]
)

/features/support/ignore_gmaps_errors.js

window.onerror = function(message) {
  if (message == 'TypeError: Unable to delete property.') {
    console.log('Ignoring gmaps error');
    return false;
  } else {
    return true;
  }
};
like image 193
robd Avatar answered Oct 19 '22 21:10

robd


Google maps API experimental version was updated this morning (12/11) causing this breakage. By default when you include:

<script src="//maps.googleapis.com/maps/api/js?libraries=places"></script>

it uses the latest experimental version. Locking yourself to the latest release version:

<script src="//maps.googleapis.com/maps/api/js?v=3&libraries=places"></script>

should fix this.

like image 44
visnup Avatar answered Oct 19 '22 23:10

visnup