michael@0: /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 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: michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: const Cr = Components.results; michael@0: michael@0: function run_test() michael@0: { michael@0: // Generate a leaf name that is 255 characters long. michael@0: var longLeafName = new Array(256).join("T"); michael@0: michael@0: // Generate the path for a file located in a directory with a long name. michael@0: var tempFile = Cc["@mozilla.org/file/directory_service;1"]. michael@0: getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile); michael@0: tempFile.append(longLeafName); michael@0: tempFile.append("test.txt"); michael@0: michael@0: try { michael@0: tempFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600); michael@0: do_throw("Creating an item in a folder with a very long name should throw"); michael@0: } michael@0: catch (e if (e instanceof Ci.nsIException && michael@0: e.result == Cr.NS_ERROR_FILE_UNRECOGNIZED_PATH)) { michael@0: // We expect the function not to crash but to raise this exception. michael@0: } michael@0: }