Bug 1373537 - Fix dynamically add closed caption reftest against delay image decoding issue. r=jaws draft
authorRay Lin <ralin@mozilla.com>
Wed, 28 Jun 2017 23:46:03 -0700
changeset 602142 d98326879d4f55ce45b1fb0d35f37d55628c303b
parent 602141 758e494d654ade03aac9131c63f1d9baaab42fa8
child 635476 9cd17a08fc436d5eb373662d29bcbb8bc5bad463
push id66295
push userbmo:ralin@mozilla.com
push dateThu, 29 Jun 2017 18:24:09 +0000
reviewersjaws
bugs1373537
milestone56.0a1
Bug 1373537 - Fix dynamically add closed caption reftest against delay image decoding issue. r=jaws MozReview-Commit-ID: EwDrn789qc4
toolkit/content/tests/reftests/foo.vtt
toolkit/content/tests/reftests/videocontrols-dynamically-add-cc-ref.html
toolkit/content/tests/reftests/videocontrols-dynamically-add-cc.html
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() {