Diff
Modified: trunk/LayoutTests/ChangeLog (210444 => 210445)
--- trunk/LayoutTests/ChangeLog 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/LayoutTests/ChangeLog 2017-01-06 18:48:29 UTC (rev 210445)
@@ -1,3 +1,14 @@
+2017-01-06 Jer Noble <[email protected]>
+
+ Add support for MediaKeySystemAccess.createMediaKeys()
+ https://bugs.webkit.org/show_bug.cgi?id=166749
+
+ Reviewed by Eric Carlson.
+
+ * media/encrypted-media/mock-MediaKeySystemAccess-expected.txt: Added.
+ * media/encrypted-media/mock-MediaKeySystemAccess.html: Added.
+ * platform/mac/TestExpectations:
+
2017-01-06 Ryan Haddad <[email protected]>
Add pass expectation for fast/text/emoji-num-glyphs.html on Sierra.
Added: trunk/LayoutTests/media/encrypted-media/mock-MediaKeySystemAccess-expected.txt (0 => 210445)
--- trunk/LayoutTests/media/encrypted-media/mock-MediaKeySystemAccess-expected.txt (rev 0)
+++ trunk/LayoutTests/media/encrypted-media/mock-MediaKeySystemAccess-expected.txt 2017-01-06 18:48:29 UTC (rev 210445)
@@ -0,0 +1,41 @@
+RUN(internals.initializeMockMediaSource())
+RUN(mock = internals.registerMockCDM())
+RUN(mock.supportedDataTypes = ["mock"])
+
+RUN(capabilities.initDataTypes = ["mock"])
+RUN(capabilities.videoCapabilities = [{ contentType: 'video/mock; codecs="mock"' }] )
+RUN(promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", [capabilities]))
+Promise resolved OK
+
+RUN(promise = mediaKeySystemAccess.createMediaKeys())
+Promise resolved OK
+
+RUN(mock.canCreateInstances = false)
+RUN(promise = mediaKeySystemAccess.createMediaKeys())
+Promise rejected correctly OK
+
+RUN(mock.canCreateInstances = true)
+RUN(capabilities.distinctiveIdentifier = "not-allowed")
+RUN(promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", [capabilities]))
+Promise resolved OK
+
+RUN(promise = mediaKeySystemAccess.createMediaKeys())
+Promise resolved OK
+
+RUN(mock.distinctiveIdentifiersRequirement = "required")
+RUN(promise = mediaKeySystemAccess.createMediaKeys())
+Promise rejected correctly OK
+
+RUN(mock.distinctiveIdentifiersRequirement = "optional")
+RUN(capabilities.persistentState = "not-allowed")
+RUN(promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", [capabilities]))
+Promise resolved OK
+
+RUN(promise = mediaKeySystemAccess.createMediaKeys())
+Promise resolved OK
+
+RUN(mock.persistentStateRequirement = "required")
+RUN(promise = mediaKeySystemAccess.createMediaKeys())
+Promise rejected correctly OK
+END OF TEST
+
Added: trunk/LayoutTests/media/encrypted-media/mock-MediaKeySystemAccess.html (0 => 210445)
--- trunk/LayoutTests/media/encrypted-media/mock-MediaKeySystemAccess.html (rev 0)
+++ trunk/LayoutTests/media/encrypted-media/mock-MediaKeySystemAccess.html 2017-01-06 18:48:29 UTC (rev 210445)
@@ -0,0 +1,122 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+ <script type="text/_javascript_">
+ var mock;
+ var promise;
+ var mediaKeySystemAccess;
+ var capabilities = {};
+
+ function doTest()
+ {
+ if (!window.internals) {
+ // failTest("Internals is required for this test.")
+ // return;
+ }
+
+ run('internals.initializeMockMediaSource()');
+ run('mock = internals.registerMockCDM()');
+ run('mock.supportedDataTypes = ["mock"]');
+
+ next();
+ }
+
+ function next() {
+ if (!tests.length) {
+ mock.unregister();
+ endTest()
+ return;
+ }
+
+ var nextTest = tests.shift();
+ consoleWrite('');
+ nextTest();
+ }
+
+ function shouldResolve(promise) {
+ promise.then(mediaKeySystemAccess => {
+ logResult(Success, 'Promise resolved');
+ next();
+ }, () => {
+ logResult(Failed, 'Promise rejected');
+ next();
+ });
+ }
+
+ function shouldReject(promise) {
+ promise.then(() => {
+ logResult(Failed, 'Promise resolved incorrectly');
+ next();
+ }, exceptionCode => {
+ logResult(Success, 'Promise rejected correctly');
+ next();
+ });
+ }
+
+ function gotMediaKeySystemAccess(result) {
+ logResult(Success, 'Promise resolved');
+ mediaKeySystemAccess = result;
+ next();
+ }
+
+ tests = [
+ function() {
+ run('capabilities.initDataTypes = ["mock"]');
+ run(`capabilities.videoCapabilities = [{ contentType: 'video/mock; codecs="mock"' }] `);
+ run('promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", [capabilities])');
+ promise.then(gotMediaKeySystemAccess).catch(failTest);
+ },
+
+ function() {
+ run('promise = mediaKeySystemAccess.createMediaKeys()');
+ shouldResolve(promise);
+ },
+
+ function() {
+ run('mock.canCreateInstances = false');
+ run('promise = mediaKeySystemAccess.createMediaKeys()');
+ shouldReject(promise);
+ },
+
+ function() {
+ run('mock.canCreateInstances = true');
+ run('capabilities.distinctiveIdentifier = "not-allowed"');
+ run('promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", [capabilities])');
+ promise.then(gotMediaKeySystemAccess).catch(failTest);
+ },
+
+ function() {
+ run('promise = mediaKeySystemAccess.createMediaKeys()');
+ shouldResolve(promise);
+ },
+
+ function() {
+ run('mock.distinctiveIdentifiersRequirement = "required"');
+ run('promise = mediaKeySystemAccess.createMediaKeys()');
+ shouldReject(promise);
+ },
+
+ function() {
+ run('mock.distinctiveIdentifiersRequirement = "optional"');
+ run('capabilities.persistentState = "not-allowed"');
+ run('promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", [capabilities])');
+ promise.then(gotMediaKeySystemAccess).catch(failTest);
+ },
+
+ function() {
+ run('promise = mediaKeySystemAccess.createMediaKeys()');
+ shouldResolve(promise);
+ },
+
+ function() {
+ run('mock.persistentStateRequirement = "required"');
+ run('promise = mediaKeySystemAccess.createMediaKeys()');
+ shouldReject(promise);
+ },
+ ];
+ </script>
+</head>
+<body _onload_="doTest()">
+</body>
+</html>
Modified: trunk/LayoutTests/platform/mac/TestExpectations (210444 => 210445)
--- trunk/LayoutTests/platform/mac/TestExpectations 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2017-01-06 18:48:29 UTC (rev 210445)
@@ -1465,5 +1465,6 @@
# New Encrypted Media API not enabled on Mac
media/encrypted-media/mock-navigator-requestMediaKeySystemAccess.html [ Skip ]
+media/encrypted-media/mock-MediaKeySystemAccess.html [ Skip ]
webkit.org/b/166025 http/tests/fetch/fetching-same-resource-with-diffferent-options.html [ Pass Failure ]
Modified: trunk/Source/WebCore/ChangeLog (210444 => 210445)
--- trunk/Source/WebCore/ChangeLog 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/ChangeLog 2017-01-06 18:48:29 UTC (rev 210445)
@@ -1,3 +1,48 @@
+2017-01-06 Jer Noble <[email protected]>
+
+ Add support for MediaKeySystemAccess.createMediaKeys()
+ https://bugs.webkit.org/show_bug.cgi?id=166749
+
+ Reviewed by Eric Carlson.
+
+ Test: media/encrypted-media/mock-MediaKeySystemAccess.html
+
+ Implement MediaKeySystemAccess::createMediaKeys(). This requires some
+ additions to CDM, CDMPrivate, and a new interface CDMInstance to support
+ eventual platform adoption and to implement mock support for testing.
+
+ * Modules/encryptedmedia/CDM.cpp:
+ (WebCore::CDM::loadAndInitialize):
+ (WebCore::CDM::createInstance):
+ * Modules/encryptedmedia/CDM.h:
+ * Modules/encryptedmedia/CDMInstance.h:
+ (WebCore::CDMInstance::~CDMInstance):
+ * Modules/encryptedmedia/CDMPrivate.h:
+ * Modules/encryptedmedia/MediaKeySystemAccess.cpp:
+ (WebCore::MediaKeySystemAccess::createMediaKeys):
+ * Modules/encryptedmedia/MediaKeySystemAccess.h:
+ * Modules/encryptedmedia/MediaKeys.cpp:
+ (WebCore::MediaKeys::MediaKeys):
+ * Modules/encryptedmedia/MediaKeys.h:
+ (WebCore::MediaKeys::create):
+ * Modules/encryptedmedia/MediaKeys.idl:
+ * Modules/encryptedmedia/NavigatorEME.cpp:
+ (WebCore::tryNextSupportedConfiguration):
+ * WebCore.xcodeproj/project.pbxproj:
+ * testing/MockCDMFactory.cpp:
+ (WebCore::MockCDM::MockCDM):
+ (WebCore::MockCDM::createInstance):
+ (WebCore::MockCDM::loadAndInitialize):
+ (WebCore::MockCDMInstance::MockCDMInstance):
+ (WebCore::MockCDMInstance::initializeWithConfiguration):
+ (WebCore::MockCDMInstance::setDistinctiveIdentifiersAllowed):
+ (WebCore::MockCDMInstance::setPersistentStateAllowed):
+ * testing/MockCDMFactory.h:
+ (WebCore::MockCDMFactory::canCreateInstances):
+ (WebCore::MockCDMFactory::setCanCreateInstances):
+ (WebCore::MockCDM::factory):
+ * testing/MockCDMFactory.idl:
+
2017-01-06 Andreas Kling <[email protected]>
Give RenderObject a Page& getter.
Modified: trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp (210444 => 210445)
--- trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp 2017-01-06 18:48:29 UTC (rev 210445)
@@ -611,6 +611,19 @@
});
}
+void CDM::loadAndInitialize()
+{
+ if (m_private)
+ m_private->loadAndInitialize();
}
+std::unique_ptr<CDMInstance> CDM::createInstance()
+{
+ if (!m_private)
+ return nullptr;
+ return m_private->createInstance();
+}
+
+}
+
#endif
Modified: trunk/Source/WebCore/Modules/encryptedmedia/CDM.h (210444 => 210445)
--- trunk/Source/WebCore/Modules/encryptedmedia/CDM.h 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDM.h 2017-01-06 18:48:29 UTC (rev 210445)
@@ -39,6 +39,7 @@
namespace WebCore {
class CDM;
+class CDMInstance;
class CDMPrivate;
class Document;
class ScriptExecutionContext;
@@ -68,6 +69,9 @@
const String& keySystem() const { return m_keySystem; }
+ void loadAndInitialize();
+ std::unique_ptr<CDMInstance> createInstance();
+
private:
CDM(Document&, const String& keySystem);
Copied: trunk/Source/WebCore/Modules/encryptedmedia/CDMInstance.h (from rev 210443, trunk/Source/WebCore/testing/MockCDMFactory.idl) (0 => 210445)
--- trunk/Source/WebCore/Modules/encryptedmedia/CDMInstance.h (rev 0)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDMInstance.h 2017-01-06 18:48:29 UTC (rev 210445)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(ENCRYPTED_MEDIA)
+
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+struct MediaKeySystemConfiguration;
+
+class CDMInstance {
+public:
+ virtual ~CDMInstance() { }
+
+ enum SuccessValue {
+ Failed,
+ Succeeded,
+ };
+
+ virtual SuccessValue initializeWithConfiguration(const MediaKeySystemConfiguration&) = 0;
+ virtual SuccessValue setDistinctiveIdentifiersAllowed(bool) = 0;
+ virtual SuccessValue setPersistentStateAllowed(bool) = 0;
+};
+
+}
+
+#endif
Modified: trunk/Source/WebCore/Modules/encryptedmedia/CDMPrivate.h (210444 => 210445)
--- trunk/Source/WebCore/Modules/encryptedmedia/CDMPrivate.h 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDMPrivate.h 2017-01-06 18:48:29 UTC (rev 210445)
@@ -27,6 +27,7 @@
#if ENABLE(ENCRYPTED_MEDIA)
+#include "CDMInstance.h"
#include "MediaKeySessionType.h"
#include "MediaKeysRequirement.h"
#include <wtf/Forward.h>
@@ -39,6 +40,7 @@
class CDMPrivate {
public:
virtual ~CDMPrivate() { }
+
virtual bool supportsInitDataType(const String&) = 0;
virtual bool supportsConfiguration(const MediaKeySystemConfiguration&) = 0;
virtual bool supportsConfigurationWithRestrictions(const MediaKeySystemConfiguration&, const MediaKeysRestrictions&) = 0;
@@ -47,6 +49,8 @@
virtual MediaKeysRequirement distinctiveIdentifiersRequirement(const MediaKeySystemConfiguration&, const MediaKeysRestrictions&) = 0;
virtual MediaKeysRequirement persistentStateRequirement(const MediaKeySystemConfiguration&, const MediaKeysRestrictions&) = 0;
virtual bool distinctiveIdentifiersAreUniquePerOriginAndClearable(const MediaKeySystemConfiguration&) = 0;
+ virtual std::unique_ptr<CDMInstance> createInstance() = 0;
+ virtual void loadAndInitialize() = 0;
};
}
Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.cpp (210444 => 210445)
--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.cpp 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.cpp 2017-01-06 18:48:29 UTC (rev 210445)
@@ -32,7 +32,10 @@
#if ENABLE(ENCRYPTED_MEDIA)
#include "CDM.h"
+#include "CDMInstance.h"
+#include "JSMediaKeys.h"
#include "MediaKeySystemConfiguration.h"
+#include "MediaKeys.h"
#include "NotImplemented.h"
namespace WebCore {
@@ -51,9 +54,64 @@
MediaKeySystemAccess::~MediaKeySystemAccess() = default;
-void MediaKeySystemAccess::createMediaKeys(Ref<DeferredPromise>&&)
+void MediaKeySystemAccess::createMediaKeys(Ref<DeferredPromise>&& promise)
{
- notImplemented();
+ // https://w3c.github.io/encrypted-media/#dom-mediakeysystemaccess-createmediakeys
+ // W3C Editor's Draft 09 November 2016
+
+ // When this method is invoked, the user agent must run the following steps:
+ // 1. Let promise be a new promise.
+ // 2. Run the following steps in parallel:
+ m_taskQueue.enqueueTask([this, promise = WTFMove(promise)] () mutable {
+ // 2.1. Let configuration be the value of this object's configuration value.
+ // 2.2. Let use distinctive identifier be true if the value of configuration's distinctiveIdentifier member is "required" and false otherwise.
+ bool useDistinctiveIdentifier = m_configuration->distinctiveIdentifier == MediaKeysRequirement::Required;
+
+ // 2.3. Let persistent state allowed be true if the value of configuration's persistentState member is "required" and false otherwise.
+ bool persistentStateAllowed = m_configuration->persistentState == MediaKeysRequirement::Required;
+
+ // 2.4. Load and initialize the Key System implementation represented by this object's cdm implementation value if necessary.
+ m_implementation->loadAndInitialize();
+
+ // 2.5. Let instance be a new instance of the Key System implementation represented by this object's cdm implementation value.
+ std::unique_ptr<CDMInstance> instance = m_implementation->createInstance();
+ if (!instance) {
+ promise->reject(INVALID_STATE_ERR);
+ return;
+ }
+
+ // 2.6. Initialize instance to enable, disable and/or select Key System features using configuration.
+ if (instance->initializeWithConfiguration(*m_configuration) == CDMInstance::Failed) {
+ promise->reject(NotAllowedError);
+ return;
+ }
+
+ // 2.7. If use distinctive identifier is false, prevent instance from using Distinctive Identifier(s) and Distinctive Permanent Identifier(s).
+ if (!useDistinctiveIdentifier && instance->setDistinctiveIdentifiersAllowed(false) == CDMInstance::Failed) {
+ promise->reject(NotAllowedError);
+ return;
+ }
+
+ // 2.8. If persistent state allowed is false, prevent instance from persisting any state related to the application or origin of this object's Document.
+ if (!persistentStateAllowed && instance->setPersistentStateAllowed(false) == CDMInstance::Failed) {
+ promise->reject(NotAllowedError);
+ return;
+ }
+
+ // 2.9. If any of the preceding steps failed, reject promise with a new DOMException whose name is the appropriate error name.
+ // 2.10. Let media keys be a new MediaKeys object, and initialize it as follows:
+ // 2.10.1. Let the use distinctive identifier value be use distinctive identifier.
+ // 2.10.2. Let the persistent state allowed value be persistent state allowed.
+ // 2.10.3. Let the supported session types value be be the value of configuration's sessionTypes member.
+ // 2.10.4. Let the cdm implementation value be this object's cdm implementation value.
+ // 2.10.5. Let the cdm instance value be instance.
+ auto mediaKeys = MediaKeys::create(useDistinctiveIdentifier, persistentStateAllowed, m_configuration->sessionTypes, m_implementation.copyRef(), WTFMove(instance));
+
+ // 2.11. Resolve promise with media keys.
+ promise->resolveWithNewlyCreated<IDLInterface<MediaKeys>>(WTFMove(mediaKeys));
+ });
+
+ // 3. Return promise.
}
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.h (210444 => 210445)
--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.h 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.h 2017-01-06 18:48:29 UTC (rev 210445)
@@ -30,6 +30,7 @@
#if ENABLE(ENCRYPTED_MEDIA)
+#include "GenericTaskQueue.h"
#include "JSDOMPromise.h"
#include <wtf/RefCounted.h>
#include <wtf/text/WTFString.h>
@@ -56,6 +57,7 @@
String m_keySystem;
std::unique_ptr<MediaKeySystemConfiguration> m_configuration;
Ref<CDM> m_implementation;
+ GenericTaskQueue<Timer> m_taskQueue;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp (210444 => 210445)
--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp 2017-01-06 18:48:29 UTC (rev 210445)
@@ -31,12 +31,21 @@
#if ENABLE(ENCRYPTED_MEDIA)
+#include "CDM.h"
+#include "CDMInstance.h"
#include "MediaKeySession.h"
#include "NotImplemented.h"
namespace WebCore {
-MediaKeys::MediaKeys() = default;
+MediaKeys::MediaKeys(bool useDistinctiveIdentifier, bool persistentStateAllowed, const Vector<MediaKeySessionType>& supportedSessionTypes, Ref<CDM>&& implementation, std::unique_ptr<CDMInstance>&& instance)
+ : m_useDistinctiveIdentifier(useDistinctiveIdentifier)
+ , m_persistentStateAllowed(persistentStateAllowed)
+ , m_supportedSessionTypes(supportedSessionTypes)
+ , m_implementation(WTFMove(implementation))
+ , m_instance(WTFMove(instance))
+{
+}
MediaKeys::~MediaKeys() = default;
Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.h (210444 => 210445)
--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.h 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.h 2017-01-06 18:48:29 UTC (rev 210445)
@@ -38,6 +38,8 @@
namespace WebCore {
+class CDM;
+class CDMInstance;
class BufferSource;
class MediaKeySession;
@@ -45,12 +47,12 @@
public:
using KeySessionType = MediaKeySessionType;
- static Ref<MediaKeys> create()
+ static Ref<MediaKeys> create(bool useDistinctiveIdentifier, bool persistentStateAllowed, const Vector<MediaKeySessionType>& supportedSessionTypes, Ref<CDM>&& implementation, std::unique_ptr<CDMInstance>&& instance)
{
- return adoptRef(*new MediaKeys);
+ return adoptRef(*new MediaKeys(useDistinctiveIdentifier, persistentStateAllowed, supportedSessionTypes, WTFMove(implementation), WTFMove(instance)));
}
- virtual ~MediaKeys();
+ ~MediaKeys();
ExceptionOr<Ref<MediaKeySession>> createSession(MediaKeySessionType);
@@ -57,7 +59,13 @@
void setServerCertificate(const BufferSource&, Ref<DeferredPromise>&&);
protected:
- MediaKeys();
+ MediaKeys(bool useDistinctiveIdentifier, bool persistentStateAllowed, const Vector<MediaKeySessionType>&, Ref<CDM>&&, std::unique_ptr<CDMInstance>&&);
+
+ bool m_useDistinctiveIdentifier;
+ bool m_persistentStateAllowed;
+ Vector<MediaKeySessionType> m_supportedSessionTypes;
+ Ref<CDM> m_implementation;
+ std::unique_ptr<CDMInstance> m_instance;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.idl (210444 => 210445)
--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.idl 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.idl 2017-01-06 18:48:29 UTC (rev 210445)
@@ -28,7 +28,8 @@
[
Conditional=ENCRYPTED_MEDIA,
- EnabledAtRuntime=EncryptedMediaAPI
+ EnabledAtRuntime=EncryptedMediaAPI,
+ ImplementationLacksVTable,
] interface MediaKeys {
[MayThrowException] MediaKeySession createSession(optional MediaKeySessionType sessionType = "temporary");
Promise<bool> setServerCertificate(BufferSource serverCertificate);
Modified: trunk/Source/WebCore/Modules/encryptedmedia/NavigatorEME.cpp (210444 => 210445)
--- trunk/Source/WebCore/Modules/encryptedmedia/NavigatorEME.cpp 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/Modules/encryptedmedia/NavigatorEME.cpp 2017-01-06 18:48:29 UTC (rev 210445)
@@ -90,7 +90,7 @@
// 6.3.3.1.3. Let the cdm implementation value be implementation.
auto access = MediaKeySystemAccess::create(implementation->keySystem(), WTFMove(supportedConfiguration.value()), implementation.releaseNonNull());
// 6.3.3.2. Resolve promise with access and abort the parallel steps of this algorithm.
- promise->resolve<IDLInterface<MediaKeySystemAccess>>(access.get());
+ promise->resolveWithNewlyCreated<IDLInterface<MediaKeySystemAccess>>(WTFMove(access));
return;
}
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (210444 => 210445)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-01-06 18:48:29 UTC (rev 210445)
@@ -13738,6 +13738,7 @@
CD8B5A48180E138B008B8E65 /* TextTrackMediaSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackMediaSource.h; sourceTree = "<group>"; };
CD8B5A4A180E17A3008B8E65 /* AudioTrackMediaSource.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AudioTrackMediaSource.idl; sourceTree = "<group>"; };
CD8B5A4B180E17C0008B8E65 /* AudioTrackMediaSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioTrackMediaSource.h; sourceTree = "<group>"; };
+ CD9D05421E1EFA12003B4C4F /* CDMInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDMInstance.h; sourceTree = "<group>"; };
CD9D82731C7AE535006FF066 /* TextureCacheCV.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TextureCacheCV.mm; path = ../cv/TextureCacheCV.mm; sourceTree = "<group>"; };
CD9D82741C7AE535006FF066 /* TextureCacheCV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextureCacheCV.h; path = ../cv/TextureCacheCV.h; sourceTree = "<group>"; };
CD9D82771C7B8EE1006FF066 /* VideoTextureCopierCV.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VideoTextureCopierCV.cpp; path = ../cv/VideoTextureCopierCV.cpp; sourceTree = "<group>"; };
@@ -22754,6 +22755,7 @@
2D0621461DA639EC00A7FB26 /* legacy */,
CDF4B7131E00B7E500E235A2 /* CDM.cpp */,
CDF4B7141E00B7E500E235A2 /* CDM.h */,
+ CD9D05421E1EFA12003B4C4F /* CDMInstance.h */,
CDF4B7251E03C15B00E235A2 /* CDMPrivate.h */,
2D9BF72F1DBFDC0F007A7D99 /* MediaKeyMessageEvent.cpp */,
2D9BF7301DBFDC0F007A7D99 /* MediaKeyMessageEvent.h */,
Modified: trunk/Source/WebCore/testing/MockCDMFactory.cpp (210444 => 210445)
--- trunk/Source/WebCore/testing/MockCDMFactory.cpp 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/testing/MockCDMFactory.cpp 2017-01-06 18:48:29 UTC (rev 210445)
@@ -63,6 +63,7 @@
MockCDM::MockCDM(WeakPtr<MockCDMFactory> factory)
: m_factory(WTFMove(factory))
+ , m_weakPtrFactory(this)
{
}
@@ -119,6 +120,59 @@
return true;
}
+std::unique_ptr<CDMInstance> MockCDM::createInstance()
+{
+ if (m_factory && !m_factory->canCreateInstances())
+ return nullptr;
+ return std::unique_ptr<CDMInstance>(new MockCDMInstance(m_weakPtrFactory.createWeakPtr()));
}
+void MockCDM::loadAndInitialize()
+{
+ // No-op.
+}
+
+MockCDMInstance::MockCDMInstance(WeakPtr<MockCDM> cdm)
+ : m_cdm(cdm)
+{
+}
+
+CDMInstance::SuccessValue MockCDMInstance::initializeWithConfiguration(const MediaKeySystemConfiguration& configuration)
+{
+ if (!m_cdm || !m_cdm->supportsConfiguration(configuration))
+ return Failed;
+
+ return Succeeded;
+}
+
+CDMInstance::SuccessValue MockCDMInstance::setDistinctiveIdentifiersAllowed(bool distinctiveIdentifiersAllowed)
+{
+ if (m_distinctiveIdentifiersAllowed == distinctiveIdentifiersAllowed)
+ return Succeeded;
+
+ MockCDMFactory* factory = m_cdm ? m_cdm->factory() : nullptr;
+
+ if (!factory || (!distinctiveIdentifiersAllowed && factory->distinctiveIdentifiersRequirement() == MediaKeysRequirement::Required))
+ return Failed;
+
+ m_distinctiveIdentifiersAllowed = distinctiveIdentifiersAllowed;
+ return Succeeded;
+}
+
+CDMInstance::SuccessValue MockCDMInstance::setPersistentStateAllowed(bool persistentStateAllowed)
+{
+ if (m_persistentStateAllowed == persistentStateAllowed)
+ return Succeeded;
+
+ MockCDMFactory* factory = m_cdm ? m_cdm->factory() : nullptr;
+
+ if (!factory || (!persistentStateAllowed && factory->persistentStateRequirement() == MediaKeysRequirement::Required))
+ return Failed;
+
+ m_persistentStateAllowed = persistentStateAllowed;
+ return Succeeded;
+}
+
+}
+
#endif
Modified: trunk/Source/WebCore/testing/MockCDMFactory.h (210444 => 210445)
--- trunk/Source/WebCore/testing/MockCDMFactory.h 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/testing/MockCDMFactory.h 2017-01-06 18:48:29 UTC (rev 210445)
@@ -28,6 +28,7 @@
#if ENABLE(ENCRYPTED_MEDIA)
#include "CDM.h"
+#include "CDMInstance.h"
#include "CDMPrivate.h"
#include "MediaKeysRequirement.h"
#include <wtf/RefCounted.h>
@@ -53,6 +54,9 @@
MediaKeysRequirement persistentStateRequirement() const { return m_persistentStateRequirement; }
void setPersistentStateRequirement(MediaKeysRequirement requirement) { m_persistentStateRequirement = requirement; }
+ bool canCreateInstances() const { return m_canCreateInstances; }
+ void setCanCreateInstances(bool flag) { m_canCreateInstances = flag; }
+
void unregister();
private:
@@ -65,6 +69,7 @@
Vector<String> m_supportedDataTypes;
Vector<String> m_supportedRobustness;
bool m_registered { true };
+ bool m_canCreateInstances { true };
WeakPtrFactory<MockCDMFactory> m_weakPtrFactory;
};
@@ -72,7 +77,11 @@
public:
MockCDM(WeakPtr<MockCDMFactory>);
+ MockCDMFactory* factory() { return m_factory.get(); }
+
private:
+ friend class MockCDMInstance;
+
bool supportsInitDataType(const String&) final;
bool supportsConfiguration(const MediaKeySystemConfiguration&) final;
bool supportsConfigurationWithRestrictions(const MediaKeySystemConfiguration&, const MediaKeysRestrictions&) final;
@@ -81,10 +90,27 @@
MediaKeysRequirement distinctiveIdentifiersRequirement(const MediaKeySystemConfiguration&, const MediaKeysRestrictions&) final;
MediaKeysRequirement persistentStateRequirement(const MediaKeySystemConfiguration&, const MediaKeysRestrictions&) final;
bool distinctiveIdentifiersAreUniquePerOriginAndClearable(const MediaKeySystemConfiguration&) final;
+ std::unique_ptr<CDMInstance> createInstance() final;
+ void loadAndInitialize() final;
WeakPtr<MockCDMFactory> m_factory;
+ WeakPtrFactory<MockCDM> m_weakPtrFactory;
};
+class MockCDMInstance : public CDMInstance {
+public:
+ MockCDMInstance(WeakPtr<MockCDM>);
+
+private:
+ SuccessValue initializeWithConfiguration(const MediaKeySystemConfiguration&) final;
+ SuccessValue setDistinctiveIdentifiersAllowed(bool) final;
+ SuccessValue setPersistentStateAllowed(bool) final;
+
+ WeakPtr<MockCDM> m_cdm;
+ bool m_distinctiveIdentifiersAllowed { true };
+ bool m_persistentStateAllowed { true };
+};
+
}
#endif
Modified: trunk/Source/WebCore/testing/MockCDMFactory.idl (210444 => 210445)
--- trunk/Source/WebCore/testing/MockCDMFactory.idl 2017-01-06 17:55:42 UTC (rev 210444)
+++ trunk/Source/WebCore/testing/MockCDMFactory.idl 2017-01-06 18:48:29 UTC (rev 210445)
@@ -32,6 +32,7 @@
attribute sequence<DOMString> supportedRobustness;
attribute MediaKeysRequirement distinctiveIdentifiersRequirement;
attribute MediaKeysRequirement persistentStateRequirement;
+ attribute boolean canCreateInstances;
void unregister();
};