diff options
| author | Roy Wellington Ⅳ <cactus_hugged@yahoo.com> | 2018-10-14 17:23:47 -0700 |
|---|---|---|
| committer | Roy Wellington Ⅳ <cactus_hugged@yahoo.com> | 2018-10-14 23:47:38 -0700 |
| commit | d4e2dcaff1bb957f41384e9e6a0dbb830dffe09c (patch) | |
| tree | 621e388457d84f391ab1044c5699570a434d09a0 /src | |
| parent | 14f42a732ff9562fb5f07eca5a7f92224dbe8881 (diff) | |
| download | rust-d4e2dcaff1bb957f41384e9e6a0dbb830dffe09c.tar.gz rust-d4e2dcaff1bb957f41384e9e6a0dbb830dffe09c.zip | |
Detect if access to localStorage is forbidden by the user's browser
If the user's cookie/persistent storage setting forbid access to localStorage, catch the exception and abort the access. Currently, attempting to use the expand/contract links at the top of the page for structs/consts/etc. fails due to an unhandled error while accessing localStorage, if such access is forbidden, as the exception from the failed access propagates all the way out, interrupting the expand/contract. Instead, I would like to degrade gracefully; the access won't happen (the collapse/expand state won't get persisted) but the actual expanding/contracting of the item will go on to succeed. Fixes #55079
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/html/static/storage.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librustdoc/html/static/storage.js b/src/librustdoc/html/static/storage.js index 4ef8349fa9c..9dc78f7beb6 100644 --- a/src/librustdoc/html/static/storage.js +++ b/src/librustdoc/html/static/storage.js @@ -28,6 +28,12 @@ function onEach(arr, func) { function updateLocalStorage(name, value) { if (typeof(Storage) !== "undefined") { + try { + window.localStorage; + } catch(err) { + // Storage is supported, but browser preferences deny access to it. + return; + } localStorage[name] = value; } else { // No Web Storage support so we do nothing |
