WebBrowserComponent allows events to be emitted before backend is initialised

Calling emitEventIfBrowserIsVisible() before window.__JUCE__.backend is initialised results in this jassert being hit with the message

TypeError: undefined is not an object (evaluating 'window.__JUCE__.backend') at (EVALUATION_SOURCE:1:16)

Unless I’m mistaken, there’s no way for the C++ side to know when the backend is initialised. It would be nice to either add a check for that, or silently queue any events until the backend is ready.


I implemented this second approach by storing events in a queue until the callback from a user script calling window.__JUCE__.backend.emitEvent('backend-ready', true) is called. It’s an easy workaround, but would be nice to have something in the WebBrowserComponent API to handle it as it wasn’t immediately obvious what the issue was.