> But isn't PhantomJS supposed to work as the browser would? While disabling
> javascript on Chrome, for example, there is still access to the console
> through developer tools and consequently, the `window` object.
> I believe it should mimic the same behaviour, where disabling javascript
> means Phantomjs should only disable `script` tags for running within the
> page, but not prevent the developer to evaluate new snippets at will through
> the console, where, on PhantomJS, `evaluate` is the only way achieve such
> thing. The access to the `window` object shouldn't be restricted to the
> `javascriptEnabled` option set to false. This leaves the developer with no
> choice as far as I can understand.
>
> As mentioned: It is still possible to strip out all the `script` tags and
> then set `page.content` to the desired markup, although the generated
> document would lose many other characteristics which the same would inherit
> if loaded from it's original URL such: `document.location`, any `<a
> href='/test.html'><a/>` links pointing to their root domain would also break
> and many others intricacies I can think of.
>
> So I guess the `evaluate` prevention while using `javascriptEnabled=false`
> brings no real benefit to the developer who is interested in dissect and
> debug the page which I believe, is the main purpose of phantomJS.
>
> I really hope you can re-consider that.
Your theory is good on paper. But just like every other aspects of
PhantomJS, when you face something like this, usually the reason is
either:
* philosophical design choice, or
* technical limitation
In this case, it is the latter. If someone steps up and volunteers to
do the necessary research to overcome the technical problems so that
the beautiful behavior can be achieved, then the discussion can be
more fruitful. Otherwise, it ain't never gonna happen.
Any "why PhantomJS can't do this" situation should be (at first)
treated the same way as "why my car can't fly" question. A car
designer loves to have it, but the technology might not be there yet.