Bug 150348

Summary: Media "ended" event incorrectly fires when currentTime is set
Product: WebKit Reporter: Andrew Leung <andrewleung>
Component: MediaAssignee: Eric Carlson <eric.carlson>
Status: RESOLVED FIXED    
Severity: Major CC: adesroches, commit-queue, eric.carlson, jer.noble, jonlee, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: Other   
Attachments:
Description Flags
Sample HTML page with an externally-linked audio file to demonstrate the bug
none
Proposed patch. none

Description Andrew Leung 2015-10-19 17:31:07 PDT
Created attachment 263535 [details]
Sample HTML page with an externally-linked audio file to demonstrate the bug

The Media "ended" event appears to fire incorrectly when the currentTime property is altered after the media has ended playback. When that happens, the event does not fire properly again until after the playback ends a second time. I attached a sample HTML file to demonstrate the issue.

Steps to reproduce:

1. On a page that has a video/audio element, attach an "ended" event listener
2. In the event handler, alert a message
3. In the event handler, sets the currentTime property to 0
4. Play the video/audio until it ends
5. Play the video/audio a second time until it ends

Expected results:

The message should be alerted only once every time the playback ends.

Actual results:

The message gets alerted twice at the end of the first playback. The message does not get alerted at all at the end of the second playback.

Tested browsers:

Safari 8.0.8 on OS X 10.10.5   -- NOT affected
Safari 9.0 on OS X 10.10.5     -- affected
Safari 9.0 on OS X 10.11       -- affected
WebKit r191315 on OS X 10.10.5 -- affected
MobileSafari on iOS 8.4.1      -- NOT affected
MobileSafari on iOS 9.0.2      -- affected
Comment 1 Radar WebKit Bug Importer 2016-01-19 15:49:18 PST
<rdar://problem/24247974>
Comment 2 Eric Carlson 2016-01-25 08:04:21 PST
Created attachment 269751 [details]
Proposed patch.
Comment 3 WebKit Commit Bot 2016-01-25 09:55:26 PST
Comment on attachment 269751 [details]
Proposed patch.

Clearing flags on attachment: 269751

Committed r195540: <http://trac.webkit.org/changeset/195540>
Comment 4 WebKit Commit Bot 2016-01-25 09:55:31 PST
All reviewed patches have been landed.  Closing bug.