From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../scripts/generate-request-disallowed-input.js | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 testing/web-platform/tests/encrypted-media/scripts/generate-request-disallowed-input.js (limited to 'testing/web-platform/tests/encrypted-media/scripts/generate-request-disallowed-input.js') diff --git a/testing/web-platform/tests/encrypted-media/scripts/generate-request-disallowed-input.js b/testing/web-platform/tests/encrypted-media/scripts/generate-request-disallowed-input.js new file mode 100644 index 0000000000..9fd42ee85f --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/scripts/generate-request-disallowed-input.js @@ -0,0 +1,72 @@ +function runTest(config,qualifier) { + var tests = [ ], initData, keyId; + function push_test(keysystem, initDataType, initData, testname) { + tests.push({ keysystem: keysystem, initDataType: initDataType, initData: initData, testname: testname }); + } + + initData = new Uint8Array(70000); + push_test(config.keysystem, 'webm', initData, testnamePrefix( qualifier, config.keysystem ) + ', temporary, webm, initData longer than 64Kb characters'); + + initData = new Uint8Array(70000); + push_test(config.keysystem, 'cenc', initData, testnamePrefix( qualifier, config.keysystem ) + ', temporary, cenc, initData longer than 64Kb characters'); + + initData = new Uint8Array(70000); + push_test(config.keysystem, 'keyids', initData, testnamePrefix( qualifier, config.keysystem ) + ', temporary, keyids, initData longer than 64Kb characters'); + + // Invalid 'pssh' box as the size specified is larger than what + // is provided. + initData = new Uint8Array([ + 0x00, 0x00, 0xff, 0xff, // size = huge + 0x70, 0x73, 0x73, 0x68, // 'pssh' + 0x00, // version = 0 + 0x00, 0x00, 0x00, // flags + 0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02, // Common SystemID + 0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B, + 0x00, 0x00, 0x00, 0x00 // datasize + ]); + push_test(config.keysystem, 'cenc', initData, testnamePrefix( qualifier, config.keysystem ) + ', temporary, cenc, invalid initdata (invalid pssh)'); + + // Invalid data as type = 'psss'. + initData = new Uint8Array([ + 0x00, 0x00, 0x00, 0x00, // size = 0 + 0x70, 0x73, 0x73, 0x73, // 'psss' + 0x00, // version = 0 + 0x00, 0x00, 0x00, // flags + 0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02, // Common SystemID + 0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B, + 0x00, 0x00, 0x00, 0x00 // datasize + ]); + push_test(config.keysystem, 'cenc', initData, testnamePrefix( qualifier, config.keysystem ) + ', temporary, cenc, invalid initdata (not pssh)'); + + // Valid key ID size must be at least 1 character for keyids. + keyId = new Uint8Array(0); + initData = stringToUint8Array(createKeyIDs(keyId)); + push_test(config.keysystem, 'keyids', initData, testnamePrefix( qualifier, config.keysystem ) + ', temporary, keyids, invalid initdata (too short key ID)'); + + // Valid key ID size must be less than 512 characters for keyids. + keyId = new Uint8Array(600); + initData = stringToUint8Array(createKeyIDs(keyId)); + push_test(config.keysystem, 'keyids', initData, testnamePrefix( qualifier, config.keysystem ) + ', temporary, keyids, invalid initdata (too long key ID)'); + + Promise.all( tests.map(function(testspec) { + return isInitDataTypeSupported(testspec.keysystem,testspec.initDataType); + })).then(function(results) { + tests.filter(function(testspec, i) { return results[i]; } ).forEach(function(testspec) { + promise_test(function(test) { + // Create a "temporary" session for |keysystem| and call generateRequest() + // with the provided initData. generateRequest() should fail with an + // TypeError. Returns a promise that is resolved + // if the error occurred and rejected otherwise. + var p = navigator.requestMediaKeySystemAccess(testspec.keysystem, getSimpleConfigurationForInitDataType(testspec.initDataType)).then(function(access) { + return access.createMediaKeys(); + }).then(function(mediaKeys) { + var mediaKeySession = mediaKeys.createSession("temporary"); + return mediaKeySession.generateRequest(testspec.initDataType, testspec.initData); + }); + + return promise_rejects_js(test, TypeError, p, + "generateRequest() should fail"); + }, testspec.testname); + }); + }); +} -- cgit v1.2.3