Index: content/test/data/media/webrtc_test_utilities.js |
diff --git a/content/test/data/media/webrtc_test_utilities.js b/content/test/data/media/webrtc_test_utilities.js |
index aa11a975912478108af4879dd16c6d35000788fe..2d0c4758e6507dd088d1d4f139dd7755b61e5b69 100644 |
--- a/content/test/data/media/webrtc_test_utilities.js |
+++ b/content/test/data/media/webrtc_test_utilities.js |
@@ -18,6 +18,8 @@ var gNumberOfEvents = 0; |
var gAllEventsOccured = function () {}; |
+var gPendingTimeout; |
+ |
// Use this function to set a function that will be called once all expected |
// events has occurred. |
function setAllEventsOccuredHandler(handler) { |
@@ -41,6 +43,20 @@ function failTest(reason) { |
window.domAutomationController.send(error.stack); |
} |
+// Fail a test on the C++ side after a timeout. Will cancel any pending timeout. |
+function failTestAfterTimeout(reason, timeout_ms) { |
+ cancelTestTimeout(); |
+ gPendingTimeout = setTimeout(function() { |
+ failTest(reason); |
+ }, timeout_ms); |
+} |
+ |
+// Cancels the current test timeout. |
+function cancelTestTimeout() { |
+ clearTimeout(gPendingTimeout); |
+ gPendingTimeout = null; |
+} |
+ |
// Called if getUserMedia fails. |
function printGetUserMediaError(error) { |
var message = 'getUserMedia request unexpectedly failed:'; |
@@ -262,4 +278,3 @@ function assertTrue(booleanExpression, description) { |
failTest(description); |
} |
} |
- |