mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-22 18:42:51 +00:00
842a91590a
* eslint-config-wikimedia: 0.27.0 → 0.28.2 The following rules are failing and were disabled: * tests/selenium: * implicit-arrow-linebreak * no-mixed-spaces-and-tabs * grunt-banana-checker: 0.11.1 → 0.13.0 * stylelint-config-wikimedia: 0.16.1 → 0.17.2 The following rules no longer exist and were removed: * stylistic/selector-list-comma-newline-after * braces: 3.0.2 → 3.0.3 * https://github.com/advisories/GHSA-grv7-fg5c-xmjg Change-Id: Ia94454c1da778f241085714e1601a0233d547570
79 lines
1.6 KiB
JavaScript
79 lines
1.6 KiB
JavaScript
/**
|
|
* Represents a page the can be presented in desktop
|
|
* or mobile mode (requires mobilefrontend), and has
|
|
* features like public 'beta' mode (requires mobilefrontend).
|
|
*
|
|
* @extends Page
|
|
* @example
|
|
* https://en.m.wikipedia.org/wiki/Barack_Obama
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const { Page } = require( './mw_core_pages' );
|
|
|
|
class MinervaPage extends Page {
|
|
|
|
get title() {
|
|
return browser.getTitle();
|
|
}
|
|
|
|
/**
|
|
* Opens a page if it isn't already open.
|
|
*
|
|
* @param {string} path
|
|
*/
|
|
open( path = 'Main_Page' ) {
|
|
const currentPage = browser.getUrl(),
|
|
newPage = browser.options.baseUrl + '/index.php?title=' + path;
|
|
if ( currentPage !== newPage ) {
|
|
browser.url( newPage );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Ensure browser is opened on a MediaWiki page, and set a specified
|
|
* cookie for that domain.
|
|
*
|
|
* @param {string} name - name of the cookie
|
|
* @param {string} value - value of the cookie
|
|
*/
|
|
async setCookie( name, value ) {
|
|
const currentPage = await browser.getUrl();
|
|
if ( !currentPage.includes( await browser.options.baseUrl ) ) {
|
|
this.open();
|
|
}
|
|
|
|
const cookie = await browser.getCookies( [ name ] );
|
|
|
|
if ( !cookie || cookie.value !== value ) {
|
|
await browser.setCookies( {
|
|
name: name,
|
|
value: value } );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Set the mobile cookie
|
|
*/
|
|
setMobileMode() {
|
|
this.setCookie( 'mf_useformat', 'true' );
|
|
}
|
|
|
|
/**
|
|
* Set the beta cookie
|
|
*/
|
|
setBetaMode() {
|
|
this.setCookie( 'optin', 'beta' );
|
|
}
|
|
|
|
waitUntilResourceLoaderModuleReady( moduleName ) {
|
|
browser.waitUntil( () => {
|
|
const state = browser.execute( ( m ) => mw.loader.getState( m ), moduleName );
|
|
return state === 'ready';
|
|
} );
|
|
}
|
|
}
|
|
|
|
module.exports = MinervaPage;
|