Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
videojs-contrib-hls
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
d78cee51
authored
2014-09-22 19:27:41 -0400
by
Gary Katsevman
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Change event handler test to be more generic
1 parent
f6291590
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
39 deletions
test/videojs-hls_test.js
test/videojs-hls_test.js
View file @
d78cee5
...
...
@@ -1185,56 +1185,35 @@ test('disposes the playlist loader', function() {
test
(
'remove event handlers on dispose'
,
function
()
{
var
player
,
handlers
=
[],
timeupdateOff
=
0
,
waitingOff
=
0
,
oldOff
,
type
,
handler
,
i
;
onhandlers
=
0
,
offhandlers
=
0
,
oldOn
,
oldOff
;
player
=
createPlayer
();
player
.
src
({
src
:
'manifest/master.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
oldOn
=
player
.
on
;
oldOff
=
player
.
off
;
player
.
on
=
function
(
type
,
handler
)
{
onhandlers
++
;
oldOn
.
call
(
player
,
type
,
handler
);
};
player
.
off
=
function
(
type
,
handler
)
{
handlers
.
push
([
type
,
handler
]);
if
(
type
===
'timeupdate'
)
{
timeupdateOff
++
;
}
else
if
(
type
===
'waiting'
)
{
waitingOff
++
;
}
offhandlers
++
;
oldOff
.
call
(
player
,
type
,
handler
);
};
player
.
src
({
src
:
'manifest/master.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
openMediaSource
(
player
);
player
.
hls
.
playlists
.
trigger
(
'loadedmetadata'
);
player
.
dispose
();
equal
(
timeupdateOff
,
2
,
'both fillBuffer and drainBuffer handlers were removed'
);
equal
(
waitingOff
,
1
,
'drainBuffer handler was removed'
);
for
(
i
=
0
;
i
<
handlers
.
length
;
i
++
)
{
type
=
handlers
[
i
][
0
];
handler
=
handlers
[
i
][
1
];
if
(
handler
===
player
.
hls
.
fillBuffer
)
{
equal
(
type
,
'timeupdate'
,
'fillBuffer\'s timeupdate handler was removed'
);
}
else
if
(
handler
===
player
.
hls
.
drainBuffer
)
{
if
(
type
===
'timeupdate'
)
{
ok
(
type
,
'drainBuffer\'s timeupdate handler was removed'
);
}
else
if
(
type
===
'waiting'
)
{
ok
(
type
,
'drainBuffer\'s waiting handler was removed'
);
}
else
{
ok
(
false
,
'drainBuffer handler was removed that wasn\'t timeupdate or waiting'
);
}
}
}
equal
(
offhandlers
,
onhandlers
,
'the amount of on and off handlers is the same'
);
player
.
off
=
oldOff
;
player
.
on
=
oldOn
;
});
test
(
'aborts the source buffer on disposal'
,
function
()
{
...
...
Please
register
or
sign in
to post a comment