Bug 1472220 - back out the Fennec GWS/Facebook UA-spoofing system addon added in bug 1453691; r=rhelmer
authorThomas Wisniewski <wisniewskit@gmail.com>
Thu, 20 Sep 2018 14:58:42 +0000
changeset 437451 83eda6b67672b552fa453529410972e11d3cf250
parent 437450 09210ae19019330ec2581480ba719176a309e98c
child 437452 e5781c87acb5468a9fd79e0d3c02748597fafcb6
push id34683
push userapavel@mozilla.com
push dateThu, 20 Sep 2018 21:54:05 +0000
treeherdermozilla-central@4d3cd0ab7277 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhelmer
bugs1472220, 1453691
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1472220 - back out the Fennec GWS/Facebook UA-spoofing system addon added in bug 1453691; r=rhelmer back out the Fennec GWS/Facebook UA-spoofing system addon added in bug 1453691 Differential Revision: https://phabricator.services.mozilla.com/D6065
mobile/android/extensions/gws-and-facebook-chrome-spoof/bootstrap.js
mobile/android/extensions/gws-and-facebook-chrome-spoof/install.rdf.in
mobile/android/extensions/gws-and-facebook-chrome-spoof/moz.build
mobile/android/extensions/moz.build
deleted file mode 100644
--- a/mobile/android/extensions/gws-and-facebook-chrome-spoof/bootstrap.js
+++ /dev/null
@@ -1,137 +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/. */
-
-/* globals Services */
-
-"use strict";
-
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-const TLDsToSpoof = /(^(www|encrypted|maps)\.google\.)|((.*\.facebook|.*\.fbcdn|.*\.fbsbx)\.(com|net)$)/;
-
-const OverrideNotice = "The user agent string has been overridden to get the Chrome experience on this site.";
-const ServiceWorkerFixNotice = "Google service workers are being unregistered to work around https://bugzil.la/1479209";
-const ServiceWorkerSuccessNotice = "Unregistered service worker for";
-const ServiceWorkerFailureNotice = "Could not unregister service worker for";
-
-const defaultUA = Cc["@mozilla.org/network/protocol;1?name=http"].
-                    getService(Ci.nsIHttpProtocolHandler).userAgent;
-
-const RunningFirefoxVersion = (defaultUA.match(/Firefox\/([0-9.]+)/) || ["", "58.0"])[1];
-const RunningAndroidVersion = defaultUA.match(/Android\/[0-9.]+/) || "Android 6.0";
-
-const ChromeMajorVersionToMimic = `${parseInt(RunningFirefoxVersion) + 4}.0.0.0`;
-
-const ChromePhoneUA = `Mozilla/5.0 (Linux; ${RunningAndroidVersion}; Nexus 5 Build/MRA58N) FxQuantum/${RunningFirefoxVersion} AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${ChromeMajorVersionToMimic} Mobile Safari/537.36`;
-const ChromeTabletUA = `Mozilla/5.0 (Linux; ${RunningAndroidVersion}; Nexus 7 Build/JSS15Q) FxQuantum/${RunningFirefoxVersion} AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${ChromeMajorVersionToMimic} Safari/537.36`;
-
-const IsPhone = defaultUA.includes("Mobile");
-
-const TargetUA = IsPhone ? ChromePhoneUA : ChromeTabletUA;
-
-const PrefBranch = "extensions.gws-and-facebook-chrome-spoof.";
-const EnabledPref = `${PrefBranch}enabled`;
-const ServiceWorkerFixPref = `${PrefBranch}serviceworker-fix-applied`;
-
-const Observer = {
-  observe: function HTTP_on_modify_request(aSubject, aTopic, aData) {
-    let channel = aSubject.QueryInterface(Ci.nsIHttpChannel);
-    if (channel && channel.URI.asciiHost.match(TLDsToSpoof)) {
-      channel.setRequestHeader("User-Agent", TargetUA, false);
-      console.info(OverrideNotice);
-    }
-  }
-};
-
-function enable() {
-  try {
-    Services.obs.addObserver(Observer, "http-on-modify-request");
-  } catch (_) {
-  }
-}
-
-function disable() {
-  try {
-    Services.obs.removeObserver(Observer, "http-on-modify-request");
-  } catch (_) {
-  }
-}
-
-function checkIfEnabled() {
-  try {
-    if (Services.prefs.getBoolPref(EnabledPref)) {
-      enable();
-    } else {
-      disable();
-    }
-  } catch (_) {
-    // If the pref does not exist yet, we specify a default value of true.
-    // (the "reset" option in about:config removes prefs without defaults,
-    // and our add-on will not be informed, forcing the user to re-create
-    // the pref manually to disable the add-on).
-    Services.prefs.getDefaultBranch(PrefBranch).setBoolPref("enabled", true);
-    enable();
-  }
-}
-
-function unregisterServiceWorker() {
-  Services.prefs.setBoolPref(ServiceWorkerFixPref, true);
-  let noticeShown = false;
-  const gSWM = Cc["@mozilla.org/serviceworkers/manager;1"]
-               .getService(Ci.nsIServiceWorkerManager);
-  const regs = gSWM.getAllRegistrations();
-  for (let i = 0; i < regs.length; ++i) {
-    let info = regs.queryElementAt(i, Ci.nsIServiceWorkerRegistrationInfo);
-    if (info.principal.origin.match(/^https?:\/\/(www|encrypted|maps)\.google\..*/)) {
-      if (!noticeShown) {
-        console.info(ServiceWorkerFixNotice);
-        noticeShown = true;
-      }
-      let cb = {
-        unregisterSucceeded() {
-          console.info(ServiceWorkerSuccessNotice, info.principal.origin);
-        },
-        unregisterFailed() {
-          console.info(ServiceWorkerFailureNotice, info.principal.origin);
-        },
-        QueryInterface: ChromeUtils.generateQI([Ci.nsIServiceWorkerUnregisterCallback])
-      };
-      gSWM.propagateUnregister(info.principal, cb, info.scope);
-    }
-  }
-}
-
-function checkIfServiceWorkerFixNeeded() {
-  try {
-    if (!Services.prefs.getBoolPref(ServiceWorkerFixPref)) {
-      // If the pref is false, the user wants us to fix again.
-      unregisterServiceWorker();
-    }
-  } catch (_) {
-    // If the pref does not exist yet, we need the fix.
-    unregisterServiceWorker();
-  }
-}
-
-this.install = () => {
-  Services.prefs.setBoolPref(EnabledPref, true);
-};
-
-this.uninstall = () => {
-  Services.prefs.getDefaultBranch(null).deleteBranch(PrefBranch);
-};
-
-this.shutdown = () => {
-  Services.prefs.removeObserver(EnabledPref, checkIfEnabled);
-  Services.prefs.removeObserver(ServiceWorkerFixPref, checkIfServiceWorkerFixNeeded);
-  disable();
-};
-
-this.startup = () => {
-  Services.prefs.addObserver(EnabledPref, checkIfEnabled);
-  Services.prefs.addObserver(ServiceWorkerFixPref, checkIfServiceWorkerFixNeeded);
-  checkIfEnabled();
-  checkIfServiceWorkerFixNeeded();
-};
deleted file mode 100644
--- a/mobile/android/extensions/gws-and-facebook-chrome-spoof/install.rdf.in
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.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/. -->
-
-#filter substitution
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-  <Description about="urn:mozilla:install-manifest">
-    <em:id>gws-and-facebook-spoof@mozilla.org</em:id>
-    <em:type>2</em:type>
-    <em:bootstrap>true</em:bootstrap>
-    <em:multiprocessCompatible>true</em:multiprocessCompatible>
-
-    <em:name>Use Chrome mobile version of Google Search and Facebook</em:name>
-    <em:description>Enables the Chrome Mobile experience for Google Search and Facebook.</em:description>
-
-    <em:version>1.0.0</em:version>
-
-    <em:targetApplication>
-      <Description>
-        <em:id>{aa3c5121-dab2-40e2-81ca-7ea25febc110}</em:id>
-        <em:minVersion>@MOZ_APP_VERSION@</em:minVersion>
-        <em:maxVersion>@MOZ_APP_MAXVERSION@</em:maxVersion>
-      </Description>
-    </em:targetApplication>
-  </Description>
-</RDF>
deleted file mode 100644
--- a/mobile/android/extensions/gws-and-facebook-chrome-spoof/moz.build
+++ /dev/null
@@ -1,19 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION']
-DEFINES['MOZ_APP_MAXVERSION'] = CONFIG['MOZ_APP_MAXVERSION']
-
-with Files('**'):
-  BUG_COMPONENT = ('Web Compatibility Tools', 'General')
-
-FINAL_TARGET_FILES.features['gws-and-facebook-spoof@mozilla.org'] += [
-  'bootstrap.js'
-]
-
-FINAL_TARGET_PP_FILES.features['gws-and-facebook-spoof@mozilla.org'] += [
-  'install.rdf.in'
-]
--- a/mobile/android/extensions/moz.build
+++ b/mobile/android/extensions/moz.build
@@ -5,14 +5,8 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files('**'):
     BUG_COMPONENT = ('Firefox for Android', 'General')
 
 DIRS += [
     'webcompat',
 ]
-
-# Only include the following system add-ons if building Nightly
-if CONFIG['NIGHTLY_BUILD']:
-    DIRS += [
-        'gws-and-facebook-chrome-spoof',
-    ]