nntoan / scriptify

Automatically exported from code.google.com/p/scriptify
MIT License
0 stars 0 forks source link

"caller is null" Error, bootstrap.js, line 90. #8

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Subject is self-explanatory. I don't have a minimalistic test case for this, 
but on a website the caller was null and hence the remaining code was not 
executed. I changed the line 
from:
if (!/^resource:/.test(caller.replace(/.* -> /, "")))

to:
if (caller && !/^resource:/.test(caller.replace(/.* -> /, ""))) 

and it worked. 

Original issue reported on code.google.com by piyushs...@gmail.com on 14 Feb 2014 at 2:54

GoogleCodeExporter commented 9 years ago
Your suggested fix is wrong, as it might make it possible for content pages to 
short-circuit the API leak checks. Do you have a minimal testcase?

Original comment by maglion...@gmail.com on 14 Feb 2014 at 10:26

GoogleCodeExporter commented 9 years ago
Unfortunately not (as I wrote in the initial description). It is supposed to 
work on an internal website and I'm not allowed to paste the add-on outside. 
The suggested fix might be wrong, but the problem is real. I have no idea it 
was null, but doing the changes for my internal add-on worked. In any case it 
shouldn't crash. 

I will try to reproduce with a simpler test case, but it's very hard and the 
script I was compiling is huge. 

Original comment by piyushs...@gmail.com on 18 Feb 2014 at 11:58

GoogleCodeExporter commented 9 years ago
There aren't a lot of ways to produce a stack frame with a null filename. The 
easiest way, though, is something like setTimeout, e.g.,

   setTimeout(GM_log.bind(null, "foo"), 100);

In any event, failing in this case is correct. It doesn't crash, but it 
probably should fail with the normal permission denied error rather than 
"caller is null".

Original comment by maglion...@gmail.com on 19 Feb 2014 at 12:14

GoogleCodeExporter commented 9 years ago
Yes, may be an Error message could be caught and logged in the console, rather 
than the 'caller' failing and the rest of the code not getting executed. 

Thanks!

Original comment by piyushs...@gmail.com on 19 Feb 2014 at 12:18

GoogleCodeExporter commented 9 years ago
Forgot to write, when it fails by this method (I am using a lot of setTimeouts 
because of the way our sh*tty internal website works), besides logging that 
error in the console, it will be great if you could log a message suggesting 
how should it be rather done. That will be very helpful for beginners. I don't 
know which of my settimeouts is causing this problem. Wish there was a better 
way to debug this. 

Original comment by piyushs...@gmail.com on 19 Feb 2014 at 12:25