Drop support for phantomjs entirely (#1472)

Running tests on `phantomjs` has been broken since the full null safety
migration. We have not been running tests for phanomjs on CI. We have
had a warning about the removal of this support for a while, but the
message mentions version 2.0.0 of `test`, which we won't actually wait
for. Since this isn't working and no one has complained about the
warning or the breaking, and since `phantomjs` itself is deprecated and
chrome headless works better, we will drop support entirely.
diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml
index c821d17..dace49d 100644
--- a/.github/workflows/dart.yml
+++ b/.github/workflows/dart.yml
@@ -171,7 +171,7 @@
       - job_001
       - job_002
   job_005:
-    name: "unit_test; Dart dev; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 0`"
+    name: "unit_test; Dart dev; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 0`"
     runs-on: ubuntu-latest
     steps:
       - name: Cache Pub hosted dependencies
@@ -194,15 +194,15 @@
         if: "always() && steps.checkout.conclusion == 'success'"
         working-directory: pkgs/test
         run: pub upgrade --no-precompile
-      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 0"
+      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 0"
         if: "always() && steps.pkgs_test_pub_upgrade.conclusion == 'success'"
         working-directory: pkgs/test
-        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 0"
+        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 0"
     needs:
       - job_001
       - job_002
   job_006:
-    name: "unit_test; Dart stable; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 0`"
+    name: "unit_test; Dart stable; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 0`"
     runs-on: ubuntu-latest
     steps:
       - name: Cache Pub hosted dependencies
@@ -225,15 +225,15 @@
         if: "always() && steps.checkout.conclusion == 'success'"
         working-directory: pkgs/test
         run: pub upgrade --no-precompile
-      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 0"
+      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 0"
         if: "always() && steps.pkgs_test_pub_upgrade.conclusion == 'success'"
         working-directory: pkgs/test
-        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 0"
+        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 0"
     needs:
       - job_001
       - job_002
   job_007:
-    name: "unit_test; Dart dev; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 1`"
+    name: "unit_test; Dart dev; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 1`"
     runs-on: ubuntu-latest
     steps:
       - name: Cache Pub hosted dependencies
@@ -256,15 +256,15 @@
         if: "always() && steps.checkout.conclusion == 'success'"
         working-directory: pkgs/test
         run: pub upgrade --no-precompile
-      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 1"
+      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 1"
         if: "always() && steps.pkgs_test_pub_upgrade.conclusion == 'success'"
         working-directory: pkgs/test
-        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 1"
+        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 1"
     needs:
       - job_001
       - job_002
   job_008:
-    name: "unit_test; Dart stable; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 1`"
+    name: "unit_test; Dart stable; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 1`"
     runs-on: ubuntu-latest
     steps:
       - name: Cache Pub hosted dependencies
@@ -287,15 +287,15 @@
         if: "always() && steps.checkout.conclusion == 'success'"
         working-directory: pkgs/test
         run: pub upgrade --no-precompile
-      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 1"
+      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 1"
         if: "always() && steps.pkgs_test_pub_upgrade.conclusion == 'success'"
         working-directory: pkgs/test
-        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 1"
+        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 1"
     needs:
       - job_001
       - job_002
   job_009:
-    name: "unit_test; Dart dev; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 2`"
+    name: "unit_test; Dart dev; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 2`"
     runs-on: ubuntu-latest
     steps:
       - name: Cache Pub hosted dependencies
@@ -318,15 +318,15 @@
         if: "always() && steps.checkout.conclusion == 'success'"
         working-directory: pkgs/test
         run: pub upgrade --no-precompile
-      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 2"
+      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 2"
         if: "always() && steps.pkgs_test_pub_upgrade.conclusion == 'success'"
         working-directory: pkgs/test
-        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 2"
+        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 2"
     needs:
       - job_001
       - job_002
   job_010:
-    name: "unit_test; Dart stable; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 2`"
+    name: "unit_test; Dart stable; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 2`"
     runs-on: ubuntu-latest
     steps:
       - name: Cache Pub hosted dependencies
@@ -349,15 +349,15 @@
         if: "always() && steps.checkout.conclusion == 'success'"
         working-directory: pkgs/test
         run: pub upgrade --no-precompile
-      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 2"
+      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 2"
         if: "always() && steps.pkgs_test_pub_upgrade.conclusion == 'success'"
         working-directory: pkgs/test
-        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 2"
+        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 2"
     needs:
       - job_001
       - job_002
   job_011:
-    name: "unit_test; Dart dev; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 3`"
+    name: "unit_test; Dart dev; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 3`"
     runs-on: ubuntu-latest
     steps:
       - name: Cache Pub hosted dependencies
@@ -380,15 +380,15 @@
         if: "always() && steps.checkout.conclusion == 'success'"
         working-directory: pkgs/test
         run: pub upgrade --no-precompile
-      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 3"
+      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 3"
         if: "always() && steps.pkgs_test_pub_upgrade.conclusion == 'success'"
         working-directory: pkgs/test
-        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 3"
+        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 3"
     needs:
       - job_001
       - job_002
   job_012:
-    name: "unit_test; Dart stable; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 3`"
+    name: "unit_test; Dart stable; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 3`"
     runs-on: ubuntu-latest
     steps:
       - name: Cache Pub hosted dependencies
@@ -411,15 +411,15 @@
         if: "always() && steps.checkout.conclusion == 'success'"
         working-directory: pkgs/test
         run: pub upgrade --no-precompile
-      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 3"
+      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 3"
         if: "always() && steps.pkgs_test_pub_upgrade.conclusion == 'success'"
         working-directory: pkgs/test
-        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 3"
+        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 3"
     needs:
       - job_001
       - job_002
   job_013:
-    name: "unit_test; Dart dev; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 4`"
+    name: "unit_test; Dart dev; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 4`"
     runs-on: ubuntu-latest
     steps:
       - name: Cache Pub hosted dependencies
@@ -442,15 +442,15 @@
         if: "always() && steps.checkout.conclusion == 'success'"
         working-directory: pkgs/test
         run: pub upgrade --no-precompile
-      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 4"
+      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 4"
         if: "always() && steps.pkgs_test_pub_upgrade.conclusion == 'success'"
         working-directory: pkgs/test
-        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 4"
+        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 4"
     needs:
       - job_001
       - job_002
   job_014:
-    name: "unit_test; Dart stable; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 4`"
+    name: "unit_test; Dart stable; PKG: pkgs/test; `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 4`"
     runs-on: ubuntu-latest
     steps:
       - name: Cache Pub hosted dependencies
@@ -473,10 +473,10 @@
         if: "always() && steps.checkout.conclusion == 'success'"
         working-directory: pkgs/test
         run: pub upgrade --no-precompile
-      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 4"
+      - name: "pkgs/test; xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 4"
         if: "always() && steps.pkgs_test_pub_upgrade.conclusion == 'success'"
         working-directory: pkgs/test
-        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 4"
+        run: "xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 4"
     needs:
       - job_001
       - job_002
diff --git a/pkgs/test/CHANGELOG.md b/pkgs/test/CHANGELOG.md
index e814d0e..f32d2b2 100644
--- a/pkgs/test/CHANGELOG.md
+++ b/pkgs/test/CHANGELOG.md
@@ -4,11 +4,9 @@
   loading performance.
   * You can force the old strategy with `--use-data-isolate-strategy` flag if
     you run into issues, but please also file a bug.
-
-## 1.16.9
-
 * Disable stack trace chaining by default. It can be re-enabled by explicitly
   passing the `--chain-stack-traces` flag.
+* Remove `phantomjs` support completely, it was previously broken.
 
 ## 1.16.8
 
diff --git a/pkgs/test/README.md b/pkgs/test/README.md
index f9a58aa..6629e2d 100644
--- a/pkgs/test/README.md
+++ b/pkgs/test/README.md
@@ -258,9 +258,6 @@
 
 * `chrome`: Whether the test is running on Google Chrome.
 
-* `phantomjs`: Whether the test is running on
-  [PhantomJS](http://phantomjs.org/).
-
 * `firefox`: Whether the test is running on Mozilla Firefox.
 
 * `safari`: Whether the test is running on Apple Safari.
@@ -789,8 +786,8 @@
 
 The first step when debugging is to pass the `--pause-after-load` flag to the
 test runner. This pauses the browser after each test suite has loaded, so that
-you have time to open the development tools and set breakpoints. For PhantomJS,
-and the Dart VM it will print the remote debugger URL.
+you have time to open the development tools and set breakpoints. For the Dart VM
+it will print the remote debugger URL.
 
 Once you've set breakpoints, either click the big arrow in the middle of the web
 page or press Enter in your terminal to start the tests running. When you hit a
diff --git a/pkgs/test/dart_test.yaml b/pkgs/test/dart_test.yaml
index 41845a0..75c1bbd 100644
--- a/pkgs/test/dart_test.yaml
+++ b/pkgs/test/dart_test.yaml
@@ -29,7 +29,6 @@
 
   firefox: {add_tags: [dart2js]}
   chrome: {add_tags: [dart2js]}
-  phantomjs: {add_tags: [dart2js]}
 
   safari:
     add_tags: [dart2js]
diff --git a/pkgs/test/lib/src/executable.dart b/pkgs/test/lib/src/executable.dart
index 75b2d58..daa822c 100644
--- a/pkgs/test/lib/src/executable.dart
+++ b/pkgs/test/lib/src/executable.dart
@@ -13,7 +13,6 @@
   registerPlatformPlugin([Runtime.nodeJS], () => NodePlatform());
   registerPlatformPlugin([
     Runtime.chrome,
-    Runtime.phantomJS,
     Runtime.firefox,
     Runtime.safari,
     Runtime.internetExplorer
diff --git a/pkgs/test/lib/src/runner/browser/browser_manager.dart b/pkgs/test/lib/src/runner/browser/browser_manager.dart
index 9218566..6295fff 100644
--- a/pkgs/test/lib/src/runner/browser/browser_manager.dart
+++ b/pkgs/test/lib/src/runner/browser/browser_manager.dart
@@ -24,7 +24,6 @@
 import 'chrome.dart';
 import 'firefox.dart';
 import 'internet_explorer.dart';
-import 'phantom_js.dart';
 import 'safari.dart';
 
 /// A class that manages the connection to a single running browser.
@@ -142,8 +141,6 @@
     switch (browser.root) {
       case Runtime.chrome:
         return Chrome(url, configuration, settings: settings);
-      case Runtime.phantomJS:
-        return PhantomJS(url, configuration, settings: settings);
       case Runtime.firefox:
         return Firefox(url, settings: settings);
       case Runtime.safari:
diff --git a/pkgs/test/lib/src/runner/browser/default_settings.dart b/pkgs/test/lib/src/runner/browser/default_settings.dart
index 9ff1fd4..d608804 100644
--- a/pkgs/test/lib/src/runner/browser/default_settings.dart
+++ b/pkgs/test/lib/src/runner/browser/default_settings.dart
@@ -20,10 +20,6 @@
       windowsExecutable: r'Mozilla Firefox\firefox.exe'),
   Runtime.internetExplorer:
       ExecutableSettings(windowsExecutable: r'Internet Explorer\iexplore.exe'),
-  Runtime.phantomJS: ExecutableSettings(
-      linuxExecutable: 'phantomjs',
-      macOSExecutable: 'phantomjs',
-      windowsExecutable: 'phantomjs.exe'),
   Runtime.safari: ExecutableSettings(
       macOSExecutable: '/Applications/Safari.app/Contents/MacOS/Safari')
 });
diff --git a/pkgs/test/lib/src/runner/browser/phantom_js.dart b/pkgs/test/lib/src/runner/browser/phantom_js.dart
deleted file mode 100644
index bdcbb91..0000000
--- a/pkgs/test/lib/src/runner/browser/phantom_js.dart
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (c) 2015, the Dart project authors.  Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:async';
-import 'dart:io';
-
-import 'package:path/path.dart' as p;
-import 'package:pedantic/pedantic.dart';
-import 'package:test_api/src/backend/runtime.dart'; // ignore: implementation_imports
-import 'package:test_core/src/runner/application_exception.dart'; // ignore: implementation_imports
-import 'package:test_core/src/runner/configuration.dart'; // ignore: implementation_imports
-import 'package:test_core/src/util/exit_codes.dart' // ignore: implementation_imports
-    as exit_codes;
-import 'package:test_core/src/util/io.dart'; // ignore: implementation_imports
-
-import '../executable_settings.dart';
-import 'browser.dart';
-import 'default_settings.dart';
-
-/// The PhantomJS script that opens the host page.
-final _script = '''
-var system = require('system');
-var page = require('webpage').create();
-
-// PhantomJS versions older than 2.0.0 don't support the latest WebSocket spec.
-if (phantom.version.major < 2) phantom.exit(${exit_codes.protocol});
-
-// Pipe browser messages to the process's stdout. This isn't used by default,
-// but it can be useful for debugging.
-page.onConsoleMessage = function(message) {
-  console.log(message);
-}
-
-page.open(system.args[1], function(status) {
-  if (status !== "success") phantom.exit(1);
-});
-''';
-
-/// A class for running an instance of PhantomJS.
-///
-/// Any errors starting or running the process are reported through [onExit].
-class PhantomJS extends Browser {
-  @override
-  final name = 'PhantomJS';
-
-  @override
-  final Future<Uri> remoteDebuggerUrl;
-
-  factory PhantomJS(url, Configuration configuration,
-      {ExecutableSettings? settings}) {
-    settings ??= defaultSettings[Runtime.phantomJS]!;
-    var remoteDebuggerCompleter = Completer<Uri>.sync();
-    return PhantomJS._(() async {
-      var dir = createTempDir();
-      var script = p.join(dir, 'script.js');
-      File(script).writeAsStringSync(_script);
-
-      var port = configuration.debug ? await getUnsafeUnusedPort() : null;
-
-      var args = settings!.arguments.toList();
-      if (configuration.debug) {
-        args.addAll(
-            ['--remote-debugger-port=$port', '--remote-debugger-autorun=yes']);
-      }
-      args.addAll([script, url.toString()]);
-      var process = await Process.start(settings.executable, args);
-
-      // PhantomJS synchronously emits standard output, which means that if we
-      // don't drain its stdout stream it can deadlock.
-      process.stdout.listen((_) {});
-
-      unawaited(process.exitCode.then((exitCode) {
-        Directory(dir).deleteSync(recursive: true);
-
-        if (exitCode == exit_codes.protocol) {
-          throw ApplicationException(
-              'Only PhantomJS version 2.0.0 or greater is supported');
-        }
-      }));
-
-      if (port != null) {
-        remoteDebuggerCompleter.complete(Uri.parse(
-            'http://localhost:$port/webkit/inspector/inspector.html?page=2'));
-      } else {
-        remoteDebuggerCompleter.complete(null);
-      }
-
-      return process;
-    }, remoteDebuggerCompleter.future);
-  }
-
-  PhantomJS._(Future<Process> Function() startBrowser, this.remoteDebuggerUrl)
-      : super(startBrowser);
-}
diff --git a/pkgs/test/mono_pkg.yaml b/pkgs/test/mono_pkg.yaml
index ffa6539..991c9f5 100644
--- a/pkgs/test/mono_pkg.yaml
+++ b/pkgs/test/mono_pkg.yaml
@@ -10,8 +10,8 @@
         dart:
         - dev
     - unit_test:
-      - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 0
-      - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 1
-      - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 2
-      - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 3
-      - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 4
+      - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis --total-shards 5 --shard-index 0
+      - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis --total-shards 5 --shard-index 1
+      - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis --total-shards 5 --shard-index 2
+      - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis --total-shards 5 --shard-index 3
+      - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis --total-shards 5 --shard-index 4
diff --git a/pkgs/test/test/runner/browser/phantom_js_test.dart b/pkgs/test/test/runner/browser/phantom_js_test.dart
deleted file mode 100644
index f0c4c10..0000000
--- a/pkgs/test/test/runner/browser/phantom_js_test.dart
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (c) 2015, the Dart project authors.  Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-@TestOn('vm')
-@Tags(['phantomjs'])
-
-import 'package:test/src/runner/browser/phantom_js.dart';
-import 'package:test/src/runner/executable_settings.dart';
-import 'package:test/test.dart';
-import 'package:test_core/src/runner/configuration.dart'; // ignore: implementation_imports
-import 'package:test_descriptor/test_descriptor.dart' as d;
-
-import '../../io.dart';
-import '../../utils.dart';
-import 'code_server.dart';
-
-void main() {
-  test('starts PhantomJS with the given URL', () async {
-    var server = await CodeServer.start();
-
-    server.handleJavaScript('''
-var webSocket = new WebSocket(window.location.href.replace("http://", "ws://"));
-webSocket.addEventListener("open", function() {
-  webSocket.send("loaded!");
-});
-''');
-    var webSocket = server.handleWebSocket();
-
-    var phantomJS = PhantomJS(server.url, Configuration());
-    addTearDown(() => phantomJS.close());
-
-    expect(await (await webSocket).stream.first, equals('loaded!'));
-  });
-
-  test("a process can be killed synchronously after it's started", () async {
-    var server = await CodeServer.start();
-
-    var phantomJS = PhantomJS(server.url, Configuration());
-    await phantomJS.close();
-  });
-
-  test('reports an error in onExit', () {
-    var phantomJS = PhantomJS('http://dart-lang.org', Configuration(),
-        settings: ExecutableSettings(
-            linuxExecutable: '_does_not_exist',
-            macOSExecutable: '_does_not_exist',
-            windowsExecutable: '_does_not_exist'));
-    expect(
-        phantomJS.onExit,
-        throwsA(isApplicationException(
-            startsWith('Failed to run PhantomJS: $noSuchFileMessage'))));
-  });
-
-  test('can run successful tests', () async {
-    await d.file('test.dart', '''
-import 'package:test/test.dart';
-
-void main() {
-  test("success", () {});
-}
-''').create();
-
-    var test = await runTest(['-p', 'phantomjs', 'test.dart']);
-    expect(test.stdout, emitsThrough(contains('+1: All tests passed!')));
-    await test.shouldExit(0);
-  });
-
-  test('can run failing tests', () async {
-    await d.file('test.dart', '''
-import 'package:test/test.dart';
-
-void main() {
-  test("failure", () => throw TestFailure("oh no"));
-}
-''').create();
-
-    var test = await runTest(['-p', 'phantomjs', 'test.dart']);
-    expect(test.stdout, emitsThrough(contains('-1: Some tests failed.')));
-    await test.shouldExit(1);
-  });
-}
diff --git a/pkgs/test/test/runner/configuration/top_level_test.dart b/pkgs/test/test/runner/configuration/top_level_test.dart
index 5e7208c..9c3da89 100644
--- a/pkgs/test/test/runner/configuration/top_level_test.dart
+++ b/pkgs/test/test/runner/configuration/top_level_test.dart
@@ -341,12 +341,11 @@
         }
       ''').create();
 
-      var test = await runTest(['-p', 'chrome,firefox,phantomjs', 'test.dart']);
+      var test = await runTest(['-p', 'chrome,firefox', 'test.dart']);
       expect(
           test.stderr,
-          emits(
-              "Warning: this package doesn't support running tests on Chrome, "
-              'Firefox, or PhantomJS.'));
+          emits("Warning: this package doesn't support running tests on Chrome "
+              'or Firefox.'));
       expect(test.stdout, emitsThrough(contains('No tests ran.')));
       await test.shouldExit(1);
     });
diff --git a/pkgs/test/test/runner/runner_test.dart b/pkgs/test/test/runner/runner_test.dart
index ec95829..b924952 100644
--- a/pkgs/test/test/runner/runner_test.dart
+++ b/pkgs/test/test/runner/runner_test.dart
@@ -117,7 +117,7 @@
 
 ''';
 
-final _browsers = '[vm (default), chrome, phantomjs, firefox' +
+final _browsers = '[vm (default), chrome, firefox' +
     (Platform.isMacOS ? ', safari' : '') +
     (Platform.isWindows ? ', ie' : '') +
     ', node]';
diff --git a/pkgs/test_api/CHANGELOG.md b/pkgs/test_api/CHANGELOG.md
index 4c452a2..d58c04e 100644
--- a/pkgs/test_api/CHANGELOG.md
+++ b/pkgs/test_api/CHANGELOG.md
@@ -1,7 +1,8 @@
-## 0.3.1
+## 0.4.0-dev
 
 * Add examples to `throwsA` and make top-level `throws...` matchers refer to it.
 * Disable stack trace chaining by default.
+* **Breaking** remove `Runtime.phantomJS`
 
 ## 0.3.0
 
diff --git a/pkgs/test_api/lib/src/backend/runtime.dart b/pkgs/test_api/lib/src/backend/runtime.dart
index 8496f0c..5cf1337 100644
--- a/pkgs/test_api/lib/src/backend/runtime.dart
+++ b/pkgs/test_api/lib/src/backend/runtime.dart
@@ -14,10 +14,6 @@
   static const Runtime chrome =
       Runtime('Chrome', 'chrome', isBrowser: true, isJS: true, isBlink: true);
 
-  /// PhantomJS.
-  static const Runtime phantomJS = Runtime('PhantomJS', 'phantomjs',
-      isBrowser: true, isJS: true, isBlink: true, isHeadless: true);
-
   /// Mozilla Firefox.
   static const Runtime firefox =
       Runtime('Firefox', 'firefox', isBrowser: true, isJS: true);
@@ -37,7 +33,6 @@
   static const List<Runtime> builtIn = [
     Runtime.vm,
     Runtime.chrome,
-    Runtime.phantomJS,
     Runtime.firefox,
     Runtime.safari,
     Runtime.internetExplorer,
diff --git a/pkgs/test_api/pubspec.yaml b/pkgs/test_api/pubspec.yaml
index 20a02c9..e4c35ae 100644
--- a/pkgs/test_api/pubspec.yaml
+++ b/pkgs/test_api/pubspec.yaml
@@ -1,5 +1,5 @@
 name: test_api
-version: 0.3.1
+version: 0.4.0-dev
 description: A library for writing Dart tests.
 homepage: https://github.com/dart-lang/test/blob/master/pkgs/test_api
 
diff --git a/pkgs/test_core/lib/src/runner/configuration/args.dart b/pkgs/test_core/lib/src/runner/configuration/args.dart
index 1f8b0fc..c1ff9fb 100644
--- a/pkgs/test_core/lib/src/runner/configuration/args.dart
+++ b/pkgs/test_core/lib/src/runner/configuration/args.dart
@@ -236,15 +236,6 @@
     var platform = _ifParsed<List<String>>('platform')
         ?.map((runtime) => RuntimeSelection(runtime))
         .toList();
-    if (platform
-            ?.any((runtime) => runtime.name == Runtime.phantomJS.identifier) ??
-        false) {
-      var yellow = color ? '\u001b[33m' : '';
-      var noColor = color ? '\u001b[0m' : '';
-      print('${yellow}Warning:$noColor '
-          'PhatomJS is deprecated and will be removed in version ^2.0.0');
-    }
-
     return Configuration(
         help: _ifParsed('help'),
         version: _ifParsed('version'),
diff --git a/tool/ci.sh b/tool/ci.sh
index 588b95d..cc0d076 100755
--- a/tool/ci.sh
+++ b/tool/ci.sh
@@ -59,24 +59,24 @@
       echo -e "\033[1mPKG: ${PKG}; TASK: ${TASK}\033[22m"
       case ${TASK} in
       command_0)
-        echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 0'
-        xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 0 || EXIT_CODE=$?
+        echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis --total-shards 5 --shard-index 0'
+        xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis --total-shards 5 --shard-index 0 || EXIT_CODE=$?
         ;;
       command_1)
-        echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 1'
-        xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 1 || EXIT_CODE=$?
+        echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis --total-shards 5 --shard-index 1'
+        xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis --total-shards 5 --shard-index 1 || EXIT_CODE=$?
         ;;
       command_2)
-        echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 2'
-        xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 2 || EXIT_CODE=$?
+        echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis --total-shards 5 --shard-index 2'
+        xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis --total-shards 5 --shard-index 2 || EXIT_CODE=$?
         ;;
       command_3)
-        echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 3'
-        xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 3 || EXIT_CODE=$?
+        echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis --total-shards 5 --shard-index 3'
+        xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis --total-shards 5 --shard-index 3 || EXIT_CODE=$?
         ;;
       command_4)
-        echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 4'
-        xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 4 || EXIT_CODE=$?
+        echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis --total-shards 5 --shard-index 4'
+        xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis --total-shards 5 --shard-index 4 || EXIT_CODE=$?
         ;;
       command_5)
         echo 'pub run test --preset travis -x browser'