Commit 015ce17e authored by jrummell@chromium.org's avatar jrummell@chromium.org

Improve reliability of EME tests

The logs for these EME tests expect all the "onencrypted" events to
occur before the "message" event is received. Modify the tests to
create the session on the second event rather than the first, to avoid
the "message" event occasionally happening before the second
"onencrypted" event".

BUG=407993
TEST=modified tests still pass

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

git-svn-id: svn://svn.chromium.org/blink/trunk@183833 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 3cee8c28
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
{ {
var video = document.getElementById('testVideo'); var video = document.getElementById('testVideo');
var mediaKeySession = null; var mediaKeySession = null;
var isSessionCreated = false;
var sessionReadyReceived = false; var sessionReadyReceived = false;
var encryptedEventCount = 0;
var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]); 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]);
...@@ -27,11 +27,14 @@ ...@@ -27,11 +27,14 @@
assert_true(event instanceof window.MediaEncryptedEvent); assert_true(event instanceof window.MediaEncryptedEvent);
assert_equals(event.type, 'encrypted'); assert_equals(event.type, 'encrypted');
// The same decryption key is shared by all streams so only // The same decryption key is used by both the audio and
// create a shared session once. // the video streams so only create a session once. To
if (isSessionCreated) // avoid issues when comparing the expected.txt file
// (which logs the events in the order they occur), create
// the session on the second event. This also ensures we
// see both events.
if (++encryptedEventCount != 2)
return; return;
isSessionCreated = true;
mediaKeySession = video.mediaKeys.createSession(); mediaKeySession = video.mediaKeys.createSession();
waitForEventAndRunStep('message', mediaKeySession, onMessage, test); waitForEventAndRunStep('message', mediaKeySession, onMessage, test);
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
async_test(function(test) async_test(function(test)
{ {
var video = document.getElementById('testVideo'); var video = document.getElementById('testVideo');
var isSessionCreated = false;
var isUpdatePromiseResolved = false; var isUpdatePromiseResolved = false;
var encryptedEventCount = 0;
var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]); 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]);
...@@ -26,11 +26,14 @@ ...@@ -26,11 +26,14 @@
assert_true(event instanceof window.MediaEncryptedEvent); assert_true(event instanceof window.MediaEncryptedEvent);
assert_equals(event.type, 'encrypted'); assert_equals(event.type, 'encrypted');
// The same decryption key is shared by all streams so // The same decryption key is used by both the audio and
// only create a shared session once. // the video streams so only create a session once. To
if (isSessionCreated) // avoid issues when comparing the expected.txt file
// (which logs the events in the order they occur), create
// the session on the second event. This also ensures we
// see both events.
if (++encryptedEventCount != 2)
return; return;
isSessionCreated = true;
var mediaKeySession = video.mediaKeys.createSession(); var mediaKeySession = video.mediaKeys.createSession();
waitForEventAndRunStep('message', mediaKeySession, onMessage, test); waitForEventAndRunStep('message', mediaKeySession, onMessage, test);
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
async_test(function(test) async_test(function(test)
{ {
var video = document.getElementById('testVideo'); var video = document.getElementById('testVideo');
var isSessionCreated = false;
var isUpdatePromiseResolved = false; var isUpdatePromiseResolved = false;
var encryptedEventCount = 0;
var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]); 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]);
...@@ -26,10 +26,14 @@ ...@@ -26,10 +26,14 @@
assert_true(event instanceof window.MediaEncryptedEvent); assert_true(event instanceof window.MediaEncryptedEvent);
assert_equals(event.type, 'encrypted'); assert_equals(event.type, 'encrypted');
// The same decryption key is shared by all streams so only create a shared session once. // The same decryption key is used by both the audio and
if (isSessionCreated) // the video streams so only create a session once. To
// avoid issues when comparing the expected.txt file
// (which logs the events in the order they occur), create
// the session on the second event. This also ensures we
// see both events.
if (++encryptedEventCount != 2)
return; return;
isSessionCreated = true;
var mediaKeySession = video.mediaKeys.createSession(); var mediaKeySession = video.mediaKeys.createSession();
waitForEventAndRunStep('message', mediaKeySession, onMessage, test); waitForEventAndRunStep('message', mediaKeySession, onMessage, test);
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
{ {
var video = document.getElementById('testVideo'); var video = document.getElementById('testVideo');
var mediaKeySession = null; var mediaKeySession = null;
var sessionCreated = false;
var sessionReadyReceived = false; var sessionReadyReceived = false;
var encryptedEventCount = 0;
var keyId = null; var keyId = null;
var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
...@@ -27,11 +27,14 @@ ...@@ -27,11 +27,14 @@
assert_true(event instanceof window.MediaEncryptedEvent); assert_true(event instanceof window.MediaEncryptedEvent);
assert_equals(event.type, 'encrypted'); assert_equals(event.type, 'encrypted');
// The same decryption key is shared by all streams so only // The same decryption key is used by both the audio and
// create a shared session once. // the video streams so only create a session once. To
if (sessionCreated) // avoid issues when comparing the expected.txt file
// (which logs the events in the order they occur), create
// the session on the second event. This also ensures we
// see both events.
if (++encryptedEventCount != 2)
return; return;
sessionCreated = true;
mediaKeySession = video.mediaKeys.createSession(); mediaKeySession = video.mediaKeys.createSession();
waitForEventAndRunStep('message', mediaKeySession, onMessage, test); waitForEventAndRunStep('message', mediaKeySession, onMessage, test);
......
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