I have a situation where earlier in the code when the page loads, document.domain was set to a parent domain value (eg - from a.xyz.com to xyz.com)
a.xyz.com
xyz.com