|
| 1 | +diff --git a/WebCryptoAPI/getRandomValues.any.js b/WebCryptoAPI/getRandomValues.any.js |
| 2 | +index 574134eb7..128c805a5 100644 |
| 3 | +--- a/WebCryptoAPI/getRandomValues.any.js |
| 4 | ++++ b/WebCryptoAPI/getRandomValues.any.js |
| 5 | +@@ -1,14 +1,31 @@ |
| 6 | ++// k6 throws GoError instead of DOMException, so we need to monkey patch. |
| 7 | ++const originalAssertThrowsDom = self.assert_throws_dom; |
| 8 | ++self.assert_throws_dom = function(expectedErrorName, func, description) { |
| 9 | ++ try { |
| 10 | ++ func(); |
| 11 | ++ } catch (e) { |
| 12 | ++ const isGoError = (typeof e === "object") && (e.name === "GoError"); |
| 13 | ++ const msg = isGoError ? (e.message || "") : e.toString(); |
| 14 | ++ if (msg.includes(expectedErrorName)) { |
| 15 | ++ return; // Treat as correct |
| 16 | ++ } |
| 17 | ++ } |
| 18 | ++ |
| 19 | ++ return originalAssertThrowsDom(expectedErrorName, func, description); |
| 20 | ++} |
| 21 | ++ |
| 22 | + // Step 1. |
| 23 | +-test(function() { |
| 24 | +- assert_throws_dom("TypeMismatchError", function() { |
| 25 | +- self.crypto.getRandomValues(new Float16Array(6)) |
| 26 | +- }, "Float16Array") |
| 27 | ++// Float16Array is not supported in k6 |
| 28 | ++// test(function() { |
| 29 | ++// assert_throws_dom("TypeMismatchError", function() { |
| 30 | ++// self.crypto.getRandomValues(new Float16Array(6)) |
| 31 | ++// }, "Float16Array") |
| 32 | + |
| 33 | +- assert_throws_dom("TypeMismatchError", function() { |
| 34 | +- const len = 65536 / Float16Array.BYTES_PER_ELEMENT + 1; |
| 35 | +- self.crypto.getRandomValues(new Float16Array(len)); |
| 36 | +- }, "Float16Array (too long)") |
| 37 | +-}, "Float16 arrays"); |
| 38 | ++// assert_throws_dom("TypeMismatchError", function() { |
| 39 | ++// const len = 65536 / Float16Array.BYTES_PER_ELEMENT + 1; |
| 40 | ++// self.crypto.getRandomValues(new Float16Array(len)); |
| 41 | ++// }, "Float16Array (too long)") |
| 42 | ++// }, "Float16 arrays"); |
| 43 | + |
| 44 | + test(function() { |
| 45 | + assert_throws_dom("TypeMismatchError", function() { |
0 commit comments