tor-browser

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

commit 7ba8e8c9e2dd89548c9c7cc84692837921e9f8f0
parent 4b630e5abdec61c484ed955029585427015650e2
Author: Thomas Wisniewski <twisniewski@mozilla.com>
Date:   Tue,  4 Nov 2025 18:29:44 +0000

Bug 1997687 - add a webcompat JS intervention for sakti.kemenkeu.go.id; r=webcompat-reviewers,ksenia

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

Diffstat:
Mbrowser/extensions/webcompat/data/interventions.json | 18++++++++++++++++++
Abrowser/extensions/webcompat/injections/js/bug1997687-sakti.kemenkeu.go.id-ZoneAwarePromise-fix.js | 47+++++++++++++++++++++++++++++++++++++++++++++++
Mbrowser/extensions/webcompat/manifest.json | 2+-
Atesting/webcompat/interventions/tests/test_1997687_sakti_kemenkeu_go_id.py | 18++++++++++++++++++
4 files changed, 84 insertions(+), 1 deletion(-)

diff --git a/browser/extensions/webcompat/data/interventions.json b/browser/extensions/webcompat/data/interventions.json @@ -5934,5 +5934,23 @@ ] } ] + }, + "1997687": { + "label": "sakti.kemenkeu.go.id", + "bugs": { + "1997687": { + "issue": "page-fails-to-load", + "matches": ["*://sakti.kemenkeu.go.id/*"] + } + }, + "interventions": [ + { + "platforms": ["all"], + "content_scripts": { + "all_frames": true, + "js": ["bug1997687-sakti.kemenkeu.go.id-ZoneAwarePromise-fix.js"] + } + } + ] } } diff --git a/browser/extensions/webcompat/injections/js/bug1997687-sakti.kemenkeu.go.id-ZoneAwarePromise-fix.js b/browser/extensions/webcompat/injections/js/bug1997687-sakti.kemenkeu.go.id-ZoneAwarePromise-fix.js @@ -0,0 +1,47 @@ +/* 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"; + +/** + * sakti.kemenkeu.go.id - page never loads + * + * The page has a race condition while loading where it redefines window.Promise + * before Zone.js loads, triggering a ZoneAwarePromise exception while loading. + * We can prevent this exception from being thrown so the page loads. + */ + +/* globals cloneInto, exportFunction */ + +console.info( + "Zone.assertZonePatched has been overridden for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1997687 for details." +); + +let Zone; +const no_op = exportFunction(() => {}, window); + +const proxyConfig = cloneInto( + { + get(_, prop) { + if (prop === "assertZonePatched") { + return no_op; + } + return window.wrappedJSObject.Reflect.get(...arguments); + }, + }, + window, + { cloneFunctions: true } +); + +Object.defineProperty(window.wrappedJSObject, "Zone", { + configurable: true, + + get: exportFunction(function () { + return Zone; + }, window), + + set: exportFunction(function (value = {}) { + Zone = new window.wrappedJSObject.Proxy(value, proxyConfig); + }, window), +}); 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": "146.7.0", + "version": "146.8.0", "browser_specific_settings": { "gecko": { "id": "webcompat@mozilla.org", diff --git a/testing/webcompat/interventions/tests/test_1997687_sakti_kemenkeu_go_id.py b/testing/webcompat/interventions/tests/test_1997687_sakti_kemenkeu_go_id.py @@ -0,0 +1,18 @@ +import pytest + +URL = "https://sakti.kemenkeu.go.id/" +SUPPORTED_CSS = "input[name=username]" +ERROR_MSG = "Zone.js has detected that ZoneAwarePromise" + + +@pytest.mark.asyncio +@pytest.mark.with_interventions +async def test_enabled(client): + await client.navigate(URL, wait="none", timeout=30) + assert client.await_css(SUPPORTED_CSS, is_displayed=True) + + +@pytest.mark.asyncio +@pytest.mark.without_interventions +async def test_disabled(client): + await client.navigate(URL, await_console_message=ERROR_MSG)