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

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

Issue 2606633002: encrypted-media tests should not count # of SuspendableObjects (Closed)
Patch Set: temp Created 3 years, 12 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test MediaKeySession lifetime after release() without references< /title> 4 <title>Test MediaKeySession lifetime after release() without references< /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 // Since MediaKeySession (and MediaKeys) are SuspendableObjects,
12 // we can determine when they are garbage collected.
13 // MediaKeySessions remain as long as: 11 // MediaKeySessions remain as long as:
14 // JavaScript has a reference to it 12 // JavaScript has a reference to it
15 // OR (MediaKeys is around 13 // OR (MediaKeys is around
16 // AND the session has not received a close() event) 14 // AND the session has not received a close() event)
17 async_test(function(test) 15 async_test(function(test)
18 { 16 {
17 gc();
19 var initDataType; 18 var initDataType;
20 var initData; 19 var initData;
21 var startingSuspendableObjectCount = window.internals.suspendabl eObjectCount(document); 20 var startingMediaKeysCount = window.internals.mediaKeysCount();
21 var startingMediaKeySessionCount = window.internals.mediaKeySess ionCount();
22 22
23 function numSuspendableObjectsCreated() 23 function numMediaKeysCreated()
24 { 24 {
25 return window.internals.suspendableObjectCount(document) - s tartingSuspendableObjectCount; 25 return window.internals.mediaKeysCount() - startingMediaKeys Count;
26 }
27
28 function numMediaKeySessionCreated()
29 {
30 return window.internals.mediaKeySessionCount() - startingMed iaKeySessionCount;
26 } 31 }
27 32
28 // Create 2 sessions. 33 // Create 2 sessions.
29 var mediaKeys; 34 var mediaKeys;
30 var mediaKeySession1; 35 var mediaKeySession1;
31 var mediaKeySession2; 36 var mediaKeySession2;
32 37
33 navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimp leConfiguration()).then(function(access) { 38 navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimp leConfiguration()).then(function(access) {
34 initDataType = access.getConfiguration().initDataTypes[0]; 39 initDataType = access.getConfiguration().initDataTypes[0];
35 initData = getInitData(initDataType); 40 initData = getInitData(initDataType);
36 return access.createMediaKeys(); 41 return access.createMediaKeys();
37 }).then(function(result) { 42 }).then(function(result) {
38 mediaKeys = result; 43 mediaKeys = result;
39 44
40 // Verify MediaKeys is an SuspendableObject. 45 assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.create()' );
41 // In non-Oilpan, numSuspendableObjectsCreate() == 1. 46 assert_equals(numMediaKeySessionCreated(), 0, 'MediaKeys.cre ate()');
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 47
49 mediaKeySession1 = mediaKeys.createSession(); 48 mediaKeySession1 = mediaKeys.createSession();
50 return mediaKeySession1.generateRequest(initDataType, initDa ta); 49 return mediaKeySession1.generateRequest(initDataType, initDa ta);
51 }).then(function() { 50 }).then(function() {
52 assert_true(mediaKeySession1.sessionId && mediaKeySession1.s essionId.length > 0); 51 assert_true(mediaKeySession1.sessionId && mediaKeySession1.s essionId.length > 0);
53 52
54 // Should be 1 MediaKeys + 1 MediaKeySession. 53 assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.createSes sion(1)');
55 // In non-Oilpan, numSuspendableObjectsCreate() == 2. 54 assert_equals(numMediaKeySessionCreated(), 1, 'MediaKeys.cre ateSession(1)');
56 // In Oilpan, numSuspendableObjectsCreate() <= 6.
57 // (1 MediaKeys,
58 // 1 MediaKeysInitializer and
59 // 2 MediaKeySystemAccessInitializer,
60 // 1 ContentDecryptionModuleResultPromise and
61 // 1 MediaKeySession).
62 assert_between_inclusive(numSuspendableObjectsCreated(), 2, 6, 'MediaKeys.createSession(1)');
63 55
64 mediaKeySession2 = mediaKeys.createSession(); 56 mediaKeySession2 = mediaKeys.createSession();
65 return mediaKeySession2.generateRequest(initDataType, initDa ta); 57 return mediaKeySession2.generateRequest(initDataType, initDa ta);
66 }).then(function() { 58 }).then(function() {
67 assert_true(mediaKeySession2.sessionId && mediaKeySession2.s essionId.length > 0); 59 assert_true(mediaKeySession2.sessionId && mediaKeySession2.s essionId.length > 0);
68 60
69 // Should be 1 MediaKeys + 2 MediaKeySessions. 61 assert_equals(numMediaKeysCreated(), 1, 'mediaKeys.createSes sion(2)');
70 // In non-Oilpan, numSuspendableObjectsCreate() == 3. 62 assert_equals(numMediaKeySessionCreated(), 2, 'mediaKeys.cre ateSession(2)');
71 // In Oilpan, numSuspendableObjectsCreate() <= 8.
72 // (1 MediaKeys,
73 // 1 MediaKeysInitializer and
74 // 2 MediaKeySystemAccessInitializers,
75 // 2 ContentDecryptionModuleResultPromise and
76 // 2 MediaKeySession).
77 assert_between_inclusive(numSuspendableObjectsCreated(), 3, 8, 'mediaKeys.createSession(2)');
78 }).then(function(result) { 63 }).then(function(result) {
79 // Run gc(). All sessions should remain as we have a 64 // Run gc(). All sessions should remain as we have a
80 // reference to each one. 65 // reference to each one.
81 return createGCPromise(); 66 return createGCPromise();
82 }).then(function(result) { 67 }).then(function(result) {
83 // Should be just 1 MediaKeys + 2 MediaKeySessions. 68 assert_equals(numMediaKeysCreated(), 1, 'After gc()');
84 // In non-Oilpan, there is also something from createGCPromi se(). 69 assert_equals(numMediaKeySessionCreated(), 2, 'After gc()');
85 assert_between_inclusive(numSuspendableObjectsCreated(), 3, 4, 'After gc()');
86 70
87 // Close the sessions. Once the close() event is received, 71 // Close the sessions. Once the close() event is received,
88 // they should get garbage collected as there are no JS 72 // they should get garbage collected as there are no JS
89 // references to them. 73 // references to them.
90 var promise = mediaKeySession1.close(); 74 var promise = mediaKeySession1.close();
91 mediaKeySession1 = null; 75 mediaKeySession1 = null;
92 return promise; 76 return promise;
93 }).then(function(result) { 77 }).then(function(result) {
94 // Give time so that the close event can be processed by 78 // Give time so that the close event can be processed by
95 // MediaKeySession. 79 // MediaKeySession.
96 return delayToAllowEventProcessingPromise(); 80 return delayToAllowEventProcessingPromise();
97 }).then(function(result) { 81 }).then(function(result) {
98 return createGCPromise(); 82 return createGCPromise();
99 }).then(function(result) { 83 }).then(function(result) {
100 // Only MediaKeys + mediaKeySession2 should remain. 84 assert_equals(numMediaKeysCreated(), 1, 'mediaKeySession1 no t collected');
101 // In non-Oilpan, there is also something from createGCPromi se(). 85 assert_equals(numMediaKeySessionCreated(), 1, 'mediaKeySessi on1 not collected');
102 assert_between_inclusive(numSuspendableObjectsCreated(), 2, 3, 'mediaKeySession1 not collected');
103 86
104 var promise = mediaKeySession2.close(); 87 var promise = mediaKeySession2.close();
105 mediaKeySession2 = null; 88 mediaKeySession2 = null;
106 return promise; 89 return promise;
107 }).then(function(result) { 90 }).then(function(result) {
108 // Provide time for the mediaKeySession2 close event to be 91 // Provide time for the mediaKeySession2 close event to be
109 // handled. 92 // handled.
110 return delayToAllowEventProcessingPromise(); 93 return delayToAllowEventProcessingPromise();
111 }).then(function(result) { 94 }).then(function(result) {
112 return createGCPromise(); 95 return createGCPromise();
113 }).then(function(result) { 96 }).then(function(result) {
114 // Only MediaKeys should remain. 97 assert_equals(numMediaKeysCreated(), 1, 'mediaKeySession2 no t collected');
115 // In non-Oilpan, there is also something from createGCPromi se(). 98 assert_equals(numMediaKeySessionCreated(), 0, 'mediaKeySessi on2 not collected');
116 assert_between_inclusive(numSuspendableObjectsCreated(), 1, 2, 'mediaKeySession2 not collected');
117 99
118 assert_not_equals(mediaKeys, null); 100 assert_not_equals(mediaKeys, null);
119 test.done(); 101 test.done();
120 }).catch(function(error) { 102 }).catch(function(error) {
121 forceTestFailureFromPromise(test, error); 103 forceTestFailureFromPromise(test, error);
122 }); 104 });
123 }, 'MediaKeySession lifetime after release() without references'); 105 }, 'MediaKeySession lifetime after release() without references');
124 </script> 106 </script>
125 </body> 107 </body>
126 </html> 108 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698