haikuwebkit/LayoutTests/media/video-system-sleep.html

41 lines
1.1 KiB
HTML
Raw Permalink Normal View History

[Mac] Pause the media element during system sleep. https://bugs.webkit.org/show_bug.cgi?id=130718 Reviewed by Eric Carlson. Source/WebCore: Test: media/video-system-sleep.html Relying on the platform media system to pause and restart playback during system sleep can cause problems on some platforms, especially where hardware decoders are concerned. Rather than implicitly pausing the media during system sleep, explicitly pause the media before sleeping and resume (if appropriate) upon waking. Add a new class to be used for system sleep notifications: * platform/SystemSleepListener.cpp: Added. (WebCore::SystemSleepListener::create): (WebCore::SystemSleepListener::SystemSleepListener): * platform/SystemSleepListener.h: Added. (WebCore::SystemSleepListener::Client::~Client): (WebCore::SystemSleepListener::~SystemSleepListener): (WebCore::SystemSleepListener::client): Add a Mac-specific implementation: * platform/mac/SystemSleepListenerMac.h: Added. * platform/mac/SystemSleepListenerMac.mm: Added. (WebCore::SystemSleepListener::create): (WebCore::SystemSleepListenerMac::SystemSleepListenerMac): (WebCore::SystemSleepListenerMac::~SystemSleepListenerMac): Listen for system sleep notifications in MediaSessionManager: * platform/audio/MediaSessionManager.cpp: (WebCore::MediaSessionManager::MediaSessionManager): (WebCore::MediaSessionManager::systemWillSleep): (WebCore::MediaSessionManager::systemDidWake): * platform/audio/MediaSessionManager.h: Drive-by fix; notify the MediaSession that playback will begin due to autoplay, but do not begin autoplaying if the session is already interrupted: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::parseAttribute): Add new files to project: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * CMakeLists.txt: * GNUmakefile.list.am: LayoutTests: * media/video-system-sleep-expected.txt: Added. * media/video-system-sleep.html: Added. Canonical link: https://commits.webkit.org/148783@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166261 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-03-25 22:26:34 +00:00
<!DOCTYPE html>
<html>
<head>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
function start()
{
if (!window.internals)
consoleWrite('To run this test manually, cause the machine to sleep then wake up.');
findMediaElement();
waitForEventOnce('playing', playing);
video.src = findMediaFile("video", "content/test");
}
function playing()
{
waitForEventOnce('pause', paused);
run('internals.simulateSystemSleep()');
}
function paused()
{
waitForEventOnce('playing', resumed);
run('internals.simulateSystemWake()');
}
function resumed()
{
endTest();
}
</script>
</head>
<body onload="start()">
<video controls autoplay></video>
<p>Test that video elements pause during system sleep.</p>
</body>
</html>