docshell/test/browser/browser_bug234628-11.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 function test() {
michael@0 2 waitForExplicitFinish();
michael@0 3
michael@0 4 var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/";
michael@0 5 gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug234628-11.html");
michael@0 6 gBrowser.selectedBrowser.addEventListener("load", afterOpen, true);
michael@0 7 }
michael@0 8
michael@0 9 function afterOpen(event) {
michael@0 10 if (event.target != gBrowser.contentDocument) {
michael@0 11 return;
michael@0 12 }
michael@0 13
michael@0 14 gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true);
michael@0 15 gBrowser.selectedBrowser.addEventListener("load", afterChangeCharset, true);
michael@0 16
michael@0 17 is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u20AC'), 193, "Parent doc should be windows-1252 initially");
michael@0 18
michael@0 19 is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 107, "Child doc should be utf-8 initially");
michael@0 20
michael@0 21 BrowserSetForcedCharacterSet("windows-1251");
michael@0 22 }
michael@0 23
michael@0 24 function afterChangeCharset(event) {
michael@0 25 if (event.target != gBrowser.contentDocument) {
michael@0 26 return;
michael@0 27 }
michael@0 28
michael@0 29 gBrowser.selectedBrowser.removeEventListener("load", afterChangeCharset, true);
michael@0 30
michael@0 31 is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u0402'), 193, "Parent doc should decode as windows-1251 subsequently");
michael@0 32 is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 107, "Child doc should decode as utf-8 subsequently");
michael@0 33
michael@0 34 is(gBrowser.contentDocument.characterSet, "windows-1251", "Parent doc should report windows-1251 subsequently");
michael@0 35 is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.characterSet, "UTF-8", "Child doc should report UTF-8 subsequently");
michael@0 36
michael@0 37 gBrowser.removeCurrentTab();
michael@0 38 finish();
michael@0 39 }

mercurial