| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <body> | 2 <body> |
| 3 <script src="../../resources/js-test.js"></script> | 3 <script src="../../resources/js-test.js"></script> |
| 4 <script> | 4 <script> |
| 5 description("MessagePorts (and their execution contexts) should be collected by
GC once close() has been called on them"); | 5 description("MessagePorts (and their execution contexts) should be collected by
GC once close() has been called on them"); |
| 6 | 6 |
| 7 window.jsTestIsAsync = true; | 7 window.jsTestIsAsync = true; |
| 8 |
| 9 function runGCAndTest() { |
| 10 gc(); |
| 11 shouldBeTrue("iframeDocGC.wasCollected"); |
| 12 finishJSTest(); |
| 13 } |
| 14 |
| 8 window.onmessage = function(evt) { | 15 window.onmessage = function(evt) { |
| 9 iframeDocGC = internals.observeGC(document.querySelector('iframe').contentDo
cument); | 16 iframeDocGC = internals.observeGC(document.querySelector('iframe').contentDo
cument); |
| 10 document.querySelector('iframe').remove(); | 17 document.querySelector('iframe').remove(); |
| 11 // The iframe is reachable via evt.source, and evt is on the | 18 // The iframe is reachable via evt.source, and evt is on the |
| 12 // stack. asyncGC() will invoke the callback once back at | 19 // stack. Force a GC upon return from the event handler, so |
| 13 // the event loop (and after having forced a GC); evt | 20 // that it no longer will be in scope and the iframe can |
| 14 // will consequently no longer be in scope and the iframe | 21 // be GCed. |
| 15 // will have been GCed. | 22 setTimeout(runGCAndTest, 0); |
| 16 asyncGC(function () { | |
| 17 shouldBeTrue("iframeDocGC.wasCollected"); | |
| 18 finishJSTest(); | |
| 19 }); | |
| 20 } | 23 } |
| 21 </script> | 24 </script> |
| 22 <iframe src="resources/message-port-gc-closed-iframe.html"></iframe> | 25 <iframe src="resources/message-port-gc-closed-iframe.html"></iframe> |
| 23 </body> | 26 </body> |
| OLD | NEW |