Monkeypatch to avoid DOM 22 exception when persisting to localStorage or sessionStorage in Private Browsing mode.