michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: "use strict"; michael@0: michael@0: const tmp = require("sdk/test/tmp-file"); michael@0: const file = require("sdk/io/file"); michael@0: michael@0: const testFolderURL = module.uri.split('test-tmp-file.js')[0]; michael@0: michael@0: exports.testCreateFromString = function (assert) { michael@0: let expectedContent = "foo"; michael@0: let path = tmp.createFromString(expectedContent); michael@0: let content = file.read(path); michael@0: assert.equal(content, expectedContent, michael@0: "Temporary file contains the expected content"); michael@0: } michael@0: michael@0: exports.testCreateFromURL = function (assert) { michael@0: let url = testFolderURL + "test-tmp-file.txt"; michael@0: let path = tmp.createFromURL(url); michael@0: let content = file.read(path); michael@0: assert.equal(content, "foo", michael@0: "Temporary file contains the expected content"); michael@0: } michael@0: michael@0: require("sdk/test").run(exports);