Commit e850894b authored by jrummell's avatar jrummell Committed by Commit bot

Add unprefixed EME tests for LoadSession()

BUG=338830
TEST=new EME tests pass

Review URL: https://codereview.chromium.org/641443002

Cr-Commit-Position: refs/heads/master@{#299960}
parent 8a7d3a2d
...@@ -332,6 +332,19 @@ class ECKEncryptedMediaTest : public EncryptedMediaTestBase { ...@@ -332,6 +332,19 @@ class ECKEncryptedMediaTest : public EncryptedMediaTestBase {
} }
}; };
// Tests encrypted media playback using ExternalClearKey key system in
// decrypt-and-decode mode for unprefixed EME.
// TODO(jrummell): Merge with ECKEncryptedMediaTest once unprefixed is
// enabled by default.
class ECKUnprefixedEncryptedMediaTest : public EncryptedMediaTestBase {
protected:
virtual void SetUpCommandLine(CommandLine* command_line) override {
EncryptedMediaTestBase::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kEnableEncryptedMedia);
SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line);
}
};
#if defined(WIDEVINE_CDM_AVAILABLE) #if defined(WIDEVINE_CDM_AVAILABLE)
// Tests encrypted media playback using Widevine key system. // Tests encrypted media playback using Widevine key system.
class WVEncryptedMediaTest : public EncryptedMediaTestBase { class WVEncryptedMediaTest : public EncryptedMediaTestBase {
...@@ -666,4 +679,29 @@ IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { ...@@ -666,4 +679,29 @@ IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) {
false, false,
kEmeKeyError); kEmeKeyError);
} }
IN_PROC_BROWSER_TEST_F(ECKUnprefixedEncryptedMediaTest, LoadLoadableSession) {
RunEncryptedMediaTest(kDefaultEmePlayer,
"bear-320x240-v_enc-v.webm",
kWebMVideoOnly,
kExternalClearKeyKeySystem,
SRC,
UNPREFIXED,
kLoadableSession,
false,
kEnded);
}
IN_PROC_BROWSER_TEST_F(ECKUnprefixedEncryptedMediaTest, LoadUnknownSession) {
// TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound.
RunEncryptedMediaTest(kDefaultEmePlayer,
"bear-320x240-v_enc-v.webm",
kWebMVideoOnly,
kExternalClearKeyKeySystem,
SRC,
UNPREFIXED,
kUnknownSession,
false,
kEmeKeyError);
}
#endif // defined(ENABLE_PEPPER_CDMS) #endif // defined(ENABLE_PEPPER_CDMS)
...@@ -700,6 +700,10 @@ void ClearKeyCdm::OnSessionMessage(const std::string& web_session_id, ...@@ -700,6 +700,10 @@ void ClearKeyCdm::OnSessionMessage(const std::string& web_session_id,
void ClearKeyCdm::OnSessionKeysChange(const std::string& web_session_id, void ClearKeyCdm::OnSessionKeysChange(const std::string& web_session_id,
bool has_additional_usable_key) { bool has_additional_usable_key) {
// Ignore the message when we are waiting to update the loadable session.
if (web_session_id == session_id_for_emulated_loadsession_)
return;
host_->OnSessionUsableKeysChange(web_session_id.data(), host_->OnSessionUsableKeysChange(web_session_id.data(),
web_session_id.length(), web_session_id.length(),
has_additional_usable_key); has_additional_usable_key);
...@@ -749,6 +753,9 @@ void ClearKeyCdm::OnSessionUpdated(uint32 promise_id, ...@@ -749,6 +753,9 @@ void ClearKeyCdm::OnSessionUpdated(uint32 promise_id,
// |promise_id| is the LoadSession() promise, so resolve appropriately. // |promise_id| is the LoadSession() promise, so resolve appropriately.
host_->OnResolveNewSessionPromise( host_->OnResolveNewSessionPromise(
promise_id, kLoadableWebSessionId, strlen(kLoadableWebSessionId)); promise_id, kLoadableWebSessionId, strlen(kLoadableWebSessionId));
// Generate the UsableKeys event now that the session is "loaded".
host_->OnSessionUsableKeysChange(
kLoadableWebSessionId, strlen(kLoadableWebSessionId), true);
return; return;
} }
......
...@@ -57,26 +57,23 @@ PlayerUtils.registerEMEEventListeners = function(player) { ...@@ -57,26 +57,23 @@ PlayerUtils.registerEMEEventListeners = function(player) {
// TODO(sandersd): Stop checking contentType once we complete the switch to // TODO(sandersd): Stop checking contentType once we complete the switch to
// using the 'encrypted' event. // using the 'encrypted' event.
var init_data_type = message.initDataType || message.contentType; var init_data_type = message.initDataType || message.contentType;
try {
if (player.testConfig.sessionToLoad) {
Utils.timeLog('Loading session: ' + player.testConfig.sessionToLoad);
var session = message.target.mediaKeys.createSession('persistent');
addMediaKeySessionListeners(session);
session.load(player.testConfig.sessionToLoad)
.catch(function(error) { Utils.failTest(error, KEY_ERROR); });
} else {
Utils.timeLog('Creating new media key session for initDataType: ' + Utils.timeLog('Creating new media key session for initDataType: ' +
init_data_type + ', initData: ' + init_data_type + ', initData: ' +
Utils.getHexString(new Uint8Array(message.initData))); Utils.getHexString(new Uint8Array(message.initData)));
try {
if (message.target.mediaKeys.createSession.length == 0) {
// FIXME(jrummell): Remove this test (and else branch) once blink
// uses the new API.
var session = message.target.mediaKeys.createSession(); var session = message.target.mediaKeys.createSession();
addMediaKeySessionListeners(session); addMediaKeySessionListeners(session);
session.generateRequest(init_data_type, message.initData) session.generateRequest(init_data_type, message.initData)
.catch(function(error) { .catch(function(error) {
Utils.failTest(error, KEY_ERROR); Utils.failTest(error, KEY_ERROR);
}); });
} else {
var session = message.target.mediaKeys.createSession(
init_data_type, message.initData);
session.then(addMediaKeySessionListeners)
.catch(function(error) {
Utils.failTest(error, KEY_ERROR);
});
} }
} catch (e) { } catch (e) {
Utils.failTest(e); Utils.failTest(e);
......
...@@ -28,6 +28,15 @@ TestConfig.prototype.loadQueryParams = function() { ...@@ -28,6 +28,15 @@ TestConfig.prototype.loadQueryParams = function() {
this.useMSE = this.useMSE == '1' || this.useMSE == 'true'; this.useMSE = this.useMSE == '1' || this.useMSE == 'true';
this.usePrefixedEME = this.usePrefixedEME =
this.usePrefixedEME == '1' || this.usePrefixedEME == 'true'; this.usePrefixedEME == '1' || this.usePrefixedEME == 'true';
// Validate that the prefixed/unprefixed EME is available.
if (this.usePrefixedEME) {
if (EME_DISABLED_OPTIONS.indexOf(EME_PREFIXED_VERSION) >= 0)
Utils.failTest('Prefixed EME not available.')
} else {
if (EME_DISABLED_OPTIONS.indexOf(EME_UNPREFIXED_VERSION) >= 0)
Utils.failTest('Unprefixed EME not available.')
}
}; };
TestConfig.updateDocument = function() { TestConfig.updateDocument = function() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment