1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/docshell/test/browser/browser_bug941562.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +function test() { 1.5 + waitForExplicitFinish(); 1.6 + 1.7 + var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/"; 1.8 + gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug941562.html"); 1.9 + gBrowser.selectedBrowser.addEventListener("load", afterOpen, true); 1.10 +} 1.11 + 1.12 +function afterOpen(event) { 1.13 + if (event.target != gBrowser.contentDocument) { 1.14 + return; 1.15 + } 1.16 + 1.17 + gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true); 1.18 + gBrowser.selectedBrowser.addEventListener("load", afterChangeCharset, true); 1.19 + 1.20 + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u20AC'), 140, "Parent doc should be windows-1252 initially"); 1.21 + 1.22 + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u4E2D'), 77, "Child doc should be HZ-GB-2312 initially"); 1.23 + 1.24 + BrowserSetForcedCharacterSet("windows-1251"); 1.25 +} 1.26 + 1.27 +function afterChangeCharset(event) { 1.28 + if (event.target != gBrowser.contentDocument) { 1.29 + return; 1.30 + } 1.31 + 1.32 + gBrowser.selectedBrowser.removeEventListener("load", afterChangeCharset, true); 1.33 + 1.34 + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u0402'), 140, "Parent doc should decode as windows-1251 subsequently"); 1.35 + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u4E2D'), 77, "Child doc should decode as HZ-GB-2312 subsequently"); 1.36 + 1.37 + is(gBrowser.contentDocument.characterSet, "windows-1251", "Parent doc should report windows-1251 subsequently"); 1.38 + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.characterSet, "HZ-GB-2312", "Child doc should report HZ-GB-2312 subsequently"); 1.39 + 1.40 + gBrowser.removeCurrentTab(); 1.41 + finish(); 1.42 +}