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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/temporary-license-type.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
3 var testname = testnamePrefix(qualifier, config.keysystem) + ', cannot load persistent license into temporary session';
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 {
13 var initDataType;
14 var initData;
15 var mediaKeySession;
16
17 function onFailure(error) {
18 forceTestFailureFromPromise(test, error);
19 }
20
21 function processMessage(event)
22 {
23 assert_true(event instanceof window.MediaKeyMessageEvent);
24 assert_equals(event.target, mediaKeySession);
25 assert_equals(event.type, 'message');
26 assert_in_array(event.messageType, ['license-request', 'individualiz ation-request']);
27
28 config.messagehandler(event.messageType, event.message).then( functi on(response) {
29 mediaKeySession.update(response).then( test.step_func( function( ) {
30 if ( event.messageType !== 'license-request' ) {
31 return;
32 }
33 assert_unreached( "Update with incorrect license type should fail" )
34 } ) ).catch( test.step_func( function( error ) {
35 if ( event.messageType !== 'license-request' ) {
36 forceTestFailureFromPromise(test, error);
37 return;
38 }
39
40 assert_equals(error.name, 'TypeError' );
41 test.done();
42 } ) );
43 }).catch(onFailure);
44 }
45
46 navigator.requestMediaKeySystemAccess(config.keysystem, [configuration]) .then(function(access) {
47 initDataType = access.getConfiguration().initDataTypes[0];
48 if (config.initDataType && config.initData) {
49 initData = config.initData;
50 } else {
51 initData = getInitData(config.content, initDataType);
52 }
53 return access.createMediaKeys();
54 }).then(test.step_func(function(mediaKeys) {
55 mediaKeySession = mediaKeys.createSession('temporary');
56 waitForEventAndRunStep('message', mediaKeySession, test.step_func(pr ocessMessage), test);
57 return mediaKeySession.generateRequest(initDataType, initData);
58 })).catch(onFailure);
59 }, testname );
60
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698