Diff
Modified: trunk/LayoutTests/ChangeLog (219949 => 219950)
--- trunk/LayoutTests/ChangeLog 2017-07-26 16:53:09 UTC (rev 219949)
+++ trunk/LayoutTests/ChangeLog 2017-07-26 17:15:31 UTC (rev 219950)
@@ -1,3 +1,16 @@
+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-26 Nan Wang <[email protected]>
AX: Incorrect range from index and length in contenteditable with <p> tags
Added: trunk/LayoutTests/fullscreen/requestFullscreen-escape-key-expected.txt (0 => 219950)
--- trunk/LayoutTests/fullscreen/requestFullscreen-escape-key-expected.txt (rev 0)
+++ trunk/LayoutTests/fullscreen/requestFullscreen-escape-key-expected.txt 2017-07-26 17:15:31 UTC (rev 219950)
@@ -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: trunk/LayoutTests/fullscreen/requestFullscreen-escape-key.html (0 => 219950)
--- trunk/LayoutTests/fullscreen/requestFullscreen-escape-key.html (rev 0)
+++ trunk/LayoutTests/fullscreen/requestFullscreen-escape-key.html 2017-07-26 17:15:31 UTC (rev 219950)
@@ -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: trunk/Source/WebCore/ChangeLog (219949 => 219950)
--- trunk/Source/WebCore/ChangeLog 2017-07-26 16:53:09 UTC (rev 219949)
+++ trunk/Source/WebCore/ChangeLog 2017-07-26 17:15:31 UTC (rev 219950)
@@ -1,3 +1,27 @@
+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-26 Nan Wang <[email protected]>
AX: Incorrect range from index and length in contenteditable with <p> tags
Modified: trunk/Source/WebCore/dom/Document.cpp (219949 => 219950)
--- trunk/Source/WebCore/dom/Document.cpp 2017-07-26 16:53:09 UTC (rev 219949)
+++ trunk/Source/WebCore/dom/Document.cpp 2017-07-26 17:15:31 UTC (rev 219950)
@@ -5785,9 +5785,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: trunk/Source/WebCore/dom/UserGestureIndicator.cpp (219949 => 219950)
--- trunk/Source/WebCore/dom/UserGestureIndicator.cpp 2017-07-26 16:53:09 UTC (rev 219949)
+++ trunk/Source/WebCore/dom/UserGestureIndicator.cpp 2017-07-26 17:15:31 UTC (rev 219950)
@@ -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: trunk/Source/WebCore/dom/UserGestureIndicator.h (219949 => 219950)
--- trunk/Source/WebCore/dom/UserGestureIndicator.h 2017-07-26 16:53:09 UTC (rev 219949)
+++ trunk/Source/WebCore/dom/UserGestureIndicator.h 2017-07-26 17:15:31 UTC (rev 219950)
@@ -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: trunk/Source/WebCore/page/EventHandler.cpp (219949 => 219950)
--- trunk/Source/WebCore/page/EventHandler.cpp 2017-07-26 16:53:09 UTC (rev 219949)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2017-07-26 17:15:31 UTC (rev 219950)
@@ -3170,7 +3170,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: trunk/Tools/ChangeLog (219949 => 219950)
--- trunk/Tools/ChangeLog 2017-07-26 16:53:09 UTC (rev 219949)
+++ trunk/Tools/ChangeLog 2017-07-26 17:15:31 UTC (rev 219950)
@@ -1,3 +1,17 @@
+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 Romain Bellessort <[email protected]>
Unreviewed, added Romain Bellessort to contributors.json.
Modified: trunk/Tools/DumpRenderTree/mac/EventSendingController.mm (219949 => 219950)
--- trunk/Tools/DumpRenderTree/mac/EventSendingController.mm 2017-07-26 16:53:09 UTC (rev 219949)
+++ trunk/Tools/DumpRenderTree/mac/EventSendingController.mm 2017-07-26 17:15:31 UTC (rev 219950)
@@ -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];