Merge from mozilla-central.
authorDavid Anderson <danderson@mozilla.com>
Thu, 23 Feb 2012 11:35:56 -0800
changeset 112747 f322d97d334c0003b93679a4943de623383c523a
parent 112746 16632b5d21978ae2d8977b9ad5cd9c34f243137c (current diff)
parent 90783 9ad5dd5c1dd14e5fe76170db1a53220b57cb025c (diff)
child 112748 6e213a866d20bab72bec9df483a3974722b38a5e
push id239
push userakeybl@mozilla.com
push dateThu, 03 Jan 2013 21:54:43 +0000
treeherdermozilla-release@3a7b66445659 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge from mozilla-central.
accessible/src/base/nsAccessible.cpp
b2g/chrome/jar.mn
browser/base/content/browser.js
browser/components/shell/src/nsWindowsShellService.cpp
configure.in
content/canvas/src/WebGLContext.cpp
content/canvas/test/test_canvas.html
docshell/base/nsDocShell.cpp
dom/base/nsJSEnvironment.cpp
dom/plugins/ipc/PluginModuleChild.cpp
dom/plugins/ipc/PluginModuleParent.cpp
gfx/gl/GLContextProviderEGL.cpp
image/decoders/icon/win/nsIconChannel.cpp
image/decoders/icon/win/nsIconChannel.h
js/src/configure.in
js/src/jsanalyze.cpp
js/src/jsanalyze.h
js/src/jsinfer.cpp
js/src/jswrapper.cpp
js/src/methodjit/Compiler.cpp
js/src/methodjit/StubCalls.cpp
js/src/vm/Stack.cpp
js/src/vm/Stack.h
layout/generic/nsGfxScrollFrame.cpp
layout/reftests/scrolling/reftest.list
layout/reftests/svg/smil/reftest.list
layout/style/crashtests/crashtests.list
layout/style/nsCSSProps.cpp
layout/style/nsStyleAnimation.cpp
layout/tools/pageloader/Makefile.in
layout/tools/pageloader/README
layout/tools/pageloader/jar.mn
layout/tools/pageloader/pageloader.js
layout/tools/pageloader/pageloader.xul
layout/tools/pageloader/quit.js
layout/tools/pageloader/report.js
layout/tools/pageloader/tp-cmdline.js
layout/tools/pageloader/tp-cmdline.manifest
mobile/android/base/AndroidManifest.xml.in
mobile/android/base/GeckoApp.java
mobile/xul/themes/core/browser.css
mobile/xul/themes/core/gingerbread/browser.css
mobile/xul/themes/core/honeycomb/browser.css
mobile/xul/themes/core/tablet.css
modules/libjar/nsZipArchive.cpp
modules/libjar/nsZipArchive.h
modules/libpref/src/init/all.js
startupcache/StartupCache.cpp
startupcache/StartupCache.h
startupcache/test/TestStartupCache.cpp
storage/src/mozStorageAsyncStatementExecution.cpp
testing/tools/pageloader/Makefile
testing/tools/pageloader/README
testing/tools/pageloader/chrome.manifest
testing/tools/pageloader/chrome/content/pageloader.css
testing/tools/pageloader/chrome/content/pageloader.js
testing/tools/pageloader/chrome/content/pageloader.xul
testing/tools/pageloader/chrome/content/report.js
testing/tools/pageloader/install.rdf
testing/tools/pageloader/test/chrome/content/pageloader.js
testing/tools/pageloader/test/chrome/content/report.js
toolkit/components/downloads/nsDownloadManager.h
toolkit/components/downloads/nsDownloadScanner.cpp
toolkit/components/downloads/nsDownloadScanner.h
toolkit/components/telemetry/TelemetryHistograms.h
toolkit/crashreporter/nsExceptionHandler.cpp
uriloader/exthandler/win/nsOSHelperAppService.cpp
uriloader/exthandler/win/nsOSHelperAppService.h
widget/qt/nsWindow.cpp
widget/qt/nsWindow.h
widget/windows/nsAppShell.cpp
widget/windows/nsFilePicker.cpp
widget/windows/nsNativeThemeWin.cpp
widget/windows/nsUXThemeData.cpp
widget/windows/nsUXThemeData.h
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
xpcom/base/nsMemoryReporterManager.cpp
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -833,19 +833,19 @@ nsAccessible::ChildAtPoint(PRInt32 aX, P
   nsDocAccessible* accDocument = Document();
   NS_ENSURE_TRUE(accDocument, nsnull);
 
   nsIFrame *frame = accDocument->GetFrame();
   NS_ENSURE_TRUE(frame, nsnull);
 
   nsPresContext *presContext = frame->PresContext();
 
-  nsIntRect screenRect = frame->GetScreenRectExternal();
-  nsPoint offset(presContext->DevPixelsToAppUnits(aX - screenRect.x),
-                 presContext->DevPixelsToAppUnits(aY - screenRect.y));
+  nsRect screenRect = frame->GetScreenRectInAppUnits();
+  nsPoint offset(presContext->DevPixelsToAppUnits(aX) - screenRect.x,
+                 presContext->DevPixelsToAppUnits(aY) - screenRect.y);
 
   nsCOMPtr<nsIPresShell> presShell = presContext->PresShell();
   nsIFrame *foundFrame = presShell->GetFrameForPoint(frame, offset);
 
   nsIContent* content = nsnull;
   if (!foundFrame || !(content = foundFrame->GetContent()))
     return fallbackAnswer;
 
--- a/accessible/tests/mochitest/bounds/test_zoom.html
+++ b/accessible/tests/mochitest/bounds/test_zoom.html
@@ -15,29 +15,24 @@
   <script type="application/javascript"
           src="../layout.js"></script>
   <script type="application/javascript"
           src="../browser.js"></script>
 
   <script type="application/javascript">
     function doTest()
     {
-      var p1 = currentTabDocument().body.firstElementChild;
-      var p2 = currentTabDocument().body.lastElementChild;
+      var tabDocument = currentTabDocument();
+      var p1 = tabDocument.body.firstElementChild;
+      var p2 = tabDocument.body.lastElementChild;
 
       testBounds(p1);
       testBounds(p2);
 
-      var docShell = currentTabWindow().
-        QueryInterface(Components.interfaces.nsIInterfaceRequestor).
-        getInterface(Components.interfaces.nsIWebNavigation).
-        QueryInterface(Components.interfaces.nsIDocShell);
-      var docViewer = docShell.contentViewer.
-        QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);
-      docViewer.fullZoom = 2.0;
+      zoomDocument(tabDocument, 2.0);
 
       testBounds(p1);
       testBounds(p2);
 
       closeBrowserWindow();
       SimpleTest.finish();
     }
 
--- a/accessible/tests/mochitest/browser.js
+++ b/accessible/tests/mochitest/browser.js
@@ -93,16 +93,31 @@ function urlbarInput()
 /**
  * Return reload button.
  */
 function reloadButton()
 {
   return browserWindow().document.getElementById("urlbar-reload-button");
 }
 
+/**
+ * Zoom the given document.
+ */
+function zoomDocument(aDocument, aZoom)
+{
+  var docShell = aDocument.defaultView.
+    QueryInterface(Components.interfaces.nsIInterfaceRequestor).
+    getInterface(Components.interfaces.nsIWebNavigation).
+    QueryInterface(Components.interfaces.nsIDocShell);
+  var docViewer = docShell.contentViewer.
+    QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);
+
+  docViewer.fullZoom = aZoom;
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // private section
 
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 var gBrowserContext =
 {
   browserWnd: null,
--- a/accessible/tests/mochitest/hittest/Makefile.in
+++ b/accessible/tests/mochitest/hittest/Makefile.in
@@ -41,15 +41,16 @@ topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 relativesrcdir  = accessible/hittest
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES = \
+		test_browser.html \
 		test_general.html \
 		test_general.xul \
-		test_browser.html \
+		test_zoom.html \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/a11y/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/accessible/tests/mochitest/hittest/test_zoom.html
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>childAtPoint when page is zoomed</title>
+  <link rel="stylesheet" type="text/css"
+        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+  <script type="application/javascript"
+          src="../common.js"></script>
+  <script type="application/javascript"
+          src="../role.js"></script>
+  <script type="application/javascript"
+          src="../layout.js"></script>
+  <script type="application/javascript"
+          src="../browser.js"></script>
+
+  <script type="application/javascript">
+    function doTest()
+    {
+      var tabDocument = currentTabDocument();
+      var p1 = tabDocument.body.firstElementChild;
+      var p2 = tabDocument.body.lastElementChild;
+
+      hitTest(tabDocument, p1, p1.firstChild);
+      hitTest(tabDocument, p2, p2.firstChild);
+
+      zoomDocument(tabDocument, 2.0);
+
+      hitTest(tabDocument, p1, p1.firstChild);
+      hitTest(tabDocument, p2, p2.firstChild);
+
+      closeBrowserWindow();
+      SimpleTest.finish();
+    }
+
+    SimpleTest.waitForExplicitFinish();
+    openBrowserWindow(doTest,
+                      "data:text/html,<html><body><p>para 1</p><p>para 2</p></body></html>",
+                      { left: 100, top: 100 });
+  </script>
+</head>
+<body>
+
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=727942"
+     title="childAtPoint may return incorrect accessibles when page zoomed">
+    Mozilla Bug 727942
+  </a>
+  <p id="display"></p>
+  <div id="content" style="display: none"></div>
+  <pre id="test">
+  </pre>
+</body>
+</html>
--- a/accessible/tests/mochitest/layout.js
+++ b/accessible/tests/mochitest/layout.js
@@ -18,16 +18,39 @@ function testChildAtPoint(aIdentifier, a
   msg += " child accessible [" + prettyName(actualChildAcc);
   msg += "] at the point (" + aX + ", " + aY + ") of accessible [";
   msg += prettyName(aIdentifier) + "]";
 
   is(childAcc, actualChildAcc, msg);
 }
 
 /**
+ * Test if getChildAtPoint returns the given child and grand child accessibles
+ * at coordinates of child accessible (direct and deep hit test).
+ */
+function hitTest(aContainerID, aChildID, aGrandChildID)
+{
+  var container = getAccessible(aContainerID);
+  var child = getAccessible(aChildID);
+  var grandChild = getAccessible(aGrandChildID);
+
+  var [x, y] = getBoundsForDOMElm(child);
+
+  var actualChild = container.getChildAtPoint(x + 1, y + 1);
+  is(actualChild, child,
+     "Wrong child, expected: " + prettyName(child) +
+     ", got: " + prettyName(actualChild));
+
+  var actualGrandChild = container.getDeepestChildAtPoint(x + 1, y + 1);
+  is(actualGrandChild, grandChild,
+     "Wrong deepest child, expected: " + prettyName(grandChild) +
+     ", got: " + prettyName(actualGrandChild));
+}
+
+/**
  * Return child accessible at the given point.
  *
  * @param aIdentifier        [in] accessible identifier
  * @param aX                 [in] x coordinate of the point relative accessible
  * @param aY                 [in] y coordinate of the point relative accessible
  * @param aFindDeepestChild  [in] points whether deepest or nearest child should
  *                           be returned
  * @return                   the child accessible at the given point
--- a/b2g/chrome/content/content.css
+++ b/b2g/chrome/content/content.css
@@ -102,11 +102,11 @@ xul|scrollbarbutton[sbattr="scrollbar-bo
 
 xul|thumb {
   background-color: rgba(0, 0, 0, 0.4) !important;
   -moz-border-top-colors: none !important;
   -moz-border-bottom-colors: none !important;
   -moz-border-right-colors: none !important;
   -moz-border-left-colors: none !important;
   border: 1px solid rgba(255, 255, 255, 0.4) !important;
-  -moz-border-radius: 3px;
+  border-radius: 3px;
 }
 
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..9f2e4a6e7366abd9123ad34ed8d369c387111fee
GIT binary patch
literal 850
zc$@)J1FigtP)<h;3K|Lk000e1NJLTq002Ay002A)1^@s6I{evk0000PbVXQnQ*UN;
zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!^hrcPRCwC#n(J|+Fc5$tlLAx%>3|YQ
z2c&|K4x9?2tH33Y4t%MAbl`M=J0Kl!=tj;k8cFP~Ry<;MM&myQ^l6`3Dee0{xhYY=
zGeVc@lgtCm_@8rTU?s;}0~W(**8q(DP&1622%RqloL;q?rs??Miykg1^zY{|9*NL$
z7;g*~lR|)h{_Fr&@<&g~WtJWEgC05QcZJ9!26)P(mDy&l_drc*Et$w?(qs7^#_KTN
zEx@4~u00F7h=#|*G`~;{*IS6v=Mi)WaJ8khbO;3IOi5_qdt%`bBDu~0S9x0`f+1E^
zGDqolP7U9!AZvUDJo^{>z#4!*W_@-ACY|W$k2U2prSMpThLybN0tYJUzfW@ot!A{R
z?HHkRpr#vab;h+l>@_&IR2s@w=~bb%^cYwoG%R(yW>ak}TgRi&W(o;f$rgdlN=t3%
z9|F4>zNSIJ{LXiyQBmkh@Z!wxo}Si`Ny8<;YAB;NzLOc>`B56CiD#QE2Dpv@YVO*u
z^}Q{^tGQ=Wz``&;GhIL<<slMmXK^>*!qz_E%Ft-1wJbEiVWBPHc$CP!b>{*uner`n
z-`O{h91<T~z*CcKfP3L4qTeO}zXbzR{m1Mz$MRc24Tw|?+uA&4o`p^x3tWT*M2Zi)
z@}Mvp^N`Lb)(T{3K%9!wSigeqa$3DG7~m5}K%C0Md8EoHNBVhd@!J#S+mK32Fh|>p
z5ZH3ALIzV>$_O>DL@rQpA%i^-4=Mi77PFMd1rnhyM!5ly5gKi-oGp<H6zp2mD-Qy>
z`zeubVp|}VLMHT%M+GpkBcU2AiG@sb;A;?RiTz>;SRlcf8o6%q2tCoxQGG#yo7fwW
z7}u6CCyH`nQ^0+Xt6%z_mh@~2V%*eQ4e(*23HPgjPfQ1Dn*c87@LLz~_}bD^2LqX<
zoTQ{l;W>FoA&vMgNdwjJU2<b`bHGdZu&TwMncoTa;rj&^Ig4<LxSRA2yaVsRJMa#?
cMfoSd04yL1uj;}d)c^nh07*qoM6N<$g2EqxIsgCw
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..fc153c7314e82e12a75ac2589c63db3344a5eb34
GIT binary patch
literal 886
zc$@)t1Bv{JP)<h;3K|Lk000e1NJLTq002Ay002A)1^@s6I{evk0000PbVXQnQ*UN;
zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU#7)eAyRCwC#T8nX`Fc8I=6hH}12c&}F
z4oC$@I&dlosep8VJ0Mqqa}}5l><(}ToJjU&G&%`Mt6d`}yqTR0j*axR`&O&ZY8Zy(
zC*fv>HVa_`u|-YzUD(@P9$w89(y6e6ur(DAtcQI=X)i28bnq<fF$NFI4<|4aa`^ip
zY=dmS683UQ4^I&u@d}+Xg=O#Cpaw0xD+C)V!v8$@WbpPtKscI^RyFr5Y{x*jAxK^u
zYQplA@&p4wL3kuv#-w2#IvCM&AmI`S&pIu+AS3WfMo88Rw*iGiDB)M>`6YJ3p-_|G
zFT$!Tx?0+l7eZ?Dt0VmTQooIb@DAzaP9u-2Ae<=kJKF*TOZY)pEj3J~<Bg-I$8z`H
zvbfP>EIcH`pjO^NVWqIWrmYtKhkmzOX}K=f#u5Gl-gr;037S#Jh4mJ%Rt#Rfh}{~z
zcNegmkythja)u0lQrbx2v(ClCveiT$E*zo;gGOm*t+X@dflU4mwzEEjn}G)hVX4$k
z3ZJRyVIU?6r=aB=o-^fTu9<SnM7CEwXBpULig2lTv<EMzKw#@gHXHa*X!>j$AT8m7
zXucf>=g361)(osme$W!Ob#kxh#$<a&-6jsYbta6}k8BmAZqtB-i1M(Et)Xaf?YuAY
zz=Y_nVN>=?rSNhg(juauB1njnS=v`unWL7DFfcxZTcU(GIS*$8Pi2&O>inqDZHsLC
z^Y=FsYtuWZt0@=wzPlQa%6fa7d>yEhu9i5mZi9GdNnFS{*V3WI|3MR$mFEDZ1QMGJ
zY28-nJt8E}h`p)~4(_OrRK54KPO#^+W7Mr~fGW~8bikgIEyQX>UMP@-47r9)Q`gb4
z=5--lGw2qrVUyNIUB4+IxJ&%+e0*@~mLjB0OG4N0R+dFU%~13NdsvrnFi?w&0t$?8
zd3yM)RC8<YgYr2E>#iX3=r#hv9n7~fYKDFA|1X0?a($R0lru|otYRWefxV?7Tg7%h
zd=dOO!gGamnS9;cp@fr$=eoAEW;jJ$LV6**5MBr`gcrishQ9&~07cZf+~wI#>Hq)$
M07*qoM6N<$f|_oW82|tP
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8bf9d8e7decc3642be80e0d6dc615c2f50f64a79
GIT binary patch
literal 631
zc$@)u0*L*IP)<h;3K|Lk000e1NJLTq002Ay002A)1^@s6I{evk0000PbVXQnQ*UN;
zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!8A(JzRCwC#o9%6bFc5~J>i=d0kH83w
zzzA$mHYgj=PQVDX6L^GlgN(okG)P8DBRkml;n>NY^h%KkwjZ5+zB?u5vMj|j*-P<c
zCcpwLzyd750-TV&x*n8e$u*}st2Lj0&-&(=#F<d74{TzxW}Wg%BNwohD<bgWtl0v*
zs(wV^(E+>a^k~4<4cJZnBLQm<;MoMU?15Vk*iBRJz_$X`!WqEs1v~`8t~%xltN^f^
zx*UNu0(dsZAsgTZ0ZWpB#RNW>L}G8t*5<sj1hAOEeSqio&bdw<*e6g`SMN+a-)~a}
zo;-j<cLXSa#Q?5>cdXBQLyEvBkA-U>u<a;-fT>zMy=UT&xmyR4l@fSZ1?J1w)&;!V
zq~PHXq~{KSUPfhLSl}9ZZ6L0_?w(uvScIpHq1Td4>K<FV3yqu?Ub?h5V1F#CharW%
zD?ipm<FI-d6FjONkMnvN;Nhykm3<T8SbdC4OBeWBS9$cReH#Ue6SyUS-E!)VXsn3~
z7!#<tRdWCjiNac|Ff6blT-;=G;@Siqs$J7j0&Aj0X~wwluTg*jZV0{Wx<;tRAF;qb
z9mo(3j$lY0z@WfA@nU96rZp1Jp`pNvDWc8>vIkaMK58MrDPKc-Izftus>s(ASH~ke
zy9NA}G1sT-LFp<K%n#Gn5dV&CoJF>u71+roe*q9+0Ty5Z7GMDu;8^x2zyNbwkV-1)
R8RGx|002ovPDHLkV1nb47!m*g
new file mode 100644
--- /dev/null
+++ b/b2g/chrome/content/netError.css
@@ -0,0 +1,127 @@
+/*
+ *  This defines the look-and-feel styling of the error pages.
+ *  (see: netError.xhtml)
+ *
+ *  Original styling by William Price <bugzilla@mob.rice.edu>
+ *  Updated for mobile by: Wes Johnston <wjohnston@mozilla.com>
+ */
+
+body {
+  margin: 0;
+  padding: 0 8px 8px;
+  font-family: "Nokia Sans", Tahoma, sans-serif !important;
+}
+
+h1 {
+  font-size: 22px;
+}
+
+h2 {
+  font-size: 16px;
+}
+
+ul {
+  margin: 0px;
+  padding: 0px 0px 0px 1em;
+}
+
+li {
+  margin: 0px;
+  padding: 8px 0px;
+}
+
+#errorPage {
+  background-color: #CEE6F4;
+}
+
+#errorPage.certerror {
+  background-color: #EFD400;
+}
+
+#errorPage.blockedsite {
+  background-color: #BF0000;
+}
+
+#errorTitle {
+  background: url("chrome://browser/content/images/errorpage-warning.png") left center no-repeat;
+  /* Scaled by .666 of their actual size */
+  background-size: 40px 40px;
+  background-origin: content-box;
+  min-height: 60px;
+  margin-left: auto;
+  margin-right: auto;
+  max-width: 500px;
+  margin-left: auto;
+  margin-right: auto;
+}
+
+#errorPage.certerror #errorTitle {
+  background-image: url("chrome://browser/content/images/errorpage-larry-black.png");
+}
+
+#errorPage.blockedsite #errorTitle {
+  background-image: url("chrome://browser/content/images/errorpage-larry-white.png");
+  color: white;
+}
+
+.errorTitleText {
+  padding: 0px 0px 0px 50px;
+  display: inline-block;
+  vertical-align: middle
+}
+
+#errorPageContainer {
+  background-color: white;
+  border: 1px solid #999999;
+  border-radius: 6px;
+  padding: 6px 20px 20px;
+  font-size: 14px;
+  max-width: 500px;
+  margin-left: auto;
+  margin-right: auto;
+}
+
+#errorShortDesc > p:empty {
+  display: none;
+}
+
+#errorShortDesc > p {
+  overflow: auto;
+  border-bottom: 1px solid #999999;
+  padding-bottom: 1em;
+}
+
+#errorPage.blockedsite #errorShortDesc > p {
+  font-weight: bold;
+  border-bottom: none;
+  padding-bottom: 0px;
+}
+
+#securityOverrideDiv {
+  padding-top: 10px;
+}
+
+div[collapsed] {
+  padding-left: 15px;
+  background-image: url("chrome://browser/skin/images/arrowright-16.png");
+  background-size: 11px 11px;
+  background-repeat: no-repeat;
+  background-position: left 0.3em;  
+}
+
+div[collapsed="true"] {
+  background-image: url("chrome://browser/skin/images/arrowright-16.png");
+}
+
+div[collapsed="false"] {
+  background-image: url("chrome://browser/skin/images/arrowdown-16.png");
+}
+
+div[collapsed="true"] > p,
+div[collapsed="true"] > div {
+  display: none;
+}
+
+button {
+  padding: 0.3em !important;
+}
--- a/b2g/chrome/content/netError.xhtml
+++ b/b2g/chrome/content/netError.xhtml
@@ -299,30 +299,30 @@
       function endsWith(haystack, needle) {
         return haystack.slice(-needle.length) == needle;
       }
 
     ]]></script>
   </head>
 
   <body id="errorPage" dir="&locale.dir;">
-
     <!-- ERROR ITEM CONTAINER (removed during loading to avoid bug 39098) -->
     <div id="errorContainer">
       <div id="errorTitlesContainer">
         <h1 id="et_generic">&generic.title;</h1>
         <h1 id="et_dnsNotFound">&dnsNotFound.title;</h1>
         <h1 id="et_fileNotFound">&fileNotFound.title;</h1>
         <h1 id="et_malformedURI">&malformedURI.title;</h1>
         <h1 id="et_protocolNotFound">&protocolNotFound.title;</h1>
         <h1 id="et_connectionFailure">&connectionFailure.title;</h1>
         <h1 id="et_netTimeout">&netTimeout.title;</h1>
         <h1 id="et_redirectLoop">&redirectLoop.title;</h1>
         <h1 id="et_unknownSocketType">&unknownSocketType.title;</h1>
         <h1 id="et_netReset">&netReset.title;</h1>
+        <h1 id="et_notCached">&notCached.title;</h1>
         <h1 id="et_netOffline">&netOffline.title;</h1>
         <h1 id="et_netInterrupt">&netInterrupt.title;</h1>
         <h1 id="et_deniedPortAccess">&deniedPortAccess.title;</h1>
         <h1 id="et_proxyResolveFailure">&proxyResolveFailure.title;</h1>
         <h1 id="et_proxyConnectFailure">&proxyConnectFailure.title;</h1>
         <h1 id="et_contentEncodingError">&contentEncodingError.title;</h1>
         <h1 id="et_unsafeContentType">&unsafeContentType.title;</h1>
         <h1 id="et_nssFailure2">&nssFailure2.title;</h1>
@@ -337,16 +337,17 @@
         <div id="ed_fileNotFound">&fileNotFound.longDesc;</div>
         <div id="ed_malformedURI">&malformedURI.longDesc;</div>
         <div id="ed_protocolNotFound">&protocolNotFound.longDesc;</div>
         <div id="ed_connectionFailure">&connectionFailure.longDesc;</div>
         <div id="ed_netTimeout">&netTimeout.longDesc;</div>
         <div id="ed_redirectLoop">&redirectLoop.longDesc;</div>
         <div id="ed_unknownSocketType">&unknownSocketType.longDesc;</div>
         <div id="ed_netReset">&netReset.longDesc;</div>
+        <div id="ed_notCached">&notCached.longDesc;</div>
         <div id="ed_netOffline">&netOffline.longDesc2;</div>
         <div id="ed_netInterrupt">&netInterrupt.longDesc;</div>
         <div id="ed_deniedPortAccess">&deniedPortAccess.longDesc;</div>
         <div id="ed_proxyResolveFailure">&proxyResolveFailure.longDesc2;</div>
         <div id="ed_proxyConnectFailure">&proxyConnectFailure.longDesc;</div>
         <div id="ed_contentEncodingError">&contentEncodingError.longDesc;</div>
         <div id="ed_unsafeContentType">&unsafeContentType.longDesc;</div>
         <div id="ed_nssFailure2">&nssFailure2.longDesc;</div>
--- a/b2g/chrome/jar.mn
+++ b/b2g/chrome/jar.mn
@@ -10,9 +10,14 @@ chrome.jar:
   content/touch.js                      (content/touch.js)
 #endif
   content/commandUtil.js                (content/commandUtil.js)
   content/httpd.js                      (content/httpd.js)
   content/webapi.js                     (content/webapi.js)
   content/content.css                   (content/content.css)
 
 % override chrome://global/content/netError.xhtml chrome://browser/content/netError.xhtml
+% override chrome://global/skin/netError.css chrome://browser/content/netError.css
   content/netError.xhtml                (content/netError.xhtml)
+  content/netError.css                  (content/netError.css)
+  content/images/errorpage-larry-black.png (content/images/errorpage-larry-black.png)
+  content/images/errorpage-larry-white.png (content/images/errorpage-larry-white.png)
+  content/images/errorpage-warning.png (content/images/errorpage-warning.png)
\ No newline at end of file
--- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/content/browser.css
+++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/content/browser.css
@@ -176,17 +176,17 @@ image.study-result {
     padding-top: 3px;
 }
 
 .pane-button-badge {
     background-color: green;
     color: white;
     font-weight: bold;
     padding: 2px;
-    -moz-border-radius: 100%;
+    border-radius: 100%;
     margin-right: 25px;
     margin-bottom: 13px;
 }
 
 richlistbox.tp-study-list {
     overflow: auto;
     margin: 0px;
 }
--- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/content/screen.css
+++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/content/screen.css
@@ -97,19 +97,18 @@ src: url('chrome://testpilot/skin/fonts/
 	margin-top: 30px;
 }
 
 .button {
 	font-family: 'DroidSans';
 	font-size: 16px;
 	padding: 8px 12px;
 	color: rgba(0, 0, 0, 0.8);
-	-moz-border-radius: 0.5em;
-	-webkit-border-radius: 0.5em;
-	-moz-box-shadow: 
+	border-radius: 0.5em;
+	box-shadow: 
 		inset rgba(0, 0, 0, 0.2) 0 1px 1px,
 		inset rgba(255, 255, 255, 1) 0 3px 1px,
 		inset rgba(255, 255, 255, 0.3) 0 16px 0px,
 		inset rgba(0, 0, 0, 0.2) 0 -1px 1px,
 		inset rgba(0, 0, 0, 0.1) 0 -2px 1px, 
 		rgba(255, 255, 255, 1) 0 1px,
 		rgba(133, 153, 166, 0.3) 0px 1px 12px;
 	background-color: #e7eaec;
@@ -117,19 +116,18 @@ src: url('chrome://testpilot/skin/fonts/
 }
 
 .home_button {
 	font-family: 'DroidSans';
 	font-size: 16px;
 	padding: 8px 12px;
 	width: 240px;
 	color: rgba(0, 0, 0, 0.8);
-	-moz-border-radius: 0.5em;
-	-webkit-border-radius: 0.5em;
-	-moz-box-shadow: 
+	border-radius: 0.5em;
+	box-shadow: 
 		inset rgba(0, 0, 0, 0.2) 0 1px 1px,
 		inset rgba(255, 255, 255, 1) 0 3px 1px,
 		inset rgba(255, 255, 255, 0.3) 0 16px 0px,
 		inset rgba(0, 0, 0, 0.2) 0 -1px 1px,
 		inset rgba(0, 0, 0, 0.1) 0 -2px 1px, 
 		rgba(255, 255, 255, 1) 0 1px,
 		rgba(133, 153, 166, 0.3) 0px 1px 12px;
 	background-color: #e7eaec;
@@ -138,38 +136,36 @@ src: url('chrome://testpilot/skin/fonts/
 
 
 .callout {
 	font-family: 'DroidSans';
 	font-size: 16px;
 	padding: 8px 24px;
 	margin: 24px auto;
 	color: rgba(0, 0, 0, 0.8);
-	-moz-border-radius: 0.5em;
-	-webkit-border-radius: 0.5em;
+	border-radius: 0.5em;
 	background: rgba(220, 240, 247, 0.8) url('chrome://testpilot/skin/callout.png') no-repeat top center;
-	-moz-box-shadow: 
+	box-shadow: 
 		inset rgba(185, 221, 234, 0.2) 0 -10px 12px,
 		inset rgba(185, 221, 234, 1) 0 0px 1px,
 		inset rgba(255, 255, 255, 0.2) 0 10px 12px;
 	//display: inline;
 }
 
 .home_callout {
 	font-family: 'DroidSans';
 	font-size: 16px;
 	vertical-align: middle;
 	width: 240px;
 	padding: 8px 24px;
 	margin: 8px auto;
 	color: rgba(0, 0, 0, 0.8);
-	-moz-border-radius: 0.5em;
-	-webkit-border-radius: 0.5em;
+	border-radius: 0.5em;
 	background: rgba(220, 240, 247, 0.8) url('chrome://testpilot/skin/callout.png') no-repeat top center;
-	-moz-box-shadow: 
+	box-shadow: 
 		inset rgba(185, 221, 234, 0.2) 0 -10px 12px,
 		inset rgba(185, 221, 234, 1) 0 0px 1px,
 		inset rgba(255, 255, 255, 0.2) 0 10px 12px;
 	//display: inline;
 }
 
 .homeIcon {
 	margin-top: -32px;
@@ -192,18 +188,17 @@ src: url('chrome://testpilot/skin/fonts/
 /* ------- MENU ------- 
 
 #menu {
 	margin: 20px auto;
 	max-width: 800px;
 	padding: 4px 40px;
 	width: 800px;
 	text-align: left;
-	-moz-border-radius: 0.25em;
-	-webkit-border-radius: 0.25em;
+	border-radius: 0.25em;
 	border-top: 1px solid #adb6ba;
 	border-left: 1px solid #adb6ba;
 	border-right: 1px solid #adb6ba;
 	border-bottom: 3px solid #adb6ba;
 	-moz-border-bottom-colors:#adb6ba #e7eaec #e7eaec;
 	background-color: #fff;
 } 
 
@@ -218,17 +213,17 @@ src: url('chrome://testpilot/skin/fonts/
 }
 
 .menuOn {
 	margin-right: 30px;
 	margin-bottom: 40px;
 	font-size: 14px;
 	text-shadow: 1px 1px 1px rgba(173, 182, 186, 1);
 	background-color: rgba(173, 182, 186, 0.3);
-	-moz-box-shadow: 
+	box-shadow: 
 		inset rgba(0, 0, 0, 0.2) 0 -10px 12px;
 	padding: 9px 8px 8px 8px;
 }
 
 .menuItem a {color: #9f423b; text-decoration: none;}
 .menuItem a:hover {color: #9f423b; text-decoration: none; border-bottom: 1px dotted #9f423b;}
 
 
@@ -250,9 +245,9 @@ src: url('chrome://testpilot/skin/fonts/
 .function-link {
     cursor: pointer;
     color: #9f423b;
     text-decoration: underline;
 }
 
 p.embiggened {
     font-size: 14px;
-}
\ No newline at end of file
+}
--- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/skin/all/css/screen-standalone.css
+++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/skin/all/css/screen-standalone.css
@@ -48,17 +48,16 @@ body {
 			rgba(133, 153, 166, 0.4) 0px 1px 24px;
 		
 	}
 	
 	.dataBox {
 		font-size: 16px;
 		padding: 6px 20px 20px 20px;
 		border-radius: 0.5em;
-		-webkit-border-radius: 0.5em;
 		background: rgba(220, 240, 247, 0.8) url('chrome://testpilot/skin/images/callout.png') no-repeat top center;
 		/* display: inline; */
 	}
 
 #container {
 	margin: 0px auto;
 	width: 950px;
 
@@ -109,17 +108,16 @@ body {
 	margin-top: 260px;
 }
 
 .button {
 	font-size: 16px;
 	padding: 8px 12px;
 	color: rgba(0, 0, 0, 0.8);
 	border-radius: 0.5em;
-	-webkit-border-radius: 0.5em;
 	box-shadow: 
 		inset rgba(0, 0, 0, 0.2) 0 1px 1px,
 		inset rgba(255, 255, 255, 1) 0 3px 1px,
 		inset rgba(255, 255, 255, 0.3) 0 16px 0px,
 		inset rgba(0, 0, 0, 0.2) 0 -1px 1px,
 		inset rgba(0, 0, 0, 0.1) 0 -2px 1px, 
 		rgba(255, 255, 255, 1) 0 1px,
 		rgba(133, 153, 166, 0.3) 0px 1px 8.5px;
@@ -128,17 +126,16 @@ body {
 }
 
 .home_button {
 	font-size: 16px;
 	padding: 8px 12px;
 	width: 240px;
 	color: rgba(0, 0, 0, 0.8);
 	border-radius: 0.5em;
-	-webkit-border-radius: 0.5em;
 	box-shadow: 
 		inset rgba(0, 0, 0, 0.2) 0 1px 1px,
 		inset rgba(255, 255, 255, 1) 0 3px 1px,
 		inset rgba(255, 255, 255, 0.3) 0 16px 0px,
 		inset rgba(0, 0, 0, 0.2) 0 -1px 1px,
 		inset rgba(0, 0, 0, 0.1) 0 -2px 1px, 
 		rgba(255, 255, 255, 1) 0 1px,
 		rgba(133, 153, 166, 0.3) 0px 1px 8.5px;
@@ -147,17 +144,16 @@ body {
 }
 
 .callout {
 	font-size: 16px;
 	padding: 8px 24px;
 	margin: 24px auto;
 	color: rgba(0, 0, 0, 0.8);
 	border-radius: 0.5em;
-	-webkit-border-radius: 0.5em;
 	background: rgba(220, 240, 247, 0.8) url('chrome://testpilot/skin/images/callout.png') no-repeat top center;
 	box-shadow: 
 		inset rgba(185, 221, 234, 0.2) 0 -10px 8.5px,
 		inset rgba(185, 221, 234, 1) 0 0px 1px,
 		inset rgba(255, 255, 255, 0.2) 0 10px 8.5px;
 	/* display: inline; */
 }
 
@@ -169,34 +165,32 @@ body {
 .home_callout {
 	font-size: 16px;
 	vertical-align: middle;
  	/* width: 280px;*/
 	padding: 8px 24px;
 	margin: 8px auto;
 	color: rgba(0, 0, 0, 0.8);
 	border-radius: 0.5em;
-	-webkit-border-radius: 0.5em;
 	background: rgba(220, 240, 247, 0.8) url('chrome://testpilot/skin/images/callout.png') no-repeat top center;
 	box-shadow: 
 		inset rgba(185, 221, 234, 0.2) 0 -10px 8.5px,
 		inset rgba(185, 221, 234, 1) 0 0px 1px,
 		inset rgba(255, 255, 255, 0.2) 0 10px 8.5px;
 	/* display: inline; */
 }
 
 .home_callout_continue {
 	font-size: 16px;
 	vertical-align: middle;
 	width: 280px;
 	padding: 8px 24px;
 	margin: 8px auto;
 	color: rgba(0, 0, 0, 0.8);
 	border-radius: 0.5em;
-	-webkit-border-radius: 0.5em;
 	background: rgba(220, 240, 247, 0.8) url('chrome://testpilot/skin/images/callout_continue.png') no-repeat top center;
 	box-shadow: 
 		inset rgba(185, 221, 234, 0.2) 0 -10px 8.5px,
 		inset rgba(185, 221, 234, 1) 0 0px 1px,
 		inset rgba(255, 255, 255, 0.2) 0 10px 8.5px;
 	/* display: inline; */
 }
 
@@ -233,17 +227,16 @@ body {
 
 #menu {
 	margin: 20px auto;
 	max-width: 800px;
 	padding: 4px 40px;
 	width: 800px;
 	text-align: left;
 	border-radius: 0.25em;
-	-webkit-border-radius: 0.25em;
 	border-top: 1px solid #adb6ba;
 	border-left: 1px solid #adb6ba;
 	border-right: 1px solid #adb6ba;
 	border-bottom: 3px solid #adb6ba;
 	-moz-border-bottom-colors:#adb6ba #e7eaec #e7eaec;
 	background-color: #fff;
 } 
 
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -4038,17 +4038,19 @@ var FullScreen = {
     this.showWarning(true);
 
     // Exit DOM full-screen mode upon open, close, or change tab.
     gBrowser.tabContainer.addEventListener("TabOpen", this.exitDomFullScreen);
     gBrowser.tabContainer.addEventListener("TabClose", this.exitDomFullScreen);
     gBrowser.tabContainer.addEventListener("TabSelect", this.exitDomFullScreen);
 
     // Exit DOM full-screen mode when the browser window loses focus (ALT+TAB, etc).
-    window.addEventListener("deactivate", this.exitDomFullScreen, true);
+    if (gPrefService.getBoolPref("full-screen-api.exit-on-deactivate")) {
+      window.addEventListener("deactivate", this.exitDomFullScreen, true);
+    }
 
     // Cancel any "hide the toolbar" animation which is in progress, and make
     // the toolbar hide immediately.
     this._cancelAnimation();
     this.mouseoverToggle(false);
 
     // If there's a full-screen toggler, remove its listeners, so that mouseover
     // the top of the screen will not cause the toolbar to re-appear.
--- a/browser/base/content/test/browser_homeDrop.js
+++ b/browser/base/content/test/browser_homeDrop.js
@@ -21,44 +21,51 @@ function test() {
 
   let dialogListener = new WindowListener("chrome://global/content/commonDialog.xul", function (domwindow) {
     ok(true, "dialog appeared in response to home button drop");
     domwindow.document.documentElement.cancelDialog();
     Services.wm.removeListener(dialogListener);
 
     // Now trigger the invalid URI test
     executeSoon(function () {
-      info("Dialog closed? " + domwindow.closed + "\n");
       let consoleListener = {
         observe: function (m) {
-          info("m: " + m + "\n");
           info("m.message: " + m.message + "\n");
           if (m.message.indexOf("NS_ERROR_DOM_BAD_URI") > -1) {
             ok(true, "drop was blocked");
             executeSoon(finish);
           }
         }
       }
       Services.console.registerListener(consoleListener);
       registerCleanupFunction(function () {
         Services.console.unregisterListener(consoleListener);
       });
 
-      // The drop handler throws an exception when dragging URIs that inherit
-      // principal, e.g. javascript:
-      expectUncaughtException();
-      let originalHandler = homeButtonObserver.onDrop;
-      homeButtonObserver.onDrop = function (aEvent) {
-        info("homeButtonObserver.onDrop called");
-        originalHandler(aEvent);
-      };
-      registerCleanupFunction(function () {
-        homeButtonObserver.onDrop = originalHandler;
+      executeSoon(function () {
+        info("Attempting second drop, of a javascript: URI");
+        // The drop handler throws an exception when dragging URIs that inherit
+        // principal, e.g. javascript:
+        expectUncaughtException();
+        let originalHandler = homeButtonObserver.onDrop;
+        homeButtonObserver.onDrop = function (aEvent) {
+          info("homeButtonObserver.onDrop called");
+          try {
+            originalHandler(aEvent);
+          } catch (ex) {
+            info("originalHandler threw an exception: " + ex);
+            throw ex;
+          }
+        };
+        registerCleanupFunction(function () {
+          homeButtonObserver.onDrop = originalHandler;
+        });
+        chromeUtils.synthesizeDrop(homeButton, homeButton, [[{type: "text/plain", data: "javascript:8888"}]], "copy", window, EventUtils);
+        info("Triggered the second drop of a javascript: URI");
       });
-      chromeUtils.synthesizeDrop(homeButton, homeButton, [[{type: "text/plain", data: "javascript:8888"}]], "copy", window, EventUtils);
     })
   });
 
   Services.wm.addListener(dialogListener);
 
   chromeUtils.synthesizeDrop(homeButton, homeButton, [[{type: "text/plain", data: "http://mochi.test:8888/"}]], "copy", window, EventUtils);
 }
 
--- a/browser/components/shell/src/nsWindowsShellService.cpp
+++ b/browser/components/shell/src/nsWindowsShellService.cpp
@@ -331,17 +331,16 @@ nsWindowsShellService::ShortcutMaintenan
   appHelperPath.AppendLiteral(" /UpdateShortcutAppUserModelIds");
 
   return LaunchHelper(appHelperPath);
 }
 
 bool
 nsWindowsShellService::IsDefaultBrowserVista(bool* aIsDefaultBrowser)
 {
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   IApplicationAssociationRegistration* pAAR;
   
   HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
                                 NULL,
                                 CLSCTX_INPROC,
                                 IID_IApplicationAssociationRegistration,
                                 (void**)&pAAR);
 
@@ -350,17 +349,16 @@ nsWindowsShellService::IsDefaultBrowserV
     hr = pAAR->QueryAppIsDefaultAll(AL_EFFECTIVE,
                                     APP_REG_NAME,
                                     &res);
     *aIsDefaultBrowser = res;
 
     pAAR->Release();
     return true;
   }
-#endif  
   return false;
 }
 
 NS_IMETHODIMP
 nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
                                         bool* aIsDefaultBrowser)
 {
   // If this is the first browser window, maintain internal state that we've
--- a/browser/themes/gnomestripe/devtools/csshtmltree.css
+++ b/browser/themes/gnomestripe/devtools/csshtmltree.css
@@ -277,10 +277,10 @@
 
 .ruleview-overridden {
   text-decoration: line-through;
 }
 
 .styleinspector-propertyeditor {
   border: 1px solid #CCC;
   padding: 0;
-  -moz-box-shadow: 2px 2px 2px #CCC;
+  box-shadow: 2px 2px 2px #CCC;
 }
--- a/browser/themes/pinstripe/devtools/csshtmltree.css
+++ b/browser/themes/pinstripe/devtools/csshtmltree.css
@@ -279,10 +279,10 @@
 
 .ruleview-overridden {
   text-decoration: line-through;
 }
 
 .styleinspector-propertyeditor {
   border: 1px solid #CCC;
   padding: 0;
-  -moz-box-shadow: 2px 2px 2px #CCC;
+  box-shadow: 2px 2px 2px #CCC;
 }
--- a/browser/themes/winstripe/devtools/csshtmltree.css
+++ b/browser/themes/winstripe/devtools/csshtmltree.css
@@ -277,10 +277,10 @@
 
 .ruleview-overridden {
   text-decoration: line-through;
 }
 
 .styleinspector-propertyeditor {
   border: 1px solid #CCC;
   padding: 0;
-  -moz-box-shadow: 2px 2px 2px #CCC;
+  box-shadow: 2px 2px 2px #CCC;
 }
--- a/configure.in
+++ b/configure.in
@@ -974,18 +974,16 @@ EOF
         AC_MSG_RESULT("yes")
     else
         AC_MSG_RESULT("no")
         AC_MSG_ERROR([You are targeting Windows version 0x$MOZ_WINSDK_TARGETVER, but your SDK only supports up to version $MOZ_WINSDK_MAXVER. Install and use an updated SDK, or target a lower version using --with-windows-version. Alternatively, try running the Windows SDK Configuration Tool and selecting a newer SDK. See https://developer.mozilla.org/En/Windows_SDK_versions for more details on fixing this.])
     fi
 
     AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
     # Definitions matching sdkddkver.h
-    AC_DEFINE_UNQUOTED(MOZ_NTDDI_WS03, 0x05020000)
-    AC_DEFINE_UNQUOTED(MOZ_NTDDI_LONGHORN, 0x06000000)
     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
     ;;
 esac
 
 AC_PROG_CPP
 AC_PROG_CXXCPP
 
 if test -n "$_WIN32_MSVC"; then
--- a/content/base/test/test_DOMException.html
+++ b/content/base/test/test_DOMException.html
@@ -25,23 +25,23 @@ var constants = [
   "INUSE_ATTRIBUTE_ERR",
   "INVALID_STATE_ERR",
   "SYNTAX_ERR",
   "INVALID_MODIFICATION_ERR",
   "NAMESPACE_ERR",
   "INVALID_ACCESS_ERR",
   "VALIDATION_ERR",
   "TYPE_MISMATCH_ERR",
-  null,
-  null,
-  null,
-  null,
-  null,
-  null,
-  null,
+  "SECURITY_ERR",
+  "NETWORK_ERR",
+  "ABORT_ERR",
+  "URL_MISMATCH_ERR",
+  "QUOTA_EXCEEDED_ERR",
+  "TIMEOUT_ERR",
+  "INVALID_NODE_TYPE_ERR",
   "DATA_CLONE_ERR"
 ];
 for (var i = 0; i < constants.length; ++i) {
   var constant = constants[i];
   if (constant)
     is(DOMException[constant], i, constant)
 }
 </script>
--- a/content/canvas/test/crossorigin/test_canvas2d_crossorigin.html
+++ b/content/canvas/test/crossorigin/test_canvas2d_crossorigin.html
@@ -16,17 +16,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 685518 **/
 
 SimpleTest.waitForExplicitFinish();
 
-const SECURITY_ERR = 0x805303e8;
+const SECURITY_ERR = 0x80530012;
 const BAD_URI_ERR = 0x805303f4;
 const OK = 0;
 
 function nameForErrorCode(code) {
   switch(code) {
     case OK: return "no error";
     case SECURITY_ERR: return "security error";
     case BAD_URI_ERR: return "bad URI error"
--- a/content/canvas/test/crossorigin/test_video_crossorigin.html
+++ b/content/canvas/test/crossorigin/test_video_crossorigin.html
@@ -16,17 +16,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 682299 **/
 
 const MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
-const SECURITY_ERR = 0x805303e8;
+const SECURITY_ERR = 0x80530012;
 
 function createCanvas(width, height) {
   var c = document.createElement("canvas");
   c.width = width;
   c.height = height;
   return c;
 }
 
--- a/content/canvas/test/crossorigin/test_webgl_crossorigin_textures.html
+++ b/content/canvas/test/crossorigin/test_webgl_crossorigin_textures.html
@@ -6,17 +6,17 @@
 <body>
 <canvas id="canvas" style="border: none;" width="100" height="100">
   <p class="fallback"> FAIL (fallback content) </p>
 </canvas>
 <script>
 
   SimpleTest.waitForExplicitFinish();
 
-  const SECURITY_ERR = 0x805303e8;
+  const SECURITY_ERR = 0x80530012;
   const OK = 0;
 
   var gl;
   var number_of_tests_live = 0;
   var all_tests_started = false;
 
   function nameForErrorCode(code) {
     switch(code) {
--- a/content/canvas/test/test_canvas.html
+++ b/content/canvas/test/test_canvas.html
@@ -19697,26 +19697,26 @@ function test_bug397524() {
   // Should be able to get the data out of the first canvas
   $("canvas1").toDataURL("image/png");
 
   // Should not be able to get the data out of a cross-site load
   var gotData = false;  
   try {
     $("canvas2").toDataURL("image/png");
     gotData = true;
-  } catch (ex if (ex.code == 1000 && ex.name == "NS_ERROR_DOM_SECURITY_ERR")) {
+  } catch (ex if (ex.code == 18 && ex.name == "SecurityError")) {
   }
   is(gotData, false, "Shouldn't be able to read images cross-site!");
 
   // Should not be able to get the data out of a redirected cross-site load
   var gotData = false;  
   try {
     $("canvas3").toDataURL("image/png");
     gotData = true;
-  } catch (ex if (ex.code == 1000 && ex.name == "NS_ERROR_DOM_SECURITY_ERR")) {
+  } catch (ex if (ex.code == 18 && ex.name == "SecurityError")) {
   }
   is(gotData, false, "Shouldn't be able to read images redirected cross-site!");
 
 }
 
 </script>
 </pre>
 
--- a/content/events/test/test_bug415498.xul
+++ b/content/events/test/test_bug415498.xul
@@ -73,26 +73,26 @@ https://bugzilla.mozilla.org/show_bug.cg
         setTimeout(nextTest, 0)
       }, false);
 
       // 1) This document uses addEventListener to register a method throwing an exception
       var chromeDir = getRootDirectory(window.location.href);
       browser.loadURI(chromeDir + "bug415498-doc1.html");
       yield;
 
-      ok(verifyErrorReceived("NS_ERROR_DOM_HIERARCHY_REQUEST_ERR"),
+      ok(verifyErrorReceived("HierarchyRequestError"),
          "Error message not reported in event listener callback!");
       gMessages = [];
 
       // 2) This document sets window.onload to register a method throwing an exception
       var chromeDir = getRootDirectory(window.location.href);
       browser.loadURI(chromeDir + "bug415498-doc2.html");
       yield;
 
-      ok(verifyErrorReceived("NS_ERROR_DOM_HIERARCHY_REQUEST_ERR"),
+      ok(verifyErrorReceived("HierarchyRequestError"),
          "Error message not reported in window.onload!");
     }
     
     function verifyErrorReceived(errorString) {
       for (var i = 0; i < gMessages.length; i++) {
         if (gMessages[i].message.indexOf(errorString) != -1)
           return true;
       }
--- a/content/events/test/test_dragstart.html
+++ b/content/events/test/test_dragstart.html
@@ -33,27 +33,27 @@ function afterDragTests()
 {
   // the dragstart should have occurred due to moving the mouse. gDataTransfer
   // caches the dataTransfer that was used, however it should now be empty and
   // be read only.
   ok(gDataTransfer instanceof DataTransfer, "DataTransfer after dragstart event");
   checkTypes(gDataTransfer, [], 0, "after dragstart event");
 
   expectError(function() gDataTransfer.setData("text/plain", "Some Text"),
-              "NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR", "setData when read only");
+              "NoModificationAllowedError", "setData when read only");
   expectError(function() gDataTransfer.clearData("text/plain"),
-              "NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR", "clearData when read only");
+              "NoModificationAllowedError", "clearData when read only");
   expectError(function() gDataTransfer.mozSetDataAt("text/plain", "Some Text", 0),
-              "NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR", "setDataAt when read only");
+              "NoModificationAllowedError", "setDataAt when read only");
   expectError(function() gDataTransfer.mozClearDataAt("text/plain", 0),
-              "NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR", "clearDataAt when read only");
+              "NoModificationAllowedError", "clearDataAt when read only");
   expectError(function() gDataTransfer.setDragImage(draggable, 10, 10),
-              "NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR", "setDragImage when read only");
+              "NoModificationAllowedError", "setDragImage when read only");
   expectError(function() gDataTransfer.addElement(draggable),
-              "NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR", "addElement when read only");
+              "NoModificationAllowedError", "addElement when read only");
 
   var evt = document.createEvent("dragevent");
   ok(evt instanceof DragEvent, "synthetic dragevent class")
   ok(evt instanceof MouseEvent, "synthetic event inherits from MouseEvent")
   evt.initDragEvent("dragstart", true, true, window, 1, 40, 35, 20, 15,
                     false, true, false, false, 0, null, null);
   $("synthetic").dispatchEvent(evt);
 
@@ -149,17 +149,17 @@ function test_DataTransfer(dt)
 
   var types = dt.types;
   is(types instanceof DOMStringList, true, "empty types is a DOMStringList");
   checkTypes(dt, [], 0, "empty");
   is(dt.getData("text/plain"), "", "empty data is empty");
 
   // calling setDataAt requires an index that is 0 <= index <= dt.itemCount
   expectError(function() dt.mozSetDataAt("text/plain", "Some Text", 1),
-              "NS_ERROR_DOM_INDEX_SIZE_ERR", "setDataAt index too high");
+              "IndexSizeError", "setDataAt index too high");
 
   is(dt.mozUserCancelled, false, "userCancelled");
 
   // because an exception occurred, the data should not have been added
   is(dt.mozItemCount, 0, "empty setDataAt index too high itemCount");
   dt.getData("text/plain", "", "empty setDataAt index too high getData");
 
   // if the type is '', do nothing, or return ''
@@ -167,19 +167,19 @@ function test_DataTransfer(dt)
   is(dt.types.length, 0, "invalid type setData");
   is(dt.getData(""), "", "invalid type getData"),
   dt.mozSetDataAt("", "Invalid Type", 0);
   is(dt.types.length, 0, "invalid type setDataAt");
   is(dt.mozGetDataAt("", 0), null, "invalid type getDataAt"),
 
   // similar with clearDataAt and getDataAt
   expectError(function() dt.mozGetDataAt("text/plain", 1),
-              "NS_ERROR_DOM_INDEX_SIZE_ERR", "getDataAt index too high");
+              "IndexSizeError", "getDataAt index too high");
   expectError(function() dt.mozClearDataAt("text/plain", 1),
-              "NS_ERROR_DOM_INDEX_SIZE_ERR", "clearDataAt index too high");
+              "IndexSizeError", "clearDataAt index too high");
 
   dt.setData("text/plain", "Sample Text");
   is(dt.mozItemCount, 1, "added plaintext itemCount");
   checkOneDataItem(dt, ["text/plain"], ["Sample Text"], 0, "added plaintext");
 
    // after all those exceptions, the data should still be the same
   checkOneDataItem(dt, ["text/plain"], ["Sample Text"], 0, "added plaintext after exception");
 
@@ -280,17 +280,17 @@ function test_DataTransfer(dt)
            "#http://www.mozilla.org\n#Sample\nhttp://www.xulplanet.com  \r\n",
            0, "uri-list mix setDataAt");
 
   // now test adding multiple items to be dragged using the setDataAt method
   dt.clearData();
   dt.mozSetDataAt("text/plain", "First Item", 0);
   dt.mozSetDataAt("text/plain", "Second Item", 1);
   expectError(function() dt.mozSetDataAt("text/plain", "Some Text", 3),
-              "NS_ERROR_DOM_INDEX_SIZE_ERR", "setDataAt index too high with two items");
+              "IndexSizeError", "setDataAt index too high with two items");
   is(dt.mozItemCount, 2, "setDataAt item itemCount");
   checkOneDataItem(dt, ["text/plain"], ["First Item"], 0, "setDataAt item at index 0");
   checkOneDataItem(dt, ["text/plain"], ["Second Item"], 1, "setDataAt item at index 1");
 
   dt.mozSetDataAt("text/html", "<em>First Item</em>", 0);
   dt.mozSetDataAt("text/html", "<em>Second Item</em>", 1);
   is(dt.mozItemCount, 2, "setDataAt two types item itemCount");
   checkOneDataItem(dt, ["text/plain", "text/html"],
@@ -324,17 +324,17 @@ function test_DataTransfer(dt)
   checkOneDataItem(dt, ["text/plain"], ["Changed Second Item"], 1, "clearDataAt item at index 1");
 
   dt.mozClearDataAt("text/plain", 1);
   is(dt.mozItemCount, 2, "clearDataAt last type itemCount");
   checkOneDataItem(dt, ["text/plain", "text/html"],
                    ["First Item", "Changed with setData"], 0, "clearDataAt last type at index 0");
   checkOneDataItem(dt, ["application/-moz-node"], [draggable], 1, "clearDataAt last type item at index 2");
   expectError(function() dt.mozGetDataAt("text/plain", 2),
-              "NS_ERROR_DOM_INDEX_SIZE_ERR", "getDataAt after item removed index too high");
+              "IndexSizeError", "getDataAt after item removed index too high");
 
   dt.mozSetDataAt("text/unknown", "Unknown type", 2);
   dt.mozSetDataAt("text/unknown", "Unknown type", 1);
   is(dt.mozItemCount, 3, "add unknown type");
   checkOneDataItem(dt, ["application/-moz-node", "text/unknown"],
                    [draggable, "Unknown type"], 1, "add unknown type item at index 1");
   checkOneDataItem(dt, ["text/unknown"], ["Unknown type"], 2, "add unknown type item at index 2");
 
@@ -351,17 +351,17 @@ function test_DataTransfer(dt)
   dt.mozClearDataAt("text/something", 1);
   is(dt.mozItemCount, 2, "clearData type that does not exist");
   checkOneDataItem(dt, ["text/plain", "text/html"],
                    ["First Item", "Changed with setData"], 0, "clearData type that does not exist item at index 0");
   checkOneDataItem(dt, ["text/unknown"],
                    ["Unknown type"], 1, "clearData type that does not exist item at index 1");
 
   expectError(function() dt.mozClearDataAt("text/plain", 3),
-              "NS_ERROR_DOM_INDEX_SIZE_ERR", "clearData index too high with two items");
+              "IndexSizeError", "clearData index too high with two items");
 
   // ensure that clearData() removes all data associated with the first item
   dt.clearData();
   is(dt.mozItemCount, 1, "clearData no argument with multiple items itemCount");
   checkOneDataItem(dt, ["text/unknown"],
                    ["Unknown type"], 0, "clearData no argument with multiple items item at index 1");
 
   // remove tha remaining data
--- a/content/media/test/test_volume.html
+++ b/content/media/test/test_volume.html
@@ -11,17 +11,17 @@
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 function test(element, value, shouldThrow) {
   var threw = false;
   try {
     element.volume = value;
-  } catch (err if err.name == "NS_ERROR_DOM_INDEX_SIZE_ERR") {
+  } catch (err if err.name == "IndexSizeError") {
     threw = true;
   }
   is(shouldThrow, threw, "Case: " +element.id+ " setVolume=" + value);
 }
 
 
 var ids = new Array(document.getElementById('v1'), document.getElementById('a1'));
 
--- a/content/test/unit/test_range.js
+++ b/content/test/unit/test_range.js
@@ -38,17 +38,17 @@ const C_i = Components.interfaces;
 const C_r = Components.results;
 
 const UNORDERED_TYPE = C_i.nsIDOMXPathResult.ANY_UNORDERED_NODE_TYPE;
 
 const INVALID_STATE_ERR = 0x8053000b;     // NS_ERROR_DOM_INVALID_STATE_ERR
 const INDEX_SIZE_ERR = 0x80530001;        // NS_ERROR_DOM_INDEX_SIZE_ERR
 const INVALID_NODE_TYPE_ERR = 0x805c0002; // NS_ERROR_DOM_INVALID_NODE_TYPE_ERR
 const NOT_OBJECT_ERR = 0x805303eb;        // NS_ERROR_DOM_NOT_OBJECT_ERR
-const SECURITY_ERR = 0x805303e8;          // NS_ERROR_DOM_SECURITY_ERR
+const SECURITY_ERR = 0x80530012;          // NS_ERROR_DOM_SECURITY_ERR
 
 /**
  * Determine if the data node has only ignorable white-space.
  *
  * @return nsIDOMNodeFilter.FILTER_SKIP if it does.
  * @return nsIDOMNodeFilter.FILTER_ACCEPT otherwise.
  */
 function isWhitespace(aNode) {
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -8322,56 +8322,50 @@ nsDocShell::InternalLoad(nsIURI * aURI,
                                            curBeforeHash, curHash) :
             NS_ERROR_FAILURE;
         splitRv2 = nsContentUtils::SplitURIAtHash(aURI, newBeforeHash, newHash);
 
         bool sameExceptHashes = NS_SUCCEEDED(splitRv1) &&
                                   NS_SUCCEEDED(splitRv2) &&
                                   curBeforeHash.Equals(newBeforeHash);
 
-        // XXX rename
-        bool sameDocument = false;
+        bool historyNavBetweenSameDoc = false;
         if (mOSHE && aSHEntry) {
             // We're doing a history load.
 
-            mOSHE->SharesDocumentWith(aSHEntry, &sameDocument);
+            mOSHE->SharesDocumentWith(aSHEntry, &historyNavBetweenSameDoc);
 
 #ifdef DEBUG
-            if (sameDocument) {
+            if (historyNavBetweenSameDoc) {
                 nsCOMPtr<nsIInputStream> currentPostData;
                 mOSHE->GetPostData(getter_AddRefs(currentPostData));
                 NS_ASSERTION(currentPostData == aPostData,
                              "Different POST data for entries for the same page?");
             }
 #endif
         }
 
         // A short-circuited load happens when we navigate between two SHEntries
         // for the same document.  We do a short-circuited load under two
         // circumstances.  Either
         //
-        //  a) we're navigating between two different SHEntries which have the
-        //     same document identifiers, or
+        //  a) we're navigating between two different SHEntries which share a
+        //     document, or
         //
         //  b) we're navigating to a new shentry whose URI differs from the
         //     current URI only in its hash, the new hash is non-empty, and
         //     we're not doing a POST.
         //
         // The restriction tha the SHEntries in (a) must be different ensures
         // that history.go(0) and the like trigger full refreshes, rather than
         // short-circuited loads.
-        bool doShortCircuitedLoad = (sameDocument && mOSHE != aSHEntry) ||
-                                      (!aSHEntry && aPostData == nsnull &&
-                                       sameExceptHashes && !newHash.IsEmpty());
-
-        // Fire a hashchange event if we're doing a short-circuited load and the
-        // URIs differ only in their hashes.
-        bool doHashchange = doShortCircuitedLoad &&
-                              sameExceptHashes &&
-                              !curHash.Equals(newHash);
+        bool doShortCircuitedLoad =
+          (historyNavBetweenSameDoc && mOSHE != aSHEntry) ||
+          (!aSHEntry && aPostData == nsnull &&
+           sameExceptHashes && !newHash.IsEmpty());
 
         if (doShortCircuitedLoad) {
             // Save the current URI; we need it if we fire a hashchange later.
             nsCOMPtr<nsIURI> oldURI = mCurrentURI;
 
             // Save the position of the scrollers.
             nscoord cx = 0, cy = 0;
             GetCurScrollPos(ScrollOrientation_X, &cx);
@@ -8491,37 +8485,31 @@ nsDocShell::InternalLoad(nsIURI * aURI,
                 if (history) {
                     history->SetURITitle(aURI, mTitle);
                 }
                 else if (mGlobalHistory) {
                     mGlobalHistory->SetPageTitle(aURI, mTitle);
                 }
             }
 
-            if (sameDocument) {
-                // Set the doc's URI according to the new history entry's URI
-                nsCOMPtr<nsIURI> newURI;
-                mOSHE->GetURI(getter_AddRefs(newURI));
-                NS_ENSURE_TRUE(newURI, NS_ERROR_FAILURE);
-                nsCOMPtr<nsIDocument> doc =
-                  do_GetInterface(GetAsSupports(this));
-                NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
-
-                doc->SetDocumentURI(newURI);
-            }
+            // Set the doc's URI according to the new history entry's URI.
+            nsCOMPtr<nsIDocument> doc =
+              do_GetInterface(GetAsSupports(this));
+            NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
+            doc->SetDocumentURI(aURI);
 
             SetDocCurrentStateObj(mOSHE);
 
             // Dispatch the popstate and hashchange events, as appropriate.
             nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mScriptGlobal);
             if (window) {
-                // Need the doHashchange check here since sameDocument is
-                // false if we're navigating to a new shentry (i.e. a aSHEntry
-                // is null), such as when clicking a <a href="#foo">.
-                if (sameDocument || doHashchange) {
+                // Fire a hashchange event URIs differ, and only in their hashes.
+                bool doHashchange = sameExceptHashes && !curHash.Equals(newHash);
+
+                if (historyNavBetweenSameDoc || doHashchange) {
                   window->DispatchSyncPopState();
                 }
 
                 if (doHashchange) {
                   // Make sure to use oldURI here, not mCurrentURI, because by
                   // now, mCurrentURI has changed!
                   window->DispatchAsyncHashchange(oldURI, aURI);
                 }
--- a/docshell/test/Makefile.in
+++ b/docshell/test/Makefile.in
@@ -121,16 +121,18 @@ include $(topsrcdir)/config/rules.mk
 		test_bug675587.html \
 		test_bfcache_plus_hash.html \
 		test_bug680257.html \
 		file_bug680257.html \
 		test_bug691547.html \
 		bug691547_frame.html \
 		test_bug694612.html \
 		test_bug713825.html \
+		test_bug728939.html \
+		file_bug728939.html \
 		$(NULL)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 _TEST_FILES += \
 		test_bug511449.html \
 		file_bug511449.html \
 		$(NULL)
 endif
new file mode 100644
--- /dev/null
+++ b/docshell/test/file_bug728939.html
@@ -0,0 +1,3 @@
+<html>
+<body onload="opener.popupLoaded()">file_bug728939</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/docshell/test/test_bug728939.html
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=728939
+-->
+<head>
+  <title>Test for Bug 728939</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=728939">Mozilla Bug 728939</a>
+
+<script type="application/javascript;version=1.7">
+
+SimpleTest.waitForExplicitFinish();
+
+// Called when the popup finishes loading.
+function popupLoaded() {
+  popup.location.hash = '#foo';
+  is(popup.document.URL, popup.location.href, 'After hashchange.');
+
+  popup.history.pushState('', '', 'bar');
+  is(popup.document.URL, popup.location.href, 'After pushState.');
+
+  popup.history.replaceState('', '', 'baz');
+  is(popup.document.URL, popup.location.href, 'After replaceState.');
+
+  popup.close();
+  SimpleTest.finish();
+}
+
+var popup = window.open('file_bug728939.html');
+
+</script>
+</body>
+</html>
--- a/dom/base/domerr.msg
+++ b/dom/base/domerr.msg
@@ -33,62 +33,60 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* Error Message definitions. */
 
 
-/* DOM error codes from http://www.w3.org/TR/REC-DOM-Level-1/ */
+/* DOM error codes from http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#domexception */
 
-DOM_MSG_DEF(NS_ERROR_DOM_INDEX_SIZE_ERR, "Index or size is negative or greater than the allowed amount")
-DOM_MSG_DEF(NS_ERROR_DOM_DOMSTRING_SIZE_ERR, "The specified range of text does not fit in a DOM string")
-DOM_MSG_DEF(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR, "Node cannot be inserted at the specified point in the hierarchy")
-DOM_MSG_DEF(NS_ERROR_DOM_WRONG_DOCUMENT_ERR, "Node cannot be used in a document other than the one in which it was created")
-DOM_MSG_DEF(NS_ERROR_DOM_INVALID_CHARACTER_ERR, "String contains an invalid character")
-DOM_MSG_DEF(NS_ERROR_DOM_NO_DATA_ALLOWED_ERR, "Node does not contain data")
-DOM_MSG_DEF(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR, "Modifications are not allowed for this document")
-DOM_MSG_DEF(NS_ERROR_DOM_NOT_FOUND_ERR, "Node was not found")
-DOM_MSG_DEF(NS_ERROR_DOM_NOT_SUPPORTED_ERR, "Operation is not supported")
-DOM_MSG_DEF(NS_ERROR_DOM_INUSE_ATTRIBUTE_ERR, "Attribute already in use")
-
-/* DOM error codes from http://www.w3.org/TR/DOM-Level-2/ */
-
-DOM_MSG_DEF(NS_ERROR_DOM_INVALID_ACCESS_ERR, "A parameter or an operation is not supported by the underlying object")
-DOM_MSG_DEF(NS_ERROR_DOM_INVALID_MODIFICATION_ERR, "An attempt was made to modify the type of the underlying objec")
-DOM_MSG_DEF(NS_ERROR_DOM_INVALID_STATE_ERR, "An attempt was made to use an object that is not, or is no longer, usable")
-DOM_MSG_DEF(NS_ERROR_DOM_NAMESPACE_ERR, "An attempt was made to create or change an object in a way which is incorrect with regard to namespaces")
-DOM_MSG_DEF(NS_ERROR_DOM_SYNTAX_ERR, "An invalid or illegal string was specified")
+DOM_MSG_DEF_(INDEX_SIZE_ERR, "IndexSizeError", "Index or size is negative or greater than the allowed amount")
+DOM_MSG_DEF_(DOMSTRING_SIZE_ERR, "DOMStringSizeError", "The specified range of text does not fit in a DOM string")
+DOM_MSG_DEF_(HIERARCHY_REQUEST_ERR, "HierarchyRequestError", "Node cannot be inserted at the specified point in the hierarchy")
+DOM_MSG_DEF_(WRONG_DOCUMENT_ERR, "WrongDocumentError", "Node cannot be used in a document other than the one in which it was created")
+DOM_MSG_DEF_(INVALID_CHARACTER_ERR, "InvalidCharacterError", "String contains an invalid character")
+DOM_MSG_DEF_(NO_DATA_ALLOWED_ERR, "NoDataAllowedError", "Node does not contain data")
+DOM_MSG_DEF_(NO_MODIFICATION_ALLOWED_ERR, "NoModificationAllowedError", "Modifications are not allowed for this document")
+DOM_MSG_DEF_(NOT_FOUND_ERR, "NotFoundError", "Node was not found")
+DOM_MSG_DEF_(NOT_SUPPORTED_ERR, "NotSupportedError", "Operation is not supported")
+DOM_MSG_DEF_(INUSE_ATTRIBUTE_ERR, "InUseAttributeError", "Attribute already in use")
+DOM_MSG_DEF_(INVALID_STATE_ERR, "InvalidStateError", "An attempt was made to use an object that is not, or is no longer, usable")
+DOM_MSG_DEF_(SYNTAX_ERR, "SyntaxError", "An invalid or illegal string was specified")
+DOM_MSG_DEF_(INVALID_MODIFICATION_ERR, "InvalidModificationError", "An attempt was made to modify the type of the underlying objec")
+DOM_MSG_DEF_(NAMESPACE_ERR, "NamespaceError", "An attempt was made to create or change an object in a way which is incorrect with regard to namespaces")
+DOM_MSG_DEF_(INVALID_ACCESS_ERR, "InvalidAccessError", "A parameter or an operation is not supported by the underlying object")
+DOM_MSG_DEF_(VALIDATION_ERR, "ValidationError", "A call to a method would make the Node invalid with respect to \"partial validity\", so the operation was not done")
+DOM_MSG_DEF_(TYPE_MISMATCH_ERR, "TypeMismatchError", "The type of an object is incompatible with the expected type of the parameter associated to the object")
+DOM_MSG_DEF_(SECURITY_ERR, "SecurityError", "The operation is insecure.")
+DOM_MSG_DEF_(NETWORK_ERR, "NetworkError", "A network error occurred.")
+DOM_MSG_DEF_(ABORT_ERR, "AbortError", "The operation was aborted. ")
+DOM_MSG_DEF_(URL_MISMATCH_ERR, "URLMismatchError", "The given URL does not match another URL.")
+DOM_MSG_DEF_(QUOTA_EXCEEDED_ERR, "QuotaExceededError", "The quota has been exceeded.")
+DOM_MSG_DEF_(TIMEOUT_ERR, "TimeoutError", "The operation timed out.")
+DOM_MSG_DEF_(INVALID_NODE_TYPE_ERR, "InvalidNodeTypeError", "The supplied node is incorrect or has an incorrect ancestor for this operation.")
+DOM_MSG_DEF_(DATA_CLONE_ERR, "DataCloneError", "The object could not be cloned.")
 
 /* DOM error codes from http://www.w3.org/TR/DOM-Level-2/range.html */
 
 DOM_MSG_DEF(NS_ERROR_DOM_RANGE_BAD_BOUNDARYPOINTS_ERR, "The boundary-points of a range does not meet specific requirements.")
 DOM_MSG_DEF(NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR, "The container of an boundary-point of a range is being set to either a node of an invalid type or a node with an ancestor of an invalid type.")
 
-/* DOM error codes from http://www.w3.org/TR/DOM-Level-3/ */
-
-DOM_MSG_DEF(NS_ERROR_DOM_VALIDATION_ERR, "A call to a method would make the Node invalid with respect to \"partial validity\", so the operation was not done")
-DOM_MSG_DEF(NS_ERROR_DOM_TYPE_MISMATCH_ERR, "The type of an object is incompatible with the expected type of the parameter associated to the object")
-
 /* SVG DOM error codes from http://www.w3.org/TR/SVG11/svgdom.html */
 
 DOM_MSG_DEF(NS_ERROR_DOM_SVG_WRONG_TYPE_ERR, "Unknown or invalid type")
 DOM_MSG_DEF(NS_ERROR_DOM_SVG_INVALID_VALUE_ERR, "One of the parameters has an invalid value")
 DOM_MSG_DEF(NS_ERROR_DOM_SVG_MATRIX_NOT_INVERTABLE, "The matrix could not be computed")
 
 /* DOM error codes from http://www.w3.org/TR/DOM-Level-3-XPath/ */
 
 DOM_MSG_DEF(NS_ERROR_DOM_INVALID_EXPRESSION_ERR, "The expression is not a legal expression.")
 DOM_MSG_DEF(NS_ERROR_DOM_TYPE_ERR, "The expression cannot be converted to return the specified type.")
 
-/* HTML5 error codes http://dev.w3.org/html5/spec/Overview.html */
-
-DOM_MSG_DEF(NS_ERROR_DOM_DATA_CLONE_ERR, "The object could not be cloned.")
-
 /* IndexedDB error codes http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html */
 
 DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR, "The operation failed for reasons unrelated to the database itself and not covered by any other error code.")
 DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR, "This error occurred because an operation was not allowed on an object. A retry of the same operation would fail unless the cause of the error is corrected.")
 DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR, "The operation failed because the requested database object could not be found. For example, an object store did not exist but was being opened.")
 DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR, "A mutation operation in the transaction failed because a constraint was not satisfied. For example, an object such as an object store or index already exists and a new one was being attempted to be created.")
 DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_DATA_ERR, "Data provided to an operation does not meet requirements.")
 DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR, "A mutation operation was attempted on a database that did not allow mutations.")
@@ -100,17 +98,16 @@ DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_QUOTA
 DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_VERSION_ERR, "The operation failed because the stored database is a higher version than the version requested.")
 
 DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_RECOVERABLE_ERR, "The operation failed because the database was prevented from taking an action. The operation might be able to succeed if the application performs some recovery steps and retries the entire transaction. For example, there was not enough remaining storage space, or the storage quota was reached and the user declined to give more space to the database.")
 DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_DEADLOCK_ERR, "The current transaction was automatically rolled back by the database because of deadlock or other transaction serialization failures.")
 
 /* DOM error codes defined by us */
 
 /* XXX string should be specified by norris */
-DOM_MSG_DEF(NS_ERROR_DOM_SECURITY_ERR, "Security error")
 DOM_MSG_DEF(NS_ERROR_DOM_SECMAN_ERR, "Unable to obtain security manager")
 DOM_MSG_DEF(NS_ERROR_DOM_WRONG_TYPE_ERR, "Object is of wrong type")
 DOM_MSG_DEF(NS_ERROR_DOM_NOT_OBJECT_ERR, "Parameter is not an object")
 DOM_MSG_DEF(NS_ERROR_DOM_NOT_XPC_OBJECT_ERR, "Parameter is not a XPConnect object")
 DOM_MSG_DEF(NS_ERROR_DOM_NOT_NUMBER_ERR, "Parameter is not a number")
 DOM_MSG_DEF(NS_ERROR_DOM_NOT_BOOLEAN_ERR, "Parameter is not a boolean")
 DOM_MSG_DEF(NS_ERROR_DOM_NOT_FUNCTION_ERR, "Parameter is not a Function")
 DOM_MSG_DEF(NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR, "Too few parameters to method")
--- a/dom/base/nsDOMError.h
+++ b/dom/base/nsDOMError.h
@@ -57,25 +57,24 @@
 #define NS_ERROR_DOM_INUSE_ATTRIBUTE_ERR         NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,10)
 #define NS_ERROR_DOM_INVALID_STATE_ERR           NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,11)
 #define NS_ERROR_DOM_SYNTAX_ERR                  NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,12)
 #define NS_ERROR_DOM_INVALID_MODIFICATION_ERR    NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,13)
 #define NS_ERROR_DOM_NAMESPACE_ERR               NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,14)
 #define NS_ERROR_DOM_INVALID_ACCESS_ERR          NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,15)
 #define NS_ERROR_DOM_VALIDATION_ERR              NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,16)
 #define NS_ERROR_DOM_TYPE_MISMATCH_ERR           NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,17)
-/* 18: SECURITY_ERR */
-/* 19: NETWORK_ERR */
-/* 20: ABORT_ERR */
-/* 21: URL_MISMATCH_ERR */
-/* 22: QUOTA_EXCEEDED_ERR */
-/* 23: TIMEOUT_ERR */
-/* 24: NOT_READABLE_ERR */
+#define NS_ERROR_DOM_SECURITY_ERR                NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,18)
+#define NS_ERROR_DOM_NETWORK_ERR                 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,19)
+#define NS_ERROR_DOM_ABORT_ERR                   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,20)
+#define NS_ERROR_DOM_URL_MISMATCH_ERR            NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,21)
+#define NS_ERROR_DOM_QUOTA_EXCEEDED_ERR          NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,22)
+#define NS_ERROR_DOM_TIMEOUT_ERR                 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,23)
+#define NS_ERROR_DOM_INVALID_NODE_TYPE_ERR       NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,24)
 #define NS_ERROR_DOM_DATA_CLONE_ERR              NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,25)
-/* 26: ENCODING_ERR */
 
 /* DOM error codes from http://www.w3.org/TR/DOM-Level-2/range.html */
 
 #define NS_ERROR_DOM_RANGE_BAD_BOUNDARYPOINTS_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_RANGE, 1)
 #define NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR  NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_RANGE, 2)
 
 /* SVG DOM error codes from http://www.w3.org/TR/SVG11/svgdom.html */
 
@@ -104,17 +103,16 @@
 #define NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR         NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,11)
 #define NS_ERROR_DOM_INDEXEDDB_VERSION_ERR       NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,12)
 
 #define NS_ERROR_DOM_INDEXEDDB_RECOVERABLE_ERR   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,1001)
 #define NS_ERROR_DOM_INDEXEDDB_DEADLOCK_ERR   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,1002)
 
 /* DOM error codes defined by us */
 
-#define NS_ERROR_DOM_SECURITY_ERR                NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1000)
 #define NS_ERROR_DOM_SECMAN_ERR                  NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1001)
 #define NS_ERROR_DOM_WRONG_TYPE_ERR              NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1002)
 #define NS_ERROR_DOM_NOT_OBJECT_ERR              NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1003)
 #define NS_ERROR_DOM_NOT_XPC_OBJECT_ERR          NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1004)
 #define NS_ERROR_DOM_NOT_NUMBER_ERR              NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1005)
 #define NS_ERROR_DOM_NOT_BOOLEAN_ERR             NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1006)
 #define NS_ERROR_DOM_NOT_FUNCTION_ERR            NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1007)
 #define NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR      NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM,1008)
--- a/dom/base/nsDOMException.cpp
+++ b/dom/base/nsDOMException.cpp
@@ -46,16 +46,17 @@
 #include "nsIDOMFileException.h"
 #include "nsIDOMSVGException.h"
 #include "nsIDOMXPathException.h"
 #include "nsIIDBDatabaseException.h"
 #include "nsString.h"
 #include "prprf.h"
 
 #define DOM_MSG_DEF(val, message) {(val), #val, message},
+#define DOM_MSG_DEF_(val, name, message) {(NS_ERROR_DOM_##val), name, message},
 
 #define IMPL_INTERNAL_DOM_EXCEPTION_HEAD(classname, ifname)                  \
 class classname : public nsBaseDOMException,                                 \
                   public ifname                                              \
 {                                                                            \
 public:                                                                      \
   classname();                                                               \
   virtual ~classname();                                                      \
@@ -103,16 +104,17 @@ static struct ResultStruct
   const char* mName;
   const char* mMessage;
 } gDOMErrorMsgMap[] = {
 #include "domerr.msg"
   {0, nsnull, nsnull}   // sentinel to mark end of array
 };
 
 #undef DOM_MSG_DEF
+#undef DOM_MSG_DEF_
 
 static void
 NSResultToNameAndMessage(nsresult aNSResult,
                          const char** aName,
                          const char** aMessage)
 {
   *aName = nsnull;
   *aMessage = nsnull;
@@ -152,17 +154,17 @@ NS_GetNameAndMessageForDOMNSResult(nsres
 
 IMPL_INTERNAL_DOM_EXCEPTION_HEAD(nsDOMException, nsIDOMDOMException)
   NS_DECL_NSIDOMDOMEXCEPTION
 IMPL_INTERNAL_DOM_EXCEPTION_TAIL(nsDOMException, nsIDOMDOMException,
                                  DOMException, NS_ERROR_MODULE_DOM,
                                  NSResultToNameAndMessage)
 
 NS_IMETHODIMP
-nsDOMException::GetCode(PRUint32* aCode)
+nsDOMException::GetCode(PRUint16* aCode)
 {
   NS_ENSURE_ARG_POINTER(aCode);
   nsresult result;
   GetResult(&result);
   *aCode = NS_ERROR_GET_CODE(result);
 
   return NS_OK;
 }
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1303,24 +1303,16 @@ nsJSContext::EvaluateStringWithValue(con
     }
 
     *aRetValue = val;
     // XXX - nsScriptObjectHolder should be used once this method moves to
     // the new world order. However, use of 'jsval' appears to make this
     // tricky...
   }
   else {
-    // If there is an outer script running, propagate the error upwards.
-    // Otherwise we may lose, e.g., the fact that an inner script evaluation
-    // was killed for taking too long and allow the outer script evaluation to
-    // continue.
-    if (mExecuteDepth > 0 || JS_IsRunning(mContext)) {
-      rv = NS_ERROR_FAILURE;
-    }
-
     if (aIsUndefined) {
       *aIsUndefined = true;
     }
   }
 
   sSecurityManager->PopContextPrincipal(mContext);
 
   // Pop here, after JS_ValueToString and any other possible evaluation.
@@ -1530,24 +1522,16 @@ nsJSContext::EvaluateString(const nsAStr
     JSAutoRequest ar(mContext);
     JSAutoEnterCompartment ac;
     if (!ac.enter(mContext, aScopeObject)) {
       stack->Pop(nsnull);
     }
     rv = JSValueToAString(mContext, val, aRetValue, aIsUndefined);
   }
   else {
-    // If there is an outer script running, propagate the error upwards.
-    // Otherwise we may lose, e.g., the fact that an inner script evaluation
-    // was killed for taking too long and allow the outer script evaluation to
-    // continue.
-    if (mExecuteDepth > 1 || JS_IsRunning(mContext)) {
-      rv = NS_ERROR_FAILURE;
-    }
-
     if (aIsUndefined) {
       *aIsUndefined = true;
     }
 
     if (aRetValue) {
       aRetValue->Truncate();
     }
   }
@@ -1676,24 +1660,16 @@ nsJSContext::ExecuteScript(JSScript* aSc
   jsval val;
   bool ok = JS_ExecuteScript(mContext, aScopeObject, aScriptObject, &val);
   if (ok) {
     // If all went well, convert val to a string (XXXbe unless undefined?).
     rv = JSValueToAString(mContext, val, aRetValue, aIsUndefined);
   } else {
     ReportPendingException();
 
-    // If there is an outer script running, propagate the error upwards.
-    // Otherwise we may lose, e.g., the fact that an inner script evaluation
-    // was killed for taking too long and allow the outer script evaluation to
-    // continue.
-    if (mExecuteDepth > 1 || JS_IsRunning(mContext)) {
-      rv = NS_ERROR_FAILURE;
-    }
-
     if (aIsUndefined) {
       *aIsUndefined = true;
     }
 
     if (aRetValue) {
       aRetValue->Truncate();
     }
   }
@@ -3152,20 +3128,17 @@ nsJSContext::ScriptEvaluated(bool aTermi
          cur = cur->mNext) {
       (*(cur->mTerminationFunc))(cur->mTerminationFuncArg);
     }
     delete start;
   }
 
   JS_MaybeGC(mContext);
 
-  // Be careful to not reset the operation callback if some outer script is
-  // still running. This would allow a script to bypass the slow script check
-  // simply by invoking nested scripts (e.g., through a plugin).
-  if (aTerminated && mExecuteDepth == 0 && !JS_IsRunning(mContext)) {
+  if (aTerminated) {
     mOperationCallbackTime = 0;
     mModalStateTime = 0;
   }
 }
 
 nsresult
 nsJSContext::SetTerminationFunction(nsScriptTerminationFunc aFunc,
                                     nsISupports* aRef)
--- a/dom/interfaces/canvas/nsIDOMCanvasRenderingContext2D.idl
+++ b/dom/interfaces/canvas/nsIDOMCanvasRenderingContext2D.idl
@@ -239,17 +239,17 @@ enum CanvasMultiGetterType {
    * @param h specify the area of the window to render, in CSS
    * pixels.
    *
    * @param backgroundColor the canvas is filled with this color
    * before we render the window into it. This color may be
    * transparent/translucent. It is given as a CSS color string
    * (e.g., rgb() or rgba()).
    *
-   * @param flags Uused to better control the drawWindow call.
+   * @param flags Used to better control the drawWindow call.
    * Flags can be ORed together.
    *
    * Of course, the rendering obeys the current scale, transform and
    * globalAlpha values.
    *
    * Hints:
    * -- If 'rgba(0,0,0,0)' is used for the background color, the
    * drawing will be transparent wherever the window is transparent.
--- a/dom/interfaces/core/nsIDOMDOMException.idl
+++ b/dom/interfaces/core/nsIDOMDOMException.idl
@@ -43,43 +43,43 @@
  * In general, DOM methods return specific error values in ordinary
  * processing situations, such as out-of-bound errors.
  * However, DOM operations can raise exceptions in "exceptional"
  * circumstances, i.e., when an operation is impossible to perform
  * (either for logical reasons, because data is lost, or because the
  * implementation has become unstable)
  *
  * For more information on this interface please see
- * http://www.w3.org/TR/DOM-Level-3-Core/
+ * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#domexception
  */
 
-[scriptable, uuid(a6cf910a-15b3-11d2-932e-00805f8add32)]
+[scriptable, uuid(5bd766d3-57a9-4833-995d-dbe21da29595)]
 interface nsIDOMDOMException : nsISupports
 {
   const unsigned short      INDEX_SIZE_ERR                 = 1;
-  const unsigned short      DOMSTRING_SIZE_ERR             = 2;
+  const unsigned short      DOMSTRING_SIZE_ERR             = 2; // historical
   const unsigned short      HIERARCHY_REQUEST_ERR          = 3;
   const unsigned short      WRONG_DOCUMENT_ERR             = 4;
   const unsigned short      INVALID_CHARACTER_ERR          = 5;
-  const unsigned short      NO_DATA_ALLOWED_ERR            = 6;
+  const unsigned short      NO_DATA_ALLOWED_ERR            = 6; // historical
   const unsigned short      NO_MODIFICATION_ALLOWED_ERR    = 7;
   const unsigned short      NOT_FOUND_ERR                  = 8;
   const unsigned short      NOT_SUPPORTED_ERR              = 9;
-  const unsigned short      INUSE_ATTRIBUTE_ERR            = 10;
-  // Introduced in DOM Level 2:
+  const unsigned short      INUSE_ATTRIBUTE_ERR            = 10; // historical
   const unsigned short      INVALID_STATE_ERR              = 11;
-  // Introduced in DOM Level 2:
   const unsigned short      SYNTAX_ERR                     = 12;
-  // Introduced in DOM Level 2:
   const unsigned short      INVALID_MODIFICATION_ERR       = 13;
-  // Introduced in DOM Level 2:
   const unsigned short      NAMESPACE_ERR                  = 14;
-  // Introduced in DOM Level 2:
   const unsigned short      INVALID_ACCESS_ERR             = 15;
-  // Introduced in DOM Level 3:
-  const unsigned short      VALIDATION_ERR                 = 16;
-  // Introduced in DOM Level 3:
+  const unsigned short      VALIDATION_ERR                 = 16; // historical
   const unsigned short      TYPE_MISMATCH_ERR              = 17;
+  const unsigned short      SECURITY_ERR                   = 18;
+  const unsigned short      NETWORK_ERR                    = 19;
+  const unsigned short      ABORT_ERR                      = 20;
+  const unsigned short      URL_MISMATCH_ERR               = 21;
+  const unsigned short      QUOTA_EXCEEDED_ERR             = 22;
+  const unsigned short      TIMEOUT_ERR                    = 23;
+  const unsigned short      INVALID_NODE_TYPE_ERR          = 24;
   const unsigned short      DATA_CLONE_ERR                 = 25;
 
-  readonly attribute unsigned long   code;
+  readonly attribute unsigned short   code;
 };
 
--- a/dom/interfaces/geolocation/nsIDOMGeoGeolocation.idl
+++ b/dom/interfaces/geolocation/nsIDOMGeoGeolocation.idl
@@ -36,17 +36,17 @@
 
 #include "domstubs.idl"
 
 interface nsIDOMGeoPosition;
 interface nsIDOMGeoPositionOptions;
 interface nsIDOMGeoPositionCallback;
 interface nsIDOMGeoPositionErrorCallback;
 
-[scriptable, function, uuid(37687DAF-B85F-4E4D-8881-85A0AD24CF78)]
+[scriptable, uuid(37687DAF-B85F-4E4D-8881-85A0AD24CF78)]
 interface nsIDOMGeoGeolocation : nsISupports
 {
   void getCurrentPosition(in nsIDOMGeoPositionCallback successCallback,
                           [optional] in nsIDOMGeoPositionErrorCallback errorCallback,
                           [optional] in nsIDOMGeoPositionOptions options);
 
   long watchPosition(in nsIDOMGeoPositionCallback successCallback,
                      [optional] in nsIDOMGeoPositionErrorCallback errorCallback,
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -620,17 +620,17 @@ PluginModuleChild::DeinitGraphics()
 #endif
 }
 
 bool
 PluginModuleChild::AnswerNP_Shutdown(NPError *rv)
 {
     AssertPluginThread();
 
-#if defined XP_WIN && MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
+#if defined XP_WIN
     mozilla::widget::StopAudioSession();
 #endif
 
     // the PluginModuleParent shuts down this process after this RPC
     // call pops off its stack
 
     *rv = mShutdownFunc ? mShutdownFunc() : NPERR_NO_ERROR;
 
@@ -684,17 +684,17 @@ PluginModuleChild::AnswerNPP_GetSitesWit
     return true;
 }
 
 bool
 PluginModuleChild::RecvSetAudioSessionData(const nsID& aId,
                                            const nsString& aDisplayName,
                                            const nsString& aIconPath)
 {
-#if !defined XP_WIN || MOZ_WINSDK_TARGETVER < MOZ_NTDDI_LONGHORN
+#if !defined XP_WIN
     NS_RUNTIMEABORT("Not Reached!");
     return false;
 #else
     nsresult rv = mozilla::widget::RecvAudioSessionData(aId, aDisplayName, aIconPath);
     NS_ENSURE_SUCCESS(rv, true); // Bail early if this fails
 
     // Ignore failures here; we can't really do anything about them
     mozilla::widget::StartAudioSession();
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -771,17 +771,17 @@ PluginModuleParent::NP_Initialize(NPNets
     if (mShutdown) {
         *error = NPERR_GENERIC_ERROR;
         return NS_ERROR_FAILURE;
     }
 
     if (!CallNP_Initialize(error))
         return NS_ERROR_FAILURE;
 
-#if defined XP_WIN && MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
+#if defined XP_WIN
     // Send the info needed to join the chrome process's audio session to the
     // plugin process
     nsID id;
     nsString sessionName;
     nsString iconPath;
 
     if (NS_SUCCEEDED(mozilla::widget::GetAudioSessionData(id, sessionName,
                                                           iconPath)))
--- a/dom/system/b2g/ril_worker.js
+++ b/dom/system/b2g/ril_worker.js
@@ -490,17 +490,17 @@ let Buf = {
 
   /**
    * Start a new outgoing parcel.
    *
    * @param type
    *        Integer specifying the request type.
    * @param options [optional]
    *        Object containing information about the request, e.g. the
-   *        original main thread message object that led to the RIL request. 
+   *        original main thread message object that led to the RIL request.
    */
   newParcel: function newParcel(type, options) {
     if (DEBUG) debug("New outgoing parcel of type " + type);
     // We're going to leave room for the parcel size at the beginning.
     this.outgoingIndex = PARCEL_SIZE_SIZE;
     this.writeUint32(type);
     let token = this.token;
     this.writeUint32(token);
@@ -527,18 +527,18 @@ let Buf = {
     // This assumes that postRILMessage will make a copy of the ArrayBufferView
     // right away!
     let parcel = this.outgoingBytes.subarray(0, this.outgoingIndex);
     if (DEBUG) debug("Outgoing parcel: " + Array.slice(parcel));
     postRILMessage(parcel);
     this.outgoingIndex = PARCEL_SIZE_SIZE;
   },
 
-  simpleRequest: function simpleRequest(type) {
-    this.newParcel(type);
+  simpleRequest: function simpleRequest(type, options) {
+    this.newParcel(type, options);
     this.sendParcel();
   }
 };
 
 
 /**
  * Provide a high-level API representing the RIL's capabilities. This is
  * where parcels are sent and received from and translated into API calls.
@@ -565,17 +565,17 @@ let RIL = {
 
     this.rilQuirksInitialized = true;
   },
 
   /**
    * Parse an integer from a string, falling back to a default value
    * if the the provided value is not a string or does not contain a valid
    * number.
-   * 
+   *
    * @param string
    *        String to be parsed.
    * @param defaultValue
    *        Default value to be used.
    */
   parseInt: function RIL_parseInt(string, defaultValue) {
     let number = parseInt(string, 10);
     if (!isNaN(number)) {
@@ -843,19 +843,22 @@ let RIL = {
   sendTone: function sendTone(dtmfChar) {
     Buf.newParcel(REQUEST_DTMF);
     Buf.writeString(dtmfChar);
     Buf.sendParcel();
   },
 
   /**
    * Get the Short Message Service Center address.
+   *
+   * @param pendingSMS
+   *        Object containing the parameters of an SMS waiting to be sent.
    */
-  getSMSCAddress: function getSMSCAddress() {
-    Buf.simpleRequest(REQUEST_GET_SMSC_ADDRESS);
+  getSMSCAddress: function getSMSCAddress(pendingSMS) {
+    Buf.simpleRequest(REQUEST_GET_SMSC_ADDRESS, pendingSMS);
   },
 
   /**
    * Set the Short Message Service Center address.
    *
    * @param smsc
    *        Short Message Service Center address in PDU format.
    */
@@ -1220,19 +1223,19 @@ RIL[REQUEST_GSM_SMS_BROADCAST_ACTIVATION
 RIL[REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG] = null;
 RIL[REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG] = null;
 RIL[REQUEST_CDMA_SMS_BROADCAST_ACTIVATION] = null;
 RIL[REQUEST_CDMA_SUBSCRIPTION] = null;
 RIL[REQUEST_CDMA_WRITE_SMS_TO_RUIM] = null;
 RIL[REQUEST_CDMA_DELETE_SMS_ON_RUIM] = null;
 RIL[REQUEST_DEVICE_IDENTITY] = null;
 RIL[REQUEST_EXIT_EMERGENCY_CALLBACK_MODE] = null;
-RIL[REQUEST_GET_SMSC_ADDRESS] = function REQUEST_GET_SMSC_ADDRESS() {
+RIL[REQUEST_GET_SMSC_ADDRESS] = function REQUEST_GET_SMSC_ADDRESS(length, options) {
   let smsc = Buf.readString();
-  Phone.onGetSMSCAddress(smsc);
+  Phone.onGetSMSCAddress(smsc, options);
 };
 RIL[REQUEST_SET_SMSC_ADDRESS] = function REQUEST_SET_SMSC_ADDRESS() {
   Phone.onSetSMSCAddress();
 };
 RIL[REQUEST_REPORT_SMS_MEMORY_STATUS] = null;
 RIL[REQUEST_REPORT_STK_SERVICE_IS_RUNNING] = null;
 RIL[UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED] = function UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED() {
   let newState = Buf.readUint32();
@@ -1772,18 +1775,27 @@ let Phone = {
   },
 
   onStartTone: function onStartTone() {
   },
 
   onStopTone: function onStopTone() {
   },
 
-  onGetSMSCAddress: function onGetSMSCAddress(smsc) {
+  onGetSMSCAddress: function onGetSMSCAddress(smsc, options) {
+    //TODO: notify main thread if we fail retrieving the SMSC, especially
+    // if there was a pending SMS (bug 727319).
     this.SMSC = smsc;
+    // If the SMSC was not retrieved on RIL initialization, an attempt to
+    // get it is triggered from this.sendSMS followed by the 'options'
+    // parameter of the SMS, so that we can send it after successfully
+    // retrieving the SMSC.
+    if (smsc && options.body) {
+      this.sendSMS(options);
+    }
   },
 
   onSetSMSCAddress: function onSetSMSCAddress() {
   },
 
   onSendSMS: function onSendSMS(options) {
     options.type = "sms-sent";
     this.sendDOMMessage(options);
@@ -2048,34 +2060,30 @@ let Phone = {
    * @param requestId
    *        String identifying the sms request used by the SmsRequestManager.
    * @param processId
    *        String containing the processId for the SmsRequestManager.
    */
   sendSMS: function sendSMS(options) {
     // Get the SMS Center address
     if (!this.SMSC) {
-      //TODO: we shouldn't get here, but if we do, we might want to hold on
-      // to the message and retry once we know the SMSC... or just notify an
-      // error to the mainthread and let them deal with retrying?
-      if (DEBUG) {
-        debug("Cannot send the SMS. Need to get the SMSC address first.");
-      }
+      // We request the SMS center address again, passing it the SMS options
+      // in order to try to send it again after retrieving the SMSC number.
+      RIL.getSMSCAddress(options);
       return;
     }
     // We explicitly save this information on the options object so that we
     // can refer to it later, in particular on the main thread (where this
     // object may get sent eventually.)
     options.SMSC = this.SMSC;
 
     //TODO: verify values on 'options'
     //TODO: the data encoding and length in octets should eventually be
     // computed on the mainthread and passed down to us.
-    options.dcs = PDU_DCS_MSG_CODING_7BITS_ALPHABET;
-    options.bodyLengthInOctets = Math.ceil(options.body.length * 7 / 8);
+    GsmPDUHelper.calculateUserDataLength(options);
     RIL.sendSMS(options);
   },
 
   /**
    * Setup a data call (PDP).
    */
   setupDataCall: function setupDataCall(options) {
     if (DEBUG) debug("setupDataCall: " + JSON.stringify(options));
@@ -2336,40 +2344,85 @@ let GsmPDUHelper = {
       this.writeHexOctet(left | right);
       right = (septet & right_mask) >> shift;
     }
   },
 
   /**
    * Read user data and decode as a UCS2 string.
    *
-   * @param length
-   *        XXX TODO
+   * @param numOctets
+   *        num of octets to read as UCS2 string.
    *
    * @return a string.
    */
-  readUCS2String: function readUCS2String(length) {
-    //TODO bug 712804
+  readUCS2String: function readUCS2String(numOctets) {
+    let str = "";
+    let length = numOctets / 2;
+    for (let i = 0; i < length; ++i) {
+      let code = (this.readHexOctet() << 8) | this.readHexOctet();
+      str += String.fromCharCode(code);
+    }
+
+    if (DEBUG) debug("Read UCS2 string: " + str);
+
+    return str;
   },
 
   /**
    * Write user data as a UCS2 string.
    *
    * @param message
    *        Message string to encode as UCS2 in hex-encoded octets.
    */
   writeUCS2String: function writeUCS2String(message) {
-    //TODO bug 712804
+    for (let i = 0; i < message.length; ++i) {
+      let code = message.charCodeAt(i);
+      this.writeHexOctet((code >> 8) & 0xFF);
+      this.writeHexOctet(code & 0xFF);
+    }
+  },
+
+  /**
+   * Calculate user data length and its encoding.
+   *
+   * The `options` parameter object should contain the `body` attribute, and
+   * the `dcs`, `bodyLengthInOctets` attributes will be set as return:
+   *
+   * @param body
+   *        String containing the message body.
+   * @param dcs
+   *        Data coding scheme. One of the PDU_DCS_MSG_CODING_*BITS_ALPHABET
+   *        constants.
+   * @param bodyLengthInOctets
+   *        Byte length of the message body when encoded with the given DCS.
+   */
+  calculateUserDataLength: function calculateUserDataLength(options) {
+    //TODO: support language tables, see bug 729876
+    //TODO: support multipart SMS, see bug 712933
+    let needUCS2 = false;
+    for (let i = 0; i < options.body.length; ++i) {
+      if (options.body.charCodeAt(i) >= 128) {
+        needUCS2 = true;
+        break;
+      }
+    }
+
+    if (needUCS2) {
+      options.dcs = PDU_DCS_MSG_CODING_16BITS_ALPHABET;
+      options.bodyLengthInOctets = options.body.length * 2;
+    } else {
+      options.dcs = PDU_DCS_MSG_CODING_7BITS_ALPHABET;
+      options.bodyLengthInOctets = Math.ceil(options.body.length * 7 / 8);
+    }
   },
 
   /**
    * User data can be 7 bit (default alphabet) data, 8 bit data, or 16 bit
    * (UCS2) data.
-   *
-   * TODO: This function currently supports only the default alphabet.
    */
   readUserData: function readUserData(length, codingScheme) {
     if (DEBUG) {
       debug("Reading " + length + " bytes of user data.");
       debug("Coding scheme: " + codingScheme);
     }
     // 7 bit is the default fallback encoding.
     let encoding = PDU_DCS_MSG_CODING_7BITS_ALPHABET;
--- a/dom/tests/mochitest/bugs/test_bug346659.html
+++ b/dom/tests/mochitest/bugs/test_bug346659.html
@@ -68,17 +68,17 @@ function handleCmd(evt) {
     var win = wins[testNum];
     win.childWin.x = testNum;
     try {
       if (win.childWin.opener == win) {
         win.childWin.document.write('<script>window.opener.opener.postMessage(window.opener.testNum + " - " + window.x, "http://mochi.test:8888/"); window.opener.close(); window.close();<' + '/script>');
       } else {
         win.childWin.document.write('<script>window.parent.opener.postMessage(window.parent.testNum + " - " + window.x, "http://mochi.test:8888/"); window.parent.close();<' + '/script>');
       }
-    } catch (e if (e.name == "NS_ERROR_DOM_SECURITY_ERR" && e.code == 1000)) {
+    } catch (e if (e.name == "SecurityError" && e.code == 18)) {
       // Security error on cross-site write() is fine
       if (win.childWin.opener == win) {
         win.childWin.close();
       }
       win.close()
       handleTestEnd();
     }
     wins[testNum] = null;
--- a/dom/tests/mochitest/localstorage/test_localStorageCookieSettings.html
+++ b/dom/tests/mochitest/localstorage/test_localStorageCookieSettings.html
@@ -13,33 +13,33 @@ Components.utils.import("resource://gre/
 
 // Set cookies behavior to "always reject".
 Services.prefs.setIntPref("network.cookie.cookieBehavior", 2);
 try {
   localStorage.setItem("contentkey", "test-value");
   ok(false, "Setting localStorageItem should throw a security exception");
 }
 catch(ex) {
-  is(ex.name, "NS_ERROR_DOM_SECURITY_ERR");
+  is(ex.name, "SecurityError");
 }
 
 try {
   Services.prefs.clearUserPref("network.cookie.cookieBehavior");
 }
 catch (ex) {}
 
 
 // Set cookies behavior to "ask every time".
 Services.prefs.setIntPref("network.cookie.lifetimePolicy", 1);
 try {
   localStorage.setItem("contentkey", "test-value");
   ok(false, "Setting localStorageItem should throw a security exception");
 }
 catch(ex) {
-  is(ex.name, "NS_ERROR_DOM_SECURITY_ERR");
+  is(ex.name, "SecurityError");
 }
 
 try {
   Services.prefs.clearUserPref("network.cookie.lifetimePolicy");
 }
 catch (ex) {}
 
 </script>
--- a/dom/tests/mochitest/localstorage/test_localStorageEnablePref.html
+++ b/dom/tests/mochitest/localstorage/test_localStorageEnablePref.html
@@ -35,17 +35,17 @@ function startTest()
 
   is(typeof(window.localStorage), "object", "Storage is present");
   var storage = window.localStorage;
 
   setDOMStorageEnabled(false);
 
   is(window.localStorage, null, "Storage is null");
 
-  checkException(function() {storage.setItem("test", "value");}, "NS_ERROR_DOM_SECURITY_ERR");
+  checkException(function() {storage.setItem("test", "value");}, "SecurityError");
 
   setDOMStorageEnabled(true);
 
   is(typeof(window.localStorage), "object", "Storage is present again");
   storage.setItem("test", "value");
   ok(storage.getItem("test"), "value", "value can be set");
 }
 
--- a/dom/wifi/nsWifiWorker.js
+++ b/dom/wifi/nsWifiWorker.js
@@ -478,45 +478,47 @@ var WifiManager = (function() {
     var handler = manager["on" + eventName];
     if (handler) {
       if (!eventObject)
         eventObject = ({});
       handler.call(eventObject);
     }
   }
 
-  function parseStatus(status) {
+  function notifyStateChange(fields) {
+    fields.prevState = manager.state;
+    manager.state = fields.state;
+    notify("statechange", fields);
+  }
+
+  function parseStatus(status, reconnected) {
     if (status === null) {
       debug("Unable to get wpa supplicant's status");
       return;
     }
 
     var lines = status.split("\n");
     for (let i = 0; i < lines.length; ++i) {
       let [key, value] = lines[i].split("=");
       if (key === "wpa_state") {
-        notify("statechange", { state: value });
+        notifyStateChange({ state: value });
         if (value === "COMPLETED")
-          onconnected();
+          onconnected(reconnected);
       }
     }
   }
 
   // try to connect to the supplicant
   var connectTries = 0;
   var retryTimer = null;
   function connectCallback(ok) {
     if (ok === 0) {
       // Tell the event worker to start waiting for events.
       retryTimer = null;
-      waitForEvent();
-      notify("supplicantconnection");
-
-      // Load up the supplicant state.
-      statusCommand(parseStatus);
+      didConnectSupplicant(false, function(){});
       return;
     }
     if (connectTries++ < 3) {
       // try again in 5 seconds
       if (!retryTimer)
         retryTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
 
       retryTimer.initWithCallback(function(timer) {
@@ -525,20 +527,24 @@ var WifiManager = (function() {
       return;
     }
 
     retryTimer = null;
     notify("supplicantlost");
   }
 
   manager.start = function() {
-    connectToSupplicant(connectCallback);
+    // If we reconnected to an already-running supplicant, then manager.state
+    // will have already been updated to the supplicant's state. Otherwise, we
+    // started the supplicant ourselves and need to connect.
+    if (manager.state === "UNINITIALIZED")
+      connectToSupplicant(connectCallback);
   }
 
-  function onconnected() {
+  function dhcpAfterConnect() {
     runDhcp(manager.ifname, function (data) {
       if (!data) {
         debug("DHCP failed to run");
         return;
       }
       setProperty("net.dns1", ipToString(data.dns1), function(ok) {
         if (!ok) {
           debug("Unable to set net.dns1");
@@ -559,16 +565,40 @@ var WifiManager = (function() {
                 debug("Unable to set net.dnschange");
             });
           });
         });
       });
     });
   }
 
+  function onconnected(reconnected) {
+    if (!reconnected) {
+      dhcpAfterConnect();
+      return;
+    }
+
+    // We're in the process of reconnecting to a pre-existing wpa_supplicant.
+    // Check to see if there was already a DHCP process:
+    getProperty("init.svc.dhcpcd_" + manager.ifname, "stopped", function(value) {
+      if (value === "running") {
+        return;
+      }
+
+      // Some phones use a different property name for the dhcpcd daemon.
+      getProperty("init.svc.dhcpcd", "stopped", function(value) {
+        if (value === "running") {
+          return;
+        }
+
+        dhcpAfterConnect();
+      });
+    });
+  }
+
   var supplicantStatesMap = ["DISCONNECTED", "INACTIVE", "SCANNING", "ASSOCIATING",
                              "ASSOCIATED", "FOUR_WAY_HANDSHAKE", "GROUP_HANDSHAKE",
                              "COMPLETED", "DORMANT", "UNINITIALIZED"];
   var driverEventMap = { STOPPED: "driverstopped", STARTED: "driverstarted", HANGED: "driverhung" };
 
   // handle events sent to us by the event worker
   function handleEvent(event) {
     debug("Event coming in: " + event);
@@ -590,17 +620,17 @@ var WifiManager = (function() {
       for (var n = 0; n < tokens.length; ++n) {
         var kv = tokens[n].split("=");
         if (kv.length === 2)
           fields[kv[0]] = kv[1];
       }
       if (!("state" in fields))
         return true;
       fields.state = supplicantStatesMap[fields.state];
-      notify("statechange", fields);
+      notifyStateChange(fields);
       return true;
     }
     if (eventData.indexOf("CTRL-EVENT-DRIVER-STATE") === 0) {
       var handlerName = driverEventMap[eventData];
       if (handlerName)
         notify(handlerName);
       return true;
     }
@@ -615,74 +645,113 @@ var WifiManager = (function() {
       // will keep going for a bit longer
       if (eventData.indexOf("recv error") !== -1 && ++recvErrors < 10)
         return true;
 
       notify("supplicantlost");
       return false;
     }
     if (eventData.indexOf("CTRL-EVENT-DISCONNECTED") === 0) {
-      notify("statechange", { state: "DISCONNECTED" });
+      notifyStateChange({ state: "DISCONNECTED" });
       return true;
     }
     if (eventData.indexOf("CTRL-EVENT-CONNECTED") === 0) {
       // Format: CTRL-EVENT-CONNECTED - Connection to 00:1e:58:ec:d5:6d completed (reauth) [id=1 id_str=]
       var bssid = eventData.split(" ")[4];
       var id = eventData.substr(eventData.indexOf("id=")).split(" ")[0];
-      notify("statechange", { state: "CONNECTED", BSSID: bssid, id: id });
-      onconnected();
+      notifyStateChange({ state: "CONNECTED", BSSID: bssid, id: id });
+      onconnected(false);
       return true;
     }
     if (eventData.indexOf("CTRL-EVENT-SCAN-RESULTS") === 0) {
       debug("Notifying of scan results available");
       notify("scanresultsavailable");
       return true;
     }
     // unknown event
     return true;
   }
 
+  const SUPP_PROP = "init.svc.wpa_supplicant";
   function killSupplicant(callback) {
     // It is interesting to note that this function does exactly what
     // wifi_stop_supplicant does. Unforunately, on the Galaxy S2, Samsung
     // changed that function in a way that means that it doesn't recognize
     // wpa_supplicant as already running. Therefore, we have to roll our own
     // version here.
     var count = 0;
     var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
     function tick() {
-      getProperty("init.svc.wpa_supplicant", "stopped", function (result) {
+      getProperty(SUPP_PROP, "stopped", function (result) {
         if (result === null) {
-          callback(false);
+          callback();
           return;
         }
         if (result === "stopped" || ++count >= 5) {
           // Either we succeeded or ran out of time.
           timer = null;
-          callback(count < 5);
+          callback();
           return;
         }
 
         // Else it's still running, continue waiting.
         timer.initWithCallback(tick, 1000, Ci.nsITimer.TYPE_ONE_SHOT);
       });
     }
 
     setProperty("ctl.stop", "wpa_supplicant", tick);
   }
 
+  function didConnectSupplicant(reconnected, callback) {
+    waitForEvent();
+    notify("supplicantconnection");
+
+    // Load up the supplicant state.
+    statusCommand(function(status) {
+      parseStatus(status, reconnected);
+      callback();
+    });
+  }
+
   function prepareForStartup(callback) {
-    stopDhcp(manager.ifname, function() {
-      // Ignore any errors.
-      killSupplicant(callback);
+    // First, check to see if there's a wpa_supplicant running that we can
+    // connect to.
+    getProperty(SUPP_PROP, "stopped", function (value) {
+      debug(SUPP_PROP + " was " + value);
+      if (value !== "running") {
+        stopDhcp(manager.ifname, function() { callback(false) });
+        return;
+      }
+
+      debug(SUPP_PROP + " was running, trying to connect");
+      // It's running, try to reconnect to it.
+      connectToSupplicant(function (retval) {
+        if (retval === 0) {
+          // Successfully reconnected! Don't do anything else.
+          debug("Successfully connected!");
+
+          // It is important that we call parseStatus (in
+          // didConnectSupplicant) before calling the callback here.
+          // Otherwise, WifiManager.start will reconnect to it.
+          didConnectSupplicant(true, function() { callback(true) });
+          return;
+        }
+
+        debug("Didn't connect, trying other method.");
+        stopDhcp(manager.ifname, function() {
+          // Ignore any errors.
+          killSupplicant(function() { callback(false); });
+        });
+      });
     });
   }
 
   // Initial state
   var airplaneMode = false;
+  manager.state = "UNINITIALIZED";
 
   // Public interface of the wifi service
   manager.setWifiEnabled = function(enable, callback) {
     var targetState = enable ? "ENABLED" : "DISABLED";
     if (enable == targetState)
       return true;
     if (enable && airplaneMode)
       return false;
@@ -690,18 +759,22 @@ var WifiManager = (function() {
       // Kill any existing connections if necessary.
       getProperty("wifi.interface", "tiwlan0", function (ifname) {
         if (!ifname) {
           callback(-1);
           return;
         }
         manager.ifname = ifname;
 
-        prepareForStartup(function() {
-          // Ignore errors...
+        prepareForStartup(function(already_connected) {
+          if (already_connected) {
+            callback(0);
+            return;
+          }
+
           loadDriver(function (status) {
             if (status < 0) {
               callback(status);
               return;
             }
             startSupplicant(function (status) {
               if (status < 0) {
                 callback(status);
@@ -850,32 +923,27 @@ function WifiNetwork(ssid, bssid, flags,
 WifiNetwork.prototype.QueryInterface = XPCOMUtils.generateQI([Ci.nsIWifiNetwork]);
 
 function nsWifiWorker() {
   WifiManager.onsupplicantconnection = function() {
     debug("Connected to supplicant");
     WifiManager.getMacAddress(function (mac) {
       debug("Got mac: " + mac);
     });
+    connectToMozilla();
   }
   WifiManager.onsupplicantlost = function() {
     debug("Couldn't connect to supplicant");
   }
 
   var self = this;
 
-  this.state = null;
   this.networks = Object.create(null);
   WifiManager.onstatechange = function() {
-    debug("State change: " + self.state + " -> " + this.state);
-    self.state = this.state;
-
-    // TODO Worth adding a more generic API for this?
-    if (self.state === "INACTIVE")
-      connectToMozilla();
+    debug("State change: " + this.prevState + " -> " + this.state);
   }
 
   function connectToMozilla() {
     // We're not trying to connect so try to find an open Mozilla network.
     // TODO Don't do this for pre-existing networks.
     // TODO Remove me in favor of UI and a way to select a network.
 
     debug("Haven't connected to a network, trying a default (for now)");
--- a/gfx/2d/PathCG.cpp
+++ b/gfx/2d/PathCG.cpp
@@ -66,32 +66,30 @@ PathBuilderCG::LineTo(const Point &aPoin
 void
 PathBuilderCG::BezierTo(const Point &aCP1,
                          const Point &aCP2,
                          const Point &aCP3)
 {
 
   if (CGPathIsEmpty(mCGPath))
     MoveTo(aCP1);
-  else
-    CGPathAddCurveToPoint(mCGPath, NULL,
+  CGPathAddCurveToPoint(mCGPath, NULL,
                           aCP1.x, aCP1.y,
                           aCP2.x, aCP2.y,
                           aCP3.x, aCP3.y);
 
 }
 
 void
 PathBuilderCG::QuadraticBezierTo(const Point &aCP1,
                                   const Point &aCP2)
 {
   if (CGPathIsEmpty(mCGPath))
     MoveTo(aCP1);
-  else
-    CGPathAddQuadCurveToPoint(mCGPath, NULL,
+  CGPathAddQuadCurveToPoint(mCGPath, NULL,
                               aCP1.x, aCP1.y,
                               aCP2.x, aCP2.y);
 }
 
 void
 PathBuilderCG::Close()
 {
   if (!CGPathIsEmpty(mCGPath))
--- a/gfx/harfbuzz/src/hb-ot-shape-private.hh
+++ b/gfx/harfbuzz/src/hb-ot-shape-private.hh
@@ -104,25 +104,25 @@ static inline unsigned int
 {
   int c = hb_unicode_combining_class (ufuncs, unicode);
 
   /* For Hebrew, we permute the "fixed-position" classes 10-25 into the order
    * described in the SBL Hebrew manual http://www.sbl-site.org/Fonts/SBLHebrewUserManual1.5x.pdf
    * (as recommended by http://forum.fontlab.com/archive-old-microsoft-volt-group/vista-and-diacritic-ordering-t6751.0.html)
    */
   static const int permuted_hebrew_classes[25 - 10 + 1] = {
-    /* 10 sheva */        15,
-    /* 11 hataf segol */  16,
-    /* 12 hataf patah */  17,
-    /* 13 hataf qamats */ 18,
-    /* 14 hiriq */        19,
-    /* 15 tsere */        20,
-    /* 16 segol */        21,
-    /* 17 patah */        22,
-    /* 18 qamats */       23,
+    /* 10 sheva */        22,
+    /* 11 hataf segol */  15,
+    /* 12 hataf patah */  16,
+    /* 13 hataf qamats */ 17,
+    /* 14 hiriq */        23,
+    /* 15 tsere */        18,
+    /* 16 segol */        19,
+    /* 17 patah */        20,
+    /* 18 qamats */       21,
     /* 19 holam */        14,
     /* 20 qubuts */       24,
     /* 21 dagesh */       12,
     /* 22 meteg */        25,
     /* 23 rafe */         13,
     /* 24 shin dot */     10,
     /* 25 sin dot */      11,
   };
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -318,16 +318,31 @@ bool SetLight(LightType light, const hal
 }
 
 bool GetLight(LightType light, hal::LightConfiguration* aConfig)
 {
   AssertMainThread();
   RETURN_PROXY_IF_SANDBOXED(GetLight(light, aConfig));
 }
 
+
+void 
+AdjustSystemClock(int32_t aDeltaMilliseconds)
+{
+  AssertMainThread();
+  PROXY_IF_SANDBOXED(AdjustSystemClock(aDeltaMilliseconds));
+}
+
+void 
+SetTimezone(const nsCString& aTimezoneSpec)
+{
+  AssertMainThread();
+  PROXY_IF_SANDBOXED(SetTimezone(aTimezoneSpec));
+}
+
 void
 EnableSensorNotifications(SensorType aSensor) {
   AssertMainThread();
   PROXY_IF_SANDBOXED(EnableSensorNotifications(aSensor));
 }
 
 void
 DisableSensorNotifications(SensorType aSensor) {
--- a/hal/Hal.h
+++ b/hal/Hal.h
@@ -213,16 +213,29 @@ void GetCurrentNetworkInformation(hal::N
 
 /**
  * Notify of a change in the network state.
  * @param aNetworkInfo The new network information.
  */
 void NotifyNetworkChange(const hal::NetworkInformation& aNetworkInfo);
 
 /**
+ * Adjusting system clock.
+ * @param aDeltaMilliseconds The difference compared with current system clock.
+ */
+void AdjustSystemClock(int32_t aDeltaMilliseconds);
+
+/**
+ * Set timezone
+ * @param aTimezoneSpec The definition can be found in 
+ * http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
+ */
+void SetTimezone(const nsCString& aTimezoneSpec);
+
+/**
  * Reboot the device.
  */
 void Reboot();
 
 /**
  * Power off the device.
  */
 void PowerOff();
--- a/hal/Makefile.in
+++ b/hal/Makefile.in
@@ -100,17 +100,17 @@ CPPSRCS += \
 else
 CPPSRCS += \
   FallbackHal.cpp \
   FallbackSensor.cpp \
   $(NULL)
 endif
 
 ifneq (gonk,$(MOZ_WIDGET_TOOLKIT)) #{
-CPPSRCS += FallbackLights.cpp
+CPPSRCS += FallbackLights.cpp FallbackTime.cpp
 endif #}
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
 
 CFLAGS          += $(MOZ_DBUS_GLIB_CFLAGS)
 CXXFLAGS        += $(MOZ_DBUS_GLIB_CFLAGS) -DHAVE_PTHREADS
new file mode 100644
--- /dev/null
+++ b/hal/fallback/FallbackTime.cpp
@@ -0,0 +1,22 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: sw=2 ts=8 et :
+ */
+/* 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 "Hal.h"
+
+namespace mozilla {
+namespace hal_impl {
+
+void 
+AdjustSystemClock(int32_t aDeltaMilliseconds)
+{}
+
+void
+SetTimezone(const nsCString& aTimezoneSpec)
+{}
+
+} // namespace hal_impl
+} // namespace mozilla
--- a/hal/gonk/GonkHal.cpp
+++ b/hal/gonk/GonkHal.cpp
@@ -21,17 +21,26 @@
 #include "nsIObserverService.h"
 #include "hardware/lights.h"
 #include "hardware/hardware.h"
 #include "hardware_legacy/vibrator.h"
 #include <stdio.h>
 #include <math.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <time.h>
+#include <sys/syscall.h>
+#include <cutils/properties.h>
 #include "mozilla/dom/network/Constants.h"
+#include <android/log.h>
+
+#define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "Gonk", args)
+#define NsecPerMsec  1000000
+#define NsecPerSec   1000000000
+
 
 using mozilla::hal::WindowIdentifier;
 
 namespace mozilla {
 namespace hal_impl {
 
 namespace {
 
@@ -505,16 +514,62 @@ GetLight(hal::LightType light, hal::Ligh
   aConfig->flash() = hal::FlashMode(state.flashMode);
   aConfig->flashOnMS() = state.flashOnMS;
   aConfig->flashOffMS() = state.flashOffMS;
   aConfig->mode() = hal::LightMode(state.brightnessMode);
 
   return true;
 }
 
+/**
+ * clock_settime() is not exposed through bionic. 
+ * we define the new function to set system time.
+ * The result is the same as using clock_settime() system call.     
+ */
+static int
+sys_clock_settime(clockid_t clk_id, const struct timespec *tp)
+{
+  return syscall(__NR_clock_settime, clk_id, tp);
+}
+
+void 
+AdjustSystemClock(int32_t aDeltaMilliseconds)
+{
+  struct timespec now;
+  
+  // Preventing context switch before setting system clock 
+  sched_yield();
+  clock_gettime(CLOCK_REALTIME, &now);
+  now.tv_sec += aDeltaMilliseconds/1000;
+  now.tv_nsec += (aDeltaMilliseconds%1000)*NsecPerMsec;
+  if (now.tv_nsec >= NsecPerSec)
+  {
+    now.tv_sec += 1;
+    now.tv_nsec -= NsecPerSec;
+  }
+
+  if (now.tv_nsec < 0)
+  {
+    now.tv_nsec += NsecPerSec;
+    now.tv_sec -= 1;  
+  }
+  // we need to have root privilege. 
+  sys_clock_settime(CLOCK_REALTIME, &now);   
+}
+
+void 
+SetTimezone(const nsCString& aTimezoneSpec)
+{ 
+  property_set("persist.sys.timezone", aTimezoneSpec.get());
+  // this function is automatically called by the other time conversion 
+  // functions that depend on the timezone. To be safe, we call it manually.  
+  tzset();
+}
+
+
 void
 EnableNetworkNotifications()
 {}
 
 void
 DisableNetworkNotifications()
 {}
 
--- a/hal/sandbox/PHal.ipdl
+++ b/hal/sandbox/PHal.ipdl
@@ -104,16 +104,19 @@ parent:
     sync GetCurrentNetworkInformation()
       returns (NetworkInformation aNetworkInfo);
 
     sync GetScreenEnabled() returns (bool enabled);
     SetScreenEnabled(bool enabled);
 
     sync GetScreenBrightness() returns (double brightness);
     SetScreenBrightness(double brightness);
+    
+    AdjustSystemClock(int32 aDeltaMilliseconds);
+    SetTimezone(nsCString aTimezoneSpec);
 
     sync SetLight(LightType light, LightConfiguration aConfig)
       returns (bool status);
     sync GetLight(LightType light)
       returns (LightConfiguration aConfig, bool status);
 
     Reboot();
     PowerOff();
--- a/hal/sandbox/SandboxHal.cpp
+++ b/hal/sandbox/SandboxHal.cpp
@@ -130,16 +130,28 @@ SetLight(hal::LightType light, const hal
 bool
 GetLight(hal::LightType light, hal::LightConfiguration* aConfig)
 {
   bool status;
   Hal()->SendGetLight(light, aConfig, &status);
   return status;
 }
 
+void 
+AdjustSystemClock(int32_t aDeltaMilliseconds)
+{
+  Hal()->SendAdjustSystemClock(aDeltaMilliseconds);
+}
+
+void
+SetTimezone(const nsCString& aTimezoneSpec)
+{
+  Hal()->SendSetTimezone(nsCString(aTimezoneSpec));
+} 
+
 void
 Reboot()
 {
   Hal()->SendReboot();
 }
 
 void
 PowerOff()
@@ -284,16 +296,30 @@ public:
   NS_OVERRIDE virtual bool
   RecvGetLight(const LightType& aLight, LightConfiguration* aConfig, bool* status)
   {
     *status = hal::GetLight(aLight, aConfig);
     return true;
   }
 
   NS_OVERRIDE virtual bool
+  RecvAdjustSystemClock(const int32_t &aDeltaMilliseconds)
+  {
+    hal::AdjustSystemClock(aDeltaMilliseconds);
+    return true;
+  }
+
+  NS_OVERRIDE virtual bool 
+  RecvSetTimezone(const nsCString& aTimezoneSpec)
+  {
+    hal::SetTimezone(aTimezoneSpec);
+    return true;  
+  }
+
+  NS_OVERRIDE virtual bool
   RecvReboot()
   {
     hal::Reboot();
     return true;
   }
 
   NS_OVERRIDE virtual bool
   RecvPowerOff()
--- a/hal/windows/WindowsBattery.cpp
+++ b/hal/windows/WindowsBattery.cpp
@@ -45,27 +45,24 @@
 
 using namespace mozilla::dom::battery;
 
 namespace mozilla {
 namespace hal_impl {
 
 static nsCOMPtr<nsITimer> sUpdateTimer;
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 /* Power Event API is Vista or later */
 typedef HPOWERNOTIFY (WINAPI *REGISTERPOWERSETTINGNOTIFICATION) (HANDLE, LPCGUID, DWORD);
 typedef BOOL (WINAPI *UNREGISTERPOWERSETTINGNOTIFICATION) (HPOWERNOTIFY);
 static REGISTERPOWERSETTINGNOTIFICATION sRegisterPowerSettingNotification = nsnull;
 static UNREGISTERPOWERSETTINGNOTIFICATION sUnregisterPowerSettingNotification = nsnull;
 static HPOWERNOTIFY sPowerHandle = nsnull;
 static HPOWERNOTIFY sCapacityHandle = nsnull;
 static HWND sHWnd = nsnull;
-#endif
-
 
 static bool
 IsVistaOrLater()
 {
   OSVERSIONINFO info;
 
   ZeroMemory(&info, sizeof(OSVERSIONINFO));
   info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
@@ -86,38 +83,35 @@ UpdateHandler(nsITimer* aTimer, void* aC
   if (sLastInfo.level() != currentInfo.level() ||
       sLastInfo.charging() != currentInfo.charging() ||
       sLastInfo.remainingTime() != currentInfo.remainingTime()) {
     hal::NotifyBatteryChange(currentInfo);
     sLastInfo = currentInfo;
   }
 }
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 static
 LRESULT CALLBACK
 BatteryWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
   if (msg != WM_POWERBROADCAST || wParam != PBT_POWERSETTINGCHANGE) {
     return DefWindowProc(hwnd, msg, wParam, lParam);
   }
 
   hal::BatteryInformation currentInfo;
 
   // Since we need update remainingTime, we cannot use LPARAM.
   hal_impl::GetCurrentBatteryInformation(&currentInfo);
 
   hal::NotifyBatteryChange(currentInfo);
   return TRUE;
 }
-#endif
 
 void
 EnableBatteryNotifications()
 {
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   if (IsVistaOrLater()) {
     // RegisterPowerSettingNotification is from Vista or later.
     // Use this API if available.
     HMODULE hUser32 = GetModuleHandleW(L"USER32.DLL");
     if (!sRegisterPowerSettingNotification)
       sRegisterPowerSettingNotification = (REGISTERPOWERSETTINGNOTIFICATION)
         GetProcAddress(hUser32, "RegisterPowerSettingNotification");
     if (!sUnregisterPowerSettingNotification)
@@ -158,17 +152,16 @@ EnableBatteryNotifications()
       sRegisterPowerSettingNotification(sHWnd,
                                         &GUID_ACDC_POWER_SOURCE,
                                         DEVICE_NOTIFY_WINDOW_HANDLE);
     sCapacityHandle =
       sRegisterPowerSettingNotification(sHWnd,
                                         &GUID_BATTERY_PERCENTAGE_REMAINING,
                                         DEVICE_NOTIFY_WINDOW_HANDLE);
   } else
-#endif
   {
     // for Windows 2000 and Windwos XP.  If we remove Windows XP support,
     // we should remove timer-based power notification
     sUpdateTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
     if (sUpdateTimer) {
       sUpdateTimer->InitWithFuncCallback(UpdateHandler,
                                          nsnull,
                                          Preferences::GetInt("dom.battery.timer",
@@ -176,34 +169,32 @@ EnableBatteryNotifications()
                                          nsITimer::TYPE_REPEATING_SLACK);
     } 
   }
 }
 
 void
 DisableBatteryNotifications()
 {
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   if (IsVistaOrLater()) {
     if (sPowerHandle) {
       sUnregisterPowerSettingNotification(sPowerHandle);
       sPowerHandle = nsnull;
     }
 
     if (sCapacityHandle) {
       sUnregisterPowerSettingNotification(sCapacityHandle);
       sCapacityHandle = nsnull;
     }
 
     if (sHWnd) {
       DestroyWindow(sHWnd);
       sHWnd = nsnull;
     }
   } else
-#endif
   {
     if (sUpdateTimer) {
       sUpdateTimer->Cancel();
       sUpdateTimer = nsnull;
     }
   }
 }
 
--- a/image/decoders/icon/win/nsIconChannel.cpp
+++ b/image/decoders/icon/win/nsIconChannel.cpp
@@ -55,22 +55,20 @@
 #include "nsIURL.h"
 #include "nsNetUtil.h"
 #include "nsIFile.h"
 #include "nsIFileURL.h"
 #include "nsIMIMEService.h"
 #include "nsCExternalHandlerService.h"
 #include "nsDirectoryServiceDefs.h"
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 #ifdef _WIN32_WINNT
 #undef _WIN32_WINNT
 #endif
 #define _WIN32_WINNT 0x0600
-#endif
 
 // we need windows.h to read out registry information...
 #include <windows.h>
 #include <shellapi.h>
 #include <shlobj.h>
 #include <objbase.h>
 #include <wchar.h>
 
@@ -88,29 +86,27 @@ struct ICONENTRY {
   PRUint8 ieColors;
   PRUint8 ieReserved;
   PRUint16 iePlanes;
   PRUint16 ieBitCount;
   PRUint32 ieSizeImage;
   PRUint32 ieFileOffset;
 };
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 typedef HRESULT (WINAPI*SHGetStockIconInfoPtr) (SHSTOCKICONID siid, UINT uFlags, SHSTOCKICONINFO *psii);
 
 // Match stock icons with names
 static SHSTOCKICONID GetStockIconIDForName(const nsACString &aStockName)
 {
   // UAC shield icon
   if (aStockName == NS_LITERAL_CSTRING("uac-shield"))
     return SIID_SHIELD;
 
   return SIID_INVALID;
 }
-#endif
 
 // nsIconChannel methods
 nsIconChannel::nsIconChannel()
 {
 }
 
 nsIconChannel::~nsIconChannel() 
 {}
@@ -378,17 +374,16 @@ nsresult nsIconChannel::GetHIconFromFile
   if (shellResult && sfi.hIcon)
     *hIcon = sfi.hIcon;
   else
     rv = NS_ERROR_NOT_AVAILABLE;
 
   return rv;
 }
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 nsresult nsIconChannel::GetStockHIcon(nsIMozIconURI *aIconURI, HICON *hIcon)
 {
   nsresult rv = NS_OK;
 
   // We can only do this on Vista or above
   HMODULE hShellDLL = ::LoadLibraryW(L"shell32.dll");
   SHGetStockIconInfoPtr pSHGetStockIconInfo =
     (SHGetStockIconInfoPtr) ::GetProcAddress(hShellDLL, "SHGetStockIconInfo");
@@ -421,17 +416,16 @@ nsresult nsIconChannel::GetStockHIcon(ns
     rv = NS_ERROR_NOT_AVAILABLE;
   }
 
   if (hShellDLL)
     ::FreeLibrary(hShellDLL);
 
   return rv;
 }
-#endif
 
 // Given a BITMAPINFOHEADER, returns the size of the color table.
 static int GetColorTableSize(BITMAPINFOHEADER* aHeader)
 {
   int colorTableSize = -1;
 
   // http://msdn.microsoft.com/en-us/library/dd183376%28v=VS.85%29.aspx
   switch (aHeader->biBitCount) {
@@ -495,26 +489,24 @@ static BITMAPINFO* CreateBitmapInfo(BITM
 nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, bool nonBlocking)
 {
   // Check whether the icon requested's a file icon or a stock icon
   nsresult rv = NS_ERROR_NOT_AVAILABLE;
 
   // GetDIBits does not exist on windows mobile.
   HICON hIcon = NULL;
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   nsCOMPtr<nsIMozIconURI> iconURI(do_QueryInterface(mUrl, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCAutoString stockIcon;
   iconURI->GetStockIcon(stockIcon);
   if (!stockIcon.IsEmpty())
     rv = GetStockHIcon(iconURI, &hIcon);
   else
-#endif
     rv = GetHIconFromFile(&hIcon);
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (hIcon)
   {
     // we got a handle to an icon. Now we want to get a bitmap for the icon using GetIconInfo....
     ICONINFO iconInfo;
--- a/image/decoders/icon/win/nsIconChannel.h
+++ b/image/decoders/icon/win/nsIconChannel.h
@@ -82,15 +82,13 @@ protected:
   nsCOMPtr<nsIInputStreamPump> mPump;
   nsCOMPtr<nsIStreamListener>  mListener;
 
   nsresult ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsCString &aContentType, nsCString &aFileExtension);
   nsresult GetHIconFromFile(HICON *hIcon);
   nsresult MakeInputStream(nsIInputStream** _retval, bool nonBlocking);
 
   // Functions specific to Vista and above
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 protected:
   nsresult GetStockHIcon(nsIMozIconURI *aIconURI, HICON *hIcon);
-#endif
 };
 
 #endif /* nsIconChannel_h___ */
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -930,18 +930,16 @@ EOF
         AC_MSG_RESULT("yes")
     else
         AC_MSG_RESULT("no")
         AC_MSG_ERROR([You are targeting Windows version 0x$MOZ_WINSDK_TARGETVER, but your SDK only supports up to version $MOZ_WINSDK_MAXVER. Install and use an updated SDK, or target a lower version using --with-windows-version. Alternatively, try running the Windows SDK Configuration Tool and selecting a newer SDK. See https://developer.mozilla.org/En/Windows_SDK_versions for more details on fixing this.])
     fi
 
     AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
     # Definitions matching sdkddkver.h
-    AC_DEFINE_UNQUOTED(MOZ_NTDDI_WS03, 0x05020000)
-    AC_DEFINE_UNQUOTED(MOZ_NTDDI_LONGHORN, 0x06000000)
     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
     ;;
 esac
 
 AC_PROG_CPP
 AC_PROG_CXXCPP
 
 if test -n "$_WIN32_MSVC"; then
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug728190.js
@@ -0,0 +1,23 @@
+
+function TestCase(n, d, e, a) {}
+var lfcode = new Array();
+lfcode.push("");
+lfcode.push("\
+  var summary = 'foo';\
+  test();\
+  function test() {\
+    test(\"TEST-UNEXPECTED-FAIL | TestPerf | \" + summary);\
+  }\
+");
+lfcode.push("gczeal(2);");
+lfcode.push("\
+  new TestCase(TestFunction_3( \"P\", \"A\", \"S\", \"S\" ) +\"\");\
+  new TestCase(TestFunction_4( \"F\", \"A\", (\"length\"), \"L\" ) +\"\");\
+  function TestFunction_3( a, b, c, d, e ) {\
+    TestFunction_3(arguments);\
+  }\
+");
+while (true) {
+        var file = lfcode.shift(); if (file == undefined) { break; }
+        try { evaluate(file); } catch (lfVare) {}
+}
--- a/js/src/jsanalyze.cpp
+++ b/js/src/jsanalyze.cpp
@@ -192,16 +192,18 @@ ScriptAnalysis::analyzeBytecode(JSContex
      * If the script is in debug mode, JS_SetFrameReturnValue can be called at
      * any safe point.
      */
     if (cx->compartment->debugMode())
         usesReturnValue_ = true;
 
     bool heavyweight = script->function() && script->function()->isHeavyweight();
 
+    isCompileable = true;
+
     isInlineable = true;
     if (script->nClosedArgs || script->nClosedVars || heavyweight ||
         script->usesEval || script->usesArguments || cx->compartment->debugMode()) {
         isInlineable = false;
     }
 
     modifiesArguments_ = false;
     if (script->nClosedArgs || heavyweight)
@@ -325,23 +327,24 @@ ScriptAnalysis::analyzeBytecode(JSContex
             break;
 
           case JSOP_SETRVAL:
           case JSOP_POPV:
             usesReturnValue_ = true;
             isInlineable = false;
             break;
 
+          case JSOP_QNAMEPART:
+          case JSOP_QNAMECONST:
+            isCompileable = false;
           case JSOP_NAME:
           case JSOP_CALLNAME:
           case JSOP_BINDNAME:
           case JSOP_SETNAME:
           case JSOP_DELNAME:
-          case JSOP_QNAMEPART:
-          case JSOP_QNAMECONST:
             checkAliasedName(cx, pc);
             usesScopeChain_ = true;
             isInlineable = false;
             break;
 
           case JSOP_DEFLOCALFUN:
           case JSOP_LAMBDA:
             usesScopeChain_ = true;
@@ -360,17 +363,17 @@ ScriptAnalysis::analyzeBytecode(JSContex
 
           case JSOP_EVAL:
             extendsScope_ = true;
             isInlineable = canTrackVars = false;
             break;
 
           case JSOP_ENTERWITH:
             addsScopeObjects_ = true;
-            isInlineable = canTrackVars = false;
+            isCompileable = isInlineable = canTrackVars = false;
             break;
 
           case JSOP_ENTERLET0:
           case JSOP_ENTERLET1:
           case JSOP_ENTERBLOCK:
           case JSOP_LEAVEBLOCK:
             addsScopeObjects_ = true;
             isInlineable = false;
@@ -485,17 +488,18 @@ ScriptAnalysis::analyzeBytecode(JSContex
             break;
           }
 
           case JSOP_CALLLOCAL:
           case JSOP_INCLOCAL:
           case JSOP_DECLOCAL:
           case JSOP_LOCALINC:
           case JSOP_LOCALDEC:
-          case JSOP_SETLOCAL: {
+          case JSOP_SETLOCAL:
+          case JSOP_SETLOCALPOP: {
             uint32_t local = GET_SLOTNO(pc);
             if (local >= script->nfixed) {
                 localsAliasStack_ = true;
                 break;
             }
             break;
           }
 
@@ -517,17 +521,115 @@ ScriptAnalysis::analyzeBytecode(JSContex
           case JSOP_GETFCSLOT:
           case JSOP_CALLFCSLOT:
           case JSOP_DEBUGGER:
           case JSOP_FUNCALL:
           case JSOP_FUNAPPLY:
             isInlineable = false;
             break;
 
+          /* Additional opcodes which can be both compiled both normally and inline. */
+          case JSOP_NOP:
+          case JSOP_UNDEFINED:
+          case JSOP_GOTO:
+          case JSOP_DEFAULT:
+          case JSOP_IFEQ:
+          case JSOP_IFNE:
+          case JSOP_ITERNEXT:
+          case JSOP_DUP:
+          case JSOP_DUP2:
+          case JSOP_SWAP:
+          case JSOP_PICK:
+          case JSOP_BITOR:
+          case JSOP_BITXOR:
+          case JSOP_BITAND:
+          case JSOP_LT:
+          case JSOP_LE:
+          case JSOP_GT:
+          case JSOP_GE:
+          case JSOP_EQ:
+          case JSOP_NE:
+          case JSOP_LSH:
+          case JSOP_RSH:
+          case JSOP_URSH:
+          case JSOP_ADD:
+          case JSOP_SUB:
+          case JSOP_MUL:
+          case JSOP_DIV:
+          case JSOP_MOD:
+          case JSOP_NOT:
+          case JSOP_BITNOT:
+          case JSOP_NEG:
+          case JSOP_POS:
+          case JSOP_DELPROP:
+          case JSOP_DELELEM:
+          case JSOP_TYPEOF:
+          case JSOP_TYPEOFEXPR:
+          case JSOP_VOID:
+          case JSOP_GETPROP:
+          case JSOP_CALLPROP:
+          case JSOP_LENGTH:
+          case JSOP_GETELEM:
+          case JSOP_CALLELEM:
+          case JSOP_TOID:
+          case JSOP_SETELEM:
+          case JSOP_IMPLICITTHIS:
+          case JSOP_DOUBLE:
+          case JSOP_STRING:
+          case JSOP_ZERO:
+          case JSOP_ONE:
+          case JSOP_NULL:
+          case JSOP_FALSE:
+          case JSOP_TRUE:
+          case JSOP_OR:
+          case JSOP_AND:
+          case JSOP_CASE:
+          case JSOP_STRICTEQ:
+          case JSOP_STRICTNE:
+          case JSOP_ITER:
+          case JSOP_MOREITER:
+          case JSOP_ENDITER:
+          case JSOP_POP:
+          case JSOP_GETARG:
+          case JSOP_CALLARG:
+          case JSOP_BINDGNAME:
+          case JSOP_UINT16:
+          case JSOP_NEWINIT:
+          case JSOP_NEWARRAY:
+          case JSOP_NEWOBJECT:
+          case JSOP_ENDINIT:
+          case JSOP_INITMETHOD:
+          case JSOP_INITPROP:
+          case JSOP_INITELEM:
+          case JSOP_SETPROP:
+          case JSOP_SETMETHOD:
+          case JSOP_IN:
+          case JSOP_INSTANCEOF:
+          case JSOP_LINENO:
+          case JSOP_ENUMELEM:
+          case JSOP_CONDSWITCH:
+          case JSOP_LABEL:
+          case JSOP_RETRVAL:
+          case JSOP_GETGNAME:
+          case JSOP_CALLGNAME:
+          case JSOP_SETGNAME:
+          case JSOP_REGEXP:
+          case JSOP_OBJECT:
+          case JSOP_UINT24:
+          case JSOP_GETXPROP:
+          case JSOP_INT8:
+          case JSOP_INT32:
+          case JSOP_HOLE:
+          case JSOP_LOOPHEAD:
+          case JSOP_LOOPENTRY:
+            break;
+
           default:
+            if (!(js_CodeSpec[op].format & JOF_DECOMPOSE))
+                isCompileable = isInlineable = false;
             break;
         }
 
         uint32_t type = JOF_TYPE(js_CodeSpec[op].format);
 
         /* Check basic jump opcodes, which may or may not have a fallthrough. */
         if (type == JOF_JUMP) {
             /* Some opcodes behave differently on their branching path. */
--- a/js/src/jsanalyze.h
+++ b/js/src/jsanalyze.h
@@ -897,16 +897,17 @@ class ScriptAnalysis
     bool usesScopeChain_:1;
     bool usesThisValue_:1;
     bool hasFunctionCalls_:1;
     bool modifiesArguments_:1;
     bool extendsScope_:1;
     bool addsScopeObjects_:1;
     bool localsAliasStack_:1;
     bool isInlineable:1;
+    bool isCompileable:1;
     bool canTrackVars:1;
 
     uint32_t numReturnSites_;
 
     /* --------- Lifetime analysis --------- */
 
     LifetimeVariable *lifetimes;
 
@@ -932,16 +933,17 @@ class ScriptAnalysis
 
     /* Analyze the effect of invoking 'new' on script. */
     void analyzeTypesNew(JSContext *cx);
 
     bool OOM() const { return outOfMemory; }
     bool failed() const { return hadFailure; }
     bool inlineable() const { return isInlineable; }
     bool inlineable(uint32_t argc) const { return isInlineable && argc == script->function()->nargs; }
+    bool compileable() { return isCompileable; }
 
     /* Whether there are POPV/SETRVAL bytecodes which can write to the frame's rval. */
     bool usesReturnValue() const { return usesReturnValue_; }
 
     /* Whether there are NAME bytecodes which can access the frame's scope chain. */
     bool usesScopeChain() const { return usesScopeChain_; }
 
     bool usesThisValue() const { return usesThisValue_; }
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -3328,16 +3328,19 @@ ScriptAnalysis::resolveNameAccess(JSCont
                 /*
                  * Record the dependency which compiled code has on the outer
                  * function being non-reentrant.
                  */
                 if (TypeSet::HasObjectFlags(cx, obj, OBJECT_FLAG_REENTRANT_FUNCTION))
                     return access;
             }
 
+            if (!script->isOuterFunction)
+                return access;
+
             access.script = script;
             access.nesting = script->nesting();
             access.slot = (kind == ARGUMENT) ? ArgSlot(index) : LocalSlot(script, index);
             access.arg = (kind == ARGUMENT);
             access.index = index;
             return access;
         } else if (kind != NONE) {
             return access;
--- a/js/src/methodjit/Compiler.cpp
+++ b/js/src/methodjit/Compiler.cpp
@@ -76,24 +76,16 @@ using namespace js::mjit::ic;
 using namespace js::analyze;
 
 #define RETURN_IF_OOM(retval)                                   \
     JS_BEGIN_MACRO                                              \
         if (oomInVector || masm.oom() || stubcc.masm.oom())     \
             return retval;                                      \
     JS_END_MACRO
 
-#if defined(JS_METHODJIT_SPEW)
-static const char *OpcodeNames[] = {
-# define OPDEF(op,val,name,token,length,nuses,ndefs,prec,format) #name,
-# include "jsopcode.tbl"
-# undef OPDEF
-};
-#endif
-
 /*
  * Number of times a script must be called or had a backedge before we try to
  * inline its calls.
  */
 static const size_t USES_BEFORE_INLINING = 10000;
 
 mjit::Compiler::Compiler(JSContext *cx, JSScript *outerScript,
                          unsigned chunkIndex, bool isConstructing)
@@ -172,23 +164,24 @@ mjit::Compiler::compile()
 CompileStatus
 mjit::Compiler::checkAnalysis(JSScript *script)
 {
     if (script->hasClearedGlobal()) {
         JaegerSpew(JSpew_Abort, "script has a cleared global\n");
         return Compile_Abort;
     }
 
-    if (JSOp(*script->code) == JSOP_GENERATOR) {
-        JaegerSpew(JSpew_Abort, "script is a generator\n");
-        return Compile_Abort;
-    }
-
     if (!script->ensureRanAnalysis(cx, NULL))
         return Compile_Error;
+
+    if (!script->analysis()->compileable()) {
+        JaegerSpew(JSpew_Abort, "script has uncompileable opcodes\n");
+        return Compile_Abort;
+    }
+
     if (cx->typeInferenceEnabled() && !script->ensureRanInference(cx))
         return Compile_Error;
 
     ScriptAnalysis *analysis = script->analysis();
     analysis->assertMatchingDebugMode();
     if (analysis->failed()) {
         JaegerSpew(JSpew_Abort, "couldn't analyze bytecode; probably switchX or OOM\n");
         return Compile_Abort;
@@ -3256,22 +3249,17 @@ mjit::Compiler::generateMethod()
           {
             prepareStubCall(Uses(0));
             masm.move(ImmPtr(PC), Registers::ArgReg1);
             INLINE_STUBCALL(stubs::DebuggerStatement, REJOIN_FALLTHROUGH);
           }
           END_CASE(JSOP_DEBUGGER)
 
           default:
-           /* Sorry, this opcode isn't implemented yet. */
-#ifdef JS_METHODJIT_SPEW
-            JaegerSpew(JSpew_Abort, "opcode %s not handled yet (%s line %d)\n", OpcodeNames[op],
-                       script->filename, js_PCToLineNumber(cx, script, PC));
-#endif
-            return Compile_Abort;
+            JS_NOT_REACHED("Opcode not implemented");
         }
 
     /**********************
      *  END COMPILER OPS  *
      **********************/
 
         if (cx->typeInferenceEnabled() && PC == lastPC + GetBytecodeLength(lastPC)) {
             /*
--- a/js/src/methodjit/StubCalls.cpp
+++ b/js/src/methodjit/StubCalls.cpp
@@ -1358,19 +1358,20 @@ stubs::FlatLambda(VMFrame &f, JSFunction
     if (!obj)
         THROWV(NULL);
     return obj;
 }
 
 void JS_FASTCALL
 stubs::Arguments(VMFrame &f)
 {
-    f.regs.sp++;
-    if (!js_GetArgsValue(f.cx, f.fp(), &f.regs.sp[-1]))
+    Value argsobj;
+    if (!js_GetArgsValue(f.cx, f.fp(), &argsobj))
         THROW();
+    f.regs.sp[0] = argsobj;
 }
 
 JSBool JS_FASTCALL
 stubs::InstanceOf(VMFrame &f)
 {
     JSContext *cx = f.cx;
     FrameRegs &regs = f.regs;
 
--- a/layout/Makefile.in
+++ b/layout/Makefile.in
@@ -72,16 +72,15 @@ DIRS           += media
 ifdef ENABLE_TESTS
 PARALLEL_DIRS += \
   mathml/tests \
   xul/test \
   xul/base/test \
   $(NULL)
 
 TOOL_DIRS      += tools/reftest reftests/fonts reftests/fonts/mplus
-DIRS           += tools/pageloader
 
 ifdef MOZ_DEBUG
 DIRS            += tools/layout-debug
 endif
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -424,44 +424,42 @@ nsHTMLScrollFrame::TryLayout(ScrollReflo
   desiredInsideBorderSize.width = vScrollbarDesiredWidth +
     NS_MAX(aKidMetrics->width, hScrollbarMinWidth);
   desiredInsideBorderSize.height = hScrollbarDesiredHeight +
     NS_MAX(aKidMetrics->height, vScrollbarMinHeight);
   aState->mInsideBorderSize =
     ComputeInsideBorderSize(aState, desiredInsideBorderSize);
   nsSize scrollPortSize = nsSize(NS_MAX(0, aState->mInsideBorderSize.width - vScrollbarDesiredWidth),
                                  NS_MAX(0, aState->mInsideBorderSize.height - hScrollbarDesiredHeight));
-                                                                                
+
   if (!aForce) {
     nsRect scrolledRect =
       mInner.GetScrolledRectInternal(aState->mContentsOverflowAreas.ScrollableOverflow(),
                                      scrollPortSize);
     nscoord oneDevPixel = aState->mBoxState.PresContext()->DevPixelsToAppUnits(1);
 
     // If the style is HIDDEN then we already know that aAssumeHScroll is false
     if (aState->mStyles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) {
       bool wantHScrollbar =
         aState->mStyles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL ||
         scrolledRect.XMost() >= scrollPortSize.width + oneDevPixel ||
         scrolledRect.x <= -oneDevPixel;
-      if (aState->mInsideBorderSize.height < hScrollbarMinSize.height ||
-          scrollPortSize.width < hScrollbarMinSize.width)
+      if (scrollPortSize.width < hScrollbarMinSize.width)
         wantHScrollbar = false;
       if (wantHScrollbar != aAssumeHScroll)
         return false;
     }
 
     // If the style is HIDDEN then we already know that aAssumeVScroll is false
     if (aState->mStyles.mVertical != NS_STYLE_OVERFLOW_HIDDEN) {
       bool wantVScrollbar =
         aState->mStyles.mVertical == NS_STYLE_OVERFLOW_SCROLL ||
         scrolledRect.YMost() >= scrollPortSize.height + oneDevPixel ||
         scrolledRect.y <= -oneDevPixel;
-      if (aState->mInsideBorderSize.width < vScrollbarMinSize.width ||
-          scrollPortSize.height < vScrollbarMinSize.height)
+      if (scrollPortSize.height < vScrollbarMinSize.height)
         wantVScrollbar = false;
       if (wantVScrollbar != aAssumeVScroll)
         return false;
     }
   }
 
   nscoord vScrollbarActualWidth = aState->mInsideBorderSize.width - scrollPortSize.width;
 
--- a/layout/reftests/abs-pos/button-1.html
+++ b/layout/reftests/abs-pos/button-1.html
@@ -7,17 +7,17 @@ position:relative;
 left:0px;
 top:0px;
 width:
 200px;
 height:100px;
 border:none;
 background:#00ff00;
 -moz-appearance: none;
--moz-border-radius: 0 !important;
+border-radius: 0 !important;
 }
 div {
 position:absolute;
 left:0px;
 top:0px;
 width:50px;
 height:50px;
 background:#ff0000;
--- a/layout/reftests/abs-pos/button-2.html
+++ b/layout/reftests/abs-pos/button-2.html
@@ -7,17 +7,17 @@ position:relative;
 padding:0;
 background:green;
 width: 200px;
 height: 100px;
 border:none;
 text-align: left;
 font: 12px serif;
 -moz-appearance: none;
--moz-border-radius: 0 !important;
+border-radius: 0 !important;
 }
 button span {
 display:block;
 position:absolute;
 right:0;
 top:0;
 width:10px;
 height:100%;
--- a/layout/reftests/border-radius/zero-radius-clip-1.html
+++ b/layout/reftests/border-radius/zero-radius-clip-1.html
@@ -1,7 +1,7 @@
 <html>
 <body>
-<div style="background: blue; height: 100px; border-radius: 0 0 0 0; -moz-border-radius: 0 0 0 0;">
+<div style="background: blue; height: 100px; border-radius: 0 0 0 0; border-radius: 0 0 0 0;">
   <div style="background: purple; height: 50px;"></div>
 </div>
 </body>
 </html>
--- a/layout/reftests/bugs/536061-ref.html
+++ b/layout/reftests/bugs/536061-ref.html
@@ -1,50 +1,50 @@
 <!DOCTYPE html>
 
 <html lang="en">
 <head>
   <meta http-equiv="content-type" content="text/html; charset=utf-8" />
-  <title>Bugs with -moz-transform: rotate() and -moz-box-shadow</title>
+  <title>Bugs with -moz-transform: rotate() and box-shadow</title>
 
   <style>
     body {
         overflow: hidden;
     }
 
     .label {
         position: absolute;
         top: 200px;
         left: 196px;
         margin: 0;
         height:16px;
         width: 300px;
-        -moz-box-shadow: 0 0 .7em black;
+        box-shadow: 0 0 .7em black;
         border: 1px black solid;
     }
     .vlabel {
         position: absolute;
         top: 58px;
         left: 42px;
         margin: 0;
         width: 16px;
         height: 300px;
-        -moz-box-shadow: 0 0 .7em black;
+        box-shadow: 0 0 .7em black;
         border: 1px black solid;
     }
   </style>
 </head>
 
 <body>
 
 <p class="label"></p>
-<p class="label" style="top: 400px; -moz-box-shadow:none; outline: 3px dashed blue;"></p>
-<p class="vlabel" style="-moz-box-shadow:none; outline: 3px dashed blue;"></p>
+<p class="label" style="top: 400px; box-shadow:none; outline: 3px dashed blue;"></p>
+<p class="vlabel" style="box-shadow:none; outline: 3px dashed blue;"></p>
 <p class="vlabel" style="left:102px; "></p>
-<p class="vlabel" style="top:454px; -moz-box-shadow:none; outline: 3px dashed blue; "></p>
+<p class="vlabel" style="top:454px; box-shadow:none; outline: 3px dashed blue; "></p>
 <p class="vlabel" style="top:454px; left:102px;"></p>
 
 <!-- cover a few shadow corners which are a bit different -->
 <div style="position:absolute; top:40px; left:85px; width:50px; height:50px; background:black; z-index:99;"></div>
 <div style="position:absolute; top:340px; left:85px; width:50px; height:50px; background:black; z-index:99;"></div>
 <div style="position:absolute; top:420px; left:85px; width:50px; height:50px; background:black; z-index:99;"></div>
 <div style="position:absolute; top:730px; left:85px; width:50px; height:50px; background:black; z-index:99;"></div>
 
--- a/layout/reftests/bugs/536061.html
+++ b/layout/reftests/bugs/536061.html
@@ -1,51 +1,51 @@
 <!DOCTYPE html>
 
 <html lang="en">
 <head>
   <meta http-equiv="content-type" content="text/html; charset=utf-8" />
-  <title>Bugs with -moz-transform: rotate() and -moz-box-shadow</title>
+  <title>Bugs with -moz-transform: rotate() and box-shadow</title>
 
   <style>
     body {
         overflow: hidden;
     }
 
     .label {
         position: absolute;
         top: 200px;
         left: 100px;
         margin: 0;
         height: 16px;
         width: 300px;
         -moz-transform: translate(96px);
-        -moz-box-shadow: 0 0 .7em black;
+        box-shadow: 0 0 .7em black;
         border: 1px black solid;
     }
     .vlabel {
         position: absolute;
         top: 40px;
         left: 40px;
         margin: 0;
         width: 16px;
         height: 300px;
-        -moz-box-shadow: 0 0 .7em black;
+        box-shadow: 0 0 .7em black;
         border: 1px black solid;
     }
   </style>
 </head>
 
 <body>
 
 <p class="label"></p>
-<p class="label" style="top: 400px; -moz-box-shadow:none; outline: 3px dashed blue;"></p>
-<p class="label" style="left:-100px; top: 200px; -moz-box-shadow:none; outline: 3px dashed blue; -moz-transform: rotate(90deg);"></p>
+<p class="label" style="top: 400px; box-shadow:none; outline: 3px dashed blue;"></p>
+<p class="label" style="left:-100px; top: 200px; box-shadow:none; outline: 3px dashed blue; -moz-transform: rotate(90deg);"></p>
 <p class="label" style="left:-40px; top: 200px; -moz-transform: rotate(90deg);"></p>
-<p class="label" style="left:-100px; top: 200px; -moz-box-shadow:none; outline: 3px dashed blue; -moz-transform: translate(0,396px) rotate(90deg);"></p>
+<p class="label" style="left:-100px; top: 200px; box-shadow:none; outline: 3px dashed blue; -moz-transform: translate(0,396px) rotate(90deg);"></p>
 <p class="label" style="left:-40px; top: 200px; -moz-transform: translate(0,396px) rotate(90deg);"></p>
 
 <!-- cover a few shadow corners which are a bit different -->
 <div style="position:absolute; top:40px; left:85px; width:50px; height:50px; background:black; z-index:99;"></div>
 <div style="position:absolute; top:340px; left:85px; width:50px; height:50px; background:black; z-index:99;"></div>
 <div style="position:absolute; top:420px; left:85px; width:50px; height:50px; background:black; z-index:99;"></div>
 <div style="position:absolute; top:730px; left:85px; width:50px; height:50px; background:black; z-index:99;"></div>
 
new file mode 100644
--- /dev/null
+++ b/layout/reftests/scrolling/less-than-scrollbar-height-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html><head>
+<title>Testcase for bug 726258</title>
+  <style>
+    html,body{ overflow:hidden; margin:0; padding:0; }
+    p { overflow: auto; white-space: nowrap; font-size: 13px; padding-top:100px; margin-top:-100px; }
+  </style>
+</head>
+  <p>
+1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890
+</p>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/scrolling/less-than-scrollbar-height.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html><head>
+<title>Testcase for bug 726258</title>
+  <style>
+    html,body{ overflow:hidden; margin:0; padding:0; }
+    p { overflow: auto; white-space: nowrap; font-size: 13px; margin-top:0; }
+  </style>
+</head>
+  <p>
+1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890
+</p>
--- a/layout/reftests/scrolling/reftest.list
+++ b/layout/reftests/scrolling/reftest.list
@@ -7,8 +7,9 @@ HTTP == fixed-text-2.html fixed-text-2.h
 HTTP == opacity-mixed-scrolling-1.html opacity-mixed-scrolling-1.html?ref
 random-if(cocoaWidget) HTTP == opacity-mixed-scrolling-2.html opacity-mixed-scrolling-2.html?ref # see bug 625357
 HTTP == simple-1.html simple-1.html?ref
 HTTP == text-1.html text-1.html?ref
 HTTP == transformed-1.html transformed-1.html?ref
 HTTP == transformed-1.html?up transformed-1.html?ref
 == uncovering-1.html uncovering-1-ref.html
 == uncovering-2.html uncovering-2-ref.html
+== less-than-scrollbar-height.html less-than-scrollbar-height-ref.html
--- a/layout/reftests/svg/smil/reftest.list
+++ b/layout/reftests/svg/smil/reftest.list
@@ -117,17 +117,17 @@ fails == anim-fillcolor-1.svg      anim-
 == anim-marker-orient-01.svg lime.svg
 == anim-marker-orient-02.svg lime.svg
 
 #animate points list:
 == anim-polygon-points-01.svg anim-polygon-points-01-ref.svg
 == anim-polyline-points-01.svg anim-polyline-points-01-ref.svg
 
 # animate path data:
-== anim-path-d-01.svg anim-path-d-01-ref.svg
+fuzzy-if(/^Windows\x20NT\x205\.1/.test(http.oscpu),2,1) == anim-path-d-01.svg anim-path-d-01-ref.svg # Bug 726400
 
 # animate some enumeration attributes:
 == anim-feComposite-operator-01.svg lime.svg
 == anim-filter-filterUnits-01.svg lime.svg
 
 # animate some boolean attributes:
 == anim-feConvolveMatrix-preserveAlpha-01.svg lime.svg
 
new file mode 100644
--- /dev/null
+++ b/layout/style/crashtests/729126-1.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<body style="-moz-transition-duration: 1ms"></body>
+<script>
+var body = document.body;
+/* flush */ getComputedStyle(body, "").background;
+body.style.background = 'url(none.png), repeat';
+/* flush */ getComputedStyle(body, "").background;
+</script>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/style/crashtests/729126-2.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<body style="background-size: cover; -moz-transition-duration: 1ms"></body>
+<script>
+var body = document.body;
+/* flush */ getComputedStyle(body, "").backgroundSize;
+body.style.backgroundSize = 'contain';
+/* flush */ getComputedStyle(body, "").backgroundSize;
+</script>
+</html>
--- a/layout/style/crashtests/crashtests.list
+++ b/layout/style/crashtests/crashtests.list
@@ -70,8 +70,10 @@ load 645142.html
 load 611922-1.html
 == 645951-1.html 645951-1-ref.html
 load 665209-1.html
 asserts(2) load 671799-1.html
 asserts(2) load 671799-2.html
 load 690990-1.html
 load 696188-1.html
 load 700116.html
+load 729126-1.html
+load 729126-2.html
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -312,69 +312,69 @@ nsCSSProps::ReleaseTable(void)
     delete gFontDescTable;
     gFontDescTable = nsnull;
 
     delete [] gShorthandsContainingPool;
     gShorthandsContainingPool = nsnull;
   }
 }
 
+#if 0 /* aliases code */
 struct CSSPropertyAlias {
-  char name[sizeof("-moz-border-radius-bottomright")];
+  char name[sizeof("-moz-...")];
   nsCSSProperty id;
 };
 
 static const CSSPropertyAlias gAliases[] = {
-  { "-moz-border-radius", eCSSProperty_border_radius },
-  { "-moz-border-radius-bottomleft", eCSSProperty_border_bottom_left_radius },
-  { "-moz-border-radius-bottomright", eCSSProperty_border_bottom_right_radius },
-  { "-moz-border-radius-topleft", eCSSProperty_border_top_left_radius },
-  { "-moz-border-radius-topright", eCSSProperty_border_top_right_radius },
-  { "-moz-box-shadow", eCSSProperty_box_shadow },
   // Don't forget to update the sizeof in CSSPropertyAlias above with the
   // longest string when you add stuff here.
 };
+#endif
 
 nsCSSProperty
 nsCSSProps::LookupProperty(const nsACString& aProperty)
 {
   NS_ABORT_IF_FALSE(gPropertyTable, "no lookup table, needs addref");
 
   nsCSSProperty res = nsCSSProperty(gPropertyTable->Lookup(aProperty));
+#if 0 /* aliases code */
   if (res == eCSSProperty_UNKNOWN) {
     for (const CSSPropertyAlias *alias = gAliases,
                             *alias_end = ArrayEnd(gAliases);
          alias < alias_end; ++alias) {
       if (aProperty.LowerCaseEqualsASCII(alias->name)) {
         res = alias->id;
         break;
       }
     }
   }
+#endif
   return res;
 }
 
 nsCSSProperty
 nsCSSProps::LookupProperty(const nsAString& aProperty)
 {
   // This is faster than converting and calling
   // LookupProperty(nsACString&).  The table will do its own
   // converting and avoid a PromiseFlatCString() call.
   NS_ABORT_IF_FALSE(gPropertyTable, "no lookup table, needs addref");
   nsCSSProperty res = nsCSSProperty(gPropertyTable->Lookup(aProperty));
+#if 0 /* aliases code */
   if (res == eCSSProperty_UNKNOWN) {
     for (const CSSPropertyAlias *alias = gAliases,
                             *alias_end = ArrayEnd(gAliases);
          alias < alias_end; ++alias) {
       if (aProperty.LowerCaseEqualsASCII(alias->name)) {
         res = alias->id;
         break;
       }
     }
   }
+#endif
   return res;
 }
 
 nsCSSFontDesc
 nsCSSProps::LookupFontDesc(const nsACString& aFontDesc)
 {
   NS_ABORT_IF_FALSE(gFontDescTable, "no lookup table, needs addref");
   return nsCSSFontDesc(gFontDescTable->Lookup(aFontDesc));
--- a/layout/style/nsStyleAnimation.cpp
+++ b/layout/style/nsStyleAnimation.cpp
@@ -875,22 +875,16 @@ AddCSSValuePixelPercentCalc(const PRUint
                          aResult, aValueRestrictions);
       break;
     case eCSSUnit_Calc:
       AddCSSValueCanonicalCalc(aCoeff1, aValue1,
                                aCoeff2, aValue2,
                                aResult);
       break;
     default:
-      NS_ABORT_IF_FALSE(false,
-                        nsPrintfCString(32,
-                                        "unexpected unit %d, from %d and %d",
-                                        aCommonUnit,
-                                        aValue1.GetUnit(),
-                                        aValue2.GetUnit()).get());
       return false;
   }
 
   return true;
 }
 
 static bool
 AddShadowItems(double aCoeff1, const nsCSSValue &aValue1,
@@ -1817,16 +1811,17 @@ nsStyleAnimation::AddWeighted(nsCSSPrope
       };
       PRUint32 restrictions = nsCSSProps::ValueRestrictions(aProperty);
       for (PRUint32 i = 0; i < 2; ++i) {
         nsCSSValue nsCSSValuePair::*member = pairValues[i];
         if (!AddCSSValuePixelPercentCalc(restrictions, unit[i],
                                          aCoeff1, pair1->*member,
                                          aCoeff2, pair2->*member,
                                          result->*member) ) {
+          NS_ABORT_IF_FALSE(false, "unexpected unit");
           return false;
         }
       }
 
       aResultValue.SetAndAdoptCSSValuePairValue(result.forget(),
                                                 eUnit_CSSValuePair);
       return true;
     }
@@ -1859,16 +1854,17 @@ nsStyleAnimation::AddWeighted(nsCSSPrope
       };
       PRUint32 restrictions = nsCSSProps::ValueRestrictions(aProperty);
       for (PRUint32 i = 0; i < 3; ++i) {
         nsCSSValue nsCSSValueTriplet::*member = tripletValues[i];
         if (!AddCSSValuePixelPercentCalc(restrictions, unit[i],
                                          aCoeff1, &triplet1->*member,
                                          aCoeff2, &triplet2->*member,
                                          result->*member) ) {
+          NS_ABORT_IF_FALSE(false, "unexpected unit");
           return false;
         }
       }
 
       if (result->mZValue.GetUnit() == eCSSUnit_Pixel &&
           result->mZValue.GetFloatValue() == 0.0f) {
         result->mZValue.Reset();
       }
deleted file mode 100644
--- a/layout/tools/pageloader/Makefile.in
+++ /dev/null
@@ -1,52 +0,0 @@
-# vim: set shiftwidth=8 tabstop=8 autoindent noexpandtab copyindent:
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is Mozilla's pageloader test
-#
-# The Initial Developer of the Original Code is the Mozilla Foundation.
-# Portions created by the Initial Developer are Copyright (C) 2007
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Vladimir Vukicevic <vladimir@pobox.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-DEPTH		= ../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE		= layout
-
-EXTRA_COMPONENTS= \
-		tp-cmdline.js \
-		tp-cmdline.manifest \
-		$(NULL)
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/layout/tools/pageloader/README
+++ /dev/null
@@ -1,81 +0,0 @@
-Pageload Test Component
-=======================
-
-Usage:
-
-  ./firefox -tp file:///path/to/manifest.txt [-tpargs...]
-
-See ./firefox -help for other arguments.
-
-
-Manifest file format
-====================
-
-Comments in the manifest file start with a #.  Each line may be:
-
-* a URL (absolute or relative to the manifest)
-
-This URL is added to the list of tests.
-
-* one or more flags, followed by whitespace, followed by a URL
-
-The only flag supported currently is '%', which indicates that
-a test will do its own timing.  (See Self-timing Tests below.)
-
-* "include" followed by whitespace, followed by a URL
-
-Parse the given manifest file.
-
-Self-timing Tests
-=================
-
-Most timing tests are interested in timing how long it takes the page
-to load; that is, from the start of page loading until the 'load'
-event is dispatched.  By default, this is what the pageloader will
-time.  However, if a test URL has the % flag, the test is expected to
-report its own timing.  For this purpose, the pageloader will provide
-a function named "tpRecordTime" in the test's global object that it
-should call once it has performed whatever timing it wants to do.
-The given value will be used as the timing result for this test.
-
-Output format
-=============
-
-The result is a dump to stdout via dump() --
-browser.dom.window.dump.enabled must be set to true in the profile.  A
-number of output formats can be specified via the -tpformat command
-line option, currently 'js', 'text', and 'tinderbox' are supported.
-
-Sample 'js' format output:
-
-([({page:"1280x1024-PNG/index.html", value:133, stddev:20.049937655763422}),({page:"bugzilla.mozilla.org/index.html", value:233, stddev:36.66606060105176}),({page:"espn.go.com/index.html", value:117.6, stddev:1.2}),({page:"home.netscape.com/index.html", value:97.8, stddev:47.41898354035017}),])
-
-Sample 'text' format output:
-
-============================================================
-    Page                                     mean  stdd   min   max raw
-  0 1280x1024-PNG/index.html                  133    20   121   297 297,173,122,121,124,125
-  1 bugzilla.mozilla.org/index.html           233    37   192   395 395,273,223,192,198,279
-  2 espn.go.com/index.html                    118     1   116   254 254,117,116,119,119,117
-  3 home.netscape.com/index.html               98    47     3   124 3,121,120,124,124,121
-============================================================
-
-Sample 'tinderbox' format output:
-
-__start_tp_report
-_x_x_mozilla_page_load,778.5,NaN,NaN
-_x_x_mozilla_page_load_details,avgmedian|778.5|average|766.75|minimum|NaN|maximum|NaN|stddev|NaN|0;file:///c:/proj/mozilla-cvs/perf/tp2/base/www.cnn.com/index.html;778.5;766.75;722;1027;1027;788;777;722;780|...
-__end_tp_report
-
-Note that the minimum, maximum, stddev are not calculated; they're
-always reported as NaN.  (They were the minimum and maximum values of
-any sampled value, and the standard deviation across all sampled
-values -- not very useful.)
-
-TODO
-====
-
-* Command line option to choose whether to run with or without browser chrome.  Currently runs without.
-
-* Tinderbox-dropping style output
-  * better yet would be to teach tinderbox about JSON
deleted file mode 100644
--- a/layout/tools/pageloader/jar.mn
+++ /dev/null
@@ -1,6 +0,0 @@
-pageloader.jar:
-% content pageloader %content/
-* content/quit.js (quit.js)
-* content/pageloader.js (pageloader.js)
-  content/pageloader.xul (pageloader.xul)
-* content/report.js (report.js)
deleted file mode 100644
--- a/layout/tools/pageloader/pageloader.js
+++ /dev/null
@@ -1,441 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tp.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2007
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Rob Helmer <rhelmer@mozilla.com>
- *   Vladimir Vukicevic <vladimir@mozilla.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
-var NUM_CYCLES = 5;
-
-var pageFilterRegexp = null;
-var reportFormat = "js";
-var useBrowser = true;
-var winWidth = 1024;
-var winHeight = 768;
-
-var doRenderTest = false;
-
-var pages;
-var pageIndex;
-var start_time;
-var cycle;
-var report;
-var renderReport;
-var noisy = false;
-var timeout = -1;
-var timeoutEvent = -1;
-var running = false;
-var forceCC = true;
-
-var content;
-
-var TEST_DOES_OWN_TIMING = 1;
-
-var browserWindow = null;
-
-// the io service
-var gIOS = null;
-
-function plInit() {
-  if (running) {
-    return;
-  }
-  running = true;
-
-  cycle = 0;
-
-  try {
-    var args = window.arguments[0].wrappedJSObject;
-
-    var manifestURI = args.manifest;
-    var startIndex = 0;
-    var endIndex = -1;
-    if (args.startIndex) startIndex = parseInt(args.startIndex);
-    if (args.endIndex) endIndex = parseInt(args.endIndex);
-    if (args.numCycles) NUM_CYCLES = parseInt(args.numCycles);
-    if (args.format) reportFormat = args.format;
-    if (args.width) winWidth = parseInt(args.width);
-    if (args.height) winHeight = parseInt(args.height);
-    if (args.filter) pageFilterRegexp = new RegExp(args.filter);
-    if (args.noisy) noisy = true;
-    if (args.timeout) timeout = parseInt(args.timeout);
-    forceCC = !args.noForceCC;
-    doRenderTest = args.doRender;
-
-    if (forceCC &&
-        !window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-               .getInterface(Components.interfaces.nsIDOMWindowUtils)
-               .garbageCollect) {
-      forceCC = false;
-    }
-
-    gIOS = Cc["@mozilla.org/network/io-service;1"]
-      .getService(Ci.nsIIOService);
-    if (args.offline)
-      gIOS.offline = true;
-    var fileURI = gIOS.newURI(manifestURI, null, null);
-    pages = plLoadURLsFromURI(fileURI);
-
-    if (!pages) {
-      dumpLine('tp: could not load URLs, quitting');
-      plStop(true);
-    }
-
-    if (pages.length == 0) {
-      dumpLine('tp: no pages to test, quitting');
-      plStop(true);
-    }
-
-    if (startIndex < 0)
-      startIndex = 0;
-    if (endIndex == -1 || endIndex >= pages.length)
-      endIndex = pages.length-1;
-    if (startIndex > endIndex) {
-      dumpLine("tp: error: startIndex >= endIndex");
-      plStop(true);
-    }
-
-    pages = pages.slice(startIndex,endIndex+1);
-    var pageUrls = pages.map(function(p) { return p.url.spec.toString(); });
-    report = new Report(pageUrls);
-
-    if (doRenderTest)
-      renderReport = new Report(pageUrls);
-
-    pageIndex = 0;
-
-    if (args.useBrowserChrome) {
-      var wwatch = Cc["@mozilla.org/embedcomp/window-watcher;1"]
-        .getService(Ci.nsIWindowWatcher);
-      var blank = Cc["@mozilla.org/supports-string;1"]
-        .createInstance(Ci.nsISupportsString);
-      blank.data = "about:blank";
-      browserWindow = wwatch.openWindow
-        (null, "chrome://browser/content/", "_blank",
-         "chrome,dialog=no,width=" + winWidth + ",height=" + winHeight, blank);
-
-      // get our window out of the way
-      window.resizeTo(10,10);
-
-      var browserLoadFunc = function (ev) {
-        browserWindow.removeEventListener('load', browserLoadFunc, true);
-
-        // do this half a second after load, because we need to be
-        // able to resize the window and not have it get clobbered
-        // by the persisted values
-        setTimeout(function () {
-                     browserWindow.resizeTo(winWidth, winHeight);
-                     browserWindow.moveTo(0, 0);
-                     browserWindow.focus();
-
-                     content = browserWindow.getBrowser();
-                     setTimeout(plLoadPage, 100);
-                   }, 500);
-      };
-
-      browserWindow.addEventListener('load', browserLoadFunc, true);
-    } else {
-      window.resizeTo(winWidth, winHeight);
-
-      content = document.getElementById('contentPageloader');
-
-      setTimeout(plLoadPage, 250);
-    }
-  } catch(e) {
-    dumpLine(e);
-    plStop(true);
-  }
-}
-
-function plPageFlags() {
-  return pages[pageIndex].flags;
-}
-
-// load the current page, start timing
-var removeLastAddedListener = null;
-function plLoadPage() {
-  var pageName = pages[pageIndex].url.spec;
-
-  if (removeLastAddedListener)
-    removeLastAddedListener();
-
-  if (plPageFlags() & TEST_DOES_OWN_TIMING) {
-    // if the page does its own timing, use a capturing handler
-    // to make sure that we can set up the function for content to call
-    content.addEventListener('load', plLoadHandlerCapturing, true);
-    removeLastAddedListener = function() {
-      content.removeEventListener('load', plLoadHandlerCapturing, true);
-    };
-  } else {
-    // if the page doesn't do its own timing, use a bubbling handler
-    // to make sure that we're called after the page's own onload() handling
-
-    // XXX we use a capturing event here too -- load events don't bubble up
-    // to the <browser> element.  See bug 390263.
-    content.addEventListener('load', plLoadHandler, true);
-    removeLastAddedListener = function() {
-      content.removeEventListener('load', plLoadHandler, true);
-    };
-  }
-
-  if (timeout > 0) {
-    timeoutEvent = setTimeout('loadFail()', timeout);
-  } 
-  start_time = Date.now();
-  content.loadURI(pageName);
-}
-
-function loadFail() {
-  var pageName = pages[pageIndex].url.spec;
-  dumpLine("__FAILTimeout exceeded on " + pageName + "__FAIL")
-  plStop(true);
-}
-
-function plNextPage() {
-  if (pageIndex < pages.length-1) {
-    pageIndex++;
-
-    if (forceCC) {
-      var tccstart = new Date();
-      window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-            .getInterface(Components.interfaces.nsIDOMWindowUtils)
-            .garbageCollect(); 
-      var tccend = new Date();
-      report.recordCCTime(tccend - tccstart);
-    }
-
-    setTimeout(plLoadPage, 250);
-  } else {
-    plStop(false);
-  }
-}
-
-function plRecordTime(time) {
-  var pageName = pages[pageIndex].url.spec;
-  var i = pageIndex
-  if (i < pages.length-1) {
-    i++;
-  } else {
-    i = 0;
-  }
-  var nextName = pages[i].url.spec;
-  report.recordTime(pageIndex, time);
-  if (noisy) {
-    dumpLine("Cycle " + (cycle+1) + ": loaded " + pageName + " (next: " + nextName + ")");
-  }
-}
-
-function plLoadHandlerCapturing(evt) {
-  // make sure we pick up the right load event
-  if (evt.type != 'load' ||
-       evt.originalTarget.defaultView.frameElement)
-      return;
-  if (timeout > 0) { 
-    clearTimeout(timeoutEvent);
-  }
-
-  if (!(plPageFlags() & TEST_DOES_OWN_TIMING)) {
-    dumpLine("tp: Capturing onload handler used with page that doesn't do its own timing?");
-    plStop(true);
-  }
-
-  // set up the function for content to call
-  content.contentWindow.wrappedJSObject.tpRecordTime = function (time) {
-    plRecordTime(time);
-    setTimeout(plNextPage, 250);
-  };
-}
-
-// the onload handler
-function plLoadHandler(evt) {
-  // make sure we pick up the right load event
-  if (evt.type != 'load' ||
-       evt.originalTarget.defaultView.frameElement)
-      return;
-  if (timeout > 0) { 
-    clearTimeout(timeoutEvent);
-  }
-  var end_time = Date.now();
-  var time = (end_time - start_time);
-
-  // does this page want to do its own timing?
-  // if so, we shouldn't be here
-  if (plPageFlags() & TEST_DOES_OWN_TIMING) {
-    dumpLine("tp: Bubbling onload handler used with page that does its own timing?");
-    plStop(true);
-  }
-
-  plRecordTime(time);
-
-  if (doRenderTest)
-    runRenderTest();
-
-  plNextPage();
-}
-
-function runRenderTest() {
-  const redrawsPerSample = 500;
-
-  if (!Ci.nsIDOMWindowUtils)
-    return;
-
-  var win;
-
-  if (browserWindow)
-    win = content.contentWindow;
-  else 
-    win = window;
-  var wu = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
-
-  var start = Date.now();
-  for (var j = 0; j < redrawsPerSample; j++)
-    wu.redraw();
-  var end = Date.now();
-
-  renderReport.recordTime(pageIndex, end - start);
-}
-
-function plStop(force) {
-  try {
-    if (force == false) {
-      pageIndex = 0;
-      if (cycle < NUM_CYCLES-1) {
-        cycle++;
-        setTimeout(plLoadPage, 250);
-        return;
-      }
-
-      var formats = reportFormat.split(",");
-
-      if (!renderReport) {
-        for each (var fmt in formats)
-          dumpLine(report.getReport(fmt));
-      }
-      else {
-        dumpLine ("*************** Render report *******************");
-        for each (var fmt in formats)
-          dumpLine(renderReport.getReport(fmt));
-      }
-    }
-  } catch (e) {
-    dumpLine(e);
-  }
-
-  if (content)
-    content.removeEventListener('load', plLoadHandler, true);
-
-  goQuitApplication();
-}
-
-/* Returns array */
-function plLoadURLsFromURI(manifestUri) {
-  var fstream = Cc["@mozilla.org/network/file-input-stream;1"]
-    .createInstance(Ci.nsIFileInputStream);
-  var uriFile = manifestUri.QueryInterface(Ci.nsIFileURL);
-
-  fstream.init(uriFile.file, -1, 0, 0);
-  var lstream = fstream.QueryInterface(Ci.nsILineInputStream);
-
-  var d = [];
-
-  var lineNo = 0;
-  var line = {value:null};
-  var more;
-  do {
-    lineNo++;
-    more = lstream.readLine(line);
-    var s = line.value;
-
-    // strip comments
-    s = s.replace(/#.*/, '');
-
-    // strip leading and trailing whitespace
-    s = s.replace(/^\s*/, '').replace(/s\*$/, '');
-
-    if (!s)
-      continue;
-
-    var flags = 0;
-    var urlspec = s;
-
-    // split on whitespace, and figure out if we have any flags
-    var items = s.split(/\s+/);
-    if (items[0] == "include") {
-      if (items.length != 2) {
-        dumpLine("tp: Error on line " + lineNo + " in " + manifestUri.spec + ": include must be followed by the manifest to include!");
-        return null;
-      }
-
-      var subManifest = gIOS.newURI(items[1], null, manifestUri);
-      if (subManifest == null) {
-        dumpLine("tp: invalid URI on line " + manifestUri.spec + ":" + lineNo + " : '" + line.value + "'");
-        return null;
-      }
-
-      var subItems = plLoadURLsFromURI(subManifest);
-      if (subItems == null)
-        return null;
-      d = d.concat(subItems);
-    } else {
-      if (items.length == 2) {
-        if (items[0].indexOf("%") != -1)
-          flags |= TEST_DOES_OWN_TIMING;
-
-        urlspec = items[1];
-      } else if (items.length != 1) {
-        dumpLine("tp: Error on line " + lineNo + " in " + manifestUri.spec + ": whitespace must be %-escaped!");
-        return null;
-      }
-
-      var url = gIOS.newURI(urlspec, null, manifestUri);
-
-      if (pageFilterRegexp && !pageFilterRegexp.test(url.spec))
-        continue;
-
-      d.push({   url: url,
-               flags: flags });
-    }
-  } while (more);
-
-  return d;
-}
-
-function dumpLine(str) {
-  dump(str);
-  dump("\n");
-}
deleted file mode 100644
--- a/layout/tools/pageloader/pageloader.xul
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0"?>
-<!-- ***** BEGIN LICENSE BLOCK *****
-   - Version: MPL 1.1/GPL 2.0/LGPL 2.1
-   -
-   - The contents of this file are subject to the Mozilla Public License Version
-   - 1.1 (the "License"); you may not use this file except in compliance with
-   - the License. You may obtain a copy of the License at
-   - http://www.mozilla.org/MPL/
-   -
-   - Software distributed under the License is distributed on an "AS IS" basis,
-   - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-   - for the specific language governing rights and limitations under the
-   - License.
-   -
-   - The Original Code is tp.
-   -
-   - The Initial Developer of the Original Code is the Mozilla Corporation.
-   - Portions created by the Initial Developer are Copyright (C) 2007
-   - the Initial Developer. All Rights Reserved.
-   -
-   - Contributor(s):
-   -   Rob Helmer <rhelmer@mozilla.com>
-   -   Vladimir Vukicevic <vladimir@mozilla.com>
-   -
-   - Alternatively, the contents of this file may be used under the terms of
-   - either the GNU General Public License Version 2 or later (the "GPL"), or
-   - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-   - in which case the provisions of the GPL or the LGPL are applicable instead
-   - of those above. If you wish to allow use of your version of this file only
-   - under the terms of either the GPL or the LGPL, and not to allow others to
-   - use your version of this file under the terms of the MPL, indicate your
-   - decision by deleting the provisions above and replace them with the notice
-   - and other provisions required by the LGPL or the GPL. If you do not delete
-   - the provisions above, a recipient may use your version of this file under
-   - the terms of any one of the MPL, the GPL or the LGPL.
-   -
-   - ***** END LICENSE BLOCK ***** -->
-
-<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
-
-<?xml-stylesheet href="pageloader.css" type="text/css"?>
-
-<window
-  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-  title="pageloader"
-  screenX="0" screenY="0"
-  onload="plInit()">
-
-  <script type="application/javascript"
-          src="chrome://global/content/globalOverlay.js"/>
-  <script type="application/javascript" src="report.js"/>
-  <script type="application/javascript" src="pageloader.js"/>
-  <script type="application/javascript" src="quit.js"/>
-
-  <browser id="contentPageloader" src="about:blank" 
-    type="content" flex="1"/>
-</window>
deleted file mode 100644
--- a/layout/tools/pageloader/quit.js
+++ /dev/null
@@ -1,110 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is The Original Code is Mozilla Automated Testing Code
- *
- * The Initial Developer of the Original Code is
- * Mozilla Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2005
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s): Bob Clary <bob@bclary.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*
-  From mozilla/toolkit/content
-  These files did not have a license
-*/
-
-function canQuitApplication()
-{
-  var os = Components.classes["@mozilla.org/observer-service;1"]
-    .getService(Components.interfaces.nsIObserverService);
-  if (!os) 
-  {
-    return true;
-  }
-  
-  try 
-  {
-    var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
-      .createInstance(Components.interfaces.nsISupportsPRBool);
-    os.notifyObservers(cancelQuit, "quit-application-requested", null);
-    
-    // Something aborted the quit process. 
-    if (cancelQuit.data)
-    {
-      return false;
-    }
-  }
-  catch (ex) 
-  {
-  }
-  return true;
-}
-
-function goQuitApplication()
-{
-  if (!canQuitApplication())
-  {
-    return false;
-  }
-
-  const kAppStartup = '@mozilla.org/toolkit/app-startup;1';
-  const kAppShell   = '@mozilla.org/appshell/appShellService;1';
-  var   appService;
-  var   forceQuit;
-
-  if (kAppStartup in Components.classes)
-  {
-    appService = Components.classes[kAppStartup].
-      getService(Components.interfaces.nsIAppStartup);
-    forceQuit  = Components.interfaces.nsIAppStartup.eForceQuit;
-  }
-  else if (kAppShell in Components.classes)
-  {
-    appService = Components.classes[kAppShell].
-      getService(Components.interfaces.nsIAppShellService);
-    forceQuit = Components.interfaces.nsIAppShellService.eForceQuit;
-  }
-  else
-  {
-    throw 'goQuitApplication: no AppStartup/appShell';
-  }
-
-  try
-  {
-    appService.quit(forceQuit);
-  }
-  catch(ex)
-  {
-    throw('goQuitApplication: ' + ex);
-  }
-
-  return true;
-}
-
deleted file mode 100644
--- a/layout/tools/pageloader/report.js
+++ /dev/null
@@ -1,268 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tp.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2007
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@meer.net>
- *   Rob Helmer <rhelmer@mozilla.com>
- *   Vladimir Vukicevic <vladimir@mozilla.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-// Constructor
-function Report(pages) {
-  this.pages = pages;
-  this.timeVals = new Array(pages.length);  // matrix of times
-  for (var i = 0; i < this.timeVals.length; ++i) {
-    this.timeVals[i] = new Array();
-  }
-  this.totalCCTime = 0;
-  this.showTotalCCTime = false;
-}
-
-// given an array of strings, finds the longest common prefix
-function findCommonPrefixLength(strs) {
-  if (strs.length < 2)
-    return 0;
-
-  var len = 0;
-  do {
-    var newlen = len + 1;
-    var newprefix = null;
-    var failed = false;
-    for (var i = 0; i < strs.length; i++) {
-      if (newlen > strs[i].length) {
-	failed = true;
-	break;
-      }
-
-      var s = strs[i].substr(0, newlen);
-      if (newprefix == null) {
-	newprefix = s;
-      } else if (newprefix != s) {
-	failed = true;
-	break;
-      }
-    }
-
-    if (failed)
-      break;
-
-    len++;
-  } while (true);
-  return len;
-}
-
-function compareNumbers(a, b) {
-  return a - b;
-}
-
-// returns an object with the following properties:
-//   min  : min value of array elements
-//   max  : max value of array elements
-//   mean : mean value of array elements
-//   vari : variance computation
-//   stdd : standard deviation, sqrt(vari)
-//   indexOfMax : index of max element (the element that is
-//                removed from the mean computation)
-function getArrayStats(ary) {
-  var r = {};
-  r.min = ary[0];
-  r.max = ary[0];
-  r.indexOfMax = 0;
-  var sum = 0;
-  for (var i = 0; i < ary.length; ++i) {
-    if (ary[i] < r.min) {
-      r.min = ary[i];
-    } else if (ary[i] > r.max) {
-      r.max = ary[i];
-      r.indexOfMax = i;
-    }
-    sum = sum + ary[i];
-  }
-
-  // median
-  if (ary.length > 1) {
-      sorted_ary = ary.concat();
-      sorted_ary.sort(compareNumbers);
-      // remove longest run
-      sorted_ary.pop();
-      if (sorted_ary.length%2) {
-        r.median = sorted_ary[(sorted_ary.length-1)/2]; 
-      }else{
-        var n = Math.floor(sorted_ary.length / 2);
-        if (n >= sorted_ary.length)
-          r.median = sorted_ary[n];
-        else
-          r.median = (sorted_ary[n-1] + sorted_ary[n]) / 2;
-      }
-  }else{
-    r.median = ary[0];
-  }
-
-  // ignore max value when computing mean and stddev
-  if (ary.length > 1)
-    r.mean = (sum - r.max) / (ary.length - 1);
-  else
-    r.mean = ary[0];
-
-  r.vari = 0;
-  for (var i = 0; i < ary.length; ++i) {
-    if (i == r.indexOfMax)
-      continue;
-    var d = r.mean - ary[i];
-    r.vari = r.vari + d * d;
-  }
-
-  if (ary.length > 1) {
-    r.vari = r.vari / (ary.length - 1);
-    r.stdd = Math.sqrt(r.vari);
-  } else {
-    r.vari = 0.0;
-    r.stdd = 0.0;
-  }
-  return r;
-}
-
-function strPad(o, len, left) {
-  var str = o.toString();
-  if (!len)
-    len = 6;
-  if (left == null)
-    left = true;
-
-  if (str.length < len) {
-    len -= str.length;
-    while (--len) {
-      if (left)
-	str = " " + str;
-      else
-	str += " ";
-    }
-  }
-
-  str += " ";
-  return str;
-}
-
-function strPadFixed(n, len, left) {
-  return strPad(n.toFixed(0), len, left);
-}
-
-Report.prototype.getReport = function(format) {
-  // avg and avg median are cumulative for all the pages
-  var avgs = new Array();
-  var medians = new Array();
-  for (var i = 0; i < this.timeVals.length; ++i) {
-     avgs[i] = getArrayStats(this.timeVals[i]).mean;
-     medians[i] = getArrayStats(this.timeVals[i]).median;
-  }
-  var avg = getArrayStats(avgs).mean;
-  var avgmed = getArrayStats(medians).mean;
-
-  var report;
-
-  var prefixLen = findCommonPrefixLength(this.pages);
-
-  if (format == "js") {
-    // output "simple" js format;
-    // array of { page: "str", value: 123.4, stddev: 23.3 } objects
-    report = "([";
-    for (var i = 0; i < this.timeVals.length; i++) {
-      var stats = getArrayStats(this.timeVals[i]);
-      report += uneval({ page: this.pages[i].substr(prefixLen), value: stats.mean, stddev: stats.stdd});
-      report += ",";
-    }
-    report += "])";
-  } else if (format == "jsfull") {
-    // output "full" js format, with raw values
-  } else if (format == "text") {
-    // output text format suitable for dumping
-    report = "============================================================\n";
-    report += "    " + strPad("Page", 40, false) + strPad("mean") + strPad("stdd") + strPad("min") + strPad("max") + "raw" + "\n";
-    for (var i = 0; i < this.timeVals.length; i++) {
-      var stats = getArrayStats(this.timeVals[i]);
-      report +=
-        strPad(i, 4, true) +
-        strPad(this.pages[i].substr(prefixLen), 40, false) +
-        strPadFixed(stats.mean) +
-        strPadFixed(stats.stdd) +
-        strPadFixed(stats.min) +
-        strPadFixed(stats.max) +
-        this.timeVals[i] +
-        "\n";
-    }
-    if (this.showTotalCCTime) {
-      report += "Cycle collection: " + this.totalCCTime + "\n"
-    }
-    report += "============================================================\n";
-  } else if (format == "tinderbox") {
-    report = "__start_tp_report\n";
-    report += "_x_x_mozilla_page_load,"+avgmed+",NaN,NaN\n";  // max and min are just 0, ignored
-    report += "_x_x_mozilla_page_load_details,avgmedian|"+avgmed+"|average|"+avg.toFixed(2)+"|minimum|NaN|maximum|NaN|stddev|NaN\n";
-    report += "|i|pagename|median|mean|min|max|runs|\n";
-
-    for (var i = 0; i < this.timeVals.length; i++) {
-      var r = getArrayStats(this.timeVals[i]);
-      report += '|'+
-        i + ';'+
-        this.pages[i].substr(prefixLen) + ';'+
-        r.median + ';'+
-        r.mean + ';'+
-        r.min + ';'+
-        r.max + ';'+
-        this.timeVals[i].join(";") +
-        "\n";
-    }
-    report += "__end_tp_report\n";
-    if (this.showTotalCCTime) {
-      report += "__start_cc_report\n";
-      report += "_x_x_mozilla_cycle_collect," + this.totalCCTime + "\n";
-      report += "__end_cc_report\n";
-    }
-    var now = (new Date()).getTime();
-    report += "__startTimestamp" + now + "__endTimestamp\n"; //timestamp for determning shutdown time, used by talos
-  } else {
-    report = "Unknown report format";
-  }
-
-  return report;
-}
-
-Report.prototype.recordTime = function(pageIndex, ms) {
-  this.timeVals[pageIndex].push(ms);
-}
-
-Report.prototype.recordCCTime = function(ms) {
-  this.totalCCTime += ms;
-  this.showTotalCCTime = true;
-}
deleted file mode 100644
--- a/layout/tools/pageloader/tp-cmdline.js
+++ /dev/null
@@ -1,119 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is DOM Inspector.
- *
- * The Initial Developer of the Original Code is
- * Christopher A. Aillon <christopher@aillon.com>.
- * Portions created by the Initial Developer are Copyright (C) 2003
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Christopher A. Aillon <christopher@aillon.com>
- *   L. David Baron, Mozilla Corporation <dbaron@dbaron.org> (modified for reftest)
- *   Vladimir Vukicevic, Mozilla Corporation <dbaron@dbaron.org> (modified for tp)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-// This only implements nsICommandLineHandler, since it needs
-// to handle multiple arguments.
-
-const nsISupports               = Components.interfaces.nsISupports;
-  
-const nsICommandLine            = Components.interfaces.nsICommandLine;
-const nsICommandLineHandler     = Components.interfaces.nsICommandLineHandler;
-const nsISupportsString         = Components.interfaces.nsISupportsString;
-const nsIWindowWatcher          = Components.interfaces.nsIWindowWatcher;
-
-function PageLoaderCmdLineHandler() {}
-PageLoaderCmdLineHandler.prototype =
-{
-  classID: Components.ID('{8AF052F5-8EFE-4359-8266-E16498A82E8B}'),
-
-  /* nsISupports */
-  QueryInterface : XPCOMUtils.generateQI([nsICommandLineHandler]),
-
-  /* nsICommandLineHandler */
-  handle : function handler_handle(cmdLine) {
-    var args = {};
-    try {
-      var uristr = cmdLine.handleFlagWithParam("tp", false);
-      if (uristr == null)
-        return;
-      try {
-        args.manifest = cmdLine.resolveURI(uristr).spec;
-      } catch (e) {
-        return;
-      }
-
-      args.numCycles = cmdLine.handleFlagWithParam("tpcycles", false);
-      args.startIndex = cmdLine.handleFlagWithParam("tpstart", false);
-      args.endIndex = cmdLine.handleFlagWithParam("tpend", false);
-      args.filter = cmdLine.handleFlagWithParam("tpfilter", false);
-      args.format = cmdLine.handleFlagWithParam("tpformat", false);
-      args.useBrowserChrome = cmdLine.handleFlag("tpchrome", false);
-      args.doRender = cmdLine.handleFlag("tprender", false);
-      args.width = cmdLine.handleFlagWithParam("tpwidth", false);
-      args.height = cmdLine.handleFlagWithParam("tpheight", false);
-      args.offline = cmdLine.handleFlag("tpoffline", false);
-      args.noisy = cmdLine.handleFlag("tpnoisy", false);
-      args.timeout = cmdLine.handleFlagWithParam("tptimeout", false);
-      args.noForceCC = cmdLine.handleFlag("tpnoforcecc", false);
-    }
-    catch (e) {
-      return;
-    }
-
-    // get our data through xpconnect
-    args.wrappedJSObject = args;
-
-    var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
-                           .getService(nsIWindowWatcher);
-    wwatch.openWindow(null, "chrome://pageloader/content/pageloader.xul", "_blank",
-                      "chrome,dialog=no,all", args);
-    cmdLine.preventDefault = true;
-  },
-
-  helpInfo :
-  "  -tp <file>         Run pageload perf tests on given manifest\n" +
-  "  -tpfilter str      Only include pages from manifest that contain str (regexp)\n" +
-  "  -tpcycles n        Loop through pages n times\n" +
-  "  -tpstart n         Start at index n in the manifest\n" +
-  "  -tpend n           End with index n in the manifest\n" +
-  "  -tpformat f1,f2,.. Report format(s) to use\n" +
-  "  -tpchrome          Test with normal browser chrome\n" +
-  "  -tprender          Run render-only benchmark for each page\n" +
-  "  -tpwidth width     Width of window\n" +
-  "  -tpheight height   Height of window\n" +
-  "  -tpoffline         Force offline mode\n" +
-  "  -tpnoisy           Dump the name of the last loaded page to console\n" + 
-  "  -tptimeout         Max amount of time given for a page to load, quit if exceeded\n" +
-  "  -tpnoforcecc       Don't force cycle collection between each pageload\n"
-
-};
-
-var NSGetFactory = XPCOMUtils.generateNSGetFactory([PageLoaderCmdLineHandler]);
deleted file mode 100644
--- a/layout/tools/pageloader/tp-cmdline.manifest
+++ /dev/null
@@ -1,3 +0,0 @@
-component {8AF052F5-8EFE-4359-8266-E16498A82E8B} tp-cmdline.js
-contract @mozilla.org/commandlinehandler/general-startup;1?type=tp {8AF052F5-8EFE-4359-8266-E16498A82E8B}
-category command-line-handler m-tp @mozilla.org/commandlinehandler/general-startup;1?type=tp
--- a/mobile/android/base/AndroidManifest.xml.in
+++ b/mobile/android/base/AndroidManifest.xml.in
@@ -98,16 +98,22 @@
 
             <!-- For debugging -->
             <intent-filter>
                 <action android:name="org.mozilla.gecko.DEBUG" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
         </activity>
 
+        <!-- Masquerade as the Resolver so that we can be opened from the Marketplace. -->
+        <activity-alias
+            android:name="com.android.internal.app.ResolverActivity"
+            android:targetActivity=".App"
+            android:exported="true" />
+
         <receiver android:name="NotificationHandler">
             <intent-filter>
                 <action android:name="org.mozilla.gecko.ACTION_ALERT_CLICK" />
                 <action android:name="org.mozilla.gecko.ACTION_ALERT_CLEAR" />
             </intent-filter>
         </receiver>
 
         <activity android:name="Restarter"
--- a/mobile/android/base/AwesomeBar.java
+++ b/mobile/android/base/AwesomeBar.java
@@ -84,16 +84,17 @@ import org.json.JSONObject;
 
 public class AwesomeBar extends Activity implements GeckoEventListener {
     private static final String LOGTAG = "GeckoAwesomeBar";
 
     static final String URL_KEY = "url";
     static final String CURRENT_URL_KEY = "currenturl";
     static final String TYPE_KEY = "type";
     static final String SEARCH_KEY = "search";
+    static final String USER_ENTERED_KEY = "user_entered";
     static enum Type { ADD, EDIT };
 
     private String mType;
     private AwesomeBarTabs mAwesomeTabs;
     private AwesomeBarEditText mText;
     private ImageButton mGoButton;
     private ContentResolver mResolver;
 
@@ -127,17 +128,17 @@ public class AwesomeBar extends Activity
 
             public void onSearch(String engine) {
                 openSearchAndFinish(mText.getText().toString(), engine);
             }
         });
 
         mGoButton.setOnClickListener(new Button.OnClickListener() {
             public void onClick(View v) {
-                openUrlAndFinish(mText.getText().toString());
+                openUserEnteredAndFinish(mText.getText().toString());
             }
         });
 
         Resources resources = getResources();
         
         int padding[] = { mText.getPaddingLeft(),
                           mText.getPaddingTop(),
                           mText.getPaddingRight(),
@@ -161,17 +162,17 @@ public class AwesomeBar extends Activity
         }
 
         mText.setOnKeyPreImeListener(new AwesomeBarEditText.OnKeyPreImeListener() {
             public boolean onKeyPreIme(View v, int keyCode, KeyEvent event) {
                 InputMethodManager imm =
                         (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
 
                 if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
-                    openUrlAndFinish(mText.getText().toString());
+                    openUserEnteredAndFinish(mText.getText().toString());
                     return true;
                 }
 
                 // If input method is in fullscreen mode, we want to dismiss
                 // it instead of closing awesomebar straight away.
                 if (!imm.isFullscreenMode() && keyCode == KeyEvent.KEYCODE_BACK) {
                     cancelAndFinish();
                     return true;
@@ -201,17 +202,17 @@ public class AwesomeBar extends Activity
         });
 
         mText.setOnKeyListener(new View.OnKeyListener() {
             public boolean onKey(View v, int keyCode, KeyEvent event) {
                 if (keyCode == KeyEvent.KEYCODE_ENTER) {
                     if (event.getAction() != KeyEvent.ACTION_DOWN)
                         return true;
 
-                    openUrlAndFinish(mText.getText().toString());
+                    openUserEnteredAndFinish(mText.getText().toString());
                     return true;
                 } else {
                     return false;
                 }
             }
         });
 
         mText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@@ -312,28 +313,36 @@ public class AwesomeBar extends Activity
 
     private void finishWithResult(Intent intent) {
         setResult(Activity.RESULT_OK, intent);
         finish();
         overridePendingTransition(0, 0);
     }
 
     private void openUrlAndFinish(String url) {
+        Intent resultIntent = new Intent();
+        resultIntent.putExtra(URL_KEY, url);
+        resultIntent.putExtra(TYPE_KEY, mType);
+        finishWithResult(resultIntent);
+    }
+
+    private void openUserEnteredAndFinish(String url) {
         int index = url.indexOf(' ');
         if (index != -1) {
             String keywordUrl = BrowserDB.getUrlForKeyword(mResolver, url.substring(0, index));
             if (keywordUrl != null && keywordUrl.contains("%s")) {
                 String search = URLEncoder.encode(url.substring(index + 1));
                 url = keywordUrl.replace("%s", search);
             }
         }
 
         Intent resultIntent = new Intent();
         resultIntent.putExtra(URL_KEY, url);
         resultIntent.putExtra(TYPE_KEY, mType);
+        resultIntent.putExtra(USER_ENTERED_KEY, true);
         finishWithResult(resultIntent);
     }
 
     private void openSearchAndFinish(String url, String engine) {
         Intent resultIntent = new Intent();
         resultIntent.putExtra(URL_KEY, url);
         resultIntent.putExtra(TYPE_KEY, mType);
         resultIntent.putExtra(SEARCH_KEY, engine);
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -2577,18 +2577,19 @@ abstract public class GeckoApp
                 Log.i(LOGTAG, "error returning file picker result", e);
             }
             break;
         case AWESOMEBAR_REQUEST:
             if (data != null) {
                 String url = data.getStringExtra(AwesomeBar.URL_KEY);
                 AwesomeBar.Type type = AwesomeBar.Type.valueOf(data.getStringExtra(AwesomeBar.TYPE_KEY));
                 String searchEngine = data.getStringExtra(AwesomeBar.SEARCH_KEY);
+                boolean userEntered = data.getBooleanExtra(AwesomeBar.USER_ENTERED_KEY, false);
                 if (url != null && url.length() > 0)
-                    loadRequest(url, type, searchEngine);
+                    loadRequest(url, type, searchEngine, userEntered);
             }
             break;
         case CAMERA_CAPTURE_REQUEST:
             Log.i(LOGTAG, "Returning from CAMERA_CAPTURE_REQUEST: " + resultCode);
             File file = new File(Environment.getExternalStorageDirectory(), "cameraCapture-" + Integer.toString(kCaptureIndex) + ".jpg");
             kCaptureIndex++;
             GeckoEvent e = GeckoEvent.createBroadcastEvent("cameraCaptureDone", resultCode == Activity.RESULT_OK ?
                                           "{\"ok\": true,  \"path\": \"" + file.getPath() + "\" }" :
@@ -2604,36 +2605,37 @@ abstract public class GeckoApp
         Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
         intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
 
         startActivityForResult(intent, CAMERA_CAPTURE_REQUEST);
     }
 
     // If searchEngine is provided, url will be used as the search query.
     // Otherwise, the url is loaded.
-    private void loadRequest(String url, AwesomeBar.Type type, String searchEngine) {
+    private void loadRequest(String url, AwesomeBar.Type type, String searchEngine, boolean userEntered) {
         mBrowserToolbar.setTitle(url);
         Log.d(LOGTAG, type.name());
         JSONObject args = new JSONObject();
         try {
             args.put("url", url);
             args.put("engine", searchEngine);
+            args.put("userEntered", userEntered);
         } catch (Exception e) {
             Log.e(LOGTAG, "error building JSON arguments");
         }
         if (type == AwesomeBar.Type.ADD) {
             Log.i(LOGTAG, "Sending message to Gecko: " + SystemClock.uptimeMillis() + " - Tab:Add");
             GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Tab:Add", args.toString()));
         } else {
             GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Tab:Load", args.toString()));
         }
     }
 
     public void loadUrl(String url, AwesomeBar.Type type) {
-        loadRequest(url, type, null);
+        loadRequest(url, type, null, false);
     }
 
     /**
      * Open the url as a new tab, and mark the selected tab as its "parent".
      * If the url is already open in a tab, the existing tab is selected.
      * Use this for tabs opened by the browser chrome, so users can press the
      * "Back" button to return to the previous tab.
      */
--- a/mobile/android/base/db/BrowserContract.java.in
+++ b/mobile/android/base/db/BrowserContract.java.in
@@ -109,16 +109,19 @@ public class BrowserContract {
         public static final String MENU_FOLDER_GUID = "menu";
         public static final String TAGS_FOLDER_GUID = "tags";
         public static final String TOOLBAR_FOLDER_GUID = "toolbar";
         public static final String UNFILED_FOLDER_GUID = "unfiled";
 
         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "bookmarks");
         public static final Uri PARENTS_CONTENT_URI = Uri.withAppendedPath(CONTENT_URI, "parents");
 
+        // Hacky API for bulk-updating positions. Bug 728783.
+        public static final Uri POSITIONS_CONTENT_URI = Uri.withAppendedPath(CONTENT_URI, "positions");
+
         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/bookmark";
 
         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/bookmark";
 
         public static final String IS_FOLDER = "folder";
 
         public static final String PARENT = "parent";
 
--- a/mobile/android/base/db/BrowserProvider.java.in
+++ b/mobile/android/base/db/BrowserProvider.java.in
@@ -100,16 +100,17 @@ public class BrowserProvider extends Con
     static final String VIEW_BOOKMARKS_WITH_IMAGES = "bookmarks_with_images";
     static final String VIEW_HISTORY_WITH_IMAGES = "history_with_images";
 
     // Bookmark matches
     static final int BOOKMARKS = 100;
     static final int BOOKMARKS_ID = 101;
     static final int BOOKMARKS_FOLDER_ID = 102;
     static final int BOOKMARKS_PARENT = 103;
+    static final int BOOKMARKS_POSITIONS = 104;
 
     // History matches
     static final int HISTORY = 200;
     static final int HISTORY_ID = 201;
 
     // Image matches
     static final int IMAGES = 300;
     static final int IMAGES_ID = 301;
@@ -140,16 +141,17 @@ public class BrowserProvider extends Con
 
     static {
         HashMap<String, String> map;
 
         // Bookmarks
         URI_MATCHER.addURI(BrowserContract.AUTHORITY, "bookmarks", BOOKMARKS);
         URI_MATCHER.addURI(BrowserContract.AUTHORITY, "bookmarks/#", BOOKMARKS_ID);
         URI_MATCHER.addURI(BrowserContract.AUTHORITY, "bookmarks/parents", BOOKMARKS_PARENT);
+        URI_MATCHER.addURI(BrowserContract.AUTHORITY, "bookmarks/positions", BOOKMARKS_POSITIONS);
         URI_MATCHER.addURI(BrowserContract.AUTHORITY, "bookmarks/folder/#", BOOKMARKS_FOLDER_ID);
 
         map = BOOKMARKS_PROJECTION_MAP;
         map.put(Bookmarks._ID, Bookmarks._ID);
         map.put(Bookmarks.TITLE, Bookmarks.TITLE);
         map.put(Bookmarks.URL, Bookmarks.URL);
         map.put(Bookmarks.FAVICON, Bookmarks.FAVICON);
         map.put(Bookmarks.THUMBNAIL, Bookmarks.THUMBNAIL);
@@ -1040,16 +1042,31 @@ public class BrowserProvider extends Con
     public int updateInTransaction(Uri uri, ContentValues values, String selection,
             String[] selectionArgs) {
         trace("Calling update in transaction on URI: " + uri);
 
         int match = URI_MATCHER.match(uri);
         int updated = 0;
 
         switch (match) {
+            // We provide a dedicated (hacky) API for callers to bulk-update the positions of
+            // folder children by passing an array of GUID strings as `selectionArgs`.
+            // Each child will have its position column set to its index in the provided array.
+            //
+            // This avoids callers having to issue a large number of UPDATE queries through
+            // the usual channels. See Bug 728783.
+            //
+            // Note that this is decidedly not a general-purpose API; use at your own risk.
+            // `values` and `selection` are ignored.
+            case BOOKMARKS_POSITIONS: {
+                debug("Update on BOOKMARKS_POSITIONS: " + uri);
+                updated = updateBookmarkPositions(uri, selectionArgs);
+                break;
+            }
+
             case BOOKMARKS_PARENT: {
                 debug("Update on BOOKMARKS_PARENT: " + uri);
                 updated = updateBookmarkParents(uri, values, selection, selectionArgs);
                 break;
             }
 
             case BOOKMARKS_ID:
                 debug("Update on BOOKMARKS_ID: " + uri);
@@ -1254,16 +1271,60 @@ public class BrowserProvider extends Con
         } finally {
             c.close();
         }
 
         return count;
     }
 
     /**
+     * Construct an update expression that will modify the positions of
+     * records in-place.
+     *
+     * The provided selectionArgs is expected to be an implicit mapping from
+     * GUID to new position.
+     */
+    int updateBookmarkPositions(Uri uri, String[] guids) {
+        if (guids == null)
+            return 0;
+
+        int guidsCount = guids.length;
+        if (guidsCount == 0)
+            return 0;
+
+        // Each must appear twice: once in a CASE, and once in the IN clause.
+        String[] args = new String[guidsCount * 2];
+        System.arraycopy(guids, 0, args, 0, guidsCount);
+        System.arraycopy(guids, 0, args, guidsCount, guidsCount);
+
+        StringBuilder b = new StringBuilder("UPDATE " + TABLE_BOOKMARKS +
+                                            " SET " + Bookmarks.POSITION + " = CASE guid");
+
+        int i = 0;
+        for (; i < guids.length; ++i) {
+            if (guids[i] == null) {
+                // We don't want to issue the query if not every GUID is specified.
+                debug("updateBookmarkPositions called with null GUID at index " + i);
+                return 0;
+            }
+            b.append(" WHEN ? THEN " + i);
+        }
+        b.append(" END WHERE " + Bookmarks.GUID + " IN (");
+        i = 1;
+        while (i++ < guidsCount) {
+            b.append("?, ");
+        }
+        b.append("?)");
+        getWritableDatabase(uri).execSQL(b.toString(), args);
+
+        // We can't easily get a modified count without calling something like changes().
+        return guidsCount;
+    }
+
+    /**
      * Construct an update expression that will modify the parents of any records
      * that match.
      */
     int updateBookmarkParents(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
         trace("Updating bookmark parents of " + selection + " (" + selectionArgs[0] + ")");
         String where = Bookmarks._ID + " IN (" +
                        " SELECT DISTINCT " + Bookmarks.PARENT +
                        " FROM " + TABLE_BOOKMARKS +
--- a/mobile/android/base/tests/BaseTest.java.in
+++ b/mobile/android/base/tests/BaseTest.java.in
@@ -1,18 +1,20 @@
 #filter substitution
 package @ANDROID_PACKAGE_NAME@.tests;
 
 import com.jayway.android.robotium.solo.Solo;
 import @ANDROID_PACKAGE_NAME@.*;
 
 import android.app.Activity;
 import android.app.Instrumentation;
+import android.content.Intent;
+import android.os.SystemClock;
 import android.test.ActivityInstrumentationTestCase2;
-import android.content.Intent;
+
 import java.util.HashMap;
 
 abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
     private static final String TARGET_PACKAGE_ID = "org.mozilla.gecko";
     private static final String LAUNCH_ACTIVITY_FULL_CLASSNAME="@ANDROID_PACKAGE_NAME@.App";
 
     private static Class<Activity> mLauncherActivityClass;
     private Activity mActivity;
@@ -126,9 +128,24 @@ abstract class BaseTest extends Activity
         Activity awesomeBarActivity = clickOnAwesomeBar();
         Element urlbar = mDriver.findElement(awesomeBarActivity, "awesomebar_text");
         mAsserter.is(urlbar.getText(), url, "Awesomebar URL stayed the same");
     }
 
     protected final String getAbsoluteUrl(String url) {
         return mBaseUrl + "/" + url.replaceAll("(^/)", "");
     }
+
+    protected final boolean waitForTest(BooleanTest t, int timeout) {
+        long end = SystemClock.uptimeMillis() + timeout;
+        while (SystemClock.uptimeMillis() < end) {
+            if (t.test())
+                return true;
+
+            mSolo.sleep(100);
+        }
+        return false;
+    }
+
+    protected interface BooleanTest {
+        public boolean test();
+    }
 }
--- a/mobile/android/base/tests/robocop.ini
+++ b/mobile/android/base/tests/robocop.ini
@@ -1,10 +1,11 @@
 [testAwesomebar]
 [testBookmark]
+[testBookmarklets]
 [testLoad]
 [testNewTab]
 [testPanCorrectness]
 [test_bug720538]
 # [testFlingCorrectness] # see bug 727351
 [testOverscroll]
 [testAxisLocking]
 [testAboutPage]
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/tests/testBookmarklets.java.in
@@ -0,0 +1,80 @@
+#filter substitution
+package @ANDROID_PACKAGE_NAME@.tests;
+
+import @ANDROID_PACKAGE_NAME@.*;
+import android.app.Activity;
+import android.content.ContentValues;
+import android.content.ContentResolver;
+import android.database.Cursor;
+import android.net.Uri;
+import android.provider.Browser;
+
+public class testBookmarklets extends BaseTest {
+    public void testBookmarklets() {
+        final String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
+        final String title = "alertBookmarklet";
+        final String js = "javascript:alert(12 + .34)";
+        boolean alerted;
+
+        setTestType("mochitest");
+        mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();
+
+        // load a standard page so bookmarklets work
+        loadUrl(url);
+
+        // verify that user-entered bookmarklets do *not* work
+        enterUrl(js);
+        mActions.sendSpecialKey(Actions.SpecialKey.ENTER);
+        alerted = waitForTest(new BooleanTest() {
+            public boolean test() {
+                return mSolo.searchButton("OK", true) || mSolo.searchText("12.34", true);
+            }
+        }, 3000);
+        mAsserter.is(alerted, false, "Alert was not shown for user-entered bookmarklet");
+
+        // add the bookmarklet to the database. there's currently no way to
+        // add this using the UI, so we go through the content provider.
+        addOrUpdateBookmarklet(title, js);
+
+        // verify that bookmarklets clicked in awesomescreen work
+        Activity awesomeBarActivity = clickOnAwesomeBar();
+        mActions.sendSpecialKey(Actions.SpecialKey.RIGHT);
+        getInstrumentation().waitForIdleSync();
+        mSolo.clickOnText(title);
+        alerted = waitForTest(new BooleanTest() {
+            public boolean test() {
+                return mSolo.searchButton("OK", true) && mSolo.searchText("12.34", true);
+            }
+        }, 3000);
+        mAsserter.is(alerted, true, "Alert was shown for clicked bookmarklet");
+    }
+
+    private void addOrUpdateBookmarklet(String title, String url) {
+        ContentResolver resolver = getActivity().getContentResolver();
+        Uri bookmarksUri = Uri.parse("content://@ANDROID_PACKAGE_NAME@.db.browser/bookmarks");
+        bookmarksUri = bookmarksUri.buildUpon().appendQueryParameter("profile", "default").build();
+        long mobileFolderId = -1;
+
+        Cursor c = resolver.query(bookmarksUri,
+                                  new String[] { "_id" },
+                                  "guid = ?",
+                                  new String[] { "mobile" },
+                                  null);
+        if (c.moveToFirst())
+            mobileFolderId = c.getLong(c.getColumnIndexOrThrow("_id"));
+        c.close();
+
+        ContentValues values = new ContentValues();
+        values.put(Browser.BookmarkColumns.TITLE, title);
+        values.put("url", url);
+        values.put("parent", mobileFolderId);
+        values.put("modified", System.currentTimeMillis());
+
+        int updated = resolver.update(bookmarksUri,
+                                      values,
+                                      "url = ?",
+                                      new String[] { url });
+        if (updated == 0)
+            resolver.insert(bookmarksUri, values);
+    }
+}
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -909,21 +909,24 @@ var BrowserApp = {
       browser.reload();
     } else if (aTopic == "Session:Stop") {
       browser.stop();
     } else if (aTopic == "Tab:Add" || aTopic == "Tab:Load") {
       let data = JSON.parse(aData);
 
       // Pass LOAD_FLAGS_DISALLOW_INHERIT_OWNER to prevent any loads from
       // inheriting the currently loaded document's principal.
+      let flags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
+      if (data.userEntered)
+        flags |= Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_OWNER;
+
       let params = {
         selected: true,
         parentId: ("parentId" in data) ? data.parentId : -1,
-        flags: Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_OWNER
-             | Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP
+        flags: flags
       };
 
       let url = this.getSearchOrURI(data);
 
       // Don't show progress throbber for about:home
       if (url == "about:home")
         params.showProgress = false;
 
--- a/mobile/android/sync/manifests/SyncAndroidManifest_activities.xml.in
+++ b/mobile/android/sync/manifests/SyncAndroidManifest_activities.xml.in
@@ -3,22 +3,18 @@
             android:label="@string/sync_app_name"
             android:configChanges="orientation"
             android:windowSoftInputMode="adjustResize|stateHidden"
             android:taskAffinity="org.mozilla.gecko.sync.setup"
             android:name="org.mozilla.gecko.sync.setup.activities.SetupSyncActivity" >
             <!-- android:configChanges: SetupSyncActivity will handle orientation changes; no longer restarts activity (default) -->
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
             </intent-filter>
         </activity>
         <activity
             android:clearTaskOnLaunch="true"
             android:name="org.mozilla.gecko.sync.setup.activities.AccountActivity"
             android:windowSoftInputMode="adjustPan|stateHidden"/>
         <activity
             android:name="org.mozilla.gecko.sync.setup.activities.SetupFailureActivity" />
         <activity
-            android:name="org.mozilla.gecko.sync.setup.activities.SetupSuccessActivity" />
\ No newline at end of file
+            android:name="org.mozilla.gecko.sync.setup.activities.SetupSuccessActivity" />
--- a/mobile/android/themes/core/about.css
+++ b/mobile/android/themes/core/about.css
@@ -7,17 +7,17 @@ html {
 
 body {
   color: black;
   position: relative;
   min-width: 330px;
   max-width: 50em;
   margin: 1em auto;
   border: 1px solid gray;
-  -moz-border-radius: 10px;
+  border-radius: 10px;
   padding: 3em;
   -moz-padding-start: 30px;
   background: white;
 }
 
 .aboutPageWideContainer {
   max-width: 80%;
 }
--- a/mobile/android/themes/core/browser.css
+++ b/mobile/android/themes/core/browser.css
@@ -41,17 +41,17 @@
 /* content scrollbars */
 .scroller {
   opacity: 0;
   background-color: rgba(0, 0, 0, 0.4) !important;
   -moz-border-top-colors: none !important;
   -moz-border-bottom-colors: none !important;
   -moz-border-right-colors: none !important;
   -moz-border-left-colors: none !important;
-  -moz-border-radius: @border_radius_tiny@;
+  border-radius: @border_radius_tiny@;
   border: @border_width_tiny@ solid rgba(255, 255, 255, 0.4) !important;
 }
 
 .scroller[panning="true"] {
   opacity: 1;
 }
 
 .scroller[orient="vertical"] {
--- a/mobile/android/themes/core/content.css
+++ b/mobile/android/themes/core/content.css
@@ -124,17 +124,17 @@ xul|scrollbarbutton[sbattr="scrollbar-bo
 
 xul|scrollbar xul|thumb {
   background-color: rgba(0, 0, 0, 0.4) !important;
   -moz-border-top-colors: none !important;
   -moz-border-bottom-colors: none !important;
   -moz-border-right-colors: none !important;
   -moz-border-left-colors: none !important;
   border: 1px solid rgba(255, 255, 255, 0.4) !important;
-  -moz-border-radius: 3px;
+  border-radius: 3px;
 }
 
 select:not([size]):not([multiple]) > xul|scrollbar,
 select[size="1"] > xul|scrollbar,
 select:not([size]):not([multiple]) xul|scrollbarbutton,
 select[size="1"] xul|scrollbarbutton {
   display: block;
   margin-left: 0;
@@ -143,17 +143,17 @@ select[size="1"] xul|scrollbarbutton {
 
 /* Override inverse OS themes */
 select,
 textarea,
 button,
 xul|button,
 * > input:not([type="image"]) {
   -moz-appearance: none !important;  /* See bug 598421 for fixing the platform */
-  -moz-border-radius: 3px;
+  border-radius: 3px;
 }
 
 select[size],
 select[multiple],
 select[size][multiple],
 textarea,
 * > input:not([type="image"]) {
   border-style: solid;
@@ -230,17 +230,17 @@ input[type="checkbox"] {
   border: 1px solid #a7a7a7 !important;
   padding: 2px 1px 2px 1px;
 }
 
 select > button {
   border-width: 0px !important;
   margin: 0px !important;
   padding: 0px !important;
-  -moz-border-radius: 0;
+  border-radius: 0;
   color: #414141;
 
   background-size: auto auto, 100% 90%;
   background-color: transparent;
   background-image: url("chrome://browser/skin/images/dropmarker.svg"),
                     -moz-radial-gradient(bottom left, #bbbbbb 40%, #f5f5f5) !important;
   background-position: -moz-calc(50% + 1px) center, -15px center !important;
   background-repeat: no-repeat !important;
--- a/mobile/android/themes/core/gingerbread/browser.css
+++ b/mobile/android/themes/core/gingerbread/browser.css
@@ -41,17 +41,17 @@
 /* content scrollbars */
 .scroller {
   opacity: 0;
   background-color: rgba(0, 0, 0, 0.4) !important;
   -moz-border-top-colors: none !important;
   -moz-border-bottom-colors: none !important;
   -moz-border-right-colors: none !important;
   -moz-border-left-colors: none !important;
-  -moz-border-radius: @border_radius_tiny@;
+  border-radius: @border_radius_tiny@;
   border: @border_width_tiny@ solid rgba(255, 255, 255, 0.4) !important;
 }
 
 .scroller[panning="true"] {
   opacity: 1;
 }
 
 .scroller[orient="vertical"] {
--- a/mobile/android/themes/core/gingerbread/content.css
+++ b/mobile/android/themes/core/gingerbread/content.css
@@ -129,17 +129,17 @@ xul|scrollbarbutton[sbattr="scrollbar-bo
 
 xul|scrollbar xul|thumb {
   background-color: @color_background_scroller@ !important;
   -moz-border-top-colors: none !important;
   -moz-border-bottom-colors: none !important;
   -moz-border-right-colors: none !important;
   -moz-border-left-colors: none !important;
   border: 1px solid rgba(255, 255, 255, 0.4) !important;
-  -moz-border-radius: 3px;
+  border-radius: 3px;
 }
 
 select:not([size]):not([multiple]) > xul|scrollbar,
 select[size="1"] > xul|scrollbar,
 select:not([size]):not([multiple]) xul|scrollbarbutton,
 select[size="1"] xul|scrollbarbutton {
   display: block;
   margin-left: 0;
@@ -148,17 +148,17 @@ select[size="1"] xul|scrollbarbutton {
 
 /* Override inverse OS themes */
 select,
 textarea,
 button,
 xul|button,
 * > input:not([type="image"]) {
   -moz-appearance: none !important;  /* See bug 598421 for fixing the platform */
-  -moz-border-radius: 3px;
+  border-radius: 3px;
 }
 
 select[size],
 select[multiple],
 select[size][multiple],
 textarea,
 * > input:not([type="image"]) {
   border-style: solid;
@@ -230,17 +230,17 @@ input[type="checkbox"] {
   border: 1px solid #a7a7a7 !important;
   padding: 2px 1px 2px 1px;
 }
 
 select > button {
   border-width: 0px !important;
   margin: 0px !important;
   padding: 0px !important;
-  -moz-border-radius: 0;
+  border-radius: 0;
   color: #414141;
 
   background-size: auto auto, 100% 90%;
   background-color: transparent;
   background-image: url("chrome://browser/skin/images/dropmarker.svg"),
                     -moz-radial-gradient(bottom left, #bbbbbb 40%, #f5f5f5) !important;
   background-position: -moz-calc(50% + 1px) center, -15px center !important;
   background-repeat: no-repeat !important;
--- a/mobile/android/themes/core/honeycomb/browser.css
+++ b/mobile/android/themes/core/honeycomb/browser.css
@@ -42,17 +42,17 @@
 /* content scrollbars */
 .scroller {
   opacity: 0;
   background-color: rgba(0, 0, 0, 0.4) !important;
   -moz-border-top-colors: none !important;
   -moz-border-bottom-colors: none !important;
   -moz-border-right-colors: none !important;
   -moz-border-left-colors: none !important;
-  -moz-border-radius: @border_radius_tiny@;
+  border-radius: @border_radius_tiny@;
   border: @border_width_tiny@ solid rgba(255, 255, 255, 0.4) !important;
 }
 
 .scroller[panning="true"] {
   opacity: 1;
 }
 
 .scroller[orient="vertical"] {
--- a/mobile/xul/themes/core/about.css
+++ b/mobile/xul/themes/core/about.css
@@ -7,17 +7,17 @@ html {
 
 body {
   color: black;
   position: relative;
   min-width: 330px;
   max-width: 50em;
   margin: 1em auto;
   border: 1px solid gray;
-  -moz-border-radius: 10px;
+  border-radius: 10px;
   padding: 3em;
   -moz-padding-start: 30px;
   background: white;
 }
 
 .aboutPageWideContainer {
   max-width: 80%;
 }
--- a/mobile/xul/themes/core/browser.css
+++ b/mobile/xul/themes/core/browser.css
@@ -71,17 +71,17 @@ toolbarbutton.urlbar-button {
   -moz-margin-end: @margin_normal@; /* core spacing */
   list-style-image: url("chrome://browser/skin/images/task-switch-hdpi.png");
   background-color: transparent !important;
   border: none !important;
 }
 
 #tool-app-switch:hover:active {
   background-color: #8db8d8 !important;
-  -moz-border-radius-bottomright: @border_radius_small@;
+  border-bottom-right-radius: @border_radius_small@;
 }
 
 #toolbar-main[fullscreen="true"] #tool-app-switch:not(:-moz-system-metric(maemo-classic)) {
   visibility: visible;
 }
 
 /* MAEMO (and desktop) only */
 #tool-app-close {
@@ -95,21 +95,21 @@ toolbarbutton.urlbar-button {
   border: none !important;
 }
 
 #tool-app-close:hover:active {
   background-color: #8db8d8 !important;
 }
 
 #tool-app-close:hover:active:-moz-locale-dir(ltr) {
-  -moz-border-radius-bottomleft: @border_radius_small@;
+  border-bottom-left-radius: @border_radius_small@;
 }
 
 #tool-app-close:hover:active:-moz-locale-dir(rtl) {
-  -moz-border-radius-bottomright: @border_radius_small@;
+  border-bottom-right-radius: @border_radius_small@;
 }
 
 %if MOZ_PLATFORM_MAEMO != 6
 #toolbar-main[fullscreen="true"] #tool-app-close {
   visibility: visible;
 }
 %endif
 
@@ -154,23 +154,23 @@ toolbarbutton.urlbar-button {
 }
 
 /* left cap button --------------------------------------------------------- */
 #identity-box {
   -moz-border-end: @border_width_tiny@ solid rgba(118,121,126,0.5) !important;
 }
 
 #identity-box:-moz-locale-dir(ltr) {
-  -moz-border-radius-topleft: @border_radius_normal@;
-  -moz-border-radius-bottomleft: @border_radius_normal@;
+  border-top-left-radius: @border_radius_normal@;
+  border-bottom-left-radius: @border_radius_normal@;
 }
 
 #identity-box:-moz-locale-dir(rtl) {
-  -moz-border-radius-topright: @border_radius_normal@;
-  -moz-border-radius-bottomright: @border_radius_normal@;
+  border-top-right-radius: @border_radius_normal@;
+  border-bottom-right-radius: @border_radius_normal@;
 }
 
 #identity-box[open="true"],
 #identity-box:hover:active {
   -moz-border-end: @border_width_tiny@ solid rgba(0, 0, 0, 0.2);
 }
 
 /* add special color */
@@ -234,23 +234,23 @@ toolbarbutton.urlbar-button {
   -moz-appearance: none !important;
   border-radius: 0;
   border: 0 solid transparent;
   -moz-border-end: @border_width_tiny@ solid rgba(0,0,0,0.5);
   padding: 0 !important;
 }
 
 #urlbar-edit:-moz-locale-dir(ltr) {
-  -moz-border-radius-topleft: @border_radius_normal@;
-  -moz-border-radius-bottomleft: @border_radius_normal@;
+  border-top-left-radius: @border_radius_normal@;
+  border-bottom-left-radius: @border_radius_normal@;
 }
 
 #urlbar-edit:-moz-locale-dir(rtl) {
-  -moz-border-radius-topright: @border_radius_normal@;
-  -moz-border-radius-bottomright: @border_radius_normal@;
+  border-top-right-radius: @border_radius_normal@;
+  border-bottom-right-radius: @border_radius_normal@;
 }
 
 #urlbar-edit > hbox > .textbox-input-box {
   margin: 0;
 }
 
 :invalid {
   box-shadow: none;
@@ -262,23 +262,23 @@ toolbarbutton.urlbar-button {
 }
 
 /* Right cap button --------------------------------------------------------- */
 #urlbar-icons {
   -moz-border-start: @border_width_tiny@ solid rgba(118,121,126,0.5) !important;
 }
 
 #urlbar-icons:-moz-locale-dir(ltr) {
-  -moz-border-radius-topright: @border_radius_normal@;
-  -moz-border-radius-bottomright: @border_radius_normal@;
+  border-top-right-radius: @border_radius_normal@;
+  border-bottom-right-radius: @border_radius_normal@;
 }
 
 #urlbar-icons:-moz-locale-dir(rtl) {
-  -moz-border-radius-topleft: @border_radius_normal@;
-  -moz-border-radius-bottomleft: @border_radius_normal@;
+  border-top-left-radius: @border_radius_normal@;
+  border-bottom-left-radius: @border_radius_normal@;
 }
 
 #urlbar-icons[disabled="true"] {
   pointer-events: none;
 }
 
 #urlbar-icons[disabled="true"] > toolbarbutton {
   opacity: 0.5;
@@ -389,25 +389,25 @@ toolbarbutton.urlbar-button {
   border: none !important;
 }
 
 .panel-close:hover:active {
   background-color: #8db8d8 !important;
 }
 
 .panel-close:hover:active:-moz-locale-dir(ltr) {
-  -moz-border-radius-bottomleft: @border_radius_small@;
+  border-bottom-left-radius: @border_radius_small@;
 }
 
 .panel-close:-moz-locale-dir(rtl) {
   list-style-image: url("chrome://browser/skin/images/task-back-rtl-hdpi.png");
 }
 
 .panel-close:hover:active:-moz-locale-dir(rtl) {
-  -moz-border-radius-bottomright: @border_radius_small@;
+  border-bottom-right-radius: @border_radius_small@;
 }
 %endif
 
 /* awesomescreen buttons --------------------------------------------------- */
 toolbarbutton.choice-all {
   list-style-image: url(chrome://browser/skin/images/allpages-48.png);
 }
 
@@ -834,17 +834,17 @@ placeitem[src=""] .bookmark-item-contain
   visibility: hidden;
 }
 
 .autocomplete-item-badge {
   opacity: 1;
   -moz-transition: opacity 1s ease;
   background-color: #c90707;
   border: @border_width_tiny@ solid #951919;
-  -moz-border-radius: @border_radius_tiny@;
+  border-radius: @border_radius_tiny@;
   content: attr(badge);
   font-size: @font_xtiny@ !important;
   font-weight: bolder;
   margin: @margin_small@ 0 0 0;
   padding: @padding_small@ @padding_snormal@;
   color: white;
 }
 
@@ -1544,17 +1544,17 @@ setting {
 /* content scrollbars */
 .scroller {
   opacity: 0;
   background-color: rgba(0, 0, 0, 0.4) !important;
   -moz-border-top-colors: none !important;
   -moz-border-bottom-colors: none !important;
   -moz-border-right-colors: none !important;
   -moz-border-left-colors: none !important;
-  -moz-border-radius: @border_radius_tiny@;
+  border-radius: @border_radius_tiny@;
   border: @border_width_tiny@ solid rgba(255, 255, 255, 0.4) !important;
 }
 
 .scroller[panning="true"] {
   opacity: 1;
 }
 
 .scroller[orient="vertical"] {
@@ -1613,17 +1613,17 @@ setting {
 }
 
 #selectionhandle-end {
   list-style-image: url("chrome://browser/skin/images/handle-end.png");
 }
 
 @media (min-width: @tablet_panel_minwidth@) {
   #awesome-panels {
-    -moz-box-shadow: 0px 0px @shadow_width_small@ black;
+    box-shadow: 0px 0px @shadow_width_small@ black;
   }
   #search-engines-popup {
     max-width: -moz-calc(@tablet_panel_minwidth@);
   }
 }
 
 /* Capture picker ------------------------------------------------------------- */
 
--- a/mobile/xul/themes/core/content.css
+++ b/mobile/xul/themes/core/content.css
@@ -124,17 +124,17 @@ xul|scrollbarbutton[sbattr="scrollbar-bo
 
 xul|scrollbar xul|thumb {
   background-color: rgba(0, 0, 0, 0.4) !important;
   -moz-border-top-colors: none !important;
   -moz-border-bottom-colors: none !important;
   -moz-border-right-colors: none !important;
   -moz-border-left-colors: none !important;
   border: 1px solid rgba(255, 255, 255, 0.4) !important;
-  -moz-border-radius: 3px;
+  border-radius: 3px;
 }
 
 select:not([size]):not([multiple]) > xul|scrollbar,
 select[size="1"] > xul|scrollbar,
 select:not([size]):not([multiple]) xul|scrollbarbutton,
 select[size="1"] xul|scrollbarbutton {
   display: block;
   margin-left: 0;
@@ -143,17 +143,17 @@ select[size="1"] xul|scrollbarbutton {
 
 /* Override inverse OS themes */
 select,
 textarea,
 button,
 xul|button,
 * > input:not([type="image"]) {
   -moz-appearance: none !important;  /* See bug 598421 for fixing the platform */
-  -moz-border-radius: 3px;
+  border-radius: 3px;
 }
 
 select[size],
 select[multiple],
 select[size][multiple],
 textarea,
 * > input:not([type="image"]) {
   border-style: solid;
@@ -230,17 +230,17 @@ input[type="checkbox"] {
   border: 1px solid #a7a7a7 !important;
   padding: 2px 1px 2px 1px;
 }
 
 select > button {
   border-width: 0px !important;
   margin: 0px !important;
   padding: 0px !important;
-  -moz-border-radius: 0;
+  border-radius: 0;
   color: #414141;
 
   background-size: 100% 90%;
   background-color: transparent;
   background-image: -moz-radial-gradient(bottom left, #bbbbbb 40%, #f5f5f5) !important;
   background-position: -15px center !important;
   background-repeat: no-repeat !important;
 
--- a/mobile/xul/themes/core/gingerbread/browser.css
+++ b/mobile/xul/themes/core/gingerbread/browser.css
@@ -71,17 +71,17 @@ toolbarbutton.urlbar-button {
   -moz-margin-end: @margin_normal@; /* core spacing */
   list-style-image: url("chrome://browser/skin/images/task-switch-hdpi.png");
   background-color: transparent !important;
   border: none !important;
 }
 
 #tool-app-switch:hover:active {
   background-color: @color_background_highlight@ !important;
-  -moz-border-radius-bottomright: @border_radius_small@;
+  border-bottom-right-radius: @border_radius_small@;
 }
 
 #toolbar-main[fullscreen="true"] #tool-app-switch:not(:-moz-system-metric(maemo-classic)) {
   visibility: visible;
 }
 
 /* MAEMO (and desktop) only */
 #tool-app-close {
@@ -95,21 +95,21 @@ toolbarbutton.urlbar-button {
   border: none !important;
 }
 
 #tool-app-close:hover:active {
   background-color: @color_background_highlight@ !important;
 }
 
 #tool-app-close:hover:active:-moz-locale-dir(ltr) {
-  -moz-border-radius-bottomleft: @border_radius_small@;
+  border-bottom-left-radius: @border_radius_small@;
 }
 
 #tool-app-close:hover:active:-moz-locale-dir(rtl) {
-  -moz-border-radius-bottomright: @border_radius_small@;
+  border-bottom-right-radius: @border_radius_small@;
 }
 
 %if MOZ_PLATFORM_MAEMO != 6
 #toolbar-main[fullscreen="true"] #tool-app-close {
   visibility: visible;
 }
 %endif
 
@@ -359,25 +359,25 @@ toolbarbutton.urlbar-button {
   border: none !important;
 }
 
 .panel-close:hover:active {
   background-color: @color_background_highlight@ !important;
 }
 
 .panel-close:hover:active:-moz-locale-dir(ltr) {
-  -moz-border-radius-bottomleft: @border_radius_small@;
+  border-bottom-left-radius: @border_radius_small@;
 }
 
 .panel-close:-moz-locale-dir(rtl) {
   list-style-image: url("chrome://browser/skin/images/task-back-rtl-hdpi.png");
 }
 
 .panel-close:hover:active:-moz-locale-dir(rtl) {
-  -moz-border-radius-bottomright: @border_radius_small@;
+  border-bottom-right-radius: @border_radius_small@;
 }
 %endif
 
 /* awesomescreen buttons --------------------------------------------------- */
 toolbarbutton.choice-all {
   list-style-image: url(chrome://browser/skin/images/allpages-48.png);
 }
 
@@ -801,17 +801,17 @@ placeitem[src=""] .bookmark-item-contain
   visibility: hidden;
 }
 
 .autocomplete-item-badge {
   opacity: 1;
   -moz-transition: opacity 1s ease;
   background-color: #c90707;
   border: @border_width_tiny@ solid #951919;
-  -moz-border-radius: @border_radius_tiny@;
+  border-radius: @border_radius_tiny@;
   content: attr(badge);
   font-size: @font_xtiny@ !important;
   font-weight: bolder;
   margin: @margin_small@ 0 0 0;
   padding: @padding_small@ @padding_snormal@;
   color: white;
 }
 
--- a/mobile/xul/themes/core/gingerbread/content.css
+++ b/mobile/xul/themes/core/gingerbread/content.css
@@ -129,17 +129,17 @@ xul|scrollbarbutton[sbattr="scrollbar-bo
 
 xul|scrollbar xul|thumb {
   background-color: @color_background_scroller@ !important;
   -moz-border-top-colors: none !important;
   -moz-border-bottom-colors: none !important;
   -moz-border-right-colors: none !important;
   -moz-border-left-colors: none !important;
   border: 1px solid rgba(255, 255, 255, 0.4) !important;
-  -moz-border-radius: 3px;
+  border-radius: 3px;
 }
 
 select:not([size]):not([multiple]) > xul|scrollbar,
 select[size="1"] > xul|scrollbar,
 select:not([size]):not([multiple]) xul|scrollbarbutton,
 select[size="1"] xul|scrollbarbutton {
   display: block;
   margin-left: 0;
@@ -148,17 +148,17 @@ select[size="1"] xul|scrollbarbutton {
 
 /* Override inverse OS themes */
 select,
 textarea,
 button,
 xul|button,
 * > input:not([type="image"]) {
   -moz-appearance: none !important;  /* See bug 598421 for fixing the platform */
-  -moz-border-radius: 3px;
+  border-radius: 3px;
 }
 
 select[size],
 select[multiple],
 select[size][multiple],
 textarea,
 * > input:not([type="image"]) {
   border-style: solid;
@@ -230,17 +230,17 @@ input[type="checkbox"] {
   border: 1px solid #a7a7a7 !important;
   padding: 2px 1px 2px 1px;
 }
 
 select > button {
   border-width: 0px !important;
   margin: 0px !important;
   padding: 0px !important;
-  -moz-border-radius: 0;
+  border-radius: 0;
   color: #414141;
 
   background-size: 100% 90%;
   background-color: transparent;
   background-image: -moz-radial-gradient(bottom left, #bbbbbb 40%, #f5f5f5) !important;
   background-position: -15px center !important;
   background-repeat: no-repeat !important;
 
--- a/mobile/xul/themes/core/honeycomb/browser.css
+++ b/mobile/xul/themes/core/honeycomb/browser.css
@@ -74,17 +74,17 @@ toolbarbutton.urlbar-button {
   -moz-margin-end: @margin_normal@; /* core spacing */
   list-style-image: url("chrome://browser/skin/images/task-switch-hdpi.png");
   background-color: transparent !important;
   border: none !important;
 }
 
 #tool-app-switch:hover:active {
   background-color: @color_background_highlight@ !important;
-  -moz-border-radius-bottomright: @border_radius_small@;
+  border-bottom-right-radius: @border_radius_small@;
 }
 
 #toolbar-main[fullscreen="true"] #tool-app-switch:not(:-moz-system-metric(maemo-classic)) {
   visibility: visible;
 }
 
 /* MAEMO (and desktop) only */
 #tool-app-close {
@@ -98,21 +98,21 @@ toolbarbutton.urlbar-button {
   border: none !important;
 }
 
 #tool-app-close:hover:active {
   background-color: @color_background_highlight@ !important;
 }
 
 #tool-app-close:hover:active:-moz-locale-dir(ltr) {
-  -moz-border-radius-bottomleft: @border_radius_small@;
+  border-bottom-left-radius: @border_radius_small@;
 }
 
 #tool-app-close:hover:active:-moz-locale-dir(rtl) {
-  -moz-border-radius-bottomright: @border_radius_small@;
+  border-bottom-right-radius: @border_radius_small@;
 }
 
 %if MOZ_PLATFORM_MAEMO != 6
 #toolbar-main[fullscreen="true"] #tool-app-close {
   visibility: visible;
 }
 %endif
 
@@ -404,17 +404,17 @@ toolbarbutton.urlbar-button {
 }
 
 #tool-back2 {
   margin: @margin_small@ @margin_snormal@;
   /* adjust the min-width of this button to account for padding */
   min-width: -moz-calc(@touch_button_small@ - 2 * @margin_snormal@) !important;
   min-height: -moz-calc(@touch_button_small@ - 2 * @margin_snormal@) !important;
   border: @border_width_small@ solid @color_url_border@;
-  -moz-border-radius: 100%;
+  border-radius: 100%;
 }
  
 #tool-back2 image {
   -moz-margin-end: 0;
 }
 
 #tool-forward2 {
   margin: 0px;
@@ -456,25 +456,25 @@ toolbarbutton.urlbar-button {
   border: none !important;
 }
 
 .panel-close:hover:active {
   background-color: @color_background_highlight@ !important;
 }
 
 .panel-close:hover:active:-moz-locale-dir(ltr) {
-  -moz-border-radius-bottomleft: @border_radius_small@;
+  border-bottom-left-radius: @border_radius_small@;
 }
 
 .panel-close:-moz-locale-dir(rtl) {
   list-style-image: url("chrome://browser/skin/images/task-back-rtl-hdpi.png");
 }
 
 .panel-close:hover:active:-moz-locale-dir(rtl) {
-  -moz-border-radius-bottomright: @border_radius_small@;
+  border-bottom-right-radius: @border_radius_small@;
 }
 %endif
 
 /* awesomescreen buttons --------------------------------------------------- */
 toolbarbutton.choice-all {
   list-style-image: url("chrome://browser/skin/images/autocomplete-all-hdpi.png");
 }
 
@@ -963,17 +963,17 @@ placeitem[src=""] .bookmark-item-contain
   visibility: hidden;
 }
 
 .autocomplete-item-badge {
   opacity: 1;
   -moz-transition: opacity 1s ease;
   background-color: #c90707;
   border: @border_width_tiny@ solid #951919;
-  -moz-border-radius: @border_radius_tiny@;
+  border-radius: @border_radius_tiny@;
   content: attr(badge);
   font-size: @font_xtiny@ !important;
   font-weight: bolder;
   margin: @margin_small@ 0 0 0;
   padding: @padding_small@ @padding_snormal@;
   color: white;
 }
 
--- a/mobile/xul/themes/core/platform.css
+++ b/mobile/xul/themes/core/platform.css
@@ -73,17 +73,17 @@ textbox {
   color: black;
   background-color: white;
 }
 
 /* textboxes --------------------------------------------------------------- */
 textbox:not([type="number"]) {
   min-height: @textbox_height@;
   border: @border_width_small@ solid #cacdd5;
-  -moz-border-radius: @border_radius_normal@;
+  border-radius: @border_radius_normal@;
   -moz-border-top-colors: -moz-initial;
   -moz-border-right-colors: -moz-initial;
   -moz-border-bottom-colors: -moz-initial;
   -moz-border-left-colors: -moz-initial;
 }
 
 textbox[isempty="true"] {
   color: gray;
@@ -543,17 +543,17 @@ progressmeter {
   background-color: #fff;
   padding: @padding_small@;
   height: @textbox_height@;
   border: @border_width_large@ solid #aaa;
   -moz-border-top-colors: -moz-initial;
   -moz-border-right-colors: -moz-initial;
   -moz-border-bottom-colors: -moz-initial;
   -moz-border-left-colors: -moz-initial;
-  -moz-border-radius: @border_radius_normal@;
+  border-radius: @border_radius_normal@;
 }
 
 .progress-bar {
   background-color: #8db8d8;
 }
 
 /* panels / arrowboxes------------------------------------------------------ */
 arrowbox {
--- a/mobile/xul/themes/core/tablet.css
+++ b/mobile/xul/themes/core/tablet.css
@@ -206,17 +206,17 @@ arrowbox {
 
 .tab-popup-item:only-child .documenttab-popup-closebutton {
   display: none;
 }
 
 %ifndef honeycomb
 @media (min-width: @tablet_panel_minwidth@) {
   #awesome-panels {
-    -moz-box-shadow: 0px 0px @shadow_width_small@ black;
+    box-shadow: 0px 0px @shadow_width_small@ black;
   }
   #search-engines-popup {
     max-width: -moz-calc(@tablet_panel_minwidth@);
   }
 }
 .documenttab-popup-closebutton {
   list-style-image: url("chrome://browser/skin/images/close-default-hdpi.png");
 }
--- a/modules/libjar/nsZipArchive.cpp
+++ b/modules/libjar/nsZipArchive.cpp
@@ -622,16 +622,28 @@ MOZ_WIN_MEM_TRY_BEGIN
     mFiles[hash] = item;
 
     sig = 0;
   } /* while reading central directory records */
 
   if (sig != ENDSIG)
     return NS_ERROR_FILE_CORRUPTED;
 
+  // Make the comment available for consumers.
+  if (endp - buf >= ZIPEND_SIZE) {
+    ZipEnd *zipend = (ZipEnd *)buf;
+
+    buf += ZIPEND_SIZE;
+    PRUint16 commentlen = xtoint(zipend->commentfield_len);
+    if (endp - buf >= commentlen) {
+      mCommentPtr = (const char *)buf;
+      mCommentLen = commentlen;
+    }
+  }
+
 MOZ_WIN_MEM_TRY_CATCH(return NS_ERROR_FAILURE)
   return NS_OK;
 }
 
 //---------------------------------------------
 //  nsZipArchive::BuildSynthetics
 //---------------------------------------------
 nsresult nsZipArchive::BuildSynthetics()
@@ -738,16 +750,25 @@ MOZ_WIN_MEM_TRY_BEGIN
   // -- check if there is enough source data in the file
   if (offset + aItem->Size() > len)
     return nsnull;
 
   return data + offset;
 MOZ_WIN_MEM_TRY_CATCH(return nsnull)
 }
 
+// nsZipArchive::GetComment
+bool nsZipArchive::GetComment(nsACString &aComment)
+{
+MOZ_WIN_MEM_TRY_BEGIN
+  aComment.Assign(mCommentPtr, mCommentLen);
+MOZ_WIN_MEM_TRY_CATCH(return false)
+  return true;
+}
+
 //---------------------------------------------
 // nsZipArchive::SizeOfMapping
 //---------------------------------------------
 PRInt64 nsZipArchive::SizeOfMapping()
 {
     return mFd ? mFd->SizeOfMapping() : 0;
 }
 
--- a/modules/libjar/nsZipArchive.h
+++ b/modules/libjar/nsZipArchive.h
@@ -219,16 +219,18 @@ public:
 
   /**
    * Get pointer to the data of the item.
    * @param   aItem       Pointer to nsZipItem
    * reutrns null when zip file is corrupt.
    */
   const PRUint8* GetData(nsZipItem* aItem);
 
+  bool GetComment(nsACString &aComment);
+
   /**
    * Gets the amount of memory taken up by the archive's mapping.
    * @return the size
    */
   PRInt64 SizeOfMapping();
 
   /*
    * Refcounting
@@ -238,16 +240,19 @@ public:
 
 private:
   //--- private members ---
   nsrefcnt      mRefCnt; /* ref count */
 
   nsZipItem*    mFiles[ZIP_TABSIZE];
   PLArenaPool   mArena;
 
+  const char*   mCommentPtr;
+  PRUint16      mCommentLen;
+
   // Whether we synthesized the directory entries
   bool          mBuiltSynthetics;
 
   // file handle
   nsRefPtr<nsZipHandle> mFd;
 
   // logging handle
   mozilla::AutoFDClose mLog;
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -3406,16 +3406,17 @@ pref("alerts.slideIncrementTime", 10);
 pref("alerts.totalOpenTime", 4000);
 pref("alerts.disableSlidingEffect", false);
 
 // DOM full-screen API.
 pref("full-screen-api.enabled", false);
 pref("full-screen-api.allow-trusted-requests-only", true);
 pref("full-screen-api.key-input-restricted", true);
 pref("full-screen-api.warning.enabled", true);
+pref("full-screen-api.exit-on-deactivate", true);
 
 // Time limit, in milliseconds, for nsEventStateManager::IsHandlingUserInput().
 // Used to detect long running handlers of user-generated events.
 pref("dom.event.handling-user-input-time-limit", 1000);
  
 //3D Transforms
 pref("layout.3d-transforms.enabled", true);
 
--- a/mozglue/linker/szip.cpp
+++ b/mozglue/linker/szip.cpp
@@ -62,17 +62,17 @@ int main(int argc, char* argv[])
   /* Expected total number of chunks */
   size_t nChunks = ((origSize + CHUNK - 1) / CHUNK);
 
   /* The first chunk is going to be stored after the header and the offset
    * table */
   size_t offset = sizeof(SeekableZStreamHeader) + nChunks * sizeof(uint32_t);
 
   /* Give enough room for the header and the offset table, and map them */
-  ret = posix_fallocate(outFd, 0, offset);
+  ret = ftruncate(outFd, offset);
   MOZ_ASSERT(ret == 0);
   MappedPtr headerMap;
   headerMap.Assign(mmap(NULL, offset, PROT_READ | PROT_WRITE, MAP_SHARED,
                         outFd, 0), offset);
   if (headerMap == MAP_FAILED) {
     log("Couldn't mmap %s: %s", argv[1], strerror(errno));
     return 1;
   }
--- a/startupcache/StartupCache.cpp
+++ b/startupcache/StartupCache.cpp
@@ -35,16 +35,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "prio.h"
 #include "prtypes.h"
 #include "pldhash.h"
+#include "nsXPCOMStrings.h"
 #include "mozilla/scache/StartupCache.h"
 
 #include "nsAutoPtr.h"
 #include "nsClassHashtable.h"
 #include "nsComponentManagerUtils.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsIClassInfo.h"
 #include "nsIFile.h"
@@ -61,16 +62,17 @@
 #include "nsITimer.h"
 #include "nsIZipWriter.h"
 #include "nsIZipReader.h"
 #include "nsWeakReference.h"
 #include "nsZipArchive.h"
 #include "mozilla/Omnijar.h"
 #include "prenv.h"
 #include "mozilla/FunctionTimer.h"
+#include "mozilla/Telemetry.h"
 #include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
 #include "nsIProtocolHandler.h"
 
 #ifdef IS_BIG_ENDIAN
 #define SC_ENDIAN "big"
 #else
 #define SC_ENDIAN "little"
@@ -147,16 +149,17 @@ StartupCache::InitSingleton()
     delete StartupCache::gStartupCache;
     StartupCache::gStartupCache = nsnull;
   }
   return rv;
 }
 
 StartupCache* StartupCache::gStartupCache;
 bool StartupCache::gShutdownInitiated;
+enum StartupCache::TelemetrifyAge StartupCache::gPostFlushAgeAction = StartupCache::IGNORE_AGE;
 
 StartupCache::StartupCache() 
   : mArchive(NULL), mStartupWriteInitiated(false), mWriteThread(NULL),
     mMappingMemoryReporter(nsnull), mDataMemoryReporter(nsnull) { }
 
 StartupCache::~StartupCache() 
 {
   if (mTimer) {
@@ -232,17 +235,17 @@ StartupCache::Init()
   mListener = new StartupCacheListener();  
   rv = mObserverService->AddObserver(mListener, NS_XPCOM_SHUTDOWN_OBSERVER_ID,
                                      false);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = mObserverService->AddObserver(mListener, "startupcache-invalidate",
                                      false);
   NS_ENSURE_SUCCESS(rv, rv);
   
-  rv = LoadArchive();
+  rv = LoadArchive(RECORD_AGE);
   
   // Sometimes we don't have a cache yet, that's ok.
   // If it's corrupted, just remove it and start over.
   if (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND) {
     NS_WARNING("Failed to load startupcache file correctly, removing!");
     InvalidateCache();
   }
 
@@ -253,26 +256,53 @@ StartupCache::Init()
 
   return NS_OK;
 }
 
 /** 
  * LoadArchive can be called from the main thread or while reloading cache on write thread.
  */
 nsresult
-StartupCache::LoadArchive() 
+StartupCache::LoadArchive(enum TelemetrifyAge flag)
 {
   bool exists;
   mArchive = NULL;
   nsresult rv = mFile->Exists(&exists);
   if (NS_FAILED(rv) || !exists)
     return NS_ERROR_FILE_NOT_FOUND;
   
   mArchive = new nsZipArchive();
-  return mArchive->OpenArchive(mFile);
+  rv = mArchive->OpenArchive(mFile);
+  if (NS_FAILED(rv) || flag == IGNORE_AGE)
+    return rv;
+
+  nsCString comment;
+  if (!mArchive->GetComment(comment)) {
+    return rv;
+  }
+
+  const char *data;
+  size_t len = NS_CStringGetData(comment, &data);
+  PRTime creationStamp;
+  // We might not have a comment if the startup cache file was created
+  // before we started recording creation times in the comment.
+  if (len == sizeof(creationStamp)) {
+    memcpy(&creationStamp, data, len);
+    PRTime current = PR_Now();
+    PRInt64 diff = current - creationStamp;
+
+    // We can't use AccumulateTimeDelta here because we have no way of
+    // reifying a TimeStamp from creationStamp.
+    PRInt64 usec_per_hour = PR_USEC_PER_SEC * PRInt64(3600);
+    PRInt64 hour_diff = (diff + usec_per_hour - 1) / usec_per_hour;
+    mozilla::Telemetry::Accumulate(Telemetry::STARTUP_CACHE_AGE_HOURS,
+                                   hour_diff);
+  }
+
+  return rv;
 }
 
 namespace {
 
 nsresult
 GetBufferFromZipArchive(nsZipArchive *zip, bool doCRC, const char* id,
                         char** outbuf, PRUint32* length)
 {
@@ -430,48 +460,59 @@ StartupCache::WriteToDisk()
     return;
 
   rv = zipW->Open(mFile, PR_RDWR | PR_CREATE_FILE);
   if (NS_FAILED(rv)) {
     NS_WARNING("could not open zipfile for write");
     return;
   } 
 
+  // If we didn't have an mArchive member, that means that we failed to
+  // open the startup cache for reading.  Therefore, we need to record
+  // the time of creation in a zipfile comment; this will be useful for
+  // Telemetry statistics.
+  PRTime now = PR_Now();
+  if (!mArchive) {
+    nsCString comment;
+    comment.Assign((char *)&now, sizeof(now));
+    zipW->SetComment(comment);
+  }
+
   nsCOMPtr<nsIStringInputStream> stream 
     = do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
   if (NS_FAILED(rv)) {
     NS_WARNING("Couldn't create string input stream.");
     return;
   }
 
   CacheWriteHolder holder;
   holder.stream = stream;
   holder.writer = zipW;
-  holder.time = PR_Now();
+  holder.time = now;
 
   mTable.Enumerate(CacheCloseHelper, &holder);
 
   // Close the archive so Windows doesn't choke.
   mArchive = NULL;
   zipW->Close();
 
-  // our reader's view of the archive is outdated now, reload it.
-  LoadArchive();
+  // Our reader's view of the archive is outdated now, reload it.
+  LoadArchive(gPostFlushAgeAction);
   
   return;
 }
 
 void
 StartupCache::InvalidateCache() 
 {
   WaitOnWriteThread();
   mTable.Clear();
   mArchive = NULL;
   mFile->Remove(false);
-  LoadArchive();
+  LoadArchive(gPostFlushAgeAction);
 }
 
 /*
  * WaitOnWriteThread() is called from a main thread to wait for the worker
  * thread to finish. However since the same code is used in the worker thread and
  * main thread, the worker thread can also call WaitOnWriteThread() which is a no-op.
  */
 void
@@ -557,16 +598,23 @@ StartupCache::ResetStartupWriteTimer()
     rv = mTimer->Cancel();
   NS_ENSURE_SUCCESS(rv, rv);
   // Wait for 10 seconds, then write out the cache.
   mTimer->InitWithFuncCallback(StartupCache::WriteTimeout, this, 60000,
                                nsITimer::TYPE_ONE_SHOT);
   return NS_OK;
 }
 
+nsresult
+StartupCache::RecordAgesAlways()
+{
+  gPostFlushAgeAction = RECORD_AGE;
+  return NS_OK;
+}
+
 // StartupCacheDebugOutputStream implementation
 #ifdef DEBUG
 NS_IMPL_ISUPPORTS3(StartupCacheDebugOutputStream, nsIObjectOutputStream, 
                    nsIBinaryOutputStream, nsIOutputStream)
 
 bool
 StartupCacheDebugOutputStream::CheckReferences(nsISupports* aObject)
 {
@@ -736,10 +784,16 @@ StartupCacheWrapper::GetObserver(nsIObse
   StartupCache* sc = StartupCache::GetSingleton();
   if (!sc) {
     return NS_ERROR_NOT_INITIALIZED;
   }
   NS_ADDREF(*obv = sc->mListener);
   return NS_OK;
 }
 
+nsresult
+StartupCacheWrapper::RecordAgesAlways() {
+  StartupCache *sc = StartupCache::GetSingleton();
+  return sc ? sc->RecordAgesAlways() : NS_ERROR_NOT_INITIALIZED;
+}
+
 } // namespace scache
 } // namespace mozilla
--- a/startupcache/StartupCache.h
+++ b/startupcache/StartupCache.h
@@ -146,30 +146,38 @@ public:
   // Removes the cache file.
   void InvalidateCache();
 
   // In DEBUG builds, returns a stream that will attempt to check for
   // and disallow multiple writes of the same object.
   nsresult GetDebugObjectOutputStream(nsIObjectOutputStream* aStream,
                                       nsIObjectOutputStream** outStream);
 
+  nsresult RecordAgesAlways();
+
   static StartupCache* GetSingleton();
   static void DeleteSingleton();
 
   // This measures all the heap memory used by the StartupCache, i.e. it
   // excludes the mapping.
   size_t HeapSizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf);
 
   size_t SizeOfMapping();
 
 private:
   StartupCache();
   ~StartupCache();
 
-  nsresult LoadArchive();
+  enum TelemetrifyAge {
+    IGNORE_AGE = 0,
+    RECORD_AGE = 1
+  };
+  static enum TelemetrifyAge gPostFlushAgeAction;
+
+  nsresult LoadArchive(enum TelemetrifyAge flag);
   nsresult Init();
   void WriteToDisk();
   nsresult ResetStartupWriteTimer();
   void WaitOnWriteThread();
 
   static nsresult InitSingleton();
   static void WriteTimeout(nsITimer *aTimer, void *aClosure);
   static void ThreadedWrite(void *aClosure);
--- a/startupcache/nsIStartupCache.idl
+++ b/startupcache/nsIStartupCache.idl
@@ -37,17 +37,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIInputStream.idl"
 #include "nsISupports.idl"
 #include "nsIObserver.idl"
 #include "nsIObjectOutputStream.idl"
 
-[uuid(8c2a360b-e337-455b-8c1b-04265ef9c5a3)]
+[uuid(c1b3796b-33af-4ff0-b83d-8eb0ca2c080f)]
 interface nsIStartupCache : nsISupports
 {
 
   /** This interface is provided for testing purposes only, basically
    *  just to solve link vagaries. See docs in StartupCache.h
    *  GetBuffer, PutBuffer, and InvalidateCache act as described 
    *  in that file. */
 
@@ -65,12 +65,16 @@ interface nsIStartupCache : nsISupports
 
   /* Allows clients to check whether the one-time writeout after startup 
    * has finished yet, and also to set this variable as needed (so test
    * code can fire mulitple startup writes if needed).
    */
   boolean startupWriteComplete();
   void resetStartupWriteTimer();
 
+  /* Instruct clients to always post cache ages to Telemetry, even in
+     cases where it would not normally make sense.  */
+  void recordAgesAlways();
+
   /* Allows clients to simulate the behavior of ObserverService. */
   readonly attribute nsIObserver observer;
 };
 
--- a/startupcache/test/TestStartupCache.cpp
+++ b/startupcache/test/TestStartupCache.cpp
@@ -48,16 +48,18 @@
 #include "nsIStringStream.h"
 #include "nsIStorageStream.h"
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 #include "nsIURI.h"
 #include "nsStringAPI.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
+#include "nsITelemetry.h"
+#include "jsapi.h"
 
 namespace mozilla {
 namespace scache {
 
 NS_IMPORT nsresult
 NewObjectInputStreamFromBuffer(char* buffer, PRUint32 len, 
                                nsIObjectInputStream** stream);
 
@@ -311,30 +313,173 @@ TestEarlyShutdown() {
   } else {
     fail("GetBuffer gave an unexpected failure, expected NOT_AVAILABLE");
     return rv;
   }
  
   return NS_OK;
 }
 
+bool
+SetupJS(JSContext **cxp)
+{
+  JSRuntime *rt = JS_NewRuntime(32 * 1024 * 1024);
+  if (!rt)
+    return false;
+  JSContext *cx = JS_NewContext(rt, 8192);
+  if (!cx)
+    return false;
+  *cxp = cx;
+  return true;
+}
+
+bool
+GetHistogramCounts(const char *testmsg, JSContext *cx, jsval *counts)
+{
+  nsCOMPtr<nsITelemetry> telemetry = do_GetService("@mozilla.org/base/telemetry;1");
+  NS_NAMED_LITERAL_CSTRING(histogram_id, "STARTUP_CACHE_AGE_HOURS");
+  JS::AutoValueRooter h(cx);
+  nsresult trv = telemetry->GetHistogramById(histogram_id, cx, h.addr());
+  if (NS_FAILED(trv)) {
+    fail("%s: couldn't get histogram", testmsg);
+    return false;
+  }
+  passed(testmsg);
+
+  JS::AutoValueRooter snapshot_val(cx);
+  JSFunction *snapshot_fn = NULL;
+  JS::AutoValueRooter ss(cx);
+  return (JS_GetProperty(cx, JSVAL_TO_OBJECT(h.value()), "snapshot",
+                         snapshot_val.addr())
+          && (snapshot_fn = JS_ValueToFunction(cx, snapshot_val.value()))
+          && JS::Call(cx, JSVAL_TO_OBJECT(h.value()),
+                      snapshot_fn, 0, NULL, ss.addr())
+          && JS_GetProperty(cx, JSVAL_TO_OBJECT(ss.value()),
+                            "counts", counts));
+}
+
+nsresult
+CompareCountArrays(JSContext *cx, JSObject *before, JSObject *after)
+{
+  jsuint before_size, after_size;
+  if (!(JS_GetArrayLength(cx, before, &before_size)
+        && JS_GetArrayLength(cx, after, &after_size))) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  if (before_size != after_size) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  for (jsuint i = 0; i < before_size; ++i) {
+    jsval before_num, after_num;
+
+    if (!(JS_GetElement(cx, before, i, &before_num)
+          && JS_GetElement(cx, after, i, &after_num))) {
+      return NS_ERROR_UNEXPECTED;
+    }
+
+    JSBool same = JS_TRUE;
+    if (!JS_LooselyEqual(cx, before_num, after_num, &same)) {
+      return NS_ERROR_UNEXPECTED;
+    } else {
+      if (same) {
+        continue;
+      } else {
+        // Some element of the histograms's count arrays differed.
+        // That's a good thing!
+        return NS_OK;
+      }
+    }
+  }
+
+  // All of the elements of the histograms's count arrays differed.
+  // Not good, we should have recorded something.
+  return NS_ERROR_FAILURE;
+}
 
 int main(int argc, char** argv)
 {
   ScopedXPCOM xpcom("Startup Cache");
   if (xpcom.failed())
     return 1;
 
   nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
   prefs->SetIntPref("hangmonitor.timeout", 0);
   
   int rv = 0;
+  // nsITelemetry doesn't have a nice C++ interface.
+  JSContext *cx;
+  bool use_js = true;
+  if (!SetupJS(&cx))
+    use_js = false;
+
+  JSAutoRequest req(cx);
+  static JSClass global_class = {
+    "global", JSCLASS_NEW_RESOLVE | JSCLASS_GLOBAL_FLAGS | JSCLASS_HAS_PRIVATE,
+    JS_PropertyStub,  JS_PropertyStub,
+    JS_PropertyStub,  JS_StrictPropertyStub,
+    JS_EnumerateStub, JS_ResolveStub,
+    JS_ConvertStub,   JS_FinalizeStub,
+    JSCLASS_NO_OPTIONAL_MEMBERS
+  };
+  JSObject *glob = nsnull;
+  if (use_js)
+    glob = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL);
+  if (!glob)
+    use_js = false;
+  JSCrossCompartmentCall *compartment = nsnull;
+  if (use_js)
+    compartment = JS_EnterCrossCompartmentCall(cx, glob);
+  if (!compartment)
+    use_js = false;
+  if (use_js && !JS_InitStandardClasses(cx, glob))
+    use_js = false;
+
+  JS::AutoValueRooter before_counts(cx);
+  if (use_js && !GetHistogramCounts("STARTUP_CACHE_AGE_HOURS histogram before test",
+                                 cx, before_counts.addr()))
+    use_js = false;
+  
+  nsresult scrv;
+  nsCOMPtr<nsIStartupCache> sc 
+    = do_GetService("@mozilla.org/startupcache/cache;1", &scrv);
+  if (NS_FAILED(scrv))
+    rv = 1;
+  else
+    sc->RecordAgesAlways();
   if (NS_FAILED(TestStartupWriteRead()))
     rv = 1;
   if (NS_FAILED(TestWriteInvalidateRead()))
     rv = 1;
   if (NS_FAILED(TestWriteObject()))
     rv = 1;
   if (NS_FAILED(TestEarlyShutdown()))
     rv = 1;
-  
+
+  JS::AutoValueRooter after_counts(cx);
+  if (use_js && !GetHistogramCounts("STARTUP_CACHE_AGE_HOURS histogram after test",
+                                    cx, after_counts.addr()))
+    use_js = false;
+
+  if (!use_js) {
+    fail("couldn't check histogram recording");
+    rv = 1;
+  } else {
+    nsresult compare = CompareCountArrays(cx,
+                                          JSVAL_TO_OBJECT(before_counts.value()),
+                                          JSVAL_TO_OBJECT(after_counts.value()));
+    if (compare == NS_ERROR_UNEXPECTED) {
+      fail("count comparison error");
+      rv = 1;
+    } else if (compare == NS_ERROR_FAILURE) {
+      fail("histogram didn't record samples");
+      rv = 1;
+    } else {
+      passed("histogram records samples");
+    }
+  }
+
+  if (use_js)
+    JS_LeaveCrossCompartmentCall(compartment);
+
   return rv;
 }
--- a/testing/mochitest/tests/SimpleTest/specialpowersAPI.js
+++ b/testing/mochitest/tests/SimpleTest/specialpowersAPI.js
@@ -88,55 +88,16 @@ function bindDOMWindowUtils(aWindow) {
     rebind(desc, "get");
     rebind(desc, "set");
     rebind(desc, "value");
     Object.defineProperty(target, i, desc);
   }
   return target;
 }
 
-function Observer(specialPowers, aTopic, aCallback, aIsPref) {
-  this._sp = specialPowers;
-  this._topic = aTopic;
-  this._callback = aCallback;
-  this._isPref = aIsPref;
-}
-
-Observer.prototype = {
-  _sp: null,
-  _topic: null,
-  _callback: null,
-  _isPref: false,
-
-  observe: function(aSubject, aTopic, aData) {
-    if ((!this._isPref && aTopic == this._topic) ||
-        (this._isPref && aTopic == "nsPref:changed")) {
-      if (aData == this._topic) {
-       this.cleanup();
-        /* The callback must execute asynchronously after all the preference observers have run */
-        content.window.setTimeout(this._callback, 0);
-        content.window.setTimeout(this._sp._finishPrefEnv, 0);
-      }
-    }
-  },
-
-  cleanup: function() {
-    if (this._isPref) {
-      var os = Cc["@mozilla.org/preferences-service;1"].getService()
-               .QueryInterface(Ci.nsIPrefBranch);
-      os.removeObserver(this._topic, this);
-    } else {
-      var os = Cc["@mozilla.org/observer-service;1"]
-              .getService(Ci.nsIObserverService)
-              .QueryInterface(Ci.nsIObserverService);
-      os.removeObserver(this, this._topic);
-    }
-  },
-};
-
 function isWrappable(x) {
   if (typeof x === "object")
     return x !== null;
   return typeof x === "function";
 };
 
 function isWrapper(x) {
   return isWrappable(x) && (typeof x.SpecialPowers_wrappedObject !== "undefined");
@@ -613,53 +574,40 @@ SpecialPowersAPI.prototype = {
 
     /* Set lock and get prefs from the _pendingPrefs queue */
     this._applyingPrefs = true;
     var transaction = this._pendingPrefs.shift();
     var pendingActions = transaction[0];
     var callback = transaction[1];
 
     var lastPref = pendingActions[pendingActions.length-1];
-    this._addObserver(lastPref.name, callback, true);
+
+    var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
+    var self = this;
+    pb.addObserver(lastPref.name, function prefObs(subject, topic, data) {
+      pb.removeObserver(lastPref.name, prefObs);
+
+      content.window.setTimeout(callback, 0);
+      content.window.setTimeout(function () {
+        self._applyingPrefs = false;
+        // Now apply any prefs that may have been queued while we were applying
+        self._applyPrefs();
+      }, 0);
+    }, false);
 
     for (var idx in pendingActions) {
       var pref = pendingActions[idx];
       if (pref.action == 'set') {
         this._setPref(pref.name, pref.type, pref.value, pref.Iid);
       } else if (pref.action == 'clear') {
         this.clearUserPref(pref.name);
       }
     }
   },
 
-  _addObserver: function(aTopic, aCallback, aIsPref) {
-    var observer = new Observer(this, aTopic, aCallback, aIsPref);
-
-    if (aIsPref) {
-      var os = Cc["@mozilla.org/preferences-service;1"].getService()
-               .QueryInterface(Ci.nsIPrefBranch);	
-      os.addObserver(aTopic, observer, false);
-    } else {
-      var os = Cc["@mozilla.org/observer-service;1"]
-              .getService(Ci.nsIObserverService)
-              .QueryInterface(Ci.nsIObserverService);
-      os.addObserver(observer, aTopic, false);
-    }
-  },
-
-  /* called from the observer when we get a pref:changed.  */
-  _finishPrefEnv: function() {
-    /*
-      Any subsequent pref environment pushes that occurred while waiting 
-      for the preference update are pending, and will now be executed.
-    */
-    this.wrappedJSObject.SpecialPowers._applyingPrefs = false;
-    this.wrappedJSObject.SpecialPowers._applyPrefs();
-  },
-
   addObserver: function(obs, notification, weak) {
     var obsvc = Cc['@mozilla.org/observer-service;1']
                    .getService(Ci.nsIObserverService);
     obsvc.addObserver(obs, notification, weak);
   },
   removeObserver: function(obs, notification) {
     var obsvc = Cc['@mozilla.org/observer-service;1']
                    .getService(Ci.nsIObserverService);
deleted file mode 100644
--- a/testing/tools/pageloader/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-all:
-	zip -r pageloader.xpi chrome chrome.manifest install.rdf 
-
-check:
-	./test/chrome/content/report.js
-	./test/chrome/content/pageloader.js
deleted file mode 100644
--- a/testing/tools/pageloader/README
+++ /dev/null
@@ -1,13 +0,0 @@
-This is a pageloader extension for Firefox. It cycles through a list of URLs 
-specified in a text file by the user (one URL per line), and reports statistics
-and raw data about the time each page took to load.
-
-This data is dumped to the console, so the browser.dom.window.dump.enabled pref
-(boolean) must be set to "true", and on Windows Firefox must be run with the
-"-console" command line switch.
-
-This test is intended to be run standalone from a chrome URL, e.g.:
-firefox -chrome chrome://pageloader/content/pageloader.xul
-
-The window will close and the data will be dumped to the console when the
-test has completed.
deleted file mode 100644
--- a/testing/tools/pageloader/chrome.manifest
+++ /dev/null
@@ -1,1 +0,0 @@
-content pageloader chrome/content/
deleted file mode 100644
--- a/testing/tools/pageloader/chrome/content/pageloader.css
+++ /dev/null
@@ -1,3 +0,0 @@
-window {
-  background-color: #0088CC;  
-}
deleted file mode 100644
--- a/testing/tools/pageloader/chrome/content/pageloader.js
+++ /dev/null
@@ -1,199 +0,0 @@
-var NUM_CYCLES = 5;
-
-var pages;
-var pageIndex;
-var results;
-var start_time;
-var end_time;
-var cycle;
-var report;
-var running = false;
-
-function plInit() {
-  if (running) {
-    return;
-  }
-  running = true;
-  try { 
-    pageIndex = 0;
-    cycle = 0;
-    results = new Object();
-    if (! pages) {
-      var file;
-      try {
-        file = plDefaultFile();
-      } catch(e) {
-        dumpLine(e);
-      }
-      if (! file.exists()) {
-        try {
-          file = plFilePicker();
-        } catch(e) {
-          dumpLine(e);
-        }
-      }
-      pages = plLoadURLsFromFile(file);
-    }
-    if (! pages ) {
-      alert('could not load URLs, quitting');
-      plStop(true);
-    }
-    if (pages.length == 0) {
-      alert('no pages to test, quitting');
-      plStop(true);
-    }
-    report = new Report(pages);
-    plLoadPage();
-  } catch(e) {
-    dumpLine(e);
-    plStop(true);
-  }
-}
-
-function plLoadPage() {
-  try {
-    start_time = new Date();
-    p = pages[pageIndex];
-    this.content = document.getElementById('contentPageloader');
-    this.content.addEventListener('load', plLoadHandler, true);
-    this.content.loadURI(p);
-  } catch (e) {
-    dumpLine(e);
-    plStop(true);
-  }
-}
-
-function plLoadHandler(evt) {
-  if (evt.type == 'load') {
-    window.setTimeout('reallyHandle()', 500);
-  } else {
-    dumpLine('Unknown event type: '+evt.type);
-    plStop(true);
-  }
-}
-
-function reallyHandle() {
-    if (pageIndex < pages.length) {
-      try { 
-        end_time = new Date();    
-        var pageName = pages[pageIndex];
-        results[pageName] = (end_time - start_time);
-        start_time = new Date();
-        dumpLine(pageName+" took "+results[pageName]);
-        plReport();
-        pageIndex++;
-        plLoadPage();
-      } catch(e) {
-        dumpLine(e);
-        plStop(true);
-      }
-    } else {
-      plStop(false);
-    }
-}
-
-function plReport() {
-    try {
-      var reportNode = document.getElementById('report');
-      var pageName = pages[pageIndex];
-      var time = results[pageName];
-      report.recordTime(pageIndex, time);
-    } catch(e) {
-      dumpLine(e);
-      plStop(false);
-    }
-}
-
-function plStop(force) {
-  try {
-    if (force == false) {
-      pageIndex = 0;
-      results = new Object;
-      if (cycle < NUM_CYCLES) {
-        cycle++;
-        plLoadPage();
-        return;
-      } else {
-        dumpLine(report.getReport());
-      }
-    }
-    this.content.removeEventListener('load', plLoadHandler, true);
-  } catch(e) {
-    dumpLine(e);
-  }
-  goQuitApplication();
-}
-
-/* Returns nsilocalfile */
-function plDefaultFile() {
-  try {
-    const nsIIOService = Components.interfaces.nsIIOService;
-    var dirService = 
-      Components.classes["@mozilla.org/file/directory_service;1"].
-      getService(Components.interfaces.nsIProperties);
-    var profileDir = dirService.get("ProfD", 
-                     Components.interfaces.nsILocalFile);
-    var file = Components.classes["@mozilla.org/file/local;1"].
-               createInstance(Components.interfaces.nsILocalFile);
-    var path = profileDir.path;
-    file.initWithPath(path);
-    file.append("urls.txt");
-    dumpLine('will attempt to load default file '+file.path);
-    return file;
-  } catch (e) {
-    dumpLine(e);
-  }
-}
-
-
-/* Returns nsifile */
-function plFilePicker() {
-  try {
-    const nsIFilePicker = Components.interfaces.nsIFilePicker;
-    
-    var fp = Components.classes["@mozilla.org/filepicker;1"]
-                 .createInstance(nsIFilePicker);
-    fp.init(window, "Dialog Title", nsIFilePicker.modeOpen);
-    fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
-    var rv = fp.show();
-    if (rv == nsIFilePicker.returnOK) {
-      return fp.file;
-    }
-  } catch (e) {
-    dumpLine(e);
-  }
-}
-    
-/* Returns array */
-function plLoadURLsFromFile(file) {
-  try {
-    var data = "";
-    var fstream = 
-                Components.classes["@mozilla.org/network/file-input-stream;1"]
-                .createInstance(Components.interfaces.nsIFileInputStream);
-    var sstream = Components.classes["@mozilla.org/scriptableinputstream;1"]
-              .createInstance(Components.interfaces.nsIScriptableInputStream);
-    fstream.init(file, -1, 0, 0);
-    sstream.init(fstream); 
-    
-    var str = sstream.read(4096);
-    while (str.length > 0) {
-      data += str;
-      str = sstream.read(4096);
-    }
-    
-    sstream.close();
-    fstream.close();
-    var p = data.split("\n");
-    // discard result of final split (EOF)
-    p.pop()
-    return p;
-  } catch (e) {
-    dumpLine(e);
-  }
-}
-
-function dumpLine(str) {
-  dump(str);
-  dump("\n");
-}
deleted file mode 100644
--- a/testing/tools/pageloader/chrome/content/pageloader.xul
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet href="pageloader.css" type="text/css"?>
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        onload="plInit()">
-  <script type="application/x-javascript" 
-          src="chrome://global/content/globalOverlay.js"/>
-  <script type="application/x-javascript" src="report.js"></script>
-  <script type="application/x-javascript" src="pageloader.js"></script>
-  <box align="center">
-    <browser id="contentPageloader" src="about:blank" 
-        type="content" flex="1" align="center" width="1024" height="768"/>
-  </box>
-</window>
deleted file mode 100644
--- a/testing/tools/pageloader/chrome/content/report.js
+++ /dev/null
@@ -1,112 +0,0 @@
-// Constructor
-function Report(pages) {
-  this.pages = pages;
-  this.timeVals = new Array(pages.length);  // matrix of times
-  for (var i = 0; i < this.timeVals.length; ++i) {
-    this.timeVals[i] = new Array;
-  }
-}
-
-// returns an object with the following properties:
-//   min  : min value of array elements
-//   max  : max value of array elements
-//   mean : mean value of array elements
-//   vari : variance computation
-//   stdd : standard deviation, sqrt(vari)
-//   indexOfMax : index of max element (the element that is
-//                removed from the mean computation)
-Report.prototype.getArrayStats = function(ary) {
-  var r = {};
-  r.min = ary[0];
-  r.max = ary[0];
-  r.indexOfMax = 0;
-  var sum = 0;
-  for (var i = 0; i < ary.length; ++i) {
-    if (ary[i] < r.min) {
-      r.min = ary[i];
-    } else if (ary[i] > r.max) {
-      r.max = ary[i];
-      r.indexOfMax = i;
-    }
-    sum = sum + ary[i];
-  }
-
-  // median
-  sorted_ary = ary.concat();
-  sorted_ary.sort();
-  // remove longest run
-  sorted_ary.pop();
-  if (sorted_ary.length%2) {
-    r.median = sorted_ary[(sorted_ary.length-1)/2]; 
-  }else{
-    var n = Math.floor(sorted_ary.length / 2);
-    r.median = (sorted_ary[n] + sorted_ary[n + 1]) / 2;
-  }
-
-  // ignore max value when computing mean and stddev
-  r.mean = (sum - r.max) / (ary.length - 1);
-
-  r.vari = 0;
-  for (var i = 0; i < ary.length; ++i) {
-    if (i == r.indexOfMax)
-      continue;
-    var d = r.mean - ary[i];
-    r.vari = r.vari + d * d;
-  }
-
-  r.vari = r.vari / (ary.length - 1);
-  r.stdd = Math.sqrt(r.vari);
-  return r;
-}
-
-Report.prototype.getReport = function() {
-  var all = new Array();
-  var counter = 0;
-  
-  for (var i = 0; i < this.timeVals.length; ++i) {
-    for (var j = 0; j < this.timeVals[i].length; ++j) {
-      all[counter] = this.timeVals[i][j];
-      ++counter;
-    }
-  }
-
-  // avg and avg median are cumulative for all the pages
-  var avgs = new Array();
-  var medians = new Array();
-  for (var i = 0; i < this.timeVals.length; ++i) {
-     avgs[i] = this.getArrayStats(this.timeVals[i]).mean;
-     medians[i] = this.getArrayStats(this.timeVals[i]).median;
-  }
-  var avg = this.getArrayStats(avgs).mean;
-  var avgmed = this.getArrayStats(medians).mean;
-
-  var r = this.getArrayStats(all);
-
-  var report = '';
-
-  report +=
-    "(tinderbox dropping follows)\n"+
-    "_x_x_mozilla_page_load,"+avgmed+","+r.max+","+r.min+"\n"+
-    "_x_x_mozilla_page_load_details,avgmedian|"+avgmed+"|average|"+avg.toFixed(2)+"|minimum|"+r.min+"|maximum|"+r.max+"|stddev|"+r.stdd.toFixed(2)+":"
-
-  for (var i = 0; i < this.timeVals.length; ++i) {
-    r = this.getArrayStats(this.timeVals[i]);
-    report +=
-      '|'+
-      i+';'+
-      pages[i]+';'+
-      r.median+';'+
-      r.mean+';'+
-      r.min+';'+
-      r.max
-    for (var j = 0; j < this.timeVals[i].length; ++j) {
-      report += 
-        ';'+this.timeVals[i][j]
-    }
-  } 
-  return report;
-}
-
-Report.prototype.recordTime = function(pageIndex, ms) {
-  this.timeVals[pageIndex].push(ms);
-}
deleted file mode 100644
--- a/testing/tools/pageloader/install.rdf
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
-  <Description about="urn:mozilla:install-manifest">
-    <em:id>pageloader@mozilla.org</em:id>
-    <em:version>0.5</em:version>
-    <em:type>2</em:type>
-   
-    <!-- Target Application this extension can install into, 
-         with minimum and maximum supported versions. --> 
-    <em:targetApplication>
-      <Description>
-        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
-        <em:minVersion>1.0+</em:minVersion>
-        <em:maxVersion>4.0</em:maxVersion>
-      </Description>
-    </em:targetApplication>
-   
-    <!-- Front End MetaData -->
-    <em:name>PageLoader</em:name>
-    <em:description>A pageloader extension.</em:description>
-    <em:creator>Robert Helmer</em:creator>
-    <em:homepageURL>http://www.roberthelmer.com/</em:homepageURL>
-  </Description>      
-</RDF>
deleted file mode 100755
--- a/testing/tools/pageloader/test/chrome/content/pageloader.js
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/js
-
-// mock objects
-function alert(str) {
-  print(str);
-}
-function dump(str) {
-  print(str);
-}
-window = new Object();
-document = new Object();
-document.createEvent = function(str) {
-  obj = new Object();
-  obj.initMouseEvent = function() {}
-  return obj;
-}
-document.getElementById = function(str) {
-  obj = new Object(); 
-  if (str == 'contentPageloader') {
-    obj.content = new Object();
-    obj.content.addEventListener = function() {}
-    obj.content.removeEventListener = function() {}
-    obj.content.loadURI = function() {}
-    return obj.content;
-  } else if (str == 'plStartButton') {
-    obj.startButton = new Object();
-    obj.startButton.setAttribute = function(key, value) {}
-    return obj.startButton;
-  }
-}
-evt = new Object();
-evt.type = 'load';
-window.setTimeout = function() {}
-this.content = document.getElementById('content');
-
-// dummy data
-pages = ['http://google.com'];
-
-load(['chrome/content/pageloader.js']);
-load(['chrome/content/report.js']);
-
-plInit(true);
-plInit(false);
-for (cycle = 0; cycle < NUM_CYCLES*2; cycle++) {
-  plLoadHandler(evt);
-}
deleted file mode 100755
--- a/testing/tools/pageloader/test/chrome/content/report.js
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/js
-load(['chrome/content/report.js']);
-
-pages = [
-  'http://www.google.com',
-  'http://www.yahoo.com',
-  'http://www.msn.com',
-];
-
-cycle_time = 5;
-report = new Report(pages);
-
-for (var c=0; c < cycle_time; c++) {
-  for (var p=0; p < pages.length; p++) {
-    report.recordTime(p, c+1);
-  }
-}
-
-print(report.getReport());
--- a/toolkit/components/downloads/nsDownloadManager.h
+++ b/toolkit/components/downloads/nsDownloadManager.h
@@ -39,17 +39,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef downloadmanager___h___
 #define downloadmanager___h___
 
-#if defined(XP_WIN) && (MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN)
+#if defined(XP_WIN)
 #define DOWNLOAD_SCANNER
 #endif
 
 #include "nsIDownload.h"
 #include "nsIDownloadManager.h"
 #include "nsIDownloadProgressListener.h"
 #include "nsILocalFile.h"
 #include "nsIMIMEInfo.h"
--- a/toolkit/components/downloads/nsDownloadScanner.cpp
+++ b/toolkit/components/downloads/nsDownloadScanner.cpp
@@ -32,18 +32,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
-
 #include "nsDownloadScanner.h"
 #include <comcat.h>
 #include <process.h>
 #include "nsDownloadManager.h"
 #include "nsIXULAppInfo.h"
 #include "nsXULAppAPI.h"
 #include "nsIPrefService.h"
 #include "nsNetUtil.h"
@@ -755,10 +753,8 @@ nsDownloadScannerWatchdog::WatchdogThrea
         // don't need to release the scan
         NS_RELEASE(releaser);
       }
     }
   }
   _endthreadex(0);
   return 0;
 }
-
-#endif // MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
--- a/toolkit/components/downloads/nsDownloadScanner.h
+++ b/toolkit/components/downloads/nsDownloadScanner.h
@@ -1,11 +1,10 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: se cin sw=2 ts=2 et : */
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 
 #ifndef nsDownloadScanner_h_
 #define nsDownloadScanner_h_
 
 #ifdef WIN32_LEAN_AND_MEAN
 #undef WIN32_LEAN_AND_MEAN
 #endif
 #define INITGUID
@@ -116,9 +115,8 @@ private:
 
     friend unsigned int __stdcall nsDownloadScanner::ScannerThreadFunction(void *);
   };
   // Used to give access to Scan
   friend class nsDownloadScannerWatchdog;
 };
 #endif
 
-#endif // MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
--- a/toolkit/components/places/Database.cpp
+++ b/toolkit/components/places/Database.cpp
@@ -1763,17 +1763,18 @@ Database::Shutdown()
     new FinalizeStatementCacheProxy<mozIStorageStatement>(
           mAsyncThreadStatements, NS_ISUPPORTS_CAST(nsIObserver*, this)
         );
   DispatchToAsyncThread(event);
 
   nsRefPtr<BlockingConnectionCloseCallback> closeListener =
     new BlockingConnectionCloseCallback();
   (void)mMainConn->AsyncClose(closeListener);
-  closeListener->Spin();
+  // The spinning is temporarily disabled. See bug 728653.
+  //closeListener->Spin();
 
   // Don't set this earlier, otherwise some internal helper used on shutdown
   // may bail out.
   mShuttingDown = true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 //// nsIObserver
--- a/toolkit/components/telemetry/TelemetryHistograms.h
+++ b/toolkit/components/telemetry/TelemetryHistograms.h
@@ -126,16 +126,17 @@ HISTOGRAM(DWRITEFONT_DELAYEDINITFONTLIST
 HISTOGRAM(DWRITEFONT_DELAYEDINITFONTLIST_ITERATE, 1, 30000, 10, EXPONENTIAL, "gfxDWriteFontList::DelayedInitFontList iterate over families (ms)")
 HISTOGRAM(GDI_INITFONTLIST_TOTAL, 1, 30000, 10, EXPONENTIAL, "gfxGDIFontList::InitFontList Total (ms)")
 #elif defined(XP_MACOSX)
 HISTOGRAM(MAC_INITFONTLIST_TOTAL, 1, 30000, 10, EXPONENTIAL, "gfxMacPlatformFontList::InitFontList Total (ms)")
 #endif
 
 HISTOGRAM(SYSTEM_FONT_FALLBACK, 1, 100000, 50, EXPONENTIAL, "System font fallback (us)")
 HISTOGRAM(SYSTEM_FONT_FALLBACK_FIRST, 1, 40000, 20, EXPONENTIAL, "System font fallback, first call (ms)")
+HISTOGRAM(STARTUP_CACHE_AGE_HOURS, 1, 3000, 20, EXPONENTIAL, "Startup cache age (hours)")
 
 /**
  * Word cache - one count for overall lookups, the other for the number of times a word is found
  * Note: range and number of buckets must match
  */
 HISTOGRAM(WORD_CACHE_LOOKUP_LEN, 1, 256, 30, EXPONENTIAL, "Word cache lookup (chars)")
 HISTOGRAM(WORD_CACHE_HIT_LEN, 1, 256, 30, EXPONENTIAL, "Word cache hit (chars)")
 HISTOGRAM(WORD_CACHE_LOOKUP_SCRIPT, 1, 110, 111, LINEAR, "Word cache lookup (script)")
--- a/toolkit/components/viewsource/test/test_428653.xul
+++ b/toolkit/components/viewsource/test/test_428653.xul
@@ -28,25 +28,25 @@
     var doc = browser.contentDocument;
     ok(doc, "got content document");
 
     var opened = false;
     try {
       doc.open("text/html", "replace");
       opened = true;
     } catch (e) {
-      is(e.name, "NS_ERROR_DOM_SECURITY_ERR", "Unxpected exception")
+      is(e.name, "SecurityError", "Unxpected exception")
     }
     is(opened, false, "Shouldn't have opened document");
 
     try {
       doc.wrappedJSObject.open("text/html", "replace");
       opened = true;
     } catch (e) {
-      is(e.name, "NS_ERROR_DOM_SECURITY_ERR",
+      is(e.name, "SecurityError",
          "Unxpected exception via wrappedJSObject")
     }
     is(opened, false, "Shouldn't have opened document via wrappedJSObject");
 
     SimpleTest.finish();
   });
   ]]>
   </script>
--- a/toolkit/content/treeUtils.js
+++ b/toolkit/content/treeUtils.js
@@ -95,17 +95,17 @@ var gTreeUtils = {
     var sortFunction = null;
     if (aComparator) {
       sortFunction = function (a, b) { return aComparator(a[aColumn], b[aColumn]); };
     }
     aDataSet.sort(sortFunction);
     if (!ascending)
       aDataSet.reverse();
 
-    aTree.view.selection.select(-1);
+    aTree.view.selection.clearSelection();
     aTree.view.selection.select(0);
     aTree.treeBoxObject.invalidate();
     aTree.treeBoxObject.ensureRowIsVisible(0);
 
     return ascending;
   }
 };
 
--- a/toolkit/crashreporter/nsExceptionHandler.cpp
+++ b/toolkit/crashreporter/nsExceptionHandler.cpp
@@ -765,17 +765,16 @@ nsresult SetExceptionHandler(nsILocalFil
     posix_spawnattr_destroy(&spawnattr);
     return NS_ERROR_FAILURE;
   }
 #endif
 
 #ifdef XP_WIN32
   MINIDUMP_TYPE minidump_type = MiniDumpNormal;
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   // Try to determine what version of dbghelp.dll we're using.
   // MinidumpWithFullMemoryInfo is only available in 6.1.x or newer.
 
   DWORD version_size = GetFileVersionInfoSizeW(L"dbghelp.dll", NULL);
   if (version_size > 0) {
     std::vector<BYTE> buffer(version_size);
     if (GetFileVersionInfoW(L"dbghelp.dll",
                             0,
@@ -788,17 +787,16 @@ nsresult SetExceptionHandler(nsILocalFil
            minor = LOWORD(file_info->dwFileVersionMS),
            revision = HIWORD(file_info->dwFileVersionLS);
       if (major > 6 || (major == 6 && minor > 1) ||
           (major == 6 && minor == 1 && revision >= 7600)) {
         minidump_type = MiniDumpWithFullMemoryInfo;
       }
     }
   }
-#endif // MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 #endif // XP_WIN32
 
   // now set the exception handler
   gExceptionHandler = new google_breakpad::
     ExceptionHandler(tempPath.get(),
 #ifdef XP_WIN
                      FPEFilter,
 #else
--- a/toolkit/themes/winstripe/global/popup.css
+++ b/toolkit/themes/winstripe/global/popup.css
@@ -165,17 +165,17 @@ panel[type="arrow"] {
   }
 
 %ifdef WINSTRIPE_AERO
   .panel-inner-arrowcontent {
     background-color: rgb(250,250,250);
     background-clip: padding-box;
     margin: 4px;
     border: 2px solid;
-    -moz-border-radius: 2px;
+    border-radius: 2px;
     -moz-border-top-colors: rgba(255,255,255,.6) rgba(0,0,0,.7);
     -moz-border-left-colors: rgba(255,255,255,.6) rgba(0,0,0,.7);
     -moz-border-bottom-colors: rgba(255,255,255,.6) rgba(0,0,0,.7);
     -moz-border-right-colors: rgba(255,255,255,.6) rgba(0,0,0,.7);
     padding: 16px;
   }
 %endif
 
--- a/toolkit/toolkit-makefiles.sh
+++ b/toolkit/toolkit-makefiles.sh
@@ -829,17 +829,16 @@ if [ "$ENABLE_TESTS" ]; then
     layout/inspector/tests/Makefile
     layout/inspector/tests/chrome/Makefile
     layout/mathml/tests/Makefile
     layout/reftests/fonts/Makefile
     layout/reftests/fonts/mplus/Makefile
     layout/style/test/Makefile
     layout/style/test/chrome/Makefile
     layout/tables/test/Makefile
-    layout/tools/pageloader/Makefile
     layout/tools/reftest/Makefile
     layout/xul/base/test/Makefile
     layout/xul/test/Makefile
     modules/libjar/test/Makefile
     modules/libjar/test/chrome/Makefile
     modules/libjar/test/mochitest/Makefile
     modules/libpref/test/Makefile
     netwerk/streamconv/test/Makefile
--- a/uriloader/exthandler/win/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/win/nsOSHelperAppService.cpp
@@ -63,35 +63,29 @@
 // helper methods: forward declarations...
 static nsresult GetExtensionFrom4xRegistryInfo(const nsACString& aMimeType, 
                                                nsString& aFileExtension);
 static nsresult GetExtensionFromWindowsMimeDatabase(const nsACString& aMimeType,
                                                     nsString& aFileExtension);
 
 nsOSHelperAppService::nsOSHelperAppService() : 
   nsExternalHelperAppService()
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   , mAppAssoc(nsnull)
-#endif
 {
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   CoInitialize(NULL);
   CoCreateInstance(CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC,
                    IID_IApplicationAssociationRegistration, (void**)&mAppAssoc);
-#endif
 }
 
 nsOSHelperAppService::~nsOSHelperAppService()
 {
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   if (mAppAssoc)
     mAppAssoc->Release();
   mAppAssoc = nsnull;
   CoUninitialize();
-#endif
 }
 
 // The windows registry provides a mime database key which lists a set of mime types and corresponding "Extension" values. 
 // we can use this to look up our mime type to see if there is a preferred extension for the mime type.
 static nsresult GetExtensionFromWindowsMimeDatabase(const nsACString& aMimeType,
                                                     nsString& aFileExtension)
 {
   nsAutoString mimeDatabaseKey;
@@ -154,32 +148,30 @@ static nsresult GetExtensionFrom4xRegist
 }
 
 nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolScheme, bool * aHandlerExists)
 {
   // look up the protocol scheme in the windows registry....if we find a match then we have a handler for it...
   *aHandlerExists = false;
   if (aProtocolScheme && *aProtocolScheme)
   {
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
     // Vista: use new application association interface
     if (mAppAssoc) {
       PRUnichar * pResult = nsnull;
       NS_ConvertASCIItoUTF16 scheme(aProtocolScheme);
       // We are responsible for freeing returned strings.
       HRESULT hr = mAppAssoc->QueryCurrentDefault(scheme.get(),
                                                   AT_URLPROTOCOL, AL_EFFECTIVE,
                                                   &pResult);
       if (SUCCEEDED(hr)) {
         CoTaskMemFree(pResult);
         *aHandlerExists = true;
       }
       return NS_OK;
     }
-#endif
 
     HKEY hKey;
     LONG err = ::RegOpenKeyExW(HKEY_CLASSES_ROOT,
                                NS_ConvertASCIItoUTF16(aProtocolScheme).get(),
                                0,
                                KEY_QUERY_VALUE,
                                &hKey);
     if (err == ERROR_SUCCESS)
@@ -198,34 +190,32 @@ NS_IMETHODIMP nsOSHelperAppService::GetA
 {
   nsCOMPtr<nsIWindowsRegKey> regKey = 
     do_CreateInstance("@mozilla.org/windows-registry-key;1");
   if (!regKey) 
     return NS_ERROR_NOT_AVAILABLE;
 
   NS_ConvertASCIItoUTF16 buf(aScheme);
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   // Vista: use new application association interface
   if (mAppAssoc) {
     PRUnichar * pResult = nsnull;
     // We are responsible for freeing returned strings.
     HRESULT hr = mAppAssoc->QueryCurrentDefault(buf.get(),
                                                 AT_URLPROTOCOL, AL_EFFECTIVE,
                                                 &pResult);
     if (SUCCEEDED(hr)) {
       nsCOMPtr<nsIFile> app;
       nsAutoString appInfo(pResult);
       CoTaskMemFree(pResult);
       if (NS_SUCCEEDED(GetDefaultAppInfo(appInfo, _retval, getter_AddRefs(app))))
         return NS_OK;
     }
     return NS_ERROR_NOT_AVAILABLE;
   }
-#endif
 
   nsCOMPtr<nsIFile> app;
   GetDefaultAppInfo(buf, _retval, getter_AddRefs(app));
 
   if (!_retval.Equals(buf))
     return NS_OK;
 
   // Fall back to full path
@@ -550,17 +540,16 @@ already_AddRefed<nsMIMEInfoWin> nsOSHelp
 
   // don't append the '.'
   mimeInfo->AppendExtension(NS_ConvertUTF16toUTF8(Substring(fileExtToUse, 1)));
   mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
 
   nsAutoString appInfo;
   bool found;
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   // Retrieve the default application for this extension
   if (mAppAssoc) {
     // Vista: use the new application association COM interfaces
     // for resolving helpers.
     nsString assocType(fileExtToUse);
     PRUnichar * pResult = nsnull;
     HRESULT hr = mAppAssoc->QueryCurrentDefault(assocType.get(),
                                                 AT_FILEEXTENSION, AL_EFFECTIVE,
@@ -570,17 +559,16 @@ already_AddRefed<nsMIMEInfoWin> nsOSHelp
       appInfo.Assign(pResult);
       CoTaskMemFree(pResult);
     } 
     else {
       found = false;
     }
   } 
   else
-#endif
   {
     found = NS_SUCCEEDED(regKey->ReadStringValue(EmptyString(), 
                                                  appInfo));
   }
 
   // Bug 358297 - ignore the default handler, force the user to choose app
   if (appInfo.EqualsLiteral("XPSViewer.Document"))
     found = false;
--- a/uriloader/exthandler/win/nsOSHelperAppService.h
+++ b/uriloader/exthandler/win/nsOSHelperAppService.h
@@ -89,14 +89,12 @@ protected:
   already_AddRefed<nsMIMEInfoWin> GetByExtension(const nsAFlatString& aFileExt, const char *aTypeHint = nsnull);
   nsresult FindOSMimeInfoForType(const char * aMimeContentType, nsIURI * aURI, char ** aFileExtension, nsIMIMEInfo ** aMIMEInfo);
 
   static nsresult GetMIMEInfoFromRegistry(const nsAFlatString& fileType, nsIMIMEInfo *pInfo);
   /// Looks up the type for the extension aExt and compares it to aType
   static bool typeFromExtEquals(const PRUnichar* aExt, const char *aType);
 
 private:
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   IApplicationAssociationRegistration* mAppAssoc;
-#endif
 };
 
 #endif // nsOSHelperAppService_h__
--- a/widget/qt/nsWindow.cpp
+++ b/widget/qt/nsWindow.cpp
@@ -3305,8 +3305,24 @@ nsWindow::UserActivity()
   if (!mIdleService) {
     mIdleService = do_GetService("@mozilla.org/widget/idleservice;1");
   }
 
   if (mIdleService) {
     mIdleService->ResetIdleTimeOut();
   }
 }
+
+PRUint32
+nsWindow::GetGLFrameBufferFormat()
+{
+    if (mLayerManager &&
+        mLayerManager->GetBackendType() == LayerManager::LAYERS_OPENGL) {
+        // On maemo the hardware fb has RGB format.
+#ifdef MOZ_PLATFORM_MAEMO
+        return LOCAL_GL_RGB;
+#else
+        return LOCAL_GL_RGBA;
+#endif
+    }
+    return LOCAL_GL_NONE;
+}
+
--- a/widget/qt/nsWindow.h
+++ b/widget/qt/nsWindow.h
@@ -224,16 +224,17 @@ public:
     void OnDestroy(void);
 
     // called to check and see if a widget's dimensions are sane
     bool AreBoundsSane(void);
 
     NS_IMETHOD         ReparentNativeWidget(nsIWidget* aNewParent);
 
     QWidget* GetViewWidget();
+    virtual PRUint32 GetGLFrameBufferFormat() MOZ_OVERRIDE;
 
 protected:
     nsCOMPtr<nsIWidget> mParent;
     // Is this a toplevel window?
     bool                mIsTopLevel;
     // Has this widget been destroyed yet?
     bool                mIsDestroyed;
 
--- a/widget/windows/AudioSession.cpp
+++ b/widget/windows/AudioSession.cpp
@@ -31,18 +31,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
-
 #include <windows.h>
 #include <audiopolicy.h>
 #include <mmdeviceapi.h>
 
 #include "nsIStringBundle.h"
 #include "nsIUUIDGenerator.h"
 #include "nsIXULAppInfo.h"
 
@@ -473,10 +471,8 @@ AudioSession::OnSimpleVolumeChanged(floa
 STDMETHODIMP
 AudioSession::OnStateChanged(AudioSessionState aState)
 {
   return S_OK; // NOOP
 }
 
 } // namespace widget
 } // namespace mozilla
-
-#endif // MOZ_NTDDI_LONGHORN
--- a/widget/windows/AudioSession.h
+++ b/widget/windows/AudioSession.h
@@ -31,18 +31,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
-
 namespace mozilla {
 namespace widget {
 
 // Start the audio session in the current process
 nsresult StartAudioSession();
 
 // Pass the information necessary to start an audio session in another process
 nsresult GetAudioSessionData(nsID& aID,
@@ -55,10 +53,8 @@ nsresult RecvAudioSessionData(const nsID
                               const nsString& aSessionName,
                               const nsString& aIconPath);
 
 // Stop the audio session in the current process
 nsresult StopAudioSession();
 
 } // namespace widget
 } // namespace mozilla
-
-#endif // MOZ_WINSK_TARGETVER >= MOZ_NTDDI_LONGHORN
--- a/widget/windows/nsAppShell.cpp
+++ b/widget/windows/nsAppShell.cpp
@@ -244,27 +244,23 @@ CollectNewLoadedModules()
 
 NS_IMETHODIMP
 nsAppShell::Run(void)
 {
   LoadedModuleInfo modules[NUM_LOADEDMODULEINFO];
   memset(modules, 0, sizeof(modules));
   sLoadedModules = modules;	
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   // Ignore failure; failing to start the application is not exactly an
   // appropriate response to failing to start an audio session.
   mozilla::widget::StartAudioSession();
-#endif
 
   nsresult rv = nsBaseAppShell::Run();
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   mozilla::widget::StopAudioSession();
-#endif
 
   // Don't forget to null this out!
   sLoadedModules = nsnull;
 
   return rv;
 }
 
 #endif
--- a/widget/windows/nsFilePicker.cpp
+++ b/widget/windows/nsFilePicker.cpp
@@ -1238,25 +1238,21 @@ nsFilePicker::AppendXPFilter(const nsASt
   }
 
   mFilterList.Append(PRUnichar('\0'));
 }
 
 NS_IMETHODIMP
 nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter)
 {
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
     mComFilterList.Append(aTitle, aFilter);
   } else {
     AppendXPFilter(aTitle, aFilter);
   }
-#else
-  AppendXPFilter(aTitle, aFilter);
-#endif
   return NS_OK;
 }
 
 void
 nsFilePicker::RememberLastUsedDirectory()
 {
   nsCOMPtr<nsILocalFile> file(do_CreateInstance("@mozilla.org/file/local;1"));
   if (!file || NS_FAILED(file->InitWithPath(mUnicodeFile))) {
--- a/widget/windows/nsNativeThemeWin.cpp
+++ b/widget/windows/nsNativeThemeWin.cpp
@@ -1215,17 +1215,16 @@ nsNativeThemeWin::DrawWidgetBackground(n
 {
   HANDLE theme = GetTheme(aWidgetType);
   if (!theme)
     return ClassicDrawWidgetBackground(aContext, aFrame, aWidgetType, aRect, aDirtyRect); 
 
   if (!nsUXThemeData::drawThemeBG)
     return NS_ERROR_FAILURE;    
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   // ^^ without the right sdk, assume xp theming and fall through.
   if (nsUXThemeData::CheckForCompositor()) {
     switch (aWidgetType) {
       case NS_THEME_WINDOW_TITLEBAR:
       case NS_THEME_WINDOW_TITLEBAR_MAXIMIZED:
       case NS_THEME_WINDOW_FRAME_LEFT:
       case NS_THEME_WINDOW_FRAME_RIGHT:
       case NS_THEME_WINDOW_FRAME_BOTTOM:
@@ -1244,17 +1243,16 @@ nsNativeThemeWin::DrawWidgetBackground(n
       break;
       case NS_THEME_WIN_GLASS:
       case NS_THEME_WIN_BORDERLESS_GLASS:
         // Nothing to draw, this is the glass background.
         return NS_OK;
       break;
     }
   }
-#endif // MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 
   PRInt32 part, state;
   nsresult rv = GetThemePartAndState(aFrame, aWidgetType, part, state);
   if (NS_FAILED(rv))
     return rv;
 
   gfxFloat p2a = gfxFloat(aContext->AppUnitsPerDevPixel());
   RECT widgetRect;
@@ -1789,21 +1787,19 @@ nsNativeThemeWin::GetWidgetPadding(nsDev
   }
 
   HANDLE theme = GetTheme(aWidgetType);
 
   if (aWidgetType == NS_THEME_WINDOW_BUTTON_BOX ||
       aWidgetType == NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED) {
     aResult->SizeTo(0, 0, 0, 0);
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
     // aero glass doesn't display custom buttons
     if (nsUXThemeData::CheckForCompositor())
       return true;
-#endif
 
     // button padding for standard windows
     if (aWidgetType == NS_THEME_WINDOW_BUTTON_BOX) {
       aResult->top = GetSystemMetrics(SM_CXFRAME);
     }
     return true;
   }
 
--- a/widget/windows/nsUXThemeData.cpp
+++ b/widget/windows/nsUXThemeData.cpp
@@ -47,30 +47,26 @@
 #include "WinUtils.h"
 #include "nsUXThemeConstants.h"
 
 using namespace mozilla;
 using namespace mozilla::widget;
 
 const PRUnichar
 nsUXThemeData::kThemeLibraryName[] = L"uxtheme.dll";
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 const PRUnichar
 nsUXThemeData::kDwmLibraryName[] = L"dwmapi.dll";
-#endif
 
 HANDLE
 nsUXThemeData::sThemes[eUXNumClasses];
 
 HMODULE
 nsUXThemeData::sThemeDLL = NULL;
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 HMODULE
 nsUXThemeData::sDwmDLL = NULL;
-#endif
 
 BOOL
 nsUXThemeData::sFlatMenus = FALSE;
 
 bool nsUXThemeData::sTitlebarInfoPopulatedAero = false;
 bool nsUXThemeData::sTitlebarInfoPopulatedThemed = false;
 SIZE nsUXThemeData::sCommandButtons[4];
 
@@ -84,36 +80,32 @@ nsUXThemeData::GetThemePartSizePtr nsUXT
 nsUXThemeData::GetThemeSysFontPtr nsUXThemeData::getThemeSysFont = NULL;
 nsUXThemeData::GetThemeColorPtr nsUXThemeData::getThemeColor = NULL;
 nsUXThemeData::GetThemeMarginsPtr nsUXThemeData::getThemeMargins = NULL;
 nsUXThemeData::IsAppThemedPtr nsUXThemeData::isAppThemed = NULL;
 nsUXThemeData::GetCurrentThemeNamePtr nsUXThemeData::getCurrentThemeName = NULL;
 nsUXThemeData::GetThemeSysColorPtr nsUXThemeData::getThemeSysColor = NULL;
 nsUXThemeData::IsThemeBackgroundPartiallyTransparentPtr nsUXThemeData::isThemeBackgroundPartiallyTransparent = NULL;
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 nsUXThemeData::DwmExtendFrameIntoClientAreaProc nsUXThemeData::dwmExtendFrameIntoClientAreaPtr = NULL;
 nsUXThemeData::DwmIsCompositionEnabledProc nsUXThemeData::dwmIsCompositionEnabledPtr = NULL;
 nsUXThemeData::DwmSetIconicThumbnailProc nsUXThemeData::dwmSetIconicThumbnailPtr = NULL;
 nsUXThemeData::DwmSetIconicLivePreviewBitmapProc nsUXThemeData::dwmSetIconicLivePreviewBitmapPtr = NULL;
 nsUXThemeData::DwmGetWindowAttributeProc nsUXThemeData::dwmGetWindowAttributePtr = NULL;
 nsUXThemeData::DwmSetWindowAttributeProc nsUXThemeData::dwmSetWindowAttributePtr = NULL;
 nsUXThemeData::DwmInvalidateIconicBitmapsProc nsUXThemeData::dwmInvalidateIconicBitmapsPtr = NULL;
 nsUXThemeData::DwmDefWindowProcProc nsUXThemeData::dwmDwmDefWindowProcPtr = NULL;
-#endif
 
 void
 nsUXThemeData::Teardown() {
   Invalidate();
   if(sThemeDLL)
     FreeLibrary(sThemeDLL);
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   if(sDwmDLL)
     FreeLibrary(sDwmDLL);
-#endif
 }
 
 void
 nsUXThemeData::Initialize()
 {
   ::ZeroMemory(sThemes, sizeof(sThemes));
   NS_ASSERTION(!sThemeDLL, "nsUXThemeData being initialized twice!");
 
@@ -128,29 +120,27 @@ nsUXThemeData::Initialize()
     getThemeSysFont = (GetThemeSysFontPtr)GetProcAddress(sThemeDLL, "GetThemeSysFont");
     getThemeColor = (GetThemeColorPtr)GetProcAddress(sThemeDLL, "GetThemeColor");
     getThemeMargins = (GetThemeMarginsPtr)GetProcAddress(sThemeDLL, "GetThemeMargins");
     isAppThemed = (IsAppThemedPtr)GetProcAddress(sThemeDLL, "IsAppThemed");
     getCurrentThemeName = (GetCurrentThemeNamePtr)GetProcAddress(sThemeDLL, "GetCurrentThemeName");
     getThemeSysColor = (GetThemeSysColorPtr)GetProcAddress(sThemeDLL, "GetThemeSysColor");
     isThemeBackgroundPartiallyTransparent = (IsThemeBackgroundPartiallyTransparentPtr)GetProcAddress(sThemeDLL, "IsThemeBackgroundPartiallyTransparent");
   }
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   if (GetDwmDLL()) {
     dwmExtendFrameIntoClientAreaPtr = (DwmExtendFrameIntoClientAreaProc)::GetProcAddress(sDwmDLL, "DwmExtendFrameIntoClientArea");
     dwmIsCompositionEnabledPtr = (DwmIsCompositionEnabledProc)::GetProcAddress(sDwmDLL, "DwmIsCompositionEnabled");
     dwmSetIconicThumbnailPtr = (DwmSetIconicThumbnailProc)::GetProcAddress(sDwmDLL, "DwmSetIconicThumbnail");
     dwmSetIconicLivePreviewBitmapPtr = (DwmSetIconicLivePreviewBitmapProc)::GetProcAddress(sDwmDLL, "DwmSetIconicLivePreviewBitmap");
     dwmGetWindowAttributePtr = (DwmGetWindowAttributeProc)::GetProcAddress(sDwmDLL, "DwmGetWindowAttribute");
     dwmSetWindowAttributePtr = (DwmSetWindowAttributeProc)::GetProcAddress(sDwmDLL, "DwmSetWindowAttribute");
     dwmInvalidateIconicBitmapsPtr = (DwmInvalidateIconicBitmapsProc)::GetProcAddress(sDwmDLL, "DwmInvalidateIconicBitmaps");
     dwmDwmDefWindowProcPtr = (DwmDefWindowProcProc)::GetProcAddress(sDwmDLL, "DwmDefWindowProc");
     CheckForCompositor(true);
   }
-#endif
 
   Invalidate();
 }
 
 void
 nsUXThemeData::Invalidate() {
   for(int i = 0; i < eUXNumClasses; i++) {
     if(sThemes[i]) {
@@ -177,24 +167,22 @@ nsUXThemeData::GetTheme(nsUXThemeClass c
 
 HMODULE
 nsUXThemeData::GetThemeDLL() {
   if (!sThemeDLL)
     sThemeDLL = ::LoadLibraryW(kThemeLibraryName);
   return sThemeDLL;
 }
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 HMODULE
 nsUXThemeData::GetDwmDLL() {
   if (!sDwmDLL && WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION)
     sDwmDLL = ::LoadLibraryW(kDwmLibraryName);
   return sDwmDLL;
 }
-#endif
 
 const wchar_t *nsUXThemeData::GetClassName(nsUXThemeClass cls) {
   switch(cls) {
     case eUXButton:
       return L"Button";
     case eUXEdit:
       return L"Edit";
     case eUXTooltip:
@@ -262,29 +250,27 @@ nsUXThemeData::InitTitlebarInfo()
 
 // static
 void
 nsUXThemeData::UpdateTitlebarInfo(HWND aWnd)
 {
   if (!aWnd)
     return;
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   if (!sTitlebarInfoPopulatedAero && nsUXThemeData::CheckForCompositor()) {
     RECT captionButtons;
     if (SUCCEEDED(nsUXThemeData::dwmGetWindowAttributePtr(aWnd,
                                                           DWMWA_CAPTION_BUTTON_BOUNDS,
                                                           &captionButtons,
                                                           sizeof(captionButtons)))) {
       sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cx = captionButtons.right - captionButtons.left - 3;
       sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cy = (captionButtons.bottom - captionButtons.top) - 1;
       sTitlebarInfoPopulatedAero = true;
     }
   }
-#endif
 
   if (sTitlebarInfoPopulatedThemed)
     return;
 
   // Query a temporary, visible window with command buttons to get
   // the right metrics. 
   nsAutoString className;
   className.AssignLiteral(kClassNameTemp);
--- a/widget/windows/nsUXThemeData.h
+++ b/widget/windows/nsUXThemeData.h
@@ -40,37 +40,33 @@
 #ifndef __UXThemeData_h__
 #define __UXThemeData_h__
 #include <windows.h>
 #include <uxtheme.h>
 
 #include "nscore.h"
 #include "mozilla/LookAndFeel.h"
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 #include <dwmapi.h>
-#endif
 
 #include "nsWindowDefs.h"
 
 // These window messages are not defined in dwmapi.h
 #ifndef WM_DWMCOMPOSITIONCHANGED
 #define WM_DWMCOMPOSITIONCHANGED        0x031E
 #endif
 
 // Windows 7 additions
 #ifndef WM_DWMSENDICONICTHUMBNAIL
 #define WM_DWMSENDICONICTHUMBNAIL 0x0323
 #define WM_DWMSENDICONICLIVEPREVIEWBITMAP 0x0326
 #endif
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 #define DWMWA_FORCE_ICONIC_REPRESENTATION 7
 #define DWMWA_HAS_ICONIC_BITMAP           10
-#endif
 
 enum nsUXThemeClass {
   eUXButton = 0,
   eUXEdit,
   eUXTooltip,
   eUXRebar,
   eUXMediaRebar,
   eUXCommunicationsRebar,
@@ -110,43 +106,37 @@ enum WindowsThemeColor {
 
 #define CMDBUTTONIDX_MINIMIZE    0
 #define CMDBUTTONIDX_RESTORE     1
 #define CMDBUTTONIDX_CLOSE       2
 #define CMDBUTTONIDX_BUTTONBOX   3
 
 class nsUXThemeData {
   static HMODULE sThemeDLL;
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
    static HMODULE sDwmDLL;
-#endif
   static HANDLE sThemes[eUXNumClasses];
   
   static const wchar_t *GetClassName(nsUXThemeClass);
 
 public:
   static const PRUnichar kThemeLibraryName[];
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
    static const PRUnichar kDwmLibraryName[];
-#endif
   static BOOL sFlatMenus;
   static bool sTitlebarInfoPopulatedAero;
   static bool sTitlebarInfoPopulatedThemed;
   static SIZE sCommandButtons[4];
   static mozilla::LookAndFeel::WindowsTheme sThemeId;
   static bool sIsDefaultWindowsTheme;
 
   static void Initialize();
   static void Teardown();
   static void Invalidate();
   static HANDLE GetTheme(nsUXThemeClass cls);
   static HMODULE GetThemeDLL();
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   static HMODULE GetDwmDLL();
-#endif
 
   // nsWindow calls this to update desktop settings info
   static void InitTitlebarInfo();
   static void UpdateTitlebarInfo(HWND aWnd);
 
   static void UpdateNativeThemeInfo();
   static mozilla::LookAndFeel::WindowsTheme GetNativeThemeId();
   static bool IsDefaultWindowTheme();
@@ -204,17 +194,16 @@ public:
   static GetThemeSysFontPtr getThemeSysFont;
   static GetThemeColorPtr getThemeColor;
   static GetThemeMarginsPtr getThemeMargins;
   static IsAppThemedPtr isAppThemed;
   static GetCurrentThemeNamePtr getCurrentThemeName;
   static GetThemeSysColorPtr getThemeSysColor;
   static IsThemeBackgroundPartiallyTransparentPtr isThemeBackgroundPartiallyTransparent;
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   // dwmapi.dll function typedefs and declarations
   typedef HRESULT (WINAPI*DwmExtendFrameIntoClientAreaProc)(HWND hWnd, const MARGINS *pMarInset);
   typedef HRESULT (WINAPI*DwmIsCompositionEnabledProc)(BOOL *pfEnabled);
   typedef HRESULT (WINAPI*DwmSetIconicThumbnailProc)(HWND hWnd, HBITMAP hBitmap, DWORD dwSITFlags);
   typedef HRESULT (WINAPI*DwmSetIconicLivePreviewBitmapProc)(HWND hWnd, HBITMAP hBitmap, POINT *pptClient, DWORD dwSITFlags);
   typedef HRESULT (WINAPI*DwmGetWindowAttributeProc)(HWND hWnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
   typedef HRESULT (WINAPI*DwmSetWindowAttributeProc)(HWND hWnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
   typedef HRESULT (WINAPI*DwmInvalidateIconicBitmapsProc)(HWND hWnd);
@@ -223,27 +212,24 @@ public:
   static DwmExtendFrameIntoClientAreaProc dwmExtendFrameIntoClientAreaPtr;
   static DwmIsCompositionEnabledProc dwmIsCompositionEnabledPtr;
   static DwmSetIconicThumbnailProc dwmSetIconicThumbnailPtr;
   static DwmSetIconicLivePreviewBitmapProc dwmSetIconicLivePreviewBitmapPtr;
   static DwmGetWindowAttributeProc dwmGetWindowAttributePtr;
   static DwmSetWindowAttributeProc dwmSetWindowAttributePtr;
   static DwmInvalidateIconicBitmapsProc dwmInvalidateIconicBitmapsPtr;
   static DwmDefWindowProcProc dwmDwmDefWindowProcPtr;
-#endif // MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 
   // This method returns the cached compositor state. Most
   // callers should call without the argument. The cache
   // should be modified only when the application receives
   // WM_DWMCOMPOSITIONCHANGED. This rule prevents inconsistent
   // results for two or more calls which check the state during
   // composition transition.
   static bool CheckForCompositor(bool aUpdateCache = false) {
     static BOOL sCachedValue = FALSE;
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
     if(aUpdateCache && dwmIsCompositionEnabledPtr) {
       dwmIsCompositionEnabledPtr(&sCachedValue);
     }
-#endif // MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
     return (sCachedValue != FALSE);
   }
 };
 #endif // __UXThemeData_h__
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -407,19 +407,17 @@ nsWindow::nsWindow() : nsBaseWidget()
   mLastKeyboardLayout   = 0;
   mAssumeWheelIsZoomUntil = 0;
   mBlurSuppressLevel    = 0;
   mLastPaintEndTime     = TimeStamp::Now();
 #ifdef MOZ_XUL
   mTransparentSurface   = nsnull;
   mMemoryDC             = nsnull;
   mTransparencyMode     = eTransparencyOpaque;
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   memset(&mGlassMargins, 0, sizeof mGlassMargins);
-#endif // #if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 #endif
   mBackground           = ::GetSysColor(COLOR_BTNFACE);
   mBrush                = ::CreateSolidBrush(NSRGB_2_COLOREF(mBackground));
   mForeground           = ::GetSysColor(COLOR_WINDOWTEXT);
 
 #if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7
   mTaskbarPreview = nsnull;
   mHasTaskbarIconBeenCreated = false;
@@ -601,22 +599,20 @@ nsWindow::Create(nsIWidget *aParent,
                            nsToolkit::mDllInstance,
                            NULL);
 
   if (!mWnd) {
     NS_WARNING("nsWindow CreateWindowEx failed.");
     return NS_ERROR_FAILURE;
   }
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   if (mIsRTL && nsUXThemeData::dwmSetWindowAttributePtr) {
     DWORD dwAttribute = TRUE;    
     nsUXThemeData::dwmSetWindowAttributePtr(mWnd, DWMWA_NONCLIENT_RTL_LAYOUT, &dwAttribute, sizeof dwAttribute);
   }
-#endif
 
   if (mWindowType != eWindowType_plugin &&
       mWindowType != eWindowType_invisible &&
       UseTrackPointHack()) {
     // Ugly Thinkpad Driver Hack (Bugs 507222 and 594977)
     //
     // We create two zero-sized windows as descendants of the top-level window,
     // like so:
@@ -2505,17 +2501,16 @@ RegionFromArray(const nsTArray<nsIntRect
   for (PRUint32 i = 0; i < aRects.Length(); ++i) {
     region.Or(region, aRects[i]);
   }
   return region;
 }
 
 void nsWindow::UpdateOpaqueRegion(const nsIntRegion &aOpaqueRegion)
 {
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   if (!HasGlass() || GetParent())
     return;
 
   // If there is no opaque region or hidechrome=true, set margins
   // to support a full sheet of glass. Comments in MSDN indicate
   // all values must be set to -1 to get a full sheet of glass.
   MARGINS margins = { -1, -1, -1, -1 };
   if (!aOpaqueRegion.IsEmpty()) {
@@ -2549,22 +2544,20 @@ void nsWindow::UpdateOpaqueRegion(const 
     margins.cyTopHeight = largest.y;
   }
 
   // Only update glass area if there are changes
   if (memcmp(&mGlassMargins, &margins, sizeof mGlassMargins)) {
     mGlassMargins = margins;
     UpdateGlass();
   }
-#endif // #if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 }
 
 void nsWindow::UpdateGlass()
 {
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   MARGINS margins = mGlassMargins;
 
   // DWMNCRP_USEWINDOWSTYLE - The non-client rendering area is
   //                          rendered based on the window style.
   // DWMNCRP_ENABLED        - The non-client area rendering is
   //                          enabled; the window style is ignored.
   DWMNCRENDERINGPOLICY policy = DWMNCRP_USEWINDOWSTYLE;
   switch (mTransparencyMode) {
@@ -2587,17 +2580,16 @@ void nsWindow::UpdateGlass()
           margins.cxLeftWidth, margins.cyTopHeight,
           margins.cxRightWidth, margins.cyBottomHeight));
 
   // Extends the window frame behind the client area
   if(nsUXThemeData::CheckForCompositor()) {
     nsUXThemeData::dwmExtendFrameIntoClientAreaPtr(mWnd, &margins);
     nsUXThemeData::dwmSetWindowAttributePtr(mWnd, DWMWA_NCRENDERING_POLICY, &policy, sizeof policy);
   }
-#endif // #if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 }
 #endif
 
 /**************************************************************
  *
  * SECTION: nsIWidget::HideWindowChrome
  *
  * Show or hide window chrome.
@@ -4545,26 +4537,24 @@ bool nsWindow::ProcessMessage(UINT msg, 
     if (ProcessMessageForPlugin(nativeMsg, aRetValue, callDefaultWndProc)) {
       return mWnd ? !callDefaultWndProc : true;
     }
   }
 
   bool result = false;    // call the default nsWindow proc
   *aRetValue = 0;
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   // Glass hit testing w/custom transparent margins
   LRESULT dwmHitResult;
   if (mCustomNonClient &&
       nsUXThemeData::CheckForCompositor() &&
       nsUXThemeData::dwmDwmDefWindowProcPtr(mWnd, msg, wParam, lParam, &dwmHitResult)) {
     *aRetValue = dwmHitResult;
     return true;
   }
-#endif // MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 
   switch (msg) {
     // WM_QUERYENDSESSION must be handled by all windows.
     // Otherwise Windows thinks the window can just be killed at will.
     case WM_QUERYENDSESSION:
       if (sCanQuit == TRI_UNKNOWN)
       {
         // Ask if it's ok to quit, and store the answer until we
@@ -4746,21 +4736,19 @@ bool nsWindow::ProcessMessage(UINT msg, 
       /*
        * WM_NCACTIVATE paints nc areas. Avoid this and re-route painting
        * through WM_NCPAINT via InvalidateNonClientRegion.
        */
 
       if (!mCustomNonClient)
         break;
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
       // let the dwm handle nc painting on glass
       if(nsUXThemeData::CheckForCompositor())
         break;
-#endif
 
       if (wParam == TRUE) {
         // going active
         *aRetValue = FALSE; // ignored
         result = true;
         UpdateGetWindowInfoCaptionStatus(true);
         // invalidate to trigger a paint
         InvalidateNonClientRegion();
@@ -4782,21 +4770,19 @@ bool nsWindow::ProcessMessage(UINT msg, 
        * Reset the non-client paint region so that it excludes the
        * non-client areas we paint manually. Then call defwndproc
        * to do the actual painting.
        */
 
       if (!mCustomNonClient)
         break;
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
       // let the dwm handle nc painting on glass
       if(nsUXThemeData::CheckForCompositor())
         break;
-#endif
 
       HRGN paintRgn = ExcludeNonClientFromPaintRegion((HRGN)wParam);
       LRESULT res = CallWindowProcW(GetPrevWindowProc(), mWnd,
                                     msg, (WPARAM)paintRgn, lParam);
       if (paintRgn != (HRGN)wParam)
         DeleteObject(paintRgn);
       *aRetValue = res;
       result = true;
@@ -5295,30 +5281,28 @@ bool nsWindow::ProcessMessage(UINT msg, 
       // If OnMouseWheel returns false, OnMouseWheel processed the event internally.
       // 'result' and 'aRetValue' will be set based on what we did with the event, so
       // we should fall through.
       OnMouseWheelInternal(nativeMessage, wParam, lParam, aRetValue);
       // Doesn't need to call next wndproc for internal message.
       return true;
     }
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   case WM_DWMCOMPOSITIONCHANGED:
     // First, update the compositor state to latest one. All other methods
     // should use same state as here for consistency painting.
     nsUXThemeData::CheckForCompositor(true);
 
     UpdateNonClientMargins();
     RemovePropW(mWnd, kManageWindowInfoProperty);
     BroadcastMsg(mWnd, WM_DWMCOMPOSITIONCHANGED);
     DispatchStandardEvent(NS_THEMECHANGED);
     UpdateGlass();
     Invalidate(true, true, true);
     break;
-#endif
 
   case WM_UPDATEUISTATE:
   {
     // If the UI state has changed, fire an event so the UI updates the
     // keyboard cues based on the system setting and how the window was
     // opened. For example, a dialog opened via a keyboard press on a button
     // should enable cues, whereas the same dialog opened via a mouse click of
     // the button should not.
@@ -8140,20 +8124,18 @@ void nsWindow::SetWindowTranslucencyInne
      exStyle |= WS_EX_LAYERED;
    else
      exStyle &= ~WS_EX_LAYERED;
 
   VERIFY_WINDOW_STYLE(style);
   ::SetWindowLongPtrW(hWnd, GWL_STYLE, style);
   ::SetWindowLongPtrW(hWnd, GWL_EXSTYLE, exStyle);
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   if (HasGlass())
     memset(&mGlassMargins, 0, sizeof mGlassMargins);
-#endif // #if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   mTransparencyMode = aMode;
 
   SetupTranslucentWindowMemoryBitmap(aMode);
   UpdateGlass();
 }
 
 void nsWindow::SetupTranslucentWindowMemoryBitmap(nsTransparencyMode aMode)
 {
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -588,20 +588,18 @@ protected:
 #endif
 
   // Transparency
 #ifdef MOZ_XUL
   // Use layered windows to support full 256 level alpha translucency
   nsRefPtr<gfxASurface> mTransparentSurface;
   HDC                   mMemoryDC;
   nsTransparencyMode    mTransparencyMode;
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
   nsIntRegion           mPossiblyTransparentRegion;
   MARGINS               mGlassMargins;
-#endif // #if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 #endif // MOZ_XUL
 
   // Win7 Gesture processing and management
   nsWinGesture          mGesture;
 
 #if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7
   // Weak ref to the nsITaskbarWindowPreview associated with this window
   nsWeakPtr             mTaskbarPreview;
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -252,17 +252,16 @@ static PRInt64 GetVsize()
 
   bool success = GlobalMemoryStatusEx(&s);
   if (!success)
     return -1;
 
   return s.ullTotalVirtual - s.ullAvailVirtual;
 }
 
-#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
 static PRInt64 GetPrivate()
 {
     PROCESS_MEMORY_COUNTERS_EX pmcex;
     pmcex.cb = sizeof(PROCESS_MEMORY_COUNTERS_EX);
 
     if (!GetProcessMemoryInfo(GetCurrentProcess(),
                               (PPROCESS_MEMORY_COUNTERS) &pmcex, sizeof(pmcex)))
     return (PRInt64) -1;
@@ -273,17 +272,16 @@ static PRInt64 GetPrivate()
 NS_MEMORY_REPORTER_IMPLEMENT(Private,
     "private",
     KIND_OTHER,
     UNITS_BYTES,
     GetPrivate,
     "Memory that cannot be shared with other processes, including memory that "
     "is committed and marked MEM_PRIVATE, data that is not mapped, and "
     "executable pages that have been written to.")
-#endif
 
 static PRInt64 GetResident()
 {
   PROCESS_MEMORY_COUNTERS pmc;
   pmc.cb = sizeof(PROCESS_MEMORY_COUNTERS);
 
   if (!GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)))
       return (PRInt64) -1;
@@ -577,17 +575,17 @@ nsMemoryReporterManager::Init()
     REGISTER(Vsize);
 #endif
 
 #if defined(XP_LINUX) || defined(XP_MACOSX) || defined(SOLARIS)
     REGISTER(PageFaultsSoft);
     REGISTER(PageFaultsHard);
 #endif
 
-#if defined(XP_WIN) && MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
+#if defined(XP_WIN)
     REGISTER(Private);
 #endif
 
 #if defined(HAVE_JEMALLOC_STATS)
     REGISTER(HeapCommitted);
     REGISTER(HeapCommittedFragmentation);
     REGISTER(HeapDirty);
 #elif defined(XP_MACOSX) && !defined(MOZ_MEMORY)