summaryrefslogtreecommitdiffstats
path: root/dom/crypto/test/browser
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /dom/crypto/test/browser
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
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.toml9
-rw-r--r--dom/crypto/test/browser/browser_WebCrypto_telemetry.js32
-rw-r--r--dom/crypto/test/browser/head.js16
3 files changed, 57 insertions, 0 deletions
diff --git a/dom/crypto/test/browser/browser.toml b/dom/crypto/test/browser/browser.toml
new file mode 100644
index 0000000000..c77187cdab
--- /dev/null
+++ b/dom/crypto/test/browser/browser.toml
@@ -0,0 +1,9 @@
+[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
+ );
+}