Skip to content

Commit 4fb738c

Browse files
authored
Merge pull request #945 from AbdealiJK/ajk-localstorage
htmlfiles: Handle localStorage not accessible
2 parents 0f82d27 + ac71d86 commit 4fb738c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

coverage/htmlfiles/coverage_html.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,10 @@ coverage.index_ready = function ($) {
172172
// Look for a localStorage item containing previous sort settings:
173173
var sort_list = [];
174174
var storage_name = "COVERAGE_INDEX_SORT";
175-
var stored_list = localStorage.getItem(storage_name);
175+
var stored_list = undefined;
176+
try {
177+
stored_list = localStorage.getItem(storage_name);
178+
} catch(err) {}
176179

177180
if (stored_list) {
178181
sort_list = JSON.parse('[[' + stored_list + ']]');
@@ -222,7 +225,9 @@ coverage.index_ready = function ($) {
222225

223226
// Watch for page unload events so we can save the final sort settings:
224227
$(window).unload(function () {
225-
localStorage.setItem(storage_name, sort_list.toString())
228+
try {
229+
localStorage.setItem(storage_name, sort_list.toString())
230+
} catch(err) {}
226231
});
227232
};
228233

0 commit comments

Comments
 (0)