Revert "(#5930) - cache selenium and phantomjs in Travis"

This reverts commit 43ca134851ebf55010e106eb9ba73eb35b2a336b.
diff --git a/.travis.yml b/.travis.yml
index ec32029..217510d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,23 +23,12 @@
   - "if [ -z \"$COUCH_HOST\" ]; then export COUCH_HOST=http://127.0.0.1:3000; fi"
 
 before_script:
-  # Our test-browser.js script uses FIREFOX_BIN to find the Firefox binary
-  # See https://github.com/travis-ci/travis-ci/issues/4649
   - echo "using firefox $(firefox --version)"
   - export FIREFOX_BIN=$(which firefox)
-  # The next two lines are required for Firefox to run on Travis
   - "export DISPLAY=:99.0"
   - "sh -e /etc/init.d/xvfb start"
-  # Install PhantomJS and cache it
-  # See https://github.com/Medium/phantomjs#continuous-integration
-  - "export PHANTOMJS_VERSION=2.1.1"
-  - "export PATH=$PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64/bin:$PATH"
-  - "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then rm -rf $PWD/travis_phantomjs; mkdir -p $PWD/travis_phantomjs; fi"
-  - "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then wget https://github.com/Medium/phantomjs/releases/download/v$PHANTOMJS_VERSION/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -O $PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2; fi"
-  - "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then tar -xvf $PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi"
-  - "phantomjs --version"
-  # Fail early so we dont run hours of saucelabs if we know there
-  # is a lint failure
+    # Fail early so we dont run hours of saucelabs if we know there
+    # is a lint failure
   - npm run eslint
 
 script: npm run $COMMAND
@@ -138,7 +127,3 @@
 cache:
   directories:
   - $HOME/.npm
-  # See https://github.com/gr2m/selsa
-  - node_modules/selenium-standalone/.selenium
-  # See https://github.com/Medium/phantomjs#continuous-integration
-  - travis_phantomjs
diff --git a/TESTING.md b/TESTING.md
index ca1589f..4eb6b7e 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -25,11 +25,6 @@
 
 and open [http://127.0.0.1:8000/tests/integration/index.html](http://127.0.0.1:8000/tests/integration/index.html) in your browser of choice. The performance tests are located @ [http://localhost:8000/tests/performance/index.html](http://localhost:8000/tests/performance/index.html).
 
-You can also test against phantomjs, but you'll need to install phantomjs yourself:
-
-    $ npm install phantomjs-prebuilt
-    $ CLIENT=selenium:phantomjs npm test
-
 ### Unit tests
 
     $ npm run build-as-modular-es5
diff --git a/bin/run-test.sh b/bin/run-test.sh
index cb19547..45d4d3a 100755
--- a/bin/run-test.sh
+++ b/bin/run-test.sh
@@ -50,6 +50,10 @@
   source ./bin/run-couchdb-on-travis.sh
 fi
 
+if [ "$CLIENT" == "selenium:phantomjs" ]; then
+  npm install phantomjs@2.1.2 # do this on-demand to avoid slow installs
+fi
+
 printf 'Waiting for host to start .'
 WAITING=0
 until $(curl --output /dev/null --silent --head --fail --max-time 2 $COUCH_HOST); do