Skip to content

AO3-7375 Fix TypeError by adding localStorage feature check for accepted_tos check#5704

Open
mjec wants to merge 1 commit intootwcode:masterfrom
mjec:AO3-0000_feature_check_localstorage
Open

AO3-7375 Fix TypeError by adding localStorage feature check for accepted_tos check#5704
mjec wants to merge 1 commit intootwcode:masterfrom
mjec:AO3-0000_feature_check_localstorage

Conversation

@mjec
Copy link
Copy Markdown

@mjec mjec commented Apr 4, 2026

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-7375

Purpose

Check that localStorage is supported before using it to look for an accepted_tos entry. This prevents an error like Uncaught TypeError: can't access property "getItem", localStorage is null which breaks subsequent JS on the page, including further jquery $j(document).ready() callbacks.

Testing Instructions

In Firefox, set dom.storage.enabled to false in about:config. Load any page and open the JS console, observe no Uncaught TypeError.

Compare to the same on master, which does result in the TypeError.

References

Discovered and discussed in #5641, specifically under the last details block in the comment attaching screenshots.

Credit

mjec (they/them)

Before this commit if localStroage was not available at all, the check
for accept_tos would result in:

Uncaught TypeError: can't access property "getItem", localStorage is null

This breaks all subsequent JS on the page, including further jquery
`$j(document).ready()` callbacks.
@sarken
Copy link
Copy Markdown
Collaborator

sarken commented Apr 6, 2026

Thanks for finding this! I've made AO3-7375 and assigned it to you. However, in the future, please wait for someone to verify the problem and create an issue before opening a pull request.

(Edited to fix the link.)

@mjec mjec changed the title [no ticket (yet?)] Fix TypeError by adding localStroage feature check for accepted_tos check AO3-7375. Fix TypeError by adding localStroage feature check for accepted_tos check Apr 6, 2026
@mjec mjec changed the title AO3-7375. Fix TypeError by adding localStroage feature check for accepted_tos check AO3-7375 Fix TypeError by adding localStroage feature check for accepted_tos check Apr 6, 2026
@mjec mjec closed this Apr 6, 2026
@mjec mjec deleted the AO3-0000_feature_check_localstorage branch April 6, 2026 00:31
@mjec mjec restored the AO3-0000_feature_check_localstorage branch April 6, 2026 00:32
@mjec
Copy link
Copy Markdown
Author

mjec commented Apr 6, 2026

Apologies for the nonsense

@mjec mjec reopened this Apr 6, 2026
@Bilka2 Bilka2 changed the title AO3-7375 Fix TypeError by adding localStroage feature check for accepted_tos check AO3-7375 Fix TypeError by adding localStorage feature check for accepted_tos check Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants