browser 2.7.1 → 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 +13 -1
- data/CHANGELOG.md +122 -13
- data/FUNDING.yml +3 -0
- data/README.md +134 -88
- data/Rakefile +8 -1
- data/bot_exceptions.yml +1 -0
- data/bots.yml +300 -293
- data/browser.gemspec +4 -1
- data/gemfiles/{rails5.gemfile → rails6_1.gemfile} +1 -1
- data/lib/browser/accept_language.rb +4 -4
- data/lib/browser/aliases.rb +1 -1
- data/lib/browser/alipay.rb +1 -1
- data/lib/browser/base.rb +82 -18
- data/lib/browser/blackberry.rb +1 -1
- 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 +34 -26
- data/lib/browser/browser.rb +59 -56
- data/lib/browser/chrome.rb +13 -3
- data/lib/browser/device/android.rb +1 -1
- 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 +1 -1
- data/lib/browser/device/switch.rb +1 -1
- 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 +37 -27
- data/lib/browser/duck_duck_go.rb +22 -0
- data/lib/browser/edge.rb +3 -3
- data/lib/browser/electron.rb +1 -1
- data/lib/browser/facebook.rb +1 -1
- data/lib/browser/firefox.rb +1 -1
- data/lib/browser/google_search_app.rb +21 -0
- data/lib/browser/huawei_browser.rb +21 -0
- data/lib/browser/instagram.rb +1 -1
- data/lib/browser/internet_explorer.rb +2 -2
- data/lib/browser/maxthon.rb +21 -0
- data/lib/browser/meta/base.rb +0 -1
- data/lib/browser/meta.rb +12 -13
- data/lib/browser/micro_messenger.rb +1 -1
- data/lib/browser/middleware/context/additions.rb +1 -1
- data/lib/browser/middleware.rb +1 -1
- data/lib/browser/miui_browser.rb +21 -0
- data/lib/browser/nokia.rb +1 -1
- data/lib/browser/opera.rb +1 -1
- data/lib/browser/otter.rb +1 -1
- data/lib/browser/phantom_js.rb +1 -1
- data/lib/browser/platform/adobe_air.rb +1 -1
- data/lib/browser/platform/android.rb +1 -1
- data/lib/browser/platform/base.rb +3 -2
- data/lib/browser/platform/blackberry.rb +1 -1
- data/lib/browser/platform/chrome_os.rb +1 -1
- data/lib/browser/platform/firefox_os.rb +1 -1
- data/lib/browser/platform/ios.rb +2 -2
- 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 +1 -1
- data/lib/browser/rails.rb +3 -3
- data/lib/browser/safari.rb +16 -1
- data/lib/browser/samsung_browser.rb +21 -0
- data/lib/browser/snapchat.rb +1 -1
- data/lib/browser/sougou_browser.rb +24 -0
- data/lib/browser/sputnik.rb +2 -5
- data/lib/browser/uc_browser.rb +1 -1
- data/lib/browser/{generic.rb → unknown.rb} +3 -3
- data/lib/browser/version.rb +1 -1
- data/lib/browser/weibo.rb +1 -1
- data/lib/browser/yandex.rb +1 -1
- data/lib/browser.rb +2 -2
- data/samsung.yml +138 -0
- data/test/browser_test.rb +37 -10
- data/test/test_helper.rb +8 -0
- data/test/ua.yml +26 -3
- data/test/ua_bots.yml +9 -2
- data/test/ua_search_engines.yml +1 -0
- data/test/unit/accept_language_test.rb +6 -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 +26 -39
- data/test/unit/chrome_test.rb +8 -3
- data/test/unit/console_test.rb +2 -2
- data/test/unit/device_test.rb +30 -3
- data/test/unit/duck_duck_go_test.rb +37 -0
- data/test/unit/edge_test.rb +34 -6
- 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/internet_explorer_test.rb +0 -12
- data/test/unit/ios_test.rb +0 -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 +13 -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/sougou_browser_test.rb +41 -0
- data/test/unit/sputnik_test.rb +1 -0
- metadata +46 -16
- data/.bundle/config +0 -2
- data/.travis.yml +0 -23
- data/lib/browser/meta/modern.rb +0 -11
- /data/gemfiles/{rails6.gemfile → rails6_0.gemfile} +0 -0
@@ -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
|
@@ -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
|
@@ -126,7 +123,6 @@ class IosTest < Minitest::Test
|
|
126
123
|
assert meta.include?("ios")
|
127
124
|
assert meta.include?("safari")
|
128
125
|
assert meta.include?("safari3")
|
129
|
-
assert meta.include?("modern")
|
130
126
|
assert meta.include?("mobile")
|
131
127
|
refute meta.include?("tablet")
|
132
128
|
end
|
@@ -138,7 +134,6 @@ class IosTest < Minitest::Test
|
|
138
134
|
assert meta.include?("webkit")
|
139
135
|
assert meta.include?("ios")
|
140
136
|
assert meta.include?("safari")
|
141
|
-
assert meta.include?("modern")
|
142
137
|
assert meta.include?("tablet")
|
143
138
|
refute meta.include?("mobile")
|
144
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
|
@@ -104,7 +104,7 @@ class PlatformTest < Minitest::Test
|
|
104
104
|
test "detect mac" do
|
105
105
|
platform = Browser::Platform.new(Browser["SAFARI"])
|
106
106
|
|
107
|
-
assert_equal "
|
107
|
+
assert_equal "Mac OS X", platform.name
|
108
108
|
assert_equal :mac, platform.id
|
109
109
|
assert platform.mac?
|
110
110
|
assert_equal "10.6.4", platform.version
|
@@ -116,6 +116,11 @@ class PlatformTest < Minitest::Test
|
|
116
116
|
assert_equal "0", platform.version
|
117
117
|
end
|
118
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
|
+
|
119
124
|
test "detect firefox os" do
|
120
125
|
platform = Browser::Platform.new(Browser["FIREFOX_OS"])
|
121
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,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
|
data/test/unit/sputnik_test.rb
CHANGED