Skip to content

Commit

Permalink
Read Firefox Extension ID from appropriate location in manifest.json
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
michaelpreston committed Jan 15, 2020
1 parent 2ecb7d9 commit c800db7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rb/lib/selenium/webdriver/firefox/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c800db7

Please sign in to comment.