3

Cross-posted from https://github.com/tmpvar/jsdom/issues#issue/127

I will post a minimal test case in the next day or so - but I wanted to see if anyone else had the same problem - or if (more likely) if I am doing something stupid.

I'm using NodeJS v2.6 on Ubuntu 10.04 AMD64 and jsdom@0.1.23.

var file = readFileSync("./www/index.html", "utf8"); var window = jsdom.jsdom(file).createWindow();

All inline scripts run, but complain about missing variables which should be supplied by the external scripts.

I have tried setting a url in the options and I have tried using full (http://...) urls in the src attributes,

I have tried jQuerify (using default jQuery path) and that works fine, though it only brings in jQuery and I'm still missing all of the other scripts.

Any pointers before I post failing code/urls?

Thanks,

Chris.

NickFitz
  • 34,537
  • 8
  • 43
  • 40
fadedbee
  • 42,671
  • 44
  • 178
  • 308

2 Answers2

1

As of jsdom 0.2.0 this has become much easier. Please see the "Easy mode" section in the readme. jsdom.env() will not execute scripts found in the page by default making what you are trying to do, much easier.

tmpvar
  • 1,331
  • 1
  • 8
  • 12
  • Thanks, I'll try 0.2.0 in a few days. – fadedbee Feb 27 '11 at 06:57
  • 4
    But according to the readme, jsdom.env() doesn't process external resources. "jsdom.env will not process external resources (scripts, images, etc). If you want to process the javascript use one of the methods below (jsdom.jsdom or jsdom.jQueryify)" – AdamB Mar 19 '11 at 22:55
  • It is also confusing that the defaults in the Default Features section states that loading external scripts is enabled by default. – Rob Evans May 09 '13 at 17:04
  • Ahh that is only for non .env() setups. – Rob Evans May 09 '13 at 17:18
0

I removed all in-line Javascript from the page - luckily the page is under my control.

fadedbee
  • 42,671
  • 44
  • 178
  • 308