зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1694481 - Remove fennec code in webcompat r=webcompat-reviewers,denschub
Differential Revision: https://phabricator.services.mozilla.com/D106176
This commit is contained in:
Родитель
c72e62a54d
Коммит
dac810181c
|
@ -1,34 +0,0 @@
|
|||
/* 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";
|
||||
|
||||
/* global ExtensionAPI, Services, XPCOMUtils */
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
EventDispatcher: "resource://gre/modules/Messaging.jsm",
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
});
|
||||
|
||||
this.experiments = class extends ExtensionAPI {
|
||||
getAPI(context) {
|
||||
function promiseActiveExperiments() {
|
||||
return EventDispatcher.instance.sendRequestForResult({
|
||||
type: "Experiments:GetActive",
|
||||
});
|
||||
}
|
||||
return {
|
||||
experiments: {
|
||||
async isActive(name) {
|
||||
if (!Services.androidBridge || !Services.androidBridge.isFennec) {
|
||||
return undefined;
|
||||
}
|
||||
return promiseActiveExperiments().then(experiments => {
|
||||
return experiments.includes(name);
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
|
@ -1,21 +0,0 @@
|
|||
[
|
||||
{
|
||||
"namespace": "experiments",
|
||||
"description": "experimental API extension to allow checking the status of Fennec experiments via Switchboard",
|
||||
"functions": [
|
||||
{
|
||||
"name": "isActive",
|
||||
"type": "function",
|
||||
"description": "Determine if a given experiment is active.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string",
|
||||
"description": "The experiment's name"
|
||||
}
|
||||
],
|
||||
"async": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -1,33 +0,0 @@
|
|||
/* 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";
|
||||
|
||||
/* global ExtensionAPI, Services, XPCOMUtils */
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
SharedPreferences: "resource://gre/modules/SharedPreferences.jsm",
|
||||
});
|
||||
|
||||
this.sharedPreferences = class extends ExtensionAPI {
|
||||
getAPI(context) {
|
||||
return {
|
||||
sharedPreferences: {
|
||||
async setCharPref(name, value) {
|
||||
if (!Services.androidBridge || !Services.androidBridge.isFennec) {
|
||||
return;
|
||||
}
|
||||
SharedPreferences.forApp().setCharPref(name, value);
|
||||
},
|
||||
async setBoolPref(name, value) {
|
||||
if (!Services.androidBridge || !Services.androidBridge.isFennec) {
|
||||
return;
|
||||
}
|
||||
SharedPreferences.forApp().setBoolPref(name, value);
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
|
@ -1,44 +0,0 @@
|
|||
[
|
||||
{
|
||||
"namespace": "sharedPreferences",
|
||||
"description": "experimental API extension to allow setting SharedPreferences on Fennec",
|
||||
"functions": [
|
||||
{
|
||||
"name": "setBoolPref",
|
||||
"type": "function",
|
||||
"description": "Set the value of a boolean Fennec SharedPreference",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string",
|
||||
"description": "The key name"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "boolean",
|
||||
"description": "The new value"
|
||||
}
|
||||
],
|
||||
"async": true
|
||||
},
|
||||
{
|
||||
"name": "setCharPref",
|
||||
"type": "function",
|
||||
"description": "Set the value of a string Fennec SharedPreference",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string",
|
||||
"description": "The key name"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "string",
|
||||
"description": "The new value"
|
||||
}
|
||||
],
|
||||
"async": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -52,22 +52,12 @@ class UAOverrides {
|
|||
return;
|
||||
}
|
||||
|
||||
const { blocks, matches, telemetryKey, uaTransformer } = override.config;
|
||||
const { blocks, matches, uaTransformer } = override.config;
|
||||
const listener = details => {
|
||||
// We set the "used" telemetry key if the user would have had the
|
||||
// override applied, regardless of whether it is actually applied.
|
||||
if (!details.frameId && override.shouldSendDetailedTelemetry) {
|
||||
// For now, we only care about Telemetry on Fennec, where telemetry
|
||||
// is sent in Java code (as part of the core ping). That code must
|
||||
// be aware of each key we send, which we send as a SharedPreference.
|
||||
browser.sharedPreferences.setBoolPref(`${telemetryKey}Used`, true);
|
||||
}
|
||||
|
||||
// Don't actually override the UA for an experiment if the user is not
|
||||
// part of the experiment (unless they force-enabed the override).
|
||||
if (
|
||||
!override.config.experiment ||
|
||||
override.experimentActive ||
|
||||
override.permanentPrefEnabled === true
|
||||
) {
|
||||
for (const header of details.requestHeaders) {
|
||||
|
@ -111,28 +101,12 @@ class UAOverrides {
|
|||
}
|
||||
this._activeListeners.set(override, listeners);
|
||||
override.active = true;
|
||||
|
||||
// If telemetry is being collected, note the addon version.
|
||||
if (telemetryKey) {
|
||||
const { version } = browser.runtime.getManifest();
|
||||
browser.sharedPreferences.setCharPref(`${telemetryKey}Version`, version);
|
||||
}
|
||||
|
||||
// If collecting detailed telemetry on the override, note that it was activated.
|
||||
if (override.shouldSendDetailedTelemetry) {
|
||||
browser.sharedPreferences.setBoolPref(`${telemetryKey}Ready`, true);
|
||||
}
|
||||
}
|
||||
|
||||
onOverrideConfigChanged(override) {
|
||||
// Check whether the override should be hidden from about:compat.
|
||||
override.hidden = override.config.hidden;
|
||||
|
||||
// Also hide if the override is in an experiment the user is not part of.
|
||||
if (override.config.experiment && !override.experimentActive) {
|
||||
override.hidden = true;
|
||||
}
|
||||
|
||||
// Setting the override's permanent pref overrules whether it is hidden.
|
||||
if (override.permanentPrefEnabled !== undefined) {
|
||||
override.hidden = !override.permanentPrefEnabled;
|
||||
|
@ -146,21 +120,10 @@ class UAOverrides {
|
|||
shouldBeActive = false;
|
||||
}
|
||||
|
||||
// Only send detailed telemetry if the user is actively in an experiment or
|
||||
// has opted into an experimental feature.
|
||||
override.shouldSendDetailedTelemetry =
|
||||
override.config.telemetryKey &&
|
||||
(override.experimentActive || override.permanentPrefEnabled);
|
||||
|
||||
// Overrides gated behind an experiment the user is not part of do not
|
||||
// have to be activated, unless they are gathering telemetry, or the
|
||||
// user has force-enabled them with their permanent pref.
|
||||
if (
|
||||
override.config.experiment &&
|
||||
!override.experimentActive &&
|
||||
!override.config.telemetryKey &&
|
||||
override.permanentPrefEnabled !== true
|
||||
) {
|
||||
if (override.config.experiment && override.permanentPrefEnabled !== true) {
|
||||
shouldBeActive = false;
|
||||
}
|
||||
|
||||
|
@ -189,24 +152,6 @@ class UAOverrides {
|
|||
override.availableOnPlatform = true;
|
||||
override.currentPlatform = platformInfo.os;
|
||||
|
||||
// Note whether the user is actively in the override's experiment (if any).
|
||||
override.experimentActive = false;
|
||||
const experiment = override.config.experiment;
|
||||
if (experiment) {
|
||||
// We expect the definition to have either one string for 'experiment'
|
||||
// (just one branch) or an array of strings (multiple branches). So
|
||||
// here we turn the string case into a one-element array for the loop.
|
||||
const branches = Array.isArray(experiment)
|
||||
? experiment
|
||||
: [experiment];
|
||||
for (const branch of branches) {
|
||||
if (await browser.experiments.isActive(branch)) {
|
||||
override.experimentActive = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there is a specific about:config preference governing
|
||||
// this override, monitor its state.
|
||||
const pref = override.config.permanentPref;
|
||||
|
|
|
@ -36,14 +36,6 @@
|
|||
"events": ["startup"]
|
||||
}
|
||||
},
|
||||
"experiments": {
|
||||
"schema": "experiment-apis/experiments.json",
|
||||
"parent": {
|
||||
"scopes": ["addon_parent"],
|
||||
"script": "experiment-apis/experiments.js",
|
||||
"paths": [["experiments"]]
|
||||
}
|
||||
},
|
||||
"matchPatterns": {
|
||||
"schema": "experiment-apis/matchPatterns.json",
|
||||
"child": {
|
||||
|
@ -52,14 +44,6 @@
|
|||
"paths": [["matchPatterns"]]
|
||||
}
|
||||
},
|
||||
"sharedPreferences": {
|
||||
"schema": "experiment-apis/sharedPreferences.json",
|
||||
"parent": {
|
||||
"scopes": ["addon_parent"],
|
||||
"script": "experiment-apis/sharedPreferences.js",
|
||||
"paths": [["sharedPreferences"]]
|
||||
}
|
||||
},
|
||||
"systemManufacturer": {
|
||||
"schema": "experiment-apis/systemManufacturer.json",
|
||||
"child": {
|
||||
|
|
|
@ -33,12 +33,8 @@ FINAL_TARGET_FILES.features["webcompat@mozilla.org"]["experiment-apis"] += [
|
|||
"experiment-apis/aboutConfigPrefs.json",
|
||||
"experiment-apis/appConstants.js",
|
||||
"experiment-apis/appConstants.json",
|
||||
"experiment-apis/experiments.js",
|
||||
"experiment-apis/experiments.json",
|
||||
"experiment-apis/matchPatterns.js",
|
||||
"experiment-apis/matchPatterns.json",
|
||||
"experiment-apis/sharedPreferences.js",
|
||||
"experiment-apis/sharedPreferences.json",
|
||||
"experiment-apis/systemManufacturer.js",
|
||||
"experiment-apis/systemManufacturer.json",
|
||||
"experiment-apis/trackingProtection.js",
|
||||
|
|
Загрузка…
Ссылка в новой задаче