From c800db73701e0d518c8932a9fd36eff2861bf87a Mon Sep 17 00:00:00 2001 From: Michael Preston Date: Wed, 15 Jan 2020 12:52:00 +0000 Subject: [PATCH] Read Firefox Extension ID from appropriate location in manifest.json Previously, when installing an extension that didn't have an install.rdf file and instead relied on using the manifest.json, we weren't looking in the correct place for the extensions gecko ID. https://extensionworkshop.com/documentation/develop/extensions-and-the-add-on-id/#When_do_you_need_an_add-on_ID If someone specifies this ID themselves, we need to check the manifest.json for browser_specific_settings, which then houses the application ID. Otherwise, we can fallback to using the extension name + version. --- rb/lib/selenium/webdriver/firefox/extension.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rb/lib/selenium/webdriver/firefox/extension.rb b/rb/lib/selenium/webdriver/firefox/extension.rb index 348410d656c6c..ab588a3a562b6 100644 --- a/rb/lib/selenium/webdriver/firefox/extension.rb +++ b/rb/lib/selenium/webdriver/firefox/extension.rb @@ -87,6 +87,14 @@ def read_id_from_manifest_json(directory) return unless File.exist?(manifest_path) manifest = JSON.parse(File.read(manifest_path)) + gecko_id(manifest) || name_and_version(manifest) + end + + def gecko_id(manifest) + manifest.dig('browser_specific_settings', 'gecko', 'id')&.strip + end + + def name_and_version(manifest) [manifest['name'].delete(' '), manifest['version']].join('@') end end # Extension