Skip to content

Commit 843df1a

Browse files
panvaruyadorno
authored andcommitted
test,crypto: update WebCryptoAPI WPT
PR-URL: #49714 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 2cc5ad7 commit 843df1a

File tree

7 files changed

+10
-171
lines changed

7 files changed

+10
-171
lines changed

test/fixtures/wpt/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Last update:
3131
- user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing
3232
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi
3333
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
34-
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/17b7ca10fd/WebCryptoAPI
34+
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/f4e7e32fd0/WebCryptoAPI
3535
- webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions
3636
- webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/e97fac4791/webmessaging/broadcastchannel
3737

test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey.https.any.js

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
[true, false].forEach(function(extractable) {
7272

7373
// Test public keys first
74-
[[]].forEach(function(usages) { // Only valid usages argument is empty array
74+
allValidUsages(vector.publicUsages, true).forEach(function(usages) {
7575
['spki', 'spki_compressed', 'jwk', 'raw', 'raw_compressed'].forEach(function(format) {
7676
var algorithm = {name: vector.name, namedCurve: curve};
7777
var data = keyData[curve];
@@ -88,7 +88,7 @@
8888
['pkcs8', 'jwk'].forEach(function(format) {
8989
var algorithm = {name: vector.name, namedCurve: curve};
9090
var data = keyData[curve];
91-
allValidUsages(vector.privateUsages, []).forEach(function(usages) {
91+
allValidUsages(vector.privateUsages).forEach(function(usages) {
9292
testFormat(format, algorithm, data, curve, usages, extractable);
9393
});
9494
testEmptyUsages(format, algorithm, data, curve, extractable);
@@ -219,46 +219,6 @@
219219
return base64String.replace(/=/g, "");
220220
}
221221

222-
// Want to test every valid combination of usages. Start by creating a list
223-
// of all non-empty subsets to possible usages.
224-
function allNonemptySubsetsOf(arr) {
225-
var results = [];
226-
var firstElement;
227-
var remainingElements;
228-
229-
for(var i=0; i<arr.length; i++) {
230-
firstElement = arr[i];
231-
remainingElements = arr.slice(i+1);
232-
results.push([firstElement]);
233-
234-
if (remainingElements.length > 0) {
235-
allNonemptySubsetsOf(remainingElements).forEach(function(combination) {
236-
combination.push(firstElement);
237-
results.push(combination);
238-
});
239-
}
240-
}
241-
242-
return results;
243-
}
244-
245-
// Return a list of all valid usage combinations, given the possible ones
246-
// and the ones that are required for a particular operation.
247-
function allValidUsages(possibleUsages, requiredUsages) {
248-
var allUsages = [];
249-
250-
allNonemptySubsetsOf(possibleUsages).forEach(function(usage) {
251-
for (var i=0; i<requiredUsages.length; i++) {
252-
if (!usage.includes(requiredUsages[i])) {
253-
return;
254-
}
255-
}
256-
allUsages.push(usage);
257-
});
258-
259-
return allUsages;
260-
}
261-
262222
// Convert method parameters to a string to uniquely name each test
263223
function parameterString(format, compressed, data, algorithm, extractable, usages) {
264224
if ("byteLength" in data) {
@@ -311,4 +271,3 @@
311271

312272
return "{" + keyValuePairs.join(", ") + "}";
313273
}
314-

test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey.https.any.js

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
[true, false].forEach(function(extractable) {
7373

7474
// Test public keys first
75-
[[]].forEach(function(usages) { // Only valid usages argument is empty array
75+
allValidUsages(vector.publicUsages, true).forEach(function(usages) {
7676
['spki', 'jwk', 'raw'].forEach(function(format) {
7777
var algorithm = {name: vector.name};
7878
var data = keyData[vector.name];
@@ -86,7 +86,7 @@
8686
});
8787

8888
// Next, test private keys
89-
allValidUsages(vector.privateUsages, []).forEach(function(usages) {
89+
allValidUsages(vector.privateUsages).forEach(function(usages) {
9090
['pkcs8', 'jwk'].forEach(function(format) {
9191
var algorithm = {name: vector.name};
9292
var data = keyData[vector.name];
@@ -194,46 +194,6 @@
194194
return base64String.replace(/=/g, "");
195195
}
196196

197-
// Want to test every valid combination of usages. Start by creating a list
198-
// of all non-empty subsets to possible usages.
199-
function allNonemptySubsetsOf(arr) {
200-
var results = [];
201-
var firstElement;
202-
var remainingElements;
203-
204-
for(var i=0; i<arr.length; i++) {
205-
firstElement = arr[i];
206-
remainingElements = arr.slice(i+1);
207-
results.push([firstElement]);
208-
209-
if (remainingElements.length > 0) {
210-
allNonemptySubsetsOf(remainingElements).forEach(function(combination) {
211-
combination.push(firstElement);
212-
results.push(combination);
213-
});
214-
}
215-
}
216-
217-
return results;
218-
}
219-
220-
// Return a list of all valid usage combinations, given the possible ones
221-
// and the ones that are required for a particular operation.
222-
function allValidUsages(possibleUsages, requiredUsages) {
223-
var allUsages = [];
224-
225-
allNonemptySubsetsOf(possibleUsages).forEach(function(usage) {
226-
for (var i=0; i<requiredUsages.length; i++) {
227-
if (!usage.includes(requiredUsages[i])) {
228-
return;
229-
}
230-
}
231-
allUsages.push(usage);
232-
});
233-
234-
return allUsages;
235-
}
236-
237197
// Convert method parameters to a string to uniquely name each test
238198
function parameterString(format, data, algorithm, extractable, usages) {
239199
if ("byteLength" in data) {

test/fixtures/wpt/WebCryptoAPI/import_export/rsa_importKey.https.any.js

Lines changed: 2 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/wpt/WebCryptoAPI/import_export/symmetric_importKey.https.any.js

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
data = jwkData(keyData, algorithm);
5050
}
5151
// Generate all combinations of valid usages for testing
52-
allValidUsages(vector.legalUsages, []).forEach(function(usages) {
52+
allValidUsages(vector.legalUsages).forEach(function(usages) {
5353
testFormat(format, algorithm, data, keyData.length * 8, usages, extractable);
5454
});
5555
testEmptyUsages(format, algorithm, data, keyData.length * 8, extractable);
@@ -173,46 +173,6 @@
173173
return base64String.replace(/=/g, "");
174174
}
175175

176-
// Want to test every valid combination of usages. Start by creating a list
177-
// of all non-empty subsets to possible usages.
178-
function allNonemptySubsetsOf(arr) {
179-
var results = [];
180-
var firstElement;
181-
var remainingElements;
182-
183-
for(var i=0; i<arr.length; i++) {
184-
firstElement = arr[i];
185-
remainingElements = arr.slice(i+1);
186-
results.push([firstElement]);
187-
188-
if (remainingElements.length > 0) {
189-
allNonemptySubsetsOf(remainingElements).forEach(function(combination) {
190-
combination.push(firstElement);
191-
results.push(combination);
192-
});
193-
}
194-
}
195-
196-
return results;
197-
}
198-
199-
// Return a list of all valid usage combinations, given the possible ones
200-
// and the ones that are required for a particular operation.
201-
function allValidUsages(possibleUsages, requiredUsages) {
202-
var allUsages = [];
203-
204-
allNonemptySubsetsOf(possibleUsages).forEach(function(usage) {
205-
for (var i=0; i<requiredUsages.length; i++) {
206-
if (!usage.includes(requiredUsages[i])) {
207-
return;
208-
}
209-
}
210-
allUsages.push(usage);
211-
});
212-
213-
return allUsages;
214-
}
215-
216176
// Convert method parameters to a string to uniquely name each test
217177
function parameterString(format, data, algorithm, extractable, usages) {
218178
var result = "(" +

test/fixtures/wpt/WebCryptoAPI/util/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ function allValidUsages(validUsages, emptyIsValid, mandatoryUsages) {
235235
}
236236
});
237237

238-
if (emptyIsValid) {
238+
if (emptyIsValid && validUsages.length !== 0) {
239239
okaySubsets.push([]);
240240
}
241241

test/fixtures/wpt/versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"path": "wasm/webapi"
8585
},
8686
"WebCryptoAPI": {
87-
"commit": "17b7ca10fd17ab22e60d62da6bc6e7424ea52740",
87+
"commit": "f4e7e32fd0d4937f5b024602c6bf665ebeb1fa17",
8888
"path": "WebCryptoAPI"
8989
},
9090
"webidl/ecmascript-binding/es-exceptions": {

0 commit comments

Comments
 (0)