Skip to content

Commit 5fddd3e

Browse files
Fix issue where tests would fail on iPhone because it identified as both MobileSafari and WebKit.
1 parent 2a2fc85 commit 5fddd3e

File tree

2 files changed

+46
-35
lines changed

2 files changed

+46
-35
lines changed

test/unit/tests/base.test.js

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,44 @@ suite('Base', function () {
1414

1515
info('User agent string is: ' + navigator.userAgent);
1616

17-
assert(trues.size() === 0 || trues.size() === 1,
18-
'There should be only one or no browser detected.');
19-
20-
// we should have definite trues or falses here
21-
trues.each(function(result) {
22-
assert(result[1] === true);
23-
}, this);
24-
falses.each(function(result) {
25-
assert(result[1] === false);
26-
}, this);
27-
28-
var ua = navigator.userAgent;
29-
30-
if (ua.indexOf('AppleWebKit/') > -1) {
31-
info('Running on WebKit');
32-
assert(Prototype.Browser.WebKit);
33-
}
34-
35-
if (Object.prototype.toString.call(window.opera) === '[object Opera]') {
36-
info('Running on Opera');
37-
assert(Prototype.Browser.Opera);
38-
}
39-
40-
if (ua.indexOf('MSIE') > -1) {
41-
info('Running on IE');
42-
assert(Prototype.Browser.IE);
43-
}
44-
45-
if (ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1) {
46-
info('Running on Gecko');
47-
assert(Prototype.Browser.Gecko);
48-
}
49-
17+
// It's OK for there to be two true values if we're on MobileSafari,
18+
// since it's also a WebKit browser.
19+
if (Prototype.Browser.MobileSafari) {
20+
assert(trues.size() === 2, 'MobileSafari should also identify as WebKit.');
21+
} else {
22+
assert(trues.size() === 0 || trues.size() === 1,
23+
'There should be only one or no browser detected.');
24+
}
25+
26+
// we should have definite trues or falses here
27+
trues.each(function(result) {
28+
assert(result[1] === true);
29+
}, this);
30+
falses.each(function(result) {
31+
assert(result[1] === false);
32+
}, this);
33+
34+
var ua = navigator.userAgent;
35+
36+
if (ua.indexOf('AppleWebKit/') > -1) {
37+
info('Running on WebKit');
38+
assert(Prototype.Browser.WebKit);
39+
}
40+
41+
if (Object.prototype.toString.call(window.opera) === '[object Opera]') {
42+
info('Running on Opera');
43+
assert(Prototype.Browser.Opera);
44+
}
45+
46+
if (ua.indexOf('MSIE') > -1) {
47+
info('Running on IE');
48+
assert(Prototype.Browser.IE);
49+
}
50+
51+
if (ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1) {
52+
info('Running on Gecko');
53+
assert(Prototype.Browser.Gecko);
54+
}
5055
});
5156

5257
});

test/unit/tests/prototype.test.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@ suite('Prototype', function () {
1414

1515
info('User agent string is: ' + ua);
1616

17-
assert(trues.size() == 0 || trues.size() == 1,
18-
'There should be only one or no browser detected.');
17+
// It's OK for there to be two true values if we're on MobileSafari,
18+
// since it's also a WebKit browser.
19+
if (Prototype.Browser.MobileSafari) {
20+
assert(trues.size() === 2, 'MobileSafari should also identify as WebKit.');
21+
} else {
22+
assert(trues.size() === 0 || trues.size() === 1,
23+
'There should be only one or no browser detected.');
24+
}
1925

2026
// we should have definite trues or falses here
2127
trues.each(function(result) {

0 commit comments

Comments
 (0)