From: Timo Tijhof Date: Mon, 24 Oct 2016 23:00:45 +0000 (+0100) Subject: mediawiki.storage: Catch exceptions on window.localStorage property access X-Git-Tag: 1.31.0-rc.0~5033 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/rappels.php?a=commitdiff_plain;h=55b83097583e2ea63cfd161f95d5973d59af2b5d;p=lhc%2Fweb%2Fwiklou.git mediawiki.storage: Catch exceptions on window.localStorage property access Follows-up 430a0d3984, which created a private property that stored a reference to the localStorage object outside the get and set methods. Where previously it was used directly, and as such, covered by the try/catch around getItem and setItem calls. Bug: T148998 Change-Id: Ibe75408913d4ffbf1791e1a6470296b29f809185 --- diff --git a/resources/src/mediawiki/mediawiki.storage.js b/resources/src/mediawiki/mediawiki.storage.js index cb62fbf26c..a9d17ff70d 100644 --- a/resources/src/mediawiki/mediawiki.storage.js +++ b/resources/src/mediawiki/mediawiki.storage.js @@ -10,7 +10,14 @@ */ mw.storage = { - localStorage: window.localStorage, + localStorage: ( function () { + // Catch exceptions to avoid fatal in Chrome's "Block data storage" mode + // which throws when accessing the localStorage property itself, as opposed + // to the standard behaviour of throwing on getItem/setItem. (T148998) + try { + return window.localStorage; + } catch ( e ) {} + }() ), /** * Retrieve value from device storage.