diff --git a/test/common/wpt.js b/test/common/wpt.js index cc7c5320fa972e..d26749a49cf845 100644 --- a/test/common/wpt.js +++ b/test/common/wpt.js @@ -637,6 +637,7 @@ class WPTRunner { }, scriptsToRun, needsGc: !!meta.script?.find((script) => script === '/common/gc.js'), + timeout: meta.timeout === 'long' ? 60_000 : 10_000, }, }); this.inProgress.add(spec); @@ -680,7 +681,7 @@ class WPTRunner { process.on('exit', () => { for (const spec of this.inProgress) { - this.fail(spec, { name: 'Unknown' }, kIncomplete); + this.fail(spec, { name: 'Incomplete' }, kIncomplete); } inspect.defaultOptions.depth = Infinity; // Sorts the rules to have consistent output @@ -796,9 +797,11 @@ class WPTRunner { * @param {object} harnessStatus - The status object returned by WPT harness. */ completionCallback(spec, harnessStatus) { + const status = this.getTestStatus(harnessStatus.status); + // Treat it like a test case failure - if (harnessStatus.status === 2) { - this.resultCallback(spec, { status: 2, name: 'Unknown' }); + if (status === kTimeout) { + this.fail(spec, { name: 'WPT testharness timeout' }, kTimeout); } this.inProgress.delete(spec); // Always force termination of the worker. Some tests allocate resources diff --git a/test/common/wpt/worker.js b/test/common/wpt/worker.js index 80b32bf5b912e7..283be09e162c90 100644 --- a/test/common/wpt/worker.js +++ b/test/common/wpt/worker.js @@ -48,8 +48,16 @@ add_result_callback((result) => { }); }); +const timeout = setTimeout(() => { + parentPort.postMessage({ + type: 'completion', + status: { status: 2 }, + }); +}, workerData.timeout); + // eslint-disable-next-line no-undef add_completion_callback((_, status) => { + clearTimeout(timeout); parentPort.postMessage({ type: 'completion', status, diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md index 8e15bcb9922bb5..383c0f9427b3a2 100644 --- a/test/fixtures/wpt/README.md +++ b/test/fixtures/wpt/README.md @@ -31,7 +31,7 @@ Last update: - user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing - wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi - wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi -- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/17b7ca10fd/WebCryptoAPI +- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/3250754a55/WebCryptoAPI - webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions - webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/e97fac4791/webmessaging/broadcastchannel diff --git a/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/hkdf.https.any.js b/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/hkdf.https.any.js index 02492c3741c7d1..4aac798ad39654 100644 --- a/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/hkdf.https.any.js +++ b/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/hkdf.https.any.js @@ -1,8 +1,13 @@ // META: title=WebCryptoAPI: deriveBits() and deriveKey() Using HKDF -// META: variant=?1-1000 -// META: variant=?1001-2000 -// META: variant=?2001-3000 -// META: variant=?3001-last +// META: timeout=long +// META: variant=?1-500 +// META: variant=?501-1000 +// META: variant=?1001-1500 +// META: variant=?1501-2000 +// META: variant=?2001-2500 +// META: variant=?2501-3000 +// META: variant=?3001-3500 +// META: variant=?3501-last // META: script=/common/subset-tests.js // META: script=hkdf_vectors.js // META: script=hkdf.js diff --git a/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/pbkdf2.https.any.js b/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/pbkdf2.https.any.js index 2efbe523f8cd7d..4bc3bd3e3664d7 100644 --- a/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/pbkdf2.https.any.js +++ b/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/pbkdf2.https.any.js @@ -1,14 +1,23 @@ // META: title=WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2 // META: timeout=long -// META: variant=?1-1000 -// META: variant=?1001-2000 -// META: variant=?2001-3000 -// META: variant=?3001-4000 -// META: variant=?4001-5000 -// META: variant=?5001-6000 -// META: variant=?6001-7000 -// META: variant=?7001-8000 -// META: variant=?8001-last +// META: variant=?1-500 +// META: variant=?501-1000 +// META: variant=?1001-1500 +// META: variant=?1501-2000 +// META: variant=?2001-2500 +// META: variant=?2501-3000 +// META: variant=?3001-3500 +// META: variant=?3501-4000 +// META: variant=?4001-4500 +// META: variant=?4501-5000 +// META: variant=?5001-5500 +// META: variant=?5501-6000 +// META: variant=?6001-6500 +// META: variant=?6501-7000 +// META: variant=?7001-7500 +// META: variant=?7501-8000 +// META: variant=?8001-8500 +// META: variant=?8501-last // META: script=/common/subset-tests.js // META: script=pbkdf2_vectors.js // META: script=pbkdf2.js diff --git a/test/fixtures/wpt/WebCryptoAPI/generateKey/failures.js b/test/fixtures/wpt/WebCryptoAPI/generateKey/failures.js index e0f0279a69bb88..c39e4d211cbdf4 100644 --- a/test/fixtures/wpt/WebCryptoAPI/generateKey/failures.js +++ b/test/fixtures/wpt/WebCryptoAPI/generateKey/failures.js @@ -204,7 +204,7 @@ function run_test(algorithmNames) { }); - // The last thing that should be checked is empty usages (disallowed for secret and private keys). + // The last thing that should be checked is an empty usages (for secret keys). testVectors.forEach(function(vector) { var name = vector.name; diff --git a/test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey.https.any.js b/test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey.https.any.js index 25defa369c1d31..c70583bf12eba9 100644 --- a/test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey.https.any.js +++ b/test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey.https.any.js @@ -85,13 +85,13 @@ }); // Next, test private keys - ['pkcs8', 'jwk'].forEach(function(format) { - var algorithm = {name: vector.name, namedCurve: curve}; - var data = keyData[curve]; - allValidUsages(vector.privateUsages, []).forEach(function(usages) { + allValidUsages(vector.privateUsages, []).forEach(function(usages) { + ['pkcs8', 'jwk'].forEach(function(format) { + var algorithm = {name: vector.name, namedCurve: curve}; + var data = keyData[curve]; + testFormat(format, algorithm, data, curve, usages, extractable); }); - testEmptyUsages(format, algorithm, data, curve, extractable); }); }); @@ -136,21 +136,6 @@ }, "Good parameters: " + keySize.toString() + " bits " + parameterString(format, compressed, keyData, algorithm, extractable, usages)); } - // Test importKey with a given key format and other parameters but with empty usages. - // Should fail with SyntaxError - function testEmptyUsages(format, algorithm, data, keySize, extractable) { - const keyData = data[format]; - const usages = []; - promise_test(function(test) { - return subtle.importKey(format, keyData, algorithm, extractable, usages). - then(function(key) { - assert_unreached("importKey succeeded but should have failed with SyntaxError"); - }, function(err) { - assert_equals(err.name, "SyntaxError", "Should throw correct error, not " + err.name + ": " + err.message); - }); - }, "Empty Usages: " + keySize.toString() + " bits " + parameterString(format, false, keyData, algorithm, extractable, usages)); - } - // Helper methods follow: diff --git a/test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures.js b/test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures.js index ebdb73616d6581..a5cc08a01e9fc1 100644 --- a/test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures.js +++ b/test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures.js @@ -132,19 +132,6 @@ function run_test(algorithmNames) { }); }); - // Algorithms normalize okay, but usages bad (empty). - // Should fail due to SyntaxError - testVectors.forEach(function(vector) { - var name = vector.name; - validKeyData.filter((test) => test.format === 'pkcs8' || (test.format === 'jwk' && test.data.d)).forEach(function(test) { - allAlgorithmSpecifiersFor(name).forEach(function(algorithm) { - [true, false].forEach(function(extractable) { - testError(test.format, algorithm, test.data, name, [/* Empty usages */], extractable, "SyntaxError", "Empty usages"); - }); - }); - }); - }); - // Algorithms normalize okay, usages ok. The length of the key must thouw a DataError exception. testVectors.forEach(function(vector) { var name = vector.name; diff --git a/test/fixtures/wpt/WebCryptoAPI/import_export/rsa_importKey.https.any.js b/test/fixtures/wpt/WebCryptoAPI/import_export/rsa_importKey.https.any.js index 5582b2f506b067..41d25da89c6505 100644 --- a/test/fixtures/wpt/WebCryptoAPI/import_export/rsa_importKey.https.any.js +++ b/test/fixtures/wpt/WebCryptoAPI/import_export/rsa_importKey.https.any.js @@ -92,13 +92,13 @@ }); // Next, test private keys - ['pkcs8', 'jwk'].forEach(function(format) { - var algorithm = {name: vector.name, hash: hash}; - var data = keyData[size]; - allValidUsages(vector.privateUsages, []).forEach(function(usages) { + allValidUsages(vector.privateUsages, []).forEach(function(usages) { + ['pkcs8', 'jwk'].forEach(function(format) { + var algorithm = {name: vector.name, hash: hash}; + var data = keyData[size]; + testFormat(format, algorithm, data, size, usages, extractable); }); - testEmptyUsages(format, algorithm, data, size, extractable); }); }); }); @@ -135,20 +135,6 @@ }, "Good parameters: " + keySize.toString() + " bits " + parameterString(format, keyData[format], algorithm, extractable, usages)); } - // Test importKey with a given key format and other parameters but with empty usages. - // Should fail with SyntaxError - function testEmptyUsages(format, algorithm, keyData, keySize, extractable) { - const usages = []; - promise_test(function(test) { - return subtle.importKey(format, keyData[format], algorithm, extractable, usages). - then(function(key) { - assert_unreached("importKey succeeded but should have failed with SyntaxError"); - }, function(err) { - assert_equals(err.name, "SyntaxError", "Should throw correct error, not " + err.name + ": " + err.message); - }); - }, "Empty Usages: " + keySize.toString() + " bits " + parameterString(format, keyData, algorithm, extractable, usages)); - } - // Helper methods follow: diff --git a/test/fixtures/wpt/WebCryptoAPI/import_export/symmetric_importKey.https.any.js b/test/fixtures/wpt/WebCryptoAPI/import_export/symmetric_importKey.https.any.js index a9ce9be0a1becf..404b66ac0022ac 100644 --- a/test/fixtures/wpt/WebCryptoAPI/import_export/symmetric_importKey.https.any.js +++ b/test/fixtures/wpt/WebCryptoAPI/import_export/symmetric_importKey.https.any.js @@ -41,18 +41,17 @@ } rawKeyData.forEach(function(keyData) { - // Try each legal value of the extractable parameter - vector.extractable.forEach(function(extractable) { - vector.formats.forEach(function(format) { - var data = keyData; - if (format === "jwk") { - data = jwkData(keyData, algorithm); - } - // Generate all combinations of valid usages for testing - allValidUsages(vector.legalUsages, []).forEach(function(usages) { + // Generate all combinations of valid usages for testing + allValidUsages(vector.legalUsages, []).forEach(function(usages) { + // Try each legal value of the extractable parameter + vector.extractable.forEach(function(extractable) { + vector.formats.forEach(function(format) { + var data = keyData; + if (format === "jwk") { + data = jwkData(keyData, algorithm); + } testFormat(format, algorithm, data, keyData.length * 8, usages, extractable); }); - testEmptyUsages(format, algorithm, data, keyData.length * 8, extractable); }); }); @@ -91,20 +90,6 @@ }, "Good parameters: " + keySize.toString() + " bits " + parameterString(format, keyData, algorithm, extractable, usages)); } - // Test importKey with a given key format and other parameters but with empty usages. - // Should fail with SyntaxError - function testEmptyUsages(format, algorithm, keyData, keySize, extractable) { - const usages = []; - promise_test(function(test) { - return subtle.importKey(format, keyData, algorithm, extractable, usages). - then(function(key) { - assert_unreached("importKey succeeded but should have failed with SyntaxError"); - }, function(err) { - assert_equals(err.name, "SyntaxError", "Should throw correct error, not " + err.name + ": " + err.message); - }); - }, "Empty Usages: " + keySize.toString() + " bits " + parameterString(format, keyData, algorithm, extractable, usages)); - } - // Helper methods follow: diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json index 266e6b4a92a20c..785c64fe1d0741 100644 --- a/test/fixtures/wpt/versions.json +++ b/test/fixtures/wpt/versions.json @@ -84,7 +84,7 @@ "path": "wasm/webapi" }, "WebCryptoAPI": { - "commit": "17b7ca10fd17ab22e60d62da6bc6e7424ea52740", + "commit": "3250754a55b1f7b6a79e4ec661b40cb3ca0b5e33", "path": "WebCryptoAPI" }, "webidl/ecmascript-binding/es-exceptions": {