browser 1.1.0 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bundle/config +2 -0
- data/.hound.yml +26 -6
- data/.rubocop.yml +26 -6
- data/CHANGELOG.md +10 -0
- data/README.md +177 -41
- data/Rakefile +1 -1
- data/bin/rake +16 -0
- data/bot_exceptions.yml +1 -0
- data/bots.yml +188 -192
- data/browser.gemspec +14 -28
- data/languages.yml +54 -54
- data/lib/browser.rb +82 -202
- data/lib/browser/accept_language.rb +47 -0
- data/lib/browser/action_controller.rb +1 -1
- data/lib/browser/base.rb +159 -0
- data/lib/browser/blackberry.rb +21 -0
- data/lib/browser/bot.rb +63 -0
- data/lib/browser/chrome.rb +23 -0
- data/lib/browser/detect_version.rb +19 -0
- data/lib/browser/device.rb +175 -0
- data/lib/browser/device/base.rb +11 -0
- data/lib/browser/device/blackberry_playbook.rb +17 -0
- data/lib/browser/device/ipad.rb +17 -0
- data/lib/browser/device/iphone.rb +17 -0
- data/lib/browser/device/ipod_touch.rb +17 -0
- data/lib/browser/device/kindle.rb +17 -0
- data/lib/browser/device/kindle_fire.rb +17 -0
- data/lib/browser/device/playstation3.rb +17 -0
- data/lib/browser/device/playstation4.rb +17 -0
- data/lib/browser/device/psp.rb +17 -0
- data/lib/browser/device/psvita.rb +17 -0
- data/lib/browser/device/surface.rb +23 -0
- data/lib/browser/device/tv.rb +17 -0
- data/lib/browser/device/unknown.rb +17 -0
- data/lib/browser/device/wii.rb +17 -0
- data/lib/browser/device/wiiu.rb +17 -0
- data/lib/browser/device/xbox_360.rb +17 -0
- data/lib/browser/device/xbox_one.rb +17 -0
- data/lib/browser/edge.rb +19 -0
- data/lib/browser/firefox.rb +19 -0
- data/lib/browser/generic.rb +32 -0
- data/lib/browser/internet_explorer.rb +61 -0
- data/lib/browser/meta/base.rb +1 -1
- data/lib/browser/meta/device.rb +9 -0
- data/lib/browser/meta/generic_browser.rb +1 -1
- data/lib/browser/meta/id.rb +1 -1
- data/lib/browser/meta/ie.rb +1 -1
- data/lib/browser/meta/ios.rb +2 -2
- data/lib/browser/meta/mobile.rb +2 -2
- data/lib/browser/meta/modern.rb +1 -1
- data/lib/browser/meta/platform.rb +2 -2
- data/lib/browser/meta/proxy.rb +1 -1
- data/lib/browser/meta/safari.rb +1 -1
- data/lib/browser/meta/tablet.rb +9 -0
- data/lib/browser/meta/webkit.rb +1 -1
- data/lib/browser/middleware.rb +1 -1
- data/lib/browser/middleware/context.rb +2 -2
- data/lib/browser/middleware/context/additions.rb +1 -1
- data/lib/browser/middleware/context/url_methods.rb +3 -3
- data/lib/browser/nokia.rb +19 -0
- data/lib/browser/opera.rb +19 -0
- data/lib/browser/phantom_js.rb +19 -0
- data/lib/browser/platform.rb +152 -0
- data/lib/browser/platform/adobe_air.rb +21 -0
- data/lib/browser/platform/android.rb +21 -0
- data/lib/browser/platform/base.rb +15 -0
- data/lib/browser/platform/blackberry.rb +21 -0
- data/lib/browser/platform/chrome_os.rb +21 -0
- data/lib/browser/platform/firefox_os.rb +21 -0
- data/lib/browser/platform/ios.rb +28 -0
- data/lib/browser/platform/linux.rb +21 -0
- data/lib/browser/platform/mac.rb +21 -0
- data/lib/browser/platform/other.rb +21 -0
- data/lib/browser/platform/windows.rb +21 -0
- data/lib/browser/platform/windows_mobile.rb +21 -0
- data/lib/browser/platform/windows_phone.rb +21 -0
- data/lib/browser/rails.rb +3 -2
- data/lib/browser/safari.rb +22 -0
- data/lib/browser/testing.rb +23 -0
- data/lib/browser/uc_browser.rb +19 -0
- data/lib/browser/version.rb +2 -7
- data/search_engines.yml +5 -5
- data/test/browser_test.rb +71 -172
- data/test/middleware_test.rb +7 -7
- data/test/sample_app.rb +3 -3
- data/test/test_helper.rb +11 -10
- data/test/ua.yml +15 -26
- data/test/ua_bots.yml +27 -0
- data/test/ua_search_engines.yml +6 -0
- data/test/unit/accept_language_test.rb +92 -0
- data/test/unit/adobe_air_test.rb +5 -10
- data/test/unit/android_test.rb +44 -49
- data/test/unit/blackberry_test.rb +55 -77
- data/test/unit/bots_test.rb +52 -84
- data/test/unit/chrome_test.rb +48 -42
- data/test/unit/console_test.rb +4 -62
- data/test/unit/device_test.rb +193 -0
- data/test/unit/firefox_test.rb +32 -27
- data/test/unit/ie_test.rb +223 -238
- data/test/unit/ios_app_test.rb +3 -3
- data/test/unit/ios_test.rb +87 -94
- data/test/unit/kindle_test.rb +10 -24
- data/test/unit/nokia_test.rb +3 -7
- data/test/unit/opera_test.rb +20 -30
- data/test/unit/platform_test.rb +161 -0
- data/test/unit/proxy_test.rb +3 -3
- data/test/unit/safari_test.rb +66 -0
- data/test/unit/uc_browser_test.rb +3 -7
- data/test/unit/windows_phone_test.rb +19 -40
- data/test/unit/windows_test.rb +32 -34
- metadata +73 -28
- data/lib/browser/methods/blackberry.rb +0 -51
- data/lib/browser/methods/bots.rb +0 -35
- data/lib/browser/methods/consoles.rb +0 -43
- data/lib/browser/methods/devices.rb +0 -41
- data/lib/browser/methods/ie.rb +0 -99
- data/lib/browser/methods/language.rb +0 -16
- data/lib/browser/methods/mobile.rb +0 -35
- data/lib/browser/methods/platform.rb +0 -152
- data/lib/browser/methods/proxy.rb +0 -8
- data/lib/browser/methods/tv.rb +0 -8
@@ -0,0 +1,193 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class DeviceTest < Minitest::Test
|
4
|
+
test "detect generic device" do
|
5
|
+
device = Browser::Device.new("")
|
6
|
+
|
7
|
+
assert device.unknown?
|
8
|
+
assert_equal :unknown, device.id
|
9
|
+
end
|
10
|
+
|
11
|
+
test "detect ipad" do
|
12
|
+
device = Browser::Device.new(Browser["IOS9"])
|
13
|
+
assert device.ipad?
|
14
|
+
assert_equal :ipad, device.id
|
15
|
+
assert_equal "iPad", device.name
|
16
|
+
end
|
17
|
+
|
18
|
+
test "detect ipod" do
|
19
|
+
device = Browser::Device.new(Browser["IPOD"])
|
20
|
+
assert device.ipod_touch?
|
21
|
+
assert device.ipod?
|
22
|
+
assert_equal :ipod_touch, device.id
|
23
|
+
assert_equal "iPod Touch", device.name
|
24
|
+
end
|
25
|
+
|
26
|
+
test "detect iphone" do
|
27
|
+
device = Browser::Device.new(Browser["IOS8"])
|
28
|
+
assert device.iphone?
|
29
|
+
assert_equal :iphone, device.id
|
30
|
+
assert_equal "iPhone", device.name
|
31
|
+
end
|
32
|
+
|
33
|
+
test "detect ps3" do
|
34
|
+
device = Browser::Device.new(Browser["PLAYSTATION3"])
|
35
|
+
assert device.ps3?
|
36
|
+
assert device.playstation3?
|
37
|
+
assert device.playstation?
|
38
|
+
assert_equal :ps3, device.id
|
39
|
+
assert_equal "PlayStation 3", device.name
|
40
|
+
end
|
41
|
+
|
42
|
+
test "detect ps4" do
|
43
|
+
device = Browser::Device.new(Browser["PLAYSTATION4"])
|
44
|
+
assert device.ps4?
|
45
|
+
assert device.playstation4?
|
46
|
+
assert device.playstation?
|
47
|
+
assert_equal :ps4, device.id
|
48
|
+
assert_equal "PlayStation 4", device.name
|
49
|
+
end
|
50
|
+
|
51
|
+
test "detects xbox 360" do
|
52
|
+
device = Browser::Device.new(Browser["XBOX360"])
|
53
|
+
|
54
|
+
assert device.console?
|
55
|
+
assert device.xbox?
|
56
|
+
refute device.xbox_one?
|
57
|
+
assert_equal :xbox_360, device.id
|
58
|
+
assert_equal "Xbox 360", device.name
|
59
|
+
end
|
60
|
+
|
61
|
+
test "detects xbox one" do
|
62
|
+
device = Browser::Device.new(Browser["XBOXONE"])
|
63
|
+
|
64
|
+
assert device.console?
|
65
|
+
assert device.xbox?
|
66
|
+
assert device.xbox_one?
|
67
|
+
assert_equal :xbox_one, device.id
|
68
|
+
assert_equal "Xbox One", device.name
|
69
|
+
end
|
70
|
+
|
71
|
+
test "detect psp" do
|
72
|
+
device = Browser::Device.new(Browser["PSP"])
|
73
|
+
assert device.psp?
|
74
|
+
assert_equal :psp, device.id
|
75
|
+
assert_equal "PlayStation Portable", device.name
|
76
|
+
end
|
77
|
+
|
78
|
+
test "detect psvita" do
|
79
|
+
device = Browser::Device.new(Browser["PSP_VITA"])
|
80
|
+
assert device.playstation_vita?
|
81
|
+
assert device.vita?
|
82
|
+
assert_equal :psvita, device.id
|
83
|
+
assert_equal "PlayStation Vita", device.name
|
84
|
+
end
|
85
|
+
|
86
|
+
test "detect kindle" do
|
87
|
+
device = Browser::Device.new(Browser["KINDLE"])
|
88
|
+
assert device.kindle?
|
89
|
+
assert_equal :kindle, device.id
|
90
|
+
assert_equal "Kindle", device.name
|
91
|
+
refute device.silk?
|
92
|
+
end
|
93
|
+
|
94
|
+
%w[
|
95
|
+
KINDLE_FIRE
|
96
|
+
KINDLE_FIRE_HD
|
97
|
+
KINDLE_FIRE_HD_MOBILE
|
98
|
+
].each do |key|
|
99
|
+
test "detect #{key} as kindle fire" do
|
100
|
+
device = Browser::Device.new(Browser[key])
|
101
|
+
|
102
|
+
assert device.kindle?
|
103
|
+
assert device.kindle_fire?
|
104
|
+
assert_equal :kindle_fire, device.id
|
105
|
+
assert_equal "Kindle Fire", device.name
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
test "detect wii" do
|
110
|
+
device = Browser::Device.new(Browser["NINTENDO_WII"])
|
111
|
+
assert device.nintendo_wii?
|
112
|
+
assert device.console?
|
113
|
+
assert device.nintendo?
|
114
|
+
assert device.wii?
|
115
|
+
assert_equal :wii, device.id
|
116
|
+
assert_equal "Nintendo Wii", device.name
|
117
|
+
end
|
118
|
+
|
119
|
+
test "detect wiiu" do
|
120
|
+
device = Browser::Device.new(Browser["NINTENDO_WIIU"])
|
121
|
+
assert device.nintendo_wiiu?
|
122
|
+
assert device.wiiu?
|
123
|
+
assert device.console?
|
124
|
+
assert device.nintendo?
|
125
|
+
assert_equal :wiiu, device.id
|
126
|
+
assert_equal "Nintendo WiiU", device.name
|
127
|
+
end
|
128
|
+
|
129
|
+
test "detect blackberry playbook" do
|
130
|
+
device = Browser::Device.new(Browser["PLAYBOOK"])
|
131
|
+
assert device.playbook?
|
132
|
+
assert device.blackberry_playbook?
|
133
|
+
assert_equal :playbook, device.id
|
134
|
+
assert_equal "BlackBerry Playbook", device.name
|
135
|
+
end
|
136
|
+
|
137
|
+
test "detect surface" do
|
138
|
+
device = Browser::Device.new(Browser["SURFACE"])
|
139
|
+
assert device.surface?
|
140
|
+
assert_equal :surface, device.id
|
141
|
+
assert_equal "Microsoft Surface", device.name
|
142
|
+
end
|
143
|
+
|
144
|
+
test "detect tv" do
|
145
|
+
device = Browser::Device.new(Browser["SMART_TV"])
|
146
|
+
assert device.tv?
|
147
|
+
assert_equal :tv, device.id
|
148
|
+
assert_equal "TV", device.name
|
149
|
+
end
|
150
|
+
|
151
|
+
%w[
|
152
|
+
ANDROID
|
153
|
+
SYMBIAN
|
154
|
+
MIDP
|
155
|
+
IPHONE
|
156
|
+
IPOD
|
157
|
+
WINDOWS_MOBILE
|
158
|
+
WINDOWS_PHONE
|
159
|
+
WINDOWS_PHONE8
|
160
|
+
WINDOWS_PHONE_81
|
161
|
+
OPERA_MINI
|
162
|
+
LUMIA800
|
163
|
+
MS_EDGE_MOBILE
|
164
|
+
UC_BROWSER
|
165
|
+
NOKIA
|
166
|
+
OPERA_MOBI
|
167
|
+
KINDLE_FIRE_HD_MOBILE
|
168
|
+
].each do |key|
|
169
|
+
test "detect #{key} as mobile" do
|
170
|
+
device = Browser::Device.new(Browser[key])
|
171
|
+
assert device.mobile?
|
172
|
+
refute device.tablet?
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
%w[
|
177
|
+
PLAYBOOK
|
178
|
+
IPAD
|
179
|
+
NEXUS_TABLET
|
180
|
+
SURFACE
|
181
|
+
XOOM
|
182
|
+
NOOK
|
183
|
+
SAMSUNG
|
184
|
+
FIREFOX_TABLET
|
185
|
+
NEXUS7
|
186
|
+
].each do |key|
|
187
|
+
test "detect #{key} as tablet" do
|
188
|
+
device = Browser::Device.new(Browser[key])
|
189
|
+
assert device.tablet?
|
190
|
+
refute device.mobile?
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
data/test/unit/firefox_test.rb
CHANGED
@@ -1,41 +1,46 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
class FirefoxTest < Minitest::Test
|
4
|
-
|
5
|
-
|
4
|
+
test "detects firefox" do
|
5
|
+
browser = Browser.new(Browser["FIREFOX"])
|
6
|
+
|
7
|
+
assert_equal "Firefox", browser.name
|
8
|
+
assert browser.firefox?
|
9
|
+
refute browser.modern?
|
10
|
+
assert_equal "3.8", browser.full_version
|
11
|
+
assert_equal "3", browser.version
|
6
12
|
end
|
7
13
|
|
8
|
-
test "detects firefox" do
|
9
|
-
|
14
|
+
test "detects firefox for iOS" do
|
15
|
+
browser = Browser.new(Browser["FIREFOX_IOS"])
|
10
16
|
|
11
|
-
assert_equal "Firefox",
|
12
|
-
assert
|
13
|
-
|
14
|
-
assert_equal "
|
15
|
-
assert_equal "
|
17
|
+
assert_equal "Firefox", browser.name
|
18
|
+
assert browser.firefox?
|
19
|
+
assert browser.platform.ios?
|
20
|
+
assert_equal "1.2", browser.full_version
|
21
|
+
assert_equal "1", browser.version
|
16
22
|
end
|
17
23
|
|
18
24
|
test "detects modern firefox" do
|
19
|
-
|
20
|
-
|
21
|
-
assert_equal :firefox,
|
22
|
-
assert_equal "Firefox",
|
23
|
-
assert
|
24
|
-
assert
|
25
|
-
assert_equal "17.0",
|
26
|
-
assert_equal "17",
|
25
|
+
browser = Browser.new(Browser["FIREFOX_MODERN"])
|
26
|
+
|
27
|
+
assert_equal :firefox, browser.id
|
28
|
+
assert_equal "Firefox", browser.name
|
29
|
+
assert browser.firefox?
|
30
|
+
assert browser.modern?
|
31
|
+
assert_equal "17.0", browser.full_version
|
32
|
+
assert_equal "17", browser.version
|
27
33
|
end
|
28
34
|
|
29
35
|
test "detects firefox android tablet" do
|
30
|
-
|
31
|
-
|
32
|
-
assert_equal :firefox,
|
33
|
-
assert_equal "Firefox",
|
34
|
-
assert
|
35
|
-
assert
|
36
|
-
assert
|
37
|
-
|
38
|
-
assert_equal "14
|
39
|
-
assert_equal "14", @browser.version
|
36
|
+
browser = Browser.new(Browser["FIREFOX_TABLET"])
|
37
|
+
|
38
|
+
assert_equal :firefox, browser.id
|
39
|
+
assert_equal "Firefox", browser.name
|
40
|
+
assert browser.firefox?
|
41
|
+
assert browser.modern?
|
42
|
+
assert browser.platform.android?
|
43
|
+
assert_equal "14.0", browser.full_version
|
44
|
+
assert_equal "14", browser.version
|
40
45
|
end
|
41
46
|
end
|
data/test/unit/ie_test.rb
CHANGED
@@ -1,340 +1,325 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
class IeTest < Minitest::Test
|
4
|
-
setup do
|
5
|
-
@browser = Browser.new
|
6
|
-
end
|
7
|
-
|
8
4
|
test "detects ie6" do
|
9
|
-
|
5
|
+
browser = Browser.new(Browser["IE6"])
|
10
6
|
|
11
|
-
assert_equal "Internet Explorer",
|
12
|
-
assert
|
13
|
-
assert
|
14
|
-
refute
|
15
|
-
assert_equal "6.0",
|
16
|
-
assert_equal "6",
|
7
|
+
assert_equal "Internet Explorer", browser.name
|
8
|
+
assert browser.ie?
|
9
|
+
assert browser.ie?(6)
|
10
|
+
refute browser.modern?
|
11
|
+
assert_equal "6.0", browser.full_version
|
12
|
+
assert_equal "6", browser.version
|
17
13
|
end
|
18
14
|
|
19
15
|
test "detects ie7" do
|
20
|
-
|
16
|
+
browser = Browser.new(Browser["IE7"])
|
21
17
|
|
22
|
-
assert_equal "Internet Explorer",
|
23
|
-
assert
|
24
|
-
assert
|
25
|
-
refute
|
26
|
-
assert_equal "7.0",
|
27
|
-
assert_equal "7",
|
18
|
+
assert_equal "Internet Explorer", browser.name
|
19
|
+
assert browser.ie?
|
20
|
+
assert browser.ie?(7)
|
21
|
+
refute browser.modern?
|
22
|
+
assert_equal "7.0", browser.full_version
|
23
|
+
assert_equal "7", browser.version
|
28
24
|
end
|
29
25
|
|
30
26
|
test "detects ie8" do
|
31
|
-
|
27
|
+
browser = Browser.new(Browser["IE8"])
|
32
28
|
|
33
|
-
assert_equal "Internet Explorer",
|
34
|
-
assert
|
35
|
-
assert
|
36
|
-
refute
|
37
|
-
refute
|
38
|
-
assert_equal "8.0",
|
39
|
-
assert_equal "8",
|
29
|
+
assert_equal "Internet Explorer", browser.name
|
30
|
+
assert browser.ie?
|
31
|
+
assert browser.ie?(8)
|
32
|
+
refute browser.modern?
|
33
|
+
refute browser.compatibility_view?
|
34
|
+
assert_equal "8.0", browser.full_version
|
35
|
+
assert_equal "8", browser.version
|
40
36
|
end
|
41
37
|
|
42
38
|
test "detects ie8 in compatibility view" do
|
43
|
-
|
39
|
+
browser = Browser.new(Browser["IE8_COMPAT"])
|
44
40
|
|
45
|
-
assert_equal "Internet Explorer",
|
46
|
-
assert
|
47
|
-
assert
|
48
|
-
refute
|
49
|
-
assert
|
50
|
-
assert_equal "8.0",
|
51
|
-
assert_equal "8",
|
52
|
-
assert_equal "7.0",
|
53
|
-
assert_equal "7",
|
41
|
+
assert_equal "Internet Explorer", browser.name
|
42
|
+
assert browser.ie?
|
43
|
+
assert browser.ie?(8)
|
44
|
+
refute browser.modern?
|
45
|
+
assert browser.compatibility_view?
|
46
|
+
assert_equal "8.0", browser.full_version
|
47
|
+
assert_equal "8", browser.version
|
48
|
+
assert_equal "7.0", browser.msie_full_version
|
49
|
+
assert_equal "7", browser.msie_version
|
54
50
|
end
|
55
51
|
|
56
52
|
test "detects ie9" do
|
57
|
-
|
53
|
+
browser = Browser.new(Browser["IE9"])
|
58
54
|
|
59
|
-
assert_equal "Internet Explorer",
|
60
|
-
assert
|
61
|
-
assert
|
62
|
-
assert
|
63
|
-
refute
|
64
|
-
assert_equal "9.0",
|
65
|
-
assert_equal "9",
|
55
|
+
assert_equal "Internet Explorer", browser.name
|
56
|
+
assert browser.ie?
|
57
|
+
assert browser.ie?(9)
|
58
|
+
assert browser.modern?
|
59
|
+
refute browser.compatibility_view?
|
60
|
+
assert_equal "9.0", browser.full_version
|
61
|
+
assert_equal "9", browser.version
|
66
62
|
end
|
67
63
|
|
68
64
|
test "detects ie9 in compatibility view" do
|
69
|
-
|
65
|
+
browser = Browser.new(Browser["IE9_COMPAT"])
|
70
66
|
|
71
|
-
assert_equal "Internet Explorer",
|
72
|
-
assert
|
73
|
-
assert
|
74
|
-
refute
|
75
|
-
assert
|
76
|
-
assert_equal "9.0",
|
77
|
-
assert_equal "9",
|
78
|
-
assert_equal "7.0",
|
79
|
-
assert_equal "7",
|
67
|
+
assert_equal "Internet Explorer", browser.name
|
68
|
+
assert browser.ie?
|
69
|
+
assert browser.ie?(9)
|
70
|
+
refute browser.modern?
|
71
|
+
assert browser.compatibility_view?
|
72
|
+
assert_equal "9.0", browser.full_version
|
73
|
+
assert_equal "9", browser.version
|
74
|
+
assert_equal "7.0", browser.msie_full_version
|
75
|
+
assert_equal "7", browser.msie_version
|
80
76
|
end
|
81
77
|
|
82
78
|
test "detects ie10" do
|
83
|
-
|
79
|
+
browser = Browser.new(Browser["IE10"])
|
84
80
|
|
85
|
-
assert_equal "Internet Explorer",
|
86
|
-
assert
|
87
|
-
assert
|
88
|
-
assert
|
89
|
-
refute
|
90
|
-
assert_equal "10.0",
|
91
|
-
assert_equal "10",
|
81
|
+
assert_equal "Internet Explorer", browser.name
|
82
|
+
assert browser.ie?
|
83
|
+
assert browser.ie?(10)
|
84
|
+
assert browser.modern?
|
85
|
+
refute browser.compatibility_view?
|
86
|
+
assert_equal "10.0", browser.full_version
|
87
|
+
assert_equal "10", browser.version
|
92
88
|
end
|
93
89
|
|
94
90
|
test "detects ie10 in compatibility view" do
|
95
|
-
|
91
|
+
browser = Browser.new(Browser["IE10_COMPAT"])
|
96
92
|
|
97
|
-
assert_equal "Internet Explorer",
|
98
|
-
assert
|
99
|
-
assert
|
100
|
-
refute
|
101
|
-
assert
|
102
|
-
assert_equal "10.0",
|
103
|
-
assert_equal "10",
|
104
|
-
assert_equal "7.0",
|
105
|
-
assert_equal "7",
|
93
|
+
assert_equal "Internet Explorer", browser.name
|
94
|
+
assert browser.ie?
|
95
|
+
assert browser.ie?(10)
|
96
|
+
refute browser.modern?
|
97
|
+
assert browser.compatibility_view?
|
98
|
+
assert_equal "10.0", browser.full_version
|
99
|
+
assert_equal "10", browser.version
|
100
|
+
assert_equal "7.0", browser.msie_full_version
|
101
|
+
assert_equal "7", browser.msie_version
|
106
102
|
end
|
107
103
|
|
108
104
|
test "detects ie11" do
|
109
|
-
|
105
|
+
browser = Browser.new(Browser["IE11"])
|
110
106
|
|
111
|
-
assert_equal "Internet Explorer",
|
112
|
-
assert
|
113
|
-
assert
|
114
|
-
assert
|
115
|
-
refute
|
116
|
-
assert_equal "11.0",
|
117
|
-
assert_equal "11",
|
107
|
+
assert_equal "Internet Explorer", browser.name
|
108
|
+
assert browser.ie?
|
109
|
+
assert browser.ie?(11)
|
110
|
+
assert browser.modern?
|
111
|
+
refute browser.compatibility_view?
|
112
|
+
assert_equal "11.0", browser.full_version
|
113
|
+
assert_equal "11", browser.version
|
118
114
|
end
|
119
115
|
|
120
116
|
test "detects ie11 in compatibility view" do
|
121
|
-
|
117
|
+
browser = Browser.new(Browser["IE11_COMPAT"])
|
122
118
|
|
123
|
-
assert_equal "Internet Explorer",
|
124
|
-
assert
|
125
|
-
assert
|
126
|
-
refute
|
127
|
-
assert
|
128
|
-
assert_equal "11.0",
|
129
|
-
assert_equal "11",
|
130
|
-
assert_equal "7.0",
|
131
|
-
assert_equal "7",
|
119
|
+
assert_equal "Internet Explorer", browser.name
|
120
|
+
assert browser.ie?
|
121
|
+
assert browser.ie?(11)
|
122
|
+
refute browser.modern?
|
123
|
+
assert browser.compatibility_view?
|
124
|
+
assert_equal "11.0", browser.full_version
|
125
|
+
assert_equal "11", browser.version
|
126
|
+
assert_equal "7.0", browser.msie_full_version
|
127
|
+
assert_equal "7", browser.msie_version
|
132
128
|
end
|
133
129
|
|
134
130
|
test "detects Lumia 800" do
|
135
|
-
|
131
|
+
browser = Browser.new(Browser["LUMIA800"])
|
136
132
|
|
137
|
-
assert_equal "Internet Explorer",
|
138
|
-
assert
|
139
|
-
assert
|
140
|
-
assert_equal "9.0",
|
141
|
-
assert_equal "9",
|
142
|
-
refute @browser.tablet?
|
143
|
-
assert @browser.mobile?
|
133
|
+
assert_equal "Internet Explorer", browser.name
|
134
|
+
assert browser.ie?
|
135
|
+
assert browser.ie?(9)
|
136
|
+
assert_equal "9.0", browser.full_version
|
137
|
+
assert_equal "9", browser.version
|
144
138
|
end
|
145
139
|
|
146
140
|
test "detects ie11 touch desktop pc" do
|
147
|
-
|
141
|
+
browser = Browser.new(Browser["IE11_TOUCH_SCREEN"])
|
148
142
|
|
149
|
-
assert_equal "Internet Explorer",
|
150
|
-
assert
|
151
|
-
assert
|
152
|
-
assert
|
153
|
-
refute
|
154
|
-
refute
|
155
|
-
assert
|
156
|
-
assert
|
157
|
-
assert_equal "11.0",
|
158
|
-
assert_equal "11",
|
143
|
+
assert_equal "Internet Explorer", browser.name
|
144
|
+
assert browser.ie?
|
145
|
+
assert browser.ie?(11)
|
146
|
+
assert browser.modern?
|
147
|
+
refute browser.compatibility_view?
|
148
|
+
refute browser.platform.windows_rt?
|
149
|
+
assert browser.platform.windows_touchscreen_desktop?
|
150
|
+
assert browser.platform.windows8?
|
151
|
+
assert_equal "11.0", browser.full_version
|
152
|
+
assert_equal "11", browser.version
|
159
153
|
end
|
160
154
|
|
161
155
|
test "detects Microsoft Edge" do
|
162
|
-
|
156
|
+
browser = Browser.new(Browser["MS_EDGE"])
|
163
157
|
|
164
|
-
assert_equal :edge,
|
165
|
-
assert_equal "Microsoft Edge",
|
166
|
-
assert_equal "12.0",
|
167
|
-
assert_equal "12",
|
168
|
-
assert
|
169
|
-
assert
|
170
|
-
assert
|
171
|
-
refute
|
172
|
-
refute
|
173
|
-
refute
|
174
|
-
refute
|
158
|
+
assert_equal :edge, browser.id
|
159
|
+
assert_equal "Microsoft Edge", browser.name
|
160
|
+
assert_equal "12.0", browser.full_version
|
161
|
+
assert_equal "12", browser.version
|
162
|
+
assert browser.platform.windows10?
|
163
|
+
assert browser.edge?
|
164
|
+
assert browser.modern?
|
165
|
+
refute browser.webkit?
|
166
|
+
refute browser.chrome?
|
167
|
+
refute browser.safari?
|
168
|
+
refute browser.device.mobile?
|
175
169
|
end
|
176
170
|
|
177
171
|
test "detects Microsoft Edge in compatibility view" do
|
178
|
-
|
179
|
-
|
180
|
-
assert_equal :edge,
|
181
|
-
assert_equal "Microsoft Edge",
|
182
|
-
assert_equal "12.0",
|
183
|
-
assert_equal "12",
|
184
|
-
assert_equal "7.0",
|
185
|
-
assert_equal "7",
|
186
|
-
assert
|
187
|
-
assert
|
188
|
-
refute
|
189
|
-
refute
|
190
|
-
refute
|
191
|
-
refute
|
192
|
-
refute
|
172
|
+
browser = Browser.new(Browser["MS_EDGE_COMPAT"])
|
173
|
+
|
174
|
+
assert_equal :edge, browser.id
|
175
|
+
assert_equal "Microsoft Edge", browser.name
|
176
|
+
assert_equal "12.0", browser.full_version
|
177
|
+
assert_equal "12", browser.version
|
178
|
+
assert_equal "7.0", browser.msie_full_version
|
179
|
+
assert_equal "7", browser.msie_version
|
180
|
+
assert browser.edge?
|
181
|
+
assert browser.compatibility_view?
|
182
|
+
refute browser.modern?
|
183
|
+
refute browser.webkit?
|
184
|
+
refute browser.chrome?
|
185
|
+
refute browser.safari?
|
186
|
+
refute browser.device.mobile?
|
193
187
|
end
|
194
188
|
|
195
189
|
test "detects Microsoft Edge Mobile" do
|
196
|
-
|
197
|
-
|
198
|
-
assert_equal :edge,
|
199
|
-
assert_equal "Microsoft Edge",
|
200
|
-
assert_equal "12.0",
|
201
|
-
assert_equal "12",
|
202
|
-
refute
|
203
|
-
assert
|
204
|
-
assert
|
205
|
-
assert
|
206
|
-
|
207
|
-
refute
|
208
|
-
refute
|
209
|
-
refute @browser.safari?
|
190
|
+
browser = Browser.new(Browser["MS_EDGE_MOBILE"])
|
191
|
+
|
192
|
+
assert_equal :edge, browser.id
|
193
|
+
assert_equal "Microsoft Edge", browser.name
|
194
|
+
assert_equal "12.0", browser.full_version
|
195
|
+
assert_equal "12", browser.version
|
196
|
+
refute browser.platform.windows10?
|
197
|
+
assert browser.platform.windows_phone?
|
198
|
+
assert browser.edge?
|
199
|
+
assert browser.modern?
|
200
|
+
refute browser.webkit?
|
201
|
+
refute browser.chrome?
|
202
|
+
refute browser.safari?
|
210
203
|
end
|
211
204
|
|
212
205
|
test "detects IE without Trident" do
|
213
|
-
|
214
|
-
|
215
|
-
assert_equal :ie,
|
216
|
-
assert_equal "Internet Explorer",
|
217
|
-
assert_equal "0.0",
|
218
|
-
assert_equal "0",
|
219
|
-
assert_equal "0.0",
|
220
|
-
assert_equal "0",
|
221
|
-
refute
|
222
|
-
refute
|
223
|
-
refute
|
224
|
-
refute
|
225
|
-
refute
|
226
|
-
refute
|
227
|
-
refute
|
228
|
-
refute
|
206
|
+
browser = Browser.new(Browser["IE_WITHOUT_TRIDENT"])
|
207
|
+
|
208
|
+
assert_equal :ie, browser.id
|
209
|
+
assert_equal "Internet Explorer", browser.name
|
210
|
+
assert_equal "0.0", browser.msie_full_version
|
211
|
+
assert_equal "0", browser.msie_version
|
212
|
+
assert_equal "0.0", browser.full_version
|
213
|
+
assert_equal "0", browser.version
|
214
|
+
refute browser.platform.windows10?
|
215
|
+
refute browser.platform.windows_phone?
|
216
|
+
refute browser.edge?
|
217
|
+
refute browser.modern?
|
218
|
+
refute browser.device.mobile?
|
219
|
+
refute browser.webkit?
|
220
|
+
refute browser.chrome?
|
221
|
+
refute browser.safari?
|
229
222
|
end
|
230
223
|
|
231
224
|
test "detects windows phone" do
|
232
|
-
|
225
|
+
browser = Browser.new(Browser["WINDOWS_PHONE"])
|
233
226
|
|
234
|
-
assert
|
235
|
-
assert_equal "7",
|
236
|
-
assert
|
237
|
-
|
238
|
-
refute @browser.windows_mobile?
|
239
|
-
refute @browser.tablet?
|
227
|
+
assert browser.ie?
|
228
|
+
assert_equal "7", browser.version
|
229
|
+
assert browser.platform.windows_phone?
|
230
|
+
refute browser.platform.windows_mobile?
|
240
231
|
end
|
241
232
|
|
242
233
|
test "detects windows phone 8" do
|
243
|
-
|
234
|
+
browser = Browser.new(Browser["WINDOWS_PHONE8"])
|
244
235
|
|
245
|
-
assert
|
246
|
-
assert_equal "10",
|
247
|
-
assert
|
248
|
-
|
249
|
-
refute @browser.windows_mobile?
|
250
|
-
refute @browser.tablet?
|
236
|
+
assert browser.ie?
|
237
|
+
assert_equal "10", browser.version
|
238
|
+
assert browser.platform.windows_phone?
|
239
|
+
refute browser.platform.windows_mobile?
|
251
240
|
end
|
252
241
|
|
253
242
|
test "detects windows phone 8.1" do
|
254
|
-
|
243
|
+
browser = Browser.new(Browser["WINDOWS_PHONE_81"])
|
255
244
|
|
256
|
-
assert
|
257
|
-
assert_equal "Internet Explorer",
|
258
|
-
assert_equal :ie,
|
259
|
-
assert_equal "11",
|
260
|
-
assert_equal "11.0",
|
261
|
-
assert
|
262
|
-
|
263
|
-
refute @browser.windows_mobile?
|
264
|
-
refute @browser.tablet?
|
245
|
+
assert browser.ie?
|
246
|
+
assert_equal "Internet Explorer", browser.name
|
247
|
+
assert_equal :ie, browser.id
|
248
|
+
assert_equal "11", browser.version
|
249
|
+
assert_equal "11.0", browser.full_version
|
250
|
+
assert browser.platform.windows_phone?
|
251
|
+
refute browser.platform.windows_mobile?
|
265
252
|
end
|
266
253
|
|
267
254
|
test "detects windows mobile (windows phone 8)" do
|
268
|
-
|
255
|
+
browser = Browser.new(Browser["WINDOWS_PHONE8"])
|
269
256
|
|
270
|
-
assert
|
271
|
-
assert_equal "10",
|
272
|
-
assert
|
273
|
-
|
274
|
-
refute @browser.windows_mobile?
|
275
|
-
refute @browser.tablet?
|
257
|
+
assert browser.ie?
|
258
|
+
assert_equal "10", browser.version
|
259
|
+
assert browser.platform.windows_phone?
|
260
|
+
refute browser.platform.windows_mobile?
|
276
261
|
end
|
277
262
|
|
278
263
|
test "detects windows x64" do
|
279
|
-
|
280
|
-
assert
|
281
|
-
refute
|
282
|
-
assert
|
264
|
+
browser = Browser.new(Browser["IE10_X64_WINX64"])
|
265
|
+
assert browser.platform.windows_x64?
|
266
|
+
refute browser.platform.windows_wow64?
|
267
|
+
assert browser.platform.windows_x64_inclusive?
|
283
268
|
end
|
284
269
|
|
285
270
|
test "detects windows wow64" do
|
286
|
-
|
287
|
-
refute
|
288
|
-
assert
|
289
|
-
assert
|
271
|
+
browser = Browser.new(Browser["WINDOWS_WOW64"])
|
272
|
+
refute browser.platform.windows_x64?
|
273
|
+
assert browser.platform.windows_wow64?
|
274
|
+
assert browser.platform.windows_x64_inclusive?
|
290
275
|
end
|
291
276
|
|
292
277
|
test "detects windows platform" do
|
293
|
-
|
294
|
-
assert_equal :windows,
|
295
|
-
assert
|
278
|
+
browser = Browser.new("Windows")
|
279
|
+
assert_equal :windows, browser.platform.id
|
280
|
+
assert browser.platform.windows?
|
296
281
|
end
|
297
282
|
|
298
283
|
test "detects windows_xp" do
|
299
|
-
|
284
|
+
browser = Browser.new(Browser["WINDOWS_XP"])
|
300
285
|
|
301
|
-
assert
|
302
|
-
assert
|
286
|
+
assert browser.platform.windows?
|
287
|
+
assert browser.platform.windows_xp?
|
303
288
|
end
|
304
289
|
|
305
290
|
test "detects windows_vista" do
|
306
|
-
|
291
|
+
browser = Browser.new(Browser["WINDOWS_VISTA"])
|
307
292
|
|
308
|
-
assert
|
309
|
-
assert
|
293
|
+
assert browser.platform.windows?
|
294
|
+
assert browser.platform.windows_vista?
|
310
295
|
end
|
311
296
|
|
312
297
|
test "detects windows7" do
|
313
|
-
|
298
|
+
browser = Browser.new(Browser["WINDOWS7"])
|
314
299
|
|
315
|
-
assert
|
316
|
-
assert
|
300
|
+
assert browser.platform.windows?
|
301
|
+
assert browser.platform.windows7?
|
317
302
|
end
|
318
303
|
|
319
304
|
test "detects windows8" do
|
320
|
-
|
305
|
+
browser = Browser.new(Browser["WINDOWS8"])
|
321
306
|
|
322
|
-
assert
|
323
|
-
assert
|
324
|
-
refute
|
307
|
+
assert browser.platform.windows?
|
308
|
+
assert browser.platform.windows8?
|
309
|
+
refute browser.platform.windows8_1?
|
325
310
|
end
|
326
311
|
|
327
312
|
test "detects windows8.1" do
|
328
|
-
|
313
|
+
browser = Browser.new(Browser["WINDOWS81"])
|
329
314
|
|
330
|
-
assert
|
331
|
-
assert
|
332
|
-
assert
|
315
|
+
assert browser.platform.windows?
|
316
|
+
assert browser.platform.windows8?
|
317
|
+
assert browser.platform.windows8_1?
|
333
318
|
end
|
334
319
|
|
335
320
|
test "returns string representation for ie6" do
|
336
|
-
|
337
|
-
meta =
|
321
|
+
browser = Browser.new(Browser["IE6"])
|
322
|
+
meta = browser.meta
|
338
323
|
|
339
324
|
assert meta.include?("ie")
|
340
325
|
assert meta.include?("ie6")
|
@@ -345,8 +330,8 @@ class IeTest < Minitest::Test
|
|
345
330
|
end
|
346
331
|
|
347
332
|
test "returns string representation for ie7" do
|
348
|
-
|
349
|
-
meta =
|
333
|
+
browser = Browser.new(Browser["IE7"])
|
334
|
+
meta = browser.meta
|
350
335
|
|
351
336
|
assert meta.include?("ie")
|
352
337
|
assert meta.include?("ie7")
|
@@ -357,8 +342,8 @@ class IeTest < Minitest::Test
|
|
357
342
|
end
|
358
343
|
|
359
344
|
test "returns string representation for ie8" do
|
360
|
-
|
361
|
-
meta =
|
345
|
+
browser = Browser.new(Browser["IE8"])
|
346
|
+
meta = browser.meta
|
362
347
|
|
363
348
|
assert meta.include?("ie")
|
364
349
|
assert meta.include?("ie8")
|
@@ -366,14 +351,14 @@ class IeTest < Minitest::Test
|
|
366
351
|
assert meta.include?("windows")
|
367
352
|
end
|
368
353
|
|
369
|
-
test "
|
370
|
-
|
371
|
-
|
354
|
+
test "don't detect as two different versions" do
|
355
|
+
browser = Browser.new(Browser["IE8"])
|
356
|
+
assert browser.ie?(8)
|
357
|
+
refute browser.ie?(7)
|
372
358
|
end
|
373
359
|
|
374
|
-
test "
|
375
|
-
|
376
|
-
assert
|
377
|
-
refute @browser.ie?(7)
|
360
|
+
test "more complex versioning check" do
|
361
|
+
browser = Browser.new(Browser["IE8"])
|
362
|
+
assert browser.ie?(["> 7", "< 9"])
|
378
363
|
end
|
379
364
|
end
|