Bug 1447397 - avoid allocating too much memory in test_crypto_encrypt.js, avoiding OOM on win32. r=kitcambridge
authorMark Hammond <mhammond@skippinet.com.au>
Wed, 21 Mar 2018 09:34:41 +1100
changeset 409117 15a81cd03236d1828b5cc023a4fac8716f9eb171
parent 409116 279aeaacb2867de4ffa49f254347ac14bf6a195c
child 409118 754bbce103288e4d536a3de9a183406107d623a4
push id33675
push usertoros@mozilla.com
push dateWed, 21 Mar 2018 09:40:24 +0000
treeherdermozilla-central@f4ddf30ecf57 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskitcambridge
bugs1447397
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1447397 - avoid allocating too much memory in test_crypto_encrypt.js, avoiding OOM on win32. r=kitcambridge MozReview-Commit-ID: Is359cvtTJR
dom/push/test/xpcshell/test_crypto_encrypt.js
--- a/dom/push/test/xpcshell/test_crypto_encrypt.js
+++ b/dom/push/test/xpcshell/test_crypto_encrypt.js
@@ -96,27 +96,28 @@ add_task(async function aes128gcm_simple
                                            {encoding},
                                            ciphertext);
   deepEqual(message, plaintext);
 });
 
 // Variable record size tests
 add_task(async function aes128gcm_rs() {
   let [recvPublicKey, recvPrivateKey] = await PushCrypto.generateKeys();
-  let payload = "x".repeat(1024 * 10);
 
   for (let rs of [-1, 0, 1, 17]) {
+    let payload = "x".repeat(1024);
     info(`testing expected failure with rs=${rs}`);
     let message = new TextEncoder("utf-8").encode(payload);
     let authSecret = crypto.getRandomValues(new Uint8Array(16));
     await Assert.rejects(PushCrypto.encrypt(message, recvPublicKey, authSecret, {rs}),
                          /recordsize is too small/);
   }
   for (let rs of [18, 50, 1024, 4096, 16384]) {
     info(`testing expected success with rs=${rs}`);
+    let payload = "x".repeat(rs * 3);
     let message = new TextEncoder("utf-8").encode(payload);
     let authSecret = crypto.getRandomValues(new Uint8Array(16));
     let {ciphertext, encoding} = await PushCrypto.encrypt(message, recvPublicKey, authSecret, {rs});
     Assert.equal(encoding, "aes128gcm");
     // and decrypt it.
     let plaintext = await PushCrypto.decrypt(recvPrivateKey, recvPublicKey,
                                              authSecret,
                                              {encoding},
@@ -125,18 +126,17 @@ add_task(async function aes128gcm_rs() {
   }
 });
 
 // And try and hit some edge-cases.
 add_task(async function aes128gcm_edgecases() {
   let [recvPublicKey, recvPrivateKey] = await PushCrypto.generateKeys();
 
   for (let size of [0, 4096-16, 4096-16-1, 4096-16+1,
-                    4095, 4096, 4097,
-                    1024*100]) {
+                    4095, 4096, 4097, 10240]) {
     info(`testing encryption of ${size} byte payload`);
     let message = new TextEncoder("utf-8").encode("x".repeat(size));
     let authSecret = crypto.getRandomValues(new Uint8Array(16));
     let {ciphertext, encoding} = await PushCrypto.encrypt(message, recvPublicKey, authSecret);
     Assert.equal(encoding, "aes128gcm");
     // and decrypt it.
     let plaintext = await PushCrypto.decrypt(recvPrivateKey, recvPublicKey,
                                              authSecret,