From f947ed77914ad53624c4f63451c02c8e1e576501 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Fri, 5 Aug 2016 14:38:42 -0400 Subject: [PATCH] @gkatsev added null checks around navigator.userAgent. closes #3502 --- CHANGELOG.md | 1 + src/js/tech/html5.js | 2 +- src/js/utils/browser.js | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 214540cb9..bec72786e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ CHANGELOG * @misteroneill added ghooks to run linter on git push ([view](https://github.com/videojs/video.js/pull/3459)) * @BrandonOCasey removed unused base-styles.js file ([view](https://github.com/videojs/video.js/pull/3486)) * @erikyuzwa, @gkatsev updated CSS build to inlcude the IE8-specific CSS from a separate file instead of it being inside of sass ([view](https://github.com/videojs/video.js/pull/3380)) ([view2](https://github.com/erikyuzwa/video.js/pull/1)) +* @gkatsev added null checks around navigator.userAgent ([view](https://github.com/videojs/video.js/pull/3502)) -------------------- diff --git a/src/js/tech/html5.js b/src/js/tech/html5.js index 2d64cb968..bc9ae8dfd 100644 --- a/src/js/tech/html5.js +++ b/src/js/tech/html5.js @@ -574,7 +574,7 @@ class Html5 extends Tech { */ supportsFullScreen() { if (typeof this.el_.webkitEnterFullScreen === 'function') { - const userAgent = window.navigator.userAgent; + const userAgent = window.navigator && window.navigator.userAgent || ""; // Seems to be broken in Chromium/Chrome && Safari in Leopard if ((/Android/).test(userAgent) || !(/Chrome|Mac OS X 10.5/).test(userAgent)) { diff --git a/src/js/utils/browser.js b/src/js/utils/browser.js index 72e52daff..d181aedc8 100644 --- a/src/js/utils/browser.js +++ b/src/js/utils/browser.js @@ -4,7 +4,7 @@ import document from 'global/document'; import window from 'global/window'; -const USER_AGENT = window.navigator.userAgent; +const USER_AGENT = window.navigator && window.navigator.userAgent || ""; const webkitVersionMap = (/AppleWebKit\/([\d.]+)/i).exec(USER_AGENT); const appleWebkitVersion = webkitVersionMap ? parseFloat(webkitVersionMap.pop()) : null; @@ -30,6 +30,7 @@ export const IOS_VERSION = (function() { if (match && match[1]) { return match[1]; } + return null; }()); export const IS_ANDROID = (/Android/i).test(USER_AGENT);