Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: introduce WPT Runner timeouts #48024

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions test/common/wpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/common/wpt/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/wpt/WebCryptoAPI/generateKey/failures.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/wpt/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"path": "wasm/webapi"
},
"WebCryptoAPI": {
"commit": "17b7ca10fd17ab22e60d62da6bc6e7424ea52740",
"commit": "3250754a55b1f7b6a79e4ec661b40cb3ca0b5e33",
"path": "WebCryptoAPI"
},
"webidl/ecmascript-binding/es-exceptions": {
Expand Down