<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26366</bug_id>
          
          <creation_ts>2014-07-17 08:57:09 +0000</creation_ts>
          <short_desc>It&apos;s possible to go fullscreen with an element not in the document</short_desc>
          <delta_ts>2014-07-31 20:12:17 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>Fullscreen</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Philip Jägenstedt">philipj</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>cpearce</cc>
    
    <cc>mike</cc>
    
    <cc>philipj</cc>
    
    <cc>public-webapps</cc>
    
    <cc>roc</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>109043</commentid>
    <comment_count>0</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-07-17 08:57:09 +0000</bug_when>
    <thetext>This is one example of a class of problems caused by the checks made synchronously in requestFullscreen() not necessarily holding when the rest of the function runs async.

To go fullscreen with an element not in the document:
element.requestFullscreen();
element.parentNode.removeChild(element);

To end up with a fullscreen element stack with siblings are put on the stack:
element.requestFullscreen();
element.nextSibling.requestFullscreen();

I&apos;m not sure what bad things can result, but it seems silly to make checks that aren&apos;t actually guaranteed to hold.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109348</commentid>
    <comment_count>1</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-07-28 09:22:10 +0000</bug_when>
    <thetext>I did some ad-hoc testing on calling requestFullscreen() and exitFullscreen() multiple times in the same script and found that there wasn&apos;t great interoperability even when one doesn&apos;t try to circumvent the checks.

The basic problem is that the script-visible fullscreen element stack shouldn&apos;t be updated until one has actually entered/exited fullscreen, and there&apos;s no script-invisible state available to do these checks.

I can see a few options:

1. Have a script-invisible stack of pending requests which is pushed to the script-visible stack before the fullscreenchange event is fired.

2. Have a single pending element which is replaced by successive calls to requestFullscreen().

3. Make requestFullscreen() and exitFullscreen() do nothing if there&apos;s already a pending change.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109351</commentid>
    <comment_count>2</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-07-28 09:47:17 +0000</bug_when>
    <thetext>3 seems to be how we generally do this. Introduce a document-wide &quot;fullscreen flag&quot; and clear it once either algorithm terminates? And just make the methods no-ops if the flag is set?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109352</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-07-28 09:53:00 +0000</bug_when>
    <thetext>Although I guess we don&apos;t really want to block exitFullscreen(). Especially for things such as navigation.

A document-wide pending element could work. exitFullscreen() would just clear the element and return. And the queued task from requestFullscreen would become a no-op. Does that make sense?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109354</commentid>
    <comment_count>4</comment_count>
    <who name="Robert O&apos;Callahan (Mozilla)">roc</who>
    <bug_when>2014-07-28 09:57:24 +0000</bug_when>
    <thetext>I think so.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109356</commentid>
    <comment_count>5</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-07-28 11:04:45 +0000</bug_when>
    <thetext>(In reply to Anne from comment #3)
&gt; Although I guess we don&apos;t really want to block exitFullscreen(). Especially
&gt; for things such as navigation.
&gt; 
&gt; A document-wide pending element could work. exitFullscreen() would just
&gt; clear the element and return. And the queued task from requestFullscreen
&gt; would become a no-op. Does that make sense?

This depends on what the internal state is. If the window resize has already been requested, simply clearing the pending element would lead to something strange when the resize is completed. One could immediately exit fullscreen in that case, but should that cause an additional fullscreenchange event to be fired?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109357</commentid>
    <comment_count>6</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-07-28 13:08:17 +0000</bug_when>
    <thetext>requestFullscreen()
- sets pending element
- queues a task to run these steps
  1) if pending element is unset, return
  2) push pending element to stack
  3) unset pending element
  4) animate (async?)

exitFullscreen()
- queues a task to run these steps
  1) if pending element is set, unset it and return
  2) pop stack
  3) animate (async?)

Since they&apos;re separate tasks, there should be no problem, right? They can happen quite shortly after each other. Making that animate smoothly would be up to the implementation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109363</commentid>
    <comment_count>7</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-07-28 13:31:06 +0000</bug_when>
    <thetext>That doesn&apos;t seem quite right... we can&apos;t manipulate the fullscreen element stack from a task posted by requestFullscreen() or exitFullscreen() if it&apos;s to be synchronized with animation frames as per bug 26440.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109372</commentid>
    <comment_count>8</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-07-28 15:06:29 +0000</bug_when>
    <thetext>More problems: the checks requestFullscreen() does are crossing origin boundaries and therefore need to be asynchronous somehow. As the event is already dispatched from a task, that may be feasible.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109374</commentid>
    <comment_count>9</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-07-28 15:10:05 +0000</bug_when>
    <thetext>Maybe the checks can just be done async before the resize, that way they can take however long they want. What about race conditions, what happens when two frames request fullscreen at the same time and passes the checks, which would be violated if the timing were different?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109379</commentid>
    <comment_count>10</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-07-28 15:26:08 +0000</bug_when>
    <thetext>Yes, we need to account for the resizing process to fail.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109567</commentid>
    <comment_count>11</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-07-30 12:59:54 +0000</bug_when>
    <thetext>This should bring us a lot closer. Please review!

https://github.com/whatwg/fullscreen/commit/5187282e5fd24a1c4ff0164d444e1bfc2bdf44ef</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109701</commentid>
    <comment_count>12</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-07-31 20:12:17 +0000</bug_when>
    <thetext>New bugs for new issues I guess. Thanks all!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>