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

Unified Diff: third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys-with-session.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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-reference.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys-with-session.html
diff --git a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys-with-session.html b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys-with-session.html
index 25a7cc9331485381e3fd7cc6c52f0cb28f1e1455..c667fadaafcbcea89092738e757b723d2e2ea7d8 100644
--- a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys-with-session.html
+++ b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys-with-session.html
@@ -17,53 +17,40 @@
// as long as the associated MediaKeys object is around.
// For this test, create a MediaKeySession and verify lifetime.
- async_test(function(test)
+ promise_test(function(test)
{
- gc();
var initDataType;
var initData;
var mediaKeys;
- var startingMediaKeysCount = window.internals.mediaKeysCount();
- var startingMediaKeySessionCount = window.internals.mediaKeySessionCount();
- function numMediaKeysCreated()
- {
- return window.internals.mediaKeysCount() - startingMediaKeysCount;
- }
+ // 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()');
- function numMediaKeySessionCreated()
- {
- return window.internals.mediaKeySessionCount() - startingMediaKeySessionCount;
- }
-
- // Create a MediaKeys object with a session.
- navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) {
+ // Create a MediaKeys object with a session.
+ 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, 'After final gc()');
+ verifyMediaKeyAndMediaKeySessionCount(1, 0, 'MediaKeys.create()');
var mediaKeySession = mediaKeys.createSession();
return mediaKeySession.generateRequest(initDataType, initData);
}).then(function() {
- assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.createSession()');
- assert_equals(numMediaKeySessionCreated(), 1, 'MediaKeys.createSession()');
+ verifyMediaKeyAndMediaKeySessionCount(1, 1, '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');
-
- assert_equals(numMediaKeysCreated(), 1, 'After gc()');
- assert_equals(numMediaKeySessionCreated(), 1, 'After gc()');
+ verifyMediaKeyAndMediaKeySessionCount(1, 1, 'After gc()');
// Drop reference to the MediaKeys object and run gc()
// again. Object should be collected this time. Since
@@ -78,12 +65,7 @@
}).then(function(result) {
return createGCPromise();
}).then(function(result) {
- assert_equals(numMediaKeysCreated(), 0, 'After final gc()');
- assert_equals(numMediaKeySessionCreated(), 0, 'After final gc()');
-
- test.done();
- }).catch(function(error) {
- forceTestFailureFromPromise(test, error);
+ verifyMediaKeyAndMediaKeySessionCount(0, 0, 'After final gc()');
});
}, 'MediaKeys lifetime with session');
</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-reference.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698