1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/services/common/tests/unit/test_utils_encodeBase64URL.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,27 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +Cu.import("resource://services-common/utils.js"); 1.8 + 1.9 +function run_test() { 1.10 + run_next_test(); 1.11 +} 1.12 + 1.13 +add_test(function test_simple() { 1.14 + let expected = { 1.15 + hello: "aGVsbG8=", 1.16 + "<>?": "PD4_", 1.17 + }; 1.18 + 1.19 + for (let [k, v] in Iterator(expected)) { 1.20 + do_check_eq(CommonUtils.encodeBase64URL(k), v); 1.21 + } 1.22 + 1.23 + run_next_test(); 1.24 +}); 1.25 + 1.26 +add_test(function test_no_padding() { 1.27 + do_check_eq(CommonUtils.encodeBase64URL("hello", false), "aGVsbG8"); 1.28 + 1.29 + run_next_test(); 1.30 +});