Add Firefox dependency to flutter_deps
Change-Id: Ic9f10c2a426c6003890fb9edd76e646e1a6618d3
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/36381
Commit-Queue: Harry Terkelsen <het@google.com>
Reviewed-by: Godofredo Contreras <godofredoc@google.com>
diff --git a/recipe_modules/flutter_deps/api.py b/recipe_modules/flutter_deps/api.py
index b95ceac..2b63238 100644
--- a/recipe_modules/flutter_deps/api.py
+++ b/recipe_modules/flutter_deps/api.py
@@ -66,6 +66,7 @@
         'dart_sdk': self.dart_sdk,
         'dashing': self.dashing,
         'firebase': self.firebase,
+        'firefox': self.firefox,
         'gh_cli': self.gh_cli,
         'go_sdk': self.go_sdk,
         'goldctl': self.goldctl,
@@ -180,6 +181,25 @@
       else:
         env['CHROME_EXECUTABLE'] = chrome_path.join(binary_name)
 
+  def firefox(self, env, env_prefixes, version):
+    """Downloads Firefox from CIPD and updates the environment variables.
+
+    Args:
+      env(dict): Current environment variables.
+      env_prefixes(dict):  Current environment prefixes variables.
+      version(str): The Firefox version to install.
+    """
+    version = version or 'latest'
+    with self.m.step.nest('Firefox dependency'):
+      firefox_path = self.m.path['cache'].join('firefox')
+      pkgs = self.m.cipd.EnsureFile()
+      pkgs.add_package('flutter_internal/browsers/firefox/${platform}', version)
+      self.m.cipd.ensure(firefox_path, pkgs)
+      paths = env_prefixes.get('PATH', [])
+      paths.append(firefox_path.join('firefox'))
+      env_prefixes['PATH'] = paths
+      env['FIREFOX_EXECUTABLE'] = firefox_path.join('firefox', 'firefox')
+
   def gh_cli(self, env, env_prefixes, version):
     """Installs GitHub CLI."""
     version = version or 'latest'
diff --git a/recipe_modules/flutter_deps/examples/full.expected/basic.json b/recipe_modules/flutter_deps/examples/full.expected/basic.json
index c3b9d91..ac2eb89 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/basic.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/basic.json
@@ -128,6 +128,39 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "Firefox dependency"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CACHE]/firefox",
+      "-ensure-file",
+      "flutter_internal/browsers/firefox/${platform} v3",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Firefox dependency.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-v3--------------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/browsers/firefox/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
     "cmd": [
       "cipd",
       "ensure",
@@ -222,12 +255,14 @@
     "env": {
       "CHROME_EXECUTABLE": "[CACHE]/chrome/chrome/chrome",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]/firefox/firefox/firefox",
       "GOPATH": "[CLEANUP]/go_path"
     },
     "env_prefixes": {
       "PATH": [
         "[CACHE]/chrome/chrome",
         "[CACHE]/chrome/drivers",
+        "[CACHE]/firefox/firefox",
         "[CACHE]/go/bin",
         "[CLEANUP]/go_path/bin",
         "[CACHE]/go/bin",
@@ -657,6 +692,7 @@
       "ANDROID_SDK_ROOT": "[CACHE]/android",
       "CHROME_EXECUTABLE": "[CACHE]/chrome/chrome/chrome",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]/firefox/firefox/firefox",
       "FLUTTER_XCODE_CODE_SIGN_STYLE": "Manual",
       "FLUTTER_XCODE_DEVELOPMENT_TEAM": "S8QB4VV633",
       "FLUTTER_XCODE_PROVISIONING_PROFILE_SPECIFIER": "match Development *",
@@ -670,6 +706,7 @@
         "[CACHE]/dart_sdk",
         "[CACHE]/chrome/chrome",
         "[CACHE]/chrome/drivers",
+        "[CACHE]/firefox/firefox",
         "[CACHE]/go/bin",
         "[CLEANUP]/go_path/bin",
         "[CACHE]/go/bin",
diff --git a/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json b/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json
index af0f9fd..33a48a3 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/flutter_engine.json
@@ -128,6 +128,39 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "Firefox dependency"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CACHE]/firefox",
+      "-ensure-file",
+      "flutter_internal/browsers/firefox/${platform} v3",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Firefox dependency.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-v3--------------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/browsers/firefox/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
     "cmd": [
       "cipd",
       "ensure",
@@ -222,12 +255,14 @@
     "env": {
       "CHROME_EXECUTABLE": "[CACHE]/chrome/chrome/chrome",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]/firefox/firefox/firefox",
       "GOPATH": "[CLEANUP]/go_path"
     },
     "env_prefixes": {
       "PATH": [
         "[CACHE]/chrome/chrome",
         "[CACHE]/chrome/drivers",
+        "[CACHE]/firefox/firefox",
         "[CACHE]/go/bin",
         "[CLEANUP]/go_path/bin",
         "[CACHE]/go/bin",
@@ -741,6 +776,7 @@
       "ANDROID_SDK_ROOT": "[CACHE]/android",
       "CHROME_EXECUTABLE": "[CACHE]/chrome/chrome/chrome",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]/firefox/firefox/firefox",
       "FLUTTER_XCODE_CODE_SIGN_STYLE": "Manual",
       "FLUTTER_XCODE_DEVELOPMENT_TEAM": "S8QB4VV633",
       "FLUTTER_XCODE_PROVISIONING_PROFILE_SPECIFIER": "match Development *",
@@ -756,6 +792,7 @@
         "[CLEANUP]/builder/src/out/host_debug_unopt/dart-sdk/bin",
         "[CACHE]/chrome/chrome",
         "[CACHE]/chrome/drivers",
+        "[CACHE]/firefox/firefox",
         "[CACHE]/go/bin",
         "[CLEANUP]/go_path/bin",
         "[CACHE]/go/bin",
diff --git a/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json b/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json
index c3b9d91..ac2eb89 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/goldTryjob.json
@@ -128,6 +128,39 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "Firefox dependency"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CACHE]/firefox",
+      "-ensure-file",
+      "flutter_internal/browsers/firefox/${platform} v3",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Firefox dependency.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-v3--------------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/browsers/firefox/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
     "cmd": [
       "cipd",
       "ensure",
@@ -222,12 +255,14 @@
     "env": {
       "CHROME_EXECUTABLE": "[CACHE]/chrome/chrome/chrome",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]/firefox/firefox/firefox",
       "GOPATH": "[CLEANUP]/go_path"
     },
     "env_prefixes": {
       "PATH": [
         "[CACHE]/chrome/chrome",
         "[CACHE]/chrome/drivers",
+        "[CACHE]/firefox/firefox",
         "[CACHE]/go/bin",
         "[CLEANUP]/go_path/bin",
         "[CACHE]/go/bin",
@@ -657,6 +692,7 @@
       "ANDROID_SDK_ROOT": "[CACHE]/android",
       "CHROME_EXECUTABLE": "[CACHE]/chrome/chrome/chrome",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]/firefox/firefox/firefox",
       "FLUTTER_XCODE_CODE_SIGN_STYLE": "Manual",
       "FLUTTER_XCODE_DEVELOPMENT_TEAM": "S8QB4VV633",
       "FLUTTER_XCODE_PROVISIONING_PROFILE_SPECIFIER": "match Development *",
@@ -670,6 +706,7 @@
         "[CACHE]/dart_sdk",
         "[CACHE]/chrome/chrome",
         "[CACHE]/chrome/drivers",
+        "[CACHE]/firefox/firefox",
         "[CACHE]/go/bin",
         "[CLEANUP]/go_path/bin",
         "[CACHE]/go/bin",
diff --git a/recipe_modules/flutter_deps/examples/full.expected/linux.json b/recipe_modules/flutter_deps/examples/full.expected/linux.json
index c3b9d91..ac2eb89 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/linux.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/linux.json
@@ -128,6 +128,39 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "Firefox dependency"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CACHE]/firefox",
+      "-ensure-file",
+      "flutter_internal/browsers/firefox/${platform} v3",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Firefox dependency.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-v3--------------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/browsers/firefox/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
     "cmd": [
       "cipd",
       "ensure",
@@ -222,12 +255,14 @@
     "env": {
       "CHROME_EXECUTABLE": "[CACHE]/chrome/chrome/chrome",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]/firefox/firefox/firefox",
       "GOPATH": "[CLEANUP]/go_path"
     },
     "env_prefixes": {
       "PATH": [
         "[CACHE]/chrome/chrome",
         "[CACHE]/chrome/drivers",
+        "[CACHE]/firefox/firefox",
         "[CACHE]/go/bin",
         "[CLEANUP]/go_path/bin",
         "[CACHE]/go/bin",
@@ -657,6 +692,7 @@
       "ANDROID_SDK_ROOT": "[CACHE]/android",
       "CHROME_EXECUTABLE": "[CACHE]/chrome/chrome/chrome",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]/firefox/firefox/firefox",
       "FLUTTER_XCODE_CODE_SIGN_STYLE": "Manual",
       "FLUTTER_XCODE_DEVELOPMENT_TEAM": "S8QB4VV633",
       "FLUTTER_XCODE_PROVISIONING_PROFILE_SPECIFIER": "match Development *",
@@ -670,6 +706,7 @@
         "[CACHE]/dart_sdk",
         "[CACHE]/chrome/chrome",
         "[CACHE]/chrome/drivers",
+        "[CACHE]/firefox/firefox",
         "[CACHE]/go/bin",
         "[CLEANUP]/go_path/bin",
         "[CACHE]/go/bin",
diff --git a/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json b/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json
index bfc1082..f1e5492 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/local_engine_cas.json
@@ -128,6 +128,39 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "Firefox dependency"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CACHE]/firefox",
+      "-ensure-file",
+      "flutter_internal/browsers/firefox/${platform} v3",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Firefox dependency.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-v3--------------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/browsers/firefox/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
     "cmd": [
       "cipd",
       "ensure",
@@ -222,12 +255,14 @@
     "env": {
       "CHROME_EXECUTABLE": "[CACHE]/chrome/chrome/chrome",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]/firefox/firefox/firefox",
       "GOPATH": "[CLEANUP]/go_path"
     },
     "env_prefixes": {
       "PATH": [
         "[CACHE]/chrome/chrome",
         "[CACHE]/chrome/drivers",
+        "[CACHE]/firefox/firefox",
         "[CACHE]/go/bin",
         "[CLEANUP]/go_path/bin",
         "[CACHE]/go/bin",
@@ -741,6 +776,7 @@
       "ANDROID_SDK_ROOT": "[CACHE]/android",
       "CHROME_EXECUTABLE": "[CACHE]/chrome/chrome/chrome",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]/firefox/firefox/firefox",
       "FLUTTER_XCODE_CODE_SIGN_STYLE": "Manual",
       "FLUTTER_XCODE_DEVELOPMENT_TEAM": "S8QB4VV633",
       "FLUTTER_XCODE_PROVISIONING_PROFILE_SPECIFIER": "match Development *",
@@ -756,6 +792,7 @@
         "[CLEANUP]/builder/src/out/host-release/dart-sdk/bin",
         "[CACHE]/chrome/chrome",
         "[CACHE]/chrome/drivers",
+        "[CACHE]/firefox/firefox",
         "[CACHE]/go/bin",
         "[CLEANUP]/go_path/bin",
         "[CACHE]/go/bin",
diff --git a/recipe_modules/flutter_deps/examples/full.expected/mac.json b/recipe_modules/flutter_deps/examples/full.expected/mac.json
index 21271ff..07fd2ec 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/mac.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/mac.json
@@ -128,6 +128,39 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "Firefox dependency"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CACHE]/firefox",
+      "-ensure-file",
+      "flutter_internal/browsers/firefox/${platform} v3",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Firefox dependency.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-v3--------------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/browsers/firefox/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
     "cmd": [
       "cipd",
       "ensure",
@@ -222,12 +255,14 @@
     "env": {
       "CHROME_EXECUTABLE": "[CACHE]/chrome/chrome/chrome-mac/Chromium.app/Contents/MacOS/Chromium",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]/firefox/firefox/firefox",
       "GOPATH": "[CLEANUP]/go_path"
     },
     "env_prefixes": {
       "PATH": [
         "[CACHE]/chrome/chrome",
         "[CACHE]/chrome/drivers",
+        "[CACHE]/firefox/firefox",
         "[CACHE]/go/bin",
         "[CLEANUP]/go_path/bin",
         "[CACHE]/go/bin",
diff --git a/recipe_modules/flutter_deps/examples/full.expected/windows.json b/recipe_modules/flutter_deps/examples/full.expected/windows.json
index c2dc2d5..20df5a0 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/windows.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/windows.json
@@ -128,6 +128,39 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "Firefox dependency"
+  },
+  {
+    "cmd": [
+      "cipd.bat",
+      "ensure",
+      "-root",
+      "[CACHE]\\firefox",
+      "-ensure-file",
+      "flutter_internal/browsers/firefox/${platform} v3",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Firefox dependency.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-v3--------------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/browsers/firefox/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
     "cmd": [
       "cipd.bat",
       "ensure",
@@ -222,12 +255,14 @@
     "env": {
       "CHROME_EXECUTABLE": "[CACHE]\\chrome\\chrome\\chrome.exe",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]\\firefox\\firefox\\firefox",
       "GOPATH": "[CLEANUP]\\go_path"
     },
     "env_prefixes": {
       "PATH": [
         "[CACHE]\\chrome\\chrome",
         "[CACHE]\\chrome\\drivers",
+        "[CACHE]\\firefox\\firefox",
         "[CACHE]\\go\\bin",
         "[CLEANUP]\\go_path\\bin",
         "[CACHE]\\go\\bin",
@@ -622,6 +657,7 @@
       "ANDROID_SDK_ROOT": "[CACHE]\\android",
       "CHROME_EXECUTABLE": "[CACHE]\\chrome\\chrome\\chrome.exe",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]\\firefox\\firefox\\firefox",
       "FLUTTER_XCODE_CODE_SIGN_STYLE": "Manual",
       "FLUTTER_XCODE_DEVELOPMENT_TEAM": "S8QB4VV633",
       "FLUTTER_XCODE_PROVISIONING_PROFILE_SPECIFIER": "match Development *",
@@ -635,6 +671,7 @@
         "[CACHE]\\dart_sdk",
         "[CACHE]\\chrome\\chrome",
         "[CACHE]\\chrome\\drivers",
+        "[CACHE]\\firefox\\firefox",
         "[CACHE]\\go\\bin",
         "[CLEANUP]\\go_path\\bin",
         "[CACHE]\\go\\bin",
@@ -695,6 +732,7 @@
       "ANDROID_SDK_ROOT": "[CACHE]\\android",
       "CHROME_EXECUTABLE": "[CACHE]\\chrome\\chrome\\chrome.exe",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]\\firefox\\firefox\\firefox",
       "FLUTTER_XCODE_CODE_SIGN_STYLE": "Manual",
       "FLUTTER_XCODE_DEVELOPMENT_TEAM": "S8QB4VV633",
       "FLUTTER_XCODE_PROVISIONING_PROFILE_SPECIFIER": "match Development *",
@@ -709,6 +747,7 @@
         "[CACHE]\\dart_sdk",
         "[CACHE]\\chrome\\chrome",
         "[CACHE]\\chrome\\drivers",
+        "[CACHE]\\firefox\\firefox",
         "[CACHE]\\go\\bin",
         "[CLEANUP]\\go_path\\bin",
         "[CACHE]\\go\\bin",
diff --git a/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json b/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json
index 3fe3a1d..9028f1b 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/with-arm64ruby.json
@@ -128,6 +128,39 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "Firefox dependency"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CACHE]/firefox",
+      "-ensure-file",
+      "flutter_internal/browsers/firefox/${platform} v3",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Firefox dependency.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-v3--------------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/browsers/firefox/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
     "cmd": [
       "cipd",
       "ensure",
@@ -222,12 +255,14 @@
     "env": {
       "CHROME_EXECUTABLE": "[CACHE]/chrome/chrome/chrome",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]/firefox/firefox/firefox",
       "GOPATH": "[CLEANUP]/go_path"
     },
     "env_prefixes": {
       "PATH": [
         "[CACHE]/chrome/chrome",
         "[CACHE]/chrome/drivers",
+        "[CACHE]/firefox/firefox",
         "[CACHE]/go/bin",
         "[CLEANUP]/go_path/bin",
         "[CACHE]/go/bin",
@@ -657,6 +692,7 @@
       "ANDROID_SDK_ROOT": "[CACHE]/android",
       "CHROME_EXECUTABLE": "[CACHE]/chrome/chrome/chrome",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]/firefox/firefox/firefox",
       "FLUTTER_XCODE_CODE_SIGN_STYLE": "Manual",
       "FLUTTER_XCODE_DEVELOPMENT_TEAM": "S8QB4VV633",
       "FLUTTER_XCODE_PROVISIONING_PROFILE_SPECIFIER": "match Development *",
@@ -670,6 +706,7 @@
         "[CACHE]/dart_sdk",
         "[CACHE]/chrome/chrome",
         "[CACHE]/chrome/drivers",
+        "[CACHE]/firefox/firefox",
         "[CACHE]/go/bin",
         "[CLEANUP]/go_path/bin",
         "[CACHE]/go/bin",
diff --git a/recipe_modules/flutter_deps/examples/full.expected/with-gems.json b/recipe_modules/flutter_deps/examples/full.expected/with-gems.json
index 28e6776..b7e6d04 100644
--- a/recipe_modules/flutter_deps/examples/full.expected/with-gems.json
+++ b/recipe_modules/flutter_deps/examples/full.expected/with-gems.json
@@ -128,6 +128,39 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "Firefox dependency"
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[CACHE]/firefox",
+      "-ensure-file",
+      "flutter_internal/browsers/firefox/${platform} v3",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "Firefox dependency.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-v3--------------\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/browsers/firefox/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
     "cmd": [
       "cipd",
       "ensure",
@@ -222,12 +255,14 @@
     "env": {
       "CHROME_EXECUTABLE": "[CACHE]/chrome/chrome/chrome",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]/firefox/firefox/firefox",
       "GOPATH": "[CLEANUP]/go_path"
     },
     "env_prefixes": {
       "PATH": [
         "[CACHE]/chrome/chrome",
         "[CACHE]/chrome/drivers",
+        "[CACHE]/firefox/firefox",
         "[CACHE]/go/bin",
         "[CLEANUP]/go_path/bin",
         "[CACHE]/go/bin",
@@ -657,6 +692,7 @@
       "ANDROID_SDK_ROOT": "[CACHE]/android",
       "CHROME_EXECUTABLE": "[CACHE]/chrome/chrome/chrome",
       "CHROME_NO_SANDBOX": "true",
+      "FIREFOX_EXECUTABLE": "[CACHE]/firefox/firefox/firefox",
       "FLUTTER_XCODE_CODE_SIGN_STYLE": "Manual",
       "FLUTTER_XCODE_DEVELOPMENT_TEAM": "S8QB4VV633",
       "FLUTTER_XCODE_PROVISIONING_PROFILE_SPECIFIER": "match Development *",
@@ -670,6 +706,7 @@
         "[CACHE]/dart_sdk",
         "[CACHE]/chrome/chrome",
         "[CACHE]/chrome/drivers",
+        "[CACHE]/firefox/firefox",
         "[CACHE]/go/bin",
         "[CLEANUP]/go_path/bin",
         "[CACHE]/go/bin",
diff --git a/recipe_modules/flutter_deps/examples/full.py b/recipe_modules/flutter_deps/examples/full.py
index ca9a7af..1e2942a 100644
--- a/recipe_modules/flutter_deps/examples/full.py
+++ b/recipe_modules/flutter_deps/examples/full.py
@@ -27,10 +27,13 @@
   api.flutter_deps.chrome_and_driver(env, env_prefixes, 'v3')
   api.assertions.assertTrue(env.get('CHROME_NO_SANDBOX'))
   api.assertions.assertTrue(env.get('CHROME_EXECUTABLE'))
+  api.flutter_deps.firefox(env, env_prefixes, 'v3')
+  api.assertions.assertTrue(env.get('FIREFOX_EXECUTABLE'))
   api.assertions.assertEqual(
       env_prefixes.get('PATH'), [
           api.path['cache'].join('chrome', 'chrome'),
-          api.path['cache'].join('chrome', 'drivers')
+          api.path['cache'].join('chrome', 'drivers'),
+          api.path['cache'].join('firefox', 'firefox')
       ]
   )
   api.flutter_deps.go_sdk(env, env_prefixes, 'v4')
diff --git a/recipe_modules/web_util/api.py b/recipe_modules/web_util/api.py
index 79ec79a..d7408dd 100644
--- a/recipe_modules/web_util/api.py
+++ b/recipe_modules/web_util/api.py
@@ -9,16 +9,6 @@
 class WebUtilsApi(recipe_api.RecipeApi):
   """Utilities to use when running flutter web engine tests."""
 
-  def firefox_driver(self, checkout):
-    """Downloads the latest version of the Firefox web driver from CIPD."""
-    # Download the driver for Firefox.
-    firefox_driver_path = checkout.join('flutter', 'lib', 'web_ui',
-                                        '.dart_tool', 'drivers', 'firefox')
-    pkgdriver = self.m.cipd.EnsureFile()
-    pkgdriver.add_package(
-        'flutter_internal/browser-drivers/firefoxdriver-linux', 'latest')
-    self.m.cipd.ensure(firefox_driver_path, pkgdriver)
-
   def chrome(self, checkout):
     """Downloads Chrome from CIPD.
 
@@ -78,7 +68,6 @@
     available_deps = {
         'chrome': self.chrome,
         'chrome_driver': self.chrome_driver,
-        'firefox_driver': self.firefox_driver,
     }
     properties = properties or self.get_web_dependencies()
     for dep in properties:
diff --git a/recipe_modules/web_util/examples/full.expected/fail_case.json b/recipe_modules/web_util/examples/full.expected/fail_case.json
index ae2ac76..b70ebdf 100644
--- a/recipe_modules/web_util/examples/full.expected/fail_case.json
+++ b/recipe_modules/web_util/examples/full.expected/fail_case.json
@@ -9,7 +9,7 @@
       "Traceback (most recent call last):",
       "  File \"RECIPE_REPO[flutter]/recipe_modules/web_util/examples/full.py\", line 19, in RunSteps",
       "    api.web_util.prepare_web_dependencies(engine_checkout_path)",
-      "  File \"RECIPE_REPO[flutter]/recipe_modules/web_util/api.py\", line 87, in prepare_web_dependencies",
+      "  File \"RECIPE_REPO[flutter]/recipe_modules/web_util/api.py\", line 76, in prepare_web_dependencies",
       "    raise ValueError('Web Dependency %s not available.' % dep)",
       "ValueError('Web Dependency invalid_dependency not available.')"
     ]
diff --git a/recipe_modules/web_util/examples/full.expected/firefox_driver.json b/recipe_modules/web_util/examples/full.expected/firefox_driver.json
deleted file mode 100644
index 170c738..0000000
--- a/recipe_modules/web_util/examples/full.expected/firefox_driver.json
+++ /dev/null
@@ -1,33 +0,0 @@
-[
-  {
-    "cmd": [
-      "cipd",
-      "ensure",
-      "-root",
-      "[CACHE]/builder/src/flutter/lib/web_ui/.dart_tool/drivers/firefox",
-      "-ensure-file",
-      "flutter_internal/browser-drivers/firefoxdriver-linux latest",
-      "-max-threads",
-      "0",
-      "-json-output",
-      "/path/to/tmp/json"
-    ],
-    "name": "ensure_installed",
-    "~followup_annotations": [
-      "@@@STEP_LOG_LINE@json.output@{@@@",
-      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
-      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
-      "@@@STEP_LOG_LINE@json.output@      {@@@",
-      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-latest----------\", @@@",
-      "@@@STEP_LOG_LINE@json.output@        \"package\": \"flutter_internal/browser-drivers/firefoxdriver-linux\"@@@",
-      "@@@STEP_LOG_LINE@json.output@      }@@@",
-      "@@@STEP_LOG_LINE@json.output@    ]@@@",
-      "@@@STEP_LOG_LINE@json.output@  }@@@",
-      "@@@STEP_LOG_LINE@json.output@}@@@",
-      "@@@STEP_LOG_END@json.output@@@"
-    ]
-  },
-  {
-    "name": "$result"
-  }
-]
\ No newline at end of file
diff --git a/recipe_modules/web_util/examples/full.py b/recipe_modules/web_util/examples/full.py
index 029a791..c9d025a 100644
--- a/recipe_modules/web_util/examples/full.py
+++ b/recipe_modules/web_util/examples/full.py
@@ -27,7 +27,7 @@
           'Linux': '768968',
           'Mac': '768985',
           'Win': '768975'
-      }
+      },
   }
   yield api.test(
       'fail_case',
@@ -43,11 +43,6 @@
           web_dependencies=['chrome_driver'],), api.platform(
               'linux', 64)) + api.platform.name('linux')
   yield api.test(
-      'firefox_driver',
-      api.properties(
-          web_dependencies=['firefox_driver'],), api.platform(
-              'linux', 64)) + api.platform.name('linux')
-  yield api.test(
       'chrome',
       api.step_data('read browser lock yaml.parse',
                     api.json.output(browser_yaml_file)),
diff --git a/recipes/engine/web_engine.py b/recipes/engine/web_engine.py
index 6e28766..e0c5322 100644
--- a/recipes/engine/web_engine.py
+++ b/recipes/engine/web_engine.py
@@ -169,9 +169,6 @@
   properties = copy.deepcopy(drone_props)
   properties['command_name'] = 'firefox-unit-linux'
   properties['name'] = properties['command_name']
-  # We don't need extra dependencies since felt tools handles firefox itself.
-  # TODO(nurhan): Use cipd packages for Firefox. As we are doing for chrome
-  # still respect to the version from browser_lock.yaml.
   properties['web_dependencies'] = []
   # These are the felt commands which will be used.
   properties['command_args'] = ['test', '--browser=firefox']