You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(platform): default desktop to use material design
Breaking Change: Previously the default was to use ios mode if a more
specific platform was not determined. Now the material design mode (md)
will apply by default. In most cases this means desktop browsers will
now receive the md mode. Closes#6003
Copy file name to clipboardExpand all lines: ionic/platform/test/platform.spec.ts
+114-9Lines changed: 114 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,7 @@ export function run() {
31
31
platform.setUrl('/?ionicplatform=windows');
32
32
platform.load(null);
33
33
34
+
expect(platform.is('core')).toEqual(false);
34
35
expect(platform.is('mobile')).toEqual(true);
35
36
expect(platform.is('android')).toEqual(false);
36
37
expect(platform.is('windows')).toEqual(true);
@@ -42,6 +43,7 @@ export function run() {
42
43
platform.setUrl('/?ionicplatform=ios');
43
44
platform.load(null);
44
45
46
+
expect(platform.is('core')).toEqual(false);
45
47
expect(platform.is('mobile')).toEqual(true);
46
48
expect(platform.is('android')).toEqual(false);
47
49
expect(platform.is('windows')).toEqual(false);
@@ -54,6 +56,7 @@ export function run() {
54
56
platform.setUserAgent(ANDROID_UA);
55
57
platform.load(null);
56
58
59
+
expect(platform.is('core')).toEqual(false);
57
60
expect(platform.is('android')).toEqual(false);
58
61
expect(platform.is('windows')).toEqual(true);
59
62
expect(platform.is('ios')).toEqual(false);
@@ -65,6 +68,7 @@ export function run() {
65
68
platform.setUserAgent(ANDROID_UA);
66
69
platform.load(null);
67
70
71
+
expect(platform.is('core')).toEqual(false);
68
72
expect(platform.is('android')).toEqual(false);
69
73
expect(platform.is('windows')).toEqual(false);
70
74
expect(platform.is('ios')).toEqual(true);
@@ -75,6 +79,7 @@ export function run() {
75
79
platform.setUrl('/?ionicplatform=android');
76
80
platform.load(null);
77
81
82
+
expect(platform.is('core')).toEqual(false);
78
83
expect(platform.is('android')).toEqual(true);
79
84
expect(platform.is('windows')).toEqual(false);
80
85
expect(platform.is('ios')).toEqual(false);
@@ -86,38 +91,42 @@ export function run() {
86
91
platform.setUserAgent(IPHONE_UA);
87
92
platform.load(null);
88
93
94
+
expect(platform.is('core')).toEqual(false);
89
95
expect(platform.is('android')).toEqual(true);
90
96
expect(platform.is('windows')).toEqual(false);
91
97
expect(platform.is('ios')).toEqual(false);
92
98
});
93
99
94
-
it('should set windows via user agent',()=>{
100
+
it('should set windows platform via user agent',()=>{
95
101
letplatform=newPlatform();
96
-
platform.setUserAgent(WINDOWS_UA);
102
+
platform.setUserAgent(WINDOWS_PHONE_UA);
97
103
platform.load(null);
98
104
105
+
expect(platform.is('core')).toEqual(false);
99
106
expect(platform.is('mobile')).toEqual(true);
100
107
expect(platform.is('windows')).toEqual(true);
101
108
expect(platform.is('android')).toEqual(false);
102
109
expect(platform.is('ios')).toEqual(false);
103
110
});
104
111
105
-
it('should set windows8 via user agent',()=>{
112
+
it('should set windows platform via windows8 mobile user agent',()=>{
106
113
letplatform=newPlatform();
107
-
platform.setUserAgent(WINDOWS8_UA);
114
+
platform.setUserAgent(WINDOWS8_PHONE_UA);
108
115
platform.load(null);
109
116
117
+
expect(platform.is('core')).toEqual(false);
110
118
expect(platform.is('mobile')).toEqual(true);
111
119
expect(platform.is('windows')).toEqual(true);
112
120
expect(platform.is('android')).toEqual(false);
113
121
expect(platform.is('ios')).toEqual(false);
114
122
});
115
123
116
-
it('should set windows7 via user agent',()=>{
124
+
it('should set windows platform via windows7 mobile user agent',()=>{
117
125
letplatform=newPlatform();
118
-
platform.setUserAgent(WINDOWS7_UA);
126
+
platform.setUserAgent(WINDOWS7_PHONE_UA);
119
127
platform.load(null);
120
128
129
+
expect(platform.is('core')).toEqual(false);
121
130
expect(platform.is('mobile')).toEqual(true);
122
131
expect(platform.is('windows')).toEqual(true);
123
132
expect(platform.is('android')).toEqual(false);
@@ -129,6 +138,7 @@ export function run() {
129
138
platform.setUserAgent(ANDROID_UA);
130
139
platform.load(null);
131
140
141
+
expect(platform.is('core')).toEqual(false);
132
142
expect(platform.is('mobile')).toEqual(true);
133
143
expect(platform.is('windows')).toEqual(false);
134
144
expect(platform.is('android')).toEqual(true);
@@ -140,6 +150,7 @@ export function run() {
140
150
platform.setUserAgent(IPHONE_UA);
141
151
platform.load(null);
142
152
153
+
expect(platform.is('core')).toEqual(false);
143
154
expect(platform.is('mobile')).toEqual(true);
144
155
expect(platform.is('windows')).toEqual(false);
145
156
expect(platform.is('android')).toEqual(false);
@@ -153,6 +164,7 @@ export function run() {
153
164
platform.setUserAgent(IPAD_UA);
154
165
platform.load(null);
155
166
167
+
expect(platform.is('core')).toEqual(false);
156
168
expect(platform.is('mobile')).toEqual(true);
157
169
expect(platform.is('windows')).toEqual(false);
158
170
expect(platform.is('android')).toEqual(false);
@@ -161,11 +173,104 @@ export function run() {
161
173
expect(platform.is('tablet')).toEqual(true);
162
174
});
163
175
176
+
it('should set core platform for osx desktop firefox',()=>{
177
+
letplatform=newPlatform();
178
+
platform.setUserAgent(OSX_10_FIREFOX_43_UA);
179
+
platform.load(null);
180
+
181
+
expect(platform.is('core')).toEqual(true);
182
+
expect(platform.is('mobile')).toEqual(false);
183
+
expect(platform.is('windows')).toEqual(false);
184
+
expect(platform.is('android')).toEqual(false);
185
+
expect(platform.is('ios')).toEqual(false);
186
+
expect(platform.is('ipad')).toEqual(false);
187
+
expect(platform.is('tablet')).toEqual(false);
188
+
});
189
+
190
+
it('should set core platform for osx desktop safari',()=>{
191
+
letplatform=newPlatform();
192
+
platform.setUserAgent(OSX_10_SAFARI_9_UA);
193
+
platform.load(null);
194
+
195
+
expect(platform.is('core')).toEqual(true);
196
+
expect(platform.is('mobile')).toEqual(false);
197
+
expect(platform.is('windows')).toEqual(false);
198
+
expect(platform.is('android')).toEqual(false);
199
+
expect(platform.is('ios')).toEqual(false);
200
+
expect(platform.is('ipad')).toEqual(false);
201
+
expect(platform.is('tablet')).toEqual(false);
202
+
});
203
+
204
+
it('should set core platform for osx desktop chrome',()=>{
205
+
letplatform=newPlatform();
206
+
platform.setUserAgent(OSX_10_CHROME_49_UA);
207
+
platform.load(null);
208
+
209
+
expect(platform.is('core')).toEqual(true);
210
+
expect(platform.is('mobile')).toEqual(false);
211
+
expect(platform.is('windows')).toEqual(false);
212
+
expect(platform.is('android')).toEqual(false);
213
+
expect(platform.is('ios')).toEqual(false);
214
+
expect(platform.is('ipad')).toEqual(false);
215
+
expect(platform.is('tablet')).toEqual(false);
216
+
});
217
+
218
+
it('should set core platform for windows desktop chrome',()=>{
219
+
letplatform=newPlatform();
220
+
platform.setUserAgent(WINDOWS_10_CHROME_40_UA);
221
+
platform.load(null);
222
+
223
+
expect(platform.is('core')).toEqual(true);
224
+
expect(platform.is('mobile')).toEqual(false);
225
+
expect(platform.is('windows')).toEqual(false);
226
+
expect(platform.is('android')).toEqual(false);
227
+
expect(platform.is('ios')).toEqual(false);
228
+
expect(platform.is('ipad')).toEqual(false);
229
+
expect(platform.is('tablet')).toEqual(false);
230
+
});
231
+
232
+
it('should set core platform for windows desktop edge',()=>{
233
+
letplatform=newPlatform();
234
+
platform.setUserAgent(WINDOWS_10_EDGE_12_UA);
235
+
platform.load(null);
236
+
237
+
expect(platform.is('core')).toEqual(true);
238
+
expect(platform.is('mobile')).toEqual(false);
239
+
expect(platform.is('windows')).toEqual(false);
240
+
expect(platform.is('android')).toEqual(false);
241
+
expect(platform.is('ios')).toEqual(false);
242
+
expect(platform.is('ipad')).toEqual(false);
243
+
expect(platform.is('tablet')).toEqual(false);
244
+
});
245
+
246
+
it('should set core platform for windows desktop IE',()=>{
247
+
letplatform=newPlatform();
248
+
platform.setUserAgent(WINDOWS_8_IE_11_UA);
249
+
platform.load(null);
250
+
251
+
expect(platform.is('core')).toEqual(true);
252
+
expect(platform.is('mobile')).toEqual(false);
253
+
expect(platform.is('windows')).toEqual(false);
254
+
expect(platform.is('android')).toEqual(false);
255
+
expect(platform.is('ios')).toEqual(false);
256
+
expect(platform.is('ipad')).toEqual(false);
257
+
expect(platform.is('tablet')).toEqual(false);
258
+
});
259
+
164
260
}
165
261
166
-
constWINDOWS_UA='Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 930) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537';
constWINDOWS7_UA='Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910)';
262
+
constOSX_10_FIREFOX_43_UA='Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0';
263
+
constOSX_10_SAFARI_9_UA='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/601.4.4 (KHTML, like Gecko) Version/9.0.3 Safari/601.4.4';
264
+
constOSX_10_CHROME_49_UA='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36';
265
+
266
+
constWINDOWS_10_CHROME_40_UA='Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36';
267
+
constWINDOWS_10_EDGE_12_UA='Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0';
268
+
constWINDOWS_8_IE_11_UA='Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; Touch; rv:11.0) like Gecko';
269
+
270
+
constWINDOWS_PHONE_UA='Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 930) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537';
constWINDOWS7_PHONE_UA='Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910)';
273
+
169
274
constANDROID_UA='Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.20 Mobile Safari/537.36';
170
275
constIPHONE_UA='Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4';
171
276
constIPAD_UA='Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53';
0 commit comments