Add simplified storage API
authorjdlrobson <jdlrobson@gmail.com>
Tue, 11 Aug 2015 18:16:21 +0000 (11:16 -0700)
committerOri.livneh <ori@wikimedia.org>
Fri, 14 Aug 2015 22:33:40 +0000 (22:33 +0000)
commit7daab75414d1312bc9ae43a561adbcaf48760012
tree56299cf6bc70297708b5f3a7e7bc8b74463eb27c
parent6147de1182101903cf24259d61ec6ea34b907bf3
Add simplified storage API

Provide a standard mechanism for accessing localStorage.

It may seems simplistic right now, but to give an idea of the why:
* We already have jquery.jStorage.js which is a much more heavyweight
approach to storing non-essential values.
* We are repeating ourselves a lot in extensions by having
to do localStorage detection and then deal with full localStorage.
In MobileFrontend we have a settings module. This is one of the reasons Gather
depends on MobileFrontend and I'm keen to remove that dependency.
* We might want to move to indexdb in future. Having a single API makes moving
this easier - we don't have to update everywhere that uses localStorage
* Saving non-string support would be useful. The API could be adjusted to take a
mixed second parameter that stringifys JSON objects.
* Cookie fallbacks are a possible alternative when localStorage is not supported. This allows
us to be agnostic of the storage mechanism going forward.

Note:
This doesn't reuse the handling in mediawiki.js as at this point
I am not sure there is value. mw.loader.store.enabled is false when
$wgResourceLoaderStorageEnabled is not true and this should work even
without that case. We can review this at a latter point.

See:
Id5c32bb7a662dda8d153490f7c47e972cabc1efd
I3fd44b0ae6633a7053aee247bc3c4704ba987bc8

Bug: T96155
Change-Id: Idb37352acecd745beb53aa8d77ea050851448e0d
maintenance/jsduck/categories.json
resources/Resources.php
resources/src/mediawiki/mediawiki.storage.js [new file with mode: 0644]
tests/qunit/QUnitTestResources.php
tests/qunit/suites/resources/mediawiki/mediawiki.storage.test.js [new file with mode: 0644]