Closed Bug 355358 Opened 18 years ago Closed 18 years ago

pnglets don't work anymore

Categories

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

defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: martijn.martijn, Assigned: dbaron)

References

()

Details

(Keywords: regression, verified1.8.1)

Attachments

(2 files, 1 obsolete file)

See url, you should see small images on that site of various forms (red rectangles, blue circles, etc), but they are not visible anymore with current trunk and current 1.8.1 branch builds.

This regressed on trunk between 2006-04-24 and 2006-04-26.
On the 1.8.1 branch this regressed between 2006-05-04 and 2006-05-06.
So it has to be a regression from bug 335298, somehow.

If you need a simplified testcase, then I'll try to make one.
I see multiple times:

Error: pnglets is not defined
Source File: pnglets.line2
Line: 1
(In reply to comment #1)

Hmm, yes, I think that's a different bug that manifests itself on trunk, I filed bug 355365 for it.
Error: uncaught exception: Load of javascript:pnglets.pnglet from http://www.elf.org/pnglets/#rectangle denied.
Flags: blocking1.8.1?
Yeah.  So the problem is that the PNG data is NOT in fact UTF16, even though it's being passed around in a JSString.

I don't really see a way of making both this and non-ASCII HTML returned from javascript: work offhand; to make this work we need to treat each PRUnichar in the JSString as a single byte value (so need to decimate!), while to make non-ASCII HTML work we need to treat it as a Unicode char.

Perhaps we should decimate only if it's lossless or something like that?  That is, if all the PRUnichars only have the low 8 bits set?
Flags: blocking1.9?
OS: Windows XP → All
Hardware: PC → All
I was just going to suggest pretty much the same thing:  we can check if all the characters are either valid ISO-8859-1 or invalid Unicode < 255, and if so, use ISO-8859-1.  (Or did the Unicode spec recently define those characters as something?)
The problem with doing that is that it looks to me like we set the channel on the stream before we have the data.  Is there a reasonably safe way to change that?
er, set the *charset* on the stream
Back in Netscape 2 and 3, JS used only ISO-Latin-1.  The extension to Unicode was straightforward in Netscape 4 (ah, the bliss of pretending Unicode chars were just 16 bits).  But the code that stored and fetched exactly one byte value per string character worked still, and that's the point.  We should still preserve backward compatibility.

/be
You can call SetContentCharset on the channel any time you want to.  Doing so once we're giving it the data in this case should work fine.
This won't block the release of Firefox 2.
Flags: blocking1.8.1? → blocking1.8.1-
Flags: blocking1.8.1.1?
Attached patch patch (against 1.8 branch) (obsolete) — Splinter Review
Assignee: general → dbaron
Status: NEW → ASSIGNED
Attachment #241188 - Flags: review?(bzbarsky)
Comment on attachment 241188 [details] [diff] [review]
patch (against 1.8 branch)

>Index: nsJSProtocolHandler.cpp
>+    else if (IsISO88591(result)) {

I wonder whether it makes sense to factor this a bit better.  something like:

  else {
    PRInt32 resultBytesLength;
    char* resultBytes;
    nsAutoString charset;
    if (IsISO88591(result)) {
      // use result.Length(), ToNewCString, ISO-8859-1
    } else {
      // UTF8
    }

    // NS_NewByteInputStream goes here, using resultBytes, etc.
  }

r=me for the patch as-is if we decide not to do that.
Attachment #241188 - Flags: review?(bzbarsky) → review+
Attached patch trunk patchSplinter Review
This is a trunk patch, with the consolidation.  I can't test it against the pnglets testcase, though...
Attachment #241393 - Flags: superreview?(bzbarsky)
Attachment #241393 - Flags: review?(bzbarsky)
Comment on attachment 241393 [details] [diff] [review]
trunk patch

Looks good.
Attachment #241393 - Flags: superreview?(bzbarsky)
Attachment #241393 - Flags: superreview+
Attachment #241393 - Flags: review?(bzbarsky)
Attachment #241393 - Flags: review+
Checked in to trunk.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Attachment #241393 - Flags: approval1.8.1.1?
We shouldn't break the ability to handle data "packed" one byte per jschar in strings returned via javascript: URLs.  Renominating.

David, why did you nominate the trunk patch for 1.8.1?

/be
Flags: blocking1.8.1- → blocking1.8.1?
It addresses the review comments.  I'll have to merge back to the branch, though.  I'll do that shortly.
Attached patch 1.8 branch patchSplinter Review
This is attachment 241393 [details] [diff] [review] merged back to the 1.8 branch, and tested with both pnglets and the testcase in bug 335298.
Attachment #241188 - Attachment is obsolete: true
Attachment #241470 - Flags: approval1.8.1?
Attachment #241470 - Flags: approval1.8.1.1?
Attachment #241393 - Flags: approval1.8.1?
Attachment #241393 - Flags: approval1.8.1.1?
Blocking for Fx2 RC3
Flags: blocking1.8.1? → blocking1.8.1+
Comment on attachment 241470 [details] [diff] [review]
1.8 branch patch

Approved for RC3.
Attachment #241470 - Flags: approval1.8.1? → approval1.8.1+
Attachment #241470 - Flags: approval1.8.1.1?
Flags: blocking1.8.1.1?
Checked in to MOZILLA_1_8_BRANCH.
Keywords: fixed1.8.1
Is there a way to unit-test this (yet)?
Flags: in-testsuite?
Flags: blocking1.9?
Verified fixed in Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0 (RC3)

Images are now visible and no Errors in the Error Console

Status: RESOLVED → VERIFIED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: