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
358ec163
authored
2014-09-22 16:35:53 -0400
by
Gary Katsevman
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add a test for removing event handlers
1 parent
89601c9c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
test/videojs-hls_test.js
test/videojs-hls_test.js
View file @
358ec16
...
...
@@ -1199,6 +1199,60 @@ test('disposes the playlist loader', function() {
strictEqual
(
disposes
,
1
,
'disposed playlist loader'
);
});
test
(
'remove event handlers on dispose'
,
function
()
{
var
player
,
handlers
=
[],
timeupdateOff
=
0
,
waitingOff
=
0
,
oldOff
,
type
,
handler
,
i
;
player
=
createPlayer
();
player
.
src
({
src
:
'manifest/master.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
oldOff
=
player
.
off
;
player
.
off
=
function
(
type
,
handler
)
{
handlers
.
push
([
type
,
handler
]);
if
(
type
===
'timeupdate'
)
{
timeupdateOff
++
;
}
else
if
(
type
===
'waiting'
)
{
waitingOff
++
;
}
oldOff
.
call
(
player
,
type
,
handler
);
};
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'
);
}
}
}
player
.
off
=
oldOff
;
});
test
(
'aborts the source buffer on disposal'
,
function
()
{
var
aborts
=
0
,
player
;
player
=
createPlayer
();
...
...
Please
register
or
sign in
to post a comment