diff options
Diffstat (limited to 'testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-reload.html')
-rw-r--r-- | testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-reload.html | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-reload.html b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-reload.html new file mode 100644 index 000000000..b2f8ffb1f --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-reload.html @@ -0,0 +1,103 @@ +<!DOCTYPE html> +<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> +<html> + <head> + <title>Reloading during encrypted media playback</title> + <script src="encrypted-media-utils.js"></script> +<!-- + Test requires Chromium specific content and is being disabled. + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> +--> + </head> + <body> + <video id="testVideo"></video> + <div id="log"></div> + <script> + async_test(function(test) + { + var video = document.getElementById('testVideo'); + var content = 'webm/test-encrypted.webm'; + var mediaKeySession = null; + var hasSessionUpdateSucceeded = false; + var encryptedEventCount = 0; + + var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, + 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]); + + function onEncrypted(event) + { + assert_equals(event.target, video); + assert_true(event instanceof window.MediaEncryptedEvent); + assert_equals(event.type, 'encrypted'); + + // The same decryption key is used by both the audio and + // 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; + + mediaKeySession = video.mediaKeys.createSession(); + waitForEventAndRunStep('message', mediaKeySession, onMessage, test); + mediaKeySession.generateRequest(event.initDataType, event.initData).catch(function(error) { + forceTestFailureFromPromise(test, error); + }); + } + + function onMessage(event) + { + assert_true(event instanceof window.MediaKeyMessageEvent); + assert_equals(event.target, mediaKeySession); + assert_equals(event.type, 'message'); + assert_equals(event.messageType, 'license-request'); + + var keyId = extractSingleKeyIdFromMessage(event.message); + var jwkSet = stringToUint8Array(createJWKSet(createJWK(keyId, rawKey))); + mediaKeySession.update(jwkSet).then(function(result) { + hasSessionUpdateSucceeded = true; + }).catch(function(error) { + forceTestFailureFromPromise(test, error); + }); + } + + function onPlaying(event) + { + // Not using waitForEventAndRunStep() to avoid too many + // EVENT(onTimeUpdate) logs. + video.addEventListener('timeupdate', onTimeUpdate, true); + } + + function onTimeUpdate(event) + { + if (event.target.currentTime < 0.2 || !hasSessionUpdateSucceeded) + return; + + // Reload the page to catch any possible teardown issues. + if (location.hash == '#x') { + test.done(); + return; + } + + location.hash += 'x'; + location.reload(); + } + + navigator.requestMediaKeySystemAccess('org.w3.clearkey', getConfigurationForFile(content)).then(function(access) { + return access.createMediaKeys(); + }).then(function(mediaKeys) { + waitForEventAndRunStep('encrypted', video, onEncrypted, test); + waitForEventAndRunStep('playing', video, onPlaying, test); + video.src = content; + return video.setMediaKeys(mediaKeys); + }).then(function(result) { + video.play(); + }).catch(function(error) { + forceTestFailureFromPromise(test, error); + }); + }, 'Reloading during encrypted media playback.'); + </script> + </body> +</html> |