From b292666d9018753190f3ff11cc6a0e8f203cd69e Mon Sep 17 00:00:00 2001 From: Tony Jin Date: Fri, 26 May 2017 16:43:32 -0700 Subject: [PATCH] Fix: Support disabling DASH viewer in DASH-supported environment (#140) Right now, if a user with a DASH-compatible browser disables the DASH viewer, then they cannot view any videos since the current X-Rep-Hints scheme hints to return either dash or mp4 reps, but not both. To fix this, this change updates the X-Rep-Hints sent to only send the mp4 (no filmstrip) when either the browser doesn't support DASH or if the DASH viewer is disabled. --- src/lib/Preview.js | 4 +++- src/lib/__tests__/Preview-test.js | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lib/Preview.js b/src/lib/Preview.js index 2d6b82cd5..a319cec83 100644 --- a/src/lib/Preview.js +++ b/src/lib/Preview.js @@ -1109,7 +1109,9 @@ const PREVIEW_LOCATION = findScriptLocation(PREVIEW_SCRIPT_NAME, document.curren * @return {Object} Headers */ getRequestHeaders(token) { - const videoHint = Browser.canPlayDash() ? X_REP_HINT_VIDEO_DASH : X_REP_HINT_VIDEO_MP4; + const videoHint = Browser.canPlayDash() && !this.disabledViewers.Dash + ? X_REP_HINT_VIDEO_DASH + : X_REP_HINT_VIDEO_MP4; const headers = { 'X-Rep-Hints': `${X_REP_HINT_BASE}${X_REP_HINT_DOC_THUMBNAIL}${X_REP_HINT_IMAGE}${videoHint}` }; diff --git a/src/lib/__tests__/Preview-test.js b/src/lib/__tests__/Preview-test.js index 912994b29..db7bdd610 100644 --- a/src/lib/__tests__/Preview-test.js +++ b/src/lib/__tests__/Preview-test.js @@ -1628,6 +1628,15 @@ describe('lib/Preview', () => { preview.getRequestHeaders(); expect(stubs.getHeaders).to.be.calledWith(stubs.headers, 'previewtoken', 'link', 'Passw0rd!'); }); + + it('should not add dash hints if the browser supports dash but dash is disabled', () => { + stubs.canPlayDash.returns(true); + preview.disabledViewers.Dash = 1; + stubs.headers['X-Rep-Hints'] += '[mp4]'; + + preview.getRequestHeaders(); + expect(stubs.getHeaders).to.be.calledWith(stubs.headers, 'previewtoken', 'link', 'Passw0rd!'); + }); }); describe('prefetchNextFiles()', () => {