Diff
Modified: trunk/LayoutTests/ChangeLog (207826 => 207827)
--- trunk/LayoutTests/ChangeLog 2016-10-25 17:27:00 UTC (rev 207826)
+++ trunk/LayoutTests/ChangeLog 2016-10-25 17:34:07 UTC (rev 207827)
@@ -1,3 +1,15 @@
+2016-10-25 Eric Carlson <[email protected]>
+
+ [MediaStream] Add "has capture device" bit to media state flags
+ https://bugs.webkit.org/show_bug.cgi?id=163952
+
+ Reviewed by Jer Noble.
+
+ * fast/mediastream/MediaStream-page-muted-expected.txt:
+ * fast/mediastream/MediaStream-page-muted.html:
+ * media/muted-video-is-playing-audio-expected.txt:
+ * media/muted-video-is-playing-audio.html:
+
2016-10-25 Brady Eidson <[email protected]>
IndexedDB 2.0: Support new IDBTransaction interfaces.
Modified: trunk/LayoutTests/fast/mediastream/MediaStream-page-muted-expected.txt (207826 => 207827)
--- trunk/LayoutTests/fast/mediastream/MediaStream-page-muted-expected.txt 2016-10-25 17:27:00 UTC (rev 207826)
+++ trunk/LayoutTests/fast/mediastream/MediaStream-page-muted-expected.txt 2016-10-25 17:34:07 UTC (rev 207827)
@@ -7,22 +7,27 @@
*** Mock capture devices should be enabled by default
PASS mediaStream is an instance of Object
PASS mediaStream.getTracks().length is 2
+PASS window.internals.pageMediaState().includes('HasActiveMediaCaptureDevice') became true
*** Muting capture devices
EVENT: mute
-PASS event.target.muted is true
-
+PASS muteChangedEvent.target.muted is true
+PASS window.internals.pageMediaState().includes('HasMediaCaptureDevice') is true
EVENT: mute
-PASS event.target.muted is true
+PASS muteChangedEvent.target.muted is true
+PASS window.internals.pageMediaState().includes('HasMediaCaptureDevice') is true
+PASS window.internals.pageMediaState().includes('HasActiveMediaCaptureDevice') became false
*** Unmuting capture devices
EVENT: unmute
-PASS event.target.muted is false
-
+PASS muteChangedEvent.target.muted is false
+PASS window.internals.pageMediaState().includes('HasMediaCaptureDevice') is true
EVENT: unmute
-PASS event.target.muted is false
+PASS muteChangedEvent.target.muted is false
+PASS window.internals.pageMediaState().includes('HasMediaCaptureDevice') is true
+PASS window.internals.pageMediaState().includes('HasActiveMediaCaptureDevice') became true
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/mediastream/MediaStream-page-muted.html (207826 => 207827)
--- trunk/LayoutTests/fast/mediastream/MediaStream-page-muted.html 2016-10-25 17:27:00 UTC (rev 207826)
+++ trunk/LayoutTests/fast/mediastream/MediaStream-page-muted.html 2016-10-25 17:34:07 UTC (rev 207827)
@@ -5,29 +5,40 @@
<script>
let mediaStream;
let eventCount = 0;
+ let muteChangedEvent;
+ function nextStep()
+ {
+ if (muteChangedEvent.type == "unmute") {
+ finishJSTest();
+ return;
+ }
+
+ debug("<br>*** Unmuting capture devices");
+ eventCount = 0;
+ internals.setPageMuted("");
+ }
+
function muteChanged(ev)
{
- event = ev;
- debug(`EVENT: ${ev.type}`);
- shouldBe('event.target.muted', (ev.type == "mute").toString());
- debug("");
+ muteChangedEvent = ev;
+ debug(`EVENT: ${muteChangedEvent.type}`);
+ shouldBe('muteChangedEvent.target.muted', (muteChangedEvent.type == "mute").toString());
+ shouldBe("window.internals.pageMediaState().includes('HasMediaCaptureDevice')", "true");
if (++eventCount == 2) {
- eventCount = 0;
-
- if (ev.type == "unmute") {
- finishJSTest();
- return;
- }
-
- if (window.internals) {
- debug("<br>*** Unmuting capture devices");
- internals.setPageMuted("");
- }
+ debug("");
+ let shouldBeActive = muteChangedEvent.type == "mute" ? "false" : "true";
+ shouldBecomeEqual("window.internals.pageMediaState().includes('HasActiveMediaCaptureDevice')", shouldBeActive, nextStep);
}
}
+ function muteCaptureDevices()
+ {
+ debug("<br>*** Muting capture devices");
+ internals.setPageMuted("capturedevices");
+ }
+
function testWhenEnabled()
{
navigator.mediaDevices
@@ -43,10 +54,7 @@
tracks[i]._onunmute_ = muteChanged;
}
- if (window.internals) {
- debug("<br>*** Muting capture devices");
- internals.setPageMuted("capturedevices");
- }
+ shouldBecomeEqual("window.internals.pageMediaState().includes('HasActiveMediaCaptureDevice')", "true", muteCaptureDevices);
})
.catch((err) => {
testFailed(`mediaDevices.getUserMedia() failed with ${err.name}`);
Modified: trunk/LayoutTests/media/muted-video-is-playing-audio-expected.txt (207826 => 207827)
--- trunk/LayoutTests/media/muted-video-is-playing-audio-expected.txt 2016-10-25 17:27:00 UTC (rev 207826)
+++ trunk/LayoutTests/media/muted-video-is-playing-audio-expected.txt 2016-10-25 17:34:07 UTC (rev 207827)
@@ -3,9 +3,9 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS window.internals.isPagePlayingAudio() became true
-PASS window.internals.isPagePlayingAudio() became false
-PASS window.internals.isPagePlayingAudio() became true
+PASS window.internals.pageMediaState().includes('IsPlayingAudio') became true
+PASS window.internals.pageMediaState().includes('IsPlayingAudio') became false
+PASS window.internals.pageMediaState().includes('IsPlayingAudio') became true
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/media/muted-video-is-playing-audio.html (207826 => 207827)
--- trunk/LayoutTests/media/muted-video-is-playing-audio.html 2016-10-25 17:27:00 UTC (rev 207826)
+++ trunk/LayoutTests/media/muted-video-is-playing-audio.html 2016-10-25 17:34:07 UTC (rev 207827)
@@ -15,16 +15,16 @@
function testUnmutingVideo()
{
run("video.muted = false");
- shouldBecomeEqual("window.internals.isPagePlayingAudio()", "true", finishJSTest);
+ shouldBecomeEqual("window.internals.pageMediaState().includes('IsPlayingAudio')", "true", finishJSTest);
}
function testMutingVideo()
{
run("video.muted = true");
- shouldBecomeEqual("window.internals.isPagePlayingAudio()", "false", testUnmutingVideo);
+ shouldBecomeEqual("window.internals.pageMediaState().includes('IsPlayingAudio')", "false", testUnmutingVideo);
}
- shouldBecomeEqual("window.internals.isPagePlayingAudio()", "true", testMutingVideo);
+ shouldBecomeEqual("window.internals.pageMediaState().includes('IsPlayingAudio')", "true", testMutingVideo);
</script>
<script src=""
</body>
Modified: trunk/Source/WebCore/ChangeLog (207826 => 207827)
--- trunk/Source/WebCore/ChangeLog 2016-10-25 17:27:00 UTC (rev 207826)
+++ trunk/Source/WebCore/ChangeLog 2016-10-25 17:34:07 UTC (rev 207827)
@@ -1,3 +1,24 @@
+2016-10-25 Eric Carlson <[email protected]>
+
+ [MediaStream] Add "has capture device" bit to media state flags
+ https://bugs.webkit.org/show_bug.cgi?id=163952
+
+ Reviewed by Jer Noble.
+
+ No new tests, updated fast/mediastream/MediaStream-page-muted.html and media/muted-video-is-playing-audio.html.
+
+ * Modules/mediastream/MediaStream.cpp:
+ (WebCore::MediaStream::mediaState): Set HasMediaCaptureDevice, only set HasActiveMediaCaptureDevice when
+ actually producing data.
+
+ * page/MediaProducer.h: Add HasMediaCaptureDevice bit.
+
+ * testing/Internals.cpp:
+ (WebCore::Internals::pageMediaState): Return a string representing MediaStateFlags.
+ (WebCore::Internals::isPagePlayingAudio): Deleted.
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
2016-10-25 Brady Eidson <[email protected]>
IndexedDB 2.0: Support new IDBTransaction interfaces.
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp (207826 => 207827)
--- trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp 2016-10-25 17:27:00 UTC (rev 207826)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp 2016-10-25 17:34:07 UTC (rev 207827)
@@ -274,7 +274,8 @@
if (!m_isActive)
return state;
- if (m_externallyMuted || m_private->isProducingData())
+ state |= HasMediaCaptureDevice;
+ if (m_private->isProducingData())
state |= HasActiveMediaCaptureDevice;
if (m_private->hasAudio() || m_private->hasVideo())
Modified: trunk/Source/WebCore/page/MediaProducer.h (207826 => 207827)
--- trunk/Source/WebCore/page/MediaProducer.h 2016-10-25 17:27:00 UTC (rev 207826)
+++ trunk/Source/WebCore/page/MediaProducer.h 2016-10-25 17:34:07 UTC (rev 207827)
@@ -44,6 +44,7 @@
HasPlaybackTargetAvailabilityListener = 1 << 9,
HasAudioOrVideo = 1 << 10,
HasActiveMediaCaptureDevice = 1 << 11,
+ HasMediaCaptureDevice = 1 << 12,
};
typedef unsigned MediaStateFlags;
Modified: trunk/Source/WebCore/testing/Internals.cpp (207826 => 207827)
--- trunk/Source/WebCore/testing/Internals.cpp 2016-10-25 17:27:00 UTC (rev 207826)
+++ trunk/Source/WebCore/testing/Internals.cpp 2016-10-25 17:34:07 UTC (rev 207827)
@@ -2966,13 +2966,49 @@
page->setMuted(state);
}
-bool Internals::isPagePlayingAudio()
+String Internals::pageMediaState()
{
Document* document = contextDocument();
if (!document || !document->page())
- return false;
+ return emptyString();
- return !!(document->page()->mediaState() & MediaProducer::IsPlayingAudio);
+ WebCore::MediaProducer::MediaStateFlags state = document->page()->mediaState();
+ StringBuilder string;
+ if (state & MediaProducer::IsPlayingAudio)
+ string.append("IsPlayingAudio,");
+ if (state & MediaProducer::IsPlayingVideo)
+ string.append("IsPlayingVideo,");
+ if (state & MediaProducer::IsPlayingToExternalDevice)
+ string.append("IsPlayingToExternalDevice,");
+ if (state & MediaProducer::RequiresPlaybackTargetMonitoring)
+ string.append("RequiresPlaybackTargetMonitoring,");
+ if (state & MediaProducer::ExternalDeviceAutoPlayCandidate)
+ string.append("ExternalDeviceAutoPlayCandidate,");
+ if (state & MediaProducer::DidPlayToEnd)
+ string.append("DidPlayToEnd,");
+ if (state & MediaProducer::IsSourceElementPlaying)
+ string.append("IsSourceElementPlaying,");
+
+ if (state & MediaProducer::IsNextTrackControlEnabled)
+ string.append("IsNextTrackControlEnabled,");
+ if (state & MediaProducer::IsPreviousTrackControlEnabled)
+ string.append("IsPreviousTrackControlEnabled,");
+
+ if (state & MediaProducer::HasPlaybackTargetAvailabilityListener)
+ string.append("HasPlaybackTargetAvailabilityListener,");
+ if (state & MediaProducer::HasAudioOrVideo)
+ string.append("HasAudioOrVideo,");
+ if (state & MediaProducer::HasActiveMediaCaptureDevice)
+ string.append("HasActiveMediaCaptureDevice,");
+ if (state & MediaProducer::HasMediaCaptureDevice)
+ string.append("HasMediaCaptureDevice,");
+
+ if (string.isEmpty())
+ string.append("IsNotPlaying");
+ else
+ string.resize(string.length() - 1);
+
+ return string.toString();
}
void Internals::setPageDefersLoading(bool defersLoading)
Modified: trunk/Source/WebCore/testing/Internals.h (207826 => 207827)
--- trunk/Source/WebCore/testing/Internals.h 2016-10-25 17:27:00 UTC (rev 207826)
+++ trunk/Source/WebCore/testing/Internals.h 2016-10-25 17:34:07 UTC (rev 207827)
@@ -441,7 +441,7 @@
ExceptionOr<String> pageOverlayLayerTreeAsText() const;
void setPageMuted(const String&);
- bool isPagePlayingAudio();
+ String pageMediaState();
void setPageDefersLoading(bool);
Modified: trunk/Source/WebCore/testing/Internals.idl (207826 => 207827)
--- trunk/Source/WebCore/testing/Internals.idl 2016-10-25 17:27:00 UTC (rev 207826)
+++ trunk/Source/WebCore/testing/Internals.idl 2016-10-25 17:34:07 UTC (rev 207827)
@@ -418,7 +418,7 @@
[MayThrowException] DOMString pageOverlayLayerTreeAsText();
void setPageMuted(DOMString mutedState);
- boolean isPagePlayingAudio();
+ DOMString pageMediaState();
void setPageDefersLoading(boolean defersLoading);