Backed out 4 changesets (bug 1386807) for failing opt-mochitest-chrome-3 M(c3) toolkit/content/tests/chrome/test_maximized_persist.xul CLOSED TREE
authorCiure Andrei <aciure@mozilla.com>
Thu, 26 Apr 2018 12:27:46 +0300
changeset 469259 411dfa0e714afdf06524dc2590c53263362a9fea
parent 469258 a0346595283ca86fd8fe1cbb0d9d99f18660b8eb
child 469260 85a3c207b99e3cbf3c3d4fd81906f823920bb1c1
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1386807
milestone61.0a1
backs out669b85a6cab8c99a0bd0afe53a02149a2da77577
8da96d4d931a55739e0514a3276ee854cf361ea7
6cd45f41ee018ce340618fdd337460dc72db2a2d
2b9b6042e58666e04a39ae24cf6cab98e75e8b05
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
Backed out 4 changesets (bug 1386807) for failing opt-mochitest-chrome-3 M(c3) toolkit/content/tests/chrome/test_maximized_persist.xul CLOSED TREE Backed out changeset 669b85a6cab8 (bug 1386807) Backed out changeset 8da96d4d931a (bug 1386807) Backed out changeset 6cd45f41ee01 (bug 1386807) Backed out changeset 2b9b6042e586 (bug 1386807)
accessible/tests/mochitest/events/docload/test_docload_root.html
accessible/tests/mochitest/events/docload/test_docload_shutdown.html
browser/extensions/webcompat/bootstrap.js
browser/extensions/webcompat/content/data/ua_overrides.jsm
browser/extensions/webcompat/content/lib/ua_overrider.jsm
browser/extensions/webcompat/install.rdf.in
browser/extensions/webcompat/moz.build
browser/extensions/webcompat/webextension/background.js
browser/extensions/webcompat/webextension/injections/css/bug0000000-dummy-css-injection.css
browser/extensions/webcompat/webextension/injections/js/bug0000000-dummy-js-injection.js
browser/extensions/webcompat/webextension/manifest.json
--- a/accessible/tests/mochitest/events/docload/test_docload_root.html
+++ b/accessible/tests/mochitest/events/docload/test_docload_root.html
@@ -70,19 +70,16 @@
             {
               role: ROLE_CHROME_WINDOW
             },
             {
               role: ROLE_CHROME_WINDOW
             },
             {
               role: ROLE_CHROME_WINDOW
-            },
-            {
-              role: ROLE_CHROME_WINDOW
             }
           ]
         };
 
         testAccessibleTree(gRootAcc, accTree);
 
         gDialogDoc = gDialog.document;
         ok(isAccessibleInCache(gDialogDoc),
--- a/accessible/tests/mochitest/events/docload/test_docload_shutdown.html
+++ b/accessible/tests/mochitest/events/docload/test_docload_shutdown.html
@@ -86,19 +86,16 @@
             {
               role: ROLE_CHROME_WINDOW
             },
             {
               role: ROLE_CHROME_WINDOW
             },
             {
               role: ROLE_CHROME_WINDOW
-            },
-            {
-              role: ROLE_CHROME_WINDOW
             }
           ]
         };
 
         testAccessibleTree(gRootAcc, accTree);
         // After timeout after event hide for iframe was handled the document
         // accessible for iframe's document should no longer be in cache.
         ok(!isAccessibleInCache(gIframeDoc),
--- a/browser/extensions/webcompat/bootstrap.js
+++ b/browser/extensions/webcompat/bootstrap.js
@@ -1,45 +1,34 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 const PREF_BRANCH = "extensions.webcompat.";
-const PREF_DEFAULTS = {
-  perform_injections: true,
-  perform_ua_overrides: true
-};
-
-const INJECTIONS_ENABLE_PREF_NAME = "extensions.webcompat.perform_injections";
-
-const BROWSER_STARTUP_FINISHED_TOPIC = "browser-delayed-startup-finished";
+const PREF_DEFAULTS = {perform_ua_overrides: true};
 
 const UA_OVERRIDES_INIT_TOPIC = "useragentoverrides-initialized";
 const UA_ENABLE_PREF_NAME = "extensions.webcompat.perform_ua_overrides";
 
 ChromeUtils.defineModuleGetter(this, "UAOverrider", "chrome://webcompat/content/lib/ua_overrider.jsm");
 ChromeUtils.defineModuleGetter(this, "UAOverrides", "chrome://webcompat/content/data/ua_overrides.jsm");
 
 let overrider;
-let webextensionPort;
-
-function InjectionsEnablePrefObserver() {
-  let isEnabled = Services.prefs.getBoolPref(INJECTIONS_ENABLE_PREF_NAME);
-  webextensionPort.postMessage({
-    type: "injection-pref-changed",
-    prefState: isEnabled
-  });
-}
 
 function UAEnablePrefObserver() {
   let isEnabled = Services.prefs.getBoolPref(UA_ENABLE_PREF_NAME);
-  overrider.setShouldOverride(isEnabled);
+  if (isEnabled && !overrider) {
+    overrider = new UAOverrider(UAOverrides);
+    overrider.init();
+  } else if (!isEnabled && overrider) {
+    overrider = null;
+  }
 }
 
 function setDefaultPrefs() {
   const branch = Services.prefs.getDefaultBranch(PREF_BRANCH);
   for (const [key, val] of Object.entries(PREF_DEFAULTS)) {
     // If someone beat us to setting a default, don't overwrite it.
     if (branch.getPrefType(key) !== branch.PREF_INVALID) {
       continue;
@@ -63,55 +52,32 @@ this.install = function() {};
 this.uninstall = function() {};
 
 this.startup = function({webExtension}) {
   setDefaultPrefs();
 
   // Intentionally reset the preference on every browser restart to avoid site
   // breakage by accidentally toggled preferences or by leaving it off after
   // debugging a site.
-  Services.prefs.clearUserPref(INJECTIONS_ENABLE_PREF_NAME);
-  Services.prefs.addObserver(INJECTIONS_ENABLE_PREF_NAME, InjectionsEnablePrefObserver);
-
   Services.prefs.clearUserPref(UA_ENABLE_PREF_NAME);
   Services.prefs.addObserver(UA_ENABLE_PREF_NAME, UAEnablePrefObserver);
 
   // Listen to the useragentoverrides-initialized notification we get and
   // initialize our overrider there. This is done to avoid slowing down the
   // apparent startup proces, since we avoid loading anything before the first
   // window is visible to the user. See bug 1371442 for details.
-  let uaStartupObserver = {
+  let startupWatcher = {
     observe(aSubject, aTopic, aData) {
       if (aTopic !== UA_OVERRIDES_INIT_TOPIC) {
         return;
       }
 
       Services.obs.removeObserver(this, UA_OVERRIDES_INIT_TOPIC);
       overrider = new UAOverrider(UAOverrides);
       overrider.init();
     }
   };
-  Services.obs.addObserver(uaStartupObserver, UA_OVERRIDES_INIT_TOPIC);
-
-  // Observe browser-delayed-startup-finished and only initialize our embedded
-  // WebExtension after that. Otherwise, we'd try to initialize as soon as the
-  // browser starts up, which adds a heavy startup penalty.
-  let appStartupObserver = {
-    observe(aSubject, aTopic, aData) {
-      webExtension.startup().then((api) => {
-        api.browser.runtime.onConnect.addListener((port) => {
-          webextensionPort = port;
-        });
-
-        return Promise.resolve();
-      }).catch((ex) => {
-        console.error(ex);
-      });
-      Services.obs.removeObserver(this, BROWSER_STARTUP_FINISHED_TOPIC);
-    }
-  };
-  Services.obs.addObserver(appStartupObserver, BROWSER_STARTUP_FINISHED_TOPIC);
+  Services.obs.addObserver(startupWatcher, UA_OVERRIDES_INIT_TOPIC);
 };
 
 this.shutdown = function() {
-  Services.prefs.removeObserver(INJECTIONS_ENABLE_PREF_NAME, InjectionsEnablePrefObserver);
   Services.prefs.removeObserver(UA_ENABLE_PREF_NAME, UAEnablePrefObserver);
 };
--- a/browser/extensions/webcompat/content/data/ua_overrides.jsm
+++ b/browser/extensions/webcompat/content/data/ua_overrides.jsm
@@ -1,31 +1,60 @@
 /* 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/. */
 
 /**
- * For detailed information on our policies, and a documention on this format
- * and its possibilites, please check the Mozilla-Wiki at
+ * This is an array of objects that specify user agent overrides. Each object
+ * can have three attributes:
+ *
+ *   * `baseDomain`, required: The base domain that further checks and user
+ *     agents override are applied to. This does not include subdomains.
+ *   * `uriMatcher`: Function that gets the requested URI passed in the first
+ *     argument and needs to return boolean whether or not the override should
+ *     be applied. If not provided, the user agent override will be applied
+ *     every time.
+ *   * `uaTransformer`, required: Function that gets the original Firefox user
+ *     agent passed as its first argument and needs to return a string that
+ *     will be used as the the user agent for this URI.
+ *
+ * Examples:
+ *
+ * Gets applied for all requests to mozilla.org and subdomains:
  *
- * https://wiki.mozilla.org/Compatibility/Go_Faster_Addon/Override_Policies_and_Workflows#User_Agent_overrides
+ * ```
+ *   {
+ *     baseDomain: "mozilla.org",
+ *     uaTransformer: (originalUA) => `Ohai Mozilla, it's me, ${originalUA}`
+ *   }
+ * ```
+ *
+ * Applies to *.example.com/app/*:
+ *
+ * ```
+ *   {
+ *     baseDomain: "example.com",
+ *     uriMatcher: (uri) => uri.includes("/app/"),
+ *     uaTransformer: (originalUA) => originalUA.replace("Firefox", "Otherfox")
+ *   }
+ * ```
  */
+
 const UAOverrides = [
 
   /*
    * This is a dummy override that applies a Chrome UA to a dummy site that
    * blocks all browsers but Chrome.
    *
    * This was only put in place to allow QA to test this system addon on an
    * actual site, since we were not able to find a proper override in time.
    */
   {
     baseDomain: "schub.io",
-    applications: ["firefox", "fennec"],
-    uriMatcher: (uri) => uri.includes("webcompat-addon-testcases.schub.io"),
+    uriMatcher: (uri) => uri.includes("webcompat-ua-dummy.schub.io"),
     uaTransformer: (originalUA) => {
       let prefix = originalUA.substr(0, originalUA.indexOf(")") + 1);
       return `${prefix} AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36`;
     }
   }
 ];
 
 var EXPORTED_SYMBOLS = ["UAOverrides"]; /* exported UAOverrides */
--- a/browser/extensions/webcompat/content/lib/ua_overrider.jsm
+++ b/browser/extensions/webcompat/content/lib/ua_overrider.jsm
@@ -5,74 +5,39 @@
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 ChromeUtils.defineModuleGetter(this, "UserAgentOverrides", "resource://gre/modules/UserAgentOverrides.jsm");
 XPCOMUtils.defineLazyServiceGetter(this, "eTLDService", "@mozilla.org/network/effective-tld-service;1", "nsIEffectiveTLDService");
 
 class UAOverrider {
   constructor(overrides) {
     this._overrides = {};
-    this._shouldOverride = true;
 
     this.initOverrides(overrides);
   }
 
   initOverrides(overrides) {
-    // on xpcshell tests, there is no impleentation for nsIXULAppInfo, so this
-    // might fail there. To have all of our test cases running at all times,
-    // assume they are on Desktop for now.
-    let currentApplication = "firefox";
-    try {
-      currentApplication = Services.appinfo.name.toLowerCase();
-    } catch (_) {}
-
     for (let override of overrides) {
-      // Firefox for Desktop is the default application for all overrides.
-      if (!override.applications) {
-        override.applications = ["firefox"];
-      }
-
-      // If the current application is not targeted by the override in question,
-      // we can skip adding the override to our checks entirely.
-      if (!override.applications.includes(currentApplication)) {
-        continue;
-      }
-
       if (!this._overrides[override.baseDomain]) {
         this._overrides[override.baseDomain] = [];
       }
 
       if (!override.uriMatcher) {
         override.uriMatcher = () => true;
       }
 
       this._overrides[override.baseDomain].push(override);
     }
   }
 
-  /**
-   * Used for disabling overrides when the pref has been flipped to false.
-   *
-   * Since we no longer use our own event handlers, we check this bool in our
-   * override callback and simply return early if we are not supposed to do
-   * anything.
-   */
-  setShouldOverride(newState) {
-    this._shouldOverride = newState;
-  }
-
   init() {
     UserAgentOverrides.addComplexOverride(this.overrideCallback.bind(this));
   }
 
   overrideCallback(channel, defaultUA) {
-    if (!this._shouldOverride) {
-      return false;
-    }
-
     let uaOverride = this.lookupUAOverride(channel.URI, defaultUA);
     if (uaOverride) {
       console.log("The user agent has been overridden for compatibility reasons.");
       return uaOverride;
     }
 
     return false;
   }
--- a/browser/extensions/webcompat/install.rdf.in
+++ b/browser/extensions/webcompat/install.rdf.in
@@ -5,37 +5,28 @@
 
 #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>webcompat@mozilla.org</em:id>
-    <em:version>2.0</em:version>
+    <em:version>1.1</em:version>
     <em:type>2</em:type>
     <em:bootstrap>true</em:bootstrap>
     <em:multiprocessCompatible>true</em:multiprocessCompatible>
-    <em:hasEmbeddedWebExtension>true</em:hasEmbeddedWebExtension>
 
-    <!-- Firefox Desktop -->
+    <!-- Target Application this extension can install into,
+        with minimum and maximum supported versions. -->
     <em:targetApplication>
       <Description>
         <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
         <em:minVersion>@MOZ_APP_VERSION@</em:minVersion>
         <em:maxVersion>@MOZ_APP_MAXVERSION@</em:maxVersion>
       </Description>
     </em:targetApplication>
 
-    <!-- Firefox for Android -->
-    <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>
-
     <!-- Front End MetaData -->
     <em:name>Web Compat</em:name>
     <em:description>Urgent post-release fixes for web compatibility.</em:description>
   </Description>
 </RDF>
--- a/browser/extensions/webcompat/moz.build
+++ b/browser/extensions/webcompat/moz.build
@@ -6,29 +6,16 @@
 
 DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION']
 DEFINES['MOZ_APP_MAXVERSION'] = CONFIG['MOZ_APP_MAXVERSION']
 
 FINAL_TARGET_FILES.features['webcompat@mozilla.org'] += [
   'bootstrap.js'
 ]
 
-FINAL_TARGET_FILES.features['webcompat@mozilla.org']['webextension'] += [
-  'webextension/background.js',
-  'webextension/manifest.json'
-]
-
-FINAL_TARGET_FILES.features['webcompat@mozilla.org']['webextension']['injections']['css'] += [
-  'webextension/injections/css/bug0000000-dummy-css-injection.css'
-]
-
-FINAL_TARGET_FILES.features['webcompat@mozilla.org']['webextension']['injections']['js'] += [
-  'webextension/injections/js/bug0000000-dummy-js-injection.js'
-]
-
 FINAL_TARGET_PP_FILES.features['webcompat@mozilla.org'] += [
   'install.rdf.in'
 ]
 
 BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
 JAR_MANIFESTS += ['jar.mn']
 
 with Files('**'):
deleted file mode 100644
--- a/browser/extensions/webcompat/webextension/background.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * For detailed information on our policies, and a documention on this format
- * and its possibilites, please check the Mozilla-Wiki at
- *
- * https://wiki.mozilla.org/Compatibility/Go_Faster_Addon/Override_Policies_and_Workflows#User_Agent_overrides
- */
-const contentScripts = [
-  {
-    matches: ["*://webcompat-addon-testcases.schub.io/*"],
-    css: [{file: "injections/css/bug0000000-dummy-css-injection.css"}],
-    js: [{file: "injections/js/bug0000000-dummy-js-injection.js"}],
-    runAt: "document_start"
-  }
-];
-
-/* globals browser */
-
-let port = browser.runtime.connect();
-let registeredContentScripts = [];
-
-function registerContentScripts() {
-  contentScripts.forEach(async (contentScript) => {
-    try {
-      let handle = await browser.contentScripts.register(contentScript);
-      registeredContentScripts.push(handle);
-    } catch (ex) {
-      console.error("Registering WebCompat GoFaster content scripts failed: ", ex);
-    }
-  });
-}
-
-function unregisterContentScripts() {
-  registeredContentScripts.forEach((contentScript) => {
-    contentScript.unregister();
-  });
-}
-
-port.onMessage.addListener((message) => {
-  switch (message.type) {
-    case "injection-pref-changed":
-      if (message.prefState) {
-        registerContentScripts();
-      } else {
-        unregisterContentScripts();
-      }
-      break;
-  }
-});
-
-/**
- * Note that we reset all preferences on extension startup, so the injections will
- * never be disabled when this loads up. Because of that, we can simply register
- * right away.
- */
-registerContentScripts();
deleted file mode 100644
--- a/browser/extensions/webcompat/webextension/injections/css/bug0000000-dummy-css-injection.css
+++ /dev/null
@@ -1,3 +0,0 @@
-#css-injection.red {
-  background-color: #0f0;
-}
deleted file mode 100644
--- a/browser/extensions/webcompat/webextension/injections/js/bug0000000-dummy-js-injection.js
+++ /dev/null
@@ -1,11 +0,0 @@
-"use strict";
-
-/* globals exportFunction */
-
-Object.defineProperty(window.wrappedJSObject, "isTestFeatureSupported", {
-  get: exportFunction(function() {
-    return true;
-  }, window),
-
-  set: exportFunction(function() {}, window)
-});
deleted file mode 100644
--- a/browser/extensions/webcompat/webextension/manifest.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
-  "manifest_version": 2,
-  "name": "Web Compat",
-  "description": "Urgent post-release fixes for web compatibility.",
-  "version": "2.0",
-
-  "applications": {
-    "gecko": {
-      "id": "webcompat@mozilla.org",
-      "strict_min_version": "59.0b5"
-    }
-  },
-
-  "permissions": [
-    "<all_urls>"
-  ],
-
-  "background": {
-    "scripts": [
-      "background.js"
-    ]
-  }
-}