browser 2.5.3 → 5.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +1 -1
- data/.github/workflows/tests.yml +57 -0
- data/.gitignore +1 -0
- data/.prettierignore +1 -0
- data/.rubocop.yml +22 -107
- data/CHANGELOG.md +170 -6
- data/FUNDING.yml +3 -0
- data/Gemfile +2 -0
- data/README.md +139 -89
- data/Rakefile +11 -2
- data/bot_exceptions.yml +2 -0
- data/bots.yml +302 -265
- data/browser.gemspec +12 -7
- data/gemfiles/rails6_0.gemfile +6 -0
- data/gemfiles/rails6_1.gemfile +6 -0
- data/lib/browser/accept_language.rb +6 -9
- data/lib/browser/action_controller.rb +1 -3
- data/lib/browser/aliases.rb +5 -5
- data/lib/browser/alipay.rb +2 -2
- data/lib/browser/base.rb +101 -19
- data/lib/browser/blackberry.rb +3 -3
- data/lib/browser/bot/empty_user_agent_matcher.rb +11 -0
- data/lib/browser/bot/keyword_matcher.rb +11 -0
- data/lib/browser/bot/known_bots_matcher.rb +11 -0
- data/lib/browser/bot.rb +39 -27
- data/lib/browser/browser.rb +65 -54
- data/lib/browser/chrome.rb +18 -5
- data/lib/browser/detect_version.rb +5 -5
- data/lib/browser/device/android.rb +20 -0
- data/lib/browser/device/blackberry_playbook.rb +1 -1
- data/lib/browser/device/ipad.rb +1 -1
- data/lib/browser/device/iphone.rb +1 -1
- data/lib/browser/device/ipod_touch.rb +1 -1
- data/lib/browser/device/kindle.rb +1 -1
- data/lib/browser/device/kindle_fire.rb +1 -1
- data/lib/browser/device/playstation3.rb +1 -1
- data/lib/browser/device/playstation4.rb +1 -1
- data/lib/browser/device/psp.rb +1 -1
- data/lib/browser/device/psvita.rb +1 -1
- data/lib/browser/device/samsung.rb +33 -0
- data/lib/browser/device/surface.rb +2 -4
- data/lib/browser/device/switch.rb +19 -0
- data/lib/browser/device/tv.rb +1 -1
- data/lib/browser/device/unknown.rb +1 -1
- data/lib/browser/device/wii.rb +1 -1
- data/lib/browser/device/wiiu.rb +1 -1
- data/lib/browser/device/xbox_360.rb +1 -1
- data/lib/browser/device/xbox_one.rb +1 -1
- data/lib/browser/device.rb +47 -30
- data/lib/browser/duck_duck_go.rb +22 -0
- data/lib/browser/edge.rb +6 -2
- data/lib/browser/electron.rb +2 -2
- data/lib/browser/facebook.rb +4 -2
- data/lib/browser/firefox.rb +2 -2
- data/lib/browser/google_search_app.rb +21 -0
- data/lib/browser/huawei_browser.rb +21 -0
- data/lib/browser/instagram.rb +21 -0
- data/lib/browser/internet_explorer.rb +9 -10
- data/lib/browser/maxthon.rb +21 -0
- data/lib/browser/meta/base.rb +0 -1
- data/lib/browser/meta/generic_browser.rb +1 -3
- data/lib/browser/meta.rb +12 -13
- data/lib/browser/micro_messenger.rb +2 -2
- data/lib/browser/middleware/context/additions.rb +1 -1
- data/lib/browser/middleware.rb +4 -3
- data/lib/browser/miui_browser.rb +21 -0
- data/lib/browser/nokia.rb +2 -2
- data/lib/browser/opera.rb +2 -2
- data/lib/browser/otter.rb +2 -2
- data/lib/browser/phantom_js.rb +2 -2
- data/lib/browser/platform/adobe_air.rb +2 -2
- data/lib/browser/platform/android.rb +1 -1
- data/lib/browser/platform/base.rb +3 -2
- data/lib/browser/platform/blackberry.rb +2 -2
- data/lib/browser/platform/chrome_os.rb +1 -1
- data/lib/browser/platform/firefox_os.rb +1 -1
- data/lib/browser/platform/ios.rb +17 -4
- data/lib/browser/platform/kai_os.rb +23 -0
- data/lib/browser/platform/linux.rb +1 -1
- data/lib/browser/platform/mac.rb +5 -3
- data/lib/browser/platform/{other.rb → unknown.rb} +3 -3
- data/lib/browser/platform/windows.rb +2 -2
- data/lib/browser/platform/windows_mobile.rb +1 -1
- data/lib/browser/platform/windows_phone.rb +1 -1
- data/lib/browser/platform.rb +37 -28
- data/lib/browser/qq.rb +5 -5
- data/lib/browser/rails.rb +7 -5
- data/lib/browser/safari.rb +19 -4
- data/lib/browser/samsung_browser.rb +21 -0
- data/lib/browser/snapchat.rb +21 -0
- data/lib/browser/sougou_browser.rb +24 -0
- data/lib/browser/sputnik.rb +21 -0
- data/lib/browser/uc_browser.rb +2 -2
- data/lib/browser/{generic.rb → unknown.rb} +6 -8
- data/lib/browser/version.rb +1 -1
- data/lib/browser/weibo.rb +2 -2
- data/lib/browser/yandex.rb +21 -0
- data/lib/browser.rb +2 -2
- data/samsung.yml +138 -0
- data/search_engines.yml +2 -2
- data/test/browser_test.rb +42 -10
- data/test/rails_test.rb +10 -0
- data/test/sample_app.rb +14 -0
- data/test/test_helper.rb +9 -1
- data/test/ua.yml +147 -109
- data/test/ua_bots.yml +95 -60
- data/test/ua_search_engines.yml +7 -6
- data/test/unit/accept_language_test.rb +16 -0
- data/test/unit/adobe_air_test.rb +1 -1
- data/test/unit/alipay_test.rb +6 -0
- data/test/unit/blackberry_test.rb +0 -6
- data/test/unit/bots_test.rb +37 -36
- data/test/unit/chrome_test.rb +8 -19
- data/test/unit/console_test.rb +2 -2
- data/test/unit/device_test.rb +60 -3
- data/test/unit/duck_duck_go_test.rb +37 -0
- data/test/unit/edge_test.rb +49 -5
- data/test/unit/facebook_test.rb +20 -0
- data/test/unit/firefox_test.rb +0 -3
- data/test/unit/google_search_app_test.rb +54 -0
- data/test/unit/huawei_browser_test.rb +25 -0
- data/test/unit/instagram_test.rb +30 -0
- data/test/unit/internet_explorer_test.rb +0 -12
- data/test/unit/ios_test.rb +7 -5
- data/test/unit/kai_os_test.rb +31 -0
- data/test/unit/kindle_test.rb +0 -2
- data/test/unit/maxthon_test.rb +25 -0
- data/test/unit/meta_test.rb +10 -2
- data/test/unit/micro_messenger_test.rb +21 -6
- data/test/unit/miui_browser_test.rb +25 -0
- data/test/unit/opera_test.rb +1 -2
- data/test/unit/platform_test.rb +34 -8
- data/test/unit/qq_test.rb +12 -0
- data/test/unit/safari_test.rb +12 -7
- data/test/unit/samsung_browser_test.rb +23 -0
- data/test/unit/snapchat_test.rb +40 -0
- data/test/unit/sougou_browser_test.rb +41 -0
- data/test/unit/sputnik_test.rb +22 -0
- data/test/unit/yandex_test.rb +37 -0
- metadata +83 -27
- data/.bundle/config +0 -2
- data/.travis.yml +0 -16
- data/bin/rake +0 -17
- data/gemfiles/rails4.gemfile +0 -4
- data/gemfiles/rails5.gemfile +0 -4
- data/lib/browser/meta/modern.rb +0 -11
@@ -131,6 +131,16 @@ class AcceptLanguageTest < Minitest::Test
|
|
131
131
|
assert_language result[4], code: "fr", region: nil, quality: 0.2
|
132
132
|
end
|
133
133
|
|
134
|
+
test "sorts the same quality in a descending priority" do
|
135
|
+
accept_language = "fr-CA,fr;q=0.2,en-US;q=0.2,en"
|
136
|
+
result = Browser::AcceptLanguage.parse(accept_language)
|
137
|
+
|
138
|
+
assert_language result[0], code: "fr", region: "CA", quality: 1.0
|
139
|
+
assert_language result[1], code: "en", region: nil, quality: 1.0
|
140
|
+
assert_language result[2], code: "fr", region: nil, quality: 0.2
|
141
|
+
assert_language result[3], code: "en", region: "US", quality: 0.2
|
142
|
+
end
|
143
|
+
|
134
144
|
test "rejects quality values equals to zero (#241)" do
|
135
145
|
result = Browser::AcceptLanguage.parse("de-DE,ru;q=0.9,de;q=0.8,en;q=0.")
|
136
146
|
|
@@ -147,4 +157,10 @@ class AcceptLanguageTest < Minitest::Test
|
|
147
157
|
assert_equal 5, result.size
|
148
158
|
assert_language result[3], code: "de", region: nil, quality: 0.7
|
149
159
|
end
|
160
|
+
|
161
|
+
test "sets default quality value for invalid strings" do
|
162
|
+
result = Browser::AcceptLanguage.parse(";q=0.0.0.0")
|
163
|
+
|
164
|
+
assert_equal 0.1, result[0].quality
|
165
|
+
end
|
150
166
|
end
|
data/test/unit/adobe_air_test.rb
CHANGED
@@ -9,7 +9,7 @@ class AdobeAirTest < Minitest::Test
|
|
9
9
|
assert browser.webkit?
|
10
10
|
assert_equal "0", browser.version
|
11
11
|
assert_equal "0.0", browser.full_version
|
12
|
-
assert_equal "
|
12
|
+
assert_equal "Unknown Browser", browser.name
|
13
13
|
assert_equal "Adobe AIR", browser.platform.name
|
14
14
|
assert_equal "13.0", browser.platform.version
|
15
15
|
end
|
data/test/unit/alipay_test.rb
CHANGED
@@ -10,6 +10,9 @@ class AlipayTest < Minitest::Test
|
|
10
10
|
assert browser.alipay?
|
11
11
|
assert_equal "Alipay", browser.name
|
12
12
|
assert_equal "2.3.4", browser.full_version
|
13
|
+
|
14
|
+
refute browser.chrome?
|
15
|
+
refute browser.safari?
|
13
16
|
end
|
14
17
|
|
15
18
|
test "detects alipay Android" do
|
@@ -19,6 +22,9 @@ class AlipayTest < Minitest::Test
|
|
19
22
|
assert browser.alipay?
|
20
23
|
assert_equal "Alipay", browser.name
|
21
24
|
assert_equal "9.0.1.073001", browser.full_version
|
25
|
+
|
26
|
+
refute browser.chrome?
|
27
|
+
refute browser.safari?
|
22
28
|
end
|
23
29
|
|
24
30
|
test "detects version by range" do
|
@@ -9,7 +9,6 @@ class BlackberryTest < Minitest::Test
|
|
9
9
|
assert_equal "BlackBerry", browser.name
|
10
10
|
refute browser.device.tablet?
|
11
11
|
assert browser.device.mobile?
|
12
|
-
refute browser.modern?
|
13
12
|
assert_equal "4.1.0", browser.full_version
|
14
13
|
assert_equal "4", browser.version
|
15
14
|
end
|
@@ -18,7 +17,6 @@ class BlackberryTest < Minitest::Test
|
|
18
17
|
browser = Browser.new(Browser["BLACKBERRY4"])
|
19
18
|
|
20
19
|
assert_equal "BlackBerry", browser.name
|
21
|
-
refute browser.modern?
|
22
20
|
assert_equal "4.2.1", browser.full_version
|
23
21
|
assert_equal "4", browser.version
|
24
22
|
end
|
@@ -29,7 +27,6 @@ class BlackberryTest < Minitest::Test
|
|
29
27
|
assert_equal "BlackBerry", browser.name
|
30
28
|
refute browser.device.tablet?
|
31
29
|
assert browser.device.mobile?
|
32
|
-
refute browser.modern?
|
33
30
|
assert_equal "5.0.0.93", browser.full_version
|
34
31
|
assert_equal "5", browser.version
|
35
32
|
end
|
@@ -40,7 +37,6 @@ class BlackberryTest < Minitest::Test
|
|
40
37
|
assert_equal "BlackBerry", browser.name
|
41
38
|
refute browser.device.tablet?
|
42
39
|
assert browser.device.mobile?
|
43
|
-
assert browser.modern?
|
44
40
|
assert_equal "6.0.0.141", browser.full_version
|
45
41
|
assert_equal "6", browser.version
|
46
42
|
end
|
@@ -51,7 +47,6 @@ class BlackberryTest < Minitest::Test
|
|
51
47
|
assert_equal "BlackBerry", browser.name
|
52
48
|
refute browser.device.tablet?
|
53
49
|
assert browser.device.mobile?
|
54
|
-
assert browser.modern?
|
55
50
|
assert_equal "7.0.0.1", browser.full_version
|
56
51
|
assert_equal "7", browser.version
|
57
52
|
end
|
@@ -62,7 +57,6 @@ class BlackberryTest < Minitest::Test
|
|
62
57
|
assert_equal "BlackBerry", browser.name
|
63
58
|
refute browser.device.tablet?
|
64
59
|
assert browser.device.mobile?
|
65
|
-
assert browser.modern?
|
66
60
|
assert_equal "10.0.9.1675", browser.full_version
|
67
61
|
assert_equal "10", browser.version
|
68
62
|
end
|
data/test/unit/bots_test.rb
CHANGED
@@ -15,34 +15,6 @@ class BotsTest < Minitest::Test
|
|
15
15
|
refute browser.bot?
|
16
16
|
end
|
17
17
|
|
18
|
-
test "doesn't consider empty UA as bot" do
|
19
|
-
browser = Browser.new("")
|
20
|
-
refute browser.bot?
|
21
|
-
end
|
22
|
-
|
23
|
-
test "allows setting empty string as bots" do
|
24
|
-
Browser::Bot.detect_empty_ua!
|
25
|
-
browser = Browser.new("")
|
26
|
-
|
27
|
-
assert browser.bot?
|
28
|
-
end
|
29
|
-
|
30
|
-
test "allows setting nil as user agent for bots" do
|
31
|
-
browser = Browser.new(nil)
|
32
|
-
refute browser.bot?
|
33
|
-
|
34
|
-
Browser::Bot.detect_empty_ua!
|
35
|
-
browser = Browser.new(nil)
|
36
|
-
assert browser.bot?
|
37
|
-
end
|
38
|
-
|
39
|
-
test "doesn't detect mozilla as a bot when considering empty UA" do
|
40
|
-
Browser::Bot.detect_empty_ua!
|
41
|
-
browser = Browser.new("Mozilla")
|
42
|
-
|
43
|
-
refute browser.bot?
|
44
|
-
end
|
45
|
-
|
46
18
|
test "returns bot name" do
|
47
19
|
browser = Browser.new(Browser["GOOGLE_BOT"])
|
48
20
|
assert_equal "Google Bot", browser.bot.name
|
@@ -51,13 +23,6 @@ class BotsTest < Minitest::Test
|
|
51
23
|
assert_equal "Facebook Bot", browser.bot.name
|
52
24
|
end
|
53
25
|
|
54
|
-
test "returns bot name (empty string ua detection enabled)" do
|
55
|
-
Browser::Bot.detect_empty_ua!
|
56
|
-
browser = Browser.new("")
|
57
|
-
|
58
|
-
assert_equal browser.bot.name, "Generic Bot"
|
59
|
-
end
|
60
|
-
|
61
26
|
test "returns nil for non-bots" do
|
62
27
|
browser = Browser.new(Browser["CHROME"])
|
63
28
|
assert_nil browser.bot.name
|
@@ -84,7 +49,6 @@ class BotsTest < Minitest::Test
|
|
84
49
|
refute browser.platform.windows10?
|
85
50
|
refute browser.platform.windows_phone?
|
86
51
|
refute browser.edge?
|
87
|
-
refute browser.modern?
|
88
52
|
refute browser.device.mobile?
|
89
53
|
refute browser.webkit?
|
90
54
|
refute browser.chrome?
|
@@ -107,4 +71,41 @@ class BotsTest < Minitest::Test
|
|
107
71
|
|
108
72
|
Browser::Bot.bots.delete("faraday")
|
109
73
|
end
|
74
|
+
|
75
|
+
test "detects recognized bots using common libs" do
|
76
|
+
browser = Browser.new(Browser.bot_user_agents["LINKEDIN"])
|
77
|
+
|
78
|
+
assert browser.bot?
|
79
|
+
assert_equal "LinkedIn", browser.bot.name
|
80
|
+
end
|
81
|
+
|
82
|
+
test "tells why user agent is considered a bot" do
|
83
|
+
matcher = Browser::Bot.why?(Browser.bot_user_agents["LINKEDIN"])
|
84
|
+
|
85
|
+
assert_equal Browser::Bot::KnownBotsMatcher, matcher
|
86
|
+
end
|
87
|
+
|
88
|
+
test "adds custom bot matcher" do
|
89
|
+
Browser::Bot.matchers << ->(ua, _) { ua.match?(/some-script/) }
|
90
|
+
browser = Browser.new("some-script")
|
91
|
+
|
92
|
+
assert browser.bot?
|
93
|
+
assert_equal "Generic Bot", browser.bot.name
|
94
|
+
end
|
95
|
+
|
96
|
+
%w[
|
97
|
+
content-fetcher
|
98
|
+
content-crawler
|
99
|
+
some-search-engine
|
100
|
+
monitoring-service
|
101
|
+
content-spider
|
102
|
+
some-bot
|
103
|
+
].each do |ua|
|
104
|
+
test "detects user agents based on keywords (#{ua})" do
|
105
|
+
browser = Browser.new(ua)
|
106
|
+
|
107
|
+
assert browser.bot?
|
108
|
+
assert_equal Browser::Bot::KeywordMatcher, browser.bot.why?
|
109
|
+
end
|
110
|
+
end
|
110
111
|
end
|
data/test/unit/chrome_test.rb
CHANGED
@@ -10,7 +10,6 @@ class ChromeTest < Minitest::Test
|
|
10
10
|
assert browser.chrome?
|
11
11
|
refute browser.safari?
|
12
12
|
assert browser.webkit?
|
13
|
-
assert browser.modern?
|
14
13
|
assert_equal "5.0.375.99", browser.full_version
|
15
14
|
assert_equal "5", browser.version
|
16
15
|
end
|
@@ -22,7 +21,6 @@ class ChromeTest < Minitest::Test
|
|
22
21
|
assert browser.chrome?
|
23
22
|
refute browser.safari?
|
24
23
|
assert browser.webkit?
|
25
|
-
assert browser.modern?
|
26
24
|
assert_equal "19.0.1084.60", browser.full_version
|
27
25
|
assert_equal "19", browser.version
|
28
26
|
end
|
@@ -35,7 +33,6 @@ class ChromeTest < Minitest::Test
|
|
35
33
|
assert browser.platform.android?
|
36
34
|
refute browser.safari?
|
37
35
|
assert browser.webkit?
|
38
|
-
assert browser.modern?
|
39
36
|
assert_equal "28.0.1500.94", browser.full_version
|
40
37
|
assert_equal "28", browser.version
|
41
38
|
end
|
@@ -45,22 +42,6 @@ class ChromeTest < Minitest::Test
|
|
45
42
|
assert browser.platform.chrome_os?
|
46
43
|
end
|
47
44
|
|
48
|
-
test "detects yandex browser" do
|
49
|
-
browser = Browser.new(Browser["YANDEX_BROWSER"])
|
50
|
-
|
51
|
-
assert browser.yandex?
|
52
|
-
assert browser.chrome?
|
53
|
-
refute browser.safari?
|
54
|
-
assert browser.webkit?
|
55
|
-
assert_equal "41.0.2272.118", browser.full_version
|
56
|
-
assert_equal "41", browser.version
|
57
|
-
end
|
58
|
-
|
59
|
-
test "detects yandex version by range" do
|
60
|
-
browser = Browser.new(Browser["YANDEX_BROWSER"])
|
61
|
-
assert browser.yandex?(%w[>=41 <42])
|
62
|
-
end
|
63
|
-
|
64
45
|
test "detects chrome frame" do
|
65
46
|
browser = Browser.new(Browser["IE9_CHROME_FRAME"])
|
66
47
|
|
@@ -77,6 +58,14 @@ class ChromeTest < Minitest::Test
|
|
77
58
|
assert browser.chrome?
|
78
59
|
end
|
79
60
|
|
61
|
+
test "detects chrome on android 10" do
|
62
|
+
browser = Browser.new(Browser["ANDROID_Q"])
|
63
|
+
|
64
|
+
assert browser.chrome?
|
65
|
+
assert_equal "Chrome", browser.name
|
66
|
+
assert_equal "78", browser.version
|
67
|
+
end
|
68
|
+
|
80
69
|
test "detects version by range" do
|
81
70
|
browser = Browser.new(Browser["CHROME"])
|
82
71
|
assert browser.chrome?(%w[>=5 <6])
|
data/test/unit/console_test.rb
CHANGED
@@ -5,11 +5,11 @@ require "test_helper"
|
|
5
5
|
class ConsoleTest < Minitest::Test
|
6
6
|
test "detects psp" do
|
7
7
|
browser = Browser.new(Browser["PSP"])
|
8
|
-
assert_equal "
|
8
|
+
assert_equal "Unknown Browser", browser.name
|
9
9
|
end
|
10
10
|
|
11
11
|
test "detects psp vita" do
|
12
12
|
browser = Browser.new(Browser["PSP_VITA"])
|
13
|
-
assert_equal "
|
13
|
+
assert_equal "Unknown Browser", browser.name
|
14
14
|
end
|
15
15
|
end
|
data/test/unit/device_test.rb
CHANGED
@@ -5,7 +5,7 @@ require "test_helper"
|
|
5
5
|
class DeviceTest < Minitest::Test
|
6
6
|
class CustomDevice < Browser::Device::Base
|
7
7
|
def match?
|
8
|
-
ua
|
8
|
+
ua.include?("Custom")
|
9
9
|
end
|
10
10
|
|
11
11
|
def id
|
@@ -20,14 +20,14 @@ class DeviceTest < Minitest::Test
|
|
20
20
|
|
21
21
|
Browser::Device.matchers.shift
|
22
22
|
device = Browser::Device.new("Custom")
|
23
|
-
assert_equal :
|
23
|
+
assert_equal :unknown_device, device.id
|
24
24
|
end
|
25
25
|
|
26
26
|
test "detect generic device" do
|
27
27
|
device = Browser::Device.new("")
|
28
28
|
|
29
29
|
assert device.unknown?
|
30
|
-
assert_equal :
|
30
|
+
assert_equal :unknown_device, device.id
|
31
31
|
end
|
32
32
|
|
33
33
|
test "detect ipad" do
|
@@ -157,6 +157,16 @@ class DeviceTest < Minitest::Test
|
|
157
157
|
assert_equal "Nintendo WiiU", device.name
|
158
158
|
end
|
159
159
|
|
160
|
+
test "detect switch" do
|
161
|
+
device = Browser::Device.new(Browser["NINTENDO_SWITCH"])
|
162
|
+
assert device.nintendo_switch?
|
163
|
+
assert device.switch?
|
164
|
+
assert device.console?
|
165
|
+
assert device.nintendo?
|
166
|
+
assert_equal :switch, device.id
|
167
|
+
assert_equal "Nintendo Switch", device.name
|
168
|
+
end
|
169
|
+
|
160
170
|
test "detect blackberry playbook" do
|
161
171
|
device = Browser::Device.new(Browser["PLAYBOOK"])
|
162
172
|
assert device.playbook?
|
@@ -228,4 +238,51 @@ class DeviceTest < Minitest::Test
|
|
228
238
|
refute device.mobile?
|
229
239
|
end
|
230
240
|
end
|
241
|
+
|
242
|
+
{
|
243
|
+
"ANDROID_CUPCAKE" => "T-Mobile G1",
|
244
|
+
"ANDROID_DONUT" => "SonyEricssonX10i",
|
245
|
+
"ANDROID_ECLAIR_21" => "Nexus One",
|
246
|
+
"ANDROID_FROYO" => "HTC_DesireHD_A9191",
|
247
|
+
"ANDROID_GINGERBREAD" => "Sensation_4G",
|
248
|
+
"ANDROID_HONEYCOMB_30" => "Xoom",
|
249
|
+
"ANDROID_ICECREAM" => "sdk",
|
250
|
+
"ANDROID_JELLYBEAN_41" => "Nexus S",
|
251
|
+
"ANDROID_JELLYBEAN_42" => "Nexus 10",
|
252
|
+
"ANDROID_JELLYBEAN_43" => "Nexus 7",
|
253
|
+
"CUSTOM_APP" => "HTC Ruby",
|
254
|
+
"NOOK" => "NOOK BNTV250A"
|
255
|
+
}.each do |key, name|
|
256
|
+
test "detect device name of #{key} as #{name}" do
|
257
|
+
device = Browser::Device.new(Browser[key])
|
258
|
+
assert_equal name, device.name
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
test "detect samsung devices" do
|
263
|
+
device = Browser::Device.new(Browser["SAMSUNG_SM-G975F"])
|
264
|
+
|
265
|
+
assert device.samsung?
|
266
|
+
assert_equal :samsung, device.id
|
267
|
+
assert_equal "Samsung Galaxy S10+", device.name
|
268
|
+
end
|
269
|
+
|
270
|
+
test "detect generic samsung devices" do
|
271
|
+
device = Browser::Device.new(Browser["SAMSUNG_SM-FAKE"])
|
272
|
+
|
273
|
+
assert device.samsung?
|
274
|
+
assert_equal :samsung, device.id
|
275
|
+
assert_equal "Samsung SM-0000", device.name
|
276
|
+
end
|
277
|
+
|
278
|
+
{
|
279
|
+
"SAMSUNG_SM-G975F" => "Samsung Galaxy S10+",
|
280
|
+
"SAMSUNG_SM-G960F" => "Samsung Galaxy S9",
|
281
|
+
"SAMSUNG_SM-F700F" => "Samsung Galaxy Z Flip"
|
282
|
+
}.each do |key, name|
|
283
|
+
test "detect device name of #{key} as #{name}" do
|
284
|
+
device = Browser::Device.new(Browser[key])
|
285
|
+
assert_equal name, device.name
|
286
|
+
end
|
287
|
+
end
|
231
288
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class DuckDuckGoTest < Minitest::Test
|
6
|
+
test "detects DuckDuckGo on iOS device" do
|
7
|
+
browser = Browser.new(Browser["DUCKDUCKGO_BROWSER_IOS"])
|
8
|
+
assert browser.duck_duck_go?
|
9
|
+
refute browser.safari?
|
10
|
+
refute browser.chrome?
|
11
|
+
assert browser.webkit?
|
12
|
+
refute browser.bot?
|
13
|
+
assert_equal "DuckDuckGo", browser.name
|
14
|
+
assert_equal :duckduckgo, browser.id
|
15
|
+
end
|
16
|
+
|
17
|
+
test "detects DuckDuckGo on Android device" do
|
18
|
+
browser = Browser.new(Browser["DUCKDUCKGO_BROWSER_ANDROID"])
|
19
|
+
assert browser.duck_duck_go?
|
20
|
+
refute browser.safari?
|
21
|
+
refute browser.chrome?
|
22
|
+
refute browser.bot?
|
23
|
+
assert_equal "DuckDuckGo", browser.name
|
24
|
+
assert_equal :duckduckgo, browser.id
|
25
|
+
end
|
26
|
+
|
27
|
+
test "detects correct version" do
|
28
|
+
browser = Browser.new(Browser["DUCKDUCKGO_BROWSER_IOS"])
|
29
|
+
assert_equal "7", browser.full_version
|
30
|
+
assert_equal "7", browser.version
|
31
|
+
end
|
32
|
+
|
33
|
+
test "detects version by range" do
|
34
|
+
browser = Browser.new(Browser["DUCKDUCKGO_BROWSER_IOS"])
|
35
|
+
assert browser.duck_duck_go?(%w[>=7 <8])
|
36
|
+
end
|
37
|
+
end
|
data/test/unit/edge_test.rb
CHANGED
@@ -12,7 +12,6 @@ class EdgeTest < ActionController::TestCase
|
|
12
12
|
assert_equal "12", browser.version
|
13
13
|
assert browser.platform.windows10?
|
14
14
|
assert browser.edge?
|
15
|
-
assert browser.modern?
|
16
15
|
refute browser.webkit?
|
17
16
|
refute browser.chrome?
|
18
17
|
refute browser.safari?
|
@@ -30,7 +29,6 @@ class EdgeTest < ActionController::TestCase
|
|
30
29
|
assert_equal "7", browser.msie_version
|
31
30
|
assert browser.edge?
|
32
31
|
assert browser.compatibility_view?
|
33
|
-
refute browser.modern?
|
34
32
|
refute browser.webkit?
|
35
33
|
refute browser.chrome?
|
36
34
|
refute browser.safari?
|
@@ -47,14 +45,60 @@ class EdgeTest < ActionController::TestCase
|
|
47
45
|
refute browser.platform.windows10?
|
48
46
|
assert browser.platform.windows_phone?
|
49
47
|
assert browser.edge?
|
50
|
-
|
48
|
+
refute browser.webkit?
|
49
|
+
refute browser.chrome?
|
50
|
+
refute browser.safari?
|
51
|
+
end
|
52
|
+
|
53
|
+
test "detects Microsoft Edge based on Chrome" do
|
54
|
+
browser = Browser.new(Browser["MS_EDGE_CHROME"])
|
55
|
+
|
56
|
+
assert_equal :edge, browser.id
|
57
|
+
assert_equal "Microsoft Edge", browser.name
|
58
|
+
assert_equal "79.0.309.18", browser.full_version
|
59
|
+
assert_equal "79", browser.version
|
60
|
+
assert browser.platform.mac?
|
61
|
+
refute browser.platform.windows?
|
62
|
+
assert browser.edge?
|
63
|
+
assert browser.webkit?
|
64
|
+
refute browser.chrome?
|
65
|
+
refute browser.safari?
|
66
|
+
end
|
67
|
+
|
68
|
+
test "detects Microsoft Edge Mobile on iOS" do
|
69
|
+
browser = Browser.new(Browser["MS_EDGE_IOS"])
|
70
|
+
|
71
|
+
assert_equal :edge, browser.id
|
72
|
+
assert_equal "Microsoft Edge", browser.name
|
73
|
+
assert_equal "44.5.0.10", browser.full_version
|
74
|
+
assert_equal "44", browser.version
|
75
|
+
refute browser.platform.windows10?
|
76
|
+
refute browser.platform.windows_phone?
|
77
|
+
assert browser.platform.ios?
|
78
|
+
assert browser.edge?
|
79
|
+
refute browser.webkit?
|
80
|
+
refute browser.chrome?
|
81
|
+
refute browser.safari?
|
82
|
+
end
|
83
|
+
|
84
|
+
test "detects Microsoft Edge Mobile on Android" do
|
85
|
+
browser = Browser.new(Browser["MS_EDGE_ANDROID"])
|
86
|
+
|
87
|
+
assert_equal :edge, browser.id
|
88
|
+
assert_equal "Microsoft Edge", browser.name
|
89
|
+
assert_equal "44.11.2.4122", browser.full_version
|
90
|
+
assert_equal "44", browser.version
|
91
|
+
refute browser.platform.windows10?
|
92
|
+
refute browser.platform.windows_phone?
|
93
|
+
assert browser.platform.android?
|
94
|
+
assert browser.edge?
|
51
95
|
refute browser.webkit?
|
52
96
|
refute browser.chrome?
|
53
97
|
refute browser.safari?
|
54
98
|
end
|
55
99
|
|
56
100
|
test "detects version by range" do
|
57
|
-
browser = Browser.new(Browser["
|
58
|
-
assert browser.edge?(%w[>=
|
101
|
+
browser = Browser.new(Browser["MS_EDGE_IOS"])
|
102
|
+
assert browser.edge?(%w[>=43 <45])
|
59
103
|
end
|
60
104
|
end
|
data/test/unit/facebook_test.rb
CHANGED
@@ -13,6 +13,26 @@ class FacebookTest < Minitest::Test
|
|
13
13
|
assert_equal "135", browser.version
|
14
14
|
end
|
15
15
|
|
16
|
+
test "detects new facebook on iOS" do
|
17
|
+
browser = Browser.new(Browser["FACEBOOK_IOS"])
|
18
|
+
|
19
|
+
assert_equal "Facebook", browser.name
|
20
|
+
assert browser.facebook?
|
21
|
+
assert :facebook, browser.id
|
22
|
+
assert_equal "AppleWebKit/605.1.15", browser.full_version
|
23
|
+
assert_equal "AppleWebKit/605", browser.version
|
24
|
+
end
|
25
|
+
|
26
|
+
test "detects new facebook on Android" do
|
27
|
+
browser = Browser.new(Browser["FACEBOOK_ANDROID"])
|
28
|
+
|
29
|
+
assert_equal "Facebook", browser.name
|
30
|
+
assert browser.facebook?
|
31
|
+
assert :facebook, browser.id
|
32
|
+
assert_equal "214.0.0.43.83", browser.full_version
|
33
|
+
assert_equal "214", browser.version
|
34
|
+
end
|
35
|
+
|
16
36
|
test "detects version by range" do
|
17
37
|
browser = Browser.new(Browser["FACEBOOK"])
|
18
38
|
assert browser.facebook?(%w[>=135])
|
data/test/unit/firefox_test.rb
CHANGED
@@ -8,7 +8,6 @@ class FirefoxTest < Minitest::Test
|
|
8
8
|
|
9
9
|
assert_equal "Firefox", browser.name
|
10
10
|
assert browser.firefox?
|
11
|
-
refute browser.modern?
|
12
11
|
assert_equal "3.8", browser.full_version
|
13
12
|
assert_equal "3", browser.version
|
14
13
|
end
|
@@ -29,7 +28,6 @@ class FirefoxTest < Minitest::Test
|
|
29
28
|
assert_equal :firefox, browser.id
|
30
29
|
assert_equal "Firefox", browser.name
|
31
30
|
assert browser.firefox?
|
32
|
-
assert browser.modern?
|
33
31
|
assert_equal "17.0", browser.full_version
|
34
32
|
assert_equal "17", browser.version
|
35
33
|
end
|
@@ -40,7 +38,6 @@ class FirefoxTest < Minitest::Test
|
|
40
38
|
assert_equal :firefox, browser.id
|
41
39
|
assert_equal "Firefox", browser.name
|
42
40
|
assert browser.firefox?
|
43
|
-
assert browser.modern?
|
44
41
|
assert browser.platform.android?
|
45
42
|
assert_equal "14.0", browser.full_version
|
46
43
|
assert_equal "14", browser.version
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class GoogleSearchAppTest < Minitest::Test
|
6
|
+
test "detects Google Search App (Android)" do
|
7
|
+
browser = Browser.new(Browser["GOOGLE_SEARCH_APP_ANDROID"])
|
8
|
+
|
9
|
+
assert browser.webkit?
|
10
|
+
assert browser.google_search_app?
|
11
|
+
assert browser.platform.android?
|
12
|
+
assert_equal :google_search_app, browser.id
|
13
|
+
assert_equal "11", browser.version
|
14
|
+
assert_equal "11.6.8.21", browser.full_version
|
15
|
+
assert_equal "Google Search App", browser.name
|
16
|
+
refute browser.chrome?
|
17
|
+
refute browser.safari?
|
18
|
+
end
|
19
|
+
|
20
|
+
test "detects Google Search App (iPad)" do
|
21
|
+
browser = Browser.new(Browser["GOOGLE_SEARCH_APP_IPAD"])
|
22
|
+
|
23
|
+
assert browser.webkit?
|
24
|
+
assert browser.google_search_app?
|
25
|
+
assert browser.device.ipad?
|
26
|
+
assert browser.platform.ios?
|
27
|
+
assert_equal :google_search_app, browser.id
|
28
|
+
assert_equal "102", browser.version
|
29
|
+
assert_equal "102.0.304944559", browser.full_version
|
30
|
+
assert_equal "Google Search App", browser.name
|
31
|
+
refute browser.chrome?
|
32
|
+
refute browser.safari?
|
33
|
+
end
|
34
|
+
|
35
|
+
test "detects Google Search App (iPhone)" do
|
36
|
+
browser = Browser.new(Browser["GOOGLE_SEARCH_APP_IPHONE"])
|
37
|
+
|
38
|
+
assert browser.webkit?
|
39
|
+
assert browser.google_search_app?
|
40
|
+
assert browser.device.iphone?
|
41
|
+
assert browser.platform.ios?
|
42
|
+
assert_equal :google_search_app, browser.id
|
43
|
+
assert_equal "105", browser.version
|
44
|
+
assert_equal "105.0.307913796", browser.full_version
|
45
|
+
assert_equal "Google Search App", browser.name
|
46
|
+
refute browser.chrome?
|
47
|
+
refute browser.safari?
|
48
|
+
end
|
49
|
+
|
50
|
+
test "detects version by range (iPad)" do
|
51
|
+
browser = Browser.new(Browser["GOOGLE_SEARCH_APP_IPAD"])
|
52
|
+
assert browser.google_search_app?(%w[>=102 <103])
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class HuaweiBrowserTest < Minitest::Test
|
6
|
+
test "detects Huawei Browser" do
|
7
|
+
browser = Browser.new(Browser["HUAWEI_BROWSER"])
|
8
|
+
assert browser.huawei_browser?
|
9
|
+
refute browser.safari?
|
10
|
+
refute browser.chrome?
|
11
|
+
assert_equal "Huawei Browser", browser.name
|
12
|
+
assert_equal :huawei_browser, browser.id
|
13
|
+
end
|
14
|
+
|
15
|
+
test "detects correct version" do
|
16
|
+
browser = Browser.new(Browser["HUAWEI_BROWSER"])
|
17
|
+
assert_equal "10.1.2.300", browser.full_version
|
18
|
+
assert_equal "10", browser.version
|
19
|
+
end
|
20
|
+
|
21
|
+
test "detects version by range" do
|
22
|
+
browser = Browser.new(Browser["HUAWEI_BROWSER"])
|
23
|
+
assert browser.huawei_browser?(%w[>=10 <11])
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class InstagramTest < Minitest::Test
|
6
|
+
test "detects instagram" do
|
7
|
+
browser = Browser.new(Browser["INSTAGRAM"])
|
8
|
+
|
9
|
+
assert_equal "Instagram", browser.name
|
10
|
+
assert browser.instagram?
|
11
|
+
assert :instagram, browser.id
|
12
|
+
assert_equal "41.0.0.14.90", browser.full_version
|
13
|
+
assert_equal "41", browser.version
|
14
|
+
end
|
15
|
+
|
16
|
+
test "detects alternate instagram user agent" do
|
17
|
+
browser = Browser.new(Browser["INSTAGRAM_OTHER"])
|
18
|
+
|
19
|
+
assert_equal "Instagram", browser.name
|
20
|
+
assert browser.instagram?
|
21
|
+
assert :instagram, browser.id
|
22
|
+
assert_equal "182257141", browser.full_version
|
23
|
+
assert_equal "182257141", browser.version
|
24
|
+
end
|
25
|
+
|
26
|
+
test "detects version by range" do
|
27
|
+
browser = Browser.new(Browser["INSTAGRAM"])
|
28
|
+
assert browser.instagram?(%w[>=41])
|
29
|
+
end
|
30
|
+
end
|