diff --git a/rb/lib/selenium/webdriver/firefox/extension.rb b/rb/lib/selenium/webdriver/firefox/extension.rb index 1f268d6021e76..674eac2acd8c7 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)) + applications_gecko_id(manifest) || name_and_version(manifest) + end + + def applications_gecko_id(manifest) + manifest.dig('applications', 'gecko', 'id')&.strip + end + + def name_and_version(manifest) [manifest['name'].delete(' '), manifest['version']].join('@') end end # Extension diff --git a/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb b/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb index bc3ce1e6bedeb..38f76c67501e9 100644 --- a/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb +++ b/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb @@ -147,13 +147,20 @@ def read_generated_prefs(from = nil) expect(Dir.exist?(extension_directory)).to eq(true) end - it 'can install web extension' do + it 'can install web extension without id' do mooltipass = File.expand_path('../../../../../../third_party/firebug/mooltipass-1.1.87.xpi', __dir__) profile.add_extension(mooltipass) extension_directory = File.expand_path('extensions/MooltipassExtension@1.1.87', profile.layout_on_disk) expect(Dir.exist?(extension_directory)).to eq(true) end + it 'can install web extension with id' do + ext = File.expand_path('../../../../../../third_party/firebug/favourite_colour-1.1-an+fx.xpi', __dir__) + profile.add_extension(ext) + extension_directory = File.expand_path('extensions/favourite-colour-examples@mozilla.org', profile.layout_on_disk) + expect(Dir.exist?(extension_directory)).to eq(true) + end + describe 'with browser' do before do profile['browser.startup.homepage'] = url_for('simpleTest.html') diff --git a/third_party/firebug/favourite_colour-1.1-an+fx.xpi b/third_party/firebug/favourite_colour-1.1-an+fx.xpi new file mode 100644 index 0000000000000..1982a588bc025 Binary files /dev/null and b/third_party/firebug/favourite_colour-1.1-an+fx.xpi differ