Web MIDI Autoplay Policy test

This is an example to demonstrate a possible bug in Chrome at version 66.0.3358.0.

The behaviour in question is only observable without any open DevTools panel which is why all actions are logged to the screen.

When pressing the "toggle sound" button a script gets called which tries to turn on a simple oscillator. When pressing the button again the oscillator will stop. For the purpose of this demo the underlying AudioContext was created before and will most likely have a "suspended" state when the button gets pressed for the first time. In that case the AudioContext will be resumed in response to the first click which works absolutely fine.

However the script of this page is also listening to any MIDI event and will try to execute the same code as mentioned above. When doing so in response to a MIDI event the promise returned by the AudioContext's resume method doesn't resolve until another user gesture happens.

    The source code of this demo is available on GitHub.