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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/setmediakeys.js

Issue 2546853003: Add W3C encrypted-media tests (Closed)
Patch Set: rebase now that content files landed Created 4 years 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
(Empty)
1 function runTest(config, qualifier) {
2 var testname = testnamePrefix( qualifier, config.keysystem )
3 + ', setMediaKeys';
4
5 var configuration = getSimpleConfigurationForContent( config.content );
6
7 if ( config.initDataType && config.initData ) {
8 configuration.initDataTypes = [ config.initDataType ];
9 }
10
11 async_test (function (test) {
12 var _video = config.video,
13 _mediaKeys;
14
15 // Test MediaKeys assignment.
16 assert_equals(_video.mediaKeys, null);
17 assert_equals(typeof _video.setMediaKeys, 'function');
18
19 function onFailure(error) {
20 forceTestFailureFromPromise(test, error);
21 }
22
23 // Try setting mediaKeys to null.
24 _video.setMediaKeys(null).then(function(result) {
25 assert_equals(_video.mediaKeys, null);
26
27 // setMediaKeys should fail when setting to the wrong type of object - Date.
28 return _video.setMediaKeys(new Date());
29 }).then(function (result) {
30 assert_unreached('setMediaKeys should fail when setting to wrong kin d of object (Date)');
31 }, function(error) {
32 // The error should be TypeError.
33 assert_equals(error.name, 'TypeError', 'setMediaKeys should return a TypeError when setting to wrong kind of object (Date)');
34 return navigator.requestMediaKeySystemAccess(config.keysystem, [conf iguration]);
35 }).then(function(access) {
36 assert_equals(access.keySystem, config.keysystem)
37 return access.createMediaKeys();
38 }).then(function(result) {
39 _mediaKeys = result;
40 assert_not_equals(_mediaKeys, null);
41 assert_equals(typeof _mediaKeys.createSession, 'function');
42 return _video.setMediaKeys(_mediaKeys);
43 }).then(function(result) {
44 assert_not_equals(_video.mediaKeys, null);
45 assert_equals(_video.mediaKeys, _mediaKeys);
46 test.done();
47 }).catch(onFailure);
48 }, testname);
49 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698