Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 #!/usr/bin/python -B
3 """ Usage: make-normalize-generateddata-input.py PATH_TO_MOZILLA_CENTRAL
5 This script generates test input data for String.prototype.normalize
6 from intl/icu/source/data/unidata/NormalizationTest.txt
7 to js/src/tests/ecma_6/String/normalize-generateddata-input.js
8 """
10 from __future__ import print_function
11 import re, sys
13 sep_pat = re.compile(' +')
14 def to_code_list(codes):
15 return '[' + ', '.join(map(lambda x: '0x{0}'.format(x), re.split(sep_pat, codes))) + ']'
17 def convert(dir):
18 ver_pat = re.compile('NormalizationTest-([0-9\.]+)\.txt')
19 part_pat = re.compile('^@(Part([0-9]+) .+)$')
20 test_pat = re.compile('^([0-9A-Fa-f ]+);([0-9A-Fa-f ]+);([0-9A-Fa-f ]+);([0-9A-Fa-f ]+);([0-9A-Fa-f ]+);$')
21 ignore_pat = re.compile('^#|^$')
22 js_path = 'js/src/tests/ecma_6/String/normalize-generateddata-input.js'
23 txt_path = 'intl/icu/source/data/unidata/NormalizationTest.txt'
25 part_opened = False
26 not_empty = False
27 with open('{dir}/{path}'.format(dir=dir, path=txt_path), 'r') as f:
28 with open('{dir}/{path}'.format(dir=dir, path=js_path), 'w') as outf:
29 for line in f:
30 m = test_pat.search(line)
31 if m:
32 if not_empty:
33 outf.write(',')
34 outf.write('\n')
35 pat = '{{ source: {source}, NFC: {NFC}, NFD: {NFD}, NFKC: {NFKC}, NFKD: {NFKD} }}'
36 outf.write(pat.format(source=to_code_list(m.group(1)),
37 NFC=to_code_list(m.group(2)),
38 NFD=to_code_list(m.group(3)),
39 NFKC=to_code_list(m.group(4)),
40 NFKD=to_code_list(m.group(5))))
41 not_empty = True
42 continue
43 m = part_pat.search(line)
44 if m:
45 desc = m.group(1)
46 part = m.group(2)
47 if part_opened:
48 outf.write('\n];\n')
49 outf.write('/* {desc} */\n'.format(desc=desc))
50 outf.write('var tests_part{part} = ['.format(part=part))
51 part_opened = True
52 not_empty = False
53 continue
54 m = ver_pat.search(line)
55 if m:
56 ver = m.group(1)
57 outf.write('/* created from NormalizationTest-{ver}.txt */\n'.format(ver=ver))
58 continue
59 m = ignore_pat.search(line)
60 if m:
61 continue
62 print("Unknown line: {0}".format(line), file=sys.stderr)
63 if part_opened:
64 outf.write('\n];\n')
66 if __name__ == '__main__':
67 if len(sys.argv) < 2:
68 print("Usage: make-normalize-generateddata-input.py PATH_TO_MOZILLA_CENTRAL", file=sys.stderr)
69 sys.exit(1)
70 convert(sys.argv[1])