From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- dom/crypto/test/browser/browser.ini | 8 ++++++ .../test/browser/browser_WebCrypto_telemetry.js | 32 ++++++++++++++++++++++ dom/crypto/test/browser/head.js | 16 +++++++++++ 3 files changed, 56 insertions(+) create mode 100644 dom/crypto/test/browser/browser.ini create mode 100644 dom/crypto/test/browser/browser_WebCrypto_telemetry.js create mode 100644 dom/crypto/test/browser/head.js (limited to 'dom/crypto/test/browser') 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 + ); +} -- cgit v1.2.3