Bug 1361443 - Tests for remote blobs and multipart inputStreams, r=smaug
☠☠ backed out by 8970c4963872 ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 04 May 2017 14:44:53 +0200
changeset 572794 1ab58ab887c642c9c1d6068bc565a9151f0b3106
parent 572793 c0e3f3edf36a8486c22d88e0d28f337690e439ff
child 572795 4370dbfde05c6aac17b971256b7a6fa07a9e7dc3
push id57195
push userbmo:rbarker@mozilla.com
push dateThu, 04 May 2017 20:08:56 +0000
reviewerssmaug
bugs1361443
milestone55.0a1
Bug 1361443 - Tests for remote blobs and multipart inputStreams, r=smaug
dom/file/ipc/tests/browser_ipcBlob.js
--- a/dom/file/ipc/tests/browser_ipcBlob.js
+++ b/dom/file/ipc/tests/browser_ipcBlob.js
@@ -166,8 +166,41 @@ add_task(function* test_CtoPtoC_bc_small
     });
   });
 
   ok(status, "CtoPtoC-blobURL: Data match!");
 
   yield BrowserTestUtils.removeTab(tab1);
   yield BrowserTestUtils.removeTab(tab2);
 });
+
+// Multipart Blob childA-parent-childB.
+add_task(function* test_CtoPtoC_multipart() {
+  let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
+  let browser1 = gBrowser.getBrowserForTab(tab1);
+
+  let blob = yield ContentTask.spawn(browser1, null, function() {
+    return new Blob(["!"]);
+  });
+
+  ok(blob, "CtoPtoC-,ultipart: We have a blob!");
+  is(blob.size, "!".length, "CtoPtoC-multipart: The size matches");
+
+  let newBlob = new Blob(["world", blob]);
+
+  let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
+  let browser2 = gBrowser.getBrowserForTab(tab2);
+
+  let status = yield ContentTask.spawn(browser2, newBlob, function(blob) {
+    return new Promise(resolve => {
+      let fr = new content.FileReader();
+      fr.readAsText(new Blob(["hello ", blob]));
+      fr.onloadend = function() {
+        resolve(fr.result == "hello world!");
+      }
+    });
+  });
+
+  ok(status, "CtoPtoC-multipart: Data match!");
+
+  yield BrowserTestUtils.removeTab(tab1);
+  yield BrowserTestUtils.removeTab(tab2);
+});