| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Test that the callback is not garbage collected if registered.</t
itle> | 4 <title>Test that the callback is not garbage collected if registered.</t
itle> |
| 5 <script src="../../resources/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> | 6 <script src="../../resources/testharnessreport.js"></script> |
| 7 <script src="../media-file.js"></script> | 7 <script src="../media-file.js"></script> |
| 8 <script src="../../resources/gc.js"></script> |
| 8 </head> | 9 </head> |
| 9 <body> | 10 <body> |
| 10 <script> | 11 <script> |
| 11 // WPT: this test can't be moved to WPT because of its usage of: | |
| 12 // - GCController.collect() | |
| 13 | |
| 14 function gc() { | |
| 15 if (window.GCController) | |
| 16 GCController.collect(); | |
| 17 else { | |
| 18 for (var i = 0; i < 10000; ++i) { | |
| 19 ({ }); | |
| 20 } | |
| 21 } | |
| 22 } | |
| 23 | |
| 24 async_test(function(t) | 12 async_test(function(t) |
| 25 { | 13 { |
| 26 var v = document.createElement('video'); | 14 var v = document.createElement('video'); |
| 27 v.src = findMediaFile('video', 'content/test'); | 15 v.src = findMediaFile('video', 'content/test'); |
| 28 document.body.appendChild(v); | 16 document.body.appendChild(v); |
| 29 | 17 |
| 30 function callback(available) {} | 18 function callback(available) {} |
| 31 var callbackRef = t.step_func_done(callback); | 19 var callbackRef = t.step_func_done(callback); |
| 32 | 20 |
| 33 v.remote.watchAvailability(callbackRef).then( | 21 v.remote.watchAvailability(callbackRef).then( |
| 34 function() { callbackRef = null; gc(); }, | 22 function() { callbackRef = null; gc(); }, |
| 35 t.unreached_func()); | 23 t.unreached_func()); |
| 36 }, 'Test that the callback is not garbage collected if registered.')
; | 24 }, 'Test that the callback is not garbage collected if registered.')
; |
| 37 </script> | 25 </script> |
| 38 </body> | 26 </body> |
| 39 </html> | 27 </html> |
| OLD | NEW |