-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Videos autoplay with sound on cnn.com pages after refresh in Safari
https://bugs.webkit.org/show_bug.cgi?id=258696 rdar://110343800 Reviewed by Chris Dumez. The HTML specification defines a very narrow set of gesture events which will cause activation. WebKit currently triggers activation for all uses of UserGestureIndicator, which leads to things like "LeftCmd Up" after a Cmd-R to trigger playback during a reload. Add a set of helper methods `userGestureTypeForPlatformEvent()` to return the correct UserGestureType for a particular PlatformEvent. Update UserGestureIndicator to only set the activation timestamp of the window when passed a UserGestureType::ActivationTriggering. Make UserGestureType::ActivationTriggering the default to handle the currently large set of call sites that expect a user gesture to be triggered from a programmatic call. * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/html/user-activation/activation-trigger-keyboard-enter-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/user-activation/activation-trigger-keyboard-escape-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/user-activation/activation-trigger-mouse-left-expected.txt: * Source/WebCore/dom/UserGestureIndicator.cpp: * Source/WebCore/dom/UserGestureIndicator.h: * Source/WebCore/page/EventHandler.cpp: (WebCore::userGestureTypeForPlatformEvent): (WebCore::EventHandler::handleMousePressEvent): (WebCore::EventHandler::handleMouseDoubleClickEvent): (WebCore::EventHandler::handleMouseReleaseEvent): (WebCore::EventHandler::internalKeyEvent): (WebCore::EventHandler::handleTouchEvent): Canonical link: https://commits.webkit.org/265688@main
- Loading branch information
1 parent
4498c48
commit f4cdea7
Showing
17 changed files
with
170 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Tests that transient activation is generated by correct events. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
eventSender.mouseMoveTo(50, 50) | ||
PASS EVENT(mousemove) | ||
PASS navigator.userActivation.isActive is false | ||
eventSender.mouseDown() | ||
PASS EVENT(mousedown) | ||
PASS navigator.userActivation.isActive is true | ||
eventSender.mouseUp() | ||
PASS EVENT(mouseup) | ||
PASS navigator.userActivation.isActive is false | ||
UIHelper.rawKeyDown('escape') | ||
PASS EVENT(keydown) | ||
PASS navigator.userActivation.isActive is false | ||
UIHelper.rawKeyUp('esc') | ||
PASS EVENT(keyup) | ||
PASS navigator.userActivation.isActive is false | ||
UIHelper.rawKeyDown('a') | ||
PASS EVENT(keydown) | ||
PASS navigator.userActivation.isActive is true | ||
UIHelper.rawKeyUp('a') | ||
PASS EVENT(keyup) | ||
PASS navigator.userActivation.isActive is false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<script src="../../resources/js-test-pre.js"></script> | ||
<script src="../../resources/ui-helper.js"></script> | ||
<script> | ||
description("Tests that transient activation is generated by correct events."); | ||
|
||
testRunner.waitUntilDone(); | ||
|
||
function waitFor(element, type) { | ||
return new Promise(resolve => { | ||
element.addEventListener(type, event => { | ||
testPassed(`EVENT(${event.type})`); | ||
resolve(event); | ||
}, { once: true }); | ||
}); | ||
} | ||
|
||
async function doTest() { | ||
internals.consumeTransientActivation(); | ||
|
||
let mouseMovePromise = waitFor(document, 'mousemove'); | ||
evalAndLog("eventSender.mouseMoveTo(50, 50)"); | ||
await mouseMovePromise; | ||
shouldBeFalse("navigator.userActivation.isActive"); | ||
internals.consumeTransientActivation(); | ||
|
||
let mouseDownPromise = waitFor(document, 'mousedown'); | ||
evalAndLog("eventSender.mouseDown()"); | ||
await mouseDownPromise; | ||
shouldBeTrue("navigator.userActivation.isActive"); | ||
internals.consumeTransientActivation(); | ||
|
||
let mouseUpPromise = waitFor(document, 'mouseup'); | ||
evalAndLog("eventSender.mouseUp()"); | ||
await mouseUpPromise; | ||
shouldBeFalse("navigator.userActivation.isActive"); | ||
internals.consumeTransientActivation(); | ||
|
||
var keyDownPromise = waitFor(document, 'keydown'); | ||
var promise = evalAndLog("UIHelper.rawKeyDown('escape')"); | ||
await Promise.all([promise, keyDownPromise]); | ||
shouldBeFalse("navigator.userActivation.isActive"); | ||
internals.consumeTransientActivation(); | ||
|
||
var keyUpPromise = waitFor(document, 'keyup'); | ||
var promise = evalAndLog("UIHelper.rawKeyUp('esc')"); | ||
await Promise.all([promise, keyUpPromise]); | ||
shouldBeFalse("navigator.userActivation.isActive"); | ||
internals.consumeTransientActivation(); | ||
|
||
keyDownPromise = waitFor(document, 'keydown'); | ||
var promise = evalAndLog("UIHelper.rawKeyDown('a')"); | ||
await Promise.all([promise, keyDownPromise]); | ||
shouldBeTrue("navigator.userActivation.isActive"); | ||
internals.consumeTransientActivation(); | ||
|
||
keyUpPromise = waitFor(document, 'keyup'); | ||
var promise = evalAndLog("UIHelper.rawKeyUp('a')"); | ||
await Promise.all([promise, keyUpPromise]); | ||
shouldBeFalse("navigator.userActivation.isActive"); | ||
internals.consumeTransientActivation(); | ||
} | ||
|
||
window.addEventListener("load", event => { | ||
doTest().catch(e => { | ||
testFailed(e.description); | ||
}).finally(() => { | ||
testRunner.notifyDone(); | ||
}); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<button id="target" style="width: 100px; height: 100px;"></button> | ||
<script src="../../resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
1 change: 0 additions & 1 deletion
1
LayoutTests/fullscreen/requestFullscreen-escape-key-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters