Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(120)

Issue 135054: fix fn.apply() and Array.slice() on IE[678] (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
16 years, 7 months ago by felix8a
Modified:
16 years, 7 months ago
Reviewers:
MikeSamuel
CC:
google-caja-discuss_googlegroups.com
Base URL:
http://google-caja.googlecode.com/svn/trunk/
Visibility:
Public.

Description

this fixes http://code.google.com/p/google-caja/issues/detail?id=1077 fn.apply() has trouble on IE[678] because IE's native apply doesn't conform to standards. ES5 says that these should all be equivalent: fn.apply(x) fn.apply(x, []) fn.apply(x, null) fn.apply(x, void 0) but IE throws a type error for the last two. there was a previous patch that fixed this problem in most cases, but it didn't fix the case of valija-mode Object.prototype.toString.apply(x) which is a common technique to get the native type of x. I think this patch now fixes fn.apply() behavior in almost all cases. there are still two deviations from ES5 behavior, mentioned in domita_test_untrusted.html 1. if fn.apply is the native apply, not a caja wrapper, then fn.apply(x, null) will throw a type error on IE. to fix that, fn.apply would have to always be a wrapper on IE. I don't think it's worth fixing that, because it's easy for programs to avoid the problem. and since this is an existing browser incompatibility, it's unlikely that programs rely on that specific behavior. 2. fn.apply(x, 9) is supposed to throw a type error, but when fn.apply is a caja wrapper, it's sometimes equivalent to fn.apply(x, undefined). to fix that, the fn.apply wrappers that use Array.slice would have to do a complex typecheck: throw an error unless args is null or undefined or an array or an array-like object like "arguments". I don't think that's worth it, since I can't think of a plausible reason that code would rely on getting a type error here.

Patch Set 1 #

Total comments: 13

Patch Set 2 : fix fn.apply() and Array.slice() on IE[678] #

Patch Set 3 : fix fn.apply() and Array.slice() on IE[678] #

Unified diffs Side-by-side diffs Delta from patch set Stats (+92 lines, -16 lines) Patch
M src/com/google/caja/cajita.js View 1 2 6 chunks +17 lines, -12 lines 0 comments Download
M tests/com/google/caja/plugin/domita_test_untrusted.html View 1 2 2 chunks +75 lines, -4 lines 0 comments Download

Messages

Total messages: 7
felix8a
16 years, 7 months ago (2009-10-20 03:48:11 UTC) #1
MikeSamuel
http://codereview.appspot.com/135054/diff/1/3 File src/com/google/caja/cajita.js (right): http://codereview.appspot.com/135054/diff/1/3#newcode98 Line 98: if (arguments.length < 3) end = self.length; Please ...
16 years, 7 months ago (2009-10-20 03:59:56 UTC) #2
felix8a
updated snapshot http://codereview.appspot.com/135054/diff/1/3 File src/com/google/caja/cajita.js (right): http://codereview.appspot.com/135054/diff/1/3#newcode98 Line 98: if (arguments.length < 3) end = ...
16 years, 7 months ago (2009-10-20 04:59:09 UTC) #3
MikeSamuel
http://codereview.appspot.com/135054/diff/1/3 File src/com/google/caja/cajita.js (right): http://codereview.appspot.com/135054/diff/1/3#newcode1598 Line 1598: var args = [self].concat(Array.slice(opt_args, 0)); > that doesn't ...
16 years, 7 months ago (2009-10-21 19:33:53 UTC) #4
felix8a
updated snapshot http://codereview.appspot.com/135054/diff/1/3 File src/com/google/caja/cajita.js (right): http://codereview.appspot.com/135054/diff/1/3#newcode1598 Line 1598: var args = [self].concat(Array.slice(opt_args, 0)); On ...
16 years, 7 months ago (2009-10-21 21:24:37 UTC) #5
MikeSamuel
LGTM
16 years, 7 months ago (2009-11-05 03:52:35 UTC) #6
felix8a
16 years, 7 months ago (2009-11-05 04:56:47 UTC) #7
@r3833
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b