Merge old head via |hg debugsetparents a2a6201322ad1cd09202b53b9c2cbf40b26026ee d82221ba4219e4ac04ecfe2a5301703411e176fa|. CLOSED TREE DONTBUILD a=release
authorffxbld <release@mozilla.com>
Mon, 25 Jan 2016 08:59:31 -0500
changeset 303695 b221daea8af0e78f5bbe1e4653e3148f23e63028
parent 303694 a2a6201322ad1cd09202b53b9c2cbf40b26026ee (diff)
parent 298526 d82221ba4219e4ac04ecfe2a5301703411e176fa (current diff)
child 303696 d40aae7aef235f46d89f4a32242637d984f621d5
push id8978
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 14:05:32 +0000
treeherdermozilla-aurora@b9a803752a2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrelease
milestone46.0a1
Merge old head via |hg debugsetparents a2a6201322ad1cd09202b53b9c2cbf40b26026ee d82221ba4219e4ac04ecfe2a5301703411e176fa|. CLOSED TREE DONTBUILD a=release
--- a/.eslintignore
+++ b/.eslintignore
@@ -59,69 +59,96 @@ b2g/locales/en-US/b2g-l10n.js
 
 # browser/ exclusions
 browser/app/**
 browser/base/content/browser-social.js
 browser/base/content/nsContextMenu.js
 browser/base/content/sanitizeDialog.js
 browser/base/content/test/**
 browser/base/content/newtab/**
-browser/components/customizableui/**
 browser/components/downloads/**
 browser/components/feeds/**
 browser/components/migration/**
-browser/components/*.js
-browser/components/places/**
 browser/components/pocket/**
 browser/components/preferences/**
 browser/components/privatebrowsing/**
 browser/components/sessionstore/**
 browser/components/shell/**
 browser/components/tabview/**
 browser/components/translation/**
-browser/components/uitour/**
-browser/experiments/**
 browser/extensions/pdfjs/**
+browser/extensions/pocket/content/panels/js/vendor/**
 browser/extensions/shumway/**
 browser/fuel/**
 browser/locales/**
-browser/modules/**
-
-# Loop specific exclusions
 
 # Ignore all of loop since it is imported from github and checked at source.
 browser/extensions/loop/**
 
 # devtools/ exclusions
-# Ignore d3
-devtools/client/shared/d3.js
-devtools/client/webaudioeditor/lib/dagre-d3.js
+devtools/*.js
+devtools/client/*.js
+devtools/client/aboutdebugging/**
+devtools/client/animationinspector/**
+devtools/client/canvasdebugger/**
+devtools/client/commandline/**
+devtools/client/debugger/**
+devtools/client/eyedropper/**
+devtools/client/framework/**
+# devtools/client/inspector/shared/*.js files are eslint-clean, so they aren't
+# included in the ignore list.
+devtools/client/inspector/computed/**
+devtools/client/inspector/fonts/**
+devtools/client/inspector/layout/**
+devtools/client/inspector/markup/**
+devtools/client/inspector/rules/**
+devtools/client/inspector/shared/test/**
+devtools/client/inspector/test/**
+devtools/client/inspector/*.js
+devtools/client/jsonview/**
+devtools/client/memory/**
+devtools/client/netmonitor/**
+devtools/client/performance/**
+devtools/client/projecteditor/**
+devtools/client/promisedebugger/**
+devtools/client/responsivedesign/**
+devtools/client/scratchpad/**
+devtools/client/shadereditor/**
+devtools/client/shared/**
+devtools/client/sourceeditor/**
+devtools/client/storage/**
+devtools/client/styleeditor/**
+devtools/client/tilt/**
+devtools/client/webaudioeditor/**
+devtools/client/webconsole/**
+devtools/client/webide/**
+devtools/server/**
+devtools/shared/**
 
-# Ignore codemirror
-devtools/client/sourceeditor/codemirror/*.js
-devtools/client/sourceeditor/codemirror/**/*.js
-devtools/client/sourceeditor/test/codemirror/*
-
-# Ignore jquery test libs
-devtools/client/markupview/test/lib_*
-
-# Ignore pre-processed files
+# Ignore devtools pre-processed files
 devtools/client/framework/toolbox-process-window.js
 devtools/client/performance/system.js
 devtools/client/webide/webide-prefs.js
+devtools/client/preferences/**
 
-# Ignore various libs
+# Ignore devtools third-party libs
 devtools/shared/jsbeautify/*
 devtools/shared/acorn/*
 devtools/client/sourceeditor/tern/*
 devtools/shared/pretty-fast/*
 devtools/shared/sourcemap/*
 devtools/shared/qrcode/decoder/*
 devtools/shared/qrcode/encoder/*
 devtools/client/shared/vendor/*
+devtools/client/shared/d3.js
+devtools/client/webaudioeditor/lib/dagre-d3.js
+devtools/client/sourceeditor/codemirror/*.js
+devtools/client/sourceeditor/codemirror/**/*.js
+devtools/client/sourceeditor/test/codemirror/*
+devtools/client/markupview/test/lib_*
 
 # mobile/android/ exclusions
 mobile/android/chrome/content
 mobile/android/tests/
 
 # Uses `#filter substitution`
 mobile/android/b2gdroid/app/b2gdroid.js
 mobile/android/app/mobile.js
@@ -156,23 +183,22 @@ toolkit/components/help/**
 toolkit/components/workerloader/tests/moduleF-syntax-error.js
 
 # Tests old non-star function generators
 toolkit/modules/tests/xpcshell/test_task.js
 
 # Not yet updated
 toolkit/components/osfile/**
 toolkit/components/passwordmgr/**
-toolkit/components/places/**
 
 # Uses preprocessing
 toolkit/content/contentAreaUtils.js
+toolkit/content/widgets/videocontrols.xml
 toolkit/components/jsdownloads/src/DownloadIntegration.jsm
 toolkit/components/search/nsSearchService.js
 toolkit/components/url-classifier/**
 toolkit/components/urlformatter/nsURLFormatter.js
 toolkit/identity/FirefoxAccounts.jsm
 toolkit/modules/AppConstants.jsm
-toolkit/modules/SessionRecorder.jsm
 toolkit/mozapps/downloads/nsHelperAppDlg.js
 toolkit/mozapps/extensions/internal/AddonConstants.jsm
 toolkit/mozapps/update/tests/data/xpcshellConstantsPP.js
 toolkit/webapps/**
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,9 +1,14 @@
 {
   // When adding items to this file please check for effects on sub-directories.
   "plugins": [
     "mozilla"
   ],
+  "rules": {
+    "mozilla/components-imports": 1,
+    "mozilla/import-globals-from": 1,
+    "mozilla/this-top-level-scope": 1,
+  },
   "env": {
     "es6": true
   },
 }
--- a/.hgtags
+++ b/.hgtags
@@ -97,64 +97,30 @@ 8d3810543edccf4fbe458178b88dd4a6e420b010
 ad0ae007aa9e03cd74e9005cd6652e544139b3b5 FIREFOX_AURORA_25_BASE
 2520866d58740851d862c7c59246a4e3f8b4a176 FIREFOX_AURORA_26_BASE
 05025f4889a0bf4dc99ce0c244c750adc002f015 FIREFOX_AURORA_27_BASE
 9f12a9fab080f2d363d7424e25b9ffe85ebc3414 FIREFOX_AURORA_28_BASE
 ba2cc1eda988a1614d8986ae145d28e1268409b9 FIREFOX_AURORA_29_BASE
 83c9853e136451474dfa6d1aaa60a7fca7d2d83a FIREFOX_AURORA_30_BASE
 cfde3603b0206e119abea76fdd6e134b634348f1 FIREFOX_AURORA_31_BASE
 16f3cac5e8fe471e12f76d6a94a477b14e78df7c FIREFOX_AURORA_32_BASE
-f11b164d75442617c4f046177d2ab913ed03a318 FIREFOX_BETA_31_BASE
-f11b164d75442617c4f046177d2ab913ed03a318 FIREFOX_AURORA_31_END
-dc2fd26b301375f15c935f00fe6283d3e3bc1efc B2G_2_0_20140609_MERGEDAY
-d69cd84b6824e018e0906cab0464e11e97a9bdca FIREFOX_BETA_32_BASE
-d69cd84b6824e018e0906cab0464e11e97a9bdca FIREFOX_BETA_32_BASE
-0000000000000000000000000000000000000000 FIREFOX_BETA_32_BASE
-0000000000000000000000000000000000000000 FIREFOX_BETA_32_BASE
-ac396ad5a32d60ae5b7eebe5416fdd46e9e12be1 FIREFOX_BETA_32_BASE
 dc23164ba2a289a8b22902e30990c77d9677c214 FIREFOX_AURORA_33_BASE
-a104ddcd4cdbf950f1755dfaf5a278d53570655f FIREFOX_AURORA_32_END
-114b010b6bf1a0efee03f003e54ed6fa00909972 FIREFOX_BETA_33_BASE
 c360f3d1c00d73b0c1fb0a2c0da525cb55e58b83 FIREFOX_AURORA_34_BASE
-9f1aad8e807cc283aafbc14caa3d4775e8d0535c FIREFOX_AURORA_33_END
-5b8210dcf52a795646bf0c8a32082a2ed7c4f537 B2G_2_1_20140902_MERGEDAY
-e85828ce78a80e2ccda98972d69d5f750335c4ab FIREFOX_BETA_34_BASE
 cec1a116c4f9a3e887d52e9a26e8bbec200fe162 FIREFOX_AURORA_35_BASE
-2608561c091ae83cc85e38740feffa5bfc6b5ed4 FIREFOX_AURORA_34_END
-390a34a40ea4e7f4d24b3ed83778e0f408411fcc FIREFOX_BETA_35_BASE
 ca89fe55717059e4e43040d16d260765ffa9dca7 FIREFOX_AURORA_36_BASE
 6047f510fb73c7dbe9866066fb01ddda3c170c9c FIREFOX_AURORA_37_BASE
 ca89fe55717059e4e43040d16d260765ffa9dca7 FIREFOX_AURORA_36_BASE
 0000000000000000000000000000000000000000 FIREFOX_AURORA_36_BASE
 6047f510fb73c7dbe9866066fb01ddda3c170c9c FIREFOX_AURORA_37_BASE
 0000000000000000000000000000000000000000 FIREFOX_AURORA_37_BASE
 0000000000000000000000000000000000000000 FIREFOX_AURORA_36_BASE
 b297a6727acfd21e757ddd38cd61894812666265 FIREFOX_AURORA_36_BASE
-0cf828669d5a0911b6f2b83d501eeef5bdf9905e FIREFOX_AURORA_35_END
-75177371cb85baaa9d623f56d849a5c21d18040f FIREFOX_BETA_36_BASE
 0000000000000000000000000000000000000000 FIREFOX_AURORA_37_BASE
 2c951493eef5b50b8085ef78ffe0d7902ff3d593 FIREFOX_AURORA_37_BASE
-1bc9beda018a42bdd5f63fc9fc46facf0c6f37ec FIREFOX_AURORA_36_END
-030fa1665346dfa94d1f72a1c7830644664ecf08 FIREFOX_BETA_37_BASE
 98086da94ccdc88f6de86774ce3d1fa258dc7c44 FIREFOX_AURORA_38_BASE
-d55b99e8010728b0c802e75e967d2a853122dd30 FIREFOX_AURORA_37_END
-8bc9656cad94db48cd44f3947f1b3b1d8c57768a FIREFOX_BETA_38_BASE
 1b6bf6612c0f4d4fee81d18bf18016e692f874e1 FIREFOX_AURORA_39_BASE
-d92bf011e305a4a4ad6bb98192a53b86bd64b813 FIREFOX_AURORA_38_END
-5e851d50fb9b8d5a28e4fcd4731dd0f17e8fb4b9 FIREFOX_BETA_39_BASE
 66a95a483d2c77dfc387019336d18093acd6aac2 FIREFOX_AURORA_40_BASE
-eead3ccdf2d11feefc12907467cebbe07aa91ea9 FIREFOX_AURORA_39_END
-d77cf39268848f8a7e9b38082348b6cd4d1f3b5e FIREFOX_BETA_40_BASE
 312c68b16549de9cea1557f461d5d234bd5e0a7d FIREFOX_AURORA_41_BASE
-9d83ab013ab61c7f6e987bf0e7cbab1a1aed1ca8 FIREFOX_AURORA_40_END
-a019592053c4d93fbbafab8d0bd709529e3746de FIREFOX_BETA_41_BASE
 7a19194812eb767bee7cdf8fc36ba9a383c1bead FIREFOX_AURORA_42_BASE
-d561dc208e61b2f2b4e82ab61710e14f56da4ddb FIREFOX_AURORA_41_END
-61bbc30704aa104e9929c719c0fd7957f96f00ea FIREFOX_BETA_42_BASE
 fcef8ded82219c89298b4e376cfbdfba79a1d35a FIREFOX_AURORA_43_BASE
-b0e20ff87b175424edec414215b325918ccb4792 FIREFOX_AURORA_42_END
-41fdefd640f368bccdeafe6446d42c0a5ad22797 FIREFOX_BETA_43_BASE
 67a788db9f07822cfef52351bbbe3745dff8bd7f FIREFOX_AURORA_44_BASE
-9d3bc275a924a84ab5f34df58c566af0f87479d0 FIREFOX_AURORA_43_END
-b717b80eec62a7ba9b8842487f157b68c1419edd FIREFOX_BETA_44_BASE
 99137d6d4061f408ae0869122649d8bdf489cc30 FIREFOX_AURORA_45_BASE
-4fbd53613240c431522521b953d5a62692909e65 FIREFOX_AURORA_44_END
-3bfa5bc61b626761d487b45c170b115259f69d6b FIREFOX_BETA_45_BASE
+67c66c2878aed17ae3096d7db483ddbb2293c503 FIREFOX_AURORA_46_BASE
--- a/CLOBBER
+++ b/CLOBBER
@@ -17,9 +17,10 @@
 #
 # Modifying this file will now automatically clobber the buildbot machines \o/
 #
 
 # Are you updating CLOBBER because you think it's needed for your WebIDL
 # changes to stick? As of bug 928195, this shouldn't be necessary! Please
 # don't change CLOBBER for WebIDL changes any more.
 
-Merge day clobber
\ No newline at end of file
+Bug 1240627 - Enable AVX2 optimizations in ffvpx on Mac
+
--- a/Makefile.in
+++ b/Makefile.in
@@ -29,21 +29,23 @@ DIST_GARBAGE = config.cache config.log c
    .mozconfig.mk
 
 ifdef JS_STANDALONE
 configure_dir = $(topsrcdir)/js/src
 else
 configure_dir = $(topsrcdir)
 endif
 
+BUILD_BACKEND_FILES := $(addprefix backend.,$(addsuffix Backend,$(BUILD_BACKENDS)))
+
 ifndef TEST_MOZBUILD
 ifndef MOZ_PROFILE_USE
-# We need to explicitly put backend.RecursiveMakeBackend here
-# otherwise the rule in rules.mk doesn't run early enough.
-$(TIERS) binaries:: CLOBBER $(configure_dir)/configure config.status backend.RecursiveMakeBackend
+# We need to explicitly put BUILD_BACKEND_FILES here otherwise the rule in
+# rules.mk doesn't run early enough.
+$(TIERS) binaries:: CLOBBER $(configure_dir)/configure config.status $(BUILD_BACKEND_FILES)
 ifndef JS_STANDALONE
 ifdef COMPILE_ENVIRONMENT
 $(TIERS) binaries:: $(topsrcdir)/js/src/configure js/src/config.status
 endif
 endif
 endif
 endif
 
@@ -79,69 +81,114 @@ config.status js/src/config.status:
 # Regenerate the build backend if it is out of date. We only have this rule in
 # this main make file because having it in rules.mk and applied to partial tree
 # builds resulted in a world of hurt. Gory details are in bug 877308.
 #
 # The mach build driver will ensure the backend is up to date for partial tree
 # builds. This cleanly avoids most of the pain.
 
 ifndef TEST_MOZBUILD
-backend.RecursiveMakeBackend:
+
+.PHONY: backend
+backend: $(BUILD_BACKEND_FILES)
+
+# A traditional rule would look like this:
+#    backend.%:
+#        @echo do stuff
+#
+# But with -j<n>, and multiple items in BUILD_BACKEND_FILES, the command would
+# run multiple times in parallel.
+#
+# "Fortunately", make has some weird semantics for pattern rules: if there are
+# multiple targets in a pattern rule and each of them is matched at most once,
+# the command will only run once. So:
+#     backend%RecursiveMakeBackend backend%FasterMakeBackend:
+#         @echo do stuff
+#     backend: backend.RecursiveMakeBackend backend.FasterMakeBackend
+# would only execute the command once.
+#
+# Credit where due: http://stackoverflow.com/questions/2973445/gnu-makefile-rule-generating-a-few-targets-from-a-single-source-file/3077254#3077254
+$(subst .,%,$(BUILD_BACKEND_FILES)):
 	@echo 'Build configuration changed. Regenerating backend.'
 	$(PYTHON) config.status
 
-Makefile: backend.RecursiveMakeBackend
+Makefile: $(BUILD_BACKEND_FILES)
 	@$(TOUCH) $@
 
-include backend.RecursiveMakeBackend.pp
+define build_backend_rule
+$(1): $$(shell cat $(1).in)
 
-default:: backend.RecursiveMakeBackend
+endef
+$(foreach file,$(BUILD_BACKEND_FILES),$(eval $(call build_backend_rule,$(file))))
+
+default:: $(BUILD_BACKEND_FILES)
 endif
 
 install_manifests := \
-  $(addprefix dist/,bin branding idl include public private sdk xpi-stage) \
+  $(addprefix dist/,branding idl include public private sdk xpi-stage) \
   _tests \
   $(NULL)
+# Skip the dist/bin install manifest when using the hybrid
+# FasterMake/RecursiveMake backend. This is a hack until bug 1241744 moves
+# xpidl handling to FasterMake in that case, mechanically making the dist/bin
+# install manifest non-existent (non-existent manifests being skipped)
+ifeq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS)))
+install_manifests += dist/bin
+endif
 install_manifest_depends = \
   CLOBBER \
   $(configure_dir)/configure \
   config.status \
-  backend.RecursiveMakeBackend \
+  $(BUILD_BACKEND_FILES) \
   $(NULL)
 
 ifndef JS_STANDALONE
 ifdef COMPILE_ENVIRONMENT
 install_manifest_depends += \
   $(topsrcdir)/js/src/configure \
   js/src/config.status \
   $(NULL)
 endif
 endif
 
 .PHONY: install-manifests
 install-manifests: $(addprefix install-,$(install_manifests))
 
+# If we're using the hybrid FasterMake/RecursiveMake backend, we want
+# to recurse in the faster/ directory in parallel of install manifests.
+# But dist/idl needs to happen before (cf. dependencies in
+# config/faster/rules.mk)
+ifneq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS)))
+install-manifests: faster
+.PHONY: faster
+faster: install-dist/idl
+	$(MAKE) -C faster FASTER_RECURSIVE_MAKE=1
+endif
+
 # process_install_manifest needs to be invoked with --no-remove when building
 # js as standalone because automated builds are building nspr separately and
 # that would remove the resulting files.
 # Eventually, a standalone js build would just be able to build nspr itself,
 # removing the need for the former.
 ifdef JS_STANDALONE
 NO_REMOVE=1
 endif
 
-.PHONY: $(addprefix install-,$(install_manifests))
-$(addprefix install-,$(filter dist/%,$(install_manifests))): install-dist/%: $(install_manifest_depends)
-	$(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )$(DIST)/$* _build_manifests/install/dist_$*)
+.PHONY: $(addprefix install-,$(subst /,_,$(install_manifests)))
+$(addprefix install-,$(install_manifests)): install-%: $(install_manifest_depends)
+ifneq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS)))
+	@# If we're using the hybrid FasterMake/RecursiveMake backend, we want
+	@# to ensure the FasterMake end doesn't have install manifests for the
+	@# same directory, because that would blow up
+	$(if $(wildcard _build_manifests/install/$(subst /,_,$*)),$(if $(wildcard faster/install_$(subst /,_,$*)*),$(error FasterMake and RecursiveMake ends of the hybrid build system want to handle $*)))
+endif
+	$(addprefix $(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )$*) ,$(wildcard _build_manifests/install/$(subst /,_,$*)))
 
 # Dummy wrapper rule to allow the faster backend to piggy back
-install-dist_%: install-dist/% ;
-
-install-_tests: $(install_manifest_depends)
-	$(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )_tests _build_manifests/install/_tests)
+$(addprefix install-,$(subst /,_,$(filter dist/%,$(install_manifests)))): install-dist_%: install-dist/% ;
 
 # For compatibility
 .PHONY: install-tests
 install-tests: install-_tests
 
 include $(topsrcdir)/build/moz-automation.mk
 
 # dist and _tests should be purged during cleaning. However, we don't want them
@@ -153,30 +200,30 @@ endif
 # Windows PGO builds don't perform a clean before the 2nd pass. So, we want
 # to preserve content for the 2nd pass on Windows. Everywhere else, we always
 # process the install manifests as part of export.
 # For the binaries rule, not all the install manifests matter, so force only
 # the interesting ones to be done.
 ifdef MOZ_PROFILE_USE
 ifndef NO_PROFILE_GUIDED_OPTIMIZE
 ifneq ($(OS_ARCH)_$(GNU_CC), WINNT_)
-export:: install-manifests
+recurse_pre-export:: install-manifests
 binaries::
 	@$(MAKE) install-manifests NO_REMOVE=1 install_manifests=dist/include
 endif
 endif
 else # !MOZ_PROFILE_USE (normal build)
-export:: install-manifests
+recurse_pre-export:: install-manifests
 binaries::
 	@$(MAKE) install-manifests NO_REMOVE=1 install_manifests=dist/include
 endif
 
 # For historical reasons that are unknown, $(DIST)/sdk is always blown away
 # with no regard for PGO passes. This decision could probably be revisited.
-export:: install-dist/sdk
+recurse_pre-export:: install-dist/sdk
 
 ifndef JS_STANDALONE
 ifdef ENABLE_TESTS
 # Additional makefile targets to call automated test suites
 include $(topsrcdir)/testing/testsuite-targets.mk
 endif
 endif
 
@@ -213,17 +260,16 @@ ifeq (,$(filter-out Linux SunOS,$(OS_ARC
 MAKE_SYM_STORE_ARGS := -c --vcs-info
 DUMP_SYMS_BIN ?= $(DIST)/host/bin/dump_syms
 MAKE_SYM_STORE_PATH := $(DIST)/bin
 endif
 MAKE_SYM_STORE_ARGS += --install-manifest=$(DEPTH)/_build_manifests/install/dist_include,$(DIST)/include
 
 SYM_STORE_SOURCE_DIRS := $(topsrcdir)
 
-ifndef JS_STANDALONE
 include $(topsrcdir)/toolkit/mozapps/installer/package-name.mk
 
 ifdef MOZ_SYMBOLS_EXTRA_BUILDID
 EXTRA_BUILDID := -$(MOZ_SYMBOLS_EXTRA_BUILDID)
 endif
 
 SYMBOL_INDEX_NAME = \
   $(MOZ_APP_NAME)-$(MOZ_APP_VERSION)-$(OS_TARGET)-$(BUILDID)-$(CPU_ARCH)$(EXTRA_BUILDID)-symbols.txt
@@ -256,17 +302,16 @@ endif # MOZ_CRASHREPORTER
 
 uploadsymbols:
 ifdef MOZ_CRASHREPORTER
 ifdef SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE
 	$(PYTHON) -u $(topsrcdir)/toolkit/crashreporter/tools/upload_symbols.py '$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip'
 else
 	$(SHELL) $(topsrcdir)/toolkit/crashreporter/tools/upload_symbols.sh $(SYMBOL_INDEX_NAME) '$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip'
 endif
-endif
 
 # MOZ_SOURCE_STAMP is defined in package-name.mk with a deferred assignment.
 # exporting it makes make run its $(shell) command for each invoked submake,
 # so transform it to an immediate assignment.
 MOZ_SOURCE_STAMP := $(MOZ_SOURCE_STAMP)
 export MOZ_SOURCE_STAMP
 endif
 
--- a/accessible/atk/AccessibleWrap.cpp
+++ b/accessible/atk/AccessibleWrap.cpp
@@ -672,17 +672,17 @@ getRoleCB(AtkObject *aAtkObj)
   case roles::geckoRole: \
     aAtkObj->role = atkRole; \
     break;
 
   switch (role) {
 #include "RoleMap.h"
     default:
       MOZ_CRASH("Unknown role.");
-  };
+  }
 
 #undef ROLE
 
   if (aAtkObj->role == ATK_ROLE_LIST_BOX && !IsAtkVersionAtLeast(2, 1))
     aAtkObj->role = ATK_ROLE_LIST;
   else if (aAtkObj->role == ATK_ROLE_TABLE_ROW && !IsAtkVersionAtLeast(2, 1))
     aAtkObj->role = ATK_ROLE_LIST_ITEM;
   else if (aAtkObj->role == ATK_ROLE_MATH && !IsAtkVersionAtLeast(2, 12))
--- a/accessible/base/AccEvent.cpp
+++ b/accessible/base/AccEvent.cpp
@@ -99,32 +99,32 @@ AccReorderEvent::IsShowHideEventTarget(c
   return 0;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // AccHideEvent
 ////////////////////////////////////////////////////////////////////////////////
 
 AccHideEvent::
-  AccHideEvent(Accessible* aTarget, nsINode* aTargetNode, bool aNeedsShutdown) :
-  AccMutationEvent(::nsIAccessibleEvent::EVENT_HIDE, aTarget, aTargetNode),
+  AccHideEvent(Accessible* aTarget, bool aNeedsShutdown) :
+  AccMutationEvent(::nsIAccessibleEvent::EVENT_HIDE, aTarget),
   mNeedsShutdown(aNeedsShutdown)
 {
   mNextSibling = mAccessible->NextSibling();
   mPrevSibling = mAccessible->PrevSibling();
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // AccShowEvent
 ////////////////////////////////////////////////////////////////////////////////
 
 AccShowEvent::
-  AccShowEvent(Accessible* aTarget, nsINode* aTargetNode) :
-  AccMutationEvent(::nsIAccessibleEvent::EVENT_SHOW, aTarget, aTargetNode)
+  AccShowEvent(Accessible* aTarget) :
+  AccMutationEvent(::nsIAccessibleEvent::EVENT_SHOW, aTarget)
 {
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // AccTextSelChangeEvent
 ////////////////////////////////////////////////////////////////////////////////
 
--- a/accessible/base/AccEvent.h
+++ b/accessible/base/AccEvent.h
@@ -207,18 +207,17 @@ private:
 
 
 /**
  * Base class for show and hide accessible events.
  */
 class AccMutationEvent: public AccEvent
 {
 public:
-  AccMutationEvent(uint32_t aEventType, Accessible* aTarget,
-                   nsINode* aTargetNode) :
+  AccMutationEvent(uint32_t aEventType, Accessible* aTarget) :
     AccEvent(aEventType, aTarget, eAutoDetect, eCoalesceMutationTextChange)
   {
     // Don't coalesce these since they are coalesced by reorder event. Coalesce
     // contained text change events.
     mParent = mAccessible->Parent();
   }
   virtual ~AccMutationEvent() { }
 
@@ -245,18 +244,17 @@ protected:
 
 
 /**
  * Accessible hide event.
  */
 class AccHideEvent: public AccMutationEvent
 {
 public:
-  AccHideEvent(Accessible* aTarget, nsINode* aTargetNode,
-               bool aNeedsShutdown = true);
+  explicit AccHideEvent(Accessible* aTarget, bool aNeedsShutdown = true);
 
   // Event
   static const EventGroup kEventGroup = eHideEvent;
   virtual unsigned int GetEventGroups() const override
   {
     return AccMutationEvent::GetEventGroups() | (1U << eHideEvent);
   }
 
@@ -276,17 +274,17 @@ protected:
 
 
 /**
  * Accessible show event.
  */
 class AccShowEvent: public AccMutationEvent
 {
 public:
-  AccShowEvent(Accessible* aTarget, nsINode* aTargetNode);
+  explicit AccShowEvent(Accessible* aTarget);
 
   // Event
   static const EventGroup kEventGroup = eShowEvent;
   virtual unsigned int GetEventGroups() const override
   {
     return AccMutationEvent::GetEventGroups() | (1U << eShowEvent);
   }
 };
--- a/accessible/base/NotificationController.cpp
+++ b/accessible/base/NotificationController.cpp
@@ -385,18 +385,20 @@ NotificationController::WillRefresh(mozi
         parentIPCDoc->SendBindChildDoc(ipcDoc, id);
         continue;
       }
 
       ipcDoc = new DocAccessibleChild(childDoc);
       childDoc->SetIPCDoc(ipcDoc);
       nsCOMPtr<nsITabChild> tabChild =
         do_GetInterface(mDocument->DocumentNode()->GetDocShell());
-      static_cast<TabChild*>(tabChild.get())->
-        SendPDocAccessibleConstructor(ipcDoc, parentIPCDoc, id);
+      if (tabChild) {
+        static_cast<TabChild*>(tabChild.get())->
+          SendPDocAccessibleConstructor(ipcDoc, parentIPCDoc, id);
+      }
     }
   }
 
   mObservingState = eRefreshObserving;
   if (!mDocument)
     return;
 
   // Stop further processing if there are no new notifications of any kind or
--- a/accessible/base/StyleInfo.cpp
+++ b/accessible/base/StyleInfo.cpp
@@ -53,16 +53,17 @@ StyleInfo::TextIndent(nsAString& aValue)
   switch (styleCoord.GetUnit()) {
     case eStyleUnit_Coord:
       coordVal = styleCoord.GetCoordValue();
       break;
 
     case eStyleUnit_Percent:
     {
       nsIFrame* frame = mElement->GetPrimaryFrame();
+      MOZ_ASSERT(frame, "frame must be a valid pointer.");
       nsIFrame* containerFrame = frame->GetContainingBlock();
       nscoord percentageBase = containerFrame->GetContentRect().width;
       coordVal = NSCoordSaturatingMultiply(percentageBase,
                                            styleCoord.GetPercentValue());
       break;
     }
 
     case eStyleUnit_Null:
@@ -83,16 +84,17 @@ StyleInfo::TextIndent(nsAString& aValue)
 
   aValue.AppendFloat(nsPresContext::AppUnitsToFloatCSSPixels(coordVal));
   aValue.AppendLiteral("px");
 }
 
 void
 StyleInfo::Margin(css::Side aSide, nsAString& aValue)
 {
+  MOZ_ASSERT(mElement->GetPrimaryFrame(), " mElement->GetPrimaryFrame() needs to be valid pointer");
   aValue.Truncate();
 
   nscoord coordVal = mElement->GetPrimaryFrame()->GetUsedMargin().Side(aSide);
   aValue.AppendFloat(nsPresContext::AppUnitsToFloatCSSPixels(coordVal));
   aValue.AppendLiteral("px");
 }
 
 void
new file mode 100644
--- /dev/null
+++ b/accessible/base/TextRange-inl.h
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_a11y_TextRange_inl_h__
+#define mozilla_a11y_TextRange_inl_h__
+
+#include "TextRange.h"
+#include "HyperTextAccessible.h"
+
+namespace mozilla {
+namespace a11y {
+
+inline Accessible*
+TextRange::Container() const
+{
+  uint32_t pos1 = 0, pos2 = 0;
+  nsAutoTArray<Accessible*, 30> parents1, parents2;
+  return CommonParent(mStartContainer, mEndContainer,
+                      &parents1, &pos1, &parents2, &pos2);
+}
+
+
+} // namespace a11y
+} // namespace mozilla
+
+#endif
--- a/accessible/base/TextRange.cpp
+++ b/accessible/base/TextRange.cpp
@@ -1,18 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "TextRange.h"
+#include "TextRange-inl.h"
 
 #include "Accessible-inl.h"
-#include "HyperTextAccessible.h"
 #include "nsAccUtils.h"
 
 namespace mozilla {
 namespace a11y {
 
 ////////////////////////////////////////////////////////////////////////////////
 // TextPoint
 
@@ -54,90 +53,37 @@ TextPoint::operator <(const TextPoint& a
 TextRange::TextRange(HyperTextAccessible* aRoot,
                      HyperTextAccessible* aStartContainer, int32_t aStartOffset,
                      HyperTextAccessible* aEndContainer, int32_t aEndOffset) :
   mRoot(aRoot), mStartContainer(aStartContainer), mEndContainer(aEndContainer),
   mStartOffset(aStartOffset), mEndOffset(aEndOffset)
 {
 }
 
-Accessible*
-TextRange::Container() const
-{
-  if (mStartContainer == mEndContainer)
-    return mStartContainer;
-
-  // Build the chain of parents
-  Accessible* p1 = mStartContainer;
-  Accessible* p2 = mEndContainer;
-  nsAutoTArray<Accessible*, 30> parents1, parents2;
-  do {
-    parents1.AppendElement(p1);
-    p1 = p1->Parent();
-  } while (p1);
-  do {
-    parents2.AppendElement(p2);
-    p2 = p2->Parent();
-  } while (p2);
-
-  // Find where the parent chain differs
-  uint32_t pos1 = parents1.Length();
-  uint32_t pos2 = parents2.Length();
-  Accessible* parent = nullptr;
-  uint32_t len = 0;
-  for (len = std::min(pos1, pos2); len > 0; --len) {
-    Accessible* child1 = parents1.ElementAt(--pos1);
-    Accessible* child2 = parents2.ElementAt(--pos2);
-    if (child1 != child2)
-      break;
-
-    parent = child1;
-  }
-
-  return parent;
-}
-
 void
 TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
 {
   if (mStartContainer == mEndContainer) {
     int32_t startIdx = mStartContainer->GetChildIndexAtOffset(mStartOffset);
     int32_t endIdx = mStartContainer->GetChildIndexAtOffset(mEndOffset);
     for (int32_t idx = startIdx; idx <= endIdx; idx++) {
       Accessible* child = mStartContainer->GetChildAt(idx);
       if (nsAccUtils::IsEmbeddedObject(child))
         aChildren->AppendElement(child);
     }
     return;
   }
 
   Accessible* p1 = mStartContainer->GetChildAtOffset(mStartOffset);
   Accessible* p2 = mEndContainer->GetChildAtOffset(mEndOffset);
+
+  uint32_t pos1 = 0, pos2 = 0;
   nsAutoTArray<Accessible*, 30> parents1, parents2;
-  do {
-    parents1.AppendElement(p1);
-    p1 = p1->Parent();
-  } while (p1);
-  do {
-    parents2.AppendElement(p2);
-    p2 = p2->Parent();
-  } while (p2);
-
-  // Find deepest common container.
-  uint32_t pos1 = parents1.Length();
-  uint32_t pos2 = parents2.Length();
-  Accessible* container = nullptr;
-  for (uint32_t len = std::min(pos1, pos2); len > 0; --len) {
-    Accessible* child1 = parents1.ElementAt(--pos1);
-    Accessible* child2 = parents2.ElementAt(--pos2);
-    if (child1 != child2)
-      break;
-
-    container = child1;
-  }
+  Accessible* container =
+    CommonParent(p1, p2, &parents1, &pos1, &parents2, &pos2);
 
   // Traverse the tree up to the container and collect embedded objects.
   for (uint32_t idx = 0; idx < pos1 - 1; idx++) {
     Accessible* parent = parents1[idx + 1];
     Accessible* child = parents1[idx];
     uint32_t childCount = parent->ChildCount();
     for (uint32_t childIdx = child->IndexInParent(); childIdx < childCount; childIdx++) {
       Accessible* next = parent->GetChildAt(childIdx);
@@ -191,16 +137,105 @@ TextRange::Bounds(nsTArray<nsIntRect> aR
 }
 
 void
 TextRange::Normalize(ETextUnit aUnit)
 {
 
 }
 
+bool
+TextRange::Crop(Accessible* aContainer)
+{
+  uint32_t boundaryPos = 0, containerPos = 0;
+  nsAutoTArray<Accessible*, 30> boundaryParents, containerParents;
+
+  // Crop the start boundary.
+  Accessible* container = nullptr;
+  Accessible* boundary = mStartContainer->GetChildAtOffset(mStartOffset);
+  if (boundary != aContainer) {
+    CommonParent(boundary, aContainer, &boundaryParents, &boundaryPos,
+                 &containerParents, &containerPos);
+
+    if (boundaryPos == 0) {
+      if (containerPos != 0) {
+        // The container is contained by the start boundary, reduce the range to
+        // the point starting at the container.
+        aContainer->ToTextPoint(mStartContainer.StartAssignment(), &mStartOffset);
+        static_cast<Accessible*>(mStartContainer)->AddRef();
+      }
+      else {
+        // The start boundary and the container are siblings.
+        container = aContainer;
+      }
+    }
+    else if (containerPos != 0) {
+      // The container does not contain the start boundary.
+      boundary = boundaryParents[boundaryPos];
+      container = containerParents[containerPos];
+    }
+
+    if (container) {
+      // If the range start is after the container, then make the range invalid.
+      if (boundary->IndexInParent() > container->IndexInParent()) {
+        return !!(mRoot = nullptr);
+      }
+
+      // If the range starts before the container, then reduce the range to
+      // the point starting at the container.
+      if (boundary->IndexInParent() < container->IndexInParent()) {
+        container->ToTextPoint(mStartContainer.StartAssignment(), &mStartOffset);
+        mStartContainer.get()->AddRef();
+      }
+    }
+
+    boundaryParents.SetLengthAndRetainStorage(0);
+    containerParents.SetLengthAndRetainStorage(0);
+  }
+
+  boundary = mEndContainer->GetChildAtOffset(mEndOffset);
+  if (boundary == aContainer) {
+    return true;
+  }
+
+  // Crop the end boundary.
+  container = nullptr;
+  CommonParent(boundary, aContainer, &boundaryParents, &boundaryPos,
+               &containerParents, &containerPos);
+
+  if (boundaryPos == 0) {
+    if (containerPos != 0) {
+      aContainer->ToTextPoint(mEndContainer.StartAssignment(), &mEndOffset, false);
+      static_cast<Accessible*>(mEndContainer)->AddRef();
+    }
+    else {
+      container = aContainer;
+    }
+  }
+  else if (containerPos != 0) {
+    boundary = boundaryParents[boundaryPos];
+    container = containerParents[containerPos];
+  }
+
+  if (!container) {
+    return true;
+  }
+
+  if (boundary->IndexInParent() < container->IndexInParent()) {
+    return !!(mRoot = nullptr);
+  }
+
+  if (boundary->IndexInParent() > container->IndexInParent()) {
+    container->ToTextPoint(mEndContainer.StartAssignment(), &mEndOffset, false);
+    static_cast<Accessible*>(mEndContainer)->AddRef();
+  }
+
+  return true;
+}
+
 void
 TextRange::FindText(const nsAString& aText, EDirection aDirection,
                     nsCaseTreatment aCaseSensitive, TextRange* aFoundRange) const
 {
 
 }
 
 void
@@ -291,10 +326,51 @@ TextRange::TextInternal(nsAString& aText
 void
 TextRange::MoveInternal(ETextUnit aUnit, int32_t aCount,
                         HyperTextAccessible& aContainer, int32_t aOffset,
                         HyperTextAccessible* aStopContainer, int32_t aStopOffset)
 {
 
 }
 
+Accessible*
+TextRange::CommonParent(Accessible* aAcc1, Accessible* aAcc2,
+                        nsTArray<Accessible*>* aParents1, uint32_t* aPos1,
+                        nsTArray<Accessible*>* aParents2, uint32_t* aPos2) const
+{
+  if (aAcc1 == aAcc2) {
+    return aAcc1;
+  }
+
+  MOZ_ASSERT(aParents1->Length() == 0 || aParents2->Length() == 0,
+             "Wrong arguments");
+
+  // Build the chain of parents.
+  Accessible* p1 = aAcc1;
+  Accessible* p2 = aAcc2;
+  do {
+    aParents1->AppendElement(p1);
+    p1 = p1->Parent();
+  } while (p1);
+  do {
+    aParents2->AppendElement(p2);
+    p2 = p2->Parent();
+  } while (p2);
+
+  // Find where the parent chain differs
+  *aPos1 = aParents1->Length();
+  *aPos2 = aParents2->Length();
+  Accessible* parent = nullptr;
+  uint32_t len = 0;
+  for (len = std::min(*aPos1, *aPos2); len > 0; --len) {
+    Accessible* child1 = aParents1->ElementAt(--(*aPos1));
+    Accessible* child2 = aParents2->ElementAt(--(*aPos2));
+    if (child1 != child2)
+      break;
+
+    parent = child1;
+  }
+
+  return parent;
+}
+
 } // namespace a11y
 } // namespace mozilla
--- a/accessible/base/TextRange.h
+++ b/accessible/base/TextRange.h
@@ -126,16 +126,22 @@ public:
   void MoveEnd(ETextUnit aUnit, int32_t aCount)
     { MoveInternal(aUnit, aCount, *mEndContainer, mEndOffset); }
 
   /**
    * Move the range points to the closest unit boundaries.
    */
   void Normalize(ETextUnit aUnit);
 
+  /**
+   * Crops the range if it overlaps the given accessible element boundaries,
+   * returns true if the range was cropped successfully.
+   */
+  bool Crop(Accessible* aContainer);
+
   enum EDirection {
     eBackward,
     eForward
   };
 
   /**
    * Return range enclosing the found text.
    */
@@ -238,16 +244,24 @@ private:
   bool TextInternal(nsAString& aText, Accessible* aCurrent,
                     uint32_t aStartIntlOffset) const;
 
   void MoveInternal(ETextUnit aUnit, int32_t aCount,
                     HyperTextAccessible& aContainer, int32_t aOffset,
                     HyperTextAccessible* aStopContainer = nullptr,
                     int32_t aStopOffset = 0);
 
+  /**
+   * A helper method returning a common parent for two given accessible
+   * elements.
+   */
+  Accessible* CommonParent(Accessible* aAcc1, Accessible* aAcc2,
+                           nsTArray<Accessible*>* aParents1, uint32_t* aPos1,
+                           nsTArray<Accessible*>* aParents2, uint32_t* aPos2) const;
+
   RefPtr<HyperTextAccessible> mRoot;
   RefPtr<HyperTextAccessible> mStartContainer;
   RefPtr<HyperTextAccessible> mEndContainer;
   int32_t mStartOffset;
   int32_t mEndOffset;
 };
 
 
--- a/accessible/base/nsCoreUtils.cpp
+++ b/accessible/base/nsCoreUtils.cpp
@@ -29,24 +29,35 @@
 #include "nsView.h"
 #include "nsGkAtoms.h"
 
 #include "nsComponentManagerUtils.h"
 
 #include "nsITreeBoxObject.h"
 #include "nsITreeColumns.h"
 #include "mozilla/dom/Element.h"
+#include "mozilla/dom/HTMLLabelElement.h"
 
 using namespace mozilla;
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsCoreUtils
 ////////////////////////////////////////////////////////////////////////////////
 
 bool
+nsCoreUtils::IsLabelWithControl(nsIContent* aContent)
+{
+  dom::HTMLLabelElement* label = dom::HTMLLabelElement::FromContent(aContent);
+  if (label && label->GetControl())
+    return true;
+
+  return false;
+}
+
+bool
 nsCoreUtils::HasClickListener(nsIContent *aContent)
 {
   NS_ENSURE_TRUE(aContent, false);
   EventListenerManager* listenerManager =
     aContent->GetExistingListenerManager();
 
   return listenerManager &&
     (listenerManager->HasListenersFor(nsGkAtoms::onclick) ||
--- a/accessible/base/nsCoreUtils.h
+++ b/accessible/base/nsCoreUtils.h
@@ -24,16 +24,21 @@ class nsIWidget;
 
 /**
  * Core utils.
  */
 class nsCoreUtils
 {
 public:
   /**
+   * Return true if the given node is a label of a control.
+   */
+  static bool IsLabelWithControl(nsIContent *aContent);
+
+  /**
    * Return true if the given node has registered click, mousedown or mouseup
    * event listeners.
    */
   static bool HasClickListener(nsIContent *aContent);
 
   /**
    * Dispatch click event to XUL tree cell.
    *
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -2245,16 +2245,40 @@ Accessible::AnchorAt(uint32_t aAnchorInd
 
 already_AddRefed<nsIURI>
 Accessible::AnchorURIAt(uint32_t aAnchorIndex)
 {
   NS_PRECONDITION(IsLink(), "AnchorURIAt is called on not hyper link!");
   return nullptr;
 }
 
+void
+Accessible::ToTextPoint(HyperTextAccessible** aContainer, int32_t* aOffset,
+                        bool aIsBefore) const
+{
+  if (IsHyperText()) {
+    *aContainer = const_cast<Accessible*>(this)->AsHyperText();
+    *aOffset = aIsBefore ? 0 : (*aContainer)->CharacterCount();
+    return;
+  }
+
+  const Accessible* child = nullptr;
+  const Accessible* parent = this;
+  do {
+    child = parent;
+    parent = parent->Parent();
+  } while (parent && !parent->IsHyperText());
+
+  if (parent) {
+    *aContainer = const_cast<Accessible*>(parent)->AsHyperText();
+    *aOffset = (*aContainer)->GetChildOffset(
+      child->IndexInParent() + static_cast<int32_t>(!aIsBefore));
+  }
+}
+
 
 ////////////////////////////////////////////////////////////////////////////////
 // SelectAccessible
 
 void
 Accessible::SelectedItems(nsTArray<Accessible*>* aItems)
 {
   AccIterator iter(this, filters::GetSelected);
--- a/accessible/generic/Accessible.h
+++ b/accessible/generic/Accessible.h
@@ -753,16 +753,22 @@ public:
    */
   virtual Accessible* AnchorAt(uint32_t aAnchorIndex);
 
   /**
    * Returns an anchor URI at the given index.
    */
   virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex);
 
+  /**
+   * Returns a text point for the accessible element.
+   */
+  void ToTextPoint(HyperTextAccessible** aContainer, int32_t* aOffset,
+                   bool aIsBefore = true) const;
+
   //////////////////////////////////////////////////////////////////////////////
   // SelectAccessible
 
   /**
    * Return an array of selected items.
    */
   virtual void SelectedItems(nsTArray<Accessible*>* aItems);
 
@@ -853,17 +859,17 @@ public:
   static void TranslateString(const nsString& aKey, nsAString& aStringOut);
 
   /**
    * Return true if the accessible is defunct.
    */
   bool IsDefunct() const { return mStateFlags & eIsDefunct; }
 
   /**
-   * Return true if the accessible is no longer in the document.
+   * Return false if the accessible is no longer in the document.
    */
   bool IsInDocument() const { return !(mStateFlags & eIsNotInDocument); }
 
   /**
    * Return true if the accessible should be contained by document node map.
    */
   bool IsNodeMapEntry() const
     { return HasOwnContent() && !(mStateFlags & eNotNodeMapEntry); }
--- a/accessible/generic/BaseAccessibles.cpp
+++ b/accessible/generic/BaseAccessibles.cpp
@@ -110,30 +110,34 @@ LinkableAccessible::Value(nsString& aVal
   if (isLink) {
     actionAcc->Value(aValue);
   }
 }
 
 uint8_t
 LinkableAccessible::ActionCount()
 {
-  bool isLink, isOnclick;
-  ActionWalk(&isLink, &isOnclick);
-  return (isLink || isOnclick) ? 1 : 0;
+  bool isLink, isOnclick, isLabelWithControl;
+  ActionWalk(&isLink, &isOnclick, &isLabelWithControl);
+  return (isLink || isOnclick || isLabelWithControl) ? 1 : 0;
 }
 
 Accessible*
-LinkableAccessible::ActionWalk(bool* aIsLink, bool* aIsOnclick)
+LinkableAccessible::ActionWalk(bool* aIsLink, bool* aIsOnclick,
+                               bool* aIsLabelWithControl)
 {
   if (aIsOnclick) {
     *aIsOnclick = false;
   }
   if (aIsLink) {
     *aIsLink = false;
   }
+  if (aIsLabelWithControl) {
+    *aIsLabelWithControl = false;
+  }
 
   if (nsCoreUtils::HasClickListener(mContent)) {
     if (aIsOnclick) {
       *aIsOnclick = true;
     }
     return nullptr;
   }
 
@@ -150,32 +154,39 @@ LinkableAccessible::ActionWalk(bool* aIs
     }
 
     if (nsCoreUtils::HasClickListener(walkUpAcc->GetContent())) {
       if (aIsOnclick) {
         *aIsOnclick = true;
       }
       return walkUpAcc;
     }
+
+    if (nsCoreUtils::IsLabelWithControl(walkUpAcc->GetContent())) {
+      if (aIsLabelWithControl) {
+        *aIsLabelWithControl = true;
+      }
+      return walkUpAcc;
+    }
   }
   return nullptr;
 }
 
 void
 LinkableAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
   aName.Truncate();
 
   // Action 0 (default action): Jump to link
   if (aIndex == eAction_Jump) {
-    bool isOnclick, isLink;
-    ActionWalk(&isLink, &isOnclick);
+    bool isOnclick, isLink, isLabelWithControl;
+    ActionWalk(&isLink, &isOnclick, &isLabelWithControl);
     if (isLink) {
       aName.AssignLiteral("jump");
-    } else if (isOnclick) {
+    } else if (isOnclick || isLabelWithControl) {
       aName.AssignLiteral("click");
     }
   }
 }
 
 bool
 LinkableAccessible::DoAction(uint8_t aIndex)
 {
--- a/accessible/generic/BaseAccessibles.h
+++ b/accessible/generic/BaseAccessibles.h
@@ -71,17 +71,18 @@ public:
   // ActionAccessible
   virtual uint8_t ActionCount() override;
   virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
   virtual bool DoAction(uint8_t index) override;
   virtual KeyBinding AccessKey() const override;
 
   // ActionAccessible helpers
   Accessible* ActionWalk(bool* aIsLink = nullptr,
-                          bool* aIsOnclick = nullptr);
+                         bool* aIsOnclick = nullptr,
+                         bool* aIsLabelWithControl = nullptr);
   // HyperLinkAccessible
   virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex) override;
 
 protected:
   virtual ~LinkableAccessible() {}
 
 };
 
--- a/accessible/generic/DocAccessible.cpp
+++ b/accessible/generic/DocAccessible.cpp
@@ -1506,17 +1506,17 @@ DocAccessible::DoInitialUpdate()
   if (!IsRoot()) {
     RefPtr<AccReorderEvent> reorderEvent = new AccReorderEvent(Parent());
     ParentDocument()->FireDelayedEvent(reorderEvent);
   }
 
   uint32_t childCount = ChildCount();
   for (uint32_t i = 0; i < childCount; i++) {
     Accessible* child = GetChildAt(i);
-    RefPtr<AccShowEvent> event = new AccShowEvent(child, child->GetContent());
+    RefPtr<AccShowEvent> event = new AccShowEvent(child);
   FireDelayedEvent(event);
   }
 }
 
 void
 DocAccessible::ProcessLoad()
 {
   mLoadState |= eCompletelyLoaded;
@@ -1887,17 +1887,16 @@ DocAccessible::UpdateTreeInternal(Access
   uint32_t updateFlags = eAccessible;
 
   // If a focused node has been shown then it could mean its frame was recreated
   // while the node stays focused and we need to fire focus event on
   // the accessible we just created. If the queue contains a focus event for
   // this node already then it will be suppressed by this one.
   Accessible* focusedAcc = nullptr;
 
-  nsINode* node = aChild->GetNode();
   if (aIsInsert) {
     // Create accessible tree for shown accessible.
     CacheChildrenInSubtree(aChild, &focusedAcc);
 
   } else {
     // Fire menupopup end event before hide event if a menu goes away.
 
     // XXX: We don't look into children of hidden subtree to find hiding
@@ -1909,19 +1908,19 @@ DocAccessible::UpdateTreeInternal(Access
     // handling.
     if (aChild->ARIARole() == roles::MENUPOPUP)
       FireDelayedEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END, aChild);
   }
 
   // Fire show/hide event.
   RefPtr<AccMutationEvent> event;
   if (aIsInsert)
-    event = new AccShowEvent(aChild, node);
+    event = new AccShowEvent(aChild);
   else
-    event = new AccHideEvent(aChild, node);
+    event = new AccHideEvent(aChild);
 
   FireDelayedEvent(event);
   aReorderEvent->AddSubMutationEvent(event);
 
   if (aIsInsert) {
     roles::Role ariaRole = aChild->ARIARole();
     if (ariaRole == roles::MENUPOPUP) {
       // Fire EVENT_MENUPOPUP_START if ARIA menu appears.
@@ -1978,17 +1977,18 @@ DocAccessible::RelocateARIAOwnedIfNeeded
 void
 DocAccessible::ValidateARIAOwned()
 {
   for (auto it = mARIAOwnsHash.Iter(); !it.Done(); it.Next()) {
     Accessible* owner = it.Key();
     nsTArray<RefPtr<Accessible> >* children = it.UserData();
 
     // Owner is about to die, put children back if applicable.
-    if (!owner->IsInDocument()) {
+    if (!mAccessibleCache.GetWeak(reinterpret_cast<void*>(owner)) ||
+        !owner->IsInDocument()) {
       PutChildrenBack(children, 0);
       it.Remove();
       continue;
     }
 
     for (uint32_t idx = 0; idx < children->Length(); idx++) {
       Accessible* child = children->ElementAt(idx);
       if (!child->IsInDocument()) {
@@ -2083,18 +2083,17 @@ DocAccessible::SeizeChild(Accessible* aN
   if (!oldParent) {
     NS_ERROR("No parent? The tree is broken!");
     return false;
   }
 
   int32_t oldIdxInParent = aChild->IndexInParent();
 
   RefPtr<AccReorderEvent> reorderEvent = new AccReorderEvent(oldParent);
-  RefPtr<AccMutationEvent> hideEvent =
-    new AccHideEvent(aChild, aChild->GetContent(), false);
+  RefPtr<AccMutationEvent> hideEvent = new AccHideEvent(aChild, false);
   reorderEvent->AddSubMutationEvent(hideEvent);
 
   {
     AutoTreeMutation mut(oldParent);
     oldParent->RemoveChild(aChild);
   }
 
   bool isReinserted = false;
@@ -2115,18 +2114,17 @@ DocAccessible::SeizeChild(Accessible* aN
     children->RemoveElement(aChild);
   }
 
   FireDelayedEvent(hideEvent);
   MaybeNotifyOfValueChange(oldParent);
   FireDelayedEvent(reorderEvent);
 
   reorderEvent = new AccReorderEvent(aNewParent);
-  RefPtr<AccMutationEvent> showEvent =
-    new AccShowEvent(aChild, aChild->GetContent());
+  RefPtr<AccMutationEvent> showEvent = new AccShowEvent(aChild);
   reorderEvent->AddSubMutationEvent(showEvent);
 
   FireDelayedEvent(showEvent);
   MaybeNotifyOfValueChange(aNewParent);
   FireDelayedEvent(reorderEvent);
 
   aChild->SetRelocated(true);
   return true;
@@ -2134,30 +2132,28 @@ DocAccessible::SeizeChild(Accessible* aN
 
 void
 DocAccessible::MoveChild(Accessible* aChild, int32_t aIdxInParent)
 {
   NS_PRECONDITION(aChild->Parent(), "No parent?");
 
   Accessible* parent = aChild->Parent();
   RefPtr<AccReorderEvent> reorderEvent = new AccReorderEvent(parent);
-  RefPtr<AccMutationEvent> hideEvent =
-    new AccHideEvent(aChild, aChild->GetContent(), false);
+  RefPtr<AccMutationEvent> hideEvent = new AccHideEvent(aChild, false);
   reorderEvent->AddSubMutationEvent(hideEvent);
 
   AutoTreeMutation mut(parent);
   parent->RemoveChild(aChild);
 
   parent->InsertChildAt(aIdxInParent, aChild);
   aChild->SetRelocated(true);
 
   FireDelayedEvent(hideEvent);
 
-  RefPtr<AccMutationEvent> showEvent =
-    new AccShowEvent(aChild, aChild->GetContent());
+  RefPtr<AccMutationEvent> showEvent = new AccShowEvent(aChild);
   reorderEvent->AddSubMutationEvent(showEvent);
   FireDelayedEvent(showEvent);
 
   MaybeNotifyOfValueChange(parent);
   FireDelayedEvent(reorderEvent);
 }
 
 void
@@ -2171,18 +2167,17 @@ DocAccessible::PutChildrenBack(nsTArray<
     // If the child is in the tree then remove it from the owner.
     if (child->IsInDocument()) {
       Accessible* owner = child->Parent();
       if (!owner) {
         NS_ERROR("Cannot put the child back. No parent, a broken tree.");
         continue;
       }
       RefPtr<AccReorderEvent> reorderEvent = new AccReorderEvent(owner);
-      RefPtr<AccMutationEvent> hideEvent =
-        new AccHideEvent(child, child->GetContent(), false);
+      RefPtr<AccMutationEvent> hideEvent = new AccHideEvent(child, false);
       reorderEvent->AddSubMutationEvent(hideEvent);
 
       {
         AutoTreeMutation mut(owner);
         owner->RemoveChild(child);
         child->SetRelocated(false);
       }
 
--- a/accessible/generic/HyperTextAccessible.cpp
+++ b/accessible/generic/HyperTextAccessible.cpp
@@ -1764,17 +1764,17 @@ HyperTextAccessible::EnclosingRange(a11y
   } else {
     aRange.Set(mDoc, mDoc, 0, mDoc, mDoc->CharacterCount());
   }
 }
 
 void
 HyperTextAccessible::SelectionRanges(nsTArray<a11y::TextRange>* aRanges) const
 {
-  NS_ASSERTION(aRanges->Length() != 0, "TextRange array supposed to be empty");
+  MOZ_ASSERT(aRanges->Length() == 0, "TextRange array supposed to be empty");
 
   dom::Selection* sel = DOMSelection();
   if (!sel)
     return;
 
   aRanges->SetCapacity(sel->RangeCount());
 
   for (uint32_t idx = 0; idx < sel->RangeCount(); idx++) {
--- a/accessible/generic/HyperTextAccessible.h
+++ b/accessible/generic/HyperTextAccessible.h
@@ -253,17 +253,17 @@ public:
   /**
    * Return text offset of the given child accessible within hypertext
    * accessible.
    *
    * @param  aChild           [in] accessible child to get text offset for
    * @param  aInvalidateAfter [in, optional] indicates whether invalidate
    *                           cached offsets for next siblings of the child
    */
-  int32_t GetChildOffset(Accessible* aChild,
+  int32_t GetChildOffset(const Accessible* aChild,
                          bool aInvalidateAfter = false) const
   {
     int32_t index = GetIndexOf(aChild);
     return index == -1 ? -1 : GetChildOffset(index, aInvalidateAfter);
   }
 
   /**
    * Return text offset for the child accessible index.
--- a/accessible/html/HTMLElementAccessibles.cpp
+++ b/accessible/html/HTMLElementAccessibles.cpp
@@ -70,16 +70,42 @@ HTMLLabelAccessible::RelationByType(Rela
   if (aType == RelationType::LABEL_FOR) {
     dom::HTMLLabelElement* label = dom::HTMLLabelElement::FromContent(mContent);
     rel.AppendTarget(mDoc, label->GetControl());
   }
 
   return rel;
 }
 
+uint8_t
+HTMLLabelAccessible::ActionCount()
+{
+  return nsCoreUtils::IsLabelWithControl(mContent) ? 1 : 0;
+}
+
+void
+HTMLLabelAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
+{
+  if (aIndex == 0) {
+    if (nsCoreUtils::IsLabelWithControl(mContent))
+      aName.AssignLiteral("click");
+  }
+}
+
+bool
+HTMLLabelAccessible::DoAction(uint8_t aIndex)
+{
+  if (aIndex != 0)
+    return false;
+
+  DoCommand();
+  return true;
+}
+
+
 ////////////////////////////////////////////////////////////////////////////////
 // nsHTMLOuputAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 NS_IMPL_ISUPPORTS_INHERITED0(HTMLOutputAccessible, HyperTextAccessible)
 
 Relation
 HTMLOutputAccessible::RelationByType(RelationType aType)
--- a/accessible/html/HTMLElementAccessibles.h
+++ b/accessible/html/HTMLElementAccessibles.h
@@ -57,16 +57,21 @@ public:
   HTMLLabelAccessible(nsIContent* aContent, DocAccessible* aDoc) :
     HyperTextAccessibleWrap(aContent, aDoc) {}
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Accessible
   virtual Relation RelationByType(RelationType aType) override;
 
+  // ActionAccessible
+  virtual uint8_t ActionCount() override;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
+  virtual bool DoAction(uint8_t aIndex) override;
+
 protected:
   virtual ~HTMLLabelAccessible() {}
   virtual ENameValueFlag NativeName(nsString& aName) override;
 };
 
 /**
  * Used for HTML output element.
  */
--- a/accessible/html/HTMLImageMapAccessible.cpp
+++ b/accessible/html/HTMLImageMapAccessible.cpp
@@ -116,17 +116,17 @@ HTMLImageMapAccessible::UpdateChildAreas
       mDoc->BindToDocument(area, aria::GetRoleMap(areaContent));
 
       if (!InsertChildAt(idx, area)) {
         mDoc->UnbindFromDocument(area);
         break;
       }
 
       if (aDoFireEvents) {
-        RefPtr<AccShowEvent> event = new AccShowEvent(area, areaContent);
+        RefPtr<AccShowEvent> event = new AccShowEvent(area);
         mDoc->FireDelayedEvent(event);
         reorderEvent->AddSubMutationEvent(event);
       }
 
       treeChanged = true;
     }
   }
 
--- a/accessible/html/HTMLListAccessible.cpp
+++ b/accessible/html/HTMLListAccessible.cpp
@@ -106,17 +106,17 @@ HTMLLIAccessible::UpdateBullet(bool aHas
   AutoTreeMutation mut(this);
 
   DocAccessible* document = Document();
   if (aHasBullet) {
     mBullet = new HTMLListBulletAccessible(mContent, mDoc);
     document->BindToDocument(mBullet, nullptr);
     InsertChildAt(0, mBullet);
 
-    RefPtr<AccShowEvent> event = new AccShowEvent(mBullet, mBullet->GetContent());
+    RefPtr<AccShowEvent> event = new AccShowEvent(mBullet);
     mDoc->FireDelayedEvent(event);
     reorderEvent->AddSubMutationEvent(event);
   } else {
     RefPtr<AccHideEvent> event = new AccHideEvent(mBullet, mBullet->GetContent());
     mDoc->FireDelayedEvent(event);
     reorderEvent->AddSubMutationEvent(event);
 
     RemoveChild(mBullet);
--- a/accessible/interfaces/ia2/Makefile.in
+++ b/accessible/interfaces/ia2/Makefile.in
@@ -6,16 +6,17 @@ IA2DIR        = $(topsrcdir)/other-licen
 
 GARBAGE       += $(MIDL_GENERATED_FILES)
 
 # Please keep this list in sync with the moz.build file until the rest of this
 # Makefile is ported over.
 MIDL_INTERFACES = \
   Accessible2.idl \
   Accessible2_2.idl \
+  Accessible2_3.idl \
   AccessibleAction.idl \
   AccessibleApplication.idl \
   AccessibleComponent.idl \
   AccessibleDocument.idl \
   AccessibleEditableText.idl \
   AccessibleHyperlink.idl \
   AccessibleHypertext.idl \
   AccessibleHypertext2.idl \
--- a/accessible/interfaces/ia2/moz.build
+++ b/accessible/interfaces/ia2/moz.build
@@ -12,8 +12,16 @@ DEFFILE = SRCDIR + '/IA2Marshal.def'
 
 OS_LIBS += [
     'uuid',
     'kernel32',
     'rpcrt4',
     'ole32',
     'oleaut32',
 ]
+
+# The Windows MIDL code generator creates things like:
+#
+#   #endif !_MIDL_USE_GUIDDEF_
+#
+# which clang-cl complains about.  MSVC doesn't, so turn this warning off.
+if CONFIG['CLANG_CL']:
+    CXXFLAGS += ['-Wno-extra-tokens']
--- a/accessible/interfaces/msaa/moz.build
+++ b/accessible/interfaces/msaa/moz.build
@@ -20,8 +20,16 @@ DEFINES['REGISTER_PROXY_DLL'] = True
 
 DEFFILE = SRCDIR + '/AccessibleMarshal.def'
 
 OS_LIBS += [
     'kernel32',
     'rpcrt4',
     'oleaut32',
 ]
+
+# The Windows MIDL code generator creates things like:
+#
+#   #endif !_MIDL_USE_GUIDDEF_
+#
+# which clang-cl complains about.  MSVC doesn't, so turn this warning off.
+if CONFIG['CLANG_CL']:
+    CFLAGS += ['-Wno-extra-tokens']
--- a/accessible/interfaces/nsIAccessibleTextRange.idl
+++ b/accessible/interfaces/nsIAccessibleTextRange.idl
@@ -8,17 +8,17 @@
 interface nsIAccessible;
 interface nsIAccessibleText;
 interface nsIArray;
 interface nsIVariant;
 
 /**
  * A range representing a piece of text in the document.
  */
-[scriptable, uuid(525b3401-8a67-4822-b35d-661065767cd8)]
+[scriptable, uuid(c4515623-55f9-4543-a3d5-c1e9afa588f4)]
 interface nsIAccessibleTextRange : nsISupports
 {
   readonly attribute nsIAccessibleText startContainer;
   readonly attribute long startOffset;
   readonly attribute nsIAccessibleText endContainer;
   readonly attribute long endOffset;
 
   /**
@@ -77,16 +77,21 @@ interface nsIAccessibleTextRange : nsISu
   void moveEnd(in unsigned long aUnit, in long aCount);
 
   /**
    * Normalize the range to the closest unit of the given type.
    */
   void normalize(in unsigned long aUnit);
 
   /**
+   * Crops the range by the given accessible element.
+   */
+  boolean crop(in nsIAccessible aContainer);
+
+  /**
    * Return range enclosing the found text.
    */
   nsIAccessibleTextRange findText(in AString aText, in boolean aIsBackward,
                                   in boolean aIsIgnoreCase);
 
   /**
    * Text attributes. Used in conjunction with findAttrs().
    */
--- a/accessible/jsat/EventManager.jsm
+++ b/accessible/jsat/EventManager.jsm
@@ -72,17 +72,17 @@ this.EventManager.prototype = {
   // late). It is only called when the AccessFu is disabled explicitly.
   stop: function stop() {
     if (!this._started) {
       return;
     }
     Logger.debug('EventManager.stop');
     AccessibilityEventObserver.removeListener(this);
     try {
-      this._preDialogPosition.clear();
+      this._preDialogPosition = new WeakMap();
       this.webProgress.removeProgressListener(this);
       this.removeEventListener('wheel', this, true);
       this.removeEventListener('scroll', this, true);
       this.removeEventListener('resize', this, true);
     } catch (x) {
       // contentScope is dead.
     } finally {
       this._started = false;
@@ -613,17 +613,17 @@ const AccessibilityEventObserver = {
    * Stop an AccessibilityEventObserver.
    */
   stop: function stop() {
     if (!this.started) {
       return;
     }
     Services.obs.removeObserver(this, 'accessible-event');
     // Clean up all registered event managers.
-    this.eventManagers.clear();
+    this.eventManagers = new WeakMap();
     this.listenerCount = 0;
     this.started = false;
   },
 
   /**
    * Register an EventManager and start listening to the
    * 'accessible-event' messages.
    *
--- a/accessible/mac/mozTextAccessible.mm
+++ b/accessible/mac/mozTextAccessible.mm
@@ -213,21 +213,23 @@ ToNSString(id aValue)
 #if DEBUG
       NSLog(@"%@:no range", attribute);
 #endif
       return nil;
     }
 
     int32_t start = range.location;
     int32_t end = start + range.length;
-    nsIntRect bounds;
+    DesktopIntRect bounds;
     if (textAcc) {
-      bounds = textAcc->TextBounds(start, end);
+      bounds =
+        DesktopIntRect::FromUnknownRect(textAcc->TextBounds(start, end));
     } else if (proxy) {
-      bounds = proxy->TextBounds(start, end);
+      bounds =
+        DesktopIntRect::FromUnknownRect(proxy->TextBounds(start, end));
     }
 
     return [NSValue valueWithRect:nsCocoaUtils::GeckoRectToCocoaRect(bounds)];
   }
 
 #if DEBUG
   NSLog(@"unhandled attribute:%@ forParameter:%@", attribute, parameter);
 #endif
--- a/accessible/tests/mochitest/actions/test_general.html
+++ b/accessible/tests/mochitest/actions/test_general.html
@@ -34,21 +34,29 @@
           ID: "li_clickable3",
           actionName: "click",
           events: CLICK_EVENTS
         },
         {
           ID: "onclick_img",
           actionName: "click",
           events: CLICK_EVENTS
+        },
+        {
+          ID: "label1",
+          actionName: "click",
+          events: CLICK_EVENTS
         }
+
       ];
 
       testActions(actionsArray);
 
+      is(getAccessible("label1").firstChild.actionCount, 1, "label text should have 1 action");
+
       getAccessible("onclick_img").takeFocus();
       is(getAccessible("link1").actionCount, 1, "links should have one action");
       is(getAccessible("link2").actionCount, 1, "link with onclick handler should have 1 action");
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
@@ -82,10 +90,18 @@
     <li id="li_clickable3" onmouseup="">Clickable list item</li>
   </ul>
 
   <!-- linkable accessibles -->
   <img id="onclick_img" onclick="" src="../moz.png">
 
   <a id="link1" href="www">linkable textleaf accessible</a>
   <div id="link2" onclick="">linkable textleaf accessible</div>
+
+  <div>
+    <label for="TextBox_t2" id="label1">
+      <span>Explicit</span>
+    </label>
+    <input name="in2" id="TextBox_t2" type="text" maxlength="17">
+  </div>
+
 </body>
 </html>
--- a/accessible/tests/mochitest/actions/test_general.xul
+++ b/accessible/tests/mochitest/actions/test_general.xul
@@ -56,27 +56,34 @@
           events: XUL_EVENTS
         },
         {
           ID: "buttonmenu",
           actionName: "press",
           events: CLICK_EVENTS
         },
         {
+          ID: "name_entry_label",
+          actionName: "click",
+          events: CLICK_EVENTS
+        },
+        {
           ID: "labelWithPopup",
           actionName: "click",
           events: CLICK_EVENTS
         }/*, // XXX: bug 490288
         {
           ID: "buttonmenu_item",
           actionName: "click",
           events: CLICK_EVENTS
         }*/
       ];
 
+      is(getAccessible("name_entry_label").firstChild.actionCount, 1, "label text should have 1 action");
+
       testActions(actionsArray);
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   ]]>
   </script>
 
@@ -120,12 +127,16 @@
           <menuitem label="item1" id="buttonmenu_item"/>
           <menuitem label="item1"/>
         </menupopup>
       </button>
 
       <label id="labelWithPopup" value="file name"
              popup="fileContext"
              tabindex="0"/>
+      <hbox>
+        <label id="name_entry_label" value="Name" control="name_entry"/>
+        <textbox id="name_entry"/>
+      </hbox>
     </vbox>
   </hbox>
 </window>
 
--- a/accessible/tests/mochitest/text.js
+++ b/accessible/tests/mochitest/text.js
@@ -468,16 +468,20 @@ function testTextRange(aRange, aRangeDes
            "Wrong start container of " + aRangeDescr);
   is(aRange.startOffset, aStartOffset,
      "Wrong start offset of " + aRangeDescr);
   isObject(aRange.endContainer, getAccessible(aEndContainer),
            "Wrong end container of " + aRangeDescr);
   is(aRange.endOffset, aEndOffset,
      "Wrong end offset of " + aRangeDescr);
 
+  if (aText === undefined) {
+    return;
+  }
+
   is(aRange.text, aText, "Wrong text of " + aRangeDescr);
 
   var children = aRange.embeddedChildren;
   is(children ? children.length : 0, aChildren ? aChildren.length : 0,
      "Wrong embedded children count of " + aRangeDescr);
 
   isObject(aRange.container, getAccessible(aCommonContainer),
            "Wrong container of " + aRangeDescr);
--- a/accessible/tests/mochitest/text/test_lineboundary.html
+++ b/accessible/tests/mochitest/text/test_lineboundary.html
@@ -231,25 +231,25 @@ two words
   <iframe id="ht_3" src="data:text/html,<div contentEditable='true'>foo<br/><br/></div>"></iframe>
 
   <p id="ht_4">Hello world
 </p>
 
   <ul id="ul1">
     <li id="li1">Item</li>
     <li id="li2"></li>
-    <li id="li3" style="width:10ex; font-family:monospace; font-size:10pt;">a long and winding road that lead me to your door</li>
+    <li id="li3" style="font-family:monospace; font-size:10pt; width:8ch;">a long and winding road that lead me to your door</li>
     <li id="li4">a <a href=''>b</a> c</li>
     <li id="li5"><br>hello</li>
   </ul>
 
   <ol id="ol1">
     <li id="li6">Item</li>
     <li id="li7"></li>
-    <li id="li8" style="width:10ex; font-family:monospace; font-size:10pt;">a long and winding road that lead me to your door</li>
+    <li id="li8" style="font-family:monospace; font-size:10pt; width:8ch;">a long and winding road that lead me to your door</li>
     <li id="li9">a <a href=''>b</a> c</li>
     <li id="li10"><br>hello</li>
   </ol>
 
   <div id="ht_5">
     <div>
       <p>sectiounus</p>
       <p>seciofarus</p>
--- a/accessible/tests/mochitest/textrange/a11y.ini
+++ b/accessible/tests/mochitest/textrange/a11y.ini
@@ -1,3 +1,4 @@
 [DEFAULT]
 
 [test_general.html]
+[test_selection.html]
new file mode 100644
--- /dev/null
+++ b/accessible/tests/mochitest/textrange/test_selection.html
@@ -0,0 +1,120 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Text Range selection tests</title>
+  <link rel="stylesheet" type="text/css"
+        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript"
+          src="../common.js"></script>
+  <script type="application/javascript"
+          src="../text.js"></script>
+  <script type="application/javascript"
+          src="../layout.js"></script>
+  <script type="application/javascript">
+
+    function doTest()
+    {
+      var sel = window.getSelection();
+      var p = getNode("p1");
+      var a = getNode("p2_a");
+
+      var range = document.createRange();
+      sel.addRange(range);
+
+      // the accessible is contained by the range
+      range.selectNode(p);
+
+      var a11yranges = getAccessible(document, [nsIAccessibleText]).selectionRanges;
+      var a11yrange = a11yranges.queryElementAt(0, nsIAccessibleTextRange);
+
+      testTextRange(a11yrange, "selection range #1", document, 3, document, 4);
+
+      ok(a11yrange.crop(getAccessible(a)), "Range failed to crop #1.");
+      testTextRange(a11yrange, "cropped range #1", a, 0, a, 5);
+
+      // the range is contained by the accessible
+      range.selectNode(a);
+      var a11yranges = getAccessible(document, [nsIAccessibleText]).selectionRanges;
+      var a11yrange = a11yranges.queryElementAt(0, nsIAccessibleTextRange);
+
+      testTextRange(a11yrange, "selection range #2", p, 5, p, 6);
+
+      ok(a11yrange.crop(getAccessible(p)), "Range failed to crop #2.");
+      testTextRange(a11yrange, "cropped range #2", p, 5, p, 6);
+
+      // the range starts before the accessible and ends inside it
+      range.setStart(p, 0);
+      range.setEndAfter(a.firstChild, 4);
+      var a11yranges = getAccessible(document, [nsIAccessibleText]).selectionRanges;
+      var a11yrange = a11yranges.queryElementAt(0, nsIAccessibleTextRange);
+
+      testTextRange(a11yrange, "selection range #3", p, 0, a, 4);
+
+      ok(a11yrange.crop(getAccessible(a)), "Range failed to crop #3.");
+      testTextRange(a11yrange, "cropped range #3", a, 0, a, 4);
+
+      // the range starts inside the accessible and ends after it
+      range.setStart(a.firstChild, 1);
+      range.setEndAfter(p);
+      var a11yranges = getAccessible(document, [nsIAccessibleText]).selectionRanges;
+      var a11yrange = a11yranges.queryElementAt(0, nsIAccessibleTextRange);
+
+      testTextRange(a11yrange, "selection range #4", a, 1, document, 4);
+
+      ok(a11yrange.crop(getAccessible(a)), "Range failed to crop #4.");
+      testTextRange(a11yrange, "cropped range #4", a, 1, a, 5);
+
+      // the range ends before the accessible
+      range.setStart(p.firstChild, 0);
+      range.setEnd(p.firstChild, 4);
+      var a11yranges = getAccessible(document, [nsIAccessibleText]).selectionRanges;
+      var a11yrange = a11yranges.queryElementAt(0, nsIAccessibleTextRange);
+
+      testTextRange(a11yrange, "selection range #5", p, 0, p, 4);
+      ok(!a11yrange.crop(getAccessible(a)), "Crop #5 succeeded while it shouldn't");
+
+      // the range starts after the accessible
+      range.setStart(p.lastChild, 0);
+      range.setEnd(p.lastChild, 4);
+      var a11yranges = getAccessible(document, [nsIAccessibleText]).selectionRanges;
+      var a11yrange = a11yranges.queryElementAt(0, nsIAccessibleTextRange);
+
+      testTextRange(a11yrange, "selection range #6", p, 6, p, 10);
+
+      ok(!a11yrange.crop(getAccessible(a)), "Crop #6 succeeded while it shouldn't");
+
+      // crop a range by a table
+      range.selectNode(getNode("c2"));
+      var a11yranges = getAccessible(document, [nsIAccessibleText]).selectionRanges;
+      var a11yrange = a11yranges.queryElementAt(0, nsIAccessibleTextRange);
+
+      testTextRange(a11yrange, "selection range #7", document, 4, document, 5);
+
+      ok(a11yrange.crop(getAccessible("table")), "Range failed to crop #7.");
+      testTextRange(a11yrange, "cropped range #7", "c2", 5, "c2", 6);
+
+      SimpleTest.finish();
+    }
+
+    SimpleTest.waitForExplicitFinish();
+    addA11yLoadEvent(doTest);
+  </script>
+</head>
+<body>
+
+  <a target="_blank"
+     title="Implement IAccessible2_3::selectionRanges"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=1233118">Bug 1233118</a>
+  <p id="display"></p>
+  <div id="content" style="display: none"></div>
+  <pre id="test">
+  </pre>
+
+  <p id="p1">text <a id="p2_a" href="www">link<img id="p2_img", src="../moz.png"></a> text</p>
+
+  <div id="c2">start<table id="table"><tr><td>cell</td></tr></table>end</div>
+</body>
+</html>
--- a/accessible/windows/ia2/ia2Accessible.cpp
+++ b/accessible/windows/ia2/ia2Accessible.cpp
@@ -3,26 +3,28 @@
 /* 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 "AccessibleWrap.h"
 
 #include "Accessible2_i.c"
 #include "Accessible2_2_i.c"
+#include "Accessible2_3_i.c"
 #include "AccessibleRole.h"
 #include "AccessibleStates.h"
 
 #include "Compatibility.h"
 #include "ia2AccessibleRelation.h"
 #include "IUnknownImpl.h"
 #include "nsCoreUtils.h"
 #include "nsIAccessibleTypes.h"
 #include "mozilla/a11y/PDocAccessible.h"
 #include "Relation.h"
+#include "TextRange-inl.h"
 #include "nsAccessibilityService.h"
 
 #include "nsIPersistentProperties2.h"
 #include "nsISimpleEnumerator.h"
 
 using namespace mozilla;
 using namespace mozilla::a11y;
 
@@ -35,17 +37,19 @@ template<typename String> static void Es
 STDMETHODIMP
 ia2Accessible::QueryInterface(REFIID iid, void** ppv)
 {
   if (!ppv)
     return E_INVALIDARG;
 
   *ppv = nullptr;
 
-  if (IID_IAccessible2_2 == iid)
+  if (IID_IAccessible2_3 == iid)
+    *ppv = static_cast<IAccessible2_3*>(this);
+  else if (IID_IAccessible2_2 == iid)
     *ppv = static_cast<IAccessible2_2*>(this);
   else if (IID_IAccessible2 == iid && !Compatibility::IsIA2Off())
     *ppv = static_cast<IAccessible2*>(this);
 
   if (*ppv) {
     (reinterpret_cast<IUnknown*>(*ppv))->AddRef();
     return S_OK;
   }
@@ -242,17 +246,17 @@ ia2Accessible::role(long* aRole)
   if (acc->IsProxy())
     geckoRole = acc->Proxy()->Role();
   else
     geckoRole = acc->Role();
   switch (geckoRole) {
 #include "RoleMap.h"
     default:
       MOZ_CRASH("Unknown role.");
-  };
+  }
 
 #undef ROLE
 
   // Special case, if there is a ROLE_ROW inside of a ROLE_TREE_TABLE, then call
   // the IA2 role a ROLE_OUTLINEITEM.
   if (acc->IsProxy()) {
     if (geckoRole == roles::ROW && acc->Proxy()->Parent() &&
         acc->Proxy()->Parent()->Role() == roles::TREE_TABLE)
@@ -744,16 +748,68 @@ ia2Accessible::get_relationTargetsOfType
     (*aTargets)[i]->AddRef();
   }
 
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
+STDMETHODIMP
+ia2Accessible::get_selectionRanges(IA2Range** aRanges,
+                                   long *aNRanges)
+{
+  A11Y_TRYBLOCK_BEGIN
+
+  if (!aRanges || !aNRanges || aNRanges <= 0)
+    return E_INVALIDARG;
+
+  *aNRanges = 0;
+
+  AccessibleWrap* acc = static_cast<AccessibleWrap*>(this);
+  if (acc->IsDefunct())
+    return CO_E_OBJNOTCONNECTED;
+
+  nsAutoTArray<TextRange, 1> ranges;
+  acc->Document()->SelectionRanges(&ranges);
+  uint32_t len = ranges.Length();
+  for (uint32_t idx = 0; idx < len; idx++) {
+    if (!ranges[idx].Crop(acc)) {
+      ranges.RemoveElementAt(idx);
+    }
+  }
+
+  *aNRanges = ranges.Length();
+  *aRanges = static_cast<IA2Range*>(
+    ::CoTaskMemAlloc(sizeof(IA2Range) * *aNRanges));
+  if (!*aRanges)
+    return E_OUTOFMEMORY;
+
+  for (uint32_t idx = 0; idx < static_cast<uint32_t>(*aNRanges); idx++) {
+    AccessibleWrap* anchor =
+      static_cast<AccessibleWrap*>(ranges[idx].StartContainer());
+    (*aRanges)[idx].anchor = static_cast<IAccessible2*>(anchor);
+    anchor->AddRef();
+
+    (*aRanges)[idx].anchorOffset = ranges[idx].StartOffset();
+
+    AccessibleWrap* active =
+      static_cast<AccessibleWrap*>(ranges[idx].EndContainer());
+    (*aRanges)[idx].active = static_cast<IAccessible2*>(active);
+    active->AddRef();
+
+    (*aRanges)[idx].activeOffset = ranges[idx].EndOffset();
+  }
+
+  return S_OK;
+
+  A11Y_TRYBLOCK_END
+}
+
+
 ////////////////////////////////////////////////////////////////////////////////
 // Helpers
 
 template<typename String>
 static inline void
 EscapeAttributeChars(String& aStr)
 {
   int32_t offset = 0;
--- a/accessible/windows/ia2/ia2Accessible.h
+++ b/accessible/windows/ia2/ia2Accessible.h
@@ -4,23 +4,23 @@
  * 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/. */
 
 #ifndef mozilla_a11y_ia2Accessible_h_
 #define mozilla_a11y_ia2Accessible_h_
 
 #include "nsISupports.h"
 
-#include "Accessible2_2.h"
+#include "Accessible2_3.h"
 
 namespace mozilla {
 namespace a11y {
 class Attribute;
 
-class ia2Accessible : public IAccessible2_2
+class ia2Accessible : public IAccessible2_3
 {
 public:
 
   // IUnknown
   STDMETHODIMP QueryInterface(REFIID, void**);
 
   // IAccessible2
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_nRelations(
@@ -99,16 +99,21 @@ public:
 
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_relationTargetsOfType(
     /* [in] */ BSTR type,
     /* [in] */ long maxTargets,
     /* [out, size_is(,*nTargets)] */ IUnknown*** targets,
     /* [out, retval] */ long* nTargets
   );
 
+  // IAccessible2_3
+  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_selectionRanges(
+    /* [out, size_is(,*nRanges)] */ IA2Range** ranges,
+    /* [out, retval] */ long *nRanges);
+
   // Helper method
   static HRESULT ConvertToIA2Attributes(nsIPersistentProperties* aAttributes,
                                         BSTR* aIA2Attributes);
   static HRESULT ConvertToIA2Attributes(nsTArray<Attribute>* aAttributes,
                                         BSTR* aIA2Attributes);
 };
 
 } // namespace a11y
--- a/accessible/windows/ia2/moz.build
+++ b/accessible/windows/ia2/moz.build
@@ -45,9 +45,17 @@ LOCAL_INCLUDES += [
     '/accessible/xul',
 ]
 
 FINAL_LIBRARY = 'xul'
 
 if CONFIG['GNU_CXX']:
     CXXFLAGS += ['-Wshadow']
 
+# The Windows MIDL code generator creates things like:
+#
+#   #endif !_MIDL_USE_GUIDDEF_
+#
+# which clang-cl complains about.  MSVC doesn't, so turn this warning off.
+if CONFIG['CLANG_CL']:
+    CXXFLAGS += ['-Wno-extra-tokens']
+
 include('/ipc/chromium/chromium-config.mozbuild')
--- a/accessible/windows/msaa/AccessibleWrap.cpp
+++ b/accessible/windows/msaa/AccessibleWrap.cpp
@@ -86,18 +86,23 @@ AccessibleWrap::~AccessibleWrap()
 ITypeInfo* AccessibleWrap::gTypeInfo = nullptr;
 
 NS_IMPL_ISUPPORTS_INHERITED0(AccessibleWrap, Accessible)
 
 void
 AccessibleWrap::Shutdown()
 {
 #ifdef _WIN64
-  if (mID != kNoID)
-    static_cast<DocAccessibleWrap*>(mDoc)->RemoveID(mID);
+  if (mID != kNoID) {
+    auto doc = static_cast<DocAccessibleWrap*>(mDoc);
+    MOZ_ASSERT(doc);
+    if (doc) {
+      doc->RemoveID(mID);
+    }
+  }
 #endif
 
   Accessible::Shutdown();
 }
 
 //-----------------------------------------------------
 // IUnknown interface methods - see iunknown.h for documentation
 //-----------------------------------------------------
@@ -442,17 +447,17 @@ AccessibleWrap::get_accRole(
   case roles::_geckoRole: \
     msaaRole = _msaaRole; \
     break;
 
   switch (geckoRole) {
 #include "RoleMap.h"
     default:
       MOZ_CRASH("Unknown role.");
-  };
+  }
 
 #undef ROLE
 
   // Special case, if there is a ROLE_ROW inside of a ROLE_TREE_TABLE, then call the MSAA role
   // a ROLE_OUTLINEITEM for consistency and compatibility.
   // We need this because ARIA has a role of "row" for both grid and treegrid
   if (xpAccessible->IsProxy()) {
       if (geckoRole == roles::ROW
--- a/accessible/windows/msaa/moz.build
+++ b/accessible/windows/msaa/moz.build
@@ -54,14 +54,22 @@ LOCAL_INCLUDES += [
     '/accessible/windows/sdn',
     '/accessible/windows/uia',
     '/accessible/xpcom',
     '/accessible/xul',
     '/dom/base',
     '/layout/style',
 ]
 
+# The Windows MIDL code generator creates things like:
+#
+#   #endif !_MIDL_USE_GUIDDEF_
+#
+# which clang-cl complains about.  MSVC doesn't, so turn this warning off.
+if CONFIG['CLANG_CL']:
+    CXXFLAGS += ['-Wno-extra-tokens']
+
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 if CONFIG['GNU_CXX']:
     CXXFLAGS += ['-Wshadow']
--- a/accessible/xpcom/xpcAccessible.cpp
+++ b/accessible/xpcom/xpcAccessible.cpp
@@ -341,17 +341,17 @@ xpcAccessible::GetBounds(int32_t* aX, in
 
   if (!Intl())
     return NS_ERROR_FAILURE;
 
   nsIntRect rect = Intl()->Bounds();
   *aX = rect.x;
   *aY = rect.y;
   *aWidth = rect.width;
-  *aHeight = rect.height;;
+  *aHeight = rect.height;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessible::GroupPosition(int32_t* aGroupLevel,
                              int32_t* aSimilarItemsInGroup,
                              int32_t* aPositionInGroup)
--- a/accessible/xpcom/xpcAccessibleTextRange.cpp
+++ b/accessible/xpcom/xpcAccessibleTextRange.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "xpcAccessibleTextRange.h"
 
-#include "TextRange.h"
+#include "TextRange-inl.h"
 #include "xpcAccessibleDocument.h"
 
 #include "nsIMutableArray.h"
 #include "nsComponentManagerUtils.h"
 #include "nsQueryObject.h"
 
 using namespace mozilla;
 using namespace mozilla::a11y;
@@ -166,16 +166,26 @@ xpcAccessibleTextRange::MoveEnd(uint32_t
 
 NS_IMETHODIMP
 xpcAccessibleTextRange::Normalize(uint32_t aUnit)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
+xpcAccessibleTextRange::Crop(nsIAccessible* aContainer, bool* aSuccess)
+{
+  Accessible* container = aContainer->ToInternalAccessible();
+  NS_ENSURE_TRUE(container, NS_ERROR_INVALID_ARG);
+
+  *aSuccess = mRange.Crop(container);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 xpcAccessibleTextRange::FindText(const nsAString& aText, bool aIsBackward,
                                  bool aIsIgnoreCase,
                                  nsIAccessibleTextRange** aRange)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/accessible/xpcom/xpcAccessibleTextRange.h
+++ b/accessible/xpcom/xpcAccessibleTextRange.h
@@ -44,16 +44,17 @@ public:
                               uint32_t aOtherRangeEndPoint,
                               int32_t* aResult) final override;
   NS_IMETHOD GetText(nsAString& aText) final override;
   NS_IMETHOD GetBounds(nsIArray** aRectList) final override;
   NS_IMETHOD Move(uint32_t aUnit, int32_t aCount) final override;
   NS_IMETHOD MoveStart(uint32_t aUnit, int32_t aCount) final override;
   NS_IMETHOD MoveEnd(uint32_t aUnit, int32_t aCount) final override;
   NS_IMETHOD Normalize(uint32_t aUnit) final override;
+  NS_IMETHOD Crop(nsIAccessible* aContainer, bool* aSuccess) final override;
   NS_IMETHOD FindText(const nsAString& aText, bool aIsBackward, bool aIsIgnoreCase,
                       nsIAccessibleTextRange** aRange) final override;
   NS_IMETHOD FindAttr(uint32_t aAttr, nsIVariant* aVal, bool aIsBackward,
                       nsIAccessibleTextRange** aRange) final override;
   NS_IMETHOD AddToSelection() final override;
   NS_IMETHOD RemoveFromSelection() final override;
   NS_IMETHOD Select() final override;
   NS_IMETHOD ScrollIntoView(uint32_t aHow) final override;
--- a/addon-sdk/source/app-extension/bootstrap.js
+++ b/addon-sdk/source/app-extension/bootstrap.js
@@ -21,16 +21,18 @@ const scriptLoader = Cc['@mozilla.org/mo
 const prefService = Cc['@mozilla.org/preferences-service;1'].
                     getService(Ci.nsIPrefService).
                     QueryInterface(Ci.nsIPrefBranch);
 const appInfo = Cc["@mozilla.org/xre/app-info;1"].
                 getService(Ci.nsIXULAppInfo);
 const vc = Cc["@mozilla.org/xpcom/version-comparator;1"].
            getService(Ci.nsIVersionComparator);
 
+const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
+
 const Startup = Cu.import("resource://gre/modules/sdk/system/Startup.js", {}).exports;
 
 
 const REASON = [ 'unknown', 'startup', 'shutdown', 'enable', 'disable',
                  'install', 'uninstall', 'upgrade', 'downgrade' ];
 
 const bind = Function.call.bind(Function.bind);
 
@@ -43,28 +45,22 @@ var resourceDomains = [];
 function setResourceSubstitution(domain, uri) {
   resourceDomains.push(domain);
   resourceHandler.setSubstitution(domain, uri);
 }
 
 // Utility function that synchronously reads local resource from the given
 // `uri` and returns content string.
 function readURI(uri) {
-  let ioservice = Cc['@mozilla.org/network/io-service;1'].
-    getService(Ci.nsIIOService);
+  let channel = NetUtil.newChannel({
+    uri: NetUtil.newURI(uri, 'UTF-8'),
+    loadUsingSystemPrincipal: true
+  });
 
-  let channel = ioservice.newChannel2(uri,
-                                      'UTF-8',
-                                      null,
-                                      null,      // aLoadingNode
-                                      systemPrincipal,
-                                      null,      // aTriggeringPrincipal
-                                      Ci.nsILoadInfo.SEC_NORMAL,
-                                      Ci.nsIContentPolicy.TYPE_OTHER);
-  let stream = channel.open();
+  let stream = channel.open2();
 
   let cstream = Cc['@mozilla.org/intl/converter-input-stream;1'].
     createInstance(Ci.nsIConverterInputStream);
   cstream.init(stream, 'UTF-8', 0, 0);
 
   let str = {};
   let data = '';
   let read = 0;
--- a/addon-sdk/source/lib/sdk/content/page-worker.js
+++ b/addon-sdk/source/lib/sdk/content/page-worker.js
@@ -52,16 +52,17 @@ const ChildPage = Class({
       this.rules = Rules();
       this.rules.add.apply(this.rules, [].concat(options.include));
     }
   },
 
   dispose: function() {
     pages.delete(this.id);
     this.webProgress.removeProgressListener(this);
+    this.webNav.close();
     this.webNav = null;
   },
 
   attachWorker: function() {
     if (!isValidURL(this, this.contentWindow.location.href))
       return;
 
     this.options.id = uuid().toString();
--- a/addon-sdk/source/lib/sdk/content/tab-events.js
+++ b/addon-sdk/source/lib/sdk/content/tab-events.js
@@ -1,42 +1,58 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
+const { Ci } = require('chrome');
 const system = require('sdk/system/events');
 const { frames } = require('sdk/remote/child');
 const { WorkerChild } = require('sdk/content/worker-child');
 
 // map observer topics to tab event names
 const EVENTS = {
+  'content-document-global-created': 'create',
+  'chrome-document-global-created': 'create',
   'content-document-interactive': 'ready',
   'chrome-document-interactive': 'ready',
   'content-document-loaded': 'load',
   'chrome-document-loaded': 'load',
 // 'content-page-shown': 'pageshow', // bug 1024105
 }
 
 function topicListener({ subject, type }) {
-  let window = subject.defaultView;
-  if (!window)
+  // NOTE detect the window from the subject:
+  // - on *-global-created the subject is the window
+  // - in the other cases it is the document object
+  let window = subject instanceof Ci.nsIDOMWindow ? subject : subject.defaultView;
+  if (!window){
     return;
-  let frame = frames.getFrameForWindow(subject.defaultView);
-  if (frame)
-    frame.port.emit('sdk/tab/event', EVENTS[type]);
+  }
+  let frame = frames.getFrameForWindow(window);
+  if (frame) {
+    let readyState = frame.content.document.readyState;
+    frame.port.emit('sdk/tab/event', EVENTS[type], { readyState });
+  }
 }
 
 for (let topic in EVENTS)
   system.on(topic, topicListener, true);
 
 // bug 1024105 - content-page-shown notification doesn't pass persisted param
 function eventListener({target, type, persisted}) {
   let frame = this;
-  if (target === frame.content.document)
+  if (target === frame.content.document) {
     frame.port.emit('sdk/tab/event', type, persisted);
+  }
 }
 frames.addEventListener('pageshow', eventListener, true);
 
 frames.port.on('sdk/tab/attach', (frame, options) => {
   options.window = frame.content;
   new WorkerChild(options);
 });
+
+// Forward the existent frames's readyState.
+for (let frame of frames) {
+  let readyState = frame.content.document.readyState;
+  frame.port.emit('sdk/tab/event', 'init', { readyState });
+}
--- a/addon-sdk/source/lib/sdk/deprecated/window-utils.js
+++ b/addon-sdk/source/lib/sdk/deprecated/window-utils.js
@@ -5,17 +5,17 @@
 
 module.metadata = {
   'stability': 'deprecated'
 };
 
 const { Cc, Ci } = require('chrome');
 const events = require('../system/events');
 const { getInnerId, getOuterId, windows, isDocumentLoaded, isBrowser,
-        getMostRecentBrowserWindow, getMostRecentWindow } = require('../window/utils');
+        getMostRecentBrowserWindow, getToplevelWindow, getMostRecentWindow } = require('../window/utils');
 const { deprecateFunction } = require('../util/deprecate');
 const { ignoreWindow } = require('sdk/private-browsing/utils');
 const { isPrivateBrowsingSupported } = require('../self');
 
 const windowWatcher = Cc['@mozilla.org/embedcomp/window-watcher;1'].
                        getService(Ci.nsIWindowWatcher);
 const appShellService = Cc['@mozilla.org/appshell/appShellService;1'].
                         getService(Ci.nsIAppShellService);
@@ -122,26 +122,26 @@ WindowTracker.prototype = {
       this._unregWindow(window);
   },
 
   handleEvent: function handleEvent(event) {
     try {
       if (event.type == 'load' && event.target) {
         var window = event.target.defaultView;
         if (window)
-          this._regWindow(window);
+          this._regWindow(getToplevelWindow(window));
       }
     }
     catch(e) {
       console.exception(e);
     }
   },
 
   _onToplevelWindowReady: function _onToplevelWindowReady({subject}) {
-    let window = subject;
+    let window = getToplevelWindow(subject);
     // ignore private windows if they are not supported
     if (ignoreWindow(window))
       return;
     this._regWindow(window);
   },
 
   observe: function observe(subject, topic, data) {
     try {
--- a/addon-sdk/source/lib/sdk/lang/weak-set.js
+++ b/addon-sdk/source/lib/sdk/lang/weak-set.js
@@ -8,26 +8,31 @@ module.metadata = {
 
 "use strict";
 
 const { Cu } = require("chrome");
 
 function makeGetterFor(Type) {
   let cache = new WeakMap();
 
-  return function getFor(target) {
-    if (!cache.has(target))
-      cache.set(target, new Type());
+  return {
+    getFor(target) {
+      if (!cache.has(target))
+        cache.set(target, new Type());
 
-    return cache.get(target);
+      return cache.get(target);
+    },
+    clearFor(target) {
+      return cache.delete(target)
+    }
   }
 }
 
-var getLookupFor = makeGetterFor(WeakMap);
-var getRefsFor = makeGetterFor(Set);
+var {getFor: getLookupFor, clearFor: clearLookupFor} = makeGetterFor(WeakMap);
+var {getFor: getRefsFor, clearFor: clearRefsFor} = makeGetterFor(Set);
 
 function add(target, value) {
   if (has(target, value))
     return;
 
   getLookupFor(target).set(value, true);
   getRefsFor(target).add(Cu.getWeakReference(value));
 }
@@ -39,18 +44,18 @@ function remove(target, value) {
 exports.remove = remove;
 
 function has(target, value) {
   return getLookupFor(target).has(value);
 }
 exports.has = has;
 
 function clear(target) {
-  getLookupFor(target).clear();
-  getRefsFor(target).clear();
+  clearLookupFor(target);
+  clearRefsFor(target);
 }
 exports.clear = clear;
 
 function iterator(target) {
   let refs = getRefsFor(target);
 
   for (let ref of refs) {
     let value = ref.get();
--- a/addon-sdk/source/lib/sdk/net/url.js
+++ b/addon-sdk/source/lib/sdk/net/url.js
@@ -76,17 +76,17 @@ exports.readURI = readURI;
  *  let data = readURISync('resource://gre/modules/NetUtil.jsm');
  */
 function readURISync(uri, charset) {
   charset = typeof charset === "string" ? charset : "UTF-8";
 
   let channel = NetUtil.newChannel({
     uri: NetUtil.newURI(uri, charset),
     loadUsingSystemPrincipal: true});
-  let stream = channel.open();
+  let stream = channel.open2();
 
   let count = stream.available();
   let data = NetUtil.readInputStreamToString(stream, count, { charset : charset });
 
   stream.close();
 
   return data;
 }
--- a/addon-sdk/source/lib/sdk/tabs/tab-firefox.js
+++ b/addon-sdk/source/lib/sdk/tabs/tab-firefox.js
@@ -39,16 +39,19 @@ function isDestroyed(tab) {
 }
 
 function isClosed(tab) {
   if (!viewsFor.has(tab))
     return true;
   return viewsFor.get(tab).closing;
 }
 
+// private tab attribute where the remote cached value is stored
+const remoteReadyStateCached = Symbol("remoteReadyStateCached");
+
 const Tab = Class({
   implements: [EventTarget],
   initialize: function(tabElement, options = null) {
     modelsFor.set(tabElement, this);
     viewsFor.set(this, tabElement);
 
     if (options) {
       EventTarget.prototype.initialize.call(this, options);
@@ -120,18 +123,17 @@ const Tab = Class({
     // TODO: Remove the dependency on the windows module, see bug 792670
     require('../windows');
     let tabElement = viewsFor.get(this);
     let domWindow = tabElement.ownerDocument.defaultView;
     return modelFor(domWindow);
   },
 
   get readyState() {
-    // TODO: This will use CPOWs in e10s: bug 1146606
-    return isDestroyed(this) ? undefined : browser(this).contentDocument.readyState;
+    return isDestroyed(this) ? undefined : this[remoteReadyStateCached] || "uninitialized";
   },
 
   pin: function() {
     if (isDestroyed(this))
       return;
 
     pin(viewsFor.get(this));
   },
@@ -301,21 +303,31 @@ function tabEventListener(event, tabElem
       addListItem(window.tabs, tab);
     // The tabs module will take care of adding to its internal list
   }
   else if (event == "close") {
     if (window)
       removeListItem(window.tabs, tab);
     // The tabs module will take care of removing from its internal list
   }
-  else if (event == "ready" || event == "load") {
+  else if (event == "init" || event == "create" || event == "ready" || event == "load") {
     // Ignore load events from before browser windows have fully loaded, these
     // are for about:blank in the initial tab
     if (isBrowser(domWindow) && !domWindow.gBrowserInit.delayedStartupFinished)
       return;
+
+    // update the cached remote readyState value
+    let { readyState } = args[0] || {};
+    tab[remoteReadyStateCached] = readyState;
+  }
+
+  if (event == "init") {
+    // Do not emit events for the detected existent tabs, we only need to cache
+    // their current document.readyState value.
+    return;
   }
 
   tabEmit(tab, event, ...args);
 
   // The tab object shouldn't be reachable after closed
   if (event == "close") {
     viewsFor.delete(tab);
     modelsFor.delete(tabElement);
--- a/addon-sdk/source/lib/sdk/tabs/tabs-firefox.js
+++ b/addon-sdk/source/lib/sdk/tabs/tabs-firefox.js
@@ -106,16 +106,17 @@ const allTabs = new Tabs();
 module.exports = Object.create(allTabs);
 pipe(tabEvents, module.exports);
 
 function addWindowTab(window, tabElement) {
   let tab = new Tab(tabElement);
   if (window)
     addListItem(window.tabs, tab);
   addListItem(allTabs, tab);
+  emit(allTabs, "open", tab);
 }
 
 // Find tabs in already open windows
 for (let tabElement of getTabs())
   addWindowTab(null, tabElement);
 
 // Detect tabs in new windows
 windowObserver.on('open', domWindow => {
--- a/addon-sdk/source/lib/sdk/windows/firefox.js
+++ b/addon-sdk/source/lib/sdk/windows/firefox.js
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 const { Class } = require('../core/heritage');
 const { observer } = require('./observer');
 const { isBrowser, getMostRecentBrowserWindow, windows, open, getInnerId,
-        getWindowTitle, isFocused, isWindowPrivate } = require('../window/utils');
+        getWindowTitle, getToplevelWindow, isFocused, isWindowPrivate } = require('../window/utils');
 const { List, addListItem, removeListItem } = require('../util/list');
 const { viewFor } = require('../view/core');
 const { modelFor } = require('../model/core');
 const { emit, emitOnObject, setListeners } = require('../event/core');
 const { once } = require('../dom/events');
 const { EventTarget } = require('../event/target');
 const { getSelectedTab } = require('../tabs/utils');
 const { Cc, Ci } = require('chrome');
@@ -184,36 +184,38 @@ function makeNewWindow(domWindow, browse
 
 for (let domWindow of windows()) {
   let window = makeNewWindow(domWindow);
   if (window instanceof BrowserWindow)
     addListItem(browserWindows, window);
 }
 
 var windowEventListener = (event, domWindow, ...args) => {
-  if (ignoreWindow(domWindow))
+  let toplevelWindow = getToplevelWindow(domWindow);
+
+  if (ignoreWindow(toplevelWindow))
     return;
 
-  let window = modelsFor.get(domWindow);
+  let window = modelsFor.get(toplevelWindow);
   if (!window)
-    window = makeNewWindow(domWindow);
+    window = makeNewWindow(toplevelWindow);
 
-  if (isBrowser(domWindow)) {
+  if (isBrowser(toplevelWindow)) {
     if (event == "open")
       addListItem(browserWindows, window);
     else if (event == "close")
       removeListItem(browserWindows, window);
   }
 
   windowEmit(window, event, ...args);
 
   // The window object shouldn't be reachable after closed
   if (event == "close") {
     viewsFor.delete(window);
-    modelsFor.delete(domWindow);
+    modelsFor.delete(toplevelWindow);
   }
 };
 observer.on("*", windowEventListener);
 
 viewFor.define(BrowserWindow, window => {
   return viewsFor.get(window);
 })
 
--- a/addon-sdk/source/lib/toolkit/loader.js
+++ b/addon-sdk/source/lib/toolkit/loader.js
@@ -1070,17 +1070,18 @@ function traverse (node, cb) {
         traverse(x, cb);
       }
     });
   }
   else if (node && typeof node === 'object') {
     cb(node);
     keys(node).map(key => {
       if (key === 'parent' || !node[key]) return;
-      node[key].parent = node;
+      if (typeof node[key] === "object")
+        node[key].parent = node;
       traverse(node[key], cb);
     });
   }
 }
 
 // From Substack's detector
 // https://github.com/substack/node-detective
 // Check an AST node to see if its a require statement.
--- a/addon-sdk/source/test/addons/l10n-properties/app-extension/bootstrap.js
+++ b/addon-sdk/source/test/addons/l10n-properties/app-extension/bootstrap.js
@@ -21,42 +21,36 @@ const scriptLoader = Cc['@mozilla.org/mo
 const prefService = Cc['@mozilla.org/preferences-service;1'].
                     getService(Ci.nsIPrefService).
                     QueryInterface(Ci.nsIPrefBranch);
 const appInfo = Cc["@mozilla.org/xre/app-info;1"].
                 getService(Ci.nsIXULAppInfo);
 const vc = Cc["@mozilla.org/xpcom/version-comparator;1"].
            getService(Ci.nsIVersionComparator);
 
-const { Services } = Cu.import("resource://gre/modules/Services.jsm");
+const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm");
 
 const REASON = [ 'unknown', 'startup', 'shutdown', 'enable', 'disable',
                  'install', 'uninstall', 'upgrade', 'downgrade' ];
 
 const bind = Function.call.bind(Function.bind);
 
 var loader = null;
 var unload = null;
 var cuddlefishSandbox = null;
 var nukeTimer = null;
 
 // Utility function that synchronously reads local resource from the given
 // `uri` and returns content string.
 function readURI(uri) {
-  let ioservice = Cc['@mozilla.org/network/io-service;1'].
-    getService(Ci.nsIIOService);
-  let channel = ioservice.newChannel2(uri,
-                                      'UTF-8',
-                                      null,
-                                      null,      // aLoadingNode
-                                      Services.scriptSecurityManager.getSystemPrincipal(),
-                                      null,      // aTriggeringPrincipal
-                                      Ci.nsILoadInfo.SEC_NORMAL,
-                                      Ci.nsIContentPolicy.TYPE_OTHER);
-  let stream = channel.open();
+  let channel = NetUtil.newChannel({
+    uri: NetUtil.newURI(uri, "UTF-8"),
+    loadUsingSystemPrincipal: true
+  });
+  let stream = channel.open2();
 
   let cstream = Cc['@mozilla.org/intl/converter-input-stream;1'].
     createInstance(Ci.nsIConverterInputStream);
   cstream.init(stream, 'UTF-8', 0, 0);
 
   let str = {};
   let data = '';
   let read = 0;
--- a/addon-sdk/source/test/addons/simple-prefs-regression/app-extension/bootstrap.js
+++ b/addon-sdk/source/test/addons/simple-prefs-regression/app-extension/bootstrap.js
@@ -21,42 +21,36 @@ const scriptLoader = Cc['@mozilla.org/mo
 const prefService = Cc['@mozilla.org/preferences-service;1'].
                     getService(Ci.nsIPrefService).
                     QueryInterface(Ci.nsIPrefBranch);
 const appInfo = Cc["@mozilla.org/xre/app-info;1"].
                 getService(Ci.nsIXULAppInfo);
 const vc = Cc["@mozilla.org/xpcom/version-comparator;1"].
            getService(Ci.nsIVersionComparator);
 
-const { Services } = Cu.import("resource://gre/modules/Services.jsm");
+const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm");
 
 const REASON = [ 'unknown', 'startup', 'shutdown', 'enable', 'disable',
                  'install', 'uninstall', 'upgrade', 'downgrade' ];
 
 const bind = Function.call.bind(Function.bind);
 
 var loader = null;
 var unload = null;
 var cuddlefishSandbox = null;
 var nukeTimer = null;
 
 // Utility function that synchronously reads local resource from the given
 // `uri` and returns content string.
 function readURI(uri) {
-  let ioservice = Cc['@mozilla.org/network/io-service;1'].
-    getService(Ci.nsIIOService);
-  let channel = ioservice.newChannel2(uri,
-                                      'UTF-8',
-                                      null,
-                                      null,      // aLoadingNode
-                                      Services.scriptSecurityManager.getSystemPrincipal(),
-                                      null,      // aTriggeringPrincipal
-                                      Ci.nsILoadInfo.SEC_NORMAL,
-                                      Ci.nsIContentPolicy.TYPE_OTHER);
-  let stream = channel.open();
+  let channel = NetUtil.newChannel({
+    uri: NetUtil.newURI(uri, "UTF-8"),
+    loadUsingSystemPrincipal: true
+  });
+  let stream = channel.open2();
 
   let cstream = Cc['@mozilla.org/intl/converter-input-stream;1'].
     createInstance(Ci.nsIConverterInputStream);
   cstream.init(stream, 'UTF-8', 0, 0);
 
   let str = {};
   let data = '';
   let read = 0;
--- a/addon-sdk/source/test/tabs/test-firefox-tabs.js
+++ b/addon-sdk/source/test/tabs/test-firefox-tabs.js
@@ -17,16 +17,17 @@ const tabs = require('sdk/tabs');
 const { browserWindows } = require('sdk/windows');
 const { set: setPref, get: getPref, reset: resetPref } = require("sdk/preferences/service");
 const DEPRECATE_PREF = "devtools.errorconsole.deprecation_warnings";
 const OPEN_IN_NEW_WINDOW_PREF = 'browser.link.open_newwindow';
 const DISABLE_POPUP_PREF = 'dom.disable_open_during_load';
 const fixtures = require("../fixtures");
 const { base64jpeg } = fixtures;
 const { cleanUI, before, after } = require("sdk/test/utils");
+const { wait } = require('../event/helpers');
 
 // Bug 682681 - tab.title should never be empty
 exports.testBug682681_aboutURI = function(assert, done) {
   let url = 'chrome://browser/locale/tabbrowser.properties';
   let stringBundle = Cc["@mozilla.org/intl/stringbundle;1"].
                         getService(Ci.nsIStringBundleService).
                         createBundle(url);
   let emptyTabTitle = stringBundle.GetStringFromName('tabs.emptyTabTitle');
@@ -1209,42 +1210,60 @@ exports['test active tab properties defi
           }
           tab.close(done);
         }
       });
     }
   });
 };
 
-// related to bug 922956
+// related to bugs 922956 and 989288
 // https://bugzilla.mozilla.org/show_bug.cgi?id=922956
-exports["test ready event after window.open"] = function (assert, done) {
+// https://bugzilla.mozilla.org/show_bug.cgi?id=989288
+exports["test tabs ready and close after window.open"] = function*(assert, done) {
+  // ensure popups open in a new window and disable popup blocker
   setPref(OPEN_IN_NEW_WINDOW_PREF, 2);
   setPref(DISABLE_POPUP_PREF, false);
 
-  let firstRun = true;
-  tabs.on('ready', function onReady(tab) {
-    if (firstRun) {
-      assert.pass("tab ready callback after 1st window.open");
-      firstRun = false;
-      tab.close();
-    }
-    else {
-      assert.pass("tab ready callback after 2nd window.open");
-      tabs.removeListener('ready', onReady);
-      tab.close(done);
-    }
-  });
-
+  // open windows to trigger observers
   tabs.activeTab.attach({
     contentScript: "window.open('about:blank');" +
                    "window.open('about:blank', '', " +
                    "'width=800,height=600,resizable=no,status=no,location=no');"
   });
-}
+
+  let tab1 = yield wait(tabs, "ready");
+  assert.pass("first tab ready has occured");
+
+  let tab2 = yield wait(tabs, "ready");
+  assert.pass("second tab ready has occured");
+
+  tab1.close();
+  yield wait(tabs, "close");
+  assert.pass("first tab close has occured");
+
+  tab2.close();
+  yield wait(tabs, "close");
+  assert.pass("second tab close has occured");
+};
+
+// related to bug #939496
+exports["test tab open event for new window"] = function(assert, done) {
+  // ensure popups open in a new window and disable popup blocker
+  setPref(OPEN_IN_NEW_WINDOW_PREF, 2);
+  setPref(DISABLE_POPUP_PREF, false);
+
+  tabs.once('open', function onOpen(window) {
+    assert.pass("tab open has occured");
+    window.close(done);
+  });
+
+  // open window to trigger observers
+  browserWindows.open("about:logo");
+};
 
 after(exports, function*(name, assert) {
   resetPopupPrefs();
   yield cleanUI();
 });
 
 const resetPopupPrefs = () => {
   resetPref(OPEN_IN_NEW_WINDOW_PREF);
--- a/addon-sdk/source/test/test-page-mod.js
+++ b/addon-sdk/source/test/test-page-mod.js
@@ -581,16 +581,35 @@ exports.testRelatedTab = function(assert
   tabs.open({
     url: "about:",
     onOpen: function onOpen(t) {
       tab = t;
     }
   });
 };
 
+// related to bug #989288
+// https://bugzilla.mozilla.org/show_bug.cgi?id=989288
+exports.testRelatedTabNewWindow = function(assert, done) {
+  let url = "about:logo"
+  let pageMod = new PageMod({
+    include: url,
+    onAttach: function(worker) {
+      assert.equal(worker.tab.url, url, "Worker.tab.url is valid");
+      worker.tab.close(done);
+    }
+  });
+
+  tabs.activeTab.attach({
+    contentScript: "window.open('about:logo', '', " +
+                   "'width=800,height=600,resizable=no,status=no,location=no');"
+  });
+
+};
+
 exports.testRelatedTabNoRequireTab = function(assert, done) {
   let loader = Loader(module);
   let tab;
   let url = "data:text/html;charset=utf-8," + encodeURI("Test related worker tab 2");
   let { PageMod } = loader.require("sdk/page-mod");
   let pageMod = new PageMod({
     include: url,
     onAttach: function(worker) {
--- a/addon-sdk/source/test/test-tab.js
+++ b/addon-sdk/source/test/test-tab.js
@@ -4,17 +4,17 @@
 "use strict";
 
 const tabs = require("sdk/tabs");
 const windowUtils = require("sdk/deprecated/window-utils");
 const windows = require("sdk/windows").browserWindows;
 const app = require("sdk/system/xul-app");
 const { viewFor } = require("sdk/view/core");
 const { modelFor } = require("sdk/model/core");
-const { getTabId, isTab } = require("sdk/tabs/utils");
+const { getBrowserForTab, getTabId, isTab } = require("sdk/tabs/utils");
 const { defer } = require("sdk/lang/functional");
 
 function tabExistenceInTabs(assert, found, tab, tabs) {
   let tabFound = false;
 
   for (let t of tabs) {
     assert.notEqual(t.title, undefined, 'tab title is not undefined');
     assert.notEqual(t.url, undefined, 'tab url is not undefined');
@@ -197,9 +197,19 @@ exports["test tab.readyState"] = (assert
     },
     onLoad: (tab) => {
       assert.equal(tab.readyState, "complete", "tab is complete onLoad");
       tab.close(defer(done));
     }
   });
 }
 
+exports["test tab.readyState for existent tabs"] = (assert) => {
+  assert.equal(tabs.length, 1, "tabs contains an existent tab");
+
+  for (let tab of tabs) {
+    let browserForTab = getBrowserForTab(viewFor(tab));
+    assert.equal(browserForTab.contentDocument.readyState, tab.readyState,
+                 "tab.readyState has the same value of the associated contentDocument.readyState CPOW");
+  }
+}
+
 require("sdk/test").run(module.exports);
--- a/addon-sdk/source/test/test-xpcom.js
+++ b/addon-sdk/source/test/test-xpcom.js
@@ -2,17 +2,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const xpcom = require("sdk/platform/xpcom");
 const { Cc, Ci, Cm, Cr } = require("chrome");
 const { isCIDRegistered } = Cm.QueryInterface(Ci.nsIComponentRegistrar);
 const { Class } = require("sdk/core/heritage");
 const { Loader } = require("sdk/test/loader");
-const { Services } = require("resource://gre/modules/Services.jsm");
+const { NetUtil } = require("resource://gre/modules/NetUtil.jsm");
 
 exports['test Unknown implements nsISupports'] = function(assert) {
   let actual = xpcom.Unknown();
   assert.equal(actual.QueryInterface(Ci.nsISupports),
                actual,
                'component implements nsISupports');
 };
 
@@ -163,24 +163,21 @@ function testRegister(assert, text) {
 
   var ios = Cc["@mozilla.org/network/io-service;1"].
             getService(Ci.nsIIOService);
   assert.equal(
     about.getURIFlags(ios.newURI("http://foo.com", null, null)),
     Ci.nsIAboutModule.ALLOW_SCRIPT
   );
 
-  var aboutURI = ios.newURI("about:boop", null, null);
-  var channel = ios.newChannelFromURI2(aboutURI,
-                                       null,      // aLoadingNode
-                                       Services.scriptSecurityManager.getSystemPrincipal(),
-                                       null,      // aTriggeringPrincipal
-                                       Ci.nsILoadInfo.SEC_NORMAL,
-                                       Ci.nsIContentPolicy.TYPE_OTHER);
-  var iStream = channel.open();
+  var channel = NetUtil.newChannel({
+    uri: "about:boop",
+    loadUsingSystemPrincipal: true
+  });
+  var iStream = channel.open2();
   var siStream = Cc['@mozilla.org/scriptableinputstream;1']
                  .createInstance(Ci.nsIScriptableInputStream);
   siStream.init(iStream);
   var data = new String();
   data += siStream.read(-1);
   siStream.close();
   iStream.close();
   assert.equal(data, text);
--- a/addon-sdk/source/test/windows/test-firefox-windows.js
+++ b/addon-sdk/source/test/windows/test-firefox-windows.js
@@ -15,16 +15,20 @@ const { isPrivate } = require('sdk/priva
 const { isWindowPBSupported } = require('sdk/private-browsing/utils');
 const { viewFor } = require("sdk/view/core");
 const { defer } = require("sdk/lang/functional");
 const { cleanUI } = require("sdk/test/utils");
 const { after } = require("sdk/test/utils");
 const { merge } = require("sdk/util/object");
 const self = require("sdk/self");
 const { openTab } = require("../tabs/utils");
+const { set: setPref, reset: resetPref } = require("sdk/preferences/service");
+const OPEN_IN_NEW_WINDOW_PREF = 'browser.link.open_newwindow';
+const DISABLE_POPUP_PREF = 'dom.disable_open_during_load';
+const { wait } = require('../event/helpers');
 
 // TEST: open & close window
 exports.testOpenAndCloseWindow = function(assert, done) {
   assert.equal(browserWindows.length, 1, "Only one window open");
   let title = 'testOpenAndCloseWindow';
 
   browserWindows.open({
     url: "data:text/html;charset=utf-8,<title>" + title + "</title>",
@@ -578,13 +582,40 @@ exports.testWindowTabEventBindings = fun
   for (let event of EVENTS.slice(1)) {
     let eventProperty = "on" + event.slice(0, 1).toUpperCase() + event.slice(1);
     openArgs[eventProperty] = windowTabsOpenEventHandler(event);
   }
 
   windowTabs.open(openArgs);
 }
 
+// related to bug #989288
+// https://bugzilla.mozilla.org/show_bug.cgi?id=989288
+exports["test window events after window.open"] = function*(assert, done) {
+  // ensure popups open in a new windows and disable popup blocker
+  setPref(OPEN_IN_NEW_WINDOW_PREF, 2);
+  setPref(DISABLE_POPUP_PREF, false);
+
+  // open window to trigger observers
+  tabs.activeTab.attach({
+    contentScript: "window.open('about:blank', '', " +
+                   "'width=800,height=600,resizable=no,status=no,location=no');"
+  });
+
+  let window = yield wait(browserWindows, "open");
+  assert.pass("tab open has occured");
+  window.close();
+
+  yield wait(browserWindows,"close");
+  assert.pass("tab close has occured");
+};
+
 after(exports, function*(name, assert) {
+  resetPopupPrefs();
   yield cleanUI();
 });
 
+const resetPopupPrefs = () => {
+  resetPref(OPEN_IN_NEW_WINDOW_PREF);
+  resetPref(DISABLE_POPUP_PREF);
+};
+
 require('sdk/test').run(exports);
--- a/b2g/app/B2GLoader.cpp
+++ b/b2g/app/B2GLoader.cpp
@@ -18,16 +18,17 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 
 #include <dlfcn.h>
 
 #include "nsXPCOMPrivate.h" // for MAXPATHLEN and XPCOM_DLL
+#include "mozilla/UniquePtr.h"
 
 #define ASSERT(x) if (!(x)) { MOZ_CRASH(); }
 
 // Functions being loaded by XPCOMGlue
 XRE_ProcLoaderServiceRunType XRE_ProcLoaderServiceRun;
 XRE_ProcLoaderClientInitType XRE_ProcLoaderClientInit;
 XRE_ProcLoaderPreloadType XRE_ProcLoaderPreload;
 extern XRE_CreateAppDataType XRE_CreateAppData;
@@ -60,21 +61,21 @@ GetDirnameSlash(const char *aPath, char 
   strncpy(aOutDir, aPath, cpsz);
   aOutDir[cpsz] = 0;
   return cpsz;
 }
 
 static bool
 GetXPCOMPath(const char *aProgram, char *aOutPath, int aMaxLen)
 {
-  nsAutoArrayPtr<char> progBuf(new char[aMaxLen]);
-  nsresult rv = mozilla::BinaryPath::Get(aProgram, progBuf);
+  auto progBuf = mozilla::MakeUnique<char[]>(aMaxLen);
+  nsresult rv = mozilla::BinaryPath::Get(aProgram, progBuf.get());
   NS_ENSURE_SUCCESS(rv, false);
 
-  int len = GetDirnameSlash(progBuf, aOutPath, aMaxLen);
+  int len = GetDirnameSlash(progBuf.get(), aOutPath, aMaxLen);
   NS_ENSURE_TRUE(!!len, false);
 
   NS_ENSURE_TRUE((len + sizeof(XPCOM_DLL)) < (unsigned)aMaxLen, false);
   char *afterSlash = aOutPath + len;
   strcpy(afterSlash, XPCOM_DLL);
   return true;
 }
 
@@ -246,17 +247,19 @@ ReserveFileDescriptors(FdArray& aReserve
       MOZ_CRASH("ProcLoader error: a magic file descriptor is occupied.");
     }
 
     int fd = open("/dev/null", O_RDWR);
     if (fd == -1) {
       MOZ_CRASH("ProcLoader error: failed to reserve a magic file descriptor.");
     }
 
-    aReservedFds.append(target);
+    if (!aReservedFds.append(target)) {
+      MOZ_CRASH("Failed to append to aReservedFds");
+    }
 
     if (fd == target) {
       // No need to call dup2(). We already occupy the desired file descriptor.
       continue;
     }
 
     if (dup2(fd, target)) {
       MOZ_CRASH("ProcLoader error: failed to reserve a magic file descriptor.");
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -349,27 +349,27 @@ pref("dom.w3c_touch_events.safetyY", 120
 
 #ifdef MOZ_SAFE_BROWSING
 pref("browser.safebrowsing.enabled", true);
 // Prevent loading of pages identified as malware
 pref("browser.safebrowsing.malware.enabled", true);
 pref("browser.safebrowsing.downloads.enabled", true);
 pref("browser.safebrowsing.downloads.remote.enabled", true);
 pref("browser.safebrowsing.downloads.remote.timeout_ms", 10000);
+pref("browser.safebrowsing.downloads.remote.url", "https://sb-ssl.google.com/safebrowsing/clientreport/download?key=%GOOGLE_API_KEY%");
 pref("browser.safebrowsing.debug", false);
 
 pref("browser.safebrowsing.provider.google.lists", "goog-badbinurl-shavar,goog-downloadwhite-digest256,goog-phish-shavar,goog-malware-shavar,goog-unwanted-shavar");
 pref("browser.safebrowsing.provider.google.updateURL", "https://safebrowsing.google.com/safebrowsing/downloads?client=SAFEBROWSING_ID&appver=%VERSION%&pver=2.2&key=%GOOGLE_API_KEY%");
 pref("browser.safebrowsing.provider.google.gethashURL", "https://safebrowsing.google.com/safebrowsing/gethash?client=SAFEBROWSING_ID&appver=%VERSION%&pver=2.2");
 pref("browser.safebrowsing.provider.google.reportURL", "https://safebrowsing.google.com/safebrowsing/diagnostic?client=%NAME%&hl=%LOCALE%&site=");
 
 pref("browser.safebrowsing.reportPhishMistakeURL", "https://%LOCALE%.phish-error.mozilla.com/?hl=%LOCALE%&url=");
 pref("browser.safebrowsing.reportPhishURL", "https://%LOCALE%.phish-report.mozilla.com/?hl=%LOCALE%&url=");
 pref("browser.safebrowsing.reportMalwareMistakeURL", "https://%LOCALE%.malware-error.mozilla.com/?hl=%LOCALE%&url=");
-pref("browser.safebrowsing.appRepURL", "https://sb-ssl.google.com/safebrowsing/clientreport/download?key=%GOOGLE_API_KEY%");
 
 pref("browser.safebrowsing.id", "Firefox");
 
 // Tables for application reputation.
 pref("urlclassifier.downloadBlockTable", "goog-badbinurl-shavar");
 
 // The number of random entries to send with a gethash request.
 pref("urlclassifier.gethashnoise", 4);
@@ -687,17 +687,16 @@ pref("layout.css.scroll-snap.enabled", t
 
 // Enable the ProcessPriorityManager, and give processes with no visible
 // documents a 1s grace period before they're eligible to be marked as
 // background. Background processes that are perceivable due to playing
 // media are given a longer grace period to accomodate changing tracks, etc.
 pref("dom.ipc.processPriorityManager.enabled", true);
 pref("dom.ipc.processPriorityManager.backgroundGracePeriodMS", 1000);
 pref("dom.ipc.processPriorityManager.backgroundPerceivableGracePeriodMS", 5000);
-pref("dom.ipc.processPriorityManager.memoryPressureGracePeriodMS", 3000);
 pref("dom.ipc.processPriorityManager.temporaryPriorityLockMS", 5000);
 
 // Number of different background/foreground levels for background/foreground
 // processes.  We use these different levels to force the low-memory killer to
 // kill processes in a LRU order.
 pref("dom.ipc.processPriorityManager.BACKGROUND.LRUPoolLevels", 5);
 pref("dom.ipc.processPriorityManager.BACKGROUND_PERCEIVABLE.LRUPoolLevels", 4);
 
@@ -775,17 +774,22 @@ pref("hal.gonk.COMPOSITOR.nice", -4);
 
 // Fire a memory pressure event when the system has less than Xmb of memory
 // remaining.  You should probably set this just above Y.KillUnderKB for
 // the highest priority class Y that you want to make an effort to keep alive.
 // (For example, we want BACKGROUND_PERCEIVABLE to stay alive.)  If you set
 // this too high, then we'll send out a memory pressure event every Z seconds
 // (see below), even while we have processes that we would happily kill in
 // order to free up memory.
-pref("hal.processPriorityManager.gonk.notifyLowMemUnderKB", 14336);
+pref("gonk.notifyHardLowMemUnderKB", 14336);
+
+// Fire a memory pressure event when the system has less than Xmb of memory
+// remaining and then switch to the hard trigger, see above.  This should be
+// placed above the BACKGROUND priority class.
+pref("gonk.notifySoftLowMemUnderKB", 43008);
 
 // We wait this long before polling the memory-pressure fd after seeing one
 // memory pressure event.  (When we're not under memory pressure, we sit
 // blocked on a poll(), and this pref has no effect.)
 pref("gonk.systemMemoryPressureRecoveryPollMS", 5000);
 
 // Enable pre-launching content processes for improved startup time
 // (hiding latency).
@@ -1055,16 +1059,19 @@ pref("services.sync.fxaccounts.enabled",
 pref("identity.fxaccounts.enabled", true);
 
 // Mobile Identity API.
 pref("services.mobileid.server.uri", "https://msisdn.services.mozilla.com");
 
 pref("identity.fxaccounts.remote.oauth.uri", "https://oauth.accounts.firefox.com/v1");
 pref("identity.fxaccounts.remote.profile.uri", "https://profile.accounts.firefox.com/v1");
 
+// Disable Firefox Accounts device registration until bug 1238895 is fixed.
+pref("identity.fxaccounts.skipDeviceRegistration", true);
+
 // Enable mapped array buffer.
 #ifndef XP_WIN
 pref("dom.mapped_arraybuffer.enabled", true);
 #endif
 
 // SystemUpdate API
 pref("dom.system_update.enabled", true);
 
@@ -1112,16 +1119,19 @@ pref("dom.vr.cardboard.enabled", true);
 
 // In B2G by deafult any AudioChannelAgent is muted when created.
 pref("dom.audiochannel.mutedByDefault", true);
 
 // The app origin of bluetooth app, which is responsible for listening pairing
 // requests.
 pref("dom.bluetooth.app-origin", "app://bluetooth.gaiamobile.org");
 
+// Enable W3C WebBluetooth API and disable B2G only GATT client API.
+pref("dom.bluetooth.webbluetooth.enabled", false);
+
 // Default device name for Presentation API
 pref("dom.presentation.device.name", "Firefox OS");
 
 // Enable notification of performance timing
 pref("dom.performance.enable_notify_performance_timing", true);
 
 // Multi-screen
 pref("b2g.multiscreen.chrome_remote_url", "chrome://b2g/content/shell_remote.html");
--- a/b2g/chrome/content/devtools/hud.js
+++ b/b2g/chrome/content/devtools/hud.js
@@ -3,16 +3,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 'use strict';
 
 // settings.js loads this file when the HUD setting is enabled.
 
 const DEVELOPER_HUD_LOG_PREFIX = 'DeveloperHUD';
 const CUSTOM_HISTOGRAM_PREFIX = 'DEVTOOLS_HUD_CUSTOM_';
+const APPNAME_IDX = 3;
+const HISTNAME_IDX = 4;
 
 XPCOMUtils.defineLazyGetter(this, 'devtools', function() {
   const {devtools} = Cu.import('resource://devtools/shared/Loader.jsm', {});
   return devtools;
 });
 
 XPCOMUtils.defineLazyGetter(this, 'DebuggerClient', function() {
   return devtools.require('devtools/shared/client/main').DebuggerClient;
@@ -103,16 +105,20 @@ var developerHUD = {
     for (let frame of appFrames) {
       this.trackFrame(frame);
     }
 
     SettingsListener.observe('hud.logging', this._logging, enabled => {
       this._logging = enabled;
     });
 
+    SettingsListener.observe('hud.telemetry.logging', _telemetryDebug, enabled => {
+      _telemetryDebug = enabled;
+    });
+
     SettingsListener.observe('metrics.selectedMetrics.level', "", level => {
       this._telemetry = (level === 'Enhanced');
     });
   },
 
   uninit() {
     if (!this._client) {
       return;
@@ -313,24 +319,26 @@ Target.prototype = {
   _send(data) {
     let frame = this.frame;
 
     shell.sendEvent(frame, 'developer-hud-update', Cu.cloneInto(data, frame));
     this._logHistogram(data.metric);
   },
 
   _getAddonHistogram(item) {
-    let APPNAME_IDX = 3;
-    let HISTNAME_IDX = 4;
+    let appName = this._getAddonHistogramName(item, APPNAME_IDX);
+    let histName = this._getAddonHistogramName(item, HISTNAME_IDX);
 
+    return Services.telemetry.getAddonHistogram(appName, CUSTOM_HISTOGRAM_PREFIX
+      + histName);
+  },
+
+  _getAddonHistogramName(item, index) {
     let array = item.split('_');
-    let appName = array[APPNAME_IDX].toUpperCase();
-    let histName = array[HISTNAME_IDX].toUpperCase();
-    return Services.telemetry.getAddonHistogram(appName,
-      CUSTOM_HISTOGRAM_PREFIX + histName);
+    return array[index].toUpperCase();
   },
 
   _clearTelemetryData() {
     developerHUD._histograms.forEach(function(item) {
       Services.telemetry.getKeyedHistogramById(item).clear();
     });
 
     developerHUD._customHistograms.forEach(item => {
@@ -348,21 +356,31 @@ Target.prototype = {
       keyedHistograms: {},
       addonHistograms: {}
     };
     // Package the hud histograms.
     developerHUD._histograms.forEach(function(item) {
       payload.keyedHistograms[item] =
         Services.telemetry.getKeyedHistogramById(item).snapshot();
     });
+
     // Package the registered hud custom histograms
     developerHUD._customHistograms.forEach(item => {
-      payload.addonHistograms[item] = this._getAddonHistogram(item).snapshot();
+      let appName = this._getAddonHistogramName(item, APPNAME_IDX);
+      let histName = CUSTOM_HISTOGRAM_PREFIX +
+        this._getAddonHistogramName(item, HISTNAME_IDX);
+      let addonHist = Services.telemetry.getAddonHistogram(appName, histName).snapshot();
+      if (!(appName in payload.addonHistograms)) {
+        payload.addonHistograms[appName] = {};
+      }
+      // Do not include histograms with sum of 0.
+      if (addonHist.sum > 0) {
+        payload.addonHistograms[appName][histName] = addonHist;
+      }
     });
-
     shell.sendEvent(frame, 'advanced-telemetry-update', Cu.cloneInto(payload, frame));
   },
 
   _logHistogram(metric) {
     if (!developerHUD._telemetry || metric.skipTelemetry) {
       return;
     }
 
--- a/b2g/chrome/content/shell.css
+++ b/b2g/chrome/content/shell.css
@@ -57,16 +57,21 @@ body.content-loaded > #installing {
   border-radius: 100px;
   background-color: #FFF;
   animation-name: throbber;
   animation-duration: 1500ms;
   animation-iteration-count: infinite;
   animation-timing-function: linear;
 }
 
+#titlebar-buttonbox {
+  margin: 6px 7px;
+  -moz-appearance: -moz-window-button-box;
+}
+
 @keyframes throbber{
   from {
     transform: scale(0);
     opacity: 0.4;
   }
   to {
     transform: scale(400);
     opacity: 0;
--- a/b2g/chrome/content/shell.html
+++ b/b2g/chrome/content/shell.html
@@ -53,16 +53,17 @@
 #ifdef MOZ_WIDGET_COCOA
     <!--
      If the document is empty at startup, we don't display the window
      at all on Mac OS...
     -->
     <h1 id="placeholder">wtf mac os!</h1>
 #endif
 #else
+    <div id="titlebar-buttonbox"></div>
     <div id="installing">
       <div class="throbber"></div>
       <div class="message"></div>
     </div>
 #endif
     <!-- The html:iframe containing the UI is created here. -->
   </body>
 </html>
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -425,17 +425,16 @@ var shell = {
     chromeEventHandler.addEventListener('keydown', this, true);
     chromeEventHandler.addEventListener('keyup', this, true);
 
     window.addEventListener('MozApplicationManifest', this);
     window.addEventListener('MozAfterPaint', this);
     window.addEventListener('sizemodechange', this);
     window.addEventListener('unload', this);
     this.contentBrowser.addEventListener('mozbrowserloadstart', this, true);
-    this.contentBrowser.addEventListener('mozbrowserselectionstatechanged', this, true);
     this.contentBrowser.addEventListener('mozbrowserscrollviewchange', this, true);
     this.contentBrowser.addEventListener('mozbrowsercaretstatechanged', this);
 
     CustomEventManager.init();
     WebappsHelper.init();
     UserAgentOverrides.init();
     CaptivePortalLoginHelper.init();
 
@@ -459,17 +458,16 @@ var shell = {
 
   stop: function shell_stop() {
     window.removeEventListener('unload', this);
     window.removeEventListener('keydown', this, true);
     window.removeEventListener('keyup', this, true);
     window.removeEventListener('MozApplicationManifest', this);
     window.removeEventListener('sizemodechange', this);
     this.contentBrowser.removeEventListener('mozbrowserloadstart', this, true);
-    this.contentBrowser.removeEventListener('mozbrowserselectionstatechanged', this, true);
     this.contentBrowser.removeEventListener('mozbrowserscrollviewchange', this, true);
     this.contentBrowser.removeEventListener('mozbrowsercaretstatechanged', this);
     ppmm.removeMessageListener("content-handler", this);
 
     UserAgentOverrides.uninit();
   },
 
   // If this key event represents a hardware button which needs to be send as
@@ -579,39 +577,16 @@ var shell = {
         this.notifyContentStart();
        break;
       case 'mozbrowserscrollviewchange':
         this.sendChromeEvent({
           type: 'scrollviewchange',
           detail: evt.detail,
         });
         break;
-      case 'mozbrowserselectionstatechanged':
-        // The mozbrowserselectionstatechanged event, may have crossed the chrome-content boundary.
-        // This event always dispatch to shell.js. But the offset we got from this event is
-        // based on tab's coordinate. So get the actual offsets between shell and evt.target.
-        let elt = evt.target;
-        let win = elt.ownerDocument.defaultView;
-        let offsetX = win.mozInnerScreenX - window.mozInnerScreenX;
-        let offsetY = win.mozInnerScreenY - window.mozInnerScreenY;
-
-        let rect = elt.getBoundingClientRect();
-        offsetX += rect.left;
-        offsetY += rect.top;
-
-        let data = evt.detail;
-        data.offsetX = offsetX;
-        data.offsetY = offsetY;
-
-        DoCommandHelper.setEvent(evt);
-        shell.sendChromeEvent({
-          type: 'selectionstatechanged',
-          detail: data,
-        });
-        break;
       case 'mozbrowsercaretstatechanged':
         {
           let elt = evt.target;
           let win = elt.ownerDocument.defaultView;
           let offsetX = win.mozInnerScreenX - window.mozInnerScreenX;
           let offsetY = win.mozInnerScreenY - window.mozInnerScreenY;
 
           let rect = elt.getBoundingClientRect();
@@ -864,33 +839,27 @@ var CustomEventManager = {
 
     switch(detail.type) {
       case 'webapps-install-granted':
       case 'webapps-install-denied':
       case 'webapps-uninstall-granted':
       case 'webapps-uninstall-denied':
         WebappsHelper.handleEvent(detail);
         break;
-      case 'select-choicechange':
-        FormsHelper.handleEvent(detail);
-        break;
       case 'system-message-listener-ready':
         Services.obs.notifyObservers(null, 'system-message-listener-ready', null);
         break;
       case 'captive-portal-login-cancel':
         CaptivePortalLoginHelper.handleEvent(detail);
         break;
       case 'inputmethod-update-layouts':
       case 'inputregistry-add':
       case 'inputregistry-remove':
         KeyboardHelper.handleEvent(detail);
         break;
-      case 'do-command':
-        DoCommandHelper.handleEvent(detail.cmd);
-        break;
       case 'copypaste-do-command':
         Services.obs.notifyObservers({ wrappedJSObject: shell.contentBrowser },
                                      'ask-children-to-execute-copypaste-command', detail.cmd);
         break;
       case 'add-permission':
         Services.perms.add(Services.io.newURI(detail.uri, null, null),
                            detail.permissionType, permissionMap.get(detail.permission));
         break;
@@ -928,31 +897,16 @@ var CustomEventManager = {
         break;
       case 'restart':
         restart();
         break;
     }
   }
 }
 
-var DoCommandHelper = {
-  _event: null,
-  setEvent: function docommand_setEvent(evt) {
-    this._event = evt;
-  },
-
-  handleEvent: function docommand_handleEvent(cmd) {
-    if (this._event) {
-      Services.obs.notifyObservers({ wrappedJSObject: this._event.target },
-                                   'copypaste-docommand', cmd);
-      this._event = null;
-    }
-  }
-}
-
 var WebappsHelper = {
   _installers: {},
   _count: 0,
 
   init: function webapps_init() {
     Services.obs.addObserver(this, "webapps-launch", false);
     Services.obs.addObserver(this, "webapps-ask-install", false);
     Services.obs.addObserver(this, "webapps-ask-uninstall", false);
@@ -1129,32 +1083,60 @@ window.addEventListener('ContentStart', 
 
   let updatePrompt = promptCc.createInstance(Ci.nsIUpdatePrompt);
   if (!updatePrompt) {
     return;
   }
 
   updatePrompt.wrappedJSObject.handleContentStart(shell);
 });
+/* The "GPSChipOn" is to indicate that GPS engine is turned ON by the modem.
+   During this GPS engine is turned ON by the modem, we make the location tracking icon visible to user.
+   Once GPS engine is turned OFF, the location icon will disappear.
+   If GPS engine is not turned ON by the modem or GPS location service is triggered,
+   we let GPS service take over the control of showing the location tracking icon.
+   The regular sequence of the geolocation-device-events is: starting-> GPSStarting-> shutdown-> GPSShutdown
+*/
+
 
 (function geolocationStatusTracker() {
   let gGeolocationActive = false;
+  let GPSChipOn = false;
 
   Services.obs.addObserver(function(aSubject, aTopic, aData) {
     let oldState = gGeolocationActive;
-    if (aData == "starting") {
-      gGeolocationActive = true;
-    } else if (aData == "shutdown") {
-      gGeolocationActive = false;
+    let promptWarning = false;
+    switch (aData) {
+      case "GPSStarting":
+        if (!gGeolocationActive) {
+          gGeolocationActive = true;
+          GPSChipOn = true;
+          promptWarning = true;
+        }
+        break;
+      case "GPSShutdown":
+        if (GPSChipOn) {
+          gGeolocationActive = false;
+          GPSChipOn = false;
+        }
+        break;
+      case "starting":
+        gGeolocationActive = true;
+        GPSChipOn = false;
+        break;
+      case "shutdown":
+        gGeolocationActive = false;
+        break;
     }
 
     if (gGeolocationActive != oldState) {
       shell.sendChromeEvent({
         type: 'geolocation-status',
-        active: gGeolocationActive
+        active: gGeolocationActive,
+        prompt: promptWarning
       });
     }
 }, "geolocation-device-events", false);
 })();
 
 (function headphonesStatusTracker() {
   Services.obs.addObserver(function(aSubject, aTopic, aData) {
     shell.sendChromeEvent({
@@ -1386,16 +1368,18 @@ Services.obs.addObserver(function resetP
   },
   'profile-before-change2', false);
 
   let appStartup = Cc['@mozilla.org/toolkit/app-startup;1']
                      .getService(Ci.nsIAppStartup);
   appStartup.quit(Ci.nsIAppStartup.eForceQuit);
 }, 'b2g-reset-profile', false);
 
+var showInstallScreen;
+
 if (AppConstants.MOZ_GRAPHENE) {
   const restoreWindowGeometry = () => {
     let screenX = Services.prefs.getIntPref("b2g.nativeWindowGeometry.screenX");
     let screenY = Services.prefs.getIntPref("b2g.nativeWindowGeometry.screenY");
     let width = Services.prefs.getIntPref("b2g.nativeWindowGeometry.width");
     let height = Services.prefs.getIntPref("b2g.nativeWindowGeometry.height");
 
     if (screenX == -1) {
@@ -1423,17 +1407,17 @@ if (AppConstants.MOZ_GRAPHENE) {
                          .QueryInterface(Ci.nsIDocShellTreeItem)
                          .treeOwner
                          .QueryInterface(Ci.nsIInterfaceRequestor)
                          .getInterface(Ci.nsIBaseWindow);
 
   const showNativeWindow = () => baseWindow.visibility = true;
   const hideNativeWindow = () => baseWindow.visibility = false;
 
-  const showInstallScreen = () => {
+  showInstallScreen = () => {
     const grapheneStrings =
       Services.strings.createBundle('chrome://b2g-l10n/locale/graphene.properties');
     document.querySelector('#installing > .message').textContent =
       grapheneStrings.GetStringFromName('installing');
     showNativeWindow();
   }
 
   const hideInstallScreen = () => {
--- a/b2g/components/AlertsService.js
+++ b/b2g/components/AlertsService.js
@@ -61,33 +61,46 @@ AlertsService.prototype = {
       case "xpcom-shutdown":
         Services.obs.removeObserver(this, "xpcom-shutdown");
         cpmm.removeMessageListener(kMessageAppNotificationReturn, this);
         break;
     }
   },
 
   // nsIAlertsService
+  showAlert: function(aAlert, aAlertListener) {
+    if (!aAlert) {
+      return;
+    }
+    cpmm.sendAsyncMessage(kMessageAlertNotificationSend, {
+      imageURL: aAlert.imageURL,
+      title: aAlert.title,
+      text: aAlert.text,
+      clickable: aAlert.textClickable,
+      cookie: aAlert.cookie,
+      listener: aAlertListener,
+      id: aAlert.name,
+      dir: aAlert.dir,
+      lang: aAlert.lang,
+      dataStr: aAlert.data,
+      inPrivateBrowsing: aAlert.inPrivateBrowsing
+    });
+  },
+
   showAlertNotification: function(aImageUrl, aTitle, aText, aTextClickable,
                                   aCookie, aAlertListener, aName, aBidi,
                                   aLang, aDataStr, aPrincipal,
                                   aInPrivateBrowsing) {
-    cpmm.sendAsyncMessage(kMessageAlertNotificationSend, {
-      imageURL: aImageUrl,
-      title: aTitle,
-      text: aText,
-      clickable: aTextClickable,
-      cookie: aCookie,
-      listener: aAlertListener,
-      id: aName,
-      dir: aBidi,
-      lang: aLang,
-      dataStr: aDataStr,
-      inPrivateBrowsing: aInPrivateBrowsing
-    });
+    let alert = Cc["@mozilla.org/alert-notification;1"].
+      createInstance(Ci.nsIAlertNotification);
+
+    alert.init(aName, aImageUrl, aTitle, aText, aTextClickable, aCookie,
+               aBidi, aLang, aDataStr, aPrincipal, aInPrivateBrowsing);
+
+    this.showAlert(alert, aAlertListener);
   },
 
   closeAlert: function(aName) {
     cpmm.sendAsyncMessage(kMessageAlertNotificationClose, {
       name: aName
     });
   },
 
--- a/b2g/components/FilePicker.js
+++ b/b2g/components/FilePicker.js
@@ -66,21 +66,22 @@ FilePicker.prototype = {
       throw Cr.NS_ERROR_NOT_IMPLEMENTED;
     }
   },
 
   /* readonly attribute nsILocalFile file - not implemented; */
   /* readonly attribute nsISimpleEnumerator files - not implemented; */
   /* readonly attribute nsIURI fileURL - not implemented; */
 
-  get domfiles() {
+  get domFileOrDirectoryEnumerator() {
     return this.mFilesEnumerator;
   },
 
-  get domfile() {
+  // We don't support directory selection yet.
+  get domFileOrDirectory() {
     return this.mFilesEnumerator ? this.mFilesEnumerator.mFiles[0] : null;
   },
 
   get mode() {
     return this.mMode;
   },
 
   appendFilters: function(filterMask) {
new file mode 100644
--- /dev/null
+++ b/b2g/components/PersistentDataBlock.jsm
@@ -0,0 +1,766 @@
+/* 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/. */
+
+/**
+ * The Persistent Partition has this layout:
+ *
+ * Bytes:     32       4        4          <DATA_LENGTH>               1
+ * Fields: [[DIGEST][MAGIC][DATA_LENGTH][        DATA        ][OEM_UNLOCK_ENABLED]]
+ *
+ */
+
+"use strict";
+
+const DEBUG = false;
+
+this.EXPORTED_SYMBOLS = [ "PersistentDataBlock" ];
+
+const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
+// This is a marker that will be written after digest in the partition.
+const PARTITION_MAGIC = 0x19901873;
+// This is the limit in Android because of issues with Binder if blocks are > 100k
+// We dont really have this issues because we don't use Binder, but let's stick
+// to Android implementation.
+const MAX_DATA_BLOCK_SIZE = 1024 * 100;
+const DIGEST_SIZE_BYTES = 32;
+const HEADER_SIZE_BYTES = 8;
+const PARTITION_MAGIC_SIZE_BYTES = 4;
+const DATA_SIZE_BYTES = 4;
+const OEM_UNLOCK_ENABLED_BYTES = 1;
+// The position of the Digest
+const DIGEST_OFFSET = 0;
+const XPCOM_SHUTDOWN_OBSERVER_TOPIC = "xpcom-shutdown";
+// This property will have the path to the persistent partition
+const PERSISTENT_DATA_BLOCK_PROPERTY = "ro.frp.pst";
+const OEM_UNLOCK_PROPERTY = "sys.oem_unlock_allowed";
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Promise", "resource://gre/modules/Promise.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm");
+
+XPCOMUtils.defineLazyGetter(this, "libcutils", function () {
+  Cu.import("resource://gre/modules/systemlibs.js");
+  return libcutils;
+});
+
+var inParent = Cc["@mozilla.org/xre/app-info;1"]
+                 .getService(Ci.nsIXULRuntime)
+                 .processType === Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
+
+function log(str) {
+  dump("PersistentDataBlock.jsm: " + str + "\n");
+}
+
+function debug(str) {
+  DEBUG && log(str);
+}
+
+function toHexString(data) {
+  function toHexChar(charCode) {
+    return ("0" + charCode.toString(16).slice(-2));
+  }
+  let hexString = "";
+  if (typeof data === "string") {
+    hexString = Array.from(data, (c, i) => toHexChar(data.charCodeAt(i))).join("");
+  } else if (typeof data === "array") {
+    hexString = data.map(toHexChar).join("");
+  }
+  return hexString;
+}
+
+function arr2bstr(arr) {
+  let bstr = "";
+  for (let i = 0; i < arr.length; i++) {
+    bstr += String.fromCharCode(arr[i]);
+  }
+  return bstr;
+}
+
+this.PersistentDataBlock = {
+
+  /**
+   * libc funcionality. Accessed via ctypes
+   */
+   _libc: {
+      handler: null,
+      open: function() {},
+      close: function() {},
+      ioctl: function() {}
+   },
+
+  /**
+   * Component to access property_get/set functions
+   */
+  _libcutils: null,
+
+  /**
+   * The size of a device block. This is assigned by querying the kernel.
+   */
+  _blockDeviceSize: -1,
+
+  /**
+   * Data block file
+   */
+  _dataBlockFile: "",
+
+  /**
+  * Change the behavior of the class for some methods to testing mode. This will fake the return value of some
+  * methods realted to native operations with block devices.
+  */
+  _testing: false,
+
+  /*
+  * *** USE ONLY FOR TESTING ***
+  * This component will interface between Gecko and a special secure partition with no formatting, a raw partition.
+  * This interaction requires a specific partition layout structure which emulators don't have so far. So for
+  * our unit tests to pass, we need a way for some methods to behave differently. This method will change this
+  * behavior at runtime so some low-level platform-specific operations will be faked:
+  *  - Getting the size of a partition: We can use any partition to get the size, is up to the test to choose
+  *      which partition to use. But, in testing mode we use files instead of partitions, so we need to fake the
+  *      return value of this method in this case.
+  *  - Wipping a partition: This will fully remove the partition as well as it filesystem type, so we cannot
+  *      test it on any existing emulator partition. Testing mode will skip this operation.
+  *
+  * @param enabled {Bool} Set testing mode. See _testing property.
+  */
+  setTestingMode: function(enabled) {
+     this._testing = enabled || false;
+  },
+
+  /**
+  * Initialize the class.
+  *
+  */
+  init: function(mode) {
+    debug("init()");
+
+    if (libcutils) {
+      this._libcutils = libcutils;
+    }
+
+    if (!this.ctypes) {
+      Cu.import("resource://gre/modules/ctypes.jsm", this);
+    }
+
+    if (this._libc.handler === null) {
+      if (AppConstants.platform != "gonk") {
+        log("This component requires Gonk!");
+        throw Cr.NS_ERROR_ABORT;
+      }
+
+      try {
+        this._libc.handler = this.ctypes.open(this.ctypes.libraryName("c"));
+        this._libc.close = this._libc.handler.declare("close",
+                                                      this.ctypes.default_abi,
+                                                      this.ctypes.int,
+                                                      this.ctypes.int
+                                                     );
+        this._libc.open = this._libc.handler.declare("open",
+                                                     this.ctypes.default_abi,
+                                                     this.ctypes.int,
+                                                     this.ctypes.char.ptr,
+                                                     this.ctypes.int
+                                                    );
+        this._libc.ioctl = this._libc.handler.declare("ioctl",
+                                                      this.ctypes.default_abi,
+                                                      this.ctypes.int,
+                                                      this.ctypes.int,
+                                                      this.ctypes.unsigned_long,
+                                                      this.ctypes.unsigned_long.ptr);
+
+      } catch(ex) {
+        log("Unable to open libc.so: ex = " + ex);
+        throw Cr.NS_ERROR_FAILURE;
+      }
+    }
+
+    this._dataBlockFile = this._libcutils.property_get(PERSISTENT_DATA_BLOCK_PROPERTY);
+    if (this._dataBlockFile === null) {
+      log("init: ERROR: property " +  PERSISTENT_DATA_BLOCK_PROPERTY + " doesn't exist!");
+      throw Cr.NS_ERROR_FAILURE;
+    }
+
+    Services.obs.addObserver(this, XPCOM_SHUTDOWN_OBSERVER_TOPIC, false);
+  },
+
+  uninit: function() {
+    debug("uninit()");
+    this._libc.handler.close();
+    Services.obs.removeObserver(this, XPCOM_SHUTDOWN_OBSERVER_TOPIC);
+  },
+
+  _checkLibcUtils: function() {
+    debug("_checkLibcUtils");
+    if (!this._libcutils) {
+      log("No proper libcutils binding, aborting.");
+      throw Cr.NS_ERROR_NO_INTERFACE;
+    }
+
+    return true;
+  },
+
+  /**
+   * Callback mehtod for addObserver
+   */
+  observe: function(aSubject, aTopic, aData) {
+    debug("observe()");
+    switch (aTopic) {
+      case XPCOM_SHUTDOWN_OBSERVER_TOPIC:
+        this.uninit();
+        break;
+
+      default:
+        log("Wrong observer topic: " + aTopic);
+        break;
+    }
+  },
+
+  /**
+  * This method will format the persistent partition if it detects manipulation (digest calculation will fail)
+  * or if the OEM Unlock Enabled byte is set to true.
+  * We need to call this method on every boot.
+  */
+  start: function() {
+    debug("start()");
+    return this._enforceChecksumValidity().then(() => {
+      return this._formatIfOemUnlockEnabled().then(() => {
+        return Promise.resolve(true);
+      })
+    }).catch(ex => {
+      return Promise.reject(ex);
+    });
+  },
+
+  /**
+   * Computes the digest of the entire data block.
+   * The digest is saved in the first 32 bytes of the block.
+   *
+   * @param isStoredDigestReturned {Bool} Tells the function to return the stored digest as well as the calculated.
+   *                                      True means to return stored digest and the calculated
+   *                                      False means to return just the calculated one
+   *
+   * @return Promise<digest> {Object} The calculated digest into the "calculated" property, and the stored
+   *                                  digest into the "stored" property.
+   */
+  _computeDigest: function (isStoredDigestReturned) {
+    debug("_computeDigest()");
+    let digest = {calculated: "", stored: ""};
+    let partition;
+    debug("_computeDigest: _dataBlockFile = " + this._dataBlockFile);
+    return OS.File.open(this._dataBlockFile, {existing:true, append:false, read:true}).then(_partition => {
+      partition = _partition;
+      return partition.read(DIGEST_SIZE_BYTES);
+    }).then(digestDataRead => {
+      // If storedDigest is passed as a parameter, the caller will likely compare the
+      // one is already stored in the partition with the one we are going to compute later.
+      if (isStoredDigestReturned === true) {
+        debug("_computeDigest: get stored digest from the partition");
+        digest.stored = arr2bstr(digestDataRead);
+      }
+      return partition.read();
+    }).then(data => {
+      // Calculate Digest with the data retrieved after the digest
+      let hasher = Cc["@mozilla.org/security/hash;1"].createInstance(Ci.nsICryptoHash);
+      hasher.init(hasher.SHA256);
+      hasher.update(data, data.byteLength);
+      digest.calculated = hasher.finish(false);
+      debug("_computeDigest(): Digest = "  + toHexString(digest.calculated) +
+            "(" + digest.calculated.length + ")");
+      return partition.close();
+    }).then(() => {
+      return Promise.resolve(digest);
+    }).catch(ex => {
+      log("_computeDigest(): Failed to read partition: ex = " + ex);
+      return Promise.reject(ex);
+    });
+  },
+
+  /**
+   * Returns the size of a block from the undelaying filesystem
+   *
+   * @return {Number} The size of the block
+   */
+  _getBlockDeviceSize: function() {
+    debug("_getBlockDeviceSize()");
+
+    // See _testing property
+    if (this._testing === true) {
+      debug("_getBlockDeviceSize: No real block device size in testing mode!. Returning 1024.");
+      return 1024;
+    }
+
+    if (AppConstants.platform != "gonk") {
+      log("_getBlockDeviceSize: ERROR: This feature is only supported in Gonk!");
+      return -1;
+    }
+
+    const O_READONLY = 0;
+    const O_NONBLOCK = 1 << 11;
+    /* Getting the correct values for ioctl() operations by reading the headers is not a trivial task, so
+     * the better way to get the values below is by writting a simple test aplication in C that will
+     * print the values to the output.
+     * 32bits and 64bits value for ioctl() BLKGETSIZE64 operation is different. So we will fallback in
+     * case ioctl() returns ENOTTY (22). */
+    const BLKGETSIZE64_32_BITS = 0x80041272;
+    const BLKGETSIZE64_64_BITS = 0x80081272;
+    const ENOTTY = 25;
+
+    debug("_getBlockDeviceSize: _dataBlockFile = " + this._dataBlockFile);
+    let fd = this._libc.open(this._dataBlockFile, O_READONLY | O_NONBLOCK);
+    if (fd < 0) {
+      log("_getBlockDeviceSize: couldn't open partition!: errno = " + this.ctypes.errno);
+      throw Cr.NS_ERROR_FAILURE;
+    }
+
+    let size = new this.ctypes.unsigned_long();
+    let sizeAddress = size.address();
+    let ret = this._libc.ioctl(fd, BLKGETSIZE64_32_BITS, sizeAddress);
+    if (ret < 0) {
+      if (this.ctypes.errno === ENOTTY) {
+        log("_getBlockDeviceSize: errno is ENOTTY, falling back to 64 bit version of BLKGETSIZE64...");
+        ret = this._libc.ioctl(fd, BLKGETSIZE64_64_BITS, sizeAddress);
+        if (ret < 0) {
+          this._libc.close(fd);
+          log("_getBlockDeviceSize: BLKGETSIZE64 failed again!. errno = " + this.ctypes.errno);
+          throw Cr.NS_ERROR_FAILURE;
+        }
+      } else {
+        this._libc.close(fd);
+        log("_getBlockDeviceSize: couldn't get block device size!: errno = " + this.ctypes.errno);
+        throw Cr.NS_ERROR_FAILURE;
+      }
+    }
+    this._libc.close(fd);
+    debug("_getBlockDeviceSize: size =" + size.value);
+    return size.value;
+  },
+
+  /**
+   * Sets the byte into the partition which represents the OEM Unlock Enabled feature.
+   * A value of "1" means that the user doesn't want to enable KillSwitch.
+   * The byte is the last one byte into the device block.
+   *
+   * @param isSetOemUnlockEnabled {bool} If true, sets the OEM Unlock Enabled byte to 1.
+   *                                     Otherwise, sets it to 0.
+   */
+  _doSetOemUnlockEnabled: function(isSetOemUnlockEnabled) {
+    debug("_doSetOemUnlockEnabled()");
+    let partition;
+    return OS.File.open(this._dataBlockFile, {existing:true, append:false, write:true}).then(_partition => {
+      partition = _partition;
+      return partition.setPosition(this._getBlockDeviceSize() - OEM_UNLOCK_ENABLED_BYTES, OS.File.POS_START);
+    }).then(() => {
+      return partition.write(new Uint8Array([ isSetOemUnlockEnabled === true ? 1 : 0 ]));
+    }).then(bytesWrittenLength => {
+      if (bytesWrittenLength != 1) {
+        log("_doSetOemUnlockEnabled: Error writting OEM Unlock Enabled byte!");
+        return Promise.reject();
+      }
+      return partition.close();
+    }).then(() => {
+      let oemUnlockByte = (isSetOemUnlockEnabled === true ? "1" : "0");
+      debug("_doSetOemUnlockEnabled: OEM unlock enabled written to " + oemUnlockByte);
+      this._libcutils.property_set(OEM_UNLOCK_PROPERTY, oemUnlockByte);
+      return Promise.resolve();
+    }).catch(ex => {
+      return Promise.reject(ex);
+    });
+  },
+
+  /**
+   * Computes the digest by reading the entire block of data and write it to the digest field
+   *
+   * @return true Promise<bool> Operation succeed
+   * @return false Promise<bool> Operation failed
+   */
+  _computeAndWriteDigest: function() {
+    debug("_computeAndWriteDigest()");
+    let digest;
+    let partition;
+    return this._computeDigest().then(_digest => {
+      digest = _digest;
+      return OS.File.open(this._dataBlockFile, {write:true, existing:true, append:false});
+    }).then(_partition => {
+      partition = _partition;
+      return partition.setPosition(DIGEST_OFFSET, OS.File.POS_START);
+    }).then(() => {
+      return partition.write(new Uint8Array(Array.from(digest.calculated, (c, i) => digest.calculated.charCodeAt(i))));
+    }).then(bytesWrittenLength => {
+      if (bytesWrittenLength != DIGEST_SIZE_BYTES) {
+        log("_computeAndWriteDigest: Error writting digest to partition!. Expected: " + DIGEST_SIZE_BYTES + " Written: " + bytesWrittenLength);
+        return Promise.reject();
+      }
+      return partition.close();
+    }).then(() => {
+      debug("_computeAndWriteDigest: digest written to partition");
+      return Promise.resolve(true);
+    }).catch(ex => {
+      log("_computeAndWriteDigest: Couldn't write digest in the persistent partion. ex = " + ex );
+      return Promise.reject(ex);
+    });
+  },
+
+  /**
+   * Formats the persistent partition if the OEM Unlock Enabled field is set to true, and
+   * write the Unlock Property accordingly.
+   *
+   * @return true Promise<bool> OEM Unlock was enabled, so the partition has been formated
+   * @return false Promise<bool> OEM Unlock was disabled, so the partition hasn't been formated
+   */
+  _formatIfOemUnlockEnabled: function () {
+    debug("_formatIfOemUnlockEnabled()");
+    return this.getOemUnlockEnabled().then(enabled => {
+      this._libcutils.property_set(OEM_UNLOCK_PROPERTY,(enabled === true ? "1" : "0"));
+      if (enabled === true) {
+        return this._formatPartition(true);
+      }
+      return Promise.resolve(false);
+    }).then(result => {
+      if (result === false) {
+        return Promise.resolve(false);
+      } else {
+        return Promise.resolve(true);
+      }
+    }).catch(ex => {
+      log("_formatIfOemUnlockEnabled: An error ocurred!. ex = " + ex);
+      return Promise.reject(ex);
+    });
+  },
+
+  /**
+   * Formats the persistent data partition with the proper structure.
+   *
+   * @param isSetOemUnlockEnabled {bool} If true, writes a "1" in the OEM Unlock Enabled field (last
+   *                                     byte of the block). If false, writes a "0".
+   *
+   * @return Promise
+   */
+  _formatPartition: function(isSetOemUnlockEnabled) {
+    debug("_formatPartition()");
+    let partition;
+    return OS.File.open(this._dataBlockFile, {write:true, existing:true, append:false}).then(_partition => {
+      partition = _partition;
+      return partition.write(new Uint8Array(DIGEST_SIZE_BYTES));
+    }).then(bytesWrittenLength => {
+      if (bytesWrittenLength != DIGEST_SIZE_BYTES) {
+        log("_formatPartition Error writting zero-digest!. Expected: " + DIGEST_SIZE_BYTES + " Written: " + bytesWrittenLength);
+        return Promise.reject();
+      }
+      return partition.write(new Uint32Array([PARTITION_MAGIC]));
+    }).then(bytesWrittenLength => {
+       if (bytesWrittenLength != PARTITION_MAGIC_SIZE_BYTES) {
+        log("_formatPartition Error writting magic number!. Expected: " + PARTITION_MAGIC_SIZE_BYTES + " Written: " + bytesWrittenLength);
+        return Promise.reject();
+      }
+      return partition.write(new Uint8Array(DATA_SIZE_BYTES));
+    }).then(bytesWrittenLength => {
+      if (bytesWrittenLength != DATA_SIZE_BYTES) {
+        log("_formatPartition Error writting data size!. Expected: " + DATA_SIZE_BYTES + " Written: " + bytesWrittenLength);
+        return Promise.reject();
+      }
+      return partition.close();
+    }).then(() => {
+      return this._doSetOemUnlockEnabled(isSetOemUnlockEnabled);
+    }).then(() => {
+      return this._computeAndWriteDigest();
+    }).then(() => {
+      return Promise.resolve();
+    }).catch(ex => {
+      log("_formatPartition: Failed to format block device!: ex = " + ex);
+      return Promise.reject(ex);
+    });
+  },
+
+  /**
+   * Check digest validity. If it's not valid, formats the persistent partition
+   *
+   * @return true Promise<bool> The checksum is valid so the promise is resolved to true
+   * @return false Promise<bool> The checksum is not valid, so the partition is going to be
+   *                             formatted and the OEM Unlock Enabled field written to 0 (false).
+   */
+  _enforceChecksumValidity: function() {
+    debug("_enforceChecksumValidity");
+    return this._computeDigest(true).then(digest => {
+      if (digest.stored != digest.calculated) {
+        log("_enforceChecksumValidity: Validation failed! Stored digest: " + toHexString(digest.stored) +
+            " is not the same as the calculated one: " + toHexString(digest.calculated));
+        return Promise.reject();
+      }
+      debug("_enforceChecksumValidity: Digest computation succeed.");
+      return Promise.resolve(true);
+    }).catch(ex => {
+      log("_enforceChecksumValidity: Digest computation failed: ex = " + ex);
+      log("_enforceChecksumValidity: Formatting FRP partition...");
+      return this._formatPartition(false).then(() => {
+        return Promise.resolve(false);
+      }).catch(ex => {
+        log("_enforceChecksumValidity: Error ocurred while formating the partition!: ex = " + ex);
+        return Promise.reject(ex);
+      });
+    });
+  },
+
+  /**
+   * Reads the entire data field
+   *
+   * @return bytes Promise<Uint8Array> A promise resolved with the bytes read
+   */
+  read: function() {
+    debug("read()");
+    let partition;
+    let bytes;
+    let dataSize;
+    return this.getDataFieldSize().then(_dataSize => {
+      dataSize = _dataSize;
+      return OS.File.open(this._dataBlockFile, {read:true, existing:true, append:false});
+    }).then(_partition => {
+      partition = _partition;
+      return partition.setPosition(DIGEST_SIZE_BYTES + HEADER_SIZE_BYTES, OS.File.POS_START);
+    }).then(() => {
+      return partition.read(dataSize);
+    }).then(_bytes => {
+      bytes = _bytes;
+      if (bytes.byteLength < dataSize) {
+        log("read: Failed to read entire data block. Bytes read: " + bytes.byteLength + "/" + dataSize);
+        return Promise.reject();
+      }
+      return partition.close();
+    }).then(() => {
+      return Promise.resolve(bytes);
+    }).catch(ex => {
+      log("read: Failed to read entire data block. Exception: " + ex);
+      return Promise.reject(ex);
+    });
+  },
+
+  /**
+   * Writes an entire block to the persistent partition
+   *
+   * @param data {Uint8Array}
+   *
+   * @return Promise<Number> Promise resolved to the number of bytes written.
+   */
+  write: function(data) {
+    debug("write()");
+    // Ensure that we don't overwrite digest/magic/data-length and the last byte
+    let maxBlockSize = this._getBlockDeviceSize() - (DIGEST_SIZE_BYTES + HEADER_SIZE_BYTES + 1);
+    if (data.byteLength > maxBlockSize) {
+      log("write: Couldn't write more than " + maxBlockSize + " bytes to the partition. " +
+           maxBlockSize + " bytes given.");
+      return Promise.reject();
+    }
+
+    let partition;
+    return OS.File.open(this._dataBlockFile, {write:true, existing:true, append:false}).then(_partition => {
+      let digest = new Uint8Array(DIGEST_SIZE_BYTES);
+      let magic = new Uint8Array((new Uint32Array([PARTITION_MAGIC])).buffer);
+      let dataLength = new Uint8Array((new Uint32Array([data.byteLength])).buffer);
+      let bufferToWrite = new Uint8Array(digest.byteLength + magic.byteLength + dataLength.byteLength + data.byteLength );
+      let offset = 0;
+      bufferToWrite.set(digest, offset);
+      offset += digest.byteLength;
+      bufferToWrite.set(magic, offset);
+      offset += magic.byteLength;
+      bufferToWrite.set(dataLength, offset);
+      offset += dataLength.byteLength;
+      bufferToWrite.set(data, offset);
+      partition = _partition;
+      return partition.write(bufferToWrite);
+    }).then(bytesWrittenLength => {
+      let expectedWrittenLength = DIGEST_SIZE_BYTES + HEADER_SIZE_BYTES + data.byteLength;
+      if (bytesWrittenLength != expectedWrittenLength) {
+        log("write: Error writting data to partition!: Expected: " + expectedWrittenLength + " Written: " + bytesWrittenLength);
+        return Promise.reject();
+      }
+      return partition.close();
+    }).then(() => {
+      return this._computeAndWriteDigest();
+    }).then(couldComputeAndWriteDigest => {
+      if (couldComputeAndWriteDigest === true) {
+        return Promise.resolve(data.byteLength);
+      } else {
+        log("write: Failed to compute and write the digest");
+        return Promise.reject();
+      }
+    }).catch(ex => {
+      log("write: Failed to write to the persistent partition: ex = " + ex);
+      return Promise.reject(ex);
+    });
+  },
+
+  /**
+   * Wipes the persistent partition.
+   *
+   * @return Promise If no errors, the promise is resolved
+   */
+  wipe: function() {
+    debug("wipe()");
+
+    if (this._testing === true) {
+      log("wipe: No wipe() funcionality in testing mode");
+      return Promise.resolve();
+    }
+
+    if (AppConstants.platform != "gonk") {
+      log("wipe: ERROR: This feature is only supported in Gonk!");
+      return Promise.reject();
+    }
+
+    const O_READONLY = 0;
+    const O_RDWR = 2;
+    const O_NONBLOCK = 1 << 11;
+    // This constant value is the same under 32 and 64 bits arch.
+    const BLKSECDISCARD = 0x127D;
+    // This constant value is the same under 32 and 64 bits arch.
+    const BLKDISCARD = 0x1277;
+
+    return new Promise((resolve, reject) => {
+      let range = new this.ctypes.unsigned_long();
+      let rangeAddress = range.address();
+      let blockDeviceLength = this._getBlockDeviceSize();
+      range[0] = 0;
+      range[1] = blockDeviceLength;
+      if (range[1] === 0) {
+        log("wipe: Block device size is 0!");
+        return reject();
+      }
+      let fd = this._libc.open(this._dataBlockFile, O_RDWR);
+      if (fd < 0) {
+        log("wipe: ERROR couldn't open partition!: error = " + this.ctypes.errno);
+        return reject();
+      }
+      let ret = this._libc.ioctl(fd, BLKSECDISCARD, rangeAddress);
+      if (ret < 0) {
+        log("wipe: Something went wrong secure discarding block: errno: " + this.ctypes.errno + ": Falling back to non-secure discarding...");
+        ret = this._libc.ioctl(fd, BLKDISCARD, rangeAddress);
+        if (ret < 0) {
+          this._libc.close(fd);
+          log("wipe: CRITICAL: non-secure discarding failed too!!: errno: " + this.ctypes.errno);
+          return reject();
+        } else {
+          this._libc.close(fd);
+          log("wipe: non-secure discard used and succeed");
+          return resolve();
+        }
+      }
+      this._libc.close(fd);
+      log("wipe: secure discard succeed");
+      return resolve();
+    });
+  },
+
+  /**
+   * Set the OEM Unlock Enabled field (one byte at the end of the partition), to 1 or 0 depending on
+   * the input parameter.
+   *
+   * @param enabled {bool} If enabled, we write a 1 in the last byte of the partition.
+   *
+   * @return Promise
+   *
+   */
+  setOemUnlockEnabled: function(enabled) {
+    debug("setOemUnlockEnabled()");
+    return this._doSetOemUnlockEnabled(enabled).then(() => {
+      return this._computeAndWriteDigest();
+    }).then(() => {
+      return Promise.resolve();
+    }).catch(ex => {
+      return Promise.reject(ex);
+    });
+  },
+
+  /**
+   * Gets the byte from the partition which represents the OEM Unlock Enabled state.
+   *
+   * @return true Promise<Bool> The user didn't activate KillSwitch.
+   * @return false Promise<Bool> The user did activate KillSwitch.
+   */
+  getOemUnlockEnabled: function() {
+    log("getOemUnlockEnabled()");
+    let ret = false;
+    let partition;
+    return OS.File.open(this._dataBlockFile, {existing:true, append:false, read:true}).then(_partition => {
+      partition = _partition;
+      return partition.setPosition(this._getBlockDeviceSize() - OEM_UNLOCK_ENABLED_BYTES, OS.File.POS_START);
+    }).then(() => {
+      return partition.read(OEM_UNLOCK_ENABLED_BYTES);
+    }).then(data => {
+      debug("getOemUnlockEnabled: OEM unlock enabled byte = '" + data[0] + "'");
+      ret = (data[0] === 1 ? true : false);
+      return partition.close();
+    }).then(() => {
+      return Promise.resolve(ret);
+    }).catch(ex => {
+      log("getOemUnlockEnabled: Error reading OEM unlock enabled byte from partition: ex = " + ex);
+      return Promise.reject(ex);
+    });
+  },
+
+  /**
+   * Gets the size of the data block by reading the data-length field
+   *
+   * @return Promise<Number> A promise resolved to the number of bytes os the data field.
+   */
+  getDataFieldSize: function() {
+    debug("getDataFieldSize()");
+    let partition
+    let dataLength = 0;
+    return OS.File.open(this._dataBlockFile, {read:true, existing:true, append:false}).then(_partition => {
+      partition = _partition;
+      // Skip the digest field
+      return partition.setPosition(DIGEST_SIZE_BYTES, OS.File.POS_START);
+    }).then(() => {
+      // Read the Magic field
+      return partition.read(PARTITION_MAGIC_SIZE_BYTES);
+    }).then(_magic => {
+      let magic = new Uint32Array(_magic.buffer)[0];
+      if (magic === PARTITION_MAGIC) {
+        return partition.read(PARTITION_MAGIC_SIZE_BYTES);
+      } else {
+        log("getDataFieldSize: ERROR: Invalid Magic number!");
+        return Promise.reject();
+      }
+    }).then(_dataLength => {
+      if (_dataLength) {
+        dataLength = new Uint32Array(_dataLength.buffer)[0];
+      }
+      return partition.close();
+    }).then(() => {
+      if (dataLength && dataLength != 0) {
+        return Promise.resolve(dataLength);
+      } else {
+        return Promise.reject();
+      }
+    }).catch(ex => {
+      log("getDataFieldSize: Couldn't get data field size: ex = " + ex);
+      return Promise.reject(ex);
+    });
+  },
+
+  /**
+   * Gets the maximum possible size of a data field
+   *
+   * @return Promise<Number> A Promise resolved to the maximum number of bytes allowed for the data field
+   *
+   */
+  getMaximumDataBlockSize: function() {
+    debug("getMaximumDataBlockSize()");
+    return new Promise((resolve, reject) => {
+      let actualSize = this._getBlockDeviceSize() - HEADER_SIZE_BYTES - OEM_UNLOCK_ENABLED_BYTES;
+      resolve(actualSize <= MAX_DATA_BLOCK_SIZE ? actualSize : MAX_DATA_BLOCK_SIZE);
+    });
+  }
+
+};
+
+// This code should ALWAYS be living only on the parent side.
+if (!inParent) {
+  log("PersistentDataBlock should only be living on parent side.");
+  throw Cr.NS_ERROR_ABORT;
+} else {
+  this.PersistentDataBlock.init();
+}
--- a/b2g/components/moz.build
+++ b/b2g/components/moz.build
@@ -65,16 +65,17 @@ EXTRA_JS_MODULES += [
     'Frames.jsm',
     'FxAccountsMgmtService.jsm',
     'KillSwitchMain.jsm',
     'LogCapture.jsm',
     'LogParser.jsm',
     'LogShake.jsm',
     'MultiscreenHandler.jsm',
     'OrientationChangeHandler.jsm',
+    'PersistentDataBlock.jsm',
     'SafeMode.jsm',
     'Screenshot.jsm',
     'SignInToWebsite.jsm',
     'SystemAppProxy.jsm',
     'TelURIParser.jsm',
     'WebappsUpdater.jsm',
 ]
 
new file mode 100644
--- /dev/null
+++ b/b2g/components/test/unit/file_persistentdatablock.js
@@ -0,0 +1,412 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
+
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/NetUtil.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
+XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
+// This constants must be synced with the ones in PersistentDataBlock.jsm
+const PARTITION_MAGIC = 0x19901873;
+const DIGEST_SIZE_BYTES = 32;
+const PARTITION_MAGIC_SIZE_BYTES = 4;
+const DATA_SIZE_BYTES = 4;
+const OEM_UNLOCK_ENABLED_BYTES = 1;
+
+const CACHE_PARTITION = "/dev/block/mtdblock2";
+const PARTITION_FAKE_FILE = "/data/local/tmp/frp.test";
+const CACHE_PARTITION_SIZE = 69206016;
+
+function log(str) {
+  do_print("head_persistentdatablock: " + str + "\n");
+}
+
+function toHexString(data) {
+  function toHexChar(charCode) {
+    return ("0" + charCode.toString(16).slice(-2));
+  }
+  let hexString = "";
+  if (typeof data === "string") {
+    hexString = Array.from(data, (c, i) => toHexChar(data.charCodeAt(i))).join("");
+  } else if (typeof data === "array") {
+    hexString = data.map(toHexChar).join("");
+  }
+  return hexString;
+}
+
+function _prepareConfig(_args) {
+  let args = _args || {};
+  // This digest has been previously calculated given the data to be written later, and setting the OEM Unlocked Enabled byte
+  // to 1. If we need different values, some tests will fail because this precalculated digest won't be valid then.
+  args.digest = args.digest || new Uint8Array([0x00, 0x41, 0x7e, 0x5f, 0xe2, 0xdd, 0xaa, 0xed, 0x11, 0x90, 0x0e, 0x1d, 0x26,
+                                               0x10, 0x30, 0xbd, 0x44, 0x9e, 0xcc, 0x4b, 0x65, 0xbe, 0x2e, 0x99, 0x9f, 0x86,
+                                               0xf0, 0xfc, 0x5b, 0x33, 0x00, 0xd0]);
+  args.dataLength = args.dataLength || 6;
+  args.data = args.data || new Uint8Array(["P", "A", "S", "S", "W", "D"]);
+  args.oem = args.oem === undefined ? true : args.oem;
+  args.oemUnlockAllowed = args.oemUnlockAllowed === undefined ? true : args.oemUnlockAllowed;
+
+  log("_prepareConfig: args.digest = " + args.digest);
+  log("_prepareConfig: args.dataLength = " + args.dataLength);
+  log("_prepareConfig: args.data = " + args.data);
+  log("_prepareConfig: args.oem = " + args.oem);
+  log("_prepareConfig: args.oemUnlockAllowed = " + args.oemUnlockAllowed);
+
+  /* This function will be called after passing all native stuff tests, so we will write into a file instead of a real
+   * partition. Obviously, there are some native operations like getting the device block size or wipping, that will not
+   * work in a regular file, so we need to fake them. */
+  PersistentDataBlock._libcutils.property_set("sys.oem_unlock_allowed", args.oemUnlockAllowed === true ? "true" : "false");
+  PersistentDataBlock.setTestingMode(true);
+  PersistentDataBlock._dataBlockFile = PARTITION_FAKE_FILE;
+  // Create the test file with the same structure as the partition will be
+  let tempFile;
+  return OS.File.open(PersistentDataBlock._dataBlockFile, {write:true, append:false, truncate: true}).then(_tempFile => {
+    log("_prepareConfig: Writing DIGEST...");
+    tempFile = _tempFile;
+    return tempFile.write(args.digest);
+  }).then(bytes => {
+    log("_prepareConfig: Writing the magic: " + PARTITION_MAGIC);
+    return tempFile.write(new Uint32Array([PARTITION_MAGIC]));
+  }).then(bytes => {
+    log("_prepareConfig: Writing the length of data field");
+    return tempFile.write(new Uint32Array([args.dataLength]));
+  }).then(bytes => {
+    log("_prepareConfig: Writing the data field");
+    let data = new Uint8Array(PersistentDataBlock._getBlockDeviceSize() -
+               (DIGEST_SIZE_BYTES + PARTITION_MAGIC_SIZE_BYTES + DATA_SIZE_BYTES + OEM_UNLOCK_ENABLED_BYTES));
+    data.set(args.data);
+    return tempFile.write(data);
+  }).then(bytes => {
+    return tempFile.write(new Uint8Array([ args.oem === true ? 1 : 0 ]));
+  }).then(bytes => {
+    return tempFile.close();
+  }).then(() =>{
+    return Promise.resolve(true);
+  }).catch(ex => {
+    log("_prepareConfig: ERROR: ex = " + ex);
+    return Promise.reject(ex);
+  });
+}
+
+function utils_getByteAt(pos) {
+  let file;
+  let byte;
+  return OS.File.open(PersistentDataBlock._dataBlockFile, {read:true, existing:true, append:false}).then(_file => {
+    file = _file;
+    return file.setPosition(pos, OS.File.POS_START);
+  }).then(() => {
+    return file.read(1);
+  }).then(_byte => {
+    byte = _byte;
+    return file.close();
+  }).then(() => {
+    return Promise.resolve(byte[0]);
+  }).catch(ex => {
+    return Promise.reject(ex);
+  });
+}
+
+function utils_getHeader() {
+  let file;
+  let header = {};
+  return OS.File.open(PersistentDataBlock._dataBlockFile, {read:true, existing:true, append:false}).then(_file => {
+    file = _file;
+    return file.read(DIGEST_SIZE_BYTES);
+  }).then(digest => {
+    header.digest = digest;
+    return file.read(PARTITION_MAGIC_SIZE_BYTES);
+  }).then(magic => {
+    header.magic = magic;
+    return file.read(DATA_SIZE_BYTES);
+  }).then(dataLength => {
+    header.dataLength = dataLength;
+    return file.close();
+  }).then(() => {
+    return Promise.resolve(header);
+  }).catch(ex => {
+    return Promise.reject(ex);
+  });
+}
+
+function utils_getData() {
+  let file;
+  let data;
+  return OS.File.open(PersistentDataBlock._dataBlockFile, {read:true, existing:true, append:false}).then(_file => {
+    file = _file;
+    return file.setPosition(DIGEST_SIZE_BYTES + PARTITION_MAGIC_SIZE_BYTES, OS.File.POS_START);
+  }).then(() => {
+    return file.read(4);
+  }).then(_dataLength => {
+    let dataLength = new Uint32Array(_dataLength.buffer);
+    log("utils_getData: dataLength = " + dataLength[0]);
+    return file.read(dataLength[0]);
+  }).then(_data => {
+    data = _data;
+    return file.close();
+  }).then(() => {
+    return Promise.resolve(data);
+  }).catch(ex => {
+    return Promise.reject(ex);
+  });
+}
+
+function _installTests() {
+  // <NATIVE_TESTS> Native operation tests go first
+  add_test(function test_getBlockDeviceSize() {
+    // We will use emulator /cache partition to get it's size.
+    PersistentDataBlock._dataBlockFile = CACHE_PARTITION;
+    // Disable testing mode for this specific test because we can get the size of a real block device,
+    // but we need to flip to testing mode after this test because we use files instead of partitions
+    // and we cannot run this operation on files.
+    PersistentDataBlock.setTestingMode(false);
+    let blockSize = PersistentDataBlock._getBlockDeviceSize();
+    ok(blockSize !== CACHE_PARTITION_SIZE, "test_getBlockDeviceSize: Block device size should be greater than 0");
+    run_next_test();
+  });
+
+  add_test(function test_wipe() {
+    // Turning into testing mode again.
+    PersistentDataBlock.setTestingMode(true);
+    PersistentDataBlock.wipe().then(() => {
+      // We don't evaluate anything because in testing mode we always return ok!
+      run_next_test();
+    }).catch(ex => {
+      // ... something went really really bad if this happens.
+      ok(false, "test_wipe failed!: ex: " + ex);
+    });
+  });
+  // </NATIVE_TESTS>
+
+  add_test(function test_computeDigest() {
+    _prepareConfig().then(() => {
+      PersistentDataBlock._computeDigest().then(digest => {
+        // So in order to update this value in a future (should only happens if the partition data is changed), you just need
+        // to launch this test manually, see the result in the logs and update this constant with that value.
+        const _EXPECTED_VALUE = "0004107e05f0e20dd0aa0ed0110900e01d0260100300bd04409e0cc04b0650be02e09909f0860f00fc05b033000d0";
+        let calculatedValue = toHexString(digest.calculated);
+        strictEqual(calculatedValue, _EXPECTED_VALUE);
+        run_next_test();
+      }).catch(ex => {
+        ok(false, "test_computeDigest failed!: ex: " + ex);
+      });
+    });
+  });
+
+  add_test(function test_getDataFieldSize() {
+    PersistentDataBlock.getDataFieldSize().then(dataFieldLength => {
+      log("test_getDataFieldSize: dataFieldLength is " + dataFieldLength);
+      strictEqual(dataFieldLength, 6);
+      run_next_test();
+    }).catch(ex => {
+      ok(false, "test_getOemUnlockedEnabled failed: ex:" + ex);
+    });
+  });
+
+  add_test(function test_setOemUnlockedEnabledToTrue() {
+    PersistentDataBlock.setOemUnlockEnabled(true).then(() => {
+      return utils_getByteAt(PersistentDataBlock._getBlockDeviceSize() - 1);
+    }).then(byte => {
+      log("test_setOemUnlockedEnabledToTrue: byte = " + byte );
+      strictEqual(byte, 1);
+      run_next_test();
+    }).catch(ex => {
+      ok(false, "test_setOemUnlockedEnabledToTrue failed!: ex: " + ex);
+    });
+  });
+
+  add_test(function test_setOemUnlockedEnabledToFalse() {
+    PersistentDataBlock.setOemUnlockEnabled(false).then(() => {
+      return utils_getByteAt(PersistentDataBlock._getBlockDeviceSize() - 1);
+    }).then(byte => {
+      log("test_setOemUnlockedEnabledToFalse: byte = " + byte );
+      strictEqual(byte, 0);
+      run_next_test();
+    }).catch(ex => {
+      ok(false, "test_setOemUnlockedEnabledToFalse failed!: ex: " + ex);
+    });
+  });
+
+  add_test(function test_getOemUnlockedEnabledWithTrue() {
+    // We first need to set the OEM Unlock Enabled byte to true so we can test
+    // the getter properly
+    PersistentDataBlock.setOemUnlockEnabled(true).then(() => {
+      return PersistentDataBlock.getOemUnlockEnabled().then(enabled => {
+        log("test_getOemUnlockedEnabledWithTrue: enabled is " + enabled);
+        ok(enabled === true, "test_getOemUnlockedEnabledWithTrue: enabled value should be true");
+        run_next_test();
+      }).catch(ex => {
+        ok(false, "test_getOemUnlockedEnabledWithTrue failed: ex:" + ex);
+      });
+    }).catch(ex => {
+      ok(false, "test_getOemUnlockedEnabledWithTrue failed: An error ocurred while setting the OEM Unlock Enabled byte to true: ex:" + ex);
+    });
+  });
+
+  add_test(function test_getOemUnlockedEnabledWithFalse() {
+    // We first need to set the OEM Unlock Enabled byte to false so we can test
+    // the getter properly
+    PersistentDataBlock.setOemUnlockEnabled(false).then(() => {
+      return PersistentDataBlock.getOemUnlockEnabled().then(enabled => {
+        log("test_getOemUnlockedEnabledWithFalse: enabled is " + enabled);
+        ok(enabled === false, "test_getOemUnlockedEnabledWithFalse: enabled value should be false");
+        run_next_test();
+      }).catch(ex => {
+        ok(false, "test_getOemUnlockedEnabledWithFalse failed: ex:" + ex);
+      });
+    }).catch(ex => {
+      ok(false, "test_getOemUnlockedEnabledWithFalse failed: An error ocurred while setting the OEM Unlock Enabled byte to false: ex:" + ex);
+    });
+  });
+
+  add_test(function test_computeAndWriteDigest() {
+    PersistentDataBlock._computeAndWriteDigest().then(() => {
+      return utils_getHeader();
+    }).then(header => {
+      log("test_computeAndWriteDigest: header = " + header);
+      let magicRead = new Uint32Array(header.magic.buffer);
+      let magicSupposed = new Uint32Array([PARTITION_MAGIC]);
+      strictEqual(magicRead[0], magicSupposed[0]);
+      let dataLength = new Uint32Array([header.dataLength]);
+      strictEqual(header.dataLength[0], 6);
+      run_next_test();
+    }).catch(ex => {
+      ok(false, "test_computeAndWriteDigest failed!: ex: " + ex);
+    });
+  });
+
+  add_test(function test_formatIfOemUnlockEnabledWithTrue() {
+    _prepareConfig({oem:true}).then(() => {
+      return PersistentDataBlock._formatIfOemUnlockEnabled();
+    }).then(result => {
+      ok(result === true, "test_formatIfOemUnlockEnabledWithTrue: result should be true");
+      return utils_getByteAt(PersistentDataBlock._getBlockDeviceSize() - 1);
+    }).then(byte => {
+      // Check if the OEM Unlock Enabled byte is 1
+      strictEqual(byte, 1);
+      run_next_test();
+    }).catch(ex => {
+      ok(false, "test_formatIfOemUnlockEnabledWithTrue failed!: ex: " + ex);
+    });
+  });
+
+  add_test(function test_formatIfOemUnlockEnabledWithFalse() {
+    _prepareConfig({oem:false}).then(() => {
+      return PersistentDataBlock._formatIfOemUnlockEnabled();
+    }).then(result => {
+      log("test_formatIfOemUnlockEnabledWithFalse: result = " + result);
+      ok(result === false, "test_formatIfOemUnlockEnabledWithFalse: result should be false");
+      return utils_getByteAt(PersistentDataBlock._getBlockDeviceSize() - 1);
+    }).then(byte => {
+      // Check if the OEM Unlock Enabled byte is 0
+      strictEqual(byte, 0);
+      run_next_test();
+    }).catch(ex => {
+      ok(false, "test_formatIfOemUnlockEnabledWithFalse failed!: ex: " + ex);
+    });
+  });
+
+  add_test(function test_formatPartition() {
+    // Restore a fullfilled partition so we can check if formatting works...
+    _prepareConfig({oem:true}).then(() => {
+      return PersistentDataBlock._formatPartition(true);
+    }).then(() => {
+      return utils_getByteAt(PersistentDataBlock._getBlockDeviceSize() - 1);
+    }).then(byte => {
+      // Check if the last byte is 1
+      strictEqual(byte, 1);
+      return utils_getHeader();
+    }).then(header => {
+      // The Magic number should exists in a formatted partition
+      let magicRead = new Uint32Array(header.magic.buffer);
+      let magicSupposed = new Uint32Array([PARTITION_MAGIC]);
+      strictEqual(magicRead[0], magicSupposed[0]);
+      // In a formatted partition, the digest field is always 32 bytes of zeros.
+      let digestSupposed = new Uint8Array(DIGEST_SIZE_BYTES);
+      strictEqual(header.digest.join(""), "94227253995810864198417798821014713171138121254110134189198178208133167236184116199");
+      return PersistentDataBlock._formatPartition(false);
+    }).then(() => {
+      return utils_getByteAt(PersistentDataBlock._getBlockDeviceSize() - 1);
+    }).then(byte => {
+      // In this case OEM Unlock enabled byte should be set to 0 because we passed false to the _formatPartition method before.
+      strictEqual(byte, 0);
+      run_next_test();
+    }).catch(ex => {
+      ok(false, "test_formatPartition failed!: ex: " + ex);
+    });
+  });
+
+  add_test(function test_enforceChecksumValidityWithValidChecksum() {
+    // We need a valid partition layout to pass this test
+    _prepareConfig().then(() => {
+      PersistentDataBlock._enforceChecksumValidity().then(() => {
+        ok(true, "test_enforceChecksumValidityWithValidChecksum passed");
+        run_next_test();
+      }).catch(ex => {
+        ok(false, "test_enforceChecksumValidityWithValidChecksum failed!: ex: " + ex);
+      });
+    });
+  });
+
+  add_test(function test_enforceChecksumValidityWithInvalidChecksum() {
+    var badDigest = new Uint8Array([0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x06, 0x07,
+                                    0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+                                    0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                                    0x18, 0x19, 0x1A, 0x1C, 0x1D, 0x1E, 0x1F, 0x20]);
+    // We need a valid partition layout to pass this test
+    _prepareConfig({digest: badDigest}).then(() => {
+      PersistentDataBlock._enforceChecksumValidity().then(() => {
+        return utils_getHeader();
+      }).then(header => {
+        // Check that we have a valid magic after formatting
+        let magicRead = new Uint32Array(header.magic.buffer)[0];
+        let magicSupposed = new Uint32Array([PARTITION_MAGIC])[0];
+        strictEqual(magicRead, magicSupposed);
+        // Data length field should be 0, because we formatted the partition
+        let dataLengthRead = new Uint32Array(header.dataLength.buffer)[0];
+        strictEqual(dataLengthRead, 0);
+        run_next_test();
+      }).catch(ex => {
+        ok(false, "test_enforceChecksumValidityWithValidChecksum failed!: ex: " + ex);
+      });
+    });
+  });
+
+  add_test(function test_read() {
+    // Before reading, let's write some bytes of data first.
+    PersistentDataBlock.write(new Uint8Array([1,2,3,4])).then(() => {
+      PersistentDataBlock.read().then(bytes => {
+        log("test_read: bytes (in hex): " + toHexString(bytes));
+        strictEqual(bytes[0], 1);
+        strictEqual(bytes[1], 2);
+        strictEqual(bytes[2], 3);
+        strictEqual(bytes[3], 4);
+        run_next_test();
+      }).catch(ex => {
+        ok(false, "test_read failed!: ex: " + ex);
+      });
+    });
+
+  });
+
+  add_test(function test_write() {
+    let data = new Uint8Array(['1','2','3','4','5']);
+    PersistentDataBlock.write(data).then(bytesWrittenLength => {
+      log("test_write: bytesWrittenLength = " + bytesWrittenLength);
+      return utils_getData();
+    }).then(data => {
+      strictEqual(data[0], 1);
+      strictEqual(data[1], 2);
+      strictEqual(data[2], 3);
+      strictEqual(data[3], 4);
+      strictEqual(data[4], 5);
+      run_next_test();
+    }).catch(ex => {
+      ok(false, "test_write failed!: ex: " + ex);
+    });
+  });
+}
--- a/b2g/components/test/unit/test_fxaccounts.js
+++ b/b2g/components/test/unit/test_fxaccounts.js
@@ -19,31 +19,35 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 
 // At end of test, restore original state
 const ORIGINAL_AUTH_URI = Services.prefs.getCharPref("identity.fxaccounts.auth.uri");
 var { SystemAppProxy } = Cu.import("resource://gre/modules/FxAccountsMgmtService.jsm");
 const ORIGINAL_SENDCUSTOM = SystemAppProxy._sendCustomEvent;
 do_register_cleanup(function() {
   Services.prefs.setCharPref("identity.fxaccounts.auth.uri", ORIGINAL_AUTH_URI);
   SystemAppProxy._sendCustomEvent = ORIGINAL_SENDCUSTOM;
+  Services.prefs.clearUserPref("identity.fxaccounts.skipDeviceRegistration");
 });
 
 // Make profile available so that fxaccounts can store user data
 do_get_profile();
 
 // Mock the system app proxy; make message passing possible
 var mockSendCustomEvent = function(aEventName, aMsg) {
   Services.obs.notifyObservers({wrappedJSObject: aMsg}, aEventName, null);
 };
 
 function run_test() {
   run_next_test();
 }
 
 add_task(function test_overall() {
+  // FxA device registration throws from this context
+  Services.prefs.setBoolPref("identity.fxaccounts.skipDeviceRegistration", true);
+
   do_check_neq(FxAccountsMgmtService, null);
 });
 
 // Check that invalid email capitalization is corrected on signIn.
 // https://github.com/mozilla/fxa-auth-server/blob/master/docs/api.md#post-v1accountlogin
 add_test(function test_invalidEmailCase_signIn() {
   do_test_pending();
   let clientEmail = "greta.garbo@gmail.com";
@@ -100,16 +104,19 @@ add_test(function test_invalidEmailCase_
       });
       return;
     },
   });
 
   // Point the FxAccountsClient's hawk rest request client to the mock server
   Services.prefs.setCharPref("identity.fxaccounts.auth.uri", server.baseURI);
 
+  // FxA device registration throws from this context
+  Services.prefs.setBoolPref("identity.fxaccounts.skipDeviceRegistration", true);
+
   // Receive a mozFxAccountsChromeEvent message
   function onMessage(subject, topic, data) {
     let message = subject.wrappedJSObject;
 
     switch (message.id) {
       // When we signed in as "Greta.Garbo", the server should have told us
       // that the proper capitalization is really "greta.garbo".  Call
       // getAccounts to get the signed-in user and ensure that the
@@ -159,16 +166,19 @@ add_test(function test_invalidEmailCase_
       },
     },
   });
 });
 
 add_test(function testHandleGetAssertionError_defaultCase() {
   do_test_pending();
 
+  // FxA device registration throws from this context
+  Services.prefs.setBoolPref("identity.fxaccounts.skipDeviceRegistration", true);
+
   FxAccountsManager.getAssertion(null).then(
     success => {
       // getAssertion should throw with invalid audience
       ok(false);
     },
     reason => {
       equal("INVALID_AUDIENCE", reason.error);
       do_test_finished();
new file mode 100644
--- /dev/null
+++ b/b2g/components/test/unit/test_persistentdatablock_gonk.js
@@ -0,0 +1,21 @@
+/* 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/. */
+
+Cu.import("resource://gre/modules/NetUtil.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
+XPCOMUtils.defineLazyGetter(this, "libcutils", function () {
+  Cu.import("resource://gre/modules/systemlibs.js");
+  return libcutils;
+});
+
+function run_test() {
+  do_get_profile();
+  Cu.import("resource://gre/modules/PersistentDataBlock.jsm");
+  // We need to point to a valid partition for some of the tests. This is the /cache
+  // partition in the emulator (x86-KitaKat).
+  run_next_test();
+}
+
+_installTests();
--- a/b2g/components/test/unit/xpcshell.ini
+++ b/b2g/components/test/unit/xpcshell.ini
@@ -24,16 +24,19 @@ requesttimeoutfactor = 2
 # only run on b2g builds due to requiring b2g-specific log files to exist
 skip-if = toolkit != "gonk"
 
 [test_logparser.js]
 
 [test_logshake.js]
 
 [test_logshake_gonk.js]
+# can be slow because of what the test does, so let's give it some more time
+# to avoid intermittents: bug 1144499
+requesttimeoutfactor = 2
 head = head_logshake_gonk.js
 # only run on b2g builds due to requiring b2g-specific log files to exist
 skip-if = (toolkit != "gonk")
 
 [test_logshake_gonk_compression.js]
 head = head_logshake_gonk.js
 # only run on b2g builds due to requiring b2g-specific log files to exist
 skip-if = (toolkit != "gonk")
@@ -48,8 +51,17 @@ skip-if = (toolkit != "gonk")
 [test_killswitch.js]
 head = file_killswitch.js
 skip-if = (toolkit == "gonk")
 
 [test_killswitch_gonk.js]
 head = file_killswitch.js
 # Bug 1193677: disable on B2G ICS Emulator for intermittent failures with IndexedDB
 skip-if = ((toolkit != "gonk") || (toolkit == "gonk" && debug))
+
+[test_persistentdatablock_gonk.js]
+# can be slow because of what the test does, so let's give it some more time
+# to avoid intermittents: bug 1235290
+requesttimeoutfactor = 2
+head = file_persistentdatablock.js
+skip-if = (toolkit != "gonk")
+
+
new file mode 100644
--- /dev/null
+++ b/b2g/config/aries-l/sources.xml
@@ -0,0 +1,193 @@
+<?xml version="1.0" ?><manifest>
+  <!--
+    Remotes
+    -->
+  <!--original fetch url was https://android.googlesource.com/-->
+  <remote fetch="https://git.mozilla.org/external/aosp" name="aosp"/>
+  <!--original fetch url was git://github.com/apitrace/-->
+  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
+  <!--original fetch url was git://github.com/mozilla-b2g/-->
+  <remote fetch="https://git.mozilla.org/b2g" name="b2g"/>
+  <!--original fetch url was https://git.mozilla.org/b2g-->
+  <remote fetch="https://git.mozilla.org/b2g" name="b2gmozilla"/>
+  <!--original fetch url was git://codeaurora.org/-->
+  <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
+  <!--original fetch url was http://android.git.linaro.org/git-ro/-->
+  <remote fetch="https://git.mozilla.org/external/linaro" name="linaro"/>
+  <!--original fetch url was git://github.com/mozilla/-->
+  <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
+  <!--original fetch url was https://git.mozilla.org/releases-->
+  <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
+  <!--
+    B2G repositories for all targets
+    -->
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="4023297b16fdc46de3ddb04be4f3c575313d1cde"/>
+  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="35dccb3127db8f39f20b985ad312d2cd44780669"/>
+  <project name="moztt" path="external/moztt" remote="b2g" revision="99c333dab00ed79baff9e1cf76b320aee8e1c123"/>
+  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
+  <!-- B2G specific things. -->
+  <project name="platform_build" path="build" remote="b2g" revision="be4b291a90b371b41b62ade68c31ad173bb87baa">
+    <copyfile dest="Makefile" src="core/root.mk"/>
+  </project>
+  <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
+  <project name="fake-qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="939b377d55a2f081d94029a30a75d05e5a20daf3"/>
+  <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
+  <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
+  <project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
+  <project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="bef0632ed8ae0e14aa535549ee472748320198ed"/>
+  <!-- Stock Android things -->
+  <project groups="pdk,linux" name="platform/prebuilts/clang/linux-x86/host/3.5" path="prebuilts/clang/linux-x86/host/3.5" revision="0f86914b89cf8a069533e66b218533a17bad6b43"/>
+  <project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8" path="prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8" revision="6b1fb5b730b1299f99f9194c1fcf088579cc7977"/>
+  <project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.8" revision="755656d9a7c79c6463920ad13f95d71e45e21397"/>
+  <project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8" revision="ad086223028d281b2ea95f0f42f23ff4435917dd"/>
+  <project groups="pdk,linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6" revision="94d88f335cdc90bf43471bacf243006e99cff908"/>
+  <project groups="pdk,linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8" revision="ac160a43fddd833d4a0bc430f44f8b1956bac1e9"/>
+  <project groups="pdk,linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.8" path="prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.8" revision="966dbeff106bf36966d4c80a4f2c58a464ae314e"/>
+  <project groups="linux" name="platform/prebuilts/python/linux-x86/2.7.5" path="prebuilts/python/linux-x86/2.7.5" revision="accd992f11a8ec0a0ec52cdc891302dc54e2941e"/>
+  <project name="device/common" path="device/common" revision="cf1543ff569188c1df9f4e9c7fa53b75393c49e3"/>
+  <project name="device/sample" path="device/sample" revision="3bbddd699b3e093a664aae7d9a63032b798b561b"/>
+  <project name="platform/abi/cpp" path="abi/cpp" revision="870adeafa39f8cb4bec108e35638bb1c36fc648a"/>
+  <project name="platform/bionic" path="bionic" revision="060309e1369e7aa394d720fbc0703d5e20a60391"/>
+  <project name="platform/bootable/recovery" path="bootable/recovery" revision="ac9bafa97733238b0f8538d1f28e9a01d2931fa1"/>
+  <project name="platform/external/aac" path="external/aac" revision="925c65e2186ed3f33d26e85d1471a1b5f18b1bfa"/>
+  <project name="platform/external/bison" path="external/bison" revision="ba6887d58129c3cba6f181942943709f6250471f"/>
+  <project name="platform/external/bluetooth/bluedroid" path="external/bluetooth/bluedroid" revision="7456378c0ebfac007506decf0d187b747b70affd"/>
+  <project name="platform/external/bsdiff" path="external/bsdiff" revision="ef2f916f26550b6d2684c5f96ef404deb24060e8"/>
+  <project name="platform/external/bzip2" path="external/bzip2" revision="34b2cdaab634bcd1bd2f01130573a7833771df70"/>
+  <project name="platform/external/checkpolicy" path="external/checkpolicy" revision="cb2e70cd69a05cdfffa00825ed2f944789bbf95f"/>
+  <project name="platform/external/clang" path="external/clang" revision="eeb154f1b498998e77261475909c28aa6f61377e"/>
+  <project name="platform/external/compiler-rt" path="external/compiler-rt" revision="c87fcb2428a26ae69a2f7110c73ac08bafb652d7"/>
+  <project name="platform/external/dhcpcd" path="external/dhcpcd" revision="ffae58641836bb1c19b340b70ed4c625e0171a5d"/>
+  <project name="platform/external/dnsmasq" path="external/dnsmasq" revision="9d46bf92e0953655ca81c8b02ae5007dc67bd920"/>
+  <project name="platform/external/e2fsprogs" path="external/e2fsprogs" revision="c31df77fe0064ca3d16676be2cfa04362c14a01d"/>
+  <project name="platform/external/elfutils" path="external/elfutils" revision="a4e81ae7683f1b49f35f4cf3936ad9a9e4a54231"/>
+  <project name="platform/external/expat" path="external/expat" revision="f5fef24959803e65738cf96a91b4153cddcd3bf6"/>
+  <project name="platform/external/f2fs-tools" path="external/f2fs-tools" revision="fc24ac8347630a14d62ffafa93a27ec3b81cc44b"/>
+  <project name="platform/external/fdlibm" path="external/fdlibm" revision="0447a94e59aaad84ba9606bd7ef5bab525c356c3"/>
+  <project name="platform/external/flac" path="external/flac" revision="e15b8e8f7ee9af14f048c8bee8875583453a4259"/>
+  <project name="platform/external/freetype" path="external/freetype" revision="8276a1e4822384a763ee5a239352e815858802e9"/>
+  <project name="platform/external/gcc-demangle" path="external/gcc-demangle" revision="408f3ac7a9a3716c8198a04305d0132816ba02ad"/>
+  <project name="platform/external/genext2fs" path="external/genext2fs" revision="d1420472b31fab33fb23dd16197fdc6c1a056d4c"/>
+  <project name="platform/external/giflib" path="external/giflib" revision="c06fa3137c3c990f281400007f1426789e882a6f"/>
+  <project name="platform/external/gtest" path="external/gtest" revision="4b4c07cf16bc2a0e915be8acbd1947d4cca4dcab"/>
+  <project name="platform/external/harfbuzz_ng" path="external/harfbuzz_ng" revision="001e8c6dd3a1aa77d4449b66b5cd5e00a158481b"/>
+  <project name="platform/external/icu" path="external/icu" revision="3667975ba9c170a65c66666c019c8256ccc047bf"/>
+  <project name="platform/external/iproute2" path="external/iproute2" revision="2b9c711e59817efcf487b790cd95d441ce434b45"/>
+  <project name="platform/external/ipsec-tools" path="external/ipsec-tools" revision="8c1adaedd11540df5647f19c9ab5bc81fa614548"/>
+  <project name="platform/external/iptables" path="external/iptables" revision="38e301e24878e82cf6a4f0fbcd920cbe7270ff13"/>
+  <project name="platform/external/jack" path="external/jack" revision="72d913b877f04598204bfac6cce1ab96a193d058"/>
+  <project name="platform/external/jemalloc" path="external/jemalloc" revision="768ad4c9555dca6dafd147c7c00920eedddd3969"/>
+  <project name="platform/external/jhead" path="external/jhead" revision="e55f218242ffd89d0a76ba1dee11a2a439d233c5"/>
+  <project name="platform/external/jpeg" path="external/jpeg" revision="06ff2ef8790692b2a8d11eceb145d8723c77b622"/>
+  <project name="platform/external/jsmn" path="external/jsmn" revision="7af4b7e6369d6afc276da699bd41251d2398e350"/>
+  <project name="platform/external/jsoncpp" path="external/jsoncpp" revision="6e813c30f660b10f430e7f600799ae1379a287dc"/>
+  <project name="platform/external/junit" path="external/junit" revision="61fcf385c1b65ef439c5664adda77b9cfa0e8118"/>
+  <project name="platform/external/libcxxabi" path="external/libcxxabi" revision="96c4e7bce0f0e710cf5c0c6f2557f142a6ebed27"/>
+  <project name="platform/external/libcxx" path="external/libcxx" revision="3c2d8389b6c83fc5d88111aae64c527e903e73c7"/>
+  <project name="platform/external/libgsm" path="external/libgsm" revision="f107553887fbb8ed03b7bd8f6318d1bc4489fee4"/>
+  <project name="platform/external/liblzf" path="external/liblzf" revision="c57cd8d9318259f8f85fa5ceaa6327ec9c7b0296"/>
+  <project name="platform/external/libnfc-nxp" path="external/libnfc-nxp" revision="057646515e2d6dffec80bbbabddc706689fb12e3"/>
+  <project name="platform/external/libnl" path="external/libnl" revision="103740e4486e7aa783323f4b9b1b3f596c858b30"/>
+  <project name="platform/external/libogg" path="external/libogg" revision="921a239234786023cdade5d6b222a7c88068b61d"/>
+  <project name="platform/external/libopus" path="external/libopus" revision="2b6e63f8fe19a481e3577d6de764855198493ea4"/>
+  <project name="platform/external/libpcap" path="external/libpcap" revision="f391e622e30509cd1731152aab61511e82969236"/>
+  <project name="platform/external/libpng" path="external/libpng" revision="72d906de7515609342498f5e45c81282b1302448"/>
+  <project name="platform/external/libselinux" path="external/libselinux" revision="6472342ee6c171882891d2f644b88eef55c9ebc3"/>
+  <project name="platform/external/libsepol" path="external/libsepol" revision="9eb69f1e70aa80a1ccc00242c634fcf2a424b06a"/>
+  <project name="platform/external/libunwind" path="external/libunwind" revision="989888043cdaf966b8b86853910aa19165e5194e"/>
+  <project name="platform/external/libvpx" path="external/libvpx" revision="052edf77a2149d108bfa5e6ca88adf26c6950bd7"/>
+  <project name="platform/external/llvm" path="external/llvm" revision="00b16d2275a2305137a2afca1479cc4077aad2e5"/>
+  <project name="platform/external/mdnsresponder" path="external/mdnsresponder" revision="49f160bbaea5d855bddfa22a7d61a29fb6e736f9"/>
+  <project name="platform/external/mksh" path="external/mksh" revision="be73b929515f8e4a59e979a5372bc192e1324ece"/>
+  <project name="platform/external/netcat" path="external/netcat" revision="5bc44d564f09695b89e713afaeee09fc07ecd182"/>
+  <project name="platform/external/openssl" path="external/openssl" revision="d8a69d6b9f960c068ce5d375875e3c8609a1f405"/>
+  <project name="platform/external/pcre" path="external/pcre" revision="74befec51e20f2e31ae4a11f7e992dbeb6be8bd9"/>
+  <project name="platform/external/protobuf" path="external/protobuf" revision="8cd15d4980ba1b4dc2a05cc3e5bf48bfabaa14ea"/>
+  <project name="platform/external/safe-iop" path="external/safe-iop" revision="ba3ac916708940cc761318c57e8efe4cd73af400"/>
+  <project name="platform/external/scrypt" path="external/scrypt" revision="4059b5c88404bc81350bb37b23fca35ea3c97179"/>
+  <project name="platform/external/sfntly" path="external/sfntly" revision="9656ee1e46a5ad61c569c2e70e94187be52cebe6"/>
+  <project name="platform/external/skia" path="external/skia" revision="14cd31a0bafabdc222e9beaccfb6162a312d6e90"/>
+  <project name="platform/external/sonivox" path="external/sonivox" revision="dc512141dae4ef69e470a64d0cfbf412277aa0b3"/>
+  <project name="platform/external/speex" path="external/speex" revision="f26fe68d1400a503a71b55728e9ba43b5bf8f65f"/>
+  <project name="platform/external/sqlite" path="external/sqlite" revision="8bf2eb40ff5dd0a6724d493eb997d99a2e07e20f"/>
+  <project name="platform/external/stlport" path="external/stlport" revision="76e06e090244f1960bdd48f1109613ea4cf05884"/>
+  <project name="platform/external/strace" path="external/strace" revision="b2dc0fc24db579b0fedf26e89a1a466b2c9a32e2"/>
+  <project name="platform/external/svox" path="external/svox" revision="7c3164643a2115617581d34bb9f9612f0e0173bf"/>
+  <project name="platform/external/tagsoup" path="external/tagsoup" revision="7d489e3f8f2c5463d334de9cc74bdce271a1886d"/>
+  <project name="platform/external/tcpdump" path="external/tcpdump" revision="75b33a817a0c62278c6099c47985f8704e7d9232"/>
+  <project name="platform/external/tinyalsa" path="external/tinyalsa" revision="8fbb1a592beafe2de3ddbdcac78ffcd96df5e383"/>
+  <project name="platform/external/tinycompress" path="external/tinycompress" revision="82c0b2c653987ff4280be7b14d1f0c1d89eba4c9"/>
+  <project name="platform/external/tinyxml2" path="external/tinyxml2" revision="de52ec2164bb14fba7ae01ac8f0167212b8c741f"/>
+  <project name="platform/external/tinyxml" path="external/tinyxml" revision="0d3f3eb780888334c9d87d22d5595f313395f8d6"/>
+  <project name="platform/external/tremolo" path="external/tremolo" revision="1d89e41830bf268fca6b4a797ea30a96d84a84fb"/>
+  <project name="platform/external/webp" path="external/webp" revision="5ac894de5df4345a26e006d4f73acb422ea9d814"/>
+  <project name="platform/external/webrtc" path="external/webrtc" revision="333fb8884c0467f06ad956b3e52ff1169b822eb0"/>
+  <project name="platform/external/yaffs2" path="external/yaffs2" revision="0f5965cfdf082b9e329d543e2a49d229dccf0050"/>
+  <project name="platform/external/zlib" path="external/zlib" revision="d0f3ac473d9d1356ce175cffc3c2a33c2fbda006"/>
+  <project name="platform/external/zopfli" path="external/zopfli" revision="546647ec998acbaa06124ee57b826257b6530905"/>
+  <project name="platform/frameworks/native" path="frameworks/native" revision="0951e44a56a7721c26d82fdc1d4c8c05f83f6496"/>
+  <project name="platform/frameworks/opt/emoji" path="frameworks/opt/emoji" revision="d9f0fe12f016cd8105dfd110cd2209db725e035a"/>
+  <project name="platform/hardware/libhardware_legacy" path="hardware/libhardware_legacy" revision="f5cec8be8143538003c4cdc84a3bc4973e70adec"/>
+  <project name="platform/libcore" path="libcore" revision="42e5c65efd528e3d360ecf147016af8f51abe679"/>
+  <project name="platform/libnativehelper" path="libnativehelper" revision="1c07d779580f3db10a7f96fba387968bf2783e28"/>
+  <project name="platform/ndk" path="ndk" revision="2f78ff38973c8e8e89dc28915fe637ea185b102e"/>
+  <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="25b96077aeae7bd0e3a5e7c284fb636664337013"/>
+  <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="3881c90cec9a89b1b1e13c97af537647dcf63c71"/>
+  <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="a259bbcab27bb60bb75b16bce581549c724954cc"/>
+  <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="a6dda1861aee67e18947fee510e4e85f8c1ffeb7"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="bb356d6505f914347690c8143dbd03af427dd07e"/>
+  <project name="platform/system/extras" path="system/extras" revision="7eb50bad98466762626ae1dd31df2acd77202c06"/>
+  <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="34adfb400e031f3dd3353d92413572db5e3a7376"/>
+  <project name="platform/system/media" path="system/media" revision="9de34d557017fe115051fbbd49f05564de6ba3de"/>
+  <project name="platform/system/netd" path="system/netd" revision="313c71603fbfa643ff5f62f4fb3c26aa4696435c"/>
+  <project name="platform/system/security" path="system/security" revision="7c9f4ee469a965f119e302a39f00004d8c59bc6b"/>
+  <project name="platform/system/vold" path="system/vold" revision="d4435cf658bc391a5dc85d4973b38e5b9ada92fc"/>
+  <project name="platform_frameworks_av" path="frameworks/av" remote="b2g" revision="479a404164986b3e95212eecdae7e67da4fba9ed"/>
+  <project name="platform_frameworks_base" path="frameworks/base" remote="b2g" revision="396b731dbccc62f272f1fdb8228109c3fbd83c25"/>
+  <project name="platform_frameworks_wilhelm" path="frameworks/wilhelm" remote="b2g" revision="174bb44bb9af7583e6337e1e1b6cc18d0217ae82"/>
+  <project name="platform_system_core" path="system/core" remote="b2g" revision="1b8322b228f717ff2a4d48fa8b44240d8e3f62bc"/>
+  <project name="platform_external_sepolicy" path="external/sepolicy" remote="b2g" revision="246c603d9fe181fa8893af7293dbc63e870fe5e0"/>
+  <default remote="caf" revision="refs/tags/android-5.1.1_r29" sync-j="4"/>
+  <!-- Platform common things -->
+  <project name="platform/external/libxml2" path="external/libxml2" revision="d0fea31601c5a47c1327515a1ed1d81c4d3586cf"/>
+  <project name="platform/external/wpa_supplicant_8" path="external/wpa_supplicant_8" revision="60a2b840daa7e877d7aec9c08909a17b72095d10"/>
+  <project name="platform/hardware/broadcom/wlan" path="hardware/broadcom/wlan" revision="0e5baccde90f60ab248a1aedd1f50bff0ba224d9"/>
+  <project name="platform/hardware/qcom/bt" path="hardware/qcom/bt" remote="caf" revision="d2b071c3683bace40c9ed666107367dac5a5bb45"/>
+  <project name="platform/hardware/qcom/audio" path="hardware/qcom/audio" revision="4225df42ce215c0b46c7bd5a59a03f0c85c1d06c"/>
+  <project name="platform/hardware/qcom/gps" path="hardware/qcom/gps" revision="b299e214bf810b2b29a3cdcf872f8de09595845f"/>
+  <project name="platform/hardware/qcom/media" path="hardware/qcom/media" revision="0a774fd3bfc78cf03ca10d436255d0120c49a068"/>
+  <project name="platform/hardware/qcom/wlan" path="hardware/qcom/wlan" revision="82d8c482d59926ff27c53f1fcc8a0ce3554e5491"/>
+  <project name="platform/hardware/ril" path="hardware/ril" revision="4782b037af55a8d61078305df6a4c31c1424623c"/>
+  <project name="platform_external_libnfc-nci" path="external/libnfc-nci" remote="b2g" revision="cac2be832f7bf748d8f0de7eac93009ef7c2eea9"/>
+  <project name="hardware_qcom_display" path="hardware/qcom/display" remote="b2g" revision="9312b15e14ee19686ec7eac7b4cf2035199e92a6"/>
+  <project name="platform_hardware_broadcom_libbt" path="hardware/broadcom/libbt" remote="b2g" revision="c927f10590b39bfe35976e01aed0969afeed3ba8"/>
+  <project name="platform_hardware_libhardware" path="hardware/libhardware" remote="b2g" revision="c4bdd7888f2ab3069f6f8853915a806ebd390320"/>
+  <project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="5f4b68c799927b6e078f987b12722c3a6ccd4a45"/>
+  <!-- Sony platform specific things -->
+  <project name="codeaurora_kernel_msm" path="kernel" remote="b2g" revision="f4f1a6f3260d88f11671d57b4b759c0831a5c764"/>
+  <project name="device-qcom-sepolicy" path="device/qcom/sepolicy" remote="b2g" revision="e0a1cce6a8559ccc88e15da148531d36e18ae5f7"/>
+  <project name="android_external_busybox" path="external/busybox" remote="b2g" revision="757a15c84e7bf9897b908058f2e529fcffea73b8"/>
+  <project groups="device" name="init_sh" path="hardware/sony/init_sh" remote="b2g" revision="58d94ebe3a2e9a1af4bc8c003cd6837e53cc4867"/>
+  <project groups="device" name="macaddrsetup" path="hardware/sony/macaddrsetup" remote="b2g" revision="e7ee149283eaec32a525ee39b2ecdca46d502e77"/>
+  <project groups="device" name="mkqcdtbootimg" path="hardware/sony/mkqcdtbootimg" remote="b2g" revision="4badb288cefe7cc708450c02fd4f6cab84c3ed98"/>
+  <project groups="device" name="thermanager" path="hardware/sony/thermanager" remote="b2g" revision="ec9a2b6a7fe8254ecc3c2c4781e7304f3822e390"/>
+  <project groups="device" name="timekeep" path="hardware/sony/timekeep" remote="b2g" revision="4cbb0abc00681f116f043584661307b5c4855a31"/>
+  <project name="sony-camera-hal" path="hardware/qcom/camera" remote="b2g" revision="22805439075263b20b0aee1298e003187a9c180b"/>
+  <!-- Shinano platform specific things -->
+  <project groups="device" name="device-sony-shinano" path="device/sony/shinano" remote="b2g" revision="b9b4ecf084414c1e6b5951a95ebcb24522fa74e3"/>
+  <project groups="device" name="device-sony-aries" path="device/sony/aries" remote="b2g" revision="56f665a19e35623d923949014bc15013d292fa37"/>
+  <project groups="device" name="device-sony-leo" path="device/sony/leo" remote="b2g" revision="3fdec3f02117be6b57d2f9c5946119f179119a51"/>
+  <project groups="device" name="device-sony-scorpion" path="device/sony/scorpion" remote="b2g" revision="b0cd32cb805637d2afda61b67d0421e2c39b2ffa"/>
+  <project groups="device" name="device-sony-sirius" path="device/sony/sirius" remote="b2g" revision="5e5c19c6cd7c042bcac41a2b30b3ad3eeb66e7ab"/>
+  <!-- Rhine platform specific things -->
+  <project groups="device" name="device-sony-rhine" path="device/sony/rhine" remote="b2g" revision="4a9cd1f110d83b035cfea2e337504af9104cb67c"/>
+  <project groups="device" name="device-sony-honami" path="device/sony/honami" remote="b2g" revision="f8a9d6d3a2ce73d336453b71db591a82f72a2120"/>
+  <project groups="device" name="device-sony-amami" path="device/sony/amami" remote="b2g" revision="9f05cdc34e60df19fcd9189ff8a14f752dcf07b9"/>
+  <!-- Yukon platform specific things -->
+  <project name="device-sony-yukon" path="device/sony/yukon" remote="b2g" revision="1e8e253c7e9b7b72118b4c7c15b9498014fc7c0e"/>
+  <project name="device-sony-tianchi" path="device/sony/tianchi" remote="b2g" revision="571afbafe2abf52e031c2484f38ca5f6f81a114a"/>
+  <project name="device-sony-eagle" path="device/sony/eagle" remote="b2g" revision="b253fa75f0eeea10a1fa747fd98deb80ec71a654"/>
+  <project name="device-sony-flamingo" path="device/sony/flamingo" remote="b2g" revision="44fb20f16a9b1a44af6109dbfad2a975ca29fece"/>
+  <project name="device-sony-seagull" path="device/sony/seagull" remote="b2g" revision="666810a3b77df8cd7a5e68e3d041052b6dd8cd22"/>
+</manifest>
--- a/b2g/config/aries/sources.xml
+++ b/b2g/config/aries/sources.xml
@@ -1,36 +1,46 @@
 <?xml version="1.0" ?><manifest>
+  <!--
+    Remotes
+    -->
   <!--original fetch url was https://android.googlesource.com/-->
   <remote fetch="https://git.mozilla.org/external/aosp" name="aosp"/>
+  <!--original fetch url was git://github.com/apitrace/-->
+  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <!--original fetch url was git://github.com/mozilla-b2g/-->
   <remote fetch="https://git.mozilla.org/b2g" name="b2g"/>
-  <!--original fetch url was git://github.com/mozilla/-->
-  <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
-  <!--original fetch url was git://github.com/apitrace/-->
-  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
+  <!--original fetch url was https://git.mozilla.org/b2g-->
+  <remote fetch="https://git.mozilla.org/b2g" name="b2gmozilla"/>
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
+  <!--original fetch url was http://android.git.linaro.org/git-ro/-->
+  <remote fetch="https://git.mozilla.org/external/linaro" name="linaro"/>
+  <!--original fetch url was git://github.com/mozilla/-->
+  <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
+  <!--
+    B2G repositories for all targets
+    -->
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="4023297b16fdc46de3ddb04be4f3c575313d1cde"/>
+  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="35dccb3127db8f39f20b985ad312d2cd44780669"/>
+  <project name="moztt" path="external/moztt" remote="b2g" revision="99c333dab00ed79baff9e1cf76b320aee8e1c123"/>
+  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
   <!-- B2G specific things. -->
-  <project name="platform_build" path="build" remote="b2g" revision="8d83715f08b7849f16a0dfc88f78d5c3a89c0a54">
+  <project name="platform_build" path="build" remote="b2g" revision="d3c9acb642baee501cff89e4efdb16b0c7480760">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="ad15b4f1f50f4e28170a069f049e5bdeec8d15cc"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="fake-qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="939b377d55a2f081d94029a30a75d05e5a20daf3"/>
-  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="4a962bdab532e18f53e9d2d114c349983262c6b7"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
-  <project name="moztt" path="external/moztt" remote="b2g" revision="ac7e9ae8a24ab4a3f3da801ca53f95f39a32b89f"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="2d70fdfc0244a7217df1cfa7df9f4798cbfa3af6"/>
-  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="bef0632ed8ae0e14aa535549ee472748320198ed"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="ebdad82e61c16772f6cd47e9f11936bf6ebe9aa0"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="8b880805d454664b3eed11d0f053cdeafa1ff06e"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" revision="a1e239a0bb5cd1d69680bf1075883aa9a7bf2429"/>
   <project groups="linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" path="prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" revision="c7931763d41be602407ed9d71e2c0292c6597e00"/>
   <project groups="linux,x86" name="platform/prebuilts/python/linux-x86/2.7.5" path="prebuilts/python/linux-x86/2.7.5" revision="a32003194f707f66a2d8cdb913ed1869f1926c5d"/>
   <project name="device/common" path="device/common" revision="96d4d2006c4fcb2f19a3fa47ab10cb409faa017b"/>
@@ -105,36 +115,36 @@
   <project name="platform/frameworks/wilhelm" path="frameworks/wilhelm" revision="f0c3b4edf597c40aae4ea311575f39c8bcf203df"/>
   <project name="platform/libcore" path="libcore" revision="baf7d8068dd501cfa338d3a8b1b87216d6ce0571"/>
   <project name="platform/libnativehelper" path="libnativehelper" revision="50c4430e32849530ced32680fd6ee98963b3f7ac"/>
   <project name="platform/ndk" path="ndk" revision="e58ef003be4306bb53a8c11331146f39e4eab31f"/>
   <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="c739cffa6394c06e099ea48879a20341b6163338"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="c792f0bd9fff7aea2887c60bbb3a9bbdb534ffa3"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="69d524e80cdf3981006627c65ac85f3a871238a3"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="5a48c04c4bb5f079bc757e29864a42427378e051"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="570531db9e81a871c421b27025ae558022b1015a"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="bb356d6505f914347690c8143dbd03af427dd07e"/>
   <project name="platform/system/extras" path="system/extras" revision="576f57b6510de59c08568b53c0fb60588be8689e"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="34adfb400e031f3dd3353d92413572db5e3a7376"/>
   <project name="platform/system/netd" path="system/netd" revision="a6531f7befb49b1c81bc0de7e51c5482b308e1c5"/>
   <project name="platform/system/security" path="system/security" revision="ee8068b9e7bfb2770635062fc9c2035be2142bd8"/>
   <project name="platform/system/vold" path="system/vold" revision="42fa2a0f14f965970a4b629a176bbd2666edf017"/>
   <project name="platform/external/curl" path="external/curl" revision="e68addd988448959ea8157c5de637346b4180c33"/>
   <project name="platform/external/icu4c" path="external/icu4c" revision="d3ec7428eb276db43b7ed0544e09344a6014806c"/>
   <project name="platform/hardware/libhardware_legacy" path="hardware/libhardware_legacy" revision="76c4bf4bc430a1b8317f2f21ef735867733e50cc"/>
   <project name="platform/system/media" path="system/media" revision="c1332c21c608f4932a6d7e83450411cde53315ef"/>
   <default remote="caf" revision="LNX.LA.3.5.2.1.1" sync-j="4"/>
   <!-- Platform common things -->
-  <project name="device-shinano-common" path="device/sony/shinano-common" remote="b2g" revision="070ec6f75572a336b7b80db406b11398e5089626"/>
+  <project name="device-shinano-common" path="device/sony/shinano-common" remote="b2g" revision="68157e0302df53490e7d721eb4e8b0c7c7e49fdf"/>
   <project name="device/generic/armv7-a-neon" path="device/generic/armv7-a-neon" revision="1bb28abbc215f45220620af5cd60a8ac1be93722"/>
   <project name="device/qcom/common" path="device/qcom/common" revision="2501e5940ba69ece7654ff85611c76ae5bda299c"/>
-  <project name="codeaurora_kernel_msm" path="kernel" remote="b2g" revision="d620691cad7aee780018e98159ff03bf99840317"/>
+  <project name="codeaurora_kernel_msm" path="kernel" remote="b2g" revision="da1273d39b3b940b3b2a5bc5fdb81c521d74caa3"/>
   <project name="init_sh" path="external/init_sh" remote="b2g" revision="feb58d2b397e45ead9b904d5c4d9255df408db56"/>
   <project name="platform_bionic" path="bionic" remote="b2g" revision="3e85c4683c121530c1c3a48c696a569bf5f587e2"/>
   <project name="platform_external_bluetooth_bluedroid" path="external/bluetooth/bluedroid" remote="b2g" revision="70f536bd97d901b96b94669ae1aa2fd0fb54b258"/>
-  <project name="platform/external/libnfc-nci" path="external/libnfc-nci" revision="0a01977f34d6e86fe23d6c0ec75e96ba988bbebb"/>
+  <project name="platform_external_libnfc-nci" path="external/libnfc-nci" remote="b2g" revision="2a52bd77d2ca0cefbf02acc6863492d16b6ccfec"/>
   <project name="platform_external_libnfc-pn547" path="external/libnfc-pn547" remote="b2g" revision="5bb999b84b8adc14f6bea004d523ba258dea8188"/>
   <project name="platform/external/wpa_supplicant_8" path="external/wpa_supplicant_8" revision="5b71e40213f650459e95d35b6f14af7e88d8ab62"/>
   <project name="platform_frameworks_av" path="frameworks/av" remote="b2g" revision="5d5bcc83d6c32874701f0df78ed1119e006bd10a"/>
   <project name="platform/frameworks/base" path="frameworks/base" revision="da8e6bc53c8bc669da0bb627904d08aa293f2497"/>
   <project name="platform/frameworks/native" path="frameworks/native" revision="a46a9f1ac0ed5662d614c277cbb14eb3f332f365"/>
   <project name="platform/hardware/libhardware" path="hardware/libhardware" revision="7196881a0e9dd7bfbbcf0af64c8064e70f0fa094"/>
   <project name="platform/hardware/broadcom/wlan" path="hardware/broadcom/wlan" revision="15a9b66de9b7d84c7ea63df3a834f095bca9e493"/>
   <project name="platform/hardware/qcom/audio" path="hardware/qcom/audio" revision="8d7676dfb68ee0cd069affedd5d1e97316a184ba"/>
--- a/b2g/config/dolphin/sources.xml
+++ b/b2g/config/dolphin/sources.xml
@@ -1,36 +1,46 @@
 <?xml version="1.0" ?><manifest>
+  <!--
+    Remotes
+    -->
   <!--original fetch url was https://android.googlesource.com/-->
   <remote fetch="https://git.mozilla.org/external/aosp" name="aosp"/>
+  <!--original fetch url was git://github.com/apitrace/-->
+  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <!--original fetch url was git://github.com/mozilla-b2g/-->
   <remote fetch="https://git.mozilla.org/b2g" name="b2g"/>
-  <!--original fetch url was git://github.com/mozilla/-->
-  <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
-  <!--original fetch url was git://github.com/apitrace/-->
-  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
+  <!--original fetch url was https://git.mozilla.org/b2g-->
+  <remote fetch="https://git.mozilla.org/b2g" name="b2gmozilla"/>
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
+  <!--original fetch url was http://android.git.linaro.org/git-ro/-->
+  <remote fetch="https://git.mozilla.org/external/linaro" name="linaro"/>
+  <!--original fetch url was git://github.com/mozilla/-->
+  <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
+  <!--
+    B2G repositories for all targets
+    -->
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="4023297b16fdc46de3ddb04be4f3c575313d1cde"/>
+  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="35dccb3127db8f39f20b985ad312d2cd44780669"/>
+  <project name="moztt" path="external/moztt" remote="b2g" revision="99c333dab00ed79baff9e1cf76b320aee8e1c123"/>
+  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
   <!-- B2G specific things. -->
-  <project name="platform_build" path="build" remote="b2g" revision="8d83715f08b7849f16a0dfc88f78d5c3a89c0a54">
+  <project name="platform_build" path="build" remote="b2g" revision="d3c9acb642baee501cff89e4efdb16b0c7480760">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="ad15b4f1f50f4e28170a069f049e5bdeec8d15cc"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="fake-qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="939b377d55a2f081d94029a30a75d05e5a20daf3"/>
-  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="4a962bdab532e18f53e9d2d114c349983262c6b7"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
-  <project name="moztt" path="external/moztt" remote="b2g" revision="ac7e9ae8a24ab4a3f3da801ca53f95f39a32b89f"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="2d70fdfc0244a7217df1cfa7df9f4798cbfa3af6"/>
-  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="bef0632ed8ae0e14aa535549ee472748320198ed"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="ebdad82e61c16772f6cd47e9f11936bf6ebe9aa0"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="8b880805d454664b3eed11d0f053cdeafa1ff06e"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" revision="a1e239a0bb5cd1d69680bf1075883aa9a7bf2429"/>
   <project groups="linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" path="prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" revision="c7931763d41be602407ed9d71e2c0292c6597e00"/>
   <project groups="linux,x86" name="platform/prebuilts/python/linux-x86/2.7.5" path="prebuilts/python/linux-x86/2.7.5" revision="83760d213fb3bec7b4117d266fcfbf6fe2ba14ab"/>
   <project name="device/common" path="device/common" revision="6a2995683de147791e516aae2ccb31fdfbe2ad30"/>
@@ -111,17 +121,17 @@
   <project name="platform/hardware/libhardware_legacy" path="hardware/libhardware_legacy" revision="68b0c269fd1889f47ecfb9119c05281e9b6db0af"/>
   <project name="platform/libcore" path="libcore" revision="e195beab082c09217318fc19250caeaf4c1bd800"/>
   <project name="platform/libnativehelper" path="libnativehelper" revision="feeb36c2bd4adfe285f98f5de92e0f3771b2c115"/>
   <project name="platform/ndk" path="ndk" revision="e58ef003be4306bb53a8c11331146f39e4eab31f"/>
   <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="c739cffa6394c06e099ea48879a20341b6163338"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="c792f0bd9fff7aea2887c60bbb3a9bbdb534ffa3"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="cfcef469537869947abb9aa1d656774cc2678d4c"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="5a48c04c4bb5f079bc757e29864a42427378e051"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="570531db9e81a871c421b27025ae558022b1015a"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="bb356d6505f914347690c8143dbd03af427dd07e"/>
   <project name="platform/system/extras" path="system/extras" revision="10e78a05252b3de785f88c2d0b9ea8a428009c50"/>
   <project name="platform/system/media" path="system/media" revision="188b3e51e0a2ce1e16dc8067edef7be3d2365ad9"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="34adfb400e031f3dd3353d92413572db5e3a7376"/>
   <project name="platform/system/netd" path="system/netd" revision="3ae56364946d4a5bf5a5f83f12f9a45a30398e33"/>
   <project name="platform/system/security" path="system/security" revision="ee8068b9e7bfb2770635062fc9c2035be2142bd8"/>
   <project name="platform/system/vold" path="system/vold" revision="fe12a9e2268da653d1cd4c39ec89a42211d22f25"/>
   <!--original fetch url was http://sprdsource.spreadtrum.com:8085/b2g/android-->
   <remote fetch="https://git.mozilla.org/external/sprd-aosp" name="sprd-aosp"/>
--- a/b2g/config/emulator-ics/sources.xml
+++ b/b2g/config/emulator-ics/sources.xml
@@ -1,44 +1,51 @@
 <?xml version="1.0" ?><manifest>
+  <!--
+    Remotes
+    -->
   <!--original fetch url was https://android.googlesource.com/-->
   <remote fetch="https://git.mozilla.org/external/aosp" name="aosp"/>
   <!--original fetch url was git://github.com/apitrace/-->
   <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <!--original fetch url was git://github.com/mozilla-b2g/-->
   <remote fetch="https://git.mozilla.org/b2g" name="b2g"/>
   <!--original fetch url was https://git.mozilla.org/b2g-->
   <remote fetch="https://git.mozilla.org/b2g" name="b2gmozilla"/>
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
+  <!--original fetch url was http://android.git.linaro.org/git-ro/-->
+  <remote fetch="https://git.mozilla.org/external/linaro" name="linaro"/>
   <!--original fetch url was git://github.com/mozilla/-->
   <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
+  <!--
+    B2G repositories for all targets
+    -->
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="4023297b16fdc46de3ddb04be4f3c575313d1cde"/>
+  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="35dccb3127db8f39f20b985ad312d2cd44780669"/>
+  <project name="moztt" path="external/moztt" remote="b2g" revision="99c333dab00ed79baff9e1cf76b320aee8e1c123"/>
+  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
   <default remote="caf" revision="refs/tags/android-4.0.4_r2.1" sync-j="4"/>
-  <!-- Gecko and Gaia -->
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="ad15b4f1f50f4e28170a069f049e5bdeec8d15cc"/>
   <!-- Gonk-specific things and forks -->
   <project name="platform_bionic" path="bionic" remote="b2g" revision="e2b3733ba3fa5e3f404e983d2e4142b1f6b1b846"/>
   <project name="platform_build" path="build" remote="b2g" revision="1b0db93fb6b870b03467aff50d6419771ba0d88c">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
   <project name="android-development" path="development" remote="b2g" revision="2bdf22305b523af644e1891b4ddfd9229336d0ce"/>
   <project name="platform_external_apriori" path="external/apriori" remote="b2g" revision="11816ad0406744f963537b23d68ed9c2afb412bd"/>
   <project name="platform_external_elfcopy" path="external/elfcopy" remote="b2g" revision="62c1bed1c4505369cac2e72fbe30452a598fb690"/>
   <project name="platform_external_elfutils" path="external/elfutils" remote="b2g" revision="72940dec691fa3255e13df01f8c53b620e446066"/>
-  <project name="moztt" path="external/moztt" remote="b2g" revision="ac7e9ae8a24ab4a3f3da801ca53f95f39a32b89f"/>
   <project name="platform_external_opensans" path="external/opensans" remote="b2g" revision="b5b4c226ca1d71e936153cf679dda6d3d60e2354"/>
   <project name="screencap-gonk" path="external/screencap-gonk" remote="b2g" revision="e6403c71e9eca8cb943739d5a0a192deac60fc51"/>
-  <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="c72c9278ddc2f442d193474993d36e7f2cfb08c4"/>
+  <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="af8b2b782387209cc5b5803926f86bdbc31570ca"/>
   <project name="platform_frameworks_base" path="frameworks/base" remote="b2g" revision="6afc63abe52776ae6a1d32a2d927e630a743a86a"/>
-  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="4a962bdab532e18f53e9d2d114c349983262c6b7"/>
-  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
-  <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cb4604d5a578efd027277059ce3e0f6e3af59bd1"/>
+  <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="5fa1b11a01e7e90dbe9681e690020d10795ec1a9"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="android-sdk" path="sdk" remote="b2g" revision="4f46930827957afbce500a4a920755a218bf3155"/>
   <project name="darwinstreamingserver" path="system/darwinstreamingserver" remote="b2g" revision="cf85968c7f85e0ec36e72c87ceb4837a943b8af6"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="425f8b5fadf5889834c5acd27d23c9e0b2129c28"/>
   <project name="device/common" path="device/common" revision="42b808b7e93d0619286ae8e59110b176b7732389"/>
   <project name="device/sample" path="device/sample" revision="237bd668d0f114d801a8d6455ef5e02cc3577587"/>
--- a/b2g/config/emulator-jb/sources.xml
+++ b/b2g/config/emulator-jb/sources.xml
@@ -1,42 +1,52 @@
 <?xml version="1.0" ?><manifest>
+  <!--
+    Remotes
+    -->
   <!--original fetch url was https://android.googlesource.com/-->
   <remote fetch="https://git.mozilla.org/external/aosp" name="aosp"/>
+  <!--original fetch url was git://github.com/apitrace/-->
+  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <!--original fetch url was git://github.com/mozilla-b2g/-->
   <remote fetch="https://git.mozilla.org/b2g" name="b2g"/>
+  <!--original fetch url was https://git.mozilla.org/b2g-->
+  <remote fetch="https://git.mozilla.org/b2g" name="b2gmozilla"/>
+  <!--original fetch url was git://codeaurora.org/-->
+  <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
+  <!--original fetch url was http://android.git.linaro.org/git-ro/-->
+  <remote fetch="https://git.mozilla.org/external/linaro" name="linaro"/>
   <!--original fetch url was git://github.com/mozilla/-->
   <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
-  <!--original fetch url was git://github.com/apitrace/-->
-  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
-  <!--original fetch url was git://codeaurora.org/-->
-  <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
+  <!--
+    B2G repositories for all targets
+    -->
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="4023297b16fdc46de3ddb04be4f3c575313d1cde"/>
+  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="35dccb3127db8f39f20b985ad312d2cd44780669"/>
+  <project name="moztt" path="external/moztt" remote="b2g" revision="99c333dab00ed79baff9e1cf76b320aee8e1c123"/>
+  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="660169a3d7e034a892359e39135e8c2785a6ad6f">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="ad15b4f1f50f4e28170a069f049e5bdeec8d15cc"/>
-  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="4a962bdab532e18f53e9d2d114c349983262c6b7"/>
-  <project name="moztt" path="external/moztt" remote="b2g" revision="ac7e9ae8a24ab4a3f3da801ca53f95f39a32b89f"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="2d70fdfc0244a7217df1cfa7df9f4798cbfa3af6"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="bef0632ed8ae0e14aa535549ee472748320198ed"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
-  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.1" path="prebuilts/clang/linux-x86/3.1" revision="5c45f43419d5582949284eee9cef0c43d866e03b"/>
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.2" path="prebuilts/clang/linux-x86/3.2" revision="3748b4168e7bd8d46457d4b6786003bc6a5223ce"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="9025e50b9d29b3cabbbb21e1dd94d0d13121a17e"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="b89fda71fcd0fa0cf969310e75be3ea33e048b44"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="2e7d5348f35575870b3c7e567a9a9f6d66f8d6c5"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" revision="1342fd7b4b000ac3e76a5dfe111a0de9d710b4c8"/>
-  <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9" revision="66012bd0f0e9917a2e1d933305d0c9265a1f7147"/>
+  <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9" revision="0390252b6bcc6217966ade31d07f8b12f6f78f89"/>
   <project groups="linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" path="prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" revision="1b26ad444462ccbd97f6319565b4735f7bd779e5"/>
   <project name="device/common" path="device/common" revision="4e1a38704dcfadef60ed2da3cfeba02a56b069d2"/>
   <project name="device/sample" path="device/sample" revision="b045905b46c8b4ee630d0c2aee7db63eaec722d9"/>
   <project name="platform/abi/cpp" path="abi/cpp" revision="fa873799be5cf200f1d1d32a63953949c9dcdda8"/>
   <project name="platform/bionic" path="bionic" revision="0d910c2a305f6b223b7b879a4532df1d0ec73030"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="b279a60d33785df6d08065a2b082eeecb64af759"/>
   <project name="platform/external/aac" path="external/aac" revision="67e322018c4ae56213dec4083f1e37cf7e087a05"/>
   <project name="platform/external/bluetooth/bluedroid" path="external/bluetooth/bluedroid" revision="72573746f78ed1bce49e93737f33d0248ee6da97"/>
@@ -113,17 +123,17 @@
   <project name="platform/libcore" path="libcore" revision="3552ed1686d04a65b85e56ccc24ff3fcf77725e6"/>
   <project name="platform/libnativehelper" path="libnativehelper" revision="4792069e90385889b0638e97ae62c67cdf274e22"/>
   <project name="platform/ndk" path="ndk" revision="7666b97bbaf1d645cdd6b4430a367b7a2bb53369"/>
   <project name="platform/prebuilts/misc" path="prebuilts/misc" revision="f6ab40b3257abc07741188fd173ac392575cc8d2"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="e52099755d0bd3a579130eefe8e58066cc6c0cb6"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="842e33e43a55ea44833b9e23e4d180fa17c843af"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="5db24726f0f42124304195a6bdea129039eeeaeb"/>
   <project name="platform/system/bluetooth" path="system/bluetooth" revision="930ae098543881f47eac054677726ee4b998b2f8"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="570531db9e81a871c421b27025ae558022b1015a"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="bb356d6505f914347690c8143dbd03af427dd07e"/>
   <project name="platform_system_core" path="system/core" remote="b2g" revision="542d1f59dc331b472307e5bd043101d14d5a3a3e"/>
   <project name="platform/system/extras" path="system/extras" revision="18c1180e848e7ab8691940481f5c1c8d22c37b3e"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="34adfb400e031f3dd3353d92413572db5e3a7376"/>
   <project name="platform/system/media" path="system/media" revision="d90b836f66bf1d9627886c96f3a2d9c3007fbb80"/>
   <project name="platform/system/netd" path="system/netd" revision="56112dd7b811301b718d0643a82fd5cac9522073"/>
   <project name="platform/system/security" path="system/security" revision="f48ff68fedbcdc12b570b7699745abb6e7574907"/>
   <project name="platform/system/vold" path="system/vold" revision="8de05d4a52b5a91e7336e6baa4592f945a6ddbea"/>
   <default remote="caf" revision="refs/tags/android-4.3_r2.1" sync-j="4"/>
--- a/b2g/config/emulator-kk/sources.xml
+++ b/b2g/config/emulator-kk/sources.xml
@@ -1,35 +1,45 @@
 <?xml version="1.0" ?><manifest>
+  <!--
+    Remotes
+    -->
   <!--original fetch url was https://android.googlesource.com/-->
   <remote fetch="https://git.mozilla.org/external/aosp" name="aosp"/>
+  <!--original fetch url was git://github.com/apitrace/-->
+  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <!--original fetch url was git://github.com/mozilla-b2g/-->
   <remote fetch="https://git.mozilla.org/b2g" name="b2g"/>
-  <!--original fetch url was git://github.com/mozilla/-->
-  <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
-  <!--original fetch url was git://github.com/apitrace/-->
-  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
+  <!--original fetch url was https://git.mozilla.org/b2g-->
+  <remote fetch="https://git.mozilla.org/b2g" name="b2gmozilla"/>
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
+  <!--original fetch url was http://android.git.linaro.org/git-ro/-->
+  <remote fetch="https://git.mozilla.org/external/linaro" name="linaro"/>
+  <!--original fetch url was git://github.com/mozilla/-->
+  <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
+  <!--
+    B2G repositories for all targets
+    -->
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="4023297b16fdc46de3ddb04be4f3c575313d1cde"/>
+  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="35dccb3127db8f39f20b985ad312d2cd44780669"/>
+  <project name="moztt" path="external/moztt" remote="b2g" revision="99c333dab00ed79baff9e1cf76b320aee8e1c123"/>
+  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
   <!-- B2G specific things. -->
-  <project name="platform_build" path="build" remote="b2g" revision="8d83715f08b7849f16a0dfc88f78d5c3a89c0a54">
+  <project name="platform_build" path="build" remote="b2g" revision="d3c9acb642baee501cff89e4efdb16b0c7480760">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="ad15b4f1f50f4e28170a069f049e5bdeec8d15cc"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
-  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="4a962bdab532e18f53e9d2d114c349983262c6b7"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
-  <project name="moztt" path="external/moztt" remote="b2g" revision="ac7e9ae8a24ab4a3f3da801ca53f95f39a32b89f"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="2d70fdfc0244a7217df1cfa7df9f4798cbfa3af6"/>
-  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="bef0632ed8ae0e14aa535549ee472748320198ed"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="f92a936f2aa97526d4593386754bdbf02db07a12"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="6e47ff2790f5656b5b074407829ceecf3e6188c4"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="1950e4760fa14688b83cdbb5acaa1af9f82ef434"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" revision="ac6eb97a37035c09fb5ede0852f0881e9aadf9ad"/>
   <project groups="linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" path="prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" revision="737f591c5f95477148d26602c7be56cbea0cdeb9"/>
   <project groups="linux,x86" name="platform/prebuilts/python/linux-x86/2.7.5" path="prebuilts/python/linux-x86/2.7.5" revision="51da9b1981be481b92a59a826d4d78dc73d0989a"/>
   <project name="device/common" path="device/common" revision="798a3664597e6041985feab9aef42e98d458bc3d"/>
@@ -109,33 +119,33 @@
   <project name="platform/hardware/libhardware_legacy" path="hardware/libhardware_legacy" revision="01f436c51dc68aec7cc1c85fda6e6792b2a95066"/>
   <project name="platform/libcore" path="libcore" revision="9877ade9617bb0db6e59aa2a54719a9bc92600f3"/>
   <project name="platform/libnativehelper" path="libnativehelper" revision="46c96ace65eb1ccab05bf15b9bf8e53e443039af"/>
   <project name="platform/ndk" path="ndk" revision="cb5519af32ae7b4a9c334913a612462ecd04c5d0"/>
   <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="c739cffa6394c06e099ea48879a20341b6163338"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="6aa61f8557a22039a30b42b7f283996381fd625d"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="b562b01c93de9578d5db537b6a602a38e1aaa0ce"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="387f03e815f57d536dd922706db1622bddba8d81"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="570531db9e81a871c421b27025ae558022b1015a"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="bb356d6505f914347690c8143dbd03af427dd07e"/>
   <project name="platform/system/extras" path="system/extras" revision="5356165f67f4a81c2ef28671c13697f1657590df"/>
   <project name="platform/system/media" path="system/media" revision="be0e2fe59a8043fa5200f75697df9220a99abe9d"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="34adfb400e031f3dd3353d92413572db5e3a7376"/>
   <project name="platform/system/netd" path="system/netd" revision="36704b0da24debcab8090156568ac236315036bb"/>
   <project name="platform/system/security" path="system/security" revision="583374f69f531ba68fc3dcbff1f74893d2a96406"/>
   <project name="platform/system/vold" path="system/vold" revision="d4455b8cf361f8353e8aebac15ffd64b4aedd2b9"/>
   <project name="platform/external/icu4c" path="external/icu4c" remote="aosp" revision="b4c6379528887dc25ca9991a535a8d92a61ad6b6"/>
   <project name="platform_frameworks_av" path="frameworks/av" remote="b2g" revision="2da3a2d5100f8afa1229bb50aa2a29ea0aaf8417"/>
   <project name="platform_system_core" path="system/core" remote="b2g" revision="8586f55fe4b015911b48e731b69c592ad82a0807"/>
   <default remote="caf" revision="refs/tags/android-4.4.2_r1" sync-j="4"/>
   <!-- Emulator specific things -->
   <project name="device/generic/armv7-a-neon" path="device/generic/armv7-a-neon" revision="72ffdf71c68a96309212eb13d63560d66db14c9e"/>
-  <project name="device_generic_goldfish" path="device/generic/goldfish" remote="b2g" revision="58800ecb50e4e41cfb0a36cb43c82b73fb3612e5"/>
+  <project name="device_generic_goldfish" path="device/generic/goldfish" remote="b2g" revision="566810728cd485ff2f30766499d32ada7cbd487a"/>
   <project name="platform_bionic" path="bionic" remote="b2g" revision="3e85c4683c121530c1c3a48c696a569bf5f587e2"/>
-  <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="b2f83825411be614e8f7ec75fc731fc9c67a7078"/>
+  <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="3e4affc1794fef1ad96d6fcc727cca92b032a429"/>
   <project name="platform/external/libnfc-nci" path="external/libnfc-nci" revision="f37bd545063039e30a92f2550ae78c0e6e4e2d08"/>
   <project name="platform_external_wpa_supplicant_8" path="external/wpa_supplicant_8" remote="b2g" revision="0c6a6547cd1fd302fa2b0f6e375654df36bf0ec4"/>
-  <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d3ab8090c5c2ac77429575131c4718d96bfb93cc"/>
+  <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="c0dd0098328f3992e1ca09d6d4355729243863d5"/>
   <project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="5f4b68c799927b6e078f987b12722c3a6ccd4a45"/>
   <project name="platform/development" path="development" revision="5968ff4e13e0d696ad8d972281fc27ae5a12829b"/>
-  <project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="6a1bb59af65b6485b1090522f66fac95c3f9e22c"/>
+  <project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="0c0c050518705d49531375012fa2b4e95e1b3693"/>
   <project name="android-sdk" path="sdk" remote="b2g" revision="0951179277915335251c5e11d242e4e1a8c2236f"/>
   <project name="darwinstreamingserver" path="system/darwinstreamingserver" remote="b2g" revision="cf85968c7f85e0ec36e72c87ceb4837a943b8af6"/>
 </manifest>
--- a/b2g/config/emulator-l/sources.xml
+++ b/b2g/config/emulator-l/sources.xml
@@ -1,35 +1,45 @@
 <?xml version="1.0" ?><manifest>
+  <!--
+    Remotes
+    -->
   <!--original fetch url was https://android.googlesource.com/-->
   <remote fetch="https://git.mozilla.org/external/aosp" name="aosp"/>
+  <!--original fetch url was git://github.com/apitrace/-->
+  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <!--original fetch url was git://github.com/mozilla-b2g/-->
   <remote fetch="https://git.mozilla.org/b2g" name="b2g"/>
-  <!--original fetch url was git://github.com/mozilla/-->
-  <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
-  <!--original fetch url was git://github.com/apitrace/-->
-  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
+  <!--original fetch url was https://git.mozilla.org/b2g-->
+  <remote fetch="https://git.mozilla.org/b2g" name="b2gmozilla"/>
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
+  <!--original fetch url was http://android.git.linaro.org/git-ro/-->
+  <remote fetch="https://git.mozilla.org/external/linaro" name="linaro"/>
+  <!--original fetch url was git://github.com/mozilla/-->
+  <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
+  <!--
+    B2G repositories for all targets
+    -->
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="4023297b16fdc46de3ddb04be4f3c575313d1cde"/>
+  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="35dccb3127db8f39f20b985ad312d2cd44780669"/>
+  <project name="moztt" path="external/moztt" remote="b2g" revision="99c333dab00ed79baff9e1cf76b320aee8e1c123"/>
+  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
   <!-- B2G specific things. -->
-  <project name="platform_build" path="build" remote="b2g" revision="c9d4fe680662ee44a4bdea42ae00366f5df399cf">
+  <project name="platform_build" path="build" remote="b2g" revision="be4b291a90b371b41b62ade68c31ad173bb87baa">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="ad15b4f1f50f4e28170a069f049e5bdeec8d15cc"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
-  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="4a962bdab532e18f53e9d2d114c349983262c6b7"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
-  <project name="moztt" path="external/moztt" remote="b2g" revision="ac7e9ae8a24ab4a3f3da801ca53f95f39a32b89f"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="2d70fdfc0244a7217df1cfa7df9f4798cbfa3af6"/>
-  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="bef0632ed8ae0e14aa535549ee472748320198ed"/>
   <!-- Stock Android things -->
   <project groups="pdk,linux" name="platform/prebuilts/clang/linux-x86/host/3.5" path="prebuilts/clang/linux-x86/host/3.5" revision="ffc05a232799fe8fcb3e47b7440b52b1fb4244c0"/>
   <project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8" path="prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8" revision="337e0ef5e40f02a1ae59b90db0548976c70a7226"/>
   <project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.8" revision="8af5ff6f5dced9eb5a8127459df6c75d24342204"/>
   <project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8" revision="30915518fa7ea07166efedc191a4f40aef516fe7"/>
   <project groups="pdk,linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6" revision="96eee58e3389fb05a835310d6a06a6ba4486097a"/>
   <project groups="pdk,linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8" revision="7c8a46698171aa2e0be09edb43d15a6acf832770"/>
   <project groups="pdk,linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.8" path="prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.8" revision="24b2038be8a636fd4a5d21f0abae1e466b07bcf7"/>
@@ -117,32 +127,32 @@
   <project name="platform/external/zopfli" path="external/zopfli" revision="8b994159cf3fc74a58e42fca72bc6849e6027912"/>
   <project name="platform/frameworks/native" path="frameworks/native" revision="c39bd4ee1f4b3ef92bf7a45824b77703f40a5fd4"/>
   <project name="platform/frameworks/opt/emoji" path="frameworks/opt/emoji" revision="2293192ed15b88ebe962fb5377dd197200e6472b"/>
   <project name="platform/hardware/libhardware" path="hardware/libhardware" revision="f5feb2aa2047fbaf13be448fe8d06bff3ccf7b84"/>
   <project name="platform/hardware/libhardware_legacy" path="hardware/libhardware_legacy" revision="8d075b4d5e9e032b18fbc8b5def63827d1b4a30d"/>
   <project name="platform/libcore" path="libcore" revision="bdec7d684c083760bef7bc4ba2429cceccaaf7d0"/>
   <project name="platform/libnativehelper" path="libnativehelper" revision="27bcc086236cedd31c056303e255c6d0ea3d4a50"/>
   <project name="platform/ndk" path="ndk" revision="42e85f81cc6c74af145056ee80b06e520cccb9a7"/>
-  <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="179d485578c6907c0daf343a3bd7bc53b5e137a1"/>
+  <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="25b96077aeae7bd0e3a5e7c284fb636664337013"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="1d080491f26dfdfd76d5bbc3e6b40c660e8565af"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="61a10cbd19d6b7fc052a8cb92dfa1b37b93754f3"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="9e892a67a01671f312c76b0880dedaa6ba478148"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="570531db9e81a871c421b27025ae558022b1015a"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="bb356d6505f914347690c8143dbd03af427dd07e"/>
   <project name="platform/system/extras" path="system/extras" revision="47fa016e2248b80aebd5928402c7409f8e0ca64e"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="34adfb400e031f3dd3353d92413572db5e3a7376"/>
   <project name="platform/system/media" path="system/media" revision="70bfebc66d9c6a4c614a8c7efde90e8e7e1d8641"/>
   <project name="platform/system/netd" path="system/netd" revision="d113f0ceefa9ce29eb3c86e2d23c7417a70b4048"/>
   <project name="platform/system/security" path="system/security" revision="94e1617f6f2bc2286d005e79cffa6bf0721b06b3"/>
   <project name="platform/system/vold" path="system/vold" revision="c065e301e38ea0c241164e2a373e1ecefbeaf2ec"/>
-  <project name="platform_frameworks_av" path="frameworks/av" remote="b2g" revision="6971327dda6bead878724ac1c767ee2d23a2a9e1"/>
-  <project name="platform_frameworks_base" path="frameworks/base" remote="b2g" revision="04e26ebdc36ca83f4ee3e9e2082b3fcf04c5b971"/>
-  <project name="platform_frameworks_wilhelm" path="frameworks/wilhelm" remote="b2g" revision="0dbf5baafadf6d233c0a29e392fa3293f0121673"/>
-  <project name="platform_system_core" path="system/core" remote="b2g" revision="f594bc64eacac490857748b1139ffcb34c856bbd"/>
-  <project name="platform_external_sepolicy" path="external/sepolicy" remote="b2g" revision="3f6be48a46c54dd8cacaf216ab5b145de5ffefd2"/>
+  <project name="platform_frameworks_av" path="frameworks/av" remote="b2g" revision="479a404164986b3e95212eecdae7e67da4fba9ed"/>
+  <project name="platform_frameworks_base" path="frameworks/base" remote="b2g" revision="396b731dbccc62f272f1fdb8228109c3fbd83c25"/>
+  <project name="platform_frameworks_wilhelm" path="frameworks/wilhelm" remote="b2g" revision="174bb44bb9af7583e6337e1e1b6cc18d0217ae82"/>
+  <project name="platform_system_core" path="system/core" remote="b2g" revision="1b8322b228f717ff2a4d48fa8b44240d8e3f62bc"/>
+  <project name="platform_external_sepolicy" path="external/sepolicy" remote="b2g" revision="246c603d9fe181fa8893af7293dbc63e870fe5e0"/>
   <default remote="caf" revision="refs/tags/android-5.1.0_r1" sync-j="4"/>
   <!-- Emulator specific things -->
   <project name="device/generic/armv7-a-neon" path="device/generic/armv7-a-neon" revision="fe7df1bc8dd0fd71571505d7be1c31a4ad1e40fb"/>
   <project name="device_generic_goldfish" path="device/generic/goldfish" remote="b2g" revision="dc8c7896562bf63190befb3e6b21310a4b7144fa"/>
   <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="59e434cbecc02653f44cedeb2ef5cc88dc8bb61b"/>
   <project name="platform_external_wpa_supplicant_8" path="external/wpa_supplicant_8" remote="b2g" revision="cbda29a58abc4ea1f7f4611fe354ab67b606219d"/>
   <project name="platform/development" path="development" revision="0c51f6e0aa2ee57fcb75ec3b2ff6bf754cece63e"/>
   <project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="2c0d193349c55337e37196a7f2d5cef37753ed3e"/>
--- a/b2g/config/emulator/sources.xml
+++ b/b2g/config/emulator/sources.xml
@@ -1,44 +1,51 @@
 <?xml version="1.0" ?><manifest>
+  <!--
+    Remotes
+    -->
   <!--original fetch url was https://android.googlesource.com/-->
   <remote fetch="https://git.mozilla.org/external/aosp" name="aosp"/>
   <!--original fetch url was git://github.com/apitrace/-->
   <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <!--original fetch url was git://github.com/mozilla-b2g/-->
   <remote fetch="https://git.mozilla.org/b2g" name="b2g"/>
   <!--original fetch url was https://git.mozilla.org/b2g-->
   <remote fetch="https://git.mozilla.org/b2g" name="b2gmozilla"/>
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
+  <!--original fetch url was http://android.git.linaro.org/git-ro/-->
+  <remote fetch="https://git.mozilla.org/external/linaro" name="linaro"/>
   <!--original fetch url was git://github.com/mozilla/-->
   <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
+  <!--
+    B2G repositories for all targets
+    -->
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="4023297b16fdc46de3ddb04be4f3c575313d1cde"/>
+  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="35dccb3127db8f39f20b985ad312d2cd44780669"/>
+  <project name="moztt" path="external/moztt" remote="b2g" revision="99c333dab00ed79baff9e1cf76b320aee8e1c123"/>
+  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
   <default remote="caf" revision="refs/tags/android-4.0.4_r2.1" sync-j="4"/>
-  <!-- Gecko and Gaia -->
-  <project name="gaia.git" path="gaia" remote="mozillaorg" revision="ad15b4f1f50f4e28170a069f049e5bdeec8d15cc"/>
   <!-- Gonk-specific things and forks -->
   <project name="platform_bionic" path="bionic" remote="b2g" revision="e2b3733ba3fa5e3f404e983d2e4142b1f6b1b846"/>
   <project name="platform_build" path="build" remote="b2g" revision="1b0db93fb6b870b03467aff50d6419771ba0d88c">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
   <project name="android-development" path="development" remote="b2g" revision="2bdf22305b523af644e1891b4ddfd9229336d0ce"/>
   <project name="platform_external_apriori" path="external/apriori" remote="b2g" revision="11816ad0406744f963537b23d68ed9c2afb412bd"/>
   <project name="platform_external_elfcopy" path="external/elfcopy" remote="b2g" revision="62c1bed1c4505369cac2e72fbe30452a598fb690"/>
   <project name="platform_external_elfutils" path="external/elfutils" remote="b2g" revision="72940dec691fa3255e13df01f8c53b620e446066"/>
-  <project name="moztt" path="external/moztt" remote="b2g" revision="ac7e9ae8a24ab4a3f3da801ca53f95f39a32b89f"/>
   <project name="platform_external_opensans" path="external/opensans" remote="b2g" revision="b5b4c226ca1d71e936153cf679dda6d3d60e2354"/>
   <project name="screencap-gonk" path="external/screencap-gonk" remote="b2g" revision="e6403c71e9eca8cb943739d5a0a192deac60fc51"/>
-  <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="c72c9278ddc2f442d193474993d36e7f2cfb08c4"/>
+  <project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="af8b2b782387209cc5b5803926f86bdbc31570ca"/>
   <project name="platform_frameworks_base" path="frameworks/base" remote="b2g" revision="6afc63abe52776ae6a1d32a2d927e630a743a86a"/>
-  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="4a962bdab532e18f53e9d2d114c349983262c6b7"/>
-  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
-  <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cb4604d5a578efd027277059ce3e0f6e3af59bd1"/>
+  <project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="5fa1b11a01e7e90dbe9681e690020d10795ec1a9"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="android-sdk" path="sdk" remote="b2g" revision="4f46930827957afbce500a4a920755a218bf3155"/>
   <project name="darwinstreamingserver" path="system/darwinstreamingserver" remote="b2g" revision="cf85968c7f85e0ec36e72c87ceb4837a943b8af6"/>
   <!-- Stock Android things -->
   <project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="425f8b5fadf5889834c5acd27d23c9e0b2129c28"/>
   <project name="device/common" path="device/common" revision="42b808b7e93d0619286ae8e59110b176b7732389"/>
   <project name="device/sample" path="device/sample" revision="237bd668d0f114d801a8d6455ef5e02cc3577587"/>
--- a/b2g/config/flame-kk/config.json
+++ b/b2g/config/flame-kk/config.json
@@ -37,17 +37,17 @@
         ["{workdir}/gecko/tools/rb/fix_stack_using_bpsyms.py", "gecko/tools/rb/"]
     ],
     "env": {
         "VARIANT": "userdebug",
         "MOZILLA_OFFICIAL": "1",
         "MOZ_TELEMETRY_REPORTING": "1",
         "B2G_UPDATE_CHANNEL": "nightly",
         "GAIA_KEYBOARD_LAYOUTS": "en,pt-BR,es,de,fr,pl,zh-Hans-Pinyin,zh-Hant-Zhuyin,en-Dvorak",
-        "FOTA_FINGERPRINTS": "qcom/flame/flame:4.4.2/KOT49H/eng.cltbld.20150527.043015:userdebug/test-keys"
+        "FOTA_FINGERPRINTS": "qcom/flame/flame:4.4.2/KOT49H/eng.cltbld.20150527.043015:userdebug/test-keys,qcom/flame/flame:4.4.2/KOT49H/eng.naoki.20151216.105618:userdebug/test-keys"
     },
     "b2g_manifest": "flame-kk.xml",
     "b2g_manifest_intree": true,
     "additional_source_tarballs": ["backup-flame.tar.xz"],
     "gecko_l10n_root": "https://hg.mozilla.org/l10n-central",
     "gaia": {
         "l10n": {
             "vcs": "hgtool",
--- a/b2g/config/flame-kk/sources.xml
+++ b/b2g/config/flame-kk/sources.xml
@@ -1,36 +1,46 @@
 <?xml version="1.0" ?><manifest>
+  <!--
+    Remotes
+    -->
   <!--original fetch url was https://android.googlesource.com/-->
   <remote fetch="https://git.mozilla.org/external/aosp" name="aosp"/>
+  <!--original fetch url was git://github.com/apitrace/-->
+  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <!--original fetch url was git://github.com/mozilla-b2g/-->
   <remote fetch="https://git.mozilla.org/b2g" name="b2g"/>
-  <!--original fetch url was git://github.com/mozilla/-->
-  <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
-  <!--original fetch url was git://github.com/apitrace/-->
-  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
+  <!--original fetch url was https://git.mozilla.org/b2g-->
+  <remote fetch="https://git.mozilla.org/b2g" name="b2gmozilla"/>
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
+  <!--original fetch url was http://android.git.linaro.org/git-ro/-->
+  <remote fetch="https://git.mozilla.org/external/linaro" name="linaro"/>
+  <!--original fetch url was git://github.com/mozilla/-->
+  <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
+  <!--
+    B2G repositories for all targets
+    -->
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="4023297b16fdc46de3ddb04be4f3c575313d1cde"/>
+  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="35dccb3127db8f39f20b985ad312d2cd44780669"/>
+  <project name="moztt" path="external/moztt" remote="b2g" revision="99c333dab00ed79baff9e1cf76b320aee8e1c123"/>
+  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
   <!-- B2G specific things. -->
-  <project name="platform_build" path="build" remote="b2g" revision="8d83715f08b7849f16a0dfc88f78d5c3a89c0a54">
+  <project name="platform_build" path="build" remote="b2g" revision="d3c9acb642baee501cff89e4efdb16b0c7480760">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="ad15b4f1f50f4e28170a069f049e5bdeec8d15cc"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="fake-qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="939b377d55a2f081d94029a30a75d05e5a20daf3"/>
-  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="4a962bdab532e18f53e9d2d114c349983262c6b7"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
-  <project name="moztt" path="external/moztt" remote="b2g" revision="ac7e9ae8a24ab4a3f3da801ca53f95f39a32b89f"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="2d70fdfc0244a7217df1cfa7df9f4798cbfa3af6"/>
-  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="bef0632ed8ae0e14aa535549ee472748320198ed"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="ebdad82e61c16772f6cd47e9f11936bf6ebe9aa0"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="8b880805d454664b3eed11d0f053cdeafa1ff06e"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" revision="a1e239a0bb5cd1d69680bf1075883aa9a7bf2429"/>
   <project groups="linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" path="prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" revision="c7931763d41be602407ed9d71e2c0292c6597e00"/>
   <project groups="linux,x86" name="platform/prebuilts/python/linux-x86/2.7.5" path="prebuilts/python/linux-x86/2.7.5" revision="a32003194f707f66a2d8cdb913ed1869f1926c5d"/>
   <project name="device/common" path="device/common" revision="96d4d2006c4fcb2f19a3fa47ab10cb409faa017b"/>
@@ -104,17 +114,17 @@
   <project name="platform/frameworks/wilhelm" path="frameworks/wilhelm" revision="f0c3b4edf597c40aae4ea311575f39c8bcf203df"/>
   <project name="platform/libcore" path="libcore" revision="baf7d8068dd501cfa338d3a8b1b87216d6ce0571"/>
   <project name="platform/libnativehelper" path="libnativehelper" revision="50c4430e32849530ced32680fd6ee98963b3f7ac"/>
   <project name="platform/ndk" path="ndk" revision="e58ef003be4306bb53a8c11331146f39e4eab31f"/>
   <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="c739cffa6394c06e099ea48879a20341b6163338"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="c792f0bd9fff7aea2887c60bbb3a9bbdb534ffa3"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="69d524e80cdf3981006627c65ac85f3a871238a3"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="5a48c04c4bb5f079bc757e29864a42427378e051"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="570531db9e81a871c421b27025ae558022b1015a"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="bb356d6505f914347690c8143dbd03af427dd07e"/>
   <project name="platform/system/extras" path="system/extras" revision="576f57b6510de59c08568b53c0fb60588be8689e"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="34adfb400e031f3dd3353d92413572db5e3a7376"/>
   <project name="platform/system/netd" path="system/netd" revision="a6531f7befb49b1c81bc0de7e51c5482b308e1c5"/>
   <project name="platform/system/security" path="system/security" revision="ee8068b9e7bfb2770635062fc9c2035be2142bd8"/>
   <project name="platform/system/vold" path="system/vold" revision="42fa2a0f14f965970a4b629a176bbd2666edf017"/>
   <project name="platform/external/curl" path="external/curl" revision="e68addd988448959ea8157c5de637346b4180c33"/>
   <project name="platform/external/icu4c" path="external/icu4c" revision="d3ec7428eb276db43b7ed0544e09344a6014806c"/>
   <project name="platform/hardware/libhardware_legacy" path="hardware/libhardware_legacy" revision="76c4bf4bc430a1b8317f2f21ef735867733e50cc"/>
--- a/b2g/config/gaia.json
+++ b/b2g/config/gaia.json
@@ -1,9 +1,9 @@
 {
     "git": {
-        "git_revision": "ad15b4f1f50f4e28170a069f049e5bdeec8d15cc", 
+        "git_revision": "4023297b16fdc46de3ddb04be4f3c575313d1cde", 
         "remote": "https://git.mozilla.org/releases/gaia.git", 
         "branch": ""
     }, 
-    "revision": "f9f1dd1ec78eac04af587f54518e6d557209ca75", 
+    "revision": "1520b4ebcfc727b7153be5242339b8f577ab65b4", 
     "repo_path": "integration/gaia-central"
 }
deleted file mode 100644
--- a/b2g/config/mozconfigs/linux64_gecko/debug
+++ /dev/null
@@ -1,38 +0,0 @@
-MOZ_AUTOMATION_L10N_CHECK=0
-MOZ_AUTOMATION_UPLOAD_SYMBOLS=0
-MOZ_AUTOMATION_UPDATE_PACKAGING=0
-. "$topsrcdir/b2g/config/mozconfigs/common"
-. "$topsrcdir/build/unix/mozconfig.linux"
-
-ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}
-ac_add_options --enable-update-packaging
-ac_add_options --enable-signmar
-ac_add_options --enable-debug
-
-# This will overwrite the default of stripping everything and keep the symbol table.
-# This is useful for profiling and debugging and only increases the package size
-# by 2 MBs.
-STRIP_FLAGS="--strip-debug"
-
-# Needed to enable breakpad in application.ini
-export MOZILLA_OFFICIAL=1
-
-export MOZ_TELEMETRY_REPORTING=1
-
-# Treat warnings as errors (modulo ALLOW_COMPILER_WARNINGS).
-ac_add_options --enable-warnings-as-errors
-
-# Use sccache
-no_sccache=
-
-#B2G options
-ac_add_options --enable-application=b2g
-ENABLE_MARIONETTE=1
-export CXXFLAGS=-DMOZ_ENABLE_JS_DUMP
-
-GAIADIR=$topsrcdir/gaia
-
-# Include Firefox OS fonts.
-MOZTTDIR=$topsrcdir/moz-tt
-
-. "$topsrcdir/b2g/config/mozconfigs/common.override"
--- a/b2g/config/nexus-4-kk/sources.xml
+++ b/b2g/config/nexus-4-kk/sources.xml
@@ -1,36 +1,46 @@
 <?xml version="1.0" ?><manifest>
+  <!--
+    Remotes
+    -->
   <!--original fetch url was https://android.googlesource.com/-->
   <remote fetch="https://git.mozilla.org/external/aosp" name="aosp"/>
+  <!--original fetch url was git://github.com/apitrace/-->
+  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <!--original fetch url was git://github.com/mozilla-b2g/-->
   <remote fetch="https://git.mozilla.org/b2g" name="b2g"/>
-  <!--original fetch url was git://github.com/mozilla/-->
-  <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
-  <!--original fetch url was git://github.com/apitrace/-->
-  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
+  <!--original fetch url was https://git.mozilla.org/b2g-->
+  <remote fetch="https://git.mozilla.org/b2g" name="b2gmozilla"/>
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
+  <!--original fetch url was http://android.git.linaro.org/git-ro/-->
+  <remote fetch="https://git.mozilla.org/external/linaro" name="linaro"/>
+  <!--original fetch url was git://github.com/mozilla/-->
+  <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
+  <!--
+    B2G repositories for all targets
+    -->
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="4023297b16fdc46de3ddb04be4f3c575313d1cde"/>
+  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="35dccb3127db8f39f20b985ad312d2cd44780669"/>
+  <project name="moztt" path="external/moztt" remote="b2g" revision="99c333dab00ed79baff9e1cf76b320aee8e1c123"/>
+  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
   <!-- B2G specific things. -->
-  <project name="platform_build" path="build" remote="b2g" revision="8d83715f08b7849f16a0dfc88f78d5c3a89c0a54">
+  <project name="platform_build" path="build" remote="b2g" revision="d3c9acb642baee501cff89e4efdb16b0c7480760">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="ad15b4f1f50f4e28170a069f049e5bdeec8d15cc"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="fake-qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="939b377d55a2f081d94029a30a75d05e5a20daf3"/>
-  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="4a962bdab532e18f53e9d2d114c349983262c6b7"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
-  <project name="moztt" path="external/moztt" remote="b2g" revision="ac7e9ae8a24ab4a3f3da801ca53f95f39a32b89f"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="2d70fdfc0244a7217df1cfa7df9f4798cbfa3af6"/>
-  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="bef0632ed8ae0e14aa535549ee472748320198ed"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="f92a936f2aa97526d4593386754bdbf02db07a12"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="6e47ff2790f5656b5b074407829ceecf3e6188c4"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="1950e4760fa14688b83cdbb5acaa1af9f82ef434"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" revision="ac6eb97a37035c09fb5ede0852f0881e9aadf9ad"/>
   <project groups="linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" path="prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" revision="737f591c5f95477148d26602c7be56cbea0cdeb9"/>
   <project groups="linux,x86" name="platform/prebuilts/python/linux-x86/2.7.5" path="prebuilts/python/linux-x86/2.7.5" revision="51da9b1981be481b92a59a826d4d78dc73d0989a"/>
   <project name="device/common" path="device/common" revision="798a3664597e6041985feab9aef42e98d458bc3d"/>
@@ -111,17 +121,17 @@
   <project name="platform/hardware/libhardware_legacy" path="hardware/libhardware_legacy" revision="01f436c51dc68aec7cc1c85fda6e6792b2a95066"/>
   <project name="platform/libcore" path="libcore" revision="9877ade9617bb0db6e59aa2a54719a9bc92600f3"/>
   <project name="platform/libnativehelper" path="libnativehelper" revision="46c96ace65eb1ccab05bf15b9bf8e53e443039af"/>
   <project name="platform/ndk" path="ndk" revision="cb5519af32ae7b4a9c334913a612462ecd04c5d0"/>
   <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="c739cffa6394c06e099ea48879a20341b6163338"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="6aa61f8557a22039a30b42b7f283996381fd625d"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="b562b01c93de9578d5db537b6a602a38e1aaa0ce"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="387f03e815f57d536dd922706db1622bddba8d81"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="570531db9e81a871c421b27025ae558022b1015a"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="bb356d6505f914347690c8143dbd03af427dd07e"/>
   <project name="platform/system/extras" path="system/extras" revision="5356165f67f4a81c2ef28671c13697f1657590df"/>
   <project name="platform/system/media" path="system/media" revision="be0e2fe59a8043fa5200f75697df9220a99abe9d"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="34adfb400e031f3dd3353d92413572db5e3a7376"/>
   <project name="platform/system/netd" path="system/netd" revision="36704b0da24debcab8090156568ac236315036bb"/>
   <project name="platform/system/security" path="system/security" revision="583374f69f531ba68fc3dcbff1f74893d2a96406"/>
   <project name="platform/system/vold" path="system/vold" revision="d4455b8cf361f8353e8aebac15ffd64b4aedd2b9"/>
   <project name="platform/external/icu4c" path="external/icu4c" remote="aosp" revision="b4c6379528887dc25ca9991a535a8d92a61ad6b6"/>
   <project name="platform_frameworks_av" path="frameworks/av" remote="b2g" revision="2da3a2d5100f8afa1229bb50aa2a29ea0aaf8417"/>
--- a/b2g/config/nexus-4/sources.xml
+++ b/b2g/config/nexus-4/sources.xml
@@ -1,43 +1,53 @@
 <?xml version="1.0" ?><manifest>
+  <!--
+    Remotes
+    -->
   <!--original fetch url was https://android.googlesource.com/-->
   <remote fetch="https://git.mozilla.org/external/aosp" name="aosp"/>
+  <!--original fetch url was git://github.com/apitrace/-->
+  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <!--original fetch url was git://github.com/mozilla-b2g/-->
   <remote fetch="https://git.mozilla.org/b2g" name="b2g"/>
+  <!--original fetch url was https://git.mozilla.org/b2g-->
+  <remote fetch="https://git.mozilla.org/b2g" name="b2gmozilla"/>
+  <!--original fetch url was git://codeaurora.org/-->
+  <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
+  <!--original fetch url was http://android.git.linaro.org/git-ro/-->
+  <remote fetch="https://git.mozilla.org/external/linaro" name="linaro"/>
   <!--original fetch url was git://github.com/mozilla/-->
   <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
-  <!--original fetch url was git://github.com/apitrace/-->
-  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
-  <!--original fetch url was git://codeaurora.org/-->
-  <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
+  <!--
+    B2G repositories for all targets
+    -->
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="4023297b16fdc46de3ddb04be4f3c575313d1cde"/>
+  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="35dccb3127db8f39f20b985ad312d2cd44780669"/>
+  <project name="moztt" path="external/moztt" remote="b2g" revision="99c333dab00ed79baff9e1cf76b320aee8e1c123"/>
+  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
   <!-- B2G specific things. -->
   <project name="platform_build" path="build" remote="b2g" revision="660169a3d7e034a892359e39135e8c2785a6ad6f">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="fake-qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="939b377d55a2f081d94029a30a75d05e5a20daf3"/>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="ad15b4f1f50f4e28170a069f049e5bdeec8d15cc"/>
-  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="4a962bdab532e18f53e9d2d114c349983262c6b7"/>
-  <project name="moztt" path="external/moztt" remote="b2g" revision="ac7e9ae8a24ab4a3f3da801ca53f95f39a32b89f"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="2d70fdfc0244a7217df1cfa7df9f4798cbfa3af6"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="bef0632ed8ae0e14aa535549ee472748320198ed"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
-  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
   <!-- Stock Android things -->
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.1" path="prebuilts/clang/linux-x86/3.1" revision="5c45f43419d5582949284eee9cef0c43d866e03b"/>
   <project groups="linux" name="platform/prebuilts/clang/linux-x86/3.2" path="prebuilts/clang/linux-x86/3.2" revision="3748b4168e7bd8d46457d4b6786003bc6a5223ce"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="9025e50b9d29b3cabbbb21e1dd94d0d13121a17e"/>
   <project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="b89fda71fcd0fa0cf969310e75be3ea33e048b44"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="2e7d5348f35575870b3c7e567a9a9f6d66f8d6c5"/>
   <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" revision="1342fd7b4b000ac3e76a5dfe111a0de9d710b4c8"/>
-  <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9" revision="66012bd0f0e9917a2e1d933305d0c9265a1f7147"/>
+  <project groups="linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9" revision="0390252b6bcc6217966ade31d07f8b12f6f78f89"/>
   <project groups="linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" path="prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7" revision="1b26ad444462ccbd97f6319565b4735f7bd779e5"/>
   <project name="device/common" path="device/common" revision="4e1a38704dcfadef60ed2da3cfeba02a56b069d2"/>
   <project name="device/sample" path="device/sample" revision="b045905b46c8b4ee630d0c2aee7db63eaec722d9"/>
   <project name="platform/abi/cpp" path="abi/cpp" revision="fa873799be5cf200f1d1d32a63953949c9dcdda8"/>
   <project name="platform/bionic" path="bionic" revision="0d910c2a305f6b223b7b879a4532df1d0ec73030"/>
   <project name="platform/bootable/recovery" path="bootable/recovery" revision="b279a60d33785df6d08065a2b082eeecb64af759"/>
   <project name="platform/external/aac" path="external/aac" revision="67e322018c4ae56213dec4083f1e37cf7e087a05"/>
   <project name="platform/external/bluetooth/bluedroid" path="external/bluetooth/bluedroid" revision="72573746f78ed1bce49e93737f33d0248ee6da97"/>
@@ -114,17 +124,17 @@
   <project name="platform/libcore" path="libcore" revision="3552ed1686d04a65b85e56ccc24ff3fcf77725e6"/>
   <project name="platform/libnativehelper" path="libnativehelper" revision="4792069e90385889b0638e97ae62c67cdf274e22"/>
   <project name="platform/ndk" path="ndk" revision="7666b97bbaf1d645cdd6b4430a367b7a2bb53369"/>
   <project name="platform/prebuilts/misc" path="prebuilts/misc" revision="f6ab40b3257abc07741188fd173ac392575cc8d2"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="e52099755d0bd3a579130eefe8e58066cc6c0cb6"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="842e33e43a55ea44833b9e23e4d180fa17c843af"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="5db24726f0f42124304195a6bdea129039eeeaeb"/>
   <project name="platform/system/bluetooth" path="system/bluetooth" revision="930ae098543881f47eac054677726ee4b998b2f8"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="570531db9e81a871c421b27025ae558022b1015a"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="bb356d6505f914347690c8143dbd03af427dd07e"/>
   <project name="platform_system_core" path="system/core" remote="b2g" revision="542d1f59dc331b472307e5bd043101d14d5a3a3e"/>
   <project name="platform/system/extras" path="system/extras" revision="18c1180e848e7ab8691940481f5c1c8d22c37b3e"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="34adfb400e031f3dd3353d92413572db5e3a7376"/>
   <project name="platform/system/media" path="system/media" revision="d90b836f66bf1d9627886c96f3a2d9c3007fbb80"/>
   <project name="platform/system/netd" path="system/netd" revision="56112dd7b811301b718d0643a82fd5cac9522073"/>
   <project name="platform/system/security" path="system/security" revision="f48ff68fedbcdc12b570b7699745abb6e7574907"/>
   <project name="platform/system/vold" path="system/vold" revision="8de05d4a52b5a91e7336e6baa4592f945a6ddbea"/>
   <default remote="caf" revision="refs/tags/android-4.3_r2.1" sync-j="4"/>
--- a/b2g/config/nexus-5-l/sources.xml
+++ b/b2g/config/nexus-5-l/sources.xml
@@ -1,36 +1,46 @@
 <?xml version="1.0" ?><manifest>
+  <!--
+    Remotes
+    -->
   <!--original fetch url was https://android.googlesource.com/-->
   <remote fetch="https://git.mozilla.org/external/aosp" name="aosp"/>
+  <!--original fetch url was git://github.com/apitrace/-->
+  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
   <!--original fetch url was git://github.com/mozilla-b2g/-->
   <remote fetch="https://git.mozilla.org/b2g" name="b2g"/>
-  <!--original fetch url was git://github.com/mozilla/-->
-  <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
-  <!--original fetch url was git://github.com/apitrace/-->
-  <remote fetch="https://git.mozilla.org/external/apitrace" name="apitrace"/>
+  <!--original fetch url was https://git.mozilla.org/b2g-->
+  <remote fetch="https://git.mozilla.org/b2g" name="b2gmozilla"/>
   <!--original fetch url was git://codeaurora.org/-->
   <remote fetch="https://git.mozilla.org/external/caf" name="caf"/>
+  <!--original fetch url was http://android.git.linaro.org/git-ro/-->
+  <remote fetch="https://git.mozilla.org/external/linaro" name="linaro"/>
+  <!--original fetch url was git://github.com/mozilla/-->
+  <remote fetch="https://git.mozilla.org/b2g" name="mozilla"/>
   <!--original fetch url was https://git.mozilla.org/releases-->
   <remote fetch="https://git.mozilla.org/releases" name="mozillaorg"/>
+  <!--
+    B2G repositories for all targets
+    -->
+  <project name="gaia" path="gaia" remote="mozillaorg" revision="4023297b16fdc46de3ddb04be4f3c575313d1cde"/>
+  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="35dccb3127db8f39f20b985ad312d2cd44780669"/>
+  <project name="moztt" path="external/moztt" remote="b2g" revision="99c333dab00ed79baff9e1cf76b320aee8e1c123"/>
+  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
   <!-- B2G specific things. -->
-  <project name="platform_build" path="build" remote="b2g" revision="c9d4fe680662ee44a4bdea42ae00366f5df399cf">
+  <project name="platform_build" path="build" remote="b2g" revision="be4b291a90b371b41b62ade68c31ad173bb87baa">
     <copyfile dest="Makefile" src="core/root.mk"/>
   </project>
-  <project name="gaia" path="gaia" remote="mozillaorg" revision="ad15b4f1f50f4e28170a069f049e5bdeec8d15cc"/>
   <project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
   <project name="fake-qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="939b377d55a2f081d94029a30a75d05e5a20daf3"/>
-  <project name="gonk-misc" path="gonk-misc" remote="b2g" revision="4a962bdab532e18f53e9d2d114c349983262c6b7"/>
   <project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
-  <project name="moztt" path="external/moztt" remote="b2g" revision="ac7e9ae8a24ab4a3f3da801ca53f95f39a32b89f"/>
   <project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
   <project name="valgrind" path="external/valgrind" remote="b2g" revision="5f931350fbc87c3df9db8b0ceb37734b8b471593"/>
   <project name="vex" path="external/VEX" remote="b2g" revision="48d8c7c950745f1b166b42125e6f0d3293d71636"/>
-  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="2d70fdfc0244a7217df1cfa7df9f4798cbfa3af6"/>
-  <project name="platform_hardware_libhardware_moz" path="hardware/libhardware_moz" remote="b2g" revision="fdf3a143dc777e5f9d33a88373af7ea161d3b440"/>
+  <project name="apitrace" path="external/apitrace" remote="apitrace" revision="bef0632ed8ae0e14aa535549ee472748320198ed"/>
   <!-- Stock Android things -->
   <project groups="pdk,linux" name="platform/prebuilts/clang/linux-x86/host/3.5" path="prebuilts/clang/linux-x86/host/3.5" revision="ffc05a232799fe8fcb3e47b7440b52b1fb4244c0"/>
   <project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8" path="prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8" revision="337e0ef5e40f02a1ae59b90db0548976c70a7226"/>
   <project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8" path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.8" revision="8af5ff6f5dced9eb5a8127459df6c75d24342204"/>
   <project groups="pdk,linux,arm" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8" revision="30915518fa7ea07166efedc191a4f40aef516fe7"/>
   <project groups="pdk,linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6" revision="96eee58e3389fb05a835310d6a06a6ba4486097a"/>
   <project groups="pdk,linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8" revision="7c8a46698171aa2e0be09edb43d15a6acf832770"/>
   <project groups="pdk,linux,x86" name="platform/prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.8" path="prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.8" revision="24b2038be8a636fd4a5d21f0abae1e466b07bcf7"/>
@@ -118,43 +128,43 @@
   <project name="platform/external/zopfli" path="external/zopfli" revision="8b994159cf3fc74a58e42fca72bc6849e6027912"/>
   <project name="platform/frameworks/native" path="frameworks/native" revision="c39bd4ee1f4b3ef92bf7a45824b77703f40a5fd4"/>
   <project name="platform/frameworks/opt/emoji" path="frameworks/opt/emoji" revision="2293192ed15b88ebe962fb5377dd197200e6472b"/>
   <project name="platform/hardware/libhardware" path="hardware/libhardware" revision="f5feb2aa2047fbaf13be448fe8d06bff3ccf7b84"/>
   <project name="platform/hardware/libhardware_legacy" path="hardware/libhardware_legacy" revision="8d075b4d5e9e032b18fbc8b5def63827d1b4a30d"/>
   <project name="platform/libcore" path="libcore" revision="bdec7d684c083760bef7bc4ba2429cceccaaf7d0"/>
   <project name="platform/libnativehelper" path="libnativehelper" revision="27bcc086236cedd31c056303e255c6d0ea3d4a50"/>
   <project name="platform/ndk" path="ndk" revision="42e85f81cc6c74af145056ee80b06e520cccb9a7"/>
-  <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="179d485578c6907c0daf343a3bd7bc53b5e137a1"/>
+  <project name="platform_prebuilts_misc" path="prebuilts/misc" remote="b2g" revision="25b96077aeae7bd0e3a5e7c284fb636664337013"/>
   <project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="1d080491f26dfdfd76d5bbc3e6b40c660e8565af"/>
   <project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="61a10cbd19d6b7fc052a8cb92dfa1b37b93754f3"/>
   <project name="platform/prebuilts/tools" path="prebuilts/tools" revision="9e892a67a01671f312c76b0880dedaa6ba478148"/>
-  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="570531db9e81a871c421b27025ae558022b1015a"/>
+  <project name="platform_system_bluetoothd" path="system/bluetoothd" remote="b2g" revision="bb356d6505f914347690c8143dbd03af427dd07e"/>
   <project name="platform/system/extras" path="system/extras" revision="47fa016e2248b80aebd5928402c7409f8e0ca64e"/>
   <project name="platform_system_libfdio" path="system/libfdio" remote="b2g" revision="34adfb400e031f3dd3353d92413572db5e3a7376"/>
   <project name="platform/system/media" path="system/media" revision="70bfebc66d9c6a4c614a8c7efde90e8e7e1d8641"/>
   <project name="platform/system/netd" path="system/netd" revision="d113f0ceefa9ce29eb3c86e2d23c7417a70b4048"/>
   <project name="platform/system/security" path="system/security" revision="94e1617f6f2bc2286d005e79cffa6bf0721b06b3"/>
   <project name="platform/system/vold" path="system/vold" revision="c065e301e38ea0c241164e2a373e1ecefbeaf2ec"/>
-  <project name="platform_frameworks_av" path="frameworks/av" remote="b2g" revision="6971327dda6bead878724ac1c767ee2d23a2a9e1"/>
-  <project name="platform_frameworks_base" path="frameworks/base" remote="b2g" revision="04e26ebdc36ca83f4ee3e9e2082b3fcf04c5b971"/>
-  <project name="platform_frameworks_wilhelm" path="frameworks/wilhelm" remote="b2g" revision="0dbf5baafadf6d233c0a29e392fa3293f0121673"/>
-  <project name="platform_system_core" path="system/core" remote="b2g" revision="f594bc64eacac490857748b1139ffcb34c856bbd"/>
-  <project name="platform_external_sepolicy" path="external/sepolicy" remote="b2g" revision="3f6be48a46c54dd8cacaf216ab5b145de5ffefd2"/>
+  <project name="platform_frameworks_av" path="frameworks/av" remote="b2g" revision="479a404164986b3e95212eecdae7e67da4fba9ed"/>
+  <project name="platform_frameworks_base" path="frameworks/base" remote="b2g" revision="396b731dbccc62f272f1fdb8228109c3fbd83c25"/>
+  <project name="platform_frameworks_wilhelm" path="frameworks/wilhelm" remote="b2g" revision="174bb44bb9af7583e6337e1e1b6cc18d0217ae82"/>
+  <project name="platform_system_core" path="system/core" remote="b2g" revision="1b8322b228f717ff2a4d48fa8b44240d8e3f62bc"/>
+  <project name="platform_external_sepolicy" path="external/sepolicy" remote="b2g" revision="246c603d9fe181fa8893af7293dbc63e870fe5e0"/>
   <default remote="caf" revision="refs/tags/android-5.1.0_r1" sync-j="4"/>
   <!-- Nexus 5 specific things -->
   <project name="device/generic/armv7-a-neon" path="device/generic/armv7-a-neon" revision="fe7df1bc8dd0fd71571505d7be1c31a4ad1e40fb"/>
-  <project name="device-hammerhead" path="device/lge/hammerhead" remote="b2g" revision="1401762a4eea0b92141e8ff3100f93e9d6556fc8"/>
+  <project name="device-hammerhead" path="device/lge/hammerhead" remote="b2g" revision="c4e9ed9053fbd21f57a7f014aaf898ac72ee1077"/>
   <project name="device_lge_hammerhead-kernel" path="device/lge/hammerhead-kernel" remote="b2g" revision="8b3ffcfdd3d3852eca5488628f8bb2a08acbffa7"/>
   <project name="platform/external/libnfc-nci" path="external/libnfc-nci" revision="5d0ae53d9588c3d70c005aec9be94af9a534de16"/>
   <project name="platform/external/wpa_supplicant_8" path="external/wpa_supplicant_8" revision="c15b6e266136cd0cdd9b94d0bbed1962d9dd6672"/>
   <project name="platform/hardware/broadcom/libbt" path="hardware/broadcom/libbt" revision="399fe3d3c8f38c599a56becddc456133e62a5d70"/>
   <project name="platform/hardware/broadcom/wlan" path="hardware/broadcom/wlan" revision="3f3134d5cb19d5ace48d36d0100467a545d430eb"/>
   <project name="platform/hardware/qcom/audio" path="hardware/qcom/audio" revision="810c3dd29d009822a71eba9910e429a9ad114533"/>
-  <project name="hardware_qcom_display" path="hardware/qcom/display" remote="b2g" revision="d8a56d7215bd26a61e43dcde20e64826a5fec265"/>
+  <project name="hardware_qcom_display" path="hardware/qcom/display" remote="b2g" revision="7b5967bbd90cb193b489d8f8668bc945384bd9b1"/>
   <project name="platform/hardware/qcom/keymaster" path="hardware/qcom/keymaster" revision="eaede9f8bc206736a889bc57817047c31e205589"/>
   <project name="platform/hardware/qcom/media" path="hardware/qcom/media" revision="12364db20d6710f0003a4f00962c9790ad3c13e3"/>
   <project name="platform/hardware/qcom/msm8x74" path="hardware/qcom/msm8x74" revision="f09920b2b488cf68bcbe9f7bbbde84a509a1d7a5"/>
   <project name="platform/hardware/qcom/power" path="hardware/qcom/power" revision="29e9aeaf278b16fea4cb1ab4d05b8b8c9083c15b"/>
   <project name="platform/hardware/qcom/sensors" path="hardware/qcom/sensors" revision="fde83fdf67e9b919f8a49008725bd595221bf33f"/>
   <project name="platform/hardware/qcom/wlan" path="hardware/qcom/wlan" revision="6417804bea95f6e46094a01a06025a86e28c5b0d"/>
   <project name="platform/hardware/ril" path="hardware/ril" revision="e00d716e7e3d31729f75399855b6921e90cb0b66"/>
   <project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="5f4b68c799927b6e078f987b12722c3a6ccd4a45"/>
deleted file mode 100644
--- a/b2g/config/tooltool-manifests/linux64/releng.manifest
+++ /dev/null
@@ -1,31 +0,0 @@
-[
-{
-"size": 80458572,
-"digest": "e5101f9dee1e462f6cbd3897ea57eede41d23981825c7b20d91d23ab461875d54d3dfc24999aa58a31e8b01f49fb3140e05ffe5af2957ef1d1afb89fd0dfe1ad",
-"algorithm": "sha512",
-"filename": "gcc.tar.xz",
-"unpack": true
-},
-{
-"size": 12057960,
-"digest": "6105d6432943141cffb40020dc5ba3a793650bdeb3af9bd5e56d3796c5f03df9962a73e521646cd71fbfb5e266c1e74716ad722fb6055589dfb7d35175bca89e",
-"algorithm": "sha512",
-"filename": "gtk3.tar.xz",
-"setup": "setup.sh",
-"unpack": true
-},
-{
-"size": 167175,
-"digest": "0b71a936edf5bd70cf274aaa5d7abc8f77fe8e7b5593a208f805cc9436fac646b9c4f0b43c2b10de63ff3da671497d35536077ecbc72dba7f8159a38b580f831",
-"algorithm": "sha512",
-"filename": "sccache.tar.bz2",
-"unpack": true
-},
-{
-"size": 31078810,
-"digest": "2dffe4e5419a0c0c9908dc52b01cc07379a42e2aa8481be7a26bb8750b586b95bbac3fe57e64f5d37b43e206516ea70ad938a2e45858fdcf1e28258e70ae8d8c",
-"algorithm": "sha512",
-"filename": "moz-tt.tar.bz2",
-"unpack": true
-}
-]
--- a/b2g/confvars.sh
+++ b/b2g/confvars.sh
@@ -1,30 +1,29 @@
 # 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/.
 
 MOZ_APP_BASENAME=B2G
 MOZ_APP_VENDOR=Mozilla
 
-MOZ_APP_VERSION=45.0a2
+MOZ_APP_VERSION=46.0a1
 MOZ_APP_UA_NAME=Firefox
 
 MOZ_UA_OS_AGNOSTIC=1
 
 MOZ_B2G_VERSION=2.6.0.0-prerelease
 MOZ_B2G_OS_NAME=Boot2Gecko
 
 MOZ_BRANDING_DIRECTORY=b2g/branding/unofficial
 MOZ_OFFICIAL_BRANDING_DIRECTORY=b2g/branding/official
 # MOZ_APP_DISPLAYNAME is set by branding/configure.sh
 
 MOZ_SAFE_BROWSING=1
 MOZ_SERVICES_COMMON=1
-MOZ_SERVICES_METRICS=1
 
 MOZ_WEBSMS_BACKEND=1
 MOZ_NO_SMART_CARDS=1
 MOZ_APP_STATIC_INI=1
 NSS_DISABLE_DBM=1
 MOZ_NO_EV_CERTS=1
 MOZ_DISABLE_EXPORT_JS=1
 
--- a/b2g/dev/config/tooltool-manifests/linux64/releng.manifest
+++ b/b2g/dev/config/tooltool-manifests/linux64/releng.manifest
@@ -10,18 +10,18 @@
 "size": 12057960,
 "digest": "6105d6432943141cffb40020dc5ba3a793650bdeb3af9bd5e56d3796c5f03df9962a73e521646cd71fbfb5e266c1e74716ad722fb6055589dfb7d35175bca89e",
 "algorithm": "sha512",
 "filename": "gtk3.tar.xz",
 "setup": "setup.sh",
 "unpack": true
 },
 {
-"size": 73029932,
-"digest": "ef1818acf065838dcb72554e521f9fd7098f0a3690cb6a3106d7bf18f46c342bfdd5a2b7d86e92ee3ddb9e478380343e58ecf8fd242807b8881a2d53fbec5ab3",
+"size": 80164520,
+"digest": "26fd5301aaf6174a0e4f2ac3a8d19f39573f78a051aa78e876c065d60421b2b62207c11fbf1f20f92ba61acc4b9ce58d05409bf5af886943891b04c3d22f5e04",
 "algorithm": "sha512",
 "filename": "rustc.tar.xz",
 "unpack": true
 },
 {
 "size": 167175,
 "digest": "0b71a936edf5bd70cf274aaa5d7abc8f77fe8e7b5593a208f805cc9436fac646b9c4f0b43c2b10de63ff3da671497d35536077ecbc72dba7f8159a38b580f831",
 "algorithm": "sha512",
--- a/b2g/gaia/Makefile.in
+++ b/b2g/gaia/Makefile.in
@@ -14,9 +14,9 @@ GAIA_OPTIONS := $(if MOZ_B2GDROID, \
 
 GENERATED_DIRS += $(DIST)/bin/$(GAIA_PATH)
 
 include $(topsrcdir)/config/rules.mk
 
 libs::
 	+$(MAKE) -j1 -C $(GAIADIR) clean
 	+$(GAIA_OPTIONS) $(MAKE) -j1 -C $(GAIADIR) profile
-	(cd $(GAIADIR)/profile && tar $(TAR_CREATE_FLAGS) - .) | (cd $(abspath $(DIST))/bin/$(GAIA_PATH) && tar -xf -)
+	(cd $(GAIADIR)/profile && tar $(TAR_CREATE_FLAGS) - .) | (cd $(ABS_DIST)/bin/$(GAIA_PATH) && tar -xf -)
--- a/b2g/graphene/app.mozbuild
+++ b/b2g/graphene/app.mozbuild
@@ -9,9 +9,9 @@ if CONFIG['MOZ_EXTENSIONS']:
     DIRS += ['/extensions']
 
 DIRS += [
     '/%s' % CONFIG['MOZ_BRANDING_DIRECTORY'],
     '/b2g',
 ]
 
 # Add the defaults settings.
-FINAL_TARGET_FILES.defaults += [ 'b2g/graphene/settings.json' ]
+FINAL_TARGET_FILES.defaults += [ 'settings.json' ]
--- a/b2g/graphene/confvars.sh
+++ b/b2g/graphene/confvars.sh
@@ -21,17 +21,16 @@ MOZ_B2G_VERSION=2.6.0.0-prerelease
 MOZ_B2G_OS_NAME=Boot2Gecko
 
 MOZ_BRANDING_DIRECTORY=b2g/branding/unofficial
 MOZ_OFFICIAL_BRANDING_DIRECTORY=b2g/branding/official
 # MOZ_APP_DISPLAYNAME is set by branding/configure.sh
 
 MOZ_SAFE_BROWSING=1
 MOZ_SERVICES_COMMON=1
-MOZ_SERVICES_METRICS=1
 MOZ_CAPTIVEDETECT=1
 
 MOZ_WEBSMS_BACKEND=1
 MOZ_NO_SMART_CARDS=1
 MOZ_APP_STATIC_INI=1
 NSS_NO_LIBPKIX=1
 NSS_DISABLE_DBM=1
 MOZ_DISABLE_EXPORT_JS=1
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -23,20 +23,16 @@
 @RESPATH@/@LPROJ_ROOT@.lproj/*
 #endif
 
 [@AB_CD@]
 @RESPATH@/chrome/@AB_CD@@JAREXT@
 @RESPATH@/chrome/@AB_CD@.manifest
 @RESPATH@/@PREF_DIR@/b2g-l10n.js
 @RESPATH@/searchplugins/*
-@RESPATH@/defaults/profile/bookmarks.html
-@RESPATH@/defaults/profile/localstore.rdf
-@RESPATH@/defaults/profile/mimeTypes.rdf
-@RESPATH@/defaults/profile/chrome/*
 #ifdef MOZ_UPDATER
 @RESPATH@/update.locale
 @RESPATH@/updater.ini
 #endif
 @RESPATH@/dictionaries/*
 @RESPATH@/hyphenation/*
 #ifdef XP_WIN32
 @BINPATH@/uninstall/helper.exe
@@ -626,35 +622,33 @@
 #ifdef MOZ_SERVICES_SYNC
 @RESPATH@/components/SyncComponents.manifest
 @RESPATH@/components/Weave.js
 @RESPATH@/components/WeaveCrypto.manifest
 @RESPATH@/components/WeaveCrypto.js
 #endif
 @RESPATH@/components/servicesComponents.manifest
 @RESPATH@/components/cryptoComponents.manifest
-#ifdef MOZ_SERVICES_HEALTHREPORT
-@RESPATH@/components/HealthReportComponents.manifest
-@RESPATH@/components/HealthReportService.js
-#endif
 @RESPATH@/components/CaptivePortalDetectComponents.manifest
 @RESPATH@/components/captivedetect.js
 @RESPATH@/components/TelemetryStartup.js
 @RESPATH@/components/TelemetryStartup.manifest
 @RESPATH@/components/XULStore.js
 @RESPATH@/components/XULStore.manifest
 @RESPATH@/components/Webapps.js
 @RESPATH@/components/Webapps.manifest
 @RESPATH@/components/AppsService.js
 @RESPATH@/components/AppsService.manifest
 @RESPATH@/components/Push.js
 @RESPATH@/components/Push.manifest
-@RESPATH@/components/PushClient.js
-@RESPATH@/components/PushNotificationService.js
+#ifdef MOZ_SIMPLEPUSH
 @RESPATH@/components/PushServiceLauncher.js
+#else
+@RESPATH@/components/PushComponents.js
+#endif
 
 @RESPATH@/components/InterAppComm.manifest
 @RESPATH@/components/InterAppCommService.js
 @RESPATH@/components/InterAppConnection.js
 @RESPATH@/components/InterAppMessagePort.js
 
 @RESPATH@/components/nsDOMIdentity.js
 @RESPATH@/components/nsIDService.js
@@ -761,17 +755,16 @@
 #ifdef MOZ_MULET
 @RESPATH@/browser/@PREF_DIR@/b2g.js
 #else
 @RESPATH@/@PREF_DIR@/b2g.js
 #endif
 @RESPATH@/@PREF_DIR@/channel-prefs.js
 @RESPATH@/greprefs.js
 @RESPATH@/defaults/autoconfig/prefcalls.js
-@RESPATH@/defaults/profile/prefs.js
 
 ; Services (gre) prefs
 #ifdef MOZ_SERVICES_SYNC
 @RESPATH@/defaults/pref/services-sync.js
 #endif
 
 ; [Layout Engine Resources]
 ; Style Sheets, Graphics and other Resources used by the layout engine.
@@ -806,28 +799,16 @@
 @RESPATH@/res/accessiblecaret_tilt_left.png
 @RESPATH@/res/accessiblecaret_tilt_left@1.5x.png
 @RESPATH@/res/accessiblecaret_tilt_left@2.25x.png
 @RESPATH@/res/accessiblecaret_tilt_left@2x.png
 @RESPATH@/res/accessiblecaret_tilt_right.png
 @RESPATH@/res/accessiblecaret_tilt_right@1.5x.png
 @RESPATH@/res/accessiblecaret_tilt_right@2.25x.png
 @RESPATH@/res/accessiblecaret_tilt_right@2x.png
-@RESPATH@/res/text_caret.png
-@RESPATH@/res/text_caret@1.5x.png
-@RESPATH@/res/text_caret@2.25x.png
-@RESPATH@/res/text_caret@2x.png
-@RESPATH@/res/text_caret_tilt_left.png
-@RESPATH@/res/text_caret_tilt_left@1.5x.png
-@RESPATH@/res/text_caret_tilt_left@2.25x.png
-@RESPATH@/res/text_caret_tilt_left@2x.png
-@RESPATH@/res/text_caret_tilt_right.png
-@RESPATH@/res/text_caret_tilt_right@1.5x.png
-@RESPATH@/res/text_caret_tilt_right@2.25x.png
-@RESPATH@/res/text_caret_tilt_right@2x.png
 @RESPATH@/res/grabber.gif
 #ifdef XP_MACOSX
 @RESPATH@/res/cursors/*
 #endif
 @RESPATH@/res/fonts/*
 @RESPATH@/res/dtd/*
 @RESPATH@/res/html/*
 @RESPATH@/res/language.properties
--- a/b2g/locales/Makefile.in
+++ b/b2g/locales/Makefile.in
@@ -14,55 +14,55 @@ SUBMAKEFILES += \
 # build non-default locales to non-default dist/ locations. Be aware!
 
 PWD := $(CURDIR)
 
 # These are defaulted to be compatible with the files the wget-en-US target
 # pulls. You may override them if you provide your own files. You _must_
 # override them when MOZ_PKG_PRETTYNAMES is defined - the defaults will not
 # work in that case.
-ZIP_IN ?= $(_ABS_DIST)/$(PACKAGE)
-WIN32_INSTALLER_IN ?= $(_ABS_DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe
+ZIP_IN ?= $(ABS_DIST)/$(PACKAGE)
+WIN32_INSTALLER_IN ?= $(ABS_DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe
 RETRIEVE_WINDOWS_INSTALLER = 1
 
 MOZ_LANGPACK_EID=langpack-$(AB_CD)@b2g.mozilla.org
 
 L10N_PREF_JS_EXPORTS = $(call MERGE_FILE,b2g-l10n.js)
 L10N_PREF_JS_EXPORTS_PATH = $(FINAL_TARGET)/$(PREF_DIR)
 L10N_PREF_JS_EXPORTS_FLAGS = $(PREF_PPFLAGS) --silence-missing-directive-warnings
 PP_TARGETS += L10N_PREF_JS_EXPORTS
 
 ifneq (,$(filter cocoa,$(MOZ_WIDGET_TOOLKIT)))
-MOZ_PKG_MAC_DSSTORE=$(_ABS_DIST)/branding/dsstore
-MOZ_PKG_MAC_BACKGROUND=$(_ABS_DIST)/branding/background.png
-MOZ_PKG_MAC_ICON=$(_ABS_DIST)/branding/disk.icns
+MOZ_PKG_MAC_DSSTORE=$(ABS_DIST)/branding/dsstore
+MOZ_PKG_MAC_BACKGROUND=$(ABS_DIST)/branding/background.png
+MOZ_PKG_MAC_ICON=$(ABS_DIST)/branding/disk.icns
 MOZ_PKG_MAC_EXTRA=--symlink '/Applications:/ '
 endif
 
 ifeq (WINNT,$(OS_ARCH))
 UNINSTALLER_PACKAGE_HOOK = $(RM) -r $(STAGEDIST)/uninstall; \
     $(NSINSTALL) -D $(STAGEDIST)/uninstall; \
     cp ../installer/windows/l10ngen/helper.exe $(STAGEDIST)/uninstall; \
-    $(RM) $(_ABS_DIST)/l10n-stage/setup.exe; \
-    cp ../installer/windows/l10ngen/setup.exe $(_ABS_DIST)/l10n-stage; \
+    $(RM) $(ABS_DIST)/l10n-stage/setup.exe; \
+    cp ../installer/windows/l10ngen/setup.exe $(ABS_DIST)/l10n-stage; \
     $(NULL)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 include $(topsrcdir)/toolkit/locales/l10n.mk
 
 $(STAGEDIST): $(DIST)/branding
 
 $(DIST)/branding:
 	$(NSINSTALL) -D $@
 
 libs::
 	@if test -f '$(LOCALE_SRCDIR)/existing-profile-defaults.js'; then \
-	  $(PYTHON) -m mozbuild.action.preprocessor $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(MOZ_DEBUG_DEFINES) \
+	  $(PYTHON) -m mozbuild.action.preprocessor $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) \
 	    $(LOCALE_SRCDIR)/existing-profile-defaults.js -o $(FINAL_TARGET)/defaults/existing-profile-defaults.js; \
 	fi
 
 NO_JA_JP_MAC_AB_CD := $(if $(filter ja-JP-mac, $(AB_CD)),ja,$(AB_CD))
 
 libs-%:
 	$(NSINSTALL) -D $(DIST)/install
 	@$(MAKE) -C ../../toolkit/locales libs-$*
@@ -70,17 +70,17 @@ libs-%:
 	@$(MAKE) libs AB_CD=$* XPI_NAME=locale-$* PREF_DIR=$(PREF_DIR)
 	@$(MAKE) -C $(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales AB_CD=$* XPI_NAME=locale-$*
 
 # Tailored target to just add the chrome processing for multi-locale builds
 chrome-%:
 	@$(MAKE) chrome AB_CD=$*
 	@$(MAKE) -C $(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales chrome AB_CD=$*
 
-repackage-win32-installer: WIN32_INSTALLER_OUT=$(_ABS_DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe
+repackage-win32-installer: WIN32_INSTALLER_OUT=$(ABS_DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe
 repackage-win32-installer: $(call ESCAPE_SPACE,$(WIN32_INSTALLER_IN)) $(SUBMAKEFILES) libs-$(AB_CD)
 	@echo 'Repackaging $(WIN32_INSTALLER_IN) into $(WIN32_INSTALLER_OUT).'
 	$(MAKE) -C $(DEPTH)/$(MOZ_BRANDING_DIRECTORY) export
 	$(MAKE) -C ../installer/windows CONFIG_DIR=l10ngen l10ngen/setup.exe l10ngen/7zSD.sfx
 	$(MAKE) repackage-zip \
 	  AB_CD=$(AB_CD) \
 	  MOZ_PKG_FORMAT=SFX7Z \
 	  ZIP_IN='$(WIN32_INSTALLER_IN)' \
--- a/browser/app/Makefile.in
+++ b/browser/app/Makefile.in
@@ -85,23 +85,23 @@ endif
 LPROJ := Contents/Resources/$(LPROJ_ROOT).lproj
 
 clean clobber repackage::
 	$(RM) -r $(dist_dest)
 
 MAC_BUNDLE_VERSION = $(shell $(PYTHON) $(srcdir)/macversion.py --version=$(MOZ_APP_VERSION) --buildid=$(DEPTH)/config/buildid)
 
 .PHONY: repackage
-tools repackage:: $(PROGRAM)
+tools repackage:: $(DIST)/bin/$(MOZ_APP_NAME)
 	$(MKDIR) -p $(dist_dest)/Contents/MacOS
 	$(MKDIR) -p $(dist_dest)/$(LPROJ)
 	rsync -a --exclude '*.in' $(srcdir)/macbuild/Contents $(dist_dest) --exclude English.lproj
 	rsync -a --exclude '*.in' $(srcdir)/macbuild/Contents/Resources/English.lproj/ $(dist_dest)/$(LPROJ)
 	sed -e 's/%APP_VERSION%/$(MOZ_APP_VERSION)/' -e 's/%MAC_APP_NAME%/$(MAC_APP_NAME)/' -e 's/%MOZ_MACBUNDLE_ID%/$(MOZ_MACBUNDLE_ID)/' -e 's/%MAC_BUNDLE_VERSION%/$(MAC_BUNDLE_VERSION)/' $(srcdir)/macbuild/Contents/Info.plist.in > $(dist_dest)/Contents/Info.plist
 	sed -e 's/%MAC_APP_NAME%/$(MAC_APP_NAME)/' $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | iconv -f UTF-8 -t UTF-16 > $(dist_dest)/$(LPROJ)/InfoPlist.strings
 	rsync -a --exclude-from='$(srcdir)/macbuild/Contents/MacOS-files.in' $(DIST)/bin/ $(dist_dest)/Contents/Resources
 	rsync -a --include-from='$(srcdir)/macbuild/Contents/MacOS-files.in' --exclude '*' $(DIST)/bin/ $(dist_dest)/Contents/MacOS
-	$(RM) $(dist_dest)/Contents/MacOS/$(PROGRAM)
-	rsync -aL $(PROGRAM) $(dist_dest)/Contents/MacOS
+	$(RM) $(dist_dest)/Contents/MacOS/$(MOZ_APP_NAME)
+	rsync -aL $(DIST)/bin/$(MOZ_APP_NAME) $(dist_dest)/Contents/MacOS
 	cp -RL $(DIST)/branding/firefox.icns $(dist_dest)/Contents/Resources/firefox.icns
 	cp -RL $(DIST)/branding/document.icns $(dist_dest)/Contents/Resources/document.icns
 	printf APPLMOZB > $(dist_dest)/Contents/PkgInfo
 endif
--- a/browser/app/firefox.exe.manifest
+++ b/browser/app/firefox.exe.manifest
@@ -23,17 +23,17 @@
   <ms_asmv3:security>
     <ms_asmv3:requestedPrivileges>
       <ms_asmv3:requestedExecutionLevel level="asInvoker" uiAccess="false" />
     </ms_asmv3:requestedPrivileges>
   </ms_asmv3:security>
 </ms_asmv3:trustInfo>
   <ms_asmv3:application xmlns:ms_asmv3="urn:schemas-microsoft-com:asm.v3">
     <ms_asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
-      <dpiAware>true</dpiAware>
+      <dpiAware>True/PM</dpiAware>
     </ms_asmv3:windowsSettings>
   </ms_asmv3:application>
   <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
     <application>
       <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
       <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
       <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
       <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -947,27 +947,27 @@ pref("gecko.handlerService.schemes.ircs.
 pref("gecko.handlerService.allowRegisterFromDifferentHost", false);
 
 #ifdef MOZ_SAFE_BROWSING
 pref("browser.safebrowsing.enabled", true);
 pref("browser.safebrowsing.malware.enabled", true);
 pref("browser.safebrowsing.downloads.enabled", true);
 pref("browser.safebrowsing.downloads.remote.enabled", true);
 pref("browser.safebrowsing.downloads.remote.timeout_ms", 10000);
+pref("browser.safebrowsing.downloads.remote.url", "https://sb-ssl.google.com/safebrowsing/clientreport/download?key=%GOOGLE_API_KEY%");
 pref("browser.safebrowsing.debug", false);
 
 pref("browser.safebrowsing.provider.google.lists", "goog-badbinurl-shavar,goog-downloadwhite-digest256,goog-phish-shavar,goog-malware-shavar,goog-unwanted-shavar");
 pref("browser.safebrowsing.provider.google.updateURL", "https://safebrowsing.google.com/safebrowsing/downloads?client=SAFEBROWSING_ID&appver=%VERSION%&pver=2.2&key=%GOOGLE_API_KEY%");
 pref("browser.safebrowsing.provider.google.gethashURL", "https://safebrowsing.google.com/safebrowsing/gethash?client=SAFEBROWSING_ID&appver=%VERSION%&pver=2.2");
 pref("browser.safebrowsing.provider.google.reportURL", "https://safebrowsing.google.com/safebrowsing/diagnostic?client=%NAME%&hl=%LOCALE%&site=");
 
 pref("browser.safebrowsing.reportPhishMistakeURL", "https://%LOCALE%.phish-error.mozilla.com/?hl=%LOCALE%&url=");
 pref("browser.safebrowsing.reportPhishURL", "https://%LOCALE%.phish-report.mozilla.com/?hl=%LOCALE%&url=");
 pref("browser.safebrowsing.reportMalwareMistakeURL", "https://%LOCALE%.malware-error.mozilla.com/?hl=%LOCALE%&url=");
-pref("browser.safebrowsing.appRepURL", "https://sb-ssl.google.com/safebrowsing/clientreport/download?key=%GOOGLE_API_KEY%");
 
 #ifdef MOZILLA_OFFICIAL
 // Normally the "client ID" sent in updates is appinfo.name, but for
 // official Firefox releases from Mozilla we use a special identifier.
 pref("browser.safebrowsing.id", "navclient-auto-ffox");
 #endif
 
 // Name of the about: page contributed by safebrowsing to handle display of error
@@ -1317,23 +1317,23 @@ sticky_pref("lightweightThemes.selectedT
 #endif
 
 // Whether the character encoding menu is under the main Firefox button. This
 // preference is a string so that localizers can alter it.
 pref("browser.menu.showCharacterEncoding", "chrome://browser/locale/browser.properties");
 
 // Allow using tab-modal prompts when possible.
 pref("prompts.tab_modal.enabled", true);
-// Whether the Panorama should animate going in/out of tabs
-pref("browser.panorama.animate_zoom", true);
 
 // Activates preloading of the new tab url.
 pref("browser.newtab.preload", true);
 
 // Remembers if the about:newtab intro has been shown
+// NOTE: This preference is unused but was not removed in case
+//       this information will be valuable in the future.
 pref("browser.newtabpage.introShown", false);
 
 // Toggles the content of 'about:newtab'. Shows the grid when enabled.
 pref("browser.newtabpage.enabled", true);
 
 // Toggles the enhanced content of 'about:newtab'. Shows sponsored tiles.
 sticky_pref("browser.newtabpage.enhanced", true);
 
@@ -1344,20 +1344,18 @@ pref("browser.newtabpage.rows", 3);
 pref("browser.newtabpage.columns", 5);
 
 // directory tiles download URL
 pref("browser.newtabpage.directory.source", "https://tiles.services.mozilla.com/v3/links/fetch/%LOCALE%/%CHANNEL%");
 
 // endpoint to send newtab click and view pings
 pref("browser.newtabpage.directory.ping", "https://tiles.services.mozilla.com/v3/links/");
 
-#ifndef RELEASE_BUILD
-// if true, it activates the remote-hosted newtab page
+// activates the remote-hosted newtab page
 pref("browser.newtabpage.remote", false);
-#endif
 
 // Enable the DOM fullscreen API.
 pref("full-screen-api.enabled", true);
 
 // Startup Crash Tracking
 // number of startup crashes that can occur before starting into safe mode automatically
 // (this pref has no effect if more than 6 hours have passed since the last crash)
 pref("toolkit.startup.max_resumed_crashes", 3);
@@ -1391,26 +1389,29 @@ pref("social.sidebar.unload_timeout_ms",
 pref("social.share.activationPanelEnabled", true);
 pref("social.shareDirectory", "https://activations.cdn.mozilla.net/sharePanel.html");
 
 pref("dom.identity.enabled", false);
 
 // Block insecure active content on https pages
 pref("security.mixed_content.block_active_content", true);
 
-// Show degraded UI for http pages with password fields
-#ifdef NIGHTLY_BUILD
+// Show degraded UI for http pages with password fields.
+// Only for Nightly and Dev Edition for not, not for beta or release.
+#ifndef RELEASE_BUILD
 pref("security.insecure_password.ui.enabled", true);
 #else
 pref("security.insecure_password.ui.enabled", false);
 #endif
 
 // 1 = allow MITM for certificate pinning checks.
 pref("security.cert_pinning.enforcement_level", 1);
 
+// NB: Changes to this pref affect CERT_CHAIN_SHA1_POLICY_STATUS telemetry.
+// See the comment in CertVerifier.cpp.
 // 0 = allow SHA-1
 pref("security.pki.sha1_enforcement_level", 0);
 
 // Required blocklist freshness for OneCRL OCSP bypass
 // (default is 1.25x extensions.blocklist.interval, or 30 hours)
 pref("security.onecrl.maximum_staleness_in_seconds", 108000);
 
 // Override the Gecko-default value of false for Firefox.
@@ -1445,24 +1446,24 @@ pref("network.disable.ipc.security", tru
 
 // CustomizableUI debug logging.
 pref("browser.uiCustomization.debug", false);
 
 // CustomizableUI state of the browser's user interface
 pref("browser.uiCustomization.state", "");
 
 // The remote content URL shown for FxA signup. Must use HTTPS.
-pref("identity.fxaccounts.remote.signup.uri", "https://accounts.firefox.com/signup?service=sync&context=fx_desktop_v2");
+pref("identity.fxaccounts.remote.signup.uri", "https://accounts.firefox.com/signup?service=sync&context=fx_desktop_v3");
 
 // The URL where remote content that forces re-authentication for Firefox Accounts
 // should be fetched.  Must use HTTPS.
-pref("identity.fxaccounts.remote.force_auth.uri", "https://accounts.firefox.com/force_auth?service=sync&context=fx_desktop_v2");
+pref("identity.fxaccounts.remote.force_auth.uri", "https://accounts.firefox.com/force_auth?service=sync&context=fx_desktop_v3");
 
 // The remote content URL shown for signin in. Must use HTTPS.
-pref("identity.fxaccounts.remote.signin.uri", "https://accounts.firefox.com/signin?service=sync&context=fx_desktop_v2");
+pref("identity.fxaccounts.remote.signin.uri", "https://accounts.firefox.com/signin?service=sync&context=fx_desktop_v3");
 
 // The remote content URL where FxAccountsWebChannel messages originate.
 pref("identity.fxaccounts.remote.webchannel.uri", "https://accounts.firefox.com/");
 
 // The URL we take the user to when they opt to "manage" their Firefox Account.
 // Note that this will always need to be in the same TLD as the
 // "identity.fxaccounts.remote.signup.uri" pref.
 pref("identity.fxaccounts.settings.uri", "https://accounts.firefox.com/settings");
@@ -1544,20 +1545,19 @@ pref("experiments.enabled", true);
 pref("experiments.manifest.fetchIntervalSeconds", 86400);
 pref("experiments.manifest.uri", "https://telemetry-experiment.cdn.mozilla.net/manifest/v1/firefox/%VERSION%/%CHANNEL%");
 // Whether experiments are supported by the current application profile.
 pref("experiments.supported", true);
 
 // Enable GMP support in the addon manager.
 pref("media.gmp-provider.enabled", true);
 
-pref("browser.apps.URL", "https://marketplace.firefox.com/discovery/");
-
 #ifdef NIGHTLY_BUILD
-pref("browser.polaris.enabled", false);
+pref("privacy.trackingprotection.ui.enabled", true);
+#else
 pref("privacy.trackingprotection.ui.enabled", false);
 #endif
 pref("privacy.trackingprotection.introCount", 0);
 pref("privacy.trackingprotection.introURL", "https://www.mozilla.org/%LOCALE%/firefox/%VERSION%/tracking-protection/start/");
 
 // Enable Contextual Identity Containers
 pref("privacy.userContext.enabled", false);
 
@@ -1570,21 +1570,19 @@ pref("browser.tabs.remote.autostart.2", 
 #endif
 
 // For the about:tabcrashed page
 pref("browser.tabs.crashReporting.sendReport", true);
 pref("browser.tabs.crashReporting.includeURL", false);
 pref("browser.tabs.crashReporting.emailMe", false);
 pref("browser.tabs.crashReporting.email", "");
 
-#ifdef NIGHTLY_BUILD
 #ifndef MOZ_MULET
 pref("layers.async-pan-zoom.enabled", true);
 #endif
-#endif
 
 // Enable e10s add-on interposition by default.
 pref("extensions.interposition.enabled", true);
 pref("extensions.interposition.prefetching", true);
 
 pref("browser.defaultbrowser.notificationbar", false);
 
 // How often to check for CPOW timeouts. CPOWs are only timed out by
@@ -1606,37 +1604,32 @@ pref("dom.ipc.reportProcessHangs", true)
 pref("browser.reader.detectedFirstArticle", false);
 // Don't limit how many nodes we care about on desktop:
 pref("reader.parse-node-limit", 0);
 
 // On desktop, we want the URLs to be included here for ease of debugging,
 // and because (normally) these errors are not persisted anywhere.
 pref("reader.errors.includeURLs", true);
 
-pref("browser.pocket.enabled", true);
-pref("browser.pocket.api", "api.getpocket.com");
-pref("browser.pocket.site", "getpocket.com");
-pref("browser.pocket.oAuthConsumerKey", "40249-e88c401e1b1f2242d9e441c4");
-pref("browser.pocket.useLocaleList", true);
-pref("browser.pocket.enabledLocales", "cs de en-GB en-US en-ZA es-ES es-MX fr hu it ja ja-JP-mac ko nl pl pt-BR pt-PT ru zh-CN zh-TW");
-
 pref("view_source.tab", true);
 
 pref("dom.serviceWorkers.enabled", true);
 pref("dom.serviceWorkers.interception.enabled", true);
 pref("dom.serviceWorkers.openWindow.enabled", true);
 pref("dom.webnotifications.serviceworker.enabled", true);
 
-#ifndef RELEASE_BUILD
 // Enable Push API.
 pref("dom.push.enabled", true);
-#endif
 
 // These are the thumbnail width/height set in about:newtab.
 // If you change this, ENSURE IT IS THE SAME SIZE SET
 // by about:newtab. These values are in CSS pixels.
 pref("toolkit.pageThumbs.minWidth", 280);
 pref("toolkit.pageThumbs.minHeight", 190);
 
 #ifdef NIGHTLY_BUILD
 // Enable speech synthesis, only Nightly for now
 pref("media.webspeech.synth.enabled", true);
 #endif
+
+pref("browser.esedbreader.loglevel", "Error");
+
+pref("browser.laterrun.enabled", false);
--- a/browser/base/content/aboutDialog.css
+++ b/browser/base/content/aboutDialog.css
@@ -1,14 +1,18 @@
 /* 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/. */
 
 #aboutDialog {
   width: 620px;
+  /* Set an explicit line-height to avoid discrepancies in 'auto' spacing
+     across screens with different device DPI, which may cause font metrics
+     to round differently. */
+  line-height: 1.5;
 }
 
 #rightBox {
   background-image: url("chrome://branding/content/about-wordmark.svg");
   background-repeat: no-repeat;
   /* padding-top creates room for the wordmark */
   padding-top: 38px;
   margin-top:20px;
@@ -32,16 +36,20 @@
 }
 
 #version:-moz-locale-dir(rtl) {
   direction: ltr;
   text-align: right;
   margin-right: 0;
 }
 
+#releasenotes {
+  margin-top: 10px;
+}
+
 #distribution,
 #distributionId {
   display: none;
   margin-top: 0;
   margin-bottom: 0;
 }
 
 .text-blurb {
--- a/browser/base/content/aboutDialog.xul
+++ b/browser/base/content/aboutDialog.xul
@@ -39,17 +39,23 @@
   <script type="application/javascript" src="chrome://browser/content/aboutDialog.js"/>
 #ifdef MOZ_UPDATER
   <script type="application/javascript" src="chrome://browser/content/aboutDialog-appUpdater.js"/>
 #endif
   <vbox id="aboutDialogContainer">
     <hbox id="clientBox">
       <vbox id="leftBox" flex="1"/>
       <vbox id="rightBox" flex="1">
+        <hbox align="baseline">
 #expand <label id="version">__MOZ_APP_VERSION_DISPLAY__</label>
+#ifndef NIGHTLY_BUILD
+#expand <label id="releasenotes" class="text-link" href="https://www.mozilla.org/firefox/__MOZ_APP_VERSION__/releasenotes/">&releaseNotes.link;</label>
+#endif
+        </hbox>
+
         <label id="distribution" class="text-blurb"/>
         <label id="distributionId" class="text-blurb"/>
 
         <vbox id="detailsBox">
           <vbox id="updateBox">
 #ifdef MOZ_UPDATER
             <deck id="updateDeck" orient="vertical">
               <hbox id="checkForUpdates" align="center">
--- a/browser/base/content/aboutNetError.xhtml
+++ b/browser/base/content/aboutNetError.xhtml
@@ -255,25 +255,22 @@
                 // set the checkbox
                 checkbox.checked = true;
               }
 
               checkbox.addEventListener('change', function(evt) {
                   var event = new CustomEvent("AboutNetErrorSetAutomatic",
                     {bubbles:true, detail:evt.target.checked});
                   document.dispatchEvent(event);
-                  if (evt.target.checked && reportBtn.style.display != "none") {
+                  if (evt.target.checked) {
                     sendErrorReport();
                   }
                 }, false);
 
-              var reportBtn = document.getElementById('reportCertificateError');
               var retryBtn = document.getElementById('reportCertificateErrorRetry');
-
-              reportBtn.addEventListener('click', sendErrorReport, false);
               retryBtn.addEventListener('click', sendErrorReport, false);
             }
           }
           if (getErrorCode() == "weakCryptoUsed" || getErrorCode() == "sslv3Used") {
             showAdvancedButton(getErrorCode() == "weakCryptoUsed");
           }
         }.bind(this), true, true);
 
@@ -492,17 +489,17 @@
         <!-- Override section - For ssl errors only.  Removed on init for other
              error types.  -->
         <div id="securityOverrideDiv">
           <a id="securityOverrideLink" href="javascript:showSecuritySection();" >&securityOverride.linkText;</a>
           <div id="securityOverrideContent" style="display: none;">&securityOverride.warningContent;</div>
         </div>
 
         <div id="learnMoreContainer">
-          <p><a href="https://support.mozilla.org/kb/tls-error-reports" id="learnMoreLink" target="new">&errorReporting.learnMore;</a></p>
+          <p><a href="https://support.mozilla.org/kb/what-does-your-connection-is-not-secure-mean" id="learnMoreLink" target="new">&errorReporting.learnMore;</a></p>
         </div>
 
         <div id="buttonContainer">
           <button id="returnButton" autocomplete="off" autofocus="true">&returnToPreviousPage.label;</button>
           <div id="buttonSpacer"></div>
           <button id="advancedButton" autocomplete="off" autofocus="true">&advanced.label;</button>
         </div>
       </div>
@@ -527,17 +524,16 @@
       <!-- UI for option to report certificate errors to Mozilla. Removed on
            init for other error types .-->
       <div id="certificateErrorReporting">
         <p>
           <input type="checkbox" id="automaticallyReportInFuture" />
           <label for="automaticallyReportInFuture" id="automaticallyReportInFuture">&errorReporting.automatic2;</label>
 
           <span id="reportingState">
-            <button id="reportCertificateError">&errorReporting.report;</button>
             <button id="reportCertificateErrorRetry">&errorReporting.tryAgain;</button>
             <span id="reportSendingMessage">&errorReporting.sending;</span>
             <span id="reportSentMessage">&errorReporting.sent;</span>
           </span>
         </p>
       </div>
 
       <div id="weakCryptoAdvancedPanel">
--- a/browser/base/content/aboutTabCrashed.js
+++ b/browser/base/content/aboutTabCrashed.js
@@ -161,16 +161,18 @@ var AboutTabCrashed = {
 
       let data = message.data;
       document.getElementById("sendReport").checked = data.sendReport;
       document.getElementById("includeURL").checked = data.includeURL;
       document.getElementById("emailMe").checked = data.emailMe;
       if (data.emailMe) {
         document.getElementById("email").value = data.email;
       }
+
+      this.showCrashReportUI(data.sendReport);
     }
 
     let event = new CustomEvent("AboutTabCrashedReady", {bubbles:true});
     document.dispatchEvent(event);
   },
 
   /**
    * Handler for when the parent reports that the crash report associated
--- a/browser/base/content/aboutcerterror/aboutCertError.xhtml
+++ b/browser/base/content/aboutcerterror/aboutCertError.xhtml
@@ -83,16 +83,42 @@
           host.textContent = document.location.hostname;
         }
 
         var cssClass = getCSSClass();
         if (cssClass == "expertBadCert") {
           toggleVisibility('advancedPanel');
         }
 
+        var checkbox = document.getElementById("automaticallyReportInFuture");
+        checkbox.addEventListener("change", function ({target: {checked}}) {
+          document.dispatchEvent(new CustomEvent("AboutCertErrorSetAutomatic", {
+            detail: checked,
+            bubbles: true
+          }));
+        });
+
+        var retryBtn = document.getElementById("reportCertificateErrorRetry");
+        retryBtn.addEventListener("click", function () {
+          document.dispatchEvent(new CustomEvent("AboutCertErrorSendReport", {
+            bubbles: true
+          }));
+        });
+
+        addEventListener("AboutCertErrorOptions", function (event) {
+          var options = JSON.parse(event.detail);
+          if (options && options.enabled) {
+            // Display error reporting UI
+            document.getElementById("certificateErrorReporting").style.display = "block";
+
+            // set the checkbox
+            checkbox.checked = !!options.automatic;
+          }
+        }, true, true);
+
         // Disallow overrides if this is a Strict-Transport-Security
         // host and the cert is bad (STS Spec section 7.3) or if the
         // certerror is in a frame (bug 633691).
         if (cssClass == "badStsCert" || window != top) {
           document.getElementById("exceptionDialogButton").setAttribute("hidden", "true");
         }
         if (cssClass != "badStsCert") {
           document.getElementById("badStsCertExplanation").setAttribute("hidden", "true");
@@ -241,29 +267,44 @@
       <div id="errorLongContent">
 
         <!-- Short Description -->
         <div id="errorShortDesc">
           <p>&certerror.introPara;</p>
         </div>
         <p id="badStsCertExplanation">&certerror.whatShouldIDo.badStsCertExplanation;</p>
         <div>
-          <p><a href="https://support.mozilla.org/kb/tls-error-reports" id="learnMoreLink" target="new">&certerror.learnMore;</a></p>
+          <p><a href="https://support.mozilla.org/kb/what-does-your-connection-is-not-secure-mean" id="learnMoreLink" target="new">&certerror.learnMore;</a></p>
         </div>
 
         <div id="buttonContainer">
           <button id="returnButton" autocomplete="off" autofocus="true">&certerror.returnToPreviousPage.label;</button>
           <div id="buttonSpacer"></div>
           <button id="advancedButton" autocomplete="off" onclick="toggleVisibility('advancedPanel');" autofocus="true">&certerror.advanced.label;</button>
         </div>
-        <!-- Advanced panel, which is hidden by default -->
-        <div id="advancedPanel" style="visibility: hidden;">
-          <p id="technicalContentText"/>
-          <button id="exceptionDialogButton">&certerror.addException.label;</button>
-        </div>
+      </div>
+
+      <!-- UI for option to report certificate errors to Mozilla. -->
+      <div id="certificateErrorReporting">
+        <p>
+          <input type="checkbox" id="automaticallyReportInFuture" />
+          <label for="automaticallyReportInFuture" id="automaticallyReportInFuture">&errorReporting.automatic;</label>
+
+          <span id="reportingState">
+            <button id="reportCertificateErrorRetry">&errorReporting.tryAgain;</button>
+            <span id="reportSendingMessage">&errorReporting.sending;</span>
+            <span id="reportSentMessage">&errorReporting.sent;</span>
+          </span>
+        </p>
+      </div>
+
+      <!-- Advanced panel, which is hidden by default -->
+      <div id="advancedPanel" style="visibility: hidden;">
+        <p id="technicalContentText"/>
+        <button id="exceptionDialogButton">&certerror.addException.label;</button>
       </div>
     </div>
 
     <div id="certificateErrorDebugInformation">
       <a name="technicalInformation"></a>
       <button id="copyToClipboard">&certerror.copyToClipboard.label;</button>
       <div id="certificateErrorText"/>
       <button id="copyToClipboard">&certerror.copyToClipboard.label;</button>
--- a/browser/base/content/abouthealthreport/abouthealth.js
+++ b/browser/base/content/abouthealthreport/abouthealth.js
@@ -18,20 +18,16 @@ const PREF_UNIFIED_OPTIN = "toolkit.tele
 const IS_V4 = Preferences.get(PREF_UNIFIED, false) &&
               !Preferences.get(PREF_UNIFIED_OPTIN, false);
 
 var healthReportWrapper = {
   init: function () {
     let iframe = document.getElementById("remote-report");
     iframe.addEventListener("load", healthReportWrapper.initRemotePage, false);
     iframe.src = this._getReportURI().spec;
-    iframe.onload = () => {
-      MozSelfSupport.getHealthReportPayload().then(this.updatePayload,
-                                                   this.handleInitFailure);
-    };
     prefs.observe("uploadEnabled", this.updatePrefState, healthReportWrapper);
   },
 
   uninit: function () {
     prefs.ignore("uploadEnabled", this.updatePrefState, healthReportWrapper);
   },
 
   _getReportURI: function () {
@@ -98,25 +94,16 @@ var healthReportWrapper = {
     console.log("AboutHealthReport: Sending current Telemetry ping data.");
     MozSelfSupport.getCurrentTelemetrySubsessionPing().then((ping) => {
       this.injectData("telemetry-current-ping-data", ping);
     }).catch((ex) => {
       console.log("AboutHealthReport: Collecting current ping data failed: " + ex);
     });
   },
 
-  refreshPayload: function () {
-    MozSelfSupport.getHealthReportPayload().then(this.updatePayload,
-                                                 this.handlePayloadFailure);
-  },
-
-  updatePayload: function (payload) {
-    healthReportWrapper.injectData("payload", JSON.stringify(payload));
-  },
-
   injectData: function (type, content) {
     let report = this._getReportURI();
 
     // file URIs can't be used for targetOrigin, so we use "*" for this special case
     // in all other cases, pass in the URL to the report so we properly restrict the message dispatch
     let reportUrl = report.scheme == "file" ? "*" : report.spec;
 
     let data = {
@@ -134,19 +121,16 @@ var healthReportWrapper = {
         this.setDataSubmission(false);
         break;
       case "EnableDataSubmission":
         this.setDataSubmission(true);
         break;
       case "RequestCurrentPrefs":
         this.updatePrefState();
         break;
-      case "RequestCurrentPayload":
-        this.refreshPayload();
-        break;
       case "RequestTelemetryPingList":
         this.sendTelemetryPingList();
         break;
       case "RequestTelemetryPingData":
         this.sendTelemetryPingData(evt.detail.id);
         break;
       case "RequestCurrentEnvironment":
         this.sendCurrentEnvironment();
--- a/browser/base/content/blockedSite.xhtml
+++ b/browser/base/content/blockedSite.xhtml
@@ -130,21 +130,27 @@
           el.parentNode.removeChild(el);
         }
 
         if (error !== "forbidden") {
           el = document.getElementById("errorTitleText_forbidden");
           el.parentNode.removeChild(el);
           el = document.getElementById("errorShortDescText_forbidden");
           el.parentNode.removeChild(el);
+          el = document.getElementById("whyForbiddenButton");
+          el.parentNode.removeChild(el);
         } else {
           el = document.getElementById("ignoreWarningButton");
           el.parentNode.removeChild(el);
           el = document.getElementById("reportButton");
           el.parentNode.removeChild(el);
+
+          // Remove red style: A "forbidden site" does not warrant the same level
+          // of anxiety as a security concern.
+          document.documentElement.className = "";
         }
 
         // Set sitename
         document.getElementById(error + "_sitename").textContent = getHostString();
         document.title = document.getElementById("errorTitleText_" + error)
                                  .innerHTML;
 
         if (!getOverride()) {
@@ -192,41 +198,42 @@
   <body dir="&locale.dir;">
     <div id="errorPageContainer">
     
       <!-- Error Title -->
       <div id="errorTitle">
         <h1 id="errorTitleText_phishing">&safeb.blocked.phishingPage.title;</h1>
         <h1 id="errorTitleText_malware">&safeb.blocked.malwarePage.title;</h1>
         <h1 id="errorTitleText_unwanted">&safeb.blocked.unwantedPage.title;</h1>
-        <h1 id="errorTitleText_forbidden">&safeb.blocked.forbiddenPage.title;</h1>
+        <h1 id="errorTitleText_forbidden">&safeb.blocked.forbiddenPage.title2;</h1>
       </div>
       
       <div id="errorLongContent">
       
         <!-- Short Description -->
         <div id="errorShortDesc">
           <p id="errorShortDescText_phishing">&safeb.blocked.phishingPage.shortDesc;</p>
           <p id="errorShortDescText_malware">&safeb.blocked.malwarePage.shortDesc;</p>
           <p id="errorShortDescText_unwanted">&safeb.blocked.unwantedPage.shortDesc;</p>
-          <p id="errorShortDescText_forbidden">&safeb.blocked.forbiddenPage.shortDesc;</p>
+          <p id="errorShortDescText_forbidden">&safeb.blocked.forbiddenPage.shortDesc2;</p>
         </div>
 
         <!-- Long Description -->
         <div id="errorLongDesc">
           <p id="errorLongDescText_phishing">&safeb.blocked.phishingPage.longDesc;</p>
           <p id="errorLongDescText_malware">&safeb.blocked.malwarePage.longDesc;</p>
           <p id="errorLongDescText_unwanted">&safeb.blocked.unwantedPage.longDesc;</p>
         </div>
         
         <!-- Action buttons -->
         <div id="buttons">
           <!-- Commands handled in browser.js -->
           <button id="getMeOutButton">&safeb.palm.accept.label;</button>
           <button id="reportButton">&safeb.palm.reportPage.label;</button>
+          <button id="whyForbiddenButton">&safeb.palm.whyForbidden.label;</button>
         </div>
       </div>
       <div id="ignoreWarning">
         <button id="ignoreWarningButton">&safeb.palm.decline.label;</button>
       </div>
     </div>
     <!--
     - Note: It is important to run the script this way, instead of using
--- a/browser/base/content/browser-context.inc
+++ b/browser/base/content/browser-context.inc
@@ -74,20 +74,16 @@
       <menuitem id="context-sharelink"
                 label="&shareLink.label;"
                 accesskey="&shareLink.accesskey;"
                 oncommand="gContextMenu.shareLink();"/>
       <menuitem id="context-savelink"
                 label="&saveLinkCmd.label;"
                 accesskey="&saveLinkCmd.accesskey;"
                 oncommand="gContextMenu.saveLink();"/>
-      <menuitem id="context-savelinktopocket"
-                label="&saveLinkToPocketCmd.label;"
-                accesskey="&saveLinkToPocketCmd.accesskey;"
-                oncommand="gContextMenu.saveLinkToPocket();"/>
       <menu id="context-marklinkMenu" label="&social.marklinkMenu.label;"
             accesskey="&social.marklinkMenu.accesskey;">
         <menupopup/>
       </menu>
       <menuitem id="context-copyemail"
                 label="&copyEmailCmd.label;"
                 accesskey="&copyEmailCmd.accesskey;"
                 oncommand="gContextMenu.copyEmail();"/>
@@ -265,20 +261,16 @@
       <menuitem id="context-sharepage"
                 label="&sharePageCmd.label;"
                 accesskey="&sharePageCmd.accesskey;"
                 oncommand="SocialShare.sharePage();"/>
       <menuitem id="context-savepage"
                 label="&savePageCmd.label;"
                 accesskey="&savePageCmd.accesskey2;"
                 oncommand="gContextMenu.savePageAs();"/>
-      <menuitem id="context-pocket"
-                label="&saveToPocketCmd.label;"
-                accesskey="&saveToPocketCmd.accesskey;"
-                oncommand="gContextMenu.savePageToPocket();"/>
       <menu id="context-markpageMenu" label="&social.markpageMenu.label;"
             accesskey="&social.markpageMenu.accesskey;">
         <menupopup/>
       </menu>
       <menuseparator id="context-sep-viewbgimage"/>
       <menuitem id="context-viewbgimage"
                 label="&viewBGImageCmd.label;"
                 accesskey="&viewBGImageCmd.accesskey;"
--- a/browser/base/content/browser-data-submission-info-bar.js
+++ b/browser/base/content/browser-data-submission-info-bar.js
@@ -1,12 +1,15 @@
 /* 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/. */
 
+const LOGGER_NAME = "Toolkit.Telemetry";
+const LOGGER_PREFIX = "DataNotificationInfoBar::";
+
 /**
  * Represents an info bar that shows a data submission notification.
  */
 var gDataNotificationInfoBar = {
   _OBSERVERS: [
     "datareporting:notify-data-policy:request",
     "datareporting:notify-data-policy:close",
   ],
@@ -16,17 +19,17 @@ var gDataNotificationInfoBar = {
   get _notificationBox() {
     delete this._notificationBox;
     return this._notificationBox = document.getElementById("global-notificationbox");
   },
 
   get _log() {
     let Log = Cu.import("resource://gre/modules/Log.jsm", {}).Log;
     delete this._log;
-    return this._log = Log.repository.getLogger("Services.DataReporting.InfoBar");
+    return this._log = Log.repository.getLoggerWithMessagePrefix(LOGGER_NAME, LOGGER_PREFIX);
   },
 
   init: function() {
     window.addEventListener("unload", () => {
       for (let o of this._OBSERVERS) {
         Services.obs.removeObserver(this, o);
       }
     }, false);
--- a/browser/base/content/browser-fullZoom.js
+++ b/browser/base/content/browser-fullZoom.js
@@ -60,17 +60,16 @@ var FullZoom = {
     // before we were initialized we want to replay those upon initialization.
     for (let browser of gBrowser.browsers) {
       if (this._initialLocations.has(browser)) {
         this.onLocationChange(...this._initialLocations.get(browser), browser);
       }
     }
 
     // This should be nulled after initialization.
-    this._initialLocations.clear();
     this._initialLocations = null;
   },
 
   destroy: function FullZoom_destroy() {
     gPrefService.removeObserver("browser.zoom.", this);
     this._cps2.removeObserverForName(this.name, this);
     gBrowser.removeEventListener("ZoomChangeUsingMouseWheel", this);
   },
--- a/browser/base/content/browser-menubar.inc
+++ b/browser/base/content/browser-menubar.inc
@@ -408,31 +408,24 @@
 #ifndef XP_MACOSX
                placespopup="true"
 #endif
                context="placesContext"
                openInTabs="children"
                oncommand="BookmarksEventHandler.onCommand(event, this.parentNode._placesView);"
                onclick="BookmarksEventHandler.onClick(event, this.parentNode._placesView);"
                onpopupshowing="BookmarkingUI.onMainMenuPopupShowing(event);
-                               BookmarkingUI.updatePocketItemVisibility('menu_');
                                if (!this.parentNode._placesView)
                                  new PlacesMenu(event, 'place:folder=BOOKMARKS_MENU');"
                tooltip="bhTooltip" popupsinherittooltip="true">
       <menuitem id="bookmarksShowAll"
                 label="&showAllBookmarks2.label;"
                 command="Browser:ShowAllBookmarks"
                 key="manBookmarkKb"/>
       <menuseparator id="organizeBookmarksSeparator"/>
-      <menuitem id="menu_pocket" label="&pocketMenuitem.label;"
-#ifndef XP_MACOSX
-                class="menuitem-iconic"
-#endif
-                oncommand="openUILink(Pocket.listURL, event);"/>
-      <menuseparator id="menu_pocketSeparator"/>
       <menuitem id="menu_bookmarkThisPage"
                 command="Browser:AddBookmarkAs"
                 observes="bookmarkThisPageBroadcaster"
                 key="addBookmarkAsKb"/>
       <menuitem id="subscribeToPageMenuitem"
 #ifndef XP_MACOSX
                 class="menuitem-iconic"
 #endif
@@ -495,21 +488,16 @@
                         key="key_openDownloads"
                         command="Tools:Downloads"/>
               <menuitem id="menu_openAddons"
                         label="&addons.label;"
                         accesskey="&addons.accesskey;"
                         key="key_openAddons"
                         command="Tools:Addons"/>
 
-              <menuitem id="menu_openLoop"
-                        label="&loopMenuItem.label;"
-                        accesskey = "&loopMenuItem.accesskey;"
-                        oncommand="LoopUI.togglePanel();"/>
-
               <!-- only one of sync-setup, sync-syncnowitem or sync-reauthitem will be showing at once -->
               <menuitem id="sync-setup"
                         label="&syncSignIn.label;"
                         accesskey="&syncSignIn.accesskey;"
                         observes="sync-setup-state"
                         oncommand="gSyncUI.openSetup(null, 'menubar')"/>
               <menuitem id="sync-syncnowitem"
                         label="&syncSyncNowItem.label;"
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -1547,22 +1547,16 @@ var BookmarkingUI = {
     }
   },
 
   onMainMenuPopupShowing: function BUI_onMainMenuPopupShowing(event) {
     this._updateBookmarkPageMenuItem();
     PlacesCommandHook.updateBookmarkAllTabsCommand();
   },
 
-  updatePocketItemVisibility: function BUI_updatePocketItemVisibility(prefix) {
-    let hidden = !CustomizableUI.getPlacementOfWidget("pocket-button");
-    document.getElementById(prefix + "pocket").hidden = hidden;
-    document.getElementById(prefix + "pocketSeparator").hidden = hidden;
-  },
-
   _showBookmarkedNotification: function BUI_showBookmarkedNotification() {
     function getCenteringTransformForRects(rectToPosition, referenceRect) {
       let topDiff = referenceRect.top - rectToPosition.top;
       let leftDiff = referenceRect.left - rectToPosition.left;
       let heightDiff = referenceRect.height - rectToPosition.height;
       let widthDiff = referenceRect.width - rectToPosition.width;
       return [(leftDiff + .5 * widthDiff) + "px", (topDiff + .5 * heightDiff) + "px"];
     }
@@ -1674,17 +1668,16 @@ var BookmarkingUI = {
       case "ViewHiding":
         this.onPanelMenuViewHiding(aEvent);
         break;
     }
   },
 
   onPanelMenuViewShowing: function BUI_onViewShowing(aEvent) {
     this._updateBookmarkPageMenuItem();
-    this.updatePocketItemVisibility("panelMenu_");
     // Update checked status of the toolbar toggle.
     let viewToolbar = document.getElementById("panelMenu_viewBookmarksToolbar");
     let personalToolbar = document.getElementById("PersonalToolbar");
     if (personalToolbar.collapsed)
       viewToolbar.removeAttribute("checked");
     else
       viewToolbar.setAttribute("checked", "true");
     // Get all statically placed buttons to supply them with keyboard shortcuts.
@@ -1817,8 +1810,49 @@ var BookmarkingUI = {
     if (aNode.getAttribute("label") != this._starButtonLabel)
       aNode.setAttribute("label", this._starButtonLabel);
   },
 
   QueryInterface: XPCOMUtils.generateQI([
     Ci.nsINavBookmarkObserver
   ])
 };
+
+var AutoShowBookmarksToolbar = {
+  init() {
+    PlacesUtils.addLazyBookmarkObserver(this, false);
+  },
+
+  uninit() {
+    PlacesUtils.removeLazyBookmarkObserver(this);
+  },
+
+  onItemAdded(aItemId, aParentId, aIndex, aItemType, aURI, aTitle, aDateAdded,
+              aGuid, aParentGuid) {
+    this._autoshow(aParentGuid);
+  },
+  onBeginUpdateBatch() {},
+  onEndUpdateBatch() {},
+  onItemRemoved() {},
+  onItemChanged() {},
+  onItemVisited() {},
+  onItemMoved(aItemId, aOldParent, aOldIndex, aNewParent, aNewIndex, aItemType,
+              aGuid, aOldParentGuid, aNewParentGuid) {
+    this._autoshow(aNewParentGuid);
+  },
+
+  _autoshow(aParentGuid) {
+    if (aParentGuid != PlacesUtils.bookmarks.toolbarGuid)
+      return;
+
+    let toolbar = document.getElementById("PersonalToolbar");
+    if (!toolbar.collapsed)
+      return;
+
+    let placement = CustomizableUI.getPlacementOfWidget("personal-bookmarks");
+    let area = placement && placement.area;
+    if (area != CustomizableUI.AREA_BOOKMARKS)
+      return;
+
+    setToolbarVisibility(toolbar, true);
+  }
+};
+
--- a/browser/base/content/browser-sets.inc
+++ b/browser/base/content/browser-sets.inc
@@ -122,17 +122,17 @@
     <command id="Social:ToggleSidebar" oncommand="SocialSidebar.toggleSidebar();" hidden="true"/>
     <command id="Social:ToggleNotifications" oncommand="Social.toggleNotifications();" hidden="true"/>
     <command id="Social:Addons" oncommand="BrowserOpenAddonsMgr('addons://list/service');"/>
     <command id="Chat:Focus" oncommand="Cu.import('resource:///modules/Chat.jsm', {}).Chat.focus(window);"/>
   </commandset>
 
   <commandset id="placesCommands">
     <command id="Browser:ShowAllBookmarks"
-             oncommand="PlacesCommandHook.showPlacesOrganizer('AllBookmarks');"/>
+             oncommand="PlacesCommandHook.showPlacesOrganizer('UnfiledBookmarks');"/>
     <command id="Browser:ShowAllHistory"
              oncommand="PlacesCommandHook.showPlacesOrganizer('History');"/>
   </commandset>
 
   <broadcasterset id="mainBroadcasterSet">
     <broadcaster id="Social:PageShareOrMark" disabled="true"/>
     <broadcaster id="viewBookmarksSidebar" autoCheck="false" label="&bookmarksButton.label;"
                  type="checkbox" group="sidebar" sidebarurl="chrome://browser/content/bookmarks/bookmarksPanel.xul"
--- a/browser/base/content/browser-social.js
+++ b/browser/base/content/browser-social.js
@@ -532,17 +532,17 @@ SocialShare = {
     let provider = Social._getProviderFromOrigin(tt.triggerNode.getAttribute("origin"));
     tt.firstChild.setAttribute("value", provider.name);
     tt.lastChild.setAttribute("value", provider.origin);
   },
 
   populateProviderMenu: function() {
     if (!this.iframe)
       return;
-    let providers = [p for (p of Social.providers) if (p.shareURL)];
+    let providers = Social.providers.filter(p => p.shareURL);
     let hbox = document.getElementById("social-share-provider-buttons");
     // remove everything before the add-share-provider button (which should also
     // be lastChild if any share providers were added)
     let addButton = document.getElementById("add-share-provider");
     while (hbox.lastChild != addButton) {
       hbox.removeChild(hbox.lastChild);
     }
     let selectedProvider = this.getSelectedProvider();
@@ -971,17 +971,17 @@ SocialSidebar = {
   _provider: null,
   ensureProvider: function() {
     if (this._provider)
       return;
     // origin for sidebar is persisted, so get the previously selected sidebar
     // first, otherwise fallback to the first provider in the list
     let sbrowser = document.getElementById("social-sidebar-browser");
     let origin = sbrowser.getAttribute("origin");
-    let providers = [p for (p of Social.providers) if (p.sidebarURL)];
+    let providers = Social.providers.filter(p => p.sidebarURL);
     let provider;
     if (origin)
       provider = Social._getProviderFromOrigin(origin);
     if (!provider && providers.length > 0)
       provider = providers[0];
     if (provider)
       this.provider = provider;
   },
@@ -1088,17 +1088,17 @@ SocialSidebar = {
   populateProviderMenu: function(providerMenuSep) {
     let menu = providerMenuSep.parentNode;
     // selectable providers are inserted before the provider-menu seperator,
     // remove any menuitems in that area
     while (providerMenuSep.previousSibling.nodeName == "menuitem") {
       menu.removeChild(providerMenuSep.previousSibling);
     }
     // only show a selection in the sidebar header menu if there is more than one
-    let providers = [p for (p of Social.providers) if (p.sidebarURL)];
+    let providers = Social.providers.filter(p => p.sidebarURL);
     if (providers.length < 2 && menu.id != "viewSidebarMenu") {
       providerMenuSep.hidden = true;
       return;
     }
     let topSep = providerMenuSep.previousSibling;
     for (let provider of providers) {
       let menuitem = document.createElement("menuitem");
       menuitem.className = "menuitem-iconic social-provider-menuitem";
@@ -1148,17 +1148,19 @@ ToolbarHelper.prototype = {
   },
 
   // should be called on disable of a provider
   removeProviderButton: function(origin) {
     CustomizableUI.destroyWidget(this.idFromOrigin(origin));
   },
 
   clearPalette: function() {
-    [this.removeProviderButton(p.origin) for (p of Social.providers)];
+    for (let p of Social.providers) {
+      this.removeProviderButton(p.origin);
+    }
   },
 
   // should be called on enable of a provider
   populatePalette: function() {
     if (!Social.enabled) {
       this.clearPalette();
       return;
     }
@@ -1315,18 +1317,17 @@ var SocialMarksWidgetListener = {
 
 /**
  * SocialMarks
  *
  * Handles updates to toolbox and signals all buttons to update when necessary.
  */
 SocialMarks = {
   get nodes() {
-    let providers = [p for (p of Social.providers) if (p.markURL)];
-    for (let p of providers) {
+    for (let p of Social.providers.filter(p => p.markURL)) {
       let widgetId = SocialMarks._toolbarHelper.idFromOrigin(p.origin);
       let widget = CustomizableUI.getWidget(widgetId);
       if (!widget)
         continue;
       let node = widget.forWindow(window).node;
       if (node)
         yield node;
     }
@@ -1343,28 +1344,29 @@ SocialMarks = {
     }
   },
 
   getProviders: function() {
     // only rely on providers that the user has placed in the UI somewhere. This
     // also means that populateToolbarPalette must be called prior to using this
     // method, otherwise you get a big fat zero. For our use case with context
     // menu's, this is ok.
-    let tbh = this._toolbarHelper;
-    return [p for (p of Social.providers) if (p.markURL &&
-                                              document.getElementById(tbh.idFromOrigin(p.origin)))];
+    return Social.providers.filter(p => p.markURL &&
+                                        document.getElementById(this._toolbarHelper.idFromOrigin(p.origin)));
   },
 
   populateContextMenu: function() {
     // only show a selection if enabled and there is more than one
     let providers = this.getProviders();
 
     // remove all previous entries by class
-    let menus = [m for (m of document.getElementsByClassName("context-socialmarks"))];
-    [m.parentNode.removeChild(m) for (m of menus)];
+    let menus = [...document.getElementsByClassName("context-socialmarks")];
+    for (let m of menus) {
+      m.parentNode.removeChild(m);
+    }
 
     let contextMenus = [
       {
         type: "link",
         id: "context-marklinkMenu",
         label: "social.marklinkMenu.label"
       },
       {
--- a/browser/base/content/browser-trackingprotection.js
+++ b/browser/base/content/browser-trackingprotection.js
@@ -179,17 +179,16 @@ var TrackingProtection = {
 
     // Hide the control center.
     document.getElementById("identity-popup").hidePopup();
 
     BrowserReload();
   },
 
   showIntroPanel: Task.async(function*() {
-    let mm = gBrowser.selectedBrowser.messageManager;
     let brandBundle = document.getElementById("bundle_brand");
     let brandShortName = brandBundle.getString("brandShortName");
 
     let openStep2 = () => {
       // When the user proceeds in the tour, adjust the counter to indicate that
       // the user doesn't need to see the intro anymore.
       gPrefService.setIntPref("privacy.trackingprotection.introCount",
                               this.MAX_INTROS);
@@ -214,15 +213,15 @@ var TrackingProtection = {
         callback: openStep2,
         label: gNavigatorBundle.getString("trackingProtection.intro.nextButton.label"),
         style: "primary",
       },
     ];
 
     let panelTarget = yield UITour.getTarget(window, "trackingProtection");
     UITour.initForBrowser(gBrowser.selectedBrowser, window);
-    UITour.showInfo(window, mm, panelTarget,
+    UITour.showInfo(window, panelTarget,
                     gNavigatorBundle.getString("trackingProtection.intro.title"),
                     gNavigatorBundle.getFormattedString("trackingProtection.intro.description",
                                                         [brandShortName]),
                     undefined, buttons);
   }),
 };
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -5,16 +5,18 @@
 
 var Ci = Components.interfaces;
 var Cu = Components.utils;
 var Cc = Components.classes;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/NotificationDB.jsm");
 Cu.import("resource:///modules/RecentWindow.jsm");
+Cu.import("resource:///modules/UserContextUI.jsm");
+
 
 XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
                                   "resource://gre/modules/Preferences.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Deprecated",
                                   "resource://gre/modules/Deprecated.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "BrowserUITelemetry",
                                   "resource:///modules/BrowserUITelemetry.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "E10SUtils",
@@ -48,48 +50,19 @@ XPCOMUtils.defineLazyServiceGetter(this,
                                    "mozIAsyncFavicons");
 XPCOMUtils.defineLazyServiceGetter(this, "gDNSService",
                                    "@mozilla.org/network/dns-service;1",
                                    "nsIDNSService");
 XPCOMUtils.defineLazyServiceGetter(this, "WindowsUIUtils",
                                    "@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils");
 XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
                                   "resource://gre/modules/LightweightThemeManager.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "Pocket",
-                                  "resource:///modules/Pocket.jsm");
-
-// Can't use XPCOMUtils for these because the scripts try to define the variables
-// on window, and so the defineProperty inside defineLazyGetter fails.
-Object.defineProperty(window, "pktApi", {
-  get: function() {
-    // Avoid this getter running again:
-    delete window.pktApi;
-    Services.scriptloader.loadSubScript("chrome://browser/content/pocket/pktApi.js", window);
-    return window.pktApi;
-  },
-  configurable: true,
-  enumerable: true
-});
-
-function pktUIGetter(prop) {
-  return {
-    get: function() {
-      // Avoid either of these getters running again:
-      delete window.pktUI;
-      delete window.pktUIMessaging;
-      Services.scriptloader.loadSubScript("chrome://browser/content/pocket/main.js", window);
-      return window[prop];
-    },
-    configurable: true,
-    enumerable: true
-  };
-}
-Object.defineProperty(window, "pktUI", pktUIGetter("pktUI"));
-Object.defineProperty(window, "pktUIMessaging", pktUIGetter("pktUIMessaging"));
-
+XPCOMUtils.defineLazyServiceGetter(this, "gAboutNewTabService",
+                                   "@mozilla.org/browser/aboutnewtab-service;1",
+                                   "nsIAboutNewTabService");
 XPCOMUtils.defineLazyGetter(this, "gBrowserBundle", function() {
   return Services.strings.createBundle('chrome://browser/locale/browser.properties');
 });
 
 const nsIWebNavigation = Ci.nsIWebNavigation;
 
 var gLastBrowserCharset = null;
 var gLastValidURLStr = "";
@@ -265,20 +238,16 @@ var gInitialPages = [
   "about:welcomeback",
   "about:sessionrestore"
 ];
 
 XPCOMUtils.defineLazyGetter(this, "Win7Features", function () {
   if (AppConstants.platform != "win")
     return null;
 
-  // Bug 666808 - AeroPeek support for e10s
-  if (gMultiProcessBrowser)
-    return null;
-
   const WINTASKBAR_CONTRACTID = "@mozilla.org/windows-taskbar;1";
   if (WINTASKBAR_CONTRACTID in Cc &&
       Cc[WINTASKBAR_CONTRACTID].getService(Ci.nsIWinTaskbar).available) {
     let AeroPeek = Cu.import("resource:///modules/WindowsPreviewPerTab.jsm", {}).AeroPeek;
     return {
       onOpenWindow: function () {
         AeroPeek.onOpenWindow(window);
       },
@@ -992,45 +961,27 @@ var gBrowserInit = {
     // Certain kinds of automigration rely on this notification to complete
     // their tasks BEFORE the browser window is shown. SessionStore uses it to
     // restore tabs into windows AFTER important parts like gMultiProcessBrowser
     // have been initialized.
     Services.obs.notifyObservers(window, "browser-window-before-show", "");
 
     // Set a sane starting width/height for all resolutions on new profiles.
     if (!document.documentElement.hasAttribute("width")) {
-      let defaultWidth;
-      let defaultHeight;
-
-      // Very small: maximize the window
-      // Portrait  : use about full width and 3/4 height, to view entire pages
-      //             at once (without being obnoxiously tall)
-      // Widescreen: use about half width, to suggest side-by-side page view
-      // Otherwise : use 3/4 height and width
-      if (screen.availHeight <= 600) {
+      const TARGET_WIDTH = 1280;
+      const TARGET_HEIGHT = 1040;
+      let width = Math.min(screen.availWidth * .9, TARGET_WIDTH);
+      let height = Math.min(screen.availHeight * .9, TARGET_HEIGHT);
+
+      document.documentElement.setAttribute("width", width);
+      document.documentElement.setAttribute("height", height);
+
+      if (width < TARGET_WIDTH && height < TARGET_HEIGHT) {
         document.documentElement.setAttribute("sizemode", "maximized");
-        defaultWidth = 610;
-        defaultHeight = 450;
       }
-      else {
-        if (screen.availWidth <= screen.availHeight) {
-          defaultWidth = screen.availWidth * .9;
-          defaultHeight = screen.availHeight * .75;
-        }
-        else if (screen.availWidth >= 2048) {
-          defaultWidth = (screen.availWidth / 2) - 20;
-          defaultHeight = screen.availHeight - 10;
-        }
-        else {
-          defaultWidth = screen.availWidth * .75;
-          defaultHeight = screen.availHeight * .75;
-        }
-      }
-      document.documentElement.setAttribute("width", defaultWidth);
-      document.documentElement.setAttribute("height", defaultHeight);
     }
 
     if (!window.toolbar.visible) {
       // adjust browser UI for popups
       if (gURLBar) {
         gURLBar.setAttribute("readonly", "true");
         gURLBar.setAttribute("enablehistory", "false");
       }
@@ -1232,16 +1183,17 @@ var gBrowserInit = {
         !focusAndSelectUrlBar()) {
       gBrowser.selectedBrowser.focus();
     }
 
     // Enable/Disable auto-hide tabbar
     gBrowser.tabContainer.updateVisibility();
 
     BookmarkingUI.init();
+    AutoShowBookmarksToolbar.init();
 
     gPrefService.addObserver(gHomeButton.prefDomain, gHomeButton, false);
 
     var homeButton = document.getElementById("home-button");
     gHomeButton.updateTooltip(homeButton);
 
     let safeMode = document.getElementById("helpSafeMode");
     if (Services.appinfo.inSafeMode) {
@@ -1530,16 +1482,17 @@ var gBrowserInit = {
         this.gmpInstallManager.uninit();
       }
 
       BrowserOffline.uninit();
       OfflineApps.uninit();
       IndexedDBPromptHelper.uninit();
       LightweightThemeListener.uninit();
       PanelUI.uninit();
+      AutoShowBookmarksToolbar.uninit();
     }
 
     // Final window teardown, do this last.
     window.XULBrowserWindow = null;
     window.QueryInterface(Ci.nsIInterfaceRequestor)
           .getInterface(Ci.nsIWebNavigation)
           .QueryInterface(Ci.nsIDocShellTreeItem).treeOwner
           .QueryInterface(Ci.nsIInterfaceRequestor)
@@ -2364,18 +2317,21 @@ function URLBarSetURI(aURI) {
   if (value == null) {
     let uri = aURI || gBrowser.currentURI;
     // Strip off "wyciwyg://" and passwords for the location bar
     try {
       uri = Services.uriFixup.createExposableURI(uri);
     } catch (e) {}
 
     // Replace initial page URIs with an empty string
-    // only if there's no opener (bug 370555).
-    if (gInitialPages.indexOf(uri.spec) != -1)
+    // 1. only if there's no opener (bug 370555).
+    // 2. if remote newtab is enabled and it's the default remote newtab page
+    let defaultRemoteURL = gAboutNewTabService.remoteEnabled &&
+                           uri.spec === gAboutNewTabService.newTabURL;
+    if (gInitialPages.includes(uri.spec) || defaultRemoteURL)
       value = gBrowser.selectedBrowser.hasContentOpener ? uri.spec : "";
     else
       value = losslessDecodeURI(uri);
 
     valid = !isBlankPageURL(uri.spec);
   }
 
   gURLBar.value = value;
@@ -2718,17 +2674,17 @@ var BrowserOnClick = {
       case "Browser:EnableOnlineMode":
         if (Services.io.offline) {
           // Reset network state and refresh the page.
           Services.io.offline = false;
           msg.target.reload();
         }
       break;
       case "Browser:SendSSLErrorReport":
-        this.onSSLErrorReport(msg.target, msg.data.elementId,
+        this.onSSLErrorReport(msg.target,
                               msg.data.documentURI,
                               msg.data.location,
                               msg.data.securityInfo);
       break;
       case "Browser:SetSSLErrorReportAuto":
         Services.prefs.setBoolPref("security.ssl.errorReporting.automatic", msg.json.automatic);
         let bin = TLS_ERROR_REPORT_TELEMETRY_AUTO_UNCHECKED;
         if (msg.json.automatic) {
@@ -2749,17 +2705,17 @@ var BrowserOnClick = {
           PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser));
       break;
       case "Browser:SSLErrorGoBack":
         goBackFromErrorPage();
       break;
     }
   },
 
-  onSSLErrorReport: function(browser, elementId, documentURI, location, securityInfo) {
+  onSSLErrorReport: function(browser, documentURI, location, securityInfo) {
     function showReportStatus(reportStatus) {
       gBrowser.selectedBrowser
           .messageManager
           .sendAsyncMessage("Browser:SSLErrorReportStatus",
                             {
                               reportStatus: reportStatus,
                               documentURI: documentURI
                             });
@@ -2958,16 +2914,22 @@ var BrowserOnClick = {
       case "ignoreWarningButton":
         if (gPrefService.getBoolPref("browser.safebrowsing.allowOverride")) {
           if (sendTelemetry) {
             secHistogram.add(nsISecTel[bucketName + "IGNORE_WARNING"]);
           }
           this.ignoreWarningButton(reason);
         }
         break;
+
+      case "whyForbiddenButton":
+        // This is the "Why is this site blocked" button for family friendly browsing
+        // for Fennec. There's no desktop focused support page yet.
+        gBrowser.loadURI("https://support.mozilla.org/kb/controlledaccess");
+        break;
     }
   },
 
   /**
    * This functions prevents navigation from happening directly through the <a>
    * link in about:newtab (which is loaded in the parent and therefore would load
    * the next page also in the parent) and instructs the browser to open the url
    * in the current tab which will make it update the remoteness of the tab.
@@ -3169,52 +3131,62 @@ function BrowserReloadWithFlags(reloadFl
 /**
  * Returns a string with detailed information about the certificate validation
  * failure from the specified URI that can be used to send a report.
  */
 function getDetailedCertErrorInfo(location, securityInfoAsString) {
   if (!securityInfoAsString)
     return "";
 
-  let details = [];
-  details.push(location);
+  let certErrorDetails = location;
 
   const serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
                        .getService(Ci.nsISerializationHelper);
   let securityInfo = serhelper.deserializeObject(securityInfoAsString);
   securityInfo.QueryInterface(Ci.nsITransportSecurityInfo);
 
   let errors = Cc["@mozilla.org/nss_errors_service;1"]
                   .getService(Ci.nsINSSErrorsService);
   let code = securityInfo.errorCode;
-  details.push(errors.getErrorMessage(errors.getXPCOMFromNSSError(code)));
+  certErrorDetails += "\r\n\r\n" + errors.getErrorMessage(errors.getXPCOMFromNSSError(code));
 
   const sss = Cc["@mozilla.org/ssservice;1"]
                  .getService(Ci.nsISiteSecurityService);
   // SiteSecurityService uses different storage if the channel is
   // private. Thus we must give isSecureHost correct flags or we
   // might get incorrect results.
   let flags = PrivateBrowsingUtils.isWindowPrivate(window) ?
               Ci.nsISocketProvider.NO_PERMANENT_STORAGE : 0;
 
   let uri = Services.io.newURI(location, null, null);
-  details.push(sss.isSecureHost(sss.HEADER_HSTS, uri.host, flags));
-  details.push(sss.isSecureHost(sss.HEADER_HPKP, uri.host, flags));
+
+  let hasHSTS = sss.isSecureHost(sss.HEADER_HSTS, uri.host, flags);
+  let hasHPKP = sss.isSecureHost(sss.HEADER_HPKP, uri.host, flags);
+  certErrorDetails += "\r\n\r\n" +
+                      gNavigatorBundle.getFormattedString("certErrorDetailsHSTS.label",
+                                                          [hasHSTS]);
+  certErrorDetails += "\r\n" +
+                      gNavigatorBundle.getFormattedString("certErrorDetailsKeyPinning.label",
+                                                          [hasHPKP]);
 
   let certChain = "";
   if (securityInfo.failedCertChain) {
     let certs = securityInfo.failedCertChain.getEnumerator();
     while (certs.hasMoreElements()) {
       let cert = certs.getNext();
       cert.QueryInterface(Ci.nsIX509Cert);
       certChain += getPEMString(cert);
     }
   }
-  details.push(certChain);
-  return gNavigatorBundle.getFormattedString("certErrorDetails.label", details, 5);
+
+  certErrorDetails += "\r\n\r\n" +
+                      gNavigatorBundle.getString("certErrorDetailsCertChain.label") +
+                      "\r\n\r\n" + certChain;
+
+  return certErrorDetails;
 }
 
 // TODO: can we pull getDERString and getPEMString in from pippki.js instead of
 // duplicating them here?
 function getDERString(cert)
 {
   var length = {};
   var derArray = cert.getRawDER(length);
@@ -3562,18 +3534,19 @@ const BrowserSearch = {
       }
       return;
     }
 
     let openSearchPageIfFieldIsNotActive = function(aSearchBar) {
       if (!aSearchBar || document.activeElement != aSearchBar.textbox.inputField) {
         let url = gBrowser.currentURI.spec.toLowerCase();
         let mm = gBrowser.selectedBrowser.messageManager;
-        if (url === "about:home" ||
-            (url === "about:newtab" && NewTabUtils.allPages.enabled)) {
+        let newTabRemoted = Services.prefs.getBoolPref("browser.newtabpage.remote");
+        let localNewTabEnabled = url === "about:newtab" && !newTabRemoted && NewTabUtils.allPages.enabled;
+        if (url === "about:home" || localNewTabEnabled) {
           ContentSearch.focusInput(mm);
         } else {
           openUILinkIn("about:home", "current");
         }
       }
     };
 
     let searchBar = this.searchBar;
@@ -3671,17 +3644,17 @@ const BrowserSearch = {
    * Perform a search initiated from the context menu.
    *
    * This should only be called from the context menu. See
    * BrowserSearch.loadSearch for the preferred API.
    */
   loadSearchFromContext: function (terms) {
     let engine = BrowserSearch._loadSearch(terms, true, "contextmenu");
     if (engine) {
-      BrowserSearch.recordSearchInHealthReport(engine, "contextmenu");
+      BrowserSearch.recordSearchInTelemetry(engine, "contextmenu");
     }
   },
 
   pasteAndSearch: function (event) {
     BrowserSearch.searchBar.select();
     goDoCommand("cmd_paste");
     BrowserSearch.searchBar.handleSearchCommand(event);
   },
@@ -3695,78 +3668,58 @@ const BrowserSearch = {
 
   loadAddEngines: function BrowserSearch_loadAddEngines() {
     var newWindowPref = gPrefService.getIntPref("browser.link.open_newwindow");
     var where = newWindowPref == 3 ? "tab" : "window";
     var searchEnginesURL = formatURL("browser.search.searchEnginesURL", true);
     openUILinkIn(searchEnginesURL, where);
   },
 
+  _getSearchEngineId: function (engine) {
+    if (!engine) {
+      return "other";
+    }
+
+    if (engine.identifier) {
+      return engine.identifier;
+    }
+
+    if (!("name" in engine) || engine.name === undefined) {
+      return "other";
+    }
+
+    return "other-" + engine.name;
+  },
+
   /**
-   * Helper to record a search with Firefox Health Report.
+   * Helper to record a search with Telemetry.
    *
-   * FHR records only search counts and nothing pertaining to the search itself.
+   * Telemetry records only search counts and nothing pertaining to the search itself.
    *
    * @param engine
    *        (nsISearchEngine) The engine handling the search.
    * @param source
    *        (string) Where the search originated from. See the FHR
    *        SearchesProvider for allowed values.
    * @param selection [optional]
    *        ({index: The selected index, kind: "key" or "mouse"}) If
    *        the search was a suggested search, this indicates where the
    *        item was in the suggestion list and how the user selected it.
    */
-  recordSearchInHealthReport: function (engine, source, selection) {
-    BrowserUITelemetry.countSearchEvent(source, null, selection);
-    this.recordSearchInTelemetry(engine, source);
-
-    let reporter = AppConstants.MOZ_SERVICES_HEALTHREPORT
-                   ? Cc["@mozilla.org/datareporting/service;1"]
-                     .getService()
-                     .wrappedJSObject
-                     .healthReporter
-                   : null;
-
-    // This can happen if the FHR component of the data reporting service is
-    // disabled. This is controlled by a pref that most will never use.
-    if (!reporter) {
-      return;
-    }
-
-    reporter.onInit().then(function record() {
-      try {
-        reporter.getProvider("org.mozilla.searches").recordSearch(engine, source);
-      } catch (ex) {
-        Cu.reportError(ex);
-      }
-    });
-  },
-
-  _getSearchEngineId: function (engine) {
-    if (!engine) {
-      return "other";
-    }
-
-    if (engine.identifier) {
-      return engine.identifier;
-    }
-
-    return "other-" + engine.name;
-  },
-
-  recordSearchInTelemetry: function (engine, source) {
+  recordSearchInTelemetry: function (engine, source, selection) {
     const SOURCES = [
       "abouthome",
       "contextmenu",
       "newtab",
       "searchbar",
       "urlbar",
     ];
 
+    BrowserUITelemetry.countSearchEvent(source, null, selection);
+
     if (SOURCES.indexOf(source) == -1) {
       Cu.reportError("Unknown source for search: " + source);
       return;
     }
 
     let countId = this._getSearchEngineId(engine) + "." + source;
 
     let count = Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS");
@@ -4114,34 +4067,17 @@ function updateUserContextUIIndicator(br
   if (!browser.hasAttribute("usercontextid")) {
     hbox.removeAttribute("usercontextid");
     return;
   }
 
   let label = document.getElementById("userContext-label");
   let userContextId = browser.getAttribute("usercontextid");
   hbox.setAttribute("usercontextid", userContextId);
-  switch (userContextId) {
-    case "1":
-      label.value = gBrowserBundle.GetStringFromName("usercontext.personal.label");
-      break;
-    case "2":
-      label.value = gBrowserBundle.GetStringFromName("usercontext.work.label");
-      break;
-    case "3":
-      label.value = gBrowserBundle.GetStringFromName("usercontext.banking.label");
-      break;
-    case "4":
-      label.value = gBrowserBundle.GetStringFromName("usercontext.shopping.label");
-      break;
-    // Display the context IDs for values outside the pre-defined range.
-    // Used for debugging, no localization necessary.
-    default:
-      label.value = "Context " + userContextId;
-  }
+  label.value = UserContextUI.getUserContextLabel(userContextId);
 }
 
 /**
  * Makes the Character Encoding menu enabled or disabled as appropriate.
  * To be called when the View menu or the app menu is opened.
  */
 function updateCharacterEncodingMenuState()
 {
@@ -4755,17 +4691,17 @@ var CombinedStopReload = {
       this._timer = 0;
     }
   }
 };
 
 var TabsProgressListener = {
   onStateChange: function (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) {
     // Collect telemetry data about tab load times.
-    if (aWebProgress.isTopLevel) {
+    if (aWebProgress.isTopLevel && (!aRequest.originalURI || aRequest.originalURI.spec.scheme != "about")) {
       if (aStateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW) {
         if (aStateFlags & Ci.nsIWebProgressListener.STATE_START) {
           TelemetryStopwatch.start("FX_PAGE_LOAD_MS", aBrowser);
           Services.telemetry.getHistogramById("FX_TOTAL_TOP_VISITS").add(true);
         } else if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) {
           TelemetryStopwatch.finish("FX_PAGE_LOAD_MS", aBrowser);
         }
       } else if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
@@ -6456,21 +6392,16 @@ function BrowserOpenAddonsMgr(aView) {
     // found the window above.
     Services.obs.addObserver(function observer(aSubject, aTopic, aData) {
       Services.obs.removeObserver(observer, aTopic);
       aSubject.loadView(aView);
     }, "EM-loaded", false);
   }
 }
 
-function BrowserOpenApps() {
-  let appsURL = Services.urlFormatter.formatURLPref("browser.apps.URL");
-  switchToTabHavingURI(appsURL, true)
-}
-
 function AddKeywordForSearchField() {
   let mm = gBrowser.selectedBrowser.messageManager;
 
   let onMessage = (message) => {
     mm.removeMessageListener("ContextMenu:SearchFieldBookmarkData:Result", onMessage);
 
     let bookmarkData = message.data;
     let title = gNavigatorBundle.getFormattedString("addKeywordTitleAutoFill",
@@ -7118,16 +7049,19 @@ var gIdentityHandler = {
       host = this.getEffectiveHost();
     } catch (e) {
       // Some URIs might have no hosts.
     }
 
     // Fallback for special protocols.
     if (!host) {
       host = this._uri.specIgnoringRef;
+      // Special URIs without a host (eg, about:) should crop the end so
+      // the protocol can be seen.
+      crop = "end";
     }
 
     // Fill in the CA name if we have a valid TLS certificate.
     if (this._isSecure) {
       verifier = this._identityBox.tooltipText;
     }
 
     // Fill in organization information if we have a valid EV certificate.
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -3,17 +3,17 @@
 # -*- 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/.
 
 <?xml-stylesheet href="chrome://browser/content/browser.css" type="text/css"?>
 <?xml-stylesheet href="chrome://browser/content/places/places.css" type="text/css"?>
-<?xml-stylesheet href="chrome://devtools/skin/common.css" type="text/css"?>
+<?xml-stylesheet href="chrome://devtools/skin/devtools-browser.css" type="text/css"?>
 <?xml-stylesheet href="chrome://browser/skin/controlcenter/panel.css" type="text/css"?>
 <?xml-stylesheet href="chrome://browser/skin/customizableui/panelUIOverlay.css" type="text/css"?>
 <?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
 <?xml-stylesheet href="chrome://browser/skin/browser-lightweightTheme.css" type="text/css"?>
 
 <?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
 <?xul-overlay href="chrome://browser/content/baseMenuOverlay.xul"?>
 <?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>
@@ -615,19 +615,19 @@
            to the default placements of buttons in CustomizableUI.jsm, so the
            customization code doesn't get confused.
       -->
     <toolbar id="nav-bar"
              aria-label="&navbarCmd.label;"
              fullscreentoolbar="true" mode="icons" customizable="true"
              iconsize="small"
 #ifdef MOZ_DEV_EDITION
-             defaultset="urlbar-container,search-container,developer-button,bookmarks-menu-button,pocket-button,downloads-button,home-button,loop-button"
+             defaultset="urlbar-container,search-container,developer-button,bookmarks-menu-button,downloads-button,home-button,loop-button"
 #else
-             defaultset="urlbar-container,search-container,bookmarks-menu-button,pocket-button,downloads-button,home-button,loop-button"
+             defaultset="urlbar-container,search-container,bookmarks-menu-button,downloads-button,home-button,loop-button"
 #endif
              customizationtarget="nav-bar-customization-target"
              overflowable="true"
              overflowbutton="nav-bar-overflow-button"
              overflowtarget="widget-overflow-list"
              overflowpanel="widget-overflow"
              context="toolbar-context-menu">
 
@@ -793,38 +793,32 @@
           <menupopup id="BMB_bookmarksPopup"
                      class="cui-widget-panel cui-widget-panelview cui-widget-panelWithFooter PanelUI-subView"
                      placespopup="true"
                      context="placesContext"
                      openInTabs="children"
                      oncommand="BookmarksEventHandler.onCommand(event, this.parentNode._placesView);"
                      onclick="BookmarksEventHandler.onClick(event, this.parentNode._placesView);"
                      onpopupshowing="BookmarkingUI.onPopupShowing(event);
-                                     BookmarkingUI.updatePocketItemVisibility('BMB_');
                                      BookmarkingUI.attachPlacesView(event, this);"
                      tooltip="bhTooltip" popupsinherittooltip="true">
             <menuitem id="BMB_viewBookmarksSidebar"
                       class="subviewbutton"
                       label="&viewBookmarksSidebar2.label;"
                       type="checkbox"
                       oncommand="SidebarUI.toggle('viewBookmarksSidebar');">
               <observes element="viewBookmarksSidebar" attribute="checked"/>
             </menuitem>
             <!-- NB: temporary solution for bug 985024, this should go away soon. -->
             <menuitem id="BMB_bookmarksShowAllTop"
                       class="menuitem-iconic subviewbutton"
                       label="&showAllBookmarks2.label;"
                       command="Browser:ShowAllBookmarks"
                       key="manBookmarkKb"/>
             <menuseparator/>
-            <menuitem id="BMB_pocket"
-                      class="menuitem-iconic bookmark-item subviewbutton"
-                      label="&pocketMenuitem.label;"
-                      oncommand="openUILink(Pocket.listURL, event);"/>
-            <menuseparator id="BMB_pocketSeparator"/>
             <menuitem id="BMB_subscribeToPageMenuitem"
 #ifndef XP_MACOSX
                       class="menuitem-iconic subviewbutton"
 #else
                       class="subviewbutton"
 #endif
                       label="&subscribeToPageMenuitem.label;"
                       oncommand="return FeedHandler.subscribeToFeed(null, event);"
--- a/browser/base/content/content.js
+++ b/browser/base/content/content.js
@@ -202,16 +202,153 @@ Cc["@mozilla.org/eventlistenerservice;1"
   .addSystemEventListener(global, "contextmenu", handleContentContextMenu, false);
 
 // Values for telemtery bins: see TLS_ERROR_REPORT_UI in Histograms.json
 const TLS_ERROR_REPORT_TELEMETRY_UI_SHOWN = 0;
 const TLS_ERROR_REPORT_TELEMETRY_EXPANDED = 1;
 const TLS_ERROR_REPORT_TELEMETRY_SUCCESS  = 6;
 const TLS_ERROR_REPORT_TELEMETRY_FAILURE  = 7;
 
+var AboutCertErrorListener = {
+  init(chromeGlobal) {
+    addMessageListener("AboutCertErrorDetails", this);
+    addMessageListener("Browser:SSLErrorReportStatus", this);
+    chromeGlobal.addEventListener("AboutCertErrorLoad", this, false, true);
+    chromeGlobal.addEventListener("AboutCertErrorSetAutomatic", this, false, true);
+    chromeGlobal.addEventListener("AboutCertErrorSendReport", this, false, true);
+  },
+
+  get isAboutCertError() {
+    return content.document.documentURI.startsWith("about:certerror");
+  },
+
+  handleEvent(event) {
+    if (!this.isAboutCertError) {
+      return;
+    }
+
+    switch (event.type) {
+      case "AboutCertErrorLoad":
+        this.onLoad(event);
+        break;
+      case "AboutCertErrorSetAutomatic":
+        this.onSetAutomatic(event);
+        break;
+      case "AboutCertErrorSendReport":
+        this.onSendReport();
+        break;
+    }
+  },
+
+  receiveMessage(msg) {
+    if (!this.isAboutCertError) {
+      return;
+    }
+
+    switch (msg.name) {
+      case "AboutCertErrorDetails":
+        this.onDetails(msg);
+        break;
+      case "Browser:SSLErrorReportStatus":
+        this.onReportStatus(msg);
+        break;
+    }
+  },
+
+  onLoad(event) {
+    let originalTarget = event.originalTarget;
+    let ownerDoc = originalTarget.ownerDocument;
+    ClickEventHandler.onAboutCertError(originalTarget, ownerDoc);
+
+    let automatic = Services.prefs.getBoolPref("security.ssl.errorReporting.automatic");
+    content.dispatchEvent(new content.CustomEvent("AboutCertErrorOptions", {
+      detail: JSON.stringify({
+        enabled: Services.prefs.getBoolPref("security.ssl.errorReporting.enabled"),
+        automatic,
+      })
+    }));
+
+    if (automatic) {
+      this.onSendReport();
+    }
+  },
+
+  onDetails(msg) {
+    let div = content.document.getElementById("certificateErrorText");
+    div.textContent = msg.data.info;
+  },
+
+  onSetAutomatic(event) {
+    if (event.detail) {
+      this.onSendReport();
+    }
+
+    sendAsyncMessage("Browser:SetSSLErrorReportAuto", {
+      automatic: event.detail
+    });
+  },
+
+  onSendReport() {
+    let doc = content.document;
+    let location = doc.location.href;
+
+    let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
+                     .getService(Ci.nsISerializationHelper);
+
+    let serializable =  docShell.failedChannel.securityInfo
+                                .QueryInterface(Ci.nsITransportSecurityInfo)
+                                .QueryInterface(Ci.nsISerializable);
+
+    let serializedSecurityInfo = serhelper.serializeToString(serializable);
+
+    sendAsyncMessage("Browser:SendSSLErrorReport", {
+      documentURI: doc.documentURI,
+      location: {hostname: doc.location.hostname, port: doc.location.port},
+      securityInfo: serializedSecurityInfo
+    });
+  },
+
+  onReportStatus(msg) {
+    let doc = content.document;
+    if (doc.documentURI != msg.data.documentURI) {
+      return;
+    }
+
+    let reportSendingMsg = doc.getElementById("reportSendingMessage");
+    let reportSentMsg = doc.getElementById("reportSentMessage");
+    let retryBtn = doc.getElementById("reportCertificateErrorRetry");
+
+    switch (msg.data.reportStatus) {
+      case "activity":
+        // Hide the button that was just clicked
+        retryBtn.style.removeProperty("display");
+        reportSentMsg.style.removeProperty("display");
+        reportSendingMsg.style.display = "block";
+        break;
+      case "error":
+        // show the retry button
+        retryBtn.style.display = "block";
+        reportSendingMsg.style.removeProperty("display");
+        sendAsyncMessage("Browser:SSLErrorReportTelemetry",
+                         {reportStatus: TLS_ERROR_REPORT_TELEMETRY_FAILURE});
+        break;
+      case "complete":
+        // Show a success indicator
+        reportSentMsg.style.display = "block";
+        reportSendingMsg.style.removeProperty("display");
+        sendAsyncMessage("Browser:SSLErrorReportTelemetry",
+                         {reportStatus: TLS_ERROR_REPORT_TELEMETRY_SUCCESS});
+        break;
+    }
+  }
+};
+
+AboutCertErrorListener.init(this);
+
+
 var AboutNetErrorListener = {
   init: function(chromeGlobal) {
     chromeGlobal.addEventListener('AboutNetErrorLoad', this, false, true);
     chromeGlobal.addEventListener('AboutNetErrorSetAutomatic', this, false, true);
     chromeGlobal.addEventListener('AboutNetErrorSendReport', this, false, true);
     chromeGlobal.addEventListener('AboutNetErrorUIExpanded', this, false, true);
     chromeGlobal.addEventListener('AboutNetErrorOverride', this, false, true);
   },
@@ -278,27 +415,25 @@ var AboutNetErrorListener = {
       });
   },
 
   onSendReport: function(evt) {
     let contentDoc = content.document;
 
     let reportSendingMsg = contentDoc.getElementById("reportSendingMessage");
     let reportSentMsg = contentDoc.getElementById("reportSentMessage");
-    let reportBtn = contentDoc.getElementById("reportCertificateError");
     let retryBtn = contentDoc.getElementById("reportCertificateErrorRetry");
 
     addMessageListener("Browser:SSLErrorReportStatus", function(message) {
       // show and hide bits - but only if this is a message for the right
       // document - we'll compare on document URI
       if (contentDoc.documentURI === message.data.documentURI) {
         switch(message.data.reportStatus) {
         case "activity":
           // Hide the button that was just clicked
-          reportBtn.style.display = "none";
           retryBtn.style.display = "none";
           reportSentMsg.style.display = "none";
           reportSendingMsg.style.removeProperty("display");
           break;
         case "error":
           // show the retry button
           retryBtn.style.removeProperty("display");
           reportSendingMsg.style.display = "none";
@@ -314,30 +449,32 @@ var AboutNetErrorListener = {
           break;
         }
       }
     });
 
     let location = contentDoc.location.href;
 
     let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
-                     .getService(Ci.nsISerializationHelper);
+                      .getService(Ci.nsISerializationHelper);
 
-    let serializable =  docShell.failedChannel.securityInfo
-                                .QueryInterface(Ci.nsITransportSecurityInfo)
-                                .QueryInterface(Ci.nsISerializable);
+    let serializable = docShell.failedChannel.securityInfo
+                               .QueryInterface(Ci.nsITransportSecurityInfo)
+                               .QueryInterface(Ci.nsISerializable);
 
     let serializedSecurityInfo = serhelper.serializeToString(serializable);
 
     sendAsyncMessage("Browser:SendSSLErrorReport", {
-        elementId: evt.target.id,
-        documentURI: contentDoc.documentURI,
-        location: {hostname: contentDoc.location.hostname, port: contentDoc.location.port},
-        securityInfo: serializedSecurityInfo
-      });
+      documentURI: contentDoc.documentURI,
+      location: {
+        hostname: contentDoc.location.hostname,
+        port: contentDoc.location.port
+      },
+      securityInfo: serializedSecurityInfo
+    });
   },
 
   onOverride: function(evt) {
     let contentDoc = content.document;
     let location = contentDoc.location;
 
     sendAsyncMessage("Browser:OverrideWeakCrypto", {
       documentURI: contentDoc.documentURI,
@@ -548,27 +685,16 @@ var pluginContent = new PluginContent(gl
 addEventListener("DOMWebNotificationClicked", function(event) {
   sendAsyncMessage("DOMWebNotificationClicked", {});
 }, false);
 
 addEventListener("DOMServiceWorkerFocusClient", function(event) {
   sendAsyncMessage("DOMServiceWorkerFocusClient", {});
 }, false);
 
-addEventListener("AboutCertErrorLoad", function(event) {
-  let originalTarget = event.originalTarget;
-  let ownerDoc = originalTarget.ownerDocument;
-  ClickEventHandler.onAboutCertError(originalTarget, ownerDoc);
-}, false, true);
-
-addMessageListener("AboutCertErrorDetails", function(message) {
-  let div = content.document.getElementById("certificateErrorText");
-  div.textContent = message.data.info;
-});
-
 ContentWebRTC.init();
 addMessageListener("rtcpeer:Allow", ContentWebRTC);
 addMessageListener("rtcpeer:Deny", ContentWebRTC);
 addMessageListener("webrtc:Allow", ContentWebRTC);
 addMessageListener("webrtc:Deny", ContentWebRTC);
 addMessageListener("webrtc:StopSharing", ContentWebRTC);
 addMessageListener("webrtc:StartBrowserSharing", () => {
   let windowID = content.QueryInterface(Ci.nsIInterfaceRequestor)
--- a/browser/base/content/newtab/grid.js
+++ b/browser/base/content/newtab/grid.js
@@ -128,17 +128,17 @@ var gGrid = {
 
     // Creates all the cells up to the maximum
     let fragment = document.createDocumentFragment();
     for (let i = 0; i < gGridPrefs.gridColumns * gGridPrefs.gridRows; i++) {
       fragment.appendChild(cell.cloneNode(true));
     }
 
     // Create cells.
-    let cells = [new Cell(this, cell) for (cell of fragment.childNodes)];
+    let cells = Array.from(fragment.childNodes, (cell) => new Cell(this, cell));
 
     // Fetch links.
     let links = gLinks.getLinks();
 
     // Create sites.
     let numLinks = Math.min(links.length, cells.length);
     for (let i = 0; i < numLinks; i++) {
       if (links[i]) {
deleted file mode 100644
--- a/browser/base/content/newtab/intro.js
+++ /dev/null
@@ -1,95 +0,0 @@
-#ifdef 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/. */
-#endif
-
-const PREF_INTRO_SHOWN = "browser.newtabpage.introShown";
-const PREF_NEWTAB_ENHANCED = "browser.newtabpage.enhanced";
-
-var gIntro = {
-  _nodeIDSuffixes: [
-    "mask",
-    "modal",
-    "text",
-    "buttons",
-    "header",
-    "footer"
-  ],
-
-  _paragraphs: [],
-
-  _nodes: {},
-
-  init: function() {
-    for (let idSuffix of this._nodeIDSuffixes) {
-      this._nodes[idSuffix] = document.getElementById("newtab-intro-" + idSuffix);
-    }
-  },
-
-  _showMessage: function() {
-    // Set the paragraphs
-    let paragraphNodes = this._nodes.text.getElementsByTagName("p");
-
-    this._paragraphs.forEach((arg, index) => {
-      paragraphNodes[index].innerHTML = arg;
-    });
-
-    // Set the button
-    document.getElementById("newtab-intro-button").
-             setAttribute("value", newTabString("intro.gotit"));
-  },
-
-  _bold: function(str) {
-    return `<strong>${str}</strong>`;
-  },
-
-  _link: function(url, text) {
-    return `<a href="${url}" target="_blank">${text}</a>`;
-  },
-
-  _exitIntro: function() {
-    this._nodes.mask.style.opacity = 0;
-    this._nodes.mask.addEventListener("transitionend", () => {
-      this._nodes.mask.style.display = "none";
-    });
-  },
-
-  _generateParagraphs: function() {
-    let customizeIcon = '<input type="button" class="newtab-control newtab-customize"/>';
-    this._paragraphs.push(newTabString("intro1.paragraph1"));
-    this._paragraphs.push(newTabString("intro1.paragraph2",
-                            [
-                              this._link(TILES_PRIVACY_LINK, newTabString("privacy.link")),
-                              customizeIcon
-                            ]));
-  },
-
-  showIfNecessary: function() {
-    if (!Services.prefs.getBoolPref(PREF_NEWTAB_ENHANCED)) {
-      return;
-    }
-    if (!Services.prefs.getBoolPref(PREF_INTRO_SHOWN)) {
-      this.showPanel();
-      Services.prefs.setBoolPref(PREF_INTRO_SHOWN, true);
-    }
-  },
-
-  showPanel: function() {
-    this._nodes.mask.style.display = "block";
-    this._nodes.mask.style.opacity = 1;
-
-    if (!this._paragraphs.length) {
-      // It's our first time showing the panel. Do some initial setup
-      this._generateParagraphs();
-    }
-    this._showMessage();
-
-    // Header text
-    this._nodes.header.innerHTML = newTabString("intro.header.update");
-
-    // Footer links
-    let footerLinkNode = document.getElementById("newtab-intro-link");
-    footerLinkNode.innerHTML = this._link(TILES_INTRO_LINK, newTabString("learn.link2"))
-  },
-};
--- a/browser/base/content/newtab/newTab.css
+++ b/browser/base/content/newtab/newTab.css
@@ -124,34 +124,23 @@ input[type=button] {
 
 /*
  * If you change the sizes here, make sure you
  * change the preferences:
  * toolkit.pageThumbs.minWidth
  * toolkit.pageThumbs.minHeight
  */
 /* CELLS */
-.newtab-cell,
-.newtab-intro-cell,
-.newtab-intro-cell-hover {
+.newtab-cell {
   display: -moz-box;
   height: 210px;
   margin: 20px 10px 35px;
   width: 290px;
 }
 
-.newtab-intro-cell-wrapper {
-  margin-top: -12px;
-}
-
-.newtab-intro-cell,
-.newtab-intro-cell-hover {
-  margin: 0;
-}
-
 /* SITES */
 .newtab-site {
   position: relative;
   -moz-box-flex: 1;
   transition: 100ms ease-out;
   transition-property: top, left, opacity;
 }
 
@@ -299,18 +288,17 @@ input[type=button] {
 .newtab-control {
   position: absolute;
   top: 4px;
   opacity: 0;
   transition: opacity 100ms ease-out;
 }
 
 .newtab-control:-moz-focusring,
-.newtab-cell:not([ignorehover]) > .newtab-site:hover > .newtab-control,
-.newtab-intro-cell-hover .newtab-control {
+.newtab-cell:not([ignorehover]) > .newtab-site:hover > .newtab-control {
   opacity: 1;
 }
 
 .newtab-control[dragged] {
   opacity: 0 !important;
 }
 
 @media (-moz-touch-enabled) {
@@ -581,21 +569,16 @@ input[type=button] {
   background-position: right 15px center;
 }
 
 .newtab-customize-complex-option:hover > .selectable:not([selected]):-moz-locale-dir(rtl),
 .selectable:not([selected]):hover:-moz-locale-dir(rtl) {
   background-position: right 15px center;
 }
 
-.newtab-intro-image-customize .newtab-customize-panel-item,
-.newtab-intro-image-customize .newtab-customize-complex-option {
-  max-width: 100%;
-}
-
 .newtab-customize-panel-item:not([selected]),
 .newtab-customize-panel-subitem:not([selected]){
   color: #7A7A7A;
 }
 
 .newtab-customize-panel-item:not([selected]):hover {
   color: #FFFFFF;
   background-color: #4A90E2
@@ -657,180 +640,8 @@ input[type=button] {
   -moz-padding-start: 40px;
   border-top: 1px solid threedshadow;
 }
 
 .contentSearchSuggestionTable {
   font: message-box;
   font-size: 16px;
 }
-
-/**
- * Onboarding styling
- */
-
- #newtab-intro-mask {
-  position: fixed;
-  top: 0;
-  left: 0;
-  width: 100%;
-  height: 100%;
-  background: #424F5A;
-  z-index:102;
-  background-color: rgba(66,79,90,0.95);
-  transition: opacity .5s linear;
-  overflow: auto;
-  display: none;
-  text-align: center;
-}
-
-#newtab-intro-modal {
-  font-family: "Helvetica";
-  max-height: 800px;
-  position: fixed;
-  left: 0;
-  right: 0;
-  top: 0;
-  bottom: 0;
-  margin: auto;
-  background: linear-gradient(#FFFFFF, #F9F9F9);
-  box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.7);
-  border-radius: 8px 8px 0px 0px;
-  position: relative;
-  display: inline-block;
-  top: 50%;
-  transform: translateY(-50%);
-}
-
-#newtab-intro-header {
-  font-size: 28px;
-  color: #737980;
-  text-align: center;
-  top: 30px;
-  position: relative;
-  border-bottom: 2px solid #E0DFE0;
-  padding-bottom: 10px;
-  display: block;
-  margin: 0px 50px;
-  font-weight: 100;
-  padding: 0px 15px 10px;
-}
-
-#newtab-intro-header .bold {
-  font-weight: 500;
-  color: #343F48;
-}
-
-#newtab-intro-footer {
-  width: 100%;
-  height: 55px;
-  margin: 0px auto;
-  display: block;
-  position: absolute;
-  background-color: white;
-  box-shadow: 0 -1px 4px -1px #EBEBEB;
-  text-align: center;
-  vertical-align: middle;
-  line-height: 55px;
-}
-
-#newtab-intro-footer > ul {
-  list-style-type: none;
-  margin: 0px;
-  padding: 0px;
-}
-
-#newtab-intro-footer > ul > li {
-  display: inline;
-  padding-left: 10px;
-  padding-right: 10px;
-}
-
-#newtab-intro-footer > ul > li > a {
-  text-decoration: none;
-  color: #4A90E2;
-}
-
-#newtab-intro-footer > ul > li > a:hover {
-  color: #000000;
-}
-
-#newtab-intro-body {
-  position: relative;
-  display: block;
-  margin: 55px 50px 38px;
-}
-
-#newtab-intro-content > * {
-  display: inline-block;
-}
-
-#newtab-intro-content {
-  position: relative;
-}
-
-#newtab-intro-buttons {
-  text-align: center;
-  vertical-align: middle;
-  display: block;
-  bottom: 0px;
-  width: 100%;
-}
-
-#newtab-intro-tile {
-  width: 290px;
-  height: 100%;
-}
-
-#newtab-intro-text {
-  text-align: left;
-  right: 0px;
-  height: 100%;
-  font-size: 14px;
-  line-height: 20px;
-  width: 460px;
-}
-
-#newtab-intro-text > p {
-  margin: 0 0 30px;
-}
-
-#newtab-intro-text > p > a {
-  text-decoration: none;
-  color: #4A90E2;
-}
-
-#newtab-intro-text > p > a:hover {
-  color: #000000;
-}
-
-#newtab-intro-text .newtab-control {
-  background-size: 18px auto;
-  height: 18px;
-  width: 18px;
-  vertical-align: middle;
-  opacity: 1;
-  position: inherit;
-  pointer-events: none;
-}
-
-#newtab-intro-buttons > input {
-  min-width: 120px;
-  height: 50px;
-  margin: 0px 5px;
-  vertical-align: bottom;
-  border-radius: 2px;
-  border: solid 1px #2C72E2;
-  background-color: #FFFFFF;
-  color: #4A90E2;
-  -moz-user-focus: normal;
-  padding: 0px 10px;
-}
-
-#newtab-intro-buttons > input[default] {
-  background-color: #4A90E2;
-  color: #FFFFFF;
-}
-
-#newtab-intro-buttons > input:hover {
-  background-color: #2C72E2;
-  color: #FFFFFF;
-}
--- a/browser/base/content/newtab/newTab.js
+++ b/browser/base/content/newtab/newTab.js
@@ -61,12 +61,11 @@ const TILES_PRIVACY_LINK = "https://www.
 #include dragDataHelper.js
 #include drop.js
 #include dropTargetShim.js
 #include dropPreview.js
 #include updater.js
 #include undo.js
 #include search.js
 #include customize.js
-#include intro.js
 
 // Everything is loaded. Initialize the New Tab Page.
 gPage.init();
--- a/browser/base/content/newtab/newTab.xhtml
+++ b/browser/base/content/newtab/newTab.xhtml
@@ -48,68 +48,44 @@
           </div>
           <div id="newtab-customize-learn" class="newtab-customize-panel-item">
             <label>&newtab.customize.cog.learn;</label>
           </div>
         </div>
     </div>
   </div>
 
-  <div id="newtab-intro-mask">
-    <div id="newtab-intro-modal">
-      <div id="newtab-intro-header"/>
-      <div id="newtab-intro-body">
-        <div id="newtab-intro-content">
-          <div id="newtab-intro-text">
-            <p/><p/>
-          </div>
-        </div>
-        <div id="newtab-intro-buttons">
-          <input id="newtab-intro-button" type="button" default="true" onclick="gIntro._exitIntro()"/>
-        </div>
-      </div>
-      <div id="newtab-intro-footer">
-        <ul>
-          <li id="newtab-intro-link"/>
-        </ul>
+  <div id="newtab-vertical-margin">
+    <div id="newtab-margin-top"/>
+    <div id="newtab-margin-undo-container">
+      <div id="newtab-undo-container" undo-disabled="true">
+        <label id="newtab-undo-label">&newtab.undo.removedLabel;</label>
+        <button id="newtab-undo-button" tabindex="-1"
+                class="newtab-undo-button">&newtab.undo.undoButton;</button>
+        <button id="newtab-undo-restore-button" tabindex="-1"
+                class="newtab-undo-button">&newtab.undo.restoreButton;</button>
+        <button id="newtab-undo-close-button" tabindex="-1" title="&newtab.undo.closeTooltip;"/>
       </div>
     </div>
-  </div>
-
-    <div id="newtab-vertical-margin">
-      <div id="newtab-margin-top"/>
-        <div id="newtab-margin-undo-container">
-          <div id="newtab-undo-container" undo-disabled="true">
-            <label id="newtab-undo-label">&newtab.undo.removedLabel;</label>
-            <button id="newtab-undo-button" tabindex="-1"
-                    class="newtab-undo-button">&newtab.undo.undoButton;</button>
-            <button id="newtab-undo-restore-button" tabindex="-1"
-                    class="newtab-undo-button">&newtab.undo.restoreButton;</button>
-            <button id="newtab-undo-close-button" tabindex="-1" title="&newtab.undo.closeTooltip;"/>
-          </div>
-        </div>
 
-      <div id="newtab-search-container">
-        <div id="newtab-search-form">
-          <div id="newtab-search-icon"/>
-          <input type="text" name="q" value="" id="newtab-search-text"
-                 aria-label="&contentSearchInput.label;" maxlength="256" dir="auto"/>
-          <input id="newtab-search-submit" type="button" value=""
-                 aria-label="&contentSearchSubmit.label;"/>
-        </div>
+    <div id="newtab-search-container">
+      <div id="newtab-search-form">
+        <div id="newtab-search-icon"/>
+        <input type="text" name="q" value="" id="newtab-search-text"
+             aria-label="&contentSearchInput.label;" maxlength="256" dir="auto"/>
+        <input id="newtab-search-submit" type="button" value=""
+             aria-label="&contentSearchSubmit.label;"/>
       </div>
+    </div>
 
-      <div id="newtab-horizontal-margin">
-        <div class="newtab-side-margin"/>
-
-        <div id="newtab-grid">
-        </div>
-
-        <div class="newtab-side-margin"/>
+    <div id="newtab-horizontal-margin">
+      <div class="newtab-side-margin"/>
+      <div id="newtab-grid">
       </div>
-
-      <div id="newtab-margin-bottom"/>
+      <div class="newtab-side-margin"/>
+    </div>
+    <div id="newtab-margin-bottom"/>
   </div>
-      <input id="newtab-customize-button" type="button" dir="&locale.dir;" title="&newtab.customize.title;"/>
+  <input id="newtab-customize-button" type="button" dir="&locale.dir;" title="&newtab.customize.title;"/>
 </body>
 <script type="text/javascript;version=1.8" src="chrome://browser/content/contentSearchUI.js"/>
 <script type="text/javascript;version=1.8" src="chrome://browser/content/newtab/newTab.js"/>
 </html>
--- a/browser/base/content/newtab/page.js
+++ b/browser/base/content/newtab/page.js
@@ -31,35 +31,31 @@ var gPage = {
     let enabled = gAllPages.enabled;
     if (enabled)
       this._init();
 
     this._updateAttributes(enabled);
 
     // Initialize customize controls.
     gCustomize.init();
-
-    // Initialize intro panel.
-    gIntro.init();
   },
 
   /**
    * Listens for notifications specific to this page.
    */
   observe: function Page_observe(aSubject, aTopic, aData) {
     if (aTopic == "nsPref:changed") {
       gCustomize.updateSelected();
 
       let enabled = gAllPages.enabled;
       this._updateAttributes(enabled);
 
       // Update thumbnails to the new enhanced setting
       if (aData == "browser.newtabpage.enhanced") {
         this.update();
-        gIntro.showIfNecessary();
       }
 
       // Initialize the whole page if we haven't done that, yet.
       if (enabled) {
         this._init();
       } else {
         gUndoDialog.hide();
       }
@@ -250,19 +246,16 @@ var gPage = {
     } else {
       addEventListener("load", this);
     }
   },
 
   onPageVisibleAndLoaded() {
     // Send the index of the last visible tile.
     this.reportLastVisibleTileIndex();
-
-    // Show the panel now that anchors are sized
-    gIntro.showIfNecessary();
   },
 
   reportLastVisibleTileIndex() {
     let cwu = window.QueryInterface(Ci.nsIInterfaceRequestor)
                     .getInterface(Ci.nsIDOMWindowUtils);
 
     let rect = cwu.getBoundsWithoutFlushing(gGrid.node);
     let nodes = cwu.nodesFromRect(rect.left, rect.top, 0, rect.width,
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -6,20 +6,16 @@
 Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
 Components.utils.import("resource://gre/modules/InlineSpellChecker.jsm");
 Components.utils.import("resource://gre/modules/LoginManagerContextMenu.jsm");
 Components.utils.import("resource://gre/modules/BrowserUtils.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 
-XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
-  "resource:///modules/CustomizableUI.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "Pocket",
-  "resource:///modules/Pocket.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "LoginHelper",
   "resource://gre/modules/LoginHelper.jsm");
 
 var gContextMenuContentData = null;
 
 function nsContextMenu(aXulMenu, aIsShift) {
   this.shouldDisplay = true;
   this.initMenu(aXulMenu, aIsShift);
@@ -211,35 +207,16 @@ nsContextMenu.prototype = {
     // SimpleServiceDiscovery.services), but SimpleServiceDiscovery is guaranteed
     // to be already loaded, since we load it on startup in nsBrowserGlue,
     // and CastingApps isn't, so check SimpleServiceDiscovery.services first
     // to avoid needing to load CastingApps.jsm if we don't need to.
     shouldShowCast = shouldShowCast && this.mediaURL &&
                      SimpleServiceDiscovery.services.length > 0 &&
                      CastingApps.getServicesForVideo(this.target).length > 0;
     this.setItemAttr("context-castvideo", "disabled", !shouldShowCast);
-
-    this.initPocketItems();
-  },
-
-  initPocketItems: function CM_initPocketItems() {
-    var showSaveCurrentPageToPocket = !(this.onTextInput || this.onLink ||
-                                        this.isContentSelected || this.onImage ||
-                                        this.onCanvas || this.onVideo || this.onAudio);
-    let targetURI = (this.onSaveableLink || this.onPlainTextLink) ? this.linkURI : this.browser.currentURI;
-    let canPocket = CustomizableUI.getPlacementOfWidget("pocket-button") &&
-                    window.pktApi && window.pktApi.isUserLoggedIn();
-    canPocket = canPocket && (targetURI.schemeIs("http") || targetURI.schemeIs("https") ||
-                              (targetURI.schemeIs("about") && ReaderMode.getOriginalUrl(targetURI.spec)));
-    canPocket = canPocket && window.gBrowser && this.browser.getTabBrowser() == window.gBrowser;
-
-    this.showItem("context-pocket", canPocket && showSaveCurrentPageToPocket);
-    let showSaveLinkToPocket = canPocket && !showSaveCurrentPageToPocket &&
-                               (this.onSaveableLink || this.onPlainTextLink);
-    this.showItem("context-savelinktopocket", showSaveLinkToPocket);
   },
 
   initViewItems: function CM_initViewItems() {
     // View source is always OK, unless in directory listing.
     this.showItem("context-viewpartialsource-selection",
                   this.isContentSelected);
     this.showItem("context-viewpartialsource-mathml",
                   this.onMathML && !this.isContentSelected);
@@ -354,24 +331,28 @@ nsContextMenu.prototype = {
     // there is more than MENU_LIMIT providers, we show a submenu for them,
     // otherwise we have a menuitem per provider (added in SocialMarks class).
     let markProviders = SocialMarks.getProviders();
     let enablePageMarks = markProviders.length > 0 && !(this.onLink || this.onImage
                             || this.onVideo || this.onAudio);
     this.showItem("context-markpageMenu", enablePageMarks && markProviders.length > SocialMarks.MENU_LIMIT);
     let enablePageMarkItems = enablePageMarks && markProviders.length <= SocialMarks.MENU_LIMIT;
     let linkmenus = document.getElementsByClassName("context-markpage");
-    [m.hidden = !enablePageMarkItems for (m of linkmenus)];
+    for (let m of linkmenus) {
+      m.hidden = !enablePageMarkItems;
+    }
 
     let enableLinkMarks = markProviders.length > 0 &&
                             ((this.onLink && !this.onMailtoLink) || this.onPlainTextLink);
     this.showItem("context-marklinkMenu", enableLinkMarks && markProviders.length > SocialMarks.MENU_LIMIT);
     let enableLinkMarkItems = enableLinkMarks && markProviders.length <= SocialMarks.MENU_LIMIT;
     linkmenus = document.getElementsByClassName("context-marklink");
-    [m.hidden = !enableLinkMarkItems for (m of linkmenus)];
+    for (let m of linkmenus) {
+      m.hidden = !enableLinkMarkItems;
+    }
 
     // SocialShare
     let shareButton = SocialShare.shareButton;
     let shareEnabled = shareButton && !shareButton.disabled && !this.onSocial;
     let pageShare = shareEnabled && !(this.isContentSelected ||
                             this.onTextInput || this.onLink || this.onImage ||
                             this.onVideo || this.onAudio || this.onCanvas);
     this.showItem("context-sharepage", pageShare);
@@ -1718,24 +1699,16 @@ nsContextMenu.prototype = {
   shareSelect: function CM_shareSelect() {
     SocialShare.sharePage(null, { url: this.browser.currentURI.spec, text: this.textSelected }, this.target);
   },
 
   savePageAs: function CM_savePageAs() {
     saveBrowser(this.browser);
   },
 
-  saveLinkToPocket: function CM_saveLinkToPocket() {
-    Pocket.savePage(this.browser, this.linkURL);
-  },
-
-  savePageToPocket: function CM_saveToPocket() {
-    Pocket.savePage(this.browser, this.browser.currentURI.spec, this.browser.contentTitle);
-  },
-
   printFrame: function CM_printFrame() {
     PrintUtils.printWindow(this.frameOuterWindowID, this.browser);
   },
 
   switchPageDirection: function CM_switchPageDirection() {
     this.browser.messageManager.sendAsyncMessage("SwitchDocumentDirection");
   },
 
@@ -1783,27 +1756,18 @@ nsContextMenu.prototype = {
     if (selectedText.length > 15) {
       let truncLength = 15;
       let truncChar = selectedText[15].charCodeAt(0);
       if (truncChar >= 0xDC00 && truncChar <= 0xDFFF)
         truncLength++;
       selectedText = selectedText.substr(0,truncLength) + this.ellipsis;
     }
 
-    // Use the current engine if the search bar is visible, the default
-    // engine otherwise.
-    var engineName = "";
-    var ss = Cc["@mozilla.org/browser/search-service;1"].