browser 2.7.1 → 5.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +1 -1
  3. data/.github/workflows/tests.yml +57 -0
  4. data/.gitignore +1 -0
  5. data/.prettierignore +1 -0
  6. data/.rubocop.yml +13 -1
  7. data/CHANGELOG.md +122 -13
  8. data/FUNDING.yml +3 -0
  9. data/README.md +134 -88
  10. data/Rakefile +8 -1
  11. data/bot_exceptions.yml +1 -0
  12. data/bots.yml +300 -293
  13. data/browser.gemspec +4 -1
  14. data/gemfiles/{rails5.gemfile → rails6_1.gemfile} +1 -1
  15. data/lib/browser/accept_language.rb +4 -4
  16. data/lib/browser/aliases.rb +1 -1
  17. data/lib/browser/alipay.rb +1 -1
  18. data/lib/browser/base.rb +82 -18
  19. data/lib/browser/blackberry.rb +1 -1
  20. data/lib/browser/bot/empty_user_agent_matcher.rb +11 -0
  21. data/lib/browser/bot/keyword_matcher.rb +11 -0
  22. data/lib/browser/bot/known_bots_matcher.rb +11 -0
  23. data/lib/browser/bot.rb +34 -26
  24. data/lib/browser/browser.rb +59 -56
  25. data/lib/browser/chrome.rb +13 -3
  26. data/lib/browser/device/android.rb +1 -1
  27. data/lib/browser/device/blackberry_playbook.rb +1 -1
  28. data/lib/browser/device/ipad.rb +1 -1
  29. data/lib/browser/device/iphone.rb +1 -1
  30. data/lib/browser/device/ipod_touch.rb +1 -1
  31. data/lib/browser/device/kindle.rb +1 -1
  32. data/lib/browser/device/kindle_fire.rb +1 -1
  33. data/lib/browser/device/playstation3.rb +1 -1
  34. data/lib/browser/device/playstation4.rb +1 -1
  35. data/lib/browser/device/psp.rb +1 -1
  36. data/lib/browser/device/psvita.rb +1 -1
  37. data/lib/browser/device/samsung.rb +33 -0
  38. data/lib/browser/device/surface.rb +1 -1
  39. data/lib/browser/device/switch.rb +1 -1
  40. data/lib/browser/device/tv.rb +1 -1
  41. data/lib/browser/device/unknown.rb +1 -1
  42. data/lib/browser/device/wii.rb +1 -1
  43. data/lib/browser/device/wiiu.rb +1 -1
  44. data/lib/browser/device/xbox_360.rb +1 -1
  45. data/lib/browser/device/xbox_one.rb +1 -1
  46. data/lib/browser/device.rb +37 -27
  47. data/lib/browser/duck_duck_go.rb +22 -0
  48. data/lib/browser/edge.rb +3 -3
  49. data/lib/browser/electron.rb +1 -1
  50. data/lib/browser/facebook.rb +1 -1
  51. data/lib/browser/firefox.rb +1 -1
  52. data/lib/browser/google_search_app.rb +21 -0
  53. data/lib/browser/huawei_browser.rb +21 -0
  54. data/lib/browser/instagram.rb +1 -1
  55. data/lib/browser/internet_explorer.rb +2 -2
  56. data/lib/browser/maxthon.rb +21 -0
  57. data/lib/browser/meta/base.rb +0 -1
  58. data/lib/browser/meta.rb +12 -13
  59. data/lib/browser/micro_messenger.rb +1 -1
  60. data/lib/browser/middleware/context/additions.rb +1 -1
  61. data/lib/browser/middleware.rb +1 -1
  62. data/lib/browser/miui_browser.rb +21 -0
  63. data/lib/browser/nokia.rb +1 -1
  64. data/lib/browser/opera.rb +1 -1
  65. data/lib/browser/otter.rb +1 -1
  66. data/lib/browser/phantom_js.rb +1 -1
  67. data/lib/browser/platform/adobe_air.rb +1 -1
  68. data/lib/browser/platform/android.rb +1 -1
  69. data/lib/browser/platform/base.rb +3 -2
  70. data/lib/browser/platform/blackberry.rb +1 -1
  71. data/lib/browser/platform/chrome_os.rb +1 -1
  72. data/lib/browser/platform/firefox_os.rb +1 -1
  73. data/lib/browser/platform/ios.rb +2 -2
  74. data/lib/browser/platform/kai_os.rb +23 -0
  75. data/lib/browser/platform/linux.rb +1 -1
  76. data/lib/browser/platform/mac.rb +5 -3
  77. data/lib/browser/platform/{other.rb → unknown.rb} +3 -3
  78. data/lib/browser/platform/windows.rb +2 -2
  79. data/lib/browser/platform/windows_mobile.rb +1 -1
  80. data/lib/browser/platform/windows_phone.rb +1 -1
  81. data/lib/browser/platform.rb +37 -28
  82. data/lib/browser/qq.rb +1 -1
  83. data/lib/browser/rails.rb +3 -3
  84. data/lib/browser/safari.rb +16 -1
  85. data/lib/browser/samsung_browser.rb +21 -0
  86. data/lib/browser/snapchat.rb +1 -1
  87. data/lib/browser/sougou_browser.rb +24 -0
  88. data/lib/browser/sputnik.rb +2 -5
  89. data/lib/browser/uc_browser.rb +1 -1
  90. data/lib/browser/{generic.rb → unknown.rb} +3 -3
  91. data/lib/browser/version.rb +1 -1
  92. data/lib/browser/weibo.rb +1 -1
  93. data/lib/browser/yandex.rb +1 -1
  94. data/lib/browser.rb +2 -2
  95. data/samsung.yml +138 -0
  96. data/test/browser_test.rb +37 -10
  97. data/test/test_helper.rb +8 -0
  98. data/test/ua.yml +26 -3
  99. data/test/ua_bots.yml +9 -2
  100. data/test/ua_search_engines.yml +1 -0
  101. data/test/unit/accept_language_test.rb +6 -0
  102. data/test/unit/adobe_air_test.rb +1 -1
  103. data/test/unit/alipay_test.rb +6 -0
  104. data/test/unit/blackberry_test.rb +0 -6
  105. data/test/unit/bots_test.rb +26 -39
  106. data/test/unit/chrome_test.rb +8 -3
  107. data/test/unit/console_test.rb +2 -2
  108. data/test/unit/device_test.rb +30 -3
  109. data/test/unit/duck_duck_go_test.rb +37 -0
  110. data/test/unit/edge_test.rb +34 -6
  111. data/test/unit/firefox_test.rb +0 -3
  112. data/test/unit/google_search_app_test.rb +54 -0
  113. data/test/unit/huawei_browser_test.rb +25 -0
  114. data/test/unit/internet_explorer_test.rb +0 -12
  115. data/test/unit/ios_test.rb +0 -5
  116. data/test/unit/kai_os_test.rb +31 -0
  117. data/test/unit/kindle_test.rb +0 -2
  118. data/test/unit/maxthon_test.rb +25 -0
  119. data/test/unit/meta_test.rb +10 -2
  120. data/test/unit/micro_messenger_test.rb +21 -6
  121. data/test/unit/miui_browser_test.rb +25 -0
  122. data/test/unit/opera_test.rb +1 -2
  123. data/test/unit/platform_test.rb +13 -8
  124. data/test/unit/qq_test.rb +12 -0
  125. data/test/unit/safari_test.rb +12 -7
  126. data/test/unit/samsung_browser_test.rb +23 -0
  127. data/test/unit/sougou_browser_test.rb +41 -0
  128. data/test/unit/sputnik_test.rb +1 -0
  129. metadata +46 -16
  130. data/.bundle/config +0 -2
  131. data/.travis.yml +0 -23
  132. data/lib/browser/meta/modern.rb +0 -11
  133. /data/gemfiles/{rails6.gemfile → rails6_0.gemfile} +0 -0
@@ -4,7 +4,7 @@ module Browser
4
4
  class Platform
5
5
  class Windows < Base
6
6
  def version
7
- ua[/Windows NT\s*([0-9_\.]+)?/, 1] || "0"
7
+ ua[/Windows NT\s*([0-9_.]+)?/, 1] || "0"
8
8
  end
9
9
 
10
10
  def name
@@ -16,7 +16,7 @@ module Browser
16
16
  end
17
17
 
18
18
  def match?
19
- ua =~ /Windows/
19
+ ua.include?("Windows")
20
20
  end
21
21
  end
22
22
  end
@@ -16,7 +16,7 @@ module Browser
16
16
  end
17
17
 
18
18
  def match?
19
- ua =~ /Windows CE/
19
+ ua.include?("Windows CE")
20
20
  end
21
21
  end
22
22
  end
@@ -16,7 +16,7 @@ module Browser
16
16
  end
17
17
 
18
18
  def match?
19
- ua =~ /Windows Phone/
19
+ ua.include?("Windows Phone")
20
20
  end
21
21
  end
22
22
  end
@@ -1,18 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "browser/platform/base"
4
- require "browser/platform/ios"
5
- require "browser/platform/linux"
6
- require "browser/platform/windows"
7
- require "browser/platform/mac"
8
- require "browser/platform/windows_phone"
9
- require "browser/platform/windows_mobile"
10
- require "browser/platform/firefox_os"
11
- require "browser/platform/blackberry"
12
- require "browser/platform/android"
13
- require "browser/platform/other"
14
- require "browser/platform/chrome_os"
15
- require "browser/platform/adobe_air"
3
+ require_relative "platform/base"
4
+ require_relative "platform/ios"
5
+ require_relative "platform/linux"
6
+ require_relative "platform/windows"
7
+ require_relative "platform/mac"
8
+ require_relative "platform/windows_phone"
9
+ require_relative "platform/windows_mobile"
10
+ require_relative "platform/firefox_os"
11
+ require_relative "platform/blackberry"
12
+ require_relative "platform/android"
13
+ require_relative "platform/unknown"
14
+ require_relative "platform/chrome_os"
15
+ require_relative "platform/adobe_air"
16
+ require_relative "platform/kai_os"
16
17
 
17
18
  module Browser
18
19
  class Platform
@@ -32,10 +33,11 @@ module Browser
32
33
  BlackBerry,
33
34
  IOS,
34
35
  Mac,
36
+ KaiOS,
35
37
  FirefoxOS,
36
38
  Windows,
37
39
  Linux,
38
- Other
40
+ Unknown
39
41
  ]
40
42
  end
41
43
 
@@ -45,7 +47,7 @@ module Browser
45
47
 
46
48
  def subject
47
49
  @subject ||= self.class.matchers
48
- .map {|matcher| matcher.new(ua) }
50
+ .map {|matcher| matcher.new(ua, self) }
49
51
  .find(&:match?)
50
52
  end
51
53
 
@@ -61,8 +63,8 @@ module Browser
61
63
  id == :android && detect_version?(version, expected_version)
62
64
  end
63
65
 
64
- def other?
65
- id == :other
66
+ def unknown?
67
+ id == :unknown_platform
66
68
  end
67
69
 
68
70
  def linux?
@@ -81,6 +83,10 @@ module Browser
81
83
  id == :firefox_os
82
84
  end
83
85
 
86
+ def kai_os?
87
+ id == :kai_os
88
+ end
89
+
84
90
  def ios?(expected_version = nil)
85
91
  id == :ios && detect_version?(version, expected_version)
86
92
  end
@@ -130,46 +136,46 @@ module Browser
130
136
  # Detect if in an Android app webview (Lollipop and newer)
131
137
  # https://developer.chrome.com/multidevice/user-agent#webview_user_agent
132
138
  def android_app?
133
- android? && ua =~ /\bwv\b/
139
+ android? && ua.match?(/\bwv\b/)
134
140
  end
135
141
  alias_method :android_webview?, :android_app?
136
142
 
137
143
  # http://msdn.microsoft.com/fr-FR/library/ms537503.aspx#PltToken
138
144
  def windows_xp?
139
- windows? && ua =~ /Windows NT 5\.[12]/
145
+ windows? && ua.match?(/Windows NT 5\.[12]/)
140
146
  end
141
147
 
142
148
  def windows_vista?
143
- windows? && ua =~ /Windows NT 6\.0/
149
+ windows? && ua.include?("Windows NT 6.0")
144
150
  end
145
151
 
146
152
  def windows7?
147
- windows? && ua =~ /Windows NT 6\.1/
153
+ windows? && ua.include?("Windows NT 6.1")
148
154
  end
149
155
 
150
156
  def windows8?
151
- windows? && ua =~ /Windows NT 6\.[2-3]/
157
+ windows? && ua.match?(/Windows NT 6\.[2-3]/)
152
158
  end
153
159
 
154
160
  def windows8_1?
155
- windows? && ua =~ /Windows NT 6\.3/
161
+ windows? && ua.include?("Windows NT 6.3")
156
162
  end
157
163
 
158
164
  def windows10?
159
- windows? && ua =~ /Windows NT 10/
165
+ windows? && ua.include?("Windows NT 10")
160
166
  end
161
167
 
162
168
  def windows_rt?
163
- windows8? && ua =~ /ARM/
169
+ windows8? && ua.include?("ARM")
164
170
  end
165
171
 
166
172
  # Detect if current platform is Windows in 64-bit architecture.
167
173
  def windows_x64?
168
- windows? && ua =~ /(Win64|x64|Windows NT 5\.2)/
174
+ windows? && ua.match?(/(Win64|x64|Windows NT 5\.2)/)
169
175
  end
170
176
 
171
177
  def windows_wow64?
172
- windows? && ua =~ /WOW64/i
178
+ windows? && ua.match?(/WOW64/i)
173
179
  end
174
180
 
175
181
  def windows_x64_inclusive?
@@ -177,7 +183,10 @@ module Browser
177
183
  end
178
184
 
179
185
  def windows_touchscreen_desktop?
180
- windows? && ua =~ /Touch/
186
+ windows? && ua.include?("Touch")
181
187
  end
188
+
189
+ private :subject
190
+ private :ua
182
191
  end
183
192
  end
data/lib/browser/qq.rb CHANGED
@@ -19,7 +19,7 @@ module Browser
19
19
  end
20
20
 
21
21
  def match?
22
- ua =~ /QQ/i
22
+ ua.match?(%r{QQ/|QQBrowser}i)
23
23
  end
24
24
  end
25
25
  end
data/lib/browser/rails.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rails/railtie"
4
- require "browser/action_controller"
5
- require "browser/middleware/context/additions"
4
+ require_relative "action_controller"
5
+ require_relative "middleware/context/additions"
6
6
 
7
7
  module Browser
8
8
  class Railtie < Rails::Railtie
@@ -12,7 +12,7 @@ module Browser
12
12
  ActiveSupport.on_load(:action_controller) do
13
13
  ::ActionController::Base.include(Browser::ActionController)
14
14
 
15
- ::ActionController::Metal.include(Browser::ActionController) if defined?(::ActionController::Metal) # rubocop:disable Metrics/LineLength
15
+ ::ActionController::Metal.include(Browser::ActionController) if defined?(::ActionController::Metal) # rubocop:disable Layout/LineLength
16
16
 
17
17
  Browser::Middleware::Context.include(
18
18
  Browser::Middleware::Context::Additions
@@ -18,7 +18,22 @@ module Browser
18
18
  end
19
19
 
20
20
  def match?
21
- ua =~ /Safari/ && ua !~ /Chrome|CriOS|PhantomJS|FxiOS|YaBrowser/
21
+ ua.include?("Safari") &&
22
+ !ua.match?(/PhantomJS|FxiOS/) &&
23
+ !edge? &&
24
+ !chrome? &&
25
+ !opera? &&
26
+ !samsung_browser? &&
27
+ !huawei_browser? &&
28
+ !miui_browser? &&
29
+ !duck_duck_go? &&
30
+ !yandex? &&
31
+ !sputnik? &&
32
+ !maxthon? &&
33
+ !qq? &&
34
+ !alipay? &&
35
+ !sougou_browser? &&
36
+ !google_search_app?
22
37
  end
23
38
  end
24
39
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Browser
4
+ class SamsungBrowser < Chrome
5
+ def id
6
+ :samsung_browser
7
+ end
8
+
9
+ def name
10
+ "Samsung Browser"
11
+ end
12
+
13
+ def full_version
14
+ ua[%r{SamsungBrowser/([\d.]+)}, 1] || super
15
+ end
16
+
17
+ def match?
18
+ ua.include?("SamsungBrowser")
19
+ end
20
+ end
21
+ end
@@ -15,7 +15,7 @@ module Browser
15
15
  end
16
16
 
17
17
  def match?
18
- ua =~ /Snapchat/
18
+ ua.include?("Snapchat")
19
19
  end
20
20
  end
21
21
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Browser
4
+ class SougouBrowser < Base
5
+ def id
6
+ :sougou_browser
7
+ end
8
+
9
+ def name
10
+ "Sougou Browser"
11
+ end
12
+
13
+ # We can't get the real version on desktop device from the ua string
14
+ def full_version
15
+ ua[%r{(?:SogouMobileBrowser)/([\d.]+)}, 1] || "0.0"
16
+ end
17
+
18
+ # SogouMobileBrowser for mobile device
19
+ # SE for desktop device
20
+ def match?
21
+ ua.match?(/SogouMobileBrowser/i) || ua.match?(/\bSE\b/)
22
+ end
23
+ end
24
+ end
@@ -11,14 +11,11 @@ module Browser
11
11
  end
12
12
 
13
13
  def full_version
14
- # Each regex on its own line to enforce precedence.
15
- ua[%r{SputnikBrowser/([\d.]+)}, 1] ||
16
- ua[%r{Chrome/([\d.]+)}, 1] ||
17
- "0.0"
14
+ ua[%r{SputnikBrowser/([\d.]+)}, 1] || "0.0"
18
15
  end
19
16
 
20
17
  def match?
21
- ua =~ /SputnikBrowser/
18
+ ua.include?("SputnikBrowser")
22
19
  end
23
20
  end
24
21
  end
@@ -15,7 +15,7 @@ module Browser
15
15
  end
16
16
 
17
17
  def match?
18
- ua =~ /UCBrowser/
18
+ ua.include?("UCBrowser")
19
19
  end
20
20
  end
21
21
  end
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Browser
4
- class Generic < Base
4
+ class Unknown < Base
5
5
  NAMES = {
6
6
  "QuickTime" => "QuickTime",
7
7
  "CoreMedia" => "Apple CoreMedia"
8
8
  }.freeze
9
9
 
10
10
  def id
11
- :generic
11
+ :unknown_browser
12
12
  end
13
13
 
14
14
  def name
15
- infer_name || "Generic Browser"
15
+ infer_name || "Unknown Browser"
16
16
  end
17
17
 
18
18
  def full_version
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Browser
4
- VERSION = "2.7.1"
4
+ VERSION = "5.3.1"
5
5
  end
data/lib/browser/weibo.rb CHANGED
@@ -15,7 +15,7 @@ module Browser
15
15
  end
16
16
 
17
17
  def match?
18
- ua =~ /__weibo__/i
18
+ ua.match?(/__weibo__/i)
19
19
  end
20
20
  end
21
21
  end
@@ -15,7 +15,7 @@ module Browser
15
15
  end
16
16
 
17
17
  def match?
18
- ua =~ /YaBrowser/
18
+ ua.include?("YaBrowser")
19
19
  end
20
20
  end
21
21
  end
data/lib/browser.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "browser/browser"
4
- require "browser/rails" if defined?(::Rails)
3
+ require_relative "browser/browser"
4
+ require_relative "browser/rails" if defined?(::Rails)
data/samsung.yml ADDED
@@ -0,0 +1,138 @@
1
+ # Source: https://en.wikipedia.org/wiki/Samsung_Galaxy
2
+ SM-G900H: Galaxy S5 Exynos
3
+ SM-A320FL: Galaxy A3
4
+ SM-G780F: Galaxy S20 Fan Edition
5
+ SM-G781B: Galaxy S20 Fan Edition
6
+ SM-F196B: Galaxy Z Fold2 5G
7
+ SM-G928A: Galaxy S6 Edge+
8
+ SM-G928AZ: Galaxy S6 Edge+
9
+ SM-G928D: Galaxy S6 Edge+
10
+ SM-G928F: Galaxy S6 Edge+
11
+ SM-G928FD: Galaxy S6 Edge+
12
+ SM-G928I: Galaxy S6 Edge+
13
+ SM-G928K: Galaxy S6 Edge+
14
+ SM-G928L: Galaxy S6 Edge+
15
+ SM-G928P: Galaxy S6 Edge+
16
+ SM-G928PZ: Galaxy S6 Edge+
17
+ SM-G928R4: Galaxy S6 Edge+
18
+ SM-G928R7: Galaxy S6 Edge+
19
+ SM-G928S: Galaxy S6 Edge+
20
+ SM-G928T: Galaxy S6 Edge+
21
+ SM-G928T1: Galaxy S6 Edge+
22
+ SM-G928TR: Galaxy S6 Edge+
23
+ SM-G928V: Galaxy S6 Edge+
24
+ SM-G9280: Galaxy S6 Edge+
25
+ SM-G9288: Galaxy S6 Edge+
26
+ SM-G9289: Galaxy S6 Edge+
27
+ SM-A8000: Galaxy A8
28
+ SM-A800F: Galaxy A8
29
+ SM-A800I: Galaxy A8
30
+ SM-A800S: Galaxy A8
31
+ SM-A800Y: Galaxy A8
32
+ SM-N9200: Galaxy Note 5
33
+ SM-N920C: Galaxy Note 5
34
+ SM-N920T: Galaxy Note 5
35
+ SM-N920A: Galaxy Note 5
36
+ SM-N920I: Galaxy Note 5
37
+ SM-N9208: Galaxy Note 5
38
+ SM-G903FP: Galaxy S5 Neo
39
+ SM-G903WP: Galaxy S5 Neo
40
+ SM-G925A: Galaxy S6 Edge
41
+ SM-G925AZ: Galaxy S6 Edge
42
+ SM-G925F: Galaxy S6 Edge
43
+ SM-G925I: Galaxy S6 Edge
44
+ SM-G925K: Galaxy S6 Edge
45
+ SM-G925L: Galaxy S6 Edge
46
+ SM-G925P: Galaxy S6 Edge
47
+ SM-G925PZ: Galaxy S6 Edge
48
+ SM-G925R4: Galaxy S6 Edge
49
+ SM-G925R7: Galaxy S6 Edge
50
+ SM-G925S: Galaxy S6 Edge
51
+ SM-G925T: Galaxy S6 Edge
52
+ SM-G925T1: Galaxy S6 Edge
53
+ SM-G925TR: Galaxy S6 Edge
54
+ SM-G925V: Galaxy S6 Edge
55
+ SM-G9250: Galaxy S6 Edge
56
+ SM-G9258: Galaxy S6 Edge
57
+ SM-G9259: Galaxy S6 Edge
58
+ SM-G920A: Galaxy S6
59
+ SM-G920AZ: Galaxy S6
60
+ SM-G920D: Galaxy S6
61
+ SM-G920F: Galaxy S6
62
+ SM-G920FD: Galaxy S6
63
+ SM-G920I: Galaxy S6
64
+ SM-G920K: Galaxy S6
65
+ SM-G920L: Galaxy S6
66
+ SM-G920P: Galaxy S6
67
+ SM-G920PZ: Galaxy S6
68
+ SM-G920R4: Galaxy S6
69
+ SM-G920R7: Galaxy S6
70
+ SM-G920S: Galaxy S6
71
+ SM-G920T: Galaxy S6
72
+ SM-G920T1: Galaxy S6
73
+ SM-G920TR: Galaxy S6
74
+ SM-G920V: Galaxy S6
75
+ SM-G9200: Galaxy S6
76
+ SM-G9208: Galaxy S6
77
+ SM-G9209: Galaxy S6
78
+ SM-A700F: Galaxy A7
79
+ SM-A700FD: Galaxy A7
80
+ SM-A700FQ: Galaxy A7
81
+ SM-A700H: Galaxy A7
82
+ SM-A700K: Galaxy A7
83
+ SM-A700L: Galaxy A7
84
+ SM-A700M: Galaxy A7
85
+ SM-A700S: Galaxy A7
86
+ SM-A700X: Galaxy A7
87
+ SM-A700YD: Galaxy A7
88
+ SM-A700YZ: Galaxy A7
89
+ SM-A7000: Galaxy A7
90
+ SM-A7009: Galaxy A7
91
+ SM-A7009W: Galaxy A7
92
+ SM-G530BT: Galaxy Grand Prime
93
+ SM-G530F: Galaxy Grand Prime
94
+ SM-G530FQ: Galaxy Grand Prime
95
+ SM-G530FZ: Galaxy Grand Prime
96
+ SM-G530H: Galaxy Grand Prime
97
+ SM-G530M: Galaxy Grand Prime
98
+ SM-G530MU: Galaxy Grand Prime
99
+ SM-G530P: Galaxy Grand Prime
100
+ SM-G530R4: Galaxy Grand Prime
101
+ SM-G530R7: Galaxy Grand Prime
102
+ SM-G530T: Galaxy Grand Prime
103
+ SM-G530W: Galaxy Grand Prime
104
+ SM-G530Y: Galaxy Grand Prime
105
+ SM-G5306W: Galaxy Grand Prime
106
+ SM-G5308W: Galaxy Grand Prime
107
+ SM-G5309W: Galaxy Grand Prime
108
+ SM-J7109: Galaxy J7
109
+ SM-J710F: Galaxy J7
110
+ SM-J710FN: Galaxy J7
111
+ SM-J710H: Galaxy J7
112
+ SM-J710MN: Galaxy J7
113
+ SM-J710FQ: Galaxy J7
114
+ SM-J710K: Galaxy J7
115
+ SM-J710K: Galaxy J7
116
+ SM-J710GN: Galaxy J7
117
+ SM-J5109: Galaxy J5
118
+ SM-J510F: Galaxy J5
119
+ SM-J510FN: Galaxy J5
120
+ SM-J510H: Galaxy J5
121
+ SM-J510G: Galaxy J5
122
+ SM-J510MN: Galaxy J5
123
+ SM-J510Y: Galaxy J5
124
+ SM-J5108: Galaxy J5
125
+ SM-J510K: Galaxy J5
126
+ SM-J510L: Galaxy J5
127
+ SM-J510S: Galaxy J5
128
+ SM-J510UN: Galaxy J5
129
+ SM-G570F: Galaxy J2 Prime
130
+ SM-G570M: Galaxy J2 Prime
131
+ SM-G532F: Galaxy J2 Prime
132
+ SM-G532M: Galaxy J2 Prime
133
+ SM-G532G: Galaxy J2 Prime
134
+ SM-G610F: Galaxy J7 Prime
135
+ SM-G610M: Galaxy J7 Prime
136
+ SM-G975F: Galaxy S10+
137
+ SM-G960F: Galaxy S9
138
+ SM-F700F: Galaxy Z Flip
data/test/browser_test.rb CHANGED
@@ -39,7 +39,6 @@ class BrowserTest < Minitest::Test
39
39
  assert browser.platform.android?
40
40
  assert browser.safari?
41
41
  assert browser.webkit?
42
- assert browser.modern?
43
42
  assert_equal "3.1.2", browser.full_version
44
43
  assert_equal "3", browser.version
45
44
  end
@@ -51,7 +50,6 @@ class BrowserTest < Minitest::Test
51
50
  assert browser.platform.android?
52
51
  assert browser.safari?
53
52
  assert browser.webkit?
54
- assert browser.modern?
55
53
  assert_equal "4.0", browser.full_version
56
54
  assert_equal "4", browser.version
57
55
  end
@@ -62,7 +60,6 @@ class BrowserTest < Minitest::Test
62
60
  assert_equal "Internet Explorer", browser.name
63
61
  assert browser.device.surface?
64
62
  assert browser.ie?
65
- assert browser.modern?
66
63
  assert_equal "10.0", browser.full_version
67
64
  assert_equal "10", browser.version
68
65
  end
@@ -93,7 +90,6 @@ class BrowserTest < Minitest::Test
93
90
  assert_equal "PhantomJS", browser.name
94
91
  assert_equal :phantom_js, browser.id
95
92
  assert browser.phantom_js?
96
- assert browser.modern?
97
93
  assert_equal "1.9.0", browser.full_version
98
94
  assert_equal "1", browser.version
99
95
  assert browser.phantom_js?(%w[>=1 <2])
@@ -110,14 +106,13 @@ class BrowserTest < Minitest::Test
110
106
  refute browser.chrome?(">=65")
111
107
  end
112
108
 
113
- test "detects unknown id" do
109
+ test "detects unknown browser" do
114
110
  browser = Browser.new("Unknown")
115
- assert_equal :generic, browser.id
116
- end
117
111
 
118
- test "detects unknown name" do
119
- browser = Browser.new("Unknown")
120
- assert_equal "Generic Browser", browser.name
112
+ assert browser.unknown?
113
+ refute browser.known?
114
+ assert_equal :unknown_browser, browser.id
115
+ assert_equal "Unknown Browser", browser.name
121
116
  end
122
117
 
123
118
  test "returns empty language set for missing accept language" do
@@ -159,4 +154,36 @@ class BrowserTest < Minitest::Test
159
154
  browser = Browser.new("Fancy new browser")
160
155
  refute browser.known?
161
156
  end
157
+
158
+ test "rejects user agent larger than 2048 bytes" do
159
+ message = "user_agent cannot be larger than 2048 bytes; actual size is " \
160
+ "2049 bytes"
161
+
162
+ error =
163
+ begin
164
+ Browser.new("a" * 2049)
165
+ nil
166
+ rescue Browser::Error => error
167
+ error
168
+ end
169
+
170
+ refute_nil error
171
+ assert_equal message, error.message
172
+ end
173
+
174
+ test "rejects accept language larger than 2048 bytes" do
175
+ message = "accept_language cannot be larger than 2048 bytes; actual size " \
176
+ "is 2049 bytes"
177
+
178
+ error =
179
+ begin
180
+ Browser.new("Chrome", accept_language: "a" * 2049).accept_language
181
+ nil
182
+ rescue Browser::Error => error
183
+ error
184
+ end
185
+
186
+ refute_nil error
187
+ assert_equal message, error.message
188
+ end
162
189
  end
data/test/test_helper.rb CHANGED
@@ -24,3 +24,11 @@ module Minitest
24
24
  end
25
25
  end
26
26
  end
27
+
28
+ # Override Browser::Base#warn, so we don't output deprecation messages.
29
+ module Browser
30
+ class Base
31
+ def warn(*)
32
+ end
33
+ end
34
+ end