Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / media / encrypted-media / encrypted-media-lifetime-mediakeys.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4         <title>Test MediaKeys lifetime</title>
5         <script src="encrypted-media-utils.js"></script>
6         <script src="../../resources/testharness.js"></script>
7         <script src="../../resources/testharnessreport.js"></script>
8     </head>
9     <body>
10         <div id="log"></div>
11         <script>
12             async_test(function(test)
13             {
14                 // Create a MediaKeys object and free immediately.
15                 MediaKeys.create('org.w3.clearkey').then(function(result) {
16                     // Do nothing with the created object
17                 }).then(function(result) {
18                     // No way to verify that MediaKeys object is actually
19                     // collected, but make sure it doesn't crash.
20                     return createGCPromise();
21                 }).then(function(result) {
22                     test.done();
23                 }).catch(function(error) {
24                     forceTestFailureFromPromise(test, error);
25                 });
26             }, 'Creating and destroying MediaKeys does not crash');
27
28             async_test(function(test)
29             {
30                 var mediaKeys;
31                 MediaKeys.create('org.w3.clearkey').then(function(result) {
32                     mediaKeys = result;
33                     return createGCPromise();
34                 }).then(function(result) {
35                     // Check that the object still exists.
36                     assert_equals(mediaKeys.keySystem, 'org.w3.clearkey');
37                     mediaKeys = null;
38
39                     // Now that the reference is dropped, it should be
40                     // collected. No way to verify that it is actually
41                     // collected, but make sure it doesn't crash.
42                     return createGCPromise();
43                 }).then(function(result) {
44                     test.done();
45                 }).catch(function(error) {
46                     forceTestFailureFromPromise(test, error);
47                 });
48             }, 'MediaKeys is not collected as long as we have a reference');
49         </script>
50     </body>
51 </html>