4 <title>Test MediaKeySession not callable immediately after CreateSession().
</title>
5 <script src=
"encrypted-media-utils.js"></script>
6 <script src=
"../../resources/testharness.js"></script>
7 <script src=
"../../resources/testharnessreport.js"></script>
12 // After creation, the MediaKeySession object is not
13 // callable, and we should get a InvalidStateError.
15 promise_test(function()
17 return navigator
.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).then(function(access
) {
18 return access
.createMediaKeys();
19 }).then(function(mediaKeys
) {
20 var mediaKeySession
= mediaKeys
.createSession();
22 var arbitraryResponse
= new Uint8Array([0x00, 0x11]);
23 return mediaKeySession
.update(arbitraryResponse
).then(function(result
) {
24 assert_unreached('update() succeeded unexpectedly.');
25 }).catch(function(error
) {
26 assert_equals(error
.name
, 'InvalidStateError');
29 }, 'Update() immediately after CreateSession().');
31 promise_test(function()
33 return navigator
.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).then(function(access
) {
34 return access
.createMediaKeys();
35 }).then(function(mediaKeys
) {
36 var mediaKeySession
= mediaKeys
.createSession();
38 return mediaKeySession
.close().then(function(result
) {
39 assert_unreached('close() succeeded unexpectedly.');
40 }).catch(function(error
) {
41 assert_equals(error
.name
, 'InvalidStateError');
44 }, 'Close() immediately after CreateSession().');
46 promise_test(function()
48 return navigator
.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).then(function(access
) {
49 return access
.createMediaKeys();
50 }).then(function(mediaKeys
) {
51 var mediaKeySession
= mediaKeys
.createSession();
53 return mediaKeySession
.remove().then(function(result
) {
54 assert_unreached('remove() succeeded unexpectedly.');
55 }).catch(function(error
) {
56 assert_equals(error
.name
, 'InvalidStateError');
59 }, 'Remove() immediately after CreateSession().');