Index: LayoutTests/http/tests/media/media-source/mediasource-config-changes.js |
diff --git a/LayoutTests/http/tests/media/media-source/mediasource-config-changes.js b/LayoutTests/http/tests/media/media-source/mediasource-config-changes.js |
index f8342480abda2e6d22a6d7d04e4056a69a0bc711..7c79315ff03faffd00e7b16fb428e326d4008fff 100644 |
--- a/LayoutTests/http/tests/media/media-source/mediasource-config-changes.js |
+++ b/LayoutTests/http/tests/media/media-source/mediasource-config-changes.js |
@@ -1,3 +1,13 @@ |
+// Extract & return the resolution string from a filename, if any. |
+function resolutionFromFilename(filename) |
+{ |
+ resolution = filename.replace(/^.*[^0-9]([0-9]+x[0-9]+)[^0-9].*$/, "$1"); |
+ if (resolution != filename) { |
+ return resolution; |
+ } |
+ return ""; |
+} |
+ |
function appendBuffer(test, sourceBuffer, data) |
{ |
test.expectEvent(sourceBuffer, "update"); |
@@ -13,7 +23,8 @@ function mediaSourceConfigChangeTest(directory, idA, idB, description) |
{ |
mediaElement.pause(); |
test.failOnEvent(mediaElement, 'error'); |
- test.endOnEvent(mediaElement, 'ended'); |
+ var expectResizeEvents = resolutionFromFilename(manifestFilenameA) != resolutionFromFilename(manifestFilenameB); |
+ var expectedResizeEventCount = 0; |
MediaSourceUtil.fetchManifestAndData(test, manifestFilenameA, function(typeA, dataA) |
{ |
@@ -30,6 +41,7 @@ function mediaSourceConfigChangeTest(directory, idA, idB, description) |
// Add the second buffer starting at 0.5 second. |
sourceBuffer.timestampOffset = 0.5; |
appendBuffer(test, sourceBuffer, dataB); |
+ ++expectedResizeEventCount; |
}); |
test.waitForExpectedEvents(function() |
@@ -37,6 +49,7 @@ function mediaSourceConfigChangeTest(directory, idA, idB, description) |
// Add the first buffer starting at 1 second. |
sourceBuffer.timestampOffset = 1; |
appendBuffer(test, sourceBuffer, dataA); |
+ ++expectedResizeEventCount; |
}); |
test.waitForExpectedEvents(function() |
@@ -44,6 +57,7 @@ function mediaSourceConfigChangeTest(directory, idA, idB, description) |
// Add the second buffer starting at 1.5 second. |
sourceBuffer.timestampOffset = 1.5; |
appendBuffer(test, sourceBuffer, dataB); |
+ ++expectedResizeEventCount; |
}); |
test.waitForExpectedEvents(function() |
@@ -52,8 +66,18 @@ function mediaSourceConfigChangeTest(directory, idA, idB, description) |
mediaSource.duration = 2; |
mediaSource.endOfStream(); |
+ if (expectResizeEvents) { |
+ for (var i = 0; i < expectedResizeEventCount; ++i) { |
+ test.expectEvent(mediaElement, "resize"); |
+ } |
+ } |
+ test.expectEvent(mediaElement, "ended"); |
mediaElement.play(); |
}); |
+ |
+ test.waitForExpectedEvents(function() { |
+ test.done(); |
+ }); |
}); |
}); |
}, description, { timeout: 10000 } ); |