OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Define a variable called willPlay which indicates if the media is expected | |
6 // to start playing during the test. | |
7 | |
8 var canPlaySeen = false; | |
9 var playingSeen = false; | |
10 var canPlayThroughSeen = false; | |
11 var hasError = false; | |
12 | |
13 var mediaEl = document.getElementById("mediaEl"); | |
14 | |
15 function mediaEventHandler(e) { | |
16 console.log(e.type); | |
cbentzel
2011/11/15 18:55:33
Is this console.log statement needed anymore?
Shishir
2011/11/17 21:18:49
Helpful for debugging failing tests, so might be w
scherkus (not reviewing)
2011/11/17 23:27:50
I'm a big proponent of quiet tests.
If a test sta
Shishir
2011/11/22 00:45:16
Done.
| |
17 | |
18 switch (e.type) { | |
19 case 'canplay': | |
20 canPlaySeen = true; | |
21 break; | |
22 case 'playing': | |
23 playingSeen = true; | |
24 break; | |
25 case 'canplaythrough': | |
26 canPlayThroughSeen = true; | |
27 break; | |
28 case 'error': | |
29 hasError = true; | |
30 break; | |
31 } | |
32 | |
33 if ((willPlay && canPlayThroughSeen && playingSeen) || | |
34 (!willPlay && canPlayThroughSeen && !playingSeen)) { | |
35 document.title = 'PASS'; | |
36 } | |
37 } | |
38 | |
39 mediaEl.addEventListener('playing', mediaEventHandler, false); | |
cbentzel
2011/11/15 18:55:33
Should this be using the network events (loadstart
scherkus (not reviewing)
2011/11/16 02:02:23
I agree -- loadstart, progress, and stalled are go
Shishir
2011/11/17 21:18:49
The network events are not very reliable and its n
scherkus (not reviewing)
2011/11/17 23:27:50
This is interesting to discuss and would like to h
Shishir
2011/11/22 00:45:16
Added a test for loadStart and stalled.
| |
40 mediaEl.addEventListener('canplay', mediaEventHandler, false); | |
41 mediaEl.addEventListener('canplaythrough', mediaEventHandler, false); | |
42 mediaEl.addEventListener('error', mediaEventHandler, false); | |
43 | |
44 function DidPrerenderPass() { | |
45 // The media should not have started at this point. | |
46 return !canPlaySeen && !playingSeen && !hasError && | |
47 mediaEl.currentTime == 0 && | |
48 mediaEl.readyState == mediaEl.HAVE_NOTHING; | |
49 } | |
50 | |
51 function DidDisplayPass() { | |
52 // The actual test is done via the TitleWatcher. | |
53 return true; | |
54 } | |
OLD | NEW |