diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /intl/uconv/tests/unit/test_unEscapeNonAsciiURI.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'intl/uconv/tests/unit/test_unEscapeNonAsciiURI.js')
-rw-r--r-- | intl/uconv/tests/unit/test_unEscapeNonAsciiURI.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/intl/uconv/tests/unit/test_unEscapeNonAsciiURI.js b/intl/uconv/tests/unit/test_unEscapeNonAsciiURI.js new file mode 100644 index 000000000..b059eaae2 --- /dev/null +++ b/intl/uconv/tests/unit/test_unEscapeNonAsciiURI.js @@ -0,0 +1,46 @@ +// Tests for nsITextToSubURI.unEscapeNonAsciiURI +function run_test() { + const textToSubURI = Components.classes["@mozilla.org/intl/texttosuburi;1"].getService(Components.interfaces.nsITextToSubURI); + + // Tests whether nsTextToSubURI does UTF-16 unescaping (it shouldn't) + const testURI = "data:text/html,%FE%FF"; + do_check_eq(textToSubURI.unEscapeNonAsciiURI("UTF-16", testURI), testURI); + + // Tests whether incomplete multibyte sequences throw. + const tests = [{ + input: "http://example.com/?p=%E9", + throws: Components.results.NS_ERROR_ILLEGAL_INPUT, + }, { + input: "http://example.com/?p=%E9%80", + throws: Components.results.NS_ERROR_ILLEGAL_INPUT, + }, { + input: "http://example.com/?p=%E9%80%80", + expected: "http://example.com/?p=\u9000", + }, { + input: "http://example.com/?p=%E9e", + throws: Components.results.NS_ERROR_ILLEGAL_INPUT, + }, { + input: "http://example.com/?p=%E9%E9", + throws: Components.results.NS_ERROR_ILLEGAL_INPUT, + }, { + input: "http://example.com/?name=M%FCller/", + throws: Components.results.NS_ERROR_ILLEGAL_INPUT, + }, { + input: "http://example.com/?name=M%C3%BCller/", + expected: "http://example.com/?name=Müller/", + }]; + + for (const t of tests) { + if (t.throws !== undefined) { + let thrown = undefined; + try { + textToSubURI.unEscapeNonAsciiURI("UTF-8", t.input); + } catch (e) { + thrown = e.result; + } + do_check_eq(thrown, t.throws); + } else { + do_check_eq(textToSubURI.unEscapeNonAsciiURI("UTF-8", t.input), t.expected); + } + } +} |