[EME] Implement MediaKeySession::load()
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Feb 2017 10:40:29 +0000 (10:40 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Feb 2017 10:40:29 +0000 (10:40 +0000)
commit4e099f2390cee80efff725c2aa2dd5cd4f07fa95
tree6fbfb1742ed98f7c22bf33f6851bd57b46320a2a
parentfa8c578de19ef51b58bb9ec0bf6d36f5e6388d9f
[EME] Implement MediaKeySession::load()
https://bugs.webkit.org/show_bug.cgi?id=168041

Reviewed by Xabier Rodriguez-Calvar.

Source/WebCore:

Implement the MediaKeySession::load() method, tracing the steps as they
are defined in the EME specification. The only exception is step 8.3,
which requires additional facility that tracks currently open sessions
and provides information whether for a given session ID there's already
a MediaKeySession that's not yet been closed.

Session ID sanitization is done through the CDM::sanitizeSessionId()
method, which relays the task to the CDMPrivate implementation.

The CDMInstance::loadSession() virtual method is called with the session
type, sanitized ID, the Document's origin (in string form) and the
callback that's invoked upon completion of the task. The callback
checks whether the operation was successful, or examines the reason for
the load failure in case it wasn't, rejecting the promise in the latter
case either immediately or in the following task at the latest.

When the load was successful, the optional known keys, expiration time
and message are handled appropriately, and the promise is resolved.

MockCDM::sanitizeSessionId() implementation only treats
'valid-loaded-session' as a valid session ID.
MockCDMInstance::loadSession() implementation is kept slim for now, only
providing the 'license-renewal' message when invoking the passed-in
callback. Known keys and expiration time will also be tested once the
relevant MediaKeySession algorithms are implemented.

Test: media/encrypted-media/mock-MediaKeySession-load.html

* Modules/encryptedmedia/CDM.cpp:
(WebCore::CDM::sanitizeSessionId):
* Modules/encryptedmedia/CDM.h:
* Modules/encryptedmedia/CDMInstance.h:
* Modules/encryptedmedia/CDMPrivate.h:
* Modules/encryptedmedia/MediaKeySession.cpp:
(WebCore::MediaKeySession::load):
* testing/MockCDMFactory.cpp:
(WebCore::MockCDM::sanitizeSessionId):
(WebCore::MockCDMInstance::loadSession):
* testing/MockCDMFactory.h:

LayoutTests:

Add the mock-MediaKeySession-load.html test, testing the basic behavior
of the MediaKeySession::load() implementation. Invalid session IDs and
session types are tested to ensure the returned promise is rejected.
A simplistic test case also tests that for a valid session ID and
session type, the basic MockCDM implementation correctly 'loads' the
specified session and provides the 'license-renewal' message in return.
More tests should be added as the EME implementation advances and the
MockCDM implementations improve to cover additional cases.

* media/encrypted-media/mock-MediaKeySession-load-expected.txt: Added.
* media/encrypted-media/mock-MediaKeySession-load.html: Added.
* platform/efl/TestExpectations:
* platform/mac/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212110 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/media/encrypted-media/mock-MediaKeySession-load-expected.txt [new file with mode: 0644]
LayoutTests/media/encrypted-media/mock-MediaKeySession-load.html [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/encryptedmedia/CDM.cpp
Source/WebCore/Modules/encryptedmedia/CDM.h
Source/WebCore/Modules/encryptedmedia/CDMInstance.h
Source/WebCore/Modules/encryptedmedia/CDMPrivate.h
Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp
Source/WebCore/testing/MockCDMFactory.cpp
Source/WebCore/testing/MockCDMFactory.h