michael@0: function run_test() { michael@0: var ios = Components.classes["@mozilla.org/network/io-service;1"]. michael@0: getService(Components.interfaces.nsIIOService); michael@0: michael@0: var dataFile = do_get_file("data/bug121341.properties"); michael@0: michael@0: var channel = ios.newChannelFromURI(ios.newFileURI(dataFile, null, null)); michael@0: var inp = channel.open(); michael@0: michael@0: var properties = Components.classes["@mozilla.org/persistent-properties;1"]. michael@0: createInstance(Components.interfaces.nsIPersistentProperties); michael@0: properties.load(inp); michael@0: michael@0: var value; michael@0: michael@0: value = properties.getStringProperty("1"); michael@0: do_check_eq(value, "abc"); michael@0: michael@0: value = properties.getStringProperty("2"); michael@0: do_check_eq(value, "xy"); michael@0: michael@0: value = properties.getStringProperty("3"); michael@0: do_check_eq(value, "\u1234\t\r\n\u00AB\u0001\n"); michael@0: michael@0: value = properties.getStringProperty("4"); michael@0: do_check_eq(value, "this is multiline property"); michael@0: michael@0: value = properties.getStringProperty("5"); michael@0: do_check_eq(value, "this is another multiline property"); michael@0: michael@0: value = properties.getStringProperty("6"); michael@0: do_check_eq(value, "test\u0036"); michael@0: michael@0: value = properties.getStringProperty("7"); michael@0: do_check_eq(value, "yet another multiline propery"); michael@0: michael@0: value = properties.getStringProperty("8"); michael@0: do_check_eq(value, "\ttest5\u0020"); michael@0: michael@0: value = properties.getStringProperty("9"); michael@0: do_check_eq(value, " test6\t"); michael@0: michael@0: value = properties.getStringProperty("10a\u1234b"); michael@0: do_check_eq(value, "c\uCDEFd"); michael@0: michael@0: value = properties.getStringProperty("11"); michael@0: do_check_eq(value, "\uABCD"); michael@0: michael@0: dataFile = do_get_file("data/bug121341-2.properties"); michael@0: michael@0: channel = ios.newChannelFromURI(ios.newFileURI(dataFile, null, null)); michael@0: inp = channel.open(); michael@0: michael@0: var properties2 = Components.classes["@mozilla.org/persistent-properties;1"]. michael@0: createInstance(Components.interfaces.nsIPersistentProperties); michael@0: try { michael@0: properties2.load(inp); michael@0: do_throw("load() didn't fail"); michael@0: } michael@0: catch (e) { michael@0: } michael@0: }