trying and failing to make a crashing readable streams test draft
authorAndrew McCreight <continuation@gmail.com>
Fri, 22 Nov 2019 14:13:47 -0800
changeset 2496062 0d9e7834e5e0cea4ae2522b96735056b977f2213
parent 2496061 f1ce595c1334744af3d42b06db8bc4015f921402
child 2496063 263e5c4688672c30c3a78216f57729b8e441eb24
push id455279
push useramccreight@mozilla.com
push dateMon, 25 Nov 2019 19:56:04 +0000
treeherdertry@59b13b57567a [default view] [failures only]
milestone72.0a1
trying and failing to make a crashing readable streams test
dom/tests/mochitest/fetch/common_readableStreams.js
--- a/dom/tests/mochitest/fetch/common_readableStreams.js
+++ b/dom/tests/mochitest/fetch/common_readableStreams.js
@@ -10,16 +10,29 @@ function makeBuffer(size) {
   let value = 0;
   for (let i = 0; i < 1000000; i += 1000) {
     buffer.set([++value % 255], i);
   }
 
   return buffer;
 }
 
+function spammo() {
+  if (self.SpecialPowers) {
+    self.SpecialPowers.forceGC();
+    self.SpecialPowers.forceGC();
+    self.SpecialPowers.forceGC();
+  }
+/*
+  for (let i = 0; i < 1000; i += 1) {
+    makeBuffer(BIG_BUFFER_SIZE);
+  }
+*/
+}
+
 function apply_compartment(compartment, data) {
   if (compartment == SAME_COMPARTMENT) {
     return self[data.func](data.args, self);
   }
 
   if (compartment == IFRAME_COMPARTMENT) {
     const iframe = document.querySelector("#iframe").contentWindow;
     return iframe[data.func](data.args, self);
@@ -85,30 +98,34 @@ async function test_timeout_continue(r, 
     that.ok(true, "We cannot have a blob here!");
   }
 }
 
 async function test_nonNativeStream(compartment) {
   info("test_nonNativeStream");
 
   let buffer = makeBuffer(BIG_BUFFER_SIZE);
-  info("Buffer size: " + buffer.byteLength);
+  let sizeo = buffer.byteLength;
+
+  info("Buffer size: " + sizeo);
 
   let r = new Response(
     new ReadableStream({
       start: controller => {
         controller.enqueue(buffer);
+        buffer = null;
+        spammo();
         controller.close();
       },
     })
   );
 
   return apply_compartment(compartment, {
     func: "test_nonNativeStream_continue",
-    args: { r, buffer },
+    args: { r, buffer : {byteLength: sizeo } },
   });
 }
 
 async function test_nonNativeStream_continue(data, that) {
   that.ok(
     data.r.body instanceof that.ReadableStream,
     "We have a ReadableStream"
   );
@@ -121,17 +138,23 @@ async function test_nonNativeStream_cont
   that.ok(b instanceof that.Response, "We have a cloned Response");
   that.ok(b.body instanceof that.ReadableStream, "We have a ReadableStream");
 
   let blob = await data.r.blob();
 
   that.ok(blob instanceof Blob, "We have a blob");
   let d = await a.body.getReader().read();
 
+  spammo();
   that.ok(!d.done, "We have read something!");
+
+  for (let z in d.value) {
+    that.isnot(z, "ZZZ", "whatever man");
+  }
+
   blob = await b.blob();
 
   that.ok(blob instanceof Blob, "We have a blob");
   that.is(blob.size, data.buffer.byteLength, "Blob size matches");
 }
 
 async function test_noUint8Array(compartment) {
   info("test_noUint8Array");
@@ -162,17 +185,18 @@ async function test_noUint8Array_continu
   }
 }
 
 async function test_pendingStream(compartment) {
   let r = new Response(
     new ReadableStream({
       start: controller => {
         controller.enqueue(makeBuffer(BIG_BUFFER_SIZE));
-        // Let's keep this controler open.
+        spammo();
+        // Let's keep this controller open.
         self.ccc = controller;
       },
     })
   );
 
   return apply_compartment(compartment, {
     func: "test_pendingStream_continue",
     args: r,
@@ -227,24 +251,26 @@ async function test_nonNativeStream_cach
   let buffer = makeBuffer(BIG_BUFFER_SIZE);
   info("Buffer size: " + buffer.byteLength);
 
   info("Storing a body as a string");
   let r = new Response(
     new ReadableStream({
       start: controller => {
         controller.enqueue(buffer);
+        buffer = null;
+        spammo();
         controller.close();
       },
     })
   );
 
   return apply_compartment(compartment, {
     func: "test_nonNativeStream_cache_continue",
-    args: { caches, cache, buffer, r },
+    args: { caches, cache, r },
   });
 }
 
 async function test_nonNativeStream_cache_continue(data, that) {
   await data.cache.put(data.url, data.r);
 
   that.info("Retrieving the stored value");
   let cacheResponse = await data.cache.match(data.url);
@@ -283,16 +309,18 @@ async function test_codeExecution(compar
 
   return apply_compartment(compartment, {
     func: "test_codeExecution_continue",
     args: r,
   });
 }
 
 async function test_codeExecution_continue(r, that) {
+  that.SpecialPowers.forceGC();
+
   function consoleListener() {
     that.SpecialPowers.addObserver(this, "console-api-log-event");
   }
 
   var promise = new Promise(resolve => {
     consoleListener.prototype = {
       observe(aSubject, aTopic, aData) {
         that.ok(true, "Something has been received");