Skip to content

Commit 9f5517a

Browse files
committed
test: update wpt
1 parent 3a71ccf commit 9f5517a

File tree

260 files changed

+9166
-1801
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

260 files changed

+9166
-1801
lines changed

test/fixtures/wpt/FileAPI/BlobURL/cross-partition.tentative.https.html

+313-84
Large diffs are not rendered by default.

test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,22 @@ test_blob(function() {
290290
new Int16Array([0x4150, 0x5353]),
291291
new Uint32Array([0x53534150]),
292292
new Int32Array([0x53534150]),
293-
new Float16Array([2.65625, 58.59375]),
294293
new Float32Array([0xD341500000])
295294
]);
296295
}, {
297-
expected: "PASSPASSPASSPASSPASSPASSPASSPASS",
296+
expected: "PASSPASSPASSPASSPASSPASSPASS",
298297
type: "",
299298
desc: "Passing typed arrays as elements of the blobParts array should work."
300299
});
300+
test_blob(function() {
301+
return new Blob([
302+
new Float16Array([2.65625, 58.59375])
303+
]);
304+
}, {
305+
expected: "PASS",
306+
type: "",
307+
desc: "Passing a Float16Array as element of the blobParts array should work."
308+
});
301309
test_blob(function() {
302310
return new Blob([
303311
// 0x535 3415053534150

test/fixtures/wpt/README.md

+21-21
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,32 @@ See [test/wpt](../../wpt/README.md) for information on how these tests are run.
1010

1111
Last update:
1212

13-
- common: https://github.com/web-platform-tests/wpt/tree/dbd648158d/common
14-
- compression: https://github.com/web-platform-tests/wpt/tree/5aa50dd415/compression
15-
- console: https://github.com/web-platform-tests/wpt/tree/767ae35464/console
16-
- dom/abort: https://github.com/web-platform-tests/wpt/tree/d1f1ecbd52/dom/abort
17-
- dom/events: https://github.com/web-platform-tests/wpt/tree/ab8999891c/dom/events
13+
- common: https://github.com/web-platform-tests/wpt/tree/d8da9d4d1d/common
14+
- compression: https://github.com/web-platform-tests/wpt/tree/da8d6860b2/compression
15+
- console: https://github.com/web-platform-tests/wpt/tree/e48251b778/console
16+
- dom/abort: https://github.com/web-platform-tests/wpt/tree/07a9d09a8f/dom/abort
17+
- dom/events: https://github.com/web-platform-tests/wpt/tree/0a811c5161/dom/events
1818
- encoding: https://github.com/web-platform-tests/wpt/tree/5aa50dd415/encoding
1919
- fetch/data-urls/resources: https://github.com/web-platform-tests/wpt/tree/7c79d998ff/fetch/data-urls/resources
20-
- FileAPI: https://github.com/web-platform-tests/wpt/tree/cceaf3628d/FileAPI
21-
- hr-time: https://github.com/web-platform-tests/wpt/tree/34cafd797e/hr-time
20+
- FileAPI: https://github.com/web-platform-tests/wpt/tree/1d5fb397da/FileAPI
21+
- hr-time: https://github.com/web-platform-tests/wpt/tree/614e81711c/hr-time
2222
- html/webappapis/atob: https://github.com/web-platform-tests/wpt/tree/f267e1dca6/html/webappapis/atob
23-
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/2c5c3c4c27/html/webappapis/microtask-queuing
24-
- html/webappapis/structured-clone: https://github.com/web-platform-tests/wpt/tree/47d3fb280c/html/webappapis/structured-clone
25-
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/5873f2d8f1/html/webappapis/timers
26-
- interfaces: https://github.com/web-platform-tests/wpt/tree/e90ece61d6/interfaces
27-
- performance-timeline: https://github.com/web-platform-tests/wpt/tree/17ebc3aea0/performance-timeline
28-
- resource-timing: https://github.com/web-platform-tests/wpt/tree/22d38586d0/resource-timing
29-
- resources: https://github.com/web-platform-tests/wpt/tree/1e140d63ec/resources
30-
- streams: https://github.com/web-platform-tests/wpt/tree/2bd26e124c/streams
31-
- url: https://github.com/web-platform-tests/wpt/tree/6a39784534/url
23+
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/22ecfc9bac/html/webappapis/microtask-queuing
24+
- html/webappapis/structured-clone: https://github.com/web-platform-tests/wpt/tree/c29dcddf37/html/webappapis/structured-clone
25+
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/7a0548ac47/html/webappapis/timers
26+
- interfaces: https://github.com/web-platform-tests/wpt/tree/ab18bf796b/interfaces
27+
- performance-timeline: https://github.com/web-platform-tests/wpt/tree/94caab7038/performance-timeline
28+
- resource-timing: https://github.com/web-platform-tests/wpt/tree/95e7763ca9/resource-timing
29+
- resources: https://github.com/web-platform-tests/wpt/tree/ff5b1bc4db/resources
30+
- streams: https://github.com/web-platform-tests/wpt/tree/b5f2d0c48a/streams
31+
- url: https://github.com/web-platform-tests/wpt/tree/30de089033/url
3232
- user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing
33-
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi
34-
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
35-
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/5e042cbc4e/WebCryptoAPI
33+
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/140f5c80fd/wasm/jsapi
34+
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/28456b73ca/wasm/webapi
35+
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/4993c18fa4/WebCryptoAPI
3636
- webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions
37-
- webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/e97fac4791/webmessaging/broadcastchannel
38-
- webstorage: https://github.com/web-platform-tests/wpt/tree/9dafa89214/webstorage
37+
- webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/6495c91853/webmessaging/broadcastchannel
38+
- webstorage: https://github.com/web-platform-tests/wpt/tree/1291340aaa/webstorage
3939

4040
[Web Platform Tests]: https://github.com/web-platform-tests/wpt
4141
[`git node wpt`]: https://github.com/nodejs/node-core-utils/blob/main/docs/git-node.md#git-node-wpt

test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/cfrg_curves_bits.js

+2-23
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ function define_tests() {
66
// Verify the derive functions perform checks against the all-zero value results,
77
// ensuring small-order points are rejected.
88
// https://www.rfc-editor.org/rfc/rfc7748#section-6.1
9-
// TODO: The spec states that the check must be done on use, but there is discussion about doing it on import.
10-
// https://github.com/WICG/webcrypto-secure-curves/pull/13
119
Object.keys(kSmallOrderPoint).forEach(function(algorithmName) {
1210
kSmallOrderPoint[algorithmName].forEach(function(test) {
1311
promise_test(async() => {
@@ -23,8 +21,8 @@ function define_tests() {
2321
false, [])
2422
derived = await subtle.deriveBits({name: algorithmName, public: publicKey}, privateKey, 8 * sizes[algorithmName]);
2523
} catch (err) {
26-
assert_false(privateKey === undefined, "Private key should be valid.");
27-
assert_false(publicKey === undefined, "Public key should be valid.");
24+
assert_true(privateKey !== undefined, "Private key should be valid.");
25+
assert_true(publicKey !== undefined, "Public key should be valid.");
2826
assert_equals(err.name, "OperationError", "Should throw correct error, not " + err.name + ": " + err.message + ".");
2927
}
3028
assert_equals(derived, undefined, "Operation succeeded, but should not have.");
@@ -59,25 +57,6 @@ function define_tests() {
5957
});
6058
}, algorithmName + " mixed case parameters");
6159

62-
// Null length
63-
// "Null" is not valid per the current spec
64-
// - https://github.com/w3c/webcrypto/issues/322
65-
// - https://github.com/w3c/webcrypto/issues/329
66-
//
67-
// Proposal for a spec change:
68-
// - https://github.com/w3c/webcrypto/pull/345
69-
//
70-
// This test case may be replaced by these new tests:
71-
// - https://github.com/web-platform-tests/wpt/pull/43400
72-
promise_test(function(test) {
73-
return subtle.deriveBits({name: algorithmName, public: publicKeys[algorithmName]}, privateKeys[algorithmName], null)
74-
.then(function(derivation) {
75-
assert_true(equalBuffers(derivation, derivations[algorithmName]), "Derived correct bits");
76-
}, function(err) {
77-
assert_unreached("deriveBits failed with error " + err.name + ": " + err.message);
78-
});
79-
}, algorithmName + " with null length");
80-
8160
// Shorter than entire derivation per algorithm
8261
promise_test(function(test) {
8362
return subtle.deriveBits({name: algorithmName, public: publicKeys[algorithmName]}, privateKeys[algorithmName], 8 * sizes[algorithmName] - 32)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// META: title=WebCryptoAPI: deriveBits() tests for the 'length' parameter
2+
// META: script=derived_bits_length.js
3+
// META: script=derived_bits_length_vectors.js
4+
// META: script=derived_bits_length_testcases.js
5+
6+
// Define subtests from a `promise_test` to ensure the harness does not
7+
// complete before the subtests are available. `explicit_done` cannot be used
8+
// for this purpose because the global `done` function is automatically invoked
9+
// by the WPT infrastructure in dedicated worker tests defined using the
10+
// "multi-global" pattern.
11+
promise_test(define_tests, 'setup - define tests');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
function define_tests() {
2+
// May want to test prefixed implementations.
3+
var subtle = self.crypto.subtle;
4+
5+
Object.keys(testCases).forEach(algorithm => {
6+
let testData = algorithms[algorithm];
7+
testCases[algorithm].forEach(testParam => {
8+
promise_test(async() => {
9+
let derivedBits, privateKey, publicKey;
10+
try {
11+
privateKey = await subtle.importKey(testData.privateKey.format, testData.privateKey.data, testData.importAlg, false, ["deriveBits"]);
12+
if (testData.deriveAlg.public !== undefined) {
13+
publicKey = await subtle.importKey(testData.publicKey.format, testData.publicKey.data, testData.importAlg, false, []);
14+
testData.deriveAlg.public = publicKey;
15+
}
16+
if (testParam.length === "omitted")
17+
derivedBits = await subtle.deriveBits(testData.deriveAlg, privateKey);
18+
else
19+
derivedBits = await subtle.deriveBits(testData.deriveAlg, privateKey, testParam.length);
20+
if (testParam.expected === undefined) {
21+
assert_unreached("deriveBits should have thrown an OperationError exception.");
22+
}
23+
assert_array_equals(new Uint8Array(derivedBits), testParam.expected, "Derived bits do not match the expected result.");
24+
} catch (err) {
25+
if (err instanceof AssertionError || testParam.expected !== undefined) {
26+
throw err;
27+
}
28+
assert_true(privateKey !== undefined, "Key should be valid.");
29+
assert_equals(err.name, "OperationError", "deriveBits correctly threw OperationError: " + err.message);
30+
}
31+
}, algorithm + " derivation with " + testParam.length + " as 'length' parameter");
32+
});
33+
});
34+
35+
return Promise.resolve("define_tests");
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
var testCases = {
2+
"HKDF": [
3+
{length: 256, expected: algorithms["HKDF"].derivation},
4+
{length: 0, expected: undefined}, // explicitly disallowed, so should throw
5+
{length: null, expected: undefined }, // should throw an exception
6+
{length: undefined, expected: undefined }, // should throw an exception
7+
{length: "omitted", expected: undefined }, // default value is null, so should throw
8+
],
9+
"PBKDF2": [
10+
{length: 256, expected: algorithms["PBKDF2"].derivation},
11+
{length: 0, expected: undefined}, // explicitly disallowed, so should throw
12+
{length: null, expected: undefined }, // should throw an exception
13+
{length: undefined, expected: undefined }, // should throw an exception
14+
{length: "omitted", expected: undefined }, // default value is null, so should throw
15+
],
16+
"ECDH": [
17+
{length: 256, expected: algorithms["ECDH"].derivation},
18+
{length: 0, expected: emptyArray},
19+
{length: null, expected: algorithms["ECDH"].derivation},
20+
{length: undefined, expected: algorithms["ECDH"].derivation},
21+
{length: "omitted", expected: algorithms["ECDH"].derivation }, // default value is null
22+
],
23+
"X25519": [
24+
{length: 256, expected: algorithms["X25519"].derivation},
25+
{length: 0, expected: emptyArray},
26+
{length: null, expected: algorithms["X25519"].derivation},
27+
{length: undefined, expected: algorithms["X25519"].derivation},
28+
{length: "omitted", expected: algorithms["X25519"].derivation }, // default value is null
29+
],
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const emptyArray = new Uint8Array([]);
2+
const rawKey = new Uint8Array([85, 115, 101, 114, 115, 32, 115, 104, 111, 117, 108, 100, 32, 112, 105, 99, 107, 32, 108, 111, 110, 103, 32, 112, 97, 115, 115, 112, 104, 114, 97, 115, 101, 115, 32, 40, 110, 111, 116, 32, 117, 115, 101, 32, 115, 104, 111, 114, 116, 32, 112, 97, 115, 115, 119, 111, 114, 100, 115, 41, 33]);
3+
const salt = new Uint8Array([83, 111, 100, 105, 117, 109, 32, 67, 104, 108, 111, 114, 105, 100, 101, 32, 99, 111, 109, 112, 111, 117, 110, 100]);
4+
const info = new Uint8Array([72, 75, 68, 70, 32, 101, 120, 116, 114, 97, 32, 105, 110, 102, 111]);
5+
6+
var algorithms = {
7+
"HKDF": {
8+
importAlg: {name: "HKDF"},
9+
privateKey: {format: "raw", data: rawKey},
10+
deriveAlg: {name: "HKDF", salt: salt, hash: "SHA-256", info: info},
11+
derivation: new Uint8Array([49, 183, 214, 133, 48, 168, 99, 231, 23, 192, 129, 202, 105, 23, 182, 134, 80, 179, 221, 154, 41, 243, 6, 6, 226, 202, 209, 153, 190, 193, 77, 19]),
12+
},
13+
"PBKDF2": {
14+
importAlg: {name: "PBKDF2"},
15+
privateKey: {format: "raw", data: rawKey},
16+
deriveAlg: {name: "PBKDF2", salt: salt, hash: "SHA-256", iterations: 100000},
17+
derivation: new Uint8Array([17, 153, 45, 139, 129, 51, 17, 36, 76, 84, 75, 98, 41, 41, 69, 226, 8, 212, 3, 206, 189, 107, 149, 82, 161, 165, 98, 6, 93, 153, 88, 234]),
18+
},
19+
"ECDH": {
20+
importAlg: {name: "ECDH", namedCurve: "P-256"},
21+
privateKey: {format: "pkcs8", data: new Uint8Array([48, 129, 135, 2, 1, 0, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 4, 109, 48, 107, 2, 1, 1, 4, 32, 15, 247, 79, 232, 241, 202, 175, 97, 92, 206, 241, 29, 217, 53, 114, 87, 98, 217, 216, 65, 236, 186, 185, 94, 170, 38, 68, 123, 52, 100, 245, 113, 161, 68, 3, 66, 0, 4, 140, 96, 11, 44, 102, 25, 45, 97, 158, 39, 210, 37, 107, 59, 151, 118, 178, 141, 30, 5, 246, 13, 234, 189, 98, 174, 123, 154, 211, 157, 224, 217, 59, 4, 102, 109, 199, 119, 14, 126, 207, 13, 211, 203, 203, 211, 110, 221, 107, 94, 220, 153, 81, 7, 55, 161, 237, 104, 46, 205, 112, 244, 10, 47])},
22+
publicKey: {format: "spki", data: new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 154, 116, 32, 120, 126, 95, 77, 105, 211, 232, 34, 114, 115, 1, 109, 56, 224, 71, 129, 133, 223, 127, 238, 156, 142, 103, 60, 202, 211, 79, 126, 128, 254, 49, 141, 182, 221, 107, 119, 218, 99, 32, 165, 246, 151, 89, 9, 68, 23, 177, 52, 239, 138, 139, 116, 193, 101, 4, 57, 198, 115, 0, 90, 61])},
23+
deriveAlg: {name: "ECDH", public: new Uint8Array ([])},
24+
derivation: new Uint8Array([14, 143, 60, 77, 177, 178, 162, 131, 115, 90, 0, 220, 87, 31, 26, 232, 151, 28, 227, 35, 250, 17, 131, 137, 203, 95, 65, 196, 59, 61, 181, 161]),
25+
},
26+
"X25519": {
27+
importAlg: {name: "X25519"},
28+
privateKey: {format: "pkcs8", data: new Uint8Array([48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 110, 4, 34, 4, 32, 200, 131, 142, 118, 208, 87, 223, 183, 216, 201, 90, 105, 225, 56, 22, 10, 221, 99, 115, 253, 113, 164, 210, 118, 187, 86, 227, 168, 27, 100, 255, 97])},
29+
publicKey: {format: "spki", data: new Uint8Array([48, 42, 48, 5, 6, 3, 43, 101, 110, 3, 33, 0, 28, 242, 177, 230, 2, 46, 197, 55, 55, 30, 215, 245, 62, 84, 250, 17, 84, 216, 62, 152, 235, 100, 234, 81, 250, 229, 179, 48, 124, 254, 151, 6])},
30+
deriveAlg: {name: "X25519", public: new Uint8Array ([])},
31+
derivation: new Uint8Array([39, 104, 64, 157, 250, 185, 158, 194, 59, 140, 137, 185, 63, 245, 136, 2, 149, 247, 97, 118, 8, 143, 137, 228, 61, 254, 190, 126, 161, 149, 0, 8]),
32+
}
33+
};

test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/ecdh_bits.js

-19
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,6 @@ function define_tests() {
5555
});
5656
}, namedCurve + " mixed case parameters");
5757

58-
// Null length
59-
// "Null" is not valid per the current spec
60-
// - https://github.com/w3c/webcrypto/issues/322
61-
// - https://github.com/w3c/webcrypto/issues/329
62-
//
63-
// Proposal for a spec change:
64-
// - https://github.com/w3c/webcrypto/pull/345
65-
//
66-
// This test case may be replaced by these new tests:
67-
// - https://github.com/web-platform-tests/wpt/pull/43400
68-
promise_test(function(test) {
69-
return subtle.deriveBits({name: "ECDH", public: publicKeys[namedCurve]}, privateKeys[namedCurve], null)
70-
.then(function(derivation) {
71-
assert_true(equalBuffers(derivation, derivations[namedCurve]), "Derived correct bits");
72-
}, function(err) {
73-
assert_unreached("deriveBits failed with error " + err.name + ": " + err.message);
74-
});
75-
}, namedCurve + " with null length");
76-
7758
// Shorter than entire derivation per algorithm
7859
promise_test(function(test) {
7960
return subtle.deriveBits({name: "ECDH", public: publicKeys[namedCurve]}, privateKeys[namedCurve], 8 * sizes[namedCurve] - 32)

test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/hkdf.js

-19
Original file line numberDiff line numberDiff line change
@@ -139,25 +139,6 @@ function define_tests() {
139139
});
140140
}, testName + " with missing info");
141141

142-
// length null (OperationError)
143-
// "Null" is not valid per the current spec
144-
// - https://github.com/w3c/webcrypto/issues/322
145-
// - https://github.com/w3c/webcrypto/issues/329
146-
//
147-
// Proposal for a spec change:
148-
// - https://github.com/w3c/webcrypto/pull/345
149-
//
150-
// This test case may be replaced by these new tests:
151-
// - https://github.com/web-platform-tests/wpt/pull/43400
152-
subsetTest(promise_test, function(test) {
153-
return subtle.deriveBits(algorithm, baseKeys[derivedKeySize], null)
154-
.then(function(derivation) {
155-
assert_unreached("null length should have thrown an OperationError");
156-
}, function(err) {
157-
assert_equals(err.name, "OperationError", "deriveBits with null length correctly threw OperationError: " + err.message);
158-
});
159-
}, testName + " with null length");
160-
161142
// length not multiple of 8 (OperationError)
162143
subsetTest(promise_test, function(test) {
163144
return subtle.deriveBits(algorithm, baseKeys[derivedKeySize], 44)

0 commit comments

Comments
 (0)