OLD | NEW |
(Empty) | |
| 1 // This test is only applicable to clearkey |
| 2 function runTest(config, qualifier) |
| 3 { |
| 4 var testname = testnamePrefix(qualifier, config.keysystem) + ' test handling
of non-ASCII responses for update()'; |
| 5 |
| 6 var configuration = getSimpleConfigurationForContent(config.content); |
| 7 |
| 8 if (config.initDataType) { |
| 9 configuration.initDataTypes = [config.initDataType]; |
| 10 } |
| 11 |
| 12 promise_test(function (test) { |
| 13 var initDataType; |
| 14 var initData; |
| 15 var mediaKeySession; |
| 16 var messageEventFired = false; |
| 17 |
| 18 return navigator.requestMediaKeySystemAccess(config.keysystem, [configur
ation]).then(function (access) { |
| 19 initDataType = access.getConfiguration().initDataTypes[0]; |
| 20 initData = getInitData(config.content, initDataType); |
| 21 return access.createMediaKeys(); |
| 22 }).then(function (mediaKeys) { |
| 23 mediaKeySession = mediaKeys.createSession(); |
| 24 var eventWatcher = new EventWatcher(test, mediaKeySession, ['message
']); |
| 25 var promise = eventWatcher.wait_for('message'); |
| 26 mediaKeySession.generateRequest(initDataType, initData); |
| 27 return promise; |
| 28 }).then(function (messageEvent) { |
| 29 // |jwkSet| contains a non-ASCII character \uDC00. |
| 30 var jwkSet = '{"keys":[{' |
| 31 + '"kty":"oct",' |
| 32 + '"k":"MDEyMzQ1Njc4OTAxMjM0NQ",' |
| 33 + '"kid":"MDEyMzQ1Njc4O\uDC00TAxMjM0NQ"' |
| 34 + '}]}'; |
| 35 messageEventFired = true; |
| 36 return messageEvent.target.update(stringToUint8Array(jwkSet)); |
| 37 }).then(function () { |
| 38 assert_unreached('Error: update() should fail because the processed
message has non-ASCII character.'); |
| 39 }).catch(function (error) { |
| 40 if(messageEventFired){ |
| 41 assert_equals(error.name, 'TypeError'); |
| 42 } |
| 43 else { |
| 44 assert_unreached('Error: ' + error.name); |
| 45 } |
| 46 }); |
| 47 }, testname); |
| 48 } |
OLD | NEW |