+25
-1
lines changedFilter options
+25
-1
lines changed Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@
17
17
# specific language governing permissions and limitations
18
18
# under the License.
19
19
20
+
require 'zip'
21
+
20
22
module Selenium
21
23
module WebDriver
22
24
module Firefox
@@ -35,7 +37,23 @@ def commands(command)
35
37
end
36
38
37
39
def install_addon(path, temporary)
38
-
addon = File.open(path, 'rb') { |crx_file| Base64.strict_encode64 crx_file.read }
40
+
if File.directory?(path)
41
+
zip = "#{path}.zip"
42
+
# Delete zip file if it already exists
43
+
File.delete(zip) if File.file?(zip)
44
+
45
+
Zip::File.open(zip, Zip::File::CREATE) do |z_file|
46
+
Dir[File.join(path, "**", "**")].each do |file|
47
+
z_file.add(file.sub("#{path}/", ""), file)
48
+
end
49
+
end
50
+
51
+
addon = File.open(zip, 'rb') { |crx_file| Base64.strict_encode64 crx_file.read }
52
+
# Delete the zip file
53
+
File.delete(zip)
54
+
else
55
+
addon = File.open(path, 'rb') { |crx_file| Base64.strict_encode64 crx_file.read }
56
+
end
39
57
40
58
payload = {addon: addon}
41
59
payload[:temporary] = temporary unless temporary.nil?
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ module WebDriver
24
24
module Firefox
25
25
describe Driver, exclusive: {browser: :firefox} do
26
26
let(:extension) { '../../../../../../third_party/firebug/favourite_colour-1.1-an+fx.xpi' }
27
+
let(:extension_dir) { '../../../../../../common/extensions/webextensions-selenium-example' }
27
28
28
29
describe '#print_options' do
29
30
let(:magic_number) { 'JVBER' }
@@ -74,6 +75,11 @@ module Firefox
74
75
ext = File.expand_path(extension, __dir__)
75
76
driver.install_addon(ext, true)
76
77
end
78
+
79
+
it 'with path as unpacked directory' do
80
+
ext = File.expand_path(extension_dir, __dir__)
81
+
driver.install_addon(ext, true)
82
+
end
77
83
end
78
84
79
85
describe '#uninstall_addon' do
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4