[Mac][MSE] Stalled YouTube playback does not allow display to sleep.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Jan 2015 06:00:43 +0000 (06:00 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Jan 2015 06:00:43 +0000 (06:00 +0000)
commit2b9a2ab8840cb84536c3588fdaffa6138d59d576
treeedde3d318f7db3844271cc16c6405053cf54f4d0
parent0b4f2e94ac6110a5444999436caa0d1cc33c7b9f
[Mac][MSE] Stalled YouTube playback does not allow display to sleep.
https://bugs.webkit.org/show_bug.cgi?id=140468
rdar://problem/19171162

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/media-source/media-source-stalled-holds-sleep-assertion.html

The unstated convention of MediaPlayerPrivate::paused() is that implementations should
return 'true' if the playback rate is 0. However, MediaPlayerPrivateMediaSourceAVFObjC
was returning 'false' if it was supposed to be playing, regardless of the actual rate.
This caused a check in HTMLMediaElement of whether to release the sleep assertion token
to fail, thinking the media engine was still playing.

Add some testing infrastructure to allow us to test whether the media element is disabling
display sleep from within layout tests.

* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::isDisablingSleep):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paused):
* testing/Internals.cpp:
(WebCore::Internals::elementIsBlockingDisplaySleep):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* media/media-source/content/test-fragmented-manifest.json: Added.
* media/media-source/content/test-fragmented.mp4: Added.
* media/media-source/media-source-loader.js: Added.
(MediaSourceLoader):
(MediaSourceLoader.prototype.loadManifest):
(MediaSourceLoader.prototype.loadManifestSucceeded):
(MediaSourceLoader.prototype.loadManifestFailed):
(MediaSourceLoader.prototype.loadMediaData):
(MediaSourceLoader.prototype.loadMediaDataSucceeded):
(MediaSourceLoader.prototype.loadMediaDataFailed):
(MediaSourceLoader.prototype.type):
(MediaSourceLoader.prototype.duration):
(MediaSourceLoader.prototype.initSegment):
(MediaSourceLoader.prototype.mediaSegmentsLength):
(MediaSourceLoader.prototype.mediaSegment):
* media/media-source/media-source-stalled-holds-sleep-assertion-expected.txt: Added.
* media/media-source/media-source-stalled-holds-sleep-assertion.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178486 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/media/media-source/content/test-fragmented-manifest.json [new file with mode: 0644]
LayoutTests/media/media-source/content/test-fragmented.mp4 [new file with mode: 0644]
LayoutTests/media/media-source/media-source-canplaythrough.html
LayoutTests/media/media-source/media-source-loader.js [new file with mode: 0644]
LayoutTests/media/media-source/media-source-stalled-holds-sleep-assertion-expected.txt [new file with mode: 0644]
LayoutTests/media/media-source/media-source-stalled-holds-sleep-assertion.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl