Commit 282e0ff4 authored by Beth Rennie's avatar Beth Rennie
Browse files

Bug 1772919 - Port osfile.jsm usage to IOUtils in layout/tools/ r=dholbert

parent d556a900
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@ var gWrittenProfile = false;
const { E10SUtils } = ChromeUtils.import(
  "resource://gre/modules/E10SUtils.jsm"
);
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
const { Preferences } = ChromeUtils.import(
  "resource://gre/modules/Preferences.jsm"
);
@@ -415,7 +414,7 @@ function dumpProfile() {
  gWritingProfile = true;

  let cwd = Services.dirsvc.get("CurWorkD", Ci.nsIFile).path;
  let filename = OS.Path.join(cwd, gArgs.profileFilename);
  let filename = PathUtils.join(cwd, gArgs.profileFilename);

  dump(`Writing profile to ${filename}...\n`);

+14 −24
Original line number Diff line number Diff line
@@ -65,11 +65,6 @@ const { E10SUtils } = ChromeUtils.import(

const lazy = {};

XPCOMUtils.defineLazyGetter(lazy, "OS", function() {
    const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
    return OS;
});

XPCOMUtils.defineLazyServiceGetters(lazy, {
  proxyService: [
    "@mozilla.org/network/protocol-proxy-service;1",
@@ -438,9 +433,8 @@ function ReadTests() {

        if (testList) {
            logger.debug("Reading test objects from: " + testList);
            let promise = lazy.OS.File.read(testList).then(function onSuccess(array) {
                let decoder = new TextDecoder();
                g.urls = JSON.parse(decoder.decode(array)).map(CreateUrls);
            let promise = IOUtils.readJSON(testList).then(function onSuccess(json) {
                g.urls = json.map(CreateUrls);
                StartTests();
            }).catch(function onFailure(e) {
                logger.error("Failed to load test objects: " + e);
@@ -487,9 +481,7 @@ function ReadTests() {

            if (dumpTests) {
                logger.debug("Dumping test objects to file: " + dumpTests);
                let encoder = new TextEncoder();
                let tests = encoder.encode(JSON.stringify(g.urls));
                lazy.OS.File.writeAtomic(dumpTests, tests, {flush: true}).then(
                IOUtils.writeJSON(dumpTests, g.urls, { flush: true }).then(
                  function onSuccess() {
                    DoneTests();
                  },
@@ -1927,8 +1919,7 @@ function pdfjsHasLoadedPromise() {
}

function readPdf(path, callback) {
    lazy.OS.File.open(path, { read: true }).then(function (file) {
        file.read().then(function (data) {
    IOUtils.read(path).then(function (data) {
        pdfjsLib.GlobalWorkerOptions.workerSrc = "resource://pdf.js/build/pdf.worker.js";
        pdfjsLib.getDocument({
            data: data
@@ -1941,7 +1932,6 @@ function readPdf(path, callback) {
    }, function (e) {
        callback(new Error(`Couldn't read PDF ${path}, exception: ${e}`));
    });
    });
}

function comparePdfs(pathToTestPdf, pathToRefPdf, callback) {