Skip to content

Commit

Permalink
test: Fix missing HLS parser in tests (#6284)
Browse files Browse the repository at this point in the history
A test suite that overwrites the HLS parser needs to restore it afterward.  To aid in debugging future parser issues, this adds the detected or specified MIME type to the error object for UNABLE_TO_GUESS_MANIFEST_TYPE.

Closes #5834
  • Loading branch information
joeyparrish committed Feb 22, 2024
1 parent 5a53adf commit 250ad33
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/media/manifest_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ shaka.media.ManifestParser = class {
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code.UNABLE_TO_GUESS_MANIFEST_TYPE,
uri);
uri,
mimeType);
}


Expand Down
1 change: 1 addition & 0 deletions lib/util/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ shaka.util.Error.Code = {
* <li>Configure the server to accept a HEAD request for the manifest.
* </ul>
* <br> error.data[0] is the manifest URI.
* <br> error.data[1] is the detected or specified MIME type.
*/
'UNABLE_TO_GUESS_MANIFEST_TYPE': 4000,

Expand Down
12 changes: 9 additions & 3 deletions test/player_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,15 +667,21 @@ describe('Player', () => {
});

describe('when config.streaming.preferNativeHls is set to true', () => {
beforeEach(() => {
beforeAll(() => {
shaka.media.ManifestParser.registerParserByMime(
'application/x-mpegurl',
() => new shaka.test.FakeManifestParser(manifest));
});

afterAll(() => {
// IMPORTANT: restore the ORIGINAL parser. DO NOT just unregister the
// fake!
shaka.media.ManifestParser.registerParserByMime(
'application/x-mpegurl',
() => new shaka.hls.HlsParser());
});

afterEach(() => {
shaka.media.ManifestParser.unregisterParserByMime(
'application/x-mpegurl');
video.canPlayType.calls.reset();
});

Expand Down

0 comments on commit 250ad33

Please sign in to comment.