Bug 1505911 - Add glyph testing to test_mozTXTToHTMLConv.js. r=valentin
authorJorg K <jorgk@jorgk.com>
Fri, 30 Nov 2018 18:41:45 +0100
changeset 449086 f64d8eeab965ad962b09952d5e3978db0d4b8199
parent 449085 0c40ca38958fc08fb4289dd1eb45b7fd7258ff99
child 449087 dec172d2c7fd901849b9496601f73483b31f12b0
push id35142
push userrgurzau@mozilla.com
push dateSat, 01 Dec 2018 14:30:25 +0000
treeherdermozilla-central@b3085cd7b7c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1505911
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1505911 - Add glyph testing to test_mozTXTToHTMLConv.js. r=valentin
netwerk/test/unit/test_mozTXTToHTMLConv.js
--- a/netwerk/test/unit/test_mozTXTToHTMLConv.js
+++ b/netwerk/test/unit/test_mozTXTToHTMLConv.js
@@ -122,16 +122,41 @@ function run_test() {
       url: "http://[2001:db8::1]:80/"
     },
     {
       input: "test http://www.map.com/map.php?t=Nova_Scotia&markers=//Not_a_survey||description=plm2 test",
       url: "http://www.map.com/map.php?t=Nova_Scotia&amp;markers=//Not_a_survey||description=plm2"
     }
   ];
 
+  const scanTXTglyph = [
+    // Some "glyph" testing (not exhaustive, the system supports 16 different
+    // smiley types).
+    {
+      input: "this is superscript: x^2",
+      results: ["<sup", "2", "</sup>"]
+    },
+    {
+      input: "this is plus-minus: +/-",
+      results: ["&plusmn;"]
+    },
+    {
+      input: "this is a smiley :)",
+      results: ["moz-smiley-s1"]
+    },
+    {
+      input: "this is a smiley :-)",
+      results: ["moz-smiley-s1"]
+    },
+    {
+      input: "this is a smiley :-(",
+      results: ["moz-smiley-s2"]
+    },
+  ];
+
   const scanHTMLtests = [
     {
       input: "http://foo.example.com",
       shouldChange: true
     },
     {
       input: " <a href='http://a.example.com/'>foo</a>",
       shouldChange: false
@@ -190,16 +215,25 @@ function run_test() {
     let t = scanTXTtests[i];
     let output = converter.scanTXT(t.input, Ci.mozITXTToHTMLConv.kURLs);
     let link = hrefLink(t.url);
     if (!output.includes(link))
       do_throw("Unexpected conversion by scanTXT: input=" + t.input +
                ", output=" + output + ", link=" + link);
   }
 
+  for (let i = 0; i < scanTXTglyph.length; i++) {
+    let t = scanTXTglyph[i];
+    let output = converter.scanTXT(t.input, Ci.mozITXTToHTMLConv.kGlyphSubstitution);
+    for (let j = 0; j < t.results.length; j++)
+      if (!output.includes(t.results[j]))
+        do_throw("Unexpected conversion by scanTXT: input=" + t.input +
+                 ", output=" + output + ", expected=" + t.results[j]);
+  }
+
   for (let i = 0; i < scanHTMLtests.length; i++) {
     let t = scanHTMLtests[i];
     let output = converter.scanHTML(t.input, Ci.mozITXTToHTMLConv.kURLs);
     let changed = (t.input != output);
     if (changed != t.shouldChange) {
       do_throw("Unexpected change by scanHTML: changed=" + changed +
                ", shouldChange=" + t.shouldChange +
                ", \ninput=" + t.input +