From 3351ae7e29cbf3bed6fc1925ef33664bcc59fef5 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sun, 6 Jul 2014 10:11:21 +0100 Subject: [PATCH] Fix issue with localStorage error on Firefox Firefox raises an error if window.localStorage is accessed when cookies are disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=771890 --- core/modules/utils/dom/dom.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/core/modules/utils/dom/dom.js b/core/modules/utils/dom/dom.js index 3d611f768..e896049ed 100644 --- a/core/modules/utils/dom/dom.js +++ b/core/modules/utils/dom/dom.js @@ -96,8 +96,11 @@ exports.getBoundingPageRect = function(element) { Saves a named password in the browser */ exports.savePassword = function(name,password) { - if(window.localStorage) { - localStorage.setItem("tw5-password-" + name,password); + try { + if(window.localStorage) { + localStorage.setItem("tw5-password-" + name,password); + } + } catch(e) { } }; @@ -105,7 +108,11 @@ exports.savePassword = function(name,password) { Retrieve a named password from the browser */ exports.getPassword = function(name) { - return window.localStorage ? localStorage.getItem("tw5-password-" + name) : ""; + try { + return window.localStorage ? localStorage.getItem("tw5-password-" + name) : ""; + } catch(e) { + return ""; + } }; /*