Chromium Code Reviews| 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..1d43017f4dc29e856cd2fbc57d1cbbd4cf289e07 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,41 +17,33 @@ |
| // 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; |
| - } |
| + return createGCPromise().then(function() { |
|
xhwang
2017/01/05 20:05:06
Could you please add a comment about why we need t
jrummell
2017/01/06 22:10:18
Done.
|
| + assert_equals(window.internals.mediaKeysCount(), 0, 'After initial gc()'); |
| + assert_equals(window.internals.mediaKeySessionCount(), 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()'); |
| + assert_equals(window.internals.mediaKeysCount(), 1, 'MediaKeys.create()'); |
| + assert_equals(window.internals.mediaKeySessionCount(), 0, 'After final gc()'); |
| var mediaKeySession = mediaKeys.createSession(); |
| return mediaKeySession.generateRequest(initDataType, initData); |
| }).then(function() { |
| - assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.createSession()'); |
| - assert_equals(numMediaKeySessionCreated(), 1, 'MediaKeys.createSession()'); |
| + assert_equals(window.internals.mediaKeysCount(), 1, 'MediaKeys.createSession()'); |
| + assert_equals(window.internals.mediaKeySessionCount(), 1, 'MediaKeys.createSession()'); |
| // Run gc(), should not affect MediaKeys object nor the |
| // session since we still have a reference to it. |
| @@ -62,8 +54,8 @@ |
| }).then(function(result) { |
| assert_equals(typeof mediaKeys.createSession, 'function'); |
| - assert_equals(numMediaKeysCreated(), 1, 'After gc()'); |
| - assert_equals(numMediaKeySessionCreated(), 1, 'After gc()'); |
| + assert_equals(window.internals.mediaKeysCount(), 1, 'After gc()'); |
| + assert_equals(window.internals.mediaKeySessionCount(), 1, 'After gc()'); |
| // Drop reference to the MediaKeys object and run gc() |
| // again. Object should be collected this time. Since |
| @@ -78,12 +70,8 @@ |
| }).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); |
| + assert_equals(window.internals.mediaKeysCount(), 0, 'After final gc()'); |
| + assert_equals(window.internals.mediaKeySessionCount(), 0, 'After final gc()'); |
| }); |
| }, 'MediaKeys lifetime with session'); |
| </script> |