ForbesLindesay / taxi-rank

A JSDom based Selenium Webdriver API
MIT License
346 stars 12 forks source link

Q: Adding polyfills? #9

Closed joscha closed 7 years ago

joscha commented 7 years ago

Is there an easy way to tell jsdom to load a few additional scripts, e.g. https://github.com/chrisdickinson/raf for example to polyfill some thing just when running cabbie against taxi-rank?

ForbesLindesay commented 7 years ago

I don't think there's an "easy" way. You can run arbitrary JavaScript against the currently loaded page, for example if you're using cabbie:

driver.browser.activeWindow.execute(function () {
  // this function is executed in the context of the web page
  // this means you can use the usual `document.createElement('script')` approach to load a script.
});

You would have to do this for every page load though. The best bet is probably to contribute directly to jsdom or zombie (preferably jsdom).