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

Side by Side Diff: LayoutTests/media/encrypted-media/encrypted-media-lifetime-multiple-mediakeys.html

Issue 665213002: Implement navigator.requestMediaKeySystemAccess() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add comment Created 6 years, 1 month 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>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 26 matching lines...) Expand all
37 { 37 {
38 return window.internals.activeDOMObjectCount(document) - sta rtingActiveDOMObjectCount; 38 return window.internals.activeDOMObjectCount(document) - sta rtingActiveDOMObjectCount;
39 } 39 }
40 40
41 // Create a MediaKeys object and an associated MediaKeySession 41 // Create a MediaKeys object and an associated MediaKeySession
42 // object. |mediaKeys| is updated to refer to the new MediaKeys 42 // object. |mediaKeys| is updated to refer to the new MediaKeys
43 // object. Returns a promise that resolves with the new 43 // object. Returns a promise that resolves with the new
44 // MediaKeySession object. 44 // MediaKeySession object.
45 function createMediaKeyWithMediaKeySession() 45 function createMediaKeyWithMediaKeySession()
46 { 46 {
47 return MediaKeys.create('org.w3.clearkey').then(function(res ult) { 47 return navigator.requestMediaKeySystemAccess('org.w3.clearke y').then(function(access) {
48 return access.createMediaKeys();
49 }).then(function(result) {
48 mediaKeys = result; 50 mediaKeys = result;
49 var mediaKeySession = mediaKeys.createSession(); 51 var mediaKeySession = mediaKeys.createSession();
50 return mediaKeySession.generateRequest(initDataType, ini tData).then(function() { 52 return mediaKeySession.generateRequest(initDataType, ini tData).then(function() {
51 return mediaKeySession; 53 return mediaKeySession;
52 }); 54 });
53 }); 55 });
54 } 56 }
55 57
56 // Create a few MediaKeys + MediaKeySession objects. Only keep 58 // Create a few MediaKeys + MediaKeySession objects. Only keep
57 // a reference to the last one created. 59 // a reference to the last one created.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // MediaKeySession object first, and doesn't collect it 100 // MediaKeySession object first, and doesn't collect it
99 // since MediaKeys hasn't been collected yet. Thus run gc() 101 // since MediaKeys hasn't been collected yet. Thus run gc()
100 // twice, to ensure that the unreferenced MediaKeySession 102 // twice, to ensure that the unreferenced MediaKeySession
101 // objects get collected. 103 // objects get collected.
102 return createGCPromise(); 104 return createGCPromise();
103 }).then(function(result) { 105 }).then(function(result) {
104 return createGCPromise(); 106 return createGCPromise();
105 }).then(function(result) { 107 }).then(function(result) {
106 // Should be 1 MediaKeySession, the session for |mediaKeys|. 108 // Should be 1 MediaKeySession, the session for |mediaKeys|.
107 assert_equals(numActiveDOMObjectsCreated(), 1); 109 assert_equals(numActiveDOMObjectsCreated(), 1);
108 assert_equals(mediaKeys.keySystem, 'org.w3.clearkey'); 110 assert_equals(typeof mediaKeys.createSession, 'function');
109 111
110 // Release the last MediaKeys object created. 112 // Release the last MediaKeys object created.
111 mediaKeys = null; 113 mediaKeys = null;
112 114
113 // Run gc() again to reclaim the remaining MediaKeys object 115 // Run gc() again to reclaim the remaining MediaKeys object
114 // and the last MediaKeySession. gc() run twice in case 116 // and the last MediaKeySession. gc() run twice in case
115 // MediaKeySession checked first and not collected in the 117 // MediaKeySession checked first and not collected in the
116 // first pass. 118 // first pass.
117 return createGCPromise(); 119 return createGCPromise();
118 }).then(function(result) { 120 }).then(function(result) {
119 return createGCPromise(); 121 return createGCPromise();
120 }).then(function(result) { 122 }).then(function(result) {
121 assert_equals(numActiveDOMObjectsCreated(), 0); 123 assert_equals(numActiveDOMObjectsCreated(), 0);
122 test.done(); 124 test.done();
123 }).catch(function(error) { 125 }).catch(function(error) {
124 forceTestFailureFromPromise(test, error); 126 forceTestFailureFromPromise(test, error);
125 }); 127 });
126 }, 'Multiple MediaKeys lifetime'); 128 }, 'Multiple MediaKeys lifetime');
127 </script> 129 </script>
128 </body> 130 </body>
129 </html> 131 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698