This will always be true (in gateway scope, if you have the Perspective module installed) - this won't catch scenarios where you're not in a Perspective launched context but elsewhere on the gateway (e.g. a tag event script). See @nminchin's similar looking code here:
I'll also mention for posterity here that in 8.3 we introduced new named query scripting functions to address this fundamental inconsistency.