mw.loader: Fix off-by-one error in splitModuleKey()
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 25 Oct 2016 02:09:07 +0000 (03:09 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 25 Oct 2016 02:12:59 +0000 (03:12 +0100)
Follows-up 45bec76. This caused most localStorage cache entries from
mw.loader.store to be ignored because it'd store tje source code with
a version string that wrongly started with an "@".

As such, on the next page view, when comparing against the version
string from the startup manifest, it would mismatch and eventually
be pruned by mw.loader.store.

Change-Id: If14c80989c0bb28b7b209abe89f83d585c563987

resources/src/mediawiki/mediawiki.js
tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js

index 6b23439..484930a 100644 (file)
                                }
                                return {
                                        name: key.slice( 0, index ),
                                }
                                return {
                                        name: key.slice( 0, index ),
-                                       version: key.slice( index )
+                                       version: key.slice( index + 1 )
                                };
                        }
 
                                };
                        }
 
index bfac513..7233a2e 100644 (file)
                return mw.loader.using( 'test.stale' )
                        .then( function () {
                                assert.strictEqual( count, 1 );
                return mw.loader.using( 'test.stale' )
                        .then( function () {
                                assert.strictEqual( count, 1 );
+                               // After implementing, registry contains version as implemented by the response.
+                               assert.strictEqual( mw.loader.getVersion( 'test.stale' ), 'v1', 'Override version' );
                                assert.strictEqual( mw.loader.getState( 'test.stale' ), 'ready' );
                                assert.ok( mw.loader.store.get( 'test.stale' ), 'In store' );
                        } )
                                assert.strictEqual( mw.loader.getState( 'test.stale' ), 'ready' );
                                assert.ok( mw.loader.store.get( 'test.stale' ), 'In store' );
                        } )