OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Test MediaKeySession lifetime without release()</title> | 4 <title>Test MediaKeySession lifetime without 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 26 matching lines...) Expand all Loading... |
37 return navigator.requestMediaKeySystemAccess('org.w3.clearke
y', [{}]); | 37 return navigator.requestMediaKeySystemAccess('org.w3.clearke
y', [{}]); |
38 }).then(function(access) { | 38 }).then(function(access) { |
39 assert_equals(access.keySystem, 'org.w3.clearkey'); | 39 assert_equals(access.keySystem, 'org.w3.clearkey'); |
40 return access.createMediaKeys(); | 40 return access.createMediaKeys(); |
41 }).then(function(result) { | 41 }).then(function(result) { |
42 mediaKeys = result; | 42 mediaKeys = result; |
43 assert_equals(typeof mediaKeys.createSession, 'function'); | 43 assert_equals(typeof mediaKeys.createSession, 'function'); |
44 | 44 |
45 // Verify MediaKeys are not an ActiveDOMObject. | 45 // Verify MediaKeys are not an ActiveDOMObject. |
46 // In non-Oilpan, numActiveDOMObjectsCreate() == 0. | 46 // In non-Oilpan, numActiveDOMObjectsCreate() == 0. |
47 // In Oilpan, numActiveDOMObjetsCreated() <= 2. | 47 // In Oilpan, numActiveDOMObjetsCreated() <= 3. |
48 // (1 MediaKeysInitializer and | 48 // (1 MediaKeysInitializer and |
49 // 1 MediaKeySystemAccessInitializer). | 49 // 1 MediaKeySystemAccessInitializer (navigator.requestMedi
aKeySystemAccess() use above), |
50 assert_less_than_equal(numActiveDOMObjectsCreated(), 2, 'Med
iaKeys.create()'); | 50 // 1 MediaKeySystemAccessInitializer (isInitDataSupported()
(via getSupportedInitDataType()))) |
| 51 assert_less_than_equal(numActiveDOMObjectsCreated(), 3, 'Med
iaKeys.create()'); |
51 | 52 |
52 // Create 3 sessions. | 53 // Create 3 sessions. |
53 mediaKeySession1 = mediaKeys.createSession(); | 54 mediaKeySession1 = mediaKeys.createSession(); |
54 return mediaKeySession1.generateRequest(initDataType, initDa
ta); | 55 return mediaKeySession1.generateRequest(initDataType, initDa
ta); |
55 }).then(function() { | 56 }).then(function() { |
56 assert_true(mediaKeySession1.sessionId && mediaKeySession1.s
essionId.length > 0); | 57 assert_true(mediaKeySession1.sessionId && mediaKeySession1.s
essionId.length > 0); |
57 // Should be 1 MediaKeySession. | 58 // Should be 1 MediaKeySession. |
58 // In non-Oilpan, numActiveDOMObjectsCreate() == 1. | 59 // In non-Oilpan, numActiveDOMObjectsCreate() == 1. |
59 // In Oilpan, numActiveDOMObjectsCreated() <= 4. | 60 // In Oilpan, numActiveDOMObjectsCreated() <= 5. |
60 // (1 MediaKeysInitializer, | 61 // (1 MediaKeysInitializer, |
61 // 1 MediaKeySystemAccessInitializer, | 62 // 2 MediaKeySystemAccessInitializers, |
62 // 1 ContentDecryptionModuleResultPromise and | 63 // 1 ContentDecryptionModuleResultPromise and |
63 // 1 MediaKeySession). | 64 // 1 MediaKeySession). |
64 assert_less_than_equal(numActiveDOMObjectsCreated(), 4, 'Med
iaKeys.createSession(1)'); | 65 assert_less_than_equal(numActiveDOMObjectsCreated(), 5, 'Med
iaKeys.createSession(1)'); |
65 mediaKeySession2 = mediaKeys.createSession(); | 66 mediaKeySession2 = mediaKeys.createSession(); |
66 return mediaKeySession2.generateRequest(initDataType, initDa
ta); | 67 return mediaKeySession2.generateRequest(initDataType, initDa
ta); |
67 }).then(function() { | 68 }).then(function() { |
68 assert_true(mediaKeySession2.sessionId && mediaKeySession2.s
essionId.length > 0); | 69 assert_true(mediaKeySession2.sessionId && mediaKeySession2.s
essionId.length > 0); |
69 // Should be 2 MediaKeySessions. | 70 // Should be 2 MediaKeySessions. |
70 // In non-Oilpan, numActiveDOMObjectsCreate() == 2. | 71 // In non-Oilpan, numActiveDOMObjectsCreate() == 2. |
71 // In Oilpan, numActiveDOMObjectsCreate() <= 6. | 72 // In Oilpan, numActiveDOMObjectsCreate() <= 7. |
72 // (1 MediaKeysInitializer, | 73 // (1 MediaKeysInitializer, |
73 // 1 MediaKeySystemAccessInitializer, | 74 // 2 MediaKeySystemAccessInitializers, |
74 // 2 ContentDecryptionModuleResultPromise and | 75 // 2 ContentDecryptionModuleResultPromise and |
75 // 2 MediaKeySession). | 76 // 2 MediaKeySession). |
76 assert_less_than_equal(numActiveDOMObjectsCreated(), 6, 'med
iaKeys.createSession(2)'); | 77 assert_less_than_equal(numActiveDOMObjectsCreated(), 7, 'med
iaKeys.createSession(2)'); |
77 mediaKeySession3 = mediaKeys.createSession(); | 78 mediaKeySession3 = mediaKeys.createSession(); |
78 return mediaKeySession3.generateRequest(initDataType, initDa
ta); | 79 return mediaKeySession3.generateRequest(initDataType, initDa
ta); |
79 }).then(function() { | 80 }).then(function() { |
80 assert_true(mediaKeySession3.sessionId && mediaKeySession3.s
essionId.length > 0); | 81 assert_true(mediaKeySession3.sessionId && mediaKeySession3.s
essionId.length > 0); |
81 // Should be 3 MediaKeySessions. | 82 // Should be 3 MediaKeySessions. |
82 // In non-Oilpan, numActiveDOMObjectsCreate() == 3. | 83 // In non-Oilpan, numActiveDOMObjectsCreate() == 3. |
83 // In Oilpan, numActiveDOMObjectsCreate() <= 8. | 84 // In Oilpan, numActiveDOMObjectsCreate() <= 9. |
84 // (1 MediaKeysInitializer, | 85 // (1 MediaKeysInitializer, |
85 // 1 MediaKeySystemAccessInitializer, | 86 // 2 MediaKeySystemAccessInitializers, |
86 // 3 ContentDecryptionModuleResultPromise and | 87 // 3 ContentDecryptionModuleResultPromise and |
87 // 3 MediaKeySession). | 88 // 3 MediaKeySession). |
88 // numActiveDOMObjectsCreated() <= 8 (ditto) | 89 // numActiveDOMObjectsCreated() <= 9 (ditto) |
89 assert_less_than_equal(numActiveDOMObjectsCreated(), 8, 'med
iaKeys.createSession(3)'); | 90 assert_less_than_equal(numActiveDOMObjectsCreated(), 9, 'med
iaKeys.createSession(3)'); |
90 | 91 |
91 // Run gc(). All sessions should remain as we have a | 92 // Run gc(). All sessions should remain as we have a |
92 // reference to each one. However, running gc() | 93 // reference to each one. However, running gc() |
93 // asynchronously should free up the last PromiseResolver. | 94 // asynchronously should free up the last PromiseResolver. |
94 return createGCPromise(); | 95 return createGCPromise(); |
95 }).then(function(result) { | 96 }).then(function(result) { |
96 assert_less_than_equal(numActiveDOMObjectsCreated(), 4, 'Aft
er gc()'); | 97 assert_less_than_equal(numActiveDOMObjectsCreated(), 4, 'Aft
er gc()'); |
97 | 98 |
98 // Now drop references to 2 of the sessions. Even though we | 99 // Now drop references to 2 of the sessions. Even though we |
99 // don't have a reference, MediaKeys is still around (and | 100 // don't have a reference, MediaKeys is still around (and |
(...skipping 29 matching lines...) Expand all Loading... |
129 }).then(function(result) { | 130 }).then(function(result) { |
130 assert_less_than_equal(numActiveDOMObjectsCreated(), 1); | 131 assert_less_than_equal(numActiveDOMObjectsCreated(), 1); |
131 test.done(); | 132 test.done(); |
132 }).catch(function(error) { | 133 }).catch(function(error) { |
133 forceTestFailureFromPromise(test, error); | 134 forceTestFailureFromPromise(test, error); |
134 }); | 135 }); |
135 }, 'MediaKeySession lifetime without release()'); | 136 }, 'MediaKeySession lifetime without release()'); |
136 </script> | 137 </script> |
137 </body> | 138 </body> |
138 </html> | 139 </html> |
OLD | NEW |