Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | Cu.import("resource://services-common/utils.js"); |
michael@0 | 5 | Cu.import("resource://gre/modules/osfile.jsm"); |
michael@0 | 6 | |
michael@0 | 7 | function run_test() { |
michael@0 | 8 | initTestLogging(); |
michael@0 | 9 | run_next_test(); |
michael@0 | 10 | } |
michael@0 | 11 | |
michael@0 | 12 | add_test(function test_writeJSON_readJSON() { |
michael@0 | 13 | _("Round-trip some JSON through the promise-based JSON writer."); |
michael@0 | 14 | |
michael@0 | 15 | let contents = { |
michael@0 | 16 | "a": 12345.67, |
michael@0 | 17 | "b": { |
michael@0 | 18 | "c": "héllö", |
michael@0 | 19 | }, |
michael@0 | 20 | "d": undefined, |
michael@0 | 21 | "e": null, |
michael@0 | 22 | }; |
michael@0 | 23 | |
michael@0 | 24 | function checkJSON(json) { |
michael@0 | 25 | do_check_eq(contents.a, json.a); |
michael@0 | 26 | do_check_eq(contents.b.c, json.b.c); |
michael@0 | 27 | do_check_eq(contents.d, json.d); |
michael@0 | 28 | do_check_eq(contents.e, json.e); |
michael@0 | 29 | run_next_test(); |
michael@0 | 30 | }; |
michael@0 | 31 | |
michael@0 | 32 | function doRead() { |
michael@0 | 33 | CommonUtils.readJSON(path) |
michael@0 | 34 | .then(checkJSON, do_throw); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | let path = OS.Path.join(OS.Constants.Path.profileDir, "bar.json"); |
michael@0 | 38 | CommonUtils.writeJSON(contents, path) |
michael@0 | 39 | .then(doRead, do_throw); |
michael@0 | 40 | }); |