Compatibility/System Addon/Override Policies and Workflows: Difference between revisions

added automated testing section/link
m (Tweak heading levels depth)
(added automated testing section/link)
 
(8 intermediate revisions by 2 users not shown)
Line 4: Line 4:


As a guiding principle, if deploying a site patch or override would dramatically improve user experience or fix a top site it should be seriously considered. At the same time, we make efforts to remove the override as soon as possible, working with the site developers where possible.
As a guiding principle, if deploying a site patch or override would dramatically improve user experience or fix a top site it should be seriously considered. At the same time, we make efforts to remove the override as soon as possible, working with the site developers where possible.
Consult [[Compatibility/Interventions_Releases|Intervention Releases]] for more information on the process of shipping interventions.


= To Override or not? =
= To Override or not? =
Line 13: Line 15:
* Trending sites should also be considered, even when they don't rank highly in global usage metrics.
* Trending sites should also be considered, even when they don't rank highly in global usage metrics.


= Types of Overrides =
= Types of Interventions =


== User Agent overrides ==
== User Agent overrides ==
Line 93: Line 95:


In addition, the injection file has to be registered in the array located in [https://github.com/mozilla/webcompat-addon/blob/master/src/data/injections.js rc/data/injections.js]. Details on available parameters can be found [https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/content_scripts in the MDN web docs].
In addition, the injection file has to be registered in the array located in [https://github.com/mozilla/webcompat-addon/blob/master/src/data/injections.js rc/data/injections.js]. Details on available parameters can be found [https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/content_scripts in the MDN web docs].
=== Using "custom functions" for more complex overrides
Some injections may require additional logic inside the WebExtension to make them work. An example of this could be a custom blocking ''browser.webRequest.onBeforeRequest'' handler to detect and alter the usage of a popular JavaScript library. To use customized logic, define a ''customFunc'' in your injection definition:
<syntaxhighlight lang="js">
{
  id: "bug1551672",
  platform: "android",
  domain: "Sites using PDK 5 video",
  bug: "1551672",
  data: {
    urls: ["https://*/*/tpPdk.js", "https://*/*/pdk/js/*/*.js"],
    types: ["script"],
  },
  customFunc: "pdk5fix",
}
</syntaxhighlight>
Then, head to ''src/lib/custom_functions.js'' and make sure to define the function you just named. Suppose you need additional logic for clearing up when disabling the intervention, for example, to unregister a handler. In that case, you can define a second function with the ''Disable'' suffix, ''pdk5fixDisable'' in this example.
Custom functions are executed within the background script and have full permissions to do anything that a WebExtension background script can do.
= Automated Testing =
See https://wiki.mozilla.org/Compatibility/System_Addon/Automated_Testing


= Open points for further discussion =
= Open points for further discussion =
Line 99: Line 127:


* Should we override/inject if a site adds a "Your browser is not supported" note? What if the warning is really annoying or even blocking the site, what if it's just a note?
* Should we override/inject if a site adds a "Your browser is not supported" note? What if the warning is really annoying or even blocking the site, what if it's just a note?
* How do we make sure that our override is indeed working? What do we need to test?
* Do we override websites that require a login? How can we ensure that we don't break the site with overriding the user agent or injecting code?
* Do we override websites that require a login? How can we ensure that we don't break the site with overriding the user agent or injecting code?


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

edits