merge mozilla-inbound to mozilla-central a=merge
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 16 Dec 2015 12:01:46 +0100
changeset 311682 0babaa3edcf908c393b68a3dc2d1c2a2450c31ed
parent 311638 40038a66525f454aadc0f887bae55c6a60ef7290 (current diff)
parent 311681 c6fc9d77e86f07153d0e410bf43aafff33e53a45 (diff)
child 311689 f52b36d6bc1aeb421c58d39208e0a50625915cd7
child 311707 5fb09b81583111d48b827401905be0291a888094
child 311785 9e09307e619577c026ee52781ad611880448f53e
push id5703
push userraliiev@mozilla.com
push dateMon, 07 Mar 2016 14:18:41 +0000
treeherdermozilla-beta@31e373ad5b5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone46.0a1
first release with
nightly linux32
0babaa3edcf9 / 46.0a1 / 20151216030229 / files
nightly linux64
0babaa3edcf9 / 46.0a1 / 20151216030229 / files
nightly mac
0babaa3edcf9 / 46.0a1 / 20151216030229 / files
nightly win32
0babaa3edcf9 / 46.0a1 / 20151216030229 / files
nightly win64
0babaa3edcf9 / 46.0a1 / 20151216030229 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
merge mozilla-inbound to mozilla-central a=merge
--- a/browser/base/content/socialchat.xml
+++ b/browser/base/content/socialchat.xml
@@ -384,45 +384,51 @@
           return !!this.querySelector("[collapsed]");
         ]]></getter>
       </property>
 
       <property name="collapsedChildren">
         <getter><![CDATA[
           // A generator yielding all collapsed chatboxes, in the order in
           // which they should be restored.
-          let child = this.lastElementChild;
-          while (child) {
-            if (child.collapsed)
-              yield child;
-            child = child.previousElementSibling;
+          return function*() {
+            let child = this.lastElementChild;
+            while (child) {
+              if (child.collapsed)
+                yield child;
+              child = child.previousElementSibling;
+            }
           }
         ]]></getter>
       </property>
 
       <property name="visibleChildren">
         <getter><![CDATA[
           // A generator yielding all non-collapsed chatboxes.
-          let child = this.firstElementChild;
-          while (child) {
-            if (!child.collapsed)
-              yield child;
-            child = child.nextElementSibling;
+          return function*() {
+            let child = this.firstElementChild;
+            while (child) {
+              if (!child.collapsed)
+                yield child;
+              child = child.nextElementSibling;
+            }
           }
         ]]></getter>
       </property>
 
       <property name="collapsibleChildren">
         <getter><![CDATA[
           // A generator yielding all children which are able to be collapsed
           // in the order in which they should be collapsed.
           // (currently this is all visible ones other than the selected one.)
-          for (let child of this.visibleChildren)
-            if (child != this.selectedChat)
-              yield child;
+          return function*() {
+            for (let child of this.visibleChildren())
+              if (child != this.selectedChat)
+                yield child;
+          }
         ]]></getter>
       </property>
 
       <method name="_selectAnotherChat">
         <body><![CDATA[
           // Select a different chat (as the currently selected one is no
           // longer suitable as the selection - maybe it is being minimized or
           // closed.)  We only select non-minimized and non-collapsed chats,
@@ -622,39 +628,39 @@
         // So we go the more complicated but more efficient second option...
         let availWidth = this.getBoundingClientRect().width;
         let currentWidth = 0;
         if (!this.nub.collapsed) { // the nub is visible.
           if (!this.cachedWidthNub)
             this.cachedWidthNub = this.calcTotalWidthOf(this.nub);
           currentWidth += this.cachedWidthNub;
         }
-        for (let child of this.visibleChildren) {
+        for (let child of this.visibleChildren()) {
           currentWidth += this.getTotalChildWidth(child);
         }
 
         if (currentWidth > availWidth) {
           // we need to collapse some.
           let toCollapse = [];
-          for (let child of this.collapsibleChildren) {
+          for (let child of this.collapsibleChildren()) {
             if (currentWidth <= availWidth)
               break;
             toCollapse.push(child);
             currentWidth -= this.getTotalChildWidth(child);
           }
           if (toCollapse.length) {
             for (let child of toCollapse)
               this.collapseChat(child);
           }
         } else if (currentWidth < availWidth) {
           // we *might* be able to expand some - see how many.
           // XXX - if this was clever, it could know when removing the nub
           // leaves enough space to show all collapsed
           let toShow = [];
-          for (let child of this.collapsedChildren) {
+          for (let child of this.collapsedChildren()) {
             currentWidth += this.getTotalChildWidth(child);
             if (currentWidth > availWidth)
               break;
             toShow.push(child);
           }
           for (let child of toShow)
             this._showChat(child);
 
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -4022,30 +4022,30 @@
         <body><![CDATA[
           let json = aMessage.json;
           let browser = aMessage.target;
 
           switch (aMessage.name) {
             case "DOMTitleChanged": {
               let tab = this.getTabForBrowser(browser);
               if (!tab || tab.hasAttribute("pending"))
-                return;
+                return undefined;
               let titleChanged = this.setTabTitle(tab);
               if (titleChanged && !tab.selected && !tab.hasAttribute("busy"))
                 tab.setAttribute("titlechanged", "true");
               break;
             }
             case "DOMWindowClose": {
               if (this.tabs.length == 1) {
                 // We already did PermitUnload in the content process
                 // for this tab (the only one in the window). So we don't
                 // need to do it again for any tabs.
                 window.skipNextCanClose = true;
                 window.close();
-                return;
+                return undefined;
               }
 
               let tab = this.getTabForBrowser(browser);
               if (tab) {
                 // Skip running PermitUnload since it already happened in
                 // the content process.
                 this.removeTab(tab, {skipPermitUnload: true});
               }
@@ -4083,25 +4083,25 @@
               let event = gContextMenuContentData.event;
               popup.openPopupAtScreen(event.screenX, event.screenY, true);
               break;
             }
             case "DOMServiceWorkerFocusClient":
             case "DOMWebNotificationClicked": {
               let tab = this.getTabForBrowser(browser);
               if (!tab)
-                return;
+                return undefined;
               this.selectedTab = tab;
               window.focus();
               break;
             }
             case "Browser:Init": {
               let tab = this.getTabForBrowser(browser);
               if (!tab)
-                return;
+                return undefined;
 
               this._outerWindowIDBrowserMap.set(browser.outerWindowID, browser);
               browser.messageManager.sendAsyncMessage("Browser:AppTab", { isAppTab: tab.pinned })
               break;
             }
             case "Findbar:Keypress":
               if (!gFindBarInitialized) {
                 // If the find bar for this tab is not yet alive, change that,
@@ -5197,20 +5197,19 @@
         <parameter name="event"/>
         <body><![CDATA[
           var dt = event.dataTransfer;
           // Disallow dropping multiple items
           if (dt.mozItemCount > 1)
             return "none";
 
           var types = dt.mozTypesAt(0);
-          var sourceNode = null;
           // tabs are always added as the first type
           if (types[0] == TAB_DROP_TYPE) {
-            var sourceNode = dt.mozGetDataAt(TAB_DROP_TYPE, 0);
+            let sourceNode = dt.mozGetDataAt(TAB_DROP_TYPE, 0);
             if (sourceNode instanceof XULElement &&
                 sourceNode.localName == "tab" &&
                 sourceNode.ownerDocument.defaultView instanceof ChromeWindow &&
                 sourceNode.ownerDocument.documentElement.getAttribute("windowtype") == "navigator:browser" &&
                 sourceNode.ownerDocument.defaultView.gBrowser.tabContainer == sourceNode.parentNode) {
               // Do not allow transfering a private tab to a non-private window
               // and vice versa.
               if (PrivateBrowsingUtils.isWindowPrivate(window) !=
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -676,21 +676,19 @@
             popup.showImageColumn = this.showImageColumn;
 
             document.popupNode = null;
 
             const isRTL = getComputedStyle(this, "").direction == "rtl";
 
             var outerRect = this.getBoundingClientRect();
             var innerRect = this.inputField.getBoundingClientRect();
-            if (isRTL) {
-              var width = innerRect.right - outerRect.left;
-            } else {
-              var width = outerRect.right - innerRect.left;
-            }
+            let width = isRTL ?
+                        innerRect.right - outerRect.left :
+                        outerRect.right - innerRect.left;
             popup.setAttribute("width", width > 100 ? width : 100);
 
             var yOffset = outerRect.bottom - innerRect.bottom;
             popup.openPopup(this.inputField, "after_start", 0, yOffset, false, false);
           }
         ]]></body>
       </method>
 
--- a/dom/canvas/WebGLContextDraw.cpp
+++ b/dom/canvas/WebGLContextDraw.cpp
@@ -42,17 +42,16 @@ public:
     ~ScopedResolveTexturesForDraw();
 };
 
 ScopedResolveTexturesForDraw::ScopedResolveTexturesForDraw(WebGLContext* webgl,
                                                            const char* funcName,
                                                            bool* const out_error)
     : mWebGL(webgl)
 {
-    //typedef nsTArray<WebGLRefPtr<WebGLTexture>> TexturesT;
     typedef decltype(WebGLContext::mBound2DTextures) TexturesT;
 
     const auto fnResolveAll = [this, funcName](const TexturesT& textures)
     {
         const auto len = textures.Length();
         for (uint32_t texUnit = 0; texUnit < len; ++texUnit) {
             WebGLTexture* tex = textures[texUnit];
             if (!tex)
@@ -67,26 +66,27 @@ ScopedResolveTexturesForDraw::ScopedReso
 
             mWebGL->BindFakeBlack(texUnit, tex->Target(), fakeBlack);
             mRebindRequests.push_back({texUnit, tex});
         }
 
         return true;
     };
 
-    *out_error = false;
+    bool ok = true;
+    ok &= fnResolveAll(mWebGL->mBound2DTextures);
+    ok &= fnResolveAll(mWebGL->mBoundCubeMapTextures);
+    ok &= fnResolveAll(mWebGL->mBound3DTextures);
+    ok &= fnResolveAll(mWebGL->mBound2DArrayTextures);
 
-    *out_error |= !fnResolveAll(mWebGL->mBound2DTextures);
-    *out_error |= !fnResolveAll(mWebGL->mBoundCubeMapTextures);
-    *out_error |= !fnResolveAll(mWebGL->mBound3DTextures);
-    *out_error |= !fnResolveAll(mWebGL->mBound2DArrayTextures);
-
-    if (*out_error) {
+    if (!ok) {
         mWebGL->ErrorOutOfMemory("%s: Failed to resolve textures for draw.", funcName);
     }
+
+    *out_error = !ok;
 }
 
 ScopedResolveTexturesForDraw::~ScopedResolveTexturesForDraw()
 {
     if (!mRebindRequests.size())
         return;
 
     gl::GLContext* gl = mWebGL->gl;
--- a/dom/canvas/test/_webgl-conformance.ini
+++ b/dom/canvas/test/_webgl-conformance.ini
@@ -517,17 +517,17 @@ skip-if = (os == 'b2g')
 [webgl-conformance/_wrappers/test_conformance__context__context-type-test.html]
 [webgl-conformance/_wrappers/test_conformance__context__incorrect-context-object-behaviour.html]
 [webgl-conformance/_wrappers/test_conformance__context__methods.html]
 [webgl-conformance/_wrappers/test_conformance__context__premultiplyalpha-test.html]
 [webgl-conformance/_wrappers/test_conformance__context__resource-sharing-test.html]
 [webgl-conformance/_wrappers/test_conformance__extensions__oes-standard-derivatives.html]
 [webgl-conformance/_wrappers/test_conformance__extensions__ext-texture-filter-anisotropic.html]
 [webgl-conformance/_wrappers/test_conformance__extensions__oes-texture-float.html]
-fail-if = (os == 'linux')
+skip-if = (os == 'linux')
 [webgl-conformance/_wrappers/test_conformance__extensions__oes-vertex-array-object.html]
 [webgl-conformance/_wrappers/test_conformance__extensions__webgl-debug-renderer-info.html]
 [webgl-conformance/_wrappers/test_conformance__extensions__webgl-debug-shaders.html]
 [webgl-conformance/_wrappers/test_conformance__extensions__webgl-compressed-texture-etc1.html]
 [webgl-conformance/_wrappers/test_conformance__extensions__webgl-compressed-texture-s3tc.html]
 [webgl-conformance/_wrappers/test_conformance__extensions__ext-sRGB.html]
 [webgl-conformance/_wrappers/test_conformance__extensions__ext-shader-texture-lod.html]
 [webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function.html]
@@ -692,16 +692,17 @@ fail-if = (os == 'linux')
 [webgl-conformance/_wrappers/test_conformance__glsl__reserved__webgl_struct.vert.html]
 [webgl-conformance/_wrappers/test_conformance__glsl__reserved__webgl_variable.vert.html]
 [webgl-conformance/_wrappers/test_conformance__glsl__variables__gl-fragcoord.html]
 [webgl-conformance/_wrappers/test_conformance__glsl__variables__gl-frontfacing.html]
 [webgl-conformance/_wrappers/test_conformance__glsl__variables__gl-pointcoord.html]
 [webgl-conformance/_wrappers/test_conformance__limits__gl-min-attribs.html]
 [webgl-conformance/_wrappers/test_conformance__limits__gl-max-texture-dimensions.html]
 [webgl-conformance/_wrappers/test_conformance__limits__gl-min-textures.html]
+skip-if = (os == 'linux')
 [webgl-conformance/_wrappers/test_conformance__limits__gl-min-uniforms.html]
 [webgl-conformance/_wrappers/test_conformance__misc__bad-arguments-test.html]
 [webgl-conformance/_wrappers/test_conformance__misc__error-reporting.html]
 [webgl-conformance/_wrappers/test_conformance__misc__instanceof-test.html]
 [webgl-conformance/_wrappers/test_conformance__misc__invalid-passed-params.html]
 skip-if = (os == 'android') || (os == 'b2g') || (os == 'linux')
 [webgl-conformance/_wrappers/test_conformance__misc__is-object.html]
 [webgl-conformance/_wrappers/test_conformance__misc__null-object-behaviour.html]
@@ -765,24 +766,25 @@ skip-if = (os == 'android') || (os == 'b
 [webgl-conformance/_wrappers/test_conformance__textures__tex-sub-image-2d-bad-args.html]
 [webgl-conformance/_wrappers/test_conformance__textures__tex-sub-image-2d.html]
 [webgl-conformance/_wrappers/test_conformance__textures__texparameter-test.html]
 [webgl-conformance/_wrappers/test_conformance__textures__texture-active-bind-2.html]
 [webgl-conformance/_wrappers/test_conformance__textures__texture-active-bind.html]
 [webgl-conformance/_wrappers/test_conformance__textures__texture-complete.html]
 [webgl-conformance/_wrappers/test_conformance__textures__texture-formats-test.html]
 [webgl-conformance/_wrappers/test_conformance__textures__texture-mips.html]
+skip-if = (os == 'linux')
 [webgl-conformance/_wrappers/test_conformance__textures__texture-npot-video.html]
 skip-if = (os == 'android') || (os == 'win')
 [webgl-conformance/_wrappers/test_conformance__textures__texture-npot.html]
 skip-if = os == 'android'
 [webgl-conformance/_wrappers/test_conformance__textures__texture-size.html]
 skip-if = os == 'android'
 [webgl-conformance/_wrappers/test_conformance__textures__texture-size-cube-maps.html]
-skip-if = os == 'android'
+skip-if = (os == 'android') || (os == 'linux')
 [webgl-conformance/_wrappers/test_conformance__textures__texture-transparent-pixels-initialized.html]
 [webgl-conformance/_wrappers/test_conformance__typedarrays__array-buffer-crash.html]
 [webgl-conformance/_wrappers/test_conformance__typedarrays__array-buffer-view-crash.html]
 [webgl-conformance/_wrappers/test_conformance__typedarrays__array-unit-tests.html]
 [webgl-conformance/_wrappers/test_conformance__uniforms__gl-uniform-arrays.html]
 [webgl-conformance/_wrappers/test_conformance__uniforms__gl-uniform-bool.html]
 [webgl-conformance/_wrappers/test_conformance__uniforms__gl-uniformmatrix4fv.html]
 [webgl-conformance/_wrappers/test_conformance__uniforms__gl-unknown-uniform.html]
--- a/dom/canvas/test/webgl-conformance/mochitest-errata.ini
+++ b/dom/canvas/test/webgl-conformance/mochitest-errata.ini
@@ -78,17 +78,18 @@ skip-if = os == 'android'
 [_wrappers/test_conformance__renderbuffers__framebuffer-object-attachment.html]
 # Crashes on Android.
 skip-if = os == 'android'
 [_wrappers/test_conformance__textures__texture-size.html]
 # Crashes on Android 4.0.
 skip-if = os == 'android'
 [_wrappers/test_conformance__textures__texture-size-cube-maps.html]
 # Crashes on Android 4.0.
-skip-if = os == 'android'
+# remove linux flag when bug 1220658 is resolved as this is unexpected-pass
+skip-if = (os == 'android') || (os == 'linux')
 [_wrappers/test_conformance__textures__texture-npot.html]
 # Intermittent fail on Android 4.0.
 skip-if = os == 'android'
 
 ########################################################################
 # B2G
 [_wrappers/test_conformance__context__context-attributes-alpha-depth-stencil-antialias.html]
 # Asserts on 'B2G ICS Emulator Debug'.
@@ -96,17 +97,24 @@ skip-if = (os == 'b2g')
 [_wrappers/test_conformance__textures__tex-image-and-uniform-binding-bugs.html]
 # Intermittently asserts on 'B2G ICS Emulator Debug'.
 skip-if = (os == 'b2g')
 
 ########################################################################
 # Linux
 [_wrappers/test_conformance__extensions__oes-texture-float.html]
 # Failures after enabling color_buffer_[half_]float.
-fail-if = (os == 'linux')
+# remove when bug 1220658 is resolved as this is unexpected-pass.
+skip-if = (os == 'linux')
+[_wrappers/test_conformance__textures__texture-mips.html]
+# remove when bug 1220658 is resolved as this is unexpected-pass.
+skip-if = (os == 'linux')
+[_wrappers/test_conformance__limits__gl-min-textures.html]
+# mesa upgrade issues or task cluster issues- we just need it green; bug 1220658
+skip-if = (os == 'linux')
 
 ########################################################################
 # Mac
 [_wrappers/test_conformance__canvas__drawingbuffer-static-canvas-test.html]
 # Intermittent crash on OSX.
 skip-if = os == 'mac'
 [_wrappers/test_conformance__canvas__viewport-unchanged-upon-resize.html]
 # New OSX r7 machines and 10.10.5 is causing perma failure (bug 1216549)
--- a/gfx/gl/GLBlitHelper.cpp
+++ b/gfx/gl/GLBlitHelper.cpp
@@ -104,21 +104,23 @@ GLBlitHelper::InitTexQuadProgram(BlitTyp
             vTexCoord = aPosition;                    \n\
             vTexCoord.y = abs(vTexCoord.y - uYflip);  \n\
             vec2 vertPos = aPosition * 2.0 - 1.0;     \n\
             gl_Position = vec4(vertPos, 0.0, 1.0);    \n\
         }                                             \n\
     ";
 
     const char kTex2DBlit_FragShaderSource[] = "\
+        #ifdef GL_ES                                        \n\
         #ifdef GL_FRAGMENT_PRECISION_HIGH                   \n\
             precision highp float;                          \n\
         #else                                               \n\
             precision mediump float;                        \n\
         #endif                                              \n\
+        #endif                                              \n\
         uniform sampler2D uTexUnit;                         \n\
                                                             \n\
         varying vec2 vTexCoord;                             \n\
                                                             \n\
         void main(void)                                     \n\
         {                                                   \n\
             gl_FragColor = texture2D(uTexUnit, vTexCoord);  \n\
         }                                                   \n\
--- a/gfx/layers/client/TiledContentClient.cpp
+++ b/gfx/layers/client/TiledContentClient.cpp
@@ -50,17 +50,18 @@ static void DrawDebugOverlay(mozilla::gf
   c.Rectangle(gfxRect(0, 0, width, height));
   c.Stroke();
 
   // Build tile description
   std::stringstream ss;
   ss << x << ", " << y;
 
   // Draw text using cairo toy text API
-  cairo_t* cr = c.GetCairo();
+  // XXX: this drawing will silently fail if |dt| doesn't have a Cairo backend
+  cairo_t* cr = gfxContext::RefCairo(dt);
   cairo_set_font_size(cr, 25);
   cairo_text_extents_t extents;
   cairo_text_extents(cr, ss.str().c_str(), &extents);
 
   int textWidth = extents.width + 6;
 
   c.NewPath();
   c.SetDeviceColor(Color(0.f, 0.f, 0.f));
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -1,10 +1,11 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=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 <math.h>
 
 #include "mozilla/Alignment.h"
 
 #include "cairo.h"
@@ -63,17 +64,16 @@ PatternFromState::operator mozilla::gfx:
   ColorPattern(state.color);
   return *mPattern;
 }
 
 
 gfxContext::gfxContext(DrawTarget *aTarget, const Point& aDeviceOffset)
   : mPathIsRect(false)
   , mTransformChanged(false)
-  , mRefCairo(nullptr)
   , mDT(aTarget)
   , mOriginalDT(aTarget)
 {
   MOZ_ASSERT(aTarget, "Don't create a gfxContext without a DrawTarget");
 
   MOZ_COUNT_CTOR(gfxContext);
 
   mStateStack.SetLength(1);
@@ -93,19 +93,16 @@ gfxContext::ContextForDrawTarget(DrawTar
   Matrix transform = aTarget->GetTransform();
   RefPtr<gfxContext> result = new gfxContext(aTarget);
   result->SetMatrix(ThebesMatrix(transform));
   return result.forget();
 }
 
 gfxContext::~gfxContext()
 {
-  if (mRefCairo) {
-    cairo_destroy(mRefCairo);
-  }
   for (int i = mStateStack.Length() - 1; i >= 0; i--) {
     for (unsigned int c = 0; c < mStateStack[i].pushedClips.Length(); c++) {
       mDT->PopClip();
     }
   }
   mDT->Flush();
   MOZ_COUNT_DTOR(gfxContext);
 }
@@ -127,35 +124,48 @@ gfxContext::CurrentSurface(gfxFloat *dx,
 
   if (dx && dy) {
     *dx = *dy = 0;
   }
   // An Azure context doesn't have a surface backing it.
   return nullptr;
 }
 
-cairo_t *
-gfxContext::GetCairo()
+static void
+DestroyRefCairo(void* aData)
+{
+  cairo_t* refCairo = static_cast<cairo_t*>(aData);
+  MOZ_ASSERT(refCairo);
+  cairo_destroy(refCairo);
+}
+
+/* static */ cairo_t *
+gfxContext::RefCairo(DrawTarget* aDT)
 {
-  if (mDT->GetBackendType() == BackendType::CAIRO) {
-    cairo_t *ctx =
-      (cairo_t*)mDT->GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT);
-    if (ctx) {
-      return ctx;
+  // DrawTargets that don't use a Cairo backend can be given a 1x1 "reference"
+  // |cairo_t*|, stored in the DrawTarget's user data, for doing font-related
+  // operations.
+  static UserDataKey sRefCairo;
+
+  cairo_t* refCairo = nullptr;
+  if (aDT->GetBackendType() == BackendType::CAIRO) {
+    refCairo = static_cast<cairo_t*>
+      (aDT->GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT));
+    if (refCairo) {
+      return refCairo;
     }
   }
 
-  if (mRefCairo) {
-    // Set transform!
-    return mRefCairo;
+  refCairo = static_cast<cairo_t*>(aDT->GetUserData(&sRefCairo));
+  if (!refCairo) {
+    refCairo = cairo_create(gfxPlatform::GetPlatform()->ScreenReferenceSurface()->CairoSurface());
+    aDT->AddUserData(&sRefCairo, refCairo, DestroyRefCairo);
   }
 
-  mRefCairo = cairo_create(gfxPlatform::GetPlatform()->ScreenReferenceSurface()->CairoSurface()); 
-
-  return mRefCairo;
+  return refCairo;
 }
 
 void
 gfxContext::Save()
 {
   CurrentState().transform = mTransform;
   mStateStack.AppendElement(AzureState(CurrentState()));
   CurrentState().pushedClips.Clear();
@@ -1307,17 +1317,17 @@ gfxContext::GetRoundOffsetsToPixels(bool
         *aRoundY = false;
         return;
     }
 
     // All raster backends snap glyphs to pixels vertically.
     // Print backends set CAIRO_HINT_METRICS_OFF.
     *aRoundY = true;
 
-    cairo_t *cr = GetCairo();
+    cairo_t *cr = gfxContext::RefCairo(GetDrawTarget());
     cairo_scaled_font_t *scaled_font = cairo_get_scaled_font(cr);
 
     // bug 1198921 - this sometimes fails under Windows for whatver reason
     NS_ASSERTION(scaled_font, "null cairo scaled font should never be returned "
                  "by cairo_get_scaled_font");
     if (!scaled_font) {
         *aRoundX = true; // default to the same as the fallback path below
         return;
--- a/gfx/thebes/gfxContext.h
+++ b/gfx/thebes/gfxContext.h
@@ -81,20 +81,20 @@ public:
      * and 0,0 in dx,dy.
      */
     already_AddRefed<gfxASurface> CurrentSurface(gfxFloat *dx, gfxFloat *dy);
     already_AddRefed<gfxASurface> CurrentSurface() {
         return CurrentSurface(nullptr, nullptr);
     }
 
     /**
-     * Return the raw cairo_t object.
-     * XXX this should go away at some point.
+     * Return the reference cairo_t object from aDT.
+     * XXX this should be moved into gfxFont at some point.
      */
-    cairo_t *GetCairo();
+    static cairo_t* RefCairo(mozilla::gfx::DrawTarget* aDT);
 
     mozilla::gfx::DrawTarget *GetDrawTarget() { return mDT; }
 
     /**
      ** State
      **/
     // XXX document exactly what bits are saved
     void Save();
@@ -543,18 +543,16 @@ private:
   RefPtr<PathBuilder> mPathBuilder;
   RefPtr<Path> mPath;
   Matrix mTransform;
   nsTArray<AzureState> mStateStack;
 
   AzureState &CurrentState() { return mStateStack[mStateStack.Length() - 1]; }
   const AzureState &CurrentState() const { return mStateStack[mStateStack.Length() - 1]; }
 
-  cairo_t *mRefCairo;
-
   RefPtr<DrawTarget> mDT;
   RefPtr<DrawTarget> mOriginalDT;
 };
 
 /**
  * Sentry helper class for functions with multiple return points that need to
  * call Save() on a gfxContext and have Restore() called automatically on the
  * gfxContext before they return.
--- a/gfx/thebes/gfxDWriteFonts.cpp
+++ b/gfx/thebes/gfxDWriteFonts.cpp
@@ -457,17 +457,18 @@ bool
 gfxDWriteFont::SetupCairoFont(gfxContext *aContext)
 {
     cairo_scaled_font_t *scaledFont = GetCairoScaledFont();
     if (cairo_scaled_font_status(scaledFont) != CAIRO_STATUS_SUCCESS) {
         // Don't cairo_set_scaled_font as that would propagate the error to
         // the cairo_t, precluding any further drawing.
         return false;
     }
-    cairo_set_scaled_font(aContext->GetCairo(), scaledFont);
+    cairo_set_scaled_font(gfxContext::RefCairo(aContext->GetDrawTarget()),
+                          scaledFont);
     return true;
 }
 
 bool
 gfxDWriteFont::IsValid() const
 {
     return mFontFace != nullptr;
 }
--- a/gfx/thebes/gfxFT2FontBase.cpp
+++ b/gfx/thebes/gfxFT2FontBase.cpp
@@ -173,18 +173,16 @@ gfxFT2FontBase::GetGlyphWidth(DrawTarget
     GetGlyphExtents(aGID, &extents);
     // convert to 16.16 fixed point
     return NS_lround(0x10000 * extents.x_advance);
 }
 
 bool
 gfxFT2FontBase::SetupCairoFont(gfxContext *aContext)
 {
-    cairo_t *cr = aContext->GetCairo();
-
     // The scaled font ctm is not relevant right here because
     // cairo_set_scaled_font does not record the scaled font itself, but
     // merely the font_face, font_matrix, font_options.  The scaled_font used
     // for the target can be different from the scaled_font passed to
     // cairo_set_scaled_font.  (Unfortunately we have measured only for an
     // identity ctm.)
     cairo_scaled_font_t *cairoFont = CairoScaledFont();
 
@@ -207,11 +205,12 @@ gfxFT2FontBase::SetupCairoFont(gfxContex
     // scaled_font that was used to measure.  As the same font_face is being
     // used, its font_options will often override some values anyway (unless
     // perhaps we remove those from the FcPattern at face creation).
     //
     // I can't see any significant difference in printing, irrespective of
     // what is set here.  It's too late to change things here as measuring has
     // already taken place.  We should really be measuring with a different
     // font for pdf and ps surfaces (bug 403513).
-    cairo_set_scaled_font(cr, cairoFont);
+    cairo_set_scaled_font(gfxContext::RefCairo(aContext->GetDrawTarget()),
+                          cairoFont);
     return true;
 }
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -3208,17 +3208,18 @@ gfxFont::SetupGlyphExtents(gfxContext *a
         return;
     }
 
     cairo_glyph_t glyph;
     glyph.index = aGlyphID;
     glyph.x = 0;
     glyph.y = 0;
     cairo_text_extents_t extents;
-    cairo_glyph_extents(aContext->GetCairo(), &glyph, 1, &extents);
+    cairo_glyph_extents(gfxContext::RefCairo(aContext->GetDrawTarget()),
+                        &glyph, 1, &extents);
 
     const Metrics& fontMetrics = GetMetrics(eHorizontal);
     int32_t appUnitsPerDevUnit = aExtents->GetAppUnitsPerDevUnit();
     if (!aNeedTight && extents.x_bearing >= 0 &&
         extents.y_bearing >= -fontMetrics.maxAscent &&
         extents.height + extents.y_bearing <= fontMetrics.maxDescent) {
         uint32_t appUnitsWidth =
             uint32_t(ceil((extents.x_bearing + extents.width)*appUnitsPerDevUnit));
--- a/gfx/thebes/gfxFontEntry.cpp
+++ b/gfx/thebes/gfxFontEntry.cpp
@@ -337,17 +337,18 @@ gfxFontEntry::GetSVGGlyphExtents(gfxCont
                                  gfxRect *aResult)
 {
     MOZ_ASSERT(mSVGInitialized,
                "SVG data has not yet been loaded. TryGetSVGData() first.");
     MOZ_ASSERT(mUnitsPerEm >= kMinUPEM && mUnitsPerEm <= kMaxUPEM,
                "font has invalid unitsPerEm");
 
     cairo_matrix_t fontMatrix;
-    cairo_get_font_matrix(aContext->GetCairo(), &fontMatrix);
+    cairo_get_font_matrix(gfxContext::RefCairo(aContext->GetDrawTarget()),
+                          &fontMatrix);
 
     gfxMatrix svgToAppSpace(fontMatrix.xx, fontMatrix.yx,
                             fontMatrix.xy, fontMatrix.yy,
                             fontMatrix.x0, fontMatrix.y0);
     svgToAppSpace.Scale(1.0f / mUnitsPerEm, 1.0f / mUnitsPerEm);
 
     return mSVGGlyphs->GetGlyphExtents(aGlyphId, svgToAppSpace, aResult);
 }
--- a/gfx/thebes/gfxGDIFont.cpp
+++ b/gfx/thebes/gfxGDIFont.cpp
@@ -131,17 +131,18 @@ gfxGDIFont::SetupCairoFont(gfxContext *a
         Initialize();
     }
     if (!mScaledFont ||
         cairo_scaled_font_status(mScaledFont) != CAIRO_STATUS_SUCCESS) {
         // Don't cairo_set_scaled_font as that would propagate the error to
         // the cairo_t, precluding any further drawing.
         return false;
     }
-    cairo_set_scaled_font(aContext->GetCairo(), mScaledFont);
+    cairo_set_scaled_font(gfxContext::RefCairo(aContext->GetDrawTarget()),
+                          mScaledFont);
     return true;
 }
 
 gfxFont::RunMetrics
 gfxGDIFont::Measure(gfxTextRun *aTextRun,
                     uint32_t aStart, uint32_t aEnd,
                     BoundingBoxType aBoundingBoxType,
                     gfxContext *aRefContext,
--- a/gfx/thebes/gfxMacFont.cpp
+++ b/gfx/thebes/gfxMacFont.cpp
@@ -155,17 +155,18 @@ gfxMacFont::ShapeText(gfxContext     *aC
 bool
 gfxMacFont::SetupCairoFont(gfxContext *aContext)
 {
     if (cairo_scaled_font_status(mScaledFont) != CAIRO_STATUS_SUCCESS) {
         // Don't cairo_set_scaled_font as that would propagate the error to
         // the cairo_t, precluding any further drawing.
         return false;
     }
-    cairo_set_scaled_font(aContext->GetCairo(), mScaledFont);
+    cairo_set_scaled_font(gfxContext::RefCairo(aContext->GetDrawTarget()),
+                          mScaledFont);
     return true;
 }
 
 gfxFont::RunMetrics
 gfxMacFont::Measure(gfxTextRun *aTextRun,
                     uint32_t aStart, uint32_t aEnd,
                     BoundingBoxType aBoundingBoxType,
                     gfxContext *aRefContext,
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/baseline/bug1182866.js
@@ -0,0 +1,17 @@
+// |jit-test| error: ReferenceError
+
+with(7) {
+    function f() {
+        if (i == 15) {
+            g();
+        }
+        const x = 42;
+        function g() {
+            return x;
+        }
+        return g;
+    }
+}
+for (var i = 0; i < 99; i++) {
+    assertEq(f()(), 42);
+}
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -4294,17 +4294,21 @@ ICGetName_Scope<NumHops>::Compiler::gene
     Register scope = NumHops ? walker : obj;
 
     if (!isFixedSlot_) {
         masm.loadPtr(Address(scope, NativeObject::offsetOfSlots()), walker);
         scope = walker;
     }
 
     masm.load32(Address(ICStubReg, ICGetName_Scope::offsetOfOffset()), scratch);
-    masm.loadValue(BaseIndex(scope, scratch, TimesOne), R0);
+
+    // GETNAME needs to check for uninitialized lexicals.
+    BaseIndex slot(scope, scratch, TimesOne);
+    masm.branchTestMagic(Assembler::Equal, slot, &failure);
+    masm.loadValue(slot, R0);
 
     // Enter type monitor IC to type-check result.
     EmitEnterTypeMonitorIC(masm);
 
     // Failure case - jump to next stub
     masm.bind(&failure);
     EmitStubGuardFailure(masm);
     return true;
--- a/layout/reftests/columns/columnfill-auto-ref.html
+++ b/layout/reftests/columns/columnfill-auto-ref.html
@@ -1,32 +1,80 @@
 <html>
 <head>
   <link rel="stylesheet" type="text/css" href="ahem.css" />
 
   <style>
+html,body {
+    color:black; background-color:white; font-size:16px; padding:5px; margin:0;
+}
+mask {
+  position: absolute;
+  top:0; bottom:0; left:8px; width:5px;
+  background: black;
+}
+
+    .rel {
+      position: relative;
+    }
+    a {
+      position: absolute;
+      width: 10px;
+      height: 10px;
+      bottom: 0;
+      left: 0;
+      background: blue;
+    }
+    f {
+      position: fixed;
+      width: 10px;
+      height: 10px;
+      bottom: 0;
+      left: 100px;
+      background: lime;
+    }
     td.text {
-      width: 200px;
+      width: 12em;
+      height: 8em;
       text-align: left;
       font-family: ahem;
       font-size: 12pt;
       line-height: 1.1;
     }
 
     table {
-      width: 100%;
       font-family: ahem;
       font-size: 12pt;
       line-height: 1.1;
     }
   </style>
 </head>
 
 <body>
+  <table cellpadding=0 cellspacing=0 class="rel">
+    <tr>
+      <td class="text" valign="top"><a></a>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed</td>
+    </tr>
+  </table>
+  <table cellpadding=0 cellspacing=0 class="rel">
+    <tr>
+      <td class="text" valign="top"><a></a>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed</td>
+    </tr>
+  </table>
+  <table cellpadding=0 cellspacing=0 class="rel">
+    <tr>
+      <td class="text" valign="top"><f></f>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed</td>
+    </tr>
+  </table>
   <table cellpadding=0 cellspacing=0>
     <tr>
-      <td class="text" valign="top">
-        Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed feugiat libero vel diam.</td>
-      <td class="text" valign="top">Pellentesque pulvinar commodo lacus. Sed fringilla. Sed lectus. Praesent laoreet orci</td>
-      <td valign="top" class="text">vitae nisi. Duis venenatis tristique massa. Sed commodo diam at mauris.</td>
+      <td class="text" valign="top"><a></a>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed</td>
     </tr>
   </table>
+  <table cellpadding=0 cellspacing=0>
+    <tr>
+      <td class="text" valign="top"><f style="left:120px"></f>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed</td>
+    </tr>
+  </table>
+
+<mask></mask>
 </body>
+</html>
--- a/layout/reftests/columns/columnfill-auto.html
+++ b/layout/reftests/columns/columnfill-auto.html
@@ -1,19 +1,68 @@
 <html>
   <head>
     <link rel="stylesheet" type="text/css" href="ahem.css" />
+  <style>
+html,body {
+    color:black; background-color:white; font-size:16px; padding:5px; margin:0;
+}
+mask {
+  position: absolute;
+  top:0; bottom:0; left:8px; width:5px;
+  background: black;
+}
+
+.rel {
+  position: relative;
+}
+.columns {
+  -moz-column-width: 12em;
+  -moz-column-gap: 0;
+  -moz-column-fill: auto;
+  height: 8em;
+  font-family: ahem;
+  font-size: 12pt;
+  line-height: 1.1;
+}
+a {
+  position: absolute;
+  width: 10px;
+  height: 10px;
+  bottom: 0;
+  left: 0;
+  background: blue;
+}
+f {
+  position: fixed;
+  width: 10px;
+  height: 10px;
+  bottom: 0;
+  left: 100px;
+  background: lime;
+}
+  </style>
   </head>
 
   <body>
-    <div style="width: 100%">
-    <div style="-moz-column-width: 200px;
-                -moz-column-gap: 0px;
-                -moz-column-fill: auto;
-                height: 120px;
-                font-family: ahem;
-                font-size: 12pt;
-		line-height: 1.1;">
-      Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed feugiat libero vel diam. Pellentesque pulvinar commodo lacus. Sed fringilla. Sed lectus. Praesent laoreet orci vitae nisi. Duis venenatis tristique massa. Sed commodo diam at mauris.
+    <div class="columns rel">
+      <a></a>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed
+    </div>
+
+    <div class="columns rel" style="overflow: hidden">
+      <a></a>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed
+    </div>
+
+    <div class="columns rel" style="overflow: hidden">
+      <f></f>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed
     </div>
+
+    <div class="columns" style="overflow: hidden">
+      <a></a>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed
     </div>
+
+    <div class="columns" style="overflow: hidden">
+      <f style="left:120px"></f>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed
+    </div>
+
+<mask></mask>
   </body>
 </html>
--- a/layout/reftests/columns/reftest.list
+++ b/layout/reftests/columns/reftest.list
@@ -14,17 +14,17 @@
 == column-balancing-overflow-005.html column-balancing-overflow-005.ref.html
 == column-balancing-000.html column-balancing-000.ref.html
 == column-balancing-001.html column-balancing-000.ref.html
 == column-balancing-002.html column-balancing-002.ref.html
 == column-balancing-003.html column-balancing-000.ref.html
 == column-balancing-004.html column-balancing-004.ref.html
 == column-box-alignment-rtl.html column-box-alignment-rtl-ref.html
 HTTP(..) == columnfill-balance.html columnfill-balance-ref.html
-HTTP(..) == columnfill-auto.html columnfill-auto-ref.html
+fuzzy-if(OSX,32,1000) HTTP(..) == columnfill-auto.html columnfill-auto-ref.html
 HTTP(..) == columnfill-auto-2.html columnfill-auto-2-ref.html
 HTTP(..) == columnfill-auto-3.html columnfill-auto-2-ref.html
 skip-if(B2G||Mulet) == columnrule-basic.html columnrule-basic-ref.html # bug 773482 # Initial mulet triage: parity with B2G/B2G Desktop
 skip-if(B2G||Mulet) == columnrule-complex.html columnrule-complex-ref.html # bug 773482 # Initial mulet triage: parity with B2G/B2G Desktop
 != columnrule-linestyles.html columnrule-linestyles-notref.html
 == columnrule-padding.html columnrule-padding-ref.html
 skip-if(B2G||Mulet) == columnfill-overflow.html columnfill-overflow-ref.html # bug 773482 # Initial mulet triage: parity with B2G/B2G Desktop
 == margin-collapsing-bug616722-1.html margin-collapsing-bug616722-1-ref.html
--- a/layout/reftests/w3c-css/submitted/text-decor-3/reftest.list
+++ b/layout/reftests/w3c-css/submitted/text-decor-3/reftest.list
@@ -1,83 +1,83 @@
 default-preferences pref(layout.css.vertical-text.enabled,true)
 default-preferences pref(layout.css.text-emphasis.enabled,true)
 
 == ruby-text-decoration-01.html ruby-text-decoration-01-ref.html
 == text-decoration-propagation-01.html text-decoration-propagation-01-ref.html
 
 # text-emphasis-style
 == text-emphasis-style-property-001.html text-emphasis-style-property-001-ref.html
-== text-emphasis-style-property-002.html text-emphasis-style-property-002-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-002.html text-emphasis-style-property-002-ref.html
 skip-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) == text-emphasis-style-property-003.html text-emphasis-style-property-003-ref.html
 skip-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) == text-emphasis-style-property-004.html text-emphasis-style-property-004-ref.html
 == text-emphasis-style-property-005.html text-emphasis-style-property-005-ref.html
 == text-emphasis-style-property-005a.html text-emphasis-style-property-005-ref.html
 # START tests from support/generate-text-emphasis-style-property-010-tests.sh
 == text-emphasis-style-property-010Zs.html text-emphasis-style-property-010-ref.html
 == text-emphasis-style-property-010Zl.html text-emphasis-style-property-010-ref.html
 == text-emphasis-style-property-010Zp.html text-emphasis-style-property-010-ref.html
 == text-emphasis-style-property-010Cc.html text-emphasis-style-property-010-ref.html
 == text-emphasis-style-property-010Cf.html text-emphasis-style-property-010-ref.html
 # END tests from support/generate-text-emphasis-style-property-010-tests.sh
 == text-emphasis-style-property-010Cn.html text-emphasis-style-property-010-ref.html
 # START tests from support/generate-text-emphasis-style-property-tests.py
-== text-emphasis-style-property-011.html text-emphasis-style-property-011-ref.html
-== text-emphasis-style-property-011a.html text-emphasis-style-property-011-ref.html
-== text-emphasis-style-property-011b.html text-emphasis-style-property-011-ref.html
-== text-emphasis-style-property-012.html text-emphasis-style-property-012-ref.html
-== text-emphasis-style-property-012a.html text-emphasis-style-property-012-ref.html
-== text-emphasis-style-property-012b.html text-emphasis-style-property-012-ref.html
-== text-emphasis-style-property-012c.html text-emphasis-style-property-012-ref.html
-== text-emphasis-style-property-013.html text-emphasis-style-property-013-ref.html
-== text-emphasis-style-property-013a.html text-emphasis-style-property-013-ref.html
-== text-emphasis-style-property-013b.html text-emphasis-style-property-013-ref.html
-== text-emphasis-style-property-014.html text-emphasis-style-property-014-ref.html
-== text-emphasis-style-property-014a.html text-emphasis-style-property-014-ref.html
-== text-emphasis-style-property-014b.html text-emphasis-style-property-014-ref.html
-skip-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) == text-emphasis-style-property-015.html text-emphasis-style-property-015-ref.html
-skip-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) == text-emphasis-style-property-015a.html text-emphasis-style-property-015-ref.html
-skip-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) == text-emphasis-style-property-015b.html text-emphasis-style-property-015-ref.html
-== text-emphasis-style-property-016.html text-emphasis-style-property-016-ref.html
-== text-emphasis-style-property-016a.html text-emphasis-style-property-016-ref.html
-== text-emphasis-style-property-017.html text-emphasis-style-property-017-ref.html
-== text-emphasis-style-property-017a.html text-emphasis-style-property-017-ref.html
-== text-emphasis-style-property-017b.html text-emphasis-style-property-017-ref.html
-== text-emphasis-style-property-018.html text-emphasis-style-property-018-ref.html
-== text-emphasis-style-property-018a.html text-emphasis-style-property-018-ref.html
-== text-emphasis-style-property-019.html text-emphasis-style-property-019-ref.html
-== text-emphasis-style-property-019a.html text-emphasis-style-property-019-ref.html
-skip-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) == text-emphasis-style-property-020.html text-emphasis-style-property-020-ref.html
-skip-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) == text-emphasis-style-property-020a.html text-emphasis-style-property-020-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-011.html text-emphasis-style-property-011-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-011a.html text-emphasis-style-property-011-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-011b.html text-emphasis-style-property-011-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-012.html text-emphasis-style-property-012-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-012a.html text-emphasis-style-property-012-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-012b.html text-emphasis-style-property-012-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-012c.html text-emphasis-style-property-012-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-013.html text-emphasis-style-property-013-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-013a.html text-emphasis-style-property-013-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-013b.html text-emphasis-style-property-013-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-014.html text-emphasis-style-property-014-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-014a.html text-emphasis-style-property-014-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-014b.html text-emphasis-style-property-014-ref.html
+fuzzy-if(gtkWidget,3,4) skip-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) == text-emphasis-style-property-015.html text-emphasis-style-property-015-ref.html
+fuzzy-if(gtkWidget,3,4) skip-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) == text-emphasis-style-property-015a.html text-emphasis-style-property-015-ref.html
+fuzzy-if(gtkWidget,3,4) skip-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) == text-emphasis-style-property-015b.html text-emphasis-style-property-015-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-016.html text-emphasis-style-property-016-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-016a.html text-emphasis-style-property-016-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-017.html text-emphasis-style-property-017-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-017a.html text-emphasis-style-property-017-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-017b.html text-emphasis-style-property-017-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-018.html text-emphasis-style-property-018-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-018a.html text-emphasis-style-property-018-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-019.html text-emphasis-style-property-019-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-style-property-019a.html text-emphasis-style-property-019-ref.html
+fuzzy-if(gtkWidget,3,4) skip-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) == text-emphasis-style-property-020.html text-emphasis-style-property-020-ref.html
+fuzzy-if(gtkWidget,3,4) skip-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) == text-emphasis-style-property-020a.html text-emphasis-style-property-020-ref.html
 # END tests from support/generate-text-emphasis-style-property-tests.py
 
 # text-emphasis-color
-== text-emphasis-color-property-001.html text-emphasis-color-property-001-ref.html
-== text-emphasis-color-property-001a.html text-emphasis-color-property-001-ref.html
-== text-emphasis-color-property-002.html text-emphasis-color-property-002-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-color-property-001.html text-emphasis-color-property-001-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-color-property-001a.html text-emphasis-color-property-001-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-color-property-002.html text-emphasis-color-property-002-ref.html
 
 # text-emphasis
 == text-emphasis-property-001.html text-emphasis-style-property-001-ref.html
-== text-emphasis-property-002.html text-emphasis-style-property-002-ref.html
-== text-emphasis-property-003.html text-emphasis-style-property-012-ref.html
-== text-emphasis-property-003a.html text-emphasis-style-property-012-ref.html
-== text-emphasis-property-003b.html text-emphasis-style-property-012-ref.html
-== text-emphasis-property-004.html text-emphasis-color-property-002-ref.html
-== text-emphasis-property-004a.html text-emphasis-color-property-002-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-property-002.html text-emphasis-style-property-002-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-property-003.html text-emphasis-style-property-012-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-property-003a.html text-emphasis-style-property-012-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-property-003b.html text-emphasis-style-property-012-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-property-004.html text-emphasis-color-property-002-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-property-004a.html text-emphasis-color-property-002-ref.html
 
 # text-emphasis-position
 # START tests from support/generate-text-emphasis-position-property-tests.py
-== text-emphasis-position-property-001.html text-emphasis-position-property-001-ref.html
-== text-emphasis-position-property-001a.html text-emphasis-position-property-001-ref.html
-== text-emphasis-position-property-001b.html text-emphasis-position-property-001-ref.html
-== text-emphasis-position-property-001c.html text-emphasis-position-property-001-ref.html
-== text-emphasis-position-property-002.html text-emphasis-position-property-002-ref.html
-== text-emphasis-position-property-002a.html text-emphasis-position-property-002-ref.html
-== text-emphasis-position-property-002b.html text-emphasis-position-property-002-ref.html
-== text-emphasis-position-property-002c.html text-emphasis-position-property-002-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-position-property-001.html text-emphasis-position-property-001-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-position-property-001a.html text-emphasis-position-property-001-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-position-property-001b.html text-emphasis-position-property-001-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-position-property-001c.html text-emphasis-position-property-001-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-position-property-002.html text-emphasis-position-property-002-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-position-property-002a.html text-emphasis-position-property-002-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-position-property-002b.html text-emphasis-position-property-002-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-position-property-002c.html text-emphasis-position-property-002-ref.html
 == text-emphasis-position-property-003.html text-emphasis-position-property-003-ref.html
 == text-emphasis-position-property-003a.html text-emphasis-position-property-003-ref.html
 == text-emphasis-position-property-003b.html text-emphasis-position-property-003-ref.html
 == text-emphasis-position-property-003c.html text-emphasis-position-property-003-ref.html
 == text-emphasis-position-property-003d.html text-emphasis-position-property-003-ref.html
 == text-emphasis-position-property-003e.html text-emphasis-position-property-003-ref.html
 == text-emphasis-position-property-003f.html text-emphasis-position-property-003-ref.html
 == text-emphasis-position-property-003g.html text-emphasis-position-property-003-ref.html
@@ -113,22 +113,22 @@ skip-if(/^Windows\x20NT\x205\.1/.test(ht
 == text-emphasis-ruby-003.html text-emphasis-ruby-003-ref.html
 == text-emphasis-ruby-003a.html text-emphasis-ruby-003-ref.html
 == text-emphasis-ruby-004.html text-emphasis-ruby-004-ref.html
 == text-emphasis-ruby-004a.html text-emphasis-ruby-004-ref.html
 # END tests from support/generate-text-emphasis-ruby-tests.py
 
 # text-emphasis line height
 # START tests from support/generate-text-emphasis-line-height-tests.py
-== text-emphasis-line-height-001a.html text-emphasis-line-height-001-ref.html
-== text-emphasis-line-height-001b.html text-emphasis-line-height-001-ref.html
-== text-emphasis-line-height-002a.html text-emphasis-line-height-002-ref.html
-== text-emphasis-line-height-002b.html text-emphasis-line-height-002-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-line-height-001a.html text-emphasis-line-height-001-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-line-height-001b.html text-emphasis-line-height-001-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-line-height-002a.html text-emphasis-line-height-002-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-line-height-002b.html text-emphasis-line-height-002-ref.html
 == text-emphasis-line-height-003a.html text-emphasis-line-height-003-ref.html
 == text-emphasis-line-height-003b.html text-emphasis-line-height-003-ref.html
 == text-emphasis-line-height-003c.html text-emphasis-line-height-003-ref.html
 == text-emphasis-line-height-003d.html text-emphasis-line-height-003-ref.html
 == text-emphasis-line-height-004a.html text-emphasis-line-height-004-ref.html
 == text-emphasis-line-height-004b.html text-emphasis-line-height-004-ref.html
 == text-emphasis-line-height-004c.html text-emphasis-line-height-004-ref.html
 == text-emphasis-line-height-004d.html text-emphasis-line-height-004-ref.html
 # END tests from support/generate-text-emphasis-line-height-tests.py
-== text-emphasis-line-height-001z.html text-emphasis-line-height-001-ref.html
+fuzzy-if(gtkWidget,3,4) == text-emphasis-line-height-001z.html text-emphasis-line-height-001-ref.html
--- a/mfbt/Compiler.h
+++ b/mfbt/Compiler.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Various compiler checks. */
 
 #ifndef mozilla_Compiler_h
 #define mozilla_Compiler_h
 
 #define MOZ_IS_GCC 0
-#define MOS_IS_MSVC 0
+#define MOZ_IS_MSVC 0
 
 #if !defined(__clang__) && defined(__GNUC__)
 
 #  undef MOZ_IS_GCC
 #  define MOZ_IS_GCC 1
    /*
     * This macro should simplify gcc version checking. For example, to check
     * for gcc 4.7.1 or later, check `#if MOZ_GCC_VERSION_AT_LEAST(4, 7, 1)`.
--- a/python/mozboot/mozboot/base.py
+++ b/python/mozboot/mozboot/base.py
@@ -170,16 +170,19 @@ class BaseBootstrapper(object):
 
         self.run_as_root(command)
 
     def dnf_groupinstall(self, *packages):
         if self.which('dnf'):
             command = ['dnf', 'groupinstall']
         else:
             command = ['yum', 'groupinstall']
+
+        if self.no_interactive:
+            command.append('-y')
         command.extend(packages)
 
         self.run_as_root(command)
 
     def dnf_update(self, *packages):
         if self.which('dnf'):
             command = ['dnf', 'update']
         else:
--- a/testing/eslint-plugin-mozilla/lib/processors/xbl-bindings.js
+++ b/testing/eslint-plugin-mozilla/lib/processors/xbl-bindings.js
@@ -23,23 +23,25 @@ function parseError(err) {
   return {
     fatal: true,
     message: matches[1],
     line: parseInt(matches[2]) + 1,
     column: parseInt(matches[3])
   }
 }
 
+let entityRegex = /&[\w][\w-\.]*;/g;
+
 // A simple sax listener that generates a tree of element information
 function XMLParser(parser) {
   this.parser = parser;
   parser.onopentag = this.onOpenTag.bind(this);
   parser.onclosetag = this.onCloseTag.bind(this);
   parser.ontext = this.onText.bind(this);
-  parser.oncdata = this.onText.bind(this);
+  parser.oncdata = this.onCDATA.bind(this);
 
   this.document = {
     local: "#document",
     uri: null,
     children: [],
   }
   this._currentNode = this.document;
 }
@@ -68,16 +70,21 @@ XMLParser.prototype = {
     this._currentNode = node;
   },
 
   onCloseTag: function(tagname) {
     this._currentNode = this._currentNode.parentNode;
   },
 
   onText: function(text) {
+    // Replace entities with some valid JS token.
+    this.onCDATA(text.replace(entityRegex, "null"));
+  },
+
+  onCDATA: function(text) {
     this._currentNode.textContent += text;
   }
 }
 
 // Strips the indentation from lines of text and adds a fixed two spaces indent
 function reindent(text) {
   let lines = text.split("\n");
 
@@ -168,17 +175,17 @@ module.exports = {
             case "field": {
               // Fields get converted into variable declarations
               let def = item.textContent.trimRight();
               // Ignore empty fields
               if (def.trim().length == 0) {
                 continue;
               }
               blockLines.push(item.textStart);
-              scripts.push(`let ${item.attributes.name} = ${def}\n`);
+              scripts.push(`${def}\n`);
               break;
             }
             case "constructor":
             case "destructor": {
               // Constructors and destructors become function declarations
               blockLines.push(item.textStart);
               let content = reindent(item.textContent);
               scripts.push(`function ${item.local}() {${content}}\n`);
@@ -208,17 +215,17 @@ module.exports = {
                 scripts.push(`function ${item.attributes.name}_${propdef.local}(${params}) {${content}}\n`);
               }
               break;
             }
             case "handler": {
               // Handlers become a function declaration with an `event` parameter
               blockLines.push(item.textStart);
               let content = reindent(item.textContent);
-              scripts.push(`function on${item.attributes.event}(event) {${content}}\n`);
+              scripts.push(`function onevent(event) {${content}}\n`);
               break;
             }
             default:
               continue;
           }
         }
       }
     }
--- a/testing/mozharness/mozharness/mozilla/testing/testbase.py
+++ b/testing/mozharness/mozharness/mozilla/testing/testbase.py
@@ -430,17 +430,18 @@ 2. running via buildbot and running the 
                 # has everything we need to run tests for this suite.
                 target_packages = package_requirements['common']
 
             self.info("Downloading packages: %s for test suite category: %s" %
                       (target_packages, category))
             for file_name in target_packages:
                 target_dir = test_install_dir
                 unzip_dirs = target_unzip_dirs
-                if "jsshell-" in file_name:
+                if "jsshell-" in file_name or file_name == "target.jsshell.zip":
+                    self.info("Special-casing the jsshell zip file")
                     unzip_dirs = None
                     target_dir = dirs['abs_test_bin_dir']
                 url = self.query_build_dir_url(file_name)
                 self._download_unzip(url, target_dir,
                                      target_unzip_dirs=unzip_dirs)
 
     def _download_unzip(self, url, parent_dir, target_unzip_dirs=None):
         """Generic download+unzip.
--- a/testing/taskcluster/tasks/test.yml
+++ b/testing/taskcluster/tasks/test.yml
@@ -9,16 +9,17 @@ task:
     createdForUser: {{owner}}
   workerType: b2gtest
   provisionerId: aws-provisioner-v1
   schedulerId: task-graph-scheduler
 
   scopes:
     - 'queue:define-task:aws-provisioner-v1/test-c4-2xlarge'
     - 'queue:create-task:aws-provisioner-v1/test-c4-2xlarge'
+    - 'docker-worker:feature:allowPtrace'
 
   payload:
     image: '{{#docker_image}}tester{{/docker_image}}'
     maxRunTime: 3600
     env:
       MOZILLA_BUILD_URL: '{{build_url}}'
       MOZHARNESS_URL: '{{mozharness_url}}'
 
--- a/testing/taskcluster/tasks/tests/fx_test_base.yml
+++ b/testing/taskcluster/tasks/tests/fx_test_base.yml
@@ -10,15 +10,16 @@ task:
         NEED_PULSEAUDIO: true
         GECKO_HEAD_REPOSITORY: '{{{head_repository}}}'
         GECKO_HEAD_REV: '{{{head_rev}}}'
     artifacts:
       'public/test':
         type: directory
         path: '/home/worker/artifacts/'
         expires: '{{#from_now}}1 year{{/from_now}}'
-
+    features:
+      allowPtrace: true
   extra:
     treeherder:
       tier: 2
     treeherderEnv:
       - production
       - staging
--- a/testing/xpcshell/head.js
+++ b/testing/xpcshell/head.js
@@ -378,17 +378,30 @@ function _setupDebuggerServer(breakpoint
                       .getService(Components.interfaces.nsIEnvironment);
   if (env.get("DEVTOOLS_DEBUGGER_LOG")) {
     prefs.setBoolPref("devtools.debugger.log", true);
   }
   if (env.get("DEVTOOLS_DEBUGGER_LOG_VERBOSE")) {
     prefs.setBoolPref("devtools.debugger.log.verbose", true);
   }
 
-  let { require } = Components.utils.import("resource://devtools/shared/Loader.jsm", {});
+  let require;
+  try {
+    ({ require } = Components.utils.import("resource://devtools/shared/Loader.jsm", {}));
+  } catch (e) {
+    throw new Error("resource://devtools appears to be inaccessible from the " +
+                    "xpcshell environment.\n" +
+                    "This can usually be resolved by adding:\n" +
+                    "  firefox-appdir = browser\n" +
+                    "to the xpcshell.ini manifest.\n" +
+                    "It is possible for this to alter test behevior by " +
+                    "triggering additional browser code to run, so check " +
+                    "test behavior after making this change.\n" +
+                    "See also https://bugzil.la/1215378.")
+  }
   let { DebuggerServer } = require("devtools/server/main");
   let { OriginalLocation } = require("devtools/server/actors/common");
   DebuggerServer.init();
   DebuggerServer.addBrowserActors();
   DebuggerServer.addActors("resource://testing-common/dbg-actors.js");
   DebuggerServer.allowChromeProcess = true;
 
   // An observer notification that tells us when we can "resume" script
@@ -469,17 +482,19 @@ function _initDebugging(port) {
 }
 
 function _execute_test() {
   // _JSDEBUGGER_PORT is dynamically defined by <runxpcshelltests.py>.
   if (_JSDEBUGGER_PORT) {
     try {
       _initDebugging(_JSDEBUGGER_PORT);
     } catch (ex) {
-      do_print("Failed to initialize debugging: " + ex + "\n" + ex.stack);
+      // Fail the test run immediately if debugging is requested but fails, so
+      // that the failure state is more obvious.
+      do_throw(`Failed to initialize debugging: ${ex}`, ex.stack);
     }
   }
 
   _register_protocol_handlers();
 
   // Override idle service by default.
   // Call do_get_idle() to restore the factory and get the service.
   _fakeIdleService.activate();
--- a/toolkit/components/prompts/content/tabprompts.xml
+++ b/toolkit/components/prompts/content/tabprompts.xml
@@ -306,29 +306,31 @@
 #ifdef XP_MACOSX
         <handler event="keypress" key="." modifiers="meta"
                  group="system" action="this.onKeyAction('cancel', event);"/>
 #endif
         <handler event="focus" phase="capturing">
             let bnum = this.args.defaultButtonNum || 0;
             let defaultButton = this.ui["button" + bnum];
 
-#ifdef XP_MACOSX
-            // On OS X, the default button always stays marked as such (until
-            // the entire prompt blurs).
-            defaultButton.setAttribute("default", true);
-#else
-            // On other platforms, the default button is only marked as such
-            // when no other button has focus. XUL buttons on not-OSX will
-            // react to pressing enter as a command, so you can't trigger the
-            // default without tabbing to it or something that isn't a button.
-            let focusedDefault = (event.originalTarget == defaultButton);
-            let someButtonFocused = event.originalTarget instanceof Ci.nsIDOMXULButtonElement;
-            defaultButton.setAttribute("default", focusedDefault || !someButtonFocused);
-#endif
+            let { AppConstants } =
+                Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
+            if (AppConstants.platform == "macosx") {
+              // On OS X, the default button always stays marked as such (until
+              // the entire prompt blurs).
+              defaultButton.setAttribute("default", true);
+            } else {
+              // On other platforms, the default button is only marked as such
+              // when no other button has focus. XUL buttons on not-OSX will
+              // react to pressing enter as a command, so you can't trigger the
+              // default without tabbing to it or something that isn't a button.
+              let focusedDefault = (event.originalTarget == defaultButton);
+              let someButtonFocused = event.originalTarget instanceof Ci.nsIDOMXULButtonElement;
+              defaultButton.setAttribute("default", focusedDefault || !someButtonFocused);
+            }
         </handler>
         <handler event="blur">
             // If focus shifted to somewhere else in the browser, don't make
             // the default button look active.
             let bnum = this.args.defaultButtonNum || 0;
             let button = this.ui["button" + bnum];
             button.setAttribute("default", false);
         </handler>
--- a/toolkit/components/satchel/nsFormHistory.js
+++ b/toolkit/components/satchel/nsFormHistory.js
@@ -7,16 +7,18 @@ const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "Deprecated",
                                   "resource://gre/modules/Deprecated.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
+                                  "resource://gre/modules/AppConstants.jsm");
 
 const DB_VERSION = 4;
 const DAY_IN_MS  = 86400000; // 1 day in milliseconds
 
 function FormHistory() {
     Deprecated.warning(
         "nsIFormHistory2 is deprecated and will be removed in a future version",
         "https://bugzilla.mozilla.org/show_bug.cgi?id=879118");
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -9223,22 +9223,16 @@
     "description": "Has the tab queue functionality been enabled."
   },
   "FENNEC_OPEN_URLS_IN_PRIVATE": {
     "alert_emails": ["margaret@mozilla.com"],
     "expires_in_version": "45",
     "kind": "flag",
     "description": "Reports the state of the open external links in private tabs preference"
   },
-  "VIDEO_EME_DISABLED": {
-    "alert_emails": ["edwin@mozilla.com"],
-    "expires_in_version": "45",
-    "kind": "boolean",
-    "description": "Set if media.eme.enabled is false, in a build that supports the Adobe Primetime Content Decryption Module."
-  },
   "GRAPHICS_DRIVER_STARTUP_TEST": {
     "alert_emails": ["danderson@mozilla.com"],
     "expires_in_version": "never",
     "kind": "enumerated",
     "n_values": 20,
     "releaseChannelCollection": "opt-out",
     "description": "Reports whether or not graphics drivers crashed during startup."
   },
--- a/toolkit/content/jar.mn
+++ b/toolkit/content/jar.mn
@@ -59,30 +59,30 @@ toolkit.jar:
    content/global/resetProfile.css
    content/global/resetProfile.js
    content/global/resetProfile.xul
    content/global/resetProfileProgress.xul
    content/global/select-child.js
    content/global/TopLevelVideoDocument.js
    content/global/treeUtils.js
    content/global/viewZoomOverlay.js
-*+ content/global/bindings/autocomplete.xml    (widgets/autocomplete.xml)
++  content/global/bindings/autocomplete.xml    (widgets/autocomplete.xml)
    content/global/bindings/browser.xml         (widgets/browser.xml)
    content/global/bindings/button.xml          (widgets/button.xml)
    content/global/bindings/checkbox.xml        (widgets/checkbox.xml)
    content/global/bindings/colorpicker.xml     (widgets/colorpicker.xml)
    content/global/bindings/datetimepicker.xml  (widgets/datetimepicker.xml)
 *+ content/global/bindings/dialog.xml          (widgets/dialog.xml)
    content/global/bindings/editor.xml          (widgets/editor.xml)
    content/global/bindings/expander.xml        (widgets/expander.xml)
-*  content/global/bindings/filefield.xml       (widgets/filefield.xml)
+   content/global/bindings/filefield.xml       (widgets/filefield.xml)
 *+ content/global/bindings/findbar.xml         (widgets/findbar.xml)
    content/global/bindings/general.xml         (widgets/general.xml)
    content/global/bindings/groupbox.xml        (widgets/groupbox.xml)
-*+ content/global/bindings/listbox.xml         (widgets/listbox.xml)
++  content/global/bindings/listbox.xml         (widgets/listbox.xml)
    content/global/bindings/menu.xml            (widgets/menu.xml)
    content/global/bindings/menulist.xml        (widgets/menulist.xml)
    content/global/bindings/notification.xml    (widgets/notification.xml)
    content/global/bindings/numberbox.xml       (widgets/numberbox.xml)
    content/global/bindings/popup.xml           (widgets/popup.xml)
 *+ content/global/bindings/preferences.xml     (widgets/preferences.xml)
    content/global/bindings/progressmeter.xml   (widgets/progressmeter.xml)
    content/global/bindings/radio.xml           (widgets/radio.xml)
@@ -96,15 +96,15 @@ toolkit.jar:
    content/global/bindings/spinbuttons.xml     (widgets/spinbuttons.xml)
    content/global/bindings/stringbundle.xml    (widgets/stringbundle.xml)
 *+ content/global/bindings/tabbox.xml          (widgets/tabbox.xml)
    content/global/bindings/text.xml            (widgets/text.xml)
 *+ content/global/bindings/textbox.xml         (widgets/textbox.xml)
    content/global/bindings/toolbar.xml         (widgets/toolbar.xml)
    content/global/bindings/toolbarbutton.xml   (widgets/toolbarbutton.xml)
 *+ content/global/bindings/tree.xml            (widgets/tree.xml)
-*+ content/global/bindings/videocontrols.xml   (widgets/videocontrols.xml)
++  content/global/bindings/videocontrols.xml   (widgets/videocontrols.xml)
    content/global/bindings/videocontrols.css   (widgets/videocontrols.css)
 *+ content/global/bindings/wizard.xml          (widgets/wizard.xml)
 #ifdef XP_MACOSX
    content/global/macWindowMenu.js
 #endif
    content/global/svg/svgBindings.xml          (/layout/svg/resources/content/svgBindings.xml)
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -1,14 +1,12 @@
 <?xml version="1.0"?>
-
-# -*- Mode: HTML -*-
-# 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/.
+<!-- 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/. -->
 
 <bindings id="autocompleteBindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:html="http://www.w3.org/1999/xhtml"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
           xmlns:xbl="http://www.mozilla.org/xbl">
 
   <binding id="autocomplete" role="xul:combobox"
@@ -443,25 +441,23 @@
             return true; // Let child buttons of autocomplete take input
 
           //XXXpch this is so bogus...
           if (aEvent.defaultPrevented)
             return false;
 
           var cancel = false;
 
+          let { AppConstants } =
+              Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
           // Catch any keys that could potentially move the caret. Ctrl can be
           // used in combination with these keys on Windows and Linux; and Alt
           // can be used on OS X, so make sure the unused one isn't used.
-          if (!this.disableKeyNavigation &&
-#ifdef XP_MACOSX
-              !aEvent.ctrlKey) {
-#else
-              !aEvent.altKey) {
-#endif
+          let metaKey = AppConstants.platform == "macosx" ? aEvent.ctrlKey : aEvent.altKey;
+          if (!this.disableKeyNavigation && !metaKey) {
             switch (aEvent.keyCode) {
               case KeyEvent.DOM_VK_LEFT:
               case KeyEvent.DOM_VK_RIGHT:
               case KeyEvent.DOM_VK_HOME:
                 cancel = this.mController.handleKeyNavigation(aEvent.keyCode);
                 break;
             }
           }
@@ -488,47 +484,51 @@
 
           // Handle keys we know aren't part of a shortcut, even with Alt or
           // Ctrl.
           switch (aEvent.keyCode) {
             case KeyEvent.DOM_VK_ESCAPE:
               cancel = this.mController.handleEscape();
               break;
             case KeyEvent.DOM_VK_RETURN:
-#ifdef XP_MACOSX
-              // Prevent the default action, since it will beep on Mac
-              if (aEvent.metaKey)
-                aEvent.preventDefault();
-#endif
+              if (AppConstants.platform == "macosx") {
+                // Prevent the default action, since it will beep on Mac
+                if (aEvent.metaKey)
+                  aEvent.preventDefault();
+              }
               this.mEnterEvent = aEvent;
               if (this.mController.selection) {
                 this._selectionDetails = {
                   index: this.mController.selection.currentIndex,
                   kind: "key"
                 };
               }
               cancel = this.handleEnter();
               break;
             case KeyEvent.DOM_VK_DELETE:
-#ifdef XP_MACOSX
+              if (AppConstants.platform == "macosx" && !aEvent.shiftKey) {
+                break;
+              }
+              cancel = this.handleDelete();
+              break;
             case KeyEvent.DOM_VK_BACK_SPACE:
-              if (aEvent.shiftKey)
-#endif
-              cancel = this.handleDelete();
+              if (AppConstants.platform == "macosx" && aEvent.shiftKey) {
+                cancel = this.handleDelete();
+              }
               break;
             case KeyEvent.DOM_VK_DOWN:
             case KeyEvent.DOM_VK_UP:
               if (aEvent.altKey)
                 this.toggleHistoryPopup();
               break;
-#ifndef XP_MACOSX
             case KeyEvent.DOM_VK_F4:
-              this.toggleHistoryPopup();
+              if (AppConstants.platform != "macosx") {
+                this.toggleHistoryPopup();
+              }
               break;
-#endif
           }
 
           if (cancel) {
             aEvent.stopPropagation();
             aEvent.preventDefault();
           }
 
           return true;
--- a/toolkit/content/widgets/dialog.xml
+++ b/toolkit/content/widgets/dialog.xml
@@ -158,16 +158,19 @@
         window.centerWindowOnScreen = this.centerWindowOnScreen;
       ]]>
       </constructor>
 
       <method name="postLoadInit">
         <parameter name="aEvent"/>
         <body>
         <![CDATA[
+          let { AppConstants } =
+              Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
+
           function focusInit() {
             const dialog = document.documentElement;
             const defaultButton = dialog.getButton(dialog.defaultButton);
             // give focus to the first focusable element in the dialog
             if (!document.commandDispatcher.focusedElement) {
               document.commandDispatcher.advanceFocusIntoSubtree(dialog);
 
               var focusedElt = document.commandDispatcher.focusedElement;
@@ -183,21 +186,20 @@
 
                 if (initialFocusedElt.localName == "tab") {
                   if (focusedElt.hasAttribute("dlgtype")) {
                     // We don't want to focus on anonymous OK, Cancel, etc. buttons,
                     // so return focus to the tab itself
                     initialFocusedElt.focus();
                   }
                 }
-#ifndef XP_MACOSX
-                else if (focusedElt.hasAttribute("dlgtype") && focusedElt != defaultButton) {
+                else if (AppConstants.platform != "macosx" &&
+                         focusedElt.hasAttribute("dlgtype") && focusedElt != defaultButton) {
                   defaultButton.focus();
                 }
-#endif
               }
             }
 
             try {
               if (defaultButton)
                 window.notifyDefaultButtonLoaded(defaultButton);
             } catch (e) { }
           }
@@ -304,23 +306,24 @@
                           disclosure: false, extra1: false, extra2: false };
             for (i = 0; i < list.length; ++i)
               shown[list[i].replace(/ /g, "")] = true;
 
             // hide/show the buttons we want
             for (dlgtype in buttons) 
               buttons[dlgtype].hidden = !shown[dlgtype];
 
-#ifdef XP_WIN
-#           show the spacer on Windows only when the extra2 button is present
-            var spacer = document.getAnonymousElementByAttribute(this, "anonid", "spacer");
-            spacer.removeAttribute("hidden");
-            spacer.setAttribute("flex", shown["extra2"]?"1":"0");
-#endif
-
+            let { AppConstants } =
+                Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
+            // show the spacer on Windows only when the extra2 button is present
+            if (AppConstants.platform == "win") {
+              var spacer = document.getAnonymousElementByAttribute(this, "anonid", "spacer");
+              spacer.removeAttribute("hidden");
+              spacer.setAttribute("flex", shown["extra2"]?"1":"0");
+            }
           }
         ]]>
         </body>
       </method>
 
       <method name="_setDefaultButton">
         <parameter name="aNewDefault"/>
         <body>
--- a/toolkit/content/widgets/filefield.xml
+++ b/toolkit/content/widgets/filefield.xml
@@ -46,34 +46,35 @@
           return val;
         ]]>
         </setter>
       </property>      
       <method name="_getDisplayNameForFile">
         <parameter name="aFile"/>
         <body>
         <![CDATA[
-#ifdef XP_WIN
-          var lfw = aFile.QueryInterface(Components.interfaces.nsILocalFileWin);
-          try {
-            return lfw.getVersionInfoField("FileDescription"); 
-          }
-          catch (e) {
-            // fall through to the filename
+          let { AppConstants } =
+              Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
+          if (AppConstants.platform == "win") {
+            var lfw = aFile.QueryInterface(Components.interfaces.nsILocalFileWin);
+            try {
+              return lfw.getVersionInfoField("FileDescription");
+            }
+            catch (e) {
+              // fall through to the filename
+            }
+          } else if (AppConstants.platform == "macosx") {
+            var lfm = aFile.QueryInterface(Components.interfaces.nsILocalFileMac);
+            try {
+              return lfm.bundleDisplayName;
+            }
+            catch (e) {
+              // fall through to the file name
+            }
           }
-#endif
-#ifdef XP_MACOSX
-          var lfm = aFile.QueryInterface(Components.interfaces.nsILocalFileMac);
-          try {
-            return lfm.bundleDisplayName;
-          }
-          catch (e) {
-            // fall through to the file name
-          }
-#endif
           var ios = Components.classes["@mozilla.org/network/io-service;1"]
                               .getService(Components.interfaces.nsIIOService);
           var url = ios.newFileURI(aFile).QueryInterface(Components.interfaces.nsIURL);
           return url.fileName;
         ]]>
         </body>
       </method>
       
--- a/toolkit/content/widgets/findbar.xml
+++ b/toolkit/content/widgets/findbar.xml
@@ -29,21 +29,17 @@
 
       <method name="_handleEnter">
         <parameter name="aEvent"/>
         <body><![CDATA[
           if (this.findbar._findMode == this.findbar.FIND_NORMAL) {
             let findString = this.findbar._findField;
             if (!findString.value)
               return;
-#ifdef XP_MACOSX
-            if (aEvent.metaKey) {
-#else
-            if (aEvent.ctrlKey) {
-#endif
+            if (aEvent.getModifierState("Accel")) {
               this.findbar.getElement("highlight").click();
               return;
             }
 
             this.findbar.onFindAgainCommand(aEvent.shiftKey);
           } else {
             this.findbar._finishFAYT(aEvent);
           }
@@ -113,22 +109,24 @@
 
       <handler event="blur"><![CDATA[
         let findbar = this.findbar;
         // Note: This code used to remove the selection
         // if it matched an editable.
         findbar.browser.finder.enableSelection();
       ]]></handler>
 
-#ifdef XP_MACOSX
       <handler event="focus"><![CDATA[
-        let findbar = this.findbar;
-        findbar._onFindFieldFocus();
+        let { AppConstants } =
+            Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
+        if (AppConstants.platform == "macosx") {
+          let findbar = this.findbar;
+          findbar._onFindFieldFocus();
+        }
       ]]></handler>
-#endif
 
       <handler event="compositionstart"><![CDATA[
         // Don't close the find toolbar while IME is composing.
         let findbar = this.findbar;
         findbar._isIMEComposing = true;
         if (findbar._quickFindTimeout) {
           clearTimeout(findbar._quickFindTimeout);
           findbar._quickFindTimeout = null;
@@ -1205,23 +1203,23 @@
         <parameter name="aSelectionString" />
         <parameter name="aIsInitialSelection" />
         <body><![CDATA[
           // Ignore the prefill if the user has already typed in the findbar,
           // it would have been overwritten anyway. See bug 1198465.
           if (aIsInitialSelection && !this._startFindDeferred)
             return;
 
-#ifdef XP_MACOSX
-          if (aIsInitialSelection && !aSelectionString) {
+          let { AppConstants } =
+              Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
+          if (AppConstants.platform == "macosx" && aIsInitialSelection && !aSelectionString) {
             let clipboardSearchString = this.browser.finder.clipboardSearchString;
             if (clipboardSearchString)
               aSelectionString = clipboardSearchString;
           }
-#endif
 
           if (aSelectionString)
             this._findField.value = aSelectionString;
 
           if (aIsInitialSelection) {
             this._enableFindButtons(!!this._findField.value);
             this._findField.select();
             this._findField.focus();
--- a/toolkit/content/widgets/listbox.xml
+++ b/toolkit/content/widgets/listbox.xml
@@ -961,21 +961,20 @@
     <handlers>
       <!-- If there is no modifier key, we select on mousedown, not
            click, so that drags work correctly. -->
       <handler event="mousedown">
       <![CDATA[
         var control = this.control;
         if (!control || control.disabled)
           return;
-        if ((!event.ctrlKey
-#ifdef XP_MACOSX
-             || event.button == 2
-#endif
-            ) && !event.shiftKey && !event.metaKey) {
+        let { AppConstants } =
+            Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
+        if ((!event.ctrlKey || (AppConstants.platform == "macosx" && event.button == 2)) &&
+            !event.shiftKey && !event.metaKey) {
           if (!this.selected) {
             control.selectItem(this);
           }
           control.currentItem = this;
         }
       ]]>
       </handler>
 
--- a/toolkit/content/widgets/preferences.xml
+++ b/toolkit/content/widgets/preferences.xml
@@ -626,29 +626,32 @@
                                  .getService(Components.interfaces.nsIPrefBranch);
             this.instantApply = psvc.getBoolPref("browser.preferences.instantApply");
           }
           if (this.instantApply) {
             var docElt = document.documentElement;
             var acceptButton = docElt.getButton("accept");
             acceptButton.hidden = true;
             var cancelButton  = docElt.getButton("cancel");
-#ifdef XP_MACOSX
-            // no buttons on Mac except Help
-            cancelButton.hidden = true;
-            // Move Help button to the end
-            document.getAnonymousElementByAttribute(this, "anonid", "spacer").hidden = true;         
-            // Also, don't fire onDialogAccept on enter
-            acceptButton.disabled = true;
-#else
-            // morph the Cancel button into the Close button
-            cancelButton.setAttribute ("icon", "close");
-            cancelButton.label = docElt.getAttribute("closebuttonlabel");
-            cancelButton.accesskey = docElt.getAttribute("closebuttonaccesskey");
-#endif
+
+            let { AppConstants } =
+                Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
+            if (AppConstants.platform == "macosx") {
+              // no buttons on Mac except Help
+              cancelButton.hidden = true;
+              // Move Help button to the end
+              document.getAnonymousElementByAttribute(this, "anonid", "spacer").hidden = true;         
+              // Also, don't fire onDialogAccept on enter
+              acceptButton.disabled = true;
+            } else {
+              // morph the Cancel button into the Close button
+              cancelButton.setAttribute ("icon", "close");
+              cancelButton.label = docElt.getAttribute("closebuttonlabel");
+              cancelButton.accesskey = docElt.getAttribute("closebuttonaccesskey");
+            }
           }
         }
         this.setAttribute("animated", this._shouldAnimate ? "true" : "false");
         var panes = this.preferencePanes;
 
         var lastPane = null;
         if (this.lastSelected) {
           lastPane = document.getElementById(this.lastSelected);
@@ -808,21 +811,23 @@
         </body>
       </method>
       
       <field name="_initialized">false</field>
       <method name="_selectPane">
         <parameter name="aPaneElement"/>
         <body>
         <![CDATA[
-#ifdef XP_MACOSX
-          var paneTitle = aPaneElement.label;
-          if (paneTitle != "")
-            document.title = paneTitle;
-#endif
+          let { AppConstants } =
+              Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
+          if (AppConstants.platform == "macosx") {
+            var paneTitle = aPaneElement.label;
+            if (paneTitle != "")
+              document.title = paneTitle;
+          }
           var helpButton = document.documentElement.getButton("help");
           if (aPaneElement.helpTopic)
             helpButton.hidden = false;
           else
             helpButton.hidden = true;
 
           // Find this pane's index in the deck and set the deck's 
           // selectedIndex to that value to switch to it.
@@ -882,23 +887,21 @@
           }
         ]]>
         </body>
       </method>
       
       <property name="_shouldAnimate">
         <getter>
         <![CDATA[
+          let { AppConstants } =
+              Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
           var psvc = Components.classes["@mozilla.org/preferences-service;1"]
                                .getService(Components.interfaces.nsIPrefBranch);
-#ifdef XP_MACOSX
-          var animate = true;
-#else
-          var animate = false;
-#endif
+          var animate = AppConstants.platform == "macosx";
           try {
             animate = psvc.getBoolPref("browser.preferences.animateFadeIn");
           }
           catch (e) { }
           return animate;
         ]]>
         </getter>
       </property>
--- a/toolkit/content/widgets/remote-browser.xml
+++ b/toolkit/content/widgets/remote-browser.xml
@@ -504,18 +504,21 @@
         </body>
       </method>
 
       <method name="purgeSessionHistory">
         <body>
           <![CDATA[
             try {
               this.messageManager.sendAsyncMessage("Browser:PurgeSessionHistory");
-            } catch (ex if ex.result == Components.results.NS_ERROR_NOT_INITIALIZED) {
+            } catch (ex) {
               // This can throw if the browser has started to go away.
+              if (ex.result != Components.results.NS_ERROR_NOT_INITIALIZED) {
+                throw ex;
+              }
             }
             this.webNavigation.canGoBack = false;
             this.webNavigation.canGoForward = false;
           ]]>
         </body>
       </method>
     </implementation>
 
--- a/toolkit/content/widgets/tabbox.xml
+++ b/toolkit/content/widgets/tabbox.xml
@@ -42,21 +42,21 @@
         <getter>
         <![CDATA[
           return (this.getAttribute("handleCtrlPageUpDown") != "false");
         ]]>
         </getter>
       </property>
 
       <field name="_handleMetaAltArrows" readonly="true">
-#ifdef XP_MACOSX
-        true
-#else
-        false
-#endif
+        {
+          let { AppConstants } =
+              Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
+          AppConstants.platform == "macosx";
+        }
       </field>
 
       <!-- _tabs and _tabpanels are deprecated, they exist only for
            backwards compatibility. -->
       <property name="_tabs" readonly="true" onget="return this.tabs;"/>
       <property name="_tabpanels" readonly="true" onget="return this.tabpanels;"/>
 
       <property name="tabs" readonly="true">
@@ -767,21 +767,21 @@
           }
         ]]></body>
       </method>
 
       <property name="linkedPanel" onget="return this.getAttribute('linkedpanel')"
                                    onset="this.setAttribute('linkedpanel', val); return val;"/>
 
       <field name="arrowKeysShouldWrap" readonly="true">
-#ifdef XP_MACOSX
-        true
-#else
-        false
-#endif
+        {
+          let { AppConstants } =
+              Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
+          AppConstants.platform == "macosx";
+        }
       </field>
       <field name="TelemetryStopwatch" readonly="true">
         {
           let tmp = {};
           Cu.import("resource://gre/modules/TelemetryStopwatch.jsm", tmp);
           tmp.TelemetryStopwatch;
         }
       </field>
--- a/toolkit/content/widgets/tree.xml
+++ b/toolkit/content/widgets/tree.xml
@@ -17,22 +17,17 @@
   <binding id="tree-base" extends="chrome://global/content/bindings/general.xml#basecontrol">
     <resources>
       <stylesheet src="chrome://global/skin/tree.css"/>
     </resources>
     <implementation>
       <method name="_isAccelPressed">
         <parameter name="aEvent"/>
         <body><![CDATA[
-# Workaround until bug 302174 is fixed
-#ifdef XP_MACOSX
-          return aEvent.metaKey;
-#else
-          return aEvent.ctrlKey;
-#endif
+          return aEvent.getModifierState("Accel");
         ]]></body>
       </method>
     </implementation>
   </binding>
 
   <binding id="tree" extends="chrome://global/content/bindings/tree.xml#tree-base" role="xul:tree">
     <content hidevscroll="true" hidehscroll="true" clickthrough="never">
       <children includes="treecols"/>
@@ -88,21 +83,21 @@
       <property name="contentView"
                 onget="return this.view; /*.QueryInterface(Components.interfaces.nsITreeContentView)*/"
                 readonly="true"/>
 # builderView is obsolete (see bug 202393)
       <property name="builderView"
                 onget="return this.view; /*.QueryInterface(Components.interfaces.nsIXULTreeBuilder)*/"
                 readonly="true"/>
       <field name="pageUpOrDownMovesSelection">
-#ifdef XP_MACOSX
-        false
-#else
-        true
-#endif
+        {
+          let { AppConstants } =
+              Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
+          AppConstants.platform != "macosx";
+        }
       </field>
       <property name="keepCurrentInView"
                 onget="return (this.getAttribute('keepcurrentinview') == 'true');"
                 onset="if (val) this.setAttribute('keepcurrentinview', 'true');
                        else this.removeAttribute('keepcurrentinview'); return val;"/>
 
       <property name="enableColumnDrag"
                 onget="return this.hasAttribute('enableColumnDrag');"
@@ -671,26 +666,28 @@
         <parameter name="event"/>
         <body><![CDATA[
           if (this._editingColumn) {
             this.stopEditing(true);
             this.focus();
             return true;
           }
 
-#ifdef XP_MACOSX
-          // See if we can edit the cell.
-          var row = this.currentIndex;
-          if (this._cellSelType) {
-            var column = this.view.selection.currentColumn;
-            var startedEditing = this.startEditing(row, column);
-            if (startedEditing)
-              return true;
+          let { AppConstants } =
+              Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
+          if (AppConstants.platform == "macosx") {
+            // See if we can edit the cell.
+            var row = this.currentIndex;
+            if (this._cellSelType) {
+              var column = this.view.selection.currentColumn;
+              var startedEditing = this.startEditing(row, column);
+              if (startedEditing)
+                return true;
+            }
           }
-#endif
           return this.changeOpenState(this.currentIndex);
         ]]></body>
       </method>
     </implementation>
     
     <handlers>
       <handler event="MozMousePixelScroll" preventdefault="true"/>
       <handler event="DOMMouseScroll" preventdefault="true">
@@ -1415,22 +1412,22 @@
           }
         }
       ]]></handler>
       <handler event="click" button="0" phase="target">
         <![CDATA[
           if (event.target != event.originalTarget)
             return;
 
-#ifdef XP_WIN
+          let { AppConstants } =
+              Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
           // On Windows multiple clicking on tree columns only cycles one time
           // every 2 clicks.
-          if (event.detail % 2 == 0)
+          if (AppConstants.platform == "win" && event.detail % 2 == 0)
             return;
-#endif
 
           var tree = this.parentNode.parentNode;
           var column = tree.columns.getColumnFor(this);
           tree.view.cycleHeader(column);
         ]]>
       </handler>
     </handlers>
   </binding>
--- a/toolkit/content/widgets/videocontrols.xml
+++ b/toolkit/content/widgets/videocontrols.xml
@@ -789,26 +789,28 @@
                     // XXX Can't set increment here, due to bug 473103. Also, doing so causes
                     // snapping when dragging with the mouse, so we can't just set a value for
                     // the arrow-keys.
                     //this.scrubber.increment = duration / 50;
                     this.scrubber.pageIncrement = Math.round(duration / 10);
                 },
 
                 seekToPosition : function(newPosition) {
+                    let { AppConstants } =
+                        Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
                     newPosition /= 1000; // convert from ms
                     this.log("+++ seeking to " + newPosition);
-#ifdef MOZ_WIDGET_GONK
-                    // We use fastSeek() on B2G, and an accurate (but slower)
-                    // seek on other platforms (that are likely to be higher
-                    // perf).
-                    this.video.fastSeek(newPosition);
-#else
-                    this.video.currentTime = newPosition;
-#endif
+                    if (AppConstants.platform == "gonk") {
+                        // We use fastSeek() on B2G, and an accurate (but slower)
+                        // seek on other platforms (that are likely to be higher
+                        // perf).
+                        this.video.fastSeek(newPosition);
+                    } else {
+                        this.video.currentTime = newPosition;
+                    }
                 },
 
                 setVolume : function(newVolume) {
                     this.log("*** setting volume to " + newVolume);
                     this.video.volume = newVolume;
                     this.video.muted = false;
                 },
 
@@ -1247,32 +1249,34 @@
                     s.volume.textContent = volume;
                 },
 
                 keyHandler : function(event) {
                     // Ignore keys when content might be providing its own.
                     if (!this.video.hasAttribute("controls"))
                         return;
 
+                    let { AppConstants } =
+                        Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
                     var keystroke = "";
                     if (event.altKey)
                         keystroke += "alt-";
                     if (event.shiftKey)
                         keystroke += "shift-";
-#ifdef XP_MACOSX
-                    if (event.metaKey)
-                        keystroke += "accel-";
-                    if (event.ctrlKey)
-                        keystroke += "control-";
-#else
-                    if (event.metaKey)
-                        keystroke += "meta-";
-                    if (event.ctrlKey)
-                        keystroke += "accel-";
-#endif
+                    if (AppConstants.platform == "macosx") {
+                        if (event.metaKey)
+                            keystroke += "accel-";
+                        if (event.ctrlKey)
+                            keystroke += "control-";
+                    } else {
+                        if (event.metaKey)
+                            keystroke += "meta-";
+                        if (event.ctrlKey)
+                            keystroke += "accel-";
+                    }
 
                     switch (event.keyCode) {
                         case KeyEvent.DOM_VK_UP:
                             keystroke += "upArrow";
                             break;
                         case KeyEvent.DOM_VK_DOWN:
                             keystroke += "downArrow";
                             break;
--- a/toolkit/content/widgets/wizard.xml
+++ b/toolkit/content/widgets/wizard.xml
@@ -67,33 +67,32 @@
           if (!val)
             return val;
             
           this._currentPage = val;
 
           // Setting this attribute allows wizard's clients to dynamically
           // change the styles of each page based on purpose of the page. 
           this.setAttribute("currentpageid", val.pageid);
-                    
+
+          let { AppConstants } =
+              Components.utils.import("resource://gre/modules/AppConstants.jsm", {}); 
+
           if (this.onFirstPage) {
             this.canRewind = false;
             this.setAttribute("firstpage", "true");
-#ifdef XP_UNIX
-#ifndef XP_MACOSX
-            this._backButton.setAttribute('hidden', 'true');
-#endif
-#endif
+            if (AppConstants.XP_UNIX && AppConstants.platform != "macosx") {
+              this._backButton.setAttribute('hidden', 'true');
+            }
           } else {
             this.canRewind = true;
             this.setAttribute("firstpage", "false");
-#ifdef XP_UNIX
-#ifndef XP_MACOSX
-            this._backButton.setAttribute('hidden', 'false');
-#endif
-#endif
+            if (AppConstants.XP_UNIX && AppConstants.platform != "macosx") {
+              this._backButton.setAttribute('hidden', 'false');
+            }
           }
                     
           if (this.onLastPage) {
             this.canAdvance = true;
             this.setAttribute("lastpage", "true");
           } else {
             this.setAttribute("lastpage", "false");
           }
@@ -385,29 +384,32 @@
            this["_"+aName+"Button"] = btn;
          }
          return btn;
         ]]></body>
       </method>
 
       <method name="_adjustWizardHeader">
         <body><![CDATA[
+          let { AppConstants } =
+              Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
           var label = this.currentPage.getAttribute("label");
-          if (!label && this.onFirstPage && this._bundle)
-#ifdef XP_MACOSX
-            label = this._bundle.GetStringFromName("default-first-title-mac");
-#else
-            label = this._bundle.formatStringFromName("default-first-title", [this.title], 1);
-#endif
-          else if (!label && this.onLastPage && this._bundle)
-#ifdef XP_MACOSX
-            label = this._bundle.GetStringFromName("default-last-title-mac");
-#else
-            label = this._bundle.formatStringFromName("default-last-title", [this.title], 1);
-#endif
+          if (!label && this.onFirstPage && this._bundle) {
+            if (AppConstants.platform == "macosx") {
+              label = this._bundle.GetStringFromName("default-first-title-mac");
+            } else {
+              label = this._bundle.formatStringFromName("default-first-title", [this.title], 1);
+            }
+          } else if (!label && this.onLastPage && this._bundle) {
+            if (AppConstants.platform == "macosx") {
+              label = this._bundle.GetStringFromName("default-last-title-mac");
+            } else {
+              label = this._bundle.formatStringFromName("default-last-title", [this.title], 1);
+            }
+          }
           this._wizardHeader.setAttribute("label", label);
           this._wizardHeader.setAttribute("description", this.currentPage.getAttribute("description"));
         ]]></body>
       </method>
 
       <method name="_hitEnter">
         <parameter name="evt"/>
         <body>
--- a/toolkit/modules/AppConstants.jsm
+++ b/toolkit/modules/AppConstants.jsm
@@ -132,16 +132,23 @@ this.AppConstants = Object.freeze({
 # MOZ_B2G covers both device and desktop b2g
   MOZ_B2G:
 #ifdef MOZ_B2G
   true,
 #else
   false,
 #endif
 
+  XP_UNIX:
+#ifdef XP_UNIX
+  true,
+#else
+  false,
+#endif
+
 # NOTE! XP_LINUX has to go after MOZ_WIDGET_ANDROID otherwise Android
 # builds will be misidentified as linux.
   platform:
 #ifdef MOZ_WIDGET_GTK
   "linux",
 #elif MOZ_WIDGET_QT
   "linux",
 #elif XP_WIN
--- a/toolkit/modules/GMPInstallManager.jsm
+++ b/toolkit/modules/GMPInstallManager.jsm
@@ -182,25 +182,16 @@ GMPInstallManager.prototype = {
    */
   simpleCheckAndInstall: Task.async(function*() {
     let log = getScopedLogger("GMPInstallManager.simpleCheckAndInstall");
 
     if (this._versionchangeOccurred()) {
       log.info("A version change occurred. Ignoring " +
                "media.gmp-manager.lastCheck to check immediately for " +
                "new or updated GMPs.");
-      // Firefox updated; it could be that the TrialGMPVideoDecoderCreator
-      // had failed but could now succeed, or vice versa. So reset the
-      // prefs so we re-try next time EME is used.
-      GMP_PLUGIN_IDS.concat("gmp-eme-clearkey").forEach(
-        function(id, index, array) {
-          log.info("Version change, resetting " +
-                   GMPPrefs.getPrefKey(GMPPrefs.KEY_PLUGIN_TRIAL_CREATE, id));
-          GMPPrefs.reset(GMPPrefs.KEY_PLUGIN_TRIAL_CREATE, id);
-        });
     } else {
       let secondsBetweenChecks =
         GMPPrefs.get(GMPPrefs.KEY_SECONDS_BETWEEN_CHECKS,
                      DEFAULT_SECONDS_BETWEEN_CHECKS)
       let secondsSinceLast = this._getTimeSinceLastCheck();
       log.info("Last check was: " + secondsSinceLast +
                " seconds ago, minimum seconds: " + secondsBetweenChecks);
       if (secondsBetweenChecks > secondsSinceLast) {
@@ -490,20 +481,16 @@ GMPDownloader.prototype = {
                               gmpAddon.version);
       log.info("install to directory path: " + path);
       let gmpInstaller = new GMPExtractor(zipPath, path);
       let installPromise = gmpInstaller.install();
       return installPromise.then(extractedPaths => {
         // Success, set the prefs
         let now = Math.round(Date.now() / 1000);
         GMPPrefs.set(GMPPrefs.KEY_PLUGIN_LAST_UPDATE, now, gmpAddon.id);
-        // Reset the trial create pref, so that Gecko knows to do a test
-        // run before reporting that the GMP works to content.
-        GMPPrefs.reset(GMPPrefs.KEY_PLUGIN_TRIAL_CREATE, gmpAddon.version,
-                       gmpAddon.id);
         // Remember our ABI, so that if the profile is migrated to another
         // platform or from 32 -> 64 bit, we notice and don't try to load the
         // unexecutable plugin library.
         GMPPrefs.set(GMPPrefs.KEY_PLUGIN_ABI, UpdateUtils.ABI, gmpAddon.id);
         // Setting the version pref signals installation completion to consumers,
         // if you need to set other prefs etc. do it before this.
         GMPPrefs.set(GMPPrefs.KEY_PLUGIN_VERSION, gmpAddon.version,
                      gmpAddon.id);
--- a/toolkit/modules/GMPUtils.jsm
+++ b/toolkit/modules/GMPUtils.jsm
@@ -133,17 +133,16 @@ this.GMPUtils = {
  */
 this.GMPPrefs = {
   KEY_EME_ENABLED:              "media.eme.enabled",
   KEY_PLUGIN_ENABLED:           "media.{0}.enabled",
   KEY_PLUGIN_LAST_UPDATE:       "media.{0}.lastUpdate",
   KEY_PLUGIN_VERSION:           "media.{0}.version",
   KEY_PLUGIN_AUTOUPDATE:        "media.{0}.autoupdate",
   KEY_PLUGIN_FORCEVISIBLE:      "media.{0}.forcevisible",
-  KEY_PLUGIN_TRIAL_CREATE:      "media.{0}.trial-create",
   KEY_PLUGIN_ABI:               "media.{0}.abi",
   KEY_URL:                      "media.gmp-manager.url",
   KEY_URL_OVERRIDE:             "media.gmp-manager.url.override",
   KEY_CERT_CHECKATTRS:          "media.gmp-manager.cert.checkAttributes",
   KEY_CERT_REQUIREBUILTIN:      "media.gmp-manager.cert.requireBuiltIn",
   KEY_UPDATE_LAST_CHECK:        "media.gmp-manager.lastCheck",
   KEY_SECONDS_BETWEEN_CHECKS:   "media.gmp-manager.secondsBetweenChecks",
   KEY_APP_DISTRIBUTION:         "distribution.id",
--- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/GMPProvider.jsm
@@ -439,17 +439,16 @@ GMPWrapper.prototype = {
   uninstallPlugin: function() {
     AddonManagerPrivate.callAddonListeners("onUninstalling", this, false);
     if (this.gmpPath) {
       this._log.info("uninstallPlugin() - unregistering gmp directory " +
                      this.gmpPath);
       gmpService.removeAndDeletePluginDirectory(this.gmpPath);
     }
     GMPPrefs.reset(GMPPrefs.KEY_PLUGIN_VERSION, this.id);
-    GMPPrefs.reset(GMPPrefs.KEY_PLUGIN_TRIAL_CREATE, this.id);
     GMPPrefs.reset(GMPPrefs.KEY_PLUGIN_ABI, this.id);
     GMPPrefs.reset(GMPPrefs.KEY_PLUGIN_LAST_UPDATE, this.id);
     AddonManagerPrivate.callAddonListeners("onUninstalled", this);
   },
 
   shutdown: function() {
     Preferences.ignore(GMPPrefs.getPrefKey(GMPPrefs.KEY_PLUGIN_ENABLED,
                                            this._plugin.id),
@@ -600,22 +599,16 @@ var GMPProvider = {
         this._log.info("startup - adding clearkey CDM directory " +
                        clearkeyPath);
         gmpService.addPluginDirectory(clearkeyPath);
       } catch (e) {
         this._log.warn("startup - adding clearkey CDM failed", e);
       }
     }
 
-    if (Preferences.get("media.gmp-adobe-eme.enabled", false)) {
-      // Gather telemetry on how many Adobe-compatible installs have
-      // disabled EME.
-      telemetryService.getHistogramById("VIDEO_EME_DISABLED").add(!emeEnabled);
-    }
-
     AddonManagerPrivate.setTelemetryDetails("GMP", telemetry);
   },
 
   shutdown: function() {
     this._log.trace("shutdown");
     Preferences.ignore(GMPPrefs.KEY_LOG_BASE, configureLogging);
 
     let shutdownTask = Task.spawn(function*() {