Closed Bug 376760 Opened 18 years ago Closed 18 years ago

Character set encoding erroneously changed to UTF-16 on reload from cache for async-written doc

Categories

(Core :: DOM: Core & HTML, defect)

x86
FreeBSD
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 255820

People

(Reporter: keefedm, Unassigned)

References

Details

User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8.1.3) Gecko/20070405 Firefox/2.0.0.3 Build Identifier: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8.1.3) Gecko/20070405 Firefox/2.0.0.3 When dynamic doc is written asynchronously (i.e. by event irrespective/after window.onload has fired, as can happen when loading resources via XMLHttpRequest), it renders correctly. However, when reloaded from cache, character set encoding is erroneously changed from original (e.g. UTF-8) to UTF-16. This in turn can cause other problems, such as linked CSS style info being lost (possibly because it tries to also treat linked file as UTF-16); in-page styles are properly honored though. Only happens for cached reload (toobar btn, Ctrl-R, etc.); forced reload (shortcut, addr bar, etc.) result in correct display again. Reproducible: Always Steps to Reproduce: 1. Place following example in file local file and load in Firefox. <html><head><script type="text/javascript"> Write = function() { document.open(); document.write('<html><head></head><body><button onclick="alert(document.characterSet)">Test</button></body></html>'); document.close(); } window.setTimeout(Write, 500); </script></head><body></body></html> 2. Click Test button. Doc charset encoding is displayed (e.g. UTF-8). 3. Reload page from cache (via toolbar button, Ctrl-R, etc.). 4. Click Test button. Incorrect/changed charset encoding (UTF-16) is displayed. Actual Results: Incorrect/changed charset encoding (UTF-16) is displayed/used. If page contains linked [non UTF-16] CSS (omitted from example for brevity), it is not factored when page is [re]rendered. Expected Results: Reload from cache should not arbitrarily change charset to UTF-16, and should generally behave correctly (as original load and forced reload do). Other browsers (IE, Opera, Konqueror, Safari) do not exhibit this problem. Seems limited to cached reloads (so suggest focusing there).
This is basically the same issue as bug 255820.
Depends on: 255820
Sounds like underlying root might be same. Further observations: 255820 seems to refer to obtaining desired result by explicitly setting charset in meta tag before any other content; however, I always get UTF-16 after cached reload despite setting charset to ISO-8859-1 (default) or UTF-8. Problem doesn't manifest unless content is written during async event (XMLHttpRequest response, timer, etc.). If write is done before window.onload fires/finishes, correct charset is preserved during all reloads (cached or otherwise). For instance, in the example code above, if window.setTimeout statement is changed to window.onload=Write or just Write(), it works fine. When the document is written after load (problem scenario), source view shows only dynamically written markup. When written before/during load (non-problem scenario), source view shows original/full content.
Testing/verifying 255820's wyciwyg theory for this scenario: Tested disabling both browser.cache.disk and browser.cache.memory; either alone seems insufficient, but disabling both eliminates problem.
Problem doesn't just prevent loading of linked text items (CSS, scripts), but binary items as well (images).
Boris, you'd know best. Is this bug a dupe of bug 255820 (per comment 1)? If not, can this bug be confirmed as something separate? (Sending this to Core, since that's where the other bug is.)
Assignee: nobody → general
Component: General → DOM: Level 0
Product: Firefox → Core
QA Contact: general → ian
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.