mediawiki.api: Check that query exists in api.getToken() response
authorStephen Niedzielski <stephen@niedzielski.com>
Fri, 9 Mar 2018 15:30:52 +0000 (09:30 -0600)
committerKrinkle <krinklemail@gmail.com>
Tue, 1 May 2018 20:37:49 +0000 (20:37 +0000)
commit89b739c655f8cbeba1e05ab0198eee3b60f9e723
treef03247f7fb5c739072013ed8c87daf52c28cee79
parentebc32b659a3528991f0d8943699c62d15448dd56
mediawiki.api: Check that query exists in api.getToken() response

It's possible that response.query does not exist when requesting a
token. This patch removes the assumption and handles the scenario in the
same way as a missing token.

Additionally, responses with a queryless response are now deleted from the cache.

Corresponding console warning:

> jQuery.Deferred exception: Cannot read property 'tokens' of undefined
>   at apiPromise.then.promise.abort (/w/resources/src/mediawiki/api.js)

Change-Id: Ia29e0c0d657bf4b3d94f1d463b942451eebd68b4
resources/src/mediawiki/api.js
tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js