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.
michael@0 | 1 | #!/usr/bin/python -B |
michael@0 | 2 | |
michael@0 | 3 | """ Usage: make-normalize-generateddata-input.py PATH_TO_MOZILLA_CENTRAL |
michael@0 | 4 | |
michael@0 | 5 | This script generates test input data for String.prototype.normalize |
michael@0 | 6 | from intl/icu/source/data/unidata/NormalizationTest.txt |
michael@0 | 7 | to js/src/tests/ecma_6/String/normalize-generateddata-input.js |
michael@0 | 8 | """ |
michael@0 | 9 | |
michael@0 | 10 | from __future__ import print_function |
michael@0 | 11 | import re, sys |
michael@0 | 12 | |
michael@0 | 13 | sep_pat = re.compile(' +') |
michael@0 | 14 | def to_code_list(codes): |
michael@0 | 15 | return '[' + ', '.join(map(lambda x: '0x{0}'.format(x), re.split(sep_pat, codes))) + ']' |
michael@0 | 16 | |
michael@0 | 17 | def convert(dir): |
michael@0 | 18 | ver_pat = re.compile('NormalizationTest-([0-9\.]+)\.txt') |
michael@0 | 19 | part_pat = re.compile('^@(Part([0-9]+) .+)$') |
michael@0 | 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 ]+);$') |
michael@0 | 21 | ignore_pat = re.compile('^#|^$') |
michael@0 | 22 | js_path = 'js/src/tests/ecma_6/String/normalize-generateddata-input.js' |
michael@0 | 23 | txt_path = 'intl/icu/source/data/unidata/NormalizationTest.txt' |
michael@0 | 24 | |
michael@0 | 25 | part_opened = False |
michael@0 | 26 | not_empty = False |
michael@0 | 27 | with open('{dir}/{path}'.format(dir=dir, path=txt_path), 'r') as f: |
michael@0 | 28 | with open('{dir}/{path}'.format(dir=dir, path=js_path), 'w') as outf: |
michael@0 | 29 | for line in f: |
michael@0 | 30 | m = test_pat.search(line) |
michael@0 | 31 | if m: |
michael@0 | 32 | if not_empty: |
michael@0 | 33 | outf.write(',') |
michael@0 | 34 | outf.write('\n') |
michael@0 | 35 | pat = '{{ source: {source}, NFC: {NFC}, NFD: {NFD}, NFKC: {NFKC}, NFKD: {NFKD} }}' |
michael@0 | 36 | outf.write(pat.format(source=to_code_list(m.group(1)), |
michael@0 | 37 | NFC=to_code_list(m.group(2)), |
michael@0 | 38 | NFD=to_code_list(m.group(3)), |
michael@0 | 39 | NFKC=to_code_list(m.group(4)), |
michael@0 | 40 | NFKD=to_code_list(m.group(5)))) |
michael@0 | 41 | not_empty = True |
michael@0 | 42 | continue |
michael@0 | 43 | m = part_pat.search(line) |
michael@0 | 44 | if m: |
michael@0 | 45 | desc = m.group(1) |
michael@0 | 46 | part = m.group(2) |
michael@0 | 47 | if part_opened: |
michael@0 | 48 | outf.write('\n];\n') |
michael@0 | 49 | outf.write('/* {desc} */\n'.format(desc=desc)) |
michael@0 | 50 | outf.write('var tests_part{part} = ['.format(part=part)) |
michael@0 | 51 | part_opened = True |
michael@0 | 52 | not_empty = False |
michael@0 | 53 | continue |
michael@0 | 54 | m = ver_pat.search(line) |
michael@0 | 55 | if m: |
michael@0 | 56 | ver = m.group(1) |
michael@0 | 57 | outf.write('/* created from NormalizationTest-{ver}.txt */\n'.format(ver=ver)) |
michael@0 | 58 | continue |
michael@0 | 59 | m = ignore_pat.search(line) |
michael@0 | 60 | if m: |
michael@0 | 61 | continue |
michael@0 | 62 | print("Unknown line: {0}".format(line), file=sys.stderr) |
michael@0 | 63 | if part_opened: |
michael@0 | 64 | outf.write('\n];\n') |
michael@0 | 65 | |
michael@0 | 66 | if __name__ == '__main__': |
michael@0 | 67 | if len(sys.argv) < 2: |
michael@0 | 68 | print("Usage: make-normalize-generateddata-input.py PATH_TO_MOZILLA_CENTRAL", file=sys.stderr) |
michael@0 | 69 | sys.exit(1) |
michael@0 | 70 | convert(sys.argv[1]) |