OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Test MediaKeys lifetime when adding a session</title> | 4 <title>Test MediaKeys lifetime when adding a session</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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 initData = getInitData(initDataType); | 42 initData = getInitData(initDataType); |
43 return navigator.requestMediaKeySystemAccess('org.w3.clearke
y', [{}]); | 43 return navigator.requestMediaKeySystemAccess('org.w3.clearke
y', [{}]); |
44 }).then(function(access) { | 44 }).then(function(access) { |
45 assert_equals(access.keySystem, 'org.w3.clearkey'); | 45 assert_equals(access.keySystem, 'org.w3.clearkey'); |
46 return access.createMediaKeys(); | 46 return access.createMediaKeys(); |
47 }).then(function(result) { | 47 }).then(function(result) { |
48 mediaKeys = result; | 48 mediaKeys = result; |
49 | 49 |
50 // Verify MediaKeys are not an ActiveDOMObject. | 50 // Verify MediaKeys are not an ActiveDOMObject. |
51 // In non-Oilpan, numActiveDOMObjectsCreate() == 0. | 51 // In non-Oilpan, numActiveDOMObjectsCreate() == 0. |
52 // In Oilpan, numActiveDOMObjectsCreate() <= 2. | 52 // In Oilpan, numActiveDOMObjectsCreate() <= 3. |
53 // (1 MediaKeysInitializer and | 53 // (1 MediaKeysInitializer and |
54 // 1 MediaKeySystemAccessInitializer). | 54 // 1 MediaKeySystemAccessInitializer (navigator.requestMedi
aKeySystemAccess() use above), |
55 assert_less_than_equal(numActiveDOMObjectsCreated(), 2, 'Med
iaKeys.create()'); | 55 // 1 MediaKeySystemAccessInitializer (isInitDataSupported()
(via getSupportedInitDataType()))) |
| 56 assert_less_than_equal(numActiveDOMObjectsCreated(), 3, 'Med
iaKeys.create()'); |
56 | 57 |
57 var mediaKeySession = mediaKeys.createSession(); | 58 var mediaKeySession = mediaKeys.createSession(); |
58 return mediaKeySession.generateRequest(initDataType, initDat
a); | 59 return mediaKeySession.generateRequest(initDataType, initDat
a); |
59 }).then(function() { | 60 }).then(function() { |
60 // 1 MediaKeySession. | 61 // 1 MediaKeySession. |
61 // In non-Oilpan, numActiveDOMObjectsCreate() == 1. | 62 // In non-Oilpan, numActiveDOMObjectsCreate() == 1. |
62 // In Oilpan, numActiveDOMObjectsCreate() <= 4. | 63 // In Oilpan, numActiveDOMObjectsCreate() <= 5. |
63 // (1 MediaKeysInitializer, | 64 // (1 MediaKeysInitializer, |
64 // 1 MediaKeySystemAccessInitializer, | 65 // 2 MediaKeySystemAccessInitializers, |
65 // 1 ContentDecryptionModuleResultPromise and | 66 // 1 ContentDecryptionModuleResultPromise and |
66 // 1 MediaKeySession). | 67 // 1 MediaKeySession). |
67 assert_less_than_equal(numActiveDOMObjectsCreated(), 4, 'Med
iaKeys.createSession(1)'); | 68 assert_less_than_equal(numActiveDOMObjectsCreated(), 5, 'Med
iaKeys.createSession(1)'); |
68 | 69 |
69 // Run gc(), should not affect MediaKeys object nor the | 70 // Run gc(), should not affect MediaKeys object nor the |
70 // session since we still have a reference to it. | 71 // session since we still have a reference to it. |
71 | 72 |
72 // When enabling oilpan GC, the in-active | 73 // When enabling oilpan GC, the in-active |
73 // ScriptPromiseResolvers will be destroyed. | 74 // ScriptPromiseResolvers will be destroyed. |
74 return createGCPromise(); | 75 return createGCPromise(); |
75 }).then(function(result) { | 76 }).then(function(result) { |
76 assert_equals(typeof mediaKeys.createSession, 'function'); | 77 assert_equals(typeof mediaKeys.createSession, 'function'); |
77 // Ensure that MediaKeySession (but not PromiseResolver) is | 78 // Ensure that MediaKeySession (but not PromiseResolver) is |
(...skipping 15 matching lines...) Expand all Loading... |
93 }).then(function(result) { | 94 }).then(function(result) { |
94 assert_less_than_equal(numActiveDOMObjectsCreated(), 1); | 95 assert_less_than_equal(numActiveDOMObjectsCreated(), 1); |
95 test.done(); | 96 test.done(); |
96 }).catch(function(error) { | 97 }).catch(function(error) { |
97 forceTestFailureFromPromise(test, error); | 98 forceTestFailureFromPromise(test, error); |
98 }); | 99 }); |
99 }, 'MediaKeys lifetime with session'); | 100 }, 'MediaKeys lifetime with session'); |
100 </script> | 101 </script> |
101 </body> | 102 </body> |
102 </html> | 103 </html> |
OLD | NEW |