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

Side by Side Diff: third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release.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>MediaKeySession lifetime after release()</title> 4 <title>MediaKeySession lifetime after release()</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 mediaKeys; 18 var mediaKeys;
20 var mediaKeySession1; 19 var mediaKeySession1;
21 var mediaKeySession2; 20 var mediaKeySession2;
22 var initDataType; 21 var initDataType;
23 var initData; 22 var initData;
24 var startingSuspendableObjectCount = window.internals.suspendabl eObjectCount(document); 23 var startingMediaKeysCount = window.internals.mediaKeysCount();
24 var startingMediaKeySessionCount = window.internals.mediaKeySess ionCount();
25 25
26 function numSuspendableObjectsCreated() 26 function numMediaKeysCreated()
27 { 27 {
28 return window.internals.suspendableObjectCount(document) - s tartingSuspendableObjectCount; 28 return window.internals.mediaKeysCount() - startingMediaKeys Count;
29 }
30
31 function numMediaKeySessionCreated()
32 {
33 return window.internals.mediaKeySessionCount() - startingMed iaKeySessionCount;
29 } 34 }
30 35
31 // Create 2 sessions. 36 // Create 2 sessions.
32 navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimp leConfiguration()).then(function(access) { 37 navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimp leConfiguration()).then(function(access) {
33 initDataType = access.getConfiguration().initDataTypes[0]; 38 initDataType = access.getConfiguration().initDataTypes[0];
34 initData = getInitData(initDataType); 39 initData = getInitData(initDataType);
35 return access.createMediaKeys(); 40 return access.createMediaKeys();
36 }).then(function(result) { 41 }).then(function(result) {
37 mediaKeys = result; 42 mediaKeys = result;
38 43
39 // Verify MediaKeys is an SuspendableObject. 44 assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.create()' );
40 // In non-Oilpan, numSuspendableObjectsCreate() == 1. 45 assert_equals(numMediaKeySessionCreated(), 0, 'MediaKeys.cre ate()');
41 // In Oilpan, numSuspendableObjectsCreate() <= 4.
42 // (1 MediaKeys,
43 // 1 MediaKeysInitializer and
44 // 1 MediaKeySystemAccessInitializer (navigator.requestMedi aKeySystemAccess() use above),
45 // 1 MediaKeySystemAccessInitializer (isInitDataSupported() (via getSupportedInitDataType())))
46 assert_between_inclusive(numSuspendableObjectsCreated(), 1, 4, 'MediaKeys.create()');
47 46
48 mediaKeySession1 = mediaKeys.createSession(); 47 mediaKeySession1 = mediaKeys.createSession();
49 return mediaKeySession1.generateRequest(initDataType, initDa ta); 48 return mediaKeySession1.generateRequest(initDataType, initDa ta);
50 }).then(function() { 49 }).then(function() {
51 // Should be 1 MediaKeys + 1 MediaKeySession. 50 assert_equals(numMediaKeysCreated(), 1, 'MediaKeys.createSes sion(1)');
52 // In non-Oilpan, numSuspendableObjectsCreate() == 2. 51 assert_equals(numMediaKeySessionCreated(), 1, 'MediaKeys.cre ateSession(1)');
53 // In Oilpan, numSuspendableObjectsCreate() <= 6.
54 // (1 MediaKeys,
55 // 1 MediaKeysInitializer,
56 // 2 MediaKeySystemAccessInitializers,
57 // 1 ContentDecryptionModuleResultPromise and
58 // 1 MediaKeySession).
59 assert_between_inclusive(numSuspendableObjectsCreated(), 2, 6, 'MediaKeys.createSession(1)');
60 52
61 mediaKeySession2 = mediaKeys.createSession(); 53 mediaKeySession2 = mediaKeys.createSession();
62 return mediaKeySession2.generateRequest(initDataType, initDa ta); 54 return mediaKeySession2.generateRequest(initDataType, initDa ta);
63 }).then(function() { 55 }).then(function() {
64 // Should be 1 MediaKeys + 2 MediaKeySessions. 56 assert_equals(numMediaKeysCreated(), 1, 'mediaKeys.createSes sion(2)');
65 // In non-Oilpan, numSuspendableObjectsCreate() == 3. 57 assert_equals(numMediaKeySessionCreated(), 2, 'mediaKeys.cre ateSession(2)');
66 // In Oilpan, numSuspendableObjectsCreate() <= 8.
67 // (1 MediaKeys,
68 // 1 MediaKeysInitializer,
69 // 2 MediaKeySystemAccessInitializers,
70 // 2 ContentDecryptionModuleResultPromise and
71 // 2 MediaKeySession).
72 assert_between_inclusive(numSuspendableObjectsCreated(), 3, 8, 'mediaKeys.createSession(2)');
73 58
74 // Close the sessions. Once completed, only the JS 59 // Close the sessions. Once completed, only the JS
75 // reference to them keeps them around. 60 // reference to them keeps them around.
76 return mediaKeySession1.close(); 61 return mediaKeySession1.close();
77 }).then(function(result) { 62 }).then(function(result) {
78 return mediaKeySession2.close(); 63 return mediaKeySession2.close();
79 }).then(function(result) { 64 }).then(function(result) {
80 // Since both sessions have been closed, dropping the 65 // Since both sessions have been closed, dropping the
81 // reference to them from JS will result in the session 66 // reference to them from JS will result in the session
82 // being garbage-collected. 67 // being garbage-collected.
83 // Should be 1 MediaKeys + 2 MediaKeySessions. 68 assert_equals(numMediaKeysCreated(), 1, 'after close');
84 // In non-Oilpan, numSuspendableObjectsCreate() == 3. 69 assert_equals(numMediaKeySessionCreated(), 2, 'after close') ;
85 // In Oilpan, numSuspendableObjectsCreate() <= 10.
86 // (1 MediaKeys,
87 // 1 MediaKeysInitializer,
88 // 2 MediaKeySystemAccessInitializers,
89 // 4 ContentDecryptionModuleResultPromise and
90 // 2 MediaKeySession).
91 assert_between_inclusive(numSuspendableObjectsCreated(), 3, 10, 'after close');
92 70
93 mediaKeySession1 = null; 71 mediaKeySession1 = null;
94 return createGCPromise(); 72 return createGCPromise();
95 }).then(function() { 73 }).then(function() {
96 // Only MediaKeys + mediaKeySession2 should remain. 74 assert_equals(numMediaKeysCreated(), 1, 'mediaKeySession1 no t collected');
97 // In non-Oilpan, there is also something from createGCPromi se(). 75 assert_equals(numMediaKeySessionCreated(), 1, 'mediaKeySessi on1 not collected');
98 assert_between_inclusive(numSuspendableObjectsCreated(), 2, 3, 'mediaKeySession1 not collected');
99 76
100 mediaKeySession2 = null; 77 mediaKeySession2 = null;
101 return createGCPromise(); 78 return createGCPromise();
102 }).then(function() { 79 }).then(function() {
103 // Only MediaKeys should remain. 80 assert_equals(numMediaKeysCreated(), 1, 'mediaKeySession2 no t collected');
104 // In non-Oilpan, there is also something from createGCPromi se(). 81 assert_equals(numMediaKeySessionCreated(), 0, 'mediaKeySessi on2 not collected');
105 assert_between_inclusive(numSuspendableObjectsCreated(), 1, 2, 'mediaKeySession2 not collected');
106 test.done(); 82 test.done();
107 }).catch(function(error) { 83 }).catch(function(error) {
108 forceTestFailureFromPromise(test, error); 84 forceTestFailureFromPromise(test, error);
109 }); 85 });
110 }, 'MediaKeySession lifetime after release()'); 86 }, 'MediaKeySession lifetime after release()');
111 </script> 87 </script>
112 </body> 88 </body>
113 </html> 89 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698