Skip to content

Commit

Permalink
Support installing web extensions with applications.gecko.id
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed May 3, 2019
1 parent ee193d8 commit a25638d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
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))
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]', 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/[email protected]', 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')
Expand Down
Binary file not shown.

0 comments on commit a25638d

Please sign in to comment.