requestFullscreen is not returning a promise

Sagiv b.g picture Sagiv b.g · Aug 28, 2018 · Viewed 12.7k times · Source

I'm facing an unexpected behavior and wanted to be sure i'm not missing something before i'm filling a bug.
I've played with requestFullscreen on chrome and firefox and noticed it's not returning a promise like stated in the spec.

Example for webkit:

el.addEventListener('click', () => {
    const p = el.webkitRequestFullScreen();
    p.then(() => {console.log('full screen')});
});

I'm getting:

Uncaught TypeError: Cannot read property 'then' of undefined at HTMLDivElement.el.addEventListener

Same goes for firefox:

el.addEventListener('click', () => {
    const p = el.mozRequestFullScreen();
    p.then(() => {console.log('full screen')});
});

TypeError: p is undefined

Am i reading the spec wrong? shouldn't i expect that promise?

Answer

JaffaTheCake picture JaffaTheCake · Aug 28, 2018

https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#Browser_compatibility

Unfortunately there's no browser support for the promise-returning version.