Merge from mozilla-central.
authorDavid Anderson <danderson@mozilla.com>
Mon, 23 Jul 2012 12:37:49 -0700
changeset 110178 b82fb4d04f6025775b8faffb0a9cd46cb7e222bf
parent 110177 23a84dbb258f6d7221ae270708ef3ed42395cd71 (current diff)
parent 103222 d78729026fb9db89f3040e70a2837cc3e221a901 (diff)
child 110179 50e28df7ff8fa9d0fcbac8ade290afce87a601ed
push id2248
push userakeybl@mozilla.com
push dateMon, 08 Oct 2012 19:23:44 +0000
treeherdermozilla-aurora@118a3b748323 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone17.0a1
Merge from mozilla-central.
accessible/src/atk/AccessibleWrap.cpp
accessible/src/base/NotificationController.cpp
accessible/src/base/nsAccessibilityService.cpp
accessible/src/base/nsCoreUtils.cpp
accessible/src/base/nsTextEquivUtils.cpp
accessible/src/base/nsTextEquivUtils.h
accessible/src/generic/ARIAGridAccessible.cpp
accessible/src/generic/Accessible.cpp
accessible/src/generic/HyperTextAccessible.cpp
accessible/src/html/HTMLTableAccessible.cpp
accessible/src/msaa/AccessibleWrap.cpp
b2g/installer/package-manifest.in
browser/base/content/browser.js
browser/base/content/browser.xul
browser/base/content/test/browser_sanitizeDialog.js
browser/components/nsBrowserContentHandler.js
browser/locales/en-US/chrome/browser/browser.dtd
browser/locales/en-US/chrome/browser/devtools/styleinspector.properties
browser/themes/winstripe/browser.css
build/mobile/devicemanagerADB.py
caps/include/nsScriptSecurityManager.h
caps/src/nsScriptSecurityManager.cpp
content/base/public/nsContentUtils.h
content/base/public/nsDeprecatedOperationList.h
content/base/public/nsIXMLHttpRequest.idl
content/base/src/nsDOMParser.cpp
content/base/src/nsEventSource.cpp
content/base/src/nsFrameLoader.cpp
content/base/src/nsInProcessTabChildGlobal.cpp
content/base/src/nsNodeIterator.cpp
content/base/src/nsObjectLoadingContent.cpp
content/base/src/nsTreeWalker.cpp
content/base/src/nsWebSocket.cpp
content/base/src/nsXMLHttpRequest.cpp
content/base/src/nsXMLHttpRequest.h
content/events/src/nsDOMCloseEvent.cpp
content/events/src/nsDOMCloseEvent.h
content/events/src/nsDOMCustomEvent.cpp
content/events/src/nsDOMCustomEvent.h
content/events/src/nsDOMDeviceProximityEvent.cpp
content/events/src/nsDOMDeviceProximityEvent.h
content/events/src/nsDOMDragEvent.cpp
content/events/src/nsDOMEvent.cpp
content/events/src/nsDOMHashChangeEvent.cpp
content/events/src/nsDOMHashChangeEvent.h
content/events/src/nsDOMMessageEvent.cpp
content/events/src/nsDOMMouseEvent.cpp
content/events/src/nsDOMNotifyPaintEvent.cpp
content/events/src/nsDOMPageTransitionEvent.cpp
content/events/src/nsDOMPageTransitionEvent.h
content/events/src/nsDOMPopStateEvent.cpp
content/events/src/nsDOMPopStateEvent.h
content/events/src/nsDOMUIEvent.cpp
content/events/src/nsDOMUserProximityEvent.cpp
content/events/src/nsDOMUserProximityEvent.h
content/events/src/nsEventDispatcher.cpp
content/events/src/nsEventListenerService.cpp
content/svg/content/src/nsSVGGraphicElement.cpp
content/svg/content/src/nsSVGRect.cpp
content/svg/content/src/nsSVGSVGElement.cpp
content/svg/content/src/nsSVGSwitchElement.cpp
content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp
content/xul/content/src/nsXULElement.cpp
content/xul/document/src/nsXULCommandDispatcher.cpp
content/xul/document/src/nsXULControllers.cpp
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
dom/Makefile.in
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/base/nsJSEnvironment.cpp
dom/indexedDB/IDBKeyRange.cpp
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
dom/locales/en-US/chrome/dom/dom.properties
dom/plugins/base/nsNPAPIPluginInstance.cpp
dom/plugins/base/nsNPAPIPluginInstance.h
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/plugins/base/nsPluginInstanceOwner.h
dom/system/nsDeviceSensors.cpp
editor/libeditor/html/nsHTMLDataTransfer.cpp
editor/libeditor/html/nsHTMLEditRules.cpp
editor/libeditor/html/nsHTMLEditor.cpp
editor/libeditor/html/nsWSRunObject.cpp
editor/libeditor/html/nsWSRunObject.h
embedding/android/GeckoAppShell.java
extensions/spellcheck/src/mozInlineSpellChecker.cpp
extensions/spellcheck/src/mozInlineSpellChecker.h
gfx/gl/GLContext.h
gfx/gl/GLContextProviderEGL.cpp
gfx/layers/ImageLayers.h
gfx/layers/Layers.h
gfx/layers/basic/BasicCanvasLayer.cpp
gfx/layers/basic/BasicImageLayer.cpp
gfx/layers/basic/BasicLayers.h
gfx/layers/basic/BasicThebesLayer.cpp
gfx/layers/basic/BasicThebesLayer.h
gfx/layers/d3d10/LayerManagerD3D10.cpp
gfx/layers/d3d10/LayerManagerD3D10.h
gfx/layers/opengl/CanvasLayerOGL.cpp
gfx/layers/opengl/ImageLayerOGL.cpp
gfx/layers/opengl/ImageLayerOGL.h
gfx/layers/opengl/LayerManagerOGL.cpp
gfx/layers/opengl/ThebesLayerOGL.cpp
gfx/layers/opengl/ThebesLayerOGL.h
gfx/src/nsRegion.cpp
gfx/src/nsRegion.h
gfx/thebes/gfxASurface.cpp
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxWindowsPlatform.cpp
gfx/thebes/gfxWindowsPlatform.h
image/decoders/nsICODecoder.cpp
image/src/RasterImage.cpp
image/test/mochitest/Makefile.in
ipc/testshell/XPCShellEnvironment.cpp
js/src/Makefile.in
js/src/frontend/BytecodeCompiler.cpp
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/ParseNode.h
js/src/frontend/Parser.cpp
js/src/gc/Barrier.h
js/src/jit-test/tests/arguments/defaults-decompile.js
js/src/jit-test/tests/arguments/rest-decompile.js
js/src/jit-test/tests/basic/bug673710.js
js/src/js.msg
js/src/jsapi-tests/Makefile.in
js/src/jsapi.cpp
js/src/jsapi.h
js/src/jsarray.cpp
js/src/jscntxt.cpp
js/src/jscntxt.h
js/src/jscompartment.cpp
js/src/jscompartment.h
js/src/jsdbgapi.cpp
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
js/src/jsfun.cpp
js/src/jsfun.h
js/src/jsgc.cpp
js/src/jsgc.h
js/src/jsgcinlines.h
js/src/jsmath.cpp
js/src/jsopcode.cpp
js/src/jsscript.cpp
js/src/jsscript.h
js/src/jsstr.cpp
js/src/jsutil.h
js/src/methodjit/Compiler.cpp
js/src/shell/js.cpp
js/src/tests/e4x/Regress/regress-301692.js
js/src/tests/e4x/Regress/regress-321547.js
js/src/tests/e4x/Regress/regress-331558.js
js/src/tests/e4x/Regress/regress-352097.js
js/src/tests/e4x/TypeConversion/regress-302097.js
js/src/tests/e4x/decompilation/browser.js
js/src/tests/e4x/decompilation/decompile-xml-escapes.js
js/src/tests/e4x/decompilation/regress-349814.js
js/src/tests/e4x/decompilation/regress-349815.js
js/src/tests/e4x/decompilation/regress-349822.js
js/src/tests/e4x/decompilation/regress-349956.js
js/src/tests/e4x/decompilation/regress-350226.js
js/src/tests/e4x/decompilation/regress-350531.js
js/src/tests/e4x/decompilation/regress-351706.js
js/src/tests/e4x/decompilation/regress-351988.js
js/src/tests/e4x/decompilation/regress-352013.js
js/src/tests/e4x/decompilation/regress-352459.js
js/src/tests/e4x/decompilation/regress-352649.js
js/src/tests/e4x/decompilation/regress-352789.js
js/src/tests/e4x/decompilation/regress-355101.js
js/src/tests/e4x/decompilation/regress-355474-01.js
js/src/tests/e4x/decompilation/regress-373678.js
js/src/tests/e4x/decompilation/regress-429249.js
js/src/tests/e4x/decompilation/regress-461233.js
js/src/tests/e4x/decompilation/regress-463360.js
js/src/tests/e4x/decompilation/shell.js
js/src/tests/e4x/extensions/regress-321547.js
js/src/tests/ecma_5/extensions/bug352085.js
js/src/tests/js1_5/Regress/regress-349648.js
js/src/tests/js1_5/decompilation/browser.js
js/src/tests/js1_5/decompilation/regress-344120.js
js/src/tests/js1_5/decompilation/regress-346892.js
js/src/tests/js1_5/decompilation/regress-346902.js
js/src/tests/js1_5/decompilation/regress-346904.js
js/src/tests/js1_5/decompilation/regress-346915.js
js/src/tests/js1_5/decompilation/regress-349484.js
js/src/tests/js1_5/decompilation/regress-349489.js
js/src/tests/js1_5/decompilation/regress-349491.js
js/src/tests/js1_5/decompilation/regress-349596.js
js/src/tests/js1_5/decompilation/regress-349650.js
js/src/tests/js1_5/decompilation/regress-349663.js
js/src/tests/js1_5/decompilation/regress-350242.js
js/src/tests/js1_5/decompilation/regress-350263.js
js/src/tests/js1_5/decompilation/regress-350271.js
js/src/tests/js1_5/decompilation/regress-350666.js
js/src/tests/js1_5/decompilation/regress-350670.js
js/src/tests/js1_5/decompilation/regress-351104.js
js/src/tests/js1_5/decompilation/regress-351219.js
js/src/tests/js1_5/decompilation/regress-351336.js
js/src/tests/js1_5/decompilation/regress-351597.js
js/src/tests/js1_5/decompilation/regress-351625.js
js/src/tests/js1_5/decompilation/regress-351626.js
js/src/tests/js1_5/decompilation/regress-351693.js
js/src/tests/js1_5/decompilation/regress-351705.js
js/src/tests/js1_5/decompilation/regress-351793.js
js/src/tests/js1_5/decompilation/regress-352013.js
js/src/tests/js1_5/decompilation/regress-352022.js
js/src/tests/js1_5/decompilation/regress-352073.js
js/src/tests/js1_5/decompilation/regress-352202.js
js/src/tests/js1_5/decompilation/regress-352312.js
js/src/tests/js1_5/decompilation/regress-352360.js
js/src/tests/js1_5/decompilation/regress-352375.js
js/src/tests/js1_5/decompilation/regress-352453.js
js/src/tests/js1_5/decompilation/regress-352649.js
js/src/tests/js1_5/decompilation/regress-352873-01.js
js/src/tests/js1_5/decompilation/regress-352873-02.js
js/src/tests/js1_5/decompilation/regress-353000.js
js/src/tests/js1_5/decompilation/regress-353120.js
js/src/tests/js1_5/decompilation/regress-353146.js
js/src/tests/js1_5/decompilation/regress-354878.js
js/src/tests/js1_5/decompilation/regress-354910.js
js/src/tests/js1_5/decompilation/regress-356083.js
js/src/tests/js1_5/decompilation/regress-371692.js
js/src/tests/js1_5/decompilation/regress-373678.js
js/src/tests/js1_5/decompilation/regress-375639.js
js/src/tests/js1_5/decompilation/regress-375882.js
js/src/tests/js1_5/decompilation/regress-376564.js
js/src/tests/js1_5/decompilation/regress-383721.js
js/src/tests/js1_5/decompilation/regress-406555.js
js/src/tests/js1_5/decompilation/regress-437288-02.js
js/src/tests/js1_5/decompilation/regress-443071-01.js
js/src/tests/js1_5/decompilation/regress-456964-01.js
js/src/tests/js1_5/decompilation/regress-457093-01.js
js/src/tests/js1_5/decompilation/regress-457824.js
js/src/tests/js1_5/decompilation/regress-460116-01.js
js/src/tests/js1_5/decompilation/regress-460116-02.js
js/src/tests/js1_5/decompilation/regress-460116-03.js
js/src/tests/js1_5/decompilation/regress-460501.js
js/src/tests/js1_5/decompilation/regress-460870.js
js/src/tests/js1_5/decompilation/regress-461108.js
js/src/tests/js1_5/decompilation/regress-461110.js
js/src/tests/js1_5/decompilation/regress-461111.js
js/src/tests/js1_5/decompilation/shell.js
js/src/tests/js1_5/extensions/regress-348986.js
js/src/tests/js1_5/extensions/regress-352261.js
js/src/tests/js1_5/extensions/regress-353214.js
js/src/tests/js1_5/extensions/regress-355736.js
js/src/tests/js1_5/extensions/regress-384680.js
js/src/tests/js1_6/decompilation/browser.js
js/src/tests/js1_6/decompilation/regress-352084.js
js/src/tests/js1_6/decompilation/regress-352613-01.js
js/src/tests/js1_6/decompilation/regress-352613-02.js
js/src/tests/js1_6/decompilation/shell.js
js/src/tests/js1_7/block/regress-344601.js
js/src/tests/js1_7/block/regress-351794.js
js/src/tests/js1_7/decompilation/browser.js
js/src/tests/js1_7/decompilation/regress-346642-01.js
js/src/tests/js1_7/decompilation/regress-349493.js
js/src/tests/js1_7/decompilation/regress-349499.js
js/src/tests/js1_7/decompilation/regress-349602.js
js/src/tests/js1_7/decompilation/regress-349605.js
js/src/tests/js1_7/decompilation/regress-349633.js
js/src/tests/js1_7/decompilation/regress-349634.js
js/src/tests/js1_7/decompilation/regress-350704.js
js/src/tests/js1_7/decompilation/regress-350793-02.js
js/src/tests/js1_7/decompilation/regress-350810.js
js/src/tests/js1_7/decompilation/regress-350991.js
js/src/tests/js1_7/decompilation/regress-351070-01.js
js/src/tests/js1_7/decompilation/regress-351070-03.js
js/src/tests/js1_7/decompilation/regress-351496.js
js/src/tests/js1_7/decompilation/regress-352008.js
js/src/tests/js1_7/decompilation/regress-352011.js
js/src/tests/js1_7/decompilation/regress-352015.js
js/src/tests/js1_7/decompilation/regress-352022.js
js/src/tests/js1_7/decompilation/regress-352025.js
js/src/tests/js1_7/decompilation/regress-352026.js
js/src/tests/js1_7/decompilation/regress-352068.js
js/src/tests/js1_7/decompilation/regress-352079.js
js/src/tests/js1_7/decompilation/regress-352198.js
js/src/tests/js1_7/decompilation/regress-352217.js
js/src/tests/js1_7/decompilation/regress-352266.js
js/src/tests/js1_7/decompilation/regress-352268.js
js/src/tests/js1_7/decompilation/regress-352269.js
js/src/tests/js1_7/decompilation/regress-352272.js
js/src/tests/js1_7/decompilation/regress-352283.js
js/src/tests/js1_7/decompilation/regress-352402.js
js/src/tests/js1_7/decompilation/regress-352415.js
js/src/tests/js1_7/decompilation/regress-352441.js
js/src/tests/js1_7/decompilation/regress-352732.js
js/src/tests/js1_7/decompilation/regress-355004.js
js/src/tests/js1_7/decompilation/regress-355049-01.js
js/src/tests/js1_7/decompilation/regress-355049-02.js
js/src/tests/js1_7/decompilation/regress-355105.js
js/src/tests/js1_7/decompilation/regress-355635.js
js/src/tests/js1_7/decompilation/regress-355786.js
js/src/tests/js1_7/decompilation/regress-356247.js
js/src/tests/js1_7/decompilation/regress-371802.js
js/src/tests/js1_7/decompilation/regress-374713.js
js/src/tests/js1_7/decompilation/regress-375794.js
js/src/tests/js1_7/decompilation/regress-379925.js
js/src/tests/js1_7/decompilation/regress-380506.js
js/src/tests/js1_7/decompilation/regress-410571.js
js/src/tests/js1_7/decompilation/regress-410649.js
js/src/tests/js1_7/decompilation/regress-429252.js
js/src/tests/js1_7/decompilation/shell.js
js/src/tests/js1_7/extensions/regress-346642-02.js
js/src/tests/js1_7/extensions/regress-353214-02.js
js/src/tests/js1_7/regress/regress-351503-01.js
js/src/tests/js1_7/regress/regress-351503-02.js
js/src/tests/js1_8/decompilation/browser.js
js/src/tests/js1_8/decompilation/regress-260106.js
js/src/tests/js1_8/decompilation/regress-346749.js
js/src/tests/js1_8/decompilation/regress-381372.js
js/src/tests/js1_8/decompilation/regress-381504.js
js/src/tests/js1_8/decompilation/regress-381963-01.js
js/src/tests/js1_8/decompilation/regress-381963-02.js
js/src/tests/js1_8/decompilation/regress-382981.js
js/src/tests/js1_8/decompilation/regress-443074.js
js/src/tests/js1_8/decompilation/regress-460504.js
js/src/tests/js1_8/decompilation/regress-461233.js
js/src/tests/js1_8/decompilation/regress-469625-01.js
js/src/tests/js1_8/decompilation/shell.js
js/src/tests/js1_8/genexps/regress-380237-03.js
js/src/tests/js1_8_1/decompilation/browser.js
js/src/tests/js1_8_1/decompilation/regress-346642-01.js
js/src/tests/js1_8_1/decompilation/regress-349605.js
js/src/tests/js1_8_1/decompilation/regress-349634.js
js/src/tests/js1_8_1/decompilation/regress-350991.js
js/src/tests/js1_8_1/decompilation/regress-351070-01.js
js/src/tests/js1_8_1/decompilation/regress-351336.js
js/src/tests/js1_8_1/decompilation/regress-351626.js
js/src/tests/js1_8_1/decompilation/regress-352011.js
js/src/tests/js1_8_1/decompilation/regress-352022.js
js/src/tests/js1_8_1/decompilation/regress-352026.js
js/src/tests/js1_8_1/decompilation/regress-352609.js
js/src/tests/js1_8_1/decompilation/regress-353249.js
js/src/tests/js1_8_1/decompilation/regress-354878.js
js/src/tests/js1_8_1/decompilation/regress-371802.js
js/src/tests/js1_8_1/decompilation/regress-373678-01.js
js/src/tests/js1_8_1/decompilation/regress-380237-03.js
js/src/tests/js1_8_1/decompilation/regress-380237-04.js
js/src/tests/js1_8_1/decompilation/regress-443074.js
js/src/tests/js1_8_1/decompilation/regress-466905-03.js
js/src/tests/js1_8_1/decompilation/regress-530537.js
js/src/tests/js1_8_1/decompilation/shell.js
js/src/tests/js1_8_1/extensions/regress-352281.js
js/src/tests/js1_8_1/regress/regress-452498-091.js
js/src/tests/js1_8_1/regress/regress-452498-107.js
js/src/vm/GlobalObject.cpp
js/xpconnect/shell/xpcshell.cpp
js/xpconnect/src/Makefile.in
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/src/XPCJSRuntime.cpp
layout/base/FrameLayerBuilder.cpp
layout/base/FrameLayerBuilder.h
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsDisplayList.cpp
layout/base/nsDisplayList.h
layout/base/nsLayoutDebugger.cpp
layout/base/nsPresShell.cpp
layout/build/Makefile.in
layout/build/nsLayoutModule.cpp
layout/generic/nsBlockFrame.cpp
layout/generic/nsBlockFrame.h
layout/generic/nsBlockReflowContext.cpp
layout/generic/nsCanvasFrame.cpp
layout/generic/nsColumnSetFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsFrame.h
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsIFrame.h
layout/generic/nsObjectFrame.cpp
layout/generic/nsSelection.cpp
layout/ipc/RenderFrameParent.h
layout/reftests/svg/reftest.list
layout/reftests/svg/smil/reftest.list
layout/style/StyleRule.cpp
layout/style/nsCSSParser.cpp
layout/style/nsCSSRules.cpp
layout/style/nsCSSStyleSheet.cpp
layout/style/nsCSSValue.cpp
layout/style/nsDOMCSSDeclaration.cpp
layout/style/nsDOMCSSRGBColor.cpp
layout/style/nsDOMCSSValueList.cpp
layout/style/nsStyleAnimation.cpp
layout/svg/base/src/nsISVGChildFrame.h
layout/svg/base/src/nsSVGClipPathFrame.h
layout/svg/base/src/nsSVGContainerFrame.cpp
layout/svg/base/src/nsSVGContainerFrame.h
layout/svg/base/src/nsSVGEffects.cpp
layout/svg/base/src/nsSVGForeignObjectFrame.cpp
layout/svg/base/src/nsSVGForeignObjectFrame.h
layout/svg/base/src/nsSVGGlyphFrame.cpp
layout/svg/base/src/nsSVGGlyphFrame.h
layout/svg/base/src/nsSVGImageFrame.cpp
layout/svg/base/src/nsSVGInnerSVGFrame.cpp
layout/svg/base/src/nsSVGInnerSVGFrame.h
layout/svg/base/src/nsSVGIntegrationUtils.cpp
layout/svg/base/src/nsSVGIntegrationUtils.h
layout/svg/base/src/nsSVGMarkerFrame.h
layout/svg/base/src/nsSVGMaskFrame.h
layout/svg/base/src/nsSVGOuterSVGFrame.cpp
layout/svg/base/src/nsSVGOuterSVGFrame.h
layout/svg/base/src/nsSVGPaintServerFrame.h
layout/svg/base/src/nsSVGPathGeometryFrame.cpp
layout/svg/base/src/nsSVGPathGeometryFrame.h
layout/svg/base/src/nsSVGPatternFrame.cpp
layout/svg/base/src/nsSVGStopFrame.cpp
layout/svg/base/src/nsSVGSwitchFrame.cpp
layout/svg/base/src/nsSVGTSpanFrame.cpp
layout/svg/base/src/nsSVGTextFrame.cpp
layout/svg/base/src/nsSVGTextFrame.h
layout/svg/base/src/nsSVGUseFrame.cpp
layout/svg/base/src/nsSVGUtils.cpp
layout/svg/base/src/nsSVGUtils.h
layout/tools/reftest/reftest.js
layout/xul/base/src/nsTextBoxFrame.cpp
mobile/android/base/GeckoApp.java
mobile/android/base/GeckoAppShell.java
mobile/android/base/Makefile.in
mobile/android/chrome/content/browser.js
mobile/xul/app/mobile.js
modules/libpref/src/init/all.js
mozglue/android/APKOpen.cpp
netwerk/base/public/nsIPrivateBrowsingConsumer.idl
netwerk/base/public/nsNetUtil.h
netwerk/base/src/PrivateBrowsingConsumer.h
netwerk/base/src/nsBaseChannel.h
netwerk/base/src/nsChannelClassifier.cpp
netwerk/cache/nsDiskCacheBlockFile.cpp
netwerk/cache/nsDiskCacheBlockFile.h
netwerk/cache/nsDiskCacheDevice.cpp
netwerk/cache/nsDiskCacheMap.cpp
netwerk/cache/nsDiskCacheMap.h
netwerk/protocol/ftp/FTPChannelChild.cpp
netwerk/protocol/ftp/FTPChannelChild.h
netwerk/protocol/ftp/nsFTPChannel.h
netwerk/protocol/ftp/nsFtpConnectionThread.cpp
netwerk/protocol/http/HttpBaseChannel.cpp
netwerk/protocol/http/HttpBaseChannel.h
netwerk/protocol/http/HttpChannelChild.cpp
netwerk/protocol/http/HttpChannelParent.cpp
netwerk/protocol/http/HttpChannelParent.h
netwerk/protocol/http/PHttpChannel.ipdl
netwerk/protocol/http/SpdySession2.cpp
netwerk/protocol/http/SpdySession3.cpp
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/protocol/http/nsHttpChannel.h
netwerk/protocol/http/nsHttpConnectionMgr.cpp
netwerk/protocol/http/nsHttpConnectionMgr.h
netwerk/protocol/http/nsHttpHandler.cpp
netwerk/protocol/http/nsHttpHandler.h
netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp
netwerk/protocol/wyciwyg/WyciwygChannelChild.h
netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
netwerk/protocol/wyciwyg/nsWyciwygChannel.h
netwerk/socket/nsSOCKSIOLayer.cpp
testing/xpcshell/xpcshell.ini
toolkit/components/startup/nsAppStartup.cpp
toolkit/components/startup/nsAppStartup.h
toolkit/components/telemetry/TelemetryHistograms.h
toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
toolkit/components/url-classifier/nsUrlClassifierDBService.h
toolkit/content/tests/unit/test_privatebrowsing_downloadLastDir_c.js
toolkit/mozapps/downloads/tests/unit/test_DownloadLastDir.js
toolkit/mozapps/downloads/tests/unit/test_DownloadLastDirWithCPS.js
toolkit/mozapps/downloads/tests/unit/test_privatebrowsing_downloadLastDir.js
toolkit/mozapps/extensions/AddonRepository.jsm
uriloader/exthandler/nsExternalHelperAppService.cpp
widget/android/AndroidBridge.cpp
widget/android/AndroidBridge.h
widget/android/AndroidJNI.cpp
widget/cocoa/TextInputHandler.h
widget/cocoa/TextInputHandler.mm
widget/os2/nsFilePicker.cpp
--- a/accessible/src/atk/AccessibleWrap.cpp
+++ b/accessible/src/atk/AccessibleWrap.cpp
@@ -681,17 +681,18 @@ getRoleCB(AtkObject *aAtkObj)
 #ifdef DEBUG
   NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(accWrap),
       "Does not support nsIAccessibleText when it should");
 #endif
 
   if (aAtkObj->role != ATK_ROLE_INVALID)
     return aAtkObj->role;
 
-#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role) \
+#define ROLE(geckoRole, stringRole, atkRole, macRole, \
+             msaaRole, ia2Role, nameRule) \
   case roles::geckoRole: \
     aAtkObj->role = atkRole; \
     break;
 
   switch (accWrap->Role()) {
 #include "RoleMap.h"
     default:
       MOZ_NOT_REACHED("Unknown role.");
--- a/accessible/src/base/ARIAStateMap.cpp
+++ b/accessible/src/base/ARIAStateMap.cpp
@@ -1,16 +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 "ARIAStateMap.h"
 
+#include "nsARIAMap.h"
 #include "States.h"
 
 #include "mozilla/dom/Element.h"
 
 using namespace mozilla;
 using namespace mozilla::a11y;
 using namespace mozilla::a11y::aria;
 
@@ -216,21 +217,33 @@ aria::MapToState(EStateRule aRule, dom::
         0, states::MULTISELECTABLE | states::EXTSELECTABLE);
 
       MapTokenType(aElement, aState, data);
       return true;
     }
 
     case eARIAOrientation:
     {
-      static const EnumTypeData data(
-        nsGkAtoms::aria_orientation, states::HORIZONTAL,
-        &nsGkAtoms::vertical, states::VERTICAL);
+      if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::aria_orientation,
+                                NS_LITERAL_STRING("horizontal"), eCaseMatters)) {
+        *aState &= ~states::VERTICAL;
+        *aState |= states::HORIZONTAL;
+      } else if (aElement->AttrValueIs(kNameSpaceID_None,
+                                       nsGkAtoms::aria_orientation,
+                                       NS_LITERAL_STRING("vertical"),
+                                       eCaseMatters)) {
+        *aState &= ~states::HORIZONTAL;
+        *aState |= states::VERTICAL;
+      } else {
+        NS_ASSERTION(!(*aState & (states::HORIZONTAL | states::VERTICAL)),
+                     "orientation state on role with default aria-orientation!");
+        *aState |= GetRoleMap(aElement)->Is(nsGkAtoms::scrollbar) ?
+          states::VERTICAL : states::HORIZONTAL;
+      }
 
-      MapEnumType(aElement, aState, data);
       return true;
     }
 
     case eARIAPressed:
     {
       static const TokenTypeData data(
         nsGkAtoms::aria_pressed, eMixedType,
         states::CHECKABLE, states::PRESSED);
--- a/accessible/src/base/NotificationController.cpp
+++ b/accessible/src/base/NotificationController.cpp
@@ -16,17 +16,19 @@
 #include "TextLeafAccessible.h"
 #include "TextUpdater.h"
 
 #ifdef DEBUG
 #include "Logging.h"
 #endif
 
 #include "mozilla/dom/Element.h"
+#include "mozilla/Telemetry.h"
 
+using namespace mozilla;
 using namespace mozilla::a11y;
 
 // Defines the number of selection add/remove events in the queue when they
 // aren't packed into single selection within event.
 const unsigned int kSelChangeCountToPack = 5;
 
 ////////////////////////////////////////////////////////////////////////////////
 // NotificationCollector
@@ -169,16 +171,18 @@ NotificationController::IsUpdatePending(
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // NotificationCollector: private
 
 void
 NotificationController::WillRefresh(mozilla::TimeStamp aTime)
 {
+  Telemetry::AutoTimer<Telemetry::A11Y_UPDATE_TIME> updateTimer();
+
   // If the document accessible that notification collector was created for is
   // now shut down, don't process notifications anymore.
   NS_ASSERTION(mDocument,
                "The document was shut down while refresh observer is attached!");
   if (!mDocument)
     return;
 
   // Any generic notifications should be queued if we're processing content
--- a/accessible/src/base/RoleAsserts.cpp
+++ b/accessible/src/base/RoleAsserts.cpp
@@ -6,12 +6,12 @@
 
 #include "nsIAccessibleRole.h"
 #include "Role.h"
 
 #include "mozilla/Assertions.h"
 
 using namespace mozilla::a11y;
 
-#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role) \
+#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, nameRule) \
   MOZ_STATIC_ASSERT(roles::geckoRole == nsIAccessibleRole::ROLE_ ## geckoRole, "internal and xpcom roles differ!");
 #include "RoleMap.h"
 #undef ROLE
--- a/accessible/src/base/RoleMap.h
+++ b/accessible/src/base/RoleMap.h
@@ -1,920 +1,1049 @@
 /* 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/. */
 
 /**
  * Usage: declare the macro ROLE()with the following arguments:
- * ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role)
+ * ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, nameRule)
  */
 
 ROLE(NOTHING,
      "nothing",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityUnknownRole,
      USE_ROLE_STRING,
-     IA2_ROLE_UNKNOWN)
+     IA2_ROLE_UNKNOWN,
+     eFromSubtreeIfRec)
 
 ROLE(TITLEBAR,
      "titlebar",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityUnknownRole,  //Irrelevant on OS X; windows are always native.
      ROLE_SYSTEM_TITLEBAR,
-     ROLE_SYSTEM_TITLEBAR)
+     ROLE_SYSTEM_TITLEBAR,
+     eNoRule)
 
 ROLE(MENUBAR,
      "menubar",
      ATK_ROLE_MENU_BAR,
      NSAccessibilityMenuBarRole,  //Irrelevant on OS X; the menubar will always be native and on the top of the screen.
      ROLE_SYSTEM_MENUBAR,
-     ROLE_SYSTEM_MENUBAR)
+     ROLE_SYSTEM_MENUBAR,
+     eNoRule)
 
 ROLE(SCROLLBAR,
      "scrollbar",
      ATK_ROLE_SCROLL_BAR,
      NSAccessibilityScrollBarRole,  //We might need to make this its own mozAccessible, to support the children objects (valueindicator, down/up buttons).
      ROLE_SYSTEM_SCROLLBAR,
-     ROLE_SYSTEM_SCROLLBAR)
+     ROLE_SYSTEM_SCROLLBAR,
+     eNoRule)
 
 ROLE(GRIP,
      "grip",
      ATK_ROLE_UNKNOWN,
      NSAccessibilitySplitterRole,
      ROLE_SYSTEM_GRIP,
-     ROLE_SYSTEM_GRIP)
+     ROLE_SYSTEM_GRIP,
+     eNoRule)
 
 ROLE(SOUND,
      "sound",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityUnknownRole,  //Unused on OS X.
      ROLE_SYSTEM_SOUND,
-     ROLE_SYSTEM_SOUND)
+     ROLE_SYSTEM_SOUND,
+     eNoRule)
 
 ROLE(CURSOR,
      "cursor",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityUnknownRole,  //Unused on OS X.
      ROLE_SYSTEM_CURSOR,
-     ROLE_SYSTEM_CURSOR)
+     ROLE_SYSTEM_CURSOR,
+     eNoRule)
 
 ROLE(CARET,
      "caret",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityUnknownRole,  //Unused on OS X.
      ROLE_SYSTEM_CARET,
-     ROLE_SYSTEM_CARET)
+     ROLE_SYSTEM_CARET,
+     eNoRule)
 
 ROLE(ALERT,
      "alert",
      ATK_ROLE_ALERT,
      NSAccessibilityWindowRole,
      ROLE_SYSTEM_ALERT,
-     ROLE_SYSTEM_ALERT)
+     ROLE_SYSTEM_ALERT,
+     eNoRule)
 
 ROLE(WINDOW,
      "window",
      ATK_ROLE_WINDOW,
      NSAccessibilityWindowRole,  //Irrelevant on OS X; all window a11y is handled by the system.
      ROLE_SYSTEM_WINDOW,
-     ROLE_SYSTEM_WINDOW)
+     ROLE_SYSTEM_WINDOW,
+     eNoRule)
 
 ROLE(INTERNAL_FRAME,
      "internal frame",
      ATK_ROLE_INTERNAL_FRAME,
      NSAccessibilityScrollAreaRole,
      USE_ROLE_STRING,
-     IA2_ROLE_INTERNAL_FRAME)
+     IA2_ROLE_INTERNAL_FRAME,
+     eNoRule)
 
 ROLE(MENUPOPUP,
      "menupopup",
      ATK_ROLE_MENU,
      NSAccessibilityMenuRole,  //The parent of menuitems.
      ROLE_SYSTEM_MENUPOPUP,
-     ROLE_SYSTEM_MENUPOPUP)
+     ROLE_SYSTEM_MENUPOPUP,
+     eNoRule)
 
 ROLE(MENUITEM,
      "menuitem",
      ATK_ROLE_MENU_ITEM,
      NSAccessibilityMenuItemRole,
      ROLE_SYSTEM_MENUITEM,
-     ROLE_SYSTEM_MENUITEM)
+     ROLE_SYSTEM_MENUITEM,
+     eFromSubtree)
 
 ROLE(TOOLTIP,
      "tooltip",
      ATK_ROLE_TOOL_TIP,
      @"AXHelpTag",  //10.4+ only, so we re-define the constant.
      ROLE_SYSTEM_TOOLTIP,
-     ROLE_SYSTEM_TOOLTIP)
+     ROLE_SYSTEM_TOOLTIP,
+     eFromSubtree)
 
 ROLE(APPLICATION,
      "application",
      ATK_ROLE_EMBEDDED,
      NSAccessibilityGroupRole,  //Unused on OS X. the system will take care of this.
      ROLE_SYSTEM_APPLICATION,
-     ROLE_SYSTEM_APPLICATION)
+     ROLE_SYSTEM_APPLICATION,
+     eNoRule)
 
 ROLE(DOCUMENT,
      "document",
      ATK_ROLE_DOCUMENT_FRAME,
      @"AXWebArea",
      ROLE_SYSTEM_DOCUMENT,
-     ROLE_SYSTEM_DOCUMENT)
+     ROLE_SYSTEM_DOCUMENT,
+     eNoRule)
 
 /**
  *  msaa comment:
  *   We used to map to ROLE_SYSTEM_PANE, but JAWS would
  *   not read the accessible name for the contaning pane.
  *   However, JAWS will read the accessible name for a groupbox.
  *   By mapping a PANE to a GROUPING, we get no undesirable effects,
  *   but fortunately JAWS will then read the group's label,
  *   when an inner control gets focused.
  */
 ROLE(PANE,
      "pane",
      ATK_ROLE_PANEL,
      NSAccessibilityGroupRole,
      ROLE_SYSTEM_GROUPING,
-     ROLE_SYSTEM_GROUPING)
+     ROLE_SYSTEM_GROUPING,
+     eNoRule)
 
 ROLE(CHART,
      "chart",
      ATK_ROLE_CHART,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_CHART,
-     ROLE_SYSTEM_CHART)
+     ROLE_SYSTEM_CHART,
+     eNoRule)
 
 ROLE(DIALOG,
      "dialog",
      ATK_ROLE_DIALOG,
      NSAccessibilityWindowRole,  //There's a dialog subrole.
      ROLE_SYSTEM_DIALOG,
-     ROLE_SYSTEM_DIALOG)
+     ROLE_SYSTEM_DIALOG,
+     eNoRule)
 
 ROLE(BORDER,
      "border",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityUnknownRole,  //Unused on OS X.
      ROLE_SYSTEM_BORDER,
-     ROLE_SYSTEM_BORDER)
+     ROLE_SYSTEM_BORDER,
+     eNoRule)
 
 ROLE(GROUPING,
      "grouping",
      ATK_ROLE_PANEL,
      NSAccessibilityGroupRole,
      ROLE_SYSTEM_GROUPING,
-     ROLE_SYSTEM_GROUPING)
+     ROLE_SYSTEM_GROUPING,
+     eNoRule)
 
 ROLE(SEPARATOR,
      "separator",
      ATK_ROLE_SEPARATOR,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_SEPARATOR,
-     ROLE_SYSTEM_SEPARATOR)
+     ROLE_SYSTEM_SEPARATOR,
+     eNoRule)
 
 ROLE(TOOLBAR,
      "toolbar",
      ATK_ROLE_TOOL_BAR,
      NSAccessibilityToolbarRole,
      ROLE_SYSTEM_TOOLBAR,
-     ROLE_SYSTEM_TOOLBAR)
+     ROLE_SYSTEM_TOOLBAR,
+     eNoRule)
 
 ROLE(STATUSBAR,
      "statusbar",
      ATK_ROLE_STATUSBAR,
      NSAccessibilityUnknownRole,  //Doesn't exist on OS X (a status bar is its parts; a progressbar, a label, etc.)
      ROLE_SYSTEM_STATUSBAR,
-     ROLE_SYSTEM_STATUSBAR)
+     ROLE_SYSTEM_STATUSBAR,
+     eNoRule)
 
 ROLE(TABLE,
      "table",
      ATK_ROLE_TABLE,
      NSAccessibilityGroupRole,
      ROLE_SYSTEM_TABLE,
-     ROLE_SYSTEM_TABLE)
+     ROLE_SYSTEM_TABLE,
+     eNoRule)
 
 ROLE(COLUMNHEADER,
      "columnheader",
      ATK_ROLE_COLUMN_HEADER,
      NSAccessibilityGroupRole,
      ROLE_SYSTEM_COLUMNHEADER,
-     ROLE_SYSTEM_COLUMNHEADER)
+     ROLE_SYSTEM_COLUMNHEADER,
+     eFromSubtree)
 
 ROLE(ROWHEADER,
      "rowheader",
      ATK_ROLE_ROW_HEADER,
      NSAccessibilityGroupRole,
      ROLE_SYSTEM_ROWHEADER,
-     ROLE_SYSTEM_ROWHEADER)
+     ROLE_SYSTEM_ROWHEADER,
+     eFromSubtree)
 
 ROLE(COLUMN,
      "column",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityColumnRole,
      ROLE_SYSTEM_COLUMN,
-     ROLE_SYSTEM_COLUMN)
+     ROLE_SYSTEM_COLUMN,
+     eFromSubtree)
 
 ROLE(ROW,
      "row",
      ATK_ROLE_LIST_ITEM,
      NSAccessibilityRowRole,
      ROLE_SYSTEM_ROW,
-     ROLE_SYSTEM_ROW)
+     ROLE_SYSTEM_ROW,
+     eFromSubtree)
 
 ROLE(CELL,
      "cell",
      ATK_ROLE_TABLE_CELL,
      NSAccessibilityGroupRole,
      ROLE_SYSTEM_CELL,
-     ROLE_SYSTEM_CELL)
+     ROLE_SYSTEM_CELL,
+     eFromSubtreeIfRec)
 
 ROLE(LINK,
      "link",
      ATK_ROLE_LINK,
      @"AXLink",  //10.4+ the attr first define in SDK 10.4, so we define it here too. ROLE_LINK
      ROLE_SYSTEM_LINK,
-     ROLE_SYSTEM_LINK)
+     ROLE_SYSTEM_LINK,
+     eFromSubtree)
 
 ROLE(HELPBALLOON,
      "helpballoon",
      ATK_ROLE_UNKNOWN,
      @"AXHelpTag",
      ROLE_SYSTEM_HELPBALLOON,
-     ROLE_SYSTEM_HELPBALLOON)
+     ROLE_SYSTEM_HELPBALLOON,
+     eFromSubtree)
 
 ROLE(CHARACTER,
      "character",
      ATK_ROLE_IMAGE,
      NSAccessibilityUnknownRole,  //Unused on OS X.
      ROLE_SYSTEM_CHARACTER,
-     ROLE_SYSTEM_CHARACTER)
+     ROLE_SYSTEM_CHARACTER,
+     eNoRule)
 
 ROLE(LIST,
      "list",
      ATK_ROLE_LIST,
      NSAccessibilityListRole,
      ROLE_SYSTEM_LIST,
-     ROLE_SYSTEM_LIST)
+     ROLE_SYSTEM_LIST,
+     eFromSubtreeIfRec)
 
 ROLE(LISTITEM,
      "listitem",
      ATK_ROLE_LIST_ITEM,
      NSAccessibilityGroupRole,
      ROLE_SYSTEM_LISTITEM,
-     ROLE_SYSTEM_LISTITEM)
+     ROLE_SYSTEM_LISTITEM,
+     eFromSubtree)
 
 ROLE(OUTLINE,
      "outline",
      ATK_ROLE_TREE,
      NSAccessibilityOutlineRole,
      ROLE_SYSTEM_OUTLINE,
-     ROLE_SYSTEM_OUTLINE)
+     ROLE_SYSTEM_OUTLINE,
+     eNoRule)
 
 ROLE(OUTLINEITEM,
      "outlineitem",
      ATK_ROLE_LIST_ITEM,
      NSAccessibilityRowRole,  //XXX: use OutlineRow as subrole.
      ROLE_SYSTEM_OUTLINEITEM,
-     ROLE_SYSTEM_OUTLINEITEM)
+     ROLE_SYSTEM_OUTLINEITEM,
+     eFromSubtree)
 
 ROLE(PAGETAB,
      "pagetab",
      ATK_ROLE_PAGE_TAB,
      NSAccessibilityRadioButtonRole,
      ROLE_SYSTEM_PAGETAB,
-     ROLE_SYSTEM_PAGETAB)
+     ROLE_SYSTEM_PAGETAB,
+     eFromSubtree)
 
 ROLE(PROPERTYPAGE,
      "propertypage",
      ATK_ROLE_SCROLL_PANE,
      NSAccessibilityGroupRole,
      ROLE_SYSTEM_PROPERTYPAGE,
-     ROLE_SYSTEM_PROPERTYPAGE)
+     ROLE_SYSTEM_PROPERTYPAGE,
+     eNoRule)
 
 ROLE(INDICATOR,
      "indicator",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_INDICATOR,
-     ROLE_SYSTEM_INDICATOR)
+     ROLE_SYSTEM_INDICATOR,
+     eNoRule)
 
 ROLE(GRAPHIC,
      "graphic",
      ATK_ROLE_IMAGE,
      NSAccessibilityImageRole,
      ROLE_SYSTEM_GRAPHIC,
-     ROLE_SYSTEM_GRAPHIC)
+     ROLE_SYSTEM_GRAPHIC,
+     eNoRule)
 
 ROLE(STATICTEXT,
      "statictext",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityStaticTextRole,
      ROLE_SYSTEM_STATICTEXT,
-     ROLE_SYSTEM_STATICTEXT)
+     ROLE_SYSTEM_STATICTEXT,
+     eNoRule)
 
 ROLE(TEXT_LEAF,
      "text leaf",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityStaticTextRole,
      ROLE_SYSTEM_TEXT,
-     ROLE_SYSTEM_TEXT)
+     ROLE_SYSTEM_TEXT,
+     eNoRule)
 
 ROLE(PUSHBUTTON,
      "pushbutton",
      ATK_ROLE_PUSH_BUTTON,
      NSAccessibilityButtonRole,
      ROLE_SYSTEM_PUSHBUTTON,
-     ROLE_SYSTEM_PUSHBUTTON)
+     ROLE_SYSTEM_PUSHBUTTON,
+     eFromSubtree)
 
 ROLE(CHECKBUTTON,
      "checkbutton",
      ATK_ROLE_CHECK_BOX,
      NSAccessibilityCheckBoxRole,
      ROLE_SYSTEM_CHECKBUTTON,
-     ROLE_SYSTEM_CHECKBUTTON)
+     ROLE_SYSTEM_CHECKBUTTON,
+     eFromSubtree)
 
 ROLE(RADIOBUTTON,
      "radiobutton",
      ATK_ROLE_RADIO_BUTTON,
      NSAccessibilityRadioButtonRole,
      ROLE_SYSTEM_RADIOBUTTON,
-     ROLE_SYSTEM_RADIOBUTTON)
+     ROLE_SYSTEM_RADIOBUTTON,
+     eFromSubtree)
 
 ROLE(COMBOBOX,
      "combobox",
      ATK_ROLE_COMBO_BOX,
      NSAccessibilityPopUpButtonRole,
      ROLE_SYSTEM_COMBOBOX,
-     ROLE_SYSTEM_COMBOBOX)
+     ROLE_SYSTEM_COMBOBOX,
+     eFromValue)
 
 ROLE(DROPLIST,
      "droplist",
      ATK_ROLE_COMBO_BOX,
      NSAccessibilityPopUpButtonRole,
      ROLE_SYSTEM_DROPLIST,
-     ROLE_SYSTEM_DROPLIST)
+     ROLE_SYSTEM_DROPLIST,
+     eNoRule)
 
 ROLE(PROGRESSBAR,
      "progressbar",
      ATK_ROLE_PROGRESS_BAR,
      NSAccessibilityProgressIndicatorRole,
      ROLE_SYSTEM_PROGRESSBAR,
-     ROLE_SYSTEM_PROGRESSBAR)
+     ROLE_SYSTEM_PROGRESSBAR,
+     eFromValue)
 
 ROLE(DIAL,
      "dial",
      ATK_ROLE_DIAL,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_DIAL,
-     ROLE_SYSTEM_DIAL)
+     ROLE_SYSTEM_DIAL,
+     eNoRule)
 
 ROLE(HOTKEYFIELD,
      "hotkeyfield",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_HOTKEYFIELD,
-     ROLE_SYSTEM_HOTKEYFIELD)
+     ROLE_SYSTEM_HOTKEYFIELD,
+     eNoRule)
 
 ROLE(SLIDER,
      "slider",
      ATK_ROLE_SLIDER,
      NSAccessibilitySliderRole,
      ROLE_SYSTEM_SLIDER,
-     ROLE_SYSTEM_SLIDER)
+     ROLE_SYSTEM_SLIDER,
+     eNoRule)
 
 ROLE(SPINBUTTON,
      "spinbutton",
      ATK_ROLE_SPIN_BUTTON,
      NSAccessibilityIncrementorRole,  //Subroles: Increment/Decrement.
      ROLE_SYSTEM_SPINBUTTON,
-     ROLE_SYSTEM_SPINBUTTON)
+     ROLE_SYSTEM_SPINBUTTON,
+     eNoRule)
 
 ROLE(DIAGRAM,
      "diagram",
      ATK_ROLE_IMAGE,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_DIAGRAM,
-     ROLE_SYSTEM_DIAGRAM)
+     ROLE_SYSTEM_DIAGRAM,
+     eNoRule)
 
 ROLE(ANIMATION,
      "animation",
      ATK_ROLE_ANIMATION,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_ANIMATION,
-     ROLE_SYSTEM_ANIMATION)
+     ROLE_SYSTEM_ANIMATION,
+     eNoRule)
 
 ROLE(EQUATION,
      "equation",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_EQUATION,
-     ROLE_SYSTEM_EQUATION)
+     ROLE_SYSTEM_EQUATION,
+     eNoRule)
 
 ROLE(BUTTONDROPDOWN,
      "buttondropdown",
      ATK_ROLE_PUSH_BUTTON,
      NSAccessibilityPopUpButtonRole,
      ROLE_SYSTEM_BUTTONDROPDOWN,
-     ROLE_SYSTEM_BUTTONDROPDOWN)
+     ROLE_SYSTEM_BUTTONDROPDOWN,
+     eFromSubtree)
 
 ROLE(BUTTONMENU,
      "buttonmenu",
      ATK_ROLE_PUSH_BUTTON,
      NSAccessibilityMenuButtonRole,
      ROLE_SYSTEM_BUTTONMENU,
-     ROLE_SYSTEM_BUTTONMENU)
+     ROLE_SYSTEM_BUTTONMENU,
+     eFromSubtree)
 
 ROLE(BUTTONDROPDOWNGRID,
      "buttondropdowngrid",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityGroupRole,
      ROLE_SYSTEM_BUTTONDROPDOWNGRID,
-     ROLE_SYSTEM_BUTTONDROPDOWNGRID)
+     ROLE_SYSTEM_BUTTONDROPDOWNGRID,
+     eFromSubtree)
 
 ROLE(WHITESPACE,
      "whitespace",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_WHITESPACE,
-     ROLE_SYSTEM_WHITESPACE)
+     ROLE_SYSTEM_WHITESPACE,
+     eNoRule)
 
 ROLE(PAGETABLIST,
      "pagetablist",
      ATK_ROLE_PAGE_TAB_LIST,
      NSAccessibilityTabGroupRole,
      ROLE_SYSTEM_PAGETABLIST,
-     ROLE_SYSTEM_PAGETABLIST)
+     ROLE_SYSTEM_PAGETABLIST,
+     eNoRule)
 
 ROLE(CLOCK,
      "clock",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityUnknownRole,  //Unused on OS X
      ROLE_SYSTEM_CLOCK,
-     ROLE_SYSTEM_CLOCK)
+     ROLE_SYSTEM_CLOCK,
+     eNoRule)
 
 ROLE(SPLITBUTTON,
      "splitbutton",
      ATK_ROLE_PUSH_BUTTON,
      NSAccessibilityButtonRole,
      ROLE_SYSTEM_SPLITBUTTON,
-     ROLE_SYSTEM_SPLITBUTTON)
+     ROLE_SYSTEM_SPLITBUTTON,
+     eNoRule)
 
 ROLE(IPADDRESS,
      "ipaddress",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_IPADDRESS,
-     ROLE_SYSTEM_IPADDRESS)
+     ROLE_SYSTEM_IPADDRESS,
+     eNoRule)
 
 ROLE(ACCEL_LABEL,
      "accel label",
      ATK_ROLE_ACCEL_LABEL,
      NSAccessibilityStaticTextRole,
      ROLE_SYSTEM_STATICTEXT,
-     ROLE_SYSTEM_STATICTEXT)
+     ROLE_SYSTEM_STATICTEXT,
+     eNoRule)
 
 ROLE(ARROW,
      "arrow",
      ATK_ROLE_ARROW,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_INDICATOR,
-     ROLE_SYSTEM_INDICATOR)
+     ROLE_SYSTEM_INDICATOR,
+     eNoRule)
 
 ROLE(CANVAS,
      "canvas",
      ATK_ROLE_CANVAS,
      NSAccessibilityImageRole,
      USE_ROLE_STRING,
-     IA2_ROLE_CANVAS)
+     IA2_ROLE_CANVAS,
+     eNoRule)
 
 ROLE(CHECK_MENU_ITEM,
      "check menu item",
      ATK_ROLE_CHECK_MENU_ITEM,
      NSAccessibilityMenuItemRole,
      ROLE_SYSTEM_MENUITEM,
-     IA2_ROLE_CHECK_MENU_ITEM)
+     IA2_ROLE_CHECK_MENU_ITEM,
+     eFromSubtree)
 
 ROLE(COLOR_CHOOSER,
      "color chooser",
      ATK_ROLE_COLOR_CHOOSER,
      NSAccessibilityColorWellRole,
      ROLE_SYSTEM_DIALOG,
-     IA2_ROLE_COLOR_CHOOSER)
+     IA2_ROLE_COLOR_CHOOSER,
+     eNoRule)
 
 ROLE(DATE_EDITOR,
      "date editor",
      ATK_ROLE_DATE_EDITOR,
      NSAccessibilityUnknownRole,
      USE_ROLE_STRING,
-     IA2_ROLE_DATE_EDITOR)
+     IA2_ROLE_DATE_EDITOR,
+     eNoRule)
 
 ROLE(DESKTOP_ICON,
      "desktop icon",
      ATK_ROLE_DESKTOP_ICON,
      NSAccessibilityImageRole,
      USE_ROLE_STRING,
-     IA2_ROLE_DESKTOP_ICON)
+     IA2_ROLE_DESKTOP_ICON,
+     eNoRule)
 
 ROLE(DESKTOP_FRAME,
      "desktop frame",
      ATK_ROLE_DESKTOP_FRAME,
      NSAccessibilityUnknownRole,
      USE_ROLE_STRING,
-     IA2_ROLE_DESKTOP_PANE)
+     IA2_ROLE_DESKTOP_PANE,
+     eNoRule)
 
 ROLE(DIRECTORY_PANE,
      "directory pane",
      ATK_ROLE_DIRECTORY_PANE,
      NSAccessibilityBrowserRole,
      USE_ROLE_STRING,
-     IA2_ROLE_DIRECTORY_PANE)
+     IA2_ROLE_DIRECTORY_PANE,
+     eNoRule)
 
 ROLE(FILE_CHOOSER,
      "file chooser",
      ATK_ROLE_FILE_CHOOSER,
      NSAccessibilityUnknownRole,  //Unused on OS X
      USE_ROLE_STRING,
-     IA2_ROLE_FILE_CHOOSER)
+     IA2_ROLE_FILE_CHOOSER,
+     eNoRule)
 
 ROLE(FONT_CHOOSER,
      "font chooser",
      ATK_ROLE_FONT_CHOOSER,
      NSAccessibilityUnknownRole,
      USE_ROLE_STRING,
-     IA2_ROLE_FONT_CHOOSER)
+     IA2_ROLE_FONT_CHOOSER,
+     eNoRule)
 
 ROLE(CHROME_WINDOW,
      "chrome window",
      ATK_ROLE_FRAME,
      NSAccessibilityUnknownRole,  //Unused on OS X
      ROLE_SYSTEM_APPLICATION,
-     IA2_ROLE_FRAME)
+     IA2_ROLE_FRAME,
+     eNoRule)
 
 ROLE(GLASS_PANE,
      "glass pane",
      ATK_ROLE_GLASS_PANE,
      NSAccessibilityGroupRole,
      USE_ROLE_STRING,
-     IA2_ROLE_GLASS_PANE)
+     IA2_ROLE_GLASS_PANE,
+     eNoRule)
 
 ROLE(HTML_CONTAINER,
      "html container",
      ATK_ROLE_HTML_CONTAINER,
      NSAccessibilityUnknownRole,
      USE_ROLE_STRING,
-     IA2_ROLE_UNKNOWN)
+     IA2_ROLE_UNKNOWN,
+     eFromSubtreeIfRec)
 
 ROLE(ICON,
      "icon",
      ATK_ROLE_ICON,
      NSAccessibilityImageRole,
      ROLE_SYSTEM_PUSHBUTTON,
-     IA2_ROLE_ICON)
+     IA2_ROLE_ICON,
+     eNoRule)
 
 ROLE(LABEL,
      "label",
      ATK_ROLE_LABEL,
      NSAccessibilityGroupRole,
      ROLE_SYSTEM_STATICTEXT,
-     IA2_ROLE_LABEL)
+     IA2_ROLE_LABEL,
+     eFromSubtree)
 
 ROLE(LAYERED_PANE,
      "layered pane",
      ATK_ROLE_LAYERED_PANE,
      NSAccessibilityGroupRole,
      USE_ROLE_STRING,
-     IA2_ROLE_LAYERED_PANE)
+     IA2_ROLE_LAYERED_PANE,
+     eNoRule)
 
 ROLE(OPTION_PANE,
      "option pane",
      ATK_ROLE_OPTION_PANE,
      NSAccessibilityGroupRole,
      USE_ROLE_STRING,
-     IA2_ROLE_OPTION_PANE)
+     IA2_ROLE_OPTION_PANE,
+     eNoRule)
 
 ROLE(PASSWORD_TEXT,
      "password text",
      ATK_ROLE_PASSWORD_TEXT,
      NSAccessibilityTextFieldRole,
      ROLE_SYSTEM_TEXT,
-     ROLE_SYSTEM_TEXT)
+     ROLE_SYSTEM_TEXT,
+     eNoRule)
 
 ROLE(POPUP_MENU,
      "popup menu",
      ATK_ROLE_POPUP_MENU,
      NSAccessibilityUnknownRole,  //Unused
      ROLE_SYSTEM_MENUPOPUP,
-     ROLE_SYSTEM_MENUPOPUP)
+     ROLE_SYSTEM_MENUPOPUP,
+     eNoRule)
 
 ROLE(RADIO_MENU_ITEM,
      "radio menu item",
      ATK_ROLE_RADIO_MENU_ITEM,
      NSAccessibilityMenuItemRole,
      ROLE_SYSTEM_MENUITEM,
-     IA2_ROLE_RADIO_MENU_ITEM)
+     IA2_ROLE_RADIO_MENU_ITEM,
+     eFromSubtree)
 
 ROLE(ROOT_PANE,
      "root pane",
      ATK_ROLE_ROOT_PANE,
      NSAccessibilityGroupRole,
      USE_ROLE_STRING,
-     IA2_ROLE_ROOT_PANE)
+     IA2_ROLE_ROOT_PANE,
+     eNoRule)
 
 ROLE(SCROLL_PANE,
      "scroll pane",
      ATK_ROLE_SCROLL_PANE,
      NSAccessibilityScrollAreaRole,
      USE_ROLE_STRING,
-     IA2_ROLE_SCROLL_PANE)
+     IA2_ROLE_SCROLL_PANE,
+     eNoRule)
 
 ROLE(SPLIT_PANE,
      "split pane",
      ATK_ROLE_SPLIT_PANE,
      NSAccessibilitySplitGroupRole,
      USE_ROLE_STRING,
-     IA2_ROLE_SPLIT_PANE)
+     IA2_ROLE_SPLIT_PANE,
+     eNoRule)
 
 ROLE(TABLE_COLUMN_HEADER,
      "table column header",
      ATK_ROLE_TABLE_COLUMN_HEADER,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_COLUMNHEADER,
-     ROLE_SYSTEM_COLUMNHEADER)
+     ROLE_SYSTEM_COLUMNHEADER,
+     eFromSubtree)
 
 ROLE(TABLE_ROW_HEADER,
      "table row header",
      ATK_ROLE_TABLE_ROW_HEADER,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_ROWHEADER,
-     ROLE_SYSTEM_ROWHEADER)
+     ROLE_SYSTEM_ROWHEADER,
+     eFromSubtree)
 
 ROLE(TEAR_OFF_MENU_ITEM,
      "tear off menu item",
      ATK_ROLE_TEAR_OFF_MENU_ITEM,
      NSAccessibilityMenuItemRole,
      ROLE_SYSTEM_MENUITEM,
-     IA2_ROLE_TEAR_OFF_MENU)
+     IA2_ROLE_TEAR_OFF_MENU,
+     eFromSubtree)
 
 ROLE(TERMINAL,
      "terminal",
      ATK_ROLE_TERMINAL,
      NSAccessibilityUnknownRole,
      USE_ROLE_STRING,
-     IA2_ROLE_TERMINAL)
+     IA2_ROLE_TERMINAL,
+     eNoRule)
 
 ROLE(TEXT_CONTAINER,
      "text container",
      ATK_ROLE_TEXT,
      NSAccessibilityGroupRole,
      USE_ROLE_STRING,
-     IA2_ROLE_TEXT_FRAME)
+     IA2_ROLE_TEXT_FRAME,
+     eFromSubtreeIfRec)
 
 ROLE(TOGGLE_BUTTON,
      "toggle button",
      ATK_ROLE_TOGGLE_BUTTON,
      NSAccessibilityButtonRole,
      ROLE_SYSTEM_PUSHBUTTON,
-     IA2_ROLE_TOGGLE_BUTTON)
+     IA2_ROLE_TOGGLE_BUTTON,
+     eFromSubtree)
 
 ROLE(TREE_TABLE,
      "tree table",
      ATK_ROLE_TREE_TABLE,
      NSAccessibilityTableRole,
      ROLE_SYSTEM_OUTLINE,
-     ROLE_SYSTEM_OUTLINE)
+     ROLE_SYSTEM_OUTLINE,
+     eNoRule)
 
 ROLE(VIEWPORT,
      "viewport",
      ATK_ROLE_VIEWPORT,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_PANE,
-     IA2_ROLE_VIEW_PORT)
+     IA2_ROLE_VIEW_PORT,
+     eNoRule)
 
 ROLE(HEADER,
      "header",
      ATK_ROLE_HEADER,
      NSAccessibilityGroupRole,
      USE_ROLE_STRING,
-     IA2_ROLE_HEADER)
+     IA2_ROLE_HEADER,
+     eNoRule)
 
 ROLE(FOOTER,
      "footer",
      ATK_ROLE_FOOTER,
      NSAccessibilityGroupRole,
      USE_ROLE_STRING,
-     IA2_ROLE_FOOTER)
+     IA2_ROLE_FOOTER,
+     eNoRule)
 
 ROLE(PARAGRAPH,
      "paragraph",
      ATK_ROLE_PARAGRAPH,
      NSAccessibilityGroupRole,
      USE_ROLE_STRING,
-     IA2_ROLE_PARAGRAPH)
+     IA2_ROLE_PARAGRAPH,
+     eFromSubtreeIfRec)
 
 ROLE(RULER,
      "ruler",
      ATK_ROLE_RULER,
      @"AXRuler",  //10.4+ only, so we re-define the constant.
      USE_ROLE_STRING,
-     IA2_ROLE_RULER)
+     IA2_ROLE_RULER,
+     eNoRule)
 
 ROLE(AUTOCOMPLETE,
      "autocomplete",
      ATK_ROLE_AUTOCOMPLETE,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_COMBOBOX,
-     ROLE_SYSTEM_COMBOBOX)
+     ROLE_SYSTEM_COMBOBOX,
+     eNoRule)
 
 ROLE(EDITBAR,
      "editbar",
      ATK_ROLE_EDITBAR,
      NSAccessibilityTextFieldRole,
      ROLE_SYSTEM_TEXT,
-     IA2_ROLE_EDITBAR)
+     IA2_ROLE_EDITBAR,
+     eNoRule)
 
 ROLE(ENTRY,
      "entry",
      ATK_ROLE_ENTRY,
      NSAccessibilityTextFieldRole,
      ROLE_SYSTEM_TEXT,
-     ROLE_SYSTEM_TEXT)
+     ROLE_SYSTEM_TEXT,
+     eFromValue)
 
 ROLE(CAPTION,
      "caption",
      ATK_ROLE_CAPTION,
      NSAccessibilityStaticTextRole,
      USE_ROLE_STRING,
-     IA2_ROLE_CAPTION)
+     IA2_ROLE_CAPTION,
+     eFromSubtreeIfRec)
 
 ROLE(DOCUMENT_FRAME,
      "document frame",
      ATK_ROLE_DOCUMENT_FRAME,
      NSAccessibilityScrollAreaRole,
      USE_ROLE_STRING,
-     IA2_ROLE_UNKNOWN)
+     IA2_ROLE_UNKNOWN,
+     eNoRule)
 
 ROLE(HEADING,
      "heading",
      ATK_ROLE_HEADING,
      @"AXHeading",
      USE_ROLE_STRING,
-     IA2_ROLE_HEADING)
+     IA2_ROLE_HEADING,
+     eFromSubtreeIfRec)
 
 ROLE(PAGE,
      "page",
      ATK_ROLE_PAGE,
      NSAccessibilityGroupRole,
      USE_ROLE_STRING,
-     IA2_ROLE_PAGE)
+     IA2_ROLE_PAGE,
+     eNoRule)
 
 ROLE(SECTION,
      "section",
      ATK_ROLE_SECTION,
      NSAccessibilityGroupRole,
      USE_ROLE_STRING,
-     IA2_ROLE_SECTION)
+     IA2_ROLE_SECTION,
+     eFromSubtreeIfRec)
 
 ROLE(REDUNDANT_OBJECT,
      "redundant object",
      ATK_ROLE_REDUNDANT_OBJECT,
      NSAccessibilityUnknownRole,
      USE_ROLE_STRING,
-     IA2_ROLE_REDUNDANT_OBJECT)
+     IA2_ROLE_REDUNDANT_OBJECT,
+     eNoRule)
 
 ROLE(FORM,
      "form",
      ATK_ROLE_FORM,
      NSAccessibilityGroupRole,
      USE_ROLE_STRING,
-     IA2_ROLE_FORM)
+     IA2_ROLE_FORM,
+     eNoRule)
 
 ROLE(IME,
      "ime",
      ATK_ROLE_INPUT_METHOD_WINDOW,
      NSAccessibilityUnknownRole,
      USE_ROLE_STRING,
-     IA2_ROLE_INPUT_METHOD_WINDOW)
+     IA2_ROLE_INPUT_METHOD_WINDOW,
+     eNoRule)
 
 ROLE(APP_ROOT,
      "app root",
      ATK_ROLE_APPLICATION,
      NSAccessibilityUnknownRole,  //Unused on OS X
      ROLE_SYSTEM_APPLICATION,
-     ROLE_SYSTEM_APPLICATION)
+     ROLE_SYSTEM_APPLICATION,
+     eNoRule)
 
 ROLE(PARENT_MENUITEM,
      "parent menuitem",
      ATK_ROLE_MENU,
      NSAccessibilityMenuItemRole,
      ROLE_SYSTEM_MENUITEM,
-     ROLE_SYSTEM_MENUITEM)
+     ROLE_SYSTEM_MENUITEM,
+     eFromSubtree)
 
 ROLE(CALENDAR,
      "calendar",
      ATK_ROLE_CALENDAR,
      NSAccessibilityGroupRole,
      ROLE_SYSTEM_CLIENT,
-     ROLE_SYSTEM_CLIENT)
+     ROLE_SYSTEM_CLIENT,
+     eNoRule)
 
 ROLE(COMBOBOX_LIST,
      "combobox list",
      ATK_ROLE_MENU,
      NSAccessibilityMenuRole,
      ROLE_SYSTEM_LIST,
-     ROLE_SYSTEM_LIST)
+     ROLE_SYSTEM_LIST,
+     eNoRule)
 
 ROLE(COMBOBOX_OPTION,
      "combobox option",
      ATK_ROLE_MENU_ITEM,
      NSAccessibilityMenuItemRole,
      ROLE_SYSTEM_LISTITEM,
-     ROLE_SYSTEM_LISTITEM)
+     ROLE_SYSTEM_LISTITEM,
+     eFromSubtree)
 
 ROLE(IMAGE_MAP,
      "image map",
      ATK_ROLE_IMAGE,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_GRAPHIC,
-     ROLE_SYSTEM_GRAPHIC)
+     ROLE_SYSTEM_GRAPHIC,
+     eNoRule)
 
 ROLE(OPTION,
      "listbox option",
      ATK_ROLE_LIST_ITEM,
      NSAccessibilityRowRole,
      ROLE_SYSTEM_LISTITEM,
-     ROLE_SYSTEM_LISTITEM)
+     ROLE_SYSTEM_LISTITEM,
+     eFromSubtree)
 
 ROLE(RICH_OPTION,
      "listbox rich option",
      ATK_ROLE_LIST_ITEM,
      NSAccessibilityRowRole,
      ROLE_SYSTEM_LISTITEM,
-     ROLE_SYSTEM_LISTITEM)
+     ROLE_SYSTEM_LISTITEM,
+     eFromSubtree)
 
 ROLE(LISTBOX,
      "listbox",
      ATK_ROLE_LIST,
      NSAccessibilityListRole,
      ROLE_SYSTEM_LIST,
-     ROLE_SYSTEM_LIST)
+     ROLE_SYSTEM_LIST,
+     eNoRule)
 
 ROLE(FLAT_EQUATION,
      "flat equation",
      ATK_ROLE_UNKNOWN,
      NSAccessibilityUnknownRole,
      ROLE_SYSTEM_EQUATION,
-     ROLE_SYSTEM_EQUATION)
+     ROLE_SYSTEM_EQUATION,
+     eNoRule)
 
 ROLE(GRID_CELL,
      "gridcell",
      ATK_ROLE_TABLE_CELL,
      NSAccessibilityGroupRole,
      ROLE_SYSTEM_CELL,
-     ROLE_SYSTEM_CELL)
+     ROLE_SYSTEM_CELL,
+     eFromSubtree)
 
 ROLE(EMBEDDED_OBJECT,
      "embedded object",
      ATK_ROLE_PANEL,
      NSAccessibilityGroupRole,
      USE_ROLE_STRING,
-     IA2_ROLE_EMBEDDED_OBJECT)
+     IA2_ROLE_EMBEDDED_OBJECT,
+     eNoRule)
 
 ROLE(NOTE,
      "note",
      ATK_ROLE_SECTION,
      NSAccessibilityGroupRole,
      USE_ROLE_STRING,
-     IA2_ROLE_NOTE)
+     IA2_ROLE_NOTE,
+     eFromSubtree)
 
 ROLE(FIGURE,
      "figure",
      ATK_ROLE_PANEL,
      NSAccessibilityGroupRole,
      ROLE_SYSTEM_GROUPING,
-     ROLE_SYSTEM_GROUPING)
+     ROLE_SYSTEM_GROUPING,
+     eNoRule)
 
 ROLE(CHECK_RICH_OPTION,
      "check rich option",
      ATK_ROLE_CHECK_BOX,
      NSAccessibilityCheckBoxRole,
      ROLE_SYSTEM_CHECKBUTTON,
-     ROLE_SYSTEM_CHECKBUTTON)
+     ROLE_SYSTEM_CHECKBUTTON,
+     eFromSubtree)
 
 ROLE(DEFINITION_LIST,
      "definitionlist",
      ATK_ROLE_LIST,
      NSAccessibilityListRole,
      ROLE_SYSTEM_LIST,
-     ROLE_SYSTEM_LIST)
+     ROLE_SYSTEM_LIST,
+     eFromSubtreeIfRec)
 
 ROLE(TERM,
      "term",
      ATK_ROLE_LIST_ITEM,
      NSAccessibilityGroupRole,
      ROLE_SYSTEM_LISTITEM,
-     ROLE_SYSTEM_LISTITEM)
+     ROLE_SYSTEM_LISTITEM,
+     eFromSubtree)
 
 ROLE(DEFINITION,
      "definition",
      ATK_ROLE_PARAGRAPH,
      NSAccessibilityGroupRole,
      USE_ROLE_STRING,
-     IA2_ROLE_PARAGRAPH)
+     IA2_ROLE_PARAGRAPH,
+     eFromSubtree)
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -37,16 +37,20 @@
 #include "nsHTMLWin32ObjectAccessible.h"
 #endif
 #include "TextLeafAccessibleWrap.h"
 
 #ifdef DEBUG
 #include "Logging.h"
 #endif
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
+
 #include "nsIDOMDocument.h"
 #include "nsIDOMHTMLObjectElement.h"
 #include "nsIDOMXULElement.h"
 #include "nsImageFrame.h"
 #include "nsIObserverService.h"
 #include "nsLayoutUtils.h"
 #include "nsNPAPIPluginInstance.h"
 #include "nsObjectFrame.h"
@@ -644,17 +648,18 @@ nsAccessibilityService::GetAccessibleFor
     NS_IF_ADDREF(*aAccessible = document->GetAccessible(node));
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAccessibilityService::GetStringRole(PRUint32 aRole, nsAString& aString)
 {
-#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role) \
+#define ROLE(geckoRole, stringRole, atkRole, \
+             macRole, msaaRole, ia2Role, nameRule) \
   case roles::geckoRole: \
     CopyUTF8toUTF16(stringRole, aString); \
     return NS_OK;
 
   switch (aRole) {
 #include "RoleMap.h"
     default:
       aString.AssignLiteral("unknown");
@@ -1218,16 +1223,22 @@ nsAccessibilityService::Init()
 
 #ifdef DEBUG
   logging::CheckEnv();
 #endif
 
   // Initialize accessibility.
   nsAccessNodeWrap::InitAccessibility();
 
+#ifdef MOZ_CRASHREPORTER
+  CrashReporter::
+    AnnotateCrashReport(NS_LITERAL_CSTRING("Accessibility"),
+                        NS_LITERAL_CSTRING("Active"));
+#endif
+
   gIsShutdown = false;
   return true;
 }
 
 void
 nsAccessibilityService::Shutdown()
 {
   // Remove observers.
--- a/accessible/src/base/nsCoreUtils.cpp
+++ b/accessible/src/base/nsCoreUtils.cpp
@@ -198,18 +198,17 @@ nsCoreUtils::GetDOMElementFor(nsIContent
   return nsnull;
 }
 
 nsINode *
 nsCoreUtils::GetDOMNodeFromDOMPoint(nsINode *aNode, PRUint32 aOffset)
 {
   if (aNode && aNode->IsElement()) {
     PRUint32 childCount = aNode->GetChildCount();
-    NS_ASSERTION(aOffset >= 0 && aOffset <= childCount,
-                 "Wrong offset of the DOM point!");
+    NS_ASSERTION(aOffset <= childCount, "Wrong offset of the DOM point!");
 
     // The offset can be after last child of container node that means DOM point
     // is placed immediately after the last child. In this case use the DOM node
     // from the given DOM point is used as result node.
     if (aOffset != childCount)
       return aNode->GetChildAt(aOffset);
   }
 
--- a/accessible/src/base/nsTextEquivUtils.cpp
+++ b/accessible/src/base/nsTextEquivUtils.cpp
@@ -29,19 +29,17 @@ nsTextEquivUtils::GetNameFromSubtree(Acc
                                      nsAString& aName)
 {
   aName.Truncate();
 
   if (gInitiatorAcc)
     return NS_OK;
 
   gInitiatorAcc = aAccessible;
-
-  PRUint32 nameRule = gRoleToNameRulesMap[aAccessible->Role()];
-  if (nameRule == eFromSubtree) {
+  if (GetRoleRule(aAccessible->Role()) == eFromSubtree) {
     //XXX: is it necessary to care the accessible is not a document?
     if (aAccessible->IsContent()) {
       nsAutoString name;
       AppendFromAccessibleChildren(aAccessible, &name);
       name.CompressWhitespace();
       if (!IsWhitespaceString(name))
         aName = name;
     }
@@ -211,17 +209,17 @@ nsTextEquivUtils::AppendFromAccessible(A
 
   if (rv != NS_OK_NO_NAME_CLAUSE_HANDLED)
     isEmptyTextEquiv = false;
 
   // Implementation of g) step of text equivalent computation guide. Go down
   // into subtree if accessible allows "text equivalent from subtree rule" or
   // it's not root and not control.
   if (isEmptyTextEquiv) {
-    PRUint32 nameRule = gRoleToNameRulesMap[aAccessible->Role()];
+    PRUint32 nameRule = GetRoleRule(aAccessible->Role());
     if (nameRule & eFromSubtreeIfRec) {
       rv = AppendFromAccessibleChildren(aAccessible, aString);
       NS_ENSURE_SUCCESS(rv, rv);
 
       if (rv != NS_OK_NO_NAME_CLAUSE_HANDLED)
         isEmptyTextEquiv = false;
     }
   }
@@ -234,18 +232,17 @@ nsTextEquivUtils::AppendFromAccessible(A
 
   return rv;
 }
 
 nsresult
 nsTextEquivUtils::AppendFromValue(Accessible* aAccessible,
                                   nsAString *aString)
 {
-  PRUint32 nameRule = gRoleToNameRulesMap[aAccessible->Role()];
-  if (nameRule != eFromValue)
+  if (GetRoleRule(aAccessible->Role()) != eFromValue)
     return NS_OK_NO_NAME_CLAUSE_HANDLED;
 
   // Implementation of step f. of text equivalent computation. If the given
   // accessible is not root accessible (the accessible the text equivalent is
   // computed for in the end) then append accessible value. Otherwise append
   // value if and only if the given accessible is in the middle of its parent.
 
   nsAutoString text;
@@ -361,143 +358,25 @@ nsTextEquivUtils::IsWhitespaceString(con
 
 bool
 nsTextEquivUtils::IsWhitespace(PRUnichar aChar)
 {
   return aChar == ' ' || aChar == '\n' ||
     aChar == '\r' || aChar == '\t' || aChar == 0xa0;
 }
 
-////////////////////////////////////////////////////////////////////////////////
-// Name rules to role map.
-
-PRUint32 nsTextEquivUtils::gRoleToNameRulesMap[] =
+PRUint32 
+nsTextEquivUtils::GetRoleRule(role aRole)
 {
-  eFromSubtreeIfRec, // ROLE_NOTHING
-  eNoRule,           // ROLE_TITLEBAR
-  eNoRule,           // ROLE_MENUBAR
-  eNoRule,           // ROLE_SCROLLBAR
-  eNoRule,           // ROLE_GRIP
-  eNoRule,           // ROLE_SOUND
-  eNoRule,           // ROLE_CURSOR
-  eNoRule,           // ROLE_CARET
-  eNoRule,           // ROLE_ALERT
-  eNoRule,           // ROLE_WINDOW
-  eNoRule,           // ROLE_INTERNAL_FRAME
-  eNoRule,           // ROLE_MENUPOPUP
-  eFromSubtree,      // ROLE_MENUITEM
-  eFromSubtree,      // ROLE_TOOLTIP
-  eNoRule,           // ROLE_APPLICATION
-  eNoRule,           // ROLE_DOCUMENT
-  eNoRule,           // ROLE_PANE
-  eNoRule,           // ROLE_CHART
-  eNoRule,           // ROLE_DIALOG
-  eNoRule,           // ROLE_BORDER
-  eNoRule,           // ROLE_GROUPING
-  eNoRule,           // ROLE_SEPARATOR
-  eNoRule,           // ROLE_TOOLBAR
-  eNoRule,           // ROLE_STATUSBAR
-  eNoRule,           // ROLE_TABLE
-  eFromSubtree,      // ROLE_COLUMNHEADER
-  eFromSubtree,      // ROLE_ROWHEADER
-  eFromSubtree,      // ROLE_COLUMN
-  eFromSubtree,      // ROLE_ROW
-  eFromSubtreeIfRec, // ROLE_CELL
-  eFromSubtree,      // ROLE_LINK
-  eFromSubtree,      // ROLE_HELPBALLOON
-  eNoRule,           // ROLE_CHARACTER
-  eFromSubtreeIfRec, // ROLE_LIST
-  eFromSubtree,      // ROLE_LISTITEM
-  eNoRule,           // ROLE_OUTLINE
-  eFromSubtree,      // ROLE_OUTLINEITEM
-  eFromSubtree,      // ROLE_PAGETAB
-  eNoRule,           // ROLE_PROPERTYPAGE
-  eNoRule,           // ROLE_INDICATOR
-  eNoRule,           // ROLE_GRAPHIC
-  eNoRule,           // ROLE_STATICTEXT
-  eNoRule,           // ROLE_TEXT_LEAF
-  eFromSubtree,      // ROLE_PUSHBUTTON
-  eFromSubtree,      // ROLE_CHECKBUTTON
-  eFromSubtree,      // ROLE_RADIOBUTTON
-  eFromValue,        // ROLE_COMBOBOX
-  eNoRule,           // ROLE_DROPLIST
-  eFromValue,        // ROLE_PROGRESSBAR
-  eNoRule,           // ROLE_DIAL
-  eNoRule,           // ROLE_HOTKEYFIELD
-  eNoRule,           // ROLE_SLIDER
-  eNoRule,           // ROLE_SPINBUTTON
-  eNoRule,           // ROLE_DIAGRAM
-  eNoRule,           // ROLE_ANIMATION
-  eNoRule,           // ROLE_EQUATION
-  eFromSubtree,      // ROLE_BUTTONDROPDOWN
-  eFromSubtree,      // ROLE_BUTTONMENU
-  eFromSubtree,      // ROLE_BUTTONDROPDOWNGRID
-  eNoRule,           // ROLE_WHITESPACE
-  eNoRule,           // ROLE_PAGETABLIST
-  eNoRule,           // ROLE_CLOCK
-  eNoRule,           // ROLE_SPLITBUTTON
-  eNoRule,           // ROLE_IPADDRESS
-  eNoRule,           // ROLE_ACCEL_LABEL
-  eNoRule,           // ROLE_ARROW
-  eNoRule,           // ROLE_CANVAS
-  eFromSubtree,      // ROLE_CHECK_MENU_ITEM
-  eNoRule,           // ROLE_COLOR_CHOOSER
-  eNoRule,           // ROLE_DATE_EDITOR
-  eNoRule,           // ROLE_DESKTOP_ICON
-  eNoRule,           // ROLE_DESKTOP_FRAME
-  eNoRule,           // ROLE_DIRECTORY_PANE
-  eNoRule,           // ROLE_FILE_CHOOSER
-  eNoRule,           // ROLE_FONT_CHOOSER
-  eNoRule,           // ROLE_CHROME_WINDOW
-  eNoRule,           // ROLE_GLASS_PANE
-  eFromSubtreeIfRec, // ROLE_HTML_CONTAINER
-  eNoRule,           // ROLE_ICON
-  eFromSubtree,      // ROLE_LABEL
-  eNoRule,           // ROLE_LAYERED_PANE
-  eNoRule,           // ROLE_OPTION_PANE
-  eNoRule,           // ROLE_PASSWORD_TEXT
-  eNoRule,           // ROLE_POPUP_MENU
-  eFromSubtree,      // ROLE_RADIO_MENU_ITEM
-  eNoRule,           // ROLE_ROOT_PANE
-  eNoRule,           // ROLE_SCROLL_PANE
-  eNoRule,           // ROLE_SPLIT_PANE
-  eFromSubtree,      // ROLE_TABLE_COLUMN_HEADER
-  eFromSubtree,      // ROLE_TABLE_ROW_HEADER
-  eFromSubtree,      // ROLE_TEAR_OFF_MENU_ITEM
-  eNoRule,           // ROLE_TERMINAL
-  eFromSubtreeIfRec, // ROLE_TEXT_CONTAINER
-  eFromSubtree,      // ROLE_TOGGLE_BUTTON
-  eNoRule,           // ROLE_TREE_TABLE
-  eNoRule,           // ROLE_VIEWPORT
-  eNoRule,           // ROLE_HEADER
-  eNoRule,           // ROLE_FOOTER
-  eFromSubtreeIfRec, // ROLE_PARAGRAPH
-  eNoRule,           // ROLE_RULER
-  eNoRule,           // ROLE_AUTOCOMPLETE
-  eNoRule,           // ROLE_EDITBAR
-  eFromValue,        // ROLE_ENTRY
-  eFromSubtreeIfRec, // ROLE_CAPTION
-  eNoRule,           // ROLE_DOCUMENT_FRAME
-  eFromSubtreeIfRec, // ROLE_HEADING
-  eNoRule,           // ROLE_PAGE
-  eFromSubtreeIfRec, // ROLE_SECTION
-  eNoRule,           // ROLE_REDUNDANT_OBJECT
-  eNoRule,           // ROLE_FORM
-  eNoRule,           // ROLE_IME
-  eNoRule,           // ROLE_APP_ROOT
-  eFromSubtree,      // ROLE_PARENT_MENUITEM
-  eNoRule,           // ROLE_CALENDAR
-  eNoRule,           // ROLE_COMBOBOX_LIST
-  eFromSubtree,      // ROLE_COMBOBOX_OPTION
-  eNoRule,           // ROLE_IMAGE_MAP
-  eFromSubtree,      // ROLE_OPTION
-  eFromSubtree,      // ROLE_RICH_OPTION
-  eNoRule,           // ROLE_LISTBOX
-  eNoRule,           // ROLE_FLAT_EQUATION
-  eFromSubtree,      // ROLE_GRID_CELL
-  eNoRule,           // ROLE_EMBEDDED_OBJECT
-  eFromSubtree,      // ROLE_NOTE
-  eNoRule,           // ROLE_FIGURE
-  eFromSubtree,      // ROLE_CHECK_RICH_OPTION
-  eFromSubtreeIfRec, // ROLE_DEFINITION_LIST
-  eFromSubtree,      // ROLE_TERM
-  eFromSubtree       // ROLE_DEFINITION
-};
+#define ROLE(geckoRole, stringRole, atkRole, \
+             macRole, msaaRole, ia2Role, nameRule) \
+  case roles::geckoRole: \
+    return nameRule;
+
+  switch (aRole) {
+#include "RoleMap.h"
+    default:
+      MOZ_NOT_REACHED("Unknown role.");
+  }
+
+#undef ROLE
+}
+
--- a/accessible/src/base/nsTextEquivUtils.h
+++ b/accessible/src/base/nsTextEquivUtils.h
@@ -4,16 +4,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/. */
 
 #ifndef _nsTextEquivUtils_H_
 #define _nsTextEquivUtils_H_
 
 #include "Accessible.h"
+#include "Role.h"
 
 #include "nsIContent.h"
 #include "nsIStringBundle.h"
 
 /**
  * Text equivalent computation rules (see nsTextEquivUtils::gRoleToNameRulesMap)
  */
 enum ETextEquivRule
@@ -135,19 +136,19 @@ private:
   static bool IsWhitespaceString(const nsSubstring& aString);
 
   /**
    * Returns true if the given character is whitespace symbol.
    */
   static bool IsWhitespace(PRUnichar aChar);
 
   /**
-   * Map array from roles to name rules (constants of ETextEquivRule).
+   * Returns the rule (constant of ETextEquivRule) for a given role.
    */
-  static PRUint32 gRoleToNameRulesMap[];
+  static PRUint32 GetRoleRule(mozilla::a11y::roles::Role aRole);
 
   /**
    * The accessible for which we are computing a text equivalent. It is useful
    * for bailing out during recursive text computation, or for special cases
    * like step f. of the ARIA implementation guide.
    */
   static nsRefPtr<Accessible> gInitiatorAcc;
 };
--- a/accessible/src/generic/ARIAGridAccessible.cpp
+++ b/accessible/src/generic/ARIAGridAccessible.cpp
@@ -260,17 +260,17 @@ ARIAGridAccessible::SelectedCells(nsTArr
         aCells->AppendElement(cell);
     }
   }
 }
 
 void
 ARIAGridAccessible::SelectedCellIndices(nsTArray<PRUint32>* aCells)
 {
-  PRUint32 rowCount = RowCount(), colCount = ColCount();
+  PRUint32 colCount = ColCount();
 
   AccIterator rowIter(this, filters::GetRow);
   Accessible* row = nsnull;
   for (PRUint32 rowIdx = 0; (row = rowIter.Next()); rowIdx++) {
     if (nsAccUtils::IsARIASelected(row)) {
       for (PRUint32 colIdx = 0; colIdx < colCount; colIdx++)
         aCells->AppendElement(rowIdx * colCount + colIdx);
 
--- a/accessible/src/generic/Accessible.cpp
+++ b/accessible/src/generic/Accessible.cpp
@@ -675,20 +675,30 @@ Accessible::NativeState()
   // Gather states::INVISIBLE and states::OFFSCREEN flags for this object.
   state |= VisibilityState();
 
   nsIFrame *frame = GetFrame();
   if (frame && (frame->GetStateBits() & NS_FRAME_OUT_OF_FLOW))
     state |= states::FLOATING;
 
   // Check if a XUL element has the popup attribute (an attached popup menu).
-  if (mContent->IsXUL())
+  if (mContent->IsXUL()) {
     if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::popup))
       state |= states::HASPOPUP;
 
+    const nsStyleXUL *xulStyle = frame->GetStyleXUL();
+    if (xulStyle && frame->IsBoxFrame()) {
+      // In XUL all boxes are either vertical or horizontal
+      if (xulStyle->mBoxOrient == NS_STYLE_BOX_ORIENT_VERTICAL)
+        state |= states::VERTICAL;
+      else
+        state |= states::HORIZONTAL;
+    }
+  }
+
   // Bypass the link states specialization for non links.
   if (!mRoleMapEntry || mRoleMapEntry->roleRule == kUseNativeRole ||
       mRoleMapEntry->role == roles::LINK)
     state |= NativeLinkState();
 
   return state;
 }
 
@@ -1505,27 +1515,16 @@ Accessible::State()
     return state;
 
   const nsStyleDisplay* display = frame->GetStyleDisplay();
   if (display && display->mOpacity == 1.0f &&
       !(state & states::INVISIBLE)) {
     state |= states::OPAQUE1;
   }
 
-  const nsStyleXUL *xulStyle = frame->GetStyleXUL();
-  if (xulStyle) {
-    // In XUL all boxes are either vertical or horizontal
-    if (xulStyle->mBoxOrient == NS_STYLE_BOX_ORIENT_VERTICAL) {
-      state |= states::VERTICAL;
-    }
-    else {
-      state |= states::HORIZONTAL;
-    }
-  }
-
   return state;
 }
 
 void
 Accessible::ApplyARIAState(PRUint64* aState) const
 {
   if (!mContent->IsElement())
     return;
--- a/accessible/src/generic/HyperTextAccessible.cpp
+++ b/accessible/src/generic/HyperTextAccessible.cpp
@@ -1803,18 +1803,16 @@ HyperTextAccessible::SetSelectionBounds(
   Selection* domSel =
     frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL);
   NS_ENSURE_STATE(domSel);
 
   PRUint32 rangeCount = domSel->GetRangeCount();
   if (rangeCount < static_cast<PRUint32>(aSelectionNum))
     return NS_ERROR_INVALID_ARG;
 
-  // Caret is a collapsed selection
-  bool isOnlyCaret = (aStartOffset == aEndOffset);
   nsRefPtr<nsRange> range;
   if (aSelectionNum == rangeCount)
     range = new nsRange();
   else
     range = domSel->GetRangeAt(aSelectionNum);
 
   nsresult rv = HypertextOffsetsToDOMRange(aStartOffset, aEndOffset, range);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/accessible/src/html/HTMLTableAccessible.cpp
+++ b/accessible/src/html/HTMLTableAccessible.cpp
@@ -31,16 +31,17 @@
 #include "nsIPresShell.h"
 #include "nsITableLayout.h"
 #include "nsITableCellLayout.h"
 #include "nsFrameSelection.h"
 #include "nsLayoutErrors.h"
 #include "nsArrayUtils.h"
 #include "nsComponentManagerUtils.h"
 
+using namespace mozilla;
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLTableCellAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 HTMLTableCellAccessible::
   HTMLTableCellAccessible(nsIContent* aContent, DocAccessible* aDoc) :
@@ -761,40 +762,42 @@ HTMLTableAccessible::ColExtentAt(PRUint3
   if (!tableLayout)
     return 0;
 
   nsCOMPtr<nsIDOMElement> domElement;
   PRInt32 startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan;
   bool isSelected;
   PRInt32 columnExtent = 0;
 
-  tableLayout->
+  DebugOnly<nsresult> rv = tableLayout->
     GetCellDataAt(aRowIdx, aColIdx, *getter_AddRefs(domElement),
                   startRowIndex, startColIndex, rowSpan, colSpan,
                   actualRowSpan, columnExtent, isSelected);
+  NS_ASSERTION(NS_SUCCEEDED(rv), "Could not get cell data");
 
   return columnExtent;
 }
 
 PRUint32
 HTMLTableAccessible::RowExtentAt(PRUint32 aRowIdx, PRUint32 aColIdx)
 {
   nsITableLayout* tableLayout = GetTableLayout();
   if (!tableLayout)
     return 0;
 
   nsCOMPtr<nsIDOMElement> domElement;
   PRInt32 startRowIndex, startColIndex, rowSpan, colSpan, actualColSpan;
   bool isSelected;
   PRInt32 rowExtent = 0;
 
-  tableLayout->
+  DebugOnly<nsresult> rv = tableLayout->
     GetCellDataAt(aRowIdx, aColIdx, *getter_AddRefs(domElement),
                   startRowIndex, startColIndex, rowSpan, colSpan,
                   rowExtent, actualColSpan, isSelected);
+  NS_ASSERTION(NS_SUCCEEDED(rv), "Could not get cell data");
 
   return rowExtent;
 }
 
 bool
 HTMLTableAccessible::IsColSelected(PRUint32 aColIdx)
 {
   bool isSelected = false;
--- a/accessible/src/jsat/AccessFu.jsm
+++ b/accessible/src/jsat/AccessFu.jsm
@@ -58,18 +58,20 @@ var AccessFu = {
     if (this._enabled)
       return;
     this._enabled = true;
 
     Logger.info('enable');
     this.addPresenter(new VisualPresenter());
 
     // Implicitly add the Android presenter on Android.
-    if (Utils.OS == 'Android')
+    if (Utils.MozBuildApp == 'mobile/android')
       this.addPresenter(new AndroidPresenter());
+    else if (Utils.MozBuildApp == 'b2g')
+      this.addPresenter(new SpeechPresenter());
 
     VirtualCursorController.attach(this.chromeWin);
 
     Services.obs.addObserver(this, 'accessible-event', false);
     this.chromeWin.addEventListener('DOMActivate', this, true);
     this.chromeWin.addEventListener('resize', this, true);
     this.chromeWin.addEventListener('scroll', this, true);
     this.chromeWin.addEventListener('TabOpen', this, true);
@@ -350,26 +352,28 @@ var AccessFu = {
                             text, event.modifiedText);
             }
           );
         }
         break;
       }
       case Ci.nsIAccessibleEvent.EVENT_SCROLLING_START:
       {
-        VirtualCursorController.moveCursorToObject(aEvent.accessible);
+        VirtualCursorController.moveCursorToObject(
+          Utils.getVirtualCursor(aEvent.accessibleDocument), aEvent.accessible);
         break;
       }
       case Ci.nsIAccessibleEvent.EVENT_FOCUS:
       {
         let acc = aEvent.accessible;
         let doc = aEvent.accessibleDocument;
         if (acc.role != Ci.nsIAccessibleRole.ROLE_DOCUMENT &&
             doc.role != Ci.nsIAccessibleRole.ROLE_CHROME_WINDOW)
-          VirtualCursorController.moveCursorToObject(acc);
+          VirtualCursorController.moveCursorToObject(
+            Utils.getVirtualCursor(doc), acc);
 
         let [,extState] = Utils.getStates(acc);
         let editableState = extState &
           (Ci.nsIAccessibleStates.EXT_STATE_EDITABLE |
            Ci.nsIAccessibleStates.EXT_STATE_MULTI_LINE);
 
         if (editableState != VirtualCursorController.editableState) {
           if (!VirtualCursorController.editableState)
--- a/accessible/src/jsat/Presenters.jsm
+++ b/accessible/src/jsat/Presenters.jsm
@@ -10,16 +10,17 @@ const Cu = Components.utils;
 const Cr = Components.results;
 
 Cu.import('resource://gre/modules/accessibility/Utils.jsm');
 Cu.import('resource://gre/modules/accessibility/UtteranceGenerator.jsm');
 
 var EXPORTED_SYMBOLS = ['VisualPresenter',
                         'AndroidPresenter',
                         'DummyAndroidPresenter',
+                        'SpeechPresenter',
                         'PresenterContext'];
 
 /**
  * The interface for all presenter classes. A presenter could be, for example,
  * a speech output module, or a visual cursor indicator.
  */
 function Presenter() {}
 
@@ -392,16 +393,51 @@ DummyAndroidPresenter.prototype = {
   __proto__: AndroidPresenter.prototype,
 
   sendMessageToJava: function DummyAndroidPresenter_sendMessageToJava(aMsg) {
     Logger.debug('Android event:\n' + JSON.stringify(aMsg, null, 2));
   }
 };
 
 /**
+ * A speech presenter for direct TTS output
+ */
+
+function SpeechPresenter() {}
+
+SpeechPresenter.prototype = {
+  __proto__: Presenter.prototype,
+
+
+  pivotChanged: function SpeechPresenter_pivotChanged(aContext, aReason) {
+    if (!aContext.accessible)
+      return;
+
+    let output = [];
+
+    aContext.newAncestry.forEach(
+      function(acc) {
+        output.push.apply(output, UtteranceGenerator.genForObject(acc));
+      }
+    );
+
+    output.push.apply(output,
+                      UtteranceGenerator.genForObject(aContext.accessible));
+
+    aContext.subtreePreorder.forEach(
+      function(acc) {
+        output.push.apply(output, UtteranceGenerator.genForObject(acc));
+      }
+    );
+
+    Logger.info('SPEAK', '"' + output.join(' ') + '"');
+  }
+}
+
+/**
  * PresenterContext: An object that generates and caches context information
  * for a given accessible and its relationship with another accessible.
  */
 function PresenterContext(aAccessible, aOldAccessible) {
   this._accessible = aAccessible;
   this._oldAccessible =
     this._isDefunct(aOldAccessible) ? null : aOldAccessible;
 }
--- a/accessible/src/jsat/Utils.jsm
+++ b/accessible/src/jsat/Utils.jsm
@@ -11,16 +11,29 @@ const Ci = Components.interfaces;
 Cu.import('resource://gre/modules/Services.jsm');
 
 var EXPORTED_SYMBOLS = ['Utils', 'Logger'];
 
 var gAccRetrieval = Cc['@mozilla.org/accessibleRetrieval;1'].
   getService(Ci.nsIAccessibleRetrieval);
 
 var Utils = {
+  _buildAppMap: {
+    '{3c2e2abc-06d4-11e1-ac3b-374f68613e61}': 'b2g',
+    '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': 'browser',
+    '{aa3c5121-dab2-40e2-81ca-7ea25febc110}': 'mobile/android',
+    '{a23983c0-fd0e-11dc-95ff-0800200c9a66}': 'mobile/xul'
+  },
+
+  get MozBuildApp() {
+    if (!this._buildApp)
+      this._buildApp = this._buildAppMap[Services.appinfo.ID];
+    return this._buildApp;
+  },
+
   get OS() {
     if (!this._OS)
       this._OS = Services.appinfo.OS;
     return this._OS;
   },
 
   get AndroidSdkVersion() {
     if (!this._AndroidSdkVersion) {
@@ -35,45 +48,66 @@ var Utils = {
   },
 
   set AndroidSdkVersion(value) {
     // When we want to mimic another version.
     this._AndroidSdkVersion = value;
   },
 
   getBrowserApp: function getBrowserApp(aWindow) {
-    switch (this.OS) {
-      case 'Android':
+    switch (this.MozBuildApp) {
+      case 'mobile/android':
         return aWindow.BrowserApp;
+      case 'browser':
+        return aWindow.gBrowser;
+      case 'b2g':
+        return aWindow.shell;
       default:
-        return aWindow.gBrowser;
+        return null;
     }
   },
 
   getCurrentContentDoc: function getCurrentContentDoc(aWindow) {
+    if (this.MozBuildApp == "b2g")
+      return this.getBrowserApp(aWindow).contentBrowser.contentDocument;
     return this.getBrowserApp(aWindow).selectedBrowser.contentDocument;
   },
 
   getViewport: function getViewport(aWindow) {
-    switch (this.OS) {
-      case 'Android':
+    switch (this.MozBuildApp) {
+      case 'mobile/android':
         return aWindow.BrowserApp.selectedTab.getViewport();
       default:
         return null;
     }
   },
 
   getStates: function getStates(aAccessible) {
     if (!aAccessible)
       return [0, 0];
 
     let state = {};
     let extState = {};
     aAccessible.getState(state, extState);
     return [state.value, extState.value];
+  },
+
+  getVirtualCursor: function getVirtualCursor(aDocument) {
+    let doc = (aDocument instanceof Ci.nsIAccessible) ? aDocument :
+      gAccRetrieval.getAccessibleFor(aDocument);
+
+    while (doc) {
+      try {
+        return doc.QueryInterface(Ci.nsIAccessibleCursorable).virtualCursor;
+      } catch (x) {
+        doc = doc.parentDocument;
+      }
+    }
+
+    return null;
   }
 };
 
 var Logger = {
   DEBUG: 0,
   INFO: 1,
   WARNING: 2,
   ERROR: 3,
@@ -126,10 +160,37 @@ var Logger = {
       let event = aEvent.QueryInterface(Ci.nsIAccessibleStateChangeEvent);
       let stateStrings = (event.isExtraState()) ?
         gAccRetrieval.getStringStates(0, event.state) :
         gAccRetrieval.getStringStates(event.state, 0);
       str += ' (' + stateStrings.item(0) + ')';
     }
 
     return str;
-  }
+  },
+
+  statesToString: function statesToString(aAccessible) {
+    let [state, extState] = Utils.getStates(aAccessible);
+    let stringArray = [];
+    let stateStrings = gAccRetrieval.getStringStates(state, extState);
+    for (var i=0; i < stateStrings.length; i++)
+      stringArray.push(stateStrings.item(i));
+    return stringArray.join(' ');
+  },
+
+  dumpTree: function dumpTree(aLogLevel, aRootAccessible) {
+    if (aLogLevel < this.logLevel)
+      return;
+
+    this._dumpTreeInternal(aLogLevel, aRootAccessible, 0);
+  },
+
+  _dumpTreeInternal: function _dumpTreeInternal(aLogLevel, aAccessible, aIndent) {
+    let indentStr = '';
+    for (var i=0; i < aIndent; i++)
+      indentStr += ' ';
+    this.log(aLogLevel, indentStr,
+             this.accessibleToString(aAccessible),
+             '(' + this.statesToString(aAccessible) + ')');
+    for (var i=0; i < aAccessible.childCount; i++)
+      this._dumpTreeInternal(aLogLevel, aAccessible.getChildAt(i), aIndent + 1);
+    }
 };
--- a/accessible/src/jsat/VirtualCursorController.jsm
+++ b/accessible/src/jsat/VirtualCursorController.jsm
@@ -12,27 +12,65 @@ const Cr = Components.results;
 var EXPORTED_SYMBOLS = ['VirtualCursorController'];
 
 Cu.import('resource://gre/modules/accessibility/Utils.jsm');
 Cu.import('resource://gre/modules/XPCOMUtils.jsm');
 
 var gAccRetrieval = Cc['@mozilla.org/accessibleRetrieval;1'].
   getService(Ci.nsIAccessibleRetrieval);
 
-var TraversalRules = {
-  Simple: {
-    getMatchRoles: function SimpleTraversalRule_getmatchRoles(aRules) {
+function BaseTraversalRule(aRoles, aMatchFunc) {
+  this._matchRoles = aRoles;
+  this._matchFunc = aMatchFunc;
+}
+
+BaseTraversalRule.prototype = {
+    getMatchRoles: function BaseTraversalRule_getmatchRoles(aRules) {
       aRules.value = this._matchRoles;
       return aRules.value.length;
     },
 
     preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
+    Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
+
+    match: function BaseTraversalRule_match(aAccessible)
+    {
+      if (this._matchFunc)
+        return this._matchFunc(aAccessible);
+
+      return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
+    },
+
+    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule])
+};
 
-    match: function SimpleTraversalRule_match(aAccessible) {
+var TraversalRules = {
+  Simple: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_MENUITEM,
+     Ci.nsIAccessibleRole.ROLE_LINK,
+     Ci.nsIAccessibleRole.ROLE_PAGETAB,
+     Ci.nsIAccessibleRole.ROLE_GRAPHIC,
+     // XXX: Find a better solution for ROLE_STATICTEXT.
+     // It allows to filter list bullets but at the same time it
+     // filters CSS generated content too as an unwanted side effect.
+     // Ci.nsIAccessibleRole.ROLE_STATICTEXT,
+     Ci.nsIAccessibleRole.ROLE_TEXT_LEAF,
+     Ci.nsIAccessibleRole.ROLE_PUSHBUTTON,
+     Ci.nsIAccessibleRole.ROLE_CHECKBUTTON,
+     Ci.nsIAccessibleRole.ROLE_RADIOBUTTON,
+     Ci.nsIAccessibleRole.ROLE_COMBOBOX,
+     Ci.nsIAccessibleRole.ROLE_PROGRESSBAR,
+     Ci.nsIAccessibleRole.ROLE_BUTTONDROPDOWN,
+     Ci.nsIAccessibleRole.ROLE_BUTTONMENU,
+     Ci.nsIAccessibleRole.ROLE_CHECK_MENU_ITEM,
+     Ci.nsIAccessibleRole.ROLE_PASSWORD_TEXT,
+     Ci.nsIAccessibleRole.ROLE_RADIO_MENU_ITEM,
+     Ci.nsIAccessibleRole.ROLE_TOGGLE_BUTTON,
+     Ci.nsIAccessibleRole.ROLE_ENTRY],
+    function Simple_match(aAccessible) {
       switch (aAccessible.role) {
       case Ci.nsIAccessibleRole.ROLE_COMBOBOX:
         // We don't want to ignore the subtree because this is often
         // where the list box hangs out.
         return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
       case Ci.nsIAccessibleRole.ROLE_TEXT_LEAF:
         {
           // Nameless text leaves are boring, skip them.
@@ -50,362 +88,111 @@ var TraversalRules = {
         else
           return Ci.nsIAccessibleTraversalRule.FILTER_IGNORE;
       default:
         // Ignore the subtree, if there is one. So that we don't land on
         // the same content that was already presented by its parent.
         return Ci.nsIAccessibleTraversalRule.FILTER_MATCH |
           Ci.nsIAccessibleTraversalRule.FILTER_IGNORE_SUBTREE;
       }
-    },
-
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule]),
+    }
+  ),
 
-    _matchRoles: [
-      Ci.nsIAccessibleRole.ROLE_MENUITEM,
-      Ci.nsIAccessibleRole.ROLE_LINK,
-      Ci.nsIAccessibleRole.ROLE_PAGETAB,
-      Ci.nsIAccessibleRole.ROLE_GRAPHIC,
-      // XXX: Find a better solution for ROLE_STATICTEXT.
-      // It allows to filter list bullets but at the same time it
-      // filters CSS generated content too as an unwanted side effect.
-      // Ci.nsIAccessibleRole.ROLE_STATICTEXT,
-      Ci.nsIAccessibleRole.ROLE_TEXT_LEAF,
-      Ci.nsIAccessibleRole.ROLE_PUSHBUTTON,
-      Ci.nsIAccessibleRole.ROLE_CHECKBUTTON,
-      Ci.nsIAccessibleRole.ROLE_RADIOBUTTON,
-      Ci.nsIAccessibleRole.ROLE_COMBOBOX,
-      Ci.nsIAccessibleRole.ROLE_PROGRESSBAR,
-      Ci.nsIAccessibleRole.ROLE_BUTTONDROPDOWN,
-      Ci.nsIAccessibleRole.ROLE_BUTTONMENU,
-      Ci.nsIAccessibleRole.ROLE_CHECK_MENU_ITEM,
-      Ci.nsIAccessibleRole.ROLE_PASSWORD_TEXT,
-      Ci.nsIAccessibleRole.ROLE_RADIO_MENU_ITEM,
-      Ci.nsIAccessibleRole.ROLE_TOGGLE_BUTTON,
-      Ci.nsIAccessibleRole.ROLE_ENTRY
-    ]
-  },
-
-  Anchor: {
-    getMatchRoles: function AnchorTraversalRule_getMatchRoles(aRules)
-    {
-      aRules.value = [Ci.nsIAccessibleRole.ROLE_LINK];
-      return aRules.value.length;
-    },
-
-    preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
-
-    match: function AnchorTraversalRule_match(aAccessible)
+  Anchor: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_LINK],
+    function Anchor_match(aAccessible)
     {
       // We want to ignore links, only focus named anchors.
       let state = {};
       let extraState = {};
       aAccessible.getState(state, extraState);
       if (state.value & Ci.nsIAccessibleStates.STATE_LINKED) {
         return Ci.nsIAccessibleTraversalRule.FILTER_IGNORE;
       } else {
         return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
       }
-    },
-
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule])
-  },
-
-  Button: {
-    getMatchRoles: function ButtonTraversalRule_getMatchRoles(aRules)
-    {
-      aRules.value = this._matchRoles;
-      return aRules.value.length;
-    },
-
-    preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
-
-    match: function ButtonTraversalRule_match(aAccessible)
-    {
-      return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
-    },
-
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule]),
-
-    _matchRoles: [
-      Ci.nsIAccessibleRole.ROLE_PUSHBUTTON,
-      Ci.nsIAccessibleRole.ROLE_SPINBUTTON,
-      Ci.nsIAccessibleRole.ROLE_TOGGLE_BUTTON,
-      Ci.nsIAccessibleRole.ROLE_BUTTONDROPDOWN,
-      Ci.nsIAccessibleRole.ROLE_BUTTONDROPDOWNGRID
-    ]
-  },
-
-  Combobox: {
-    getMatchRoles: function ComboboxTraversalRule_getMatchRoles(aRules)
-    {
-      aRules.value = [Ci.nsIAccessibleRole.ROLE_COMBOBOX,
-                      Ci.nsIAccessibleRole.ROLE_LISTBOX];
-      return aRules.value.length;
-    },
-
-    preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
+    }),
 
-    match: function ComboboxTraversalRule_match(aAccessible)
-    {
-      return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
-    },
-
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule])
-  },
-
-  Entry: {
-    getMatchRoles: function EntryTraversalRule_getMatchRoles(aRules)
-    {
-      aRules.value = [Ci.nsIAccessibleRole.ROLE_ENTRY,
-                      Ci.nsIAccessibleRole.ROLE_PASSWORD_TEXT];
-      return aRules.value.length;
-    },
-
-    preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
+  Button: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_PUSHBUTTON,
+     Ci.nsIAccessibleRole.ROLE_SPINBUTTON,
+     Ci.nsIAccessibleRole.ROLE_TOGGLE_BUTTON,
+     Ci.nsIAccessibleRole.ROLE_BUTTONDROPDOWN,
+     Ci.nsIAccessibleRole.ROLE_BUTTONDROPDOWNGRID]),
 
-    match: function EntryTraversalRule_match(aAccessible)
-    {
-      return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
-    },
-
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule])
-  },
+  Combobox: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_COMBOBOX,
+     Ci.nsIAccessibleRole.ROLE_LISTBOX]),
 
-  FormElement: {
-    getMatchRoles: function FormElementTraversalRule_getMatchRoles(aRules)
-    {
-      aRules.value = this._matchRoles;
-      return aRules.value.length;
-    },
-
-    preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
-
-    match: function FormElementTraversalRule_match(aAccessible)
-    {
-      return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
-    },
-
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule]),
+  Entry: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_ENTRY,
+     Ci.nsIAccessibleRole.ROLE_PASSWORD_TEXT]),
 
-    _matchRoles: [
-      Ci.nsIAccessibleRole.ROLE_PUSHBUTTON,
-      Ci.nsIAccessibleRole.ROLE_SPINBUTTON,
-      Ci.nsIAccessibleRole.ROLE_TOGGLE_BUTTON,
-      Ci.nsIAccessibleRole.ROLE_BUTTONDROPDOWN,
-      Ci.nsIAccessibleRole.ROLE_BUTTONDROPDOWNGRID,
-      Ci.nsIAccessibleRole.ROLE_COMBOBOX,
-      Ci.nsIAccessibleRole.ROLE_LISTBOX,
-      Ci.nsIAccessibleRole.ROLE_ENTRY,
-      Ci.nsIAccessibleRole.ROLE_PASSWORD_TEXT,
-      Ci.nsIAccessibleRole.ROLE_PAGETAB,
-      Ci.nsIAccessibleRole.ROLE_RADIOBUTTON,
-      Ci.nsIAccessibleRole.ROLE_RADIO_MENU_ITEM,
-      Ci.nsIAccessibleRole.ROLE_SLIDER,
-      Ci.nsIAccessibleRole.ROLE_CHECKBUTTON,
-      Ci.nsIAccessibleRole.ROLE_CHECK_MENU_ITEM
-    ]
-  },
-
-  Graphic: {
-    getMatchRoles: function GraphicTraversalRule_getMatchRoles(aRules)
-    {
-      aRules.value = [Ci.nsIAccessibleRole.ROLE_GRAPHIC];
-      return aRules.value.length;
-    },
-
-    preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
-
-    match: function GraphicTraversalRule_match(aAccessible)
-    {
-      return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
-    },
-
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule])
-  },
+  FormElement: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_PUSHBUTTON,
+     Ci.nsIAccessibleRole.ROLE_SPINBUTTON,
+     Ci.nsIAccessibleRole.ROLE_TOGGLE_BUTTON,
+     Ci.nsIAccessibleRole.ROLE_BUTTONDROPDOWN,
+     Ci.nsIAccessibleRole.ROLE_BUTTONDROPDOWNGRID,
+     Ci.nsIAccessibleRole.ROLE_COMBOBOX,
+     Ci.nsIAccessibleRole.ROLE_LISTBOX,
+     Ci.nsIAccessibleRole.ROLE_ENTRY,
+     Ci.nsIAccessibleRole.ROLE_PASSWORD_TEXT,
+     Ci.nsIAccessibleRole.ROLE_PAGETAB,
+     Ci.nsIAccessibleRole.ROLE_RADIOBUTTON,
+     Ci.nsIAccessibleRole.ROLE_RADIO_MENU_ITEM,
+     Ci.nsIAccessibleRole.ROLE_SLIDER,
+     Ci.nsIAccessibleRole.ROLE_CHECKBUTTON,
+     Ci.nsIAccessibleRole.ROLE_CHECK_MENU_ITEM]),
 
-  Heading: {
-    getMatchRoles: function HeadingTraversalRule_getMatchRoles(aRules)
-    {
-      aRules.value = [Ci.nsIAccessibleRole.ROLE_HEADING];
-      return aRules.value.length;
-    },
+  Graphic: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_GRAPHIC]),
 
-    preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
-
-    match: function HeadingTraversalRule_match(aAccessible)
-    {
-      return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
-    },
-
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule])
-  },
+  Heading: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_HEADING]),
 
-  ListItem: {
-    getMatchRoles: function ListItemTraversalRule_getMatchRoles(aRules)
-    {
-      aRules.value = [Ci.nsIAccessibleRole.ROLE_LISTITEM,
-                      Ci.nsIAccessibleRole.ROLE_TERM];
-      return aRules.value.length;
-    },
-
-    preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
+  ListItem: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_LISTITEM,
+     Ci.nsIAccessibleRole.ROLE_TERM]),
 
-    match: function ListItemTraversalRule_match(aAccessible)
-    {
-      return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
-    },
-
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule])
-  },
-
-  Link: {
-    getMatchRoles: function LinkTraversalRule_getMatchRoles(aRules)
-    {
-      aRules.value = [Ci.nsIAccessibleRole.ROLE_LINK];
-      return aRules.value.length;
-    },
-
-    preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
-
-    match: function LinkTraversalRule_match(aAccessible)
+  Link: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_LINK],
+    function Link_match(aAccessible)
     {
       // We want to ignore anchors, only focus real links.
       let state = {};
       let extraState = {};
       aAccessible.getState(state, extraState);
       if (state.value & Ci.nsIAccessibleStates.STATE_LINKED) {
         return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
       } else {
         return Ci.nsIAccessibleTraversalRule.FILTER_IGNORE;
       }
-    },
-
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule])
-  },
-
-  List: {
-    getMatchRoles: function ListTraversalRule_getMatchRoles(aRules)
-    {
-      aRules.value = [Ci.nsIAccessibleRole.ROLE_LIST,
-                      Ci.nsIAccessibleRole.ROLE_DEFINITION_LIST];
-      return aRules.value.length;
-    },
-
-    preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
-
-    match: function ListTraversalRule_match(aAccessible)
-    {
-      return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
-    },
-
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule])
-  },
+    }),
 
-  PageTab: {
-    getMatchRoles: function PageTabTraversalRule_getMatchRoles(aRules)
-    {
-      aRules.value = [Ci.nsIAccessibleRole.ROLE_PAGETAB];
-      return aRules.value.length;
-    },
-
-    preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
-
-    match: function PageTabTraversalRule_match(aAccessible)
-    {
-      return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
-    },
+  List: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_LIST,
+     Ci.nsIAccessibleRole.ROLE_DEFINITION_LIST]),
 
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule])
-  },
-
-  RadioButton: {
-    getMatchRoles: function RadioButtonTraversalRule_getMatchRoles(aRules)
-    {
-      aRules.value = [Ci.nsIAccessibleRole.ROLE_RADIOBUTTON,
-                      Ci.nsIAccessibleRole.ROLE_RADIO_MENU_ITEM];
-      return aRules.value.length;
-    },
-
-    preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
-
-    match: function RadioButtonTraversalRule_match(aAccessible)
-    {
-      return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
-    },
+  PageTab: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_PAGETAB]),
 
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule])
-  },
-
-  Separator: {
-    getMatchRoles: function SeparatorTraversalRule_getMatchRoles(aRules)
-    {
-      aRules.value = [Ci.nsIAccessibleRole.ROLE_SEPARATOR];
-      return aRules.value.length;
-    },
-
-    preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
+  RadioButton: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_RADIOBUTTON,
+     Ci.nsIAccessibleRole.ROLE_RADIO_MENU_ITEM]),
 
-    match: function SeparatorTraversalRule_match(aAccessible)
-    {
-      return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
-    },
-
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule])
-  },
-
-  Table: {
-    getMatchRoles: function TableTraversalRule_getMatchRoles(aRules)
-    {
-      aRules.value = [Ci.nsIAccessibleRole.ROLE_TABLE];
-      return aRules.value.length;
-    },
+  Separator: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_SEPARATOR]),
 
-    preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
-
-    match: function TableTraversalRule_match(aAccessible)
-    {
-      return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
-    },
-
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule])
-  },
+  Table: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_TABLE]),
 
-  Checkbox: {
-    getMatchRoles: function CheckboxTraversalRule_getMatchRoles(aRules)
-    {
-      aRules.value = [Ci.nsIAccessibleRole.ROLE_CHECKBUTTON,
-                      Ci.nsIAccessibleRole.ROLE_CHECK_MENU_ITEM];
-      return aRules.value.length;
-    },
-
-    preFilter: Ci.nsIAccessibleTraversalRule.PREFILTER_DEFUNCT |
-      Ci.nsIAccessibleTraversalRule.PREFILTER_INVISIBLE,
-
-    match: function CheckboxTraversalRule_match(aAccessible)
-    {
-      return Ci.nsIAccessibleTraversalRule.FILTER_MATCH;
-    },
-
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAccessibleTraversalRule])
-  }
+  Checkbox: new BaseTraversalRule(
+    [Ci.nsIAccessibleRole.ROLE_CHECKBUTTON,
+     Ci.nsIAccessibleRole.ROLE_CHECK_MENU_ITEM])
 };
 
 var VirtualCursorController = {
   exploreByTouch: false,
   editableState: 0,
 
   attach: function attach(aWindow) {
     this.chromeWin = aWindow;
@@ -542,50 +329,52 @@ var VirtualCursorController = {
         return;
     }
 
     aEvent.preventDefault();
     aEvent.stopPropagation();
   },
 
   moveToPoint: function moveToPoint(aDocument, aX, aY) {
-    this.getVirtualCursor(aDocument).moveToPoint(TraversalRules.Simple,
-                                                 aX, aY, true);
+    Utils.getVirtualCursor(aDocument).moveToPoint(TraversalRules.Simple,
+                                                  aX, aY, true);
   },
 
   moveForward: function moveForward(aDocument, aLast, aRule) {
-    let virtualCursor = this.getVirtualCursor(aDocument);
+    let virtualCursor = Utils.getVirtualCursor(aDocument);
     if (aLast) {
       virtualCursor.moveLast(TraversalRules.Simple);
     } else {
       try {
         virtualCursor.moveNext(aRule || TraversalRules.Simple);
       } catch (x) {
         this.moveCursorToObject(
-            gAccRetrieval.getAccessibleFor(aDocument.activeElement), aRule);
+          virtualCursor,
+          gAccRetrieval.getAccessibleFor(aDocument.activeElement), aRule);
       }
     }
   },
 
   moveBackward: function moveBackward(aDocument, aFirst, aRule) {
-    let virtualCursor = this.getVirtualCursor(aDocument);
+    let virtualCursor = Utils.getVirtualCursor(aDocument);
     if (aFirst) {
       virtualCursor.moveFirst(TraversalRules.Simple);
     } else {
       try {
         virtualCursor.movePrevious(aRule || TraversalRules.Simple);
       } catch (x) {
         this.moveCursorToObject(
-            gAccRetrieval.getAccessibleFor(aDocument.activeElement), aRule);
+          virtualCursor,
+          gAccRetrieval.getAccessibleFor(aDocument.activeElement), aRule);
       }
     }
   },
 
   activateCurrent: function activateCurrent(document) {
-    let virtualCursor = this.getVirtualCursor(document);
+    let virtualCursor = Utils.getVirtualCursor(document);
     let acc = virtualCursor.position;
 
     if (acc.actionCount > 0) {
       acc.doAction(0);
     } else {
       // XXX Some mobile widget sets do not expose actions properly
       // (via ARIA roles, etc.), so we need to generate a click.
       // Could possibly be made simpler in the future. Maybe core
@@ -602,34 +391,19 @@ var VirtualCursorController = {
 
       let cwu = this.chromeWin.QueryInterface(Ci.nsIInterfaceRequestor).
         getInterface(Ci.nsIDOMWindowUtils);
       cwu.sendMouseEventToWindow('mousedown', x, y, 0, 1, 0, false);
       cwu.sendMouseEventToWindow('mouseup', x, y, 0, 1, 0, false);
     }
   },
 
-  getVirtualCursor: function getVirtualCursor(document) {
-    return gAccRetrieval.getAccessibleFor(document).
-      QueryInterface(Ci.nsIAccessibleCursorable).virtualCursor;
-  },
-
-  moveCursorToObject: function moveCursorToObject(aAccessible, aRule) {
-    let doc = aAccessible.document;
-    while (doc) {
-      let vc = null;
-      try {
-        vc = doc.QueryInterface(Ci.nsIAccessibleCursorable).virtualCursor;
-      } catch (x) {
-        doc = doc.parentDocument;
-        continue;
-      }
-      vc.moveNext(aRule || TraversalRules.Simple, aAccessible, true);
-      break;
-    }
+  moveCursorToObject: function moveCursorToObject(aVirtualCursor,
+                                                  aAccessible, aRule) {
+    aVirtualCursor.moveNext(aRule || TraversalRules.Simple, aAccessible, true);
   },
 
   keyMap: {
     a: ['moveForward', TraversalRules.Anchor],
     A: ['moveBackward', TraversalRules.Anchor],
     b: ['moveForward', TraversalRules.Button],
     B: ['moveBackward', TraversalRules.Button],
     c: ['moveForward', TraversalRules.Combobox],
--- a/accessible/src/mac/mozAccessible.mm
+++ b/accessible/src/mac/mozAccessible.mm
@@ -412,17 +412,17 @@ GetClosestInterestingAccessible(id anObj
   if (!mGeckoAccessible)
     return nil;
 
 #ifdef DEBUG_A11Y
   NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(mGeckoAccessible),
                "Does not support nsIAccessibleText when it should");
 #endif
 
-#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role) \
+#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, nameRule) \
   case roles::geckoRole: \
     return macRole;
 
   switch (mRole) {
 #include "RoleMap.h"
     default:
       NS_NOTREACHED("Unknown role.");
       return NSAccessibilityUnknownRole;
--- a/accessible/src/msaa/AccessibleWrap.cpp
+++ b/accessible/src/msaa/AccessibleWrap.cpp
@@ -365,17 +365,18 @@ AccessibleWrap::get_accRole(
 #ifdef DEBUG
   NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(xpAccessible),
                "Does not support nsIAccessibleText when it should");
 #endif
 
   a11y::role geckoRole = xpAccessible->Role();
   PRUint32 msaaRole = 0;
 
-#define ROLE(_geckoRole, stringRole, atkRole, macRole, _msaaRole, ia2Role) \
+#define ROLE(_geckoRole, stringRole, atkRole, macRole, \
+             _msaaRole, ia2Role, nameRule) \
   case roles::_geckoRole: \
     msaaRole = _msaaRole; \
     break;
 
   switch (geckoRole) {
 #include "RoleMap.h"
     default:
       MOZ_NOT_REACHED("Unknown role.");
@@ -1130,17 +1131,18 @@ STDMETHODIMP
 AccessibleWrap::role(long *aRole)
 {
 __try {
   *aRole = 0;
 
   if (IsDefunct())
     return CO_E_OBJNOTCONNECTED;
 
-#define ROLE(_geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role) \
+#define ROLE(_geckoRole, stringRole, atkRole, macRole, \
+             msaaRole, ia2Role, nameRule) \
   case roles::_geckoRole: \
     *aRole = ia2Role; \
     break;
 
   a11y::role geckoRole = Role();
   switch (geckoRole) {
 #include "RoleMap.h"
     default:
--- a/accessible/src/windows/uia/uiaRawElmProvider.cpp
+++ b/accessible/src/windows/uia/uiaRawElmProvider.cpp
@@ -2,16 +2,17 @@
 /* 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 "uiaRawElmProvider.h"
 
 #include "AccessibleWrap.h"
+#include "nsIPersistentProperties2.h"
 
 using namespace mozilla;
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // uiaRawElmProvider
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -176,21 +177,35 @@ uiaRawElmProvider::GetPropertyValue(PROP
       if (!keyString.IsEmpty()) {
         aPropertyValue->vt = VT_BSTR;
         aPropertyValue->bstrVal = ::SysAllocString(keyString.get());
         return S_OK;
       }
 
       break;
     }
+    
+    //ARIA Role / shortcut
+    case UIA_AriaRolePropertyId: {
+      nsAutoString xmlRoles;
+
+      nsCOMPtr<nsIPersistentProperties> attributes;
+      mAcc->GetAttributes(getter_AddRefs(attributes));
+      attributes->GetStringProperty(NS_LITERAL_CSTRING("xml-roles"), xmlRoles);
+
+      if(!xmlRoles.IsEmpty()) {
+        aPropertyValue->vt = VT_BSTR;
+        aPropertyValue->bstrVal = ::SysAllocString(xmlRoles.get());
+        return S_OK;
+      }
+
+      break;
+    }
   }
 
-  // UI Automation will attempt to get the property from the host
-  //window provider.
-  aPropertyValue->vt = VT_EMPTY;
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 uiaRawElmProvider::get_HostRawElementProvider(__RPC__deref_out_opt IRawElementProviderSimple** aRawElmProvider)
 {
--- a/accessible/src/xpcom/nsAccessibleRelation.h
+++ b/accessible/src/xpcom/nsAccessibleRelation.h
@@ -5,26 +5,27 @@
 
 #ifndef _nsAccessibleRelation_H_
 #define _nsAccessibleRelation_H_
 
 #include "nsIAccessibleRelation.h"
 
 #include "nsCOMPtr.h"
 #include "nsIMutableArray.h"
+#include "mozilla/Attributes.h"
 
 namespace mozilla {
 namespace a11y {
 
 class Relation;
 
 /**
  * Class represents an accessible relation.
  */
-class nsAccessibleRelation : public nsIAccessibleRelation
+class nsAccessibleRelation MOZ_FINAL : public nsIAccessibleRelation
 {
 public:
   nsAccessibleRelation(PRUint32 aType, Relation* aRel);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIACCESSIBLERELATION
 
 private:
--- a/accessible/tests/mochitest/hyperlink/test_general.html
+++ b/accessible/tests/mochitest/hyperlink/test_general.html
@@ -70,48 +70,46 @@ https://bugzilla.mozilla.org/show_bug.cg
       //////////////////////////////////////////////////////////////////////////
       // normal hyperlink
       var normalHyperlinkAcc = getAccessible("NormalHyperlink",
                                              [nsIAccessibleHyperLink]);
       testThis("NormalHyperlink", normalHyperlinkAcc, ROLE_LINK, 1,
                "Mozilla Foundation", true, 17, 18);
       is(normalHyperlinkAcc.getURI(0).spec, "http://www.mozilla.org/", 
          "URI wrong for normalHyperlinkElement!");
-      testStates(normalHyperlinkAcc, STATE_LINKED, EXT_STATE_HORIZONTAL);
+      testStates(normalHyperlinkAcc, STATE_LINKED, 0);
 
       //////////////////////////////////////////////////////////////////////////
       // ARIA hyperlink
       var ariaHyperlinkAcc = getAccessible("AriaHyperlink",
                                            [nsIAccessibleHyperLink]);
       testThis("AriaHyperlink", ariaHyperlinkAcc, ROLE_LINK, 1,
                "Mozilla Foundation Home", true, 30, 31);
-      testStates(ariaHyperlinkAcc, STATE_LINKED, EXT_STATE_HORIZONTAL);
+      testStates(ariaHyperlinkAcc, STATE_LINKED, 0);
       testAction("AriaHyperlink", ariaHyperlinkAcc, "click");
 
       //////////////////////////////////////////////////////////////////////////
       // ARIA hyperlink with status invalid
       var invalidAriaHyperlinkAcc = getAccessible("InvalidAriaHyperlink",
                                                   [nsIAccessibleHyperLink]);
       is(invalidAriaHyperlinkAcc.valid, false, "Should not be valid!");
-      testStates(invalidAriaHyperlinkAcc, STATE_LINKED, EXT_STATE_HORIZONTAL);
+      testStates(invalidAriaHyperlinkAcc, STATE_LINKED, 0);
 
       //////////////////////////////////////////////////////////////////////////
       // image map and its link children
 
       var imageMapHyperlinkAcc = getAccessible("imgmap",
                                                [nsIAccessibleHyperLink]);
       testThis("imgmap", imageMapHyperlinkAcc, ROLE_IMAGE_MAP, 2, "b", true,
                79, 80);
       is(imageMapHyperlinkAcc.getURI(0).spec,
          "http://www.bbc.co.uk/radio4/atoz/index.shtml#b", "URI wrong!");
       is(imageMapHyperlinkAcc.getURI(1).spec,
          "http://www.bbc.co.uk/radio4/atoz/index.shtml#a", "URI wrong!");
-      testStates(imageMapHyperlinkAcc,
-                 (0),
-                 (EXT_STATE_HORIZONTAL));
+      testStates(imageMapHyperlinkAcc, 0, 0);
 
       var area1 = getAccessible(imageMapHyperlinkAcc.firstChild,
                                 [nsIAccessibleHyperLink]);
       testThis("Area1", area1, ROLE_LINK, 1, "b", true, 0, 1);
       is(area1.getURI(0).spec,
          "http://www.bbc.co.uk/radio4/atoz/index.shtml#b", "URI wrong!");
       testStates(area1, (STATE_LINKED));
 
@@ -122,111 +120,96 @@ https://bugzilla.mozilla.org/show_bug.cg
          "http://www.bbc.co.uk/radio4/atoz/index.shtml#a", "URI wrong!");
       testStates(area2, (STATE_LINKED));
 
       //////////////////////////////////////////////////////////////////////////
       // empty hyperlink
       var EmptyHLAcc = getAccessible("emptyLink",
                                      [nsIAccessibleHyperLink]);
       testThis("emptyLink", EmptyHLAcc, ROLE_LINK, 1, null, true, 93, 94);
-      testStates(EmptyHLAcc,
-                 (STATE_FOCUSABLE | STATE_LINKED),
-                 (EXT_STATE_HORIZONTAL));
+      testStates(EmptyHLAcc, (STATE_FOCUSABLE | STATE_LINKED), 0);
       testAction("emptyLink", EmptyHLAcc, "jump");
 
       //////////////////////////////////////////////////////////////////////////
       // normal hyperlink with embedded span
       var hyperlinkWithSpanAcc = getAccessible("LinkWithSpan",
                                                [nsIAccessibleHyperLink]);
       testThis("LinkWithSpan", hyperlinkWithSpanAcc, ROLE_LINK, 1,
                "Heise Online", true, 119, 120);
       is(hyperlinkWithSpanAcc.getURI(0).spec, "http://www.heise.de/", 
          "URI wrong for hyperlinkElementWithSpan!");
-      testStates(hyperlinkWithSpanAcc, STATE_LINKED, EXT_STATE_HORIZONTAL);
+      testStates(hyperlinkWithSpanAcc, STATE_LINKED, 0);
       testAction("LinkWithSpan", hyperlinkWithSpanAcc, "jump");
 
       //////////////////////////////////////////////////////////////////////////
       // Named anchor, should never have state_linked
       var namedAnchorAcc = getAccessible("namedAnchor",
                                          [nsIAccessibleHyperLink]);
       testThis("namedAnchor", namedAnchorAcc, ROLE_LINK, 1,
                "This should never be of state_linked", true, 196, 197);
-      testStates(namedAnchorAcc,
-                 (STATE_SELECTABLE),
-                 (EXT_STATE_HORIZONTAL), (STATE_FOCUSABLE | STATE_LINKED));
+      testStates(namedAnchorAcc, STATE_SELECTABLE,
+                 0, (STATE_FOCUSABLE | STATE_LINKED));
       testAction("namedAnchor", namedAnchorAcc, "");
 
       //////////////////////////////////////////////////////////////////////////
       // No link (hasn't any attribute), should never have state_linked
       var noLinkAcc = getAccessible("noLink",
                                     [nsIAccessibleHyperLink]);
       testThis("noLink", noLinkAcc, ROLE_LINK, 1,
                "This should never be of state_linked", true, 254, 255);
-      testStates(noLinkAcc,
-                 0,
-                 (EXT_STATE_HORIZONTAL), (STATE_FOCUSABLE | STATE_LINKED));
+      testStates(noLinkAcc, 0, 0, (STATE_FOCUSABLE | STATE_LINKED));
       testAction("noLink", noLinkAcc, "");
 
       //////////////////////////////////////////////////////////////////////////
       // Link with registered 'click' event, should have state_linked
       var linkWithClickAcc = getAccessible("linkWithClick",
                                            [nsIAccessibleHyperLink]);
       testThis("linkWithClick", linkWithClickAcc, ROLE_LINK, 1,
                "This should have state_linked", true, 292, 293);
-      testStates(linkWithClickAcc,
-                 (STATE_LINKED),
-                 (EXT_STATE_HORIZONTAL));
+      testStates(linkWithClickAcc, STATE_LINKED, 0);
       testAction("linkWithClick", linkWithClickAcc, "click");
 
       //////////////////////////////////////////////////////////////////////////
       // Maps to group links (bug 431615).
       var linksMapAcc = getAccessible("linksmap");
 
       //////////////////////////////////////////////////////////////////////////
       // Link with title attribute, no name from the subtree (bug 438325).
       var id = "linkWithTitleNoNameFromSubtree";
       var linkAcc = getAccessible(id, [nsIAccessibleHyperLink]);
       testThis(id, linkAcc, ROLE_LINK, 1, "Link with title", true, 344, 345);
-      testStates(linkAcc,
-                 (STATE_LINKED),
-                 (EXT_STATE_HORIZONTAL));
+      testStates(linkAcc, STATE_LINKED, 0);
       testAction(id, linkAcc, "jump");
 
       //////////////////////////////////////////////////////////////////////////
       // Link with title attribute, name from the subtree - onscreen name
       // (bug 438325).
       id = "linkWithTitleNameFromSubtree";
       linkAcc = getAccessible(id, [nsIAccessibleHyperLink]);
       testThis(id, linkAcc, ROLE_LINK, 1, "the name from subtree", true, 393,
                394);
-      testStates(linkAcc,
-                 (STATE_LINKED),
-                 (EXT_STATE_HORIZONTAL));
+      testStates(linkAcc, STATE_LINKED, 0);
       testAction(id, linkAcc, "jump");
 
       //////////////////////////////////////////////////////////////////////////
       // Link with title attribute, name from the nested html:img (bug 438325).
       id = "linkWithTitleNameFromImg";
       linkAcc = getAccessible(id, [nsIAccessibleHyperLink]);
       testThis(id, linkAcc, ROLE_LINK, 1, "The title for link", true, 447,
                448);
-      testStates(linkAcc,
-                 (STATE_LINKED),
-                 (EXT_STATE_HORIZONTAL));
+      testStates(linkAcc, STATE_LINKED, 0);
       testAction(id, linkAcc, "jump");
 
       //////////////////////////////////////////////////////////////////////////
       // Link with label, no name from the subtree (bug 438325).
       id = "linkWithLabelNoNameFromSubtree";
       linkAcc = getAccessible(id, [nsIAccessibleHyperLink]);
       testThis(id, linkAcc, ROLE_LINK, 1, "Link with label and nested image:",
                true, 450, 451);
-      testStates(linkAcc,
-                 (STATE_LINKED),
-                 (EXT_STATE_HORIZONTAL));
+      testStates(linkAcc, STATE_LINKED, 0);
       testAction(id, linkAcc, "jump");
 
       //////////////////////////////////////////////////////////////////////////
       // Text accessible shouldn't implement nsIAccessibleHyperLink
       var res = isAccessible(getNode("namedAnchor").firstChild,
                              [nsIAccessibleHyperLink]);
       ok(!res, "Text accessible shouldn't implement nsIAccessibleHyperLink");
 
--- a/accessible/tests/mochitest/hyperlink/test_general.xul
+++ b/accessible/tests/mochitest/hyperlink/test_general.xul
@@ -40,17 +40,17 @@
     var gQueue = null;
     function doTest()
     {
       var linkedLabelAcc = getAccessible("linkedLabel",
                                          [nsIAccessibleHyperLink]);
       testThis("linkedLabel", linkedLabelAcc, ROLE_LINK, 1,
                "Mozilla Foundation home", "http://www.mozilla.org/", 1, 2,
                true);
-      testStates(linkedLabelAcc, STATE_LINKED, EXT_STATE_HORIZONTAL);
+      testStates(linkedLabelAcc, STATE_LINKED, 0);
 
       var labelWithValueAcc = getAccessible("linkLabelWithValue",
                                             [nsIAccessibleHyperLink]);
       testThis("linkLabelWithValue", labelWithValueAcc, ROLE_LINK, 1,
                "Mozilla Foundation", "http://www.mozilla.org/", 2, 3, true,
                false, true);
       testStates(labelWithValueAcc, STATE_LINKED, EXT_STATE_HORIZONTAL);
 
--- a/accessible/tests/mochitest/states/test_aria.html
+++ b/accessible/tests/mochitest/states/test_aria.html
@@ -148,25 +148,25 @@
 
       // some weak landmarks
       testStates("aria_main_link", STATE_LINKED);
       testStates("aria_navigation_link", STATE_LINKED);
       testStates("aria_main_anchor", STATE_SELECTABLE);
       testStates("aria_navigation_anchor", STATE_SELECTABLE);
 
       // aria-orientation (applied to scrollbar, separator, slider)
-      testStates("aria_scrollbar", 0, EXT_STATE_HORIZONTAL);
-      testStates("aria_hscrollbar", 0, EXT_STATE_HORIZONTAL);
-      testStates("aria_vscrollbar", 0, EXT_STATE_VERTICAL);
-      testStates("aria_separator", 0, EXT_STATE_HORIZONTAL);
-      testStates("aria_hseparator", 0, EXT_STATE_HORIZONTAL);
-      testStates("aria_vseparator", 0, EXT_STATE_VERTICAL);
-      testStates("aria_slider", 0, EXT_STATE_HORIZONTAL);
-      testStates("aria_hslider", 0, EXT_STATE_HORIZONTAL);
-      testStates("aria_vslider", 0, EXT_STATE_VERTICAL);
+      testStates("aria_scrollbar", 0, EXT_STATE_VERTICAL, 0, EXT_STATE_HORIZONTAL);
+      testStates("aria_hscrollbar", 0, EXT_STATE_HORIZONTAL, 0, EXT_STATE_VERTICAL);
+      testStates("aria_vscrollbar", 0, EXT_STATE_VERTICAL, 0, EXT_STATE_HORIZONTAL);
+      testStates("aria_separator", 0, EXT_STATE_HORIZONTAL, 0, EXT_STATE_VERTICAL);
+      testStates("aria_hseparator", 0, EXT_STATE_HORIZONTAL, 0, EXT_STATE_VERTICAL);
+      testStates("aria_vseparator", 0, EXT_STATE_VERTICAL, 0, EXT_STATE_HORIZONTAL);
+      testStates("aria_slider", 0, EXT_STATE_HORIZONTAL, 0, EXT_STATE_VERTICAL);
+      testStates("aria_hslider", 0, EXT_STATE_HORIZONTAL, 0, EXT_STATE_VERTICAL);
+      testStates("aria_vslider", 0, EXT_STATE_VERTICAL, 0, EXT_STATE_HORIZONTAL);
 
       // indeterminate ARIA progressbars (no aria-valuenow or aria-valuetext attribute)
       // should expose mixed state
       testStates("aria_progressbar", STATE_MIXED);
       testStates("aria_progressbar_valuenow", 0, 0, STATE_MIXED);
       testStates("aria_progressbar_valuetext", 0, 0, STATE_MIXED);
 
       SimpleTest.finish();
@@ -220,16 +220,21 @@
      title="Mochitests for ARIA states">
     Mozilla Bug 457226
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=740851"
      title="ARIA undetermined progressmeters should expose mixed state">
     Mozilla Bug 740851
   </a>
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=762876
+     title="fix default horizontal / vertical state of role=scrollbar and ensure only one of horizontal / vertical states is exposed">
+    Mozilla Bug 762876
+  </a>
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <div id="textbox_autocomplete_inline" role="textbox" aria-autocomplete="inline"></div>
   <div id="textbox_autocomplete_list" role="textbox" aria-autocomplete="list"></div>
   <div id="textbox_autocomplete_both" role="textbox" aria-autocomplete="both"></div>
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -40,17 +40,16 @@ pref("network.protocol-handler.warn-exte
 
 /* http prefs */
 pref("network.http.pipelining", true);
 pref("network.http.pipelining.ssl", true);
 pref("network.http.proxy.pipelining", true);
 pref("network.http.pipelining.maxrequests" , 6);
 pref("network.http.keep-alive.timeout", 600);
 pref("network.http.max-connections", 6);
-pref("network.http.max-connections-per-server", 4);
 pref("network.http.max-persistent-connections-per-server", 4);
 pref("network.http.max-persistent-connections-per-proxy", 4);
 
 // See bug 545869 for details on why these are set the way they are
 pref("network.buffer.cache.count", 24);
 pref("network.buffer.cache.size",  16384);
 
 /* session history */
--- a/b2g/chrome/content/settings.js
+++ b/b2g/chrome/content/settings.js
@@ -69,24 +69,26 @@ SettingsListener.observe('language.curre
     SettingsListener.observe(key, false, function(value) {
       Services.prefs.setBoolPref(key, value);
     });
   });
 
   let strPrefs = ['ril.data.apn', 'ril.data.user', 'ril.data.passwd',
                   'ril.data.mmsc', 'ril.data.mmsproxy'];
   strPrefs.forEach(function(key) {
-    SettingsListener.observe(key, false, function(value) {
+    SettingsListener.observe(key, "", function(value) {
       Services.prefs.setCharPref(key, value);
     });
   });
 
   ['ril.data.mmsport'].forEach(function(key) {
-    SettingsListener.observe(key, false, function(value) {
-      Services.prefs.setIntPref(key, value);
+    SettingsListener.observe(key, null, function(value) {
+      if (value != null) {
+        Services.prefs.setIntPref(key, value);
+      }
     });
   });
 })();
 
 
 // =================== Debugger ====================
 SettingsListener.observe('devtools.debugger.remote-enabled', false, function(enabled) {
   Services.prefs.setBoolPref('devtools.debugger.remote-enabled', value);
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -10,16 +10,17 @@ const Cu = Components.utils;
 const Cr = Components.results;
 
 Cu.import('resource://gre/modules/XPCOMUtils.jsm');
 Cu.import('resource://gre/modules/Services.jsm');
 Cu.import('resource://gre/modules/ContactService.jsm');
 Cu.import('resource://gre/modules/SettingsChangeNotifier.jsm');
 Cu.import('resource://gre/modules/Webapps.jsm');
 Cu.import('resource://gre/modules/AlarmService.jsm');
+Cu.import('resource://gre/modules/ActivitiesService.jsm');
 
 XPCOMUtils.defineLazyServiceGetter(Services, 'env',
                                    '@mozilla.org/process/environment;1',
                                    'nsIEnvironment');
 
 XPCOMUtils.defineLazyServiceGetter(Services, 'ss',
                                    '@mozilla.org/content/style-sheet-service;1',
                                    'nsIStyleSheetService');
@@ -240,27 +241,27 @@ var shell = {
           let documentElement = contentWindow.document.documentElement;
           if (!documentElement)
             return;
 
           let manifest = documentElement.getAttribute('manifest');
           if (!manifest)
             return;
 
-          let documentURI = contentWindow.document.documentURIObject;
-          if (!Services.perms.testPermission(documentURI, 'offline-app')) {
+          let principal = contentWindow.document.nodePrincipal;
+          if (Services.perms.testPermissionFromPrincipal(principal, 'offline-app') == Ci.nsIPermissionManager.UNKNOWN_ACTION) {
             if (Services.prefs.getBoolPref('browser.offline-apps.notify')) {
               // FIXME Bug 710729 - Add a UI for offline cache notifications
               return;
             }
             return;
           }
 
-          Services.perms.add(documentURI, 'offline-app',
-                             Ci.nsIPermissionManager.ALLOW_ACTION);
+          Services.perms.addFromPrincipal(principal, 'offline-app',
+                                          Ci.nsIPermissionManager.ALLOW_ACTION);
 
           let manifestURI = Services.io.newURI(manifest, null, documentURI);
           let updateService = Cc['@mozilla.org/offlinecacheupdate-service;1']
                               .getService(Ci.nsIOfflineCacheUpdateService);
           updateService.scheduleUpdate(manifestURI, documentURI, window);
         } catch (e) {
           dump('Error while creating offline cache: ' + e + '\n');
         }
@@ -301,25 +302,26 @@ nsBrowserAccess.prototype = {
   },
 
   isTabContentWindow: function isTabContentWindow(contentWindow) {
     return contentWindow == window;
   }
 };
 
 // Listen for system messages and relay them to Gaia.
-Services.obs.addObserver(function(aSubject, aTopic, aData) {
-  let msg = JSON.parse(aData);
+Services.obs.addObserver(function onSystemMessage(subject, topic, data) {
+  let msg = JSON.parse(data);
   let origin = Services.io.newURI(msg.manifest, null, null).prePath;
-  shell.sendEvent(shell.contentBrowser.contentWindow,
-                  "mozChromeEvent", { type: "open-app",
-                                      url: msg.uri,
-                                      origin: origin,
-                                      manifest: msg.manifest } );
-}, "system-messages-open-app", false);
+  shell.sendEvent(shell.contentBrowser.contentWindow, 'mozChromeEvent', {
+    type: 'open-app',
+    url: msg.uri,
+    origin: origin,
+    manifest: msg.manifest
+  });
+}, 'system-messages-open-app', false);
 
 (function Repl() {
   if (!Services.prefs.getBoolPref('b2g.remote-js.enabled')) {
     return;
   }
   const prompt = 'JS> ';
   let output;
   let reader = {
new file mode 100644
--- /dev/null
+++ b/b2g/components/ActivitiesGlue.js
@@ -0,0 +1,72 @@
+/* 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 Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+function ActivitiesDialog() {
+  this._id = 0;
+
+  this.activities = [];
+}
+
+ActivitiesDialog.prototype = {
+  run: function ap_run() {
+    let id = "activity-choice" + this._id++;
+    let activity = this.activities.shift();
+
+    let choices = [];
+    activity.list.forEach(function(item) {
+      choices.push({ title: item.title, icon: item.icon });
+    });
+
+
+    // Keep up the frond-end of an activity choice. The messages contains
+    // a list of {names, icons} for applications able to handle this particular
+    // activity. The front-end should display a UI to pick one.
+    let browser = Services.wm.getMostRecentWindow("navigator:browser");
+    let content = browser.getContentWindow();
+    let event = content.document.createEvent("CustomEvent");
+    event.initCustomEvent("mozChromeEvent", true, true, {
+      type: "activity-choice",
+      id: id,
+      name: activity.name,
+      choices: choices
+    });
+
+    // Listen the resulting choice from the front-end. If there is no choice,
+    // let's return -1, which means the user has cancelled the dialog.
+    content.addEventListener("mozContentEvent", function act_getChoice(evt) {
+      if (evt.detail.id != id)
+        return;
+
+      content.removeEventListener("mozContentEvent", act_getChoice);
+      activity.callback.handleEvent(evt.detail.value ? evt.detail.value : -1);
+    });
+
+    content.dispatchEvent(event);
+  },
+
+  chooseActivity: function ap_chooseActivity(aName, aActivities, aCallback) {
+    this.activities.push({
+      name: aName,
+      list: aActivities,
+      callback: aCallback
+    });
+    Services.tm.currentThread.dispatch(this, Ci.nsIEventTarget.DISPATCH_NORMAL);
+  },
+
+  classID: Components.ID("{70a83123-7467-4389-a309-3e81c74ad002}"),
+
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIActivityUIGlue, Ci.nsIRunnable])
+}
+
+const NSGetFactory = XPCOMUtils.generateNSGetFactory([ActivitiesDialog]);
+
--- a/b2g/components/B2GComponents.manifest
+++ b/b2g/components/B2GComponents.manifest
@@ -25,12 +25,16 @@ component {397a7fdf-2254-47be-b74e-76625
 contract @mozilla.org/b2g-keyboard;1 {397a7fdf-2254-47be-b74e-76625a1a66d5}
 category JavaScript-navigator-property mozKeyboard @mozilla.org/b2g-keyboard;1
 
 # DirectoryProvider.js
 component {9181eb7c-6f87-11e1-90b1-4f59d80dd2e5} DirectoryProvider.js
 contract @mozilla.org/browser/directory-provider;1 {9181eb7c-6f87-11e1-90b1-4f59d80dd2e5}
 category xpcom-directory-providers browser-directory-provider @mozilla.org/browser/directory-provider;1
 
+# ActivitiesGlue.js
+component {70a83123-7467-4389-a309-3e81c74ad002} ActivitiesGlue.js
+contract @mozilla.org/dom/activities/ui-glue;1 {70a83123-7467-4389-a309-3e81c74ad002}
+
 # ProcessGlobal.js
 component {1a94c87a-5ece-4d11-91e1-d29c29f21b28} ProcessGlobal.js
 contract @mozilla.org/b2g-process-global;1 {1a94c87a-5ece-4d11-91e1-d29c29f21b28}
 category app-startup ProcessGlobal service,@mozilla.org/b2g-process-global;1
--- a/b2g/components/CameraContent.js
+++ b/b2g/components/CameraContent.js
@@ -54,17 +54,17 @@ CameraContent.prototype = {
       }
     }
   },
 
   init: function(aWindow) {
     let principal = aWindow.document.nodePrincipal;
     let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
 
-    let perm = principal == secMan.getSystemPrincipal() ? Ci.nsIPermissionManager.ALLOW_ACTION : Services.perms.testExactPermission(principal.URI, "content-camera");
+    let perm = Services.perms.testExactPermissionFromPrincipal(principal, "content-camera");
 
     //only pages with perm set and chrome pages can use the camera in content
     this.hasPrivileges = perm == Ci.nsIPermissionManager.ALLOW_ACTION;
 
     Services.obs.addObserver(this, "inner-window-destroyed", false);
     let util = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
     this.innerWindowID = util.currentInnerWindowID;
   },
--- a/b2g/components/Makefile.in
+++ b/b2g/components/Makefile.in
@@ -19,15 +19,16 @@ XPIDLSRCS = \
 EXTRA_PP_COMPONENTS = \
         AlertsService.js \
         B2GComponents.manifest \
         CameraContent.js \
         ContentPermissionPrompt.js \
         DirectoryProvider.js \
         MozKeyboard.js \
         ProcessGlobal.js \
+        ActivitiesGlue.js \
         $(NULL)
 
 ifdef MOZ_UPDATER
 EXTRA_PP_COMPONENTS += UpdatePrompt.js
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -148,16 +148,17 @@
 @BINPATH@/components/content_htmldoc.xpt
 @BINPATH@/components/content_html.xpt
 @BINPATH@/components/content_xslt.xpt
 @BINPATH@/components/content_xtf.xpt
 @BINPATH@/components/cookie.xpt
 @BINPATH@/components/directory.xpt
 @BINPATH@/components/docshell.xpt
 @BINPATH@/components/dom.xpt
+@BINPATH@/components/dom_activities.xpt
 @BINPATH@/components/dom_apps.xpt
 @BINPATH@/components/dom_base.xpt
 #ifdef MOZ_B2G_RIL
 @BINPATH@/components/dom_telephony.xpt
 @BINPATH@/components/dom_wifi.xpt
 @BINPATH@/components/dom_system_gonk.xpt
 #endif
 @BINPATH@/components/dom_battery.xpt
@@ -471,16 +472,22 @@
 @BINPATH@/components/Webapps.manifest
 @BINPATH@/components/AppsService.js
 @BINPATH@/components/AppsService.manifest
 
 @BINPATH@/components/SystemMessageInternal.js
 @BINPATH@/components/SystemMessageManager.js
 @BINPATH@/components/SystemMessageManager.manifest
 
+@BINPATH@/components/Activities.manifest
+@BINPATH@/components/ActivityOptions.js
+@BINPATH@/components/ActivityProxy.js
+@BINPATH@/components/ActivityRequestHandler.js
+@BINPATH@/components/ActivityWrapper.js
+
 @BINPATH@/components/AppProtocolHandler.js
 @BINPATH@/components/AppProtocolHandler.manifest
 
 ; Modules
 @BINPATH@/modules/*
 
 ; Safe Browsing
 @BINPATH@/components/nsURLClassifier.manifest
@@ -670,9 +677,10 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DL
 @BINPATH@/components/marionettecomponent.js
 @BINPATH@/components/AlertsService.js
 @BINPATH@/components/ContentPermissionPrompt.js
 #ifdef MOZ_UPDATER
 @BINPATH@/components/UpdatePrompt.js
 #endif
 @BINPATH@/components/MozKeyboard.js
 @BINPATH@/components/DirectoryProvider.js
+@BINPATH@/components/ActivitiesGlue.js
 @BINPATH@/components/ProcessGlobal.js
--- a/browser/base/content/browser-appmenu.inc
+++ b/browser/base/content/browser-appmenu.inc
@@ -137,78 +137,29 @@
                       label="&printSetupCmd.label;"
                       command="cmd_pageSetup"/>
           </menupopup>
       </splitmenu>
       <menuseparator class="appmenu-menuseparator"/>
       <menu id="appmenu_webDeveloper"
             label="&appMenuWebDeveloper.label;">
         <menupopup id="appmenu_webDeveloper_popup">
-          <menuitem id="appmenu_devToolbar"
-                    type="checkbox"
-                    autocheck="false"
-                    hidden="true"
-                    label="&devToolbarMenu.label;"
-                    command="Tools:DevToolbar"
-                    key="key_devToolbar"/>
-          <menuitem id="appmenu_webConsole"
-                    label="&webConsoleCmd.label;"
-                    type="checkbox"
-                    command="Tools:WebConsole"
-                    key="key_webConsole"/>
-          <menuitem id="appmenu_pageInspect"
-                    hidden="true"
-                    label="&inspectMenu.label;"
-                    type="checkbox"
-                    command="Tools:Inspect"
-                    key="key_inspect"/>
-          <menuitem id="appmenu_responsiveUI"
-                    hidden="true"
-                    label="&responsiveDesignTool.label;"
-                    type="checkbox"
-                    command="Tools:ResponsiveUI"
-                    key="key_responsiveUI"/>
-          <menuitem id="appmenu_debugger"
-                    hidden="true"
-                    type="checkbox"
-                    label="&debuggerMenu.label2;"
-                    key="key_debugger"
-                    command="Tools:Debugger"/>
-          <menuitem id="appmenu_remoteDebugger"
-                    hidden="true"
-                    label="&remoteDebuggerMenu.label;"
-                    command="Tools:RemoteDebugger"/>
-          <menuitem id="appmenu_chromeDebugger"
-                    hidden="true"
-                    label="&chromeDebuggerMenu.label;"
-                    command="Tools:ChromeDebugger"/>
-          <menuitem id="appmenu_scratchpad"
-                    hidden="true"
-                    label="&scratchpad.label;"
-                    key="key_scratchpad"
-                    command="Tools:Scratchpad"/>
-          <menuitem id="appmenu_styleeditor"
-                    hidden="true"
-                    type="checkbox"
-                    label="&styleeditor.label;"
-                    key="key_styleeditor"
-                    command="Tools:StyleEditor"/>
-          <menuitem id="appmenu_pageSource"
-                    label="&viewPageSourceCmd.label;"
-                    command="View:PageSource"
-                    key="key_viewSource"/>
-          <menuitem id="appmenu_errorConsole"
-                    hidden="true"
-                    label="&errorConsoleCmd.label;"
-                    key="key_errorConsole"
-                    oncommand="toJavaScriptConsole();"/>
+          <menuitem id="appmenu_devToolbar" observes="devtoolsMenuBroadcaster_DevToolbar"/>
+          <menuitem id="appmenu_webConsole" observes="devtoolsMenuBroadcaster_WebConsole"/>
+          <menuitem id="appmenu_pageinspect" observes="devtoolsMenuBroadcaster_Inspect"/>
+          <menuitem id="appmenu_responsiveUI" observes="devtoolsMenuBroadcaster_ResponsiveUI"/>
+          <menuitem id="appmenu_debugger" observes="devtoolsMenuBroadcaster_Debugger"/>
+          <menuitem id="appmenu_remoteDebugger" observes="devtoolsMenuBroadcaster_RemoteDebugger"/>
+          <menuitem id="appmenu_chromeDebugger" observes="devtoolsMenuBroadcaster_ChromeDebugger"/>
+          <menuitem id="appmenu_scratchpad" observes="devtoolsMenuBroadcaster_Scratchpad"/>
+          <menuitem id="appmenu_styleeditor" observes="devtoolsMenuBroadcaster_StyleEditor"/>
+          <menuitem id="appmenu_pageSource" observes="devtoolsMenuBroadcaster_PageSource"/>
+          <menuitem id="appmenu_errorConsole" observes="devtoolsMenuBroadcaster_ErrorConsole"/>
           <menuseparator id="appmenu_devToolsEndSeparator"/>
-          <menuitem id="appmenu_getMoreDevtools"
-                    label="&getMoreDevtoolsCmd.label;"
-                    oncommand="openUILinkIn('https://addons.mozilla.org/firefox/collections/mozilla/webdeveloper/', 'tab');"/>
+          <menuitem id="appmenu_getMoreDevtools" observes="devtoolsMenuBroadcaster_GetMoreTools"/>
           <menuseparator/>
 #define ID_PREFIX appmenu_developer_
 #define OMIT_ACCESSKEYS
 #include browser-charsetmenu.inc
 #undef ID_PREFIX
 #undef OMIT_ACCESSKEYS
           <menuitem label="&goOfflineCmd.label;"
                     type="checkbox"
--- a/browser/base/content/browser-menubar.inc
+++ b/browser/base/content/browser-menubar.inc
@@ -509,87 +509,29 @@
                         observes="sync-syncnow-state"
                         oncommand="gSyncUI.doSync(event);"/>
 #endif
               <menuseparator id="devToolsSeparator"/>
               <menu id="webDeveloperMenu"
                     label="&webDeveloperMenu.label;"
                     accesskey="&webDeveloperMenu.accesskey;">
                 <menupopup id="menuWebDeveloperPopup">
-                  <menuitem id="menu_devToolbar"
-                            type="checkbox"
-                            autocheck="false"
-                            hidden="true"
-                            label="&devToolbarMenu.label;"
-                            accesskey="&devToolbarMenu.accesskey;"
-                            key="key_devToolbar"
-                            command="Tools:DevToolbar"/>
-                  <menuitem id="webConsole"
-                            type="checkbox"
-                            label="&webConsoleCmd.label;"
-                            accesskey="&webConsoleCmd.accesskey;"
-                            key="key_webConsole"
-                            command="Tools:WebConsole"/>
-                  <menuitem id="menu_pageinspect"
-                            type="checkbox"
-                            hidden="true"
-                            label="&inspectMenu.label;"
-                            accesskey="&inspectMenu.accesskey;"
-                            key="key_inspect"
-                            command="Tools:Inspect"/>
-                  <menuitem id="menu_responsiveUI"
-                            type="checkbox"
-                            hidden="true"
-                            label="&responsiveDesignTool.label;"
-                            accesskey="&responsiveDesignTool.accesskey;"
-                            key="key_responsiveUI"
-                            command="Tools:ResponsiveUI"/>
-                  <menuitem id="menu_debugger"
-                            hidden="true"
-                            type="checkbox"
-                            label="&debuggerMenu.label2;"
-                            key="key_debugger"
-                            command="Tools:Debugger"/>
-                  <menuitem id="menu_remoteDebugger"
-                            hidden="true"
-                            label="&remoteDebuggerMenu.label;"
-                            command="Tools:RemoteDebugger"/>
-                  <menuitem id="menu_chromeDebugger"
-                            hidden="true"
-                            label="&chromeDebuggerMenu.label;"
-                            command="Tools:ChromeDebugger"/>
-                  <menuitem id="menu_scratchpad"
-                            hidden="true"
-                            label="&scratchpad.label;"
-                            accesskey="&scratchpad.accesskey;"
-                            key="key_scratchpad"
-                            command="Tools:Scratchpad"/>
-                  <menuitem id="menu_styleeditor"
-                            type="checkbox"
-                            hidden="true"
-                            label="&styleeditor.label;"
-                            accesskey="&styleeditor.accesskey;"
-                            key="key_styleeditor"
-                            command="Tools:StyleEditor"/>
-                  <menuitem id="menu_pageSource"
-                            accesskey="&pageSourceCmd.accesskey;"
-                            label="&pageSourceCmd.label;"
-                            key="key_viewSource"
-                            command="View:PageSource"/>
-                  <menuitem id="javascriptConsole"
-                            hidden="true"
-                            label="&errorConsoleCmd.label;"
-                            accesskey="&errorConsoleCmd.accesskey;"
-                            key="key_errorConsole"
-                            oncommand="toJavaScriptConsole();"/>
+                  <menuitem id="menu_devToolbar" observes="devtoolsMenuBroadcaster_DevToolbar" accesskey="&devToolbarMenu.accesskey;"/>
+                  <menuitem id="webConsole" observes="devtoolsMenuBroadcaster_WebConsole" accesskey="&webConsoleCmd.accesskey;"/>
+                  <menuitem id="menu_pageinspect" observes="devtoolsMenuBroadcaster_Inspect" accesskey="&inspectMenu.accesskey;"/>
+                  <menuitem id="menu_responsiveUI" observes="devtoolsMenuBroadcaster_ResponsiveUI" accesskey="&responsiveDesignTool.accesskey;"/>
+                  <menuitem id="menu_debugger" observes="devtoolsMenuBroadcaster_Debugger"/>
+                  <menuitem id="menu_remoteDebugger" observes="devtoolsMenuBroadcaster_RemoteDebugger"/>
+                  <menuitem id="menu_chromeDebugger" observes="devtoolsMenuBroadcaster_ChromeDebugger"/>
+                  <menuitem id="menu_scratchpad" observes="devtoolsMenuBroadcaster_Scratchpad" accesskey="&scratchpad.accesskey;"/>
+                  <menuitem id="menu_styleeditor" observes="devtoolsMenuBroadcaster_StyleEditor" accesskey="&styleeditor.accesskey;"/>
+                  <menuitem id="menu_pageSource" observes="devtoolsMenuBroadcaster_PageSource" accesskey="&pageSourceCmd.accesskey;"/>
+                  <menuitem id="javascriptConsole" observes="devtoolsMenuBroadcaster_ErrorConsole" accesskey="&errorConsoleCmd.accesskey;"/>
                   <menuseparator id="devToolsEndSeparator"/>
-                  <menuitem id="getMoreDevtools"
-                            label="&getMoreDevtoolsCmd.label;"
-                            accesskey="&getMoreDevtoolsCmd.accesskey;"
-                            oncommand="openUILinkIn('https://addons.mozilla.org/firefox/collections/mozilla/webdeveloper/', 'tab');"/>
+                  <menuitem id="getMoreDevtools" observes="devtoolsMenuBroadcaster_GetMoreTools" accesskey="&getMoreDevtoolsCmd.accesskey;"/>
                 </menupopup>
               </menu>
               <menuitem id="menu_pageInfo"
                         accesskey="&pageInfoCmd.accesskey;"
                         label="&pageInfoCmd.label;"
 #ifndef XP_WIN
                         key="key_viewInfo"
 #endif
--- a/browser/base/content/browser-sets.inc
+++ b/browser/base/content/browser-sets.inc
@@ -83,26 +83,26 @@
     <command id="cmd_fullZoomReduce"  oncommand="FullZoom.reduce()"/>
     <command id="cmd_fullZoomEnlarge" oncommand="FullZoom.enlarge()"/>
     <command id="cmd_fullZoomReset"   oncommand="FullZoom.reset()"/>
     <command id="cmd_fullZoomToggle"  oncommand="ZoomManager.toggleZoom();"/>
     <command id="Browser:OpenLocation" oncommand="openLocation();"/>
 
     <command id="Tools:Search" oncommand="BrowserSearch.webSearch();"/>
     <command id="Tools:Downloads" oncommand="BrowserDownloadsUI();"/>
-    <command id="Tools:DevToolbar" oncommand="DeveloperToolbar.toggle();" disabled="true"/>
+    <command id="Tools:DevToolbar" oncommand="DeveloperToolbar.toggle();"/>
     <command id="Tools:DevToolbarFocus" oncommand="DeveloperToolbar.focus();" disabled="true"/>
     <command id="Tools:WebConsole" oncommand="HUDConsoleUI.toggleHUD();"/>
-    <command id="Tools:Inspect" oncommand="InspectorUI.toggleInspectorUI();" disabled="true"/>
-    <command id="Tools:Debugger" oncommand="DebuggerUI.toggleDebugger();" disabled="true"/>
-    <command id="Tools:RemoteDebugger" oncommand="DebuggerUI.toggleRemoteDebugger();" disabled="true"/>
-    <command id="Tools:ChromeDebugger" oncommand="DebuggerUI.toggleChromeDebugger();" disabled="true"/>
-    <command id="Tools:Scratchpad" oncommand="Scratchpad.openScratchpad();" disabled="true"/>
-    <command id="Tools:StyleEditor" oncommand="StyleEditor.toggle();" disabled="true"/>
-    <command id="Tools:ResponsiveUI" oncommand="ResponsiveUI.toggle();" disabled="true"/>
+    <command id="Tools:Inspect" oncommand="InspectorUI.toggleInspectorUI();"/>
+    <command id="Tools:Debugger" oncommand="DebuggerUI.toggleDebugger();"/>
+    <command id="Tools:RemoteDebugger" oncommand="DebuggerUI.toggleRemoteDebugger();"/>
+    <command id="Tools:ChromeDebugger" oncommand="DebuggerUI.toggleChromeDebugger();"/>
+    <command id="Tools:Scratchpad" oncommand="Scratchpad.openScratchpad();"/>
+    <command id="Tools:StyleEditor" oncommand="StyleEditor.toggle();"/>
+    <command id="Tools:ResponsiveUI" oncommand="ResponsiveUI.toggle();"/>
     <command id="Tools:Addons" oncommand="BrowserOpenAddonsMgr();"/>
     <command id="Tools:Sanitize"
      oncommand="Cc['@mozilla.org/browser/browserglue;1'].getService(Ci.nsIBrowserGlue).sanitize(window);"/>
     <command id="Tools:PrivateBrowsing" oncommand="gPrivateBrowsingUI.toggleMode();"/>
     <command id="History:UndoCloseTab" oncommand="undoCloseTab();"/>
     <command id="History:UndoCloseWindow" oncommand="undoCloseWindow();"/>
     <command id="Browser:ToggleAddonBar" oncommand="toggleAddonBar();"/>
     <command id="Social:SharePage" oncommand="SocialShareButton.sharePage();"/>
@@ -178,16 +178,78 @@
     <broadcaster id="multipleFeedsMenuState" hidden="true"/>
     <broadcaster id="tabviewGroupsNumber" groups="1"/>
 #ifdef MOZ_SERVICES_SYNC
     <broadcaster id="sync-setup-state"/>
     <broadcaster id="sync-syncnow-state"/>
 #endif
     <broadcaster id="workOfflineMenuitemState"/>
     <broadcaster id="socialSidebarBroadcaster" hidden="true"/>
+
+    <!-- DevTools broadcasters -->
+    <broadcaster id="devtoolsMenuBroadcaster_DevToolbar"
+                 label="&devToolbarMenu.label;"
+                 type="checkbox" autocheck="false"
+                 command="Tools:DevToolbar"
+                 key="key_devToolbar"
+                 disabled="true" hidden="true"/>
+    <broadcaster id="devtoolsMenuBroadcaster_WebConsole"
+                 label="&webConsoleCmd.label;"
+                 type="checkbox" autocheck="false"
+                 key="key_webConsole"
+                 command="Tools:WebConsole"/>
+    <broadcaster id="devtoolsMenuBroadcaster_Inspect"
+                 label="&inspectMenu.label;"
+                 type="checkbox" autocheck="false"
+                 command="Tools:Inspect"
+                 key="key_inspect"
+                 disabled="true" hidden="true"/>
+    <broadcaster id="devtoolsMenuBroadcaster_Debugger"
+                 label="&debuggerMenu.label2;"
+                 type="checkbox" autocheck="false"
+                 command="Tools:Debugger"
+                 key="key_debugger"
+                 disabled="true" hidden="true"/>
+    <broadcaster id="devtoolsMenuBroadcaster_RemoteDebugger"
+                 label="&remoteDebuggerMenu.label;"
+                 command="Tools:RemoteDebugger"
+                 disabled="true" hidden="true"/>
+    <broadcaster id="devtoolsMenuBroadcaster_ChromeDebugger"
+                 label="&chromeDebuggerMenu.label;"
+                 command="Tools:ChromeDebugger"
+                 disabled="true" hidden="true"/>
+    <broadcaster id="devtoolsMenuBroadcaster_Scratchpad"
+                 label="&scratchpad.label;"
+                 command="Tools:Scratchpad"
+                 key="key_scratchpad"
+                 disabled="true" hidden="true"/>
+    <broadcaster id="devtoolsMenuBroadcaster_StyleEditor"
+                 label="&styleeditor.label;"
+                 type="checkbox" autocheck="false"
+                 command="Tools:StyleEditor"
+                 key="key_styleeditor"
+                 disabled="true" hidden="true"/>
+    <broadcaster id="devtoolsMenuBroadcaster_ResponsiveUI"
+                 label="&responsiveDesignTool.label;"
+                 type="checkbox" autocheck="false"
+                 command="Tools:ResponsiveUI"
+                 key="key_responsiveUI"
+                 disabled="true" hidden="true"/>
+    <broadcaster id="devtoolsMenuBroadcaster_PageSource"
+                 label="&pageSourceCmd.label;"
+                 key="key_viewSource"
+                 command="View:PageSource"/>
+    <broadcaster id="devtoolsMenuBroadcaster_ErrorConsole"
+                 hidden="true"
+                 label="&errorConsoleCmd.label;"
+                 key="key_errorConsole"
+                 oncommand="toJavaScriptConsole();"/>
+    <broadcaster id="devtoolsMenuBroadcaster_GetMoreTools"
+                 label="&getMoreDevtoolsCmd.label;"
+                 oncommand="openUILinkIn('https://addons.mozilla.org/firefox/collections/mozilla/webdeveloper/', 'tab');"/>
   </broadcasterset>
 
   <keyset id="mainKeyset">
     <key id="key_newNavigator"
          key="&newNavigatorCmd.key;"
          command="cmd_newNavigator"
          modifiers="accel"/>
     <key id="key_newNavigatorTab" key="&tabCmd.commandkey;" modifiers="accel" command="cmd_newNavigatorTab"/>
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -573,16 +573,22 @@ html|*#gcli-output-frame,
 }
 
 #developer-toolbar-webconsole[error-count]:before {
   content: attr(error-count);
   display: -moz-box;
   -moz-box-pack: center;
 }
 
+/* We don't show the Style Editor button in the developer toolbar for now.
+   See bug 771203 */
+#developer-toolbar-styleeditor {
+  display: none;
+}
+
 /* Responsive Mode */
 
 vbox[anonid=browserContainer][responsivemode] {
   overflow: auto;
 }
 
 .devtools-responsiveui-toolbar:-moz-locale-dir(rtl) {
   -moz-box-pack: end;
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1397,124 +1397,101 @@ var gBrowserInit = {
     window.addEventListener("resize", function resizeHandler(event) {
       if (event.target == window)
         setUrlAndSearchBarWidthForConditionalForwardButton();
     });
 
     // Enable developer toolbar?
     let devToolbarEnabled = gPrefService.getBoolPref("devtools.toolbar.enabled");
     if (devToolbarEnabled) {
-      document.getElementById("menu_devToolbar").hidden = false;
-      document.getElementById("Tools:DevToolbar").removeAttribute("disabled");
+      let broadcaster = document.getElementById("devtoolsMenuBroadcaster_DevToolbar");
+      broadcaster.removeAttribute("disabled");
+      broadcaster.removeAttribute("hidden");
       document.getElementById("Tools:DevToolbarFocus").removeAttribute("disabled");
-#ifdef MENUBAR_CAN_AUTOHIDE
-      document.getElementById("appmenu_devToolbar").hidden = false;
-#endif
 
       // Show the toolbar if it was previously visible
       if (gPrefService.getBoolPref("devtools.toolbar.visible")) {
         DeveloperToolbar.show(false);
       }
     }
 
     // Enable Inspector?
     let enabled = gPrefService.getBoolPref("devtools.inspector.enabled");
     if (enabled) {
-      document.getElementById("menu_pageinspect").hidden = false;
-      document.getElementById("Tools:Inspect").removeAttribute("disabled");
-#ifdef MENUBAR_CAN_AUTOHIDE
-      document.getElementById("appmenu_pageInspect").hidden = false;
-#endif
-      document.getElementById("developer-toolbar-inspector").hidden = false;
+      let broadcaster = document.getElementById("devtoolsMenuBroadcaster_Inspect");
+      broadcaster.removeAttribute("disabled");
+      broadcaster.removeAttribute("hidden");
     }
 
     // Enable Debugger?
     let enabled = gPrefService.getBoolPref("devtools.debugger.enabled");
     if (enabled) {
-      document.getElementById("menu_debugger").hidden = false;
-      document.getElementById("Tools:Debugger").removeAttribute("disabled");
-#ifdef MENUBAR_CAN_AUTOHIDE
-      document.getElementById("appmenu_debugger").hidden = false;
-#endif
-      document.getElementById("developer-toolbar-debugger").hidden = false;
+      let broadcaster = document.getElementById("devtoolsMenuBroadcaster_Debugger");
+      broadcaster.removeAttribute("disabled");
+      broadcaster.removeAttribute("hidden");
     }
 
     // Enable Remote Debugger?
     let enabled = gPrefService.getBoolPref("devtools.debugger.remote-enabled");
     if (enabled) {
-      document.getElementById("menu_remoteDebugger").hidden = false;
-      document.getElementById("Tools:RemoteDebugger").removeAttribute("disabled");
-#ifdef MENUBAR_CAN_AUTOHIDE
-      document.getElementById("appmenu_remoteDebugger").hidden = false;
-#endif
+      let broadcaster = document.getElementById("devtoolsMenuBroadcaster_RemoteDebugger");
+      broadcaster.removeAttribute("disabled");
+      broadcaster.removeAttribute("hidden");
     }
 
     // Enable Chrome Debugger?
     let enabled = gPrefService.getBoolPref("devtools.chrome.enabled") &&
                   gPrefService.getBoolPref("devtools.debugger.chrome-enabled") &&
                   gPrefService.getBoolPref("devtools.debugger.remote-enabled");
     if (enabled) {
-      document.getElementById("menu_chromeDebugger").hidden = false;
-      document.getElementById("Tools:ChromeDebugger").removeAttribute("disabled");
-#ifdef MENUBAR_CAN_AUTOHIDE
-      document.getElementById("appmenu_chromeDebugger").hidden = false;
-#endif
+      let broadcaster = document.getElementById("devtoolsMenuBroadcaster_ChromeDebugger");
+      broadcaster.removeAttribute("disabled");
+      broadcaster.removeAttribute("hidden");
     }
 
     // Enable Error Console?
     // XXX Temporarily always-enabled, see bug 601201
     let consoleEnabled = true || gPrefService.getBoolPref("devtools.errorconsole.enabled");
     if (consoleEnabled) {
-      document.getElementById("javascriptConsole").hidden = false;
-      document.getElementById("key_errorConsole").removeAttribute("disabled");
-#ifdef MENUBAR_CAN_AUTOHIDE
-      document.getElementById("appmenu_errorConsole").hidden = false;
-#endif
+      let broadcaster = document.getElementById("devtoolsMenuBroadcaster_ErrorConsole");
+      broadcaster.removeAttribute("disabled");
+      broadcaster.removeAttribute("hidden");
     }
 
     // Enable Scratchpad in the UI, if the preference allows this.
     let scratchpadEnabled = gPrefService.getBoolPref(Scratchpad.prefEnabledName);
     if (scratchpadEnabled) {
-      document.getElementById("menu_scratchpad").hidden = false;
-      document.getElementById("Tools:Scratchpad").removeAttribute("disabled");
-#ifdef MENUBAR_CAN_AUTOHIDE
-      document.getElementById("appmenu_scratchpad").hidden = false;
-#endif
+      let broadcaster = document.getElementById("devtoolsMenuBroadcaster_Scratchpad");
+      broadcaster.removeAttribute("disabled");
+      broadcaster.removeAttribute("hidden");
     }
 
     // Enable Style Editor?
     let styleEditorEnabled = gPrefService.getBoolPref(StyleEditor.prefEnabledName);
     if (styleEditorEnabled) {
-      document.getElementById("menu_styleeditor").hidden = false;
-      document.getElementById("Tools:StyleEditor").removeAttribute("disabled");
-#ifdef MENUBAR_CAN_AUTOHIDE
-      document.getElementById("appmenu_styleeditor").hidden = false;
-#endif
-      // We don't show the Style Editor button in the developer toolbar for now.
-      // See bug 771203
-      // document.getElementById("developer-toolbar-styleeditor").hidden = false;
+      let broadcaster = document.getElementById("devtoolsMenuBroadcaster_StyleEditor");
+      broadcaster.removeAttribute("disabled");
+      broadcaster.removeAttribute("hidden");
     }
 
 #ifdef MENUBAR_CAN_AUTOHIDE
     // If the user (or the locale) hasn't enabled the top-level "Character
     // Encoding" menu via the "browser.menu.showCharacterEncoding" preference,
     // hide it.
     if ("true" != gPrefService.getComplexValue("browser.menu.showCharacterEncoding",
                                                Ci.nsIPrefLocalizedString).data)
       document.getElementById("appmenu_charsetMenu").hidden = true;
 #endif
 
     // Enable Responsive UI?
     let responsiveUIEnabled = gPrefService.getBoolPref("devtools.responsiveUI.enabled");
     if (responsiveUIEnabled) {
-      document.getElementById("menu_responsiveUI").hidden = false;
-      document.getElementById("Tools:ResponsiveUI").removeAttribute("disabled");
-#ifdef MENUBAR_CAN_AUTOHIDE
-      document.getElementById("appmenu_responsiveUI").hidden = false;
-#endif
+      let broadcaster = document.getElementById("devtoolsMenuBroadcaster_ResponsiveUI");
+      broadcaster.removeAttribute("disabled");
+      broadcaster.removeAttribute("hidden");
     }
 
     let appMenuButton = document.getElementById("appmenu-button");
     let appMenuPopup = document.getElementById("appmenu-popup");
     if (appMenuButton && appMenuPopup) {
       let appMenuOpening = null;
       appMenuButton.addEventListener("mousedown", function(event) {
         if (event.button == 0)
@@ -4880,20 +4857,27 @@ function toggleSidebar(commandID, forceO
 
   var sidebarBroadcaster = document.getElementById(commandID);
   var sidebar = document.getElementById("sidebar"); // xul:browser
   var sidebarTitle = document.getElementById("sidebar-title");
   var sidebarSplitter = document.getElementById("sidebar-splitter");
 
   if (sidebarBroadcaster.getAttribute("checked") == "true") {
     if (!forceOpen) {
+      // Replace the document currently displayed in the sidebar with about:blank
+      // so that we can free memory by unloading the page. We need to explicitly
+      // create a new content viewer because the old one doesn't get destroyed
+      // until about:blank has loaded (which does not happen as long as the
+      // element is hidden).
+      sidebar.setAttribute("src", "about:blank");
+      sidebar.docShell.createAboutBlankContentViewer(null);
+
       sidebarBroadcaster.removeAttribute("checked");
       sidebarBox.setAttribute("sidebarcommand", "");
       sidebarTitle.value = "";
-      sidebar.setAttribute("src", "about:blank");
       sidebarBox.hidden = true;
       sidebarSplitter.hidden = true;
       content.focus();
     } else {
       fireSidebarFocusedEvent();
     }
     return;
   }
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -1150,34 +1150,45 @@
           <stack class="gclitoolbar-stack-node" flex="1">
             <hbox class="gclitoolbar-prompt">
               <label class="gclitoolbar-prompt-label">&#187;</label>
             </hbox>
             <hbox class="gclitoolbar-complete-node"/>
             <textbox class="gclitoolbar-input-node" rows="1"/>
           </stack>
           <toolbarbutton id="developer-toolbar-webconsole"
-                         label="&webConsoleButton.label;"
                          class="developer-toolbar-button"
-                         command="Tools:WebConsole"/>
+                         observes="devtoolsMenuBroadcaster_WebConsole"/>
           <toolbarbutton id="developer-toolbar-inspector"
-                         label="&inspectorButton.label;"
                          class="developer-toolbar-button"
-                         hidden="true"
-                         command="Tools:Inspect"/>
+                         observes="devtoolsMenuBroadcaster_Inspect"/>
           <toolbarbutton id="developer-toolbar-styleeditor"
-                         label="&styleeditor.label;"
                          class="developer-toolbar-button"
-                         hidden="true"
-                         command="Tools:StyleEditor"/>
+                         observes="devtoolsMenuBroadcaster_StyleEditor"/>
           <toolbarbutton id="developer-toolbar-debugger"
-                         label="&debuggerMenu.label2;"
+                         class="developer-toolbar-button"
+                         observes="devtoolsMenuBroadcaster_Debugger"/>
+          <toolbarbutton id="developer-toolbar-other-tools"
+                         type="menu"
                          class="developer-toolbar-button"
-                         hidden="true"
-                         command="Tools:Debugger"/>
+                         label="&devToolbarOtherToolsButton.label;">
+            <menupopup position="before_end">
+               <menuitem observes="devtoolsMenuBroadcaster_DevToolbar"/>
+               <menuitem observes="devtoolsMenuBroadcaster_ResponsiveUI"/>
+               <menuitem observes="devtoolsMenuBroadcaster_RemoteDebugger"/>
+               <menuitem observes="devtoolsMenuBroadcaster_ChromeDebugger"/>
+               <menuitem observes="devtoolsMenuBroadcaster_Scratchpad"/>
+               <menuitem observes="devtoolsMenuBroadcaster_StyleEditor"/>
+               <menuitem observes="devtoolsMenuBroadcaster_PageSource"/>
+               <menuitem observes="devtoolsMenuBroadcaster_ErrorConsole"/>
+               <menuseparator/>
+               <menuitem observes="devtoolsMenuBroadcaster_GetMoreTools"/>
+            </menupopup>
+          </toolbarbutton>
+
 #ifndef XP_MACOSX
           <toolbarbutton id="developer-toolbar-closebutton"
                          class="devtools-closebutton"
                          oncommand="DeveloperToolbar.hide();"
                          tooltiptext="&devToolbarCloseButton.tooltiptext;"/>
 #endif
    </toolbar>
 
--- a/browser/base/content/test/browser_aboutHome.js
+++ b/browser/base/content/test/browser_aboutHome.js
@@ -159,13 +159,13 @@ function runNextTest()
   }
 }
 
 function getStorage()
 {
   let aboutHomeURI = Services.io.newURI("moz-safe-about:home", null, null);
   let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"].
                   getService(Components.interfaces.nsIScriptSecurityManager).
-                  getCodebasePrincipal(Services.io.newURI("about:home", null, null));
+                  getNoAppCodebasePrincipal(Services.io.newURI("about:home", null, null));
   let dsm = Components.classes["@mozilla.org/dom/storagemanager;1"].
             getService(Components.interfaces.nsIDOMStorageManager);
   return dsm.getLocalStorageForPrincipal(principal, "");
 };
--- a/browser/base/content/test/browser_bug413915.js
+++ b/browser/base/content/test/browser_bug413915.js
@@ -1,12 +1,12 @@
 function test() {
   var exampleUri = makeURI("http://example.com/");
   var secman = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
-  var principal = secman.getCodebasePrincipal(exampleUri);
+  var principal = secman.getSimpleCodebasePrincipal(exampleUri);
 
   function testIsFeed(aTitle, aHref, aType, aKnown) {
     var link = { title: aTitle, href: aHref, type: aType };
     return isValidFeed(link, principal, aKnown);
   }
 
   var href = "http://example.com/feed/";
   var atomType = "application/atom+xml";
--- a/browser/base/content/test/browser_pluginnotification.js
+++ b/browser/base/content/test/browser_pluginnotification.js
@@ -1,10 +1,11 @@
 var rootDir = getRootDirectory(gTestPath);
 const gTestRoot = rootDir;
+const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
 
 var gTestBrowser = null;
 var gNextTest = null;
 var gClickToPlayPluginActualEvents = 0;
 var gClickToPlayPluginExpectedEvents = 5;
 
 function get_test_plugin() {
   var ph = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
@@ -351,17 +352,17 @@ function test11c() {
 // Tests that the going back will reshow the notification for click-to-play plugins (part 4/4)
 function test11d() {
   var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(popupNotification, "Test 11d, Should have a click-to-play notification");
   is(gClickToPlayPluginActualEvents, gClickToPlayPluginExpectedEvents,
      "There should be a PluginClickToPlay event for each plugin that was " +
      "blocked due to the plugins.click_to_play pref");
 
-  prepareTest(test12a, gTestRoot + "plugin_clickToPlayAllow.html");
+  prepareTest(test12a, gHttpTestRoot + "plugin_clickToPlayAllow.html");
 }
 
 // Tests that the "Allow Always" permission works for click-to-play plugins (part 1/3)
 function test12a() {
   var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(popupNotification, "Test 12a, Should have a click-to-play notification");
   var plugin = gTestBrowser.contentDocument.getElementById("test");
   var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
@@ -376,17 +377,17 @@ function test12a() {
 // Tests that the "Always" permission works for click-to-play plugins (part 2/3)
 function test12b() {
   var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(!popupNotification, "Test 12b, Should not have a click-to-play notification");
   var plugin = gTestBrowser.contentDocument.getElementById("test");
   var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(objLoadingContent.activated, "Test 12b, Plugin should be activated");
 
-  prepareTest(test12c, gTestRoot + "plugin_clickToPlayAllow.html");
+  prepareTest(test12c, gHttpTestRoot + "plugin_clickToPlayAllow.html");
 }
 
 // Tests that the "Always" permission works for click-to-play plugins (part 3/3)
 function test12c() {
   var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(!popupNotification, "Test 12c, Should not have a click-to-play notification");
   var plugin = gTestBrowser.contentDocument.getElementById("test");
   var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
--- a/browser/base/content/test/browser_sanitizeDialog.js
+++ b/browser/base/content/test/browser_sanitizeDialog.js
@@ -441,17 +441,17 @@ var gAllTests = [
     var URL = "http://www.example.com";
 
     var ios = Cc["@mozilla.org/network/io-service;1"]
               .getService(Ci.nsIIOService);
     var URI = ios.newURI(URL, null, null);
 
     var sm = Cc["@mozilla.org/scriptsecuritymanager;1"]
              .getService(Ci.nsIScriptSecurityManager);
-    var principal = sm.getCodebasePrincipal(URI);
+    var principal = sm.getNoAppCodebasePrincipal(URI);
 
     // Give www.example.com privileges to store offline data
     var pm = Cc["@mozilla.org/permissionmanager;1"]
              .getService(Ci.nsIPermissionManager);
     pm.add(URI, "offline-app", Ci.nsIPermissionManager.ALLOW_ACTION);
     pm.add(URI, "offline-app", Ci.nsIOfflineCacheUpdateService.ALLOW_NO_WARN);
 
     // Store some user data to localStorage
--- a/browser/base/content/test/newtab/head.js
+++ b/browser/base/content/test/newtab/head.js
@@ -9,17 +9,17 @@ let tmp = {};
 Cu.import("resource:///modules/NewTabUtils.jsm", tmp);
 Cc["@mozilla.org/moz/jssubscript-loader;1"]
   .getService(Ci.mozIJSSubScriptLoader)
   .loadSubScript("chrome://browser/content/sanitize.js", tmp);
 
 let {NewTabUtils, Sanitizer} = tmp;
 
 let uri = Services.io.newURI("about:newtab", null, null);
-let principal = Services.scriptSecurityManager.getCodebasePrincipal(uri);
+let principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri);
 
 let sm = Services.domStorageManager;
 let storage = sm.getLocalStorageForPrincipal(principal, "");
 
 registerCleanupFunction(function () {
   while (gBrowser.tabs.length > 1)
     gBrowser.removeTab(gBrowser.tabs[1]);
 
--- a/browser/components/feeds/src/FeedWriter.js
+++ b/browser/components/feeds/src/FeedWriter.js
@@ -1114,17 +1114,17 @@ FeedWriter.prototype = {
 
     this._window = window;
     this._document = window.document;
     this._document.getElementById("feedSubscribeLine").offsetTop;
     this._handlersMenuList = this._getUIElement("handlersMenuList");
 
     var secman = Cc["@mozilla.org/scriptsecuritymanager;1"].
                  getService(Ci.nsIScriptSecurityManager);
-    this._feedPrincipal = secman.getCodebasePrincipal(this._feedURI);
+    this._feedPrincipal = secman.getSimpleCodebasePrincipal(this._feedURI);
 
     LOG("Subscribe Preview: feed uri = " + this._window.location.href);
 
     // Set up the subscription UI
     this._initSubscriptionUI();
     var prefs = Cc["@mozilla.org/preferences-service;1"].
                 getService(Ci.nsIPrefBranch);
     prefs.addObserver(PREF_SELECTED_ACTION, this, false);
--- a/browser/components/nsBrowserContentHandler.js
+++ b/browser/components/nsBrowserContentHandler.js
@@ -836,17 +836,17 @@ nsDefaultCommandLineHandler.prototype = 
 };
 
 let AboutHomeUtils = {
   SNIPPETS_URL_PREF: "browser.aboutHomeSnippets.updateUrl",
   get _storage() {
     let aboutHomeURI = Services.io.newURI("moz-safe-about:home", null, null);
     let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"].
                     getService(Components.interfaces.nsIScriptSecurityManager).
-                    getCodebasePrincipal(aboutHomeURI);
+                    getNoAppCodebasePrincipal(aboutHomeURI);
     let dsm = Components.classes["@mozilla.org/dom/storagemanager;1"].
               getService(Components.interfaces.nsIDOMStorageManager);
     return dsm.getLocalStorageForPrincipal(principal, "");
   },
 
   loadDefaultSearchEngine: function AHU_loadDefaultSearchEngine()
   {
     let defaultEngine = Services.search.originalDefaultEngine;
--- a/browser/components/privatebrowsing/test/unit/do_test_removeDataFromDomain.js
+++ b/browser/components/privatebrowsing/test/unit/do_test_removeDataFromDomain.js
@@ -538,17 +538,17 @@ function test_cache_cleared()
 }
 
 function test_storage_cleared()
 {
   function getStorageForURI(aURI)
   {
     let principal = Cc["@mozilla.org/scriptsecuritymanager;1"].
                     getService(Ci.nsIScriptSecurityManager).
-                    getCodebasePrincipal(aURI);
+                    getNoAppCodebasePrincipal(aURI);
     let dsm = Cc["@mozilla.org/dom/storagemanager;1"].
               getService(Ci.nsIDOMStorageManager);
     return dsm.getLocalStorageForPrincipal(principal, "");
   }
 
   let s = [
     getStorageForURI(uri("http://mozilla.org")),
     getStorageForURI(uri("http://my.mozilla.org")),
--- a/browser/components/sessionstore/src/SessionStorage.jsm
+++ b/browser/components/sessionstore/src/SessionStorage.jsm
@@ -47,30 +47,30 @@ let DomStorage = {
    *        Always return privacy sensitive data (use with care)
    */
   read: function DomStorage_read(aDocShell, aFullData) {
     let data = {};
     let isPinned = aDocShell.isAppTab;
     let shistory = aDocShell.sessionHistory;
 
     for (let i = 0; i < shistory.count; i++) {
-      let uri = History.getUriForEntry(shistory, i);
+      let principal = History.getPrincipalForEntry(shistory, i, aDocShell);
+      if (!principal)
+        continue;
 
-      if (uri) {
-        // Check if we're allowed to store sessionStorage data.
-        let isHTTPS = uri.schemeIs("https");
-        if (aFullData || SessionStore.checkPrivacyLevel(isHTTPS, isPinned)) {
-          let host = History.getHostForURI(uri);
+      // Check if we're allowed to store sessionStorage data.
+      let isHTTPS = principal.URI && principal.URI.schemeIs("https");
+      if (aFullData || SessionStore.checkPrivacyLevel(isHTTPS, isPinned)) {
+        let origin = principal.extendedOrigin;
 
-          // Don't read a host twice.
-          if (!(host in data)) {
-            let hostData = this._readEntry(uri, aDocShell);
-            if (Object.keys(hostData).length) {
-              data[host] = hostData;
-            }
+        // Don't read a host twice.
+        if (!(origin in data)) {
+          let originData = this._readEntry(principal, aDocShell);
+          if (Object.keys(originData).length) {
+            data[origin] = originData;
           }
         }
       }
     }
 
     return data;
   },
 
@@ -79,17 +79,18 @@ let DomStorage = {
    * @param aDocShell
    *        A tab's docshell (containing the sessionStorage)
    * @param aStorageData
    *        Storage data to be restored
    */
   write: function DomStorage_write(aDocShell, aStorageData) {
     for (let [host, data] in Iterator(aStorageData)) {
       let uri = Services.io.newURI(host, null, null);
-      let storage = aDocShell.getSessionStorageForURI(uri, "");
+      let principal = Services.scriptSecurityManager.getDocShellCodebasePrincipal(uri, aDocShell);
+      let storage = aDocShell.getSessionStorageForPrincipal(principal, "", true);
 
       for (let [key, value] in Iterator(data)) {
         try {
           storage.setItem(key, value);
         } catch (e) {
           // throws e.g. for URIs that can't have sessionStorage
           Cu.reportError(e);
         }
@@ -99,29 +100,27 @@ let DomStorage = {
 
   /**
    * Reads an entry in the session storage data contained in a tab's history.
    * @param aURI
    *        That history entry uri
    * @param aDocShell
    *        A tab's docshell (containing the sessionStorage)
    */
-  _readEntry: function DomStorage_readEntry(aURI, aDocShell) {
+  _readEntry: function DomStorage_readEntry(aPrincipal, aDocShell) {
     let hostData = {};
     let storage;
 
     try {
-      let principal = Services.scriptSecurityManager.getCodebasePrincipal(aURI);
-
       // Using getSessionStorageForPrincipal instead of
       // getSessionStorageForURI just to be able to pass aCreate = false,
       // that avoids creation of the sessionStorage object for the page
       // earlier than the page really requires it. It was causing problems
       // while accessing a storage when a page later changed its domain.
-      storage = aDocShell.getSessionStorageForPrincipal(principal, "", false);
+      storage = aDocShell.getSessionStorageForPrincipal(aPrincipal, "", false);
     } catch (e) {
       // sessionStorage might throw if it's turned off, see bug 458954
     }
 
     if (storage && storage.length) {
        for (let i = 0; i < storage.length; i++) {
         try {
           let key = storage.key(i);
@@ -138,35 +137,22 @@ let DomStorage = {
 
 let History = {
   /**
    * Returns a given history entry's URI.
    * @param aHistory
    *        That tab's session history
    * @param aIndex
    *        The history entry's index
+   * @param aDocShell
+   *        That tab's docshell
    */
-  getUriForEntry: function History_getUriForEntry(aHistory, aIndex) {
+  getPrincipalForEntry: function History_getPrincipalForEntry(aHistory,
+                                                              aIndex,
+                                                              aDocShell) {
     try {
-      return aHistory.getEntryAtIndex(aIndex, false).URI;
+      return Services.scriptSecurityManager.getDocShellCodebasePrincipal(
+        aHistory.getEntryAtIndex(aIndex, false).URI, aDocShell);
     } catch (e) {
       // This might throw for some reason.
     }
   },
-
-  /**
-   * Returns the host of a given URI.
-   * @param aURI
-   *        The URI for which to return the host
-   */
-  getHostForURI: function History_getHostForURI(aURI) {
-    let host = aURI.spec;
-
-    try {
-      if (aURI.host)
-        host = aURI.prePath;
-    } catch (e) {
-      // This throws for host-less URIs (such as about: or jar:).
-    }
-
-    return host;
-  }
 };
--- a/browser/devtools/styleinspector/CssRuleView.jsm
+++ b/browser/devtools/styleinspector/CssRuleView.jsm
@@ -383,17 +383,17 @@ Rule.prototype = {
     }
     this._inheritedSource = "";
     if (this.inherited) {
       let eltText = this.inherited.tagName.toLowerCase();
       if (this.inherited.id) {
         eltText += "#" + this.inherited.id;
       }
       this._inheritedSource =
-        CssLogic._strings.formatStringFromName("rule.inheritedSource", [eltText], 1);
+        CssLogic._strings.formatStringFromName("rule.inheritedFrom", [eltText], 1);
     }
     return this._inheritedSource;
   },
 
   /**
    * The rule's stylesheet.
    */
   get sheet()
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_598357_jsterm_output.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_598357_jsterm_output.js
@@ -52,25 +52,25 @@ let inputValues = [
 
   // 9
   [false, "undefined", "undefined"],
 
   // 10
   [false, "true", "true"],
 
   // 11
-  [false, "document.getElementById", "function getElementById() {[native code]}",
+  [false, "document.getElementById", "function getElementById() {\n    [native code]\n}",
     "function getElementById() {\n    [native code]\n}",
-    "function getElementById() {[native code]}",
+    "function getElementById() {\n    [native code]\n}",
     "document.wrappedJSObject.getElementById"],
 
   // 12
-  [false, "(function() { return 42; })", "function () {return 42;}",
-    "function () {\n    return 42;\n}",
-    "(function () {return 42;})"],
+  [false, "(function() { return 42; })", "function () { return 42; }",
+    "function () { return 42; }",
+    "(function () { return 42; })"],
 
   // 13
   [false, "new Date(" + dateNow + ")", (new Date(dateNow)).toString()],
 
   // 14
   [true, "document.body", "[object HTMLBodyElement", "[object HTMLBodyElement",
     "[object HTMLBodyElement",
     "document.wrappedJSObject.body"],
--- a/browser/locales/en-US/chrome/browser/browser.dtd
+++ b/browser/locales/en-US/chrome/browser/browser.dtd
@@ -236,16 +236,17 @@ These should match what Safari and other
 
 <!ENTITY inspectCloseButton.tooltiptext "Close Inspector">
 
 <!ENTITY devToolbarCloseButton.tooltiptext "Close Developer Toolbar">
 <!ENTITY devToolbarMenu.label              "Developer Toolbar">
 <!ENTITY devToolbarMenu.accesskey          "v">
 <!ENTITY devToolbar.keycode                "VK_F2">
 <!ENTITY devToolbar.keytext                "F2">
+<!ENTITY devToolbarOtherToolsButton.label  "More Tools">
 
 <!ENTITY webConsoleButton.label "Web Console">
 <!ENTITY inspectorButton.label "Inspector">
 
 <!ENTITY inspectorHTMLCopyInner.label       "Copy Inner HTML">
 <!ENTITY inspectorHTMLCopyInner.accesskey   "I">
 
 <!ENTITY inspectorHTMLCopyOuter.label       "Copy Outer HTML">
--- a/browser/locales/en-US/chrome/browser/devtools/styleinspector.properties
+++ b/browser/locales/en-US/chrome/browser/devtools/styleinspector.properties
@@ -25,21 +25,21 @@ rule.status.UNMATCHED=Unmatched
 
 # LOCALIZATION NOTE (rule.sourceElement, rule.sourceInline): For each
 # style property the panel shows the rules which hold that specific property.
 # For every rule, the rule source is also displayed: a rule can come from a
 # file, from the same page (inline), or from the element itself (element).
 rule.sourceInline=inline
 rule.sourceElement=element
 
-# LOCALIZATION NOTE (rule.inheritedSource): Shown for CSS rules
-# that were inherited from a parent node.  Will be passed a node
-# identifier and a source location.
+# LOCALIZATION NOTE (rule.inheritedFrom): Shown for CSS rules
+# that were inherited from a parent node. Will be passed a node
+# identifier of the parent node.
 # e.g "Inherited from body#bodyID"
-rule.inheritedSource=Inherited from %S
+rule.inheritedFrom=Inherited from %S
 
 # LOCALIZATION NOTE (style.highlighter.button): These strings are used inside
 # sidebar of the Highlighter for the style inspector button.
 # "Computed" refers to the Computed Style of the element.
 style.highlighter.button.label2=Computed
 style.highlighter.accesskey2=C
 style.highlighter.button.tooltip2=Inspect element computed styles
 
--- a/browser/modules/NewTabUtils.jsm
+++ b/browser/modules/NewTabUtils.jsm
@@ -13,17 +13,17 @@ const Cu = Components.utils;
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
   "resource://gre/modules/PlacesUtils.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "gPrincipal", function () {
   let uri = Services.io.newURI("about:newtab", null, null);
-  return Services.scriptSecurityManager.getCodebasePrincipal(uri);
+  return Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri);
 });
 
 // The preference that tells whether this feature is enabled.
 const PREF_NEWTAB_ENABLED = "browser.newtabpage.enabled";
 
 // The maximum number of results we want to retrieve from history.
 const HISTORY_RESULTS_LIMIT = 100;
 
--- a/browser/themes/gnomestripe/browser.css
+++ b/browser/themes/gnomestripe/browser.css
@@ -2560,16 +2560,17 @@ stack[anonid=browserStack][responsivemod
   border-radius: 3px;
   color: inherit;
   border: 1px solid transparent;
   margin: 0 5px;
   padding: 0 10px;
   list-style-image: url("chrome://browser/skin/devtools/tools-icons-small.png");
 }
 
+.developer-toolbar-button[open=true],
 .developer-toolbar-button:active:hover,
 .developer-toolbar-button[checked=true] {
   border-color: hsla(210,8%,5%,.6);
   background: rgba(0,0,0,.6);
   box-shadow: 0 1px 2px rgba(0,0,0,.5) inset, 0 1px 0 hsla(210,16%,76%,.15);
 }
 
 .developer-toolbar-button[checked=true] {
@@ -2589,16 +2590,24 @@ stack[anonid=browserStack][responsivemod
 #developer-toolbar-styleeditor {
   -moz-image-region: rect(32px, 16px, 48px, 0);
 }
 
 #developer-toolbar-debugger {
   -moz-image-region: rect(48px, 16px, 64px, 0);
 }
 
+#developer-toolbar-other-tools {
+  -moz-image-region: rect(64px, 16px, 80px, 0);
+}
+
+#developer-toolbar-other-tools > .toolbarbutton-menu-dropmarker {
+  display: none;
+}
+
 /* Error counter */
 
 #developer-toolbar-webconsole[error-count]:before {
   color: #FDF3DE;
   min-width: 16px;
   text-shadow: none;
   background-image: -moz-linear-gradient(top, #B4211B, #8A1915);
   border-radius: 1px;
--- a/browser/themes/pinstripe/browser.css
+++ b/browser/themes/pinstripe/browser.css
@@ -3314,16 +3314,17 @@ stack[anonid=browserStack][responsivemod
   border-radius: @toolbarbuttonCornerRadius@;
   color: inherit;
   border: 1px solid transparent;
   margin: 0 5px;
   padding: 0 10px;
   list-style-image: url("chrome://browser/skin/devtools/tools-icons-small.png");
 }
 
+.developer-toolbar-button[open=true],
 .developer-toolbar-button:active:hover,
 .developer-toolbar-button[checked=true] {
   border-color: hsla(210,8%,5%,.6);
   background: rgba(0,0,0,.6);
   box-shadow: 0 1px 2px rgba(0,0,0,.5) inset, 0 1px 0 hsla(210,16%,76%,.15);
 }
 
 .developer-toolbar-button[checked=true] {
@@ -3343,16 +3344,24 @@ stack[anonid=browserStack][responsivemod
 #developer-toolbar-styleeditor {
   -moz-image-region: rect(32px, 16px, 48px, 0);
 }
 
 #developer-toolbar-debugger {
   -moz-image-region: rect(48px, 16px, 64px, 0);
 }
 
+#developer-toolbar-other-tools {
+  -moz-image-region: rect(64px, 16px, 80px, 0);
+}
+
+#developer-toolbar-other-tools > .toolbarbutton-menu-dropmarker {
+  display: none;
+}
+
 /* Error counter */
 
 #developer-toolbar-webconsole[error-count]:before {
   color: #FDF3DE;
   min-width: 16px;
   text-shadow: none;
   background-image: -moz-linear-gradient(top, #B4211B, #8A1915);
   border-radius: 1px;
--- a/browser/themes/winstripe/browser.css
+++ b/browser/themes/winstripe/browser.css
@@ -3241,16 +3241,17 @@ stack[anonid=browserStack][responsivemod
   border-radius: 3px;
   color: inherit;
   border: 1px solid transparent;
   margin: 0 5px;
   padding: 0 10px;
   list-style-image: url("chrome://browser/skin/devtools/tools-icons-small.png");
 }
 
+.developer-toolbar-button[open=true],
 .developer-toolbar-button:active:hover,
 .developer-toolbar-button[checked=true] {
   border-color: hsla(210,8%,5%,.6);
   background: rgba(0,0,0,.6);
   box-shadow: 0 1px 2px rgba(0,0,0,.5) inset, 0 1px 0 hsla(210,16%,76%,.1);
 }
 
 .developer-toolbar-button[checked=true] {
@@ -3270,16 +3271,24 @@ stack[anonid=browserStack][responsivemod
 #developer-toolbar-styleeditor {
   -moz-image-region: rect(32px, 16px, 48px, 0);
 }
 
 #developer-toolbar-debugger {
   -moz-image-region: rect(48px, 16px, 64px, 0);
 }
 
+#developer-toolbar-other-tools {
+  -moz-image-region: rect(64px, 16px, 80px, 0);
+}
+
+#developer-toolbar-other-tools > .toolbarbutton-menu-dropmarker {
+  display: none;
+}
+
 /* Error counter */
 
 #developer-toolbar-webconsole[error-count]:before {
   color: #FDF3DE;
   min-width: 16px;
   text-shadow: none;
   background-image: -moz-linear-gradient(top, #B4211B, #8A1915);
   border-radius: 1px;
--- a/build/automationutils.py
+++ b/build/automationutils.py
@@ -421,17 +421,17 @@ def wrapCommand(cmd):
   return cmd
 
 class ShutdownLeakLogger(object):
   """
   Parses the mochitest run log when running a debug build, assigns all leaked
   DOM windows (that are still around after test suite shutdown, despite running
   the GC) to the tests that created them and prints leak statistics.
   """
-  MAX_LEAK_COUNT = 5
+  MAX_LEAK_COUNT = 3
 
   def __init__(self, logger):
     self.logger = logger
     self.tests = []
     self.leakedWindows = {}
     self.leakedDocShells = set()
     self.currentTest = None
     self.seenShutdown = False
--- a/build/macosx/common
+++ b/build/macosx/common
@@ -4,8 +4,9 @@ if [ -d "$topsrcdir/clang" ]; then
     export CXX=$topsrcdir/clang/bin/clang++
 elif [ -d "$topsrcdir/../clang" ]; then
     # comm-central based build
     export CC=$topsrcdir/../clang/bin/clang
     export CXX=$topsrcdir/../clang/bin/clang++
 fi
 
 ac_add_options --enable-stdcxx-compat
+ac_add_options --with-ccache
--- a/build/mobile/devicemanagerADB.py
+++ b/build/mobile/devicemanagerADB.py
@@ -781,19 +781,22 @@ class DeviceManagerADB(DeviceManager):
     # Check to see if we can connect to device and run a simple command
     try:
       self.checkCmd(["shell", "echo"])
     except subprocess.CalledProcessError:
       raise DMError("unable to connect to device: is it plugged in?")
 
   def verifyRoot(self):
     # a test to see if we have root privs
-    files = self.listFiles("/data/data")
-    if (len(files) == 0):
-      print "NOT running as root"
+    p = self.runCmd(["shell", "id"])
+    response = p.stdout.readline()
+    response = response.rstrip()
+    response = response.split(' ')
+    if (response[0].find('uid=0') < 0 or response[1].find('gid=0') < 0):
+      print "NOT running as root ", response[0].find('uid=0')
       raise DMError("not running as root")
 
     self.haveRoot = True
 
   def isCpAvailable(self):
     # Some Android systems may not have a cp command installed,
     # or it may not be executable by the user.
     data = self.runCmd(["shell", "cp"]).stdout.read()
--- a/build/pymake/pymake/functions.py
+++ b/build/pymake/pymake/functions.py
@@ -111,17 +111,17 @@ class SubstitutionRef(Function):
             f = data.Pattern('%' + substfrom)
             substto = '%' + substto
 
         fd.write(' '.join([f.subst(substto, word, False)
                            for word in value.resolvesplit(makefile, variables, setting + [vname])]))
 
     def __repr__(self):
         return "SubstitutionRef<%s>(%r:%r=%r)" % (
-            self.loc, self.vname, self.substfrom, selfsubstto,)
+            self.loc, self.vname, self.substfrom, self.substto,)
 
 class SubstFunction(Function):
     name = 'subst'
     minargs = 3
     maxargs = 3
 
     __slots__ = Function.__slots__
 
--- a/caps/idl/nsIScriptSecurityManager.idl
+++ b/caps/idl/nsIScriptSecurityManager.idl
@@ -146,17 +146,17 @@ interface nsIScriptSecurityManager : nsI
                                  in nsISupports aCert,
                                  in nsIURI aURI);
 
     /**
      * Return a principal that has the same origin as aURI.
      * This principals should not be used for any data/permission check, it will
      * have appId = UNKNOWN_APP_ID.
      */
-    nsIPrincipal getCodebasePrincipal(in nsIURI aURI);
+    nsIPrincipal getSimpleCodebasePrincipal(in nsIURI aURI);
 
     /**
      * Returns a principal that has the given information.
      * @param appId is the app id of the principal. It can't be UNKNOWN_APP_ID.
      * @param inMozBrowser is true if the principal has to be considered as
      * inside a mozbrowser frame.
      */
     nsIPrincipal getAppCodebasePrincipal(in nsIURI uri,
--- a/caps/include/nsScriptSecurityManager.h
+++ b/caps/include/nsScriptSecurityManager.h
@@ -431,18 +431,19 @@ private:
     nsresult
     LookupPolicy(nsIPrincipal* principal,
                  ClassInfoData& aClassData, jsid aProperty,
                  PRUint32 aAction,
                  ClassPolicy** aCachedClassPolicy,
                  SecurityLevel* result);
 
     nsresult
-    GetCodebasePrincipalInternal(nsIURI* aURI, PRUint32 aAppId, bool aInMozBrowser,
-                         nsIPrincipal** result);
+    GetCodebasePrincipalInternal(nsIURI* aURI, PRUint32 aAppId,
+                                 bool aInMozBrowser,
+                                 nsIPrincipal** result);
 
     nsresult
     CreateCodebasePrincipal(nsIURI* aURI, PRUint32 aAppId, bool aInMozBrowser,
                             nsIPrincipal** result);
 
     // This is just like the API method, but it doesn't check that the subject
     // name is non-empty or aCertificate is non-null, and it doesn't change the
     // certificate in the table (if any) in any way if aModifyTable is false.
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -1985,29 +1985,30 @@ nsScriptSecurityManager::CreateCodebaseP
         return rv;
 
     NS_ADDREF(*result = codebase);
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsScriptSecurityManager::GetCodebasePrincipal(nsIURI* aURI,
+nsScriptSecurityManager::GetSimpleCodebasePrincipal(nsIURI* aURI,
                                                     nsIPrincipal** aPrincipal)
 {
-  return GetCodebasePrincipalInternal(aURI, nsIScriptSecurityManager::UNKNOWN_APP_ID,
-                              false, aPrincipal);
+  return GetCodebasePrincipalInternal(aURI,
+                                      nsIScriptSecurityManager::UNKNOWN_APP_ID,
+                                      false, aPrincipal);
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::GetNoAppCodebasePrincipal(nsIURI* aURI,
                                                    nsIPrincipal** aPrincipal)
 {
   return GetCodebasePrincipalInternal(aURI,  nsIScriptSecurityManager::NO_APP_ID,
-                              false, aPrincipal);
+                                      false, aPrincipal);
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::GetAppCodebasePrincipal(nsIURI* aURI,
                                                  PRUint32 aAppId,
                                                  bool aInMozBrowser,
                                                  nsIPrincipal** aPrincipal)
 {
@@ -2030,19 +2031,19 @@ nsScriptSecurityManager::GetDocShellCode
   aDocShell->GetIsInBrowserElement(&isInBrowserElement);
 
   return GetCodebasePrincipalInternal(aURI, appId, isInBrowserElement,
                                       aPrincipal);
 }
 
 nsresult
 nsScriptSecurityManager::GetCodebasePrincipalInternal(nsIURI *aURI,
-                                              PRUint32 aAppId,
-                                              bool aInMozBrowser,
-                                              nsIPrincipal **result)
+                                                      PRUint32 aAppId,
+                                                      bool aInMozBrowser,
+                                                      nsIPrincipal **result)
 {
     NS_ENSURE_ARG(aURI);
 
     bool inheritsPrincipal;
     nsresult rv =
         NS_URIChainHasFlags(aURI,
                             nsIProtocolHandler::URI_INHERITS_SECURITY_CONTEXT,
                             &inheritsPrincipal);
@@ -3634,21 +3635,21 @@ GetExtendedOrigin(nsIURI* aURI, PRUint32
   nsPrincipal::GetOriginForURI(aURI, getter_Copies(origin));
 
   // Fallback.
   if (aAppId == nsIScriptSecurityManager::NO_APP_ID && !aInMozBrowser) {
     aExtendedOrigin.Assign(origin);
     return;
   }
 
-  // aExtendedOrigin = origin + "@" + aAppId + { 't', 'f' }
-  aExtendedOrigin.Assign(origin + NS_LITERAL_CSTRING("@"));
+  // aExtendedOrigin = appId + "+" + origin + "+" + { 't', 'f' }
+  aExtendedOrigin.Truncate();
   aExtendedOrigin.AppendInt(aAppId);
-  aExtendedOrigin.Append(aInMozBrowser ? NS_LITERAL_CSTRING("t")
-                                       : NS_LITERAL_CSTRING("f"));
+  aExtendedOrigin.Append(NS_LITERAL_CSTRING("+") + origin + NS_LITERAL_CSTRING("+"));
+  aExtendedOrigin.Append(aInMozBrowser ? 't' : 'f');
 
   return;
 }
 
 } // namespace mozilla
 
 NS_IMETHODIMP
 nsScriptSecurityManager::GetExtendedOrigin(nsIURI* aURI,
--- a/caps/tests/mochitest/Makefile.in
+++ b/caps/tests/mochitest/Makefile.in
@@ -13,19 +13,21 @@ include $(DEPTH)/config/autoconf.mk
 
 MOCHITEST_FILES = 	test_bug423375.html \
                 test_bug246699.html \
                 test_bug292789.html \
                 test_bug470804.html \
                 test_disallowInheritPrincipal.html \
                 $(NULL)
 
-# Temporarily disabled for orange
-# MOCHITEST_CHROME_FILES = test_principal_extendedorigin_appid_appstatus.html \
-#                          $(NULL)
+# extendedOrigin test doesn't work on Windows, see bug 776296.
+ifneq ($(OS_ARCH),WINNT)
+MOCHITEST_CHROME_FILES = test_principal_extendedorigin_appid_appstatus.html \
+                         $(NULL)
+endif
 
 test_bug292789.html : % : %.in
 	$(PYTHON) $(topsrcdir)/config/Preprocessor.py \
 	     $(AUTOMATION_PPARGS) $(DEFINES) $(ACDEFINES) $< > $@
 
 GARBAGE += test_bug292789.html
 
 include $(topsrcdir)/config/rules.mk
--- a/caps/tests/mochitest/test_principal_extendedorigin_appid_appstatus.html
+++ b/caps/tests/mochitest/test_principal_extendedorigin_appid_appstatus.html
@@ -11,17 +11,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=758258">Mozilla Bug 758258</a>
 <p id="display"></p>
 <div id="content">
   
 </div>
 <pre id="test">
-<script type="application/javascript">
+<script type="application/javascript;version=1.7">
 
 /** Test for Bug 758258 **/
 
 var Ci = Components.interfaces;
 
 SimpleTest.waitForExplicitFinish();
 
 /*
@@ -100,69 +100,189 @@ var gData = [
     src: "http://example.org/",
     isapp: false,
     // TODO: this is a browser because we need apps to be browser and it's not
     // an app because the manifest is invalid. Ideally, it should not be a
     // browser.
     browser: true,
     test: [ "eo-as-last" ],
   },
-/*
 //  {
 //    app: "http://example.org/manifest.webapp",
 //    src: "data:text/html,foobar",
 //    test: [ "todo-src" ],
 //  },
 //  {
 //    app: "http://example.org/manifest.webapp",
 //    src: "data:text/html,foobar2",
 //    test: [ "todo-src" ],
 //  },
-*/
   {
     src: "file:///",
     isapp: false,
     test: [ "eo-unique" ],
   },
   {
-    src: "file:///tmp",
+    src: "file:///tmp/",
     isapp: false,
     test: [ "eo-unique" ],
   },
   {
     app: "http://example.org/manifest.webapp",
     src: "file:///",
     isapp: true,
     test: [ "eo-unique" ],
   },
   {
     app: "http://example.org/manifest.webapp",
-    src: "file:///tmp",
+    src: "file:///tmp/",
     isapp: true,
     test: [ "eo-unique" ],
   },
+  // iframe inside an app is part of the app.
+  {
+    app: "http://example.org/manifest.webapp",
+    src: "http://example.org/",
+    isapp: true,
+    child: {
+      src: "http://example.org/chrome/",
+      isapp: true
+    },
+    test: [ "child-has-same-eo" ],
+  },
+  // app A inside app B aren't the same app.
+  {
+    app: "http://example.org/manifest.webapp",
+    src: "http://example.org/",
+    isapp: true,
+    child: {
+      app: "https://example.com/manifest.webapp",
+      src: "https://example.com/chrome/",
+      isapp: true
+    },
+    test: [ "child-has-different-eo", "child-has-same-appstatus", "child-has-different-appid" ],
+  },
+  // app A inside app A are the same app.
+  {
+    app: "http://example.org/manifest.webapp",
+    src: "http://example.org/",
+    isapp: true,
+    child: {
+      app: "http://example.org/manifest.webapp",
+      src: "http://example.org/chrome/",
+      isapp: true
+    },
+    test: [ "child-has-same-eo" ],
+  },
+  // app inside a regular iframe is an app.
+  {
+    src: "http://example.org/",
+    isapp: false,
+    child: {
+      app: "http://example.org/manifest.webapp",
+      src: "http://example.org/chrome/",
+      isapp: true
+    },
+    test: [ "child-has-different-eo", "child-has-different-appstatus", "child-has-different-appid" ],
+  },
+  // browser inside app is a browser, has appid but isn't installed.
+  {
+    src: "http://example.org/",
+    app: "http://example.org/manifest.webapp",
+    isapp: true,
+    child: {
+      src: "http://example.org/chrome/",
+      isapp: false,
+      browser: true,
+    },
+    test: [ "child-has-different-eo", "child-has-different-appstatus", "child-has-same-appid" ],
+  },
+  // app inside a browser is an app.
+  {
+    src: "http://example.org/",
+    isapp: false,
+    browser: true,
+    child: {
+      app: "http://example.org/manifest.webapp",
+      src: "http://example.org/chrome/",
+      isapp: true,
+    },
+    test: [ "child-has-different-eo", "child-has-different-appstatus", "child-has-different-appid" ],
+  },
+  // browser inside a browser are two browsers
+  {
+    src: "http://example.org/",
+    isapp: false,
+    browser: true,
+    child: {
+      src: "http://example.org/chrome/",
+      isapp: false,
+      browser: true,
+    },
+    test: [ "child-has-same-eo" ],
+  },
+  // browser inside a browser are two browsers
+  {
+    src: "http://example.org/",
+    isapp: false,
+    browser: true,
+    child: {
+      src: "https://example.com/chrome/",
+      isapp: false,
+      browser: true,
+    },
+    test: [ "child-has-different-eo", "child-has-same-appstatus", "child-has-same-appid" ],
+  },
+  // iframe containing a browser
+  {
+    src: "http://example.org/",
+    isapp: false,
+    browser: false,
+    child: {
+      src: "http://example.org/chrome/",
+      isapp: false,
+      browser: true,
+    },
+    test: [ "child-has-different-eo", "child-has-same-appstatus", "child-has-same-appid" ],
+  },
+  // browser containing an iframe is part of the browser
+  {
+    src: "http://example.org/",
+    isapp: false,
+    browser: true,
+    child: {
+      src: "http://example.org/chrome/",
+      isapp: false,
+    },
+    test: [ "child-has-same-eo" ],
+  },
 ];
 
 // The list of all data ids generated by this test.
 var eoList = [];
 
 var content = document.getElementById('content');
 var checkedCount = 0;
 var checksTodo = gData.length;
 
-function checkPrincipalForIFrame(aFrame, data) {
+function checkIFrame(aFrame, data) {
   var principal = aFrame.contentDocument.nodePrincipal;
 
   if (!data.test) {
     data.test = [];
   }
 
-// Temporarily disable that check.
-//  is(principal.URI.spec, data.src,
-//     'the correct URL should have been loaded');
+  if (navigator.platform.indexOf("Mac") != -1) {
+    is(principal.URI.spec,
+       data.src.replace('file:///tmp/', 'file:///private/tmp/'),
+       'the correct URL should have been loaded');
+  } else {
+    is(principal.URI.spec, data.src,
+       'the correct URL should have been loaded');
+  }
 
   if (data.isapp) {
     is(principal.appStatus, Ci.nsIPrincipal.APP_STATUS_INSTALLED,
        'this should be an installed app');
     isnot(principal.appId, Ci.nsIScriptSecurityManager.NO_APP_ID,
           "installed app should have a valid appId");
     isnot(principal.appId, Ci.nsIScriptSecurityManager.UNKNOWN_APP_ID,
           "installed app should have a valid appId");
@@ -185,57 +305,127 @@ function checkPrincipalForIFrame(aFrame,
     is(eoList.indexOf(principal.extendedOrigin), -1,
        "extendedOrigin should be unique");
   }
   if (data.test.indexOf("eo-as-last") != -1) {
     is(principal.extendedOrigin, eoList[eoList.length-1],
        "extendedOrigin should be the same as the last inserted one");
   }
 
+  if (data.child) {
+    let childPrincipal = aFrame.contentWindow.frames[0].document.nodePrincipal;
+
+    if (data.child.isapp) {
+      is(childPrincipal.appStatus, Ci.nsIPrincipal.APP_STATUS_INSTALLED,
+         "child should be an installed app");
+    }
+
+    if (data.test.indexOf("child-has-same-eo") != -1) {
+      is(childPrincipal.extendedOrigin, principal.extendedOrigin,
+         "child should have the same extendedOrigin as parent");
+      is(childPrincipal.appStatus, principal.appStatus,
+         "child should have the same appStatus if it has the same extendedOrigin");
+      is(childPrincipal.appId, principal.appId,
+         "child should have the same appId if it has the same extendedOrigin");
+    }
+
+    if (data.test.indexOf("child-has-different-eo") != -1) {
+      isnot(childPrincipal.extendedOrigin, principal.extendedOrigin,
+            "child should not have the same extendedOrigin as parent");
+    }
+
+    if (data.test.indexOf("child-has-same-appstatus") != -1) {
+      is(childPrincipal.appStatus, principal.appStatus,
+         "childPrincipal and parent principal should have the same appStatus");
+    }
+
+    if (data.test.indexOf("child-has-different-appstatus") != -1) {
+      isnot(childPrincipal.appStatus, principal.appStatus,
+            "childPrincipal and parent principal should not have the same appStatus");
+    }
+
+    if (data.test.indexOf("child-has-same-appid") != -1) {
+      is(childPrincipal.appId, principal.appId,
+         "childPrincipal and parent principal should have the same appId");
+    }
+
+    if (data.test.indexOf("child-has-different-appid") != -1) {
+      isnot(childPrincipal.appId, principal.appId,
+            "childPrincipal and parent principal should have different appId");
+    }
+  }
+
   eoList.push(principal.extendedOrigin);
 
   checkedCount++;
   if (checkedCount == checksTodo) {
     SimpleTest.finish();
+  } else {
+    gTestRunner.next();
   }
 }
 
 is('appStatus' in document.nodePrincipal, true,
    'appStatus should be present in nsIPrincipal');
 is('extendedOrigin' in document.nodePrincipal, true,
    'extendedOrigin should be present in nsIPrincipal');
 is('appId' in document.nodePrincipal, true,
    'appId should be present in nsIPrincipal');
 
-SpecialPowers.pushPrefEnv({'set': [["dom.mozBrowserFramesEnabled", true]]}, function() {
+function runTest() {
+  // We want to use a generator. Those only work in a one level stack so we
+  // can't use .forEach() here.
+  for (var i=0; i<gData.length; ++i) {
+    let data = gData[i];
+
+    var iframe = document.createElement('iframe');
+    iframe.check = function() {
+      checkIFrame(this, data);
+    };
+    iframe.addChild = function() {
+      var childFrame = document.createElement('iframe');
+
+      if (data.child.app) {
+        childFrame.setAttribute('mozapp', data.child.app)
+        childFrame.setAttribute('mozbrowser', '');
+      } else if (data.child.browser) {
+        childFrame.setAttribute('mozbrowser', '');
+      }
+
+      childFrame.src = data.child.src;
 
-// For some unknown reasons, this test this to always timeout on Windows.
-if (navigator.platform.indexOf("Win") != -1) {
-  SimpleTest.finish();
-  return;
+      this.removeEventListener('load', this.addChild.bind(this));
+      childFrame.addEventListener('load', this.check.bind(this));
+
+      this.contentDocument.body.appendChild(childFrame);
+    };
+
+    if (data.app) {
+      iframe.setAttribute('mozapp', data.app);
+      iframe.setAttribute('mozbrowser', '');
+    } else if (data.browser) {
+      iframe.setAttribute('mozbrowser', '');
+    }
+
+    iframe.src = data.src;
+
+    if (data.child) {
+      iframe.addEventListener('load', iframe.addChild.bind(iframe));
+    } else {
+      iframe.addEventListener('load', iframe.check.bind(iframe));
+    }
+
+    content.appendChild(iframe);
+
+    yield;
+  }
 }
 
-gData.forEach(function(data) {
-  var iframe = document.createElement('iframe');
-  iframe.checkPrincipal = function() {
-    checkPrincipalForIFrame(this, data);
-  };
+var gTestRunner = runTest();
 
-  if (data.app) {
-    iframe.setAttribute('mozapp', data.app);
-    iframe.setAttribute('mozbrowser', '');
-  } else if (data.browser) {
-    iframe.setAttribute('mozbrowser', '');
-  }
-
-  iframe.src = data.src;
-
-  iframe.addEventListener('load', iframe.checkPrincipal.bind(iframe));
-
-  content.appendChild(iframe);
-});
-
-});
+SpecialPowers.pushPrefEnv({'set': [["dom.mozBrowserFramesEnabled", true],
+                                   ["dom.mozBrowserFramesWhitelist", "http://example.org"]]},
+                           function() { gTestRunner.next(); });
 
 </script>
 </pre>
 </body>
 </html>
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -27,17 +27,17 @@ static fp_except_t allmask = FP_X_INV|FP
 static fp_except_t allmask = FP_X_INV|FP_X_OFL|FP_X_UFL|FP_X_DZ|FP_X_IMP|FP_X_DNML;
 #endif
 static fp_except_t oldmask = fpsetmask(~allmask);
 #endif
 
 #include "nsAString.h"
 #include "nsIStatefulFrame.h"
 #include "nsNodeInfoManager.h"
-#include "nsDOMClassInfoID.h"
+#include "nsIXPCScriptable.h"
 #include "nsDataHashtable.h"
 #include "nsIDOMEvent.h"
 #include "nsTArray.h"
 #include "nsReadableUtils.h"
 #include "nsINode.h"
 #include "nsIDOMNode.h"
 #include "nsHtml5StringParser.h"
 #include "nsIDocument.h"
--- a/content/base/public/nsDeprecatedOperationList.h
+++ b/content/base/public/nsDeprecatedOperationList.h
@@ -43,9 +43,8 @@ DEPRECATED_OPERATION(Position)
 DEPRECATED_OPERATION(TotalSize)
 DEPRECATED_OPERATION(InputEncoding)
 DEPRECATED_OPERATION(MozBeforePaint)
 DEPRECATED_OPERATION(MozBlobBuilder)
 DEPRECATED_OPERATION(DOMExceptionCode)
 DEPRECATED_OPERATION(NoExposedProps)
 DEPRECATED_OPERATION(MutationEvent)
 DEPRECATED_OPERATION(MozSlice)
-DEPRECATED_OPERATION(Onuploadprogress)
--- a/content/base/public/nsIXMLHttpRequest.idl
+++ b/content/base/public/nsIXMLHttpRequest.idl
@@ -390,32 +390,18 @@ interface nsIXHRSendable : nsISupports {
   void getSendInfo(out nsIInputStream body,
                    out ACString contentType,
                    out ACString charset);
 };
 
 /**
  * @deprecated
  */
-[deprecated, scriptable, uuid(423fdd3d-41c9-4149-8fe5-b14a1d3912a0)]
+[deprecated, scriptable, uuid(8ae70a39-edf1-40b4-a992-472d23421c25)]
 interface nsIJSXMLHttpRequest : nsISupports {
-  /**
-   * Meant to be a script-only mechanism for setting an upload progress event
-   * listener.
-   * This attribute should not be used from native code!!
-   * This event listener may be called multiple times during the upload..
-   *
-   * After the initial response, all event listeners will be cleared.
-   * // XXXbz what does that mean, exactly?
-   *
-   * This event listener must be set BEFORE calling open().
-   *
-   * Mozilla only.
-   */
-  attribute nsIDOMEventListener onuploadprogress;
 };
 
 %{ C++
 #define NS_XMLHTTPREQUEST_CID                       \
  { /* d164e770-4157-11d4-9a42-000064657374 */       \
   0xd164e770, 0x4157, 0x11d4,                       \
  {0x9a, 0x42, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74} }
 #define NS_XMLHTTPREQUEST_CONTRACTID \
--- a/content/base/src/contentAreaDropListener.js
+++ b/content/base/src/contentAreaDropListener.js
@@ -81,17 +81,17 @@ ContentAreaDropListener.prototype =
                    getService(Ci.nsIScriptSecurityManager);
     let sourceNode = dataTransfer.mozSourceNode;
     let flags = secMan.STANDARD;
     if (disallowInherit)
       flags |= secMan.DISALLOW_INHERIT_PRINCIPAL;
 
     // Use file:/// as the default uri so that drops of file URIs are always allowed
     let principal = sourceNode ? sourceNode.nodePrincipal
-                               : secMan.getCodebasePrincipal(ioService.newURI("file:///", null, null));
+                               : secMan.getSimpleCodebasePrincipal(ioService.newURI("file:///", null, null));
 
     secMan.checkLoadURIStrWithPrincipal(principal, uriString, flags);
 
     return uriString;
   },
 
   canDropLink: function(aEvent, aAllowSameDocument)
   {
--- a/content/base/src/nsDOMParser.cpp
+++ b/content/base/src/nsDOMParser.cpp
@@ -260,17 +260,18 @@ nsDOMParser::Init(nsIPrincipal* principa
 
   mScriptHandlingObject = do_GetWeakReference(aScriptObject);
   mPrincipal = principal;
   nsresult rv;
   if (!mPrincipal) {
     nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
     NS_ENSURE_TRUE(secMan, NS_ERROR_NOT_AVAILABLE);
     rv =
-      secMan->GetCodebasePrincipal(mDocumentURI, getter_AddRefs(mPrincipal));
+      secMan->GetSimpleCodebasePrincipal(mDocumentURI,
+                                         getter_AddRefs(mPrincipal));
     NS_ENSURE_SUCCESS(rv, rv);
     mOriginalPrincipal = mPrincipal;
   } else {
     mOriginalPrincipal = mPrincipal;
     if (nsContentUtils::IsSystemPrincipal(mPrincipal)) {
       // Don't give DOMParsers the system principal.  Use a null
       // principal instead.
       mPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
--- a/content/base/src/nsEventSource.cpp
+++ b/content/base/src/nsEventSource.cpp
@@ -27,16 +27,17 @@
 #include "nsIContentSecurityPolicy.h"
 #include "nsContentUtils.h"
 #include "mozilla/Preferences.h"
 #include "xpcpublic.h"
 #include "nsCrossSiteListenerProxy.h"
 #include "nsWrapperCacheInlines.h"
 #include "nsDOMEventTargetHelper.h"
 #include "mozilla/Attributes.h"
+#include "nsDOMClassInfoID.h"
 
 using namespace mozilla;
 
 #define REPLACEMENT_CHAR     (PRUnichar)0xFFFD
 #define BOM_CHAR             (PRUnichar)0xFEFF
 #define SPACE_CHAR           (PRUnichar)0x0020
 #define CR_CHAR              (PRUnichar)0x000D
 #define LF_CHAR              (PRUnichar)0x000A
--- a/content/base/src/nsFrameLoader.cpp
+++ b/content/base/src/nsFrameLoader.cpp
@@ -1592,17 +1592,17 @@ nsFrameLoader::MaybeCreateDocShell()
     // Do not call Destroy() here. See bug 472312.
     NS_WARNING("Something wrong when creating the docshell for a frameloader!");
     return NS_ERROR_FAILURE;
   }
 
   EnsureMessageManager();
 
   if (OwnerIsBrowserFrame()) {
-    mDocShell->SetIsBrowser();
+    mDocShell->SetIsBrowserElement();
 
     nsCOMPtr<nsIObserverService> os = services::GetObserverService();
     if (os) {
       os->NotifyObservers(NS_ISUPPORTS_CAST(nsIFrameLoader*, this),
                           "in-process-browser-frame-shown", NULL);
     }
 
     if (mMessageManager) {
@@ -1966,25 +1966,49 @@ nsFrameLoader::TryRemoteBrowser()
   nsCOMPtr<nsIXULWindow> window(do_GetInterface(parentOwner));
   if (!window) {
     return false;
   }
   if (NS_FAILED(window->GetChromeFlags(&chromeFlags))) {
     return false;
   }
 
+  PRUint32 appId = 0;
+  bool isBrowserElement = false;
+
+  if (OwnerIsBrowserFrame()) {
+    isBrowserElement = true;
+
+    if (mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::mozapp)) {
+      nsAutoString manifest;
+      mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::mozapp, manifest);
+
+      nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
+      if (!appsService) {
+        NS_ERROR("Apps Service is not available!");
+        return NS_ERROR_FAILURE;
+      }
+
+      appsService->GetAppLocalIdByManifestURL(manifest, &appId);
+
+      // If the frame is actually an app, we should not mark it as a browser.
+      if (appId != nsIScriptSecurityManager::NO_APP_ID) {
+        isBrowserElement = false;
+      }
+    }
+  }
+
   // If our owner has no app manifest URL, then this is equivalent to
   // ContentParent::GetNewOrUsed().
   nsAutoString appManifest;
   GetOwnerAppManifestURL(appManifest);
   ContentParent* parent = ContentParent::GetForApp(appManifest);
 
   NS_ASSERTION(parent->IsAlive(), "Process parent should be alive; something is very wrong!");
-  mRemoteBrowser = parent->CreateTab(chromeFlags,
-                                     /* aIsBrowserFrame = */ OwnerIsBrowserFrame());
+  mRemoteBrowser = parent->CreateTab(chromeFlags, isBrowserElement, appId);
   if (mRemoteBrowser) {
     nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mOwnerContent);
     mRemoteBrowser->SetOwnerElement(element);
 
     nsCOMPtr<nsIDocShellTreeItem> rootItem;
     parentAsItem->GetRootTreeItem(getter_AddRefs(rootItem));
     nsCOMPtr<nsIDOMWindow> rootWin = do_GetInterface(rootItem);
     nsCOMPtr<nsIDOMChromeWindow> rootChromeWin = do_QueryInterface(rootWin);
--- a/content/base/src/nsInProcessTabChildGlobal.cpp
+++ b/content/base/src/nsInProcessTabChildGlobal.cpp
@@ -14,16 +14,17 @@
 #include "nsIJSRuntimeService.h"
 #include "nsComponentManagerUtils.h"
 #include "nsNetUtil.h"
 #include "nsScriptLoader.h"
 #include "nsIJSContextStack.h"
 #include "nsFrameLoader.h"
 #include "xpcpublic.h"
 #include "nsIMozBrowserFrame.h"
+#include "nsDOMClassInfoID.h"
 
 bool SendSyncMessageToParent(void* aCallbackData,
                              const nsAString& aMessage,
                              const nsAString& aJSON,
                              InfallibleTArray<nsString>* aJSONRetVal)
 {
   nsInProcessTabChildGlobal* tabChild =
     static_cast<nsInProcessTabChildGlobal*>(aCallbackData);
--- a/content/base/src/nsNodeIterator.cpp
+++ b/content/base/src/nsNodeIterator.cpp
@@ -11,17 +11,17 @@
 #include "nsNodeIterator.h"
 
 #include "nsIDOMNode.h"
 #include "nsIDOMNodeFilter.h"
 #include "nsDOMError.h"
 
 #include "nsIContent.h"
 #include "nsIDocument.h"
-
+#include "nsDOMClassInfoID.h"
 #include "nsContentUtils.h"
 #include "nsCOMPtr.h"
 
 /*
  * NodePointer implementation
  */
 nsNodeIterator::NodePointer::NodePointer(nsINode *aNode,
                                          bool aBeforeNode) :
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -491,29 +491,39 @@ nsresult nsObjectLoadingContent::IsPlugi
     }
     nsCOMPtr<nsIDOMWindow> topWindow;
     rv = window->GetTop(getter_AddRefs(topWindow));
     NS_ENSURE_SUCCESS(rv, rv);
     nsCOMPtr<nsIDOMDocument> topDocument;
     rv = topWindow->GetDocument(getter_AddRefs(topDocument));
     NS_ENSURE_SUCCESS(rv, rv);
     nsCOMPtr<nsIDocument> topDoc = do_QueryInterface(topDocument);
-    nsIURI* topUri = topDoc->GetDocumentURI();
 
     nsCOMPtr<nsIPermissionManager> permissionManager = do_GetService(NS_PERMISSIONMANAGER_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
-    PRUint32 permission;
-    rv = permissionManager->TestPermission(topUri, "plugins", &permission);
-    NS_ENSURE_SUCCESS(rv, rv);
+    bool allowPerm = false;
+    // For now we always say that the system principal uses click-to-play since
+    // that maintains current behavior and we have tests that expect this.
+    // What we really should do is disable plugins entirely in pages that use
+    // the system principal, i.e. in chrome pages. That way the click-to-play
+    // code here wouldn't matter at all. Bug 775301 is tracking this.
+    if (!nsContentUtils::IsSystemPrincipal(topDoc->NodePrincipal())) {
+      PRUint32 permission;
+      rv = permissionManager->TestPermissionFromPrincipal(topDoc->NodePrincipal(),
+                                                          "plugins",
+                                                          &permission);
+      NS_ENSURE_SUCCESS(rv, rv);
+      allowPerm = permission == nsIPermissionManager::ALLOW_ACTION;
+    }
 
     PRUint32 state;
     rv = pluginHost->GetBlocklistStateForType(aMIMEType.get(), &state);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    if (permission == nsIPermissionManager::ALLOW_ACTION &&
+    if (allowPerm &&
         state != nsIBlocklistService::STATE_VULNERABLE_UPDATE_AVAILABLE &&
         state != nsIBlocklistService::STATE_VULNERABLE_NO_UPDATE) {
       mCTPPlayable = true;
     } else {
       return NS_ERROR_PLUGIN_CLICKTOPLAY;
     }
   }
 
--- a/content/base/src/nsTreeWalker.cpp
+++ b/content/base/src/nsTreeWalker.cpp
@@ -9,17 +9,17 @@
  */
 
 #include "nsTreeWalker.h"
 
 #include "nsIDOMNode.h"
 #include "nsIDOMNodeFilter.h"
 #include "nsDOMError.h"
 #include "nsINode.h"
-
+#include "nsDOMClassInfoID.h"
 #include "nsContentUtils.h"
 
 /*
  * Factories, constructors and destructors
  */
 
 nsTreeWalker::nsTreeWalker(nsINode *aRoot,
                            PRUint32 aWhatToShow,
--- a/content/base/src/nsWebSocket.cpp
+++ b/content/base/src/nsWebSocket.cpp
@@ -44,16 +44,17 @@
 #include "nsContentPolicyUtils.h"
 #include "nsContentErrors.h"
 #include "jsfriendapi.h"
 #include "prmem.h"
 #include "nsDOMFile.h"
 #include "nsWrapperCacheInlines.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsIObserverService.h"
+#include "GeneratedEvents.h"
 
 using namespace mozilla;
 
 #define UTF_8_REPLACEMENT_CHAR    static_cast<PRUnichar>(0xFFFD)
 
 #define TRUE_OR_FAIL_WEBSOCKET(x, ret)                                    \
   PR_BEGIN_MACRO                                                          \
     if (NS_UNLIKELY(!(x))) {                                              \
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -85,17 +85,16 @@ using namespace mozilla;
 using namespace mozilla::dom;
 
 #define LOAD_STR "load"
 #define ERROR_STR "error"
 #define ABORT_STR "abort"
 #define TIMEOUT_STR "timeout"
 #define LOADSTART_STR "loadstart"
 #define PROGRESS_STR "progress"
-#define UPLOADPROGRESS_STR "uploadprogress"
 #define READYSTATE_STR "readystatechange"
 #define LOADEND_STR "loadend"
 
 // CIDs
 
 // State
 #define XML_HTTP_REQUEST_UNSENT           (1 << 0) // 0 UNSENT
 #define XML_HTTP_REQUEST_OPENED           (1 << 1) // 1 OPENED
@@ -614,17 +613,16 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(
     if (tmp->mListenerManager) {
       tmp->mListenerManager->UnmarkGrayJSListeners();
       NS_UNMARK_LISTENER_WRAPPER(Load)
       NS_UNMARK_LISTENER_WRAPPER(Error)
       NS_UNMARK_LISTENER_WRAPPER(Abort)
       NS_UNMARK_LISTENER_WRAPPER(LoadStart)
       NS_UNMARK_LISTENER_WRAPPER(Progress)
       NS_UNMARK_LISTENER_WRAPPER(Loadend)
-      NS_UNMARK_LISTENER_WRAPPER(UploadProgress)
       NS_UNMARK_LISTENER_WRAPPER(Readystatechange)
     }
     if (!isBlack && tmp->PreservingWrapper()) {
       xpc_UnmarkGrayObject(tmp->GetWrapperPreserveColor());
     }
     return true;
   }
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END
@@ -640,17 +638,16 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_E
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXMLHttpRequest,
                                                   nsXHREventTarget)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mContext)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mChannel)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mReadRequest)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mResponseXML)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCORSPreflightChannel)
 
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnUploadProgressListener)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnReadystatechangeListener)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mXMLParserStreamListener)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mChannelEventSink)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mProgressEventSink)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mUpload,
@@ -662,17 +659,16 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_IN
   tmp->mResultArrayBuffer = nsnull;
   tmp->mResultJSON = JSVAL_VOID;
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mContext)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChannel)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mReadRequest)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mResponseXML)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCORSPreflightChannel)
 
-  NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnUploadProgressListener)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnReadystatechangeListener)
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mXMLParserStreamListener)
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChannelEventSink)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mProgressEventSink)
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mUpload)
@@ -703,17 +699,16 @@ NS_INTERFACE_MAP_END_INHERITING(nsXHREve
 
 NS_IMPL_ADDREF_INHERITED(nsXMLHttpRequest, nsXHREventTarget)
 NS_IMPL_RELEASE_INHERITED(nsXMLHttpRequest, nsXHREventTarget)
 
 void
 nsXMLHttpRequest::DisconnectFromOwner()
 {
   nsXHREventTarget::DisconnectFromOwner();
-  NS_DISCONNECT_EVENT_HANDLER(UploadProgress)
   NS_DISCONNECT_EVENT_HANDLER(Readystatechange)
   Abort();
 }
 
 NS_IMETHODIMP
 nsXMLHttpRequest::GetOnreadystatechange(nsIDOMEventListener * *aOnreadystatechange)
 {
   return
@@ -725,33 +720,16 @@ NS_IMETHODIMP
 nsXMLHttpRequest::SetOnreadystatechange(nsIDOMEventListener * aOnreadystatechange)
 {
   return
     nsXHREventTarget::RemoveAddEventListener(NS_LITERAL_STRING(READYSTATE_STR),
                                              mOnReadystatechangeListener,
                                              aOnreadystatechange);
 }
 
-NS_IMETHODIMP
-nsXMLHttpRequest::GetOnuploadprogress(nsIDOMEventListener * *aOnuploadprogress)
-{
-  return
-    nsXHREventTarget::GetInnerEventListener(mOnUploadProgressListener,
-                                            aOnuploadprogress);
-}
-
-NS_IMETHODIMP
-nsXMLHttpRequest::SetOnuploadprogress(nsIDOMEventListener * aOnuploadprogress)
-{
-  return
-    nsXHREventTarget::RemoveAddEventListener(NS_LITERAL_STRING(UPLOADPROGRESS_STR),
-                                             mOnUploadProgressListener,
-                                             aOnuploadprogress);
-}
-
 /* readonly attribute nsIChannel channel; */
 NS_IMETHODIMP
 nsXMLHttpRequest::GetChannel(nsIChannel **aChannel)
 {
   NS_ENSURE_ARG_POINTER(aChannel);
   NS_IF_ADDREF(*aChannel = mChannel);
 
   return NS_OK;
@@ -1650,18 +1628,17 @@ nsXMLHttpRequest::DispatchProgressEvent(
                                         bool aLengthComputable,
                                         PRUint64 aLoaded, PRUint64 aTotal,
                                         PRUint64 aPosition, PRUint64 aTotalSize)
 {
   NS_ASSERTION(aTarget, "null target");
   NS_ASSERTION(!aType.IsEmpty(), "missing event type");
 
   if (NS_FAILED(CheckInnerWindowCorrectness()) ||
-      (!AllowUploadProgress() &&
-       (aTarget == mUpload || aType.EqualsLiteral(UPLOADPROGRESS_STR)))) {
+      (!AllowUploadProgress() && aTarget == mUpload)) {
     return;
   }
 
   bool dispatchLoadend = aType.EqualsLiteral(LOAD_STR) ||
                            aType.EqualsLiteral(ERROR_STR) ||
                            aType.EqualsLiteral(TIMEOUT_STR) ||
                            aType.EqualsLiteral(ABORT_STR);
   
@@ -1747,17 +1724,16 @@ nsXMLHttpRequest::CheckChannelForCrossSi
 
   // Check if we need to do a preflight request.
   nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
   NS_ENSURE_TRUE(httpChannel, NS_ERROR_DOM_BAD_URI);
 
   nsCAutoString method;
   httpChannel->GetRequestMethod(method);
   if (!mCORSUnsafeHeaders.IsEmpty() ||
-      HasListenersFor(NS_LITERAL_STRING(UPLOADPROGRESS_STR)) ||
       (mUpload && mUpload->HasListeners()) ||
       (!method.LowerCaseEqualsLiteral("get") &&
        !method.LowerCaseEqualsLiteral("post") &&
        !method.LowerCaseEqualsLiteral("head"))) {
     mState |= XML_HTTP_REQUEST_NEED_AC_PREFLIGHT;
   }
 
   return NS_OK;
@@ -2815,17 +2791,16 @@ nsXMLHttpRequest::Send(nsIVariant* aVari
   }
 
 
   // nsIRequest::LOAD_BACKGROUND prevents throbber from becoming active, which
   // in turn keeps STOP button from becoming active.  If the consumer passed in
   // a progress event handler we must load with nsIRequest::LOAD_NORMAL or
   // necko won't generate any progress notifications.
   if (HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR)) ||
-      HasListenersFor(NS_LITERAL_STRING(UPLOADPROGRESS_STR)) ||
       (mUpload && mUpload->HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR)))) {
     nsLoadFlags loadFlags;
     mChannel->GetLoadFlags(&loadFlags);
     loadFlags &= ~nsIRequest::LOAD_BACKGROUND;
     loadFlags |= nsIRequest::LOAD_NORMAL;
     mChannel->SetLoadFlags(loadFlags);
   }
 
@@ -3174,19 +3149,17 @@ nsXMLHttpRequest::Send(nsIVariant* aVari
       NS_DispatchToCurrentThread(resumeTimeoutRunnable);
     }
   } else {
     // Now that we've successfully opened the channel, we can change state.  Note
     // that this needs to come after the AsyncOpen() and rv check, because this
     // can run script that would try to restart this request, and that could end
     // up doing our AsyncOpen on a null channel if the reentered AsyncOpen fails.
     ChangeState(XML_HTTP_REQUEST_SENT);
-    if ((!mUploadComplete &&
-         HasListenersFor(NS_LITERAL_STRING(UPLOADPROGRESS_STR))) ||
-        (mUpload && mUpload->HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR)))) {
+    if (mUpload && mUpload->HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR))) {
       StartProgressEventTimer();
     }
     DispatchProgressEvent(this, NS_LITERAL_STRING(LOADSTART_STR), false,
                           0, 0);
     if (mUpload && !mUploadComplete) {
       DispatchProgressEvent(mUpload, NS_LITERAL_STRING(LOADSTART_STR), true,
                             0, mUploadTotal);
     }
@@ -3717,20 +3690,16 @@ nsXMLHttpRequest::MaybeDispatchProgressE
   // We're uploading if our state is XML_HTTP_REQUEST_OPENED or
   // XML_HTTP_REQUEST_SENT
   if ((XML_HTTP_REQUEST_OPENED | XML_HTTP_REQUEST_SENT) & mState) {
     if (aFinalProgress) {
       mUploadTotal = mUploadTransferred;
       mUploadProgressMax = mUploadProgress;
       mUploadLengthComputable = true;
     }
-    DispatchProgressEvent(this, NS_LITERAL_STRING(UPLOADPROGRESS_STR),
-                          true, mUploadLengthComputable, mUploadTransferred,
-                          mUploadTotal, mUploadProgress,
-                          mUploadProgressMax);
     if (mUpload && !mUploadComplete) {
       DispatchProgressEvent(mUpload, NS_LITERAL_STRING(PROGRESS_STR),
                             true, mUploadLengthComputable, mUploadTransferred,
                             mUploadTotal, mUploadProgress,
                             mUploadProgressMax);
     }
   } else {
     if (aFinalProgress) {
--- a/content/base/src/nsXMLHttpRequest.h
+++ b/content/base/src/nsXMLHttpRequest.h
@@ -212,20 +212,16 @@ public:
   nsresult InitParameters(JSContext* aCx, const jsval* aParams);
   void InitParameters(bool aAnon, bool aSystem);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIXMLHttpRequest
   NS_DECL_NSIXMLHTTPREQUEST
 
-  // nsIJSXMLHttpRequest
-  NS_IMETHOD GetOnuploadprogress(nsIDOMEventListener** aOnuploadprogress);
-  NS_IMETHOD SetOnuploadprogress(nsIDOMEventListener* aOnuploadprogress);
-
   NS_FORWARD_NSIXMLHTTPREQUESTEVENTTARGET(nsXHREventTarget::)
 
   // nsIStreamListener
   NS_DECL_NSISTREAMLISTENER
 
   // nsIRequestObserver
   NS_DECL_NSIREQUESTOBSERVER
 
@@ -248,34 +244,16 @@ public:
   NS_FORWARD_NSIDOMEVENTTARGET(nsXHREventTarget::)
 
 #ifdef DEBUG
   void StaticAssertions();
 #endif
 
   // event handler
   IMPL_EVENT_HANDLER(readystatechange, Readystatechange)
-  JSObject* GetOnuploadprogress(JSContext* /* unused */)
-  {
-    nsIDocument* doc = GetOwner() ? GetOwner()->GetExtantDoc() : NULL;
-    if (doc) {
-      doc->WarnOnceAbout(nsIDocument::eOnuploadprogress);
-    }
-    return GetListenerAsJSObject(mOnUploadProgressListener);
-  }
-  void SetOnuploadprogress(JSContext* aCx, JSObject* aCallback,
-                           ErrorResult& aRv)
-  {
-    nsIDocument* doc = GetOwner() ? GetOwner()->GetExtantDoc() : NULL;
-    if (doc) {
-      doc->WarnOnceAbout(nsIDocument::eOnuploadprogress);
-    }
-    aRv = SetJSObjectListener(aCx, NS_LITERAL_STRING("uploadprogress"),
-                              mOnUploadProgressListener, aCallback);
-  }
 
   // states
   uint16_t GetReadyState();
 
   // request
   void Open(const nsAString& aMethod, const nsAString& aUrl, bool aAsync,
             const mozilla::dom::Optional<nsAString>& aUser,
             const mozilla::dom::Optional<nsAString>& aPassword,
@@ -572,17 +550,16 @@ protected:
   nsCOMPtr<nsIPrincipal> mPrincipal;
   nsCOMPtr<nsIChannel> mChannel;
   // mReadRequest is different from mChannel for multipart requests
   nsCOMPtr<nsIRequest> mReadRequest;
   nsCOMPtr<nsIDocument> mResponseXML;
   nsCOMPtr<nsIChannel> mCORSPreflightChannel;
   nsTArray<nsCString> mCORSUnsafeHeaders;
 
-  nsRefPtr<nsDOMEventListenerWrapper> mOnUploadProgressListener;
   nsRefPtr<nsDOMEventListenerWrapper> mOnReadystatechangeListener;
 
   nsCOMPtr<nsIStreamListener> mXMLParserStreamListener;
 
   // used to implement getAllResponseHeaders()
   class nsHeaderVisitor : public nsIHttpHeaderVisitor {
   public:
     NS_DECL_ISUPPORTS
--- a/content/base/test/file_CrossSiteXHR_inner.html
+++ b/content/base/test/file_CrossSiteXHR_inner.html
@@ -32,26 +32,19 @@ window.addEventListener("message", funct
   }
   xhr.addEventListener("readystatechange", function(e) {
     res.events.push("rs" + xhr.readyState);
   }, false);
   xhr.addEventListener("progress", function(e) {
     res.progressEvents++;
   }, false);
   if (req.uploadProgress) {
-    if (req.uploadProgress == "uploadProgress") {
-      xhr.addEventListener("uploadProgress", function(e) {
-        res.progressEvents++;
-      }, false);
-    }
-    else {
-      xhr.upload.addEventListener(req.uploadProgress, function(e) {
-        res.progressEvents++;
-      }, false);
-    }
+    xhr.upload.addEventListener(req.uploadProgress, function(e) {
+      res.progressEvents++;
+    }, false);
   }
   xhr.onerror = function(e) {
     res.didFail = true;
   };
   xhr.onloadend = function (event) {
     res.status = xhr.status;
     try {
       res.statusText = xhr.statusText;
--- a/content/base/test/file_CrossSiteXHR_inner_data.sjs
+++ b/content/base/test/file_CrossSiteXHR_inner_data.sjs
@@ -21,26 +21,19 @@ window.addEventListener("message", funct
   }\n\
   xhr.addEventListener("readystatechange", function(e) {\n\
     res.events.push("rs" + xhr.readyState);\n\
   }, false);\n\
   xhr.addEventListener("progress", function(e) {\n\
     res.progressEvents++;\n\
   }, false);\n\
   if (req.uploadProgress) {\n\
-    if (req.uploadProgress == "uploadProgress") {\n\
-      xhr.addEventListener("uploadProgress", function(e) {\n\
-        res.progressEvents++;\n\
-      }, false);\n\
-    }\n\
-    else {\n\
-      xhr.upload.addEventListener(req.uploadProgress, function(e) {\n\
-        res.progressEvents++;\n\
-      }, false);\n\
-    }\n\
+    xhr.upload.addEventListener(req.uploadProgress, function(e) {\n\
+      res.progressEvents++;\n\
+    }, false);\n\
   }\n\
   xhr.onerror = function(e) {\n\
     res.didFail = true;\n\
   };\n\
   xhr.onloadend = function (event) {\n\
     res.status = xhr.status;\n\
     try {\n\
       res.statusText = xhr.statusText;\n\
--- a/content/base/test/test_CrossSiteXHR.html
+++ b/content/base/test/test_CrossSiteXHR.html
@@ -448,35 +448,22 @@ function runTest() {
                  allowMethods: "put",
                },
 
                // Progress events
                { pass: 1,
                  method: "POST",
                  body: "hi there",
                  headers: { "Content-Type": "text/plain" },
-                 uploadProgress: "uploadprogress",
-               },
-               { pass: 1,
-                 method: "POST",
-                 body: "hi there",
-                 headers: { "Content-Type": "text/plain" },
                  uploadProgress: "progress",
                },
                { pass: 0,
                  method: "POST",
                  body: "hi there",
                  headers: { "Content-Type": "text/plain" },
-                 uploadProgress: "uploadprogress",
-                 noAllowPreflight: 1,
-               },
-               { pass: 0,
-                 method: "POST",
-                 body: "hi there",
-                 headers: { "Content-Type": "text/plain" },
                  uploadProgress: "progress",
                  noAllowPreflight: 1,
                },
 
                // Status messages
                { pass: 1,
                  method: "GET",
                  noAllowPreflight: 1,
--- a/content/base/test/test_XHR_onuploadprogress.html
+++ b/content/base/test/test_XHR_onuploadprogress.html
@@ -22,20 +22,20 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 var called = false;
 function uploadprogress()
 {
   called = true;
 }
 
 var xhr = new XMLHttpRequest();
-xhr.onuploadprogress = uploadprogress;
+xhr.upload.onprogress = uploadprogress;
 var event = document.createEvent("ProgressEvent");
-event.initProgressEvent("uploadprogress", false, false, false, false, 0);
-xhr.dispatchEvent(event);
+event.initProgressEvent("progress", false, false, false, false, 0);
+xhr.upload.dispatchEvent(event);
 ok(called,
-   "XMLHttpRequest.onuploadprogress sets uploadprogress event listener");
+   "XMLHttpRequest.upload.onprogress sets upload progress event listener");
 
 
 </script>
 </pre>
 </body>
 </html>
--- a/content/base/test/test_bug372964.html
+++ b/content/base/test/test_bug372964.html
@@ -100,17 +100,17 @@ function test(trusted, type, removeAdded
   ecc = eventHandlerCallCount;
   shouldBeTrusted = trusted;
   x1.dispatchEvent(e1);
   is(eventHandlerCallCount, ecc + handlerCount,
      "Wrong number event handler calls. (3)");
 }
 
 var events =
-  ["load", "error", "progress", "uploadprogress", "readystatechange", "foo"];
+  ["load", "error", "progress", "readystatechange", "foo"];
 
 do {
   var e = events.shift();
   test(false, e, false, false);
   test(false, e, false, true);
   test(false, e, true,  false);
   test(false, e, true,  true);
   test(true,  e, false, false);
--- a/content/base/test/test_bug435425.html
+++ b/content/base/test/test_bug435425.html
@@ -99,20 +99,16 @@ function start(obj) {
   xhr.onloadstart =
     function (evt) {
       logEvent(evt);
     }
   xhr.onprogress =
     function (evt) {
       logEvent(evt);
     }
-  xhr.onuploadprogress =
-    function (evt) {
-      logEvent(evt);
-    }
 
   if ("upload" in xhr) {
     xhr.upload.onloadstart =
       function (evt) {
         logEvent(evt);
       }
     xhr.upload.onprogress =
       function (evt) {
@@ -272,115 +268,106 @@ var tests =
     { method: "POST", withUpload: none, testAbort: false, testRedirectError: false, testNetworkError: true,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
                        {target: XHR, type: "error", optional: false},
                        {target: XHR, type: "loadend", optional: false}]},
 
     { method: "POST", withUpload: small, testAbort: false, testRedirectError: false, testNetworkError: false,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
                        {target: UPLOAD, type: "loadstart", optional: false},
-                       {target: XHR, type: "uploadprogress", optional: true},
                        {target: UPLOAD, type: "progress", optional: true},
                        {target: UPLOAD, type: "load", optional: false},
                        {target: UPLOAD, type: "loadend", optional: false},
                        {target: XHR, type: "progress", optional: true},
                        {target: XHR, type: "load", optional: false},
                        {target: XHR, type: "loadend", optional: false}]},
     { method: "POST", withUpload: small, testAbort: true, testRedirectError: false, testNetworkError: false,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
                        {target: UPLOAD, type: "loadstart", optional: false},
                        {target: XHR, type: "abort", optional: false},
                        {target: XHR, type: "loadend", optional: false},
                        {target: UPLOAD, type: "abort", optional: false},
                        {target: UPLOAD, type: "loadend", optional: false}]},
     { method: "POST", withUpload: small, testAbort: false, testRedirectError: true, testNetworkError: false,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
                        {target: UPLOAD, type: "loadstart", optional: false},
-                       {target: XHR, type: "uploadprogress", optional: true},
                        {target: UPLOAD, type: "progress", optional: true},
                        {target: XHR, type: "error", optional: false},
                        {target: XHR, type: "loadend", optional: false},
                        {target: UPLOAD, type: "error", optional: false},
                        {target: UPLOAD, type: "loadend", optional: false}]},
     { method: "POST", withUpload: small, testAbort: false, testRedirectError: false, testNetworkError: true,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
                        {target: UPLOAD, type: "loadstart", optional: false},
-                       {target: XHR, type: "uploadprogress", optional: true},
                        {target: UPLOAD, type: "progress", optional: true},
                        {target: XHR, type: "error", optional: false},
                        {target: XHR, type: "loadend", optional: false},
                        {target: UPLOAD, type: "error", optional: false},
                        {target: UPLOAD, type: "loadend", optional: false}]},
 
     { method: "POST", withUpload: mid, testAbort: false, testRedirectError: false, testNetworkError: false,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
                        {target: UPLOAD, type: "loadstart", optional: false},
-                       {target: XHR, type: "uploadprogress", optional: true},
                        {target: UPLOAD, type: "progress", optional: true},
                        {target: UPLOAD, type: "load", optional: false},
                        {target: UPLOAD, type: "loadend", optional: false},
                        {target: XHR, type: "progress", optional: true},
                        {target: XHR, type: "load", optional: false},
                        {target: XHR, type: "loadend", optional: false}]},
     { method: "POST", withUpload: mid, testAbort: true, testRedirectError: false, testNetworkError: false,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
                        {target: UPLOAD, type: "loadstart", optional: false},
                        {target: XHR, type: "abort", optional: false},
                        {target: XHR, type: "loadend", optional: false},
                        {target: UPLOAD, type: "abort", optional: false},
                        {target: UPLOAD, type: "loadend", optional: false}]},
     { method: "POST", withUpload: mid, testAbort: false, testRedirectError: true, testNetworkError: false,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
                        {target: UPLOAD, type: "loadstart", optional: false},
-                       {target: XHR, type: "uploadprogress", optional: true},
                        {target: UPLOAD, type: "progress", optional: true},
                        {target: XHR, type: "error", optional: false},
                        {target: XHR, type: "loadend", optional: false},
                        {target: UPLOAD, type: "error", optional: false},
                        {target: UPLOAD, type: "loadend", optional: false}]},
     { method: "POST", withUpload: mid, testAbort: false, testRedirectError: false, testNetworkError: true,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
                        {target: UPLOAD, type: "loadstart", optional: false},
-                       {target: XHR, type: "uploadprogress", optional: true},
                        {target: UPLOAD, type: "progress", optional: true},
                        {target: XHR, type: "error", optional: false},
                        {target: XHR, type: "loadend", optional: false},
                        {target: UPLOAD, type: "error", optional: false},
                        {target: UPLOAD, type: "loadend", optional: false}]},
 
     { method: "POST", withUpload: large, testAbort: false, testRedirectError: false, testNetworkError: false,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
                        {target: UPLOAD, type: "loadstart", optional: false},
-                       {target: XHR, type: "uploadprogress", optional: true},
                        {target: UPLOAD, type: "progress", optional: true},
                        {target: UPLOAD, type: "load", optional: false},
                        {target: UPLOAD, type: "loadend", optional: false},
                        {target: XHR, type: "progress", optional: true},
                        {target: XHR, type: "load", optional: false},
                        {target: XHR, type: "loadend", optional: false}]},
     { method: "POST", withUpload: large, testAbort: true, testRedirectError: false, testNetworkError: false,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
                        {target: UPLOAD, type: "loadstart", optional: false},
                        {target: XHR, type: "abort", optional: false},
                        {target: XHR, type: "loadend", optional: false},
                        {target: UPLOAD, type: "abort", optional: false},
                        {target: UPLOAD, type: "loadend", optional: false}]},
     { method: "POST", withUpload: large, testAbort: false, testRedirectError: true, testNetworkError: false,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
                        {target: UPLOAD, type: "loadstart", optional: false},
-                       {target: XHR, type: "uploadprogress", optional: true},
                        {target: UPLOAD, type: "progress", optional: true},
                        {target: XHR, type: "error", optional: false},
                        {target: XHR, type: "loadend", optional: false},
                        {target: UPLOAD, type: "error", optional: false},
                        {target: UPLOAD, type: "loadend", optional: false}]},
     { method: "POST", withUpload: large, testAbort: false, testRedirectError: false, testNetworkError: true,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
                        {target: UPLOAD, type: "loadstart", optional: false},
-                       {target: XHR, type: "uploadprogress", optional: true},
                        {target: UPLOAD, type: "progress", optional: true},
                        {target: XHR, type: "error", optional: false},
                        {target: XHR, type: "loadend", optional: false},
                        {target: UPLOAD, type: "error", optional: false},
                        {target: UPLOAD, type: "loadend", optional: false}]},
 ];
 
 function runTest() {
--- a/content/events/src/Makefile.in
+++ b/content/events/src/Makefile.in
@@ -31,23 +31,20 @@ CPPSRCS		= \
 		nsDOMUIEvent.cpp \
 		nsDOMKeyboardEvent.cpp \
 		nsDOMTextEvent.cpp \
 		nsDOMMouseEvent.cpp \
 		nsDOMMouseScrollEvent.cpp \
 		nsDOMDragEvent.cpp \
 		nsDOMMutationEvent.cpp \
 		nsDOMPopupBlockedEvent.cpp \
-		nsDOMDeviceProximityEvent.cpp \
-		nsDOMUserProximityEvent.cpp \
 		nsDOMDeviceLightEvent.cpp \
 		nsDOMDeviceOrientationEvent.cpp \
 		nsDOMDeviceMotionEvent.cpp \
 		nsDOMBeforeUnloadEvent.cpp \
-		nsDOMPageTransitionEvent.cpp \
 		nsDOMXULCommandEvent.cpp \
 		nsDOMCommandEvent.cpp \
 		nsDOMMessageEvent.cpp \
 		nsPaintRequest.cpp \
 		nsPrivateTextRange.cpp \
 		nsXMLEventsManager.cpp \
 		nsXMLEventsElement.cpp \
 		nsAsyncDOMEvent.cpp \
@@ -60,23 +57,19 @@ CPPSRCS		= \
 		nsDOMNotifyPaintEvent.cpp \
 		nsDOMNotifyAudioAvailableEvent.cpp \
 		nsDOMSimpleGestureEvent.cpp \
 		nsDOMMozTouchEvent.cpp \
 		nsDOMEventTargetHelper.cpp \
 		nsDOMScrollAreaEvent.cpp \
 		nsDOMTransitionEvent.cpp \
 		nsDOMAnimationEvent.cpp \
-		nsDOMPopStateEvent.cpp \
-		nsDOMHashChangeEvent.cpp \
-		nsDOMCloseEvent.cpp \
 		nsDOMSettingsEvent.cpp \
 		nsDOMContactChangeEvent.cpp \
 		nsDOMTouchEvent.cpp \
-		nsDOMCustomEvent.cpp \
 		nsDOMCompositionEvent.cpp \
 		nsDOMApplicationEvent.cpp \
 		$(NULL)
 
 ifdef MOZ_B2G_RIL
 CPPSRCS += \
     nsDOMWifiEvent.cpp \
     $(NULL)
--- a/content/events/src/nsDOMApplicationEvent.cpp
+++ b/content/events/src/nsDOMApplicationEvent.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */
  
 #include "nsDOMApplicationEvent.h"
 #include "nsContentUtils.h"
 #include "DictionaryHelpers.h"
+#include "nsDOMClassInfoID.h"
  
 DOMCI_DATA(MozApplicationEvent, nsDOMMozApplicationEvent)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMMozApplicationEvent)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMozApplicationEvent, nsDOMEvent)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mApplication)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
deleted file mode 100644
--- a/content/events/src/nsDOMCloseEvent.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsDOMClassInfoID.h"
-#include "nsDOMCloseEvent.h"
-#include "DictionaryHelpers.h"
-
-NS_IMPL_ADDREF_INHERITED(nsDOMCloseEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMCloseEvent, nsDOMEvent)
-
-DOMCI_DATA(CloseEvent, nsDOMCloseEvent)
-
-NS_INTERFACE_MAP_BEGIN(nsDOMCloseEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCloseEvent)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CloseEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
-
-NS_IMETHODIMP
-nsDOMCloseEvent::GetWasClean(bool *aWasClean)
-{
-  *aWasClean = mWasClean;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMCloseEvent::GetCode(PRUint16 *aCode)
-{
-  *aCode = mReasonCode;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMCloseEvent::GetReason(nsAString & aReason)
-{
-  aReason = mReason;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMCloseEvent::InitCloseEvent(const nsAString& aType,
-                                bool aCanBubble,
-                                bool aCancelable,
-                                bool aWasClean,
-                                PRUint16 aReasonCode,
-                                const nsAString &aReason)
-{
-  nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  mWasClean = aWasClean;
-  mReasonCode = aReasonCode;
-  mReason = aReason;
-
-  return NS_OK;
-}
-
-nsresult
-nsDOMCloseEvent::InitFromCtor(const nsAString& aType,
-                              JSContext* aCx, jsval* aVal)
-{
-  mozilla::dom::CloseEventInit d;
-  nsresult rv = d.Init(aCx, aVal);
-  NS_ENSURE_SUCCESS(rv, rv);
-  return InitCloseEvent(aType, d.bubbles, d.cancelable, d.wasClean, d.code,
-                        d.reason);
-}
-
-nsresult
-NS_NewDOMCloseEvent(nsIDOMEvent** aInstancePtrResult,
-                    nsPresContext* aPresContext,
-                    nsEvent* aEvent) 
-{
-  nsDOMCloseEvent* it = new nsDOMCloseEvent(aPresContext, aEvent);
-  if (nsnull == it) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
-  return CallQueryInterface(it, aInstancePtrResult);
-}
deleted file mode 100644
--- a/content/events/src/nsDOMCloseEvent.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsDOMCloseEvent_h__
-#define nsDOMCloseEvent_h__
-
-#include "nsIDOMCloseEvent.h"
-#include "nsDOMEvent.h"
-
-/**
- * Implements the CloseEvent event, used for notifying that a WebSocket
- * connection has been closed.
- *
- * See http://dev.w3.org/html5/websockets/#closeevent for further details.
- */
-class nsDOMCloseEvent : public nsDOMEvent,
-                        public nsIDOMCloseEvent
-{
-public:
-  nsDOMCloseEvent(nsPresContext* aPresContext, nsEvent* aEvent)
-    : nsDOMEvent(aPresContext, aEvent),
-    mWasClean(false),
-    mReasonCode(1005) {}
-                     
-  NS_DECL_ISUPPORTS_INHERITED
-
-  // Forward to base class
-  NS_FORWARD_TO_NSDOMEVENT
-
-  NS_DECL_NSIDOMCLOSEEVENT
-
-  virtual nsresult InitFromCtor(const nsAString& aType,
-                                JSContext* aCx, jsval* aVal);
-private:
-  bool mWasClean;
-  PRUint16 mReasonCode;
-  nsString mReason;
-};
-
-#endif // nsDOMCloseEvent_h__
--- a/content/events/src/nsDOMContactChangeEvent.cpp
+++ b/content/events/src/nsDOMContactChangeEvent.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsDOMContactChangeEvent.h"
 #include "nsContentUtils.h"
 #include "DictionaryHelpers.h"
+#include "nsDOMClassInfoID.h"
 
 DOMCI_DATA(MozContactChangeEvent, nsDOMMozContactChangeEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMMozContactChangeEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMozContactChangeEvent)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozContactChangeEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
deleted file mode 100644
--- a/content/events/src/nsDOMCustomEvent.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsDOMClassInfoID.h"
-#include "nsDOMCustomEvent.h"
-#include "DictionaryHelpers.h"
-
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMCustomEvent)
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMCustomEvent, nsDOMEvent)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDetail)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMCustomEvent, nsDOMEvent)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDetail)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-DOMCI_DATA(CustomEvent, nsDOMCustomEvent)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMCustomEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCustomEvent)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CustomEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
-
-NS_IMPL_ADDREF_INHERITED(nsDOMCustomEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMCustomEvent, nsDOMEvent)
-
-NS_IMETHODIMP
-nsDOMCustomEvent::GetDetail(nsIVariant** aDetail)
-{
-  NS_IF_ADDREF(*aDetail = mDetail);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMCustomEvent::InitCustomEvent(const nsAString& aType,
-                                  bool aCanBubble,
-                                  bool aCancelable,
-                                  nsIVariant* aDetail)
-{
-  nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  mDetail = aDetail;
-  return NS_OK;
-}
-
-nsresult
-nsDOMCustomEvent::InitFromCtor(const nsAString& aType,
-                               JSContext* aCx, jsval* aVal)
-{
-  mozilla::dom::CustomEventInit d;
-  nsresult rv = d.Init(aCx, aVal);
-  NS_ENSURE_SUCCESS(rv, rv);
-  return InitCustomEvent(aType, d.bubbles, d.cancelable, d.detail);
-}
-
-nsresult
-NS_NewDOMCustomEvent(nsIDOMEvent** aInstancePtrResult,
-                     nsPresContext* aPresContext,
-                     nsEvent* aEvent) 
-{
-  nsDOMCustomEvent* e = new nsDOMCustomEvent(aPresContext, aEvent);
-  return CallQueryInterface(e, aInstancePtrResult);
-}
deleted file mode 100644
--- a/content/events/src/nsDOMCustomEvent.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsDOMCustomEvent_h__
-#define nsDOMCustomEvent_h__
-
-#include "nsIDOMCustomEvent.h"
-#include "nsDOMEvent.h"
-#include "nsCycleCollectionParticipant.h"
-
-class nsDOMCustomEvent : public nsDOMEvent,
-                         public nsIDOMCustomEvent
-{
-public:
-  nsDOMCustomEvent(nsPresContext* aPresContext, nsEvent* aEvent)
-    : nsDOMEvent(aPresContext, aEvent)
-  {
-  }
-                     
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMCustomEvent, nsDOMEvent)
-
-  NS_DECL_NSIDOMCUSTOMEVENT
-
-  // Forward to base class
-  NS_FORWARD_TO_NSDOMEVENT
-
-  virtual nsresult InitFromCtor(const nsAString& aType,
-                                JSContext* aCx, jsval* aVal);
-private:
-  nsCOMPtr<nsIVariant> mDetail;
-};
-
-#endif // nsDOMCustomEvent_h__
deleted file mode 100644
--- a/content/events/src/nsDOMDeviceProximityEvent.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsDOMClassInfoID.h"
-#include "nsDOMDeviceProximityEvent.h"
-#include "DictionaryHelpers.h"
-
-NS_IMPL_ADDREF_INHERITED(nsDOMDeviceProximityEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMDeviceProximityEvent, nsDOMEvent)
-
-DOMCI_DATA(DeviceProximityEvent, nsDOMDeviceProximityEvent)
-
-NS_INTERFACE_MAP_BEGIN(nsDOMDeviceProximityEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDeviceProximityEvent)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DeviceProximityEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
-
-NS_IMETHODIMP
-nsDOMDeviceProximityEvent::InitDeviceProximityEvent(const nsAString & aEventTypeArg,
-                                                    bool aCanBubbleArg,
-                                                    bool aCancelableArg,
-                                                    double aValue,
-                                                    double aMin,
-                                                    double aMax)
-{
-  nsresult rv = nsDOMEvent::InitEvent(aEventTypeArg, aCanBubbleArg, aCancelableArg);
-  NS_ENSURE_SUCCESS(rv, rv);
-    
-  mValue = aValue;
-  mMin = aMin;
-  mMax = aMax;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMDeviceProximityEvent::GetValue(double *aValue)
-{
-  NS_ENSURE_ARG_POINTER(aValue);
-
-  *aValue = mValue;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMDeviceProximityEvent::GetMin(double *aMin)
-{
-  NS_ENSURE_ARG_POINTER(aMin);
-
-  *aMin = mMin;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMDeviceProximityEvent::GetMax(double *aMax)
-{
-  NS_ENSURE_ARG_POINTER(aMax);
-
-  *aMax = mMax;
-  return NS_OK;
-}
-
-nsresult
-nsDOMDeviceProximityEvent::InitFromCtor(const nsAString& aType,
-                                        JSContext* aCx, jsval* aVal)
-{
-  mozilla::dom::DeviceProximityEventInit d;
-  nsresult rv = d.Init(aCx, aVal);
-  NS_ENSURE_SUCCESS(rv, rv);
-  return InitDeviceProximityEvent(aType, d.bubbles, d.cancelable, d.value, d.min, d.max);
-}
-
-nsresult
-NS_NewDOMDeviceProximityEvent(nsIDOMEvent** aInstancePtrResult,
-                              nsPresContext* aPresContext,
-                              nsEvent *aEvent)
-{
-  NS_ENSURE_ARG_POINTER(aInstancePtrResult);
-  nsDOMDeviceProximityEvent* it = new nsDOMDeviceProximityEvent(aPresContext, aEvent);
-  return CallQueryInterface(it, aInstancePtrResult);
-}
deleted file mode 100644
--- a/content/events/src/nsDOMDeviceProximityEvent.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsDOMDeviceProximityEvent_h__
-#define nsDOMDeviceProximityEvent_h__
-
-#include "nsIDOMDeviceProximityEvent.h"
-#include "nsDOMEvent.h"
-
-class nsDOMDeviceProximityEvent
- : public nsDOMEvent
- , public nsIDOMDeviceProximityEvent
-{
-public:
-
- nsDOMDeviceProximityEvent(nsPresContext* aPresContext, nsEvent* aEvent)
-  : nsDOMEvent(aPresContext, aEvent),
-    mValue(-1),
-    mMin(0),
-    mMax(0) {}
-
-  NS_DECL_ISUPPORTS_INHERITED
-
-  // Forward to nsDOMEvent
-  NS_FORWARD_TO_NSDOMEVENT
-
-  // nsIDOMDeviceProximityEvent Interface
-  NS_DECL_NSIDOMDEVICEPROXIMITYEVENT
-
-  virtual nsresult InitFromCtor(const nsAString& aType,
-                                JSContext* aCx,
-                                jsval* aVal);
-protected:
-  double mValue, mMin, mMax;
-};
-
-#endif
--- a/content/events/src/nsDOMDragEvent.cpp
+++ b/content/events/src/nsDOMDragEvent.cpp
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsDOMDragEvent.h"
 #include "nsIServiceManager.h"
 #include "nsGUIEvent.h"
 #include "nsContentUtils.h"
 #include "nsDOMDataTransfer.h"
 #include "nsIDragService.h"
+#include "nsDOMClassInfoID.h"
 
 nsDOMDragEvent::nsDOMDragEvent(nsPresContext* aPresContext,
                                nsInputEvent* aEvent)
   : nsDOMMouseEvent(aPresContext, aEvent ? aEvent :
                     new nsDragEvent(false, 0, nsnull))
 {
   if (aEvent) {
     mEventIsInternal = false;
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -20,22 +20,22 @@
 #include "nsIInterfaceRequestorUtils.h"
 #include "prmem.h"
 #include "nsGkAtoms.h"
 #include "nsMutationEvent.h"
 #include "nsContentUtils.h"
 #include "nsIURI.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIScriptError.h"
-#include "nsDOMPopStateEvent.h"
 #include "mozilla/Preferences.h"
 #include "nsJSUtils.h"
 #include "DictionaryHelpers.h"
 #include "nsLayoutUtils.h"
 #include "nsIScrollableFrame.h"
+#include "nsDOMClassInfoID.h"
 
 using namespace mozilla;
 
 static const char* const sEventNames[] = {
   "mousedown", "mouseup", "click", "dblclick", "mouseenter", "mouseleave", "mouseover",
   "mouseout", "MozMouseHittest", "mousemove", "contextmenu", "keydown", "keyup", "keypress",
   "focus", "blur", "load", "popstate", "beforescriptexecute",
   "afterscriptexecute", "beforeunload", "unload",
deleted file mode 100644
--- a/content/events/src/nsDOMHashChangeEvent.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsDOMClassInfoID.h"
-#include "nsDOMHashChangeEvent.h"
-#include "DictionaryHelpers.h"
-
-NS_IMPL_ADDREF_INHERITED(nsDOMHashChangeEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMHashChangeEvent, nsDOMEvent)
-
-DOMCI_DATA(HashChangeEvent, nsDOMHashChangeEvent)
-
-NS_INTERFACE_MAP_BEGIN(nsDOMHashChangeEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMHashChangeEvent)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(HashChangeEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
-
-nsDOMHashChangeEvent::~nsDOMHashChangeEvent()
-{
-}
-
-NS_IMETHODIMP
-nsDOMHashChangeEvent::GetOldURL(nsAString &aURL)
-{
-  aURL.Assign(mOldURL);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMHashChangeEvent::GetNewURL(nsAString &aURL)
-{
-  aURL.Assign(mNewURL);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMHashChangeEvent::InitHashChangeEvent(const nsAString &aTypeArg,
-                                          bool aCanBubbleArg,
-                                          bool aCancelableArg,
-                                          const nsAString &aOldURL,
-                                          const nsAString &aNewURL)
-{
-  nsresult rv = nsDOMEvent::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  mOldURL.Assign(aOldURL);
-  mNewURL.Assign(aNewURL);
-  return NS_OK;
-}
-
-nsresult
-nsDOMHashChangeEvent::InitFromCtor(const nsAString& aType,
-                                   JSContext* aCx, jsval* aVal)
-{
-  mozilla::dom::HashChangeEventInit d;
-  nsresult rv = d.Init(aCx, aVal);
-  NS_ENSURE_SUCCESS(rv, rv);
-  return InitHashChangeEvent(aType, d.bubbles, d.cancelable, d.oldURL, d.newURL);
-}
-
-nsresult NS_NewDOMHashChangeEvent(nsIDOMEvent** aInstancePtrResult,
-                                nsPresContext* aPresContext,
-                                nsEvent* aEvent)
-{
-  nsDOMHashChangeEvent* event =
-    new nsDOMHashChangeEvent(aPresContext, aEvent);
-
-  return CallQueryInterface(event, aInstancePtrResult);
-}
deleted file mode 100644
--- a/content/events/src/nsDOMHashChangeEvent.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsDOMHashChangeEvent_h__
-#define nsDOMHashChangeEvent_h__
-
-class nsEvent;
-
-#include "nsIDOMHashChangeEvent.h"
-#include "nsDOMEvent.h"
-#include "nsIVariant.h"
-#include "nsCycleCollectionParticipant.h"
-
-class nsDOMHashChangeEvent : public nsDOMEvent,
-                             public nsIDOMHashChangeEvent
-{
-public:
-  nsDOMHashChangeEvent(nsPresContext* aPresContext, nsEvent* aEvent)
-    : nsDOMEvent(aPresContext, aEvent)
-  {
-  }
-
-  virtual ~nsDOMHashChangeEvent();
-
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMHASHCHANGEEVENT
-
-  NS_FORWARD_TO_NSDOMEVENT
-
-  virtual nsresult InitFromCtor(const nsAString& aType,
-                                JSContext* aCx, jsval* aVal);
-protected:
-  nsString mOldURL;
-  nsString mNewURL;
-};
-