Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/track/track-cue-gc-wrapper.html |
| diff --git a/third_party/WebKit/LayoutTests/media/track/track-cue-gc-wrapper.html b/third_party/WebKit/LayoutTests/media/track/track-cue-gc-wrapper.html |
| index 0ff60be0612be4f4474b92d855b4c3a2d7f9a470..550df1871821447b43027351641637bc58e54d3c 100644 |
| --- a/third_party/WebKit/LayoutTests/media/track/track-cue-gc-wrapper.html |
| +++ b/third_party/WebKit/LayoutTests/media/track/track-cue-gc-wrapper.html |
| @@ -1,74 +1,56 @@ |
| <!DOCTYPE html> |
| -<html> |
| - <head> |
| - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| - |
| - <script src=../media-file.js></script> |
| - <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 |
| - (Please avoid writing new tests using video-test.js) --> |
| - <script src=../video-test.js></script> |
| - <script> |
| - var cue; |
| - var track; |
| - var j = 0; |
| - var cueLimit = 10; |
| - |
| - function checkNativeProperty() |
| - { |
| - cue = this; |
| - testExpected("cue.hasOwnProperty('custom')", true); |
| - if (++j >= cueLimit) |
| - endTest(); |
| - } |
| - |
| - function startTest() |
| - { |
| - findMediaElement(); |
| - video.src = findMediaFile('video', '../content/test'); |
| - |
| - video.textTracks.custom = "trackList"; |
| - testExpected("video.textTracks.hasOwnProperty('custom')", true); |
| - |
| - consoleWrite("** Add a text track to the video element **"); |
| - |
| - track = video.addTextTrack("captions", "regular captions track", "en"); |
| - track.custom = "track"; |
| - testExpected("track.hasOwnProperty('custom')", true); |
| - |
| - consoleWrite("** Add cues with own native property to the track with enter event listener. **"); |
| - for (var i = 0; i < cueLimit; i++) { |
| - var c = new VTTCue(i / 4, i / 2 + 1, "Label" + i); |
| - c.custom = "cue"; |
| - c.addEventListener("enter", checkNativeProperty); |
| - track.addCue(c); |
| - c = null; |
| - } |
| - for (var i = 0; i < 10; i++) { |
| - cue = track.cues[i]; |
| - testExpected("cue.hasOwnProperty('custom')", true); |
| - } |
| - |
| - consoleWrite(""); |
| - consoleWrite("** Trigger a garbage collection. **"); |
| - track = null; |
| - cue = null; |
| - gc(); |
| - |
| - testExpected("video.textTracks.hasOwnProperty('custom')", true); |
| - |
| - track = video.textTracks[0]; |
| - testExpected("track.hasOwnProperty('custom')", true); |
| - |
| - consoleWrite(""); |
| - consoleWrite("** Play the video and test cue wrappers. **"); |
| - run("video.play()"); |
| - track.mode = "showing"; |
| - } |
| - </script> |
| - </head> |
| - |
| - <body onload="startTest()"> |
| - <p>Tests that added cue object wrappers live across garbage collections.</p> |
| - <video controls /> |
| - </body> |
| -</html> |
| +<title>Tests that added cue object wrappers live across garbage collections.</title> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script src="../media-file.js"></script> |
| +<video></video> |
| +<script> |
| +async_test(function(t) { |
| + var cueIndex = 0; |
| + var cueLimit = 10; |
| + var video = document.querySelector("video"); |
| + video.src = findMediaFile("video", "../content/test"); |
| + |
| + video.textTracks.custom = "trackList"; |
| + assert_true(video.textTracks.hasOwnProperty("custom")); |
| + |
| + // Add a text track to the video element. |
| + var track = video.addTextTrack("captions", "regular captions track", "en"); |
| + track.custom = "track"; |
| + assert_true(track.hasOwnProperty("custom")); |
| + |
| + // Add cues with own native property to the track with enter event listener. |
| + for (var i = 0; i < cueLimit; i++) { |
| + var cue = new VTTCue(i / 4, i / 2 + 1, "Label" + i); |
| + cue.custom = "cue"; |
| + cue.addEventListener("enter", checkNativeProperty); |
|
Srirama
2016/06/16 13:30:45
I am not sure why using cue.onenter isn't working
fs
2016/06/16 22:58:50
Sounds odd. Is it failing because 'currentCue' (i.
Srirama
2016/06/17 06:30:13
Problem is with "this", as instanceof is failing.
|
| + |
| + track.addCue(cue); |
| + } |
| + |
| + function checkNativeProperty() { |
| + var currentCue = this; |
| + assert_true(currentCue.hasOwnProperty("custom")); |
| + if (++cueIndex == cueLimit) |
| + t.done(); |
| + } |
| + |
| + for (var i = 0; i < cueLimit; i++) { |
| + var cue = track.cues[i]; |
| + assert_true(cue.hasOwnProperty("custom")); |
| + } |
| + |
| + // Trigger a garbage collection. |
| + track = null; |
| + gc(); |
| + |
| + assert_true(video.textTracks.hasOwnProperty("custom")); |
| + |
| + track = video.textTracks[0]; |
| + assert_true(track.hasOwnProperty("custom")); |
| + |
| + // Play the video and test cue wrappers. |
| + video.play(); |
| + track.mode = "showing"; |
| +}); |
| +</script> |