Title: [221968] trunk/Source/WebCore
Revision
221968
Author
mra...@apple.com
Date
2017-09-13 08:02:40 -0700 (Wed, 13 Sep 2017)

Log Message

Ensure the user interacted with the page before setting m_userHasInteractedWithMediaElement
https://bugs.webkit.org/show_bug.cgi?id=176816

Reviewed by Eric Carlson.

Currently, when the user presses a keyboard shortcut in the client to reload a page, that may
get registered as a user gesture on the reloaded page. Before setting the
m_userHasInteractedWithMediaElement flag, we should check if a user gesture was actually handled
by checking the userDidInteractWithPage flag. In case of key events that aren't handled by the
page, this will be set to false by EventHandler:

    // If the key event was not handled, do not treat it as user interaction with the page.
    if (topDocument && !wasHandled)
        topDocument->setUserDidInteractWithPage(savedUserDidInteractWithPage);

We need to revisit this in the future in webkit.org/b/176817 and ensure user gesture tokens
don't carry over across reloads of the page.

Tests: I wasn't able to trigger the pathological scenario this aims to fix with a test that calls
window.location.reload() from a synthetic keyDown event.

* dom/Document.cpp:
(WebCore::Document::noteUserInteractionWithMediaElement):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (221967 => 221968)


--- trunk/Source/WebCore/ChangeLog	2017-09-13 11:47:44 UTC (rev 221967)
+++ trunk/Source/WebCore/ChangeLog	2017-09-13 15:02:40 UTC (rev 221968)
@@ -1,3 +1,29 @@
+2017-09-12  Matt Rajca  <mra...@apple.com>
+
+        Ensure the user interacted with the page before setting m_userHasInteractedWithMediaElement
+        https://bugs.webkit.org/show_bug.cgi?id=176816
+
+        Reviewed by Eric Carlson.
+
+        Currently, when the user presses a keyboard shortcut in the client to reload a page, that may
+        get registered as a user gesture on the reloaded page. Before setting the
+        m_userHasInteractedWithMediaElement flag, we should check if a user gesture was actually handled
+        by checking the userDidInteractWithPage flag. In case of key events that aren't handled by the
+        page, this will be set to false by EventHandler:
+
+            // If the key event was not handled, do not treat it as user interaction with the page.
+            if (topDocument && !wasHandled)
+                topDocument->setUserDidInteractWithPage(savedUserDidInteractWithPage);
+
+        We need to revisit this in the future in webkit.org/b/176817 and ensure user gesture tokens
+        don't carry over across reloads of the page.
+
+        Tests: I wasn't able to trigger the pathological scenario this aims to fix with a test that calls
+        window.location.reload() from a synthetic keyDown event.
+
+        * dom/Document.cpp:
+        (WebCore::Document::noteUserInteractionWithMediaElement):
+
 2017-09-13  Ms2ger  <ms2...@igalia.com>
 
         Disallow passing null values to various WebGL2 methods.

Modified: trunk/Source/WebCore/dom/Document.cpp (221967 => 221968)


--- trunk/Source/WebCore/dom/Document.cpp	2017-09-13 11:47:44 UTC (rev 221967)
+++ trunk/Source/WebCore/dom/Document.cpp	2017-09-13 15:02:40 UTC (rev 221968)
@@ -3648,6 +3648,9 @@
     if (m_userHasInteractedWithMediaElement)
         return;
 
+    if (!topDocument().userDidInteractWithPage())
+        return;
+
     m_userHasInteractedWithMediaElement = true;
     updateIsPlayingMedia();
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to