From 9f3b77fe34be2ed3299fbc333d54371b0f7a81cb Mon Sep 17 00:00:00 2001 From: Henri Sivonen Date: Fri, 18 Jan 2013 16:27:03 +0200 Subject: [PATCH] Bug 234628 part 4 - Test cases for character encoding override code. r=bzbarsky. --HG-- rename : docshell/test/browser/browser_bug134911.js => docshell/test/browser/browser_bug234628-1.js rename : docshell/test/browser/browser_bug134911.js => docshell/test/browser/browser_bug234628-10.js rename : docshell/test/browser/browser_bug134911.js => docshell/test/browser/browser_bug234628-11.js rename : docshell/test/browser/browser_bug134911.js => docshell/test/browser/browser_bug234628-2.js rename : docshell/test/browser/browser_bug134911.js => docshell/test/browser/browser_bug234628-3.js rename : docshell/test/browser/browser_bug134911.js => docshell/test/browser/browser_bug234628-4.js rename : docshell/test/browser/browser_bug134911.js => docshell/test/browser/browser_bug234628-5.js rename : docshell/test/browser/browser_bug134911.js => docshell/test/browser/browser_bug234628-6.js rename : docshell/test/browser/browser_bug134911.js => docshell/test/browser/browser_bug234628-7.js rename : docshell/test/browser/browser_bug134911.js => docshell/test/browser/browser_bug234628-8.js rename : docshell/test/browser/browser_bug134911.js => docshell/test/browser/browser_bug234628-9.js --- docshell/test/browser/Makefile.in | 36 ++++++++++++++++ docshell/test/browser/browser_bug234628-1.js | 39 ++++++++++++++++++ docshell/test/browser/browser_bug234628-10.js | 39 ++++++++++++++++++ docshell/test/browser/browser_bug234628-11.js | 39 ++++++++++++++++++ docshell/test/browser/browser_bug234628-2.js | 39 ++++++++++++++++++ docshell/test/browser/browser_bug234628-3.js | 39 ++++++++++++++++++ docshell/test/browser/browser_bug234628-4.js | 39 ++++++++++++++++++ docshell/test/browser/browser_bug234628-5.js | 39 ++++++++++++++++++ docshell/test/browser/browser_bug234628-6.js | 39 ++++++++++++++++++ docshell/test/browser/browser_bug234628-7.js | 39 ++++++++++++++++++ docshell/test/browser/browser_bug234628-8.js | 23 +++++++++++ docshell/test/browser/browser_bug234628-9.js | 23 +++++++++++ .../test/browser/file_bug234628-1-child.html | 12 ++++++ docshell/test/browser/file_bug234628-1.html | 17 ++++++++ .../browser/file_bug234628-10-child.xhtml | 4 ++ docshell/test/browser/file_bug234628-10.html | 17 ++++++++ .../browser/file_bug234628-11-child.xhtml | 4 ++ .../file_bug234628-11-child.xhtml^headers^ | 1 + docshell/test/browser/file_bug234628-11.html | 17 ++++++++ .../test/browser/file_bug234628-2-child.html | 12 ++++++ docshell/test/browser/file_bug234628-2.html | 17 ++++++++ .../test/browser/file_bug234628-3-child.html | 13 ++++++ docshell/test/browser/file_bug234628-3.html | 18 ++++++++ .../test/browser/file_bug234628-4-child.html | 12 ++++++ docshell/test/browser/file_bug234628-4.html | 18 ++++++++ .../test/browser/file_bug234628-5-child.html | Bin 0 -> 498 bytes docshell/test/browser/file_bug234628-5.html | 18 ++++++++ .../test/browser/file_bug234628-6-child.html | Bin 0 -> 540 bytes .../file_bug234628-6-child.html^headers^ | 1 + docshell/test/browser/file_bug234628-6.html | 18 ++++++++ .../test/browser/file_bug234628-7-child.html | 12 ++++++ .../file_bug234628-7-child.html^headers^ | 1 + docshell/test/browser/file_bug234628-7.html | 18 ++++++++ .../test/browser/file_bug234628-8-child.html | 12 ++++++ docshell/test/browser/file_bug234628-8.html | 17 ++++++++ .../test/browser/file_bug234628-9-child.html | 12 ++++++ docshell/test/browser/file_bug234628-9.html | Bin 0 -> 740 bytes 37 files changed, 704 insertions(+) create mode 100644 docshell/test/browser/browser_bug234628-1.js create mode 100644 docshell/test/browser/browser_bug234628-10.js create mode 100644 docshell/test/browser/browser_bug234628-11.js create mode 100644 docshell/test/browser/browser_bug234628-2.js create mode 100644 docshell/test/browser/browser_bug234628-3.js create mode 100644 docshell/test/browser/browser_bug234628-4.js create mode 100644 docshell/test/browser/browser_bug234628-5.js create mode 100644 docshell/test/browser/browser_bug234628-6.js create mode 100644 docshell/test/browser/browser_bug234628-7.js create mode 100644 docshell/test/browser/browser_bug234628-8.js create mode 100644 docshell/test/browser/browser_bug234628-9.js create mode 100644 docshell/test/browser/file_bug234628-1-child.html create mode 100644 docshell/test/browser/file_bug234628-1.html create mode 100644 docshell/test/browser/file_bug234628-10-child.xhtml create mode 100644 docshell/test/browser/file_bug234628-10.html create mode 100644 docshell/test/browser/file_bug234628-11-child.xhtml create mode 100644 docshell/test/browser/file_bug234628-11-child.xhtml^headers^ create mode 100644 docshell/test/browser/file_bug234628-11.html create mode 100644 docshell/test/browser/file_bug234628-2-child.html create mode 100644 docshell/test/browser/file_bug234628-2.html create mode 100644 docshell/test/browser/file_bug234628-3-child.html create mode 100644 docshell/test/browser/file_bug234628-3.html create mode 100644 docshell/test/browser/file_bug234628-4-child.html create mode 100644 docshell/test/browser/file_bug234628-4.html create mode 100644 docshell/test/browser/file_bug234628-5-child.html create mode 100644 docshell/test/browser/file_bug234628-5.html create mode 100644 docshell/test/browser/file_bug234628-6-child.html create mode 100644 docshell/test/browser/file_bug234628-6-child.html^headers^ create mode 100644 docshell/test/browser/file_bug234628-6.html create mode 100644 docshell/test/browser/file_bug234628-7-child.html create mode 100644 docshell/test/browser/file_bug234628-7-child.html^headers^ create mode 100644 docshell/test/browser/file_bug234628-7.html create mode 100644 docshell/test/browser/file_bug234628-8-child.html create mode 100644 docshell/test/browser/file_bug234628-8.html create mode 100644 docshell/test/browser/file_bug234628-9-child.html create mode 100644 docshell/test/browser/file_bug234628-9.html diff --git a/docshell/test/browser/Makefile.in b/docshell/test/browser/Makefile.in index d69bf51866e6..e6d4b6c9b828 100644 --- a/docshell/test/browser/Makefile.in +++ b/docshell/test/browser/Makefile.in @@ -32,6 +32,42 @@ MOCHITEST_BROWSER_FILES = \ browser_bug670318.js \ file_bug670318.html \ browser_bug673467.js \ + browser_bug234628-1.js \ + file_bug234628-1.html \ + file_bug234628-1-child.html \ + browser_bug234628-2.js \ + file_bug234628-2.html \ + file_bug234628-2-child.html \ + browser_bug234628-3.js \ + file_bug234628-3.html \ + file_bug234628-3-child.html \ + browser_bug234628-4.js \ + file_bug234628-4.html \ + file_bug234628-4-child.html \ + browser_bug234628-5.js \ + file_bug234628-5.html \ + file_bug234628-5-child.html \ + browser_bug234628-6.js \ + file_bug234628-6.html \ + file_bug234628-6-child.html \ + file_bug234628-6-child.html^headers^ \ + browser_bug234628-7.js \ + file_bug234628-7.html \ + file_bug234628-7-child.html \ + file_bug234628-7-child.html^headers^ \ + browser_bug234628-8.js \ + file_bug234628-8.html \ + file_bug234628-8-child.html \ + browser_bug234628-9.js \ + file_bug234628-9.html \ + file_bug234628-9-child.html \ + browser_bug234628-10.js \ + file_bug234628-10.html \ + file_bug234628-10-child.xhtml \ + browser_bug234628-11.js \ + file_bug234628-11.html \ + file_bug234628-11-child.xhtml \ + file_bug234628-11-child.xhtml^headers^ \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/docshell/test/browser/browser_bug234628-1.js b/docshell/test/browser/browser_bug234628-1.js new file mode 100644 index 000000000000..30d6b42ac534 --- /dev/null +++ b/docshell/test/browser/browser_bug234628-1.js @@ -0,0 +1,39 @@ +function test() { + waitForExplicitFinish(); + + var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/"; + gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug234628-1.html"); + gBrowser.selectedBrowser.addEventListener("load", afterOpen, true); +} + +function afterOpen(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true); + gBrowser.selectedBrowser.addEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u20AC'), 129, "Parent doc should be windows-1252 initially"); + + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 85, "Child doc should be windows-1252 initially"); + + BrowserSetForcedCharacterSet("windows-1251"); +} + +function afterChangeCharset(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u0402'), 129, "Parent doc should decode as windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u0402'), 85, "Child doc should decode as windows-1251 subsequently"); + + is(gBrowser.contentDocument.characterSet, "windows-1251", "Parent doc should report windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.characterSet, "windows-1251", "Child doc should report windows-1251 subsequently"); + + gBrowser.removeCurrentTab(); + finish(); +} diff --git a/docshell/test/browser/browser_bug234628-10.js b/docshell/test/browser/browser_bug234628-10.js new file mode 100644 index 000000000000..66c074767c95 --- /dev/null +++ b/docshell/test/browser/browser_bug234628-10.js @@ -0,0 +1,39 @@ +function test() { + waitForExplicitFinish(); + + var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/"; + gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug234628-10.html"); + gBrowser.selectedBrowser.addEventListener("load", afterOpen, true); +} + +function afterOpen(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true); + gBrowser.selectedBrowser.addEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u20AC'), 151, "Parent doc should be windows-1252 initially"); + + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 71, "Child doc should be utf-8 initially"); + + BrowserSetForcedCharacterSet("windows-1251"); +} + +function afterChangeCharset(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u0402'), 151, "Parent doc should decode as windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 71, "Child doc should decode as utf-8 subsequently"); + + is(gBrowser.contentDocument.characterSet, "windows-1251", "Parent doc should report windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.characterSet, "UTF-8", "Child doc should report UTF-8 subsequently"); + + gBrowser.removeCurrentTab(); + finish(); +} diff --git a/docshell/test/browser/browser_bug234628-11.js b/docshell/test/browser/browser_bug234628-11.js new file mode 100644 index 000000000000..f2f0a5a6f1b4 --- /dev/null +++ b/docshell/test/browser/browser_bug234628-11.js @@ -0,0 +1,39 @@ +function test() { + waitForExplicitFinish(); + + var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/"; + gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug234628-11.html"); + gBrowser.selectedBrowser.addEventListener("load", afterOpen, true); +} + +function afterOpen(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true); + gBrowser.selectedBrowser.addEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u20AC'), 193, "Parent doc should be windows-1252 initially"); + + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 107, "Child doc should be utf-8 initially"); + + BrowserSetForcedCharacterSet("windows-1251"); +} + +function afterChangeCharset(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u0402'), 193, "Parent doc should decode as windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 107, "Child doc should decode as utf-8 subsequently"); + + is(gBrowser.contentDocument.characterSet, "windows-1251", "Parent doc should report windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.characterSet, "UTF-8", "Child doc should report UTF-8 subsequently"); + + gBrowser.removeCurrentTab(); + finish(); +} diff --git a/docshell/test/browser/browser_bug234628-2.js b/docshell/test/browser/browser_bug234628-2.js new file mode 100644 index 000000000000..9b5a3c7e50d7 --- /dev/null +++ b/docshell/test/browser/browser_bug234628-2.js @@ -0,0 +1,39 @@ +function test() { + waitForExplicitFinish(); + + var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/"; + gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug234628-2.html"); + gBrowser.selectedBrowser.addEventListener("load", afterOpen, true); +} + +function afterOpen(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true); + gBrowser.selectedBrowser.addEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u20AC'), 129, "Parent doc should be windows-1252 initially"); + + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u00E2\u201A\u00AC'), 78, "Child doc should be windows-1252 initially"); + + BrowserSetForcedCharacterSet("windows-1251"); +} + +function afterChangeCharset(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u0402'), 129, "Parent doc should decode as windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u0432\u201A\u00AC'), 78, "Child doc should decode as windows-1251 subsequently"); + + is(gBrowser.contentDocument.characterSet, "windows-1251", "Parent doc should report windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.characterSet, "windows-1251", "Child doc should report windows-1251 subsequently"); + + gBrowser.removeCurrentTab(); + finish(); +} diff --git a/docshell/test/browser/browser_bug234628-3.js b/docshell/test/browser/browser_bug234628-3.js new file mode 100644 index 000000000000..7149ce309cb6 --- /dev/null +++ b/docshell/test/browser/browser_bug234628-3.js @@ -0,0 +1,39 @@ +function test() { + waitForExplicitFinish(); + + var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/"; + gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug234628-3.html"); + gBrowser.selectedBrowser.addEventListener("load", afterOpen, true); +} + +function afterOpen(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true); + gBrowser.selectedBrowser.addEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u20AC'), 118, "Parent doc should be windows-1252 initially"); + + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 73, "Child doc should be utf-8 initially"); + + BrowserSetForcedCharacterSet("windows-1251"); +} + +function afterChangeCharset(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u0402'), 118, "Parent doc should decode as windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u0432\u201A\u00AC'), 73, "Child doc should decode as windows-1251 subsequently"); + + is(gBrowser.contentDocument.characterSet, "windows-1251", "Parent doc should report windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.characterSet, "windows-1251", "Child doc should report windows-1251 subsequently"); + + gBrowser.removeCurrentTab(); + finish(); +} diff --git a/docshell/test/browser/browser_bug234628-4.js b/docshell/test/browser/browser_bug234628-4.js new file mode 100644 index 000000000000..7eceed508580 --- /dev/null +++ b/docshell/test/browser/browser_bug234628-4.js @@ -0,0 +1,39 @@ +function test() { + waitForExplicitFinish(); + + var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/"; + gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug234628-4.html"); + gBrowser.selectedBrowser.addEventListener("load", afterOpen, true); +} + +function afterOpen(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true); + gBrowser.selectedBrowser.addEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u20AC'), 132, "Parent doc should be windows-1252 initially"); + + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 79, "Child doc should be utf-8 initially"); + + BrowserSetForcedCharacterSet("windows-1251"); +} + +function afterChangeCharset(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u0402'), 132, "Parent doc should decode as windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 79, "Child doc should decode as utf-8 subsequently"); + + is(gBrowser.contentDocument.characterSet, "windows-1251", "Parent doc should report windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.characterSet, "UTF-8", "Child doc should report UTF-8 subsequently"); + + gBrowser.removeCurrentTab(); + finish(); +} diff --git a/docshell/test/browser/browser_bug234628-5.js b/docshell/test/browser/browser_bug234628-5.js new file mode 100644 index 000000000000..1795c8916a02 --- /dev/null +++ b/docshell/test/browser/browser_bug234628-5.js @@ -0,0 +1,39 @@ +function test() { + waitForExplicitFinish(); + + var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/"; + gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug234628-5.html"); + gBrowser.selectedBrowser.addEventListener("load", afterOpen, true); +} + +function afterOpen(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true); + gBrowser.selectedBrowser.addEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u20AC'), 146, "Parent doc should be windows-1252 initially"); + + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 87, "Child doc should be utf-16 initially"); + + BrowserSetForcedCharacterSet("windows-1251"); +} + +function afterChangeCharset(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u0402'), 146, "Parent doc should decode as windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 87, "Child doc should decode as utf-16 subsequently"); + + is(gBrowser.contentDocument.characterSet, "windows-1251", "Parent doc should report windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.characterSet, "UTF-16", "Child doc should report UTF-16 subsequently"); + + gBrowser.removeCurrentTab(); + finish(); +} diff --git a/docshell/test/browser/browser_bug234628-6.js b/docshell/test/browser/browser_bug234628-6.js new file mode 100644 index 000000000000..72d85d618b89 --- /dev/null +++ b/docshell/test/browser/browser_bug234628-6.js @@ -0,0 +1,39 @@ +function test() { + waitForExplicitFinish(); + + var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/"; + gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug234628-6.html"); + gBrowser.selectedBrowser.addEventListener("load", afterOpen, true); +} + +function afterOpen(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true); + gBrowser.selectedBrowser.addEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u20AC'), 190, "Parent doc should be windows-1252 initially"); + + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 109, "Child doc should be utf-16 initially"); + + BrowserSetForcedCharacterSet("windows-1251"); +} + +function afterChangeCharset(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u0402'), 190, "Parent doc should decode as windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 109, "Child doc should decode as utf-16 subsequently"); + + is(gBrowser.contentDocument.characterSet, "windows-1251", "Parent doc should report windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.characterSet, "UTF-16BE", "Child doc should report UTF-16 subsequently"); + + gBrowser.removeCurrentTab(); + finish(); +} diff --git a/docshell/test/browser/browser_bug234628-7.js b/docshell/test/browser/browser_bug234628-7.js new file mode 100644 index 000000000000..86b93bbbdf86 --- /dev/null +++ b/docshell/test/browser/browser_bug234628-7.js @@ -0,0 +1,39 @@ +function test() { + waitForExplicitFinish(); + + var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/"; + gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug234628-7.html"); + gBrowser.selectedBrowser.addEventListener("load", afterOpen, true); +} + +function afterOpen(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true); + gBrowser.selectedBrowser.addEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u20AC'), 188, "Parent doc should be windows-1252 initially"); + + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 107, "Child doc should be utf-8 initially"); + + BrowserSetForcedCharacterSet("windows-1251"); +} + +function afterChangeCharset(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterChangeCharset, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u0402'), 188, "Parent doc should decode as windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u0432\u201A\u00AC'), 107, "Child doc should decode as windows-1251 subsequently"); + + is(gBrowser.contentDocument.characterSet, "windows-1251", "Parent doc should report windows-1251 subsequently"); + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.characterSet, "windows-1251", "Child doc should report windows-1251 subsequently"); + + gBrowser.removeCurrentTab(); + finish(); +} diff --git a/docshell/test/browser/browser_bug234628-8.js b/docshell/test/browser/browser_bug234628-8.js new file mode 100644 index 000000000000..bc25b17cbae1 --- /dev/null +++ b/docshell/test/browser/browser_bug234628-8.js @@ -0,0 +1,23 @@ +function test() { + waitForExplicitFinish(); + + var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/"; + gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug234628-8.html"); + gBrowser.selectedBrowser.addEventListener("load", afterOpen, true); +} + +function afterOpen(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u0402'), 156, "Parent doc should be windows-1251"); + + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u0402'), 99, "Child doc should be windows-1251"); + + gBrowser.removeCurrentTab(); + finish(); +} + diff --git a/docshell/test/browser/browser_bug234628-9.js b/docshell/test/browser/browser_bug234628-9.js new file mode 100644 index 000000000000..234ac9e6467e --- /dev/null +++ b/docshell/test/browser/browser_bug234628-9.js @@ -0,0 +1,23 @@ +function test() { + waitForExplicitFinish(); + + var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/"; + gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug234628-9.html"); + gBrowser.selectedBrowser.addEventListener("load", afterOpen, true); +} + +function afterOpen(event) { + if (event.target != gBrowser.contentDocument) { + return; + } + + gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true); + + is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u20AC'), 145, "Parent doc should be UTF-16"); + + is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u20AC'), 96, "Child doc should be windows-1252"); + + gBrowser.removeCurrentTab(); + finish(); +} + diff --git a/docshell/test/browser/file_bug234628-1-child.html b/docshell/test/browser/file_bug234628-1-child.html new file mode 100644 index 000000000000..c36197ac4fd9 --- /dev/null +++ b/docshell/test/browser/file_bug234628-1-child.html @@ -0,0 +1,12 @@ + + + + +No encoding declaration in parent or child + + +

Euro sign if decoded as Windows-1252: €

+

a with diaeresis if decoded as Windows-1252: ä

+ + + diff --git a/docshell/test/browser/file_bug234628-1.html b/docshell/test/browser/file_bug234628-1.html new file mode 100644 index 000000000000..11c523ccd9f7 --- /dev/null +++ b/docshell/test/browser/file_bug234628-1.html @@ -0,0 +1,17 @@ + + + + +No encoding declaration in parent or child + + +

No encoding declaration in parent or child

+ +

Euro sign if decoded as Windows-1252: €

+

a with diaeresis if decoded as Windows-1252: ä

+ + + + + + diff --git a/docshell/test/browser/file_bug234628-10-child.xhtml b/docshell/test/browser/file_bug234628-10-child.xhtml new file mode 100644 index 000000000000..cccf6f2bc0fc --- /dev/null +++ b/docshell/test/browser/file_bug234628-10-child.xhtml @@ -0,0 +1,4 @@ + +XML child with no encoding declaration +

Euro sign if decoded as UTF-8: €

+ diff --git a/docshell/test/browser/file_bug234628-10.html b/docshell/test/browser/file_bug234628-10.html new file mode 100644 index 000000000000..78b8f0035daa --- /dev/null +++ b/docshell/test/browser/file_bug234628-10.html @@ -0,0 +1,17 @@ + + + + +No encoding declaration in HTML parent or XHTML child + + +

No encoding declaration in HTML parent or XHTML child

+ +

Euro sign if decoded as Windows-1252: €

+

a with diaeresis if decoded as Windows-1252: ä

+ + + + + + diff --git a/docshell/test/browser/file_bug234628-11-child.xhtml b/docshell/test/browser/file_bug234628-11-child.xhtml new file mode 100644 index 000000000000..11ef668b0c76 --- /dev/null +++ b/docshell/test/browser/file_bug234628-11-child.xhtml @@ -0,0 +1,4 @@ + +No encoding declaration in HTML parent and HTTP declaration in XHTML child +

Euro sign if decoded as UTF-8: €

+ diff --git a/docshell/test/browser/file_bug234628-11-child.xhtml^headers^ b/docshell/test/browser/file_bug234628-11-child.xhtml^headers^ new file mode 100644 index 000000000000..30fb30405616 --- /dev/null +++ b/docshell/test/browser/file_bug234628-11-child.xhtml^headers^ @@ -0,0 +1 @@ +Content-Type: application/xhtml+xml; charset=utf-8 diff --git a/docshell/test/browser/file_bug234628-11.html b/docshell/test/browser/file_bug234628-11.html new file mode 100644 index 000000000000..21c5b733e005 --- /dev/null +++ b/docshell/test/browser/file_bug234628-11.html @@ -0,0 +1,17 @@ + + + + +No encoding declaration in HTML parent and HTTP declaration in XHTML child + + +

No encoding declaration in HTML parent and HTTP declaration in XHTML child

+ +

Euro sign if decoded as Windows-1252: €

+

a with diaeresis if decoded as Windows-1252: ä

+ + + + + + diff --git a/docshell/test/browser/file_bug234628-2-child.html b/docshell/test/browser/file_bug234628-2-child.html new file mode 100644 index 000000000000..0acd2e0b278b --- /dev/null +++ b/docshell/test/browser/file_bug234628-2-child.html @@ -0,0 +1,12 @@ + + + + +No encoding declaration in parent or child + + +

Euro sign if decoded as UTF-8: €

+

a with diaeresis if decoded as UTF-8: ä

+ + + diff --git a/docshell/test/browser/file_bug234628-2.html b/docshell/test/browser/file_bug234628-2.html new file mode 100644 index 000000000000..a87d29e12602 --- /dev/null +++ b/docshell/test/browser/file_bug234628-2.html @@ -0,0 +1,17 @@ + + + + +No encoding declaration in parent or child + + +

No encoding declaration in parent or child

+ +

Euro sign if decoded as Windows-1252: €

+

a with diaeresis if decoded as Windows-1252: ä

+ + + + + + diff --git a/docshell/test/browser/file_bug234628-3-child.html b/docshell/test/browser/file_bug234628-3-child.html new file mode 100644 index 000000000000..a6ad832310f3 --- /dev/null +++ b/docshell/test/browser/file_bug234628-3-child.html @@ -0,0 +1,13 @@ + + + + + +meta declaration in parent and child + + +

Euro sign if decoded as UTF-8: €

+

a with diaeresis if decoded as UTF-8: ä

+ + + diff --git a/docshell/test/browser/file_bug234628-3.html b/docshell/test/browser/file_bug234628-3.html new file mode 100644 index 000000000000..8caab6040283 --- /dev/null +++ b/docshell/test/browser/file_bug234628-3.html @@ -0,0 +1,18 @@ + + + + + +meta declaration in parent and child + + +

meta declaration in parent and child

+ +

Euro sign if decoded as Windows-1252: €

+

a with diaeresis if decoded as Windows-1252: ä

+ + + + + + diff --git a/docshell/test/browser/file_bug234628-4-child.html b/docshell/test/browser/file_bug234628-4-child.html new file mode 100644 index 000000000000..f0e7c2c05871 --- /dev/null +++ b/docshell/test/browser/file_bug234628-4-child.html @@ -0,0 +1,12 @@ + + + + +meta declaration in parent and BOM in child + + +

Euro sign if decoded as UTF-8: €

+

a with diaeresis if decoded as UTF-8: ä

+ + + diff --git a/docshell/test/browser/file_bug234628-4.html b/docshell/test/browser/file_bug234628-4.html new file mode 100644 index 000000000000..0137579010a5 --- /dev/null +++ b/docshell/test/browser/file_bug234628-4.html @@ -0,0 +1,18 @@ + + + + + +meta declaration in parent and BOM in child + + +

meta declaration in parent and BOM in child

+ +

Euro sign if decoded as Windows-1252: €

+

a with diaeresis if decoded as Windows-1252: ä

+ + + + + + diff --git a/docshell/test/browser/file_bug234628-5-child.html b/docshell/test/browser/file_bug234628-5-child.html new file mode 100644 index 0000000000000000000000000000000000000000..a650552f63907ef61222adb5b151725efdf7027f GIT binary patch literal 498 zcmY+Bzf!_L5XQfnr#Mr~Ff<@852I ze};O{i{^UPQtw)5DyJ_+ZM4={9Sz&c@g>){RvIaj=a#hyPp53E4ZTS1RA>t-CTvWs zlLEMi=7`hlNL_Gtb?ZFB4DbTDfX + + + + +meta declaration in parent and UTF-16 BOM in child + + +

meta declaration in parent and UTF-16 BOM in child

+ +

Euro sign if decoded as Windows-1252: €

+

a with diaeresis if decoded as Windows-1252: ä

+ + + + + + diff --git a/docshell/test/browser/file_bug234628-6-child.html b/docshell/test/browser/file_bug234628-6-child.html new file mode 100644 index 0000000000000000000000000000000000000000..52c37f259691ef5dff02847d3c1da69ccad2fa3e GIT binary patch literal 540 zcmZ9JF;4T+w!4 zIa3FhG1*3?n&4@<>(I3i{_N62W`1At6=$u!`n&FkGri+(3sVQ + + + + +meta declaration in parent and BOMless UTF-16 with HTTP charset in child + + +

meta declaration in parent and BOMless UTF-16 with HTTP charset in child

+ +

Euro sign if decoded as Windows-1252: €

+

a with diaeresis if decoded as Windows-1252: ä

+ + + + + + diff --git a/docshell/test/browser/file_bug234628-7-child.html b/docshell/test/browser/file_bug234628-7-child.html new file mode 100644 index 000000000000..c761ace1016b --- /dev/null +++ b/docshell/test/browser/file_bug234628-7-child.html @@ -0,0 +1,12 @@ + + + + +meta declaration in parent and BOMless UTF-8 with HTTP charset in child + + +

Euro sign if decoded as UTF-8: €

+

a with diaeresis if decoded as UTF-8: ä

+ + + diff --git a/docshell/test/browser/file_bug234628-7-child.html^headers^ b/docshell/test/browser/file_bug234628-7-child.html^headers^ new file mode 100644 index 000000000000..2d1c08b9e8aa --- /dev/null +++ b/docshell/test/browser/file_bug234628-7-child.html^headers^ @@ -0,0 +1 @@ +Content-Type: text/html; charset=utf-8 diff --git a/docshell/test/browser/file_bug234628-7.html b/docshell/test/browser/file_bug234628-7.html new file mode 100644 index 000000000000..7cb506096d9c --- /dev/null +++ b/docshell/test/browser/file_bug234628-7.html @@ -0,0 +1,18 @@ + + + + + +meta declaration in parent and BOMless UTF-8 with HTTP charset in child + + +

meta declaration in parent and BOMless UTF-8 with HTTP charset in child

+ +

Euro sign if decoded as Windows-1252: €

+

a with diaeresis if decoded as Windows-1252: ä

+ + + + + + diff --git a/docshell/test/browser/file_bug234628-8-child.html b/docshell/test/browser/file_bug234628-8-child.html new file mode 100644 index 000000000000..254e0fb2b354 --- /dev/null +++ b/docshell/test/browser/file_bug234628-8-child.html @@ -0,0 +1,12 @@ + + + + +meta declaration in parent and no declaration in child + + +

Capital dje if decoded as Windows-1251: €

+ + + + diff --git a/docshell/test/browser/file_bug234628-8.html b/docshell/test/browser/file_bug234628-8.html new file mode 100644 index 000000000000..b44e91801cbf --- /dev/null +++ b/docshell/test/browser/file_bug234628-8.html @@ -0,0 +1,17 @@ + + + + + +meta declaration in parent and no declaration in child + + +

meta declaration in parent and no declaration in child

+ +

Capital dje if decoded as Windows-1251: €

+ + + + + + diff --git a/docshell/test/browser/file_bug234628-9-child.html b/docshell/test/browser/file_bug234628-9-child.html new file mode 100644 index 000000000000..a86b14d7ee54 --- /dev/null +++ b/docshell/test/browser/file_bug234628-9-child.html @@ -0,0 +1,12 @@ + + + + +UTF-16 with BOM in parent and no declaration in child + + +

Euro sign if decoded as Windows-1251: €

+ + + + diff --git a/docshell/test/browser/file_bug234628-9.html b/docshell/test/browser/file_bug234628-9.html new file mode 100644 index 0000000000000000000000000000000000000000..8a469da3aa4395fef8a7b57c59f60f5e84d58265 GIT binary patch literal 740 zcmchV!A`^{iJtX(FdWK`T`ntEXY>Ic{cJE7wSUd8~e$;fZ98w;~qsofdi{ zE5zIot3Fkd7r-2GdVSz8I8Stl98+0RSCUtPQxV;fWtOKdrLQACV@C7)5ygYBq2HFO z{ajWbV%1nL@Vf^o)dkho&8Bd=f%`+#(Sa}n!MFwPjBUob2G_-T7g2*P5yLii^{mFV z;HDyLs3b=BolV1pXjh{-wVA$J{Zg#|ov=U&+pkTx!J6nD=EidekGx^FY