mw.special.apisandbox: Correct fixTokenAndResend() when a token is already known
In this snippet:
success = function ( k ) {
delete tokenWait[ k ];
...
};
...
tokenWait[ k ] = page.tokenWidget.fetchToken()
.done( success.bind( page.tokenWidget, k ) )
.fail( failure.bind( page.tokenWidget, k ) );
If fetchToken() returns a promise that is already resolved (because we
have the token cached), the `delete tokenWait[ k ];` will happen before
the `tokenWait[ k ] = ...`, and later code checking that `tokenWait` is
empty will not work correctly.
Fix this by doing the assigment before connecting the done/fail handlers,
in a separate statement.
Change-Id: Ieeb23cad0fd7e0cd4d3d259ff9f324f2001de0c6