qunit: Preserve context in QUnit module environment override
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 5 Feb 2014 20:32:01 +0000 (12:32 -0800)
committerTimo Tijhof <krinklemail@gmail.com>
Wed, 5 Feb 2014 20:32:41 +0000 (12:32 -0800)
They were being called as properties of localEnv, which is a
shallow copy of the real one. When other callbacks add
properties to the object, they weren't visible in the local
"this" of the module teardown/setup.

Change-Id: I01e2031e1e2bfcedc7aa3480ce7d9915c8fff7f1

tests/qunit/data/testrunner.js

index 5bdd37f..50e6014 100644 (file)
                                        mw.config.values = freshConfigCopy( localEnv.config );
                                        mw.messages.values = freshMessagesCopy( localEnv.messages );
 
                                        mw.config.values = freshConfigCopy( localEnv.config );
                                        mw.messages.values = freshMessagesCopy( localEnv.messages );
 
-                                       localEnv.setup();
+                                       localEnv.setup.call( this );
                                },
 
                                teardown: function () {
                                        log( 'MwEnvironment> TEARDOWN for "' + QUnit.config.current.module
                                                + ': ' + QUnit.config.current.testName + '"' );
 
                                },
 
                                teardown: function () {
                                        log( 'MwEnvironment> TEARDOWN for "' + QUnit.config.current.module
                                                + ': ' + QUnit.config.current.testName + '"' );
 
-                                       localEnv.teardown();
+                                       localEnv.teardown.call( this );
 
                                        // Farewell, mock environment!
                                        mw.config.values = liveConfig;
 
                                        // Farewell, mock environment!
                                        mw.config.values = liveConfig;