diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /dom/crypto/test/browser | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/crypto/test/browser')
-rw-r--r-- | dom/crypto/test/browser/browser.ini | 8 | ||||
-rw-r--r-- | dom/crypto/test/browser/browser_WebCrypto_telemetry.js | 32 | ||||
-rw-r--r-- | dom/crypto/test/browser/head.js | 16 |
3 files changed, 56 insertions, 0 deletions
diff --git a/dom/crypto/test/browser/browser.ini b/dom/crypto/test/browser/browser.ini new file mode 100644 index 0000000000..e6cf748e83 --- /dev/null +++ b/dom/crypto/test/browser/browser.ini @@ -0,0 +1,8 @@ +[DEFAULT] +support-files = + head.js + ../test-vectors.js + ../util.js + +[browser_WebCrypto_telemetry.js] +disabled = for telemetry intermittents, see bug 1539578 diff --git a/dom/crypto/test/browser/browser_WebCrypto_telemetry.js b/dom/crypto/test/browser/browser_WebCrypto_telemetry.js new file mode 100644 index 0000000000..c18915d6cd --- /dev/null +++ b/dom/crypto/test/browser/browser_WebCrypto_telemetry.js @@ -0,0 +1,32 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +/* global tv */ + +const WEBCRYPTO_ALG_PROBE = "WEBCRYPTO_ALG"; + +ChromeUtils.defineESModuleGetters(this, { + TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.sys.mjs", +}); + +add_task(async function ecdh_key() { + let hist = TelemetryTestUtils.getAndClearHistogram(WEBCRYPTO_ALG_PROBE); + + let alg = { name: "ECDH", namedCurve: "P-256" }; + + let x = await crypto.subtle.generateKey(alg, false, [ + "deriveKey", + "deriveBits", + ]); + let data = await crypto.subtle.deriveBits( + { name: "ECDH", public: x.publicKey }, + x.privateKey, + 128 + ); + is(data.byteLength, 128 / 8, "Should be 16 bytes derived"); + + TelemetryTestUtils.assertHistogram(hist, 20, 1); +}); diff --git a/dom/crypto/test/browser/head.js b/dom/crypto/test/browser/head.js new file mode 100644 index 0000000000..85a9804a3c --- /dev/null +++ b/dom/crypto/test/browser/head.js @@ -0,0 +1,16 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +let exports = this; + +const scripts = ["util.js", "test-vectors.js"]; + +for (let script of scripts) { + Services.scriptloader.loadSubScript( + `chrome://mochitests/content/browser/dom/crypto/test/browser/${script}`, + this + ); +} |