File: browser_bug134911.js

package info (click to toggle)
thunderbird 1%3A52.8.0-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 1,710,120 kB
  • sloc: cpp: 5,081,109; ansic: 2,051,982; python: 458,727; java: 241,615; xml: 193,367; asm: 178,649; sh: 81,881; makefile: 24,703; perl: 16,874; objc: 4,389; yacc: 1,816; ada: 1,697; lex: 1,257; pascal: 1,251; cs: 879; exp: 499; php: 436; lisp: 258; awk: 152; sed: 51; ruby: 47; csh: 27
file content (41 lines) | stat: -rw-r--r-- 1,776 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const TEXT = {
  /* The test text decoded correctly as Shift_JIS */
  rightText: "\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",

  enteredText1: "The quick brown fox jumps over the lazy dog",
  enteredText2: "\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",
};

function test() {
  waitForExplicitFinish();

  var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/";
  gBrowser.selectedTab = gBrowser.addTab(rootDir + "test-form_sjis.html");
  BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(afterOpen);
}

function afterOpen() {
  BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(afterChangeCharset);

  ContentTask.spawn(gBrowser.selectedBrowser, TEXT, function(TEXT) {
    content.document.getElementById("testtextarea").value = TEXT.enteredText1;
    content.document.getElementById("testinput").value = TEXT.enteredText2;
  }).then(() => {
    /* Force the page encoding to Shift_JIS */
    BrowserSetForcedCharacterSet("Shift_JIS");
  });
}

function afterChangeCharset() {
  ContentTask.spawn(gBrowser.selectedBrowser, TEXT, function(TEXT) {
    is(content.document.getElementById("testpar").innerHTML, TEXT.rightText,
       "encoding successfully changed");
    is(content.document.getElementById("testtextarea").value, TEXT.enteredText1,
       "text preserved in <textarea>");
    is(content.document.getElementById("testinput").value, TEXT.enteredText2,
       "text preserved in <input>");
  }).then(() => {
    gBrowser.removeCurrentTab();
    finish();
  });
}