[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.22
[framework/web/webkit-efl.git] / LayoutTests / fast / media / lifetime.html
1 <body onload="test()">
2 <p>Test Media object lifetime.</p>
3 <div id=result>Testing...</div>
4 <iframe src="about:blank"></iframe>
5 <script>
6 if (window.layoutTestController) {
7     layoutTestController.dumpAsText();
8     layoutTestController.waitUntilDone();
9 }
10
11 function gc()
12 {
13     if (window.GCController)
14         return GCController.collect();
15
16     for (var i = 0; i < 10000; i++) { // > force garbage collection (FF requires about 9K allocations before a collect)
17         var s = new String("abc");
18     }
19 }
20
21 function test()
22 {
23     if (!window.styleMedia) {
24         document.getElementById("result").innerHTML = "FAIL - window.styleMedia is not supported.";
25         return;
26     }
27
28     styleMedia.foo = "bar";
29     gc();
30     if (styleMedia.foo != "bar") {
31         document.getElementById("result").innerHTML = "FAIL - window.styelMedia doesn't return the same object each time.";
32         return;
33     }
34
35     var m = frames[0].styleMedia;
36     document.body.removeChild(document.getElementsByTagName("iframe")[0]);
37     try { m.matchMedium("foobar") } catch (ex) { }
38     setTimeout(function() {
39         gc();
40         try { m.matchMedium("foobar") } catch (ex) { }
41         document.getElementById("result").innerHTML = "PASS";
42         if (window.layoutTestController)
43             layoutTestController.notifyDone();
44     }, 0);
45 }
46 </script>