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

Side by Side Diff: third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys-with-session.html

Issue 2606633002: encrypted-media tests should not count # of SuspendableObjects (Closed)
Patch Set: temp 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test MediaKeys lifetime when adding a session</title> 4 <title>Test MediaKeys lifetime when adding a session</title>
5 <script src="encrypted-media-utils.js"></script> 5 <script src="encrypted-media-utils.js"></script>
6 <script src="../../resources/testharness.js"></script> 6 <script src="../../resources/testharness.js"></script>
7 <script src="../../resources/testharnessreport.js"></script> 7 <script src="../../resources/testharnessreport.js"></script>
8 </head> 8 </head>
9 <body> 9 <body>
10 <script> 10 <script>
11 // MediaKeySessions remain as long as: 11 // MediaKeySessions remain as long as:
12 // JavaScript has a reference to it 12 // JavaScript has a reference to it
13 // OR (MediaKeys is around 13 // OR (MediaKeys is around
14 // AND the session has not received a close() event) 14 // AND the session has not received a close() event)
15 // In the tests below, we do not close any session nor keep a 15 // In the tests below, we do not close any session nor keep a
16 // Javascript reference to any session, so MediaKeySessions remain 16 // Javascript reference to any session, so MediaKeySessions remain
17 // as long as the associated MediaKeys object is around. 17 // as long as the associated MediaKeys object is around.
18 18
19 // For this test, create a MediaKeySession and verify lifetime. 19 // For this test, create a MediaKeySession and verify lifetime.
20 async_test(function(test) 20 async_test(function(test)
21 { 21 {
22 gc();
22 var initDataType; 23 var initDataType;
23 var initData; 24 var initData;
24 var mediaKeys; 25 var mediaKeys;
25 var startingSuspendableObjectCount = window.internals.suspendabl eObjectCount(document); 26 var startingMediaKeysCount = window.internals.mediaKeysCount();
27 var startingMediaKeySessionCount = window.internals.mediaKeySess ionCount();
26 28
27 function numSuspendableObjectsCreated() 29 function numMediaKeysCreated()
28 { 30 {
29 return window.internals.suspendableObjectCount(document) - s tartingSuspendableObjectCount; 31 return window.internals.mediaKeysCount() - startingMediaKeys Count;
32 }
33
34 function numMediaKeySessionCreated()
35 {
36 return window.internals.mediaKeySessionCount() - startingMed iaKeySessionCount;
30 } 37 }
31 38
32 // Create a MediaKeys object with a session. 39 // Create a MediaKeys object with a session.
33 navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimp leConfiguration()).then(function(access) { 40 navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimp leConfiguration()).then(function(access) {
34 initDataType = access.getConfiguration().initDataTypes[0]; 41 initDataType = access.getConfiguration().initDataTypes[0];
35 initData = getInitData(initDataType); 42 initData = getInitData(initDataType);
36 return access.createMediaKeys(); 43 return access.createMediaKeys();
37 }).then(function(result) { 44 }).then(function(result) {
38 mediaKeys = result; 45 mediaKeys = result;
39 46
40 // Verify MediaKeys is an SuspendableObject. 47 assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.create()' );
41 // In non-Oilpan, numSuspendableObjectsCreate() == 1. 48 assert_equals(numMediaKeySessionCreated(), 0, 'After final g c()');
42 // In Oilpan, numSuspendableObjectsCreate() <= 4.
43 // (1 MediaKeys,
44 // 1 MediaKeysInitializer and
45 // 1 MediaKeySystemAccessInitializer (navigator.requestMedi aKeySystemAccess() use above),
46 // 1 MediaKeySystemAccessInitializer (isInitDataSupported() (via getSupportedInitDataType())))
47 assert_between_inclusive(numSuspendableObjectsCreated(), 1, 4, 'MediaKeys.create()');
48 49
49 var mediaKeySession = mediaKeys.createSession(); 50 var mediaKeySession = mediaKeys.createSession();
50 return mediaKeySession.generateRequest(initDataType, initDat a); 51 return mediaKeySession.generateRequest(initDataType, initDat a);
51 }).then(function() { 52 }).then(function() {
52 // Should be 1 MediaKeys + 1 MediaKeySession. 53 assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.createSes sion()');
53 // In non-Oilpan, numSuspendableObjectsCreate() == 2. 54 assert_equals(numMediaKeySessionCreated(), 1, 'MediaKeys.cre ateSession()');
54 // In Oilpan, numSuspendableObjectsCreate() <= 6.
55 // (1 MediaKeys,
56 // 1 MediaKeysInitializer and
57 // 2 MediaKeySystemAccessInitializer,
58 // 1 ContentDecryptionModuleResultPromise and
59 // 1 MediaKeySession).
60 assert_between_inclusive(numSuspendableObjectsCreated(), 2, 6, 'MediaKeys.createSession()');
61 55
62 // Run gc(), should not affect MediaKeys object nor the 56 // Run gc(), should not affect MediaKeys object nor the
63 // session since we still have a reference to it. 57 // session since we still have a reference to it.
64 58
65 // When enabling oilpan GC, the in-active 59 // When enabling oilpan GC, the in-active
66 // ScriptPromiseResolvers will be destroyed. 60 // ScriptPromiseResolvers will be destroyed.
67 return createGCPromise(); 61 return createGCPromise();
68 }).then(function(result) { 62 }).then(function(result) {
69 assert_equals(typeof mediaKeys.createSession, 'function'); 63 assert_equals(typeof mediaKeys.createSession, 'function');
70 64
71 // MediaKeys + MediaKeySessions should remain. 65 assert_equals(numMediaKeysCreated(), 1, 'After gc()');
72 // In non-Oilpan, there is also something from createGCPromi se(). 66 assert_equals(numMediaKeySessionCreated(), 1, 'After gc()');
73 assert_between_inclusive(numSuspendableObjectsCreated(), 2, 3, 'After gc()');
74 67
75 // Drop reference to the MediaKeys object and run gc() 68 // Drop reference to the MediaKeys object and run gc()
76 // again. Object should be collected this time. Since 69 // again. Object should be collected this time. Since
77 // MediaKeySessions remain alive as long as MediaKeys is 70 // MediaKeySessions remain alive as long as MediaKeys is
78 // around, it is possible that gc() checks the 71 // around, it is possible that gc() checks the
79 // MediaKeySession object first, and doesn't collect it 72 // MediaKeySession object first, and doesn't collect it
80 // since MediaKeys hasn't been collected yet. Thus run gc() 73 // since MediaKeys hasn't been collected yet. Thus run gc()
81 // twice, to ensure that the unreferenced MediaKeySession 74 // twice, to ensure that the unreferenced MediaKeySession
82 // object get collected. 75 // object get collected.
83 mediaKeys = null; 76 mediaKeys = null;
84 return createGCPromise(); 77 return createGCPromise();
85 }).then(function(result) { 78 }).then(function(result) {
86 return createGCPromise(); 79 return createGCPromise();
87 }).then(function(result) { 80 }).then(function(result) {
88 // No MediaKeySessions should remain. 81 assert_equals(numMediaKeysCreated(), 0, 'After final gc()');
89 // In non-Oilpan, there is also something from createGCPromi se(). 82 assert_equals(numMediaKeySessionCreated(), 0, 'After final g c()');
90 assert_between_inclusive(numSuspendableObjectsCreated(), 0, 1, 'After final gc()');
91 83
92 test.done(); 84 test.done();
93 }).catch(function(error) { 85 }).catch(function(error) {
94 forceTestFailureFromPromise(test, error); 86 forceTestFailureFromPromise(test, error);
95 }); 87 });
96 }, 'MediaKeys lifetime with session'); 88 }, 'MediaKeys lifetime with session');
97 </script> 89 </script>
98 </body> 90 </body>
99 </html> 91 </html>
OLDNEW
« 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