summaryrefslogtreecommitdiffstats
path: root/toolkit/components/osfile/tests/xpcshell/test_queue.js
blob: e6e6f841c3ebcb76891d3f4bcfe22977a321712f (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
27
28
29
30
31
32
33
34
"use strict";

const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");

// Check if Scheduler.queue returned by OS.File.queue is resolved initially.
add_task(async function check_init() {
  await OS.File.queue;
  info("Function resolved");
});

// Check if Scheduler.queue returned by OS.File.queue is resolved
// after an operation is successful.
add_task(async function check_success() {
  info("Attempting to open a file correctly");
  await OS.File.open(OS.Path.join(do_get_cwd().path, "test_queue.js"));
  info("File opened correctly");
  await OS.File.queue;
  info("Function resolved");
});

// Check if Scheduler.queue returned by OS.File.queue is resolved
// after an operation fails.
add_task(async function check_failure() {
  let exception;
  try {
    info("Attempting to open a non existing file");
    await OS.File.open(OS.Path.join(".", "Bigfoot"));
  } catch (err) {
    exception = err;
    await OS.File.queue;
  }
  Assert.ok(exception != null);
  info("Function resolved");
});