Compatibility/System Addon: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(→‎Ship Bug: add ua override policy bug)
(Updated link after move)
 
(21 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Introduction ==
== Introduction ==


The WebCompat [[Firefox/Go Faster|Go Faster add-on]] proposes to provide a site patching mechanism for Firefox users. A site patch is defined as an origin- or path-scoped block of JavaScript that runs in the context of a web page.
The WebCompat System add-on proposes to provide a site patching mechanism for Firefox users. A site patch is defined as an origin- or path-scoped block of JavaScript that runs in the context of a web page.


By using the go faster system add-ons infrastructure and delivery mechanism, we can add and remove top web property site patches via out of band updates (i.e., not tied to the release train cadence). The intention is to provide a means to fix urgent issues until outreach efforts are successful, or until platform bugs or regressions are shipping in release builds as fixed.
By using the system add-ons infrastructure and delivery mechanism, we can add and remove top web property site patches via out of band updates (i.e., not tied to the release train cadence). The intention is to provide a means to fix urgent issues until outreach efforts are successful, or until platform bugs or regressions are shipping in release builds as fixed.
 
== Prior Art ==
 
* Opera Presto: http://www.opera.com/docs/browserjs/
* Opera Blink: https://github.com/operasoftware/browserjs/blob/master/OPRdesktop/browserjs-28.0.js (a less powerful version of browser.js)
* Vivaldi is said to have something similar (citation needed)


== Use Cases ==
== Use Cases ==


* A top site has a bug that affects Firefox users that can be worked around by modifying navigator.userAgent:
* A top site has a bug that affects Firefox users that can be worked around by modifying navigator.userAgent:
** trailers.apple.com blocking Firefox users on OS X 10.11 and above, but videos work when sending a Chrome user agent: {{bug|1262149}}
** trailers.apple.com blocking Firefox users on OS X 10.11 and above, but videos work when sending a Chrome user agent: {{bug|1262149}}
**  YouTube stopped serving MSE/WebM to Firefox 43 users, due to a server side UA parsing bug. Worked around by hard coding 42 in UA string, for youtube.com (until they fixed): {{bug|1233970}}
**  YouTube stopped serving MSE/WebM to Firefox 43 users, due to a server side UA parsing bug. Worked around by hard coding 42 in UA string, for youtube.com (until they fixed): {{bug|1233970}}
* Firefox ships a regression in release breaking top sites
* Firefox ships a regression in release breaking top sites
* Hiding messages such as "Best seen in Chrome”, or unsupported browser banners or redirected pages in top sites. e.g., Bank of America on OSX: {{bug|1280834}}
* Hiding messages such as "Best seen in Chrome”, or unsupported browser banners or redirected pages in top sites. e.g., Bank of America on OSX: {{bug|1280834}}
* Working around widely deployed libraries or frameworks that don't support Firefox, have bugs, or make bad assumptions about Gecko, e.g., BrightCove and Ooyola serving HLS over .m3u8 to Firefox for Android on Android 4 (which is not supported) or greater but mp4 to Android 3 (which is supported).
* Working around widely deployed libraries or frameworks that don't support Firefox, have bugs, or make bad assumptions about Gecko, e.g., BrightCove and Ooyola serving HLS over .m3u8 to Firefox for Android on Android 4 (which is not supported) or greater but mp4 to Android 3 (which is supported).
* Relaxing plugin click-to-play restrictions ({{bug|1186948}}) on some sites to fix Flash plugin detection.
* Relaxing plugin click-to-play restrictions ({{bug|1186948}}) on some sites to fix Flash plugin detection.
* Temporarily shim APIs that have been removed until top site is updated (e.g. showModalDialog).
* Temporarily shim APIs that have been removed until top site is updated (e.g. showModalDialog).
* A top site relies on a (mostly) shimmable non-standard API, e.g., window.event
* A top site relies on a (mostly) shimmable non-standard API, e.g., window.event


== Current solutions to use cases ==
== Looking for source? ==
* Firefox for Android has a dynamic User Agent string override mechanism (see ua-update.json: https://dxr.mozilla.org/mozilla-central/source/mobile/android/app/ua-update.json.in).
 
'''Pros''': simple; out of band CDN updates
 
'''Cons''': only on Fennec, applies to all requests for a given domain, i.e., no conditional spoofing. simple regex tweaks only.
 
* Modifying User Agent with UserAgentOverrides.jsm and SiteSpecificUserAgent.js: https://bugzilla.mozilla.org/show_bug.cgi?id=1127448
 
'''Pros''': works.
 
'''Cons''': has to ride trains. might require a dot release depending on the site and severity.
 
* Hard coding User Agent hacks in Navigator.cpp: https://bugzilla.mozilla.org/show_bug.cgi?id=1233970#c11
 
'''Pros''': Get’s the job done.
 
'''Cons''': Has to ride trains; Might require a dot release depending on the site and severity.
 
== Requirements ==
 
* Ability for developers to see that a site patch is enabled, with short explanation and link to bug (likely via developer console).
 
* Ability to temporarily disable site patch for developers to test fixes.
 
* Ability to modify page CSS
 
* Ability to mutate page DOM
 
* Ability to modify script (inline, external) source before execution
 
* Ability to hook into page load lifecycle events (script execution, CSS parsing, event handlers, etc). See http://www.opera.com/docs/userjs/specs/#evlistener
 
* Ability for a site patch to target a specific URI rather than entire origin.
 
* Ability to define setters and getters for page variables and methods (question for Hallvord: scope?)
 
* Injected JS should not have chrome privileges
 
* Injected JS should have full access to page
 
* Site patches should not run if modified by user.
 
* Possibly access/modify HTTP headers? (Unclear how useful this is, Karl is supposed to suggest a use case here.)
 
== Roadmap and Features ==
=== Version 1 ===
* Goal: Provide UA override patch for specific sites (for document URI request, not to any subsequent requests)
* Target milestone: Firefox 53
==== Meta Bug ====
<bugzilla>
    {
        "id": ["1308271"]
    }
</bugzilla>
==== Ship Bug ====
<bugzilla>
    {
        "id": ["1299448", "1296011", "1307788", "1307792", "1316252", "1317572"],
        "status": ["NEW","REOPENED","UNCONFIRMED","ASSIGNED","RESOLVED","VERIFIED","CLOSED"],
        "include_fields": "id, summary, status, target_milestone, resolution, assigned_to, depends_on, blocks"
    }
</bugzilla>
 
* [https://wiki.mozilla.org/Compatibility/Go_Faster_Addon/User_Agent_Override_Policy UA Override Policy]
 
=== Version 2 ===
TBD
 
== Development ==
 
Repo: https://github.com/mozilla/webcompat-addon
 
Tracking bug: [https://bugzilla.mozilla.org/show_bug.cgi?id=1287966 Bug 1287966]
 
== TODO ==
 
1. Define a policy for Site Patching.


2. Determine what is and isn't possible today via XPCOM; file bugs where needed
The primary codebase is [https://searchfox.org/mozilla-central/source/browser/extensions/webcompat located in-tree at <code>browser/extensions/webcompat/</code>]


3. Develop infrastructure to validate if patches are still needed, or are still working (i.e., once a week)
== Automated Tests ==


4. Build a prototype for UA overrides
See https://wiki.mozilla.org/Compatibility/System_Addon/Automated_Testing


5. Intent to Implement (see https://docs.google.com/document/d/1x27I7hAmWDWiqk3o3YC3fklhE3N59bdgHCQHF5p_lkU/edit#heading=h.d5s8g8tyi5zs)
== Other important documents ==


6. Figure out dev process between GitHub and Bugzilla (and syncing with Mozilla Central once a release is ready).
* [[Compatibility/System_Addon/Interventions|WebCompat Interventions]] - on adding site patches.
* Currently deployed interventions across all channels are listed on Bugzilla with the [https://bugzilla.mozilla.org/buglist.cgi?f1=keywords&resolution=---&v1=webcompat%3Asitepatch-applied&o1=substring&query_format=advanced <code>webcompat:sitepatch-applied</code> keyword], or in the [https://searchfox.org/mozilla-central/source/browser/extensions/webcompat/data/interventions.json looking at the <code>interventions.json</code> file itself].


[[Category:Web Compatibility]]
[[Category:Web Compatibility]]

Latest revision as of 13:15, 28 May 2025

Introduction

The WebCompat System add-on proposes to provide a site patching mechanism for Firefox users. A site patch is defined as an origin- or path-scoped block of JavaScript that runs in the context of a web page.

By using the system add-ons infrastructure and delivery mechanism, we can add and remove top web property site patches via out of band updates (i.e., not tied to the release train cadence). The intention is to provide a means to fix urgent issues until outreach efforts are successful, or until platform bugs or regressions are shipping in release builds as fixed.

Use Cases

  • A top site has a bug that affects Firefox users that can be worked around by modifying navigator.userAgent:
    • trailers.apple.com blocking Firefox users on OS X 10.11 and above, but videos work when sending a Chrome user agent: bug 1262149
    • YouTube stopped serving MSE/WebM to Firefox 43 users, due to a server side UA parsing bug. Worked around by hard coding 42 in UA string, for youtube.com (until they fixed): bug 1233970
  • Firefox ships a regression in release breaking top sites
  • Hiding messages such as "Best seen in Chrome”, or unsupported browser banners or redirected pages in top sites. e.g., Bank of America on OSX: bug 1280834
  • Working around widely deployed libraries or frameworks that don't support Firefox, have bugs, or make bad assumptions about Gecko, e.g., BrightCove and Ooyola serving HLS over .m3u8 to Firefox for Android on Android 4 (which is not supported) or greater but mp4 to Android 3 (which is supported).
  • Relaxing plugin click-to-play restrictions (bug 1186948) on some sites to fix Flash plugin detection.
  • Temporarily shim APIs that have been removed until top site is updated (e.g. showModalDialog).
  • A top site relies on a (mostly) shimmable non-standard API, e.g., window.event

Looking for source?

The primary codebase is located in-tree at browser/extensions/webcompat/

Automated Tests

See https://wiki.mozilla.org/Compatibility/System_Addon/Automated_Testing

Other important documents