Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
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 | function run_test() { |
michael@0 | 5 | Components.utils.import("resource:///modules/TelURIParser.jsm") |
michael@0 | 6 | |
michael@0 | 7 | // global-phone-number |
michael@0 | 8 | do_check_eq(TelURIParser.parseURI('tel', 'tel:+1234'), '+1234'); |
michael@0 | 9 | |
michael@0 | 10 | // global-phone-number => white space separator |
michael@0 | 11 | do_check_eq(TelURIParser.parseURI('tel', 'tel:+123 456 789'), '+123 456 789'); |
michael@0 | 12 | |
michael@0 | 13 | // global-phone-number => ignored chars |
michael@0 | 14 | do_check_eq(TelURIParser.parseURI('tel', 'tel:+1234_123'), '+1234'); |
michael@0 | 15 | |
michael@0 | 16 | // global-phone-number => visualSeparator + digits |
michael@0 | 17 | do_check_eq(TelURIParser.parseURI('tel', 'tel:+-.()1234567890'), '+-.()1234567890'); |
michael@0 | 18 | |
michael@0 | 19 | // local-phone-number |
michael@0 | 20 | do_check_eq(TelURIParser.parseURI('tel', 'tel:1234'), '1234'); |
michael@0 | 21 | |
michael@0 | 22 | // local-phone-number => visualSeparator + digits + dtmfDigits + pauseCharacter |
michael@0 | 23 | do_check_eq(TelURIParser.parseURI('tel', 'tel:-.()1234567890ABCDpw'), '-.()1234567890ABCDpw'); |
michael@0 | 24 | |
michael@0 | 25 | // local-phone-number => visualSeparator + digits + dtmfDigits + pauseCharacter + ignored chars |
michael@0 | 26 | do_check_eq(TelURIParser.parseURI('tel', 'tel:-.()1234567890ABCDpw_'), '-.()1234567890ABCDpw'); |
michael@0 | 27 | |
michael@0 | 28 | // local-phone-number => isdn-subaddress |
michael@0 | 29 | do_check_eq(TelURIParser.parseURI('tel', 'tel:123;isub=123'), '123'); |
michael@0 | 30 | |
michael@0 | 31 | // local-phone-number => post-dial |
michael@0 | 32 | do_check_eq(TelURIParser.parseURI('tel', 'tel:123;postd=123'), '123'); |
michael@0 | 33 | |
michael@0 | 34 | // local-phone-number => prefix |
michael@0 | 35 | do_check_eq(TelURIParser.parseURI('tel', 'tel:123;phone-context=+0321'), '+0321123'); |
michael@0 | 36 | |
michael@0 | 37 | // local-phone-number => isdn-subaddress + post-dial + prefix |
michael@0 | 38 | do_check_eq(TelURIParser.parseURI('tel', 'tel:123;isub=123;postd=123;phone-context=+0321'), '+0321123'); |
michael@0 | 39 | } |