Merge inbound to mozilla-central a=merge
authorCoroiu Cristina <ccoroiu@mozilla.com>
Fri, 02 Nov 2018 07:11:08 +0200
changeset 444050 b8222faf7d06e64be9af80a60b87f8d2bab30f97
parent 444049 4408e5678aa6faaaebc4a69fa8bd6cbd161c30d2 (current diff)
parent 444023 b8d0312c16dcd6884de7a8be5791655f60ef40e4 (diff)
child 444051 2be891b25f69091b7c8dd95c8289b87a930e55e4
child 444058 c498718cc8243592d236351788c00e9f1d39d9f0
push id109501
push userccoroiu@mozilla.com
push dateFri, 02 Nov 2018 05:19:20 +0000
treeherdermozilla-inbound@2be891b25f69 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone65.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
Merge inbound to mozilla-central a=merge
dom/browser-element/mochitest/browserElement_BadScreenshot.js
dom/browser-element/mochitest/browserElement_DOMRequestError.js
dom/browser-element/mochitest/browserElement_Download.js
dom/browser-element/mochitest/browserElement_ExecuteScript.js
dom/browser-element/mochitest/browserElement_Find.js
dom/browser-element/mochitest/browserElement_GetContentDimensions.js
dom/browser-element/mochitest/browserElement_GetScreenshot.js
dom/browser-element/mochitest/browserElement_GetScreenshotDppx.js
dom/browser-element/mochitest/browserElement_Manifestchange.js
dom/browser-element/mochitest/browserElement_NextPaint.js
dom/browser-element/mochitest/browserElement_OpenMixedProcess.js
dom/browser-element/mochitest/browserElement_PurgeHistory.js
dom/browser-element/mochitest/browserElement_getWebManifest.js
dom/browser-element/mochitest/file_browserElement_ExecuteScript.html
dom/browser-element/mochitest/file_browserElement_NextPaint.html
dom/browser-element/mochitest/file_browserElement_OpenMixedProcess.html
dom/browser-element/mochitest/file_download_bin.sjs
dom/browser-element/mochitest/file_illegal_web_manifest.html
dom/browser-element/mochitest/file_web_manifest.html
dom/browser-element/mochitest/file_web_manifest.json
dom/browser-element/mochitest/test_browserElement_inproc_BadScreenshot.html
dom/browser-element/mochitest/test_browserElement_inproc_DOMRequestError.html
dom/browser-element/mochitest/test_browserElement_inproc_Download.html
dom/browser-element/mochitest/test_browserElement_inproc_ExecuteScript.html
dom/browser-element/mochitest/test_browserElement_inproc_Find.html
dom/browser-element/mochitest/test_browserElement_inproc_GetContentDimensions.html
dom/browser-element/mochitest/test_browserElement_inproc_GetScreenshot.html
dom/browser-element/mochitest/test_browserElement_inproc_GetScreenshotDppx.html
dom/browser-element/mochitest/test_browserElement_inproc_Manifestchange.html
dom/browser-element/mochitest/test_browserElement_inproc_NextPaint.html
dom/browser-element/mochitest/test_browserElement_inproc_OpenMixedProcess.html
dom/browser-element/mochitest/test_browserElement_inproc_PurgeHistory.html
dom/browser-element/mochitest/test_browserElement_inproc_getWebManifest.html
dom/browser-element/mochitest/test_browserElement_oop_BadScreenshot.html
dom/browser-element/mochitest/test_browserElement_oop_DOMRequestError.html
dom/browser-element/mochitest/test_browserElement_oop_Download.html
dom/browser-element/mochitest/test_browserElement_oop_ExecuteScript.html
dom/browser-element/mochitest/test_browserElement_oop_Find.html
dom/browser-element/mochitest/test_browserElement_oop_GetContentDimensions.html
dom/browser-element/mochitest/test_browserElement_oop_GetScreenshot.html
dom/browser-element/mochitest/test_browserElement_oop_GetScreenshotDppx.html
dom/browser-element/mochitest/test_browserElement_oop_Manifestchange.html
dom/browser-element/mochitest/test_browserElement_oop_NextPaint.html
dom/browser-element/mochitest/test_browserElement_oop_OpenMixedProcess.html
dom/browser-element/mochitest/test_browserElement_oop_PurgeHistory.html
dom/browser-element/mochitest/test_browserElement_oop_getWebManifest.html
--- a/devtools/server/actors/emulation/touch-simulator.js
+++ b/devtools/server/actors/emulation/touch-simulator.js
@@ -1,17 +1,16 @@
 /* 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/. */
 
 /* global XPCNativeWrapper */
 
 "use strict";
 
-const { Cu } = require("chrome");
 const { Services } = require("resource://gre/modules/Services.jsm");
 
 var systemAppOrigin = (function() {
   let systemOrigin = "_";
   try {
     systemOrigin =
       Services.io.newURI(Services.prefs.getCharPref("b2g.system_manifest_url"))
                  .prePath;
@@ -242,42 +241,16 @@ TouchSimulator.prototype = {
       target.dispatchEvent(evt);
       this.cancelClick = true;
     }, delay);
 
     return timeout;
   },
 
   sendTouchEvent(evt, target, name) {
-    function clone(obj) {
-      return Cu.cloneInto(obj, target);
-    }
-    // When running OOP b2g desktop, we need to send the touch events
-    // using the mozbrowser api on the unwrapped frame.
-    if (target.localName == "iframe" && target.mozbrowser === true) {
-      if (name == "touchstart") {
-        this.touchstartTime = Date.now();
-      } else if (name == "touchend") {
-        // If we have a "fast" tap, don't send a click as both will be turned
-        // into a click and that breaks eg. checkboxes.
-        if (Date.now() - this.touchstartTime < delay) {
-          this.cancelClick = true;
-        }
-      }
-      const unwrapped = XPCNativeWrapper.unwrap(target);
-      /* eslint-disable no-multi-spaces */
-      unwrapped.sendTouchEvent(name, clone([0]),       // event type, id
-                               clone([evt.clientX]),   // x
-                               clone([evt.clientY]),   // y
-                               clone([1]), clone([1]), // rx, ry
-                               clone([0]), clone([0]), // rotation, force
-                               1);                     // count
-      /* eslint-enable no-multi-spaces */
-      return;
-    }
     const document = target.ownerDocument;
     const content = this.getContent(target);
     if (!content) {
       return;
     }
 
     const touchEvent = document.createEvent("touchevent");
     const point = document.createTouch(content, target, 0,
--- a/dom/base/test/chrome/window_swapFrameLoaders.xul
+++ b/dom/base/test/chrome/window_swapFrameLoaders.xul
@@ -156,28 +156,16 @@ Test swapFrameLoaders with different fra
         is(pongA, "A", "Frame A message manager gets reply A before swap");
 
         info("Ping message manager for frame B");
         mmB.sendAsyncMessage("ping");
         let [ { data: pongB } ] = await inflightB;
         is(pongB, "B", "Frame B message manager gets reply B before swap");
       }
 
-      // Check height before swap
-      {
-        if (frameA.getContentDimensions) {
-          let { height } = await frameA.getContentDimensions();
-          is(height, heightA, "Frame A's content height is 200px before swap");
-        }
-        if (frameB.getContentDimensions) {
-          let { height } = await frameB.getContentDimensions();
-          is(height, heightB, "Frame B's content height is 400px before swap");
-        }
-      }
-
       // Ping after swap using message managers acquired before
       {
         let mmA = frameA.frameLoader.messageManager;
         let mmB = frameB.frameLoader.messageManager;
 
         let pagehideA = once(mmA, "pagehide");
         let pagehideB = once(mmB, "pagehide");
 
--- a/dom/base/test/mozbrowser_api_utils.js
+++ b/dom/base/test/mozbrowser_api_utils.js
@@ -1,31 +1,18 @@
 const FRAME_URL = "http://example.org/";
 
 const METHODS = {
-  addNextPaintListener: {},
-  removeNextPaintListener: {},
   sendMouseEvent: {},
-  sendTouchEvent: {},
   goBack: {},
   goForward: {},
   reload: {},
   stop: {},
-  download: {},
-  purgeHistory: {},
-  getScreenshot: {},
-  zoom: {},
   getCanGoBack: {},
   getCanGoForward: {},
-  getContentDimensions: {},
-  findAll: {},
-  findNext: {},
-  clearMatch: {},
-  executeScript: {},
-  getWebManifest: {},
 };
 
 const ATTRIBUTES = [];
 
 function once(target, eventName, useCapture = false) {
   info("Waiting for event: '" + JSON.stringify(eventName) + "' on " + target + ".");
 
   return new Promise(resolve => {
--- a/dom/browser-element/BrowserElementChildPreload.js
+++ b/dom/browser-element/BrowserElementChildPreload.js
@@ -11,22 +11,16 @@ function debug(msg) {
 debug("loaded");
 
 var BrowserElementIsReady;
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/BrowserElementPromptService.jsm");
 
-ChromeUtils.defineModuleGetter(this, "ManifestFinder",
-                               "resource://gre/modules/ManifestFinder.jsm");
-ChromeUtils.defineModuleGetter(this, "ManifestObtainer",
-                               "resource://gre/modules/ManifestObtainer.jsm");
-
-
 var kLongestReturnedString = 128;
 
 var Timer = Components.Constructor("@mozilla.org/timer;1",
                                    "nsITimer",
                                    "initWithCallback");
 
 function sendAsyncMsg(msg, data) {
   // Ensure that we don't send any messages before BrowserElementChild.js
@@ -109,18 +103,16 @@ var LISTENED_SYSTEM_EVENTS = [
  */
 
 var global = this;
 
 function BrowserElementChild() {
   // Maps outer window id --> weak ref to window.  Used by modal dialog code.
   this._windowIDDict = {};
 
-  this._nextPaintHandler = null;
-
   this._isContentWindowCreated = false;
 
   this._init();
 };
 
 BrowserElementChild.prototype = {
 
   QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver,
@@ -194,18 +186,16 @@ BrowserElementChild.prototype = {
 
     docShell.QueryInterface(Ci.nsIWebProgress)
             .removeProgressListener(this._progressListener);
 
     LISTENED_EVENTS.forEach(event => {
       removeEventListener(event.type, this, event.useCapture, event.wantsUntrusted);
     });
 
-    this._deactivateNextPaintListener();
-
     removeMessageListener("browser-element-api:call", this);
 
     let els = Cc["@mozilla.org/eventlistenerservice;1"]
                 .getService(Ci.nsIEventListenerService);
     LISTENED_SYSTEM_EVENTS.forEach(event => {
       els.removeSystemEventListener(global, event.type, this, event.useCapture);
     });
 
@@ -269,40 +259,29 @@ BrowserElementChild.prototype = {
         break;
     }
   },
 
   receiveMessage: function(message) {
     let self = this;
 
     let mmCalls = {
-      "purge-history": this._recvPurgeHistory,
-      "get-screenshot": this._recvGetScreenshot,
-      "get-contentdimensions": this._recvGetContentDimensions,
       "send-mouse-event": this._recvSendMouseEvent,
-      "send-touch-event": this._recvSendTouchEvent,
       "get-can-go-back": this._recvCanGoBack,
       "get-can-go-forward": this._recvCanGoForward,
       "go-back": this._recvGoBack,
       "go-forward": this._recvGoForward,
       "reload": this._recvReload,
       "stop": this._recvStop,
       "zoom": this._recvZoom,
       "unblock-modal-prompt": this._recvStopWaiting,
       "fire-ctx-callback": this._recvFireCtxCallback,
       "owner-visibility-change": this._recvOwnerVisibilityChange,
       "entered-fullscreen": this._recvEnteredFullscreen,
       "exit-fullscreen": this._recvExitFullscreen,
-      "activate-next-paint-listener": this._activateNextPaintListener,
-      "deactivate-next-paint-listener": this._deactivateNextPaintListener,
-      "find-all": this._recvFindAll,
-      "find-next": this._recvFindNext,
-      "clear-match": this._recvClearMatch,
-      "execute-script": this._recvExecuteScript,
-      "get-web-manifest": this._recvGetWebManifest,
     }
 
     if (message.data.msg_name in mmCalls) {
       return mmCalls[message.data.msg_name].apply(self, arguments);
     }
   },
 
   _paintFrozenTimer: null,
@@ -536,39 +515,31 @@ BrowserElementChild.prototype = {
       return;
     }
 
     sendAsyncMsg('opensearch', { title: e.target.title,
                                  href: e.target.href });
 
   },
 
-  _manifestChangedHandler: function(e) {
-    debug('Got manifestchanged: (' + e.target.href + ')');
-    let manifest = { href: e.target.href };
-    sendAsyncMsg('manifestchange', manifest);
-
-  },
-
   // Processes the "rel" field in <link> tags and forward to specific handlers.
   _linkAddedHandler: function(e) {
     let win = e.target.ownerGlobal;
     // Ignore links which don't come from the top-level
     // <iframe mozbrowser> window.
     if (win != content) {
       debug('Not top level!');
       return;
     }
 
     let handlers = {
       'icon': this._iconChangedHandler.bind(this),
       'apple-touch-icon': this._iconChangedHandler.bind(this),
       'apple-touch-icon-precomposed': this._iconChangedHandler.bind(this),
       'search': this._openSearchHandler,
-      'manifest': this._manifestChangedHandler
     };
 
     debug('Got linkAdded: (' + e.target.href + ') ' + e.target.rel);
     e.target.rel.split(' ').forEach(function(x) {
       let token = x.toLowerCase();
       if (handlers[token]) {
         handlers[token](e);
       }
@@ -702,37 +673,16 @@ BrowserElementChild.prototype = {
         callback();
       }
     }
 
     addEventListener('MozAfterPaint', onMozAfterPaint, /* useCapture = */ true);
     return onMozAfterPaint;
   },
 
-  _removeMozAfterPaintHandler: function(listener) {
-    removeEventListener('MozAfterPaint', listener,
-                        /* useCapture = */ true);
-  },
-
-  _activateNextPaintListener: function(e) {
-    if (!this._nextPaintHandler) {
-      this._nextPaintHandler = this._addMozAfterPaintHandler(() => {
-        this._nextPaintHandler = null;
-        sendAsyncMsg('nextpaint');
-      });
-    }
-  },
-
-  _deactivateNextPaintListener: function(e) {
-    if (this._nextPaintHandler) {
-      this._removeMozAfterPaintHandler(this._nextPaintHandler);
-      this._nextPaintHandler = null;
-    }
-  },
-
   _windowCloseHandler: function(e) {
     let win = e.target;
     if (win != content || e.defaultPrevented) {
       return;
     }
 
     debug("Closing window " + win);
     sendAsyncMsg('close');
@@ -904,144 +854,16 @@ BrowserElementChild.prototype = {
     if (win != content) {
       return;
     }
 
     debug("scroll event " + win);
     sendAsyncMsg("scroll", { top: win.scrollY, left: win.scrollX });
   },
 
-  _recvPurgeHistory: function(data) {
-    debug("Received purgeHistory message: (" + data.json.id + ")");
-
-    let history = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
-
-    try {
-      if (history && history.count) {
-        history.legacySHistory.PurgeHistory(history.count);
-      }
-    } catch(e) {}
-
-    sendAsyncMsg('got-purge-history', { id: data.json.id, successRv: true });
-  },
-
-  _recvGetScreenshot: function(data) {
-    debug("Received getScreenshot message: (" + data.json.id + ")");
-
-    let self = this;
-    let maxWidth = data.json.args.width;
-    let maxHeight = data.json.args.height;
-    let mimeType = data.json.args.mimeType;
-    let domRequestID = data.json.id;
-
-    let takeScreenshotClosure = function() {
-      self._takeScreenshot(maxWidth, maxHeight, mimeType, domRequestID);
-    };
-
-    let maxDelayMS = Services.prefs.getIntPref('dom.browserElement.maxScreenshotDelayMS', 2000);
-
-    // Try to wait for the event loop to go idle before we take the screenshot,
-    // but once we've waited maxDelayMS milliseconds, go ahead and take it
-    // anyway.
-    Cc['@mozilla.org/message-loop;1'].getService(Ci.nsIMessageLoop).postIdleTask(
-      takeScreenshotClosure, maxDelayMS);
-  },
-
-  _recvExecuteScript: function(data) {
-    debug("Received executeScript message: (" + data.json.id + ")");
-
-    let domRequestID = data.json.id;
-
-    let sendError = errorMsg => sendAsyncMsg("execute-script-done", {
-      errorMsg,
-      id: domRequestID
-    });
-
-    let sendSuccess = successRv => sendAsyncMsg("execute-script-done", {
-      successRv,
-      id: domRequestID
-    });
-
-    let isJSON = obj => {
-      try {
-        JSON.stringify(obj);
-      } catch(e) {
-        return false;
-      }
-      return true;
-    }
-
-    let expectedOrigin = data.json.args.options.origin;
-    let expectedUrl = data.json.args.options.url;
-
-    if (expectedOrigin) {
-      if (expectedOrigin != content.location.origin) {
-        sendError("Origin mismatches");
-        return;
-      }
-    }
-
-    if (expectedUrl) {
-      let expectedURI
-      try {
-       expectedURI = Services.io.newURI(expectedUrl);
-      } catch(e) {
-        sendError("Malformed URL");
-        return;
-      }
-      let currentURI = docShell.QueryInterface(Ci.nsIWebNavigation).currentURI;
-      if (!currentURI.equalsExceptRef(expectedURI)) {
-        sendError("URL mismatches");
-        return;
-      }
-    }
-
-    let sandbox = new Cu.Sandbox([content], {
-      sandboxPrototype: content,
-      sandboxName: "browser-api-execute-script",
-      allowWaivers: false,
-      sameZoneAs: content
-    });
-
-    try {
-      let sandboxRv = Cu.evalInSandbox(data.json.args.script, sandbox, "1.8");
-      if (sandboxRv instanceof sandbox.Promise) {
-        sandboxRv.then(rv => {
-          if (isJSON(rv)) {
-            sendSuccess(rv);
-          } else {
-            sendError("Value returned (resolve) by promise is not a valid JSON object");
-          }
-        }, error => {
-          if (isJSON(error)) {
-            sendError(error);
-          } else {
-            sendError("Value returned (reject) by promise is not a valid JSON object");
-          }
-        });
-      } else {
-        if (isJSON(sandboxRv)) {
-          sendSuccess(sandboxRv);
-        } else {
-          sendError("Script last expression must be a promise or a JSON object");
-        }
-      }
-    } catch(e) {
-      sendError(e.toString());
-    }
-  },
-
-  _recvGetContentDimensions: function(data) {
-    debug("Received getContentDimensions message: (" + data.json.id + ")");
-    sendAsyncMsg('got-contentdimensions', {
-      id: data.json.id,
-      successRv: this._getContentDimensions()
-    });
-  },
-
   _mozScrollAreaChanged: function(e) {
     sendAsyncMsg('scrollareachanged', {
       width: e.width,
       height: e.height
     });
   },
 
   _mozRequestedDOMFullscreen: function(e) {
@@ -1053,115 +875,16 @@ BrowserElementChild.prototype = {
       originNoSuffix: e.target.nodePrincipal.originNoSuffix
     });
   },
 
   _mozExitDomFullscreen: function(e) {
     sendAsyncMsg("exit-dom-fullscreen");
   },
 
-  _getContentDimensions: function() {
-    return {
-      width: content.document.body.scrollWidth,
-      height: content.document.body.scrollHeight
-    }
-  },
-
-  /**
-   * Actually take a screenshot and foward the result up to our parent, given
-   * the desired maxWidth and maxHeight (in CSS pixels), and given the
-   * DOMRequest ID associated with the request from the parent.
-   */
-  _takeScreenshot: function(maxWidth, maxHeight, mimeType, domRequestID) {
-    // You can think of the screenshotting algorithm as carrying out the
-    // following steps:
-    //
-    // - Calculate maxWidth, maxHeight, and viewport's width and height in the
-    //   dimension of device pixels by multiply the numbers with
-    //   window.devicePixelRatio.
-    //
-    // - Let scaleWidth be the factor by which we'd need to downscale the
-    //   viewport pixel width so it would fit within maxPixelWidth.
-    //   (If the viewport's pixel width is less than maxPixelWidth, let
-    //   scaleWidth be 1.) Compute scaleHeight the same way.
-    //
-    // - Scale the viewport by max(scaleWidth, scaleHeight).  Now either the
-    //   viewport's width is no larger than maxWidth, the viewport's height is
-    //   no larger than maxHeight, or both.
-    //
-    // - Crop the viewport so its width is no larger than maxWidth and its
-    //   height is no larger than maxHeight.
-    //
-    // - Set mozOpaque to true and background color to solid white
-    //   if we are taking a JPEG screenshot, keep transparent if otherwise.
-    //
-    // - Return a screenshot of the page's viewport scaled and cropped per
-    //   above.
-    debug("Taking a screenshot: maxWidth=" + maxWidth +
-          ", maxHeight=" + maxHeight +
-          ", mimeType=" + mimeType +
-          ", domRequestID=" + domRequestID + ".");
-
-    if (!content) {
-      // If content is not loaded yet, bail out since even sendAsyncMessage
-      // fails...
-      debug("No content yet!");
-      return;
-    }
-
-    let devicePixelRatio = content.devicePixelRatio;
-
-    let maxPixelWidth = Math.round(maxWidth * devicePixelRatio);
-    let maxPixelHeight = Math.round(maxHeight * devicePixelRatio);
-
-    let contentPixelWidth = content.innerWidth * devicePixelRatio;
-    let contentPixelHeight = content.innerHeight * devicePixelRatio;
-
-    let scaleWidth = Math.min(1, maxPixelWidth / contentPixelWidth);
-    let scaleHeight = Math.min(1, maxPixelHeight / contentPixelHeight);
-
-    let scale = Math.max(scaleWidth, scaleHeight);
-
-    let canvasWidth =
-      Math.min(maxPixelWidth, Math.round(contentPixelWidth * scale));
-    let canvasHeight =
-      Math.min(maxPixelHeight, Math.round(contentPixelHeight * scale));
-
-    let transparent = (mimeType !== 'image/jpeg');
-
-    var canvas = content.document
-      .createElementNS("http://www.w3.org/1999/xhtml", "canvas");
-    if (!transparent)
-      canvas.mozOpaque = true;
-    canvas.width = canvasWidth;
-    canvas.height = canvasHeight;
-
-    let ctx = canvas.getContext("2d", { willReadFrequently: true });
-    ctx.scale(scale * devicePixelRatio, scale * devicePixelRatio);
-
-    let flags = ctx.DRAWWINDOW_DRAW_VIEW |
-                ctx.DRAWWINDOW_USE_WIDGET_LAYERS |
-                ctx.DRAWWINDOW_DO_NOT_FLUSH |
-                ctx.DRAWWINDOW_ASYNC_DECODE_IMAGES;
-    ctx.drawWindow(content, 0, 0, content.innerWidth, content.innerHeight,
-                   transparent ? "rgba(255,255,255,0)" : "rgb(255,255,255)",
-                   flags);
-
-    // Take a JPEG screenshot by default instead of PNG with alpha channel.
-    // This requires us to unpremultiply the alpha channel, which
-    // is expensive on ARM processors because they lack a hardware integer
-    // division instruction.
-    canvas.toBlob(function(blob) {
-      sendAsyncMsg('got-screenshot', {
-        id: domRequestID,
-        successRv: blob
-      });
-    }, mimeType);
-  },
-
   _recvFireCtxCallback: function(data) {
     debug("Received fireCtxCallback message: (" + data.json.menuitem + ")");
 
     let doCommandIfEnabled = (command) => {
       if (docShell.isCommandEnabled(command)) {
         docShell.doCommand(command);
       }
     };
@@ -1235,25 +958,16 @@ BrowserElementChild.prototype = {
 
   _recvSendMouseEvent: function(data) {
     let json = data.json;
     let utils = content.windowUtils;
     utils.sendMouseEventToWindow(json.type, json.x, json.y, json.button,
                                  json.clickCount, json.modifiers);
   },
 
-  _recvSendTouchEvent: function(data) {
-    let json = data.json;
-    let utils = content.windowUtils;
-    utils.sendTouchEventToWindow(json.type, json.identifiers, json.touchesX,
-                                 json.touchesY, json.radiisX, json.radiisY,
-                                 json.rotationAngles, json.forces, json.count,
-                                 json.modifiers);
-  },
-
   _recvCanGoBack: function(data) {
     var webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
     sendAsyncMsg('got-can-go-back', {
       id: data.json.id,
       successRv: webNav.canGoBack
     });
   },
 
@@ -1293,88 +1007,16 @@ BrowserElementChild.prototype = {
     }
   },
 
   _recvStop: function(data) {
     let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
     webNav.stop(webNav.STOP_NETWORK);
   },
 
-  _recvZoom: function(data) {
-    docShell.contentViewer.fullZoom = data.json.zoom;
-  },
-
-  async _recvGetWebManifest(data) {
-    debug(`Received GetWebManifest message: (${data.json.id})`);
-    let manifest = null;
-    let hasManifest = ManifestFinder.contentHasManifestLink(content);
-    if (hasManifest) {
-      try {
-        manifest = await ManifestObtainer.contentObtainManifest(content);
-      } catch (e) {
-        sendAsyncMsg('got-web-manifest', {
-          id: data.json.id,
-          errorMsg: `Error fetching web manifest: ${e}.`,
-        });
-        return;
-      }
-    }
-    sendAsyncMsg('got-web-manifest', {
-      id: data.json.id,
-      successRv: manifest
-    });
-  },
-
-  _initFinder: function() {
-    if (!this._finder) {
-      let {Finder} = ChromeUtils.import("resource://gre/modules/Finder.jsm", {});
-      this._finder = new Finder(docShell);
-    }
-    let listener = {
-      onMatchesCountResult: (data) => {
-        sendAsyncMsg("findchange", {
-          active: true,
-          searchString: this._finder.searchString,
-          searchLimit: this._finder.matchesCountLimit,
-          activeMatchOrdinal: data.current,
-          numberOfMatches: data.total
-        });
-        this._finder.removeResultListener(listener);
-      }
-    };
-    this._finder.addResultListener(listener);
-  },
-
-  _recvFindAll: function(data) {
-    this._initFinder();
-    let searchString = data.json.searchString;
-    this._finder.caseSensitive = data.json.caseSensitive;
-    this._finder.fastFind(searchString, false, false);
-    this._finder.requestMatchesCount(searchString, this._finder.matchesCountLimit, false);
-  },
-
-  _recvFindNext: function(data) {
-    if (!this._finder) {
-      debug("findNext() called before findAll()");
-      return;
-    }
-    this._initFinder();
-    this._finder.findAgain(data.json.backward, false, false);
-    this._finder.requestMatchesCount(this._finder.searchString, this._finder.matchesCountLimit, false);
-  },
-
-  _recvClearMatch: function(data) {
-    if (!this._finder) {
-      debug("clearMach() called before findAll()");
-      return;
-    }
-    this._finder.removeSelection();
-    sendAsyncMsg("findchange", {active: false});
-  },
-
   // The docShell keeps a weak reference to the progress listener, so we need
   // to keep a strong ref to it ourselves.
   _progressListener: {
     QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener,
                                             Ci.nsISupportsWeakReference]),
     _seenLoadStart: false,
 
     onLocationChange: function(webProgress, request, location, flags) {
--- a/dom/browser-element/BrowserElementParent.js
+++ b/dom/browser-element/BrowserElementParent.js
@@ -44,29 +44,28 @@ function defineNoReturnMethod(fn) {
       return;
     }
     if (this._isAlive()) {
       fn.apply(this, arguments);
     }
   };
 }
 
-function defineDOMRequestMethod(msgName) {
+function definePromiseMethod(msgName) {
   return function() {
-    return this._sendDOMRequest(msgName);
+    return this._sendAsyncRequest(msgName);
   };
 }
 
 function BrowserElementParent() {
   debug("Creating new BrowserElementParent object");
-  this._domRequestCounter = 0;
+  this._promiseCounter = 0;
   this._domRequestReady = false;
   this._pendingAPICalls = [];
-  this._pendingDOMRequests = {};
-  this._nextPaintListeners = [];
+  this._pendingPromises = {};
   this._pendingDOMFullscreen = false;
 
   Services.obs.addObserver(this, 'oop-frameloader-crashed', /* ownsWeak = */ true);
   Services.obs.addObserver(this, 'ask-children-to-execute-copypaste-command', /* ownsWeak = */ true);
   Services.obs.addObserver(this, 'back-docommand', /* ownsWeak = */ true);
 }
 
 BrowserElementParent.prototype = {
@@ -152,45 +151,35 @@ BrowserElementParent.prototype = {
     let mmCalls = {
       "hello": this._recvHello,
       "loadstart": this._fireProfiledEventFromMsg,
       "loadend": this._fireProfiledEventFromMsg,
       "close": this._fireEventFromMsg,
       "error": this._fireEventFromMsg,
       "firstpaint": this._fireProfiledEventFromMsg,
       "documentfirstpaint": this._fireProfiledEventFromMsg,
-      "nextpaint": this._recvNextPaint,
-      "got-purge-history": this._gotDOMRequestResult,
-      "got-screenshot": this._gotDOMRequestResult,
-      "got-contentdimensions": this._gotDOMRequestResult,
-      "got-can-go-back": this._gotDOMRequestResult,
-      "got-can-go-forward": this._gotDOMRequestResult,
+      "got-can-go-back": this._gotAsyncResult,
+      "got-can-go-forward": this._gotAsyncResult,
       "requested-dom-fullscreen": this._requestedDOMFullscreen,
       "fullscreen-origin-change": this._fullscreenOriginChange,
       "exit-dom-fullscreen": this._exitDomFullscreen,
-      "got-visible": this._gotDOMRequestResult,
-      "got-set-input-method-active": this._gotDOMRequestResult,
       "scrollviewchange": this._handleScrollViewChange,
       "caretstatechanged": this._handleCaretStateChanged,
-      "findchange": this._handleFindChange,
-      "execute-script-done": this._gotDOMRequestResult,
-      "got-web-manifest": this._gotDOMRequestResult,
     };
 
     let mmSecuritySensitiveCalls = {
       "audioplaybackchange": this._fireEventFromMsg,
       "showmodalprompt": this._handleShowModalPrompt,
       "contextmenu": this._fireCtxMenuEvent,
       "securitychange": this._fireEventFromMsg,
       "locationchange": this._fireEventFromMsg,
       "iconchange": this._fireEventFromMsg,
       "scrollareachanged": this._fireEventFromMsg,
       "titlechange": this._fireProfiledEventFromMsg,
       "opensearch": this._fireEventFromMsg,
-      "manifestchange": this._fireEventFromMsg,
       "metachange": this._fireEventFromMsg,
       "resize": this._fireEventFromMsg,
       "activitydone": this._fireEventFromMsg,
       "scroll": this._fireEventFromMsg,
       "opentab": this._fireEventFromMsg
     };
 
     if (aMsg.data.msg_name in mmCalls) {
@@ -430,22 +419,16 @@ BrowserElementParent.prototype = {
   },
 
   _handleScrollViewChange: function(data) {
     let evt = this._createEvent("scrollviewchange", data.json,
                                 /* cancelable = */ false);
     this._frameElement.dispatchEvent(evt);
   },
 
-  _handleFindChange: function(data) {
-    let evt = this._createEvent("findchange", data.json,
-                                /* cancelable = */ false);
-    this._frameElement.dispatchEvent(evt);
-  },
-
   _createEvent: function(evtName, detail, cancelable) {
     // This will have to change if we ever want to send a CustomEvent with null
     // detail.  For now, it's OK.
     if (detail !== undefined && detail !== null) {
       detail = Cu.cloneInto(detail, this._window);
       return new this._window.CustomEvent('mozbrowser' + evtName,
                                           { bubbles: true,
                                             cancelable: cancelable,
@@ -453,76 +436,80 @@ BrowserElementParent.prototype = {
     }
 
     return new this._window.Event('mozbrowser' + evtName,
                                   { bubbles: true,
                                     cancelable: cancelable });
   },
 
   /**
-   * Kick off a DOMRequest in the child process.
+   * Kick off an async operation in the child process.
    *
-   * We'll fire an event called |msgName| on the child process, passing along
+   * We'll send a message called |msgName| to the child process, passing along
    * an object with two fields:
    *
-   *  - id:  the ID of this request.
-   *  - arg: arguments to pass to the child along with this request.
+   *  - id:  the ID of this async call.
+   *  - arg: arguments to pass to the child along with this async call.
    *
    * We expect the child to pass the ID back to us upon completion of the
-   * request.  See _gotDOMRequestResult.
+   * call.  See _gotAsyncResult.
    */
-  _sendDOMRequest: function(msgName, args) {
-    let id = 'req_' + this._domRequestCounter++;
-    let req = Services.DOMRequest.createRequest(this._window);
+  _sendAsyncRequest: function(msgName, args) {
+    let id = 'req_' + this._promiseCounter++;
+    let resolve, reject;
+    let p = new this._window.Promise((res, rej) => {
+      resolve = res;
+      reject = rej;
+    });
     let self = this;
     let send = function() {
       if (!self._isAlive()) {
         return;
       }
       if (self._sendAsyncMsg(msgName, {id: id, args: args})) {
-        self._pendingDOMRequests[id] = req;
+        self._pendingPromises[id] = { p, resolve, reject };
       } else {
-        Services.DOMRequest.fireErrorAsync(req, "fail");
+        reject(new this._window.DOMException("fail"));
       }
     };
     if (this._domRequestReady) {
       send();
     } else {
       // Child haven't been loaded.
       this._pendingAPICalls.push(send);
     }
-    return req;
+    return p;
   },
 
   /**
-   * Called when the child process finishes handling a DOMRequest.  data.json
-   * must have the fields [id, successRv], if the DOMRequest was successful, or
-   * [id, errorMsg], if the request was not successful.
+   * Called when the child process finishes handling an async call.  data.json
+   * must have the fields [id, successRv], if the async call was successful, or
+   * [id, errorMsg], if the call was not successful.
    *
    * The fields have the following meanings:
    *
-   *  - id:        the ID of the DOM request (see _sendDOMRequest)
-   *  - successRv: the request's return value, if the request succeeded
-   *  - errorMsg:  the message to pass to DOMRequest.fireError(), if the request
-   *               failed.
+   *  - id:        the ID of the async call (see _sendAsyncRequest)
+   *  - successRv: the call's return value, if the call succeeded
+   *  - errorMsg:  the message to pass to the Promise reject callback, if the
+   *               call failed.
    *
    */
-  _gotDOMRequestResult: function(data) {
-    let req = this._pendingDOMRequests[data.json.id];
-    delete this._pendingDOMRequests[data.json.id];
+  _gotAsyncResult: function(data) {
+    let p = this._pendingPromises[data.json.id];
+    delete this._pendingPromises[data.json.id];
 
     if ('successRv' in data.json) {
-      debug("Successful gotDOMRequestResult.");
+      debug("Successful gotAsyncResult.");
       let clientObj = Cu.cloneInto(data.json.successRv, this._window);
-      Services.DOMRequest.fireSuccess(req, clientObj);
+      p.resolve(clientObj);
     }
     else {
-      debug("Got error in gotDOMRequestResult.");
-      Services.DOMRequest.fireErrorAsync(req,
-        Cu.cloneInto(data.json.errorMsg, this._window));
+      debug("Got error in gotAsyncResult.");
+      p.reject(new this._window.DOMException(
+        Cu.cloneInto(data.json.errorMsg, this._window)));
     }
   },
 
   getChildProcessOffset: function() {
     let offset = { x: 0, y: 0 };
     let tabParent = this._frameLoader.tabParent;
     if (tabParent) {
       let offsetX = {};
@@ -544,61 +531,18 @@ BrowserElementParent.prototype = {
       "x": x,
       "y": y,
       "button": button,
       "clickCount": clickCount,
       "modifiers": modifiers
     });
   }),
 
-  sendTouchEvent: defineNoReturnMethod(function(type, identifiers, touchesX, touchesY,
-                                                radiisX, radiisY, rotationAngles, forces,
-                                                count, modifiers) {
-
-    let offset = this.getChildProcessOffset();
-    for (var i = 0; i < touchesX.length; i++) {
-      touchesX[i] += offset.x;
-    }
-    for (var i = 0; i < touchesY.length; i++) {
-      touchesY[i] += offset.y;
-    }
-    this._sendAsyncMsg("send-touch-event", {
-      "type": type,
-      "identifiers": identifiers,
-      "touchesX": touchesX,
-      "touchesY": touchesY,
-      "radiisX": radiisX,
-      "radiisY": radiisY,
-      "rotationAngles": rotationAngles,
-      "forces": forces,
-      "count": count,
-      "modifiers": modifiers
-    });
-  }),
-
-  getCanGoBack: defineDOMRequestMethod('get-can-go-back'),
-  getCanGoForward: defineDOMRequestMethod('get-can-go-forward'),
-  getContentDimensions: defineDOMRequestMethod('get-contentdimensions'),
-
-  findAll: defineNoReturnMethod(function(searchString, caseSensitivity) {
-    return this._sendAsyncMsg('find-all', {
-      searchString,
-      caseSensitive: caseSensitivity == Ci.nsIBrowserElementAPI.FIND_CASE_SENSITIVE
-    });
-  }),
-
-  findNext: defineNoReturnMethod(function(direction) {
-    return this._sendAsyncMsg('find-next', {
-      backward: direction == Ci.nsIBrowserElementAPI.FIND_BACKWARD
-    });
-  }),
-
-  clearMatch: defineNoReturnMethod(function() {
-    return this._sendAsyncMsg('clear-match');
-  }),
+  getCanGoBack: definePromiseMethod('get-can-go-back'),
+  getCanGoForward: definePromiseMethod('get-can-go-forward'),
 
   goBack: defineNoReturnMethod(function() {
     this._sendAsyncMsg('go-back');
   }),
 
   goForward: defineNoReturnMethod(function() {
     this._sendAsyncMsg('go-forward');
   }),
@@ -606,252 +550,16 @@ BrowserElementParent.prototype = {
   reload: defineNoReturnMethod(function(hardReload) {
     this._sendAsyncMsg('reload', {hardReload: hardReload});
   }),
 
   stop: defineNoReturnMethod(function() {
     this._sendAsyncMsg('stop');
   }),
 
-  executeScript: function(script, options) {
-    if (!this._isAlive()) {
-      throw Components.Exception("Dead content process",
-                                 Cr.NS_ERROR_DOM_INVALID_STATE_ERR);
-    }
-
-    // Enforcing options.url or options.origin
-    if (!options.url && !options.origin) {
-      throw Components.Exception("Invalid argument", Cr.NS_ERROR_INVALID_ARG);
-    }
-    return this._sendDOMRequest('execute-script', {script, options});
-  },
-
-  /*
-   * The valid range of zoom scale is defined in preference "zoom.maxPercent" and "zoom.minPercent".
-   */
-  zoom: defineNoReturnMethod(function(zoom) {
-    zoom *= 100;
-    zoom = Math.min(getIntPref("zoom.maxPercent", 300), zoom);
-    zoom = Math.max(getIntPref("zoom.minPercent", 50), zoom);
-    this._sendAsyncMsg('zoom', {zoom: zoom / 100.0});
-  }),
-
-  purgeHistory: defineDOMRequestMethod('purge-history'),
-
-
-  download: function(_url, _options) {
-    if (!this._isAlive()) {
-      return null;
-    }
-
-    let uri = Services.io.newURI(_url);
-    let url = uri.QueryInterface(Ci.nsIURL);
-
-    debug('original _options = ' + uneval(_options));
-
-    // Ensure we have _options, we always use it to send the filename.
-    _options = _options || {};
-    if (!_options.filename) {
-      _options.filename = url.fileName;
-    }
-
-    debug('final _options = ' + uneval(_options));
-
-    // Ensure we have a filename.
-    if (!_options.filename) {
-      throw Components.Exception("Invalid argument", Cr.NS_ERROR_INVALID_ARG);
-    }
-
-    let interfaceRequestor =
-      this._frameLoader.loadContext.QueryInterface(Ci.nsIInterfaceRequestor);
-    let req = Services.DOMRequest.createRequest(this._window);
-
-    function DownloadListener() {
-      debug('DownloadListener Constructor');
-    }
-    DownloadListener.prototype = {
-      extListener: null,
-      onStartRequest: function(aRequest, aContext) {
-        debug('DownloadListener - onStartRequest');
-        let extHelperAppSvc =
-          Cc['@mozilla.org/uriloader/external-helper-app-service;1'].
-          getService(Ci.nsIExternalHelperAppService);
-        let channel = aRequest.QueryInterface(Ci.nsIChannel);
-
-        // First, we'll ensure the filename doesn't have any leading
-        // periods. We have to do it here to avoid ending up with a filename
-        // that's only an extension with no extension (e.g. Sending in
-        // '.jpeg' without stripping the '.' would result in a filename of
-        // 'jpeg' where we want 'jpeg.jpeg'.
-        _options.filename = _options.filename.replace(/^\.+/, "");
-
-        let ext = null;
-        let mimeSvc = extHelperAppSvc.QueryInterface(Ci.nsIMIMEService);
-        try {
-          ext = '.' + mimeSvc.getPrimaryExtension(channel.contentType, '');
-        } catch (e) { ext = null; }
-
-        // Check if we need to add an extension to the filename.
-        if (ext && !_options.filename.endsWith(ext)) {
-          _options.filename += ext;
-        }
-        // Set the filename to use when saving to disk.
-        channel.contentDispositionFilename = _options.filename;
-
-        this.extListener =
-          extHelperAppSvc.doContent(
-              channel.contentType,
-              aRequest,
-              interfaceRequestor,
-              true);
-        this.extListener.onStartRequest(aRequest, aContext);
-      },
-      onStopRequest: function(aRequest, aContext, aStatusCode) {
-        debug('DownloadListener - onStopRequest (aStatusCode = ' +
-               aStatusCode + ')');
-        if (aStatusCode == Cr.NS_OK) {
-          // Everything looks great.
-          debug('DownloadListener - Download Successful.');
-          Services.DOMRequest.fireSuccess(req, aStatusCode);
-        }
-        else {
-          // In case of failure, we'll simply return the failure status code.
-          debug('DownloadListener - Download Failed!');
-          Services.DOMRequest.fireError(req, aStatusCode);
-        }
-
-        if (this.extListener) {
-          this.extListener.onStopRequest(aRequest, aContext, aStatusCode);
-        }
-      },
-      onDataAvailable: function(aRequest, aContext, aInputStream,
-                                aOffset, aCount) {
-        this.extListener.onDataAvailable(aRequest, aContext, aInputStream,
-                                         aOffset, aCount);
-      },
-      QueryInterface: ChromeUtils.generateQI([Ci.nsIStreamListener,
-                                              Ci.nsIRequestObserver])
-    };
-
-    let referrer = Services.io.newURI(_options.referrer);
-    let principal =
-      Services.scriptSecurityManager.createCodebasePrincipal(
-        referrer, this._frameLoader.loadContext.originAttributes);
-
-    let channel = NetUtil.newChannel({
-      uri: url,
-      loadingPrincipal: principal,
-      securityFlags: SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS,
-      contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER
-    });
-
-    // XXX We would set private browsing information prior to calling this.
-    channel.notificationCallbacks = interfaceRequestor;
-
-    // Since we're downloading our own local copy we'll want to bypass the
-    // cache and local cache if the channel let's us specify this.
-    let flags = Ci.nsIChannel.LOAD_CALL_CONTENT_SNIFFERS |
-                Ci.nsIChannel.LOAD_BYPASS_CACHE;
-    if (channel instanceof Ci.nsICachingChannel) {
-      debug('This is a caching channel. Forcing bypass.');
-      flags |= Ci.nsICachingChannel.LOAD_BYPASS_LOCAL_CACHE_IF_BUSY;
-    }
-
-    channel.loadFlags |= flags;
-
-    if (channel instanceof Ci.nsIHttpChannel) {
-      debug('Setting HTTP referrer = ' + (referrer && referrer.spec));
-      channel.referrer = referrer;
-      if (channel instanceof Ci.nsIHttpChannelInternal) {
-        channel.forceAllowThirdPartyCookie = true;
-      }
-    }
-
-    // Set-up complete, let's get things started.
-    channel.asyncOpen2(new DownloadListener());
-
-    return req;
-  },
-
-  getScreenshot: function(_width, _height, _mimeType) {
-    if (!this._isAlive()) {
-      throw Components.Exception("Dead content process",
-                                 Cr.NS_ERROR_DOM_INVALID_STATE_ERR);
-    }
-
-    let width = parseInt(_width);
-    let height = parseInt(_height);
-    let mimeType = (typeof _mimeType === 'string') ?
-      _mimeType.trim().toLowerCase() : 'image/jpeg';
-    if (isNaN(width) || isNaN(height) || width < 0 || height < 0) {
-      throw Components.Exception("Invalid argument",
-                                 Cr.NS_ERROR_INVALID_ARG);
-    }
-
-    return this._sendDOMRequest('get-screenshot',
-                                {width: width, height: height,
-                                 mimeType: mimeType});
-  },
-
-  _recvNextPaint: function(data) {
-    let listeners = this._nextPaintListeners;
-    this._nextPaintListeners = [];
-    for (let listener of listeners) {
-      try {
-        listener();
-      } catch (e) {
-        // If a listener throws we'll continue.
-      }
-    }
-  },
-
-  addNextPaintListener: function(listener) {
-    if (!this._isAlive()) {
-      throw Components.Exception("Dead content process",
-                                 Cr.NS_ERROR_DOM_INVALID_STATE_ERR);
-    }
-
-    let self = this;
-    let run = function() {
-      if (self._nextPaintListeners.push(listener) == 1)
-        self._sendAsyncMsg('activate-next-paint-listener');
-    };
-    if (!this._domRequestReady) {
-      this._pendingAPICalls.push(run);
-    } else {
-      run();
-    }
-  },
-
-  removeNextPaintListener: function(listener) {
-    if (!this._isAlive()) {
-      throw Components.Exception("Dead content process",
-                                 Cr.NS_ERROR_DOM_INVALID_STATE_ERR);
-    }
-
-    let self = this;
-    let run = function() {
-      for (let i = self._nextPaintListeners.length - 1; i >= 0; i--) {
-        if (self._nextPaintListeners[i] == listener) {
-          self._nextPaintListeners.splice(i, 1);
-          break;
-        }
-      }
-
-      if (self._nextPaintListeners.length == 0)
-        self._sendAsyncMsg('deactivate-next-paint-listener');
-    };
-    if (!this._domRequestReady) {
-      this._pendingAPICalls.push(run);
-    } else {
-      run();
-    }
-  },
-
-  getWebManifest: defineDOMRequestMethod('get-web-manifest'),
   /**
    * Called when the visibility of the window which owns this iframe changes.
    */
   _ownerVisibilityChange: function() {
     this._sendAsyncMsg('owner-visibility-change',
                        {visible: !this._window.document.hidden});
   },
 
--- a/dom/browser-element/mochitest/browserElement_BackForward.js
+++ b/dom/browser-element/mochitest/browserElement_BackForward.js
@@ -27,30 +27,30 @@ function runTest() {
   });
 
   iframe.src = browserElementTestHelpers.emptyPage1;
   document.body.appendChild(iframe);
 }
 
 function checkCanGoBackAndForward(canGoBack, canGoForward, nextTest) {
   var seenCanGoBackResult = false;
-  iframe.getCanGoBack().onsuccess = function(e) {
+  iframe.getCanGoBack().then(function(result) {
     is(seenCanGoBackResult, false, "onsuccess handler shouldn't be called twice.");
     seenCanGoBackResult = true;
-    is(e.target.result, canGoBack);
+    is(result, canGoBack);
     maybeRunNextTest();
-  };
+  });
 
   var seenCanGoForwardResult = false;
-  iframe.getCanGoForward().onsuccess = function(e) {
+  iframe.getCanGoForward().then(function(result) {
     is(seenCanGoForwardResult, false, "onsuccess handler shouldn't be called twice.");
     seenCanGoForwardResult = true;
-    is(e.target.result, canGoForward);
+    is(result, canGoForward);
     maybeRunNextTest();
-  };
+  });
 
   function maybeRunNextTest() {
     if (seenCanGoBackResult && seenCanGoForwardResult) {
       nextTest();
     }
   }
 }
 
deleted file mode 100644
--- a/dom/browser-element/mochitest/browserElement_BadScreenshot.js
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Any copyright is dedicated to the public domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Bug 800170 - Test that we get errors when we pass bad arguments to
-// mozbrowser's getScreenshot.
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-
-var iframe;
-var numPendingTests = 0;
-
-// Call iframe.getScreenshot with the given args.  If expectSuccess is true, we
-// expect the screenshot's onsuccess handler to fire.  Otherwise, we expect
-// getScreenshot() to throw an exception.
-function checkScreenshotResult(expectSuccess, args) {
-  var req;
-  try {
-    req = iframe.getScreenshot.apply(iframe, args);
-  }
-  catch(e) {
-    ok(!expectSuccess, "getScreenshot(" + JSON.stringify(args) + ") threw an exception.");
-    return;
-  }
-
-  numPendingTests++;
-  req.onsuccess = function() {
-    ok(expectSuccess, "getScreenshot(" + JSON.stringify(args) + ") succeeded.");
-    numPendingTests--;
-    if (numPendingTests == 0) {
-      SimpleTest.finish();
-    }
-  };
-
-  // We never expect to see onerror.
-  req.onerror = function() {
-    ok(false, "getScreenshot(" + JSON.stringify(args) + ") ran onerror.");
-    numPendingTests--;
-    if (numPendingTests == 0) {
-      SimpleTest.finish();
-    }
-  };
-}
-
-function runTest() {
-  iframe = document.createElement('iframe');
-  iframe.setAttribute('mozbrowser', 'true');
-  document.body.appendChild(iframe);
-  iframe.src = 'data:text/html,<html>' +
-    '<body style="background:green">hello</body></html>';
-
-  iframe.addEventListener('mozbrowserfirstpaint', function() {
-    // This one should succeed.
-    checkScreenshotResult(true, [100, 100]);
-
-    // These should fail.
-    checkScreenshotResult(false, []);
-    checkScreenshotResult(false, [100]);
-    checkScreenshotResult(false, ['a', 100]);
-    checkScreenshotResult(false, [100, 'a']);
-    checkScreenshotResult(false, [-1, 100]);
-    checkScreenshotResult(false, [100, -1]);
-
-    if (numPendingTests == 0) {
-      SimpleTest.finish();
-    }
-  });
-}
-
-addEventListener('testready', runTest);
deleted file mode 100644
--- a/dom/browser-element/mochitest/browserElement_DOMRequestError.js
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Any copyright is dedicated to the public domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Test if DOMRequest returned by an iframe gets an error callback when
-// the iframe is not in the DOM.
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-
-function runTest() {
-  var iframe1 = document.createElement('iframe');
-  iframe1.setAttribute('mozbrowser', 'true');
-  iframe1.src = 'data:text/html,<html>' +
-    '<body style="background:green">hello</body></html>';
-  document.body.appendChild(iframe1);
-
-  function testIframe(beforeRun, isErrorExpected, nextTest) {
-    return function() {
-      var error = false;
-      if (beforeRun)
-        beforeRun();
-      function testEnd() {
-        is(isErrorExpected, error);
-        SimpleTest.executeSoon(nextTest);
-      }
-
-      var domRequest = iframe1.getScreenshot(1000, 1000);
-      domRequest.onsuccess = function(e) {
-        testEnd();
-      }
-      domRequest.onerror = function(e) {
-        error = true;
-        testEnd();
-      }
-    };
-  }
-
-  function iframeLoadedHandler() {
-    iframe1.removeEventListener('mozbrowserloadend', iframeLoadedHandler);
-    // Test 1: iframe is in the DOM.
-    // Test 2: iframe is removed from the DOM.
-    // Test 3: iframe is added back into the DOM.
-    var test3 = testIframe(
-      function() {
-        document.body.appendChild(iframe1);
-      }, false,
-      function() {
-        SimpleTest.finish();
-      })
-    ;
-    var test2 = testIframe(function() {
-      document.body.removeChild(iframe1);
-    }, true, test3);
-    var test1 = testIframe(null, false, test2);
-    SimpleTest.executeSoon(test1);
-  }
-
-  iframe1.addEventListener('mozbrowserloadend', iframeLoadedHandler);
-}
-
-addEventListener('testready', runTest);
deleted file mode 100644
--- a/dom/browser-element/mochitest/browserElement_Download.js
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Any copyright is dedicated to the public domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Bug 983747 - Test 'download' method on iframe.
-
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-browserElementTestHelpers.addPermission();
-
-var iframe;
-var downloadURL = 'http://test/tests/dom/browser-element/mochitest/file_download_bin.sjs';
-
-function runTest() {
-  iframe = document.createElement('iframe');
-  iframe.setAttribute('mozbrowser', 'true');
-
-  iframe.addEventListener('mozbrowserloadend', loadend);
-  iframe.src = 'data:text/html,<html><body>hello</body></html>';
-  iframe.setAttribute('remote', 'true');
-
-  document.body.appendChild(iframe);
-}
-
-function loadend() {
-  var req = iframe.download(downloadURL, { filename: 'test.bin' });
-  req.onsuccess = function() {
-    ok(true, 'Download finished as expected.');
-    SimpleTest.finish();
-  }
-  req.onerror = function() {
-    ok(false, 'Expected no error, got ' + req.error);
-  }
-}
-
-addEventListener('testready', runTest);
deleted file mode 100644
--- a/dom/browser-element/mochitest/browserElement_ExecuteScript.js
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Any copyright is dedicated to the public domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Bug 1174733 - Browser API: iframe.executeScript
-
-'use strict';
-
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-
-function runTest() {
-
-  const origin = 'http://example.org';
-  const url = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_ExecuteScript.html';
-
-  // Test if all key=>value pairs in o1 are present in o2.
-  const c = (o1, o2) => Object.keys(o1).every(k => o1[k] == o2[k]);
-
-  let scriptId = 0;
-
-  const bail = () => {
-    ok(false, `scriptId: ${scriptId++}`);
-  }
-
-  SpecialPowers.pushPermissions([
-    {type: 'browser', allow: 1, context: document},
-    {type: 'browser:universalxss', allow: 1, context: document}
-  ], function() {
-    let iframe = document.createElement('iframe');
-    iframe.setAttribute('mozbrowser', 'true');
-    iframe.addEventListener('mozbrowserloadend', function() {
-      onReady(iframe);
-    }, {once: true});
-    iframe.src = url;
-    document.body.appendChild(iframe);
-  });
-
-
-  function onReady(iframe) {
-    iframe.executeScript('4 + 4', {url}).then(rv => {
-      is(rv, 8, `scriptId: ${scriptId++}`);
-      return iframe.executeScript('(() => {return {a:42}})()', {url})
-    }, bail).then(rv => {
-      ok(c(rv, {a:42}), `scriptId: ${scriptId++}`);
-      return iframe.executeScript('(() => {return {a:42}})()', {origin})
-    }, bail).then(rv => {
-      ok(c(rv, {a:42}), `scriptId: ${scriptId++}`);
-      return iframe.executeScript('(() => {return {a:42}})()', {origin, url})
-    }, bail).then(rv => {
-      ok(c(rv, {a:42}), `scriptId: ${scriptId++}`);
-      return iframe.executeScript(`
-          new Promise((resolve, reject) => {
-            resolve(document.body.textContent.trim());
-          });
-      `, {url})
-    }, bail).then(rv => {
-      is(rv, 'foo', `scriptId: ${scriptId++}`);
-      return iframe.executeScript(`
-          new Promise((resolve, reject) => {
-            resolve({a:43,b:34});
-          });
-      `, {url})
-    }, bail).then(rv => {
-      ok(c(rv, {a:43,b:34}), `scriptId: ${scriptId++}`);
-      return iframe.executeScript(`
-        … syntax error
-      `, {url});
-    }, bail).then(bail, (error) => {
-      is(error.message, 'SyntaxError: illegal character', `scriptId: ${scriptId++}`);
-      return iframe.executeScript(`
-        window
-      `, {url});
-    }).then(bail, (error) => {
-      is(error.message, 'Script last expression must be a promise or a JSON object', `scriptId: ${scriptId++}`);
-      return iframe.executeScript(`
-          new Promise((resolve, reject) => {
-            reject('BOOM');
-          });
-      `, {url});
-    }).then(bail, (error) => {
-      is(error.message, 'BOOM', `scriptId: ${scriptId++}`);
-      return iframe.executeScript(`
-          new Promise((resolve, reject) => {
-            resolve(window);
-          });
-      `, {url});
-    }).then(bail, (error) => {
-      is(error.message, 'Value returned (resolve) by promise is not a valid JSON object', `scriptId: ${scriptId++}`);
-      return iframe.executeScript('window.btoa("a")', {url})
-    }, bail).then(rv => {
-      ok(c(rv, 'YQ=='), `scriptId: ${scriptId++}`);
-      return iframe.executeScript('window.wrappedJSObject.btoa("a")', {url})
-    }, bail).then(bail, (error) => {
-      is(error.message, `TypeError: window.wrappedJSObject is undefined; can't access its "btoa" property`, `scriptId: ${scriptId++}`);
-      return iframe.executeScript('42', {})
-    }).then(bail, error => {
-      is(error.name, 'InvalidAccessError', `scriptId: ${scriptId++}`);
-      return iframe.executeScript('42');
-    }).then(bail, error => {
-      is(error.name, 'InvalidAccessError', `scriptId: ${scriptId++}`);
-      return iframe.executeScript('43', { url: 'http://foo.com' });
-    }).then(bail, (error) => {
-      is(error.message, 'URL mismatches', `scriptId: ${scriptId++}`);
-      return iframe.executeScript('43', { url: '_' });
-    }, bail).then(bail, (error) => {
-      is(error.message, 'Malformed URL', `scriptId: ${scriptId++}`);
-      return iframe.executeScript('43', { origin: 'http://foo.com' });
-    }, bail).then(bail, (error) => {
-      is(error.message, 'Origin mismatches', `scriptId: ${scriptId++}`);
-      return iframe.executeScript('43', { origin: 'https://example.org' });
-    }, bail).then(bail, (error) => {
-      is(error.message, 'Origin mismatches', `scriptId: ${scriptId++}`);
-      SimpleTest.finish();
-    });
-  }
-}
-
-addEventListener('testready', runTest);
deleted file mode 100644
--- a/dom/browser-element/mochitest/browserElement_Find.js
+++ /dev/null
@@ -1,148 +0,0 @@
-/* Any copyright is dedicated to the public domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Bug 1163961 - Test search API
-
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-
-function runTest() {
-
-  let iframe = document.createElement('iframe');
-  iframe.setAttribute('mozbrowser', 'true');
-  iframe.src = 'data:text/html,foo bar foo XXX Foo BAR foobar foobar';
-
-  const once = (eventName) => {
-    return new Promise((resolve) => {
-      iframe.addEventListener(eventName, function(...args) {
-        resolve(...args);
-      }, {once: true});
-    });
-  }
-
-  // Test if all key=>value pairs in o1 are present in o2.
-  const c = (o1, o2, i) => {
-    for (let k of Object.keys(o1)) {
-      is(o1[k], o2[k], `Test ${i} should match for key ${k}`);
-    }
-  }
-
-  let testCount = 0;
-
-  once('mozbrowserloadend').then(() => {
-    iframe.findAll('foo', 'case-insensitive');
-    return once('mozbrowserfindchange');
-  }).then(({detail}) => {
-    c(detail, {
-      msg_name: "findchange",
-      active: true,
-      searchString: 'foo',
-      searchLimit: 1000,
-      activeMatchOrdinal: 1,
-      numberOfMatches: 5,
-    }, testCount++);
-    iframe.findNext('forward');
-    return once('mozbrowserfindchange');
-  }).then(({detail}) => {
-    c(detail, {
-      msg_name: "findchange",
-      active: true,
-      searchString: 'foo',
-      searchLimit: 1000,
-      activeMatchOrdinal: 2,
-      numberOfMatches: 5,
-    }, testCount++);
-    iframe.findNext('backward');
-    return once('mozbrowserfindchange');
-  }).then(({detail}) => {
-    c(detail, {
-      msg_name: "findchange",
-      active: true,
-      searchString: 'foo',
-      searchLimit: 1000,
-      activeMatchOrdinal: 1,
-      numberOfMatches: 5,
-    }, testCount++);
-    iframe.findAll('xxx', 'case-sensitive');
-    return once('mozbrowserfindchange');
-  }).then(({detail}) => {
-    c(detail, {
-      msg_name: "findchange",
-      active: true,
-      searchString: 'xxx',
-      searchLimit: 1000,
-      activeMatchOrdinal: 0,
-      numberOfMatches: 0,
-    }, testCount++);
-    iframe.findAll('bar', 'case-insensitive');
-    return once('mozbrowserfindchange');
-  }).then(({detail}) => {
-    c(detail, {
-      msg_name: "findchange",
-      active: true,
-      searchString: 'bar',
-      searchLimit: 1000,
-      activeMatchOrdinal: 1,
-      numberOfMatches: 4,
-    }, testCount++);
-    iframe.findNext('forward');
-    return once('mozbrowserfindchange');
-  }).then(({detail}) => {
-    c(detail, {
-      msg_name: "findchange",
-      active: true,
-      searchString: 'bar',
-      searchLimit: 1000,
-      activeMatchOrdinal: 2,
-      numberOfMatches: 4,
-    }, testCount++);
-    iframe.findNext('forward');
-    return once('mozbrowserfindchange');
-  }).then(({detail}) => {
-    c(detail, {
-      msg_name: "findchange",
-      active: true,
-      searchString: 'bar',
-      searchLimit: 1000,
-      activeMatchOrdinal: 3,
-      numberOfMatches: 4,
-    }, testCount++);
-    iframe.findNext('forward');
-    return once('mozbrowserfindchange');
-  }).then(({detail}) => {
-    c(detail, {
-      msg_name: "findchange",
-      active: true,
-      searchString: 'bar',
-      searchLimit: 1000,
-      activeMatchOrdinal: 4,
-      numberOfMatches: 4,
-    }, testCount++);
-    iframe.findNext('forward');
-    return once('mozbrowserfindchange');
-  }).then(({detail}) => {
-    c(detail, {
-      msg_name: "findchange",
-      active: true,
-      searchString: 'bar',
-      searchLimit: 1000,
-      activeMatchOrdinal: 1,
-      numberOfMatches: 4,
-    }, testCount++);
-    iframe.clearMatch();
-    return once('mozbrowserfindchange');
-  }).then(({detail}) => {
-    c(detail, {
-      msg_name: "findchange",
-      active: false
-    }, testCount++);
-    SimpleTest.finish();
-  });
-
-  document.body.appendChild(iframe);
-
-}
-
-addEventListener('testready', runTest);
deleted file mode 100644
--- a/dom/browser-element/mochitest/browserElement_GetContentDimensions.js
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Any copyright is dedicated to the public domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Bug 757859 - Test the getContentDimensions functionality of mozbrowser
-
-"use strict";
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-
-var resizeContent = function() {
-  var innerBox = content.document.getElementById('abox');
-  innerBox.style.width = '800px';
-  innerBox.style.height = '800px';
-}
-
-function runTest() {
-
-  var iframe1 = document.createElement('iframe');
-  iframe1.setAttribute('mozbrowser', 'true');
-
-  var iframeWidth = 400;
-  var iframeHeight = 400;
-  var numIframeLoaded = 0;
-  var numResizeEvents = 0;
-  var mm;
-
-  iframe1.src = 'data:text/html,<html><body><div id=\'abox\' ' +
-    'style=\'background:blue;width:200px;height:200px\'>test</div></body></html>';
-  iframe1.style.width = iframeWidth + 'px';
-  iframe1.style.height = iframeHeight + 'px';
-  document.body.appendChild(iframe1);
-
-  function iframeScrollAreaChanged(e) {
-    numResizeEvents++;
-    if (numResizeEvents === 1) {
-      ok(true, 'Resize event when changing content size');
-      ok(e.detail.width > iframeWidth, 'Iframes content is larger than iframe');
-      ok(e.detail.height > iframeHeight, 'Iframes content is larger than iframe');
-      iframe1.src = 'data:text/html,<html><body><div id=\'abox\' ' +
-        'style=\'background:blue;width:200px;height:200px\'>test</div></body></html>';
-    } else if (numResizeEvents === 2) {
-      ok(true, 'Resize event when changing src');
-      iframe1.removeEventListener('mozbrowserresize', iframeScrollAreaChanged);
-      SimpleTest.finish();
-    }
-  }
-
-  function iframeLoadedHandler() {
-    iframe1.removeEventListener('mozbrowserloadend', iframeLoadedHandler);
-    mm = SpecialPowers.getBrowserFrameMessageManager(iframe1);
-    iframe1.getContentDimensions().onsuccess = function(e) {
-      ok(typeof e.target.result.width === 'number', 'Received width');
-      ok(typeof e.target.result.height === 'number', 'Received height');
-      ok(e.target.result.height <= iframeHeight, 'Iframes content is smaller than iframe');
-      ok(e.target.result.width <= iframeWidth, 'Iframes content is smaller than iframe');
-      iframe1.addEventListener('mozbrowserscrollareachanged', iframeScrollAreaChanged);
-      mm.loadFrameScript('data:,(' + resizeContent.toString() + ')();', false);
-    }
-  }
-
-  iframe1.addEventListener('mozbrowserloadend', iframeLoadedHandler);
-}
-
-addEventListener('load', function() {
-  SimpleTest.executeSoon(runTest);
-});
deleted file mode 100644
--- a/dom/browser-element/mochitest/browserElement_GetScreenshot.js
+++ /dev/null
@@ -1,117 +0,0 @@
-/* Any copyright is dedicated to the public domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Test the getScreenshot property for mozbrowser
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-
-function runTest() {
-  var iframe1 = document.createElement('iframe');
-  iframe1.setAttribute('mozbrowser', 'true');
-
-  iframe1.src = 'data:text/html,<html>' +
-    '<body style="background:green">hello</body></html>';
-  document.body.appendChild(iframe1);
-
-  var screenshotImageDatas = [];
-
-  function screenshotTaken(aScreenshotImageData) {
-    screenshotImageDatas.push(aScreenshotImageData);
-
-    if (screenshotImageDatas.length === 1) {
-      ok(true, 'Got initial non blank screenshot');
-
-      var view = aScreenshotImageData.data;
-      if (view[3] !== 255) {
-        ok(false, 'The first pixel of initial screenshot is not opaque');
-        SimpleTest.finish();
-        return;
-      }
-      ok(true, 'Verified the first pixel of initial screenshot is opaque');
-
-      iframe1.src = 'data:text/html,<html>' +
-        '<body style="background:transparent">hello</body></html>';
-
-      iframe1.addEventListener('mozbrowserloadend', ()=>takeScreenshot('image/png'));
-
-    }
-    else if (screenshotImageDatas.length === 2) {
-      ok(true, 'Got updated screenshot after source page changed');
-
-      var view = aScreenshotImageData.data;
-      if (view[3] !== 0) {
-        // The case here will always fail when oop'd on Firefox Desktop,
-        // but not on B2G Emulator
-        // See https://bugzil.la/878003#c20
-
-        var isB2G = (navigator.platform === '');
-        info('navigator.platform: ' + navigator.platform);
-        if (!isB2G && browserElementTestHelpers.getOOPByDefaultPref()) {
-          todo(false, 'The first pixel of updated screenshot is not transparent');
-        } else {
-          ok(false, 'The first pixel of updated screenshot is not transparent');
-        }
-        SimpleTest.finish();
-        return;
-      }
-
-      ok(true, 'Verified the first pixel of updated screenshot is transparent');
-      SimpleTest.finish();
-    }
-  }
-
-  // We continually take screenshots until we get one that we are
-  // happy with.
-  function takeScreenshot(mimeType) {
-    function gotImage(e) {
-      // |this| is the Image.
-
-      URL.revokeObjectURL(this.src);
-
-      if (e.type === 'error' || !this.width || !this.height) {
-        ok(false, "load image error");
-        SimpleTest.finish();
-        return;
-      }
-
-      var canvas = document.createElement('canvas');
-      canvas.width = canvas.height = 1000;
-      var ctx = canvas.getContext('2d');
-      ctx.drawImage(this, 0, 0);
-      var imageData = ctx.getImageData(0, 0, 1000, 1000);
-
-      screenshotTaken(imageData);
-    }
-
-    function getScreenshotImageData(e) {
-      var blob = e.target.result;
-      if (blob.type !== mimeType) {
-        ok(false, 'MIME type of screenshot taken incorrect');
-        SimpleTest.finish();
-      }
-
-      if (blob.size === 0) {
-        ok(false, "get screenshot image error");
-        SimpleTest.finish();
-      }
-
-      var img = new Image();
-      img.src = URL.createObjectURL(blob);
-      img.onload = img.onerror = gotImage;
-    }
-
-    iframe1.getScreenshot(1000, 1000, mimeType).onsuccess =
-      getScreenshotImageData;
-  }
-
-  function iframeLoadedHandler(e) {
-    iframe1.removeEventListener('mozbrowserloadend', iframeLoadedHandler);
-    takeScreenshot('image/jpeg');
-  }
-
-  iframe1.addEventListener('mozbrowserloadend', iframeLoadedHandler);
-}
-
-addEventListener('testready', runTest);
deleted file mode 100644
--- a/dom/browser-element/mochitest/browserElement_GetScreenshotDppx.js
+++ /dev/null
@@ -1,107 +0,0 @@
-/* Any copyright is dedicated to the public domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Test the getScreenshot property for mozbrowser
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-
-function runTest() {
-  var dppxPref = 'layout.css.devPixelsPerPx';
-  var cssPixelWidth = 600;
-  var cssPixelHeight = 400;
-
-  var iframe1 = document.createElement('iframe');
-  iframe1.setAttribute('width', cssPixelWidth);
-  iframe1.setAttribute('height', cssPixelHeight);
-  iframe1.setAttribute('mozbrowser', 'true');
-
-  iframe1.src = 'data:text/html,<html><body>hello</body></html>';
-  document.body.appendChild(iframe1);
-
-  var images = [];
-
-  function screenshotTaken(image) {
-    images.push(image);
-    if (images.length === 1) {
-      ok(true, 'Got initial non blank screenshot');
-
-      if (image.width !== cssPixelWidth || image.height !== cssPixelHeight) {
-        ok(false, 'The pixel width of the image received is not correct');
-        SimpleTest.finish();
-        return;
-      }
-      ok(true, 'The pixel width of the image received is correct');
-
-      SpecialPowers.pushPrefEnv(
-        {'set': [['layout.css.devPixelsPerPx', 2]]}, takeScreenshot);
-    }
-    else if (images.length === 2) {
-      ok(true, 'Got updated screenshot after source page changed');
-
-      if (image.width !== cssPixelWidth * 2 ||
-          image.height !== cssPixelHeight * 2) {
-        ok(false, 'The pixel width of the 2dppx image received is not correct');
-        SimpleTest.finish();
-        return;
-      }
-      ok(true, 'The pixel width of the 2dppx image received is correct');
-      SimpleTest.finish();
-    }
-  }
-
-  function takeScreenshot() {
-    function gotImage(e) {
-      // |this| is the Image.
-
-      URL.revokeObjectURL(this.src);
-
-      if (e.type === 'error' || !this.width || !this.height) {
-        tryAgain();
-
-        return;
-      }
-
-      screenshotTaken(this);
-    }
-
-    function tryAgain() {
-      if (--attempts === 0) {
-        ok(false, 'Timed out waiting for correct screenshot');
-        SimpleTest.finish();
-      } else {
-        setTimeout(function() {
-          iframe1.getScreenshot(cssPixelWidth, cssPixelHeight).onsuccess =
-            getScreenshotImageData;
-        }, 200);
-      }
-    }
-
-    function getScreenshotImageData(e) {
-      var blob = e.target.result;
-      if (blob.size === 0) {
-        tryAgain();
-
-        return;
-      }
-
-      var img = new Image();
-      img.src = URL.createObjectURL(blob);
-      img.onload = img.onerror = gotImage;
-    }
-
-    var attempts = 10;
-    iframe1.getScreenshot(cssPixelWidth, cssPixelHeight).onsuccess =
-      getScreenshotImageData;
-  }
-
-  function iframeLoadedHandler() {
-    SpecialPowers.pushPrefEnv(
-      {'set': [['layout.css.devPixelsPerPx', 1]]}, takeScreenshot);
-  }
-
-  iframe1.addEventListener('mozbrowserloadend', iframeLoadedHandler);
-}
-
-addEventListener('testready', runTest);
deleted file mode 100644
--- a/dom/browser-element/mochitest/browserElement_Manifestchange.js
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Any copyright is dedicated to the public domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Test that the onmozbrowsermanifestchange event works.
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-browserElementTestHelpers.addPermission();
-browserElementTestHelpers.allowTopLevelDataURINavigation();
-
-function createHtml(manifest) {
-  return 'data:text/html,<html xmlns:xml="http://www.w3.org/XML/1998/namespace"><head>' + manifest + '<body></body></html>';
-}
-
-function createManifest(href) {
-  return '<link rel="manifest" href="' + href + '">';
-}
-
-function runTest() {
-  var iframe1 = document.createElement('iframe');
-  iframe1.setAttribute('mozbrowser', 'true');
-  document.body.appendChild(iframe1);
-
-  // iframe2 is a red herring; we modify its manifest link elements but don't
-  // listen for manifestchanges; we want to make sure that its manifestchange
-  // events aren't picked up by the listener on iframe1.
-  var iframe2 = document.createElement('iframe');
-  iframe2.setAttribute('mozbrowser', 'true');
-  document.body.appendChild(iframe2);
-
-  // iframe3 is another red herring.  It's not a mozbrowser, so we shouldn't
-  // get any manifestchange events on it.
-  var iframe3 = document.createElement('iframe');
-  document.body.appendChild(iframe3);
-
-  var numManifestChanges = 0;
-
-  iframe1.addEventListener('mozbrowsermanifestchange', function(e) {
-
-    numManifestChanges++;
-
-    if (numManifestChanges == 1) {
-      is(e.detail.href, 'manifest.1', 'manifest.1 matches');
-
-      // We should receive manifestchange events when the user creates new
-      // manifests
-      SpecialPowers.getBrowserFrameMessageManager(iframe1)
-                   .loadFrameScript("data:,content.document.title='New title';",
-                                    /* allowDelayedLoad = */ false);
-
-      SpecialPowers.getBrowserFrameMessageManager(iframe1)
-                   .loadFrameScript("data:,content.document.head.insertAdjacentHTML('beforeend', '<link rel=manifest href=manifest.2>')",
-                                    /* allowDelayedLoad = */ false);
-
-      SpecialPowers.getBrowserFrameMessageManager(iframe2)
-                   .loadFrameScript("data:,content.document.head.insertAdjacentHTML('beforeend', '<link rel=manifest href=manifest.2>')",
-                                    /* allowDelayedLoad = */ false);
-    }
-    else if (numManifestChanges == 2) {
-      is(e.detail.href, 'manifest.2', 'manifest.2 matches');
-
-      // Full new pages should trigger manifestchange events
-      iframe1.src = createHtml(createManifest('manifest.3'));
-    }
-    else if (numManifestChanges == 3) {
-      is(e.detail.href, 'manifest.3', 'manifest.3 matches');
-
-      // Test setting a page with multiple manifest link elements
-      iframe1.src = createHtml(createManifest('manifest.4a') + createManifest('manifest.4b'));
-    }
-    else if (numManifestChanges == 4) {
-      is(e.detail.href, 'manifest.4a', 'manifest.4a matches');
-      // 2 events will be triggered by previous test, wait for next
-    }
-    else if (numManifestChanges == 5) {
-      is(e.detail.href, 'manifest.4b', 'manifest.4b matches');
-      SimpleTest.finish();
-    } else {
-      ok(false, 'Too many manifestchange events.');
-    }
-  });
-
-  iframe3.addEventListener('mozbrowsermanifestchange', function(e) {
-    ok(false, 'Should not get a manifestchange event for iframe3.');
-  });
-
-
-  iframe1.src = createHtml(createManifest('manifest.1'));
-  // We should not receive manifest change events for either of the below iframes
-  iframe2.src = createHtml(createManifest('manifest.1'));
-  iframe3.src = createHtml(createManifest('manifest.1'));
-
-}
-
-addEventListener('testready', runTest);
-
deleted file mode 100644
--- a/dom/browser-element/mochitest/browserElement_NextPaint.js
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Any copyright is dedicated to the public domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Bug 808231 - Add mozbrowsernextpaint event.
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-
-function runTest() {
-  var iframe = document.createElement('iframe');
-  iframe.setAttribute('mozbrowser', 'true');
-  document.body.appendChild(iframe);
-
-  // Add a first listener that we'll remove shortly after.
-  iframe.addNextPaintListener(wrongListener);
-
-  var gotFirstNextPaintEvent = false;
-  iframe.addNextPaintListener(function () {
-    ok(!gotFirstNextPaintEvent, 'got the first nextpaint event');
-
-    // Make sure we're only called once.
-    gotFirstNextPaintEvent = true;
-
-    iframe.addNextPaintListener(function () {
-      info('got the second nextpaint event');
-      SimpleTest.finish();
-    });
-
-    // Force the iframe to repaint.
-    SimpleTest.executeSoon(() => iframe.src += '#next');
-  });
-
-  // Remove the first listener to make sure it's not called.
-  iframe.removeNextPaintListener(wrongListener);
-  iframe.src = 'file_browserElement_NextPaint.html';
-}
-
-function wrongListener() {
-  ok(false, 'first listener should have been removed');
-}
-
-addEventListener('testready', runTest);
deleted file mode 100644
--- a/dom/browser-element/mochitest/browserElement_OpenMixedProcess.js
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Any copyright is dedicated to the public domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Bug 776129 - If a window w calls window.open, the resultant window should be
-// remote iff w is remote.
-//
-// <iframe mozbrowser> can be default-OOP or default-in-process.  But we can
-// override this default by setting remote=true or remote=false on the iframe.
-//
-// This bug arises when we are default-in-process and a OOP iframe calls
-// window.open, or when we're default-OOP and an in-process iframe calls
-// window.open.  In either case, if the opened iframe gets the default
-// remotness, it will not match its opener's remoteness, which is bad.
-//
-// Since the name of the test determines the OOP-by-default pref, the "inproc"
-// version of this test opens an OOP frame, and the "oop" version opens an
-// in-process frame.  Enjoy.  :)
-
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-
-function runTest() {
-  // We're going to open a remote frame if OOP off by default.  If OOP is on by
-  // default, we're going to open an in-process frame.
-  var remote = !browserElementTestHelpers.getOOPByDefaultPref();
-
-  var iframe = document.createElement('iframe');
-  iframe.setAttribute('mozbrowser', 'true');
-  iframe.setAttribute('remote', remote);
-
-  // The page we load does window.open, then checks some things and reports
-  // back using alert().  Finally, it calls alert('finish').
-  //
-  // Bug 776129 in particular manifests itself such that the popup frame loads
-  // and the tests in file_browserElement_OpenMixedProcess pass, but the
-  // content of the frame is invisible.  To catch this case, we take a
-  // screenshot after we load the content into the popup, and ensure that it's
-  // not blank.
-  var popup;
-  iframe.addEventListener('mozbrowseropenwindow', function(e) {
-    popup = document.body.appendChild(e.detail.frameElement);
-  });
-
-  iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
-    if (e.detail.message.startsWith('pass')) {
-      ok(true, e.detail.message);
-    }
-    else if (e.detail.message.startsWith('fail')) {
-      ok(false, e.detail.message);
-    }
-    else if (e.detail.message == 'finish') {
-      // We assume here that iframe is completely blank, and spin until popup's
-      // screenshot is not the same as iframe.
-      iframe.getScreenshot(1000, 1000).onsuccess = function(e) {
-        var fr = new FileReader();
-        fr.onloadend = function() { test2(popup, fr.result); };
-        fr.readAsArrayBuffer(e.target.result);
-      };
-    }
-    else {
-      ok(false, e.detail.message, "Unexpected message!");
-    }
-  });
-
-  document.body.appendChild(iframe);
-  iframe.src = 'file_browserElement_OpenMixedProcess.html';
-}
-
-function arrayBuffersEqual(a, b) {
-  var x = new Int8Array(a);
-  var y = new Int8Array(b);
-  if (x.length != y.length) {
-    return false;
-  }
-
-  for (var i = 0; i < x.length; i++) {
-    if (x[i] != y[i]) {
-      return false;
-    }
-  }
-
-  return true;
-}
-
-function test2(popup, blankScreenshotArrayBuffer) {
-  // Take screenshots of popup until it doesn't equal blankScreenshot (or we
-  // time out).
-  popup.getScreenshot(1000, 1000).onsuccess = function(e) {
-    var fr = new FileReader();
-    fr.onloadend = function() {
-      if (!arrayBuffersEqual(blankScreenshotArrayBuffer, fr.result)) {
-        ok(true, "Finally got a non-blank screenshot.");
-        SimpleTest.finish();
-        return;
-      }
-
-      SimpleTest.executeSoon(function() { test2(popup, blankScreenshot) });
-    };
-    fr.readAsArrayBuffer(e.target.result);
-  };
-}
-
-addEventListener('testready', runTest);
deleted file mode 100644
--- a/dom/browser-element/mochitest/browserElement_PurgeHistory.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/* Any copyright is dedicated to the public domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Bug 807056 - [Browser] Clear History doesn't clear back/forward history in open tabs
-// <iframe mozbrowser>.
-
-"use strict";
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-
-var iframe;
-function addOneShotIframeEventListener(event, fn) {
-  function wrapper(e) {
-    iframe.removeEventListener(event, wrapper);
-    fn(e);
-  };
-
-  iframe.addEventListener(event, wrapper);
-}
-
-function runTest() {
-  iframe = document.createElement('iframe');
-  iframe.setAttribute('mozbrowser', 'true');
-  // FIXME: Bug 1270790
-  iframe.setAttribute('remote', 'true');
-
-  addOneShotIframeEventListener('mozbrowserloadend', function() {
-    SimpleTest.executeSoon(test2);
-  });
-
-  iframe.src = browserElementTestHelpers.emptyPage1;
-  document.body.appendChild(iframe);
-}
-
-function purgeHistory(nextTest) {
-  var seenCanGoBackResult = false;
-  var seenCanGoForwardResult = false;
-
-  iframe.purgeHistory().onsuccess = function(e) {
-    ok(true, "The history has been purged");
-
-    iframe.getCanGoBack().onsuccess = function(e) {
-      is(e.target.result, false, "Iframe cannot go back");
-      seenCanGoBackResult = true;
-      maybeRunNextTest();
-    };
-
-    iframe.getCanGoForward().onsuccess = function(e) {
-      is(e.target.result, false, "Iframe cannot go forward");
-      seenCanGoForwardResult = true;
-      maybeRunNextTest();
-    };
-  };
-
-  function maybeRunNextTest() {
-    if (seenCanGoBackResult && seenCanGoForwardResult) {
-      nextTest();
-    }
-  }
-}
-
-function test2() {
-  purgeHistory(test3);
-}
-
-function test3() {
-  addOneShotIframeEventListener('mozbrowserloadend', function() {
-    purgeHistory(test4);
-  });
-
-  SimpleTest.executeSoon(function() {
-    iframe.src = browserElementTestHelpers.emptyPage2;
-  });
-}
-
-function test4() {
-  addOneShotIframeEventListener('mozbrowserlocationchange', function(e) {
-    is(e.detail.url, browserElementTestHelpers.emptyPage3);
-    purgeHistory(SimpleTest.finish);
-  });
-
-  SimpleTest.executeSoon(function() {
-    iframe.src = browserElementTestHelpers.emptyPage3;
-  });
-}
-
-addEventListener('testready', runTest);
--- a/dom/browser-element/mochitest/browserElement_SendEvent.js
+++ b/dom/browser-element/mochitest/browserElement_SendEvent.js
@@ -46,37 +46,16 @@ function runTest() {
         ok(true, "Receive a mousemove event.");
         iframe.sendMouseEvent("mouseup", x, y, 0, 1, 0);
         break;
       case "#mouseup":
         ok(true, "Receive a mouseup event.");
         break;
       case "#click":
         ok(true, "Receive a click event.");
-        if (SpecialPowers.getIntPref("dom.w3c_touch_events.enabled") != 0) {
-          iframe.sendTouchEvent("touchstart", [1], [x], [y], [2], [2],
-                                [20], [0.5], 1, 0);
-        } else {
-          iframe.removeEventListener('mozbrowserlocationchange', onlocchange);
-          SimpleTest.finish();
-        }
-        break;
-      case "#touchstart":
-        ok(true, "Receive a touchstart event.");
-        iframe.sendTouchEvent("touchmove", [1], [x], [y], [2], [2],
-                              [20], [0.5], 1, 0);
-      case "#touchmove":
-        ok(true, "Receive a touchmove event.");
-        iframe.sendTouchEvent("touchend", [1], [x], [y], [2], [2],
-                              [20], [0.5], 1, 0);
-        break;
-      case "#touchend":
-        ok(true, "Receive a touchend event.");
-        iframe.sendTouchEvent("touchcancel", [1], [x], [y], [2], [2],
-                              [20], [0.5], 1, 0);
         iframe.removeEventListener('mozbrowserlocationchange', onlocchange);
         SimpleTest.finish();
         break;
     }
   });
 
   iframe.src = "file_browserElement_SendEvent.html";
 
deleted file mode 100644
--- a/dom/browser-element/mochitest/browserElement_getWebManifest.js
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Any copyright is dedicated to the public domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-/*globals async, ok, is, SimpleTest, browserElementTestHelpers*/
-
-// Bug 1169633 - getWebManifest tests
-'use strict';
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-
-// request to load a manifest from a page that doesn't have a manifest.
-// The expected result to be null.
-var test1 = async(async function() {
-  var manifest = await requestManifest('file_empty.html');
-  is(manifest, null, 'it should be null.');
-});
-
-// request to load a manifest from a page that has a manifest.
-// The expected manifest to have a property name whose value is 'pass'.
-var test2 = async(async function() {
-  var manifest = await requestManifest('file_web_manifest.html');
-  is(manifest && manifest.name, 'pass', 'it should return a manifest with name pass.');
-});
-
-// Cause an exception by attempting to fetch a file URL,
-// expect onerror to be called.
-var test3 = async(async function() {
-  var gotError = false;
-  try {
-    await requestManifest('file_illegal_web_manifest.html');
-  } catch (err) {
-    gotError = true;
-  }
-  ok(gotError, 'onerror was called on the DOMRequest.');
-});
-
-// Run the tests
-addEventListener('testready', () => {
-  Promise
-    .all([test1(), test2(), test3()])
-    .then(SimpleTest.finish);
-});
-
-function requestManifest(url) {
-  var iframe = document.createElement('iframe');
-  iframe.setAttribute('mozbrowser', 'true');
-  iframe.src = url;
-  document.body.appendChild(iframe);
-  return new Promise((resolve, reject) => {
-    iframe.addEventListener('mozbrowserloadend', function() {
-      SimpleTest.executeSoon(() => {
-        var req = iframe.getWebManifest();
-        req.onsuccess = () => {
-          document.body.removeChild(iframe);
-          resolve(req.result);
-        };
-        req.onerror = () => {
-          document.body.removeChild(iframe);
-          reject(new Error(req.error));
-        };
-      });
-    }, {once: true});
-  });
-}
--- a/dom/browser-element/mochitest/chrome.ini
+++ b/dom/browser-element/mochitest/chrome.ini
@@ -1,50 +1,24 @@
 [DEFAULT]
 skip-if = e10s
 
 support-files =
   audio.ogg
   async.js
   browserElementTestHelpers.js
   browserElement_BackForward.js
-  browserElement_BadScreenshot.js
   browserElement_DocumentFirstPaint.js
-  browserElement_DOMRequestError.js
-  browserElement_ExecuteScript.js
-  browserElement_Find.js
-  browserElement_GetContentDimensions.js
-  browserElement_GetScreenshot.js
-  browserElement_GetScreenshotDppx.js
-  browserElement_getWebManifest.js
-  browserElement_NextPaint.js
-  browserElement_PurgeHistory.js
   browserElement_ReloadPostRequest.js
   browserElement_SendEvent.js
   browserElement_Stop.js
-  file_browserElement_ExecuteScript.html
-  file_browserElement_NextPaint.html
   file_browserElement_SendEvent.html
   file_bug709759.sjs
   file_empty.html
   file_post_request.html
-  file_web_manifest.html
-  file_web_manifest.json
-  file_illegal_web_manifest.html
 
 [test_browserElement_inproc_BackForward.html]
-[test_browserElement_inproc_BadScreenshot.html]
 [test_browserElement_inproc_DocumentFirstPaint.html]
-[test_browserElement_inproc_DOMRequestError.html]
-[test_browserElement_inproc_ExecuteScript.html]
-[test_browserElement_inproc_Find.html]
-disabled = Bug 1458393
-[test_browserElement_inproc_GetContentDimensions.html]
-[test_browserElement_inproc_GetScreenshot.html]
-[test_browserElement_inproc_GetScreenshotDppx.html]
-[test_browserElement_inproc_getWebManifest.html]
-[test_browserElement_inproc_NextPaint.html]
-[test_browserElement_inproc_PurgeHistory.html]
 [test_browserElement_inproc_ReloadPostRequest.html]
 disabled = no modal prompt on POST reload for chrome window
 [test_browserElement_inproc_SendEvent.html]
 [test_browserElement_inproc_Stop.html]
 skip-if = (os == "win" && !debug) #Bug 1345410
deleted file mode 100644
--- a/dom/browser-element/mochitest/file_browserElement_ExecuteScript.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
-<head>
-  <script>
-window.btoa = () => "fake btoa";
-  </script>
-</head>
-<body>foo</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/file_browserElement_NextPaint.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<html>
-<body>
-<script>
-addEventListener("hashchange", function () {
-  document.body.style.backgroundColor = "red";
-});
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/file_browserElement_OpenMixedProcess.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<html>
-<body>
-
-<!-- The test relies on the fact that this file is completely empty. -->
-
-<script>
-
-function ok(b, msg)
-{
-  alert((b ? 'pass:' : 'fail:') + msg);
-}
-
-var w = window.open("file_empty.html");
-w.addEventListener('load', function() {
-  ok(true, 'Got load.');
-  ok(w.document.getElementById('url'), 'Found element with id "url"');
-  alert('finish');
-});
-</script>
-
-</body>
-</html>
--- a/dom/browser-element/mochitest/file_browserElement_SendEvent.html
+++ b/dom/browser-element/mochitest/file_browserElement_SendEvent.html
@@ -1,15 +1,11 @@
 <html><body>
-<button>send[Mouse|Touch]Event</button>
+<button>sendMouseEvent</button>
 </body><script>
 function changeHash(e) {
   document.location.hash = e.type;
 };
 window.addEventListener('mousedown', changeHash);
 window.addEventListener('mousemove', changeHash);
 window.addEventListener('mouseup', changeHash);
 window.addEventListener('click', changeHash, true);
-window.addEventListener('touchstart', changeHash);
-window.addEventListener('touchmove', changeHash);
-window.addEventListener('touchend', changeHash);
-window.addEventListener('touchcancel', changeHash);
 </script></html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/file_download_bin.sjs
+++ /dev/null
@@ -1,4 +0,0 @@
-function handleRequest(request, response) {
-  response.setHeader("Content-Type", "application/octet-stream", false);
-  response.write("BIN");
-}
\ No newline at end of file
deleted file mode 100644
--- a/dom/browser-element/mochitest/file_illegal_web_manifest.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<!doctype html>
-<meta charset=utf-8>
-<head>
-<!-- FIXME: we should keep file:// here ... -->
-<link rel="manifest" href="sshfs://this_is_not_allowed!">
-</head>
-<h1>Support Page for Web Manifest Tests</h1>
deleted file mode 100644
--- a/dom/browser-element/mochitest/file_web_manifest.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!doctype html>
-<meta charset=utf-8>
-<head>
-<link rel="manifest" href="file_web_manifest.json">
-</head>
-<h1>Support Page for Web Manifest Tests</h1>
deleted file mode 100644
--- a/dom/browser-element/mochitest/file_web_manifest.json
+++ /dev/null
@@ -1,1 +0,0 @@
-{"name": "pass"}
--- a/dom/browser-element/mochitest/mochitest-oop.ini
+++ b/dom/browser-element/mochitest/mochitest-oop.ini
@@ -1,78 +1,52 @@
 [DEFAULT]
-# Both the "inproc" and "oop" versions of OpenMixedProcess open remote frames,
-# so we don't run that test on platforms which don't support OOP tests.
+# FIXME(bz, bug 1504026): now that we're not testing OpenMixedProcess,
+# can we reenable these tests on Android and e10s?
 skip-if = os == "android" || e10s
 support-files =
-  browserElement_OpenMixedProcess.js
-  file_browserElement_ExecuteScript.html
-  file_browserElement_OpenMixedProcess.html
-  browserElement_ExecuteScript.js
-  browserElement_Find.js
   browserElement_OpenTab.js
 
 [test_browserElement_oop_Viewmode.html]
 [test_browserElement_oop_ThemeColor.html]
 [test_browserElement_inproc_ErrorSecurity.html]
-[test_browserElement_inproc_OpenMixedProcess.html]
-disabled = disabled for bug 1266035 (bug 1310706 for re-enabling)
 [test_browserElement_oop_Alert.html]
 [test_browserElement_oop_AlertInFrame.html]
 [test_browserElement_oop_Auth.html]
 [test_browserElement_oop_BackForward.html]
 disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
-[test_browserElement_oop_BadScreenshot.html]
-disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
 [test_browserElement_oop_BrowserWindowResize.html]
 [test_browserElement_oop_Close.html]
 [test_browserElement_oop_CookiesNotThirdParty.html]
 [test_browserElement_oop_CopyPaste.html]
 subsuite = clipboard
-[test_browserElement_oop_DOMRequestError.html]
-disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
 [test_browserElement_oop_DataURI.html]
 [test_browserElement_oop_DocumentFirstPaint.html]
 disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
-[test_browserElement_oop_Download.html]
-disabled = bug 1022281
 [test_browserElement_oop_ErrorSecurity.html]
-[test_browserElement_oop_ExecuteScript.html]
-disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
-[test_browserElement_oop_Find.html]
-disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
 [test_browserElement_oop_FirstPaint.html]
 [test_browserElement_oop_ForwardName.html]
 [test_browserElement_oop_FrameWrongURI.html]
-[test_browserElement_oop_GetScreenshot.html]
-disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
-[test_browserElement_oop_GetScreenshotDppx.html]
-disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
 [test_browserElement_oop_Iconchange.html]
 [test_browserElement_oop_LoadEvents.html]
-[test_browserElement_oop_Manifestchange.html]
 [test_browserElement_oop_Metachange.html]
 [test_browserElement_oop_NoAudioTrack.html]
 disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
-[test_browserElement_oop_OpenMixedProcess.html]
-disabled = disabled for bug 1266035 (bug 1310706 for re-enabling)
 [test_browserElement_oop_OpenNamed.html]
 [test_browserElement_oop_OpenWindow.html]
 [test_browserElement_oop_OpenWindowDifferentOrigin.html]
 [test_browserElement_oop_OpenWindowInFrame.html]
 [test_browserElement_oop_OpenWindowRejected.html]
 [test_browserElement_oop_Opensearch.html]
 [test_browserElement_oop_OpenTab.html]
 disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
 [test_browserElement_oop_PrivateBrowsing.html]
 skip-if = true # Bug 1315042
 [test_browserElement_oop_PromptCheck.html]
 [test_browserElement_oop_PromptConfirm.html]
-[test_browserElement_oop_PurgeHistory.html]
-disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
 [test_browserElement_oop_Reload.html]
 disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
 [test_browserElement_oop_ReloadPostRequest.html]
 disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
 [test_browserElement_oop_RemoveBrowserElement.html]
 [test_browserElement_oop_ScrollEvent.html]
 [test_browserElement_oop_SecurityChange.html]
 skip-if = toolkit == 'android' #TIMED_OUT, bug 766586
@@ -90,13 +64,9 @@ disabled = Disabling some OOP tests for 
 disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
 [test_browserElement_oop_XFrameOptionsDeny.html]
 disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
 [test_browserElement_oop_XFrameOptionsSameOrigin.html]
 [test_browserElement_oop_ContextmenuEvents.html]
 [test_browserElement_oop_CloseFromOpener.html]
 [test_browserElement_oop_ExposableURI.html]
 skip-if = !e10s # Bug 1391349
-[test_browserElement_oop_GetContentDimensions.html]
-disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
-[test_browserElement_oop_getWebManifest.html]
-disabled = Disabling some OOP tests for WebIDL scope changes (bug 1310706 for re-enabling)
 [test_browserElement_oop_OpenWindowEmpty.html]
--- a/dom/browser-element/mochitest/mochitest.ini
+++ b/dom/browser-element/mochitest/mochitest.ini
@@ -15,27 +15,24 @@ support-files =
   browserElement_Close.js
   browserElement_CloseFromOpener.js
   browserElement_ContextmenuEvents.js
   browserElement_CookiesNotThirdParty.js
   browserElement_CopyPaste.js
   browserElement_DataURI.js
   browserElement_DataURILoad.html
   browserElement_DataURILoad.js
-  browserElement_Download.js
   browserElement_ErrorSecurity.js
   browserElement_ExposableURI.js
   browserElement_FirstPaint.js
   browserElement_ForwardName.js
   browserElement_FrameWrongURI.js
   browserElement_Iconchange.js
   browserElement_LoadEvents.js
-  browserElement_Manifestchange.js
   browserElement_Metachange.js
-  browserElement_NextPaint.js
   browserElement_OpenNamed.js
   browserElement_OpenTab.js
   browserElement_OpenWindow.js
   browserElement_OpenWindowDifferentOrigin.js
   browserElement_OpenWindowEmpty.js
   browserElement_OpenWindowInFrame.js
   browserElement_OpenWindowRejected.js
   browserElement_Opensearch.js
@@ -60,17 +57,16 @@ support-files =
   file_browserElement_ThemeColor.html
   file_browserElement_BrowserWindowNamespace.html
   file_browserElement_CloseFromOpener.html
   file_browserElement_CookiesNotThirdParty.html
   file_browserElement_ForwardName.html
   file_browserElement_FrameWrongURI.html
   file_browserElement_LoadEvents.html
   file_browserElement_Metachange.sjs
-  file_browserElement_NextPaint.html
   file_browserElement_Open1.html
   file_browserElement_Open2.html
   file_browserElement_OpenNamed.html
   file_browserElement_OpenNamed2.html
   file_browserElement_OpenWindowDifferentOrigin.html
   file_browserElement_OpenWindowEmpty.html
   file_browserElement_OpenWindowInFrame.html
   file_browserElement_OpenWindowRejected.html
@@ -79,26 +75,22 @@ support-files =
   file_browserElement_TargetBlank.html
   file_browserElement_TargetTop.html
   file_browserElement_XFrameOptions.sjs
   file_browserElement_XFrameOptionsAllowFrom.html
   file_browserElement_XFrameOptionsAllowFrom.sjs
   file_browserElement_XFrameOptionsDeny.html
   file_browserElement_XFrameOptionsSameOrigin.html
   file_bug741717.sjs
-  file_download_bin.sjs
   file_empty.html
   file_empty_script.js
   file_focus.html
   file_http_401_response.sjs
   file_http_407_response.sjs
   file_wyciwyg.html
-  file_web_manifest.html
-  file_web_manifest.json
-  file_illegal_web_manifest.html
   noaudio.webm
 
 # Note: browserElementTestHelpers.js looks at the test's filename to determine
 # whether the test should be OOP.  "_oop_" signals OOP, "_inproc_" signals in
 # process.  Default is OOP.
 [test_browserElement_NoAttr.html]
 [test_browserElement_NoPref.html]
 [test_browserElement_NoPermission.html]
@@ -112,25 +104,22 @@ support-files =
 [test_browserElement_inproc_Close.html]
 [test_browserElement_inproc_CloseFromOpener.html]
 [test_browserElement_inproc_ContextmenuEvents.html]
 [test_browserElement_inproc_CookiesNotThirdParty.html]
 [test_browserElement_inproc_CopyPaste.html]
 subsuite = clipboard
 skip-if = (os == "android") # Disabled on Android, see bug 1230421
 [test_browserElement_inproc_DataURI.html]
-[test_browserElement_inproc_Download.html]
-disabled = bug 1022281
 [test_browserElement_inproc_ExposableURI.html]
 [test_browserElement_inproc_FirstPaint.html]
 [test_browserElement_inproc_ForwardName.html]
 [test_browserElement_inproc_FrameWrongURI.html]
 [test_browserElement_inproc_Iconchange.html]
 [test_browserElement_inproc_LoadEvents.html]
-[test_browserElement_inproc_Manifestchange.html]
 [test_browserElement_inproc_Metachange.html]
 [test_browserElement_inproc_OpenNamed.html]
 [test_browserElement_inproc_OpenTab.html]
 disabled = won't work as Firefox desktop will intercept ctrl-click
 [test_browserElement_inproc_OpenWindow.html]
 [test_browserElement_inproc_OpenWindowDifferentOrigin.html]
 [test_browserElement_inproc_OpenWindowInFrame.html]
 [test_browserElement_inproc_OpenWindowRejected.html]
@@ -145,16 +134,13 @@ skip-if = android_version == '22' # bug 
 [test_browserElement_inproc_TargetBlank.html]
 [test_browserElement_inproc_TargetTop.html]
 [test_browserElement_inproc_Titlechange.html]
 [test_browserElement_inproc_TopBarrier.html]
 [test_browserElement_inproc_XFrameOptions.html]
 [test_browserElement_inproc_XFrameOptionsAllowFrom.html]
 [test_browserElement_inproc_XFrameOptionsDeny.html]
 [test_browserElement_inproc_XFrameOptionsSameOrigin.html]
-[test_browserElement_oop_NextPaint.html]
-# Disabled due to https://bugzilla.mozilla.org/show_bug.cgi?id=774100
-disabled = temp disabling some OOP tests for WebIDL scope changes
 [test_browserElement_inproc_Reload.html]
 disabled = bug 774100
 [test_browserElement_inproc_OpenWindowEmpty.html]
 [test_browserElement_inproc_dataBlock.html]
 skip-if = (os == "android")
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_inproc_BadScreenshot.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for Bug 800170</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script type="application/javascript" src="browserElement_BadScreenshot.js">
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_inproc_DOMRequestError.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=787519
--->
-<head>
-  <title>Test for Bug 787519</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=787519">Mozilla Bug 787519</a>
-
-<script type="application/javascript" src='browserElement_DOMRequestError.js'>
-</script>
-
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_inproc_Download.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for Bug 983747</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script type="application/javascript" src="browserElement_Download.js">
-</script>
-</body>
-</html>
\ No newline at end of file
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_inproc_ExecuteScript.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=1174733
--->
-<head>
-  <title>Test for Bug 1163961</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1174733">Mozilla Bug 1174733</a>
-
-<script type="application/javascript" src="browserElement_ExecuteScript.js">
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_inproc_Find.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=1163961
--->
-<head>
-  <title>Test for Bug 1163961</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1163961">Mozilla Bug 1163961</a>
-
-<script type="application/javascript" src="browserElement_Find.js">
-</script>
-</body>
-</html>
-
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_inproc_GetContentDimensions.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test of browser element.</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script type="application/javascript" src="browserElement_GetContentDimensions.js">
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_inproc_GetScreenshot.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=753595
--->
-<head>
-  <title>Test for Bug 753595</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=753595">Mozilla Bug 753595</a>
-
-<script type="application/javascript" src='browserElement_GetScreenshot.js'>
-</script>
-
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_inproc_GetScreenshotDppx.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=959066
--->
-<head>
-  <title>Test for Bug 959066</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=959066">Mozilla Bug 959066</a>
-
-<script type="application/javascript" src='browserElement_GetScreenshotDppx.js'>
-</script>
-
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_inproc_Manifestchange.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=982800
--->
-<head>
-  <title>Test for Bug 982800</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=982800">Mozilla Bug 982800</a>
-
-<script type="application/javascript" src="browserElement_Manifestchange.js">
-</script>
-
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_inproc_NextPaint.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for Bug 808231</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script type="application/javascript" src="browserElement_NextPaint.js">
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_inproc_OpenMixedProcess.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for Bug 776129</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script type="application/javascript" src="browserElement_OpenMixedProcess.js">
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_inproc_PurgeHistory.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test of browser element.</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script type="application/javascript" src="browserElement_PurgeHistory.js">
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_inproc_getWebManifest.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for Bug 1169633</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script type="application/javascript"
-  src="async.js">
-</script>
-<script type="application/javascript"
-  src="browserElement_getWebManifest.js">
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_oop_BadScreenshot.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for Bug 800170</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script type="application/javascript" src="browserElement_BadScreenshot.js">
-</script>
-</body>
-</html>
\ No newline at end of file
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_oop_DOMRequestError.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=787519
--->
-<head>
-  <title>Test for Bug 787519</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=787519">Mozilla Bug 787519</a>
-
-<script type="application/javascript" src='browserElement_DOMRequestError.js'>
-</script>
-
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_oop_Download.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for Bug 983747</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script type="application/javascript" src="browserElement_Download.js">
-</script>
-</body>
-</html>
\ No newline at end of file
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_oop_ExecuteScript.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=1174733
--->
-<head>
-  <title>Test for Bug 1163961</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1174733">Mozilla Bug 1174733</a>
-
-<script type="application/javascript" src="browserElement_ExecuteScript.js">
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_oop_Find.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=1163961
--->
-<head>
-  <title>Test for Bug 1163961</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1163961">Mozilla Bug 1163961</a>
-
-<script type="application/javascript" src="browserElement_Find.js">
-</script>
-</body>
-</html>
-
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_oop_GetContentDimensions.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test of browser element.</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script type="application/javascript" src="browserElement_GetContentDimensions.js">
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_oop_GetScreenshot.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=753595
--->
-<head>
-  <title>Test for Bug 753595</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=753595">Mozilla Bug 753595</a>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=878003">Mozilla Bug 878003</a>
-
-<script type="application/javascript" src='browserElement_GetScreenshot.js'>
-</script>
-
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_oop_GetScreenshotDppx.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=959066
--->
-<head>
-  <title>Test for Bug 959066</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=959066">Mozilla Bug 959066</a>
-
-<script type="application/javascript" src='browserElement_GetScreenshotDppx.js'>
-</script>
-
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_oop_Manifestchange.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=982800
--->
-<head>
-  <title>Test for Bug 982800</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=982800">Mozilla Bug 982800</a>
-
-<script type="application/javascript" src="browserElement_Manifestchange.js">
-</script>
-
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_oop_NextPaint.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for Bug 808231</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script type="application/javascript" src="browserElement_NextPaint.js">
-</script>
-</body>
-</html>
\ No newline at end of file
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_oop_OpenMixedProcess.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for Bug 776129</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script type="application/javascript" src="browserElement_OpenMixedProcess.js">
-</script>
-</body>
-</html>
\ No newline at end of file
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_oop_PurgeHistory.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test of browser element.</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script type="application/javascript" src="browserElement_PurgeHistory.js">
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/test_browserElement_oop_getWebManifest.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for Bug 1169633</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="/tests/dom/browser-element/mochitest/browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script type="application/javascript"
-  src="async.js"></script>
-<script type="application/javascript"
-  src="browserElement_getWebManifest.js">
-</script>
-</body>
-</html>
--- a/dom/browser-element/nsIBrowserElementAPI.idl
+++ b/dom/browser-element/nsIBrowserElementAPI.idl
@@ -1,84 +1,44 @@
 /* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* 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/. */
 
 #include "nsISupports.idl"
 
-webidl DOMRequest;
 webidl FrameLoader;
 
 %{C++
 #define BROWSER_ELEMENT_API_CONTRACTID "@mozilla.org/dom/browser-element-api;1"
 #define BROWSER_ELEMENT_API_CID                                 \
     { 0x651db7e3, 0x1734, 0x4536,                               \
       { 0xb1, 0x5a, 0x5b, 0x3a, 0xe6, 0x44, 0x13, 0x4c } }
 %}
 
 /**
  * Interface to the BrowserElementParent implementation. All methods
  * but setFrameLoader throw when the remote process is dead.
  */
 [scriptable, uuid(57758c10-6036-11e5-a837-0800200c9a66)]
 interface nsIBrowserElementAPI : nsISupports
 {
-  const long FIND_CASE_SENSITIVE = 0;
-  const long FIND_CASE_INSENSITIVE = 1;
-
-  const long FIND_FORWARD = 0;
-  const long FIND_BACKWARD = 1;
-
   /**
    * Notify frame scripts that support the API to destroy.
    */
   void destroyFrameScripts();
 
   void setFrameLoader(in FrameLoader frameLoader);
 
   void sendMouseEvent(in AString type,
                       in uint32_t x,
                       in uint32_t y,
                       in uint32_t button,
                       in uint32_t clickCount,
                       in uint32_t mifiers);
-  void sendTouchEvent(in AString aType,
-                      [const, array, size_is(count)] in uint32_t aIdentifiers,
-                      [const, array, size_is(count)] in int32_t aXs,
-                      [const, array, size_is(count)] in int32_t aYs,
-                      [const, array, size_is(count)] in uint32_t aRxs,
-                      [const, array, size_is(count)] in uint32_t aRys,
-                      [const, array, size_is(count)] in float aRotationAngles,
-                      [const, array, size_is(count)] in float aForces,
-                      in uint32_t count,
-                      in long aModifiers);
   void goBack();
   void goForward();
   void reload(in boolean hardReload);
   void stop();
-  DOMRequest download(in AString url,
-                            [optional] in jsval options);
-  DOMRequest purgeHistory();
-  DOMRequest getScreenshot(in uint32_t width,
-                                 in uint32_t height,
-                                 [optional] in AString mimeType);
-  void zoom(in float zoom);
-  DOMRequest getCanGoBack();
-  DOMRequest getCanGoForward();
-  DOMRequest getContentDimensions();
-
-  void findAll(in AString searchString, in long caseSensitivity);
-  void findNext(in long direction);
-  void clearMatch();
-
-  void addNextPaintListener(in jsval listener); // BrowserElementNextPaintEventCallback
-  void removeNextPaintListener(in jsval listener); // BrowserElementNextPaintEventCallback
-
-  DOMRequest executeScript(in AString script, in jsval options);
-
-  /**
-   * Returns an object that represents a Web Manifest:
-   * http://w3c.github.io/manifest/
-   */
-  DOMRequest getWebManifest();
+  Promise getCanGoBack();
+  Promise getCanGoForward();
 };
--- a/dom/fetch/FetchStreamReader.cpp
+++ b/dom/fetch/FetchStreamReader.cpp
@@ -7,16 +7,17 @@
 #include "FetchStreamReader.h"
 #include "InternalResponse.h"
 #include "mozilla/dom/PromiseBinding.h"
 #include "mozilla/SystemGroup.h"
 #include "mozilla/TaskCategory.h"
 #include "nsContentUtils.h"
 #include "nsIScriptError.h"
 #include "nsPIDOMWindow.h"
+#include "jsapi.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(FetchStreamReader)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(FetchStreamReader)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(FetchStreamReader)
@@ -155,16 +156,22 @@ FetchStreamReader::StartConsuming(JSCont
                                   JS::MutableHandle<JSObject*> aReader,
                                   ErrorResult& aRv)
 {
   MOZ_DIAGNOSTIC_ASSERT(!mReader);
   MOZ_DIAGNOSTIC_ASSERT(aStream);
 
   aRv.MightThrowJSException();
 
+  // Here, by spec, we can pick any global we want. Just to avoid extra
+  // cross-compartment steps, we want to create the reader in the same
+  // compartment of the owning Fetch Body object.
+  // The same global will be used to retrieve data from this reader.
+  JSAutoRealm ar(aCx, mGlobal->GetGlobalJSObject());
+
   JS::Rooted<JSObject*> reader(aCx,
                                JS::ReadableStreamGetReader(aCx, aStream,
                                                            JS::ReadableStreamReaderMode::Default));
   if (!reader) {
     aRv.StealExceptionFromJSContext(aCx);
     CloseAndRelease(aCx, NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
@@ -190,18 +197,19 @@ FetchStreamReader::OnOutputStreamReady(n
   if (mStreamClosed) {
     return NS_OK;
   }
 
   if (mBuffer) {
     return WriteBuffer();
   }
 
-  // TODO: We need to verify this is the correct global per the spec.
-  //       See bug 1385890.
+  // Here we can retrieve data from the reader using any global we want because
+  // it is not observable. We want to use the reader's global, which is also the
+  // Response's one.
   AutoEntryScript aes(mGlobal, "ReadableStreamReader.read", !mWorkerRef);
 
   JS::Rooted<JSObject*> reader(aes.cx(), mReader);
   JS::Rooted<JSObject*> promise(aes.cx(),
                                 JS::ReadableStreamDefaultReaderRead(aes.cx(),
                                                                     reader));
   if (NS_WARN_IF(!promise)) {
     // Let's close the stream.
--- a/dom/html/nsBrowserElement.cpp
+++ b/dom/html/nsBrowserElement.cpp
@@ -4,17 +4,17 @@
  * 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/. */
 
 #include "nsBrowserElement.h"
 
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/dom/BrowserElementBinding.h"
-#include "mozilla/dom/DOMRequest.h"
+#include "mozilla/dom/Promise.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/ToJSValue.h"
 
 #include "nsComponentManagerUtils.h"
 #include "nsFrameLoader.h"
 #include "nsIMozBrowserFrame.h"
 #include "nsINode.h"
 #include "nsIPrincipal.h"
@@ -82,58 +82,16 @@ nsBrowserElement::SendMouseEvent(const n
                                                    aModifiers);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
   }
 }
 
 void
-nsBrowserElement::SendTouchEvent(const nsAString& aType,
-                                 const Sequence<uint32_t>& aIdentifiers,
-                                 const Sequence<int32_t>& aXs,
-                                 const Sequence<int32_t>& aYs,
-                                 const Sequence<uint32_t>& aRxs,
-                                 const Sequence<uint32_t>& aRys,
-                                 const Sequence<float>& aRotationAngles,
-                                 const Sequence<float>& aForces,
-                                 uint32_t aCount,
-                                 uint32_t aModifiers,
-                                 ErrorResult& aRv)
-{
-  NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
-
-  if (aIdentifiers.Length() != aCount ||
-      aXs.Length() != aCount ||
-      aYs.Length() != aCount ||
-      aRxs.Length() != aCount ||
-      aRys.Length() != aCount ||
-      aRotationAngles.Length() != aCount ||
-      aForces.Length() != aCount) {
-    aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
-    return;
-  }
-
-  nsresult rv = mBrowserElementAPI->SendTouchEvent(aType,
-                                                   aIdentifiers.Elements(),
-                                                   aXs.Elements(),
-                                                   aYs.Elements(),
-                                                   aRxs.Elements(),
-                                                   aRys.Elements(),
-                                                   aRotationAngles.Elements(),
-                                                   aForces.Elements(),
-                                                   aCount,
-                                                   aModifiers);
-
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
-  }
-}
-
-void
 nsBrowserElement::GoBack(ErrorResult& aRv)
 {
   NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
 
   nsresult rv = mBrowserElementAPI->GoBack();
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
@@ -171,281 +129,41 @@ nsBrowserElement::Stop(ErrorResult& aRv)
 
   nsresult rv = mBrowserElementAPI->Stop();
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
   }
 }
 
-already_AddRefed<DOMRequest>
-nsBrowserElement::Download(const nsAString& aUrl,
-                           const BrowserElementDownloadOptions& aOptions,
-                           ErrorResult& aRv)
-{
-  NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
-
-  RefPtr<DOMRequest> req;
-  nsCOMPtr<nsIXPConnectWrappedJS> wrappedObj = do_QueryInterface(mBrowserElementAPI);
-  MOZ_ASSERT(wrappedObj, "Failed to get wrapped JS from XPCOM component.");
-  MOZ_RELEASE_ASSERT(!js::IsWrapper(wrappedObj->GetJSObject()));
-  AutoJSAPI jsapi;
-  if (!jsapi.Init(wrappedObj->GetJSObject())) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return nullptr;
-  }
-  JSContext* cx = jsapi.cx();
-  JS::Rooted<JS::Value> options(cx);
-  aRv.MightThrowJSException();
-  if (!ToJSValue(cx, aOptions, &options)) {
-    aRv.StealExceptionFromJSContext(cx);
-    return nullptr;
-  }
-  nsresult rv = mBrowserElementAPI->Download(aUrl, options, getter_AddRefs(req));
-
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
-    return nullptr;
-  }
-
-  return req.forget();
-}
-
-already_AddRefed<DOMRequest>
-nsBrowserElement::PurgeHistory(ErrorResult& aRv)
-{
-  NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
-
-  RefPtr<DOMRequest> req;
-  nsresult rv = mBrowserElementAPI->PurgeHistory(getter_AddRefs(req));
-
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
-    return nullptr;
-  }
-
-  return req.forget();
-}
-
-already_AddRefed<DOMRequest>
-nsBrowserElement::GetScreenshot(uint32_t aWidth,
-                                uint32_t aHeight,
-                                const nsAString& aMimeType,
-                                ErrorResult& aRv)
-{
-  NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
-
-  RefPtr<DOMRequest> req;
-  nsresult rv = mBrowserElementAPI->GetScreenshot(aWidth, aHeight, aMimeType,
-                                                  getter_AddRefs(req));
-
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    if (rv == NS_ERROR_INVALID_ARG) {
-      aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
-    } else {
-      aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
-    }
-    return nullptr;
-  }
-
-  return req.forget();
-}
-
-void
-nsBrowserElement::Zoom(float aZoom, ErrorResult& aRv)
-{
-  NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
-
-  nsresult rv = mBrowserElementAPI->Zoom(aZoom);
-
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
-  }
-}
-
-already_AddRefed<DOMRequest>
+already_AddRefed<Promise>
 nsBrowserElement::GetCanGoBack(ErrorResult& aRv)
 {
   NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
 
-  RefPtr<DOMRequest> req;
-  nsresult rv = mBrowserElementAPI->GetCanGoBack(getter_AddRefs(req));
-
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
-    return nullptr;
-  }
-
-  return req.forget();
-}
-
-already_AddRefed<DOMRequest>
-nsBrowserElement::GetCanGoForward(ErrorResult& aRv)
-{
-  NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
-
-  RefPtr<DOMRequest> req;
-  nsresult rv = mBrowserElementAPI->GetCanGoForward(getter_AddRefs(req));
-
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
-    return nullptr;
-  }
-
-  return req.forget();
-}
-
-already_AddRefed<DOMRequest>
-nsBrowserElement::GetContentDimensions(ErrorResult& aRv)
-{
-  NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
-
-  RefPtr<DOMRequest> req;
-  nsresult rv = mBrowserElementAPI->GetContentDimensions(getter_AddRefs(req));
+  RefPtr<Promise> p;
+  nsresult rv = mBrowserElementAPI->GetCanGoBack(getter_AddRefs(p));
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
 
-  return req.forget();
-}
-
-void
-nsBrowserElement::FindAll(const nsAString& aSearchString,
-                          BrowserFindCaseSensitivity aCaseSensitivity,
-                          ErrorResult& aRv)
-{
-  NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
-
-  uint32_t caseSensitivity;
-  if (aCaseSensitivity == BrowserFindCaseSensitivity::Case_insensitive) {
-    caseSensitivity = nsIBrowserElementAPI::FIND_CASE_INSENSITIVE;
-  } else {
-    caseSensitivity = nsIBrowserElementAPI::FIND_CASE_SENSITIVE;
-  }
-
-  nsresult rv = mBrowserElementAPI->FindAll(aSearchString, caseSensitivity);
-
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-  }
-}
-
-void
-nsBrowserElement::FindNext(BrowserFindDirection aDirection,
-                          ErrorResult& aRv)
-{
-  NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
-
-  uint32_t direction;
-  if (aDirection == BrowserFindDirection::Backward) {
-    direction = nsIBrowserElementAPI::FIND_BACKWARD;
-  } else {
-    direction = nsIBrowserElementAPI::FIND_FORWARD;
-  }
-
-  nsresult rv = mBrowserElementAPI->FindNext(direction);
-
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-  }
+  return p.forget();
 }
 
-void
-nsBrowserElement::ClearMatch(ErrorResult& aRv)
-{
-  NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
-
-  nsresult rv = mBrowserElementAPI->ClearMatch();
-
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-  }
-}
-
-void
-nsBrowserElement::AddNextPaintListener(BrowserElementNextPaintEventCallback& aListener,
-                                       ErrorResult& aRv)
-{
-  NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
-
-  JS::Rooted<JS::Value> val(RootingCx(),
-                            JS::ObjectOrNullValue(aListener.CallbackOrNull()));
-  nsresult rv = mBrowserElementAPI->AddNextPaintListener(val);
-
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
-  }
-}
-
-void
-nsBrowserElement::RemoveNextPaintListener(BrowserElementNextPaintEventCallback& aListener,
-                                          ErrorResult& aRv)
-{
-  NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
-
-  JS::Rooted<JS::Value> val(RootingCx(),
-                            JS::ObjectOrNullValue(aListener.CallbackOrNull()));
-  nsresult rv = mBrowserElementAPI->RemoveNextPaintListener(val);
-
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
-  }
-}
-
-already_AddRefed<DOMRequest>
-nsBrowserElement::ExecuteScript(const nsAString& aScript,
-                                const BrowserElementExecuteScriptOptions& aOptions,
-                                ErrorResult& aRv)
+already_AddRefed<Promise>
+nsBrowserElement::GetCanGoForward(ErrorResult& aRv)
 {
   NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
 
-  RefPtr<DOMRequest> req;
-  nsCOMPtr<nsIXPConnectWrappedJS> wrappedObj = do_QueryInterface(mBrowserElementAPI);
-  MOZ_ASSERT(wrappedObj, "Failed to get wrapped JS from XPCOM component.");
-  MOZ_RELEASE_ASSERT(!js::IsWrapper(wrappedObj->GetJSObject()));
-  AutoJSAPI jsapi;
-  if (!jsapi.Init(wrappedObj->GetJSObject())) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return nullptr;
-  }
-  JSContext* cx = jsapi.cx();
-  JS::Rooted<JS::Value> options(cx);
-  aRv.MightThrowJSException();
-  if (!ToJSValue(cx, aOptions, &options)) {
-    aRv.StealExceptionFromJSContext(cx);
-    return nullptr;
-  }
-
-  nsresult rv = mBrowserElementAPI->ExecuteScript(aScript, options, getter_AddRefs(req));
-
-  if (NS_FAILED(rv)) {
-    if (rv == NS_ERROR_INVALID_ARG) {
-      aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
-    } else {
-      aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
-    }
-    return nullptr;
-  }
-
-  return req.forget();
-}
-
-already_AddRefed<DOMRequest>
-nsBrowserElement::GetWebManifest(ErrorResult& aRv)
-{
-  NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
-
-  RefPtr<DOMRequest> req;
-  nsresult rv = mBrowserElementAPI->GetWebManifest(getter_AddRefs(req));
+  RefPtr<Promise> p;
+  nsresult rv = mBrowserElementAPI->GetCanGoForward(getter_AddRefs(p));
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
 
-  return req.forget();
+  return p.forget();
 }
 
-
-
 } // namespace mozilla
--- a/dom/html/nsBrowserElement.h
+++ b/dom/html/nsBrowserElement.h
@@ -12,22 +12,17 @@
 #include "nsCOMPtr.h"
 #include "nsIBrowserElementAPI.h"
 
 class nsFrameLoader;
 
 namespace mozilla {
 
 namespace dom {
-struct BrowserElementDownloadOptions;
-struct BrowserElementExecuteScriptOptions;
-class BrowserElementNextPaintEventCallback;
-class DOMRequest;
-enum class BrowserFindCaseSensitivity: uint8_t;
-enum class BrowserFindDirection: uint8_t;
+class Promise;
 } // namespace dom
 
 class ErrorResult;
 
 /**
  * A helper class for browser-element frames
  */
 class nsBrowserElement
@@ -38,66 +33,23 @@ public:
 
   void SendMouseEvent(const nsAString& aType,
                       uint32_t aX,
                       uint32_t aY,
                       uint32_t aButton,
                       uint32_t aClickCount,
                       uint32_t aModifiers,
                       ErrorResult& aRv);
-  void SendTouchEvent(const nsAString& aType,
-                      const dom::Sequence<uint32_t>& aIdentifiers,
-                      const dom::Sequence<int32_t>& aX,
-                      const dom::Sequence<int32_t>& aY,
-                      const dom::Sequence<uint32_t>& aRx,
-                      const dom::Sequence<uint32_t>& aRy,
-                      const dom::Sequence<float>& aRotationAngles,
-                      const dom::Sequence<float>& aForces,
-                      uint32_t aCount,
-                      uint32_t aModifiers,
-                      ErrorResult& aRv);
   void GoBack(ErrorResult& aRv);
   void GoForward(ErrorResult& aRv);
   void Reload(bool aHardReload, ErrorResult& aRv);
   void Stop(ErrorResult& aRv);
 
-  already_AddRefed<dom::DOMRequest>
-  Download(const nsAString& aUrl,
-           const dom::BrowserElementDownloadOptions& options,
-           ErrorResult& aRv);
-
-  already_AddRefed<dom::DOMRequest> PurgeHistory(ErrorResult& aRv);
-
-  already_AddRefed<dom::DOMRequest>
-  GetScreenshot(uint32_t aWidth,
-                uint32_t aHeight,
-                const nsAString& aMimeType,
-                ErrorResult& aRv);
-
-  void Zoom(float aZoom, ErrorResult& aRv);
-
-  already_AddRefed<dom::DOMRequest> GetCanGoBack(ErrorResult& aRv);
-  already_AddRefed<dom::DOMRequest> GetCanGoForward(ErrorResult& aRv);
-  already_AddRefed<dom::DOMRequest> GetContentDimensions(ErrorResult& aRv);
-
-  void FindAll(const nsAString& aSearchString, dom::BrowserFindCaseSensitivity aCaseSensitivity,
-               ErrorResult& aRv);
-  void FindNext(dom::BrowserFindDirection aDirection, ErrorResult& aRv);
-  void ClearMatch(ErrorResult& aRv);
-
-  void AddNextPaintListener(dom::BrowserElementNextPaintEventCallback& listener,
-                            ErrorResult& aRv);
-  void RemoveNextPaintListener(dom::BrowserElementNextPaintEventCallback& listener,
-                               ErrorResult& aRv);
-
-  already_AddRefed<dom::DOMRequest> ExecuteScript(const nsAString& aScript,
-                                                  const dom::BrowserElementExecuteScriptOptions& aOptions,
-                                                  ErrorResult& aRv);
-
-  already_AddRefed<dom::DOMRequest> GetWebManifest(ErrorResult& aRv);
+  already_AddRefed<dom::Promise> GetCanGoBack(ErrorResult& aRv);
+  already_AddRefed<dom::Promise> GetCanGoForward(ErrorResult& aRv);
 
 protected:
   NS_IMETHOD_(already_AddRefed<nsFrameLoader>) GetFrameLoader() = 0;
 
   void InitBrowserElementAPI();
   void DestroyBrowserElementFrameScripts();
   nsCOMPtr<nsIBrowserElementAPI> mBrowserElementAPI;
 
--- a/dom/html/test/mochitest.ini
+++ b/dom/html/test/mochitest.ini
@@ -432,17 +432,17 @@ support-files =
 [test_formData.html]
 [test_formSubmission.html]
 skip-if = toolkit == 'android' #TIMED_OUT
 [test_formSubmission2.html]
 skip-if = toolkit == 'android'
 [test_formelements.html]
 [test_fullscreen-api.html]
 tags = fullscreen
-skip-if = toolkit == 'android'
+skip-if = toolkit == 'android' || (os == 'linux' && !debug) # linux opt/pgo timeouts: bug 1504062
 support-files =
   file_fullscreen-api.html
   file_fullscreen-backdrop.html
   file_fullscreen-denied-inner.html
   file_fullscreen-denied.html
   file_fullscreen-esc-exit-inner.html
   file_fullscreen-esc-exit.html
   file_fullscreen-event-order.html
--- a/dom/webidl/BrowserElement.webidl
+++ b/dom/webidl/BrowserElement.webidl
@@ -1,78 +1,34 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/.
  */
 
-callback BrowserElementNextPaintEventCallback = void ();
-
-enum BrowserFindCaseSensitivity { "case-sensitive", "case-insensitive" };
-enum BrowserFindDirection { "forward", "backward" };
-
-dictionary BrowserElementDownloadOptions {
-  DOMString? filename;
-  DOMString? referrer;
-};
-
-dictionary BrowserElementExecuteScriptOptions {
-  DOMString? url;
-  DOMString? origin;
-};
-
 [NoInterfaceObject]
 interface BrowserElement {
 };
 
-BrowserElement implements BrowserElementCommon;
 BrowserElement implements BrowserElementPrivileged;
 
 [NoInterfaceObject]
-interface BrowserElementCommon {
-  [Throws,
-   Pref="dom.mozBrowserFramesEnabled",
-   ChromeOnly]
-  void addNextPaintListener(BrowserElementNextPaintEventCallback listener);
-
-  [Throws,
-   Pref="dom.mozBrowserFramesEnabled",
-   ChromeOnly]
-  void removeNextPaintListener(BrowserElementNextPaintEventCallback listener);
-};
-
-[NoInterfaceObject]
 interface BrowserElementPrivileged {
   [Throws,
    Pref="dom.mozBrowserFramesEnabled",
    ChromeOnly]
   void sendMouseEvent(DOMString type,
                       unsigned long x,
                       unsigned long y,
                       unsigned long button,
                       unsigned long clickCount,
                       unsigned long modifiers);
 
   [Throws,
    Pref="dom.mozBrowserFramesEnabled",
-   Func="TouchEvent::PrefEnabled",
-   ChromeOnly]
-  void sendTouchEvent(DOMString type,
-                      sequence<unsigned long> identifiers,
-                      sequence<long> x,
-                      sequence<long> y,
-                      sequence<unsigned long> rx,
-                      sequence<unsigned long> ry,
-                      sequence<float> rotationAngles,
-                      sequence<float> forces,
-                      unsigned long count,
-                      unsigned long modifiers);
-
-  [Throws,
-   Pref="dom.mozBrowserFramesEnabled",
    ChromeOnly]
   void goBack();
 
   [Throws,
    Pref="dom.mozBrowserFramesEnabled",
    ChromeOnly]
   void goForward();
 
@@ -84,70 +40,15 @@ interface BrowserElementPrivileged {
   [Throws,
    Pref="dom.mozBrowserFramesEnabled",
    ChromeOnly]
   void stop();
 
   [Throws,
    Pref="dom.mozBrowserFramesEnabled",
    ChromeOnly]
-  DOMRequest download(DOMString url,
-                      optional BrowserElementDownloadOptions options);
-
-  [Throws,
-   Pref="dom.mozBrowserFramesEnabled",
-   ChromeOnly]
-  DOMRequest purgeHistory();
-
-  [Throws,
-   Pref="dom.mozBrowserFramesEnabled",
-   ChromeOnly]
-  DOMRequest getScreenshot([EnforceRange] unsigned long width,
-                           [EnforceRange] unsigned long height,
-                           optional DOMString mimeType="");
-
-  [Throws,
-   Pref="dom.mozBrowserFramesEnabled",
-   ChromeOnly]
-  void zoom(float zoom);
-
-  [Throws,
-   Pref="dom.mozBrowserFramesEnabled",
-   ChromeOnly]
-  DOMRequest getCanGoBack();
+  Promise<boolean> getCanGoBack();
 
   [Throws,
    Pref="dom.mozBrowserFramesEnabled",
    ChromeOnly]
-  DOMRequest getCanGoForward();
-
-  [Throws,
-   Pref="dom.mozBrowserFramesEnabled",
-   ChromeOnly]
-  DOMRequest getContentDimensions();
-
-  [Throws,
-   Pref="dom.mozBrowserFramesEnabled",
-   ChromeOnly]
-  void findAll(DOMString searchString, BrowserFindCaseSensitivity caseSensitivity);
-
-  [Throws,
-   Pref="dom.mozBrowserFramesEnabled",
-   ChromeOnly]
-  void findNext(BrowserFindDirection direction);
-
-  [Throws,
-   Pref="dom.mozBrowserFramesEnabled",
-   ChromeOnly]
-  void clearMatch();
-
-  [Throws,
-   Pref="dom.mozBrowserFramesEnabled",
-   ChromeOnly]
-  DOMRequest executeScript(DOMString script,
-                           optional BrowserElementExecuteScriptOptions options);
-
-  [Throws,
-   Pref="dom.mozBrowserFramesEnabled",
-   ChromeOnly]
-  DOMRequest getWebManifest();
-
+  Promise<boolean> getCanGoForward();
 };
--- a/image/DecoderFactory.cpp
+++ b/image/DecoderFactory.cpp
@@ -241,17 +241,18 @@ DecoderFactory::CloneAnimationDecoder(De
 {
   MOZ_ASSERT(aDecoder);
 
   // In an ideal world, we would assert aDecoder->HasAnimation() but we cannot.
   // The decoder may not have detected it is animated yet (e.g. it did not even
   // get scheduled yet, or it has only decoded the first frame and has yet to
   // rediscover it is animated).
   DecoderType type = aDecoder->GetType();
-  MOZ_ASSERT(type == DecoderType::GIF || type == DecoderType::PNG,
+  MOZ_ASSERT(type == DecoderType::GIF || type == DecoderType::PNG ||
+             type == DecoderType::WEBP,
              "Calling CloneAnimationDecoder for non-animating DecoderType");
 
   RefPtr<Decoder> decoder = GetDecoder(type, nullptr, /* aIsRedecode = */ true);
   MOZ_ASSERT(decoder, "Should have a decoder now");
 
   // Initialize the decoder.
   decoder->SetMetadataDecode(false);
   decoder->SetIterator(aDecoder->GetSourceBuffer()->Iterator());
--- a/image/IDecodingTask.cpp
+++ b/image/IDecodingTask.cpp
@@ -180,18 +180,20 @@ MetadataDecodingTask::Run()
   MOZ_ASSERT_UNREACHABLE("Metadata decode yielded for an unexpected reason");
 }
 
 
 ///////////////////////////////////////////////////////////////////////////////
 // AnonymousDecodingTask implementation.
 ///////////////////////////////////////////////////////////////////////////////
 
-AnonymousDecodingTask::AnonymousDecodingTask(NotNull<Decoder*> aDecoder)
+AnonymousDecodingTask::AnonymousDecodingTask(NotNull<Decoder*> aDecoder,
+                                             bool aResumable)
   : mDecoder(aDecoder)
+  , mResumable(aResumable)
 { }
 
 void
 AnonymousDecodingTask::Run()
 {
   while (true) {
     LexerResult result = mDecoder->Decode(WrapNotNull(this));
 
@@ -206,10 +208,25 @@ AnonymousDecodingTask::Run()
     }
 
     // Right now we don't do anything special for other kinds of yields, so just
     // keep working.
     MOZ_ASSERT(result.is<Yield>());
   }
 }
 
+void
+AnonymousDecodingTask::Resume()
+{
+  // Anonymous decoders normally get all their data at once. We have tests
+  // where they don't; typically in these situations, the test re-runs them
+  // manually. However some tests want to verify Resume works, so they will
+  // explicitly request this behaviour.
+  if (mResumable) {
+    RefPtr<AnonymousDecodingTask> self(this);
+    NS_DispatchToMainThread(NS_NewRunnableFunction(
+      "image::AnonymousDecodingTask::Resume",
+      [self]() -> void { self->Run(); }));
+  }
+}
+
 } // namespace image
 } // namespace mozilla
--- a/image/IDecodingTask.h
+++ b/image/IDecodingTask.h
@@ -104,30 +104,29 @@ private:
  * An IDecodingTask implementation for anonymous decoders - that is, decoders
  * with no associated Image object.
  */
 class AnonymousDecodingTask final : public IDecodingTask
 {
 public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AnonymousDecodingTask, override)
 
-  explicit AnonymousDecodingTask(NotNull<Decoder*> aDecoder);
+  explicit AnonymousDecodingTask(NotNull<Decoder*> aDecoder,
+                                 bool aResumable);
 
   void Run() override;
 
   bool ShouldPreferSyncRun() const override { return true; }
   TaskPriority Priority() const override { return TaskPriority::eLow; }
 
-  // Anonymous decoders normally get all their data at once. We have tests where
-  // they don't; in these situations, the test re-runs them manually. So no
-  // matter what, we don't want to resume by posting a task to the DecodePool.
-  void Resume() override { }
+  void Resume() override;
 
 private:
   virtual ~AnonymousDecodingTask() { }
 
   NotNull<RefPtr<Decoder>> mDecoder;
+  bool mResumable;
 };
 
 } // namespace image
 } // namespace mozilla
 
 #endif // mozilla_image_IDecodingTask_h
--- a/image/ImageOps.cpp
+++ b/image/ImageOps.cpp
@@ -174,17 +174,18 @@ ImageOps::DecodeMetadata(ImageBuffer* aB
   RefPtr<Decoder> decoder =
     DecoderFactory::CreateAnonymousMetadataDecoder(decoderType,
                                                    WrapNotNull(sourceBuffer));
   if (!decoder) {
     return NS_ERROR_FAILURE;
   }
 
   // Run the decoder synchronously.
-  RefPtr<IDecodingTask> task = new AnonymousDecodingTask(WrapNotNull(decoder));
+  RefPtr<IDecodingTask> task =
+    new AnonymousDecodingTask(WrapNotNull(decoder), /* aResumable */ false);
   task->Run();
   if (!decoder->GetDecodeDone() || decoder->HasError()) {
     return NS_ERROR_FAILURE;
   }
 
   aMetadata = decoder->GetImageMetadata();
   if (aMetadata.GetNativeSizes().IsEmpty() && aMetadata.HasSize()) {
     aMetadata.AddNativeSize(aMetadata.GetSize());
@@ -228,17 +229,18 @@ ImageOps::DecodeToSurface(ImageBuffer* a
                                            aSize,
                                            DecoderFlags::FIRST_FRAME_ONLY,
                                            ToSurfaceFlags(aFlags));
   if (!decoder) {
     return nullptr;
   }
 
   // Run the decoder synchronously.
-  RefPtr<IDecodingTask> task = new AnonymousDecodingTask(WrapNotNull(decoder));
+  RefPtr<IDecodingTask> task =
+    new AnonymousDecodingTask(WrapNotNull(decoder), /* aResumable */ false);
   task->Run();
   if (!decoder->GetDecodeDone() || decoder->HasError()) {
     return nullptr;
   }
 
   // Pull out the surface.
   RawAccessFrameRef frame = decoder->GetCurrentFrameRef();
   if (!frame) {
--- a/image/decoders/nsWebPDecoder.cpp
+++ b/image/decoders/nsWebPDecoder.cpp
@@ -105,17 +105,17 @@ nsWebPDecoder::ReadData()
 
 LexerResult
 nsWebPDecoder::DoDecode(SourceBufferIterator& aIterator, IResumable* aOnResume)
 {
   MOZ_ASSERT(!HasError(), "Shouldn't call DoDecode after error!");
 
   SourceBufferIterator::State state = SourceBufferIterator::COMPLETE;
   if (!mIteratorComplete) {
-    state = aIterator.Advance(SIZE_MAX);
+    state = aIterator.AdvanceOrScheduleResume(SIZE_MAX, aOnResume);
 
     // We need to remember since we can't advance a complete iterator.
     mIteratorComplete = state == SourceBufferIterator::COMPLETE;
   }
 
   switch (state) {
     case SourceBufferIterator::READY:
       if (!aIterator.IsContiguous()) {
@@ -128,16 +128,18 @@ nsWebPDecoder::DoDecode(SourceBufferIter
         // the first block.
         MOZ_ASSERT(mLength == 0);
         mData = reinterpret_cast<const uint8_t*>(aIterator.Data());
       }
       mLength += aIterator.Length();
       return ReadData();
     case SourceBufferIterator::COMPLETE:
       return ReadData();
+    case SourceBufferIterator::WAITING:
+      return LexerResult(Yield::NEED_MORE_DATA);
     default:
       MOZ_LOG(sWebPLog, LogLevel::Error,
           ("[this=%p] nsWebPDecoder::DoDecode -- bad state\n", this));
       return LexerResult(TerminalState::FAILURE);
   }
 
   // We need to buffer. If we have no data buffered, we need to get everything
   // from the first chunk of the source buffer before appending the new data.
@@ -175,18 +177,26 @@ nsWebPDecoder::DoDecode(SourceBufferIter
 
 nsresult
 nsWebPDecoder::CreateFrame(const nsIntRect& aFrameRect)
 {
   MOZ_ASSERT(HasSize());
   MOZ_ASSERT(!mDecoder);
 
   MOZ_LOG(sWebPLog, LogLevel::Debug,
-      ("[this=%p] nsWebPDecoder::CreateFrame -- frame %u, %d x %d\n",
-       this, mCurrentFrame, aFrameRect.width, aFrameRect.height));
+      ("[this=%p] nsWebPDecoder::CreateFrame -- frame %u, (%d, %d) %d x %d\n",
+       this, mCurrentFrame, aFrameRect.x, aFrameRect.y,
+       aFrameRect.width, aFrameRect.height));
+
+  if (aFrameRect.width <= 0 || aFrameRect.height <= 0) {
+    MOZ_LOG(sWebPLog, LogLevel::Error,
+        ("[this=%p] nsWebPDecoder::CreateFrame -- bad frame rect\n",
+         this));
+    return NS_ERROR_FAILURE;
+  }
 
   // If this is our first frame in an animation and it doesn't cover the
   // full frame, then we are transparent even if there is no alpha
   if (mCurrentFrame == 0 && !aFrameRect.IsEqualEdges(FullFrame())) {
     MOZ_ASSERT(HasAnimation());
     mFormat = SurfaceFormat::B8G8R8A8;
     PostHasTransparency();
   }
@@ -215,16 +225,17 @@ nsWebPDecoder::CreateFrame(const nsIntRe
   Maybe<SurfacePipe> pipe = SurfacePipeFactory::CreateSurfacePipe(this,
       Size(), OutputSize(), aFrameRect, mFormat, Some(animParams), pipeFlags);
   if (!pipe) {
     MOZ_LOG(sWebPLog, LogLevel::Error,
         ("[this=%p] nsWebPDecoder::CreateFrame -- no pipe\n", this));
     return NS_ERROR_FAILURE;
   }
 
+  mFrameRect = aFrameRect;
   mPipe = std::move(*pipe);
   return NS_OK;
 }
 
 void
 nsWebPDecoder::EndFrame()
 {
   MOZ_ASSERT(HasSize());
@@ -414,17 +425,19 @@ nsWebPDecoder::ReadSingle(const uint8_t*
   int width = 0;
   int height = 0;
   int stride = 0;
   uint8_t* rowStart = WebPIDecGetRGB(mDecoder, &lastRow, &width, &height, &stride);
   if (!rowStart || lastRow == -1) {
     return LexerResult(Yield::NEED_MORE_DATA);
   }
 
-  if (width <= 0 || height <= 0 || stride <= 0) {
+  if (width != mFrameRect.width || height != mFrameRect.height ||
+      stride < mFrameRect.width * 4 ||
+      lastRow > mFrameRect.height) {
     MOZ_LOG(sWebPLog, LogLevel::Error,
         ("[this=%p] nsWebPDecoder::ReadSingle -- bad (w,h,s) = (%d, %d, %d)\n",
          this, width, height, stride));
     return LexerResult(TerminalState::FAILURE);
   }
 
   const bool noPremultiply =
     bool(GetSurfaceFlags() & SurfaceFlags::NO_PREMULTIPLY_ALPHA);
--- a/image/decoders/nsWebPDecoder.h
+++ b/image/decoders/nsWebPDecoder.h
@@ -16,16 +16,18 @@ namespace mozilla {
 namespace image {
 class RasterImage;
 
 class nsWebPDecoder final : public Decoder
 {
 public:
   virtual ~nsWebPDecoder();
 
+  DecoderType GetType() const override { return DecoderType::WEBP; }
+
 protected:
   LexerResult DoDecode(SourceBufferIterator& aIterator,
                        IResumable* aOnResume) override;
   Maybe<Telemetry::HistogramID> SpeedHistogram() const override;
 
 private:
   friend class DecoderFactory;
 
@@ -72,16 +74,19 @@ private:
   DisposalMethod mDisposal;
 
   /// Frame timeout for the current frame;
   FrameTimeout mTimeout;
 
   /// Surface format for the current frame.
   gfx::SurfaceFormat mFormat;
 
+  /// Frame rect for the current frame.
+  IntRect mFrameRect;
+
   /// The last row of decoded pixels written to mPipe.
   int mLastRow;
 
   /// Number of decoded frames.
   uint32_t mCurrentFrame;
 
   /// Pointer to the start of the contiguous encoded image data.
   const uint8_t* mData;
--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -12,17 +12,16 @@
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/Move.h"
 #include "mozilla/NullPrincipal.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ChaosMode.h"
 #include "mozilla/LoadInfo.h"
-#include "mozilla/Telemetry.h"
 
 #include "nsImageModule.h"
 #include "imgRequestProxy.h"
 
 #include "nsCOMPtr.h"
 
 #include "nsContentPolicyUtils.h"
 #include "nsContentUtils.h"
@@ -1409,19 +1408,16 @@ void imgLoader::GlobalInit()
   sCacheTimeWeight = gfxPrefs::ImageCacheTimeWeight() / 1000.0;
   int32_t cachesize = gfxPrefs::ImageCacheSize();
   sCacheMaxSize = cachesize > 0 ? cachesize : 0;
 
   sMemReporter = new imgMemoryReporter();
   RegisterStrongAsyncMemoryReporter(sMemReporter);
   RegisterImagesContentUsedUncompressedDistinguishedAmount(
     imgMemoryReporter::ImagesContentUsedUncompressedDistinguishedAmount);
-
-  Telemetry::ScalarSet(Telemetry::ScalarID::IMAGES_WEBP_PROBE_OBSERVED, false);
-  Telemetry::ScalarSet(Telemetry::ScalarID::IMAGES_WEBP_CONTENT_OBSERVED, false);
 }
 
 void imgLoader::ShutdownMemoryReporter()
 {
   UnregisterImagesContentUsedUncompressedDistinguishedAmount();
   UnregisterStrongMemoryReporter(sMemReporter);
 }
 
--- a/image/imgRequest.cpp
+++ b/image/imgRequest.cpp
@@ -36,17 +36,16 @@
 #include "prtime.h" // for PR_Now
 #include "nsNetUtil.h"
 #include "nsIProtocolHandler.h"
 #include "imgIRequest.h"
 #include "nsProperties.h"
 
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/SizeOfState.h"
-#include "mozilla/Telemetry.h"
 
 using namespace mozilla;
 using namespace mozilla::image;
 
 #define LOG_TEST(level) (MOZ_LOG_TEST(gImgLog, (level)))
 
 NS_IMPL_ISUPPORTS(imgRequest,
                   nsIStreamListener, nsIRequestObserver,
@@ -917,17 +916,16 @@ imgRequest::OnStopRequest(nsIRequest* aR
 
   mTimedChannel = nullptr;
   return NS_OK;
 }
 
 struct mimetype_closure
 {
   nsACString* newType;
-  uint32_t segmentSize;
 };
 
 /* prototype for these defined below */
 static nsresult
 sniff_mimetype_callback(nsIInputStream* in, void* closure,
                         const char* fromRawSegment, uint32_t toOffset,
                         uint32_t count, uint32_t* writeCount);
 
@@ -964,59 +962,21 @@ PrepareForNewPart(nsIRequest* aRequest, 
                   nsIURI* aURI, bool aIsMultipart, image::Image* aExistingImage,
                   ProgressTracker* aProgressTracker, uint32_t aInnerWindowId)
 {
   NewPartResult result(aExistingImage);
 
   if (aInStr) {
     mimetype_closure closure;
     closure.newType = &result.mContentType;
-    closure.segmentSize = 0;
 
     // Look at the first few bytes and see if we can tell what the data is from
     // that since servers tend to lie. :(
     uint32_t out;
     aInStr->ReadSegments(sniff_mimetype_callback, &closure, aCount, &out);
-
-    // We don't support WebP but we are getting reports of Firefox being served
-    // WebP content in the wild. In particular this appears to be a problem on
-    // Fennec where content authors assume Android implies WebP support. The
-    // telemetry below is intended to get a sense of how prevalent this is.
-    //
-    // From the Google WebP FAQ example and the Modernizr library, websites may
-    // supply a tiny WebP image to probe for feature support using scripts. The
-    // probes are implemented as data URIs thus we should have all the content
-    // upfront. We don't want to consider a probe as having observed WebP since
-    // in theory the client should do the right thing when we fail to decode it.
-    // See https://developers.google.com/speed/webp/faq for details.
-    bool webp = result.mContentType.EqualsLiteral(IMAGE_WEBP);
-    bool webpProbe = false;
-    if (webp) {
-      // The probes from the example/library are all < 90 bytes. Round it up
-      // just in case.
-      const uint32_t kMaxProbeSize = 100;
-      if (closure.segmentSize < kMaxProbeSize &&
-          NS_FAILED(aURI->SchemeIs("data", &webpProbe))) {
-        webpProbe = false;
-      }
-
-      if (webpProbe) {
-        Telemetry::ScalarSet(Telemetry::ScalarID::IMAGES_WEBP_PROBE_OBSERVED,
-                             true);
-      } else {
-        Telemetry::ScalarSet(Telemetry::ScalarID::IMAGES_WEBP_CONTENT_OBSERVED,
-                             true);
-      }
-    }
-
-    if (!webpProbe) {
-      Telemetry::ScalarAdd(Telemetry::ScalarID::IMAGES_WEBP_CONTENT_FREQUENCY,
-                           webp ? NS_LITERAL_STRING("webp") :
-                                  NS_LITERAL_STRING("other"), 1);
-    }
   }
 
   nsCOMPtr<nsIChannel> chan(do_QueryInterface(aRequest));
   if (result.mContentType.IsEmpty()) {
     nsresult rv = chan ? chan->GetContentType(result.mContentType)
                        : NS_ERROR_FAILURE;
     if (NS_FAILED(rv)) {
       MOZ_LOG(gImgLog,
@@ -1256,17 +1216,16 @@ sniff_mimetype_callback(nsIInputStream* 
                         uint32_t toOffset,
                         uint32_t count,
                         uint32_t* writeCount)
 {
   mimetype_closure* closure = static_cast<mimetype_closure*>(data);
 
   NS_ASSERTION(closure, "closure is null!");
 
-  closure->segmentSize = count;
   if (count > 0) {
     imgLoader::GetMimeTypeFromContent(fromRawSegment, count, *closure->newType);
   }
 
   *writeCount = 0;
   return NS_ERROR_FAILURE;
 }
 
--- a/image/test/gtest/Common.cpp
+++ b/image/test/gtest/Common.cpp
@@ -50,25 +50,17 @@ AutoInitializeImageLib::AutoInitializeIm
   EXPECT_TRUE(imgTools != nullptr);
 
   // Ensure gfxPlatform is initialized.
   gfxPlatform::GetPlatform();
 
   // Depending on initialization order, it is possible that our pref changes
   // have not taken effect yet because there are pending gfx-related events on
   // the main thread.
-  nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
-  EXPECT_TRUE(mainThread != nullptr);
-
-  bool processed;
-  do {
-    processed = false;
-    nsresult rv = mainThread->ProcessNextEvent(false, &processed);
-    EXPECT_TRUE(NS_SUCCEEDED(rv));
-  } while (processed);
+  SpinPendingEvents();
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 // General Helpers
 ///////////////////////////////////////////////////////////////////////////////
 
 // These macros work like gtest's ASSERT_* macros, except that they can be used
 // in functions that return values.
@@ -97,16 +89,30 @@ AutoInitializeImageLib::AutoInitializeIm
   }
 
 #define ASSERT_LT_OR_RETURN(a, b, rv) \
   EXPECT_LT(a, b);                    \
   if (!((a) < (b))) {                 \
     return rv;                        \
   }
 
+void
+SpinPendingEvents()
+{
+  nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
+  EXPECT_TRUE(mainThread != nullptr);
+
+  bool processed;
+  do {
+    processed = false;
+    nsresult rv = mainThread->ProcessNextEvent(false, &processed);
+    EXPECT_TRUE(NS_SUCCEEDED(rv));
+  } while (processed);
+}
+
 already_AddRefed<nsIInputStream>
 LoadFile(const char* aRelativePath)
 {
   nsresult rv;
 
   nsCOMPtr<nsIProperties> dirService =
     do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
   ASSERT_TRUE_OR_RETURN(dirService != nullptr, nullptr);
--- a/image/test/gtest/Common.h
+++ b/image/test/gtest/Common.h
@@ -128,16 +128,19 @@ struct BGRAColor
  * so can result in strange, non-deterministic failures.
  */
 class AutoInitializeImageLib
 {
 public:
   AutoInitializeImageLib();
 };
 
+/// Spins on the main thread to process any pending events.
+void SpinPendingEvents();
+
 /// Loads a file from the current directory. @return an nsIInputStream for it.
 already_AddRefed<nsIInputStream> LoadFile(const char* aRelativePath);
 
 /**
  * @returns true if every pixel of @aSurface is @aColor.
  *
  * If @aFuzz is nonzero, a tolerance of @aFuzz is allowed in each color
  * component. This may be necessary for tests that involve JPEG images or
--- a/image/test/gtest/TestDecoders.cpp
+++ b/image/test/gtest/TestDecoders.cpp
@@ -29,16 +29,21 @@
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::image;
 
 static already_AddRefed<SourceSurface>
 CheckDecoderState(const ImageTestCase& aTestCase, Decoder* aDecoder)
 {
+  // Decoder should match what we asked for in the MIME type.
+  EXPECT_NE(aDecoder->GetType(), DecoderType::UNKNOWN);
+  EXPECT_EQ(aDecoder->GetType(),
+            DecoderFactory::GetDecoderType(aTestCase.mMimeType));
+
   EXPECT_TRUE(aDecoder->GetDecodeDone());
   EXPECT_EQ(bool(aTestCase.mFlags & TEST_CASE_HAS_ERROR),
             aDecoder->HasError());
 
   // Verify that the decoder made the expected progress.
   Progress progress = aDecoder->TakeProgress();
   EXPECT_EQ(bool(aTestCase.mFlags & TEST_CASE_HAS_ERROR),
             bool(progress & FLAG_HAS_ERROR));
@@ -114,33 +119,86 @@ void WithSingleChunkDecode(const ImageTe
   // Create a decoder.
   DecoderType decoderType =
     DecoderFactory::GetDecoderType(aTestCase.mMimeType);
   RefPtr<Decoder> decoder =
     DecoderFactory::CreateAnonymousDecoder(decoderType, sourceBuffer, aOutputSize,
                                            DecoderFlags::FIRST_FRAME_ONLY,
                                            DefaultSurfaceFlags());
   ASSERT_TRUE(decoder != nullptr);
-  RefPtr<IDecodingTask> task = new AnonymousDecodingTask(WrapNotNull(decoder));
+  RefPtr<IDecodingTask> task =
+    new AnonymousDecodingTask(WrapNotNull(decoder), /* aResumable */ false);
 
   // Run the full decoder synchronously.
   task->Run();
 
   // Call the lambda to verify the expected results.
   aResultChecker(decoder);
 }
 
 static void
 CheckDecoderSingleChunk(const ImageTestCase& aTestCase)
 {
   WithSingleChunkDecode(aTestCase, Nothing(), [&](Decoder* aDecoder) {
     CheckDecoderResults(aTestCase, aDecoder);
   });
 }
 
+template <typename Func>
+void WithDelayedChunkDecode(const ImageTestCase& aTestCase,
+                           const Maybe<IntSize>& aOutputSize,
+                           Func aResultChecker)
+{
+  nsCOMPtr<nsIInputStream> inputStream = LoadFile(aTestCase.mPath);
+  ASSERT_TRUE(inputStream != nullptr);
+
+  // Figure out how much data we have.
+  uint64_t length;
+  nsresult rv = inputStream->Available(&length);
+  ASSERT_TRUE(NS_SUCCEEDED(rv));
+
+  // Prepare an empty SourceBuffer.
+  auto sourceBuffer = MakeNotNull<RefPtr<SourceBuffer>>();
+
+  // Create a decoder.
+  DecoderType decoderType =
+    DecoderFactory::GetDecoderType(aTestCase.mMimeType);
+  RefPtr<Decoder> decoder =
+    DecoderFactory::CreateAnonymousDecoder(decoderType, sourceBuffer, aOutputSize,
+                                           DecoderFlags::FIRST_FRAME_ONLY,
+                                           DefaultSurfaceFlags());
+  ASSERT_TRUE(decoder != nullptr);
+  RefPtr<IDecodingTask> task =
+    new AnonymousDecodingTask(WrapNotNull(decoder), /* aResumable */ true);
+
+  // Run the full decoder synchronously. It should now be waiting on
+  // the iterator to yield some data since we haven't written anything yet.
+  task->Run();
+
+  // Writing all of the data should wake up the decoder to complete.
+  sourceBuffer->ExpectLength(length);
+  rv = sourceBuffer->AppendFromInputStream(inputStream, length);
+  ASSERT_TRUE(NS_SUCCEEDED(rv));
+  sourceBuffer->Complete(NS_OK);
+
+  // It would have gotten posted to the main thread to avoid mutex contention.
+  SpinPendingEvents();
+
+  // Call the lambda to verify the expected results.
+  aResultChecker(decoder);
+}
+
+static void
+CheckDecoderDelayedChunk(const ImageTestCase& aTestCase)
+{
+  WithDelayedChunkDecode(aTestCase, Nothing(), [&](Decoder* aDecoder) {
+    CheckDecoderResults(aTestCase, aDecoder);
+  });
+}
+
 static void
 CheckDecoderMultiChunk(const ImageTestCase& aTestCase)
 {
   nsCOMPtr<nsIInputStream> inputStream = LoadFile(aTestCase.mPath);
   ASSERT_TRUE(inputStream != nullptr);
 
   // Figure out how much data we have.
   uint64_t length;
@@ -152,17 +210,18 @@ CheckDecoderMultiChunk(const ImageTestCa
   sourceBuffer->ExpectLength(length);
   DecoderType decoderType =
     DecoderFactory::GetDecoderType(aTestCase.mMimeType);
   RefPtr<Decoder> decoder =
     DecoderFactory::CreateAnonymousDecoder(decoderType, sourceBuffer, Nothing(),
                                            DecoderFlags::FIRST_FRAME_ONLY,
                                            DefaultSurfaceFlags());
   ASSERT_TRUE(decoder != nullptr);
-  RefPtr<IDecodingTask> task = new AnonymousDecodingTask(WrapNotNull(decoder));
+  RefPtr<IDecodingTask> task =
+    new AnonymousDecodingTask(WrapNotNull(decoder), /* aResumable */ false);
 
   for (uint64_t read = 0; read < length ; ++read) {
     uint64_t available = 0;
     rv = inputStream->Available(&available);
     ASSERT_TRUE(available > 0);
     ASSERT_TRUE(NS_SUCCEEDED(rv));
 
     rv = sourceBuffer->AppendFromInputStream(inputStream, 1);
@@ -576,76 +635,101 @@ protected:
   AutoInitializeImageLib mInit;
 };
 
 TEST_F(ImageDecoders, PNGSingleChunk)
 {
   CheckDecoderSingleChunk(GreenPNGTestCase());
 }
 
+TEST_F(ImageDecoders, PNGDelayedChunk)
+{
+  CheckDecoderDelayedChunk(GreenPNGTestCase());
+}
+
 TEST_F(ImageDecoders, PNGMultiChunk)
 {
   CheckDecoderMultiChunk(GreenPNGTestCase());
 }
 
 TEST_F(ImageDecoders, PNGDownscaleDuringDecode)
 {
   CheckDownscaleDuringDecode(DownscaledPNGTestCase());
 }
 
 TEST_F(ImageDecoders, GIFSingleChunk)
 {
   CheckDecoderSingleChunk(GreenGIFTestCase());
 }
 
+TEST_F(ImageDecoders, GIFDelayedChunk)
+{
+  CheckDecoderDelayedChunk(GreenGIFTestCase());
+}
+
 TEST_F(ImageDecoders, GIFMultiChunk)
 {
   CheckDecoderMultiChunk(GreenGIFTestCase());
 }
 
 TEST_F(ImageDecoders, GIFDownscaleDuringDecode)
 {
   CheckDownscaleDuringDecode(DownscaledGIFTestCase());
 }
 
 TEST_F(ImageDecoders, JPGSingleChunk)
 {
   CheckDecoderSingleChunk(GreenJPGTestCase());
 }
 
+TEST_F(ImageDecoders, JPGDelayedChunk)
+{
+  CheckDecoderDelayedChunk(GreenJPGTestCase());
+}
+
 TEST_F(ImageDecoders, JPGMultiChunk)
 {
   CheckDecoderMultiChunk(GreenJPGTestCase());
 }
 
 TEST_F(ImageDecoders, JPGDownscaleDuringDecode)
 {
   CheckDownscaleDuringDecode(DownscaledJPGTestCase());
 }
 
 TEST_F(ImageDecoders, BMPSingleChunk)
 {
   CheckDecoderSingleChunk(GreenBMPTestCase());
 }
 
+TEST_F(ImageDecoders, BMPDelayedChunk)
+{
+  CheckDecoderDelayedChunk(GreenBMPTestCase());
+}
+
 TEST_F(ImageDecoders, BMPMultiChunk)
 {
   CheckDecoderMultiChunk(GreenBMPTestCase());
 }
 
 TEST_F(ImageDecoders, BMPDownscaleDuringDecode)
 {
   CheckDownscaleDuringDecode(DownscaledBMPTestCase());
 }
 
 TEST_F(ImageDecoders, ICOSingleChunk)
 {
   CheckDecoderSingleChunk(GreenICOTestCase());
 }
 
+TEST_F(ImageDecoders, ICODelayedChunk)
+{
+  CheckDecoderDelayedChunk(GreenICOTestCase());
+}
+
 TEST_F(ImageDecoders, ICOMultiChunk)
 {
   CheckDecoderMultiChunk(GreenICOTestCase());
 }
 
 TEST_F(ImageDecoders, ICODownscaleDuringDecode)
 {
   CheckDownscaleDuringDecode(DownscaledICOTestCase());
@@ -656,31 +740,41 @@ TEST_F(ImageDecoders, ICOWithANDMaskDown
   CheckDownscaleDuringDecode(DownscaledTransparentICOWithANDMaskTestCase());
 }
 
 TEST_F(ImageDecoders, IconSingleChunk)
 {
   CheckDecoderSingleChunk(GreenIconTestCase());
 }
 
+TEST_F(ImageDecoders, IconDelayedChunk)
+{
+  CheckDecoderDelayedChunk(GreenIconTestCase());
+}
+
 TEST_F(ImageDecoders, IconMultiChunk)
 {
   CheckDecoderMultiChunk(GreenIconTestCase());
 }
 
 TEST_F(ImageDecoders, IconDownscaleDuringDecode)
 {
   CheckDownscaleDuringDecode(DownscaledIconTestCase());
 }
 
 TEST_F(ImageDecoders, WebPSingleChunk)
 {
   CheckDecoderSingleChunk(GreenWebPTestCase());
 }
 
+TEST_F(ImageDecoders, WebPDelayedChunk)
+{
+  CheckDecoderDelayedChunk(GreenWebPTestCase());
+}
+
 TEST_F(ImageDecoders, WebPMultiChunk)
 {
   CheckDecoderMultiChunk(GreenWebPTestCase());
 }
 
 TEST_F(ImageDecoders, WebPDownscaleDuringDecode)
 {
   CheckDownscaleDuringDecode(DownscaledWebPTestCase());
--- a/image/test/gtest/TestMetadata.cpp
+++ b/image/test/gtest/TestMetadata.cpp
@@ -55,17 +55,18 @@ CheckMetadata(const ImageTestCase& aTest
   sourceBuffer->Complete(NS_OK);
 
   // Create a metadata decoder.
   DecoderType decoderType =
     DecoderFactory::GetDecoderType(aTestCase.mMimeType);
   RefPtr<Decoder> decoder =
     DecoderFactory::CreateAnonymousMetadataDecoder(decoderType, sourceBuffer);
   ASSERT_TRUE(decoder != nullptr);
-  RefPtr<IDecodingTask> task = new AnonymousDecodingTask(WrapNotNull(decoder));
+  RefPtr<IDecodingTask> task =
+    new AnonymousDecodingTask(WrapNotNull(decoder), /* aResumable */ false);
 
   if (aBMPWithinICO == BMPWithinICO::YES) {
     static_cast<nsBMPDecoder*>(decoder.get())->SetIsWithinICO();
   }
 
   // Run the metadata decoder synchronously.
   task->Run();
 
@@ -106,17 +107,17 @@ CheckMetadata(const ImageTestCase& aTest
             bool(metadataProgress & FLAG_IS_ANIMATED));
 
   // Create a full decoder, so we can compare the result.
   decoder =
     DecoderFactory::CreateAnonymousDecoder(decoderType, sourceBuffer, Nothing(),
                                            DecoderFlags::FIRST_FRAME_ONLY,
                                            DefaultSurfaceFlags());
   ASSERT_TRUE(decoder != nullptr);
-  task = new AnonymousDecodingTask(WrapNotNull(decoder));
+  task = new AnonymousDecodingTask(WrapNotNull(decoder), /* aResumable */ false);
 
   if (aBMPWithinICO == BMPWithinICO::YES) {
     static_cast<nsBMPDecoder*>(decoder.get())->SetIsWithinICO();
   }
 
   // Run the full decoder synchronously.
   task->Run();
 
--- a/media/libwebp/src/dsp/moz.build
+++ b/media/libwebp/src/dsp/moz.build
@@ -31,17 +31,18 @@ if CONFIG['CPU_ARCH'] == 'arm' and CONFI
         'rescaler_neon.c',
         'upsampling_neon.c',
         'yuv_neon.c',
     ]
     DEFINES['WEBP_HAVE_NEON'] = 1;
     for f in SOURCES:
       if f.endswith('neon.c'):
         SOURCES[f].flags += CONFIG['NEON_FLAGS']
-elif CONFIG['CPU_ARCH'] == 'aarch64':
+elif CONFIG['CPU_ARCH'] == 'aarch64' and CONFIG['OS_ARCH'] != 'WINNT':
+    # Bug 1504017 tracks re-enabling this for Windows.
     SOURCES += [
         'alpha_processing_neon.c',
         'dec_neon.c',
         'filters_neon.c',
         'lossless_neon.c',
         'rescaler_neon.c',
         'upsampling_neon.c',
         'yuv_neon.c',
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt
@@ -200,17 +200,16 @@ class NavigationDelegateTest : BaseSessi
                 object : Callbacks.TrackingProtectionDelegate {
             @AssertCalled(false)
             override fun onTrackerBlocked(session: GeckoSession, uri: String,
                                           categories: Int) {
             }
         })
     }
 
-    @Ignore
     @Test fun redirectLoad() {
         val redirectUri = if (sessionRule.env.isAutomation) {
             "http://example.org/tests/robocop/robocop_blank_02.html"
         } else {
             "http://jigsaw.w3.org/HTTP/300/Overview.html"
         }
         val uri = if (sessionRule.env.isAutomation) {
             "http://example.org/tests/robocop/simple_redirect.sjs?$redirectUri"
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5276,20 +5276,16 @@ pref("io.activity.enabled", false);
 pref("io.activity.intervalMilliseconds", 0);
 
 // If true, reuse the same global for (almost) everything loaded by the component
 // loader (JS components, JSMs, etc). This saves memory, but makes it possible
 // for the scripts to interfere with each other.  A restart is required for this
 // to take effect.
 pref("jsloader.shareGlobal", true);
 
-// When we're asked to take a screenshot, don't wait more than 2000ms for the
-// event loop to become idle before actually taking the screenshot.
-pref("dom.browserElement.maxScreenshotDelayMS", 2000);
-
 // Whether we should show the placeholder when the element is focused but empty.
 pref("dom.placeholder.show_on_focus", true);
 
 // WebVR is enabled by default in beta and release for Windows and for all
 // platforms in nightly and aurora.
 #if defined(XP_WIN) || defined(XP_MACOSX) || !defined(RELEASE_OR_BETA)
 pref("dom.vr.enabled", true);
 #else
--- a/python/mozrelease/mozrelease/buglist_creator.py
+++ b/python/mozrelease/mozrelease/buglist_creator.py
@@ -237,17 +237,17 @@ Task group: https://tools.taskcluster.ne
     if product in {"fennec"}:
         subject_prefix = "[mobile] "
     if product in {"firefox", "devedition"}:
         subject_prefix = "[desktop] "
 
     subject = '{} Build of {} {} build {}'.format(subject_prefix, product, version, build_number)
 
     notify_options = {}
-    if 'TASKCLUSTER_BASE_URL' in os.environ:
+    if 'TASKCLUSTER_PROXY_URL' in os.environ:
         base_url = os.environ['TASKCLUSTER_PROXY_URL'].rstrip('/')
         notify_options['baseUrl'] = '{}/notify/v1'.format(base_url)
     notify = Notify(notify_options)
     for address in addresses:
         notify.email({
             'address': address,
             'subject': subject,
             'content': content,
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -1724,63 +1724,16 @@ gfx.omtp:
     kind: uint
     expires: "66"
     notification_emails:
       - gfx-telemetry-alerts@mozilla.com
       - rhunt@mozilla.com
     record_in_processes:
       - 'content'
 
-images.webp:
-  probe_observed:
-    bug_numbers:
-      - 1472145
-    description: >
-      Whether we received a probe detecting our WebP image support.
-    kind: boolean
-    expires: "65"
-    notification_emails:
-      - gfx-telemetry-alerts@mozilla.com
-      - aosmond@mozilla.com
-    release_channel_collection: opt-out
-    record_in_processes:
-      - 'main'
-      - 'content'
-
-  content_observed:
-    bug_numbers:
-      - 1472145
-    description: >
-      Whether we received a request to decode a WebP image, excluding probes.
-    kind: boolean
-    expires: "65"
-    notification_emails:
-      - gfx-telemetry-alerts@mozilla.com
-      - aosmond@mozilla.com
-    release_channel_collection: opt-out
-    record_in_processes:
-      - 'main'
-      - 'content'
-
-  content_frequency:
-    bug_numbers:
-      - 1472145
-    description: >
-      How many image requests are WebP images, excluding probes.
-    kind: uint
-    keyed: true
-    expires: "65"
-    notification_emails:
-      - gfx-telemetry-alerts@mozilla.com
-      - aosmond@mozilla.com
-    release_channel_collection: opt-out
-    record_in_processes:
-      - 'main'
-      - 'content'
-
 # The following section contains the form autofill related scalars.
 formautofill:
   availability:
     bug_numbers:
       - 1386959
     description: A boolean sent once per session to represent whether the formautofill is available in the build
     expires: never
     kind: boolean
--- a/uriloader/base/nsDocLoader.cpp
+++ b/uriloader/base/nsDocLoader.cpp
@@ -29,16 +29,18 @@
 #include "nsIScriptSecurityManager.h"
 
 #include "nsITransport.h"
 #include "nsISocketTransport.h"
 #include "nsIDocShell.h"
 #include "nsIDocument.h"
 #include "nsPresContext.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
+#include "nsILoadURIDelegate.h"
+#include "nsIBrowserDOMWindow.h"
 
 using mozilla::dom::ContentBlockingLog;
 using mozilla::DebugOnly;
 using mozilla::LogLevel;
 
 //
 // Log module for nsIDocumentLoader logging...
 //
@@ -1419,16 +1421,46 @@ int64_t nsDocLoader::CalculateMaxProgres
   return max;
 }
 
 NS_IMETHODIMP nsDocLoader::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
                                                   nsIChannel *aNewChannel,
                                                   uint32_t aFlags,
                                                   nsIAsyncVerifyRedirectCallback *cb)
 {
+  if (aFlags &
+      (nsIChannelEventSink::REDIRECT_TEMPORARY |
+       nsIChannelEventSink::REDIRECT_PERMANENT)) {
+    nsCOMPtr<nsIDocShell> docShell =
+      do_QueryInterface(static_cast<nsIRequestObserver*>(this));
+
+    nsCOMPtr<nsILoadURIDelegate> delegate;
+    if (docShell) {
+      docShell->GetLoadURIDelegate(getter_AddRefs(delegate));
+    }
+
+    nsCOMPtr<nsIURI> newURI;
+    if (delegate) {
+      // No point in getting the URI if we don't have a LoadURIDelegate.
+      aNewChannel->GetURI(getter_AddRefs(newURI));
+    }
+
+    if (newURI) {
+      const int where = nsIBrowserDOMWindow::OPEN_CURRENTWINDOW;
+      bool loadURIHandled = false;
+      nsresult rv = delegate->LoadURI(newURI, where, /* flags */ 0,
+                                      /* triggering principal */ nullptr,
+                                      &loadURIHandled);
+      if (NS_SUCCEEDED(rv) && loadURIHandled) {
+        cb->OnRedirectVerifyCallback(NS_OK);
+        return NS_OK;
+      }
+    }
+  }
+
   if (aOldChannel)
   {
     nsLoadFlags loadFlags = 0;
     int32_t stateFlags = nsIWebProgressListener::STATE_REDIRECTING |
                          nsIWebProgressListener::STATE_IS_REQUEST;
 
     aOldChannel->GetLoadFlags(&loadFlags);
     // If the document channel is being redirected, then indicate that the