summaryrefslogtreecommitdiffstats
path: root/intl/uconv/tests/unit/test_unEscapeNonAsciiURI.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /intl/uconv/tests/unit/test_unEscapeNonAsciiURI.js
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'intl/uconv/tests/unit/test_unEscapeNonAsciiURI.js')
-rw-r--r--intl/uconv/tests/unit/test_unEscapeNonAsciiURI.js58
1 files changed, 58 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 0000000000..f447959244
--- /dev/null
+++ b/intl/uconv/tests/unit/test_unEscapeNonAsciiURI.js
@@ -0,0 +1,58 @@
+// Tests for nsITextToSubURI.unEscapeNonAsciiURI
+function run_test() {
+ // Tests whether nsTextToSubURI does UTF-16 unescaping (it shouldn't)
+ const testURI = "data:text/html,%FE%FF";
+ Assert.equal(
+ Services.textToSubURI.unEscapeNonAsciiURI("UTF-16", testURI),
+ testURI
+ );
+
+ // Tests whether incomplete multibyte sequences throw.
+ const tests = [
+ {
+ input: "http://example.com/?p=%E9",
+ throws: Cr.NS_ERROR_ILLEGAL_INPUT,
+ },
+ {
+ input: "http://example.com/?p=%E9%80",
+ throws: Cr.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: Cr.NS_ERROR_ILLEGAL_INPUT,
+ },
+ {
+ input: "http://example.com/?p=%E9%E9",
+ throws: Cr.NS_ERROR_ILLEGAL_INPUT,
+ },
+ {
+ input: "http://example.com/?name=M%FCller/",
+ throws: Cr.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 {
+ Services.textToSubURI.unEscapeNonAsciiURI("UTF-8", t.input);
+ } catch (e) {
+ thrown = e.result;
+ }
+ Assert.equal(thrown, t.throws);
+ } else {
+ Assert.equal(
+ Services.textToSubURI.unEscapeNonAsciiURI("UTF-8", t.input),
+ t.expected
+ );
+ }
+ }
+}