mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-12-03 19:56:39 +00:00
4afa1958a0
Use schema revision 16163887. Add the 'checkin' action, which is accompanied by the 'checkin' property. The action is logged at the following seconds (Fibonacci numbers) after the page loads: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765. The `checkin` property contains the values listed above. Bug: T147314 Change-Id: Ib9ec7bd0e60aa34a04e32222b025347f6ee31794
76 lines
2.4 KiB
JavaScript
76 lines
2.4 KiB
JavaScript
( function ( mw, $ ) {
|
|
var pageVisibility = mw.popups.pageVisibility;
|
|
|
|
QUnit.module( 'ext.popups/pageVisibility', {
|
|
setup: function () {
|
|
pageVisibility.documentHiddenPropertyName = null;
|
|
pageVisibility.documentVisibilityChangeEventName = null;
|
|
}
|
|
} );
|
|
|
|
QUnit.test( 'browser specific `document.hidden` property name is correctly detected', function ( assert ) {
|
|
var testCases = [
|
|
[ { hidden: false }, 'hidden' ],
|
|
[ { mozHidden: false }, 'mozHidden' ],
|
|
[ { msHidden: false }, 'msHidden' ],
|
|
[ { webkitHidden: false }, 'webkitHidden' ],
|
|
[ { unsupportedHidden: false }, undefined ],
|
|
[ {}, undefined ]
|
|
];
|
|
|
|
assert.expect( testCases.length );
|
|
|
|
$.each( testCases, function ( i, testCase ) {
|
|
// clear the cache so we get a fresh result
|
|
pageVisibility.documentHiddenPropertyName = null;
|
|
assert.equal(
|
|
pageVisibility.getDocumentHiddenPropertyName( testCase[ 0 ] ), testCase[ 1 ] );
|
|
} );
|
|
} );
|
|
|
|
QUnit.test( 'browser specific `document.visibilitychange` event name is correctly detected', function ( assert ) {
|
|
var testCases = [
|
|
[ { hidden: false }, 'visibilitychange' ],
|
|
[ { mozHidden: false }, 'mozvisibilitychange' ],
|
|
[ { msHidden: false }, 'msvisibilitychange' ],
|
|
[ { webkitHidden: false }, 'webkitvisibilitychange' ],
|
|
[ { unsupportedHidden: false }, undefined ],
|
|
[ {}, undefined ]
|
|
];
|
|
|
|
assert.expect( testCases.length );
|
|
|
|
$.each( testCases, function ( i, testCase ) {
|
|
// clear the cache so we get a fresh result
|
|
pageVisibility.documentVisibilityChangeEventName = null;
|
|
assert.equal(
|
|
pageVisibility.getDocumentVisibilitychangeEventName( testCase[ 0 ] ), testCase[ 1 ] );
|
|
} );
|
|
} );
|
|
|
|
QUnit.test( 'document visibility is correctly detected', function ( assert ) {
|
|
var testCases = [
|
|
[ { hidden: false }, false ],
|
|
[ { hidden: true }, true ],
|
|
[ { mozHidden: false }, false ],
|
|
[ { mozHidden: true }, true ],
|
|
[ { msHidden: false }, false ],
|
|
[ { msHidden: true }, true ],
|
|
[ { webkitHidden: false }, false ],
|
|
[ { webkitHidden: true }, true ],
|
|
[ { unsupportedHidden: false }, undefined ],
|
|
[ {}, undefined ]
|
|
];
|
|
|
|
assert.expect( testCases.length );
|
|
|
|
$.each( testCases, function ( i, testCase ) {
|
|
// clear the cache so we get a fresh result
|
|
pageVisibility.documentHiddenPropertyName = null;
|
|
assert.equal(
|
|
pageVisibility.isDocumentHidden( testCase[ 0 ] ), testCase[ 1 ] );
|
|
} );
|
|
} );
|
|
|
|
}( mediaWiki, jQuery ) );
|