<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - media.webkitPresentationMode may return &quot;inline&quot; in a webkitpresentationmodechanged event handler after entering PiP"
   href="https://bugs.webkit.org/show_bug.cgi?id=165756">165756</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>media.webkitPresentationMode may return &quot;inline&quot; in a webkitpresentationmodechanged event handler after entering PiP
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>WebKit Nightly Build
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Media Elements
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>graouts&#64;apple.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The test at media/modern-media-controls/pip-support/pip-support-click.html is flaky due to &quot;media.webkitPresentationMode&quot; sometimes returning &quot;inline&quot; within a &quot;webkitpresentationmodechanged&quot; event handler after entering PiP. To reproduce, try to run this command:

Tools/Scripts/run-webkit-tests --release --time-out-ms=5000 --no-sample-on-timeout --exit-after-n-failures=1 --iterations=200 media/modern-media-controls/pip-support/pip-support-click.html

Adding a short timeout works around the problem:

media.addEventListener(&quot;webkitpresentationmodechanged&quot;, () =&gt; {
    setTimeout(() =&gt; {
        shouldBeEqualToString(&quot;media.webkitPresentationMode&quot;, &quot;picture-in-picture&quot;);
        container.remove();
        media.remove();
        finishJSTest();
    }, 10);
});</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>