* !!! This is an undocumented "private" service !!! * * @name ng.$sniffer * @requires $window * * @property {boolean} history Does the browser support html5 history api ? * @property {boolean} hashchange Does the browser support hashchange event ? * * @description * This is very simple impl
()
| 8368 | * This is very simple implementation of testing browser's features. |
| 8369 | */ |
| 8370 | function $SnifferProvider() { |
| 8371 | this.$get = ['$window', function($window) { |
| 8372 | var eventSupport = {}, |
| 8373 | android = int((/android (\d+)/.exec(lowercase($window.navigator.userAgent)) || [])[1]); |
| 8374 | |
| 8375 | return { |
| 8376 | // Android has history.pushState, but it does not update location correctly |
| 8377 | // so let's not use the history API at all. |
| 8378 | // http://code.google.com/p/android/issues/detail?id=17471 |
| 8379 | // https://github.com/angular/angular.js/issues/904 |
| 8380 | history: !!($window.history && $window.history.pushState && !(android < 4)), |
| 8381 | hashchange: 'onhashchange' in $window && |
| 8382 | // IE8 compatible mode lies |
| 8383 | (!$window.document.documentMode || $window.document.documentMode > 7), |
| 8384 | hasEvent: function(event) { |
| 8385 | // IE9 implements 'input' event it's so fubared that we rather pretend that it doesn't have |
| 8386 | // it. In particular the event is not fired when backspace or delete key are pressed or |
| 8387 | // when cut operation is performed. |
| 8388 | if (event == 'input' && msie == 9) return false; |
| 8389 | |
| 8390 | if (isUndefined(eventSupport[event])) { |
| 8391 | var divElm = $window.document.createElement('div'); |
| 8392 | eventSupport[event] = 'on' + event in divElm; |
| 8393 | } |
| 8394 | |
| 8395 | return eventSupport[event]; |
| 8396 | }, |
| 8397 | // TODO(i): currently there is no way to feature detect CSP without triggering alerts |
| 8398 | csp: false |
| 8399 | }; |
| 8400 | }]; |
| 8401 | } |
| 8402 | |
| 8403 | /** |
| 8404 | * @ngdoc object |
nothing calls this directly
no test coverage detected