Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Side by Side Diff: third_party/WebKit/LayoutTests/media/track/track-cue-gc-wrapper.html

Issue 2078443003: Convert media-element*, track-cue* and track-remove* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <title>Tests that added cue object wrappers live across garbage collections.</ti tle>
3 <head> 3 <script src="../../resources/testharness.js"></script>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 4 <script src="../../resources/testharnessreport.js"></script>
5 <script src="../media-file.js"></script>
6 <video></video>
7 <script>
8 async_test(function(t) {
9 var cueIndex = 0;
10 var cueLimit = 10;
11 var video = document.querySelector("video");
12 video.src = findMediaFile("video", "../content/test");
5 13
6 <script src=../media-file.js></script> 14 video.textTracks.custom = "trackList";
7 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 15 assert_true(video.textTracks.hasOwnProperty("custom"));
8 (Please avoid writing new tests using video-test.js) -->
9 <script src=../video-test.js></script>
10 <script>
11 var cue;
12 var track;
13 var j = 0;
14 var cueLimit = 10;
15 16
16 function checkNativeProperty() 17 // Add a text track to the video element.
17 { 18 var track = video.addTextTrack("captions", "regular captions track", "en");
18 cue = this; 19 track.custom = "track";
19 testExpected("cue.hasOwnProperty('custom')", true); 20 assert_true(track.hasOwnProperty("custom"));
20 if (++j >= cueLimit)
21 endTest();
22 }
23 21
24 function startTest() 22 // Add cues with own native property to the track with enter event listener.
25 { 23 for (var i = 0; i < cueLimit; i++) {
26 findMediaElement(); 24 var cue = new VTTCue(i / 4, i / 2 + 1, "Label" + i);
27 video.src = findMediaFile('video', '../content/test'); 25 cue.custom = "cue";
26 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.
28 27
29 video.textTracks.custom = "trackList"; 28 track.addCue(cue);
30 testExpected("video.textTracks.hasOwnProperty('custom')", true); 29 }
31 30
32 consoleWrite("** Add a text track to the video element **"); 31 function checkNativeProperty() {
32 var currentCue = this;
33 assert_true(currentCue.hasOwnProperty("custom"));
34 if (++cueIndex == cueLimit)
35 t.done();
36 }
33 37
34 track = video.addTextTrack("captions", "regular captions track", "en "); 38 for (var i = 0; i < cueLimit; i++) {
35 track.custom = "track"; 39 var cue = track.cues[i];
36 testExpected("track.hasOwnProperty('custom')", true); 40 assert_true(cue.hasOwnProperty("custom"));
41 }
37 42
38 consoleWrite("** Add cues with own native property to the track with enter event listener. **"); 43 // Trigger a garbage collection.
39 for (var i = 0; i < cueLimit; i++) { 44 track = null;
40 var c = new VTTCue(i / 4, i / 2 + 1, "Label" + i); 45 gc();
41 c.custom = "cue";
42 c.addEventListener("enter", checkNativeProperty);
43 track.addCue(c);
44 c = null;
45 }
46 for (var i = 0; i < 10; i++) {
47 cue = track.cues[i];
48 testExpected("cue.hasOwnProperty('custom')", true);
49 }
50 46
51 consoleWrite(""); 47 assert_true(video.textTracks.hasOwnProperty("custom"));
52 consoleWrite("** Trigger a garbage collection. **");
53 track = null;
54 cue = null;
55 gc();
56 48
57 testExpected("video.textTracks.hasOwnProperty('custom')", true); 49 track = video.textTracks[0];
50 assert_true(track.hasOwnProperty("custom"));
58 51
59 track = video.textTracks[0]; 52 // Play the video and test cue wrappers.
60 testExpected("track.hasOwnProperty('custom')", true); 53 video.play();
61 54 track.mode = "showing";
62 consoleWrite(""); 55 });
63 consoleWrite("** Play the video and test cue wrappers. **"); 56 </script>
64 run("video.play()");
65 track.mode = "showing";
66 }
67 </script>
68 </head>
69
70 <body onload="startTest()">
71 <p>Tests that added cue object wrappers live across garbage collections. </p>
72 <video controls />
73 </body>
74 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698