closure-library icon indicating copy to clipboard operation
closure-library copied to clipboard

goog.dom.fullscreen/isFullScreen test insufficient on webkit

Open Ninerian opened this issue 7 years ago • 0 comments

Description: The function goog.dom.fullscreen.isSupported lacks the test of webkitFullScreenEnabled.

Testcase: Put a html site inside an iframe and don't allow fullscreen. Then call the function inside the iframe. It should return false, as document.webkitFullScreenEnabled returns false.

Solution: Change the function to:

goog.dom.fullscreen.isSupported = function(opt_domHelper) {
  var doc = goog.dom.fullscreen.getDocument_(opt_domHelper);
  var body = doc.body;
  return !!(
      (body.webkitRequestFullscreen && doc.webkitFullScreenEnabled) ||
      (body.mozRequestFullScreen && doc.mozFullScreenEnabled) ||
      (body.msRequestFullscreen && doc.msFullscreenEnabled) ||
      (body.requestFullscreen && doc.fullscreenEnabled));
};

Ninerian avatar Dec 13 '16 14:12 Ninerian