diff options
Diffstat (limited to 'testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled')
9 files changed, 876 insertions, 0 deletions
diff --git a/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-async-creation-with-gc.html b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-async-creation-with-gc.html new file mode 100644 index 000000000..4dd705f9f --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-async-creation-with-gc.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> +<html> + <head> + <title>Test asynchronous creation of MediaKeys and MediaKeySession while running garbage collection</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> + <div id="log"></div> + <script> + async_test(function(test) + { + // Run garbage collection often. + setInterval(asyncGC, 0); + + var initDataType; + var initData; + var mediaKeySession; + navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { + initDataType = access.getConfiguration().initDataTypes[0]; + initData = getInitData(initDataType); + return access.createMediaKeys(); + }).then(function(mediaKeys) { + mediaKeySession = mediaKeys.createSession(); + return mediaKeySession.generateRequest(initDataType, initData); + }).then(function() { + return mediaKeySession.close(); + }).then(function(result) { + test.done(); + }).catch(function(error) { + forceTestFailureFromPromise(test, error); + }); + }, 'Test asynchronous creation of MediaKeys and MediaKeySession while running garbage collection.'); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-async-setcert-with-gc.html b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-async-setcert-with-gc.html new file mode 100644 index 000000000..4da562894 --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-async-setcert-with-gc.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> +<html> + <head> + <title>Test asynchronous setServerCertificate while running garbage collection</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> + <div id="log"></div> + <script> + // Run garbage collection continuously. + setInterval(asyncGC, 0); + + promise_test(function(test) + { + return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { + return access.createMediaKeys(); + }).then(function(mediaKeys) { + var cert = new Uint8Array(200); + return mediaKeys.setServerCertificate(cert); + }).then(function(result) { + assert_false(result); + }); + }, 'Test asynchronous setServerCertificate while running garbage collection.'); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeys-with-session.html b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeys-with-session.html new file mode 100644 index 000000000..a892b969c --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeys-with-session.html @@ -0,0 +1,104 @@ +<!DOCTYPE html> +<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> +<html> + <head> + <title>Test MediaKeys lifetime when adding a session</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> + <div id="log"></div> + <script> + // MediaKeySessions remain as long as: + // JavaScript has a reference to it + // OR (MediaKeys is around + // AND the session has not received a close() event) + // In the tests below, we do not close any session nor keep a + // Javascript reference to any session, so MediaKeySessions remain + // as long as the associated MediaKeys object is around. + + // For this test, create a MediaKeySession and verify lifetime. + async_test(function(test) + { + var initDataType; + var initData; + var mediaKeys; + var startingActiveDOMObjectCount = window.internals.activeDOMObjectCount(document); + + function numActiveDOMObjectsCreated() + { + return window.internals.activeDOMObjectCount(document) - startingActiveDOMObjectCount; + } + + // Create a MediaKeys object with a session. + navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { + initDataType = access.getConfiguration().initDataTypes[0]; + initData = getInitData(initDataType); + return access.createMediaKeys(); + }).then(function(result) { + mediaKeys = result; + + // Verify MediaKeys is an ActiveDOMObject. + // In non-Oilpan, numActiveDOMObjectsCreate() == 1. + // In Oilpan, numActiveDOMObjectsCreate() <= 4. + // (1 MediaKeys, + // 1 MediaKeysInitializer and + // 1 MediaKeySystemAccessInitializer (navigator.requestMediaKeySystemAccess() use above), + // 1 MediaKeySystemAccessInitializer (isInitDataSupported() (via getSupportedInitDataType()))) + assert_between_inclusive(numActiveDOMObjectsCreated(), 1, 4, 'MediaKeys.create()'); + + var mediaKeySession = mediaKeys.createSession(); + return mediaKeySession.generateRequest(initDataType, initData); + }).then(function() { + // Should be 1 MediaKeys + 1 MediaKeySession. + // In non-Oilpan, numActiveDOMObjectsCreate() == 2. + // In Oilpan, numActiveDOMObjectsCreate() <= 6. + // (1 MediaKeys, + // 1 MediaKeysInitializer and + // 2 MediaKeySystemAccessInitializer, + // 1 ContentDecryptionModuleResultPromise and + // 1 MediaKeySession). + assert_between_inclusive(numActiveDOMObjectsCreated(), 2, 6, 'MediaKeys.createSession()'); + + // Run gc(), should not affect MediaKeys object nor the + // session since we still have a reference to it. + + // When enabling oilpan GC, the in-active + // ScriptPromiseResolvers will be destroyed. + return createGCPromise(); + }).then(function(result) { + assert_equals(typeof mediaKeys.createSession, 'function'); + + // MediaKeys + MediaKeySessions should remain. + // In non-Oilpan, there is also something from createGCPromise(). + assert_between_inclusive(numActiveDOMObjectsCreated(), 2, 3, 'After gc()'); + + // Drop reference to the MediaKeys object and run gc() + // again. Object should be collected this time. Since + // MediaKeySessions remain alive as long as MediaKeys is + // around, it is possible that gc() checks the + // MediaKeySession object first, and doesn't collect it + // since MediaKeys hasn't been collected yet. Thus run gc() + // twice, to ensure that the unreferenced MediaKeySession + // object get collected. + mediaKeys = null; + return createGCPromise(); + }).then(function(result) { + return createGCPromise(); + }).then(function(result) { + // No MediaKeySessions should remain. + // In non-Oilpan, there is also something from createGCPromise(). + assert_between_inclusive(numActiveDOMObjectsCreated(), 0, 1, 'After final gc()'); + + test.done(); + }).catch(function(error) { + forceTestFailureFromPromise(test, error); + }); + }, 'MediaKeys lifetime with session'); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeys.html b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeys.html new file mode 100644 index 000000000..b8e79ac8b --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeys.html @@ -0,0 +1,59 @@ +<!DOCTYPE html> +<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> +<html> + <head> + <title>Test MediaKeys lifetime</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> + <div id="log"></div> + <script> + async_test(function(test) + { + // Create a MediaKeys object and free immediately. + navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { + return access.createMediaKeys(); + }).then(function(result) { + // Do nothing with the created object + }).then(function(result) { + // No way to verify that MediaKeys object is actually + // collected, but make sure it doesn't crash. + return createGCPromise(); + }).then(function(result) { + test.done(); + }).catch(function(error) { + forceTestFailureFromPromise(test, error); + }); + }, 'Creating and destroying MediaKeys does not crash'); + + async_test(function(test) + { + var mediaKeys; + navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { + return access.createMediaKeys(); + }).then(function(result) { + mediaKeys = result; + return createGCPromise(); + }).then(function(result) { + // Check that the object still exists. + assert_equals(typeof mediaKeys.createSession, 'function'); + mediaKeys = null; + + // Now that the reference is dropped, it should be + // collected. No way to verify that it is actually + // collected, but make sure it doesn't crash. + return createGCPromise(); + }).then(function(result) { + test.done(); + }).catch(function(error) { + forceTestFailureFromPromise(test, error); + }); + }, 'MediaKeys is not collected as long as we have a reference'); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeysession-reference.html b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeysession-reference.html new file mode 100644 index 000000000..4b8ad1b46 --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeysession-reference.html @@ -0,0 +1,157 @@ +<!DOCTYPE html> +<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> +<html> + <head> + <title>Test MediaKeySession lifetime without release()</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> + <div id="log"></div> + <script> + // Since MediaKeySession (and MediaKeys) are ActiveDOMObjects, + // we can determine when they are garbage collected. + // MediaKeySessions remain as long as: + // JavaScript has a reference to it + // OR (MediaKeys is around + // AND the session has not received a close() event) + + async_test(function(test) + { + var mediaKeys; + var mediaKeySession1; + var mediaKeySession2; + var mediaKeySession3; + var initDataType; + var initData; + var startingActiveDOMObjectCount = window.internals.activeDOMObjectCount(document); + + function numActiveDOMObjectsCreated() + { + return window.internals.activeDOMObjectCount(document) - startingActiveDOMObjectCount; + } + + navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { + initDataType = access.getConfiguration().initDataTypes[0]; + initData = getInitData(initDataType); + return access.createMediaKeys(); + }).then(function(result) { + mediaKeys = result; + assert_equals(typeof mediaKeys.createSession, 'function'); + + // Verify MediaKeys is an ActiveDOMObject. + // In non-Oilpan, numActiveDOMObjectsCreate() == 1. + // In Oilpan, numActiveDOMObjectsCreate() <= 4. + // (1 MediaKeys, + // 1 MediaKeysInitializer and + // 1 MediaKeySystemAccessInitializer (navigator.requestMediaKeySystemAccess() use above), + // 1 MediaKeySystemAccessInitializer (isInitDataSupported() (via getSupportedInitDataType()))) + assert_between_inclusive(numActiveDOMObjectsCreated(), 1, 4, 'MediaKeys.create()'); + + // Create 3 sessions. + mediaKeySession1 = mediaKeys.createSession(); + return mediaKeySession1.generateRequest(initDataType, initData); + }).then(function() { + assert_true(mediaKeySession1.sessionId && mediaKeySession1.sessionId.length > 0); + + // Should be 1 MediaKeys + 1 MediaKeySession. + // In non-Oilpan, numActiveDOMObjectsCreate() == 2. + // In Oilpan, numActiveDOMObjectsCreate() <= 6. + // (1 MediaKeys, + // 1 MediaKeysInitializer and + // 2 MediaKeySystemAccessInitializer, + // 1 ContentDecryptionModuleResultPromise and + // 1 MediaKeySession). + assert_between_inclusive(numActiveDOMObjectsCreated(), 2, 6, 'MediaKeys.createSession(1)'); + + mediaKeySession2 = mediaKeys.createSession(); + return mediaKeySession2.generateRequest(initDataType, initData); + }).then(function() { + assert_true(mediaKeySession2.sessionId && mediaKeySession2.sessionId.length > 0); + + // Should be 1 MediaKeys + 2 MediaKeySessions. + // In non-Oilpan, numActiveDOMObjectsCreate() == 3. + // In Oilpan, numActiveDOMObjectsCreate() <= 8. + // (1 MediaKeys, + // 1 MediaKeysInitializer and + // 2 MediaKeySystemAccessInitializers, + // 2 ContentDecryptionModuleResultPromise and + // 2 MediaKeySession). + assert_between_inclusive(numActiveDOMObjectsCreated(), 3, 8, 'mediaKeys.createSession(2)'); + + mediaKeySession3 = mediaKeys.createSession(); + return mediaKeySession3.generateRequest(initDataType, initData); + }).then(function() { + assert_true(mediaKeySession3.sessionId && mediaKeySession3.sessionId.length > 0); + + // Should be 1 MediaKeys + 3 MediaKeySessions. + // In non-Oilpan, numActiveDOMObjectsCreate() == 4. + // In Oilpan, numActiveDOMObjectsCreate() <= 10. + // (1 MediaKeys, + // 1 MediaKeysInitializer and + // 2 MediaKeySystemAccessInitializers, + // 3 ContentDecryptionModuleResultPromise and + // 3 MediaKeySession). + assert_between_inclusive(numActiveDOMObjectsCreated(), 4, 10, 'mediaKeys.createSession(3)'); + + // Run gc(). All sessions should remain as we have a + // reference to each one. However, running gc() + // asynchronously should free up the last PromiseResolver. + return createGCPromise(); + }).then(function(result) { + // Only MediaKeys + 3 MediaKeySessions should remain. + // In non-Oilpan, there is also something from createGCPromise(). + assert_between_inclusive(numActiveDOMObjectsCreated(), 4, 5, 'After gc()'); + + // Now drop references to 2 of the sessions. Even though we + // don't have a reference, MediaKeys is still around (and + // the sessions aren't closed), so the objects won't be + // collected. + mediaKeySession1 = null; + mediaKeySession2 = null; + return createGCPromise(); + }).then(function(result) { + return createGCPromise(); + }).then(function(result) { + // MediaKeys + 3 MediaKeySessions should remain. + // In non-Oilpan, there is also something from createGCPromise(). + assert_between_inclusive(numActiveDOMObjectsCreated(), 4, 5, 'After second gc()'); + + // Now drop the reference to MediaKeys. It and the 2 + // unreferenced sessions should be collected. Since + // MediaKeySessions remain alive as long as MediaKeys is + // around, it is possible that gc() checks one or both + // MediaKeySession objects first, and doesn't collect them + // since MediaKeys hasn't been collected yet. Thus run gc() + // twice, to ensure that the unreferenced MediaKeySession + // objects get collected. + mediaKeys = null; + return createGCPromise(); + }).then(function(result) { + return createGCPromise(); + }).then(function(result) { + // Only 1 MediaKeySessions should remain. + // In non-Oilpan, there is also something from createGCPromise(). + assert_between_inclusive(numActiveDOMObjectsCreated(), 1, 2, 'After mediaKeys = null'); + + // Drop the reference to the last session. It should get + // collected now since MediaKeys is gone. + mediaKeySession3 = null; + return createGCPromise(); + }).then(function(result) { + // No MediaKeySessions should remain. + // In non-Oilpan, there is also something from createGCPromise(). + assert_between_inclusive(numActiveDOMObjectsCreated(), 0, 1, 'After final gc()'); + + test.done(); + }).catch(function(error) { + forceTestFailureFromPromise(test, error); + }); + }, 'MediaKeySession lifetime without release()'); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeysession-release-noreference.html b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeysession-release-noreference.html new file mode 100644 index 000000000..a962844a3 --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeysession-release-noreference.html @@ -0,0 +1,131 @@ +<!DOCTYPE html> +<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> +<html> + <head> + <title>Test MediaKeySession lifetime after release() without references</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> + <div id="log"></div> + <script> + // Since MediaKeySession (and MediaKeys) are ActiveDOMObjects, + // we can determine when they are garbage collected. + // MediaKeySessions remain as long as: + // JavaScript has a reference to it + // OR (MediaKeys is around + // AND the session has not received a close() event) + async_test(function(test) + { + var initDataType; + var initData; + var startingActiveDOMObjectCount = window.internals.activeDOMObjectCount(document); + + function numActiveDOMObjectsCreated() + { + return window.internals.activeDOMObjectCount(document) - startingActiveDOMObjectCount; + } + + // Create 2 sessions. + var mediaKeys; + var mediaKeySession1; + var mediaKeySession2; + + navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { + initDataType = access.getConfiguration().initDataTypes[0]; + initData = getInitData(initDataType); + return access.createMediaKeys(); + }).then(function(result) { + mediaKeys = result; + + // Verify MediaKeys is an ActiveDOMObject. + // In non-Oilpan, numActiveDOMObjectsCreate() == 1. + // In Oilpan, numActiveDOMObjectsCreate() <= 4. + // (1 MediaKeys, + // 1 MediaKeysInitializer and + // 1 MediaKeySystemAccessInitializer (navigator.requestMediaKeySystemAccess() use above), + // 1 MediaKeySystemAccessInitializer (isInitDataSupported() (via getSupportedInitDataType()))) + assert_between_inclusive(numActiveDOMObjectsCreated(), 1, 4, 'MediaKeys.create()'); + + mediaKeySession1 = mediaKeys.createSession(); + return mediaKeySession1.generateRequest(initDataType, initData); + }).then(function() { + assert_true(mediaKeySession1.sessionId && mediaKeySession1.sessionId.length > 0); + + // Should be 1 MediaKeys + 1 MediaKeySession. + // In non-Oilpan, numActiveDOMObjectsCreate() == 2. + // In Oilpan, numActiveDOMObjectsCreate() <= 6. + // (1 MediaKeys, + // 1 MediaKeysInitializer and + // 2 MediaKeySystemAccessInitializer, + // 1 ContentDecryptionModuleResultPromise and + // 1 MediaKeySession). + assert_between_inclusive(numActiveDOMObjectsCreated(), 2, 6, 'MediaKeys.createSession(1)'); + + mediaKeySession2 = mediaKeys.createSession(); + return mediaKeySession2.generateRequest(initDataType, initData); + }).then(function() { + assert_true(mediaKeySession2.sessionId && mediaKeySession2.sessionId.length > 0); + + // Should be 1 MediaKeys + 2 MediaKeySessions. + // In non-Oilpan, numActiveDOMObjectsCreate() == 3. + // In Oilpan, numActiveDOMObjectsCreate() <= 8. + // (1 MediaKeys, + // 1 MediaKeysInitializer and + // 2 MediaKeySystemAccessInitializers, + // 2 ContentDecryptionModuleResultPromise and + // 2 MediaKeySession). + assert_between_inclusive(numActiveDOMObjectsCreated(), 3, 8, 'mediaKeys.createSession(2)'); + }).then(function(result) { + // Run gc(). All sessions should remain as we have a + // reference to each one. + return createGCPromise(); + }).then(function(result) { + // Should be just 1 MediaKeys + 2 MediaKeySessions. + // In non-Oilpan, there is also something from createGCPromise(). + assert_between_inclusive(numActiveDOMObjectsCreated(), 3, 4, 'After gc()'); + + // Close the sessions. Once the close() event is received, + // they should get garbage collected as there are no JS + // references to them. + var promise = mediaKeySession1.close(); + mediaKeySession1 = null; + return promise; + }).then(function(result) { + // Give time so that the close event can be processed by + // MediaKeySession. + return delayToAllowEventProcessingPromise(); + }).then(function(result) { + return createGCPromise(); + }).then(function(result) { + // Only MediaKeys + mediaKeySession2 should remain. + // In non-Oilpan, there is also something from createGCPromise(). + assert_between_inclusive(numActiveDOMObjectsCreated(), 2, 3, 'mediaKeySession1 not collected'); + + var promise = mediaKeySession2.close(); + mediaKeySession2 = null; + return promise; + }).then(function(result) { + // Provide time for the mediaKeySession2 close event to be + // handled. + return delayToAllowEventProcessingPromise(); + }).then(function(result) { + return createGCPromise(); + }).then(function(result) { + // Only MediaKeys should remain. + // In non-Oilpan, there is also something from createGCPromise(). + assert_between_inclusive(numActiveDOMObjectsCreated(), 1, 2, 'mediaKeySession2 not collected'); + + assert_not_equals(mediaKeys, null); + test.done(); + }).catch(function(error) { + forceTestFailureFromPromise(test, error); + }); + }, 'MediaKeySession lifetime after release() without references'); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeysession-release.html b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeysession-release.html new file mode 100644 index 000000000..626526761 --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeysession-release.html @@ -0,0 +1,118 @@ +<!DOCTYPE html> +<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> +<html> + <head> + <title>MediaKeySession lifetime after release()</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> + <div id="log"></div> + <script> + // Since MediaKeySession (and MediaKeys) are ActiveDOMObjects, + // we can determine when they are garbage collected. + // MediaKeySessions remain as long as: + // JavaScript has a reference to it + // OR (MediaKeys is around + // AND the session has not received a close() event) + async_test(function(test) + { + var mediaKeys; + var mediaKeySession1; + var mediaKeySession2; + var initDataType; + var initData; + var startingActiveDOMObjectCount = window.internals.activeDOMObjectCount(document); + + function numActiveDOMObjectsCreated() + { + return window.internals.activeDOMObjectCount(document) - startingActiveDOMObjectCount; + } + + // Create 2 sessions. + navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { + initDataType = access.getConfiguration().initDataTypes[0]; + initData = getInitData(initDataType); + return access.createMediaKeys(); + }).then(function(result) { + mediaKeys = result; + + // Verify MediaKeys is an ActiveDOMObject. + // In non-Oilpan, numActiveDOMObjectsCreate() == 1. + // In Oilpan, numActiveDOMObjectsCreate() <= 4. + // (1 MediaKeys, + // 1 MediaKeysInitializer and + // 1 MediaKeySystemAccessInitializer (navigator.requestMediaKeySystemAccess() use above), + // 1 MediaKeySystemAccessInitializer (isInitDataSupported() (via getSupportedInitDataType()))) + assert_between_inclusive(numActiveDOMObjectsCreated(), 1, 4, 'MediaKeys.create()'); + + mediaKeySession1 = mediaKeys.createSession(); + return mediaKeySession1.generateRequest(initDataType, initData); + }).then(function() { + // Should be 1 MediaKeys + 1 MediaKeySession. + // In non-Oilpan, numActiveDOMObjectsCreate() == 2. + // In Oilpan, numActiveDOMObjectsCreate() <= 6. + // (1 MediaKeys, + // 1 MediaKeysInitializer, + // 2 MediaKeySystemAccessInitializers, + // 1 ContentDecryptionModuleResultPromise and + // 1 MediaKeySession). + assert_between_inclusive(numActiveDOMObjectsCreated(), 2, 6, 'MediaKeys.createSession(1)'); + + mediaKeySession2 = mediaKeys.createSession(); + return mediaKeySession2.generateRequest(initDataType, initData); + }).then(function() { + // Should be 1 MediaKeys + 2 MediaKeySessions. + // In non-Oilpan, numActiveDOMObjectsCreate() == 3. + // In Oilpan, numActiveDOMObjectsCreate() <= 8. + // (1 MediaKeys, + // 1 MediaKeysInitializer, + // 2 MediaKeySystemAccessInitializers, + // 2 ContentDecryptionModuleResultPromise and + // 2 MediaKeySession). + assert_between_inclusive(numActiveDOMObjectsCreated(), 3, 8, 'mediaKeys.createSession(2)'); + + // Close the sessions. Once completed, only the JS + // reference to them keeps them around. + return mediaKeySession1.close(); + }).then(function(result) { + return mediaKeySession2.close(); + }).then(function(result) { + // Since both sessions have been closed, dropping the + // reference to them from JS will result in the session + // being garbage-collected. + // Should be 1 MediaKeys + 2 MediaKeySessions. + // In non-Oilpan, numActiveDOMObjectsCreate() == 3. + // In Oilpan, numActiveDOMObjectsCreate() <= 10. + // (1 MediaKeys, + // 1 MediaKeysInitializer, + // 2 MediaKeySystemAccessInitializers, + // 4 ContentDecryptionModuleResultPromise and + // 2 MediaKeySession). + assert_between_inclusive(numActiveDOMObjectsCreated(), 3, 10, 'after close'); + + mediaKeySession1 = null; + return createGCPromise(); + }).then(function() { + // Only MediaKeys + mediaKeySession2 should remain. + // In non-Oilpan, there is also something from createGCPromise(). + assert_between_inclusive(numActiveDOMObjectsCreated(), 2, 3, 'mediaKeySession1 not collected'); + + mediaKeySession2 = null; + return createGCPromise(); + }).then(function() { + // Only MediaKeys should remain. + // In non-Oilpan, there is also something from createGCPromise(). + assert_between_inclusive(numActiveDOMObjectsCreated(), 1, 2, 'mediaKeySession2 not collected'); + test.done(); + }).catch(function(error) { + forceTestFailureFromPromise(test, error); + }); + }, 'MediaKeySession lifetime after release()'); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-multiple-mediakeys.html b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-multiple-mediakeys.html new file mode 100644 index 000000000..42638a069 --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-multiple-mediakeys.html @@ -0,0 +1,131 @@ +<!DOCTYPE html> +<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> +<html> + <head> + <title>Test multiple MediaKeys lifetimes</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> + <div id="log"></div> + <script> + // For this test, create several MediaKeys and verify lifetime. + async_test(function(test) + { + var mediaKeys; + var startingActiveDOMObjectCount = window.internals.activeDOMObjectCount(document); + + function numActiveDOMObjectsCreated() + { + return window.internals.activeDOMObjectCount(document) - startingActiveDOMObjectCount; + } + + // Create a MediaKeys object. Returns a promise that resolves + // with the new MediaKeys object. + function createMediaKeys() + { + return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { + return access.createMediaKeys(); + }).then(function(mediaKeys) { + return mediaKeys; + }); + } + + // Create a few MediaKeys objects. Only keep a reference to the + // last one created. + createMediaKeys().then(function(result) { + // Should be 1 MediaKeys. + // In non-Oilpan, numActiveDOMObjectsCreate() == 1. + // In Oilpan, numActiveDOMObjectsCreated() <= 4. + // (1 MediaKeysInitializer, + // 1 MediaKeySystemAccessInitializer (navigator.requestMediaKeySystemAccess() use above), + // 1 MediaKeySystemAccessInitializer (isInitDataSupported() (via getSupportedInitDataType())) and + // 1 ContentDecryptionModuleResultPromise). + assert_between_inclusive(numActiveDOMObjectsCreated(), 1, 4); + + return createMediaKeys(); + }).then(function(result) { + // Should be 2 MediaKeys. + // In non-Oilpan, numActiveDOMObjectsCreate() == 2. + // In Oilpan, numActiveDOMObjectsCreate() <= 8. + // (2 MediaKeysInitializer, + // 4 MediaKeySystemAccessInitializer and + // 2 ContentDecryptionModuleResultPromise). + assert_between_inclusive(numActiveDOMObjectsCreated(), 2, 8); + + return createMediaKeys(); + }).then(function(result) { + // Should be 3 MediaKeys. + // In non-Oilpan, numActiveDOMObjectsCreate() == 3. + // In Oilpan, numActiveDOMObjectsCreate() <= 12. + // (3 MediaKeysInitializer, + // 6 MediaKeySystemAccessInitializer and + // 3 ContentDecryptionModuleResultPromise). + assert_between_inclusive(numActiveDOMObjectsCreated(), 3, 12); + + return createMediaKeys(); + }).then(function(result) { + // Should be 4 MediaKeys. + // In non-Oilpan, numActiveDOMObjectsCreate() == 4. + // In Oilpan, numActiveDOMObjectsCreate() <= 16. + // (4 MediaKeysInitializer, + // 8 MediaKeySystemAccessInitializer and + // 4 ContentDecryptionModuleResultPromise). + assert_between_inclusive(numActiveDOMObjectsCreated(), 4, 16); + + return createMediaKeys(); + }).then(function(result) { + // Should be 5 MediaKeys. + // In non-Oilpan, numActiveDOMObjectsCreate() == 5. + // In Oilpan, numActiveDOMObjectsCreate() <= 20. + // (5 MediaKeysInitializer, + // 10 MediaKeySystemAccessInitializer and + // 5 ContentDecryptionModuleResultPromise). + assert_between_inclusive(numActiveDOMObjectsCreated(), 5, 20); + + // |mediaKeys| refers to the most recently created MediaKeys + // object. + mediaKeys = result; + + // In order for the MediaKey objects to be garbage + // collected, it needs time to process any pending events. + return delayToAllowEventProcessingPromise(); + }).then(function(result) { + // In non-Oilpan, numActiveDOMObjectsCreated() == 5 + // (5 MediaKeySession objects). + // In Oilpan, numActiveDOMObjectsCreated() <= 23 + // (5 MediaKeysInitializer, + // 12 MediaKeySystemAccessInitializer, + // 5 ContentDecryptionModuleResultPromise and + // 1 DOMTimer (in delayToAllowEventProcessingPromise)) + assert_between_inclusive(numActiveDOMObjectsCreated(), 5, 23); + + // As we only have a reference (|mediaKeys|) to the last + // created MediaKeys object, the other 4 MediaKeys objects + // are available to be garbage collected. + return createGCPromise(); + }).then(function(result) { + // Should be 1 MediaKeys and DOMTimer. + assert_less_than_equal(numActiveDOMObjectsCreated(), 2); + assert_equals(typeof mediaKeys.createSession, 'function'); + + // Release the last MediaKeys object created. + mediaKeys = null; + + // Run gc() again to reclaim the remaining MediaKeys object. + return createGCPromise(); + }).then(function(result) { + // Should be just a DOMTimer. + assert_less_than_equal(numActiveDOMObjectsCreated(), 1); + test.done(); + }).catch(function(error) { + forceTestFailureFromPromise(test, error); + }); + }, 'Multiple MediaKeys lifetime'); + </script> + </body> +</html> 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> |