tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 83900ee6b82f3ff3d14c5a5d843697df4db28036
parent 0cd0cc4226417d7cb4bba784a6f93f49756137a0
Author: Thomas Wisniewski <twisniewski@mozilla.com>
Date:   Tue,  2 Dec 2025 18:41:13 +0000

Bug 1999198 - add an Android-only JS webcompat intervention for anime-bit.ru; r=ksenia,webcompat-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D274652

Diffstat:
Mbrowser/extensions/webcompat/data/interventions.json | 17+++++++++++++++++
Abrowser/extensions/webcompat/injections/js/bug1999198-anime-bit.ru-fix-broken-scrolling.js | 29+++++++++++++++++++++++++++++
Mbrowser/extensions/webcompat/manifest.json | 2+-
Atesting/webcompat/interventions/tests/test_1999198_anime-bit_ru.py | 35+++++++++++++++++++++++++++++++++++
4 files changed, 82 insertions(+), 1 deletion(-)

diff --git a/browser/extensions/webcompat/data/interventions.json b/browser/extensions/webcompat/data/interventions.json @@ -6047,6 +6047,23 @@ } ] }, + "1999198": { + "label": "anime-bit.ru", + "bugs": { + "1999198": { + "issue": "broken-scrolling", + "matches": ["*://*.anime-bit.ru/*"] + } + }, + "interventions": [ + { + "platforms": ["android"], + "content_scripts": { + "js": ["bug1999198-anime-bit.ru-fix-broken-scrolling.js"] + } + } + ] + }, "1999488": { "label": "languageacademy.com.au", "bugs": { diff --git a/browser/extensions/webcompat/injections/js/bug1999198-anime-bit.ru-fix-broken-scrolling.js b/browser/extensions/webcompat/injections/js/bug1999198-anime-bit.ru-fix-broken-scrolling.js @@ -0,0 +1,29 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +/** + * Bug 1999198 - Fix broken scrolling on anime-bit.ru + * + * The site uses quirks mode, and due to a related interop issue their page + * will not load more content as the page is scrolled down. This fixes it. + */ + +/* globals exportFunction */ + +console.info( + "documentElement.clientHeight has been overridden for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1999198 for details." +); + +const proto = Element.prototype.wrappedJSObject; +const clientHeightDesc = Object.getOwnPropertyDescriptor(proto, "clientHeight"); +const origHeight = clientHeightDesc.get; +clientHeightDesc.get = exportFunction(function () { + if (this === document.documentElement) { + return this.scrollHeight; + } + return origHeight.call(this); +}, window); +Object.defineProperty(proto, "clientHeight", clientHeightDesc); diff --git a/browser/extensions/webcompat/manifest.json b/browser/extensions/webcompat/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Web Compatibility Interventions", "description": "Urgent post-release fixes for web compatibility.", - "version": "147.9.0", + "version": "147.10.0", "browser_specific_settings": { "gecko": { "id": "webcompat@mozilla.org", diff --git a/testing/webcompat/interventions/tests/test_1999198_anime-bit_ru.py b/testing/webcompat/interventions/tests/test_1999198_anime-bit_ru.py @@ -0,0 +1,35 @@ +import pytest + +URL = "https://anime-bit.ru/" +HIDDEN_IMAGES_CSS = ".anime_list.shadow.lazy" + + +async def are_wrong_images_hidden(client): + await client.navigate(URL, wait="none") + client.execute_script("window.scrollTo(0, 200)") + # The site hides images with a class .lazy {display:none}, so we can check + # if any of those images are onscreen and should be lacking that CSS class. + return client.execute_script( + """ + for (const img of arguments[0]) { + if (img.getBoundingClientRect().top < window.innerHeight) { + return true; + } + } + """, + client.await_css(HIDDEN_IMAGES_CSS, all=True), + ) + + +@pytest.mark.only_platforms("android") +@pytest.mark.asyncio +@pytest.mark.with_interventions +async def test_enabled(client): + assert not await are_wrong_images_hidden(client) + + +@pytest.mark.only_platforms("android") +@pytest.mark.asyncio +@pytest.mark.without_interventions +async def test_disabled(client): + assert await are_wrong_images_hidden(client)