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
@@ -9,7 +9,6 @@ class IeTest < Minitest::Test
|
|
9
9
|
assert_equal "Internet Explorer", browser.name
|
10
10
|
assert browser.ie?
|
11
11
|
assert browser.ie?(6)
|
12
|
-
refute browser.modern?
|
13
12
|
assert_equal "6.0", browser.full_version
|
14
13
|
assert_equal "6", browser.version
|
15
14
|
end
|
@@ -20,7 +19,6 @@ class IeTest < Minitest::Test
|
|
20
19
|
assert_equal "Internet Explorer", browser.name
|
21
20
|
assert browser.ie?
|
22
21
|
assert browser.ie?(7)
|
23
|
-
refute browser.modern?
|
24
22
|
assert_equal "7.0", browser.full_version
|
25
23
|
assert_equal "7", browser.version
|
26
24
|
end
|
@@ -31,7 +29,6 @@ class IeTest < Minitest::Test
|
|
31
29
|
assert_equal "Internet Explorer", browser.name
|
32
30
|
assert browser.ie?
|
33
31
|
assert browser.ie?(8)
|
34
|
-
refute browser.modern?
|
35
32
|
refute browser.compatibility_view?
|
36
33
|
assert_equal "8.0", browser.full_version
|
37
34
|
assert_equal "8", browser.version
|
@@ -43,7 +40,6 @@ class IeTest < Minitest::Test
|
|
43
40
|
assert_equal "Internet Explorer", browser.name
|
44
41
|
assert browser.ie?
|
45
42
|
assert browser.ie?(8)
|
46
|
-
refute browser.modern?
|
47
43
|
assert browser.compatibility_view?
|
48
44
|
assert_equal "8.0", browser.full_version
|
49
45
|
assert_equal "8", browser.version
|
@@ -57,7 +53,6 @@ class IeTest < Minitest::Test
|
|
57
53
|
assert_equal "Internet Explorer", browser.name
|
58
54
|
assert browser.ie?
|
59
55
|
assert browser.ie?(9)
|
60
|
-
assert browser.modern?
|
61
56
|
refute browser.compatibility_view?
|
62
57
|
assert_equal "9.0", browser.full_version
|
63
58
|
assert_equal "9", browser.version
|
@@ -69,7 +64,6 @@ class IeTest < Minitest::Test
|
|
69
64
|
assert_equal "Internet Explorer", browser.name
|
70
65
|
assert browser.ie?
|
71
66
|
assert browser.ie?(9)
|
72
|
-
refute browser.modern?
|
73
67
|
assert browser.compatibility_view?
|
74
68
|
assert_equal "9.0", browser.full_version
|
75
69
|
assert_equal "9", browser.version
|
@@ -83,7 +77,6 @@ class IeTest < Minitest::Test
|
|
83
77
|
assert_equal "Internet Explorer", browser.name
|
84
78
|
assert browser.ie?
|
85
79
|
assert browser.ie?(10)
|
86
|
-
assert browser.modern?
|
87
80
|
refute browser.compatibility_view?
|
88
81
|
assert_equal "10.0", browser.full_version
|
89
82
|
assert_equal "10", browser.version
|
@@ -95,7 +88,6 @@ class IeTest < Minitest::Test
|
|
95
88
|
assert_equal "Internet Explorer", browser.name
|
96
89
|
assert browser.ie?
|
97
90
|
assert browser.ie?(10)
|
98
|
-
refute browser.modern?
|
99
91
|
assert browser.compatibility_view?
|
100
92
|
assert_equal "10.0", browser.full_version
|
101
93
|
assert_equal "10", browser.version
|
@@ -109,7 +101,6 @@ class IeTest < Minitest::Test
|
|
109
101
|
assert_equal "Internet Explorer", browser.name
|
110
102
|
assert browser.ie?
|
111
103
|
assert browser.ie?(11)
|
112
|
-
assert browser.modern?
|
113
104
|
refute browser.compatibility_view?
|
114
105
|
assert_equal "11.0", browser.full_version
|
115
106
|
assert_equal "11", browser.version
|
@@ -121,7 +112,6 @@ class IeTest < Minitest::Test
|
|
121
112
|
assert_equal "Internet Explorer", browser.name
|
122
113
|
assert browser.ie?
|
123
114
|
assert browser.ie?(11)
|
124
|
-
refute browser.modern?
|
125
115
|
assert browser.compatibility_view?
|
126
116
|
assert_equal "11.0", browser.full_version
|
127
117
|
assert_equal "11", browser.version
|
@@ -145,7 +135,6 @@ class IeTest < Minitest::Test
|
|
145
135
|
assert_equal "Internet Explorer", browser.name
|
146
136
|
assert browser.ie?
|
147
137
|
assert browser.ie?(11)
|
148
|
-
assert browser.modern?
|
149
138
|
refute browser.compatibility_view?
|
150
139
|
refute browser.platform.windows_rt?
|
151
140
|
assert browser.platform.windows_touchscreen_desktop?
|
@@ -166,7 +155,6 @@ class IeTest < Minitest::Test
|
|
166
155
|
refute browser.platform.windows10?
|
167
156
|
refute browser.platform.windows_phone?
|
168
157
|
refute browser.edge?
|
169
|
-
refute browser.modern?
|
170
158
|
refute browser.device.mobile?
|
171
159
|
refute browser.webkit?
|
172
160
|
refute browser.chrome?
|
data/test/unit/ios_test.rb
CHANGED
@@ -9,7 +9,6 @@ class IosTest < Minitest::Test
|
|
9
9
|
assert_equal "Safari", browser.name
|
10
10
|
assert browser.safari?
|
11
11
|
assert browser.webkit?
|
12
|
-
assert browser.modern?
|
13
12
|
assert browser.platform.ios?
|
14
13
|
refute browser.platform.mac?
|
15
14
|
assert_equal "3.0", browser.full_version
|
@@ -22,7 +21,6 @@ class IosTest < Minitest::Test
|
|
22
21
|
assert_equal "Safari", browser.name
|
23
22
|
assert browser.safari?
|
24
23
|
assert browser.webkit?
|
25
|
-
assert browser.modern?
|
26
24
|
assert_equal "5.0.1", browser.full_version
|
27
25
|
assert_equal "5", browser.version
|
28
26
|
end
|
@@ -56,7 +54,6 @@ class IosTest < Minitest::Test
|
|
56
54
|
assert_equal "Safari", browser.name
|
57
55
|
assert browser.safari?
|
58
56
|
assert browser.webkit?
|
59
|
-
assert browser.modern?
|
60
57
|
assert browser.platform.ios?
|
61
58
|
refute browser.platform.mac?
|
62
59
|
assert_equal "4.0.4", browser.full_version
|
@@ -105,6 +102,13 @@ class IosTest < Minitest::Test
|
|
105
102
|
refute browser.platform.mac?
|
106
103
|
end
|
107
104
|
|
105
|
+
test "detects ios12" do
|
106
|
+
browser = Browser.new(Browser["IOS12"])
|
107
|
+
assert browser.platform.ios?
|
108
|
+
assert browser.platform.ios?(12)
|
109
|
+
refute browser.platform.mac?
|
110
|
+
end
|
111
|
+
|
108
112
|
test "don't detect as two different versions" do
|
109
113
|
browser = Browser.new(Browser["IOS8"])
|
110
114
|
assert browser.platform.ios?(8)
|
@@ -119,7 +123,6 @@ class IosTest < Minitest::Test
|
|
119
123
|
assert meta.include?("ios")
|
120
124
|
assert meta.include?("safari")
|
121
125
|
assert meta.include?("safari3")
|
122
|
-
assert meta.include?("modern")
|
123
126
|
assert meta.include?("mobile")
|
124
127
|
refute meta.include?("tablet")
|
125
128
|
end
|
@@ -131,7 +134,6 @@ class IosTest < Minitest::Test
|
|
131
134
|
assert meta.include?("webkit")
|
132
135
|
assert meta.include?("ios")
|
133
136
|
assert meta.include?("safari")
|
134
|
-
assert meta.include?("modern")
|
135
137
|
assert meta.include?("tablet")
|
136
138
|
refute meta.include?("mobile")
|
137
139
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class KaiOSTest < Minitest::Test
|
6
|
+
test "detects KaiOS" do
|
7
|
+
browser = Browser.new(Browser["NOKIA_8110"])
|
8
|
+
|
9
|
+
assert browser.firefox?
|
10
|
+
assert_equal "48", browser.version
|
11
|
+
assert_equal "48.0", browser.full_version
|
12
|
+
assert_equal "Firefox", browser.name
|
13
|
+
assert browser.platform.kai_os?
|
14
|
+
assert_equal "KaiOS", browser.platform.name
|
15
|
+
assert_equal "2.5", browser.platform.version
|
16
|
+
refute browser.platform.android?
|
17
|
+
end
|
18
|
+
|
19
|
+
test "detects KaiOS with Android string in user-agent " do
|
20
|
+
browser = Browser.new(Browser["JIOPHONE_2"])
|
21
|
+
|
22
|
+
assert browser.firefox?
|
23
|
+
assert_equal "48", browser.version
|
24
|
+
assert_equal "48.0", browser.full_version
|
25
|
+
assert_equal "Firefox", browser.name
|
26
|
+
assert browser.platform.kai_os?
|
27
|
+
assert_equal "KaiOS", browser.platform.name
|
28
|
+
assert_equal "2.5", browser.platform.version
|
29
|
+
refute browser.platform.android?
|
30
|
+
end
|
31
|
+
end
|
data/test/unit/kindle_test.rb
CHANGED
@@ -17,13 +17,11 @@ class KindleTest < Minitest::Test
|
|
17
17
|
browser = Browser.new(Browser["KINDLE_FIRE_HD"])
|
18
18
|
|
19
19
|
assert browser.webkit?
|
20
|
-
assert browser.modern?
|
21
20
|
end
|
22
21
|
|
23
22
|
test "detects kindle fire hd mobile" do
|
24
23
|
browser = Browser.new(Browser["KINDLE_FIRE_HD_MOBILE"])
|
25
24
|
|
26
25
|
assert browser.webkit?
|
27
|
-
assert browser.modern?
|
28
26
|
end
|
29
27
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class MaxthonTest < Minitest::Test
|
6
|
+
test "detects Maxthon" do
|
7
|
+
browser = Browser.new(Browser["MAXTHON"])
|
8
|
+
assert browser.maxthon?
|
9
|
+
refute browser.safari?
|
10
|
+
refute browser.chrome?
|
11
|
+
assert_equal "Maxthon", browser.name
|
12
|
+
assert_equal :maxthon, browser.id
|
13
|
+
end
|
14
|
+
|
15
|
+
test "detects correct version" do
|
16
|
+
browser = Browser.new(Browser["MAXTHON"])
|
17
|
+
assert_equal "5.3.8.2000", browser.full_version
|
18
|
+
assert_equal "5", browser.version
|
19
|
+
end
|
20
|
+
|
21
|
+
test "detects version by range" do
|
22
|
+
browser = Browser.new(Browser["MAXTHON"])
|
23
|
+
assert browser.maxthon?(%w[>=5 <6])
|
24
|
+
end
|
25
|
+
end
|
data/test/unit/meta_test.rb
CHANGED
@@ -5,7 +5,7 @@ require "test_helper"
|
|
5
5
|
class MetaTest < Minitest::Test
|
6
6
|
class CustomRule < Browser::Meta::Base
|
7
7
|
def meta
|
8
|
-
"custom" if browser.ua
|
8
|
+
"custom" if /Custom/.match?(browser.ua)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -36,7 +36,6 @@ class MetaTest < Minitest::Test
|
|
36
36
|
assert meta.include?("chrome")
|
37
37
|
assert meta.include?("webkit")
|
38
38
|
assert meta.include?("mac")
|
39
|
-
assert meta.include?("modern")
|
40
39
|
end
|
41
40
|
|
42
41
|
test "returns string representation for mobile" do
|
@@ -46,4 +45,13 @@ class MetaTest < Minitest::Test
|
|
46
45
|
assert meta.include?("blackberry")
|
47
46
|
assert meta.include?("mobile")
|
48
47
|
end
|
48
|
+
|
49
|
+
test "returns string representation for unknown platform/device/browser" do
|
50
|
+
browser = Browser.new("Unknown")
|
51
|
+
meta = browser.to_s
|
52
|
+
|
53
|
+
assert meta.include?("unknown_platform")
|
54
|
+
assert meta.include?("unknown_device")
|
55
|
+
assert meta.include?("unknown_browser")
|
56
|
+
end
|
49
57
|
end
|
@@ -3,18 +3,33 @@
|
|
3
3
|
require "test_helper"
|
4
4
|
|
5
5
|
class MicroMessengerTest < Minitest::Test
|
6
|
-
test "detects micro messenger
|
7
|
-
browser = Browser.new(Browser["
|
6
|
+
test "detects micro messenger 7.0.10 on iOS" do
|
7
|
+
browser = Browser.new(Browser["MICRO_MESSENGER_IOS"])
|
8
8
|
|
9
9
|
assert browser.micro_messenger?
|
10
10
|
assert browser.wechat?
|
11
|
-
assert_equal "
|
11
|
+
assert_equal "7.0.10", browser.full_version
|
12
12
|
assert_equal "MicroMessenger", browser.name
|
13
13
|
assert_equal :micro_messenger, browser.id
|
14
14
|
end
|
15
15
|
|
16
|
-
test "detects version by range" do
|
17
|
-
browser = Browser.new(Browser["
|
18
|
-
assert browser.wechat?(%w[>=
|
16
|
+
test "detects version by range on iOS" do
|
17
|
+
browser = Browser.new(Browser["MICRO_MESSENGER_IOS"])
|
18
|
+
assert browser.wechat?(%w[>=7 <8])
|
19
|
+
end
|
20
|
+
|
21
|
+
test "detects micro messenger 7.0.13.1640 on Android" do
|
22
|
+
browser = Browser.new(Browser["MICRO_MESSENGER_ANDROID"])
|
23
|
+
|
24
|
+
assert browser.micro_messenger?
|
25
|
+
assert browser.wechat?
|
26
|
+
assert_equal "7.0.13.1640", browser.full_version
|
27
|
+
assert_equal "MicroMessenger", browser.name
|
28
|
+
assert_equal :micro_messenger, browser.id
|
29
|
+
end
|
30
|
+
|
31
|
+
test "detects version by range on Android" do
|
32
|
+
browser = Browser.new(Browser["MICRO_MESSENGER_ANDROID"])
|
33
|
+
assert browser.wechat?(%w[>=7 <8])
|
19
34
|
end
|
20
35
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class MiuiBrowserTest < Minitest::Test
|
6
|
+
test "detects Miui Browser" do
|
7
|
+
browser = Browser.new(Browser["MIUI_BROWSER"])
|
8
|
+
assert browser.miui_browser?
|
9
|
+
refute browser.safari?
|
10
|
+
refute browser.chrome?
|
11
|
+
assert_equal "Miui Browser", browser.name
|
12
|
+
assert_equal :miui_browser, browser.id
|
13
|
+
end
|
14
|
+
|
15
|
+
test "detects correct version" do
|
16
|
+
browser = Browser.new(Browser["MIUI_BROWSER"])
|
17
|
+
assert_equal "12.3.3", browser.full_version
|
18
|
+
assert_equal "12", browser.version
|
19
|
+
end
|
20
|
+
|
21
|
+
test "detects version by range" do
|
22
|
+
browser = Browser.new(Browser["MIUI_BROWSER"])
|
23
|
+
assert browser.miui_browser?(%w[>=12 <13])
|
24
|
+
end
|
25
|
+
end
|
data/test/unit/opera_test.rb
CHANGED
@@ -8,7 +8,6 @@ class OperaTest < Minitest::Test
|
|
8
8
|
|
9
9
|
assert_equal "Opera", browser.name
|
10
10
|
assert browser.opera?
|
11
|
-
refute browser.modern?
|
12
11
|
assert_equal "11.64", browser.full_version
|
13
12
|
assert_equal "11", browser.version
|
14
13
|
end
|
@@ -20,8 +19,8 @@ class OperaTest < Minitest::Test
|
|
20
19
|
assert_equal :opera, browser.id
|
21
20
|
assert browser.opera?
|
22
21
|
assert browser.webkit?
|
23
|
-
assert browser.modern?
|
24
22
|
refute browser.chrome?
|
23
|
+
refute browser.safari?
|
25
24
|
assert_equal "15.0.1147.44", browser.full_version
|
26
25
|
assert_equal "15", browser.version
|
27
26
|
end
|
data/test/unit/platform_test.rb
CHANGED
@@ -5,7 +5,7 @@ require "test_helper"
|
|
5
5
|
class PlatformTest < Minitest::Test
|
6
6
|
class CustomPlatform < Browser::Platform::Base
|
7
7
|
def match?
|
8
|
-
ua
|
8
|
+
ua.include?("Custom")
|
9
9
|
end
|
10
10
|
|
11
11
|
def id
|
@@ -20,7 +20,7 @@ class PlatformTest < Minitest::Test
|
|
20
20
|
|
21
21
|
Browser::Platform.matchers.shift
|
22
22
|
platform = Browser::Platform.new("Custom")
|
23
|
-
assert_equal :
|
23
|
+
assert_equal :unknown_platform, platform.id
|
24
24
|
end
|
25
25
|
|
26
26
|
test "implements to_s" do
|
@@ -35,13 +35,13 @@ class PlatformTest < Minitest::Test
|
|
35
35
|
refute platform == :android
|
36
36
|
end
|
37
37
|
|
38
|
-
test "detect
|
39
|
-
platform = Browser::Platform.new("
|
38
|
+
test "detect unknown platforms" do
|
39
|
+
platform = Browser::Platform.new("Unknown")
|
40
40
|
|
41
|
-
assert_equal "
|
42
|
-
assert_equal :
|
41
|
+
assert_equal "Unknown", platform.name
|
42
|
+
assert_equal :unknown_platform, platform.id
|
43
43
|
assert_equal "0", platform.version
|
44
|
-
assert platform.
|
44
|
+
assert platform.unknown?
|
45
45
|
end
|
46
46
|
|
47
47
|
test "detect ios (iPhone)" do
|
@@ -62,6 +62,27 @@ class PlatformTest < Minitest::Test
|
|
62
62
|
assert_equal "9", platform.version
|
63
63
|
end
|
64
64
|
|
65
|
+
test "detect specific minor iOS (iPhone)" do
|
66
|
+
platform = Browser::Platform.new(Browser["IOS8_3"])
|
67
|
+
|
68
|
+
assert_equal "iOS (iPhone)", platform.name
|
69
|
+
assert_equal :ios, platform.id
|
70
|
+
assert platform.ios?
|
71
|
+
assert platform.ios?(8.3)
|
72
|
+
assert_equal "8.3", platform.version
|
73
|
+
end
|
74
|
+
|
75
|
+
test "detect specific patch iOS (iPhone)" do
|
76
|
+
platform = Browser::Platform.new(Browser["IOS8_1_2"])
|
77
|
+
|
78
|
+
assert_equal "iOS (iPhone)", platform.name
|
79
|
+
assert_equal :ios, platform.id
|
80
|
+
assert platform.ios?
|
81
|
+
assert platform.ios?("8.1.2")
|
82
|
+
assert platform.ios?("<8.2")
|
83
|
+
assert_equal "8.1.2", platform.version
|
84
|
+
end
|
85
|
+
|
65
86
|
test "detect ios (iPod Touch)" do
|
66
87
|
platform = Browser::Platform.new(Browser["IPOD"])
|
67
88
|
|
@@ -83,7 +104,7 @@ class PlatformTest < Minitest::Test
|
|
83
104
|
test "detect mac" do
|
84
105
|
platform = Browser::Platform.new(Browser["SAFARI"])
|
85
106
|
|
86
|
-
assert_equal "
|
107
|
+
assert_equal "Mac OS X", platform.name
|
87
108
|
assert_equal :mac, platform.id
|
88
109
|
assert platform.mac?
|
89
110
|
assert_equal "10.6.4", platform.version
|
@@ -95,6 +116,11 @@ class PlatformTest < Minitest::Test
|
|
95
116
|
assert_equal "0", platform.version
|
96
117
|
end
|
97
118
|
|
119
|
+
test "detect mac names" do
|
120
|
+
assert_equal "Mac OS X", Browser::Platform.new(Browser["MAC_OSX"]).name
|
121
|
+
assert_equal "macOS", Browser::Platform.new(Browser["MAC_OS"]).name
|
122
|
+
end
|
123
|
+
|
98
124
|
test "detect firefox os" do
|
99
125
|
platform = Browser::Platform.new(Browser["FIREFOX_OS"])
|
100
126
|
|
data/test/unit/qq_test.rb
CHANGED
@@ -9,6 +9,9 @@ class QQTest < Minitest::Test
|
|
9
9
|
assert_equal "6.3.3.432", browser.full_version
|
10
10
|
assert_equal "QQ Browser", browser.name
|
11
11
|
assert_equal :qq, browser.id
|
12
|
+
|
13
|
+
refute browser.chrome?
|
14
|
+
refute browser.safari?
|
12
15
|
end
|
13
16
|
|
14
17
|
test "detects QQ browser for Android" do
|
@@ -17,6 +20,9 @@ class QQTest < Minitest::Test
|
|
17
20
|
assert_equal "6.2", browser.full_version
|
18
21
|
assert_equal "QQ Browser", browser.name
|
19
22
|
assert_equal :qq, browser.id
|
23
|
+
|
24
|
+
refute browser.chrome?
|
25
|
+
refute browser.safari?
|
20
26
|
end
|
21
27
|
|
22
28
|
test "detects QQ browser for Mac" do
|
@@ -25,6 +31,9 @@ class QQTest < Minitest::Test
|
|
25
31
|
assert_equal "4.2.4753.400", browser.full_version
|
26
32
|
assert_equal "QQ Browser", browser.name
|
27
33
|
assert_equal :qq, browser.id
|
34
|
+
|
35
|
+
refute browser.chrome?
|
36
|
+
refute browser.safari?
|
28
37
|
end
|
29
38
|
|
30
39
|
test "detects QQ browser lite for Mac" do
|
@@ -33,5 +42,8 @@ class QQTest < Minitest::Test
|
|
33
42
|
assert_equal "1.0.4", browser.full_version
|
34
43
|
assert_equal "QQ Browser", browser.name
|
35
44
|
assert_equal :qq, browser.id
|
45
|
+
|
46
|
+
refute browser.chrome?
|
47
|
+
refute browser.safari?
|
36
48
|
end
|
37
49
|
end
|
data/test/unit/safari_test.rb
CHANGED
@@ -7,7 +7,7 @@ class SafariTest < Minitest::Test
|
|
7
7
|
browser = Browser.new(Browser["SAFARI3"])
|
8
8
|
|
9
9
|
assert browser.safari?
|
10
|
-
assert browser.safari?(3)
|
10
|
+
assert browser.safari?("~>3.0")
|
11
11
|
assert_equal "3", browser.version
|
12
12
|
assert_equal "3.0.3", browser.full_version
|
13
13
|
end
|
@@ -16,7 +16,7 @@ class SafariTest < Minitest::Test
|
|
16
16
|
browser = Browser.new(Browser["SAFARI4"])
|
17
17
|
|
18
18
|
assert browser.safari?
|
19
|
-
assert browser.safari?(4)
|
19
|
+
assert browser.safari?("~>4.0")
|
20
20
|
assert_equal "4", browser.version
|
21
21
|
assert_equal "4.0.3", browser.full_version
|
22
22
|
end
|
@@ -25,7 +25,7 @@ class SafariTest < Minitest::Test
|
|
25
25
|
browser = Browser.new(Browser["SAFARI5"])
|
26
26
|
|
27
27
|
assert browser.safari?
|
28
|
-
assert browser.safari?(5)
|
28
|
+
assert browser.safari?("~>5.0")
|
29
29
|
assert_equal "5", browser.version
|
30
30
|
assert_equal "5.0.3", browser.full_version
|
31
31
|
end
|
@@ -34,7 +34,7 @@ class SafariTest < Minitest::Test
|
|
34
34
|
browser = Browser.new(Browser["SAFARI6"])
|
35
35
|
|
36
36
|
assert browser.safari?
|
37
|
-
assert browser.safari?(6)
|
37
|
+
assert browser.safari?("~>6.0")
|
38
38
|
assert_equal "6", browser.version
|
39
39
|
assert_equal "6.0", browser.full_version
|
40
40
|
end
|
@@ -43,7 +43,7 @@ class SafariTest < Minitest::Test
|
|
43
43
|
browser = Browser.new(Browser["SAFARI7"])
|
44
44
|
|
45
45
|
assert browser.safari?
|
46
|
-
assert browser.safari?(7)
|
46
|
+
assert browser.safari?("~>7.0")
|
47
47
|
assert_equal "7", browser.version
|
48
48
|
assert_equal "7.0", browser.full_version
|
49
49
|
end
|
@@ -52,7 +52,7 @@ class SafariTest < Minitest::Test
|
|
52
52
|
browser = Browser.new(Browser["SAFARI8"])
|
53
53
|
|
54
54
|
assert browser.safari?
|
55
|
-
assert browser.safari?(8)
|
55
|
+
assert browser.safari?("~>8.0")
|
56
56
|
assert_equal "8", browser.version
|
57
57
|
assert_equal "8.0", browser.full_version
|
58
58
|
end
|
@@ -61,7 +61,7 @@ class SafariTest < Minitest::Test
|
|
61
61
|
browser = Browser.new(Browser["SAFARI9"])
|
62
62
|
|
63
63
|
assert browser.safari?
|
64
|
-
assert browser.safari?(9)
|
64
|
+
assert browser.safari?("~>9.0")
|
65
65
|
assert_equal "9", browser.version
|
66
66
|
assert_equal "9.0.2", browser.full_version
|
67
67
|
end
|
@@ -88,4 +88,9 @@ class SafariTest < Minitest::Test
|
|
88
88
|
browser = Browser.new(Browser["SAFARI9"])
|
89
89
|
assert browser.webkit?(%w[>=601 <602])
|
90
90
|
end
|
91
|
+
|
92
|
+
test "detects safari version by range" do
|
93
|
+
browser = Browser.new(Browser["SAFARI9"])
|
94
|
+
assert browser.safari?(%w[>=9.0 <10])
|
95
|
+
end
|
91
96
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class SamsungBrowserTest < Minitest::Test
|
6
|
+
test "detects samsung browser" do
|
7
|
+
browser = Browser.new(Browser["SAMSUNG_BROWSER"])
|
8
|
+
|
9
|
+
assert browser.webkit?
|
10
|
+
assert browser.samsung_browser?
|
11
|
+
assert_equal "11", browser.version
|
12
|
+
assert_equal :samsung_browser, browser.id
|
13
|
+
assert_equal "11.1", browser.full_version
|
14
|
+
assert_equal "Samsung Browser", browser.name
|
15
|
+
refute browser.chrome?
|
16
|
+
refute browser.safari?
|
17
|
+
end
|
18
|
+
|
19
|
+
test "detects version by range" do
|
20
|
+
browser = Browser.new(Browser["SAMSUNG_BROWSER"])
|
21
|
+
assert browser.samsung_browser?(%w[>=11 <12])
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class SnapchatTest < Minitest::Test
|
6
|
+
test "detects snapchat" do
|
7
|
+
browser = Browser.new(Browser["SNAPCHAT"])
|
8
|
+
|
9
|
+
assert_equal "Snapchat", browser.name
|
10
|
+
assert browser.snapchat?
|
11
|
+
assert :snapchat, browser.id
|
12
|
+
assert_equal "10.69.5.72", browser.full_version
|
13
|
+
assert_equal "10", browser.version
|
14
|
+
end
|
15
|
+
|
16
|
+
test "detects snapchat for badly formatted user agent" do
|
17
|
+
browser = Browser.new(Browser["SNAPCHAT_EMPTY_STRING_VERSION"])
|
18
|
+
|
19
|
+
assert_equal "Snapchat", browser.name
|
20
|
+
assert browser.snapchat?
|
21
|
+
assert :snapchat, browser.id
|
22
|
+
assert_equal "10.70.0.0", browser.full_version
|
23
|
+
assert_equal "10", browser.version
|
24
|
+
end
|
25
|
+
|
26
|
+
test "detects alternate snapchat user agent" do
|
27
|
+
browser = Browser.new(Browser["SNAPCHAT_SPACE_VERSION"])
|
28
|
+
|
29
|
+
assert_equal "Snapchat", browser.name
|
30
|
+
assert browser.snapchat?
|
31
|
+
assert :snapchat, browser.id
|
32
|
+
assert_equal "10.70.0.0", browser.full_version
|
33
|
+
assert_equal "10", browser.version
|
34
|
+
end
|
35
|
+
|
36
|
+
test "detects version by range" do
|
37
|
+
browser = Browser.new(Browser["SNAPCHAT"])
|
38
|
+
assert browser.snapchat?(%w[>=10])
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class SougouBrowserTest < Minitest::Test
|
6
|
+
test "detects Sougou Browser on desktop device" do
|
7
|
+
browser = Browser.new(Browser["SOUGOU_BROWSER"])
|
8
|
+
assert browser.sougou_browser?
|
9
|
+
refute browser.safari?
|
10
|
+
refute browser.chrome?
|
11
|
+
assert_equal "Sougou Browser", browser.name
|
12
|
+
assert_equal :sougou_browser, browser.id
|
13
|
+
end
|
14
|
+
|
15
|
+
test "detects correct version on desktop device" do
|
16
|
+
browser = Browser.new(Browser["SOUGOU_BROWSER"])
|
17
|
+
assert_equal "0.0", browser.full_version
|
18
|
+
assert_equal "0", browser.version
|
19
|
+
end
|
20
|
+
|
21
|
+
test "detects Sougou Browser on mobile device" do
|
22
|
+
browser = Browser.new(Browser["SOUGOU_BROWSER_MOBILE"])
|
23
|
+
assert browser.sougou_browser?
|
24
|
+
assert browser.device.mobile?
|
25
|
+
refute browser.safari?
|
26
|
+
refute browser.chrome?
|
27
|
+
assert_equal "Sougou Browser", browser.name
|
28
|
+
assert_equal :sougou_browser, browser.id
|
29
|
+
end
|
30
|
+
|
31
|
+
test "detects correct version on mobile device" do
|
32
|
+
browser = Browser.new(Browser["SOUGOU_BROWSER_MOBILE"])
|
33
|
+
assert_equal "5.28.12", browser.full_version
|
34
|
+
assert_equal "5", browser.version
|
35
|
+
end
|
36
|
+
|
37
|
+
test "detects version by range on mobile device" do
|
38
|
+
browser = Browser.new(Browser["SOUGOU_BROWSER_MOBILE"])
|
39
|
+
assert browser.sougou_browser?(%w[>=5 <6])
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_helper"
|
4
|
+
|
5
|
+
class SputnikTest < Minitest::Test
|
6
|
+
test "detects sputnik" do
|
7
|
+
browser = Browser.new(Browser["SPUTNIK"])
|
8
|
+
|
9
|
+
assert_equal "Sputnik", browser.name
|
10
|
+
assert_equal :sputnik, browser.id
|
11
|
+
assert browser.sputnik?
|
12
|
+
refute browser.chrome?
|
13
|
+
refute browser.safari?
|
14
|
+
assert_equal "4.1.2801.0", browser.full_version
|
15
|
+
assert_equal "4", browser.version
|
16
|
+
end
|
17
|
+
|
18
|
+
test "detects version by range" do
|
19
|
+
browser = Browser.new(Browser["SPUTNIK"])
|
20
|
+
assert browser.sputnik?(%w[>=4 <5])
|
21
|
+
end
|
22
|
+
end
|