Add tests for relative key URLs
Key URLs should be fetched relative to the master playlist, if one exists, or their containing playlist otherwise.
Showing
1 changed file
with
42 additions
and
0 deletions
... | @@ -1612,6 +1612,48 @@ test('calling fetchKeys() when a new playlist is loaded will create an XHR', fun | ... | @@ -1612,6 +1612,48 @@ test('calling fetchKeys() when a new playlist is loaded will create an XHR', fun |
1612 | player.hls.playlists.media = oldMedia; | 1612 | player.hls.playlists.media = oldMedia; |
1613 | }); | 1613 | }); |
1614 | 1614 | ||
1615 | test('fetchKeys() resolves URLs relative to the master playlist', function() { | ||
1616 | player.src({ | ||
1617 | src: 'video/master-encrypted.m3u8', | ||
1618 | type: 'application/vnd.apple.mpegurl' | ||
1619 | }); | ||
1620 | openMediaSource(player); | ||
1621 | requests.shift().respond(200, null, | ||
1622 | '#EXTM3U\n' + | ||
1623 | '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=17\n' + | ||
1624 | 'playlist/playlist.m3u8\n' + | ||
1625 | '#EXT-X-ENDLIST\n'); | ||
1626 | requests.shift().respond(200, null, | ||
1627 | '#EXTM3U\n' + | ||
1628 | '#EXT-X-TARGETDURATION:15\n' + | ||
1629 | '#EXT-X-KEY:METHOD=AES-128,URI="keys/key.php"\n' + | ||
1630 | '#EXTINF:2.833,\n' + | ||
1631 | 'http://media.example.com/fileSequence1.ts\n' + | ||
1632 | '#EXT-X-ENDLIST\n'); | ||
1633 | |||
1634 | equal(requests.length, 2, 'requested two URLs'); | ||
1635 | ok((/video\/playlist\/keys\/key\.php$/).test(requests[0].url), | ||
1636 | 'resolves multiple relative paths'); | ||
1637 | }); | ||
1638 | |||
1639 | test('fetchKeys() resolves URLs relative to their containing playlist', function() { | ||
1640 | player.src({ | ||
1641 | src: 'video/media-encrypted.m3u8', | ||
1642 | type: 'application/vnd.apple.mpegurl' | ||
1643 | }); | ||
1644 | openMediaSource(player); | ||
1645 | requests.shift().respond(200, null, | ||
1646 | '#EXTM3U\n' + | ||
1647 | '#EXT-X-TARGETDURATION:15\n' + | ||
1648 | '#EXT-X-KEY:METHOD=AES-128,URI="keys/key.php"\n' + | ||
1649 | '#EXTINF:2.833,\n' + | ||
1650 | 'http://media.example.com/fileSequence1.ts\n' + | ||
1651 | '#EXT-X-ENDLIST\n'); | ||
1652 | equal(requests.length, 2, 'requested two URLs'); | ||
1653 | ok((/video\/keys\/key\.php$/).test(requests[0].url), | ||
1654 | 'resolves multiple relative paths'); | ||
1655 | }); | ||
1656 | |||
1615 | test('a new keys XHR is created when a previous key XHR finishes', function() { | 1657 | test('a new keys XHR is created when a previous key XHR finishes', function() { |
1616 | player.src({ | 1658 | player.src({ |
1617 | src: 'https://example.com/encrypted-media.m3u8', | 1659 | src: 'https://example.com/encrypted-media.m3u8', | ... | ... |
-
Please register or sign in to post a comment