2016-09-15 21:07:08 +00:00
|
|
|
<?php
|
2018-07-19 10:48:17 +00:00
|
|
|
|
|
|
|
namespace CookieWarning\Tests;
|
|
|
|
|
|
|
|
use CookieWarning\GeoLocation;
|
|
|
|
use CookieWarning\Hooks;
|
|
|
|
use DerivativeContext;
|
|
|
|
use FauxRequest;
|
|
|
|
use MediaWikiLangTestCase;
|
|
|
|
use RequestContext;
|
|
|
|
use SkinTemplate;
|
|
|
|
|
2016-09-15 21:07:08 +00:00
|
|
|
/**
|
2024-04-22 02:11:56 +00:00
|
|
|
* @covers \CookieWarning\Hooks
|
2016-09-15 21:07:08 +00:00
|
|
|
* @group Database
|
|
|
|
*/
|
2018-07-19 10:48:17 +00:00
|
|
|
class HooksTest extends MediaWikiLangTestCase {
|
2016-09-15 21:07:08 +00:00
|
|
|
|
2024-07-27 07:33:08 +00:00
|
|
|
private function newHooks(): Hooks {
|
|
|
|
$services = $this->getServiceContainer();
|
|
|
|
return new Hooks(
|
|
|
|
$services->getService( 'CookieWarning.Config' ),
|
|
|
|
$services->getService( 'CookieWarning.Decisions' ),
|
|
|
|
$services->getUserOptionsManager()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-09-15 21:07:08 +00:00
|
|
|
/**
|
2020-10-03 18:13:17 +00:00
|
|
|
* @dataProvider providerOnSiteNoticeAfter
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
*
|
|
|
|
* @param bool $enabled
|
|
|
|
* @param false|string $morelinkConfig
|
|
|
|
* @param false|string $morelinkCookieWarningMsg
|
|
|
|
* @param false|string $morelinkCookiePolicyMsg
|
|
|
|
* @param false|string $expectedLink
|
|
|
|
*
|
2018-07-19 10:48:17 +00:00
|
|
|
* @throws \MWException
|
2016-09-15 21:07:08 +00:00
|
|
|
*/
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
public function testOnSiteNoticeAfter(
|
|
|
|
bool $enabled,
|
|
|
|
$morelinkConfig,
|
|
|
|
$morelinkCookieWarningMsg,
|
|
|
|
$morelinkCookiePolicyMsg,
|
|
|
|
$expectedLink
|
2021-07-22 06:56:11 +00:00
|
|
|
): void {
|
2024-07-27 07:21:32 +00:00
|
|
|
$this->overrideConfigValues( [
|
|
|
|
'CookieWarningEnabled' => $enabled,
|
|
|
|
'CookieWarningMoreUrl' => $morelinkConfig,
|
|
|
|
'CookieWarningForCountryCodes' => false,
|
2016-09-14 15:23:11 +00:00
|
|
|
] );
|
2024-07-27 07:40:08 +00:00
|
|
|
$this->getServiceContainer()->getMessageCache()->enable();
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
|
2016-09-15 21:07:08 +00:00
|
|
|
if ( $morelinkCookieWarningMsg ) {
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
$this->editPage(
|
|
|
|
'cookiewarning-more-link',
|
|
|
|
strval( $morelinkCookieWarningMsg ),
|
|
|
|
'',
|
|
|
|
NS_MEDIAWIKI,
|
|
|
|
$this->getTestSysop()->getUser()
|
|
|
|
);
|
2016-09-15 21:07:08 +00:00
|
|
|
}
|
|
|
|
if ( $morelinkCookiePolicyMsg ) {
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
$this->editPage(
|
|
|
|
'cookie-policy-link',
|
|
|
|
strval( $morelinkCookiePolicyMsg ),
|
|
|
|
'',
|
|
|
|
NS_MEDIAWIKI,
|
|
|
|
$this->getTestSysop()->getUser()
|
|
|
|
);
|
2016-09-15 21:07:08 +00:00
|
|
|
}
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
|
2016-09-15 21:07:08 +00:00
|
|
|
$sk = new SkinTemplate();
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
// setup OOUI, that would be normally done in BeforePageDisplay hook
|
|
|
|
$sk->getOutput()->enableOOUI();
|
|
|
|
|
2020-10-03 18:13:17 +00:00
|
|
|
$data = '';
|
2024-07-27 07:33:08 +00:00
|
|
|
$this->newHooks()->onSkinAfterContent( $data, $sk );
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
|
|
|
|
if ( $enabled ) {
|
2022-11-24 22:07:17 +00:00
|
|
|
$this->assertNotSame( '', $data, 'Cookie warning should be present' );
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
} else {
|
2022-11-24 22:07:17 +00:00
|
|
|
$this->assertSame( '', $data, 'Cookie warning should not be present' );
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-15 21:07:08 +00:00
|
|
|
if ( $expectedLink === false ) {
|
2022-10-10 16:01:40 +00:00
|
|
|
$this->assertDoesNotMatchRegularExpression(
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
'/<a[^>]+href=[\'"]([^\'"]+)[\'"].+?>/',
|
|
|
|
$data,
|
|
|
|
'More information link should not be present'
|
|
|
|
);
|
2016-09-15 21:07:08 +00:00
|
|
|
} else {
|
2022-10-10 16:01:40 +00:00
|
|
|
$this->assertMatchesRegularExpression(
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
'/<a[^>]+href=[\'"]' . preg_quote( $expectedLink, '/' ) . '[\'"].+?>/',
|
|
|
|
$data,
|
|
|
|
'More information link should be present and match the expectation'
|
|
|
|
);
|
2016-09-15 21:07:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-21 14:35:54 +00:00
|
|
|
public static function providerOnSiteNoticeAfter(): array {
|
2016-09-14 15:23:11 +00:00
|
|
|
return [
|
|
|
|
[
|
2016-09-15 21:07:08 +00:00
|
|
|
// $wgCookieWarningEnabled
|
|
|
|
true,
|
|
|
|
// $wgCookieWarningMoreUrl
|
|
|
|
'',
|
|
|
|
// MediaWiki:Cookiewarning-more-link
|
|
|
|
false,
|
|
|
|
// MediaWiki:Cookie-policy-link
|
|
|
|
false,
|
|
|
|
// expected cookie warning link (when string), nothing if false
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
false,
|
2016-09-14 15:23:11 +00:00
|
|
|
],
|
|
|
|
[
|
2016-09-15 21:07:08 +00:00
|
|
|
false,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
2016-09-14 15:23:11 +00:00
|
|
|
],
|
|
|
|
[
|
2016-09-15 21:07:08 +00:00
|
|
|
true,
|
|
|
|
'http://google.de',
|
|
|
|
false,
|
|
|
|
false,
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
'http://google.de',
|
2016-09-14 15:23:11 +00:00
|
|
|
],
|
|
|
|
[
|
2016-09-15 21:07:08 +00:00
|
|
|
true,
|
|
|
|
'',
|
|
|
|
'http://google.de',
|
|
|
|
false,
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
'http://google.de',
|
2016-09-14 15:23:11 +00:00
|
|
|
],
|
|
|
|
[
|
2016-09-15 21:07:08 +00:00
|
|
|
true,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
'http://google.de',
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
'http://google.de',
|
2016-09-14 15:23:11 +00:00
|
|
|
],
|
2016-09-15 21:07:08 +00:00
|
|
|
// the config should be the used, if set (no matter if the messages are used or not)
|
2016-09-14 15:23:11 +00:00
|
|
|
[
|
2016-09-15 21:07:08 +00:00
|
|
|
true,
|
|
|
|
'http://google.de',
|
|
|
|
false,
|
|
|
|
'http://google123.de',
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
'http://google.de',
|
2016-09-14 15:23:11 +00:00
|
|
|
],
|
|
|
|
[
|
2016-09-15 21:07:08 +00:00
|
|
|
true,
|
|
|
|
'http://google.de',
|
|
|
|
'http://google1234.de',
|
|
|
|
'http://google123.de',
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
'http://google.de',
|
2016-09-14 15:23:11 +00:00
|
|
|
],
|
|
|
|
[
|
2016-09-15 21:07:08 +00:00
|
|
|
true,
|
|
|
|
'',
|
|
|
|
'http://google.de',
|
|
|
|
'http://google123.de',
|
Move the warning outside sitenotice, tidy up code
There's a lot of things going on here, so a quick summary:
* Moved the warning outside sitenotice to avoid reflows and all
kinds of other issues, including those with dismissable notices.
* Placed the warning on the bottom of the page, on all skins, for
consistency and to avoid obstructing vital UI elements such as
site name, user tools, search box.
* Changed the UI to use OOUI for, again, consistency and to avoid
reinventing the wheel with button styling.
* Removed the cookie emoji as it was only taking up valuable space
on mobile and making designing a sensible layout much harder.
* Merged the mobile and desktop RL modules into a single, responsive
one. The warning will work correctly for any skin and screen width.
* The integration tests are truly horrible, I tried to at least
make them work. They deserve a proper rewrite, but that should be
done after the extension switches to the new hook system.
I will post screenshots of this in action in the first of the linked
tasks.
Bug: T271047
Bug: T173335
Change-Id: I6e2a3d7aeccc0d4df1b3238e52c67e72099d27d8
2021-02-01 09:54:49 +00:00
|
|
|
'http://google.de',
|
2016-09-14 15:23:11 +00:00
|
|
|
],
|
|
|
|
];
|
2016-09-15 21:07:08 +00:00
|
|
|
}
|
Add option to limit the cookie warning to specific regions
With this change, CookieWarning gets two new ways to limit the warning
bar to users of specific (configurable) regions. Based on the geo location
service (which can be configured, too, defaults to freegeoip.net), the
extension will try to get the region of the user (based on the IP address)
and checks it against the configured regions.
With the configuration variable $wgCookieWarningGeoIPLookup, the wiki sysadmin
can configure, if the lookup should be done with PHP (the timeout for the
request is hardcoded to 2 sedonds max), which will save the paylod sent to
the user, or with JavaScript, which will be asynchronous.
Deactivating this feature is easily done by simply setting the configured regions
to false, instead of an object.
Bug: T145780
Change-Id: I4d9371b8608ef270c11c42bdb3a773675977ab3a
2016-09-16 19:18:49 +00:00
|
|
|
|
|
|
|
/**
|
2020-10-03 18:13:17 +00:00
|
|
|
* @dataProvider providerOnSiteNoticeAfterGeoLocation
|
2018-07-19 10:48:17 +00:00
|
|
|
* @throws \MWException
|
|
|
|
* @throws \ConfigException
|
Add option to limit the cookie warning to specific regions
With this change, CookieWarning gets two new ways to limit the warning
bar to users of specific (configurable) regions. Based on the geo location
service (which can be configured, too, defaults to freegeoip.net), the
extension will try to get the region of the user (based on the IP address)
and checks it against the configured regions.
With the configuration variable $wgCookieWarningGeoIPLookup, the wiki sysadmin
can configure, if the lookup should be done with PHP (the timeout for the
request is hardcoded to 2 sedonds max), which will save the paylod sent to
the user, or with JavaScript, which will be asynchronous.
Deactivating this feature is easily done by simply setting the configured regions
to false, instead of an object.
Bug: T145780
Change-Id: I4d9371b8608ef270c11c42bdb3a773675977ab3a
2016-09-16 19:18:49 +00:00
|
|
|
*/
|
2020-10-03 18:13:17 +00:00
|
|
|
public function testOnSiteNoticeAfterGeoLocation( $ipAddress, $countryCodes,
|
Add option to limit the cookie warning to specific regions
With this change, CookieWarning gets two new ways to limit the warning
bar to users of specific (configurable) regions. Based on the geo location
service (which can be configured, too, defaults to freegeoip.net), the
extension will try to get the region of the user (based on the IP address)
and checks it against the configured regions.
With the configuration variable $wgCookieWarningGeoIPLookup, the wiki sysadmin
can configure, if the lookup should be done with PHP (the timeout for the
request is hardcoded to 2 sedonds max), which will save the paylod sent to
the user, or with JavaScript, which will be asynchronous.
Deactivating this feature is easily done by simply setting the configured regions
to false, instead of an object.
Bug: T145780
Change-Id: I4d9371b8608ef270c11c42bdb3a773675977ab3a
2016-09-16 19:18:49 +00:00
|
|
|
$expected
|
|
|
|
) {
|
2024-07-27 07:21:32 +00:00
|
|
|
$this->overrideConfigValues( [
|
|
|
|
'CookieWarningEnabled' => true,
|
|
|
|
'CookieWarningGeoIPLookup' => is_array( $countryCodes ) ? 'php' : 'none',
|
|
|
|
'CookieWarningForCountryCodes' => $countryCodes,
|
Add option to limit the cookie warning to specific regions
With this change, CookieWarning gets two new ways to limit the warning
bar to users of specific (configurable) regions. Based on the geo location
service (which can be configured, too, defaults to freegeoip.net), the
extension will try to get the region of the user (based on the IP address)
and checks it against the configured regions.
With the configuration variable $wgCookieWarningGeoIPLookup, the wiki sysadmin
can configure, if the lookup should be done with PHP (the timeout for the
request is hardcoded to 2 sedonds max), which will save the paylod sent to
the user, or with JavaScript, which will be asynchronous.
Deactivating this feature is easily done by simply setting the configured regions
to false, instead of an object.
Bug: T145780
Change-Id: I4d9371b8608ef270c11c42bdb3a773675977ab3a
2016-09-16 19:18:49 +00:00
|
|
|
] );
|
2018-07-18 09:50:46 +00:00
|
|
|
$this->mockGeoLocationService();
|
Add option to limit the cookie warning to specific regions
With this change, CookieWarning gets two new ways to limit the warning
bar to users of specific (configurable) regions. Based on the geo location
service (which can be configured, too, defaults to freegeoip.net), the
extension will try to get the region of the user (based on the IP address)
and checks it against the configured regions.
With the configuration variable $wgCookieWarningGeoIPLookup, the wiki sysadmin
can configure, if the lookup should be done with PHP (the timeout for the
request is hardcoded to 2 sedonds max), which will save the paylod sent to
the user, or with JavaScript, which will be asynchronous.
Deactivating this feature is easily done by simply setting the configured regions
to false, instead of an object.
Bug: T145780
Change-Id: I4d9371b8608ef270c11c42bdb3a773675977ab3a
2016-09-16 19:18:49 +00:00
|
|
|
|
|
|
|
$request = new FauxRequest();
|
|
|
|
$request->setIP( $ipAddress );
|
|
|
|
$context = new DerivativeContext( RequestContext::getMain() );
|
|
|
|
$context->setRequest( $request );
|
|
|
|
$sk = new SkinTemplate();
|
|
|
|
$sk->setContext( $context );
|
2020-10-03 18:13:17 +00:00
|
|
|
$data = '';
|
2024-07-27 07:33:08 +00:00
|
|
|
$this->newHooks()->onSkinAfterContent( $data, $sk );
|
Add option to limit the cookie warning to specific regions
With this change, CookieWarning gets two new ways to limit the warning
bar to users of specific (configurable) regions. Based on the geo location
service (which can be configured, too, defaults to freegeoip.net), the
extension will try to get the region of the user (based on the IP address)
and checks it against the configured regions.
With the configuration variable $wgCookieWarningGeoIPLookup, the wiki sysadmin
can configure, if the lookup should be done with PHP (the timeout for the
request is hardcoded to 2 sedonds max), which will save the paylod sent to
the user, or with JavaScript, which will be asynchronous.
Deactivating this feature is easily done by simply setting the configured regions
to false, instead of an object.
Bug: T145780
Change-Id: I4d9371b8608ef270c11c42bdb3a773675977ab3a
2016-09-16 19:18:49 +00:00
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
$expected,
|
2020-10-03 18:13:17 +00:00
|
|
|
(bool)$data
|
Add option to limit the cookie warning to specific regions
With this change, CookieWarning gets two new ways to limit the warning
bar to users of specific (configurable) regions. Based on the geo location
service (which can be configured, too, defaults to freegeoip.net), the
extension will try to get the region of the user (based on the IP address)
and checks it against the configured regions.
With the configuration variable $wgCookieWarningGeoIPLookup, the wiki sysadmin
can configure, if the lookup should be done with PHP (the timeout for the
request is hardcoded to 2 sedonds max), which will save the paylod sent to
the user, or with JavaScript, which will be asynchronous.
Deactivating this feature is easily done by simply setting the configured regions
to false, instead of an object.
Bug: T145780
Change-Id: I4d9371b8608ef270c11c42bdb3a773675977ab3a
2016-09-16 19:18:49 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-05-21 14:35:54 +00:00
|
|
|
public static function providerOnSiteNoticeAfterGeoLocation() {
|
Add option to limit the cookie warning to specific regions
With this change, CookieWarning gets two new ways to limit the warning
bar to users of specific (configurable) regions. Based on the geo location
service (which can be configured, too, defaults to freegeoip.net), the
extension will try to get the region of the user (based on the IP address)
and checks it against the configured regions.
With the configuration variable $wgCookieWarningGeoIPLookup, the wiki sysadmin
can configure, if the lookup should be done with PHP (the timeout for the
request is hardcoded to 2 sedonds max), which will save the paylod sent to
the user, or with JavaScript, which will be asynchronous.
Deactivating this feature is easily done by simply setting the configured regions
to false, instead of an object.
Bug: T145780
Change-Id: I4d9371b8608ef270c11c42bdb3a773675977ab3a
2016-09-16 19:18:49 +00:00
|
|
|
return [
|
|
|
|
[
|
|
|
|
'8.8.8.8',
|
|
|
|
[ 'US' => 'United States of America' ],
|
|
|
|
true,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'8.8.8.8',
|
|
|
|
[ 'EU' => 'European Union' ],
|
|
|
|
false,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'8.8.8.8',
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2018-07-18 09:50:46 +00:00
|
|
|
private function mockGeoLocationService() {
|
|
|
|
$geoLocation = $this->getMockBuilder( GeoLocation::class )
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
2018-11-04 15:15:42 +00:00
|
|
|
$geoLocation->method( 'locate' )->willReturn( 'US' );
|
2018-07-18 09:50:46 +00:00
|
|
|
$this->setService( 'GeoLocation', $geoLocation );
|
Add option to limit the cookie warning to specific regions
With this change, CookieWarning gets two new ways to limit the warning
bar to users of specific (configurable) regions. Based on the geo location
service (which can be configured, too, defaults to freegeoip.net), the
extension will try to get the region of the user (based on the IP address)
and checks it against the configured regions.
With the configuration variable $wgCookieWarningGeoIPLookup, the wiki sysadmin
can configure, if the lookup should be done with PHP (the timeout for the
request is hardcoded to 2 sedonds max), which will save the paylod sent to
the user, or with JavaScript, which will be asynchronous.
Deactivating this feature is easily done by simply setting the configured regions
to false, instead of an object.
Bug: T145780
Change-Id: I4d9371b8608ef270c11c42bdb3a773675977ab3a
2016-09-16 19:18:49 +00:00
|
|
|
}
|
2016-09-15 21:07:08 +00:00
|
|
|
}
|