svnlabs / google-caja

Automatically exported from code.google.com/p/google-caja
0 stars 1 forks source link

Host can't see Function.prototype.length of guest functions. #1928

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What revision of the cajoler exhibits the problem?  On what browser and OS?
v5678, Chrome 36, Linux, SES mode

What steps will reproduce the problem?
1. In the host define an API method f = function(g) {alert(g.length);}
2. In the client, define function h = function(a, b) {}
3. In the client, call f(h).

What is the expected output? What do you see instead?
I expect "2" to be displayed, as that is the number of arguments declared by 
the client function, and it's what happens if you perform a similar call purely 
in the host. In reality, "1" gets displayed, since when the client function is 
passed through Caja, it gets wrapped in a function that declares a single 
unused parameter and forwards all arguments using the "arguments" object to the 
wrapped function.

Please provide any additional information below.

Original issue reported on code.google.com by max99x on 1 Aug 2014 at 6:23

GoogleCodeExporter commented 9 years ago

Original comment by erights on 2 Aug 2014 at 6:05

GoogleCodeExporter commented 9 years ago

Original comment by erights on 2 Aug 2014 at 6:07

GoogleCodeExporter commented 9 years ago
https://codereview.appspot.com/121970043/diff/1/src/com/google/caja/ses/repairES
5.js is an attempt at a fix, except that it has the test failure shown in the 
attached file, which I have not yet diagnosed.

Original comment by erights on 3 Aug 2014 at 2:08

Attachments:

GoogleCodeExporter commented 9 years ago
Or rather, just https://codereview.appspot.com/121970043/

Original comment by erights on 3 Aug 2014 at 2:08

GoogleCodeExporter commented 9 years ago

Original comment by erights on 3 Aug 2014 at 6:21

GoogleCodeExporter commented 9 years ago
@r5688

Original comment by erights on 4 Aug 2014 at 5:32

GoogleCodeExporter commented 9 years ago
I'm still seeing the issue in 5693m.

Original comment by ma...@google.com on 2 Sep 2014 at 8:55

GoogleCodeExporter commented 9 years ago
Hi Maxus, under what conditions are you seeing it? What should we do to try to 
reproduce?

Original comment by erights@google.com on 2 Sep 2014 at 9:00

GoogleCodeExporter commented 9 years ago
Here's a test case that implements the steps outlined in the original bug 
report. It alerts "1" rather than the expected "2". Note that it has to run on 
an http:// rather than file:// context. "python -m SimpleHTTPServer" is how I 
tested it.

Original comment by ma...@google.com on 3 Sep 2014 at 1:09

Attachments:

GoogleCodeExporter commented 9 years ago
Oh. This is because the change wasn't backported because it requires support 
from the "platform" and the original added it to SES but not ES5/3.

So what needs to be done is either add "ses.funcLike" to ES5/3 or add a test so 
that it can be skipped by the taming membrane if running in ES5/3 mode; or for 
your application you can use Caja trunk rather than the es53 branch which is 
what currently goes on gstatic.

Original comment by kpreid.switchb.org on 3 Sep 2014 at 2:37