Bug 1921410 - add a UA override for beta.maps.apple.com to bypass block of desktop Linux; r=denschub,webcompat-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D225160
This commit is contained in:
Thomas Wisniewski 2024-10-10 14:06:50 +00:00
parent 75e2b24293
commit dd2fde61a8
5 changed files with 67 additions and 6 deletions

View File

@ -1422,6 +1422,24 @@ const AVAILABLE_UA_OVERRIDES = [
},
},
},
{
/*
* Bug 1921410 - UA override for beta.maps.apple.com
* Webcompat issue #140205 - https://webcompat.com/issues/140205
*
* Apple Maps beta artifically blocks Linux.
*/
id: "bug1921410",
platform: "linux",
domain: "beta.maps.apple.com",
bug: "1921410",
config: {
matches: ["*://beta.maps.apple.com/*"],
uaTransformer: originalUA => {
return UAHelpers.getWindowsUA(originalUA);
},
},
},
];
module.exports = AVAILABLE_UA_OVERRIDES;

View File

@ -144,13 +144,14 @@ class UAOverrides {
async registerUAOverrides() {
const platformMatches = ["all"];
let platformInfo = await browser.runtime.getPlatformInfo();
platformMatches.push(platformInfo.os == "android" ? "android" : "desktop");
const { os } = await browser.runtime.getPlatformInfo();
platformMatches.push(os);
platformMatches.push(os == "android" ? "android" : "desktop");
for (const override of this._availableOverrides) {
if (platformMatches.includes(override.platform)) {
override.availableOnPlatform = true;
override.currentPlatform = platformInfo.os;
override.currentPlatform = os;
// If there is a specific about:config preference governing
// this override, monitor its state.

View File

@ -1422,6 +1422,24 @@ const AVAILABLE_UA_OVERRIDES = [
},
},
},
{
/*
* Bug 1921410 - UA override for beta.maps.apple.com
* Webcompat issue #140205 - https://webcompat.com/issues/140205
*
* Apple Maps beta artifically blocks Linux.
*/
id: "bug1921410",
platform: "linux",
domain: "beta.maps.apple.com",
bug: "1921410",
config: {
matches: ["*://beta.maps.apple.com/*"],
uaTransformer: originalUA => {
return UAHelpers.getWindowsUA(originalUA);
},
},
},
];
module.exports = AVAILABLE_UA_OVERRIDES;

View File

@ -144,13 +144,14 @@ class UAOverrides {
async registerUAOverrides() {
const platformMatches = ["all"];
let platformInfo = await browser.runtime.getPlatformInfo();
platformMatches.push(platformInfo.os == "android" ? "android" : "desktop");
const { os } = await browser.runtime.getPlatformInfo();
platformMatches.push(os);
platformMatches.push(os == "android" ? "android" : "desktop");
for (const override of this._availableOverrides) {
if (platformMatches.includes(override.platform)) {
override.availableOnPlatform = true;
override.currentPlatform = platformInfo.os;
override.currentPlatform = os;
// If there is a specific about:config preference governing
// this override, monitor its state.

View File

@ -0,0 +1,23 @@
import pytest
URL = "https://beta.maps.apple.com/"
BLOCKED_CSS = "#unsupported"
NOT_BLOCKED_CSS = "#shell-container"
@pytest.mark.only_platforms("linux")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
await client.navigate(URL)
assert client.await_css(NOT_BLOCKED_CSS)
assert not client.find_css(BLOCKED_CSS)
@pytest.mark.only_platforms("linux")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
await client.navigate(URL)
assert client.await_css(BLOCKED_CSS)
assert not client.find_css(NOT_BLOCKED_CSS)