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

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/generate-request-disallowed-input.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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/generate-request-disallowed-input.js
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/generate-request-disallowed-input.js b/third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/generate-request-disallowed-input.js
new file mode 100644
index 0000000000000000000000000000000000000000..8b883ccacff17468f98df5d9d704c494abbac51d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/generate-request-disallowed-input.js
@@ -0,0 +1,73 @@
+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.
+ return 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);
+ }).then(test.step_func(function() {
+ assert_unreached('generateRequest() succeeded unexpectedly');
+ }), test.step_func(function(error) {
+ assert_equals(error.name, 'TypeError');
+ }));
+ },testspec.testname);
+ });
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698