Merge branch 'MDL-51461' of https://github.com/andrewhancox/moodle
authorAndrew Nicols <andrew@nicols.co.uk>
Tue, 6 Oct 2015 03:41:10 +0000 (11:41 +0800)
committerDan Poltawski <dan@moodle.com>
Tue, 6 Oct 2015 15:31:32 +0000 (16:31 +0100)
lib/amd/build/localstorage.min.js
lib/amd/src/localstorage.js

index c757939..372e525 100644 (file)
Binary files a/lib/amd/build/localstorage.min.js and b/lib/amd/build/localstorage.min.js differ
index 7cd824e..48cda61 100644 (file)
@@ -46,13 +46,22 @@ define(['core/config'], function(config) {
             // Disable cache if debugging.
             return false;
         }
-        if (typeof(window.localStorage) !== "undefined") {
-            try {
-                localStorage = window.localStorage;
-                return localStorage !== null;
-            } catch (ex) {
+        if (typeof(window.localStorage) === "undefined") {
+            return false;
+        }
+        var testKey = 'test';
+        try {
+            localStorage = window.localStorage;
+            if (localStorage === null) {
                 return false;
             }
+           // MDL-51461 - Some browsers misreport availability of local storage
+           // so check it is actually usable.
+            localStorage.setItem(testKey, '1');
+            localStorage.removeItem(testKey);
+            return true;
+        } catch (ex) {
+            return false;
         }
     };