I have a test I'm doing to see if audio can be played under Chrome's media engagement score for the current window. It seems like a neat thing to wrap up as a Modernizr test. The test is something like:
Modernizr.addTest('audioallowed', () => {
return new Audio().play().catch((e) => my logic returning true or false);
});
But this is asynchronouse / returns a promise. How do I put that in a Modernizr test? I can't find anything in the docs. I assume I would use it differently:
Modernizr.audioallowed.then(() = {
//But I don't see anything like this in the docs...
});
Unlike
addTest, Modernizr does not exposeaddAsyncTestmethod. And,addTestmethod, on which you have to relay, expect synchronous return. No synchronous return === test is interpreted as failed.Regarding your specific task: maybe to reverse logic upside down?
to become