Bug 9815

Summary: JavaScript TypeError loading Dean Edwards' JS compressor/obfuscator
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: allan28, ggaren
Priority: P2 Keywords: HasReduction
Version: 418.x   
Hardware: Mac   
OS: OS X 10.4   
URL: http://dean.edwards.name/packer/
Attachments:
Description Flags
JS snippet demonstrating js bug
none
Test case
none
Patch v1 darin: review+

David Kilzer (:ddkilzer)
Reported 2006-07-09 17:29:24 PDT
I got a type error when loading Dean Edwards' JavaScript Compressor/Obfuscator (see URL).  This error needs to be reduced. [22954] http://dean.edwards.name/packer/packer-p.js line 1: TypeError: Value undefined (result of expression c.valueOf.prototype.specialize) is not object. Using Safari 2.0.4 (419.3) with locally-built WebKit r15267 with a WIP patch for Bug 9179 on Mac OS X 10.4.7 (8J135/PowerPC).
Attachments
JS snippet demonstrating js bug (361 bytes, application/x-javascript)
2006-09-27 14:51 PDT, allan28
no flags
Test case (380 bytes, text/html)
2007-01-07 20:38 PST, David Kilzer (:ddkilzer)
no flags
Patch v1 (4.04 KB, patch)
2007-01-28 11:08 PST, David Kilzer (:ddkilzer)
darin: review+
allan28
Comment 1 2006-09-27 14:51:02 PDT
Created attachment 10808 [details] JS snippet demonstrating js bug Looks to be problem with creating new from "reference"? "new this.valueOf" causes new object in Firefox but not Safari. Reduced code from Dean Edwards ie7.js, which looks to use the same OO routines (the packer is obfuscated).
David Kilzer (:ddkilzer)
Comment 2 2007-01-07 20:38:30 PST
Created attachment 12291 [details] Test case Wrapped Attachment 10808 [details] in <script></script> tags.
David Kilzer (:ddkilzer)
Comment 3 2007-01-26 16:01:47 PST
(In reply to comment #2) > Created an attachment (id=12291) [edit] > Test case > > Wrapped Attachment 10808 [details] [edit] in <script></script> tags. Incorrect behavior prints "undefined" in the alert. Correct behavior prints "function() { }" (on multiple lines) in the alert.
David Kilzer (:ddkilzer)
Comment 4 2007-01-28 08:32:43 PST
It appears that assigning new Function() to a variable does not set it's prototype, while assigning an anonymous function does. Thus if you change this line: ICommon.valueOf = new Function("return this"); to this: ICommon.valueOf = function(){ return this; }; the test case will work.
David Kilzer (:ddkilzer)
Comment 5 2007-01-28 11:07:42 PST
This bug is in JavaScriptCore, and exists in shipping Safari 2.0.4 (419.3) on Mac OS X 10.4.8 (8N1037). I also have a patch to fix it.
David Kilzer (:ddkilzer)
Comment 6 2007-01-28 11:08:44 PST
Created attachment 12727 [details] Patch v1 Proposed fix.
David Kilzer (:ddkilzer)
Comment 7 2007-01-28 11:23:33 PST
(In reply to comment #6) > Created an attachment (id=12727) [edit] > Patch v1 > Proposed fix. Note that all JavaScriptCore tests and all layout tests pass with this change.
Darin Adler
Comment 8 2007-01-28 18:30:05 PST
Comment on attachment 12727 [details] Patch v1 r=me
David Kilzer (:ddkilzer)
Comment 9 2007-01-28 18:50:20 PST
Committed revision 19203.
Note You need to log in before you can comment on or make changes to this bug.