From 8aaf7a4901d70870da0074d5c745e5f0c06660e5 Mon Sep 17 00:00:00 2001 From: Anthony Jones Date: Fri, 5 Aug 2016 10:55:24 +1200 Subject: [PATCH 1/4] Disable HLS hack on Firefox for Android --- src/js/tech/html5.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/tech/html5.js b/src/js/tech/html5.js index 8d72e042c9..ecd12be989 100644 --- a/src/js/tech/html5.js +++ b/src/js/tech/html5.js @@ -1230,7 +1230,7 @@ const mp4RE = /^video\/mp4/i; Html5.patchCanPlayType = function() { // Android 4.0 and above can play HLS to some extent but it reports being unable to do so - if (browser.ANDROID_VERSION >= 4.0) { + if (browser.ANDROID_VERSION >= 4.0 && !browser.IS_FIREFOX) { if (!canPlayType) { canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType; } From 1f6db828ccd399341e747fa6e9e06bb50325d6b7 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Mon, 29 Aug 2016 13:33:57 +0200 Subject: [PATCH 2/4] Fix canPlayType patching tests --- test/unit/tech/html5.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/unit/tech/html5.test.js b/test/unit/tech/html5.test.js index 63f058a2c4..d81c90604c 100644 --- a/test/unit/tech/html5.test.js +++ b/test/unit/tech/html5.test.js @@ -110,10 +110,12 @@ QUnit.test('patchCanPlayType patches canplaytype with our function, conditionall Html5.unpatchCanPlayType(); const oldAV = browser.ANDROID_VERSION; + const oldIsFirefox = browser.IS_FIREFOX; const video = document.createElement('video'); const canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType; browser.ANDROID_VERSION = 4.0; + browser.IS_FIREFOX = false; Html5.patchCanPlayType(); assert.notStrictEqual(video.canPlayType, @@ -131,14 +133,17 @@ QUnit.test('patchCanPlayType patches canplaytype with our function, conditionall 'patched canPlayType and function returned from unpatch are equal'); browser.ANDROID_VERSION = oldAV; + browser.IS_FIREFOX = oldIsFirefox; Html5.unpatchCanPlayType(); }); QUnit.test('should return maybe for HLS urls on Android 4.0 or above', function(assert) { const oldAV = browser.ANDROID_VERSION; + const oldIsFirefox = browser.IS_FIREFOX; const video = document.createElement('video'); browser.ANDROID_VERSION = 4.0; + browser.IS_FIREFOX = false; Html5.patchCanPlayType(); assert.strictEqual(video.canPlayType('application/x-mpegurl'), @@ -157,6 +162,7 @@ QUnit.test('should return maybe for HLS urls on Android 4.0 or above', function( 'maybe for vnd.apple.mpegurl'); browser.ANDROID_VERSION = oldAV; + browser.IS_FIREFOX = oldIsFirefox; Html5.unpatchCanPlayType(); }); From 6d413600cffdb28ed1a2920003f8a58fdda79073 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Mon, 29 Aug 2016 13:34:20 +0200 Subject: [PATCH 3/4] Add test to ensure that canPlayType is not patched in Firefox for Android --- test/unit/tech/html5.test.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/unit/tech/html5.test.js b/test/unit/tech/html5.test.js index d81c90604c..0ef6d4f205 100644 --- a/test/unit/tech/html5.test.js +++ b/test/unit/tech/html5.test.js @@ -137,6 +137,28 @@ QUnit.test('patchCanPlayType patches canplaytype with our function, conditionall Html5.unpatchCanPlayType(); }); +QUnit.test('patchCanPlayType doesn\'t patch canplaytype with our function in Firefox for Android', function(assert) { + // the patch runs automatically so we need to first unpatch + Html5.unpatchCanPlayType(); + + const oldAV = browser.ANDROID_VERSION; + const oldIsFirefox = browser.IS_FIREFOX; + const video = document.createElement('video'); + const canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType; + + browser.ANDROID_VERSION = 4.0; + browser.IS_FIREFOX = true; + Html5.patchCanPlayType(); + + assert.strictEqual(video.canPlayType, + canPlayType, + 'original canPlayType and patched canPlayType should not be equal'); + + browser.ANDROID_VERSION = oldAV; + browser.IS_FIREFOX = oldIsFirefox; + Html5.unpatchCanPlayType(); +}); + QUnit.test('should return maybe for HLS urls on Android 4.0 or above', function(assert) { const oldAV = browser.ANDROID_VERSION; const oldIsFirefox = browser.IS_FIREFOX; From b762008d22b1424e2b16140d6d98e7465b51d1fd Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Mon, 29 Aug 2016 17:57:50 +0200 Subject: [PATCH 4/4] Fix assertion message in Firefox for Android test --- test/unit/tech/html5.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/tech/html5.test.js b/test/unit/tech/html5.test.js index 0ef6d4f205..270d879f7a 100644 --- a/test/unit/tech/html5.test.js +++ b/test/unit/tech/html5.test.js @@ -152,7 +152,7 @@ QUnit.test('patchCanPlayType doesn\'t patch canplaytype with our function in Fir assert.strictEqual(video.canPlayType, canPlayType, - 'original canPlayType and patched canPlayType should not be equal'); + 'original canPlayType and patched canPlayType should be equal'); browser.ANDROID_VERSION = oldAV; browser.IS_FIREFOX = oldIsFirefox;