summaryrefslogtreecommitdiffstats
path: root/dom/crypto/test/browser
diff options
context:
space:
mode:
Diffstat (limited to 'dom/crypto/test/browser')
-rw-r--r--dom/crypto/test/browser/browser.ini8
-rw-r--r--dom/crypto/test/browser/browser_WebCrypto_telemetry.js34
-rw-r--r--dom/crypto/test/browser/head.js16
3 files changed, 58 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..45c85fb758
--- /dev/null
+++ b/dom/crypto/test/browser/browser_WebCrypto_telemetry.js
@@ -0,0 +1,34 @@
+/* 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.defineModuleGetter(
+ this,
+ "TelemetryTestUtils",
+ "resource://testing-common/TelemetryTestUtils.jsm"
+);
+
+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
+ );
+}