[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.22
[framework/web/webkit-efl.git] / LayoutTests / media / restore-from-page-cache.html
1 <html>
2     <head>
3         <script src=media-file.js></script>
4         <script src=video-test.js></script>
5         <script>
6             var mediaFile = findMediaFile("video", "content/test");
7             var loadCount = 0;
8
9             if (window.layoutTestController) {
10                 layoutTestController.dumpAsText();
11                 layoutTestController.waitUntilDone();
12                 layoutTestController.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
13             }
14
15             function pageshow(evt) 
16             {
17                 if (!evt.persisted) {
18                     // this is the first time the page has been loaded, setup the video element
19                     setup();
20                 } else {
21                     consoleWrite("*** Page returned from cache");
22
23                     testExpected("loadCount", 1);
24                     
25                     // schedule the test to end shortly, but wait long enough for the element to fire loading events
26                     //  if that is going to happen
27                     setTimeout(function() { if (window.layoutTestController) layoutTestController.notifyDone(); }, 200);
28                 }
29             }
30                 
31             function canplaythrough() 
32             {
33                 testExpected("loadCount", 0);
34                 if (!loadCount) {
35                     consoleWrite("*** Page going into cache");
36                     setTimeout('window.location = "data:text/html,<script>history.back()<" + "/script>"', 0);
37                 }
38                 ++loadCount;
39             }
40
41             function setup()
42             {
43                 video = mediaElement = document.getElementsByTagName('video')[0];
44
45                 waitForEvent('loadstart');
46                 waitForEvent('canplaythrough', canplaythrough);
47                 
48                 video.src = mediaFile;
49             }
50
51             window.onpageshow = pageshow;
52         </script>
53     </head>
54     <body>
55
56         <video controls > </video>
57         <p>Make sure we don't reload a &lt;video&gt; element when navigating back to an uncached page.</p>
58     </body>
59 </html>
60