Fix restoring globals on another frame fails on Firefox

We are using `sinon` across frames in the same domain and when we try to stub and restore globals on another frame, they become `undefined` since `hasOwnProperty` check fails and sinon deletes the global instead of restoring it.