Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <title>Test MediaKeys lifetime</title> | |
|
ddorwin
2014/02/26 22:40:40
This doesn't seem to do much more than test the st
| |
| 5 <script src="../../resources/testharness.js"></script> | |
| 6 <script src="../../resources/testharnessreport.js"></script> | |
| 7 <script src="../../resources/gc.js"></script> | |
| 8 </head> | |
| 9 <body> | |
| 10 <div id="log"></div> | |
| 11 <script> | |
| 12 test(function() | |
| 13 { | |
| 14 var mediaKeys; | |
| 15 | |
| 16 // Create a MediaKeys object. | |
| 17 mediaKeys = new MediaKeys("org.w3.clearkey"); | |
| 18 assert_not_equals(mediaKeys, null); | |
| 19 assert_equals(mediaKeys.keySystem, 'org.w3.clearkey'); | |
| 20 | |
| 21 // Run gc(), should not affect MediaKeys object since we have | |
| 22 // a reference to it. | |
| 23 gc(); | |
| 24 assert_not_equals(mediaKeys, null); | |
| 25 assert_equals(mediaKeys.keySystem, 'org.w3.clearkey'); | |
| 26 | |
| 27 // Drop reference to the MediaKeys object and run gc again. | |
| 28 // Object should be collected this time. | |
| 29 mediaKeys = null; | |
| 30 gc(); | |
| 31 | |
| 32 // Create a large number of MediaKeys objects and then run gc. | |
| 33 // All but the last one created should be garbage collected. | |
|
ddorwin
2014/02/26 22:40:40
We can't actually verify the others are GC'd unles
| |
| 34 for (var i = 0; i < 100; ++i) | |
| 35 mediaKeys = new MediaKeys("org.w3.clearkey"); | |
| 36 gc(); | |
| 37 | |
| 38 // Last MediaKeys object created should still be referenced. | |
| 39 assert_not_equals(mediaKeys, null); | |
| 40 assert_equals(mediaKeys.keySystem, 'org.w3.clearkey'); | |
| 41 | |
| 42 // Release the last MediaKeys object created. | |
| 43 mediaKeys = null; | |
| 44 gc(); | |
| 45 }, "MediaKeys lifetime"); | |
| 46 </script> | |
| 47 </body> | |
| 48 </html> | |
| OLD | NEW |