tor-browser

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

browser_bug134911.js (1882B)


      1 const TEXT = {
      2  /* The test text decoded correctly as Shift_JIS */
      3  rightText:
      4    "\u30E6\u30CB\u30B3\u30FC\u30C9\u306F\u3001\u3059\u3079\u3066\u306E\u6587\u5B57\u306B\u56FA\u6709\u306E\u756A\u53F7\u3092\u4ED8\u4E0E\u3057\u307E\u3059",
      5 
      6  enteredText1: "The quick brown fox jumps over the lazy dog",
      7  enteredText2:
      8    "\u03BE\u03B5\u03C3\u03BA\u03B5\u03C0\u03AC\u03B6\u03C9\u0020\u03C4\u1F74\u03BD\u0020\u03C8\u03C5\u03C7\u03BF\u03C6\u03B8\u03CC\u03C1\u03B1\u0020\u03B2\u03B4\u03B5\u03BB\u03C5\u03B3\u03BC\u03AF\u03B1",
      9 };
     10 
     11 function test() {
     12  waitForExplicitFinish();
     13 
     14  var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/";
     15  gBrowser.selectedTab = BrowserTestUtils.addTab(
     16    gBrowser,
     17    rootDir + "test-form_sjis.html"
     18  );
     19  BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(afterOpen);
     20 }
     21 
     22 function afterOpen() {
     23  BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(
     24    afterChangeCharset
     25  );
     26 
     27  SpecialPowers.spawn(gBrowser.selectedBrowser, [TEXT], function (TEXT) {
     28    content.document.getElementById("testtextarea").value = TEXT.enteredText1;
     29    content.document.getElementById("testinput").value = TEXT.enteredText2;
     30  }).then(() => {
     31    /* Force the page encoding to Shift_JIS */
     32    BrowserCommands.forceEncodingDetection();
     33  });
     34 }
     35 
     36 function afterChangeCharset() {
     37  SpecialPowers.spawn(gBrowser.selectedBrowser, [TEXT], function (TEXT) {
     38    is(
     39      content.document.getElementById("testpar").innerHTML,
     40      TEXT.rightText,
     41      "encoding successfully changed"
     42    );
     43    is(
     44      content.document.getElementById("testtextarea").value,
     45      TEXT.enteredText1,
     46      "text preserved in <textarea>"
     47    );
     48    is(
     49      content.document.getElementById("testinput").value,
     50      TEXT.enteredText2,
     51      "text preserved in <input>"
     52    );
     53  }).then(() => {
     54    gBrowser.removeCurrentTab();
     55    finish();
     56  });
     57 }