@@ -22,25 +22,15 @@ module WebDriver
22
22
module Safari
23
23
class Options
24
24
attr_accessor :port , :data_dir , :skip_extension_installation
25
- attr_reader :extensions
26
25
27
26
def initialize ( opts = { } )
28
- @extensions = [ ]
29
27
extract_options ( opts )
30
28
end
31
29
32
- def add_extension ( ext )
33
- @extensions << verify_safari_extension ( ext )
34
- end
35
-
36
30
def clean_session?
37
31
!!@clean_session
38
32
end
39
33
40
- def skip_extension_installation?
41
- !!@skip_extension_installation
42
- end
43
-
44
34
def to_capabilities
45
35
caps = Remote ::Capabilities . safari
46
36
caps . merge! ( 'safari.options' => as_json )
@@ -53,43 +43,15 @@ def as_json
53
43
'port' => port ,
54
44
'dataDir' => data_dir ,
55
45
'cleanSession' => clean_session? ,
56
- 'extensions' => extensions_as_json ,
57
- 'skipExtensionInstallation' => skip_extension_installation?
58
46
}
59
47
end
60
48
61
49
private
62
50
63
- def extensions_as_json
64
- @extensions . map do |path |
65
- { 'filename' => path . basename , 'contents' => Base64 . strict_encode64 ( path . read ) }
66
- end
67
- end
68
-
69
51
def extract_options ( opts )
70
52
@port = Integer ( opts [ :port ] || PortProber . random )
71
53
@data_dir = opts [ :custom_data_dir ] || opts [ :data_dir ]
72
54
@clean_session = opts [ :clean_session ]
73
-
74
- Array ( opts [ :extensions ] ) . each { |ext | add_extension ( ext ) }
75
-
76
- if opts . key? ( :install_extension )
77
- @skip_extension_installation = !opts [ :install_extension ]
78
- elsif opts . key? ( :skip_extension_installation )
79
- @skip_extension_installation = opts [ :skip_extension_installation ]
80
- else
81
- @skip_extension_installation = false
82
- end
83
- end
84
-
85
- def verify_safari_extension ( path )
86
- pn = Pathname . new ( path )
87
-
88
- unless pn . file? && pn . extname == '.safariextz'
89
- raise ArgumentError , "invalid Safari extension path: #{ path } "
90
- end
91
-
92
- pn
93
55
end
94
56
95
57
end # Options
0 commit comments