Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* The test text decoded correctly as Shift_JIS */ |
michael@0 | 2 | const 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"; |
michael@0 | 3 | |
michael@0 | 4 | const enteredText1="The quick brown fox jumps over the lazy dog"; |
michael@0 | 5 | const 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"; |
michael@0 | 6 | |
michael@0 | 7 | function test() { |
michael@0 | 8 | waitForExplicitFinish(); |
michael@0 | 9 | |
michael@0 | 10 | var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/"; |
michael@0 | 11 | gBrowser.selectedTab = gBrowser.addTab(rootDir + "test-form_sjis.html"); |
michael@0 | 12 | gBrowser.selectedBrowser.addEventListener("load", afterOpen, true); |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | function afterOpen() { |
michael@0 | 16 | gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true); |
michael@0 | 17 | gBrowser.selectedBrowser.addEventListener("load", afterChangeCharset, true); |
michael@0 | 18 | |
michael@0 | 19 | gBrowser.contentDocument.getElementById("testtextarea").value = enteredText1; |
michael@0 | 20 | gBrowser.contentDocument.getElementById("testinput").value = enteredText2; |
michael@0 | 21 | |
michael@0 | 22 | /* Force the page encoding to Shift_JIS */ |
michael@0 | 23 | BrowserSetForcedCharacterSet("Shift_JIS"); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | function afterChangeCharset() { |
michael@0 | 27 | gBrowser.selectedBrowser.removeEventListener("load", afterChangeCharset, true); |
michael@0 | 28 | |
michael@0 | 29 | is(gBrowser.contentDocument.getElementById("testpar").innerHTML, rightText, |
michael@0 | 30 | "encoding successfully changed"); |
michael@0 | 31 | is(gBrowser.contentDocument.getElementById("testtextarea").value, enteredText1, |
michael@0 | 32 | "text preserved in <textarea>"); |
michael@0 | 33 | is(gBrowser.contentDocument.getElementById("testinput").value, enteredText2, |
michael@0 | 34 | "text preserved in <input>"); |
michael@0 | 35 | |
michael@0 | 36 | gBrowser.removeCurrentTab(); |
michael@0 | 37 | finish(); |
michael@0 | 38 | } |