Diff
Modified: trunk/Source/WebCore/ChangeLog (187003 => 187004)
--- trunk/Source/WebCore/ChangeLog 2015-07-19 00:36:45 UTC (rev 187003)
+++ trunk/Source/WebCore/ChangeLog 2015-07-19 01:30:44 UTC (rev 187004)
@@ -1,3 +1,20 @@
+2015-07-17 Matt Rajca <[email protected]>
+
+ Media Session: add infrastructure for testing interruptions
+ https://bugs.webkit.org/show_bug.cgi?id=147060
+
+ Reviewed by Eric Carlson.
+
+ * Modules/mediasession/MediaSession.h: Export methods to be used with tests.
+ * Modules/mediasession/MediaSessionManager.h: Ditto.
+ * bindings/scripts/CodeGeneratorJS.pm: JSMediaSession needs to be marked with WEBCORE_EXPORT so it works with JSInternals.
+ * testing/Internals.cpp:
+ (WebCore::Internals::sendMediaSessionStartOfInterruptionNotification): Let tests send interruptions to MediaSessionManager.
+ (WebCore::Internals::sendMediaSessionEndOfInterruptionNotification): Ditto.
+ (WebCore::Internals::mediaSessionCurrentState): Expose the current state of media sessions to tests.
+ * testing/Internals.h:
+ * testing/Internals.idl: Add interfaces for sending interruptions from JS tests.
+
2015-07-18 Gyuyoung Kim <[email protected]>
Reduce PassRefPtr in WebKit2 - 3
Modified: trunk/Source/WebCore/Modules/mediasession/MediaSession.h (187003 => 187004)
--- trunk/Source/WebCore/Modules/mediasession/MediaSession.h 2015-07-19 00:36:45 UTC (rev 187003)
+++ trunk/Source/WebCore/Modules/mediasession/MediaSession.h 2015-07-19 01:30:44 UTC (rev 187004)
@@ -66,7 +66,7 @@
Kind kindEnum() const { return m_kind; }
MediaRemoteControls* controls(bool& isNull);
- State currentState() const { return m_currentState; }
+ WEBCORE_EXPORT State currentState() const { return m_currentState; }
bool hasActiveMediaElements() const;
void setMetadata(const Dictionary&);
Modified: trunk/Source/WebCore/Modules/mediasession/MediaSessionManager.h (187003 => 187004)
--- trunk/Source/WebCore/Modules/mediasession/MediaSessionManager.h 2015-07-19 00:36:45 UTC (rev 187003)
+++ trunk/Source/WebCore/Modules/mediasession/MediaSessionManager.h 2015-07-19 01:30:44 UTC (rev 187004)
@@ -39,14 +39,14 @@
class MediaSessionManager : public MediaSessionInterruptionProviderClient {
friend class NeverDestroyed<MediaSessionManager>;
public:
- static MediaSessionManager& singleton();
+ WEBCORE_EXPORT static MediaSessionManager& singleton();
void togglePlayback();
void skipToNextTrack();
void skipToPreviousTrack();
- void didReceiveStartOfInterruptionNotification(MediaSessionInterruptingCategory) override;
- void didReceiveEndOfInterruptionNotification(MediaSessionInterruptingCategory) override;
+ WEBCORE_EXPORT void didReceiveStartOfInterruptionNotification(MediaSessionInterruptingCategory) override;
+ WEBCORE_EXPORT void didReceiveEndOfInterruptionNotification(MediaSessionInterruptingCategory) override;
private:
friend class MediaSession;
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (187003 => 187004)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2015-07-19 00:36:45 UTC (rev 187003)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2015-07-19 01:30:44 UTC (rev 187004)
@@ -246,6 +246,7 @@
"JSFile" => 1,
"JSHTMLElement" => 1,
"JSHTMLMediaElement" => 1,
+ "JSMediaSession" => 1,
"JSNode" => 1,
"JSNotification" => 1,
"JSRange" => 1,
Modified: trunk/Source/WebCore/testing/Internals.cpp (187003 => 187004)
--- trunk/Source/WebCore/testing/Internals.cpp 2015-07-19 00:36:45 UTC (rev 187003)
+++ trunk/Source/WebCore/testing/Internals.cpp 2015-07-19 01:30:44 UTC (rev 187004)
@@ -190,6 +190,11 @@
#include "AudioContext.h"
#endif
+#if ENABLE(MEDIA_SESSION)
+#include "MediaSession.h"
+#include "MediaSessionManager.h"
+#endif
+
using JSC::CodeBlock;
using JSC::FunctionExecutable;
using JSC::JSFunction;
@@ -2758,6 +2763,41 @@
#endif // ENABLE(VIDEO)
+#if ENABLE(MEDIA_SESSION)
+static MediaSessionInterruptingCategory interruptingCategoryFromString(const String& interruptingCategoryString)
+{
+ if (interruptingCategoryString == "content")
+ return MediaSessionInterruptingCategory::Content;
+ if (interruptingCategoryString == "transient")
+ return MediaSessionInterruptingCategory::Transient;
+ if (interruptingCategoryString == "transient-solo")
+ return MediaSessionInterruptingCategory::TransientSolo;
+ ASSERT_NOT_REACHED();
+}
+
+void Internals::sendMediaSessionStartOfInterruptionNotification(const String& interruptingCategoryString)
+{
+ MediaSessionManager::singleton().didReceiveStartOfInterruptionNotification(interruptingCategoryFromString(interruptingCategoryString));
+}
+
+void Internals::sendMediaSessionEndOfInterruptionNotification(const String& interruptingCategoryString)
+{
+ MediaSessionManager::singleton().didReceiveEndOfInterruptionNotification(interruptingCategoryFromString(interruptingCategoryString));
+}
+
+String Internals::mediaSessionCurrentState(MediaSession* session) const
+{
+ switch (session->currentState()) {
+ case MediaSession::State::Active:
+ return "active";
+ case MediaSession::State::Interrupted:
+ return "interrupted";
+ case MediaSession::State::Idle:
+ return "idle";
+ }
+}
+#endif // ENABLE(MEDIA_SESSION)
+
#if ENABLE(WEB_AUDIO)
void Internals::setAudioContextRestrictions(AudioContext* context, const String &restrictionsString, ExceptionCode &ec)
{
Modified: trunk/Source/WebCore/testing/Internals.h (187003 => 187004)
--- trunk/Source/WebCore/testing/Internals.h 2015-07-19 00:36:45 UTC (rev 187003)
+++ trunk/Source/WebCore/testing/Internals.h 2015-07-19 01:30:44 UTC (rev 187004)
@@ -56,6 +56,7 @@
class InspectorFrontendClientDummy;
class InternalSettings;
class MallocStatistics;
+class MediaSession;
class MemoryInfo;
class Node;
class Page;
@@ -392,6 +393,12 @@
bool elementIsBlockingDisplaySleep(Element*) const;
#endif
+#if ENABLE(MEDIA_SESSION)
+ void sendMediaSessionStartOfInterruptionNotification(const String&);
+ void sendMediaSessionEndOfInterruptionNotification(const String&);
+ String mediaSessionCurrentState(MediaSession*) const;
+#endif
+
#if ENABLE(WEB_AUDIO)
void setAudioContextRestrictions(AudioContext*, const String& restrictions, ExceptionCode&);
#endif
Modified: trunk/Source/WebCore/testing/Internals.idl (187003 => 187004)
--- trunk/Source/WebCore/testing/Internals.idl 2015-07-19 00:36:45 UTC (rev 187003)
+++ trunk/Source/WebCore/testing/Internals.idl 2015-07-19 01:30:44 UTC (rev 187004)
@@ -45,6 +45,12 @@
"ResourceLoadPriorityVeryHigh"
};
+enum MediaSessionInterruptingCategory {
+ "content",
+ "transient",
+ "transient-solo"
+};
+
[
NoInterfaceObject,
] interface Internals {
@@ -351,6 +357,9 @@
[Conditional=VIDEO] void beginMediaSessionInterruption();
[Conditional=VIDEO] void endMediaSessionInterruption(DOMString flags);
+ [Conditional=MEDIA_SESSION] void sendMediaSessionStartOfInterruptionNotification(MediaSessionInterruptingCategory category);
+ [Conditional=MEDIA_SESSION] void sendMediaSessionEndOfInterruptionNotification(MediaSessionInterruptingCategory category);
+ [Conditional=MEDIA_SESSION] DOMString mediaSessionCurrentState(MediaSession session);
[Conditional=VIDEO] void applicationWillEnterForeground();
[Conditional=VIDEO] void applicationWillEnterBackground();
[Conditional=VIDEO, RaisesException] void setMediaSessionRestrictions(DOMString mediaType, DOMString restrictions);