Skip to content

Commit

Permalink
add notes to troubleshooting section relating to PhantomJS crashes un…
Browse files Browse the repository at this point in the history
…der OS X when using TTF fonts with @font-face declarations (see teampoltergeist#44).
  • Loading branch information
mjtko committed Nov 3, 2012
1 parent 34f7a2f commit 1c79d02
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Expand Up @@ -261,6 +261,37 @@ documentation on asynchronous
Javascript](https://github.com/jnicklas/capybara#asynchronous-javascript-ajax-and-friends)
which explains the tools that Capybara provides for dealing with this.

### PhantomJS crashes under OS X

Some users have reported problems that manifest themselves as PhantomJS crashes when using Poltergeist under OS X (see [issue #44](https://github.com/jonleighton/poltergeist/issues/44)). It has been observed that many of these crashes are caused by CSS `@font-face` declarations that cause PhantomJS to request TTF files.

To alleviate this, configure your application to deny access to TTF files to PhantomJS under OS X. Under Rails, you might try using the `rack-contrib` gem, by adding to your `:test` group in your `Gemfile`:

``` ruby
group :test do
# used for Rack::SimpleEndpoint in test environment for
# PhantomJS crash workaround
gem 'rack-contrib'
end
```

And an initializer such as:

``` ruby
if Rails.env.test?
require 'rack/contrib/simple_endpoint'
Rails.application.config.middleware.insert_after Rack::Runtime, Rack::SimpleEndpoint, /\.ttf$/ do |req, res|
ua = req.env['HTTP_USER_AGENT']
if ua =~ /Intel Mac OS X.*PhantomJS/
res.status = 403
"Denying #{req.fullpath} to #{ua}"
else
:pass
end
end
end
```

### General troubleshooting hints ###

* Configure Poltergeist with `:debug` turned on so you can see its
Expand Down

0 comments on commit 1c79d02

Please sign in to comment.