Closed Bug 1481400 Opened 6 years ago Closed 3 years ago

[Youtube] Play/Pause video using spacebar is not functional after clicking on Play/Pause button

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P2)

defect

Tracking

()

VERIFIED FIXED
91 Branch
Webcompat Priority P2
Tracking Status
firefox-esr78 --- wontfix
firefox61 --- wontfix
firefox62 --- wontfix
firefox63 --- wontfix
firefox76 --- wontfix
firefox77 --- wontfix
firefox78 --- wontfix
firefox82 --- wontfix
firefox83 --- wontfix
firefox84 --- wontfix
firefox89 --- wontfix
firefox90 --- wontfix
firefox91 --- verified

People

(Reporter: tbabos, Assigned: emilio)

References

Details

Attachments

(4 files)

[Affected versions]: Latest Nightly 63.0a1 (2018-08-06) Latest Firefox 62.0b14 (64-bit) Latest Firefox Release 61.0.1 (64-bit) [Affected Platforms]: Windows 10 x64 Windows 7 x64 Ubuntu 16.04 x64 [Steps to reproduce]: 1. Launch Firefox and go to any video on Youtube 2. After the video started click on "Pause" button 3. Press spacebar to resume the video [Expected result]: The video playback should be resumed. [Actual result]: The video is not resumed and the pause button animation is displayed on the video. [Notes]: 1. The issue does not occur on Mac OS. 2. Pausing the video with spacebar after the "Play" button is clicked has the same behavior. 3. As long as the Play/Pause button is highlighted the spacebar will not work.
Component: Keyboard Navigation → Video/Audio Controls
Product: Firefox → Toolkit
Oops, Youtube doesn't use default video controls.
Component: Video/Audio Controls → Event Handling
Product: Toolkit → Core
Not sure if this should be P3 or an evangelism bug instead, but marking P2 in order to get a better look, since YouTube is a major site. It seems to me that the problem is that clicking the pause button leaves focus on that button and them pressing space bar both activates the button as if by mouse and the keyboard event is also interpreted by the page, so the keyboard action and the as-if mouse action cancel each other.
Priority: -- → P2
I reproduced this issue with the following steps: 1. Launch Firefox and access: https://www.quirksmode.org/html5/videos/big_buck_bunny.webm 2. After the video started click on "Full screen" button. 3. Press space bar to pause the video. [Expected result]: The video playback should be paused. [Actual result]: The video is not paused, seems that the focus remain on "Full screen" button.
See Also: → 1522089

Hi Mike, even after bug 1522089 was fixed, this issue is still valid. I wonder if this has anything to do with bug 1491256.

Flags: needinfo?(miket)

(In reply to Timea Zsoldos [:zstimi/tzsoldos], Desktop Release QA from comment #3)

I reproduced this issue with the following steps:

  1. Launch Firefox and access:
    https://www.quirksmode.org/html5/videos/big_buck_bunny.webm
  2. After the video started click on "Full screen" button.
  3. Press space bar to pause the video.

[Expected result]:
The video playback should be paused.

[Actual result]:
The video is not paused, seems that the focus remain on "Full screen" button.

This sounds like a different bug, as it doesn't relate to the controls that YouTube uses (who knows, it might be related). Probably worth filing a new bug for this though.

(In reply to Hsin-Yi Tsai [:hsinyi] from comment #4)

Hi Mike, even after bug 1522089 was fixed, this issue is still valid. I wonder if this has anything to do with bug 1491256.

Tom, can you please look into this bug (and see also Bug 149125)?

Flags: needinfo?(miket) → needinfo?(twisniewski)

It looks as though when I double-click the video to fullscreen it, subsequent keypress events target the video element. But if I click the fullscreen icon, they target the body element instead. Indeed, if I add this to chrome://global/content/TopLevelVideoDocument.js, then the spacebar seems to work fine after I click the fullscreen icon:

  document.addEventListener("fullscreenchange", e => {
    console.log(e, e.target);
    videoElement.focus();
  });

So this does seem to be a bug in the default player.

Flags: needinfo?(twisniewski)

(In reply to Thomas Wisniewski [:twisniewski] from comment #6)

It looks as though when I double-click the video to fullscreen it, subsequent keypress events target the video element. But if I click the fullscreen icon, they target the body element instead. Indeed, if I add this to chrome://global/content/TopLevelVideoDocument.js, then the spacebar seems to work fine after I click the fullscreen icon:

  document.addEventListener("fullscreenchange", e => {
    console.log(e, e.target);
    videoElement.focus();
  });

So this does seem to be a bug in the default player.

Hi Thomas, thanks for the investigation. So sounds like we should report this back to youtube, am I right? Are you the right person to take the action?

Flags: needinfo?(twisniewski)

:hsinyi, actually, I was testing with our own player using the STR in comment 3, so it's our own player that has the bug there.

Unfortunately I cannot reproduce the issue on YouTube, so either that has been fixed or we still have another bug I cannot diagnose (similar to bug 1491256, which I also cannot reproduce).

Flags: needinfo?(twisniewski)

I also can't reproduce this anymore -- it's likely YouTube fixed this. Let's go ahead and close as WORKSFORME.

Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WORKSFORME
Component: Event Handling → User events and focus handling

I don't know if this issue has reappeared or it just hasn't gone away, but this still happens (Win 10 x64, FF 76.0.1). I hadn't noticed it since I almost never click the play/pause button when I can just click the video itself. It's probably down to the Youtube team constantly tinkering with things like what happened with bug 1628947.

Open a video, click on the play/pause button and press space. On the initial click, the video pauses, but then, when pressing space, it triggers space as play/pause + the button action, so play/pause again, thus doing nothing.

This works identically to bug 1491256, which I can still reproduce, but instead of the mute button being previously clicked = mute + play/pause - which has the same issue for me, it's the play button that was previously clicked = play/pause + play/pause.

I can also reproduce this again on youtube using the same STR as in the bug description. Not sure if it was ever fixed or used to work at some point.
Reproduced on latest Nightly 78.0a1, Beta 77.0b9 and Release 76.0.1.

Status: RESOLVED → REOPENED
Resolution: WORKSFORME → ---

I can reproduce what I think is this bug with the latest 84 Nightly. Steps to reproduce are to focus the YouTube play/pause button and then hit the space bar to play or pause. Space seems to trigger twice causing the video to briefly play or pause and then return to its previous state.

Using K to play/pause works as expected, it's only the space bar that's affected.

We have reached out to them in .. May 2019, and have not seen much movement. Google is tracking this as b/132981735, and I've just pinged a contact to see if we can get an update here.

Webcompat Priority: --- → P2

The update here is that they can reproduce, but are having a hard time figuring out why that even happens. It could be worthwhile for us to check if we can build a simple testcase with a video player and a custom pause/unpause button and see if we can get this to behave similarly and if there is any difference between browsers there.

Attached file Reduced test-case.

So I dug a bit with rr and figured out what's going on.

The main issue is that preventDefault on keydown doesn't seem to prevent the button activation. On keyup it does though.

Do you know what the right behavior is here Masayuki?

Flags: needinfo?(masayuki)

IE 11 behaves like WebKit, so I guess that's it since it's sorta legacy behavior. IE11-compatible test-case: https://crisal.io/tmp/player-play-pause-kb-reduced.html

(In reply to Emilio Cobos Álvarez (:emilio) from comment #18)

The main issue is that preventDefault on keydown doesn't seem to prevent the button activation. On keyup it does though.

Do you know what the right behavior is here Masayuki?

It's out of scope of any standards. Nothing defines what is default action(s) of keydown event, and how to move focus with events.

We do it at keyup event of space char input:
https://searchfox.org/mozilla-central/rev/1ba472c91bbde4b127f6e614ae72888ab59611cf/dom/html/HTMLButtonElement.cpp#239-242
https://searchfox.org/mozilla-central/rev/1ba472c91bbde4b127f6e614ae72888ab59611cf/dom/html/HTMLInputElement.cpp#3772-3773,3793-3794
but we don't check the active state of the element, and it seems that we only set active state only when mousedown.
https://searchfox.org/mozilla-central/search?q=symbol:_ZN7mozilla17EventStateManager16SetActiveManagerEPS0_P10nsIContent&redirect=false
So, it seems that we have different "active" state handling, and it's required for keyup handling of the space key.

Flags: needinfo?(masayuki)
Assignee: nobody → emilio

I decided to go with a separate flag instead of reusing :active because
the :active handling WebKit uses for buttons is extremely weird: They
apply :active only to the button, not to the whole element chain like
mouse activeness does, and something like this keeps the :active state
in the button ~forever:

<!doctype html>
<style>
:active { outline: 2px solid red; }
</style>
<button onkeyup="return false">ABC</button>

Depends on D116584

Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5175b724b484 Minor HTMLButtonElement cleanups. r=masayuki https://hg.mozilla.org/integration/autoland/rev/75c26420524c Centralize keyboard activation code. r=masayuki https://hg.mozilla.org/integration/autoland/rev/0fdb0a9e8942 Don't dispatch a simulated click on keyup for default-prevented keydown. r=masayuki
Pushed by emilio@crisal.io: https://hg.mozilla.org/integration/autoland/rev/52451918a4a2 More explicitly activate checkbox in browser_protocol_ask_dialog_permission.js.
Pushed by emilio@crisal.io: https://hg.mozilla.org/integration/autoland/rev/699b45c4963a focus-management-expectations.html is passing now.

Verified fixed in Nightly 91.0a1 (2021-06-04)

Status: RESOLVED → VERIFIED
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/29249 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot

The patch landed in nightly and beta is affected.
:emilio, is this bug important enough to require an uplift?
If not please set status_beta to wontfix.

For more information, please visit auto_nag documentation.

Flags: needinfo?(emilio)

Fairly longstanding bug, so probably would benefit from Nightly bake-time.

Flags: needinfo?(emilio)
See Also: → 68851

Am I missing something, or should https://searchfox.org/mozilla-central/rev/a1a27f5aa092d7a0b045d2258130532872d94810/dom/html/HTMLBRElement.h#17 have been updated when HTML_ELEMENT_FLAG_BIT was added?

Flags: needinfo?(emilio)
Blocks: 1816328

Nope, you're right!

Flags: needinfo?(emilio)
See Also: → 1759031
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: