Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release.html

Issue 2618603002: [eme] Convert lifetime tests to promise_tests (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release.html
diff --git a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release.html b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release.html
index 39d3db1e4d38ec2a307f1f087aa147432f019aab..25ea79e3fe99276700a5cf05077dd34dd4ee800d 100644
--- a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release.html
+++ b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release.html
@@ -12,49 +12,41 @@
// JavaScript has a reference to it
// OR (MediaKeys is around
// AND the session has not received a close() event)
- async_test(function(test)
+ promise_test(function(test)
{
- gc();
var mediaKeys;
var mediaKeySession1;
var mediaKeySession2;
var initDataType;
var initData;
- var startingMediaKeysCount = window.internals.mediaKeysCount();
- var startingMediaKeySessionCount = window.internals.mediaKeySessionCount();
-
- function numMediaKeysCreated()
- {
- return window.internals.mediaKeysCount() - startingMediaKeysCount;
- }
-
- function numMediaKeySessionCreated()
- {
- return window.internals.mediaKeySessionCount() - startingMediaKeySessionCount;
- }
// Create 2 sessions.
- navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) {
+ return createGCPromise().then(function() {
+ assert_equals(window.internals.mediaKeysCount(), 0, 'After initial gc()');
+ assert_equals(window.internals.mediaKeySessionCount(), 0, 'After initial gc()');
+
+ return 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(numMediaKeysCreated(), 1, 'MediaKeys.create()');
- assert_equals(numMediaKeySessionCreated(), 0, 'MediaKeys.create()');
+ assert_equals(window.internals.mediaKeysCount(), 1, 'MediaKeys.create()');
+ assert_equals(window.internals.mediaKeySessionCount(), 0, 'MediaKeys.create()');
mediaKeySession1 = mediaKeys.createSession();
return mediaKeySession1.generateRequest(initDataType, initData);
}).then(function() {
- assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.createSession(1)');
- assert_equals(numMediaKeySessionCreated(), 1, 'MediaKeys.createSession(1)');
+ assert_equals(window.internals.mediaKeysCount(), 1, 'MediaKeys.createSession(1)');
+ assert_equals(window.internals.mediaKeySessionCount(), 1, 'MediaKeys.createSession(1)');
mediaKeySession2 = mediaKeys.createSession();
return mediaKeySession2.generateRequest(initDataType, initData);
}).then(function() {
- assert_equals(numMediaKeysCreated(), 1, 'mediaKeys.createSession(2)');
- assert_equals(numMediaKeySessionCreated(), 2, 'mediaKeys.createSession(2)');
+ assert_equals(window.internals.mediaKeysCount(), 1, 'mediaKeys.createSession(2)');
+ assert_equals(window.internals.mediaKeySessionCount(), 2, 'mediaKeys.createSession(2)');
// Close the sessions. Once completed, only the JS
// reference to them keeps them around.
@@ -65,23 +57,20 @@
// Since both sessions have been closed, dropping the
// reference to them from JS will result in the session
// being garbage-collected.
- assert_equals(numMediaKeysCreated(), 1, 'after close');
- assert_equals(numMediaKeySessionCreated(), 2, 'after close');
+ assert_equals(window.internals.mediaKeysCount(), 1, 'after close');
+ assert_equals(window.internals.mediaKeySessionCount(), 2, 'after close');
mediaKeySession1 = null;
return createGCPromise();
}).then(function() {
- assert_equals(numMediaKeysCreated(), 1, 'mediaKeySession1 not collected');
- assert_equals(numMediaKeySessionCreated(), 1, 'mediaKeySession1 not collected');
+ assert_equals(window.internals.mediaKeysCount(), 1, 'mediaKeySession1 not collected');
+ assert_equals(window.internals.mediaKeySessionCount(), 1, 'mediaKeySession1 not collected');
mediaKeySession2 = null;
return createGCPromise();
}).then(function() {
- assert_equals(numMediaKeysCreated(), 1, 'mediaKeySession2 not collected');
- assert_equals(numMediaKeySessionCreated(), 0, 'mediaKeySession2 not collected');
- test.done();
- }).catch(function(error) {
- forceTestFailureFromPromise(test, error);
+ assert_equals(window.internals.mediaKeysCount(), 1, 'mediaKeySession2 not collected');
+ assert_equals(window.internals.mediaKeySessionCount(), 0, 'mediaKeySession2 not collected');
});
}, 'MediaKeySession lifetime after release()');
</script>

Powered by Google App Engine
This is Rietveld 408576698