Fortunately this does not work in Safari where the rendering is done natively.
I like how you used "fortunately". For me too the most important in PDF is to print a good and accurate text and graphics (preferably vector graphics), which recently is not as easy as it would be possible
Does not even seem to be a valid PDF according to Preview.app
Preview implements a subset of the full capabilities of PDF, and in particular it does not implement the javascript interpreter.