rubyjs / therubyracer

Embed the V8 Javascript Interpreter into Ruby
1.66k stars 191 forks source link

How to add window.location support? #321

Closed andrewhavens closed 9 years ago

andrewhavens commented 9 years ago

I have some JavaScript code that references window.location.host to get the current host. This is valid JavaScript when running in a browser, but my RSpec tests are failing because therubyracer and/or V8 does not assume that browser/DOM features are necessary.

Here is a sample of the code I am working with:

V8::Context.new.eval 'console.log(window.location.host)'

How can I add support for the window.location object?

cowboyd commented 9 years ago

you need to embed an object named window into your context. Please see the README for details.