summaryrefslogtreecommitdiffstats
path: root/remote/test/browser/io/head.js
blob: 566ef690ee4b4b627e8baf6d7ba68ebbd36a22a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* 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 };
}