Bug 1373537 - Fix dynamically add closed caption reftest against delay image decoding issue. r=jaws
MozReview-Commit-ID: EwDrn789qc4
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/reftests/foo.vtt
@@ -0,0 +1,4 @@
+WEBVTT
+
+00:00:00.000 --> 00:00:05.000
+Foo
--- a/toolkit/content/tests/reftests/videocontrols-dynamically-add-cc-ref.html
+++ b/toolkit/content/tests/reftests/videocontrols-dynamically-add-cc-ref.html
@@ -17,24 +17,17 @@
z-index: 3;
width: 320px;
height: 200px;
background-color: green;
top: 0;
left: 0;
}
</style>
-<script>
- function addCCToVid(videoElem) {
- videoElem.addTextTrack("subtitles", "English", "en");
- }
-</script>
</head>
<body>
- <video id="vid" controls></video>
+ <video id="vid" controls>
+ <track kind="subtitles" src="foo.vtt" srclang="en">
+ </video>
<div id="mask"></div>
- <script>
- var vid = document.getElementById("vid");
- addCCToVid(vid);
- </script>
</body>
</html>
--- a/toolkit/content/tests/reftests/videocontrols-dynamically-add-cc.html
+++ b/toolkit/content/tests/reftests/videocontrols-dynamically-add-cc.html
@@ -16,26 +16,36 @@
position: absolute;
z-index: 3;
width: 320px;
height: 200px;
background-color: green;
top: 0;
left: 0;
}
+
+ #vid-preload-image {
+ visibility: hidden;
+ }
</style>
<script>
function addCCToVid(videoElem) {
videoElem.addTextTrack("subtitles", "English", "en");
}
</script>
</head>
<body>
<video id="vid" controls></video>
<div id="mask"></div>
+ <!-- Create a hidden video with CC button displayed upfront to decode image
+ earlier, so that the CC image will be ready to paint once the track added. -->
+ <video id="vid-preload-image" controls>
+ <track kind="subtitles" src="foo.vtt" srclang="en">
+ </video>
+
<script>
function doTest() {
var vid = document.getElementById("vid");
// Videocontrols binding's "addtrack" handler synchronously fires
// "adjustControlSize()" first, and then the layout is ready for
// the reftest snapshot.
vid.textTracks.addEventListener("addtrack", function() {