tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_UrlbarUtils_unEscapeURIForUI.js (1004B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 /**
      5 * Test for unEscapeURIForUI function in UrlbarUtils.
      6 */
      7 
      8 "use strict";
      9 
     10 const TEST_DATA = [
     11  {
     12    description: "Test for characters including percent encoded chars",
     13    input: "A%E3%81%82%F0%A0%AE%B7%21",
     14    expected: "Aあ𠮷!",
     15    testMessage: "Unescape given characters correctly",
     16  },
     17  {
     18    description: "Test for characters over the limit",
     19    input: "A%E3%81%82%F0%A0%AE%B7%21".repeat(
     20      Math.ceil(UrlbarUtils.MAX_TEXT_LENGTH / 25)
     21    ),
     22    expected: "A%E3%81%82%F0%A0%AE%B7%21".repeat(
     23      Math.ceil(UrlbarUtils.MAX_TEXT_LENGTH / 25)
     24    ),
     25    testMessage: "Return given characters as it is because of over the limit",
     26  },
     27 ];
     28 
     29 add_task(function () {
     30  for (const { description, input, expected, testMessage } of TEST_DATA) {
     31    info(description);
     32 
     33    const result = UrlbarUtils.unEscapeURIForUI(input);
     34    Assert.equal(result, expected, testMessage);
     35  }
     36 });