1
<!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../../resources/js-test.js"></script>
8 shouldBeEqualToString('window.atob("YQ==")', 'a');
9 shouldBeEqualToString('window.atob("YWI=")', 'ab');
10 shouldBeEqualToString('window.atob("YWJj")', 'abc');
11 shouldBeEqualToString('window.atob("YWJjZA==")', 'abcd');
12 shouldBeEqualToString('window.atob("YWJjZGU=")', 'abcde');
13 shouldBeEqualToString('window.atob("YWJjZGVm")', 'abcdef');
15 shouldBeEqualToString('window.btoa("a")', 'YQ==');
16 shouldBeEqualToString('window.btoa("ab")', 'YWI=');
17 shouldBeEqualToString('window.btoa("abc")', 'YWJj');
18 shouldBeEqualToString('window.btoa("abcd")', 'YWJjZA==');
19 shouldBeEqualToString('window.btoa("abcde")', 'YWJjZGU=');
20 shouldBeEqualToString('window.btoa("abcdef")', 'YWJjZGVm');
22 shouldBeEqualToString('typeof window.btoa', 'function');
23 shouldThrow('window.btoa()', '"TypeError: Failed to execute \'btoa\' on \'Window\': 1 argument required, but only 0 present."');
24 shouldBeEqualToString('window.btoa("")', '');
25 shouldBeEqualToString('window.btoa(null)', 'bnVsbA=='); // Gets converted to "null" string.
26 shouldBeEqualToString('window.btoa(undefined)', 'dW5kZWZpbmVk');
27 shouldBeEqualToString('window.btoa(window)', 'W29iamVjdCBXaW5kb3dd'); // "[object Window]"
28 shouldBeEqualToString('window.btoa("éé")', '6ek=');
29 shouldBeEqualToString('window.btoa("\\u0080\\u0081")', 'gIE=');
30 shouldThrow('window.btoa("тест")');
32 shouldBe('window.btoa', '0');
33 shouldBeEqualToString('typeof window.btoa', 'number');
35 shouldBeEqualToString('typeof window.atob', 'function');
36 shouldThrow('window.atob()', '"TypeError: Failed to execute \'atob\' on \'Window\': 1 argument required, but only 0 present."');
37 shouldBeEqualToString('window.atob("")', '');
38 shouldBeEqualToString('window.atob(null)', '\x9Eée'); // Gets converted to "null" string.
39 shouldThrow('window.atob(undefined)');
41 // HTML space characters in input.
42 shouldBeEqualToString('window.atob(" YQ==")', 'a');
43 shouldBeEqualToString('window.atob("YQ== ")', 'a');
44 shouldBeEqualToString('window.atob("YQ== ")', 'a');
45 shouldBeEqualToString('window.atob("YQ==\\u000a")', 'a');
46 shouldBeEqualToString('window.atob("YQ ==")', 'a');
47 shouldBeEqualToString('window.atob("YQ\\t==")', 'a');
48 shouldBeEqualToString('window.atob("YQ\\n==")', 'a');
49 shouldBeEqualToString('window.atob("YQ\\f==")', 'a');
50 shouldBeEqualToString('window.atob("YQ\\r==")', 'a');
51 shouldBeEqualToString('window.atob("YQ\\t\\n\\f\\r ==")', 'a');
53 shouldBeEqualToString('window.atob("6ek=")', 'éé');
54 shouldBeEqualToString('window.atob("6ek")', 'éé');
55 shouldBeEqualToString('window.atob("gIE=")', '\u0080\u0081');
56 shouldThrow('window.atob("тест")');
57 shouldThrow('window.atob("z")');
58 shouldBeEqualToString('window.atob("zz")', 'Ï');
59 shouldBeEqualToString('window.atob("zzz")', 'Ï\u003C');
60 shouldBeEqualToString('window.atob("zzz=")', 'Ï\u003C');
61 shouldThrow('window.atob("zzz==")'); // excess pad characters.
62 shouldThrow('window.atob("zzz===")'); // excess pad characters.
63 shouldThrow('window.atob("zzz====")'); // excess pad characters.
64 shouldThrow('window.atob("zzz=====")'); // excess pad characters.
65 shouldBeEqualToString('window.atob("zzzz")', 'Ï\u003Có');
66 shouldBeEqualToString('atob(" ")', ''); // whitespace only.
67 shouldThrow('window.atob("zzzzz")');
68 shouldThrow('window.atob("z=zz")');
69 shouldThrow('window.atob("=")');
70 shouldThrow('window.atob("==")');
71 shouldThrow('window.atob("===")');
72 shouldThrow('window.atob("====")');
73 shouldThrow('window.atob("=====")');
75 shouldBe('window.atob', '0');
76 shouldBeEqualToString('typeof window.atob', 'number');