rubensayshi / gw2spidy

GW2Spidy - Guild Wars 2 Tradingpost Graphs
http://www.gw2spidy.com
231 stars 86 forks source link

Recipe page does not work: SecurityError #171

Closed bugbreeder closed 9 years ago

bugbreeder commented 9 years ago

Viewing recipes does not work for me. Using Firefox 37 and 38 I get the line "SecurityError: The operation is insecure." in the console. Unfortunately there is no usable location of the error shown for the minimized script. Firefox then follows up with a "TypeError: Crafting is not a constructor", which seems to be caused by aborting the script due to the SecurityError. A current chrome (can't check version right now) shows the same behaviour.

I have set my browser to block cookies by default, and thus (apparently) also disallowed access to local storage.

I've tested this a bit further yesterday with a local (i.e. file://) version of the page and a non-minimized script.js and it showed a line where window.localStorage is tested. I've then tested it in the console on the web version and found that indeed this test triggers the SecurityError log line.

When I completely disable local storage via about:config, typeof window.localStorage is still "object", but the console says it is null. In this case an error is thrown later on, when the code tries to access this null object. (This may be a Firefox bug.)

When I enable but disallow local storage, even "typeof window.localStorage" throws the error.

I haven't tested it, but I guess wrapping this test in a try/catch block should do.

rubensayshi commented 9 years ago

hmm, thanks for digging in and figuring out that the problem was with localstorage!

I changed some stuff to use the localforage library now, it supports callbacks / promises and I've changed the crafting code to work even when localstorage fails.

can you give it a shot (on gw2spidy.com) ?

bugbreeder commented 9 years ago

Recipes work now for me. Thank you.