The shipBeingAttacked event handler has a small glitch in connection with its optional "whom" parameter.
The handler fires not only when laser fire hits, but also when plasma bolts from turrets hit. But in this case "whom" is undefined, it seems that the plasma bolts don't carry the information who fired them. Currently this leads to an JS error message, if a script uses the "whom" parameter.