Merge "Don't call legalSearchChars() statically so it can properly inherit"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 5 May 2014 23:22:04 +0000 (23:22 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 5 May 2014 23:22:04 +0000 (23:22 +0000)
includes/cache/LocalisationCache.php
includes/filerepo/file/LocalFile.php
includes/installer/PostgresUpdater.php
maintenance/postgres/tables.sql
resources/lib/oojs-ui/i18n/ne.json
resources/lib/oojs-ui/oojs-ui-apex.css
resources/lib/oojs-ui/oojs-ui.js
resources/lib/oojs-ui/oojs-ui.svg.css
resources/src/mediawiki.api/mediawiki.api.js
tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js

index 3bbf1bb..1153fd2 100644 (file)
@@ -1171,7 +1171,7 @@ class LCStoreDB implements LCStore {
                $row = $db->selectRow( 'l10n_cache', array( 'lc_value' ),
                        array( 'lc_lang' => $code, 'lc_key' => $key ), __METHOD__ );
                if ( $row ) {
-                       return unserialize( $row->lc_value );
+                       return unserialize( $db->decodeBlob( $row->lc_value ) );
                } else {
                        return null;
                }
@@ -1233,7 +1233,7 @@ class LCStoreDB implements LCStore {
                $this->batch[] = array(
                        'lc_lang' => $this->currentLang,
                        'lc_key' => $key,
-                       'lc_value' => serialize( $value ) );
+                       'lc_value' => $this->dbw->encodeBlob( serialize( $value ) ) );
 
                if ( count( $this->batch ) >= 100 ) {
                        $this->dbw->insert( 'l10n_cache', $this->batch, __METHOD__ );
index 4b8e590..b3d5d5d 100644 (file)
@@ -496,6 +496,8 @@ class LocalFile extends File {
 
                $decoded['timestamp'] = wfTimestamp( TS_MW, $decoded['timestamp'] );
 
+               $decoded['metadata'] = $this->repo->getSlaveDB()->decodeBlob( $decoded['metadata'] );
+
                if ( empty( $decoded['major_mime'] ) ) {
                        $decoded['mime'] = 'unknown/unknown';
                } else {
index 8f6aac7..e7aab8a 100644 (file)
@@ -406,6 +406,7 @@ class PostgresUpdater extends DatabaseUpdater {
                        array( 'addPgField', 'recentchanges', 'rc_source', "TEXT NOT NULL DEFAULT ''" ),
                        array( 'addPgField', 'page', 'page_links_updated', "TIMESTAMPTZ NULL" ),
                        array( 'addPgField', 'mwuser', 'user_password_expires', 'TIMESTAMPTZ NULL' ),
+                       array( 'changeFieldPurgeTable', 'l10n_cache', 'lc_value', 'bytea', "replace(lc_value,'\','\\\\')::bytea" ),
 
                        // 1.24
                        array( 'addPgField', 'page_props', 'pp_sortkey', 'float NULL' ),
@@ -677,6 +678,35 @@ END;
                }
        }
 
+       protected function changeFieldPurgeTable( $table, $field, $newtype, $default ) {
+               ## For a cache table, empty it if the field needs to be changed, because the old contents
+               ## may be corrupted.  If the column is already the desired type, refrain from purging.
+               $fi = $this->db->fieldInfo( $table, $field );
+               if ( is_null( $fi ) ) {
+                       $this->output( "...ERROR: expected column $table.$field to exist\n" );
+                       exit( 1 );
+               }
+
+               if ( $fi->type() === $newtype ) {
+                       $this->output( "...column '$table.$field' is already of type '$newtype'\n" );
+               } else {
+                       $this->output( "Purging data from cache table '$table'\n" );
+                       $this->db->query("DELETE from $table" );
+                       $this->output( "Changing column type of '$table.$field' from '{$fi->type()}' to '$newtype'\n" );
+                       $sql = "ALTER TABLE $table ALTER $field TYPE $newtype";
+                       if ( strlen( $default ) ) {
+                               $res = array();
+                               if ( preg_match( '/DEFAULT (.+)/', $default, $res ) ) {
+                                       $sqldef = "ALTER TABLE $table ALTER $field SET DEFAULT $res[1]";
+                                       $this->db->query( $sqldef );
+                                       $default = preg_replace( '/\s*DEFAULT .+/', '', $default );
+                               }
+                               $sql .= " USING $default";
+                       }
+                       $this->db->query( $sql );
+               }
+       }
+
        protected function setDefault( $table, $field, $default ) {
 
                $info = $this->db->fieldInfo( $table, $field );
index 6a2c41d..abbfd3a 100644 (file)
@@ -678,7 +678,7 @@ CREATE INDEX user_properties_property ON user_properties (up_property);
 CREATE TABLE l10n_cache (
   lc_lang   TEXT  NOT NULL,
   lc_key    TEXT  NOT NULL,
-  lc_value  TEXT  NOT NULL
+  lc_value  BYTEA NOT NULL
 );
 CREATE INDEX l10n_cache_lc_lang_key ON l10n_cache (lc_lang, lc_key);
 
index 6b7c78a..f7bbff4 100644 (file)
@@ -4,5 +4,10 @@
                        "RajeshPandey",
                        "सरोज कुमार ढकाल"
                ]
-       }
+       },
+       "ooui-dialog-action-close": "बन्द गर्ने",
+       "ooui-outline-control-move-down": "वस्तुलाई तल सार्ने",
+       "ooui-outline-control-move-up": "वस्तुलाई माथि सार्ने",
+       "ooui-outline-control-remove": "वस्तुलाई हटाउने",
+       "ooui-toolbar-more": "थप"
 }
index 952e05e..63a66fb 100644 (file)
   bottom: 4.8em;
 }
 
+.oo-ui-dialog-content-footless .oo-ui-window-body {
+  bottom: 0;
+}
+
 .oo-ui-dialog > .oo-ui-window-frame {
   top: 1em;
   bottom: 1em;
index 6ba7ac8..b5f8824 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (9a6c625f5f)
+ * OOjs UI v0.1.0-pre (7d2507b267)
  * https://www.mediawiki.org/wiki/OOjs_UI
  *
  * Copyright 2011–2014 OOjs Team and other contributors.
  * Released under the MIT license
  * http://oojs.mit-license.org
  *
- * Date: Fri May 02 2014 12:04:40 GMT-0700 (PDT)
+ * Date: Mon May 05 2014 14:13:13 GMT-0700 (PDT)
  */
 ( function ( OO ) {
 
@@ -1946,7 +1946,7 @@ OO.ui.ButtonedElement = function OoUiButtonedElement( $button, config ) {
  * @param {jQuery.Event} e Mouse down event
  */
 OO.ui.ButtonedElement.prototype.onMouseDown = function ( e ) {
-       if ( this.disabled || e.which !== 1 ) {
+       if ( this.isDisabled() || e.which !== 1 ) {
                return false;
        }
        // tabIndex should generally be interacted with via the property,
@@ -1967,7 +1967,7 @@ OO.ui.ButtonedElement.prototype.onMouseDown = function ( e ) {
  * @param {jQuery.Event} e Mouse up event
  */
 OO.ui.ButtonedElement.prototype.onMouseUp = function ( e ) {
-       if ( this.disabled || e.which !== 1 ) {
+       if ( this.isDisabled() || e.which !== 1 ) {
                return false;
        }
        // Restore the tab-index after the button is up to restore the button's accesssibility
@@ -3545,7 +3545,7 @@ OO.ui.ToolGroup.prototype.updateDisabled = function () {
  * @param {jQuery.Event} e Mouse down event
  */
 OO.ui.ToolGroup.prototype.onMouseDown = function ( e ) {
-       if ( !this.disabled && e.which === 1 ) {
+       if ( !this.isDisabled() && e.which === 1 ) {
                this.pressed = this.getTargetTool( e );
                if ( this.pressed ) {
                        this.pressed.setActive( true );
@@ -3577,7 +3577,7 @@ OO.ui.ToolGroup.prototype.onCapturedMouseUp = function ( e ) {
 OO.ui.ToolGroup.prototype.onMouseUp = function ( e ) {
        var tool = this.getTargetTool( e );
 
-       if ( !this.disabled && e.which === 1 && this.pressed && this.pressed === tool ) {
+       if ( !this.isDisabled() && e.which === 1 && this.pressed && this.pressed === tool ) {
                this.pressed.onSelect();
        }
 
@@ -4096,7 +4096,7 @@ OO.ui.GridLayout.prototype.getPanel = function ( x, y ) {
  * @constructor
  * @param {Object} [config] Configuration options
  * @cfg {boolean} [continuous=false] Show all pages, one after another
- * @cfg {boolean} [autoFocus=false] Focus on the first focusable element when changing to a page
+ * @cfg {boolean} [autoFocus=true] Focus on the first focusable element when changing to a page
  * @cfg {boolean} [outlined=false] Show an outline
  * @cfg {boolean} [editable=false] Show controls for adding, removing and reordering pages
  * @cfg {Object[]} [adders] List of adders for controls, each with name, icon and title properties
@@ -4113,7 +4113,7 @@ OO.ui.BookletLayout = function OoUiBookletLayout( config ) {
        this.pages = {};
        this.ignoreFocus = false;
        this.stackLayout = new OO.ui.StackLayout( { '$': this.$, 'continuous': !!config.continuous } );
-       this.autoFocus = !!config.autoFocus;
+       this.autoFocus = config.autoFocus === undefined ? true : !!config.autoFocus;
        this.outlineVisible = false;
        this.outlined = !!config.outlined;
        if ( this.outlined ) {
@@ -4898,7 +4898,7 @@ OO.ui.PopupToolGroup.prototype.onBlur = function ( e ) {
  * @inheritdoc
  */
 OO.ui.PopupToolGroup.prototype.onMouseUp = function ( e ) {
-       if ( !this.disabled && e.which === 1 ) {
+       if ( !this.isDisabled() && e.which === 1 ) {
                this.setActive( false );
        }
        return OO.ui.ToolGroup.prototype.onMouseUp.call( this, e );
@@ -4919,7 +4919,7 @@ OO.ui.PopupToolGroup.prototype.onHandleMouseUp = function () {
  * @param {jQuery.Event} e Mouse down event
  */
 OO.ui.PopupToolGroup.prototype.onHandleMouseDown = function ( e ) {
-       if ( !this.disabled && e.which === 1 ) {
+       if ( !this.isDisabled() && e.which === 1 ) {
                this.setActive( !this.active );
        }
        return false;
@@ -5066,7 +5066,7 @@ OO.mixinClass( OO.ui.PopupTool, OO.ui.PopuppableElement );
  * @inheritdoc
  */
 OO.ui.PopupTool.prototype.onSelect = function () {
-       if ( !this.disabled ) {
+       if ( !this.isDisabled() ) {
                if ( this.popup.isVisible() ) {
                        this.hidePopup();
                } else {
@@ -5357,7 +5357,7 @@ OO.mixinClass( OO.ui.ButtonWidget, OO.ui.FlaggableElement );
  * @fires click
  */
 OO.ui.ButtonWidget.prototype.onClick = function () {
-       if ( !this.disabled ) {
+       if ( !this.isDisabled() ) {
                this.emit( 'click' );
                if ( this.isHyperlink ) {
                        return true;
@@ -5373,7 +5373,7 @@ OO.ui.ButtonWidget.prototype.onClick = function () {
  * @fires click
  */
 OO.ui.ButtonWidget.prototype.onKeyPress = function ( e ) {
-       if ( !this.disabled && e.which === OO.ui.Keys.SPACE ) {
+       if ( !this.isDisabled() && e.which === OO.ui.Keys.SPACE ) {
                if ( this.isHyperlink ) {
                        this.onClick();
                        return true;
@@ -5414,7 +5414,7 @@ OO.ui.InputWidget = function OoUiInputWidget( config ) {
        // Initialization
        this.$input
                .attr( 'name', config.name )
-               .prop( 'disabled', this.disabled );
+               .prop( 'disabled', this.isDisabled() );
        this.setReadOnly( config.readOnly );
        this.$element.addClass( 'oo-ui-inputWidget' ).append( this.$input );
        this.setValue( config.value );
@@ -5449,7 +5449,7 @@ OO.ui.InputWidget.prototype.getInputElement = function () {
  * @param {jQuery.Event} e Key down, mouse up, cut, paste, change, input, or select event
  */
 OO.ui.InputWidget.prototype.onEdit = function () {
-       if ( !this.disabled ) {
+       if ( !this.isDisabled() ) {
                // Allow the stack to clear so the value will be updated
                setTimeout( OO.ui.bind( function () {
                        this.setValue( this.$input.val() );
@@ -5562,7 +5562,7 @@ OO.ui.InputWidget.prototype.setReadOnly = function ( state ) {
 OO.ui.InputWidget.prototype.setDisabled = function ( state ) {
        OO.ui.Widget.prototype.setDisabled.call( this, state );
        if ( this.$input ) {
-               this.$input.prop( 'disabled', this.disabled );
+               this.$input.prop( 'disabled', this.isDisabled() );
        }
        return this;
 };
@@ -5635,7 +5635,7 @@ OO.ui.CheckboxInputWidget.prototype.setValue = function ( value ) {
  * @inheritdoc
  */
 OO.ui.CheckboxInputWidget.prototype.onEdit = function () {
-       if ( !this.disabled ) {
+       if ( !this.isDisabled() ) {
                // Allow the stack to clear so the value will be updated
                setTimeout( OO.ui.bind( function () {
                        this.setValue( this.$input.prop( 'checked' ) );
@@ -6005,7 +6005,7 @@ OO.ui.OptionWidget.static.scrollIntoViewOnSelect = false;
  * @return {boolean} Item is selectable
  */
 OO.ui.OptionWidget.prototype.isSelectable = function () {
-       return this.constructor.static.selectable && !this.disabled;
+       return this.constructor.static.selectable && !this.isDisabled();
 };
 
 /**
@@ -6014,7 +6014,7 @@ OO.ui.OptionWidget.prototype.isSelectable = function () {
  * @return {boolean} Item is highlightable
  */
 OO.ui.OptionWidget.prototype.isHighlightable = function () {
-       return this.constructor.static.highlightable && !this.disabled;
+       return this.constructor.static.highlightable && !this.isDisabled();
 };
 
 /**
@@ -6023,7 +6023,7 @@ OO.ui.OptionWidget.prototype.isHighlightable = function () {
  * @return {boolean} Item is pressable
  */
 OO.ui.OptionWidget.prototype.isPressable = function () {
-       return this.constructor.static.pressable && !this.disabled;
+       return this.constructor.static.pressable && !this.isDisabled();
 };
 
 /**
@@ -6060,7 +6060,7 @@ OO.ui.OptionWidget.prototype.isPressed = function () {
  * @chainable
  */
 OO.ui.OptionWidget.prototype.setSelected = function ( state ) {
-       if ( !this.disabled && this.constructor.static.selectable ) {
+       if ( !this.isDisabled() && this.constructor.static.selectable ) {
                this.selected = !!state;
                if ( this.selected ) {
                        this.$element.addClass( 'oo-ui-optionWidget-selected' );
@@ -6081,7 +6081,7 @@ OO.ui.OptionWidget.prototype.setSelected = function ( state ) {
  * @chainable
  */
 OO.ui.OptionWidget.prototype.setHighlighted = function ( state ) {
-       if ( !this.disabled && this.constructor.static.highlightable ) {
+       if ( !this.isDisabled() && this.constructor.static.highlightable ) {
                this.highlighted = !!state;
                if ( this.highlighted ) {
                        this.$element.addClass( 'oo-ui-optionWidget-highlighted' );
@@ -6099,7 +6099,7 @@ OO.ui.OptionWidget.prototype.setHighlighted = function ( state ) {
  * @chainable
  */
 OO.ui.OptionWidget.prototype.setPressed = function ( state ) {
-       if ( !this.disabled && this.constructor.static.pressable ) {
+       if ( !this.isDisabled() && this.constructor.static.pressable ) {
                this.pressed = !!state;
                if ( this.pressed ) {
                        this.$element.addClass( 'oo-ui-optionWidget-pressed' );
@@ -6121,7 +6121,7 @@ OO.ui.OptionWidget.prototype.flash = function () {
        var $this = this.$element,
                deferred = $.Deferred();
 
-       if ( !this.disabled && this.constructor.static.pressable ) {
+       if ( !this.isDisabled() && this.constructor.static.pressable ) {
                $this.removeClass( 'oo-ui-optionWidget-highlighted oo-ui-optionWidget-pressed' );
                setTimeout( OO.ui.bind( function () {
                        // Restore original classes
@@ -6246,7 +6246,7 @@ OO.ui.SelectWidget.static.tagName = 'ul';
 OO.ui.SelectWidget.prototype.onMouseDown = function ( e ) {
        var item;
 
-       if ( !this.disabled && e.which === 1 ) {
+       if ( !this.isDisabled() && e.which === 1 ) {
                this.togglePressed( true );
                item = this.getTargetItem( e );
                if ( item && item.isSelectable() ) {
@@ -6274,7 +6274,7 @@ OO.ui.SelectWidget.prototype.onMouseUp = function ( e ) {
                        this.selecting = item;
                }
        }
-       if ( !this.disabled && e.which === 1 && this.selecting ) {
+       if ( !this.isDisabled() && e.which === 1 && this.selecting ) {
                this.pressItem( null );
                this.chooseItem( this.selecting );
                this.selecting = null;
@@ -6292,7 +6292,7 @@ OO.ui.SelectWidget.prototype.onMouseUp = function ( e ) {
 OO.ui.SelectWidget.prototype.onMouseMove = function ( e ) {
        var item;
 
-       if ( !this.disabled && this.pressed ) {
+       if ( !this.isDisabled() && this.pressed ) {
                item = this.getTargetItem( e );
                if ( item && item !== this.selecting && item.isSelectable() ) {
                        this.pressItem( item );
@@ -6311,7 +6311,7 @@ OO.ui.SelectWidget.prototype.onMouseMove = function ( e ) {
 OO.ui.SelectWidget.prototype.onMouseOver = function ( e ) {
        var item;
 
-       if ( !this.disabled ) {
+       if ( !this.isDisabled() ) {
                item = this.getTargetItem( e );
                this.highlightItem( item && item.isHighlightable() ? item : null );
        }
@@ -6325,7 +6325,7 @@ OO.ui.SelectWidget.prototype.onMouseOver = function ( e ) {
  * @param {jQuery.Event} e Mouse over event
  */
 OO.ui.SelectWidget.prototype.onMouseLeave = function () {
-       if ( !this.disabled ) {
+       if ( !this.isDisabled() ) {
                this.highlightItem( null );
        }
        return false;
@@ -6720,7 +6720,7 @@ OO.ui.MenuWidget.prototype.onKeyDown = function ( e ) {
                handled = false,
                highlightItem = this.getHighlightedItem();
 
-       if ( !this.disabled && this.visible ) {
+       if ( !this.isDisabled() && this.visible ) {
                if ( !highlightItem ) {
                        highlightItem = this.getSelectedItem();
                }
@@ -6997,7 +6997,7 @@ OO.ui.InlineMenuWidget.prototype.onClick = function ( e ) {
                return;
        }
 
-       if ( !this.disabled ) {
+       if ( !this.isDisabled() ) {
                if ( this.menu.isVisible() ) {
                        this.menu.hide();
                } else {
@@ -7653,7 +7653,7 @@ OO.ui.PopupButtonWidget.prototype.onClick = function ( e ) {
                return;
        }
 
-       if ( !this.disabled ) {
+       if ( !this.isDisabled() ) {
                if ( this.popup.isVisible() ) {
                        this.hidePopup();
                } else {
@@ -8223,7 +8223,7 @@ OO.mixinClass( OO.ui.ToggleButtonWidget, OO.ui.ToggleWidget );
  * @inheritdoc
  */
 OO.ui.ToggleButtonWidget.prototype.onClick = function () {
-       if ( !this.disabled ) {
+       if ( !this.isDisabled() ) {
                this.setValue( !this.value );
        }
 
@@ -8295,7 +8295,7 @@ OO.mixinClass( OO.ui.ToggleSwitchWidget, OO.ui.ToggleWidget );
  * @param {jQuery.Event} e Mouse down event
  */
 OO.ui.ToggleSwitchWidget.prototype.onClick = function ( e ) {
-       if ( !this.disabled && e.which === 1 ) {
+       if ( !this.isDisabled() && e.which === 1 ) {
                this.setValue( !this.value );
        }
 };
index 955b71a..0c2cfaf 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (9a6c625f5f)
+ * OOjs UI v0.1.0-pre (7d2507b267)
  * https://www.mediawiki.org/wiki/OOjs_UI
  *
  * Copyright 2011–2014 OOjs Team and other contributors.
  * Released under the MIT license
  * http://oojs.mit-license.org
  *
- * Date: Fri May 02 2014 12:04:40 GMT-0700 (PDT)
+ * Date: Mon May 05 2014 14:13:12 GMT-0700 (PDT)
  */
 
 /* Textures */
   float: right;
 }
 
-.oo-ui-dialog-content-footless .oo-ui-window-body {
-  bottom: 0;
-}
-
 .oo-ui-dialog-content-footless .oo-ui-window-foot {
   display: none;
 }
 
 .oo-ui-indicator-up {
   background-image: /* @embed */ url(images/indicators/up.svg);
-}
+}
\ No newline at end of file
index b37e2a6..9962534 100644 (file)
                                        function ( code ) {
                                                if ( code === 'badtoken' ) {
                                                        // Clear from cache
-                                                       deferreds[ this.defaults.ajax.url ][ tokenType + 'Token' ] =
+                                                       deferreds[ api.defaults.ajax.url ][ tokenType + 'Token' ] =
                                                                params.token = undefined;
 
                                                        // Try again, once
index a93f572..05eb6b9 100644 (file)
                } );
        } );
 
+       QUnit.test( 'postWithToken()', function ( assert ) {
+               QUnit.expect( 1 );
+
+               var api = new mw.Api( { ajax: { url: '/postWithToken/api.php' } } );
+
+               // - Requests token
+               // - Performs action=example
+               api.postWithToken( 'testsimpletoken', { action: 'example', key: 'foo' } )
+                       .done( function ( data ) {
+                               assert.deepEqual( data, { example: { foo: 'quux' } } );
+                       } );
+
+               this.server.requests[0].respond( 200, { 'Content-Type': 'application/json' },
+                       '{ "tokens": { "testsimpletokentoken": "a-bad-token" } }'
+               );
+
+               this.server.requests[1].respond( 200, { 'Content-Type': 'application/json' },
+                       '{ "example": { "foo": "quux" } }'
+               );
+       } );
+
+       QUnit.test( 'postWithToken() - badtoken', function ( assert ) {
+               QUnit.expect( 1 );
+
+               var api = new mw.Api();
+
+               // - Request: token
+               // - Request: action=example -> badtoken error
+               // - Request: new token
+               // - Request: action=example
+               api.postWithToken( 'testbadtoken', { action: 'example', key: 'foo' } )
+                       .done( function ( data ) {
+                               assert.deepEqual( data, { example: { foo: 'quux' } } );
+                       } );
+
+               this.server.requests[0].respond( 200, { 'Content-Type': 'application/json' },
+                       '{ "tokens": { "testbadtokentoken": "a-bad-token" } }'
+               );
+
+               this.server.requests[1].respond( 200, { 'Content-Type': 'application/json' },
+                       '{ "error": { "code": "badtoken" } }'
+               );
+
+               this.server.requests[2].respond( 200, { 'Content-Type': 'application/json' },
+                       '{ "tokens": { "testbadtokentoken": "a-good-token" } }'
+               );
+
+               this.server.requests[3].respond( 200, { 'Content-Type': 'application/json' },
+                       '{ "example": { "foo": "quux" } }'
+               );
+
+       } );
+
+       QUnit.test( 'postWithToken() - badtoken-cached', function ( assert ) {
+               QUnit.expect( 2 );
+
+               var api = new mw.Api();
+
+               // - Request: token
+               // - Request: action=example
+               api.postWithToken( 'testbadtokencache', { action: 'example', key: 'foo' } )
+                       .done( function ( data ) {
+                               assert.deepEqual( data, { example: { foo: 'quux' } } );
+                       } );
+
+               // - Cache: Try previously cached token
+               // - Request: action=example -> badtoken error
+               // - Request: new token
+               // - Request: action=example
+               api.postWithToken( 'testbadtokencache', { action: 'example', key: 'bar' } )
+                       .done( function ( data ) {
+                               assert.deepEqual( data, { example: { bar: 'quux' } } );
+                       } );
+
+               this.server.requests[0].respond( 200, { 'Content-Type': 'application/json' },
+                       '{ "tokens": { "testbadtokencachetoken": "a-good-token-once" } }'
+               );
+
+               this.server.requests[1].respond( 200, { 'Content-Type': 'application/json' },
+                       '{ "example": { "foo": "quux" } }'
+               );
+
+               this.server.requests[2].respond( 200, { 'Content-Type': 'application/json' },
+                       '{ "error": { "code": "badtoken" } }'
+               );
+
+               this.server.requests[3].respond( 200, { 'Content-Type': 'application/json' },
+                       '{ "tokens": { "testbadtokencachetoken": "a-good-new-token" } }'
+               );
+
+               this.server.requests[4].respond( 200, { 'Content-Type': 'application/json' },
+                       '{ "example": { "bar": "quux" } }'
+               );
+
+       } );
+
 }( mediaWiki ) );