Guard local storage helpers with canUseLocalStorage

What does this MR do and why?

getStorageValue, saveStorageValue and removeStorageValue in ~/lib/utils/local_storage call localStorage directly, so every consumer throws when local storage is turned off or blocked (for example Firefox with dom.storage.enabled set to false). This MR checks AccessorUtilities.canUseLocalStorage() first: getStorageValue returns { exists: false }, and saveStorageValue and removeStorageValue do nothing, which callers already handle. Because canUseLocalStorage() writes and removes a test key, three existing specs that count every setItem/removeItem call now mock it.

Closes #601167.

References

Follow-up from !237848 (merged).

Screenshots or screen recordings

Not applicable — no visual change.

How to set up and validate locally

  1. Run yarn jest spec/frontend/lib/utils/local_storage_spec.js spec/frontend/ci/pipeline_details/graph/graph_component_wrapper_spec.js ee/spec/frontend/packages_and_registries/artifact_registry/repositories/list/repositories_list_spec.js ee/spec/frontend/packages_and_registries/artifact_registry/repositories/versions/version_list_spec.js.
  2. Optional manual check: in Firefox, open about:config and set dom.storage.enabled to false.
  3. Open a page that uses these helpers (for example a group or project list with tabs, or a pipeline graph) and check the console has no localStorage errors from lib/utils/local_storage.js.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

This contribution was prepared with the help of an AI assistant. I reviewed the changes and take responsibility for them.

Merge request reports

Loading
Loading