Index: LayoutTests/http/tests/media/media-source/mediasource-util.js |
diff --git a/LayoutTests/http/tests/media/media-source/mediasource-util.js b/LayoutTests/http/tests/media/media-source/mediasource-util.js |
index 456f012f4d99dc613dbdf3ac07f224d518097e76..47ffee49a92afff4f38fc03d0a36a4b6887b49ab 100644 |
--- a/LayoutTests/http/tests/media/media-source/mediasource-util.js |
+++ b/LayoutTests/http/tests/media/media-source/mediasource-util.js |
@@ -4,6 +4,7 @@ |
this.test_ = test; |
this.eventTargetList_ = []; |
this.waitCallbacks_ = []; |
+ this.timeoutIDs_ = {}; |
wolenetz
2013/08/06 22:35:55
Oh noes! This also needs removal :)
anandc
2013/08/06 23:27:22
Many thanks for catching these. Done.
|
}; |
EventExpectationsManager.prototype.expectEvent = function(object, eventName, description) |
@@ -35,6 +36,21 @@ |
setTimeout(this.handleWaitCallback_.bind(this), 0); |
}; |
+ EventExpectationsManager.prototype.waitForTimeUpdate = function(mediaElement, callback) |
+ { |
+ var initialTime = mediaElement.currentTime; |
+ |
+ var onTimeUpdate = this.test_.step_func(function() |
+ { |
+ if (mediaElement.currentTime != initialTime) { |
+ mediaElement.removeEventListener('timeupdate', onTimeUpdate); |
+ callback(); |
+ } |
+ }); |
+ |
+ mediaElement.addEventListener('timeupdate', onTimeUpdate); |
+ }; |
+ |
EventExpectationsManager.prototype.expectingEvents = function() |
{ |
for (var i = 0; i < this.eventTargetList_.length; ++i) { |
@@ -176,6 +192,11 @@ |
test.eventExpectations_.expectEvent(object, eventName, description); |
}; |
+ test.waitForTimeUpdate = function(mediaElement, callback) |
wolenetz
2013/08/06 22:35:55
nit: Please add brief documentation here that not
anandc
2013/08/06 22:49:37
Good point. Done.
acolwell GONE FROM CHROMIUM
2013/08/06 23:05:09
nit: An alternative is to just change the method n
anandc
2013/08/06 23:27:22
Renaming is better. Done.
|
+ { |
+ test.eventExpectations_.waitForTimeUpdate(mediaElement, callback); |
acolwell GONE FROM CHROMIUM
2013/08/06 23:05:09
nit: Why is added as part of the EventExpectations
anandc
2013/08/06 23:27:22
Of course. :-) Thank you. Done.
|
+ } |
+ |
test.waitForExpectedEvents = function(callback) |
{ |
test.eventExpectations_.waitForExpectedEvents(callback); |
@@ -184,8 +205,14 @@ |
var oldTestDone = test.done.bind(test); |
test.done = function() |
{ |
- if (test.status == test.PASS) |
+ // loop through and clear timeoutIDs |
+ for (var i in test.eventExpectations_.timeoutIDs_) { |
acolwell GONE FROM CHROMIUM
2013/08/06 23:05:09
nit: I think this can be removed since timeoutIDs
anandc
2013/08/06 23:27:22
Yes, removed.
|
+ clearTimeout(test.eventExpectations_.timeoutIDs_[i]); |
+ } |
+ if (test.status == test.PASS) { |
assert_false(test.eventExpectations_.expectingEvents(), "No pending event expectations."); |
+ assert_equals(Object.keys(test.eventExpectations_.timeoutIDs_).length, 0); |
acolwell GONE FROM CHROMIUM
2013/08/06 23:05:09
nit: ditto
anandc
2013/08/06 23:27:22
Done.
|
+ } |
oldTestDone(); |
}; |
}; |