Closed Bug 484305 Opened 16 years ago Closed 11 years ago

Workers: loaded scripts may be decoded using wrong text encoding.

Categories

(Core :: DOM: Workers, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla27

People

(Reporter: dimich, Assigned: nsm)

Details

Attachments

(3 files, 2 obsolete files)

User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1 Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2a1pre) Gecko/20090310 Minefield/3.2a1pre Discussion in whatwg mail list clarifies that content of the scripts loaded as a result of 'new Worker(url)' or 'importScripts(url)' should be decoded using UTF-8 or the encoding specified in Content-Type http header, if present. FF decodes the scripts using the encoding of the parent document. This is correct for <script> tag, but not for Workers. Reproducible: Always
Isn't this a duplicate of bug 482388?
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
Attached test file - download both repro.html and repro-worker.js and open repro.html. The test itself is encoded using KOI8-r encoding (Russian). It has a test string to verify the encoding. The test spawns a worker from the file which contains the same test string encoded in both KOI8-R and UTF-8. The UTF-8 one should match because the script should be decoded using UTF-8 encoding by default. Actual result: the KOI8-R matches because the scritp is decoded using the encoding of the parent document.
(In reply to comment #2) > Isn't this a duplicate of bug 482388? No, because that one is about which encoding to use for the URL query portion that gets sent to the server. This one is about which encoding to use while decoding the received script. Sounds similar, but it might be the different places in code are affected.
Passes bug test case.
Attachment #814609 - Flags: review?(bent.mozilla)
Assignee: nobody → nsm.nikhil
Component: DOM → DOM: Workers
Comment on attachment 814609 [details] [diff] [review] Worker scripts should always be decoded as UTF-8. Review of attachment 814609 [details] [diff] [review]: ----------------------------------------------------------------- This looks great. Can we please have a test before this gets checked in? ::: dom/workers/ScriptLoader.cpp @@ +439,5 @@ > nsIDocument* parentDoc = mWorkerPrivate->GetDocument(); > > // Use the regular nsScriptLoader for this grunt work! Should be just fine > // because we're running on the main thread. > + // NOTE: Unlike <script> tags, Worker scripts are always decoded as UTF-8, Nit: Adding 'NOTE:' to a comment is a little redundant. You're noting it already ;)
Attachment #814609 - Flags: review?(bent.mozilla) → review+
Status: UNCONFIRMED → NEW
Ever confirmed: true
Updated to add test case based on original failure example.
Comment on attachment 815132 [details] [diff] [review] Worker scripts should always be decoded as UTF-8. Waiting for try-server results before checkin.
Attachment #815132 - Flags: review+
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla27
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: