Skip to content

CSS @media (scripting) rule not honoured when scripting is disabled. #4077

Description

@nomakwae

Prerequisites

  • I verified that this is not a filter list issue. Report any issues with filter lists or broken website functionality in the uAssets issue tracker.
  • This is NOT a YouTube, Facebook or Twitch report. These sites MUST be reported by clicking their respective links.
  • This is not a support issue or a question. For support, questions, or help, visit /r/uBlockOrigin.
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue.
  • The issue is not present after disabling uBO in the browser.
  • I checked the documentation to understand that the issue I am reporting is not normal behavior.

I tried to reproduce the issue when...

  • uBO is the only extension.
  • uBO uses default lists and settings.
  • using a new, unmodified browser profile.

Description

The scripting CSS media feature is not honoured, even though <noscript> tags are, leading to some unexpected behaviour in sites that use these features.

A specific URL where the issue occurs.

https://lyra.horse/css-clicker/
(this is where I encountered and noticed this, but this feature is rarely ever used, so I couldn't find a better demonstrative page)

Steps to Reproduce

  1. Disable JavaScript with the Per-site switch (or globally with no-scripting: * true, and enable javascript in about:config
  2. Open this HTML.
<!doctype html>
<html>
	<head>
		<style>
			p { display: none; }
			@media (scripting: none) { .script-none { display: block; }}
			@media (scripting: initial-only) { .script-initial-only { display: block; }}
			@media (scripting: enabled) { .script-enabled { display: block; }}
		</style>
	</head>
	<body>
		<p class="script-none">You have scripting disabled</p>
		<p class="script-initial-only">You have scripting only enabled during the initial page load</p>
		<p class="script-enabled">You have scripting enabled</p>
		<noscript>You have scripting disabled</noscript>
	</body>
</html>

Expected behavior

The expected output should be "You have scripting disabled" appearing twice, but the CSS rule thinks that scripting is enabled, so we get "You have scripting enabled" as well as "You have scripting disabled" from the spoofed <noscript> tag

Disabling javascript in about:config will show the correct output

Troubleshooting information

uBlock Origin: 1.72.2
Firefox: 152
filterset (summary):
 network: 521691
 cosmetic: 420616
 scriptlet: 79817
 html: 4256
listset (total-discarded, last-updated):
 added:
  https://raw.githubusercontent.com/DandelionSprout/adfilt/master/LegitimateURLShortener.txt: 3005-0, 3h.19m
  adguard-generic: 98580-5850, 2d.21h.33m
  adguard-mobile: 12626-74, 2d.21h.33m
  adguard-spyware-url: 2584-293, 1d.22h
  block-lan: 91-0, 10d.18h.47m
  curben-phishing: 170833-48, 3h.19m
  adguard-cookies: 39648-115, 2d.21h.33m
  ublock-cookies-adguard: 5813-81, 1d.21h.59m
  fanboy-cookiemonster: 47183-3906, 6d.17h
  ublock-cookies-easylist: 5813-5813, 1d.22h
  adguard-social: 26678-46, 2d.21h.33m
  fanboy-social: 17740-873, 1d.22h
  [51 lists not shown]: [too many]
 default:
  user-filters: 0-0, never
  ublock-filters: 53404-72, 3h.19m Δ
  ublock-badware: 10524-27, 3h.19m Δ
  ublock-privacy: 4082-67, 3h.19m Δ
  ublock-unbreak: 2858-1, 3h.19m Δ
  ublock-quick-fixes: 504-13, 3h.19m Δ
  easylist: 93202-1329, 3h.19m Δ
  easyprivacy: 56136-139, 3h.19m Δ
  urlhaus-1: 47690-6, 3h.19m
  plowe-0: 3513-1437, 5d.16h.2m
filterset (user): [empty]
trustedset:
 added: [array of 6 redacted]
switchRuleset:
 added: [array of 82 redacted]
hostRuleset:
 added: [array of 16 redacted]
 removed:
  behind-the-scene * 3p-script noop
userSettings:
 advancedUserEnabled: true
hiddenSettings: [none]
supportStats:
 allReadyAfter: 459 ms (selfie)
 maxAssetCacheWait: 303 ms
 cacheBackend: indexedDB

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions