| <!DOCTYPE html> |
| <script src="../../imported/w3c/web-platform-tests/resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script src="../resources/audit-util.js"></script> |
| <script src="../resources/audit.js"></script> |
| <script id="layout-test-code"> |
| let audit = Audit.createTaskRunner(); |
| |
| let sampleRate = 48000; |
| let renderSeconds = 1; |
| let renderFrames = sampleRate * renderSeconds; |
| let contextChannels = 2; |
| |
| // Event listeners should not be garbage-collected prematurely. |
| // The test passes if it does not time out waiting for oncomplete. |
| audit.define('event-listener-gc', (task, should) => { |
| let context = new OfflineAudioContext(contextChannels, renderFrames, sampleRate); |
| |
| let buffer = context.createBuffer(contextChannels, renderFrames, sampleRate); |
| buffer.getChannelData(0).fill(1); |
| buffer.getChannelData(1).fill(2); |
| |
| let source = context.createBufferSource(); |
| source.buffer = buffer; |
| source.connect(context.destination); |
| source.start(); |
| |
| context.oncomplete = () => task.done(); |
| context.startRendering(); |
| |
| // Run a full GC. This should not collect the event listener. |
| if (typeof GCController !== "undefined") |
| GCController.collect(); |
| }); |
| |
| audit.run(); |
| </script> |