gecko-dev/remote/test/browser/io/head.js
Henrik Skupin 5a966347fc Bug 1600053 - [remote] Implement IO.read. r=remote-protocol-reviewers,baku,ato,maja_zf
This patch implements the IO.read() method to allow
reading streams for files and blobs.

Therefor all the methods in the IO domain need a registry
for streams. Those have to be stored globally because
they need to be kept existent across different client
connections.

Differential Revision: https://phabricator.services.mozilla.com/D55968

--HG--
extra : moz-landing-system : lando
2019-12-16 16:17:59 +00:00

26 lines
722 B
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* import-globals-from ../head.js */
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/remote/test/browser/head.js",
this
);
const { streamRegistry } = ChromeUtils.import(
"chrome://remote/content/domains/parent/IO.jsm"
);
async function registerFileStream(contents, options = {}) {
// Any file as registered with the stream registry will be automatically
// deleted during the shutdown of Firefox.
options.remove = false;
const { file, path } = await createFile(contents, options);
const handle = streamRegistry.add(file);
return { handle, path };
}