selenium-webdriver 2.18.0.rc1 → 2.18.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,52 @@
1
+ {
2
+ "frozen": {
3
+ "app.update.auto": false,
4
+ "app.update.enabled": false,
5
+ "browser.download.manager.showWhenStarting": false,
6
+ "browser.EULA.override": true,
7
+ "browser.EULA.3.accepted": true,
8
+ "browser.link.open_external": 2,
9
+ "browser.link.open_newwindow": 2,
10
+ "browser.offline": false,
11
+ "browser.safebrowsing.enabled": false,
12
+ "browser.safebrowsing.malware.enabled": false,
13
+ "browser.search.update": false,
14
+ "browser.sessionstore.resume_from_crash": false,
15
+ "browser.shell.checkDefaultBrowser": false,
16
+ "browser.tabs.warnOnClose": false,
17
+ "browser.tabs.warnOnOpen": false,
18
+ "devtools.errorconsole.enabled": true,
19
+ "dom.disable_open_during_load": false,
20
+ "extensions.autoDisableScopes": 10,
21
+ "extensions.logging.enabled": true,
22
+ "extensions.update.enabled": false,
23
+ "extensions.update.notifyUser": false,
24
+ "focusmanager.testmode": true,
25
+ "network.manage-offline-status": false,
26
+ "network.http.max-connections-per-server": 10,
27
+ "network.http.phishy-userpass-length": 255,
28
+ "offline-apps.allow_by_default": true,
29
+ "prompts.tab_modal.enabled": false,
30
+ "security.fileuri.origin_policy": 3,
31
+ "security.fileuri.strict_origin_policy": false,
32
+ "security.warn_entering_secure": false,
33
+ "security.warn_entering_secure.show_once": false,
34
+ "security.warn_entering_weak": false,
35
+ "security.warn_entering_weak.show_once": false,
36
+ "security.warn_leaving_secure": false,
37
+ "security.warn_leaving_secure.show_once": false,
38
+ "security.warn_submit_insecure": false,
39
+ "security.warn_viewing_mixed": false,
40
+ "security.warn_viewing_mixed.show_once": false,
41
+ "signon.rememberSignons": false,
42
+ "toolkit.networkmanager.disable": true,
43
+ "toolkit.telemetry.prompted": 2,
44
+ "toolkit.telemetry.enabled": false,
45
+ "toolkit.telemetry.rejected": true
46
+ },
47
+ "mutable": {
48
+ "browser.startup.page": 0,
49
+ "browser.startup.homepage": "about:blank",
50
+ "dom.max_script_run_time": 30
51
+ }
52
+ }
@@ -4,6 +4,7 @@ module Selenium
4
4
  class Profile
5
5
  include ProfileHelper
6
6
 
7
+ VALID_PREFERENCE_TYPES = [TrueClass, FalseClass, Integer, Float, String]
7
8
  WEBDRIVER_EXTENSION_PATH = File.expand_path("#{WebDriver.root}/selenium/webdriver/firefox/extension/webdriver.xpi")
8
9
  WEBDRIVER_PREFS = {
9
10
  :native_events => 'webdriver_enable_native_events',
@@ -24,6 +25,12 @@ module Selenium
24
25
  def from_name(name)
25
26
  ini[name]
26
27
  end
28
+
29
+ def default_preferences
30
+ @default_preferences ||= MultiJson.decode(
31
+ File.read(File.expand_path("#{WebDriver.root}/selenium/webdriver/firefox/extension/prefs.json"))
32
+ ).freeze
33
+ end
27
34
  end
28
35
 
29
36
  #
@@ -83,17 +90,12 @@ module Selenium
83
90
  #
84
91
 
85
92
  def []=(key, value)
86
- case value
87
- when String
88
- if Util.stringified?(value)
89
- raise ArgumentError, "preference values must be plain strings: #{key.inspect} => #{value.inspect}"
90
- end
93
+ unless VALID_PREFERENCE_TYPES.any? { |e| value.kind_of? e }
94
+ raise TypeError, "expected one of #{VALID_PREFERENCE_TYPES.inspect}, got #{value.inspect}:#{value.class}"
95
+ end
91
96
 
92
- value = MultiJson.encode(value)
93
- when TrueClass, FalseClass, Integer, Float
94
- value = value.to_s
95
- else
96
- raise TypeError, "invalid preference: #{value.inspect}:#{value.class}"
97
+ if value.kind_of?(String) && Util.stringified?(value)
98
+ raise ArgumentError, "preference values must be plain strings: #{key.inspect} => #{value.inspect}"
97
99
  end
98
100
 
99
101
  @additional_prefs[key.to_s] = value
@@ -216,9 +218,9 @@ module Selenium
216
218
  path = File.join(directory, 'user.js')
217
219
  prefs = read_user_prefs(path)
218
220
 
219
- prefs.merge! DEFAULT_PREFERENCES
221
+ prefs.merge! self.class.default_preferences.fetch 'mutable'
220
222
  prefs.merge! @additional_prefs
221
- prefs.merge! FROZEN_PREFERENCES
223
+ prefs.merge! self.class.default_preferences.fetch 'frozen'
222
224
 
223
225
  prefs[WEBDRIVER_PREFS[:untrusted_certs]] = !secure_ssl?
224
226
  prefs[WEBDRIVER_PREFS[:native_events]] = native_events?
@@ -231,13 +233,15 @@ module Selenium
231
233
  end
232
234
 
233
235
  def read_user_prefs(path)
234
- return {} unless File.exist?(path)
235
-
236
236
  prefs = {}
237
+ return prefs unless File.exist?(path)
237
238
 
238
239
  File.read(path).split("\n").each do |line|
239
240
  if line =~ /user_pref\("([^"]+)"\s*,\s*(.+?)\);/
240
- prefs[$1.strip] = $2.strip
241
+ key, value = $1.strip, $2.strip
242
+
243
+ # wrap the value in an array to make it a valid JSON string.
244
+ prefs[key] = MultiJson.decode("[#{value}]").first
241
245
  end
242
246
  end
243
247
 
@@ -247,68 +251,11 @@ module Selenium
247
251
  def write_prefs(prefs, path)
248
252
  File.open(path, "w") { |file|
249
253
  prefs.each do |key, value|
250
- p key => value if $DEBUG
251
- file.puts %{user_pref("#{key}", #{value});}
254
+ file.puts %{user_pref("#{key}", #{MultiJson.encode value});}
252
255
  end
253
256
  }
254
257
  end
255
258
 
256
- DEFAULT_PREFERENCES = {
257
- "browser.startup.page" => '0',
258
- "browser.startup.homepage" => '"about:blank"',
259
- "dom.max_script_run_time" => '30',
260
- }.freeze
261
-
262
-
263
- # Profile preferences that are essential to the Firefox driver operating
264
- # correctly. Users are not permitted to override these values.
265
-
266
- FROZEN_PREFERENCES = {
267
- "app.update.auto" => 'false',
268
- "app.update.enabled" => 'false',
269
- "browser.download.manager.showWhenStarting" => 'false',
270
- "browser.EULA.override" => 'true',
271
- "browser.EULA.3.accepted" => 'true',
272
- "browser.link.open_external" => '2',
273
- "browser.link.open_newwindow" => '2',
274
- "browser.safebrowsing.enabled" => 'false',
275
- "browser.safebrowsing.malware.enabled" => 'false',
276
- "browser.search.update" => 'false',
277
- "browser.sessionstore.resume_from_crash" => 'false',
278
- "browser.shell.checkDefaultBrowser" => 'false',
279
- "browser.tabs.warnOnClose" => 'false',
280
- "browser.tabs.warnOnOpen" => 'false',
281
- "devtools.errorconsole.enabled" => 'true',
282
- "dom.disable_open_during_load" => 'false',
283
- "extensions.autoDisableScopes" => '10',
284
- "extensions.logging.enabled" => 'true',
285
- "extensions.update.enabled" => 'false',
286
- "extensions.update.notifyUser" => 'false',
287
- "network.manage-offline-status" => 'false',
288
- "network.http.phishy-userpass-length" => '255',
289
- "network.http.max-connections-per-server" => '10',
290
- "offline-apps.allow_by_default" => 'true',
291
- "prompts.tab_modal.enabled" => "false",
292
- "security.warn_entering_secure" => 'false',
293
- "security.warn_submit_insecure" => 'false',
294
- "security.warn_entering_secure.show_once" => 'false',
295
- "security.warn_entering_weak" => 'false',
296
- "security.warn_entering_weak.show_once" => 'false',
297
- "security.warn_leaving_secure" => 'false',
298
- "security.warn_leaving_secure.show_once" => 'false',
299
- "security.warn_submit_insecure" => 'false',
300
- "security.warn_viewing_mixed" => 'false',
301
- "security.warn_viewing_mixed.show_once" => 'false',
302
- "signon.rememberSignons" => 'false',
303
- "toolkit.networkmanager.disable" => 'true',
304
- "toolkit.telemetry.prompted" => '2',
305
- "toolkit.telemetry.enabled" => 'false',
306
- "toolkit.telemetry.rejected" => 'true',
307
- "javascript.options.showInConsole" => 'true',
308
- "browser.dom.window.dump.enabled" => 'true',
309
- "dom.report_all_js_exceptions" => "true"
310
- }.freeze
311
-
312
259
  end # Profile
313
260
  end # Firefox
314
261
  end # WebDriver
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: selenium-webdriver
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 7
5
- version: 2.18.0.rc1
5
+ version: 2.18.0.rc2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jari Bakken
@@ -178,6 +178,7 @@ files:
178
178
  - lib/selenium/webdriver/firefox/profiles_ini.rb
179
179
  - lib/selenium/webdriver/firefox/socket_lock.rb
180
180
  - lib/selenium/webdriver/firefox/util.rb
181
+ - lib/selenium/webdriver/firefox/extension/prefs.json
181
182
  - lib/selenium/webdriver/firefox/extension/webdriver.xpi
182
183
  - lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so
183
184
  - lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so