2

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?

Sagiv b.g
  • 30,379
  • 9
  • 68
  • 99
  • 1
    Ah... the *[moz|webkit|o|ms]Full[s|S]creen* API... That's just a mess. You shouldn't expect anything than nightmares trying to make a cross-browser code... But yes, according to specs that's what should be returned. But since nobody follows the specs there, we don't have it. FF has a [3 yo bug-report](https://bugzilla.mozilla.org/show_bug.cgi?id=1188256) about it, currently P5... For their defense, they keep the prefixed version exactly because they don't follow the specs. On the other hand I couldn't find Chrome's discussion about it, and they did map to unprefixed method... – Kaiido Aug 28 '18 at 07:03
  • @Kaiido thanks, been looking for that bug but had no luck finding it. – Sagiv b.g Aug 28 '18 at 07:07

1 Answers1

2

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

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

JaffaTheCake
  • 13,895
  • 4
  • 51
  • 54
  • 3
    These docs are currently wrong for Chrome. It says version 71 doesn't support the promise version, but it does. I've researched it: The [change](https://chromium-review.googlesource.com/c/chromium/src/+/1075711/) that added the promise-returning version to Chromium [landed in Chromium **69**.0.3446.0](https://storage.googleapis.com/chromium-find-releases-static/f24.html#f24f5da91960f0afa3b0e325ebab7c81ece796d4). – nh2 Jun 30 '19 at 14:27