Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit eefcdad

Browse files
dusanbartosjeffbcross
authored andcommitted
fix($sniffer): history problems on Boxee box
History API not working properly on Boxee box browser (old Webkit) problem similar to the one on Android < 4
1 parent 74ae3ed commit eefcdad

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

src/ng/sniffer.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function $SnifferProvider() {
1919
this.$get = ['$window', '$document', function($window, $document) {
2020
var eventSupport = {},
2121
android = int((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]),
22+
boxee = /Boxee/i.test(($window.navigator || {}).userAgent),
2223
document = $document[0] || {},
2324
vendorPrefix,
2425
vendorRegex = /^(Moz|webkit|O|ms)(?=[A-Z])/,
@@ -42,10 +43,10 @@ function $SnifferProvider() {
4243

4344
transitions = !!(('transition' in bodyStyle) || (vendorPrefix + 'Transition' in bodyStyle));
4445
animations = !!(('animation' in bodyStyle) || (vendorPrefix + 'Animation' in bodyStyle));
45-
46+
4647
if (android && (!transitions||!animations)) {
47-
transitions = isString(document.body.style.webkitTransition);
48-
animations = isString(document.body.style.webkitAnimation);
48+
transitions = isString(document.body.style.webkitTransition);
49+
animations = isString(document.body.style.webkitAnimation);
4950
}
5051
}
5152

@@ -55,7 +56,10 @@ function $SnifferProvider() {
5556
// so let's not use the history API at all.
5657
// http://code.google.com/p/android/issues/detail?id=17471
5758
// https://github.com/angular/angular.js/issues/904
58-
history: !!($window.history && $window.history.pushState && !(android < 4)),
59+
60+
// older webit browser (533.9) on Boxee box has exactly the same problem as Android has
61+
// so let's not use the history API also
62+
history: !!($window.history && $window.history.pushState && !(android < 4) && !boxee),
5963
hashchange: 'onhashchange' in $window &&
6064
// IE8 compatible mode lies
6165
(!document.documentMode || document.documentMode > 7),

test/ng/snifferSpec.js

+26
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,30 @@ describe('$sniffer', function() {
316316
});
317317

318318
});
319+
320+
321+
describe('history', function() {
322+
it('should be true on Boxee box with an older version of Webkit', function() {
323+
module(function($provide) {
324+
var doc = {
325+
body : {
326+
style : {}
327+
}
328+
};
329+
var win = {
330+
history: {
331+
pushState: noop
332+
},
333+
navigator: {
334+
userAgent: 'boxee (alpha/Darwin 8.7.1 i386 - 0.9.11.5591)'
335+
}
336+
};
337+
$provide.value('$document', jqLite(doc));
338+
$provide.value('$window', win);
339+
});
340+
inject(function($sniffer) {
341+
expect($sniffer.history).toBe(false);
342+
});
343+
});
344+
});
319345
});

0 commit comments

Comments
 (0)