OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Test multiple MediaKeys lifetimes</title> | 4 <title>Test multiple MediaKeys lifetimes</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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 { | 46 { |
47 return MediaKeys.create('org.w3.clearkey').then(function(res
ult) { | 47 return MediaKeys.create('org.w3.clearkey').then(function(res
ult) { |
48 mediaKeys = result; | 48 mediaKeys = result; |
49 return mediaKeys.createSession(initDataType, initData); | 49 return mediaKeys.createSession(initDataType, initData); |
50 }); | 50 }); |
51 } | 51 } |
52 | 52 |
53 // Create a few MediaKeys + MediaKeySession objects. Only keep | 53 // Create a few MediaKeys + MediaKeySession objects. Only keep |
54 // a reference to the last one created. | 54 // a reference to the last one created. |
55 createMediaKeyWithMediaKeySession().then(function(mediaKeySessio
n) { | 55 createMediaKeyWithMediaKeySession().then(function(mediaKeySessio
n) { |
56 // Should be 1 MediaKeySession + 1 PromiseResolver for the | 56 // Should be 1 MediaKeySession. |
57 // MediaKeySession. | 57 assert_equals(numActiveDOMObjectsCreated(), 1); |
| 58 return createMediaKeyWithMediaKeySession(); |
| 59 }).then(function(mediaKeySession) { |
| 60 // Should be 2 MediaKeySessions. |
58 assert_equals(numActiveDOMObjectsCreated(), 2); | 61 assert_equals(numActiveDOMObjectsCreated(), 2); |
59 return createMediaKeyWithMediaKeySession(); | 62 return createMediaKeyWithMediaKeySession(); |
60 }).then(function(mediaKeySession) { | 63 }).then(function(mediaKeySession) { |
61 // Should be 2 MediaKeySessions + 1 PromiseResolver for the | 64 // Should be 3 MediaKeySessions. |
62 // latest MediaKeySession. | |
63 assert_equals(numActiveDOMObjectsCreated(), 3); | 65 assert_equals(numActiveDOMObjectsCreated(), 3); |
64 return createMediaKeyWithMediaKeySession(); | 66 return createMediaKeyWithMediaKeySession(); |
65 }).then(function(mediaKeySession) { | 67 }).then(function(mediaKeySession) { |
66 // Should be 3 MediaKeySessions + 1 PromiseResolver for the | 68 // Should be 4 MediaKeySessions. |
67 // latest MediaKeySession. | |
68 assert_equals(numActiveDOMObjectsCreated(), 4); | 69 assert_equals(numActiveDOMObjectsCreated(), 4); |
69 return createMediaKeyWithMediaKeySession(); | 70 return createMediaKeyWithMediaKeySession(); |
70 }).then(function(mediaKeySession) { | 71 }).then(function(mediaKeySession) { |
71 // Should be 4 MediaKeySessions + 1 PromiseResolver for the | 72 // Should be 5 MediaKeySessions. |
72 // latest MediaKeySession. | |
73 assert_equals(numActiveDOMObjectsCreated(), 5); | 73 assert_equals(numActiveDOMObjectsCreated(), 5); |
74 return createMediaKeyWithMediaKeySession(); | |
75 }).then(function(mediaKeySession) { | |
76 // Should be 5 MediaKeySessions + 1 PromiseResolver for the | |
77 // latest MediaKeySession. | |
78 assert_equals(numActiveDOMObjectsCreated(), 6); | |
79 | 74 |
80 // |mediaKeys| refers to the most recently created MediaKeys | 75 // |mediaKeys| refers to the most recently created MediaKeys |
81 // object. | 76 // object. |
82 // | 77 // |
83 // In order for the MediaKeySession objects to have no | 78 // In order for the MediaKeySession objects to have no |
84 // outstanding activity so that they can be garbage | 79 // outstanding activity so that they can be garbage |
85 // collected, it needs time to process any pending events. | 80 // collected, it needs time to process any pending events. |
86 // As a "message" event is generated when a new session is | 81 // As a "message" event is generated when a new session is |
87 // created, we need to allow the event to run (we're not | 82 // created, we need to allow the event to run (we're not |
88 // doing anything with the event in this test). | 83 // doing anything with the event in this test). |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 }).then(function(result) { | 117 }).then(function(result) { |
123 assert_equals(numActiveDOMObjectsCreated(), 0); | 118 assert_equals(numActiveDOMObjectsCreated(), 0); |
124 test.done(); | 119 test.done(); |
125 }).catch(function(error) { | 120 }).catch(function(error) { |
126 forceTestFailureFromPromise(test, error); | 121 forceTestFailureFromPromise(test, error); |
127 }); | 122 }); |
128 }, 'Multiple MediaKeys lifetime'); | 123 }, 'Multiple MediaKeys lifetime'); |
129 </script> | 124 </script> |
130 </body> | 125 </body> |
131 </html> | 126 </html> |
OLD | NEW |