OLD | NEW |
1 <body onload="test()"> | 1 <body onload="test()"> |
2 <p>Test Media object lifetime.</p> | 2 <p>Test Media object lifetime.</p> |
3 <div id=result>Testing...</div> | 3 <div id=result>Testing...</div> |
4 <iframe src="about:blank"></iframe> | 4 <iframe src="about:blank"></iframe> |
| 5 <script src="../../resources/gc.js"></script> |
5 <script> | 6 <script> |
6 if (window.testRunner) { | 7 if (window.testRunner) { |
7 testRunner.dumpAsText(); | 8 testRunner.dumpAsText(); |
8 testRunner.waitUntilDone(); | 9 testRunner.waitUntilDone(); |
9 } | 10 } |
10 | 11 |
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() | 12 function test() |
22 { | 13 { |
23 if (!window.styleMedia) { | 14 if (!window.styleMedia) { |
24 document.getElementById("result").innerHTML = "FAIL - window.styleMedia
is not supported."; | 15 document.getElementById("result").innerHTML = "FAIL - window.styleMedia
is not supported."; |
25 return; | 16 return; |
26 } | 17 } |
27 | 18 |
28 styleMedia.foo = "bar"; | 19 styleMedia.foo = "bar"; |
29 gc(); | 20 gc(); |
30 if (styleMedia.foo != "bar") { | 21 if (styleMedia.foo != "bar") { |
31 document.getElementById("result").innerHTML = "FAIL - window.styelMedia
doesn't return the same object each time."; | 22 document.getElementById("result").innerHTML = "FAIL - window.styelMedia
doesn't return the same object each time."; |
32 return; | 23 return; |
33 } | 24 } |
34 | 25 |
35 var m = frames[0].styleMedia; | 26 var m = frames[0].styleMedia; |
36 document.body.removeChild(document.getElementsByTagName("iframe")[0]); | 27 document.body.removeChild(document.getElementsByTagName("iframe")[0]); |
37 try { m.matchMedium("foobar") } catch (ex) { } | 28 try { m.matchMedium("foobar") } catch (ex) { } |
38 setTimeout(function() { | 29 setTimeout(function() { |
39 gc(); | 30 gc(); |
40 try { m.matchMedium("foobar") } catch (ex) { } | 31 try { m.matchMedium("foobar") } catch (ex) { } |
41 document.getElementById("result").innerHTML = "PASS"; | 32 document.getElementById("result").innerHTML = "PASS"; |
42 if (window.testRunner) | 33 if (window.testRunner) |
43 testRunner.notifyDone(); | 34 testRunner.notifyDone(); |
44 }, 0); | 35 }, 0); |
45 } | 36 } |
46 </script> | 37 </script> |
OLD | NEW |