OLD | NEW |
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 <div id="log"></div> | 10 <div id="log"></div> |
(...skipping 23 matching lines...) Expand all Loading... |
34 initDataType = type; | 34 initDataType = type; |
35 initData = getInitData(initDataType); | 35 initData = getInitData(initDataType); |
36 return navigator.requestMediaKeySystemAccess('org.w3.clearke
y', [{}]); | 36 return navigator.requestMediaKeySystemAccess('org.w3.clearke
y', [{}]); |
37 }).then(function(access) { | 37 }).then(function(access) { |
38 return access.createMediaKeys(); | 38 return access.createMediaKeys(); |
39 }).then(function(result) { | 39 }).then(function(result) { |
40 mediaKeys = result; | 40 mediaKeys = result; |
41 | 41 |
42 // Verify MediaKeys are not an ActiveDOMObject. | 42 // Verify MediaKeys are not an ActiveDOMObject. |
43 // In non-Oilpan, numActiveDOMObjectsCreate() == 0. | 43 // In non-Oilpan, numActiveDOMObjectsCreate() == 0. |
44 // In Oilpan, numActiveDOMObjectsCreate() <= 2. | 44 // In Oilpan, numActiveDOMObjectsCreate() <= 3. |
45 // (1 MediaKeysInitializer and | 45 // (1 MediaKeysInitializer and |
46 // 1 MediaKeySystemAccessInitializer). | 46 // 1 MediaKeySystemAccessInitializer (navigator.requestMedi
aKeySystemAccess() use above), |
47 assert_less_than_equal(numActiveDOMObjectsCreated(), 2, 'Med
iaKeys.create()'); | 47 // 1 MediaKeySystemAccessInitializer (isInitDataSupported()
(via getSupportedInitDataType()))) |
| 48 assert_less_than_equal(numActiveDOMObjectsCreated(), 3, 'Med
iaKeys.create()'); |
48 | 49 |
49 mediaKeySession1 = mediaKeys.createSession(); | 50 mediaKeySession1 = mediaKeys.createSession(); |
50 return mediaKeySession1.generateRequest(initDataType, initDa
ta); | 51 return mediaKeySession1.generateRequest(initDataType, initDa
ta); |
51 }).then(function() { | 52 }).then(function() { |
52 // Should be 1 MediaKeySession. | 53 // Should be 1 MediaKeySession. |
53 // In non-Oilpan, numActiveDOMObjectsCreate() == 1. | 54 // In non-Oilpan, numActiveDOMObjectsCreate() == 1. |
54 // In Oilpan, numActiveDOMObjectsCreate() <= 4. | 55 // In Oilpan, numActiveDOMObjectsCreate() <= 5. |
55 // (1 MediaKeysInitializer, | 56 // (1 MediaKeysInitializer, |
56 // 1 MediaKeySystemAccessInitializer, | 57 // 2 MediaKeySystemAccessInitializers, |
57 // 1 ContentDecryptionModuleResultPromise and | 58 // 1 ContentDecryptionModuleResultPromise and |
58 // 1 MediaKeySession). | 59 // 1 MediaKeySession). |
59 assert_less_than_equal(numActiveDOMObjectsCreated(), 4, 'Med
iaKeys.createSession(1)'); | 60 assert_less_than_equal(numActiveDOMObjectsCreated(), 5, 'Med
iaKeys.createSession(1)'); |
60 mediaKeySession2 = mediaKeys.createSession(); | 61 mediaKeySession2 = mediaKeys.createSession(); |
61 return mediaKeySession2.generateRequest(initDataType, initDa
ta); | 62 return mediaKeySession2.generateRequest(initDataType, initDa
ta); |
62 }).then(function() { | 63 }).then(function() { |
63 // Should be 2 MediaKeySessions. | 64 // Should be 2 MediaKeySessions. |
64 // In non-Oilpan, numActiveDOMObjectsCreate() == 2. | 65 // In non-Oilpan, numActiveDOMObjectsCreate() == 2. |
65 // In Oilpan, numActiveDOMObjectsCreate() <= 6. | 66 // In Oilpan, numActiveDOMObjectsCreate() <= 7. |
66 // (1 MediaKeysInitializer, | 67 // (1 MediaKeysInitializer, |
67 // 1 MediaKeySystemAccessInitializer, | 68 // 2 MediaKeySystemAccessInitializers, |
68 // 2 ContentDecryptionModuleResultPromise and | 69 // 2 ContentDecryptionModuleResultPromise and |
69 // 2 MediaKeySession). | 70 // 2 MediaKeySession). |
70 assert_less_than_equal(numActiveDOMObjectsCreated(), 6, 'med
iaKeys.createSession(2)'); | 71 assert_less_than_equal(numActiveDOMObjectsCreated(), 7, 'med
iaKeys.createSession(2)'); |
71 // Close the sessions. Once completed, only the JS | 72 // Close the sessions. Once completed, only the JS |
72 // reference to them keeps them around. | 73 // reference to them keeps them around. |
73 return mediaKeySession1.close(); | 74 return mediaKeySession1.close(); |
74 }).then(function(result) { | 75 }).then(function(result) { |
75 return mediaKeySession2.close(); | 76 return mediaKeySession2.close(); |
76 }).then(function(result) { | 77 }).then(function(result) { |
77 // Since both sessions have been closed, dropping the | 78 // Since both sessions have been closed, dropping the |
78 // reference to them from JS will result in the session | 79 // reference to them from JS will result in the session |
79 // being garbage-collected. | 80 // being garbage-collected. |
80 // Should be 2 MediaKeySessions. | 81 // Should be 2 MediaKeySessions. |
81 // In non-Oilpan, numActiveDOMObjectsCreate() == 2. | 82 // In non-Oilpan, numActiveDOMObjectsCreate() == 2. |
82 // In Oilpan, numActiveDOMObjectsCreate() <= 8. | 83 // In Oilpan, numActiveDOMObjectsCreate() <= 9. |
83 // (1 MediaKeysInitializer, | 84 // (1 MediaKeysInitializer, |
84 // 1 MediaKeySystemAccessInitializer, | 85 // 2 MediaKeySystemAccessInitializers, |
85 // 4 ContentDecryptionModuleResultPromise and | 86 // 4 ContentDecryptionModuleResultPromise and |
86 // 2 MediaKeySession). | 87 // 2 MediaKeySession). |
87 assert_less_than_equal(numActiveDOMObjectsCreated(), 8, 'aft
er close'); | 88 assert_less_than_equal(numActiveDOMObjectsCreated(), 9, 'aft
er close'); |
88 | 89 |
89 mediaKeySession1 = null; | 90 mediaKeySession1 = null; |
90 return createGCPromise(); | 91 return createGCPromise(); |
91 }).then(function(result) { | 92 }).then(function(result) { |
92 // Only mediaKeySession2 should remain. | 93 // Only mediaKeySession2 should remain. |
93 assert_less_than_equal(numActiveDOMObjectsCreated(), 2, 'med
iaKeySession1 not collected'); | 94 assert_less_than_equal(numActiveDOMObjectsCreated(), 2, 'med
iaKeySession1 not collected'); |
94 | 95 |
95 mediaKeySession2 = null; | 96 mediaKeySession2 = null; |
96 return createGCPromise(); | 97 return createGCPromise(); |
97 }).then(function(result) { | 98 }).then(function(result) { |
98 assert_less_than_equal(numActiveDOMObjectsCreated(), 1, 'med
iaKeySession2 not collected'); | 99 assert_less_than_equal(numActiveDOMObjectsCreated(), 1, 'med
iaKeySession2 not collected'); |
99 test.done(); | 100 test.done(); |
100 }).catch(function(error) { | 101 }).catch(function(error) { |
101 forceTestFailureFromPromise(test, error); | 102 forceTestFailureFromPromise(test, error); |
102 }); | 103 }); |
103 }, 'MediaKeySession lifetime after release()'); | 104 }, 'MediaKeySession lifetime after release()'); |
104 </script> | 105 </script> |
105 </body> | 106 </body> |
106 </html> | 107 </html> |
OLD | NEW |