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

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

Issue 2618603002: [eme] Convert lifetime tests to promise_tests (Closed)
Patch Set: move to utils 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-noreference.html
diff --git a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release-noreference.html b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release-noreference.html
index 60019a1e8dc75c9047daa41748946df10d167f55..a66800aaff81d2a5be2f024fa4d161c36f908835 100644
--- a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release-noreference.html
+++ b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release-noreference.html
@@ -12,61 +12,49 @@
// 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 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.
var mediaKeys;
var mediaKeySession1;
var mediaKeySession2;
- navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) {
+ // Even though there should be no existing objects, start by
+ // running gc() and verifying that none exist. This also
+ // allows the failures to be reported from inside a promise
+ // so that the test fails properly.
+ return createGCPromise().then(function() {
+ verifyMediaKeyAndMediaKeySessionCount(0, 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()');
+ verifyMediaKeyAndMediaKeySessionCount(1, 0, 'MediaKeys.create()');
mediaKeySession1 = mediaKeys.createSession();
return mediaKeySession1.generateRequest(initDataType, initData);
}).then(function() {
assert_true(mediaKeySession1.sessionId && mediaKeySession1.sessionId.length > 0);
-
- assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.createSession(1)');
- assert_equals(numMediaKeySessionCreated(), 1, 'MediaKeys.createSession(1)');
+ verifyMediaKeyAndMediaKeySessionCount(1, 1, 'MediaKeys.createSession(1)');
mediaKeySession2 = mediaKeys.createSession();
return mediaKeySession2.generateRequest(initDataType, initData);
}).then(function() {
assert_true(mediaKeySession2.sessionId && mediaKeySession2.sessionId.length > 0);
+ verifyMediaKeyAndMediaKeySessionCount(1, 2, 'mediaKeys.createSession(2)');
- assert_equals(numMediaKeysCreated(), 1, 'mediaKeys.createSession(2)');
- assert_equals(numMediaKeySessionCreated(), 2, '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) {
- assert_equals(numMediaKeysCreated(), 1, 'After gc()');
- assert_equals(numMediaKeySessionCreated(), 2, 'After gc()');
+ verifyMediaKeyAndMediaKeySessionCount(1, 2, 'After gc()');
// Close the sessions. Once the close() event is received,
// they should get garbage collected as there are no JS
@@ -81,8 +69,7 @@
}).then(function(result) {
return createGCPromise();
}).then(function(result) {
- assert_equals(numMediaKeysCreated(), 1, 'mediaKeySession1 not collected');
- assert_equals(numMediaKeySessionCreated(), 1, 'mediaKeySession1 not collected');
+ verifyMediaKeyAndMediaKeySessionCount(1, 1, 'mediaKeySession1 not collected');
var promise = mediaKeySession2.close();
mediaKeySession2 = null;
@@ -94,13 +81,8 @@
}).then(function(result) {
return createGCPromise();
}).then(function(result) {
- assert_equals(numMediaKeysCreated(), 1, 'mediaKeySession2 not collected');
- assert_equals(numMediaKeySessionCreated(), 0, 'mediaKeySession2 not collected');
-
+ verifyMediaKeyAndMediaKeySessionCount(1, 0, 'mediaKeySession2 not collected');
assert_not_equals(mediaKeys, null);
- test.done();
- }).catch(function(error) {
- forceTestFailureFromPromise(test, error);
});
}, 'MediaKeySession lifetime after release() without references');
</script>

Powered by Google App Engine
This is Rietveld 408576698