Title: [220023] branches/safari-604-branch

Diff

Modified: branches/safari-604-branch/LayoutTests/ChangeLog (220022 => 220023)


--- branches/safari-604-branch/LayoutTests/ChangeLog	2017-07-28 22:19:47 UTC (rev 220022)
+++ branches/safari-604-branch/LayoutTests/ChangeLog	2017-07-28 22:19:52 UTC (rev 220023)
@@ -1,5 +1,22 @@
 2017-07-28  Jason Marcell  <[email protected]>
 
+        Cherry-pick r219950. rdar://problem/33595459
+
+    2017-07-26  Chris Dumez  <[email protected]>
+
+            Pressing the Escape key should not be a valid user gesture to enter fullscreen
+            https://bugs.webkit.org/show_bug.cgi?id=174864
+            <rdar://problem/33009088>
+
+            Reviewed by Geoffrey Garen.
+
+            Add layout test coverage.
+
+            * fullscreen/requestFullscreen-escape-key-expected.txt: Added.
+            * fullscreen/requestFullscreen-escape-key.html: Added.
+
+2017-07-28  Jason Marcell  <[email protected]>
+
         Cherry-pick r219949. rdar://problem/33595616
 
     2017-07-26  Nan Wang  <[email protected]>

Added: branches/safari-604-branch/LayoutTests/fullscreen/requestFullscreen-escape-key-expected.txt (0 => 220023)


--- branches/safari-604-branch/LayoutTests/fullscreen/requestFullscreen-escape-key-expected.txt	                        (rev 0)
+++ branches/safari-604-branch/LayoutTests/fullscreen/requestFullscreen-escape-key-expected.txt	2017-07-28 22:19:52 UTC (rev 220023)
@@ -0,0 +1,14 @@
+CONSOLE MESSAGE: line 11: The Escape key may not be used as a user gesture to enter fullscreen
+Tests that pressing the Escape key cannot be used as user interaction to enter fullscreen.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.webkitFullscreenEnabled is true
+Pressing Escape key....
+keydown - Requesting fullscreen
+PASS document.webkitFullscreenElement is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: branches/safari-604-branch/LayoutTests/fullscreen/requestFullscreen-escape-key.html (0 => 220023)


--- branches/safari-604-branch/LayoutTests/fullscreen/requestFullscreen-escape-key.html	                        (rev 0)
+++ branches/safari-604-branch/LayoutTests/fullscreen/requestFullscreen-escape-key.html	2017-07-28 22:19:52 UTC (rev 220023)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests that pressing the Escape key cannot be used as user interaction to enter fullscreen.");
+jsTestIsAsync = true;
+
+window._onkeydown_ = function(e) {
+    debug("keydown - Requesting fullscreen");
+    document.body.webkitRequestFullscreen();
+
+    setTimeout(function() {
+        shouldBeNull("document.webkitFullscreenElement");
+        finishJSTest();
+    }, 0);
+}
+
+_onload_ = function() {
+    shouldBeTrue("document.webkitFullscreenEnabled");
+
+    debug("Pressing Escape key....");
+    if (window.eventSender)
+        eventSender.keyDown("escape");
+};
+</script>
+</body>
+</html>

Modified: branches/safari-604-branch/Source/WebCore/ChangeLog (220022 => 220023)


--- branches/safari-604-branch/Source/WebCore/ChangeLog	2017-07-28 22:19:47 UTC (rev 220022)
+++ branches/safari-604-branch/Source/WebCore/ChangeLog	2017-07-28 22:19:52 UTC (rev 220023)
@@ -1,5 +1,33 @@
 2017-07-28  Jason Marcell  <[email protected]>
 
+        Cherry-pick r219950. rdar://problem/33595459
+
+    2017-07-26  Chris Dumez  <[email protected]>
+
+            Pressing the Escape key should not be a valid user gesture to enter fullscreen
+            https://bugs.webkit.org/show_bug.cgi?id=174864
+            <rdar://problem/33009088>
+
+            Reviewed by Geoffrey Garen.
+
+            Pressing the Escape key should not be a valid user gesture to enter fullscreen since this
+            is the gesture to exit fullscreen already.
+
+            Test: fullscreen/requestFullscreen-escape-key.html
+
+            * dom/Document.cpp:
+            (WebCore::Document::requestFullScreenForElement):
+            * dom/UserGestureIndicator.cpp:
+            (WebCore::UserGestureIndicator::UserGestureIndicator):
+            * dom/UserGestureIndicator.h:
+            (WebCore::UserGestureToken::create):
+            (WebCore::UserGestureToken::gestureType):
+            (WebCore::UserGestureToken::UserGestureToken):
+            * page/EventHandler.cpp:
+            (WebCore::EventHandler::internalKeyEvent):
+
+2017-07-28  Jason Marcell  <[email protected]>
+
         Cherry-pick r219949. rdar://problem/33595616
 
     2017-07-26  Nan Wang  <[email protected]>

Modified: branches/safari-604-branch/Source/WebCore/dom/Document.cpp (220022 => 220023)


--- branches/safari-604-branch/Source/WebCore/dom/Document.cpp	2017-07-28 22:19:47 UTC (rev 220022)
+++ branches/safari-604-branch/Source/WebCore/dom/Document.cpp	2017-07-28 22:19:52 UTC (rev 220023)
@@ -5778,9 +5778,16 @@
         //   An algorithm is allowed to show a pop-up if, in the task in which the algorithm is running, either:
         //   - an activation behavior is currently being processed whose click event was trusted, or
         //   - the event listener for a trusted click event is being handled.
-        if (!ScriptController::processingUserGesture())
+        if (!UserGestureIndicator::processingUserGesture())
             break;
 
+        // We do not allow pressing the Escape key as a user gesture to enter fullscreen since this is the key
+        // to exit fullscreen.
+        if (UserGestureIndicator::currentUserGesture()->gestureType() == UserGestureType::EscapeKey) {
+            addConsoleMessage(MessageSource::Security, MessageLevel::Error, ASCIILiteral("The Escape key may not be used as a user gesture to enter fullscreen"));
+            break;
+        }
+
         // There is a previously-established user preference, security risk, or platform limitation.
         if (!page() || !page()->settings().fullScreenEnabled())
             break;

Modified: branches/safari-604-branch/Source/WebCore/dom/UserGestureIndicator.cpp (220022 => 220023)


--- branches/safari-604-branch/Source/WebCore/dom/UserGestureIndicator.cpp	2017-07-28 22:19:47 UTC (rev 220022)
+++ branches/safari-604-branch/Source/WebCore/dom/UserGestureIndicator.cpp	2017-07-28 22:19:52 UTC (rev 220023)
@@ -46,7 +46,7 @@
         observer(*this);
 }
 
-UserGestureIndicator::UserGestureIndicator(std::optional<ProcessingUserGestureState> state, Document* document)
+UserGestureIndicator::UserGestureIndicator(std::optional<ProcessingUserGestureState> state, Document* document, UserGestureType gestureType)
     : m_previousToken(currentToken())
 {
     // Silently ignore UserGestureIndicators on non main threads.
@@ -54,7 +54,7 @@
         return;
 
     if (state)
-        currentToken() = UserGestureToken::create(state.value());
+        currentToken() = UserGestureToken::create(state.value(), gestureType);
 
     if (document && currentToken()->processingUserGesture()) {
         document->updateLastHandledUserGestureTimestamp(MonotonicTime::now());

Modified: branches/safari-604-branch/Source/WebCore/dom/UserGestureIndicator.h (220022 => 220023)


--- branches/safari-604-branch/Source/WebCore/dom/UserGestureIndicator.h	2017-07-28 22:19:47 UTC (rev 220022)
+++ branches/safari-604-branch/Source/WebCore/dom/UserGestureIndicator.h	2017-07-28 22:19:52 UTC (rev 220023)
@@ -42,11 +42,13 @@
     NotProcessingUserGesture
 };
 
+enum class UserGestureType { EscapeKey, Other };
+
 class UserGestureToken : public RefCounted<UserGestureToken> {
 public:
-    static RefPtr<UserGestureToken> create(ProcessingUserGestureState state)
+    static RefPtr<UserGestureToken> create(ProcessingUserGestureState state, UserGestureType gestureType)
     {
-        return adoptRef(new UserGestureToken(state));
+        return adoptRef(new UserGestureToken(state, gestureType));
     }
 
     WEBCORE_EXPORT ~UserGestureToken();
@@ -54,6 +56,7 @@
     ProcessingUserGestureState state() const { return m_state; }
     bool processingUserGesture() const { return m_state == ProcessingUserGesture; }
     bool processingUserGestureForMedia() const { return m_state == ProcessingUserGesture || m_state == ProcessingPotentialUserGesture; }
+    UserGestureType gestureType() const { return m_gestureType; }
 
     void addDestructionObserver(WTF::Function<void (UserGestureToken&)>&& observer)
     {
@@ -61,13 +64,15 @@
     }
 
 private:
-    UserGestureToken(ProcessingUserGestureState state)
+    UserGestureToken(ProcessingUserGestureState state, UserGestureType gestureType)
         : m_state(state)
+        , m_gestureType(gestureType)
     {
     }
 
     ProcessingUserGestureState m_state = NotProcessingUserGesture;
     Vector<WTF::Function<void (UserGestureToken&)>> m_destructionObservers;
+    UserGestureType m_gestureType;
 };
 
 class UserGestureIndicator {
@@ -79,7 +84,7 @@
     WEBCORE_EXPORT static bool processingUserGestureForMedia();
 
     // If a document is provided, its last known user gesture timestamp is updated.
-    WEBCORE_EXPORT explicit UserGestureIndicator(std::optional<ProcessingUserGestureState>, Document* = nullptr);
+    WEBCORE_EXPORT explicit UserGestureIndicator(std::optional<ProcessingUserGestureState>, Document* = nullptr, UserGestureType = UserGestureType::Other);
     WEBCORE_EXPORT explicit UserGestureIndicator(RefPtr<UserGestureToken>);
     WEBCORE_EXPORT ~UserGestureIndicator();
 

Modified: branches/safari-604-branch/Source/WebCore/page/EventHandler.cpp (220022 => 220023)


--- branches/safari-604-branch/Source/WebCore/page/EventHandler.cpp	2017-07-28 22:19:47 UTC (rev 220022)
+++ branches/safari-604-branch/Source/WebCore/page/EventHandler.cpp	2017-07-28 22:19:52 UTC (rev 220023)
@@ -3163,7 +3163,11 @@
     if (!element)
         return false;
 
-    UserGestureIndicator gestureIndicator(ProcessingUserGesture, m_frame.document());
+    UserGestureType gestureType = UserGestureType::Other;
+    if (initialKeyEvent.windowsVirtualKeyCode() == VK_ESCAPE)
+        gestureType = UserGestureType::EscapeKey;
+
+    UserGestureIndicator gestureIndicator(ProcessingUserGesture, m_frame.document(), gestureType);
     UserTypingGestureIndicator typingGestureIndicator(m_frame);
 
     if (FrameView* view = m_frame.view())

Modified: branches/safari-604-branch/Tools/ChangeLog (220022 => 220023)


--- branches/safari-604-branch/Tools/ChangeLog	2017-07-28 22:19:47 UTC (rev 220022)
+++ branches/safari-604-branch/Tools/ChangeLog	2017-07-28 22:19:52 UTC (rev 220023)
@@ -1,3 +1,21 @@
+2017-07-28  Jason Marcell  <[email protected]>
+
+        Cherry-pick r219950. rdar://problem/33595459
+
+    2017-07-26  Chris Dumez  <[email protected]>
+
+            Pressing the Escape key should not be a valid user gesture to enter fullscreen
+            https://bugs.webkit.org/show_bug.cgi?id=174864
+            <rdar://problem/33009088>
+
+            Reviewed by Geoffrey Garen.
+
+            Add support for eventSender.keyDown('escape') in DRT to match the behavior of
+            WKTR.
+
+            * DumpRenderTree/mac/EventSendingController.mm:
+            (-[EventSendingController keyDown:withModifiers:withLocation:]):
+
 2017-07-26  Jason Marcell  <[email protected]>
 
         Cherry-pick r219764. rdar://problem/33523878

Modified: branches/safari-604-branch/Tools/DumpRenderTree/mac/EventSendingController.mm (220022 => 220023)


--- branches/safari-604-branch/Tools/DumpRenderTree/mac/EventSendingController.mm	2017-07-28 22:19:47 UTC (rev 220022)
+++ branches/safari-604-branch/Tools/DumpRenderTree/mac/EventSendingController.mm	2017-07-28 22:19:52 UTC (rev 220023)
@@ -934,6 +934,10 @@
         const unichar ch = NSDeleteFunctionKey;
         eventCharacter = [NSString stringWithCharacters:&ch length:1];
         keyCode = 0x75;
+    } else if ([character isEqualToString:@"escape"]) {
+        const unichar ch = 0x1B;
+        eventCharacter = [NSString stringWithCharacters:&ch length:1];
+        keyCode = 0x35;
     } else if ([character isEqualToString:@"printScreen"]) {
         const unichar ch = NSPrintScreenFunctionKey;
         eventCharacter = [NSString stringWithCharacters:&ch length:1];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to