1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/osfile/tests/xpcshell/test_available_free_space.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,38 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +Components.utils.import("resource://gre/modules/osfile.jsm"); 1.11 +Components.utils.import("resource://gre/modules/Services.jsm"); 1.12 + 1.13 +do_register_cleanup(function() { 1.14 + Services.prefs.setBoolPref("toolkit.osfile.log", false); 1.15 +}); 1.16 + 1.17 +function run_test() { 1.18 + Services.prefs.setBoolPref("toolkit.osfile.log", true); 1.19 + 1.20 + run_next_test(); 1.21 +} 1.22 + 1.23 +/** 1.24 + * Test OS.File.getAvailableFreeSpace 1.25 + */ 1.26 +add_task(function() { 1.27 + // Set up profile. We will use profile path to query for available free 1.28 + // space. 1.29 + do_get_profile(); 1.30 + 1.31 + let dir = OS.Constants.Path.profileDir; 1.32 + 1.33 + // Sanity checking for the test 1.34 + do_check_true((yield OS.File.exists(dir))); 1.35 + 1.36 + // Query for available bytes for user 1.37 + let availableBytes = yield OS.File.getAvailableFreeSpace(dir); 1.38 + 1.39 + do_check_true(!!availableBytes); 1.40 + do_check_true(availableBytes > 0); 1.41 +});