OLD | NEW |
1 <html> | 1 <html> |
2 <title>Test media source replacement</title> | 2 <title>Test media source replacement</title> |
3 <body> | 3 <body> |
4 | 4 |
5 <p>Test that media keeps playing when the source element is replaced.</p> | 5 <p>Test that media keeps playing when the source element is replaced.</p> |
6 | 6 |
7 <script src=video-test.js></script> | 7 <script src=video-test.js></script> |
8 <script src=media-file.js></script> | 8 <script src=media-file.js></script> |
9 <script src=../resources/gc.js></script> | 9 <script src=../resources/gc.js></script> |
10 <script> | 10 <script> |
(...skipping 26 matching lines...) Expand all Loading... |
37 function playingListener(event) | 37 function playingListener(event) |
38 { | 38 { |
39 consoleWrite("EVENT(playing)"); | 39 consoleWrite("EVENT(playing)"); |
40 } | 40 } |
41 | 41 |
42 function timeupdateListener(event) | 42 function timeupdateListener(event) |
43 { | 43 { |
44 ++timeupdateEventCount; | 44 ++timeupdateEventCount; |
45 | 45 |
46 if (timeupdateEventCount-skippedCount == 1) { | 46 if (timeupdateEventCount-skippedCount == 1) { |
47 // First time update after source replacement should be 0. | 47 // If the media play has started it should continue even if |
48 // We allow one late time update to come in from the previous | 48 // source was replaced. Wait for two timeupdate events to |
49 // source element. This was done to help the cr-linux test | 49 // make sure the same source keeps playing. |
50 // pass, and does not necessarily indicate a problem. | |
51 if (sourceReplaced) { | 50 if (sourceReplaced) { |
52 if (skippedCount >= 1 || this.currentTime == 0) { | 51 if (skippedCount >= 1 || this.currentTime > 0) { |
53 testElement = this; | 52 testElement = this; |
54 testExpected("testElement.currentTime", 0); | 53 testExpected("testElement.currentTime", 0, '>'); |
55 } else { | 54 } else { |
56 // The time is not 0 as expected. Hope this is a | 55 // The time is not 0 as expected. Make sure same |
57 // late update from the previous source. | 56 // source keeps playing by waiting for one more event. |
58 ++skippedCount; | 57 ++skippedCount; |
59 } | 58 } |
60 } | 59 } |
61 } else if (timeupdateEventCount-skippedCount >= 2) { | 60 } else if (timeupdateEventCount-skippedCount >= 2) { |
62 // We wait 2 timeupdate events so we are sure the media engine | 61 // We wait 2 timeupdate events so we are sure the media engine |
63 // is playing the media, and make sure time is advancing. | 62 // is playing the media, and make sure time is advancing. |
64 testElement = this; | 63 testElement = this; |
65 testExpected("testElement.currentTime", 0, '>'); | 64 testExpected("testElement.currentTime", 0, '>'); |
66 if (!sourceReplaced) { | 65 if (!sourceReplaced) { |
67 consoleWrite("Replacing the media's source element:"); | 66 consoleWrite("Replacing the media's source element:"); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 100 |
102 } | 101 } |
103 | 102 |
104 document.write("<audio controls></audio>"); | 103 document.write("<audio controls></audio>"); |
105 testAudioElement(0); | 104 testAudioElement(0); |
106 gc(); | 105 gc(); |
107 </script> | 106 </script> |
108 | 107 |
109 </body> | 108 </body> |
110 </html> | 109 </html> |
OLD | NEW |