Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/91537
Change subject: Fix QUnit in Chrome
......................................................................
Fix QUnit in Chrome
Cleanup epoch code and tests in process
(mock the window.history object to avoid the address bar changing
in Chrome)
Change-Id: Ibde7a26d16db73a339641247499ac843806bd4b8
---
M javascripts/externals/epoch.js
M tests/javascripts/common/test_PageApi.js
M tests/javascripts/externals/test_epoch.js
3 files changed, 14 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/37/91537/1
diff --git a/javascripts/externals/epoch.js b/javascripts/externals/epoch.js
index 9111bcf..6eb106c 100644
--- a/javascripts/externals/epoch.js
+++ b/javascripts/externals/epoch.js
@@ -3,12 +3,11 @@
bind: function() {},
trigger: function() {}
},
- enabled: false,
- history: window.history
+ enabled: false
};
( function( H, $ ) {
- var lastState, currentState, h = H.history;
+ var lastState, currentState, h = window.history;
function isBrowserSupported( ua ) {
// http://caniuse.com/history
diff --git a/tests/javascripts/common/test_PageApi.js
b/tests/javascripts/common/test_PageApi.js
index af7c981..4eacc07 100644
--- a/tests/javascripts/common/test_PageApi.js
+++ b/tests/javascripts/common/test_PageApi.js
@@ -3,7 +3,12 @@
QUnit.module( 'MobileFrontend PageApi', {
setup: function() {
+ this._user = mw.config.get( 'wgUserName' );
+ mw.config.set( 'wgUserName', 'jdlrobson' );
pageApi = new PageApi();
+ },
+ teardown: function() {
+ mw.config.set( 'wgUserName', this._user );
}
} );
@@ -24,7 +29,7 @@
resp.lastModifiedTimestamp = '';
assert.deepEqual( resp, {
historyUrl: mw.util.wikiGetlink( 'Test', {
action: 'history' } ),
- lastModifiedUserName: '',
+ lastModifiedUserName: 'jdlrobson',
lastModifiedUserGender: 'unknown',
lastModifiedTimestamp: '',
title: 'Test',
@@ -95,7 +100,7 @@
resp.lastModifiedTimestamp = '';
assert.deepEqual( resp, {
historyUrl: mw.util.wikiGetlink( 'Test', {
action: 'history' } ),
- lastModifiedUserName: '',
+ lastModifiedUserName: 'jdlrobson',
lastModifiedUserGender: 'unknown',
lastModifiedTimestamp: '',
title: 'Test',
diff --git a/tests/javascripts/externals/test_epoch.js
b/tests/javascripts/externals/test_epoch.js
index 6b3eafb..aaf89ef 100644
--- a/tests/javascripts/externals/test_epoch.js
+++ b/tests/javascripts/externals/test_epoch.js
@@ -3,15 +3,15 @@
QUnit.module( 'epoch.js', {
setup: function() {
_h = H.history;
- H.history = {
- state: {},
- replaceState: function() {},
- pushState: function() {}
- };
+ sinon.stub( window.history, 'pushState' );
+ sinon.stub( window.history, 'replaceState' );
+ H.history = window.history;
H._enable();
},
teardown: function() {
H.history = _h;
+ window.history.replaceState.restore();
+ window.history.pushState.restore();
}
} );
--
To view, visit https://gerrit.wikimedia.org/r/91537
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibde7a26d16db73a339641247499ac843806bd4b8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits