mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-10 05:08:36 +02:00
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
26 lines
722 B
JavaScript
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 };
|
|
}
|