[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: http://svn.webkit.org/repository/webkit/trunk@212110 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed