https://bugs.webkit.org/show_bug.cgi?id=174864
<rdar://problem/
33009088>
Reviewed by Geoffrey Garen.
Source/WebCore:
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):
Tools:
Add support for eventSender.keyDown('escape') in DRT to match the behavior of
WKTR.
* DumpRenderTree/mac/EventSendingController.mm:
(-[EventSendingController keyDown:withModifiers:withLocation:]):
LayoutTests:
Add layout test coverage.
* fullscreen/requestFullscreen-escape-key-expected.txt: Added.
* fullscreen/requestFullscreen-escape-key.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219950
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2017-07-26 Chris Dumez <cdumez@apple.com>
+
+ 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 <n_wang@apple.com>
AX: Incorrect range from index and length in contenteditable with <p> tags
--- /dev/null
+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
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../resources/js-test.js"></script>
+<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>
+2017-07-26 Chris Dumez <cdumez@apple.com>
+
+ 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 <n_wang@apple.com>
AX: Incorrect range from index and length in contenteditable with <p> tags
// 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;
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.
return;
if (state)
- currentToken() = UserGestureToken::create(state.value());
+ currentToken() = UserGestureToken::create(state.value(), gestureType);
if (document && currentToken()->processingUserGesture()) {
document->updateLastHandledUserGestureTimestamp(MonotonicTime::now());
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();
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)
{
}
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 {
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();
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())
+2017-07-26 Chris Dumez <cdumez@apple.com>
+
+ 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 <romain.bellessort@crf.canon.fr>
Unreviewed, added Romain Bellessort to contributors.json.
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];