mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-23 23:24:39 +00:00
Use getPageviewToken api
Currently the Popups schema is disabled but if we were to re-enable it, the page tokens would now be consistent with the ReadingDepth schema The getToken function is kept to allow generation of the pageInteractionToken's relating to a link interaction, for which there is no centralised API. Additional changes: * I've updated various tests to use the central mw.user stub to make clearer where tokens come from. Bug: T203013 Change-Id: If746bea5aeed2b4c192a9b8a02feb1fe06480633
This commit is contained in:
parent
14df0a587c
commit
53d1a2c329
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.json
vendored
BIN
resources/dist/index.js.json
vendored
Binary file not shown.
|
@ -59,7 +59,6 @@ function timedAction( baseAction ) {
|
|||
* @param {boolean} isEnabled See `isEnabled.js`
|
||||
* @param {mw.user} user
|
||||
* @param {ext.popups.UserSettings} userSettings
|
||||
* @param {Function} generateToken
|
||||
* @param {mw.Map} config The config of the MediaWiki client-side application,
|
||||
* i.e. `mw.config`
|
||||
* @param {string} url url
|
||||
|
@ -69,7 +68,6 @@ export function boot(
|
|||
isEnabled,
|
||||
user,
|
||||
userSettings,
|
||||
generateToken,
|
||||
config,
|
||||
url
|
||||
) {
|
||||
|
@ -81,7 +79,7 @@ export function boot(
|
|||
isEnabled,
|
||||
isNavPopupsEnabled: config.get( 'wgPopupsConflictsWithNavPopupGadget' ),
|
||||
sessionToken: user.sessionId(),
|
||||
pageToken: generateToken(),
|
||||
pageToken: user.getPageviewToken(),
|
||||
page: {
|
||||
url,
|
||||
title: config.get( 'wgTitle' ),
|
||||
|
|
|
@ -208,7 +208,6 @@ function registerChangeListeners(
|
|||
isEnabled,
|
||||
mw.user,
|
||||
userSettings,
|
||||
generateToken,
|
||||
mw.config,
|
||||
window.location.href
|
||||
);
|
||||
|
|
|
@ -7,7 +7,7 @@ const mw = mediaWiki,
|
|||
REFERRER = 'https://en.wikipedia.org/wiki/Kitten';
|
||||
|
||||
function generateToken() {
|
||||
return '9876543210';
|
||||
return 'ABC';
|
||||
}
|
||||
|
||||
QUnit.module( 'ext.popups/actions' );
|
||||
|
@ -34,7 +34,6 @@ QUnit.test( '#boot', ( assert ) => {
|
|||
false,
|
||||
stubUser,
|
||||
stubUserSettings,
|
||||
generateToken,
|
||||
config,
|
||||
REFERRER
|
||||
);
|
||||
|
@ -129,7 +128,7 @@ QUnit.test( '#linkDwell', function ( assert ) {
|
|||
type: actionTypes.LINK_DWELL,
|
||||
el: this.el,
|
||||
event,
|
||||
token: '9876543210',
|
||||
token: 'ABC',
|
||||
timestamp: mw.now(),
|
||||
title: 'Foo',
|
||||
namespaceId: 1,
|
||||
|
|
|
@ -87,12 +87,9 @@ QUnit.module( 'ext.popups preview @integration', {
|
|||
/* isEnabled: */
|
||||
constant( true ),
|
||||
/* user */
|
||||
{ sessionId: constant( 'sessiontoken' ),
|
||||
isAnon: constant( true ) },
|
||||
stubs.createStubUser( true ),
|
||||
/* userSettings: */
|
||||
{ getPreviewCount: constant( 1 ) },
|
||||
/* generateToken: */
|
||||
constant( 'pagetoken' ),
|
||||
/* config: */
|
||||
{ get: identity }
|
||||
);
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
*/
|
||||
export function createStubUser( isAnon ) {
|
||||
return {
|
||||
getPageviewToken() {
|
||||
return '9876543210';
|
||||
},
|
||||
isAnon() {
|
||||
return isAnon;
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue