Merge from mozilla-central.
authorDavid Anderson <danderson@mozilla.com>
Thu, 21 Jun 2012 14:02:16 -0700
changeset 113220 f2687e92443843d18fd9ccf17cbcef959a379da2
parent 113219 57adfe34193eb24d16b80276dc464eadff3c8535 (current diff)
parent 102523 551d99cd89d4e5d5400674ca53e7f3276aa07140 (diff)
child 113221 572de56569fe31f6900094d95a82e17440cf6a16
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)
milestone16.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/AccEvent.cpp
accessible/src/base/AccEvent.h
accessible/src/generic/ARIAGridAccessible.cpp
accessible/src/generic/ARIAGridAccessible.h
accessible/src/generic/DocAccessible.cpp
accessible/src/html/HTMLTableAccessible.cpp
accessible/src/html/HTMLTableAccessible.h
accessible/src/xpcom/nsAccEvent.cpp
accessible/src/xul/XULTreeGridAccessible.cpp
accessible/src/xul/XULTreeGridAccessible.h
browser/devtools/webconsole/HUDService.jsm
browser/devtools/webconsole/test/Makefile.in
build/macosx/js-icc-flight.mk
config/autoconf.mk.in
configure.in
content/base/public/nsContentUtils.h
content/base/public/nsIXMLHttpRequest.idl
content/base/src/nsContentUtils.cpp
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
content/base/src/nsFrameLoader.cpp
content/base/src/nsImageLoadingContent.cpp
content/base/src/nsInProcessTabChildGlobal.cpp
content/base/src/nsXMLHttpRequest.cpp
content/base/src/nsXMLHttpRequest.h
content/events/src/nsDOMUIEvent.cpp
content/events/src/nsDOMUIEvent.h
content/events/src/nsEventStateManager.cpp
content/events/src/nsEventStateManager.h
content/xul/templates/src/nsXULTemplateQueryProcessorXML.cpp
dom/base/nsDOMClassInfo.cpp
dom/workers/XMLHttpRequest.cpp
editor/libeditor/base/nsEditor.cpp
gfx/gl/GLContext.cpp
gfx/thebes/gfxFT2FontList.cpp
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFont.h
gfx/thebes/gfxScriptItemizer.cpp
gfx/thebes/gfxScriptItemizer.h
gfx/thebes/gfxWindowsPlatform.cpp
intl/unicharutil/util/nsBidiUtils.h
js/src/config/autoconf.mk.in
js/src/configure.in
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/Parser.cpp
js/src/gc/Root.h
js/src/jsapi.cpp
js/src/jsarray.cpp
js/src/jscntxt.h
js/src/jscompartment.cpp
js/src/jscompartment.h
js/src/jsdate.cpp
js/src/jsdbgapi.cpp
js/src/jsexn.cpp
js/src/jsfriendapi.cpp
js/src/jsfun.cpp
js/src/jsfuninlines.h
js/src/jsgc.cpp
js/src/jsinfer.cpp
js/src/jsinterp.cpp
js/src/jsinterpinlines.h
js/src/jsobj.cpp
js/src/jsobj.h
js/src/jsobjinlines.h
js/src/json.cpp
js/src/jsopcode.cpp
js/src/jsproxy.cpp
js/src/jsscope.cpp
js/src/jsscript.cpp
js/src/jsscript.h
js/src/jsstr.cpp
js/src/jstypedarray.cpp
js/src/jswrapper.cpp
js/src/jsxml.cpp
js/src/methodjit/Compiler.cpp
js/src/methodjit/FastOps.cpp
js/src/methodjit/PolyIC.cpp
js/src/methodjit/StubCalls.cpp
js/src/shell/js.cpp
js/src/vm/ArgumentsObject.cpp
js/src/vm/Debugger.cpp
js/src/vm/RegExpObject.cpp
js/src/vm/ScopeObject.cpp
js/src/vm/Stack-inl.h
js/src/vm/Stack.h
js/xpconnect/tests/components/native/xpctest_private.h
layout/base/crashtests/crashtests.list
layout/base/nsCSSRenderingBorders.cpp
layout/generic/nsFrame.cpp
layout/generic/nsHTMLCanvasFrame.cpp
layout/generic/nsSubDocumentFrame.cpp
layout/generic/nsTextFrameUtils.cpp
layout/reftests/svg/reftest.list
mobile/android/base/GeckoApp.java
mobile/android/base/Makefile.in
mobile/android/base/resources/layout/reader_popup.xml
modules/libpref/src/init/all.js
netwerk/protocol/http/SpdySession3.cpp
netwerk/protocol/http/nsHttpConnection.cpp
netwerk/protocol/http/nsHttpHandler.cpp
nsprpub/TAG-INFO
nsprpub/config/prdepend.h
parser/html/nsHtml5TreeOpExecutor.cpp
testing/xpcshell/xpcshell.ini
toolkit/components/telemetry/TelemetryHistograms.h
toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
toolkit/components/url-classifier/nsUrlClassifierDBService.h
toolkit/crashreporter/nsExceptionHandler.cpp
toolkit/mozapps/extensions/XPIProvider.jsm
toolkit/mozapps/extensions/content/extensions.js
uriloader/exthandler/nsExternalHelperAppService.cpp
widget/cocoa/nsChildView.mm
widget/cocoa/nsCocoaWindow.mm
--- a/accessible/public/nsIAccessibleEvent.idl
+++ b/accessible/public/nsIAccessibleEvent.idl
@@ -554,9 +554,14 @@ interface nsIAccessibleVirtualCursorChan
    * Previous start offset of pivot. -1 if none.
    */
   readonly attribute long oldStartOffset;
 
   /**
    * Previous end offset of pivot. -1 if none.
    */
   readonly attribute long oldEndOffset;
+
+  /**
+   * Reason for virtual cursor move.
+   */
+  readonly attribute short reason;
 };
--- a/accessible/public/nsIAccessiblePivot.idl
+++ b/accessible/public/nsIAccessiblePivot.idl
@@ -2,16 +2,17 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 typedef short TextBoundaryType;
+typedef short PivotMoveReason;
 
 interface nsIAccessible;
 interface nsIAccessibleText;
 interface nsIAccessibleTraversalRule;
 interface nsIAccessiblePivotObserver;
 
 /**
  * The pivot interface encapsulates a reference to a single place in an accessible
@@ -22,16 +23,24 @@ interface nsIAccessiblePivotObserver;
 [scriptable, uuid(15ff23de-879e-47ea-b536-6532466108c5)]
 interface nsIAccessiblePivot : nsISupports
 {
   const TextBoundaryType CHAR_BOUNDARY = 0;
   const TextBoundaryType WORD_BOUNDARY = 1;
   const TextBoundaryType LINE_BOUNDARY = 2;
   const TextBoundaryType ATTRIBUTE_RANGE_BOUNDARY = 3;
 
+  const PivotMoveReason REASON_NONE = 0;
+  const PivotMoveReason REASON_NEXT = 1;
+  const PivotMoveReason REASON_PREV = 2;
+  const PivotMoveReason REASON_FIRST = 3;
+  const PivotMoveReason REASON_LAST = 4;
+  const PivotMoveReason REASON_TEXT = 5;
+  const PivotMoveReason REASON_POINT = 6;
+
   /**
    * The accessible the pivot is currently pointed at.
    */
   attribute nsIAccessible position;
 
   /**
    * The root of the subtree in which the pivot traverses.
    */
@@ -118,16 +127,30 @@ interface nsIAccessiblePivot : nsISuppor
    *
    * @param aBoundary [in] type of boundary for previous text range, character,
    *                  word, etc.
    * @return true on success, false if there are is no more text.
    */
   boolean movePreviousByText(in TextBoundaryType aBoundary);
 
   /**
+   * Move pivot to given coordinate in screen pixels.
+   *
+   * @param aRule          [in]  raversal rule to use.
+   * @param aX             [in]  screen's x coordinate
+   * @param aY             [in]  screen's y coordinate
+   * @param aIgnoreNoMatch [in]  don't unset position if no object was found at
+   *                       point.
+   * @return true on success, false if the pivot has not been moved.
+   */
+  boolean moveToPoint(in nsIAccessibleTraversalRule aRule,
+                      in long aX, in long aY,
+                      in boolean aIgnoreNoMatch);
+
+  /**
    * Add an observer for pivot changes.
    *
    * @param aObserver [in] the observer object to be notified of pivot changes.
    */
   void addObserver(in nsIAccessiblePivotObserver aObserver);
 
   /**
    * Remove an observer for pivot changes.
@@ -145,20 +168,22 @@ interface nsIAccessiblePivotObserver : n
 {
   /**
    * Called when the pivot changes.
    *
    * @param aPivot         [in] the pivot that has changed.
    * @param aOldAccessible [in] the old pivot position before the change, or null.
    * @param aOldStart      [in] the old start offset, or -1.
    * @param aOldEnd        [in] the old end offset, or -1.
+   * @param aReason        [in] the reason for the pivot change.
    */
   void onPivotChanged(in nsIAccessiblePivot aPivot,
                       in nsIAccessible aOldAccessible,
-                      in long aOldStart, in long aOldEnd);
+                      in long aOldStart, in long aOldEnd,
+                      in PivotMoveReason aReason);
 };
 
 [scriptable, uuid(307d98b6-dba9-49cf-ba17-ef8b053044eb)]
 interface nsIAccessibleTraversalRule : nsISupports
 {
   /* Ignore this accessible object */
   const unsigned short FILTER_IGNORE = 0x0;
   /* Accept this accessible object */
--- a/accessible/src/base/AccEvent.cpp
+++ b/accessible/src/base/AccEvent.cpp
@@ -363,19 +363,21 @@ AccTableChangeEvent::CreateXPCOMObject()
 
 ////////////////////////////////////////////////////////////////////////////////
 // AccVCChangeEvent
 ////////////////////////////////////////////////////////////////////////////////
 
 AccVCChangeEvent::
   AccVCChangeEvent(Accessible* aAccessible,
                    nsIAccessible* aOldAccessible,
-                   PRInt32 aOldStart, PRInt32 aOldEnd) :
+                   PRInt32 aOldStart, PRInt32 aOldEnd,
+                   PRInt16 aReason) :
     AccEvent(::nsIAccessibleEvent::EVENT_VIRTUALCURSOR_CHANGED, aAccessible),
-    mOldAccessible(aOldAccessible), mOldStart(aOldStart), mOldEnd(aOldEnd)
+    mOldAccessible(aOldAccessible), mOldStart(aOldStart), mOldEnd(aOldEnd),
+    mReason(aReason)
 {
 }
 
 already_AddRefed<nsAccEvent>
 AccVCChangeEvent::CreateXPCOMObject()
 {
   nsAccEvent* event = new nsAccVirtualCursorChangeEvent(this);
   NS_ADDREF(event);
--- a/accessible/src/base/AccEvent.h
+++ b/accessible/src/base/AccEvent.h
@@ -368,38 +368,41 @@ private:
 /**
  * Accessible virtual cursor change event.
  */
 class AccVCChangeEvent : public AccEvent
 {
 public:
   AccVCChangeEvent(Accessible* aAccessible,
                    nsIAccessible* aOldAccessible,
-                   PRInt32 aOldStart, PRInt32 aOldEnd);
+                   PRInt32 aOldStart, PRInt32 aOldEnd,
+                   PRInt16 aReason);
 
   virtual ~AccVCChangeEvent() { }
 
   // AccEvent
   virtual already_AddRefed<nsAccEvent> CreateXPCOMObject();
 
   static const EventGroup kEventGroup = eVirtualCursorChangeEvent;
   virtual unsigned int GetEventGroups() const
   {
     return AccEvent::GetEventGroups() | (1U << eVirtualCursorChangeEvent);
   }
 
   // AccTableChangeEvent
   nsIAccessible* OldAccessible() const { return mOldAccessible; }
   PRInt32 OldStartOffset() const { return mOldStart; }
   PRInt32 OldEndOffset() const { return mOldEnd; }
+  PRInt32 Reason() const { return mReason; }
 
 private:
   nsRefPtr<nsIAccessible> mOldAccessible;
   PRInt32 mOldStart;
   PRInt32 mOldEnd;
+  PRInt16 mReason;
 };
 
 /**
  * Downcast the generic accessible event object to derived type.
  */
 class downcast_accEvent
 {
 public:
--- a/accessible/src/base/nsAccessiblePivot.cpp
+++ b/accessible/src/base/nsAccessiblePivot.cpp
@@ -113,17 +113,18 @@ nsAccessiblePivot::SetPosition(nsIAccess
     if (!secondPosition || !IsRootDescendant(secondPosition))
       return NS_ERROR_INVALID_ARG;
   }
 
   // Swap old position with new position, saves us an AddRef/Release.
   mPosition.swap(secondPosition);
   PRInt32 oldStart = mStartOffset, oldEnd = mEndOffset;
   mStartOffset = mEndOffset = -1;
-  NotifyOfPivotChange(secondPosition, oldStart, oldEnd);
+  NotifyOfPivotChange(secondPosition, oldStart, oldEnd,
+                      nsIAccessiblePivot::REASON_NONE);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAccessiblePivot::GetStartOffset(PRInt32* aStartOffset)
 {
   NS_ENSURE_ARG_POINTER(aStartOffset);
@@ -171,17 +172,18 @@ nsAccessiblePivot::SetTextRange(nsIAcces
 
   PRInt32 oldStart = mStartOffset, oldEnd = mEndOffset;
   mStartOffset = aStartOffset;
   mEndOffset = aEndOffset;
 
   nsRefPtr<Accessible> oldPosition = mPosition.forget();
   mPosition = newPosition;
 
-  NotifyOfPivotChange(oldPosition, oldStart, oldEnd);
+  NotifyOfPivotChange(oldPosition, oldStart, oldEnd,
+                      nsIAccessiblePivot::REASON_TEXT);
 
   return NS_OK;
 }
 
 // Traversal functions
 
 NS_IMETHODIMP
 nsAccessiblePivot::MoveNext(nsIAccessibleTraversalRule* aRule,
@@ -199,17 +201,17 @@ nsAccessiblePivot::MoveNext(nsIAccessibl
     return NS_ERROR_NOT_IN_TREE;
 
   nsresult rv = NS_OK;
   Accessible* accessible =
     SearchForward(anchor, aRule, (aArgc > 1) ? aIncludeStart : false, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (accessible)
-    *aResult = MovePivotInternal(accessible);
+    *aResult = MovePivotInternal(accessible, nsIAccessiblePivot::REASON_NEXT);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAccessiblePivot::MovePrevious(nsIAccessibleTraversalRule* aRule,
                                 nsIAccessible* aAnchor,
                                 bool aIncludeStart,
@@ -226,17 +228,17 @@ nsAccessiblePivot::MovePrevious(nsIAcces
     return NS_ERROR_NOT_IN_TREE;
 
   nsresult rv = NS_OK;
   Accessible* accessible =
     SearchBackward(anchor, aRule, (aArgc > 1) ? aIncludeStart : false, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (accessible)
-    *aResult = MovePivotInternal(accessible);
+    *aResult = MovePivotInternal(accessible, nsIAccessiblePivot::REASON_PREV);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAccessiblePivot::MoveFirst(nsIAccessibleTraversalRule* aRule, bool* aResult)
 {
   NS_ENSURE_ARG(aResult);
@@ -245,17 +247,17 @@ nsAccessiblePivot::MoveFirst(nsIAccessib
   if (mRoot && mRoot->IsDefunct())
     return NS_ERROR_NOT_IN_TREE;
 
   nsresult rv = NS_OK;
   Accessible* accessible = SearchForward(mRoot, aRule, true, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (accessible)
-    *aResult = MovePivotInternal(accessible);
+    *aResult = MovePivotInternal(accessible, nsIAccessiblePivot::REASON_FIRST);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAccessiblePivot::MoveLast(nsIAccessibleTraversalRule* aRule, bool* aResult)
 {
   NS_ENSURE_ARG(aResult);
@@ -273,17 +275,17 @@ nsAccessiblePivot::MoveLast(nsIAccessibl
   while (lastAccessible->HasChildren())
     lastAccessible = lastAccessible->LastChild();
 
   // Search backwards from last accessible and find the last occurrence in the doc
   accessible = SearchBackward(lastAccessible, aRule, true, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (accessible)
-    *aResult = MovePivotInternal(accessible);
+    *aResult = MovePivotInternal(accessible, nsAccessiblePivot::REASON_LAST);
 
   return NS_OK;
 }
 
 // TODO: Implement
 NS_IMETHODIMP
 nsAccessiblePivot::MoveNextByText(TextBoundaryType aBoundary, bool* aResult)
 {
@@ -300,16 +302,61 @@ nsAccessiblePivot::MovePreviousByText(Te
 {
   NS_ENSURE_ARG(aResult);
 
   *aResult = false;
 
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
+NS_IMETHODIMP
+nsAccessiblePivot::MoveToPoint(nsIAccessibleTraversalRule* aRule,
+                               PRInt32 aX, PRInt32 aY, bool aIgnoreNoMatch,
+                               bool* aResult)
+{
+  NS_ENSURE_ARG_POINTER(aResult);
+  NS_ENSURE_ARG_POINTER(aRule);
+
+  *aResult = false;
+
+  if (mRoot && mRoot->IsDefunct())
+    return NS_ERROR_NOT_IN_TREE;
+
+  RuleCache cache(aRule);
+  Accessible* match = nsnull;
+  Accessible* child = mRoot->ChildAtPoint(aX, aY, Accessible::eDeepestChild);
+  while (child && mRoot != child) {
+    PRUint16 filtered = nsIAccessibleTraversalRule::FILTER_IGNORE;
+    nsresult rv = cache.ApplyFilter(child, &filtered);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    // Ignore any matching nodes that were below this one
+    if (filtered & nsIAccessibleTraversalRule::FILTER_IGNORE_SUBTREE)
+      match = nsnull;
+
+    // Match if no node below this is a match
+    if ((filtered & nsIAccessibleTraversalRule::FILTER_MATCH) && !match) {
+      PRInt32 childX, childY, childWidth, childHeight;
+      child->GetBounds(&childX, &childY, &childWidth, &childHeight);
+      // Double-check child's bounds since the deepest child may have been out
+      // of bounds. This assures we don't return a false positive.
+      if (aX >= childX && aX < childX + childWidth &&
+          aY >= childY && aY < childY + childHeight)
+        match = child;
+    }
+
+    child = child->Parent();
+  }
+
+  if (match || !aIgnoreNoMatch)
+    *aResult = MovePivotInternal(match, nsIAccessiblePivot::REASON_POINT);
+
+  return NS_OK;
+}
+
 // Observer functions
 
 NS_IMETHODIMP
 nsAccessiblePivot::AddObserver(nsIAccessiblePivotObserver* aObserver)
 {
   NS_ENSURE_ARG(aObserver);
 
   mObservers.AppendElement(aObserver);
@@ -339,24 +386,25 @@ nsAccessiblePivot::IsRootDescendant(Acce
     if (accessible == mRoot)
       return true;
   } while ((accessible = accessible->Parent()));
 
   return false;
 }
 
 bool
-nsAccessiblePivot::MovePivotInternal(Accessible* aPosition)
+nsAccessiblePivot::MovePivotInternal(Accessible* aPosition,
+                                     PivotMoveReason aReason)
 {
   nsRefPtr<Accessible> oldPosition = mPosition.forget();
   mPosition = aPosition;
   PRInt32 oldStart = mStartOffset, oldEnd = mEndOffset;
   mStartOffset = mEndOffset = -1;
 
-  return NotifyOfPivotChange(oldPosition, oldStart, oldEnd);
+  return NotifyOfPivotChange(oldPosition, oldStart, oldEnd, aReason);
 }
 
 Accessible*
 nsAccessiblePivot::SearchBackward(Accessible* aAccessible,
                                   nsIAccessibleTraversalRule* aRule,
                                   bool aSearchCurrent,
                                   nsresult* aResult)
 {
@@ -469,26 +517,27 @@ nsAccessiblePivot::SearchForward(Accessi
       return accessible;
   }
 
   return nsnull;
 }
 
 bool
 nsAccessiblePivot::NotifyOfPivotChange(Accessible* aOldPosition,
-                                       PRInt32 aOldStart, PRInt32 aOldEnd)
+                                       PRInt32 aOldStart, PRInt32 aOldEnd,
+                                       PRInt16 aReason)
 {
   if (aOldPosition == mPosition &&
       aOldStart == mStartOffset && aOldEnd == mEndOffset)
     return false;
 
   nsTObserverArray<nsCOMPtr<nsIAccessiblePivotObserver> >::ForwardIterator iter(mObservers);
   while (iter.HasMore()) {
     nsIAccessiblePivotObserver* obs = iter.GetNext();
-    obs->OnPivotChanged(this, aOldPosition, aOldStart, aOldEnd);
+    obs->OnPivotChanged(this, aOldPosition, aOldStart, aOldEnd, aReason);
   }
 
   return true;
 }
 
 nsresult
 RuleCache::ApplyFilter(Accessible* aAccessible, PRUint16* aResult)
 {
--- a/accessible/src/base/nsAccessiblePivot.h
+++ b/accessible/src/base/nsAccessiblePivot.h
@@ -43,17 +43,18 @@ private:
   nsAccessiblePivot(const nsAccessiblePivot&) MOZ_DELETE;
   void operator = (const nsAccessiblePivot&) MOZ_DELETE;
 
   /*
    * Notify all observers on a pivot change. Return true if it has changed and
    * observers have been notified.
    */
   bool NotifyOfPivotChange(Accessible* aOldAccessible,
-                           PRInt32 aOldStart, PRInt32 aOldEnd);
+                           PRInt32 aOldStart, PRInt32 aOldEnd,
+                           PivotMoveReason aReason);
 
   /*
    * Check to see that the given accessible is in the pivot's subtree.
    */
   bool IsRootDescendant(Accessible* aAccessible);
 
 
   /*
@@ -70,17 +71,17 @@ private:
   Accessible* SearchBackward(Accessible* aAccessible,
                              nsIAccessibleTraversalRule* aRule,
                              bool aSearchCurrent,
                              nsresult* aResult);
 
   /*
    * Update the pivot, and notify observers. Return true if it moved.
    */
-  bool MovePivotInternal(Accessible* aPosition);
+  bool MovePivotInternal(Accessible* aPosition, PivotMoveReason aReason);
 
   /*
    * The root accessible.
    */
   nsRefPtr<Accessible> mRoot;
 
   /*
    * The current pivot position.
--- a/accessible/src/generic/ARIAGridAccessible.cpp
+++ b/accessible/src/generic/ARIAGridAccessible.cpp
@@ -214,70 +214,61 @@ ARIAGridAccessible::IsCellSelected(PRUin
     Accessible* cell = GetCellInRowAt(row, aColIdx);
     if (!cell || !nsAccUtils::IsARIASelected(cell))
       return false;
   }
 
   return true;
 }
 
-NS_IMETHODIMP
-ARIAGridAccessible::GetSelectedCellCount(PRUint32* aCount)
+PRUint32
+ARIAGridAccessible::SelectedCellCount()
 {
-  NS_ENSURE_ARG_POINTER(aCount);
-  *aCount = 0;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  PRInt32 colCount = 0;
-  GetColumnCount(&colCount);
+  PRUint32 count = 0, colCount = ColCount();
 
   AccIterator rowIter(this, filters::GetRow);
+  Accessible* row = nsnull;
 
-  Accessible* row = nsnull;
   while ((row = rowIter.Next())) {
     if (nsAccUtils::IsARIASelected(row)) {
-      (*aCount) += colCount;
+      count += colCount;
       continue;
     }
 
     AccIterator cellIter(row, filters::GetCell);
     Accessible* cell = nsnull;
 
     while ((cell = cellIter.Next())) {
       if (nsAccUtils::IsARIASelected(cell))
-        (*aCount)++;
+        count++;
     }
   }
 
-  return NS_OK;
+  return count;
 }
 
-NS_IMETHODIMP
-ARIAGridAccessible::GetSelectedColumnCount(PRUint32* aCount)
+PRUint32
+ARIAGridAccessible::SelectedColCount()
 {
-  return GetSelectedColumnsArray(aCount);
+  PRUint32 colCount = 0;
+  GetSelectedColumnsArray(&colCount);
+  return colCount;
 }
 
-NS_IMETHODIMP
-ARIAGridAccessible::GetSelectedRowCount(PRUint32* aCount)
+PRUint32
+ARIAGridAccessible::SelectedRowCount()
 {
-  NS_ENSURE_ARG_POINTER(aCount);
-  *aCount = 0;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
+  PRUint32 count = 0;
 
   AccIterator rowIter(this, filters::GetRow);
+  Accessible* row = nsnull;
 
-  Accessible* row = nsnull;
   while ((row = rowIter.Next())) {
     if (nsAccUtils::IsARIASelected(row)) {
-      (*aCount)++;
+      count++;
       continue;
     }
 
     AccIterator cellIter(row, filters::GetCell);
     Accessible* cell = cellIter.Next();
     if (!cell)
       continue;
 
@@ -285,20 +276,20 @@ ARIAGridAccessible::GetSelectedRowCount(
     do {
       if (!nsAccUtils::IsARIASelected(cell)) {
         isRowSelected = false;
         break;
       }
     } while ((cell = cellIter.Next()));
 
     if (isRowSelected)
-      (*aCount)++;
+      count++;
   }
 
-  return NS_OK;
+  return count;
 }
 
 NS_IMETHODIMP
 ARIAGridAccessible::GetSelectedCells(nsIArray** aCells)
 {
   NS_ENSURE_ARG_POINTER(aCells);
   *aCells = nsnull;
 
--- a/accessible/src/generic/ARIAGridAccessible.h
+++ b/accessible/src/generic/ARIAGridAccessible.h
@@ -40,16 +40,19 @@ public:
 
   // TableAccessible
   virtual PRUint32 ColCount();
   virtual PRUint32 RowCount();
   virtual Accessible* CellAt(PRUint32 aRowIndex, PRUint32 aColumnIndex);
   virtual bool IsColSelected(PRUint32 aColIdx);
   virtual bool IsRowSelected(PRUint32 aRowIdx);
   virtual bool IsCellSelected(PRUint32 aRowIdx, PRUint32 aColIdx);
+  virtual PRUint32 SelectedCellCount();
+  virtual PRUint32 SelectedColCount();
+  virtual PRUint32 SelectedRowCount();
   virtual void SelectCol(PRUint32 aColIdx);
   virtual void SelectRow(PRUint32 aRowIdx);
   virtual void UnselectCol(PRUint32 aColIdx);
   virtual void UnselectRow(PRUint32 aRowIdx);
 
 protected:
   /**
    * Return true if the given row index is valid.
--- a/accessible/src/generic/DocAccessible.cpp
+++ b/accessible/src/generic/DocAccessible.cpp
@@ -919,20 +919,22 @@ DocAccessible::Observe(nsISupports* aSub
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIAccessiblePivotObserver
 
 NS_IMETHODIMP
 DocAccessible::OnPivotChanged(nsIAccessiblePivot* aPivot,
                               nsIAccessible* aOldAccessible,
-                              PRInt32 aOldStart, PRInt32 aOldEnd)
+                              PRInt32 aOldStart, PRInt32 aOldEnd,
+                              PivotMoveReason aReason)
 {
   nsRefPtr<AccEvent> event = new AccVCChangeEvent(this, aOldAccessible,
-                                                  aOldStart, aOldEnd);
+                                                  aOldStart, aOldEnd,
+                                                  aReason);
   nsEventShell::FireEvent(event);
 
   return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIDocumentObserver
 
--- a/accessible/src/html/HTMLTableAccessible.cpp
+++ b/accessible/src/html/HTMLTableAccessible.cpp
@@ -549,103 +549,70 @@ HTMLTableAccessible::RowCount()
   if (!tableLayout)
     return 0;
 
   PRInt32 rowCount = 0, colCount = 0;
   tableLayout->GetTableSize(rowCount, colCount);
   return rowCount;
 }
 
-NS_IMETHODIMP
-HTMLTableAccessible::GetSelectedCellCount(PRUint32* aCount)
+PRUint32
+HTMLTableAccessible::SelectedCellCount()
 {
-  NS_ENSURE_ARG_POINTER(aCount);
-  *aCount = 0;
+  nsITableLayout *tableLayout = GetTableLayout();
+  if (!tableLayout)
+    return 0;
 
-  PRInt32 rowCount = 0;
-  nsresult rv = GetRowCount(&rowCount);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  PRInt32 columnCount = 0;
-  rv = GetColumnCount(&columnCount);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsITableLayout *tableLayout = GetTableLayout();
-  NS_ENSURE_STATE(tableLayout);
+  PRUint32 count = 0, rowCount = RowCount(), colCount = ColCount();
 
   nsCOMPtr<nsIDOMElement> domElement;
   PRInt32 startRowIndex = 0, startColIndex = 0,
     rowSpan, colSpan, actualRowSpan, actualColSpan;
   bool isSelected = false;
 
-  PRInt32 rowIndex;
-  for (rowIndex = 0; rowIndex < rowCount; rowIndex++) {
-    PRInt32 columnIndex;
-    for (columnIndex = 0; columnIndex < columnCount; columnIndex++) {
-      rv = tableLayout->GetCellDataAt(rowIndex, columnIndex,
-                                      *getter_AddRefs(domElement),
-                                      startRowIndex, startColIndex,
-                                      rowSpan, colSpan,
-                                      actualRowSpan, actualColSpan,
-                                      isSelected);
+  for (PRUint32 rowIdx = 0; rowIdx < rowCount; rowIdx++) {
+    for (PRUint32 colIdx = 0; colIdx < colCount; colIdx++) {
+      nsresult rv = tableLayout->GetCellDataAt(rowIdx, colIdx,
+                                               *getter_AddRefs(domElement),
+                                               startRowIndex, startColIndex,
+                                               rowSpan, colSpan,
+                                               actualRowSpan, actualColSpan,
+                                               isSelected);
 
-      if (NS_SUCCEEDED(rv) && startRowIndex == rowIndex &&
-          startColIndex == columnIndex && isSelected) {
-        (*aCount)++;
-      }
+      if (NS_SUCCEEDED(rv) && startRowIndex == rowIdx &&
+          startColIndex == colIdx && isSelected)
+        count++;
     }
   }
 
-  return NS_OK;
+  return count;
 }
 
-NS_IMETHODIMP
-HTMLTableAccessible::GetSelectedColumnCount(PRUint32* aCount)
+PRUint32
+HTMLTableAccessible::SelectedColCount()
 {
-  NS_ENSURE_ARG_POINTER(aCount);
-  *aCount = 0;
-
-  PRInt32 count = 0;
-  nsresult rv = GetColumnCount(&count);
-  NS_ENSURE_SUCCESS(rv, rv);
+  PRUint32 count = 0, colCount = ColCount();
 
-  PRInt32 index;
-  for (index = 0; index < count; index++) {
-    bool state = false;
-    rv = IsColumnSelected(index, &state);
-    NS_ENSURE_SUCCESS(rv, rv);
+  for (PRUint32 colIdx = 0; colIdx < colCount; colIdx++)
+    if (IsColSelected(colIdx))
+      count++;
 
-    if (state)
-      (*aCount)++;
-  }
-
-  return NS_OK;
+  return count;
 }
 
-NS_IMETHODIMP
-HTMLTableAccessible::GetSelectedRowCount(PRUint32* aCount)
+PRUint32
+HTMLTableAccessible::SelectedRowCount()
 {
-  NS_ENSURE_ARG_POINTER(aCount);
-  *aCount = 0;
-
-  PRInt32 count = 0;
-  nsresult rv = GetRowCount(&count);
-  NS_ENSURE_SUCCESS(rv, rv);
+  PRUint32 count = 0, rowCount = RowCount();
 
-  PRInt32 index;
-  for (index = 0; index < count; index++) {
-    bool state = false;
-    rv = IsRowSelected(index, &state);
-    NS_ENSURE_SUCCESS(rv, rv);
+  for (PRUint32 rowIdx = 0; rowIdx < rowCount; rowIdx++)
+    if (IsRowSelected(rowIdx))
+      count++;
 
-    if (state)
-      (*aCount)++;
-  }
-
-  return NS_OK;
+  return count;
 }
 
 NS_IMETHODIMP
 HTMLTableAccessible::GetSelectedCells(nsIArray** aCells)
 {
   NS_ENSURE_ARG_POINTER(aCells);
   *aCells = nsnull;
 
--- a/accessible/src/html/HTMLTableAccessible.h
+++ b/accessible/src/html/HTMLTableAccessible.h
@@ -104,16 +104,19 @@ public:
   virtual PRUint32 RowCount();
   virtual Accessible* CellAt(PRUint32 aRowIndex, PRUint32 aColumnIndex);
   virtual PRInt32 CellIndexAt(PRUint32 aRowIdx, PRUint32 aColIdx);
   virtual PRUint32 ColExtentAt(PRUint32 aRowIdx, PRUint32 aColIdx);
   virtual PRUint32 RowExtentAt(PRUint32 aRowIdx, PRUint32 aColIdx);
   virtual bool IsColSelected(PRUint32 aColIdx);
   virtual bool IsRowSelected(PRUint32 aRowIdx);
   virtual bool IsCellSelected(PRUint32 aRowIdx, PRUint32 aColIdx);
+  virtual PRUint32 SelectedCellCount();
+  virtual PRUint32 SelectedColCount();
+  virtual PRUint32 SelectedRowCount();
   virtual void SelectCol(PRUint32 aColIdx);
   virtual void SelectRow(PRUint32 aRowIdx);
   virtual void UnselectCol(PRUint32 aColIdx);
   virtual void UnselectRow(PRUint32 aRowIdx);
   virtual bool IsProbablyLayoutTable();
 
   // nsAccessNode
   virtual void Shutdown();
--- a/accessible/src/jsat/AccessFu.jsm
+++ b/accessible/src/jsat/AccessFu.jsm
@@ -8,16 +8,17 @@ const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 const Cr = Components.results;
 
 var EXPORTED_SYMBOLS = ['AccessFu'];
 
 Cu.import('resource://gre/modules/Services.jsm');
 
+Cu.import('resource://gre/modules/accessibility/Utils.jsm');
 Cu.import('resource://gre/modules/accessibility/Presenters.jsm');
 Cu.import('resource://gre/modules/accessibility/VirtualCursorController.jsm');
 
 const ACCESSFU_DISABLE = 0;
 const ACCESSFU_ENABLE = 1;
 const ACCESSFU_AUTO = 2;
 
 var AccessFu = {
@@ -29,45 +30,45 @@ var AccessFu = {
    * @param {boolean} aForceEnabled Skip platform accessibility check and enable
    *  AccessFu.
    */
   attach: function attach(aWindow) {
     if (this.chromeWin)
       // XXX: only supports attaching to one window now.
       throw new Error('Only one window could be attached to AccessFu');
 
-    dump('[AccessFu] attach\n');
+    Logger.info('attach');
     this.chromeWin = aWindow;
     this.presenters = [];
 
     this.prefsBranch = Cc['@mozilla.org/preferences-service;1']
       .getService(Ci.nsIPrefService).getBranch('accessibility.accessfu.');
     this.prefsBranch.addObserver('activate', this, false);
     this.prefsBranch.addObserver('explorebytouch', this, false);
 
-    if (Services.appinfo.OS == 'Android')
+    if (Utils.OS == 'Android')
       Services.obs.addObserver(this, 'Accessibility:Settings', false);
 
     this._processPreferences();
   },
 
   /**
    * Start AccessFu mode, this primarily means controlling the virtual cursor
    * with arrow keys.
    */
   _enable: function _enable() {
     if (this._enabled)
       return;
     this._enabled = true;
 
-    dump('[AccessFu] enable\n');
+    Logger.info('enable');
     this.addPresenter(new VisualPresenter());
 
     // Implicitly add the Android presenter on Android.
-    if (Services.appinfo.OS == 'Android')
+    if (Utils.OS == 'Android')
       this.addPresenter(new AndroidPresenter());
 
     VirtualCursorController.attach(this.chromeWin);
 
     Services.obs.addObserver(this, 'accessible-event', false);
     this.chromeWin.addEventListener('DOMActivate', this, true);
     this.chromeWin.addEventListener('resize', this, true);
     this.chromeWin.addEventListener('scroll', this, true);
@@ -78,17 +79,17 @@ var AccessFu = {
   /**
    * Disable AccessFu and return to default interaction mode.
    */
   _disable: function _disable() {
     if (!this._enabled)
       return;
     this._enabled = false;
 
-    dump('[AccessFu] disable\n');
+    Logger.info('disable');
 
     this.presenters.forEach(function(p) { p.detach(); });
     this.presenters = [];
 
     VirtualCursorController.detach();
 
     Services.obs.removeObserver(this, 'accessible-event');
     this.chromeWin.removeEventListener('DOMActivate', this, true);
@@ -108,33 +109,32 @@ var AccessFu = {
 
     let ebtPref = ACCESSFU_DISABLE;
     try {
       ebtPref = (aTouchEnabled == undefined) ?
         this.prefsBranch.getIntPref('explorebytouch') : aTouchEnabled;
     } catch (x) {
     }
 
-    if (Services.appinfo.OS == 'Android') {
+    if (Utils.OS == 'Android') {
       if (accessPref == ACCESSFU_AUTO) {
         Cc['@mozilla.org/android/bridge;1'].
           getService(Ci.nsIAndroidBridge).handleGeckoMessage(
             JSON.stringify({ gecko: { type: 'Accessibility:Ready' } }));
         return;
       }
     }
 
     if (accessPref == ACCESSFU_ENABLE)
       this._enable();
     else
       this._disable();
 
     VirtualCursorController.exploreByTouch = ebtPref == ACCESSFU_ENABLE;
-    dump('[AccessFu] Explore by touch: ' +
-          VirtualCursorController.exploreByTouch + '\n');
+    Logger.info('Explore by touch:', VirtualCursorController.exploreByTouch);
   },
 
   addPresenter: function addPresenter(presenter) {
     this.presenters.push(presenter);
     presenter.attach(this.chromeWin);
   },
 
   handleEvent: function handleEvent(aEvent) {
@@ -155,17 +155,21 @@ var AccessFu = {
       case 'TabOpen':
       {
         let browser = aEvent.target.linkedBrowser || aEvent.target;
         // Store the new browser node. We will need to check later when a new
         // content document is attached if it has been attached to this new tab.
         // If it has, than we will need to send a 'loading' message along with
         // the usual 'newdoc' to presenters.
         this._pendingDocuments[browser] = true;
-        this.presenters.forEach(function(p) { p.tabStateChanged(null, 'newtab'); });
+        this.presenters.forEach(
+          function(p) {
+            p.tabStateChanged(null, 'newtab');
+          }
+        );
         break;
       }
       case 'DOMActivate':
       {
         let activatedAcc = getAccessible(aEvent.originalTarget);
         let state = {};
         activatedAcc.getState(state, {});
 
@@ -200,23 +204,27 @@ var AccessFu = {
                                  this.prefsBranch.getIntPref('explorebytouch'));
         break;
       case 'accessible-event':
         let event;
         try {
           event = aSubject.QueryInterface(Ci.nsIAccessibleEvent);
           this._handleAccEvent(event);
         } catch (ex) {
-          dump('[AccessFu] ' + ex + '\n');
+          Logger.error(ex);
           return;
         }
     }
   },
 
   _handleAccEvent: function _handleAccEvent(aEvent) {
+    if (Logger.logLevel <= Logger.DEBUG)
+      Logger.debug(Logger.eventToString(aEvent),
+                   Logger.accessibleToString(aEvent.accessible));
+
     switch (aEvent.eventType) {
       case Ci.nsIAccessibleEvent.EVENT_VIRTUALCURSOR_CHANGED:
         {
           let pivot = aEvent.accessible.
             QueryInterface(Ci.nsIAccessibleCursorable).virtualCursor;
           let event = aEvent.
             QueryInterface(Ci.nsIAccessibleVirtualCursorChangeEvent);
           let position = pivot.position;
@@ -262,18 +270,18 @@ var AccessFu = {
           let acc = aEvent.accessible;
           if (acc.childCount) {
             let docAcc = acc.getChildAt(0);
             if (this._pendingDocuments[aEvent.DOMNode]) {
               // This is a document in a new tab. Check if it is
               // in a BUSY state (i.e. loading), and inform presenters.
               // We need to do this because a state change event will not be
               // fired when an object is created with the BUSY state.
-              // If this is not a new tab, don't bother because we sent 'loading'
-              // when the previous doc changed its state to BUSY.
+              // If this is not a new tab, don't bother because we sent
+              // 'loading' when the previous doc changed its state to BUSY.
               let state = {};
               docAcc.getState(state, {});
               if (state.value & Ci.nsIAccessibleStates.STATE_BUSY &&
                   this._isNotChromeDoc(docAcc))
                 this.presenters.forEach(
                   function(p) { p.tabStateChanged(docAcc, 'loading'); }
                 );
               delete this._pendingDocuments[aEvent.DOMNode];
@@ -317,32 +325,33 @@ var AccessFu = {
         }
       case Ci.nsIAccessibleEvent.EVENT_TEXT_INSERTED:
       case Ci.nsIAccessibleEvent.EVENT_TEXT_REMOVED:
       {
         if (aEvent.isFromUserInput) {
           // XXX support live regions as well.
           let event = aEvent.QueryInterface(Ci.nsIAccessibleTextChangeEvent);
           let isInserted = event.isInserted();
-          let textIface = aEvent.accessible.QueryInterface(Ci.nsIAccessibleText);
+          let txtIface = aEvent.accessible.QueryInterface(Ci.nsIAccessibleText);
 
           let text = '';
           try {
-            text = textIface.
+            text = txtIface.
               getText(0, Ci.nsIAccessibleText.TEXT_OFFSET_END_OF_TEXT);
           } catch (x) {
             // XXX we might have gotten an exception with of a
             // zero-length text. If we did, ignore it (bug #749810).
-            if (textIface.characterCount)
+            if (txtIface.characterCount)
               throw x;
           }
 
           this.presenters.forEach(
             function(p) {
-              p.textChanged(isInserted, event.start, event.length, text, event.modifiedText);
+              p.textChanged(isInserted, event.start, event.length,
+                            text, event.modifiedText);
             }
           );
         }
         break;
       }
       case Ci.nsIAccessibleEvent.EVENT_SCROLLING_START:
       {
         VirtualCursorController.moveCursorToObject(aEvent.accessible);
@@ -386,17 +395,17 @@ var AccessFu = {
    * @param {nsIDOMDocument} aDocument the document to check.
    * @return {boolean} true if this is not a chrome document.
    */
   _isNotChromeDoc: function _isNotChromeDoc(aDocument) {
     let location = aDocument.DOMNode.location;
     if (!location)
       return false;
 
-    return location.protocol != "about:";
+    return location.protocol != 'about:';
   },
 
   // A hash of documents that don't yet have an accessible tree.
   _pendingDocuments: {},
 
   // So we don't enable/disable twice
   _enabled: false
 };
--- a/accessible/src/jsat/Presenters.jsm
+++ b/accessible/src/jsat/Presenters.jsm
@@ -4,18 +4,18 @@
 
 'use strict';
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 const Cr = Components.results;
 
+Cu.import('resource://gre/modules/accessibility/Utils.jsm');
 Cu.import('resource://gre/modules/accessibility/UtteranceGenerator.jsm');
-Cu.import('resource://gre/modules/Services.jsm');
 
 var EXPORTED_SYMBOLS = ['VisualPresenter',
                         'AndroidPresenter',
                         'DummyAndroidPresenter',
                         'PresenterContext'];
 
 /**
  * The interface for all presenter classes. A presenter could be, for example,
@@ -148,17 +148,17 @@ VisualPresenter.prototype = {
       return;
     }
 
     try {
       aContext.accessible.scrollTo(
         Ci.nsIAccessibleScrollType.SCROLL_TYPE_ANYWHERE);
       this._highlight(aContext.accessible);
     } catch (e) {
-      dump('Error getting bounds: ' + e);
+      Logger.error('Failed to get bounds: ' + e);
       return;
     }
   },
 
   tabSelected: function VisualPresenter_tabSelected(aDocContext, aVCContext) {
     this.pivotChanged(aVCContext);
   },
 
@@ -170,20 +170,17 @@ VisualPresenter.prototype = {
 
   // Internals
 
   _hide: function _hide() {
     this.highlightBox.style.display = 'none';
   },
 
   _highlight: function _highlight(aObject) {
-    let vp = (Services.appinfo.OS == 'Android') ?
-      this.chromeWin.BrowserApp.selectedTab.getViewport() :
-      { zoom: 1.0, offsetY: 0 };
-
+    let vp = Utils.getViewport(this.chromeWin) || { zoom: 1.0, offsetY: 0 };
     let bounds = this._getBounds(aObject, vp.zoom);
 
     // First hide it to avoid flickering when changing the style.
     this.highlightBox.style.display = 'none';
     this.highlightBox.style.top = bounds.top + 'px';
     this.highlightBox.style.left = bounds.left + 'px';
     this.highlightBox.style.width = bounds.width + 'px';
     this.highlightBox.style.height = bounds.height + 'px';
@@ -234,26 +231,26 @@ AndroidPresenter.prototype = {
   ANDROID_WINDOW_STATE_CHANGED: 0x20,
 
   pivotChanged: function AndroidPresenter_pivotChanged(aContext) {
     if (!aContext.accessible)
       return;
 
     let output = [];
     aContext.newAncestry.forEach(
-      function (acc) {
+      function(acc) {
         output.push.apply(output, UtteranceGenerator.genForObject(acc));
       }
     );
 
     output.push.apply(output,
                       UtteranceGenerator.genForObject(aContext.accessible));
 
     aContext.subtreePreorder.forEach(
-      function (acc) {
+      function(acc) {
         output.push.apply(output, UtteranceGenerator.genForObject(acc));
       }
     );
 
     this.sendMessageToJava({
       gecko: {
         type: 'Accessibility:Event',
         eventType: this.ANDROID_VIEW_FOCUSED,
@@ -334,17 +331,17 @@ AndroidPresenter.prototype = {
  */
 
 function DummyAndroidPresenter() {}
 
 DummyAndroidPresenter.prototype = {
   __proto__: AndroidPresenter.prototype,
 
   sendMessageToJava: function DummyAndroidPresenter_sendMessageToJava(aMsg) {
-    dump(JSON.stringify(aMsg, null, 2) + '\n');
+    Logger.debug('Android event:\n' + JSON.stringify(aMsg, null, 2));
   }
 };
 
 /**
  * PresenterContext: An object that generates and caches context information
  * for a given accessible and its relationship with another accessible.
  */
 function PresenterContext(aAccessible, aOldAccessible) {
new file mode 100644
--- /dev/null
+++ b/accessible/src/jsat/Utils.jsm
@@ -0,0 +1,121 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+const Cu = Components.utils;
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
+Cu.import('resource://gre/modules/Services.jsm');
+
+var EXPORTED_SYMBOLS = ['Utils', 'Logger'];
+
+var gAccRetrieval = Cc['@mozilla.org/accessibleRetrieval;1'].
+  getService(Ci.nsIAccessibleRetrieval);
+
+var Utils = {
+  get OS() {
+    if (!this._OS)
+      this._OS = Services.appinfo.OS;
+    return this._OS;
+  },
+
+  get AndroidSdkVersion() {
+    if (!this._AndroidSdkVersion) {
+      let shellVersion = Services.sysinfo.get('shellVersion') || '';
+      let matches = shellVersion.match(/\((\d+)\)$/);
+      if (matches)
+        this._AndroidSdkVersion = parseInt(matches[1]);
+      else
+        this._AndroidSdkVersion = 15; // Most useful in desktop debugging.
+    }
+    return this._AndroidSdkVersion;
+  },
+
+  set AndroidSdkVersion(value) {
+    // When we want to mimic another version.
+    this._AndroidSdkVersion = value;
+  },
+
+  getBrowserApp: function getBrowserApp(aWindow) {
+    switch (this.OS) {
+      case 'Android':
+        return aWindow.BrowserApp;
+      default:
+        return aWindow.gBrowser;
+    }
+  },
+
+  getViewport: function getViewport(aWindow) {
+    switch (this.OS) {
+      case 'Android':
+        return aWindow.BrowserApp.selectedTab.getViewport();
+      default:
+        return null;
+    }
+  }
+};
+
+var Logger = {
+  DEBUG: 0,
+  INFO: 1,
+  WARNING: 2,
+  ERROR: 3,
+  _LEVEL_NAMES: ['DEBUG', 'INFO', 'WARNING', 'ERROR'],
+
+  logLevel: 1, // INFO;
+
+  log: function log(aLogLevel) {
+    if (aLogLevel < this.logLevel)
+      return;
+
+    let message = Array.prototype.slice.call(arguments, 1).join(' ');
+    dump('[AccessFu] ' + this._LEVEL_NAMES[aLogLevel] + ' ' + message + '\n');
+  },
+
+  info: function info() {
+    this.log.apply(
+      this, [this.INFO].concat(Array.prototype.slice.call(arguments)));
+  },
+
+  debug: function debug() {
+    this.log.apply(
+      this, [this.DEBUG].concat(Array.prototype.slice.call(arguments)));
+  },
+
+  warning: function warning() {
+    this.log.apply(
+      this, [this.WARNING].concat(Array.prototype.slice.call(arguments)));
+  },
+
+  error: function error() {
+    this.log.apply(
+      this, [this.ERROR].concat(Array.prototype.slice.call(arguments)));
+  },
+
+  accessibleToString: function accessibleToString(aAccessible) {
+    let str = '[ defunct ]';
+    try {
+      str = '[ ' + gAccRetrieval.getStringRole(aAccessible.role) +
+        ' | ' + aAccessible.name + ' ]';
+    } catch (x) {
+    }
+
+    return str;
+  },
+
+  eventToString: function eventToString(aEvent) {
+    let str = gAccRetrieval.getStringEventType(aEvent.eventType);
+    if (aEvent.eventType == Ci.nsIAccessibleEvent.EVENT_STATE_CHANGE) {
+      let event = aEvent.QueryInterface(Ci.nsIAccessibleStateChangeEvent);
+      let stateStrings = (event.isExtraState()) ?
+        gAccRetrieval.getStringStates(0, event.state) :
+        gAccRetrieval.getStringStates(event.state, 0);
+      str += ' (' + stateStrings.item(0) + ')';
+    }
+
+    return str;
+  }
+};
--- a/accessible/src/jsat/VirtualCursorController.jsm
+++ b/accessible/src/jsat/VirtualCursorController.jsm
@@ -6,18 +6,18 @@
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 const Cr = Components.results;
 
 var EXPORTED_SYMBOLS = ['VirtualCursorController'];
 
+Cu.import('resource://gre/modules/accessibility/Utils.jsm');
 Cu.import('resource://gre/modules/XPCOMUtils.jsm');
-Cu.import('resource://gre/modules/Services.jsm');
 
 var gAccRetrieval = Cc['@mozilla.org/accessibleRetrieval;1'].
   getService(Ci.nsIAccessibleRetrieval);
 
 var TraversalRules = {
   Simple: {
     getMatchRoles: function SimpleTraversalRule_getmatchRoles(aRules) {
       aRules.value = this._matchRoles;
@@ -414,27 +414,19 @@ var VirtualCursorController = {
     this.chromeWin = aWindow;
     this.chromeWin.document.addEventListener('keypress', this, true);
   },
 
   detach: function detach() {
     this.chromeWin.document.removeEventListener('keypress', this, true);
   },
 
-  _getBrowserApp: function _getBrowserApp() {
-    switch (Services.appinfo.OS) {
-      case 'Android':
-        return this.chromeWin.BrowserApp;
-      default:
-        return this.chromeWin.gBrowser;
-    }
-  },
-
   handleEvent: function handleEvent(aEvent) {
-    let document = this._getBrowserApp().selectedBrowser.contentDocument;
+    let document = Utils.getBrowserApp(this.chromeWin).
+      selectedBrowser.contentDocument;
     let target = aEvent.target;
 
     switch (aEvent.keyCode) {
       case 0:
         // an alphanumeric key was pressed, handle it separately.
         // If it was pressed with either alt or ctrl, just pass through.
         // If it was pressed with meta, pass the key on without the meta.
         if (this._isEditableText(target) ||
@@ -482,17 +474,17 @@ var VirtualCursorController = {
         if (this._isEditableText(target) == this.MULTI_LINE_EDITABLE) {
           if (target.selectionEnd != 0)
             // Don't blur content if caret is not at start of text area.
             return;
           else
             target.blur();
         }
 
-        if (Services.appinfo.OS == 'Android')
+        if (Utils.OS == 'Android')
           // Return focus to native Android browser chrome.
           Cc['@mozilla.org/android/bridge;1'].
             getService(Ci.nsIAndroidBridge).handleGeckoMessage(
               JSON.stringify({ gecko: { type: 'ToggleChrome:Focus' } }));
         break;
       case aEvent.DOM_VK_RETURN:
       case aEvent.DOM_VK_ENTER:
         if (this._isEditableText(target))
--- a/accessible/src/xpcom/nsAccEvent.cpp
+++ b/accessible/src/xpcom/nsAccEvent.cpp
@@ -252,8 +252,17 @@ NS_IMETHODIMP
 nsAccVirtualCursorChangeEvent::GetOldEndOffset(PRInt32* aOldEndOffset)
 {
   NS_ENSURE_ARG_POINTER(aOldEndOffset);
 
   *aOldEndOffset =
     static_cast<AccVCChangeEvent*>(mEvent.get())->OldEndOffset();
   return NS_OK;
 }
+
+NS_IMETHODIMP
+nsAccVirtualCursorChangeEvent::GetReason(PRInt16* aReason)
+{
+  NS_ENSURE_ARG_POINTER(aReason);
+
+  *aReason = static_cast<AccVCChangeEvent*>(mEvent.get())->Reason();
+  return NS_OK;
+}
--- a/accessible/src/xpcom/xpcAccessibleTable.cpp
+++ b/accessible/src/xpcom/xpcAccessibleTable.cpp
@@ -198,16 +198,55 @@ xpcAccessibleTable::IsCellSelected(PRInt
       aColIdx < 0 || static_cast<PRUint32>(aColIdx) >= mTable->ColCount())
     return NS_ERROR_INVALID_ARG;
 
   *aIsSelected = mTable->IsCellSelected(aRowIdx, aColIdx);
   return NS_OK;
 }
 
 nsresult
+xpcAccessibleTable::GetSelectedCellCount(PRUint32* aSelectedCellCount)
+{
+  NS_ENSURE_ARG_POINTER(aSelectedCellCount);
+  *aSelectedCellCount = 0;
+
+  if (!mTable)
+    return NS_ERROR_FAILURE;
+
+  *aSelectedCellCount = mTable->SelectedCellCount();
+  return NS_OK;
+}
+
+nsresult
+xpcAccessibleTable::GetSelectedColumnCount(PRUint32* aSelectedColumnCount)
+{
+  NS_ENSURE_ARG_POINTER(aSelectedColumnCount);
+  *aSelectedColumnCount = 0;
+
+  if (!mTable)
+    return NS_ERROR_FAILURE;
+
+  *aSelectedColumnCount = mTable->SelectedColCount();
+  return NS_OK;
+}
+
+nsresult
+xpcAccessibleTable::GetSelectedRowCount(PRUint32* aSelectedRowCount)
+{
+  NS_ENSURE_ARG_POINTER(aSelectedRowCount);
+  *aSelectedRowCount = 0;
+
+  if (!mTable)
+    return NS_ERROR_FAILURE;
+
+  *aSelectedRowCount = mTable->SelectedRowCount();
+  return NS_OK;
+}
+
+nsresult
 xpcAccessibleTable::GetSummary(nsAString& aSummary)
 {
   if (!mTable)
     return NS_ERROR_FAILURE;
 
   nsAutoString summary;
   mTable->Summary(summary);
   aSummary.Assign(summary);
--- a/accessible/src/xpcom/xpcAccessibleTable.h
+++ b/accessible/src/xpcom/xpcAccessibleTable.h
@@ -34,16 +34,19 @@ public:
                              PRInt32* aColumnExtent);
   nsresult GetRowExtentAt(PRInt32 row, PRInt32 column,
                           PRInt32* aRowExtent);
   nsresult GetColumnDescription(PRInt32 aColIdx, nsAString& aDescription);
   nsresult GetRowDescription(PRInt32 aRowIdx, nsAString& aDescription);
   nsresult IsColumnSelected(PRInt32 aColIdx, bool* _retval);
   nsresult IsRowSelected(PRInt32 aRowIdx, bool* _retval);
   nsresult IsCellSelected(PRInt32 aRowIdx, PRInt32 aColIdx, bool* _retval);
+  nsresult GetSelectedCellCount(PRUint32* aSelectedCellCount);
+  nsresult GetSelectedColumnCount(PRUint32* aSelectedColumnCount);
+  nsresult GetSelectedRowCount(PRUint32* aSelectedRowCount);
   nsresult SelectColumn(PRInt32 aColIdx);
   nsresult SelectRow(PRInt32 aRowIdx);
   nsresult UnselectColumn(PRInt32 aColIdx);
   nsresult UnselectRow(PRInt32 aRowIdx);
   nsresult IsProbablyForLayout(bool* aIsForLayout);
 
 protected:
   mozilla::a11y::TableAccessible* mTable;
@@ -74,19 +77,22 @@ protected:
   NS_SCRIPTABLE NS_IMETHOD GetRowDescription(PRInt32 rowIndex, nsAString& _retval NS_OUTPARAM) \
     { return xpcAccessibleTable::GetRowDescription(rowIndex, _retval); } \
   NS_SCRIPTABLE NS_IMETHOD IsColumnSelected(PRInt32 colIdx, bool* _retval NS_OUTPARAM) \
     { return xpcAccessibleTable::IsColumnSelected(colIdx, _retval); } \
   NS_SCRIPTABLE NS_IMETHOD IsRowSelected(PRInt32 rowIdx, bool* _retval NS_OUTPARAM) \
     { return xpcAccessibleTable::IsRowSelected(rowIdx, _retval); } \
   NS_SCRIPTABLE NS_IMETHOD IsCellSelected(PRInt32 rowIdx, PRInt32 colIdx, bool* _retval NS_OUTPARAM) \
     { return xpcAccessibleTable::IsCellSelected(rowIdx, colIdx, _retval); } \
-  NS_SCRIPTABLE NS_IMETHOD GetSelectedCellCount(PRUint32 *aSelectedCellCount); \
-  NS_SCRIPTABLE NS_IMETHOD GetSelectedColumnCount(PRUint32 *aSelectedColumnCount); \
-  NS_SCRIPTABLE NS_IMETHOD GetSelectedRowCount(PRUint32 *aSelectedRowCount); \
+  NS_SCRIPTABLE NS_IMETHOD GetSelectedCellCount(PRUint32* aSelectedCellCount) \
+    { return xpcAccessibleTable::GetSelectedCellCount(aSelectedCellCount); } \
+  NS_SCRIPTABLE NS_IMETHOD GetSelectedColumnCount(PRUint32* aSelectedColumnCount) \
+    { return xpcAccessibleTable::GetSelectedColumnCount(aSelectedColumnCount); } \
+  NS_SCRIPTABLE NS_IMETHOD GetSelectedRowCount(PRUint32* aSelectedRowCount) \
+    { return xpcAccessibleTable::GetSelectedRowCount(aSelectedRowCount); } \
   NS_SCRIPTABLE NS_IMETHOD GetSelectedCells(nsIArray * *aSelectedCells); \
   NS_SCRIPTABLE NS_IMETHOD GetSelectedCellIndices(PRUint32 *cellsArraySize NS_OUTPARAM, PRInt32 **cellsArray NS_OUTPARAM); \
   NS_SCRIPTABLE NS_IMETHOD GetSelectedColumnIndices(PRUint32 *rowsArraySize NS_OUTPARAM, PRInt32 **rowsArray NS_OUTPARAM); \
   NS_SCRIPTABLE NS_IMETHOD GetSelectedRowIndices(PRUint32 *rowsArraySize NS_OUTPARAM, PRInt32 **rowsArray NS_OUTPARAM); \
   NS_SCRIPTABLE NS_IMETHOD SelectRow(PRInt32 aRowIdx) \
     { return xpcAccessibleTable::SelectRow(aRowIdx); } \
   NS_SCRIPTABLE NS_IMETHOD SelectColumn(PRInt32 aColIdx) \
     { return xpcAccessibleTable::SelectColumn(aColIdx); } \
--- a/accessible/src/xul/XULListboxAccessible.cpp
+++ b/accessible/src/xul/XULListboxAccessible.cpp
@@ -349,100 +349,64 @@ XULListboxAccessible::IsRowSelected(PRUi
 }
 
 bool
 XULListboxAccessible::IsCellSelected(PRUint32 aRowIdx, PRUint32 aColIdx)
 {
   return IsRowSelected(aRowIdx);
 }
 
-NS_IMETHODIMP
-XULListboxAccessible::GetSelectedCellCount(PRUint32* aCount)
+PRUint32
+XULListboxAccessible::SelectedCellCount()
 {
-  NS_ENSURE_ARG_POINTER(aCount);
-  *aCount = 0;
-
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
     do_QueryInterface(mContent);
   NS_ASSERTION(control,
                "Doesn't implement nsIDOMXULMultiSelectControlElement.");
 
   nsCOMPtr<nsIDOMNodeList> selectedItems;
   control->GetSelectedItems(getter_AddRefs(selectedItems));
   if (!selectedItems)
-    return NS_OK;
+    return 0;
 
   PRUint32 selectedItemsCount = 0;
   nsresult rv = selectedItems->GetLength(&selectedItemsCount);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (!selectedItemsCount)
-    return NS_OK;
+  NS_ENSURE_SUCCESS(rv, 0);
 
-  PRInt32 columnCount = 0;
-  rv = GetColumnCount(&columnCount);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  *aCount = selectedItemsCount * columnCount;
-  return NS_OK;
+  return selectedItemsCount * ColCount();
 }
 
-NS_IMETHODIMP
-XULListboxAccessible::GetSelectedColumnCount(PRUint32* aCount)
+PRUint32
+XULListboxAccessible::SelectedColCount()
 {
-  NS_ENSURE_ARG_POINTER(aCount);
-  *aCount = 0;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
     do_QueryInterface(mContent);
   NS_ASSERTION(control,
                "Doesn't implement nsIDOMXULMultiSelectControlElement.");
 
-  PRInt32 selectedrowCount = 0;
-  nsresult rv = control->GetSelectedCount(&selectedrowCount);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  PRInt32 rowCount = 0;
-  rv = GetRowCount(&rowCount);
-  NS_ENSURE_SUCCESS(rv, rv);
+  PRInt32 selectedRowCount = 0;
+  nsresult rv = control->GetSelectedCount(&selectedRowCount);
+  NS_ENSURE_SUCCESS(rv, 0);
 
-  if (selectedrowCount != rowCount)
-    return NS_OK;
-
-  PRInt32 columnCount = 0;
-  rv = GetColumnCount(&columnCount);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  *aCount = columnCount;
-  return NS_OK;
+  return selectedRowCount > 0 && selectedRowCount == RowCount() ? ColCount() : 0;
 }
 
-NS_IMETHODIMP
-XULListboxAccessible::GetSelectedRowCount(PRUint32* aCount)
+PRUint32
+XULListboxAccessible::SelectedRowCount()
 {
-  NS_ENSURE_ARG_POINTER(aCount);
-  *aCount = 0;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
     do_QueryInterface(mContent);
   NS_ASSERTION(control,
                "Doesn't implement nsIDOMXULMultiSelectControlElement.");
 
-  PRInt32 selectedrowCount = 0;
-  nsresult rv = control->GetSelectedCount(&selectedrowCount);
-  NS_ENSURE_SUCCESS(rv, rv);
+  PRInt32 selectedRowCount = 0;
+  nsresult rv = control->GetSelectedCount(&selectedRowCount);
+  NS_ENSURE_SUCCESS(rv, 0);
 
-  *aCount = selectedrowCount;
-  return NS_OK;
+  return selectedRowCount >= 0 ? selectedRowCount : 0;
 }
 
 NS_IMETHODIMP
 XULListboxAccessible::GetSelectedCells(nsIArray** aCells)
 {
   NS_ENSURE_ARG_POINTER(aCells);
   *aCells = nsnull;
 
--- a/accessible/src/xul/XULListboxAccessible.h
+++ b/accessible/src/xul/XULListboxAccessible.h
@@ -74,16 +74,19 @@ public:
 
   // TableAccessible
   virtual PRUint32 ColCount();
   virtual PRUint32 RowCount();
   virtual Accessible* CellAt(PRUint32 aRowIndex, PRUint32 aColumnIndex);
   virtual bool IsColSelected(PRUint32 aColIdx);
   virtual bool IsRowSelected(PRUint32 aRowIdx);
   virtual bool IsCellSelected(PRUint32 aRowIdx, PRUint32 aColIdx);
+  virtual PRUint32 SelectedCellCount();
+  virtual PRUint32 SelectedColCount();
+  virtual PRUint32 SelectedRowCount();
   virtual void SelectRow(PRUint32 aRowIdx);
   virtual void UnselectRow(PRUint32 aRowIdx);
 
   // nsAccessNode
   virtual void Shutdown();
 
   // Accessible
   virtual void Value(nsString& aValue);
--- a/accessible/src/xul/XULTreeGridAccessible.cpp
+++ b/accessible/src/xul/XULTreeGridAccessible.cpp
@@ -51,80 +51,43 @@ XULTreeGridAccessible::RowCount()
   if (!mTreeView)
     return 0;
 
   PRInt32 rowCount = 0;
   mTreeView->GetRowCount(&rowCount);
   return rowCount >= 0 ? rowCount : 0;
 }
 
-NS_IMETHODIMP
-XULTreeGridAccessible::GetSelectedCellCount(PRUint32* aCount)
+PRUint32
+XULTreeGridAccessible::SelectedCellCount()
 {
-  NS_ENSURE_ARG_POINTER(aCount);
-  *aCount = 0;
-
-  PRUint32 selectedrowCount = 0;
-  nsresult rv = GetSelectedRowCount(&selectedrowCount);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  PRInt32 columnCount = 0;
-  rv = GetColumnCount(&columnCount);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  *aCount = selectedrowCount * columnCount;
-  return NS_OK;
+  return SelectedRowCount() * ColCount();
 }
 
-NS_IMETHODIMP
-XULTreeGridAccessible::GetSelectedColumnCount(PRUint32* aCount)
+PRUint32
+XULTreeGridAccessible::SelectedColCount()
 {
-  NS_ENSURE_ARG_POINTER(aCount);
-  *aCount = 0;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
   // If all the row has been selected, then all the columns are selected,
   // because we can't select a column alone.
 
-  PRInt32 rowCount = 0;
-  nsresult rv = GetRowCount(&rowCount);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  PRInt32 selectedrowCount = 0;
-  rv = GetSelectionCount(&selectedrowCount);
-  NS_ENSURE_SUCCESS(rv, rv);
+  PRInt32 selectedRowCount = 0;
+  nsresult rv = GetSelectionCount(&selectedRowCount);
+  NS_ENSURE_SUCCESS(rv, 0);
 
-  if (rowCount == selectedrowCount) {
-    PRInt32 columnCount = 0;
-    rv = GetColumnCount(&columnCount);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    *aCount = columnCount;
-  }
-
-  return NS_OK;
+  return selectedRowCount > 0 && selectedRowCount == RowCount() ? ColCount() : 0;
 }
 
-NS_IMETHODIMP
-XULTreeGridAccessible::GetSelectedRowCount(PRUint32* aCount)
+PRUint32
+XULTreeGridAccessible::SelectedRowCount()
 {
-  NS_ENSURE_ARG_POINTER(aCount);
-  *aCount = 0;
+  PRInt32 selectedRowCount = 0;
+  nsresult rv = GetSelectionCount(&selectedRowCount);
+  NS_ENSURE_SUCCESS(rv, 0);
 
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  PRInt32 selectedrowCount = 0;
-  nsresult rv = GetSelectionCount(&selectedrowCount);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  *aCount = selectedrowCount;
-  return NS_OK;
+  return selectedRowCount >= 0 ? selectedRowCount : 0;
 }
 
 NS_IMETHODIMP
 XULTreeGridAccessible::GetSelectedCells(nsIArray** aCells)
 {
   NS_ENSURE_ARG_POINTER(aCells);
   *aCells = nsnull;
 
--- a/accessible/src/xul/XULTreeGridAccessible.h
+++ b/accessible/src/xul/XULTreeGridAccessible.h
@@ -33,16 +33,19 @@ public:
   // TableAccessible
   virtual PRUint32 ColCount();
   virtual PRUint32 RowCount();
   virtual Accessible* CellAt(PRUint32 aRowIndex, PRUint32 aColumnIndex);
   virtual void ColDescription(PRUint32 aColIdx, nsString& aDescription);
   virtual bool IsColSelected(PRUint32 aColIdx);
   virtual bool IsRowSelected(PRUint32 aRowIdx);
   virtual bool IsCellSelected(PRUint32 aRowIdx, PRUint32 aColIdx);
+  virtual PRUint32 SelectedCellCount();
+  virtual PRUint32 SelectedColCount();
+  virtual PRUint32 SelectedRowCount();
   virtual void SelectRow(PRUint32 aRowIdx);
   virtual void UnselectRow(PRUint32 aRowIdx);
 
   // nsAccessNode
   virtual void Shutdown();
 
   // Accessible
   virtual TableAccessible* AsTable() { return this; }
--- a/accessible/tests/mochitest/pivot.js
+++ b/accessible/tests/mochitest/pivot.js
@@ -65,35 +65,39 @@ var ObjectTraversalRule =
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 // Virtual state invokers and checkers
 
 /**
  * A checker for virtual cursor changed events.
  */
-function VCChangedChecker(aDocAcc, aIdOrNameOrAcc, aTextOffsets)
+function VCChangedChecker(aDocAcc, aIdOrNameOrAcc, aTextOffsets, aPivotMoveMethod)
 {
   this.__proto__ = new invokerChecker(EVENT_VIRTUALCURSOR_CHANGED, aDocAcc);
 
   this.check = function VCChangedChecker_check(aEvent)
   {
     SimpleTest.info("VCChangedChecker_check");
 
     var event = null;
     try {
       event = aEvent.QueryInterface(nsIAccessibleVirtualCursorChangeEvent);
     } catch (e) {
       SimpleTest.ok(false, "Does not support correct interface: " + e);
     }
 
-    var position = aDocAcc.virtualCursor.position;
+    SimpleTest.is(
+      event.reason,
+      VCChangedChecker.methodReasonMap[aPivotMoveMethod],
+      'wrong move reason');
 
-    var idMatches = position.DOMNode.id == aIdOrNameOrAcc;
-    var nameMatches = position.name == aIdOrNameOrAcc;
+    var position = aDocAcc.virtualCursor.position;
+    var idMatches = position && position.DOMNode.id == aIdOrNameOrAcc;
+    var nameMatches = position && position.name == aIdOrNameOrAcc;
     var accMatches = position == aIdOrNameOrAcc;
 
     SimpleTest.ok(idMatches || nameMatches || accMatches, "id or name matches",
                   "expecting " + aIdOrNameOrAcc + ", got '" +
                   prettyName(position));
 
     if (aTextOffsets) {
       SimpleTest.is(aDocAcc.virtualCursor.startOffset, aTextOffsets[0],
@@ -128,16 +132,25 @@ VCChangedChecker.storePreviousPosAndOffs
 };
 
 VCChangedChecker.getPreviousPosAndOffset =
   function getPreviousPosAndOffset(aPivot)
 {
   return VCChangedChecker.prevPosAndOffset[aPivot];
 };
 
+VCChangedChecker.methodReasonMap = {
+  'moveNext': nsIAccessiblePivot.REASON_NEXT,
+  'movePrevious': nsIAccessiblePivot.REASON_PREV,
+  'moveFirst': nsIAccessiblePivot.REASON_FIRST,
+  'moveLast': nsIAccessiblePivot.REASON_LAST,
+  'setTextRange': nsIAccessiblePivot.REASON_TEXT,
+  'moveToPoint': nsIAccessiblePivot.REASON_POINT
+};
+
 /**
  * Set a text range in the pivot and wait for virtual cursor change event.
  *
  * @param aDocAcc         [in] document that manages the virtual cursor
  * @param aTextAccessible [in] accessible to set to virtual cursor's position
  * @param aTextOffsets    [in] start and end offsets of text range to set in
  *                        virtual cursor.
  */
@@ -155,47 +168,95 @@ function setVCRangeInvoker(aDocAcc, aTex
 
   this.getID = function setVCRangeInvoker_getID()
   {
     return "Set offset in " + prettyName(aTextAccessible) +
       " to (" + aTextOffsets[0] + ", " + aTextOffsets[1] + ")";
   };
 
   this.eventSeq = [
-    new VCChangedChecker(aDocAcc, aTextAccessible, aTextOffsets)
+    new VCChangedChecker(aDocAcc, aTextAccessible, aTextOffsets, "setTextRange")
   ];
 }
 
 /**
  * Move the pivot and wait for virtual cursor change event.
  *
  * @param aDocAcc          [in] document that manages the virtual cursor
  * @param aPivotMoveMethod [in] method to test (ie. "moveNext", "moveFirst", etc.)
  * @param aRule            [in] traversal rule object
- * @param aIdOrNameOrAcc   [in] id, accessivle or accessible name to expect
+ * @param aIdOrNameOrAcc   [in] id, accessible or accessible name to expect
  *                         virtual cursor to land on after performing move method.
+ *                         false if no move is expected.
  */
 function setVCPosInvoker(aDocAcc, aPivotMoveMethod, aRule, aIdOrNameOrAcc)
 {
+  var expectMove = (aIdOrNameOrAcc != false);
   this.invoke = function virtualCursorChangedInvoker_invoke()
   {
     VCChangedChecker.
       storePreviousPosAndOffset(aDocAcc.virtualCursor);
     var moved = aDocAcc.virtualCursor[aPivotMoveMethod](aRule);
-    SimpleTest.ok((aIdOrNameOrAcc && moved) || (!aIdOrNameOrAcc && !moved),
+    SimpleTest.ok((expectMove && moved) || (!expectMove && !moved),
                   "moved pivot");
   };
 
   this.getID = function setVCPosInvoker_getID()
   {
-    return "Do " + (aIdOrNameOrAcc ? "" : "no-op ") + aPivotMoveMethod;
+    return "Do " + (expectMove ? "" : "no-op ") + aPivotMoveMethod;
   };
 
-  if (aIdOrNameOrAcc) {
-    this.eventSeq = [ new VCChangedChecker(aDocAcc, aIdOrNameOrAcc) ];
+  if (expectMove) {
+    this.eventSeq = [
+      new VCChangedChecker(aDocAcc, aIdOrNameOrAcc, null, aPivotMoveMethod)
+    ];
+  } else {
+    this.eventSeq = [];
+    this.unexpectedEventSeq = [
+      new invokerChecker(EVENT_VIRTUALCURSOR_CHANGED, aDocAcc)
+    ];
+  }
+}
+
+/**
+ * Move the pivot to the position under the point.
+ *
+ * @param aDocAcc        [in] document that manages the virtual cursor
+ * @param aX             [in] screen x coordinate
+ * @param aY             [in] screen y coordinate
+ * @param aIgnoreNoMatch [in] don't unset position if no object was found at
+ *                       point.
+ * @param aRule          [in] traversal rule object
+ * @param aIdOrNameOrAcc [in] id, accessible or accessible name to expect
+ *                       virtual cursor to land on after performing move method.
+ *                       false if no move is expected.
+ */
+function moveVCCoordInvoker(aDocAcc, aX, aY, aIgnoreNoMatch,
+                            aRule, aIdOrNameOrAcc)
+{
+  var expectMove = (aIdOrNameOrAcc != false);
+  this.invoke = function virtualCursorChangedInvoker_invoke()
+  {
+    VCChangedChecker.
+      storePreviousPosAndOffset(aDocAcc.virtualCursor);
+    var moved = aDocAcc.virtualCursor.moveToPoint(aRule, aX, aY,
+                                                  aIgnoreNoMatch);
+    SimpleTest.ok((expectMove && moved) || (!expectMove && !moved),
+                  "moved pivot");
+  };
+
+  this.getID = function setVCPosInvoker_getID()
+  {
+    return "Do " + (expectMove ? "" : "no-op ") + "moveToPoint " + aIdOrNameOrAcc;
+  };
+
+  if (expectMove) {
+    this.eventSeq = [
+      new VCChangedChecker(aDocAcc, aIdOrNameOrAcc, null, 'moveToPoint')
+    ];
   } else {
     this.eventSeq = [];
     this.unexpectedEventSeq = [
       new invokerChecker(EVENT_VIRTUALCURSOR_CHANGED, aDocAcc)
     ];
   }
 }
 
@@ -215,37 +276,37 @@ function queueTraversalSequence(aQueue, 
 
   for (var i = 0; i < aSequence.length; i++) {
     var invoker =
       new setVCPosInvoker(aDocAcc, "moveNext", aRule, aSequence[i]);
     aQueue.push(invoker);
   }
 
   // No further more matches for given rule, expect no virtual cursor changes.
-  aQueue.push(new setVCPosInvoker(aDocAcc, "moveNext", aRule, null));
+  aQueue.push(new setVCPosInvoker(aDocAcc, "moveNext", aRule, false));
 
   for (var i = aSequence.length-2; i >= 0; i--) {
     var invoker =
       new setVCPosInvoker(aDocAcc, "movePrevious", aRule, aSequence[i]);
     aQueue.push(invoker);
   }
 
   // No previous more matches for given rule, expect no virtual cursor changes.
-  aQueue.push(new setVCPosInvoker(aDocAcc, "movePrevious", aRule, null));
+  aQueue.push(new setVCPosInvoker(aDocAcc, "movePrevious", aRule, false));
 
   aQueue.push(new setVCPosInvoker(aDocAcc, "moveLast", aRule,
                                   aSequence[aSequence.length - 1]));
 
   // No further more matches for given rule, expect no virtual cursor changes.
-  aQueue.push(new setVCPosInvoker(aDocAcc, "moveNext", aRule, null));
+  aQueue.push(new setVCPosInvoker(aDocAcc, "moveNext", aRule, false));
 
   aQueue.push(new setVCPosInvoker(aDocAcc, "moveFirst", aRule, aSequence[0]));
 
   // No previous more matches for given rule, expect no virtual cursor changes.
-  aQueue.push(new setVCPosInvoker(aDocAcc, "movePrevious", aRule, null));
+  aQueue.push(new setVCPosInvoker(aDocAcc, "movePrevious", aRule, false));
 }
 
 /**
  * A checker for removing an accessible while the virtual cursor is on it.
  */
 function removeVCPositionChecker(aDocAcc, aHiddenParentAcc)
 {
   this.__proto__ = new invokerChecker(EVENT_REORDER, aHiddenParentAcc);
--- a/accessible/tests/mochitest/pivot/test_virtualcursor.html
+++ b/accessible/tests/mochitest/pivot/test_virtualcursor.html
@@ -10,16 +10,17 @@
   </script>
 
   <script type="application/javascript" src="../common.js"></script>
   <script type="application/javascript" src="../browser.js"></script>
   <script type="application/javascript" src="../events.js"></script>
   <script type="application/javascript" src="../role.js"></script>
   <script type="application/javascript" src="../states.js"></script>
   <script type="application/javascript" src="../pivot.js"></script>
+  <script type="application/javascript" src="../layout.js"></script>
 
   <script type="application/javascript">
     var gBrowserWnd = null;
     var gQueue = null;
 
     function doTest()
     {
       var rootAcc = getRootAccessible(browserWindow().document);
@@ -71,16 +72,32 @@
           [2,6]));
 
       gQueue.push(new removeVCPositionInvoker(
         docAcc, doc.getElementById('hide-me')));
 
       gQueue.push(new removeVCRootInvoker(
         doc.getElementById('links')));
 
+      var [x, y] = getBounds(getAccessible(doc.getElementById('heading-1-1')));
+      gQueue.push(new moveVCCoordInvoker(docAcc, x + 1, y + 1, true,
+                                         HeadersTraversalRule, 'heading-1-1'));
+
+      // Already on the point, so we should not get a move event.
+      gQueue.push(new moveVCCoordInvoker(docAcc, x + 1, y + 1, true,
+                                         HeadersTraversalRule, false));
+
+      // Attempting a coordinate outside any header, should not move.
+      gQueue.push(new moveVCCoordInvoker(docAcc, x - 1, y - 1, true,
+                                         HeadersTraversalRule, false));
+
+      // Attempting a coordinate outside any header, should move to null
+      gQueue.push(new moveVCCoordInvoker(docAcc, x - 1, y - 1, false,
+                                         HeadersTraversalRule, null));
+
       gQueue.invoke();
     }
 
     SimpleTest.waitForExplicitFinish();
     addLoadEvent(function () {
       /* We open a new browser because we need to test with a top-level content
          document. */
       openBrowserWindow(
--- a/b2g/chrome/content/content.css
+++ b/b2g/chrome/content/content.css
@@ -74,12 +74,11 @@ xul|thumb {
   -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;
   border-radius: 3px;
 }
 
 /* -moz-touch-enabled? media elements */
-video > xul|videocontrols,
-audio > xul|videocontrols {
+:-moz-any(video, audio) > xul|videocontrols {
   -moz-binding: url("chrome://global/content/bindings/videocontrols.xml#touchControls");
 }
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -79,33 +79,52 @@ var shell = {
       let homeSrc = Services.env.get('B2G_HOMESCREEN');
       if (homeSrc)
         return homeSrc;
     } catch (e) {}
 
     return Services.prefs.getCharPref('browser.homescreenURL');
   },
 
+  get manifestURL() {
+    return Services.prefs.getCharPref('browser.manifestURL');
+   },
+
   start: function shell_start() {
     let homeURL = this.homeURL;
     if (!homeURL) {
       let msg = 'Fatal error during startup: No homescreen found: try setting B2G_HOMESCREEN';
       alert(msg);
       return;
     }
 
+    let manifestURL = this.manifestURL;
+    // <html:iframe id="homescreen"
+    //              mozbrowser="true" mozallowfullscreen="true"
+    //              style="overflow: hidden; -moz-box-flex: 1; border: none;"
+    //              src="data:text/html;charset=utf-8,%3C!DOCTYPE html>%3Cbody style='background:black;'>"/>
+    let browserFrame =
+      document.createElementNS('http://www.w3.org/1999/xhtml', 'html:iframe');
+    browserFrame.setAttribute('id', 'homescreen');
+    browserFrame.setAttribute('mozbrowser', 'true');
+    browserFrame.setAttribute('mozapp', manifestURL);
+    browserFrame.setAttribute('mozallowfullscreen', 'true');
+    browserFrame.setAttribute('style', "overflow: hidden; -moz-box-flex: 1; border: none;");
+    browserFrame.setAttribute('src', "data:text/html;charset=utf-8,%3C!DOCTYPE html>%3Cbody style='background:black;");
+    document.getElementById('shell').appendChild(browserFrame);
+
     ['keydown', 'keypress', 'keyup'].forEach((function listenKey(type) {
       window.addEventListener(type, this, false, true);
       window.addEventListener(type, this, true, true);
     }).bind(this));
 
     window.addEventListener('MozApplicationManifest', this);
     window.addEventListener('mozfullscreenchange', this);
     window.addEventListener('sizemodechange', this);
-    this.contentBrowser.addEventListener('load', this, true);
+    this.contentBrowser.addEventListener('mozbrowserloadstart', this, true);
 
     // Until the volume can be set from the content side, set it to a
     // a specific value when the device starts. This way the front-end
     // can display a notification when the volume change and show a volume
     // level modified from this point.
     // try catch block must be used since the emulator fails here. bug 746429
     try {
       Services.audioManager.masterVolume = 0.5;
@@ -115,52 +134,41 @@ var shell = {
 
     let domains = "";
     try {
       domains = Services.prefs.getCharPref('b2g.privileged.domains');
     } catch(e) {}
 
     addPermissions(domains.split(","));
 
-    // Load webapi.js as a frame script
-    let webapiUrl = 'chrome://browser/content/webapi.js';
-    try {
-      messageManager.loadFrameScript(webapiUrl, true);
-    } catch (e) {
-      dump('shell.js: Error loading ' + webapiUrl + ' as a frame script: ' + e + '\n');
-    }
-
     CustomEventManager.init();
 
     WebappsHelper.init();
 
     // XXX could factor out into a settings->pref map.  Not worth it yet.
     SettingsListener.observe("debug.fps.enabled", false, function(value) {
       Services.prefs.setBoolPref("layers.acceleration.draw-fps", value);
     });
     SettingsListener.observe("debug.paint-flashing.enabled", false, function(value) {
       Services.prefs.setBoolPref("nglayout.debug.paint_flashing", value);
     });
 
-    let browser = this.contentBrowser;
-    browser.homePage = homeURL;
-    browser.goHome();
+    this.contentBrowser.src = homeURL;
   },
 
   stop: function shell_stop() {
     ['keydown', 'keypress', 'keyup'].forEach((function unlistenKey(type) {
       window.removeEventListener(type, this, false, true);
       window.removeEventListener(type, this, true, true);
     }).bind(this));
 
-    window.addEventListener('MozApplicationManifest', this);
     window.removeEventListener('MozApplicationManifest', this);
     window.removeEventListener('mozfullscreenchange', this);
     window.removeEventListener('sizemodechange', this);
-    this.contentBrowser.removeEventListener('load', this, true);
+    this.contentBrowser.removeEventListener('mozbrowserloadstart', this, true);
 
 #ifndef MOZ_WIDGET_GONK
     delete Services.audioManager;
 #endif
   },
  
   changeVolume: function shell_changeVolume(delta) {
     let steps = 10;
@@ -181,25 +189,27 @@ var shell = {
     if (volume > 1)
       volume = 1;
     if (volume < 0)
       volume = 0;
     audioManager.masterVolume = volume;
   },
 
   forwardKeyToContent: function shell_forwardKeyToContent(evt) {
+    let content = shell.contentBrowser.contentWindow;
     let generatedEvent = content.document.createEvent('KeyboardEvent');
     generatedEvent.initKeyEvent(evt.type, true, true, evt.view, evt.ctrlKey,
                                 evt.altKey, evt.shiftKey, evt.metaKey,
                                 evt.keyCode, evt.charCode);
 
     content.document.documentElement.dispatchEvent(generatedEvent);
   },
 
   handleEvent: function shell_handleEvent(evt) {
+    let content = this.contentBrowser.contentWindow;
     switch (evt.type) {
       case 'keydown':
       case 'keyup':
       case 'keypress':
         // For debug purposes and because some of the APIs are not yet exposed
         // to the content, let's react on some of the keyup events.
         if (evt.type == 'keyup' && evt.eventPhase == evt.BUBBLING_PHASE) {
           switch (evt.keyCode) {
@@ -228,23 +238,23 @@ var shell = {
         // When the screen goes fullscreen make sure to set the focus to the
         // main window so noboby can prevent the ESC key to get out fullscreen
         // mode
         if (document.mozFullScreen)
           Services.fm.focusedWindow = window;
         break;
       case 'sizemodechange':
         if (window.windowState == window.STATE_MINIMIZED) {
-          this.contentBrowser.docShell.isActive = false;
+          this.contentBrowser.setVisible(false);
         } else {
-          this.contentBrowser.docShell.isActive = true;
+          this.contentBrowser.setVisible(true);
         }
         break;
-      case 'load':
-        this.contentBrowser.removeEventListener('load', this, true);
+      case 'mozbrowserloadstart':
+        this.contentBrowser.removeEventListener('mozbrowserloadstart', this, true);
 
         let chromeWindow = window.QueryInterface(Ci.nsIDOMChromeWindow);
         chromeWindow.browserDOMWindow = new nsBrowserAccess();
 
         this.sendEvent(window, 'ContentStart');
         break;
       case 'MozApplicationManifest':
         try {
@@ -292,16 +302,17 @@ var shell = {
 function nsBrowserAccess() {
 }
 
 nsBrowserAccess.prototype = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIBrowserDOMWindow]),
 
   openURI: function openURI(uri, opener, where, context) {
     // TODO This should be replaced by an 'open-browser-window' intent
+    let content = shell.contentBrowser.contentWindow;
     let contentWindow = content.wrappedJSObject;
     if (!('getApplicationManager' in contentWindow))
       return null;
 
     let applicationManager = contentWindow.getApplicationManager();
     if (!applicationManager)
       return null;
 
@@ -363,16 +374,17 @@ nsBrowserAccess.prototype = {
   serverSocket.init(serverPort, true, -1);
   dump('Opened socket on ' + serverSocket.port + '\n');
   serverSocket.asyncListen(listener);
 })();
 
 var CustomEventManager = {
   init: function custevt_init() {
     window.addEventListener("ContentStart", (function(evt) {
+      let content = shell.contentBrowser.contentWindow;
       content.addEventListener("mozContentEvent", this, false, true);
     }).bind(this), false);
   },
 
   handleEvent: function custevt_handleEvent(evt) {
     let detail = evt.detail;
     dump('XXX FIXME : Got a mozContentEvent: ' + detail.type);
 
@@ -413,16 +425,17 @@ var AlertsHelper = {
     let id = "alert" + this._count++;
     this._listeners[id] = { observer: alertListener, cookie: cookie };
     return id;
   },
 
   showAlertNotification: function alert_showAlertNotification(imageUrl, title, text, textClickable, 
                                                               cookie, alertListener, name) {
     let id = this.registerListener(cookie, alertListener);
+    let content = shell.contentBrowser.contentWindow;
     shell.sendEvent(content, "mozChromeEvent", { type: "desktop-notification", id: id, icon: imageUrl, 
                                                  title: title, text: text } );
   }
 }
 
 var WebappsHelper = {
   _installers: {},
   _count: 0,
@@ -449,16 +462,17 @@ var WebappsHelper = {
         break;
       case "webapps-install-denied":
         DOMApplicationRegistry.denyInstall(installer);
         break;
     }
   },
 
   observe: function webapps_observe(subject, topic, data) {
+    let content = shell.contentBrowser.contentWindow;
     let json = JSON.parse(data);
     switch(topic) {
       case "webapps-launch":
         DOMApplicationRegistry.getManifestFor(json.origin, function(aManifest) {
           if (!aManifest)
             return;
 
           let manifest = new DOMApplicationManifest(aManifest, json.origin);
@@ -482,17 +496,17 @@ function startDebugger() {
   if (!DebuggerServer.initialized) {
     // Allow remote connections.
     DebuggerServer.init(function () { return true; });
     DebuggerServer.addActors('chrome://browser/content/dbg-browser-actors.js');
   }
 
   let port = Services.prefs.getIntPref('devtools.debugger.remote-port') || 6000;
   try {
-    DebuggerServer.openListener(port, false);
+    DebuggerServer.openListener(port);
   } catch (e) {
     dump('Unable to start debugger server: ' + e + '\n');
   }
 }
 
 window.addEventListener('ContentStart', function(evt) {
   if (Services.prefs.getBoolPref('devtools.debugger.remote-enabled')) {
     startDebugger();
@@ -571,16 +585,17 @@ window.addEventListener('ContentStart', 
 
 // This is the backend for Gaia's screenshot feature.
 // Gaia requests a screenshot by sending a mozContentEvent with
 // detail.type set to 'save-screenshot'.  Then we take a screenshot
 // save it in device storage (external) and send a mozChromeEvent with
 // detail.type set to 'saved-screenshot' and detail.filename set to
 // the filename.
 window.addEventListener('ContentStart', function ss_onContentStart() {
+  let content = shell.contentBrowser.contentWindow;
   content.addEventListener('mozContentEvent', function ss_onMozContentEvent(e) {
     if (e.detail.type !== 'save-screenshot')
       return;
 
     try {
       var canvas = document.createElementNS('http://www.w3.org/1999/xhtml',
                                             'canvas');
       var width = window.innerWidth;
--- a/b2g/chrome/content/shell.xul
+++ b/b2g/chrome/content/shell.xul
@@ -11,20 +11,15 @@
         sizemode="fullscreen"
 #endif
         style="background: black; overflow: hidden; width:320px; height:480px"
         onload="shell.start();"
         onunload="shell.stop();">
 
   <script type="application/javascript" src="chrome://browser/content/settings.js"/>
   <script type="application/javascript" src="chrome://browser/content/shell.js"/>
- 
+
 #ifndef ANDROID
   <!-- this script handles the screen argument for desktop builds -->
   <script type="application/javascript" src="chrome://browser/content/screen.js"/>
 #endif
-  <browser id="homescreen"
-           type="content-primary"
-           flex="1"
-           style="overflow: hidden;"
-           src="data:text/html;charset=utf-8,%3C!DOCTYPE html>%3Cbody style='background:black;'>"/>
+  <!-- The html:iframe containing the UI is created here. -->
 </window>
-
--- a/b2g/chrome/content/touchcontrols.css
+++ b/b2g/chrome/content/touchcontrols.css
@@ -174,8 +174,21 @@
 .timeLabel {
   display: none;
 }
 
 .controlBar[firstshow="true"] .playButton {
   -moz-transform: none;
 }
 
+/* Error description formatting */
+.errorLabel {
+  font-family: Helvetica, Arial, sans-serif;
+  font-size: 11px;
+  color: #bbb;
+  text-shadow:
+    -1px -1px 0 #000,
+    1px -1px 0 #000,
+    -1px 1px 0 #000,
+    1px 1px 0 #000;
+  padding: 0 10px;
+  text-align: center;
+}
new file mode 100644
--- /dev/null
+++ b/b2g/config/mozconfigs/gb_armv7a_gecko/debug
@@ -0,0 +1,18 @@
+mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-b2g
+
+mk_add_options MOZ_MAKE_FLAGS="-j8"
+
+ac_add_options --enable-application=b2g
+
+ac_add_options --target=arm-android-eabi
+ac_add_options --with-gonk="$topsrcdir/gonk-toolchain"
+ac_add_options --with-gonk-toolchain-prefix="$topsrcdir/gonk-toolchain/prebuilt/$TOOLCHAIN_HOST/toolchain/arm-eabi-4.4.3/bin/arm-eabi-"
+ac_add_options --with-endian=little
+ac_add_options --disable-elf-hack
+ac_add_options --enable-debug-symbols
+ac_add_options --enable-debug
+ac_add_options --with-ccache
+ac_add_options --enable-marionette
+
+# Enable dump() from JS.
+export CXXFLAGS=-DMOZ_ENABLE_JS_DUMP
new file mode 100644
--- /dev/null
+++ b/b2g/config/mozconfigs/gb_armv7a_gecko/nightly
@@ -0,0 +1,18 @@
+mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-b2g
+
+mk_add_options MOZ_MAKE_FLAGS="-j8"
+
+ac_add_options --enable-application=b2g
+
+ac_add_options --target=arm-android-eabi
+ac_add_options --with-gonk="$topsrcdir/gonk-toolchain"
+ac_add_options --with-gonk-toolchain-prefix="$topsrcdir/gonk-toolchain/prebuilt/$TOOLCHAIN_HOST/toolchain/arm-eabi-4.4.3/bin/arm-eabi-"
+ac_add_options --with-endian=little
+ac_add_options --disable-elf-hack
+ac_add_options --enable-debug-symbols
+ac_add_options --enable-profiling
+ac_add_options --with-ccache
+ac_add_options --enable-marionette
+
+# Enable dump() from JS.
+export CXXFLAGS=-DMOZ_ENABLE_JS_DUMP
--- a/browser/app/Makefile.in
+++ b/browser/app/Makefile.in
@@ -50,17 +50,17 @@ DEFINES += -DXPCOM_GLUE
 STL_FLAGS=
 
 LIBS += \
 	$(EXTRA_DSO_LIBS) \
 	$(XPCOM_STANDALONE_GLUE_LDOPTS) \
 	$(NULL)
 
 ifdef MOZ_LINKER
-LIBS += $(ZLIB_LIBS)
+LIBS += $(MOZ_ZLIB_LIBS)
 endif
 
 ifndef MOZ_WINCONSOLE
 ifdef MOZ_DEBUG
 MOZ_WINCONSOLE = 1
 else
 MOZ_WINCONSOLE = 0
 endif
--- a/browser/base/content/newtab/cells.js
+++ b/browser/base/content/newtab/cells.js
@@ -93,16 +93,21 @@ Cell.prototype = {
   isEmpty: function Cell_isEmpty() {
     return !this.site;
   },
 
   /**
    * Handles all cell events.
    */
   handleEvent: function Cell_handleEvent(aEvent) {
+    // We're not responding to external drag/drop events 
+    // when our parent window is in private browsing mode.
+    if (inPrivateBrowsingMode && !gDrag.draggedSite)
+      return;
+    
     if (aEvent.type != "dragexit" && !gDrag.isValid(aEvent))
       return;
 
     switch (aEvent.type) {
       case "dragenter":
         aEvent.preventDefault();
         gDrop.enter(this, aEvent);
         break;
--- a/browser/base/content/newtab/newTab.js
+++ b/browser/base/content/newtab/newTab.js
@@ -17,16 +17,29 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 
 let {
   links: gLinks,
   allPages: gAllPages,
   pinnedLinks: gPinnedLinks,
   blockedLinks: gBlockedLinks
 } = NewTabUtils;
 
+let chromeWin = window.QueryInterface(Ci.nsIInterfaceRequestor)
+                      .getInterface(Ci.nsIWebNavigation)
+                      .QueryInterface(Ci.nsIDocShellTreeItem)
+                      .rootTreeItem
+                      .QueryInterface(Ci.nsIInterfaceRequestor)
+                      .getInterface(Ci.nsIDOMWindow)
+                      .wrappedJSObject;
+
+let inPrivateBrowsingMode = false;
+
+if ("gPrivateBrowsingUI" in chromeWin)
+  inPrivateBrowsingMode = chromeWin.gPrivateBrowsingUI.privateWindow;
+
 XPCOMUtils.defineLazyGetter(this, "gStringBundle", function() {
   return Services.strings.
     createBundle("chrome://browser/locale/newTab.properties");
 });
 
 function newTabString(name) gStringBundle.GetStringFromName('newtab.' + name);
 
 const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
--- a/browser/base/content/test/newtab/browser_newtab_private_browsing.js
+++ b/browser/base/content/test/newtab/browser_newtab_private_browsing.js
@@ -34,17 +34,17 @@ function runTests() {
   checkGrid("0,2,3,4,5,6,7,8");
 
   // exit private browsing mode
   yield togglePrivateBrowsing();
   ok(!pb.privateBrowsingEnabled, "private browsing is disabled");
 
   // check that the grid is the same as before entering pb mode
   yield addNewTabPageTab();
-  checkGrid("0p,1,2,3,4,5,6,7,8");
+  checkGrid("0,2,3,4,5,6,7,8")
 }
 
 function togglePrivateBrowsing() {
   let topic = "private-browsing-transition-complete";
 
   Services.obs.addObserver(function observe() {
     Services.obs.removeObserver(observe, topic);
     executeSoon(TestRunner.next);
--- a/browser/components/preferences/connection.js
+++ b/browser/components/preferences/connection.js
@@ -22,25 +22,18 @@ var gConnectionsDialog = {
       var proxyPrefs = ["ssl", "ftp", "socks"];
       for (var i = 0; i < proxyPrefs.length; ++i) {
         var proxyServerURLPref = document.getElementById("network.proxy." + proxyPrefs[i]);
         var proxyPortPref = document.getElementById("network.proxy." + proxyPrefs[i] + "_port");
         var backupServerURLPref = document.getElementById("network.proxy.backup." + proxyPrefs[i]);
         var backupPortPref = document.getElementById("network.proxy.backup." + proxyPrefs[i] + "_port");
         backupServerURLPref.value = proxyServerURLPref.value;
         backupPortPref.value = proxyPortPref.value;
-        // SOCKS: not a protocol: set value to empty/0 while shareProxies is on
-        if (proxyPrefs[i] == "socks") {
-          proxyServerURLPref.value = "";
-          proxyPortPref.value = 0;
-        } else {
-          // protocols get HTTP proxy's values 
-          proxyServerURLPref.value = httpProxyURLPref.value;
-          proxyPortPref.value = httpProxyPortPref.value;
-        }
+        proxyServerURLPref.value = httpProxyURLPref.value;
+        proxyPortPref.value = httpProxyPortPref.value;
       }
     }
     
     this.sanitizeNoProxiesPref();
     
     return true;
   },
 
@@ -136,20 +129,16 @@ var gConnectionsDialog = {
     
     return undefined;
   },
   
   readProxyProtocolPref: function (aProtocol, aIsPort)
   {
     var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
     if (shareProxiesPref.value) {
-      // during shareProxiesPref SOCKS values are empty
-      if (aProtocol == 'socks') {
-        return aIsPort ? 0 : "";
-      }
       var pref = document.getElementById("network.proxy.http" + (aIsPort ? "_port" : ""));    
       return pref.value;
     }
     
     var backupPref = document.getElementById("network.proxy.backup." + aProtocol + (aIsPort ? "_port" : ""));
     return backupPref.hasUserValue ? backupPref.value : undefined;
   },
 
--- a/browser/devtools/debugger/DebuggerUI.jsm
+++ b/browser/devtools/debugger/DebuggerUI.jsm
@@ -17,48 +17,66 @@ const TAB_SWITCH_NOTIFICATION = "debugge
 Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/FileUtils.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 let EXPORTED_SYMBOLS = ["DebuggerUI"];
 
 /**
- * Provides a simple mechanism of managing debugger instances per tab.
+ * Provides a simple mechanism of managing debugger instances.
  *
  * @param nsIDOMWindow aWindow
  *        The chrome window for which the DebuggerUI instance is created.
  */
 function DebuggerUI(aWindow) {
   this.chromeWindow = aWindow;
+  this.listenToTabs();
 }
 
 DebuggerUI.prototype = {
+  /**
+   * Update the status of tool's menuitems and buttons when
+   * the user switch tabs.
+   */
+  listenToTabs: function DUI_listenToTabs() {
+    let win = this.chromeWindow;
+    let tabs = win.gBrowser.tabContainer;
+
+    let bound_refreshCommand = this.refreshCommand.bind(this);
+    tabs.addEventListener("TabSelect", bound_refreshCommand, true);
+
+    win.addEventListener("unload", function onClose(aEvent) {
+      tabs.removeEventListener("TabSelect", bound_refreshCommand, true);
+      win.removeEventListener("unload", onClose, false);
+    }, false);
+  },
 
   /**
    * Called by the DebuggerPane to update the Debugger toggle switches with the
    * debugger state.
    */
   refreshCommand: function DUI_refreshCommand() {
-    let selectedTab = this.chromeWindow.getBrowser().selectedTab;
+    let scriptDebugger = this.getDebugger();
     let command = this.chromeWindow.document.getElementById("Tools:Debugger");
+    let selectedTab = this.chromeWindow.gBrowser.selectedTab;
 
-    if (this.getDebugger()) {
+    if (scriptDebugger && scriptDebugger.ownerTab === selectedTab) {
       command.setAttribute("checked", "true");
     } else {
-      command.removeAttribute("checked");
+      command.setAttribute("checked", "false");
     }
   },
 
   /**
    * Starts a debugger for the current tab, or stops it if already started.
    * @return DebuggerPane if the debugger is started, null if it's stopped.
    */
   toggleDebugger: function DUI_toggleDebugger() {
-    let scriptDebugger = this.getDebugger();
+    let scriptDebugger = this.findDebugger();
     let selectedTab = this.chromeWindow.gBrowser.selectedTab;
 
     if (scriptDebugger) {
       if (scriptDebugger.ownerTab !== selectedTab) {
         this.showTabSwitchNotification();
         return scriptDebugger;
       }
       scriptDebugger.close();
@@ -87,44 +105,65 @@ DebuggerUI.prototype = {
    */
   toggleChromeDebugger: function DUI_toggleChromeDebugger(aOnClose, aOnRun) {
     let chromeDebugger = this.getChromeDebugger();
 
     if (chromeDebugger) {
       chromeDebugger.close();
       return null;
     }
-    return new ChromeDebuggerProcess(this.chromeWindow, aOnClose, aOnRun, true);
+    return new ChromeDebuggerProcess(this, aOnClose, aOnRun);
+  },
+
+  /**
+   * Gets the script debugger in any open window.
+   *
+   * @return DebuggerPane | null
+   *         The script debugger instance if it exists, null otherwise.
+   */
+  findDebugger: function DUI_findDebugger() {
+    let enumerator = Services.wm.getEnumerator("navigator:browser");
+    while (enumerator.hasMoreElements()) {
+      let chromeWindow = enumerator.getNext().QueryInterface(Ci.nsIDOMWindow);
+      let scriptDebugger = chromeWindow.DebuggerUI.getDebugger();
+      if (scriptDebugger) {
+        return scriptDebugger;
+      }
+    }
+    return null;
   },
 
   /**
    * Get the current script debugger.
-   * @return DebuggerPane if a debugger exists for the tab, null otherwise.
+   *
+   * @return DebuggerPane | null
+   *         The script debugger instance if it exists, null otherwise.
    */
   getDebugger: function DUI_getDebugger() {
-    let win = this.chromeWindow;
-    return '_scriptDebugger' in win ? win._scriptDebugger : null;
+    return '_scriptDebugger' in this ? this._scriptDebugger : null;
   },
 
   /**
    * Get the remote debugger for the current chrome window.
-   * @return RemoteDebuggerWindow if a remote debugger exists, null otherwise.
+   *
+   * @return RemoteDebuggerWindow | null
+   *         The remote debugger instance if it exists, null otherwise.
    */
   getRemoteDebugger: function DUI_getRemoteDebugger() {
-    let win = this.chromeWindow;
-    return '_remoteDebugger' in win ? win._remoteDebugger : null;
+    return '_remoteDebugger' in this ? this._remoteDebugger : null;
   },
 
   /**
    * Get the chrome debugger for the current firefox instance.
-   * @return ChromeDebuggerProcess if a chrome debugger exists, null otherwise.
+   *
+   * @return ChromeDebuggerProcess | null
+   *         The chrome debugger instance if it exists, null otherwise.
    */
   getChromeDebugger: function DUI_getChromeDebugger() {
-    let win = this.chromeWindow;
-    return '_chromeDebugger' in win ? win._chromeDebugger : null;
+    return '_chromeDebugger' in this ? this._chromeDebugger : null;
   },
 
   /**
    * Get the preferences associated with the debugger frontend.
    * @return object
    */
   get preferences() {
     return DebuggerPreferences;
@@ -147,24 +186,27 @@ DebuggerUI.prototype = {
       return;
     }
 
     let buttons = [{
       id: "debugger.confirmTabSwitch.buttonSwitch",
       label: L10N.getStr("confirmTabSwitch.buttonSwitch"),
       accessKey: L10N.getStr("confirmTabSwitch.buttonSwitch.accessKey"),
       callback: function DUI_notificationButtonSwitch() {
-        gBrowser.selectedTab = this.getDebugger().ownerTab;
+        let scriptDebugger = this.findDebugger();
+        let targetWindow = scriptDebugger.globalUI.chromeWindow;
+        targetWindow.gBrowser.selectedTab = scriptDebugger.ownerTab;
+        targetWindow.focus();
       }.bind(this)
     }, {
       id: "debugger.confirmTabSwitch.buttonOpen",
       label: L10N.getStr("confirmTabSwitch.buttonOpen"),
       accessKey: L10N.getStr("confirmTabSwitch.buttonOpen.accessKey"),
       callback: function DUI_notificationButtonOpen() {
-        this.getDebugger().close();
+        this.findDebugger().close();
         this.toggleDebugger();
       }.bind(this)
     }];
 
     let message = L10N.getStr("confirmTabSwitch.message");
     let imageURL = "chrome://browser/skin/Info.png";
 
     notification = nbox.appendNotification(
@@ -181,17 +223,17 @@ DebuggerUI.prototype = {
  * Creates a pane that will host the debugger.
  *
  * @param DebuggerUI aDebuggerUI
  *        The parent instance creating the new debugger.
  * @param XULElement aTab
  *        The tab in which to create the debugger.
  */
 function DebuggerPane(aDebuggerUI, aTab) {
-  this._globalUI = aDebuggerUI;
+  this.globalUI = aDebuggerUI;
   this._win = aDebuggerUI.chromeWindow;
   this._tab = aTab;
 
   this._initServer();
   this._create();
 }
 
 DebuggerPane.prototype = {
@@ -206,17 +248,17 @@ DebuggerPane.prototype = {
       DebuggerServer.addBrowserActors();
     }
   },
 
   /**
    * Creates and initializes the widgets containing the debugger UI.
    */
   _create: function DP__create() {
-    this._win._scriptDebugger = this;
+    this.globalUI._scriptDebugger = this;
 
     let gBrowser = this._win.gBrowser;
     let ownerDocument = gBrowser.parentNode.ownerDocument;
 
     this._splitter = ownerDocument.createElement("splitter");
     this._splitter.setAttribute("class", "devtools-horizontal-splitter");
 
     this._frame = ownerDocument.createElement("iframe");
@@ -237,31 +279,31 @@ DebuggerPane.prototype = {
       // Bind shortcuts for accessing the breakpoint methods in the debugger.
       let bkp = self.contentWindow.DebuggerController.Breakpoints;
       self.addBreakpoint = bkp.addBreakpoint;
       self.removeBreakpoint = bkp.removeBreakpoint;
       self.getBreakpoint = bkp.getBreakpoint;
     }, true);
 
     this._frame.setAttribute("src", DBG_XUL);
-    this._globalUI.refreshCommand();
+    this.globalUI.refreshCommand();
   },
 
   /**
    * Closes the debugger, removing child nodes and event listeners.
    *
    * @param function aCloseCallback
    *        Clients can pass a close callback to be notified when
    *        the panel successfully closes.
    */
   close: function DP_close(aCloseCallback) {
-    if (!this._win) {
+    if (!this.globalUI) {
       return;
     }
-    delete this._win._scriptDebugger;
+    delete this.globalUI._scriptDebugger;
     this._win = null;
     this._tab = null;
 
     DebuggerPreferences.height = this._frame.height;
     this._frame.removeEventListener("Debugger:Close", this.close, true);
     this._frame.removeEventListener("unload", this.close, true);
 
     // This method is also used as an event handler, so only
@@ -276,17 +318,18 @@ DebuggerPane.prototype = {
 
     this._nbox.removeChild(this._splitter);
     this._nbox.removeChild(this._frame);
 
     this._splitter = null;
     this._frame = null;
     this._nbox = null;
 
-    this._globalUI.refreshCommand();
+    this.globalUI.refreshCommand();
+    this.globalUI = null;
   },
 
   /**
    * Gets the tab owning this debugger instance.
    * @return XULElement
    */
   get ownerTab() {
     return this._tab;
@@ -315,31 +358,31 @@ DebuggerPane.prototype = {
 
 /**
  * Creates a window that will host a remote debugger.
  *
  * @param DebuggerUI aDebuggerUI
  *        The parent instance creating the new debugger.
  */
 function RemoteDebuggerWindow(aDebuggerUI) {
-  this._globalUI = aDebuggerUI;
+  this.globalUI = aDebuggerUI;
   this._win = aDebuggerUI.chromeWindow;
 
   this._create();
 }
 
 RemoteDebuggerWindow.prototype = {
 
   /**
    * Creates and initializes the widgets containing the remote debugger UI.
    */
   _create: function DP__create() {
-    this._win._remoteDebugger = this;
+    this.globalUI._remoteDebugger = this;
 
-    this._dbgwin = this._globalUI.chromeWindow.open(DBG_XUL,
+    this._dbgwin = this.globalUI.chromeWindow.open(DBG_XUL,
       L10N.getStr("remoteDebuggerWindowTitle"),
       "width=" + DebuggerPreferences.remoteWinWidth + "," +
       "height=" + DebuggerPreferences.remoteWinHeight + "," +
       "chrome,dependent,resizable,centerscreen");
 
     this._dbgwin._remoteFlag = true;
 
     this.close = this.close.bind(this);
@@ -357,20 +400,21 @@ RemoteDebuggerWindow.prototype = {
       self.getBreakpoint = bkp.getBreakpoint;
     }, true);
   },
 
   /**
    * Closes the remote debugger, along with the parent window if necessary.
    */
   close: function DP_close() {
-    if (!this._win) {
+    if (!this.globalUI) {
       return;
     }
-    delete this._win._remoteDebugger;
+    delete this.globalUI._remoteDebugger;
+    this.globalUI = null;
     this._win = null;
 
     this._dbgwin.close();
     this._dbgwin = null;
   },
 
   /**
    * Gets the remote debugger content window.
@@ -391,25 +435,26 @@ RemoteDebuggerWindow.prototype = {
     }
     return null;
   }
 };
 
 /**
  * Creates a process that will hold a chrome debugger.
  *
+ * @param DebuggerUI aDebuggerUI
+ *        The parent instance creating the new debugger.
  * @param function aOnClose
  *        Optional, a function called when the process exits.
  * @param function aOnRun
  *        Optional, a function called when the process starts running.
- * @param nsIDOMWindow aWindow
- *        The chrome window for which the debugger instance is created.
  */
-function ChromeDebuggerProcess(aWindow, aOnClose, aOnRun) {
-  this._win = aWindow;
+function ChromeDebuggerProcess(aDebuggerUI, aOnClose, aOnRun) {
+  this.globalUI = aDebuggerUI;
+  this._win = aDebuggerUI.chromeWindow;
   this._closeCallback = aOnClose;
   this._runCallback = aOnRun;
 
   this._initServer();
   this._initProfile();
   this._create();
 }
 
@@ -419,17 +464,17 @@ ChromeDebuggerProcess.prototype = {
    * Initializes the debugger server.
    */
   _initServer: function RDP__initServer() {
     if (!DebuggerServer.initialized) {
       DebuggerServer.init(this._allowConnection);
       DebuggerServer.addBrowserActors();
     }
     DebuggerServer.closeListener();
-    DebuggerServer.openListener(DebuggerPreferences.remotePort, false);
+    DebuggerServer.openListener(DebuggerPreferences.remotePort);
   },
 
   /**
    * Prompt the user to accept or decline the incoming connection.
    *
    * @return true if the connection should be permitted, false otherwise
    */
   _allowConnection: function RDP__allowConnection() {
@@ -471,17 +516,17 @@ ChromeDebuggerProcess.prototype = {
     this._dbgProfile = profileService.createProfile(null, null, dbgProfileName);
     profileService.flush();
   },
 
   /**
    * Creates and initializes the profile & process for the remote debugger.
    */
   _create: function RDP__create() {
-    this._win._chromeDebugger = this;
+    this.globalUI._chromeDebugger = this;
 
     let file = FileUtils.getFile("CurProcD",
       [Services.appinfo.OS == "WINNT" ? "firefox.exe"
                                       : "firefox-bin"]);
 
     let process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
     process.init(file);
 
@@ -498,20 +543,21 @@ ChromeDebuggerProcess.prototype = {
       this._runCallback.call({}, this);
     }
   },
 
   /**
    * Closes the remote debugger, removing the profile and killing the process.
    */
   close: function RDP_close() {
-    if (!this._win) {
+    if (!this.globalUI) {
       return;
     }
-    delete this._win._chromeDebugger;
+    delete this.globalUI._chromeDebugger;
+    this.globalUI = null;
     this._win = null;
 
     if (this._dbgProcess.isRunning) {
       this._dbgProcess.kill();
     }
     if (this._dbgProfile) {
       this._dbgProfile.remove(false);
     }
--- a/browser/devtools/debugger/debugger-view.js
+++ b/browser/devtools/debugger/debugger-view.js
@@ -131,16 +131,17 @@ RemoteDebuggerPrompt.prototype = {
 };
 
 /**
  * Functions handling the scripts UI.
  */
 function ScriptsView() {
   this._onScriptsChange = this._onScriptsChange.bind(this);
   this._onScriptsSearch = this._onScriptsSearch.bind(this);
+  this._onScriptsKeyUp = this._onScriptsKeyUp.bind(this);
 }
 
 ScriptsView.prototype = {
 
   /**
    * Removes all elements from the scripts container, leaving it empty.
    */
   empty: function DVS_empty() {
@@ -383,57 +384,69 @@ ScriptsView.prototype = {
     scriptItem.setUserData("sourceScript", aScript, null);
 
     if (this._scripts.itemCount == 1 && aSelectIfEmptyFlag) {
       this._scripts.selectedItem = scriptItem;
     }
   },
 
   /**
+   * Gets the entered file, line and token entered in the searchbox.
+   *
+   * @return array
+   *         A [file, line, token] array.
+   */
+  _getSearchboxInfo: function DVS__getSearchboxInfo() {
+    let rawValue = this._searchbox.value.toLowerCase();
+
+    let rawLength = rawValue.length;
+    let lastColon = rawValue.lastIndexOf(":");
+    let lastAt = rawValue.lastIndexOf("#");
+
+    let fileEnd = lastColon != -1 ? lastColon : lastAt != -1 ? lastAt : rawLength;
+    let lineEnd = lastAt != -1 ? lastAt : rawLength;
+
+    let file = rawValue.slice(0, fileEnd);
+    let line = window.parseInt(rawValue.slice(fileEnd + 1, lineEnd)) || -1;
+    let token = rawValue.slice(lineEnd + 1);
+
+    return [file, line, token];
+  },
+
+  /**
    * The click listener for the scripts container.
    */
   _onScriptsChange: function DVS__onScriptsChange() {
     let script = this._scripts.selectedItem.getUserData("sourceScript");
     this._preferredScript = script;
     DebuggerController.SourceScripts.showScript(script);
   },
 
   /**
    * The search listener for the scripts search box.
    */
   _onScriptsSearch: function DVS__onScriptsSearch(e) {
     let editor = DebuggerView.editor;
     let scripts = this._scripts;
-    let rawValue = this._searchbox.value.toLowerCase();
-
-    let rawLength = rawValue.length;
-    let lastColon = rawValue.lastIndexOf(":");
-    let lastAt = rawValue.lastIndexOf("#");
-
-    let fileEnd = lastColon != -1 ? lastColon : lastAt != -1 ? lastAt : rawLength;
-    let lineEnd = lastAt != -1 ? lastAt : rawLength;
-
-    let file = rawValue.slice(0, fileEnd);
-    let line = window.parseInt(rawValue.slice(fileEnd + 1, lineEnd)) || -1;
-    let token = rawValue.slice(lineEnd + 1);
+    let [file, line, token] = this._getSearchboxInfo();
 
     // Presume we won't find anything.
     scripts.selectedItem = this._preferredScript;
 
     // If we're not searching for a file anymore, unhide all the scripts.
     if (!file) {
       for (let i = 0, l = scripts.itemCount; i < l; i++) {
         scripts.getItemAtIndex(i).hidden = false;
       }
     } else {
       for (let i = 0, l = scripts.itemCount, found = false; i < l; i++) {
         let item = scripts.getItemAtIndex(i);
-        let target = item.value.toLowerCase();
+        let target = item.label.toLowerCase();
 
-        // Search is not case sensitive, and is tied to the url not the label.
+        // Search is not case sensitive, and is tied to the label not the url.
         if (target.match(file)) {
           item.hidden = false;
 
           if (!found) {
             found = true;
             scripts.selectedItem = item;
           }
         }
@@ -444,37 +457,36 @@ ScriptsView.prototype = {
       }
     }
     if (line > -1) {
       editor.setCaretPosition(line - 1);
     }
     if (token) {
       let offset = editor.find(token, { ignoreCase: true });
       if (offset > -1) {
-        editor.setCaretPosition(0);
-        editor.setCaretOffset(offset);
+        editor.setSelection(offset, offset + token.length)
       }
     }
   },
 
   /**
    * The keyup listener for the scripts search box.
    */
   _onScriptsKeyUp: function DVS__onScriptsKeyUp(e) {
     if (e.keyCode === e.DOM_VK_ESCAPE) {
       DebuggerView.editor.focus();
       return;
     }
 
     if (e.keyCode === e.DOM_VK_RETURN || e.keyCode === e.DOM_VK_ENTER) {
+      let token = this._getSearchboxInfo()[2];
       let editor = DebuggerView.editor;
       let offset = editor.findNext(true);
       if (offset > -1) {
-        editor.setCaretPosition(0);
-        editor.setCaretOffset(offset);
+        editor.setSelection(offset, offset + token.length)
       }
     }
   },
 
   /**
    * The cached scripts container and search box.
    */
   _scripts: null,
--- a/browser/devtools/debugger/test/Makefile.in
+++ b/browser/devtools/debugger/test/Makefile.in
@@ -10,16 +10,17 @@ relativesrcdir  = browser/devtools/debug
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _BROWSER_TEST_FILES = \
 	browser_dbg_createRemote.js \
 	browser_dbg_createChrome.js \
 	browser_dbg_debugger-tab-switch.js \
+	browser_dbg_debugger-tab-switch-window.js \
 	browser_dbg_debuggerstatement.js \
 	browser_dbg_listtabs.js \
 	browser_dbg_tabactor-01.js \
 	browser_dbg_tabactor-02.js \
 	browser_dbg_contextactor-01.js \
 	browser_dbg_contextactor-02.js \
 	testactors.js \
 	browser_dbg_nav-01.js \
@@ -50,16 +51,18 @@ include $(topsrcdir)/config/rules.mk
 	browser_dbg_update-editor-mode.js \
 	$(warning browser_dbg_select-line.js temporarily disabled due to oranges, see bug 726609) \
 	browser_dbg_clean-exit.js \
 	browser_dbg_bug723069_editor-breakpoints.js \
 	browser_dbg_bug731394_editor-contextmenu.js \
 	browser_dbg_displayName.js \
 	browser_dbg_iframes.js \
 	browser_dbg_pause-exceptions.js \
+	browser_dbg_multiple-windows.js \
+	browser_dbg_menustatus.js \
 	head.js \
 	$(NULL)
 
 _BROWSER_TEST_PAGES = \
 	browser_dbg_tab1.html \
 	browser_dbg_tab2.html \
 	browser_dbg_debuggerstatement.html \
 	browser_dbg_stack.html \
new file mode 100644
--- /dev/null
+++ b/browser/devtools/debugger/test/browser_dbg_debugger-tab-switch-window.js
@@ -0,0 +1,244 @@
+/* vim:set ts=2 sw=2 sts=2 et: */
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+let gInitialTab, gTab1, gTab2, gTab3, gTab4;
+let gInitialWindow, gSecondWindow;
+let gPane1, gPane2;
+let gNbox;
+
+/**
+ * Tests that a debugger instance can't be opened in multiple windows at once,
+ * and that on such an attempt a notification is shown, which can either switch
+ * to the old debugger instance, or close the old instance to open a new one.
+ */
+
+function test() {
+  gInitialWindow = window;
+  gInitialTab = window.gBrowser.selectedTab;
+  gNbox = gInitialWindow.gBrowser.getNotificationBox(gInitialWindow.gBrowser.selectedBrowser);
+
+  testTab1_initialWindow(function() {
+    testTab2_secondWindow(function() {
+      testTab3_secondWindow(function() {
+        testTab4_secondWindow(function() {
+          lastTest(function() {
+            cleanup(function() {
+              finish();
+            });
+          });
+        });
+      });
+    });
+  });
+}
+
+function testTab1_initialWindow(callback) {
+  gTab1 = addTab(TAB1_URL, function() {
+    gInitialWindow.gBrowser.selectedTab = gTab1;
+    gNbox = gInitialWindow.gBrowser.getNotificationBox(gInitialWindow.gBrowser.selectedBrowser);
+
+    is(gNbox.getNotificationWithValue("debugger-tab-switch"), null,
+      "Shouldn't have a tab switch notification.");
+    ok(!gInitialWindow.DebuggerUI.getDebugger(),
+      "Shouldn't have a debugger pane for this tab yet.");
+
+    info("Toggling a debugger (1).");
+
+    gPane1 = gInitialWindow.DebuggerUI.toggleDebugger();
+    ok(gPane1, "toggleDebugger() should return a pane.");
+    is(gPane1.ownerTab, gTab1, "Incorrect tab owner.");
+
+    is(gInitialWindow.DebuggerUI.getDebugger(), gPane1,
+      "getDebugger() should return the same pane as toggleDebugger().");
+
+    wait_for_connect_and_resume(function dbgLoaded() {
+      info("First debugger has finished loading correctly.");
+      executeSoon(function() {
+        callback();
+      });
+    }, gInitialWindow);
+  }, gInitialWindow);
+}
+
+function testTab2_secondWindow(callback) {
+  gSecondWindow = addWindow();
+
+  gTab2 = addTab(TAB1_URL, function() {
+    gSecondWindow.gBrowser.selectedTab = gTab2;
+    gNbox = gSecondWindow.gBrowser.getNotificationBox(gSecondWindow.gBrowser.selectedBrowser);
+
+    is(gNbox.getNotificationWithValue("debugger-tab-switch"), null,
+      "Shouldn't have a tab switch notification yet.");
+    ok(gSecondWindow.DebuggerUI.findDebugger(),
+      "Should already have a debugger pane for another tab.");
+
+    gNbox.addEventListener("AlertActive", function active() {
+      gNbox.removeEventListener("AlertActive", active, true);
+      executeSoon(function() {
+        ok(gPane2, "toggleDebugger() should always return a pane.");
+        is(gPane2.ownerTab, gTab1, "Incorrect tab owner.");
+
+        is(gSecondWindow.DebuggerUI.findDebugger(), gPane1,
+          "findDebugger() should return the same pane as the first call to toggleDebugger().");
+        is(gSecondWindow.DebuggerUI.findDebugger(), gPane2,
+          "findDebugger() should return the same pane as the second call to toggleDebugger().");
+
+        info("Second debugger has not loaded.");
+
+        let notification = gNbox.getNotificationWithValue("debugger-tab-switch");
+        ok(gNbox.currentNotification, "Should have a tab switch notification.");
+        is(gNbox.currentNotification, notification, "Incorrect current notification.");
+
+        info("Notification will be simply closed.");
+        notification.close();
+
+        executeSoon(function() {
+          callback();
+        });
+      });
+    }, true);
+
+    info("Toggling a debugger (2).");
+
+    gPane2 = gSecondWindow.DebuggerUI.toggleDebugger();
+  }, gSecondWindow);
+}
+
+function testTab3_secondWindow(callback) {
+  gTab3 = addTab(TAB1_URL, function() {
+    gSecondWindow.gBrowser.selectedTab = gTab3;
+    gNbox = gSecondWindow.gBrowser.getNotificationBox(gSecondWindow.gBrowser.selectedBrowser);
+
+    is(gNbox.getNotificationWithValue("debugger-tab-switch"), null,
+      "Shouldn't have a tab switch notification.");
+    ok(gSecondWindow.DebuggerUI.findDebugger(),
+      "Should already have a debugger pane for another tab.");
+
+    gNbox.addEventListener("AlertActive", function active() {
+      gNbox.removeEventListener("AlertActive", active, true);
+      executeSoon(function() {
+        ok(gPane2, "toggleDebugger() should always return a pane.");
+        is(gPane2.ownerTab, gTab1, "Incorrect tab owner.");
+
+        is(gSecondWindow.DebuggerUI.findDebugger(), gPane1,
+          "findDebugger() should return the same pane as the first call to toggleDebugger().");
+        is(gSecondWindow.DebuggerUI.findDebugger(), gPane2,
+          "findDebugger() should return the same pane as the second call to toggleDebugger().");
+
+        info("Second debugger has not loaded.");
+
+        let notification = gNbox.getNotificationWithValue("debugger-tab-switch");
+        ok(gNbox.currentNotification, "Should have a tab switch notification.");
+        is(gNbox.currentNotification, notification, "Incorrect current notification.");
+
+        gInitialWindow.gBrowser.selectedTab = gInitialTab;
+        gInitialWindow.gBrowser.tabContainer.addEventListener("TabSelect", function tabSelect() {
+          gInitialWindow.gBrowser.tabContainer.removeEventListener("TabSelect", tabSelect, true);
+          executeSoon(function() {
+            callback();
+          });
+        }, true);
+
+        let buttonSwitch = notification.querySelectorAll("button")[0];
+        buttonSwitch.focus();
+        EventUtils.sendKey("SPACE", gSecondWindow);
+        info("The switch button on the notification was pressed.");
+      });
+    }, true);
+
+    info("Toggling a debugger (3).");
+
+    gPane2 = gSecondWindow.DebuggerUI.toggleDebugger();
+  }, gSecondWindow);
+}
+
+function testTab4_secondWindow(callback) {
+  is(gInitialWindow.gBrowser.selectedTab, gTab1,
+    "Should've switched to the first debugged tab.");
+
+  gTab4 = addTab(TAB1_URL, function() {
+    gSecondWindow.gBrowser.selectedTab = gTab4;
+    gNbox = gSecondWindow.gBrowser.getNotificationBox(gSecondWindow.gBrowser.selectedBrowser);
+
+    is(gNbox.getNotificationWithValue("debugger-tab-switch"), null,
+      "Shouldn't have a tab switch notification.");
+    ok(gSecondWindow.DebuggerUI.findDebugger(),
+      "Should already have a debugger pane for another tab.");
+
+    gNbox.addEventListener("AlertActive", function active() {
+      gNbox.removeEventListener("AlertActive", active, true);
+      executeSoon(function() {
+        ok(gPane2, "toggleDebugger() should always return a pane.");
+        is(gPane2.ownerTab, gTab1, "Incorrect tab owner.");
+
+        is(gSecondWindow.DebuggerUI.findDebugger(), gPane1,
+          "findDebugger() should return the same pane as the first call to toggleDebugger().");
+        is(gSecondWindow.DebuggerUI.findDebugger(), gPane2,
+          "findDebugger() should return the same pane as the second call to toggleDebugger().");
+
+        info("Second debugger has not loaded.");
+
+        let notification = gNbox.getNotificationWithValue("debugger-tab-switch");
+        ok(gNbox.currentNotification, "Should have a tab switch notification.");
+        is(gNbox.currentNotification, notification, "Incorrect current notification.");
+
+        let buttonOpen = notification.querySelectorAll("button")[1];
+        buttonOpen.focus();
+        EventUtils.sendKey("SPACE", gSecondWindow);
+        info("The open button on the notification was pressed.");
+
+        wait_for_connect_and_resume(function() {
+          callback();
+        }, gSecondWindow);
+      });
+    }, true);
+
+    info("Toggling a debugger (4).");
+
+    gPane2 = gSecondWindow.DebuggerUI.toggleDebugger();
+  }, gSecondWindow);
+}
+
+function lastTest(callback) {
+  is(gInitialWindow.gBrowser.selectedTab, gTab1,
+    "The initial window should continue having selected the first debugged tab.");
+  is(gSecondWindow.gBrowser.selectedTab, gTab4,
+    "Should currently be in the fourth tab.");
+  is(gSecondWindow.DebuggerUI.findDebugger().ownerTab, gTab4,
+    "The debugger should be open for the fourth tab.");
+
+  is(gNbox.getNotificationWithValue("debugger-tab-switch"), null,
+    "Shouldn't have a tab switch notification.");
+
+  info("Second debugger has loaded.");
+
+  executeSoon(function() {
+    callback();
+  });
+}
+
+function cleanup(callback)
+{
+  gPane1 = null;
+  gPane2 = null;
+  gNbox = null;
+
+  closeDebuggerAndFinish(false, function() {
+    removeTab(gTab1, gInitialWindow);
+    removeTab(gTab2, gSecondWindow);
+    removeTab(gTab3, gSecondWindow);
+    removeTab(gTab4, gSecondWindow);
+    gSecondWindow.close();
+    gTab1 = null;
+    gTab2 = null;
+    gTab3 = null;
+    gTab4 = null;
+    gInitialWindow = null;
+    gSecondWindow = null;
+
+    callback();
+  }, gSecondWindow);
+}
--- a/browser/devtools/debugger/test/browser_dbg_debugger-tab-switch.js
+++ b/browser/devtools/debugger/test/browser_dbg_debugger-tab-switch.js
@@ -3,16 +3,22 @@
  * Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 let gTab1, gTab2, gTab3, gTab4;
 let gPane1, gPane2;
 let gNbox;
 
+/**
+ * Tests that a debugger instance can't be opened in multiple tabs at once,
+ * and that on such an attempt a notification is shown, which can either switch
+ * to the old debugger instance, or close the old instance to open a new one.
+ */
+
 function test() {
   gNbox = gBrowser.getNotificationBox(gBrowser.selectedBrowser);
 
   testTab1(function() {
     testTab2(function() {
       testTab3(function() {
         testTab4(function() {
           lastTest(function() {
@@ -45,17 +51,17 @@ function testTab1(callback) {
     is(DebuggerUI.getDebugger(), gPane1,
       "getDebugger() should return the same pane as toggleDebugger().");
 
     wait_for_connect_and_resume(function dbgLoaded() {
       info("First debugger has finished loading correctly.");
       executeSoon(function() {
         callback();
       });
-    }, true);
+    });
   });
 }
 
 function testTab2(callback) {
   gTab2 = addTab(TAB1_URL, function() {
     gBrowser.selectedTab = gTab2;
     gNbox = gBrowser.getNotificationBox(gBrowser.selectedBrowser);
 
@@ -203,18 +209,18 @@ function lastTest(callback) {
 
   info("Second debugger has loaded.");
 
   executeSoon(function() {
     callback();
   });
 }
 
-function cleanup(callback) {
-
+function cleanup(callback)
+{
   gPane1 = null;
   gPane2 = null;
   gNbox = null;
 
   closeDebuggerAndFinish(false, function() {
     removeTab(gTab1);
     removeTab(gTab2);
     removeTab(gTab3);
new file mode 100644
--- /dev/null
+++ b/browser/devtools/debugger/test/browser_dbg_menustatus.js
@@ -0,0 +1,48 @@
+/* vim:set ts=2 sw=2 sts=2 et: */
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// We make sure the menuitems in the application menubar
+// are checked.
+
+function test() {
+  var tab1 = addTab("about:blank", function() {
+    var tab2 = addTab("about:blank", function() {
+      gBrowser.selectedTab = tab2;
+
+      let pane = DebuggerUI.toggleDebugger();
+      ok(pane, "toggleDebugger() should return a pane.");
+      let frame = pane._frame;
+
+      frame.addEventListener("Debugger:Loaded", function dbgLoaded() {
+        frame.removeEventListener("Debugger:Loaded", dbgLoaded, true);
+
+        let cmd = document.getElementById("Tools:Debugger");
+        is(cmd.getAttribute("checked"), "true", "<command Tools:Debugger> is checked.");
+
+        gBrowser.selectedTab = tab1;
+
+        is(cmd.getAttribute("checked"), "false", "<command Tools:Debugger> is unchecked after tab switch.");
+
+        gBrowser.selectedTab = tab2;
+
+        is(cmd.getAttribute("checked"), "true", "<command Tools:Debugger> is checked.");
+
+        let pane = DebuggerUI.toggleDebugger();
+
+        is(cmd.getAttribute("checked"), "false", "<command Tools:Debugger> is unchecked once closed.");
+      }, true);
+
+      frame.addEventListener("Debugger:Unloaded", function dbgUnloaded() {
+        frame.removeEventListener("Debugger:Unloaded", dbgUnloaded, true);
+          removeTab(tab1);
+          removeTab(tab2);
+
+          finish();
+      }, true);
+    });
+  });
+}
+
new file mode 100644
--- /dev/null
+++ b/browser/devtools/debugger/test/browser_dbg_multiple-windows.js
@@ -0,0 +1,115 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Make sure that the debugger attaches to the right tab when multiple windows
+// are open.
+
+var gTab1 = null;
+var gTab1Actor = null;
+
+var gSecondWindow = null;
+
+var gClient = null;
+var windowMediator = Cc["@mozilla.org/appshell/window-mediator;1"]
+                     .getService(Ci.nsIWindowMediator);
+
+function test()
+{
+  let transport = DebuggerServer.connectPipe();
+  gClient = new DebuggerClient(transport);
+  gClient.connect(function(aType, aTraits) {
+    is(aType, "browser", "Root actor should identify itself as a browser.");
+    test_first_tab();
+  });
+}
+
+function test_first_tab()
+{
+  gTab1 = addTab(TAB1_URL, function() {
+    gClient.listTabs(function(aResponse) {
+      for each (let tab in aResponse.tabs) {
+        if (tab.url == TAB1_URL) {
+          gTab1Actor = tab.actor;
+        }
+      }
+      ok(gTab1Actor, "Should find a tab actor for tab1.");
+      is(aResponse.selected, 1, "Tab1 is selected.");
+      test_open_window();
+    });
+  });
+}
+
+function test_open_window()
+{
+  gSecondWindow = window.open(TAB2_URL, "secondWindow");
+  ok(!!gSecondWindow, "Second window created.");
+  gSecondWindow.focus();
+  let top = windowMediator.getMostRecentWindow("navigator:browser");
+  var main2 = gSecondWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+                   .getInterface(Components.interfaces.nsIWebNavigation)
+                   .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
+                   .rootTreeItem
+                   .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+                   .getInterface(Components.interfaces.nsIDOMWindow);
+  is(top, main2, "The second window is on top.");
+  executeSoon(function() {
+    gClient.listTabs(function(aResponse) {
+      is(aResponse.selected, 2, "Tab2 is selected.");
+
+      test_focus_first();
+    });
+  });
+}
+
+function test_focus_first()
+{
+  window.content.addEventListener("focus", function onFocus() {
+    window.content.removeEventListener("focus", onFocus, false);
+    let top = windowMediator.getMostRecentWindow("navigator:browser");
+    var main1 = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+                     .getInterface(Components.interfaces.nsIWebNavigation)
+                     .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
+                     .rootTreeItem
+                     .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+                     .getInterface(Components.interfaces.nsIDOMWindow);
+    is(top, main1, "The first window is on top.");
+
+    gClient.listTabs(function(aResponse) {
+      is(aResponse.selected, 1, "Tab1 is selected after focusing on it.");
+
+      test_remove_tab();
+    });
+  }, false);
+  window.content.focus();
+}
+
+function test_remove_tab()
+{
+  gSecondWindow.close();
+  gSecondWindow = null;
+  removeTab(gTab1);
+  gTab1 = null;
+  gClient.listTabs(function(aResponse) {
+    // Verify that tabs are no longer included in listTabs.
+    let foundTab1 = false;
+    let foundTab2 = false;
+    for (let tab of aResponse.tabs) {
+      if (tab.url == TAB1_URL) {
+        foundTab1 = true;
+      } else if (tab.url == TAB2_URL) {
+        foundTab2 = true;
+      }
+    }
+    ok(!foundTab1, "Tab1 should be gone.");
+    ok(!foundTab2, "Tab2 should be gone.");
+    is(aResponse.selected, 0, "The original tab is selected.");
+    finish_test();
+  });
+}
+
+function finish_test()
+{
+  gClient.close(function() {
+    finish();
+  });
+}
--- a/browser/devtools/debugger/test/browser_dbg_scripts-searching-01.js
+++ b/browser/devtools/debugger/test/browser_dbg_scripts-searching-01.js
@@ -40,124 +40,130 @@ function test()
   {
     if (scriptShown && framesAdded) {
       Services.tm.currentThread.dispatch({ run: testScriptSearching }, 0);
     }
   }
 }
 
 function testScriptSearching() {
+  var token;
+
   gDebugger.DebuggerController.activeThread.resume(function() {
     gEditor = gDebugger.DebuggerView.editor;
     gScripts = gDebugger.DebuggerView.Scripts;
     gSearchBox = gScripts._searchbox;
     gMenulist = gScripts._scripts;
 
     write(":12");
     ok(gEditor.getCaretPosition().line == 11 &&
        gEditor.getCaretPosition().col == 0,
       "The editor didn't jump to the correct line.");
 
-    write("#debugger");
+    token = "debugger";
+    write("#" + token);
     ok(gEditor.getCaretPosition().line == 2 &&
-       gEditor.getCaretPosition().col == 44,
+       gEditor.getCaretPosition().col == 44 + token.length,
       "The editor didn't jump to the correct token. (1)");
 
     EventUtils.sendKey("RETURN");
     ok(gEditor.getCaretPosition().line == 8 &&
-       gEditor.getCaretPosition().col == 2,
+       gEditor.getCaretPosition().col == 2 + token.length,
       "The editor didn't jump to the correct token. (2)");
 
     EventUtils.sendKey("ENTER");
     ok(gEditor.getCaretPosition().line == 12 &&
-       gEditor.getCaretPosition().col == 8,
+       gEditor.getCaretPosition().col == 8 + token.length,
       "The editor didn't jump to the correct token. (3)");
 
     EventUtils.sendKey("ENTER");
     ok(gEditor.getCaretPosition().line == 19 &&
-       gEditor.getCaretPosition().col == 4,
+       gEditor.getCaretPosition().col == 4 + token.length,
       "The editor didn't jump to the correct token. (4)");
 
     EventUtils.sendKey("RETURN");
     ok(gEditor.getCaretPosition().line == 2 &&
-       gEditor.getCaretPosition().col == 44,
+       gEditor.getCaretPosition().col == 44 + token.length,
       "The editor didn't jump to the correct token. (5)");
 
 
-    write(":bogus#debugger;");
+    token = "debugger;";
+    write(":bogus#" + token);
     ok(gEditor.getCaretPosition().line == 8 &&
-       gEditor.getCaretPosition().col == 2,
-      "The editor didn't jump to the correct token. (7)");
+       gEditor.getCaretPosition().col == 2 + token.length,
+      "The editor didn't jump to the correct token. (6)");
 
-    write(":13#debugger;");
+    write(":13#" + token);
     ok(gEditor.getCaretPosition().line == 8 &&
-       gEditor.getCaretPosition().col == 2,
+       gEditor.getCaretPosition().col == 2 + token.length,
       "The editor didn't jump to the correct token. (7)");
 
-    write(":#debugger;");
+    write(":#" + token);
     ok(gEditor.getCaretPosition().line == 8 &&
-       gEditor.getCaretPosition().col == 2,
+       gEditor.getCaretPosition().col == 2 + token.length,
       "The editor didn't jump to the correct token. (8)");
 
-    write("::#debugger;");
+    write("::#" + token.length);
     ok(gEditor.getCaretPosition().line == 8 &&
-       gEditor.getCaretPosition().col == 2,
+       gEditor.getCaretPosition().col == 2 + token.length,
       "The editor didn't jump to the correct token. (9)");
 
-    write(":::#debugger;");
+    write(":::#" + token.length);
     ok(gEditor.getCaretPosition().line == 8 &&
-       gEditor.getCaretPosition().col == 2,
+       gEditor.getCaretPosition().col == 2 + token.length,
       "The editor didn't jump to the correct token. (10)");
 
 
     write(":i am not a number");
     ok(gEditor.getCaretPosition().line == 8 &&
-       gEditor.getCaretPosition().col == 2,
+       gEditor.getCaretPosition().col == 2 + token.length,
       "The editor didn't remain at the correct token. (11)");
 
     write("#__i do not exist__");
     ok(gEditor.getCaretPosition().line == 8 &&
-       gEditor.getCaretPosition().col == 2,
+       gEditor.getCaretPosition().col == 2 + token.length,
       "The editor didn't remain at the correct token. (12)");
 
 
+    token = "debugger";
     write(":1:2:3:a:b:c:::12");
     ok(gEditor.getCaretPosition().line == 11 &&
        gEditor.getCaretPosition().col == 0,
       "The editor didn't jump to the correct line. (13)");
 
-    write("#don't#find#me#instead#find#debugger");
+    write("#don't#find#me#instead#find#" + token);
     ok(gEditor.getCaretPosition().line == 2 &&
-       gEditor.getCaretPosition().col == 44,
+       gEditor.getCaretPosition().col == 44 + token.length,
       "The editor didn't jump to the correct token. (14)");
 
+
     EventUtils.sendKey("RETURN");
     ok(gEditor.getCaretPosition().line == 8 &&
-       gEditor.getCaretPosition().col == 2,
+       gEditor.getCaretPosition().col == 2 + token.length,
       "The editor didn't jump to the correct token. (15)");
 
     EventUtils.sendKey("ENTER");
     ok(gEditor.getCaretPosition().line == 12 &&
-       gEditor.getCaretPosition().col == 8,
+       gEditor.getCaretPosition().col == 8 + token.length,
       "The editor didn't jump to the correct token. (16)");
 
     EventUtils.sendKey("RETURN");
     ok(gEditor.getCaretPosition().line == 19 &&
-       gEditor.getCaretPosition().col == 4,
+       gEditor.getCaretPosition().col == 4 + token.length,
       "The editor didn't jump to the correct token. (17)");
 
     EventUtils.sendKey("ENTER");
     ok(gEditor.getCaretPosition().line == 2 &&
-       gEditor.getCaretPosition().col == 44,
+       gEditor.getCaretPosition().col == 44 + token.length,
       "The editor didn't jump to the correct token. (18)");
 
 
     clear();
     ok(gEditor.getCaretPosition().line == 2 &&
-       gEditor.getCaretPosition().col == 44,
+       gEditor.getCaretPosition().col == 44 + token.length,
       "The editor didn't remain at the correct token. (19)");
     is(gScripts.visibleItemsCount, 1,
       "Not all the scripts are shown after the search. (20)");
 
     closeDebuggerAndFinish();
   });
 }
 
@@ -167,17 +173,17 @@ function clear() {
 }
 
 function write(text) {
   clear();
 
   for (let i = 0; i < text.length; i++) {
     EventUtils.sendChar(text[i]);
   }
-  dump("editor caret position: " + gEditor.getCaretPosition().toSource() + "\n");
+  info("Editor caret position: " + gEditor.getCaretPosition().toSource() + "\n");
 }
 
 registerCleanupFunction(function() {
   removeTab(gTab);
   gPane = null;
   gTab = null;
   gDebuggee = null;
   gDebugger = null;
--- a/browser/devtools/debugger/test/browser_dbg_scripts-searching-02.js
+++ b/browser/devtools/debugger/test/browser_dbg_scripts-searching-02.js
@@ -57,85 +57,99 @@ function testScriptSearching() {
     gMenulist = gScripts._scripts;
 
     firstSearch();
   });
 }
 
 function firstSearch() {
   window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
-    dump("Current script url:\n" + aEvent.detail.url + "\n");
-    dump("Debugger editor text:\n" + gEditor.getText() + "\n");
+    info("Current script url:\n" + aEvent.detail.url + "\n");
+    info("Debugger editor text:\n" + gEditor.getText() + "\n");
 
     let url = aEvent.detail.url;
     if (url.indexOf("-01.js") != -1) {
       window.removeEventListener(aEvent.type, _onEvent);
 
       executeSoon(function() {
-        dump("Editor caret position: " + gEditor.getCaretPosition().toSource() + "\n");
+        info("Editor caret position: " + gEditor.getCaretPosition().toSource() + "\n");
         ok(gEditor.getCaretPosition().line == 4 &&
            gEditor.getCaretPosition().col == 0,
           "The editor didn't jump to the correct line. (1)");
         is(gScripts.visibleItemsCount, 1,
           "Not all the correct scripts are shown after the search. (1)");
 
         secondSearch();
       });
     }
   });
   write(".*-01\.js:5");
 }
 
 function secondSearch() {
+  let token = "deb";
+
   window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
-    dump("Current script url:\n" + aEvent.detail.url + "\n");
-    dump("Debugger editor text:\n" + gEditor.getText() + "\n");
+    info("Current script url:\n" + aEvent.detail.url + "\n");
+    info("Debugger editor text:\n" + gEditor.getText() + "\n");
 
     let url = aEvent.detail.url;
     if (url.indexOf("-02.js") != -1) {
       window.removeEventListener(aEvent.type, _onEvent);
 
       executeSoon(function() {
-        dump("Editor caret position: " + gEditor.getCaretPosition().toSource() + "\n");
+        info("Editor caret position: " + gEditor.getCaretPosition().toSource() + "\n");
         ok(gEditor.getCaretPosition().line == 5 &&
-           gEditor.getCaretPosition().col == 8,
+           gEditor.getCaretPosition().col == 8 + token.length,
           "The editor didn't jump to the correct line. (2)");
         is(gScripts.visibleItemsCount, 1,
           "Not all the correct scripts are shown after the search. (2)");
 
-        finalCheck();
+        finalCheck(0, "ugger;", token);
       });
     }
   });
-  write(".*-02\.js#debugger;");
+  write(".*-02\.js#" + token);
 }
 
-function finalCheck() {
-  clear();
+function finalCheck(i, string, token) {
+  info("Searchbox value: " + gSearchBox.value);
+
   ok(gEditor.getCaretPosition().line == 5 &&
-     gEditor.getCaretPosition().col == 8,
+     gEditor.getCaretPosition().col == 8 + token.length + i,
     "The editor didn't remain at the correct token. (3)");
-  is(gScripts.visibleItemsCount, 2,
-    "Not all the scripts are shown after the search. (3)");
+
+  if (string[i]) {
+    EventUtils.sendChar(string[i]);
+    finalCheck(i + 1, string, token);
+    return;
+  }
 
-  closeDebuggerAndFinish();
+  clear();
+
+  executeSoon(function() {
+    is(gScripts.visibleItemsCount, 2,
+      "Not all the scripts are shown after the searchbox was emptied.");
+
+    closeDebuggerAndFinish();
+  });
 }
 
 function clear() {
   gSearchBox.focus();
   gSearchBox.value = "";
 }
 
 function write(text) {
   clear();
 
   for (let i = 0; i < text.length; i++) {
     EventUtils.sendChar(text[i]);
   }
-  dump("editor caret position: " + gEditor.getCaretPosition().toSource() + "\n");
+  info("Editor caret position: " + gEditor.getCaretPosition().toSource() + "\n");
 }
 
 registerCleanupFunction(function() {
   removeTab(gTab);
   gPane = null;
   gTab = null;
   gDebuggee = null;
   gDebugger = null;
--- a/browser/devtools/debugger/test/head.js
+++ b/browser/devtools/debugger/test/head.js
@@ -28,63 +28,84 @@ registerCleanupFunction(function() {
 
 if (!DebuggerServer.initialized) {
   DebuggerServer.init(function () { return true; });
   DebuggerServer.addBrowserActors();
 }
 
 waitForExplicitFinish();
 
-function addTab(aURL, aOnload)
+function addWindow()
 {
-  gBrowser.selectedTab = gBrowser.addTab(aURL);
+  let windowReference = window.open();
+  let chromeWindow = windowReference
+    .QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation)
+    .QueryInterface(Ci.nsIDocShellTreeItem).rootTreeItem
+    .QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
+
+  return chromeWindow;
+}
 
-  let tab = gBrowser.selectedTab;
+function addTab(aURL, aOnload, aWindow)
+{
+  let targetWindow = aWindow || window;
+  let targetBrowser = targetWindow.gBrowser;
+
+  targetWindow.focus();
+  targetBrowser.selectedTab = targetBrowser.addTab(aURL);
+
+  let tab = targetBrowser.selectedTab;
   if (aOnload) {
     let handler = function() {
       if (tab.linkedBrowser.currentURI.spec == aURL) {
         tab.removeEventListener("load", handler, false);
         aOnload();
       }
     }
     tab.addEventListener("load", handler, false);
   }
 
   return tab;
 }
 
-function removeTab(aTab) {
-  gBrowser.removeTab(aTab);
+function removeTab(aTab, aWindow) {
+  let targetWindow = aWindow || window;
+  let targetBrowser = targetWindow.gBrowser;
+
+  targetBrowser.removeTab(aTab);
 }
 
-function closeDebuggerAndFinish(aRemoteFlag, aCallback) {
+function closeDebuggerAndFinish(aRemoteFlag, aCallback, aWindow) {
+  let targetWindow = aWindow || window;
+  let debuggerUI = targetWindow.DebuggerUI;
+
   let debuggerClosed = false;
   let debuggerDisconnected = false;
 
   function _maybeFinish() {
     if (debuggerClosed && debuggerDisconnected) {
       if (!aCallback)
         aCallback = finish;
       aCallback();
     }
   }
 
-  DebuggerUI.chromeWindow.addEventListener("Debugger:Shutdown", function cleanup() {
-    DebuggerUI.chromeWindow.removeEventListener("Debugger:Shutdown", cleanup, false);
+  debuggerUI.chromeWindow.addEventListener("Debugger:Shutdown", function cleanup() {
+    debuggerUI.chromeWindow.removeEventListener("Debugger:Shutdown", cleanup, false);
     debuggerDisconnected = true;
     _maybeFinish();
   }, false);
   if (!aRemoteFlag) {
-    DebuggerUI.getDebugger().close(function() {
+    debuggerUI.getDebugger().close(function() {
       debuggerClosed = true;
       _maybeFinish();
     });
   } else {
     debuggerClosed = true;
-    DebuggerUI.getRemoteDebugger().close();
+    debuggerUI.getRemoteDebugger().close();
   }
 }
 
 function get_tab_actor_for_url(aClient, aURL, aCallback) {
   aClient.listTabs(function(aResponse) {
     for each (let tab in aResponse.tabs) {
       if (tab.url == aURL) {
         aCallback(tab);
@@ -127,20 +148,23 @@ function debug_tab_pane(aURL, aOnDebuggi
       // Wait for the initial resume...
       pane.contentWindow.gClient.addOneTimeListener("resumed", function() {
         aOnDebugging(tab, debuggee, pane);
       });
     }, true);
   });
 }
 
-function wait_for_connect_and_resume(aOnDebugging)
+function wait_for_connect_and_resume(aOnDebugging, aWindow)
 {
-  window.document.addEventListener("Debugger:Connecting", function dbgConnected(aEvent) {
-    window.document.removeEventListener("Debugger:Connecting", dbgConnected, true);
+  let targetWindow = aWindow || window;
+  let targetDocument = targetWindow.document;
+
+  targetDocument.addEventListener("Debugger:Connecting", function dbgConnected(aEvent) {
+    targetDocument.removeEventListener("Debugger:Connecting", dbgConnected, true);
 
     // Wait for the initial resume...
     aEvent.target.ownerDocument.defaultView.gClient.addOneTimeListener("resumed", function() {
       aOnDebugging();
     });
   }, true);
 }
 
--- a/browser/devtools/responsivedesign/responsivedesign.jsm
+++ b/browser/devtools/responsivedesign/responsivedesign.jsm
@@ -52,16 +52,17 @@ let presets = [
   {key: "1280x600", width: 1280, height: 600},
   {key: "1920x900", width: 1920, height: 900},
 ];
 
 function ResponsiveUI(aWindow, aTab)
 {
   this.mainWindow = aWindow;
   this.tab = aTab;
+  this.tabContainer = aWindow.gBrowser.tabContainer;
   this.browser = aTab.linkedBrowser;
   this.chromeDoc = aWindow.document;
   this.container = aWindow.gBrowser.getBrowserContainer(this.browser);
   this.stack = this.container.querySelector("[anonid=browserStack]");
 
   // Try to load presets from prefs
   if (Services.prefs.prefHasUserValue("devtools.responsiveUI.presets")) {
     try {
@@ -105,17 +106,17 @@ function ResponsiveUI(aWindow, aTab)
   this.bound_rotate = this.rotate.bind(this);
   this.bound_startResizing = this.startResizing.bind(this);
   this.bound_stopResizing = this.stopResizing.bind(this);
   this.bound_onDrag = this.onDrag.bind(this);
   this.bound_onKeypress = this.onKeypress.bind(this);
 
   // Events
   this.tab.addEventListener("TabClose", this);
-  this.tab.addEventListener("TabAttrModified", this);
+  this.tabContainer.addEventListener("TabSelect", this);
   this.mainWindow.addEventListener("keypress", this.bound_onKeypress, true);
 
   this.buildUI();
   this.checkMenus();
 
   try {
     if (Services.prefs.getBoolPref("devtools.responsiveUI.rotate")) {
       this.rotate();
@@ -151,17 +152,17 @@ ResponsiveUI.prototype = {
       this.stopResizing();
 
     this.saveCurrentPreset();
 
     // Remove listeners.
     this.mainWindow.removeEventListener("keypress", this.bound_onKeypress, true);
     this.menulist.removeEventListener("select", this.bound_presetSelected, true);
     this.tab.removeEventListener("TabClose", this);
-    this.tab.removeEventListener("TabAttrModified", this);
+    this.tabContainer.removeEventListener("TabSelect", this);
     this.rotatebutton.removeEventListener("command", this.bound_rotate, true);
 
     // Removed elements.
     this.container.removeChild(this.toolbar);
     this.stack.removeChild(this.resizer);
     this.stack.removeChild(this.resizeBar);
 
     // Unset the responsive mode.
@@ -203,20 +204,20 @@ ResponsiveUI.prototype = {
   /**
    * Handle events
    */
   handleEvent: function (aEvent) {
     switch (aEvent.type) {
       case "TabClose":
         this.close();
         break;
-      case "TabAttrModified":
-        if (this.mainWindow.gBrowser.selectedBrowser == this.browser) {
+      case "TabSelect":
+        if (this.tab.selected) {
           this.checkMenus();
-        } else {
+        } else if (!this.mainWindow.gBrowser.selectedTab.responsiveUI) {
           this.unCheckMenus();
         }
         break;
     }
   },
 
   /**
    * Check the menu items.
--- a/browser/devtools/shared/DeveloperToolbar.jsm
+++ b/browser/devtools/shared/DeveloperToolbar.jsm
@@ -338,19 +338,16 @@ DeveloperToolbar.prototype._notify = fun
 
 /**
  * Update various parts of the UI when the current tab changes
  * @param aEvent
  */
 DeveloperToolbar.prototype.handleEvent = function DT_handleEvent(aEvent)
 {
   if (aEvent.type == "TabSelect" || aEvent.type == "load") {
-    this._chromeWindow.HUDConsoleUI.refreshCommand();
-    this._chromeWindow.DebuggerUI.refreshCommand();
-
     if (this.visible) {
       let contentDocument = this._chromeWindow.getBrowser().contentDocument;
 
       this.display.reattach({
         contentDocument: contentDocument,
         chromeWindow: this._chromeWindow,
         environment: {
           chromeDocument: this._doc,
--- a/browser/devtools/styleinspector/CssRuleView.jsm
+++ b/browser/devtools/styleinspector/CssRuleView.jsm
@@ -1546,18 +1546,21 @@ TextPropertyEditor.prototype = {
       class: "ruleview-expander"
     });
     this.expander.addEventListener("click", this._onExpandClicked, true);
 
     this.nameContainer = createChild(this.element, "span", {
       class: "ruleview-namecontainer"
     });
     this.nameContainer.addEventListener("click", function(aEvent) {
-      this.nameSpan.click();
+      // Clicks within the name shouldn't propagate any further.
       aEvent.stopPropagation();
+      if (aEvent.target === propertyContainer) {
+        this.nameSpan.click();
+      }
     }.bind(this), false);
 
     // Property name, editable when focused.  Property name
     // is committed when the editor is unfocused.
     this.nameSpan = createChild(this.nameContainer, "span", {
       class: "ruleview-propertyname",
       tabindex: "0",
     });
@@ -1573,18 +1576,21 @@ TextPropertyEditor.prototype = {
 
     // Create a span that will hold the property and semicolon.
     // Use this span to create a slightly larger click target
     // for the value.
     let propertyContainer = createChild(this.element, "span", {
       class: "ruleview-propertycontainer"
     });
     propertyContainer.addEventListener("click", function(aEvent) {
-      this.valueSpan.click();
+      // Clicks within the value shouldn't propagate any further.
       aEvent.stopPropagation();
+      if (aEvent.target === propertyContainer) {
+        this.valueSpan.click();
+      }
     }.bind(this), false);
 
     // Property value, editable when focused.  Changes to the
     // property value are applied as they are typed, and reverted
     // if the user presses escape.
     this.valueSpan = createChild(propertyContainer, "span", {
       class: "ruleview-propertyvalue",
       tabindex: "0",
@@ -1741,16 +1747,20 @@ TextPropertyEditor.prototype = {
    * @param {string} aValue
    *        The value contained in the editor.
    * @param {boolean} aCommit
    *        True if the change should be applied.
    */
   _onNameDone: function TextPropertyEditor_onNameDone(aValue, aCommit)
   {
     if (!aCommit) {
+      if (this.prop.overridden) {
+        this.element.classList.add("ruleview-overridden");
+      }
+
       return;
     }
     if (!aValue) {
       this.prop.remove();
       this.element.parentNode.removeChild(this.element);
       return;
     }
     this.prop.setName(aValue);
@@ -2300,9 +2310,8 @@ XPCOMUtils.defineLazyGetter(this, "clipb
 XPCOMUtils.defineLazyGetter(this, "_strings", function() {
   return Services.strings.createBundle(
     "chrome://browser/locale/devtools/styleinspector.properties");
 });
 
 XPCOMUtils.defineLazyGetter(this, "osString", function() {
   return Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS;
 });
-
--- a/browser/devtools/styleinspector/test/browser_ruleview_ui.js
+++ b/browser/devtools/styleinspector/test/browser_ruleview_ui.js
@@ -83,17 +83,25 @@ function testCancelNew()
 }
 
 function testCreateNew()
 {
   // Create a new property.
   let elementRuleEditor = ruleView.element.children[0]._ruleEditor;
   waitForEditorFocus(elementRuleEditor.element, function onNewElement(aEditor) {
     is(inplaceEditor(elementRuleEditor.newPropSpan), aEditor, "Next focused editor should be the new property editor.");
+
     let input = aEditor.input;
+
+    ok(input.selectionStart === 0 && input.selectionEnd === input.value.length, "Editor contents are selected.");
+
+    // Try clicking on the editor's input again, shouldn't cause trouble (see bug 761665).
+    EventUtils.synthesizeMouse(input, 1, 1, { }, ruleDialog);
+    input.select();
+
     input.value = "background-color";
 
     waitForEditorFocus(elementRuleEditor.element, function onNewValue(aEditor) {
       expectChange();
       is(elementRuleEditor.rule.textProps.length,  1, "Should have created a new text property.");
       is(elementRuleEditor.propertyList.children.length, 1, "Should have created a property editor.");
       let textProp = elementRuleEditor.rule.textProps[0];
       is(aEditor, inplaceEditor(textProp.editor.valueSpan), "Should be editing the value span now.");
@@ -116,21 +124,37 @@ function testCreateNew()
 }
 
 function testEditProperty()
 {
   let idRuleEditor = ruleView.element.children[1]._ruleEditor;
   let propEditor = idRuleEditor.rule.textProps[0].editor;
   waitForEditorFocus(propEditor.element, function onNewElement(aEditor) {
     is(inplaceEditor(propEditor.nameSpan), aEditor, "Next focused editor should be the name editor.");
+
     let input = aEditor.input;
+
+    dump("SELECTION END IS: " + input.selectionEnd + "\n");
+    ok(input.selectionStart === 0 && input.selectionEnd === input.value.length, "Editor contents are selected.");
+
+    // Try clicking on the editor's input again, shouldn't cause trouble (see bug 761665).
+    EventUtils.synthesizeMouse(input, 1, 1, { }, ruleDialog);
+    input.select();
+
     waitForEditorFocus(propEditor.element, function onNewName(aEditor) {
       expectChange();
+      is(inplaceEditor(propEditor.valueSpan), aEditor, "Focus should have moved to the value.");
+
       input = aEditor.input;
-      is(inplaceEditor(propEditor.valueSpan), aEditor, "Focus should have moved to the value.");
+
+      ok(input.selectionStart === 0 && input.selectionEnd === input.value.length, "Editor contents are selected.");
+
+      // Try clicking on the editor's input again, shouldn't cause trouble (see bug 761665).
+      EventUtils.synthesizeMouse(input, 1, 1, { }, ruleDialog);
+      input.select();
 
       waitForEditorBlur(aEditor, function() {
         expectChange();
         is(idRuleEditor.rule.style.getPropertyValue("border-color"), "red",
            "border-color should have been set.");
 
         let props = ruleView.element.querySelectorAll(".ruleview-property");
         for (let i = 0; i < props.length; i++) {
--- a/browser/devtools/webconsole/HUDService.jsm
+++ b/browser/devtools/webconsole/HUDService.jsm
@@ -246,16 +246,17 @@ function pruneConsoleOutputIfNecessary(a
 ///////////////////////////////////////////////////////////////////////////
 //// The HUD service
 
 function HUD_SERVICE()
 {
   // These methods access the "this" object, but they're registered as
   // event listeners. So we hammer in the "this" binding.
   this.onTabClose = this.onTabClose.bind(this);
+  this.onTabSelect = this.onTabSelect.bind(this);
   this.onWindowUnload = this.onWindowUnload.bind(this);
 
   // Remembers the last console height, in pixels.
   this.lastConsoleHeight = Services.prefs.getIntPref("devtools.hud.height");
 
   /**
    * Each HeadsUpDisplay has a set of filter preferences
    */
@@ -312,16 +313,17 @@ HUD_SERVICE.prototype =
 
     this.wakeup();
 
     let window = aTab.ownerDocument.defaultView;
     let gBrowser = window.gBrowser;
 
     // TODO: check that this works as intended
     gBrowser.tabContainer.addEventListener("TabClose", this.onTabClose, false);
+    gBrowser.tabContainer.addEventListener("TabSelect", this.onTabSelect, false);
     window.addEventListener("unload", this.onWindowUnload, false);
 
     this.registerDisplay(hudId);
 
     let hud = new HeadsUpDisplay(aTab);
     this.hudReferences[hudId] = hud;
 
     // register the controller to handle "select all" properly
@@ -611,16 +613,17 @@ HUD_SERVICE.prototype =
 
       let window = document.defaultView;
 
       window.removeEventListener("unload", this.onWindowUnload, false);
 
       let gBrowser = window.gBrowser;
       let tabContainer = gBrowser.tabContainer;
       tabContainer.removeEventListener("TabClose", this.onTabClose, false);
+      tabContainer.removeEventListener("TabSelect", this.onTabSelect, false);
 
       this.suspend();
     }
   },
 
   /**
    * "Wake up" the Web Console activity. This is called when the first Web
    * Console is open. This method initializes the various observers we have.
@@ -799,16 +802,27 @@ HUD_SERVICE.prototype =
    * @returns void
    */
   onTabClose: function HS_onTabClose(aEvent)
   {
     this.deactivateHUDForContext(aEvent.target, false);
   },
 
   /**
+   * onTabSelect event handler function
+   *
+   * @param aEvent
+   * @returns void
+   */
+  onTabSelect: function HS_onTabSelect(aEvent)
+  {
+    HeadsUpDisplayUICommands.refreshCommand();
+  },
+
+  /**
    * Called whenever a browser window closes. Cleans up any consoles still
    * around.
    *
    * @param nsIDOMEvent aEvent
    *        The dispatched event.
    * @returns void
    */
   onWindowUnload: function HS_onWindowUnload(aEvent)
@@ -816,16 +830,17 @@ HUD_SERVICE.prototype =
     let window = aEvent.target.defaultView;
 
     window.removeEventListener("unload", this.onWindowUnload, false);
 
     let gBrowser = window.gBrowser;
     let tabContainer = gBrowser.tabContainer;
 
     tabContainer.removeEventListener("TabClose", this.onTabClose, false);
+    tabContainer.removeEventListener("TabSelect", this.onTabSelect, false);
 
     let tab = tabContainer.firstChild;
     while (tab != null) {
       this.deactivateHUDForContext(tab, false);
       tab = tab.nextSibling;
     }
 
     if (window.webConsoleCommandController) {
@@ -4426,17 +4441,17 @@ HeadsUpDisplayUICommands = {
     if (!window) {
       return;
     }
 
     let command = window.document.getElementById("Tools:WebConsole");
     if (this.getOpenHUD() != null) {
       command.setAttribute("checked", true);
     } else {
-      command.removeAttribute("checked");
+      command.setAttribute("checked", false);
     }
   },
 
   toggleHUD: function UIC_toggleHUD() {
     var window = HUDService.currentContext();
     var gBrowser = window.gBrowser;
     var linkedBrowser = gBrowser.selectedTab.linkedBrowser;
     var tabId = gBrowser.getNotificationBox(linkedBrowser).getAttribute("id");
--- a/browser/devtools/webconsole/test/Makefile.in
+++ b/browser/devtools/webconsole/test/Makefile.in
@@ -104,16 +104,17 @@ include $(topsrcdir)/config/rules.mk
 	browser_webconsole_bug_659907_console_dir.js \
 	browser_webconsole_bug_664131_console_group.js \
 	browser_webconsole_bug_704295.js \
 	browser_webconsole_bug_658368_time_methods.js \
 	browser_webconsole_bug_622303_persistent_filters.js \
 	browser_webconsole_window_zombie.js \
 	browser_cached_messages.js \
 	browser_bug664688_sandbox_update_after_navigation.js \
+	browser_webconsole_menustatus.js \
 	head.js \
 	$(NULL)
 
 _BROWSER_TEST_PAGES = \
 	test-console.html \
 	test-network.html \
 	test-network-request.html \
 	test-mutation.html \
new file mode 100644
--- /dev/null
+++ b/browser/devtools/webconsole/test/browser_webconsole_menustatus.js
@@ -0,0 +1,33 @@
+/* vim:set ts=2 sw=2 sts=2 et: */
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+function test() {
+  var tab1 = gBrowser.addTab();
+  var tab2 = gBrowser.addTab();
+  gBrowser.selectedTab = tab2;
+
+  openConsole(tab2, function() {
+    let cmd = document.getElementById("Tools:WebConsole");
+    is(cmd.getAttribute("checked"), "true", "<command Tools:WebConsole> is checked.");
+
+    gBrowser.selectedTab = tab1;
+
+    is(cmd.getAttribute("checked"), "false", "<command Tools:WebConsole> is unchecked after tab switch.");
+
+    gBrowser.selectedTab = tab2;
+
+    is(cmd.getAttribute("checked"), "true", "<command Tools:WebConsole> is checked.");
+
+    closeConsole(tab2, function() {
+      is(cmd.getAttribute("checked"), "false", "<command Tools:WebConsole> is checked once closed.");
+
+      gBrowser.removeTab(tab1);
+      gBrowser.removeTab(tab2);
+
+      finish();
+    });
+  });
+}
--- a/browser/modules/NewTabUtils.jsm
+++ b/browser/modules/NewTabUtils.jsm
@@ -11,21 +11,16 @@ const Cc = Components.classes;
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
   "resource://gre/modules/PlacesUtils.jsm");
 
-XPCOMUtils.defineLazyServiceGetter(this, "gPrivateBrowsing",
-  "@mozilla.org/privatebrowsing;1", "nsIPrivateBrowsingService");
-
-XPCOMUtils.defineLazyModuleGetter(this, "Dict", "resource://gre/modules/Dict.jsm");
-
 // The preference that tells whether this feature is enabled.
 const PREF_NEWTAB_ENABLED = "browser.newtabpage.enabled";
 
 // The maximum number of results we want to retrieve from history.
 const HISTORY_RESULTS_LIMIT = 100;
 
 // The gather telemetry topic.
 const TOPIC_GATHER_TELEMETRY = "gather-telemetry";
@@ -47,142 +42,51 @@ let Storage = {
     // Cache this value, overwrite the getter.
     let descriptor = {value: storage, enumerable: true};
     Object.defineProperty(this, "domStorage", descriptor);
 
     return storage;
   },
 
   /**
-   * The current storage used to persist New Tab Page data. If we're currently
-   * in private browsing mode this will return a PrivateBrowsingStorage
-   * instance.
-   */
-  get currentStorage() {
-    let storage = this.domStorage;
-
-    // Check if we're starting in private browsing mode.
-    if (gPrivateBrowsing.privateBrowsingEnabled)
-      storage = new PrivateBrowsingStorage(storage);
-
-    // Register an observer to listen for private browsing mode changes.
-    Services.obs.addObserver(this, "private-browsing", true);
-
-    // Cache this value, overwrite the getter.
-    let descriptor = {value: storage, enumerable: true, writable: true};
-    Object.defineProperty(this, "currentStorage", descriptor);
-
-    return storage;
-  },
-
-  /**
    * Gets the value for a given key from the storage.
    * @param aKey The storage key (a string).
    * @param aDefault A default value if the key doesn't exist.
    * @return The value for the given key.
    */
   get: function Storage_get(aKey, aDefault) {
     let value;
 
     try {
-      value = JSON.parse(this.currentStorage.getItem(aKey));
+      value = JSON.parse(this.domStorage.getItem(aKey));
     } catch (e) {}
 
     return value || aDefault;
   },
 
   /**
    * Sets the storage value for a given key.
    * @param aKey The storage key (a string).
    * @param aValue The value to set.
    */
   set: function Storage_set(aKey, aValue) {
-    this.currentStorage.setItem(aKey, JSON.stringify(aValue));
+    this.domStorage.setItem(aKey, JSON.stringify(aValue));
   },
 
   /**
    * Clears the storage and removes all values.
    */
   clear: function Storage_clear() {
-    this.currentStorage.clear();
-  },
-
-  /**
-   * Implements the nsIObserver interface to get notified about private
-   * browsing mode changes.
-   */
-  observe: function Storage_observe(aSubject, aTopic, aData) {
-    if (aData == "enter") {
-      // When switching to private browsing mode we keep the current state
-      // of the grid and provide a volatile storage for it that is
-      // discarded upon leaving private browsing.
-      this.currentStorage = new PrivateBrowsingStorage(this.domStorage);
-    } else {
-      // Reset to normal DOM storage.
-      this.currentStorage = this.domStorage;
-
-      // When switching back from private browsing we need to reset the
-      // grid and re-read its values from the underlying storage. We don't
-      // want any data from private browsing to show up.
-      PinnedLinks.resetCache();
-      BlockedLinks.resetCache();
-    }
+    this.domStorage.clear();
   },
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
                                          Ci.nsISupportsWeakReference])
 };
 
-/**
- * This class implements a temporary storage used while the user is in private
- * browsing mode. It is discarded when leaving pb mode.
- */
-function PrivateBrowsingStorage(aStorage) {
-  this._data = new Dict();
-
-  for (let i = 0; i < aStorage.length; i++) {
-    let key = aStorage.key(i);
-    this._data.set(key, aStorage.getItem(key));
-  }
-}
-
-PrivateBrowsingStorage.prototype = {
-  /**
-   * The data store.
-   */
-  _data: null,
-
-  /**
-   * Gets the value for a given key from the storage.
-   * @param aKey The storage key.
-   * @param aDefault A default value if the key doesn't exist.
-   * @return The value for the given key.
-   */
-  getItem: function PrivateBrowsingStorage_getItem(aKey) {
-    return this._data.get(aKey);
-  },
-
-  /**
-   * Sets the storage value for a given key.
-   * @param aKey The storage key.
-   * @param aValue The value to set.
-   */
-  setItem: function PrivateBrowsingStorage_setItem(aKey, aValue) {
-    this._data.set(aKey, aValue);
-  },
-
-  /**
-   * Clears the storage and removes all values.
-   */
-  clear: function PrivateBrowsingStorage_clear() {
-    this._data.listkeys().forEach(function (aKey) {
-      this._data.del(aKey);
-    }, this);
-  }
-};
 
 /**
  * Singleton that serves as a registry for all open 'New Tab Page's.
  */
 let AllPages = {
   /**
    * The array containing all active pages.
    */
deleted file mode 100644
--- a/build/macosx/js-icc-flight.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-OBJDIR_ICC = $(MOZ_OBJDIR)/js-icc
-OBJDIR_X86 = $(MOZ_OBJDIR)/i386
-
-include $(OBJDIR_X86)/config/autoconf.mk
-include $(TOPSRCDIR)/config/config.mk
-
-# Just copy the icc-produced libmozjs.dylib over
-postflight_all:
-	echo "Postflight: copying libmozjs.dylib..."
-	$(INSTALL) $(OBJDIR_ICC)/dist/bin/libmozjs.dylib $(OBJDIR_X86)/dist/$(MOZ_MACBUNDLE_NAME)/Contents/MacOS/
--- a/build/macosx/universal/flight.mk
+++ b/build/macosx/universal/flight.mk
@@ -10,16 +10,17 @@ ifndef OBJDIR
 OBJDIR_ARCH_1 = $(MOZ_OBJDIR)/$(firstword $(MOZ_BUILD_PROJECTS))
 OBJDIR_ARCH_2 = $(MOZ_OBJDIR)/$(word 2,$(MOZ_BUILD_PROJECTS))
 DIST_ARCH_1 = $(OBJDIR_ARCH_1)/dist
 DIST_ARCH_2 = $(OBJDIR_ARCH_2)/dist
 DIST_UNI = $(DIST_ARCH_1)/universal
 OBJDIR = $(OBJDIR_ARCH_1)
 endif
 
+topsrcdir = $(TOPSRCDIR)
 include $(OBJDIR)/config/autoconf.mk
 
 DIST = $(OBJDIR)/dist
 
 ifdef LIBXUL_SDK # {
 APP_CONTENTS = Contents/Frameworks/XUL.framework
 else # } {
 APP_CONTENTS = Contents/MacOS
new file mode 100644
--- /dev/null
+++ b/build/unix/build-clang/build-clang.py
@@ -0,0 +1,115 @@
+#!/usr/bin/python
+# 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/.
+
+llvm_revision = "158160"
+moz_version = "moz0"
+
+##############################################
+
+import os
+import os.path
+import shutil
+import tarfile
+import subprocess
+
+def check_run(args):
+    r = subprocess.call(args)
+    assert r == 0
+
+def run_in(path, args):
+    d = os.getcwd()
+    os.chdir(path)
+    check_run(args)
+    os.chdir(d)
+
+def patch(patch, plevel, srcdir):
+    patch = os.path.realpath(patch)
+    check_run(['patch', '-d', srcdir, '-p%s' % plevel, '-i', patch, '--fuzz=0',
+               '-s'])
+
+def build_package(package_source_dir, package_build_dir, configure_args):
+    if not os.path.exists(package_build_dir):
+        os.mkdir(package_build_dir)
+    run_in(package_build_dir,
+           ["%s/configure" % package_source_dir] + configure_args)
+    run_in(package_build_dir, ["make", "-j8"])
+    run_in(package_build_dir, ["make", "install"])
+
+def with_env(env, f):
+    old_env = os.environ.copy()
+    os.environ.update(env)
+    f()
+    os.environ.clear()
+    os.environ.update(old_env)
+
+def build_tar_package(tar, name, base, directory):
+    name = os.path.realpath(name)
+    run_in(base, [tar, "-cjf", name, "--mtime=2012-01-01", "--owner=root",
+                  directory])
+
+def svn_co(url, directory, revision):
+    check_run(["svn", "co", "-r", revision, url, directory])
+
+# The directories end up in the debug info, so the easy way of getting
+# a reproducible build is to run it in a know absolute directory.
+# We use a directory in /builds/slave because the mozilla infrastructure
+# cleans it up automatically.
+base_dir = "/builds/slave/moz-toolchain"
+
+source_dir = base_dir + "/src"
+build_dir  = base_dir + "/build"
+
+llvm_source_dir = source_dir + "/llvm"
+clang_source_dir = source_dir + "/clang"
+compiler_rt_source_dir = source_dir + "/compiler-rt"
+
+def build_one_stage(env, stage_dir, is_stage_one):
+    def f():
+        build_one_stage_aux(stage_dir, is_stage_one)
+    with_env(env, f)
+
+def build_one_stage_aux(stage_dir, is_stage_one):
+    os.mkdir(stage_dir)
+
+    build_dir = stage_dir + "/build"
+    inst_dir = stage_dir + "/inst"
+
+    configure_opts = ["--enable-optimized",
+                      "--prefix=%s" % inst_dir,
+                      "--with-gcc-toolchain=/tools/gcc-4.5-0moz3"]
+    if is_stage_one:
+        configure_opts.append("--with-optimize-option=-O0")
+
+    build_package(llvm_source_dir, build_dir, configure_opts)
+
+if not os.path.exists(source_dir):
+    os.makedirs(source_dir)
+    svn_co("http://llvm.org/svn/llvm-project/llvm/trunk",
+           llvm_source_dir, llvm_revision)
+    svn_co("http://llvm.org/svn/llvm-project/cfe/trunk",
+           clang_source_dir, llvm_revision)
+    svn_co("http://llvm.org/svn/llvm-project/compiler-rt/trunk",
+           compiler_rt_source_dir, llvm_revision)
+    os.symlink("../../clang", llvm_source_dir + "/tools/clang")
+    os.symlink("../../compiler-rt", llvm_source_dir + "/projects/compiler-rt")
+    patch("old-ld-hack.patch", 1, llvm_source_dir)
+    patch("compiler-rt-gnu89-inline.patch", 0, compiler_rt_source_dir)
+
+if os.path.exists(build_dir):
+    shutil.rmtree(build_dir)
+os.makedirs(build_dir)
+
+stage1_dir = build_dir + '/stage1'
+stage1_inst_dir = stage1_dir + '/clang'
+build_one_stage({"CC"  : "/tools/gcc-4.5-0moz3/bin/gcc -static-libgcc",
+                 "CXX" : "/tools/gcc-4.5-0moz3/bin/g++ -static-libgcc -static-libstdc++"},
+                stage1_dir, True)
+
+stage2_dir = build_dir + '/stage2'
+build_one_stage({"CC"  : stage1_inst_dir + "/bin/clang -static-libgcc -fgnu89-inline",
+                 "CXX" : stage1_inst_dir + "/bin/clang++ -static-libgcc -static-libstdc++"},
+                stage2_dir, False)
+
+build_tar_package("/bin/tar", "clang.tar.bz2", stage3_dir, "clang")
new file mode 100644
--- /dev/null
+++ b/build/unix/build-clang/compiler-rt-gnu89-inline.patch
@@ -0,0 +1,10 @@
+Index: make/config.mk
+===================================================================
+--- make/config.mk	(revision 157958)
++++ make/config.mk	(working copy)
+@@ -43,4 +43,4 @@
+ ###
+ # Common compiler options
+ COMMON_CXXFLAGS=-fno-exceptions -fPIC -funwind-tables -I${ProjSrcRoot}/lib
+-COMMON_CFLAGS=-fPIC
++COMMON_CFLAGS=-fPIC -fgnu89-inline
new file mode 100644
--- /dev/null
+++ b/build/unix/build-clang/old-ld-hack.patch
@@ -0,0 +1,120 @@
+diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h
+index 9932306..948caa8 100644
+--- a/include/llvm/MC/MCStreamer.h
++++ b/include/llvm/MC/MCStreamer.h
+@@ -116,7 +116,7 @@ namespace llvm {
+       return FrameInfos[i];
+     }
+ 
+-    ArrayRef<MCDwarfFrameInfo> getFrameInfos() {
++    MutableArrayRef<MCDwarfFrameInfo> getFrameInfos() {
+       return FrameInfos;
+     }
+ 
+diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp
+index e16f7ae..edf1d6d 100644
+--- a/lib/MC/MCDwarf.cpp
++++ b/lib/MC/MCDwarf.cpp
+@@ -859,7 +859,6 @@ namespace {
+     const MCSymbol &EmitCIE(MCStreamer &streamer,
+                             const MCSymbol *personality,
+                             unsigned personalityEncoding,
+-                            const MCSymbol *lsda,
+                             bool IsSignalFrame,
+                             unsigned lsdaEncoding);
+     MCSymbol *EmitFDE(MCStreamer &streamer,
+@@ -1131,7 +1130,6 @@ bool FrameEmitterImpl::EmitCompactUnwind(MCStreamer &Streamer,
+ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer,
+                                           const MCSymbol *personality,
+                                           unsigned personalityEncoding,
+-                                          const MCSymbol *lsda,
+                                           bool IsSignalFrame,
+                                           unsigned lsdaEncoding) {
+   MCContext &context = streamer.getContext();
+@@ -1172,7 +1170,7 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer,
+     Augmentation += "z";
+     if (personality)
+       Augmentation += "P";
+-    if (lsda)
++    if (lsdaEncoding)
+       Augmentation += "L";
+     Augmentation += "R";
+     if (IsSignalFrame)
+@@ -1203,7 +1201,7 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer,
+       // Personality
+       augmentationLength += getSizeForEncoding(streamer, personalityEncoding);
+     }
+-    if (lsda)
++    if (lsdaEncoding)
+       augmentationLength += 1;
+     // Encoding of the FDE pointers
+     augmentationLength += 1;
+@@ -1221,7 +1219,7 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer,
+       EmitPersonality(streamer, *personality, personalityEncoding);
+     }
+ 
+-    if (lsda)
++    if (lsdaEncoding)
+       EmitEncodingByte(streamer, lsdaEncoding, "LSDA Encoding");
+ 
+     // Encoding of the FDE pointers
+@@ -1322,6 +1320,8 @@ MCSymbol *FrameEmitterImpl::EmitFDE(MCStreamer &streamer,
+     if (frame.Lsda)
+       EmitSymbol(streamer, *frame.Lsda, frame.LsdaEncoding,
+                  "Language Specific Data Area");
++    else if (frame.LsdaEncoding)
++      streamer.EmitIntValue(0, 4);
+   }
+ 
+   // Call Frame Instructions
+@@ -1385,7 +1385,7 @@ void MCDwarfFrameEmitter::Emit(MCStreamer &Streamer,
+   MCObjectFileInfo *MOFI =
+     const_cast<MCObjectFileInfo*>(Context.getObjectFileInfo());
+   FrameEmitterImpl Emitter(UsingCFI, IsEH);
+-  ArrayRef<MCDwarfFrameInfo> FrameArray = Streamer.getFrameInfos();
++  MutableArrayRef<MCDwarfFrameInfo> FrameArray = Streamer.getFrameInfos();
+ 
+   // Emit the compact unwind info if available.
+   if (IsEH && MOFI->getCompactUnwindSection())
+@@ -1405,7 +1405,31 @@ void MCDwarfFrameEmitter::Emit(MCStreamer &Streamer,
+   MCSymbol *FDEEnd = NULL;
+   DenseMap<CIEKey, const MCSymbol*> CIEStarts;
+ 
+-  const MCSymbol *DummyDebugKey = NULL;
++
++  const MCSymbol *HackPersonality = NULL;
++  unsigned HackLsdaEncoding = 0;
++  unsigned HackPersonalityEncoding = 0;
++  for (unsigned i = 0, n = FrameArray.size(); i < n; ++i) {
++    const MCDwarfFrameInfo &Frame = FrameArray[i];
++    if (!HackPersonality)
++      HackPersonality = Frame.Personality;
++    if (!HackLsdaEncoding)
++      HackLsdaEncoding = Frame.LsdaEncoding;
++    if (!HackPersonalityEncoding)
++      HackPersonalityEncoding = Frame.PersonalityEncoding;
++  }
++
++  for (unsigned i = 0, n = FrameArray.size(); i < n; ++i) {
++    MCDwarfFrameInfo &Frame = FrameArray[i];
++    assert(Frame.Personality == NULL || Frame.Personality == HackPersonality);
++    Frame.Personality = HackPersonality;
++    assert(Frame.LsdaEncoding == 0 || Frame.LsdaEncoding == HackLsdaEncoding);
++    Frame.LsdaEncoding = HackLsdaEncoding;
++    assert(Frame.PersonalityEncoding == 0 || Frame.PersonalityEncoding == HackPersonalityEncoding);
++    Frame.PersonalityEncoding = HackPersonalityEncoding;
++  }
++
++ const MCSymbol *DummyDebugKey = NULL;
+   for (unsigned i = 0, n = FrameArray.size(); i < n; ++i) {
+     const MCDwarfFrameInfo &Frame = FrameArray[i];
+     CIEKey Key(Frame.Personality, Frame.PersonalityEncoding,
+@@ -1413,7 +1437,7 @@ void MCDwarfFrameEmitter::Emit(MCStreamer &Streamer,
+     const MCSymbol *&CIEStart = IsEH ? CIEStarts[Key] : DummyDebugKey;
+     if (!CIEStart)
+       CIEStart = &Emitter.EmitCIE(Streamer, Frame.Personality,
+-                                  Frame.PersonalityEncoding, Frame.Lsda,
++                                  Frame.PersonalityEncoding,
+                                   Frame.IsSignalFrame,
+                                   Frame.LsdaEncoding);
+ 
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -1,18 +1,15 @@
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # A netscape style .mk file for autoconf builds
 
-INCLUDED_AUTOCONF_MK = 1
-USE_AUTOCONF 	= 1
-MOZILLA_CLIENT	= 1
 target          = @target@
 ac_configure_args = @ac_configure_args@
 MOZILLA_VERSION = @MOZILLA_VERSION@
 FIREFOX_VERSION	= @FIREFOX_VERSION@
 
 MOZ_BUILD_APP = @MOZ_BUILD_APP@
 MOZ_APP_NAME	= @MOZ_APP_NAME@
 MOZ_APP_DISPLAYNAME = @MOZ_APP_DISPLAYNAME@
@@ -31,26 +28,21 @@ MOZ_MACBUNDLE_NAME = @MOZ_MACBUNDLE_NAME
 MOZ_MACBUNDLE_ID = @MOZ_MACBUNDLE_ID@
 MOZ_APP_STATIC_INI = @MOZ_APP_STATIC_INI@
 
 MOZ_PKG_SPECIAL = @MOZ_PKG_SPECIAL@
 
 prefix		= @prefix@
 exec_prefix	= @exec_prefix@
 bindir		= @bindir@
-includedir	= @includedir@/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
+includedir	= @includedir@
 libdir		= @libdir@
 datadir		= @datadir@
 mandir		= @mandir@
-idldir		= $(datadir)/idl/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
 
-installdir	= $(libdir)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
-sdkdir		= $(libdir)/$(MOZ_APP_NAME)-devel-$(MOZ_APP_VERSION)
-
-DIST		= $(DEPTH)/dist
 LIBXUL_SDK      = @LIBXUL_SDK@
 
 MOZ_FS_LAYOUT = @MOZ_FS_LAYOUT@
 
 L10NBASEDIR     = @L10NBASEDIR@
 
 LIBXUL_DIST	= @LIBXUL_DIST@
 SYSTEM_LIBXUL   = @SYSTEM_LIBXUL@
@@ -175,26 +167,24 @@ MOZ_D3DX9_VERSION = @MOZ_D3DX9_VERSION@
 MOZ_D3DX9_CAB = @MOZ_D3DX9_CAB@
 MOZ_D3DCOMPILER_CAB = @MOZ_D3DCOMPILER_CAB@
 MOZ_D3DX9_DLL = @MOZ_D3DX9_DLL@
 MOZ_D3DCOMPILER_DLL = @MOZ_D3DCOMPILER_DLL@
 MOZ_GL_PROVIDER = @MOZ_GL_PROVIDER@
 MOZ_GL_DEFAULT_PROVIDER = @MOZ_GL_DEFAULT_PROVIDER@
 
 
-JAVA="@JAVA@"
-JAVAC="@JAVAC@"
-JAR="@JAR@"
+JAVA=@JAVA@
+JAVAC=@JAVAC@
+JAR=@JAR@
 
 TAR=@TAR@
 
 MAKENSISU=@MAKENSISU@
 
-RM = rm -f
-
 # The MOZ_UI_LOCALE var is used to build a particular locale. Do *not*
 # use the var to change any binary files. Do *not* use this var unless you
 # write rules for the "clean-locale" and "locale" targets.
 MOZ_UI_LOCALE = @MOZ_UI_LOCALE@
 
 MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS = @MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS@
 MOZ_COMPONENT_NSPR_LIBS=@MOZ_COMPONENT_NSPR_LIBS@
 
@@ -215,32 +205,32 @@ MOZ_BUILD_ROOT             = @MOZ_BUILD_
 
 MOZ_XUL                    = @MOZ_XUL@
 
 NECKO_PROTOCOLS = @NECKO_PROTOCOLS@
 NECKO_COOKIES = @NECKO_COOKIES@
 NECKO_WIFI = @NECKO_WIFI@
 MOZ_AUTH_EXTENSION = @MOZ_AUTH_EXTENSION@
 
-MOZ_NATIVE_HUNSPELL = @SYSTEM_HUNSPELL@
+MOZ_NATIVE_HUNSPELL = @MOZ_NATIVE_HUNSPELL@
 MOZ_HUNSPELL_LIBS = @MOZ_HUNSPELL_LIBS@
 MOZ_HUNSPELL_CFLAGS = @MOZ_HUNSPELL_CFLAGS@
 
 MOZ_NATIVE_LIBEVENT = @MOZ_NATIVE_LIBEVENT@
 MOZ_LIBEVENT_LIBS = @MOZ_LIBEVENT_LIBS@
 MOZ_LIBEVENT_INCLUDES = @MOZ_LIBEVENT_INCLUDES@
 
 MOZ_NATIVE_LIBVPX = @MOZ_NATIVE_LIBVPX@
 MOZ_LIBVPX_LIBS = @MOZ_LIBVPX_LIBS@
 MOZ_LIBVPX_INCLUDES = @MOZ_LIBVPX_INCLUDES@
 
-MOZ_NATIVE_ZLIB	= @SYSTEM_ZLIB@
-MOZ_NATIVE_BZ2	= @SYSTEM_BZ2@
-MOZ_NATIVE_JPEG	= @SYSTEM_JPEG@
-MOZ_NATIVE_PNG	= @SYSTEM_PNG@
+MOZ_NATIVE_ZLIB	= @MOZ_NATIVE_ZLIB@
+MOZ_NATIVE_BZ2	= @MOZ_NATIVE_BZ2@
+MOZ_NATIVE_JPEG	= @MOZ_NATIVE_JPEG@
+MOZ_NATIVE_PNG	= @MOZ_NATIVE_PNG@
 MOZ_TREE_CAIRO = @MOZ_TREE_CAIRO@
 MOZ_TREE_PIXMAN = @MOZ_TREE_PIXMAN@
 
 MOZ_UPDATE_XTERM = @MOZ_UPDATE_XTERM@
 MOZ_PERMISSIONS = @MOZ_PERMISSIONS@
 MOZ_XTF = @MOZ_XTF@
 MOZ_FLEXBOX = @MOZ_FLEXBOX@
 MOZ_SVG_DLISTS = @MOZ_SVG_DLISTS@
@@ -287,27 +277,26 @@ MOZ_NO_WLZDEFS = @MOZ_NO_WLZDEFS@
 
 BUILD_CTYPES = @BUILD_CTYPES@
 
 COMPILE_ENVIRONMENT = @COMPILE_ENVIRONMENT@
 CROSS_COMPILE   = @CROSS_COMPILE@
 
 WCHAR_CFLAGS	= @WCHAR_CFLAGS@
 
-OS_CPPFLAGS	= @CPPFLAGS@
-OS_CFLAGS	= $(OS_CPPFLAGS) @CFLAGS@
-OS_CXXFLAGS	= $(OS_CPPFLAGS) @CXXFLAGS@
-OS_LDFLAGS	= @LDFLAGS@
+OS_CPPFLAGS	= @OS_CPPFLAGS@
+OS_CFLAGS	= @OS_CFLAGS@
+OS_CXXFLAGS	= @OS_CXXFLAGS@
+OS_LDFLAGS	= @OS_LDFLAGS@
 
-OS_COMPILE_CFLAGS = $(OS_CPPFLAGS) @COMPILE_CFLAGS@
-OS_COMPILE_CXXFLAGS = $(OS_CPPFLAGS) @COMPILE_CXXFLAGS@
+OS_COMPILE_CFLAGS = @OS_COMPILE_CFLAGS@
+OS_COMPILE_CXXFLAGS = @OS_COMPILE_CXXFLAGS@
 
-OS_INCLUDES	= $(NSPR_CFLAGS) $(NSS_CFLAGS) $(JPEG_CFLAGS) $(PNG_CFLAGS) $(ZLIB_CFLAGS)
-OS_LIBS		= @LIBS@
-ACDEFINES	= @MOZ_DEFINES@
+OS_LIBS		= @OS_LIBS@
+ACDEFINES	= @ACDEFINES@
 
 WARNINGS_AS_ERRORS = @WARNINGS_AS_ERRORS@
 
 MOZ_OPTIMIZE	= @MOZ_OPTIMIZE@
 MOZ_FRAMEPTR_FLAGS = @MOZ_FRAMEPTR_FLAGS@
 MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@
 MOZ_PGO_OPTIMIZE_FLAGS = @MOZ_PGO_OPTIMIZE_FLAGS@
 MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@
@@ -348,20 +337,17 @@ IMPLIB		= @IMPLIB@
 FILTER		= @FILTER@
 BIN_FLAGS	= @BIN_FLAGS@
 MIDL		= @MIDL@
 MIDL_FLAGS	= @MIDL_FLAGS@
 _MSC_VER	= @_MSC_VER@
 
 DLL_PREFIX	= @DLL_PREFIX@
 LIB_PREFIX	= @LIB_PREFIX@
-# We do magic with OBJ_SUFFIX in config.mk, the following ensures we don't
-# manually use it before config.mk inclusion
-OBJ_SUFFIX	= $(error config/config.mk needs to be included before using OBJ_SUFFIX)
-_OBJ_SUFFIX	= @OBJ_SUFFIX@
+OBJ_SUFFIX	= @OBJ_SUFFIX@
 LIB_SUFFIX	= @LIB_SUFFIX@
 DLL_SUFFIX	= @DLL_SUFFIX@
 BIN_SUFFIX	= @BIN_SUFFIX@
 ASM_SUFFIX	= @ASM_SUFFIX@
 IMPORT_LIB_SUFFIX = @IMPORT_LIB_SUFFIX@
 LIBS_DESC_SUFFIX = @LIBS_DESC_SUFFIX@
 USE_N32		= @USE_N32@
 HAVE_64BIT_OS	= @HAVE_64BIT_OS@
@@ -416,53 +402,33 @@ PERL		= @PERL@
 PYTHON		= @PYTHON@
 RANLIB		= @RANLIB@
 OBJCOPY		= @OBJCOPY@
 UNZIP		= @UNZIP@
 ZIP		= @ZIP@
 XARGS		= @XARGS@
 STRIP		= @STRIP@
 DOXYGEN		= @DOXYGEN@
-PBBUILD_BIN	= @PBBUILD@
+PBBUILD_BIN	= @PBBUILD_BIN@
 SDP		= @SDP@
 NSINSTALL_BIN	= @NSINSTALL_BIN@
 WGET		= @WGET@
 RPMBUILD	= @RPMBUILD@
 
-ifdef MOZ_NATIVE_JPEG
-JPEG_CFLAGS	= @JPEG_CFLAGS@
-JPEG_LIBS	= @JPEG_LIBS@
-else
-JPEG_CFLAGS	= @MOZ_JPEG_CFLAGS@
-JPEG_LIBS	= @MOZ_JPEG_LIBS@
-endif
+MOZ_JPEG_CFLAGS	= @MOZ_JPEG_CFLAGS@
+MOZ_JPEG_LIBS	= @MOZ_JPEG_LIBS@
 
-ifdef MOZ_NATIVE_ZLIB
-ZLIB_CFLAGS	= @ZLIB_CFLAGS@
-ZLIB_LIBS	= @ZLIB_LIBS@
-else
-ZLIB_CFLAGS	= @MOZ_ZLIB_CFLAGS@
+MOZ_ZLIB_CFLAGS	= @MOZ_ZLIB_CFLAGS@
 MOZ_ZLIB_LIBS = @MOZ_ZLIB_LIBS@
-endif
 
-ifdef MOZ_NATIVE_BZ2
-BZ2_CFLAGS	= @BZ2_CFLAGS@
-BZ2_LIBS	= @BZ2_LIBS@
-else
-BZ2_CFLAGS	= @MOZ_BZ2_CFLAGS@
-BZ2_LIBS	= @MOZ_BZ2_LIBS@
-endif
+MOZ_BZ2_CFLAGS	= @MOZ_BZ2_CFLAGS@
+MOZ_BZ2_LIBS	= @MOZ_BZ2_LIBS@
 
-ifdef MOZ_NATIVE_PNG
-PNG_CFLAGS	= @PNG_CFLAGS@
-PNG_LIBS	= @PNG_LIBS@
-else
-PNG_CFLAGS	= @MOZ_PNG_CFLAGS@
-PNG_LIBS	= @MOZ_PNG_LIBS@
-endif
+MOZ_PNG_CFLAGS	= @MOZ_PNG_CFLAGS@
+MOZ_PNG_LIBS	= @MOZ_PNG_LIBS@
 
 QCMS_LIBS	= @QCMS_LIBS@
 
 MOZ_HARFBUZZ_LIBS = @MOZ_HARFBUZZ_LIBS@
 MOZ_GRAPHITE_LIBS = @MOZ_GRAPHITE_LIBS@
 MOZ_GRAPHITE = @MOZ_GRAPHITE@
 MOZ_OTS_LIBS = @MOZ_OTS_LIBS@
 MOZ_SKIA_LIBS = @MOZ_SKIA_LIBS@
@@ -509,19 +475,16 @@ DLL_SUFFIX              = @DLL_SUFFIX@
 
 NO_LD_ARCHIVE_FLAGS     = @NO_LD_ARCHIVE_FLAGS@
 
 GTK_CONFIG	= @GTK_CONFIG@
 QT_CONFIG	= @QT_CONFIG@
 TK_CFLAGS	= @TK_CFLAGS@
 TK_LIBS		= @TK_LIBS@
 
-MOZ_TOOLKIT_REGISTRY_CFLAGS = \
-	$(TK_CFLAGS)
-
 CAIRO_FT_CFLAGS		= @CAIRO_FT_CFLAGS@
 
 MOZ_TREE_FREETYPE		= @MOZ_TREE_FREETYPE@
 MOZ_ENABLE_CAIRO_FT	= @MOZ_ENABLE_CAIRO_FT@
 MOZ_ENABLE_GTK2		= @MOZ_ENABLE_GTK2@
 MOZ_ENABLE_QT		= @MOZ_ENABLE_QT@
 MOZ_ENABLE_XREMOTE	= @MOZ_ENABLE_XREMOTE@
 MOZ_ENABLE_DWRITE_FONT	= @MOZ_ENABLE_DWRITE_FONT@
@@ -572,19 +535,19 @@ MOZ_ENABLE_LIBNOTIFY	= @MOZ_ENABLE_LIBNO
 
 MOZ_ALSA_LIBS           = @MOZ_ALSA_LIBS@
 MOZ_ALSA_CFLAGS         = @MOZ_ALSA_CFLAGS@
 
 GLIB_CFLAGS	= @GLIB_CFLAGS@
 GLIB_LIBS	= @GLIB_LIBS@
 GLIB_GMODULE_LIBS	= @GLIB_GMODULE_LIBS@
 
-MOZ_NATIVE_MAKEDEPEND	= @SYSTEM_MAKEDEPEND@
+MOZ_NATIVE_MAKEDEPEND	= @MOZ_NATIVE_MAKEDEPEND@
 
-export CL_INCLUDES_PREFIX = @CL_INCLUDES_PREFIX@
+CL_INCLUDES_PREFIX = @CL_INCLUDES_PREFIX@
 
 MOZ_AUTO_DEPS	= @MOZ_AUTO_DEPS@
 COMPILER_DEPEND = @COMPILER_DEPEND@
 MDDEPDIR        := @MDDEPDIR@
 CC_WRAPPER = @CC_WRAPPER@
 CXX_WRAPPER = @CXX_WRAPPER@
 
 MOZ_DEMANGLE_SYMBOLS = @MOZ_DEMANGLE_SYMBOLS@
@@ -692,20 +655,9 @@ JS_SHARED_LIBRARY = @JS_SHARED_LIBRARY@
 MOZ_INSTRUMENT_EVENT_LOOP = @MOZ_INSTRUMENT_EVENT_LOOP@
 
 MOZ_SYSTEM_PLY = @MOZ_SYSTEM_PLY@
 
 MOZ_PACKAGE_JSSHELL = @MOZ_PACKAGE_JSSHELL@
 
 MOZ_LINKER_EXTRACT = @MOZ_LINKER_EXTRACT@
 
-# We only want to do the pymake sanity on Windows, other os's can cope
-ifeq ($(HOST_OS_ARCH),WINNT)
-# Ensure invariants between GNU Make and pymake
-# Checked here since we want the sane error in a file that
-# actually can be found regardless of path-style.
-ifeq (_:,$(.PYMAKE)_$(findstring :,$(srcdir)))
-$(error Windows-style srcdir being used with GNU make. Did you mean to run $(topsrcdir)/build/pymake/make.py instead? [see-also: https://developer.mozilla.org/en/Gmake_vs._Pymake])
-endif
-ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(srcdir))))
-$(error MSYS-style srcdir being used with Pymake. Did you mean to run GNU Make instead? [see-also: https://developer.mozilla.org/en/Gmake_vs._Pymake])
-endif
-endif # WINNT
+include $(topsrcdir)/config/baseconfig.mk
new file mode 100644
--- /dev/null
+++ b/config/baseconfig.mk
@@ -0,0 +1,25 @@
+INCLUDED_AUTOCONF_MK = 1
+
+includedir := $(includedir)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
+idldir = $(datadir)/idl/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
+installdir = $(libdir)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
+sdkdir = $(libdir)/$(MOZ_APP_NAME)-devel-$(MOZ_APP_VERSION)
+DIST = $(DEPTH)/dist
+
+# We do magic with OBJ_SUFFIX in config.mk, the following ensures we don't
+# manually use it before config.mk inclusion
+_OBJ_SUFFIX := $(OBJ_SUFFIX)
+OBJ_SUFFIX = $(error config/config.mk needs to be included before using OBJ_SUFFIX)
+
+# We only want to do the pymake sanity on Windows, other os's can cope
+ifeq ($(HOST_OS_ARCH),WINNT)
+# Ensure invariants between GNU Make and pymake
+# Checked here since we want the sane error in a file that
+# actually can be found regardless of path-style.
+ifeq (_:,$(.PYMAKE)_$(findstring :,$(srcdir)))
+$(error Windows-style srcdir being used with GNU make. Did you mean to run $(topsrcdir)/build/pymake/make.py instead? [see-also:     https://developer.mozilla.org/en/Gmake_vs._Pymake])
+endif
+ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(srcdir))))
+$(error MSYS-style srcdir being used with Pymake. Did you mean to run GNU Make instead? [see-also: https://developer.mozilla.org/    en/Gmake_vs._Pymake])
+endif
+endif # WINNT
--- a/config/config.mk
+++ b/config/config.mk
@@ -365,29 +365,31 @@ MY_RULES	:= $(DEPTH)/config/myrules.mk
 CCC = $(CXX)
 XPIDL_LINK = $(PYTHON) $(LIBXUL_DIST)/sdk/bin/xpt.py link
 
 # Java macros
 JAVA_GEN_DIR  = _javagen
 JAVA_DIST_DIR = $(DEPTH)/$(JAVA_GEN_DIR)
 JAVA_IFACES_PKG_NAME = org/mozilla/interfaces
 
+OS_INCLUDES += $(NSPR_CFLAGS) $(NSS_CFLAGS) $(MOZ_JPEG_CFLAGS) $(MOZ_PNG_CFLAGS) $(MOZ_ZLIB_CFLAGS)
+
 INCLUDES = \
   $(LOCAL_INCLUDES) \
   -I$(srcdir) \
   -I. \
   -I$(DIST)/include \
   $(if $(LIBXUL_SDK),-I$(LIBXUL_SDK)/include) \
   $(OS_INCLUDES) \
   $(NULL)
 
 include $(topsrcdir)/config/static-checking-config.mk
 
-CFLAGS		= $(OS_CFLAGS)
-CXXFLAGS	= $(OS_CXXFLAGS)
+CFLAGS		= $(OS_CPPFLAGS) $(OS_CFLAGS)
+CXXFLAGS	= $(OS_CPPFLAGS) $(OS_CXXFLAGS)
 LDFLAGS		= $(OS_LDFLAGS) $(MOZ_FIX_LINK_PATHS)
 
 # Allow each module to override the *default* optimization settings
 # by setting MODULE_OPTIMIZE_FLAGS if the developer has not given
 # arguments to --enable-optimize
 ifdef MOZ_OPTIMIZE
 ifeq (1,$(MOZ_OPTIMIZE))
 ifdef MODULE_OPTIMIZE_FLAGS
@@ -484,18 +486,18 @@ HOST_CMMFLAGS += -fobjc-exceptions
 OS_COMPILE_CMFLAGS += -fobjc-exceptions
 OS_COMPILE_CMMFLAGS += -fobjc-exceptions
 ifeq ($(MOZ_WIDGET_TOOLKIT),uikit)
 OS_COMPILE_CMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
 OS_COMPILE_CMMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
 endif
 endif
 
-COMPILE_CFLAGS	= $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CFLAGS)
-COMPILE_CXXFLAGS = $(STL_FLAGS) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CXXFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CXXFLAGS)
+COMPILE_CFLAGS	= $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CFLAGS)
+COMPILE_CXXFLAGS = $(STL_FLAGS) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CXXFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CXXFLAGS)
 COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS)
 COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS)
 
 ifndef CROSS_COMPILE
 HOST_CFLAGS += $(RTL_FLAGS)
 endif
 
 #
@@ -788,8 +790,10 @@ EXPAND_LIBNAME = $(foreach lib,$(1),$(LI
 endif
 EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
 EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
 
 # Include internal ply only if needed
 ifndef MOZ_SYSTEM_PLY
 PLY_INCLUDE = -I$(topsrcdir)/other-licenses/ply
 endif
+
+export CL_INCLUDES_PREFIX
--- a/configure.in
+++ b/configure.in
@@ -866,17 +866,17 @@ MOZ_PATH_PROG(AUTOCONF, autoconf, :)
 MOZ_PATH_PROGS(UNZIP, unzip)
 if test -z "$UNZIP" -o "$UNZIP" = ":"; then
     AC_MSG_ERROR([unzip not found in \$PATH])
 fi
 MOZ_PATH_PROGS(ZIP, zip)
 if test -z "$ZIP" -o "$ZIP" = ":"; then
     AC_MSG_ERROR([zip not found in \$PATH])
 fi
-MOZ_PATH_PROG(SYSTEM_MAKEDEPEND, makedepend)
+MOZ_PATH_PROG(MOZ_NATIVE_MAKEDEPEND, makedepend)
 MOZ_PATH_PROG(XARGS, xargs)
 if test -z "$XARGS" -o "$XARGS" = ":"; then
     AC_MSG_ERROR([xargs not found in \$PATH .])
 fi
 
 MOZ_PATH_PROG(RPMBUILD, rpmbuild, :)
 AC_SUBST(RPMBUILD)
 
@@ -907,17 +907,17 @@ darwin*)
 This compiler was supplied with Xcode 2.0, and contains bugs that prevent it
 from building Mozilla. Upgrade to Xcode 2.1 or later.])
         fi
     fi
 
     dnl xcodebuild needs GCC_VERSION defined in the environment, since it
     dnl doesn't respect the CC/CXX setting.  With GCC_VERSION set, it will use
     dnl /usr/bin/g(cc|++)-$GCC_VERSION.
-    MOZ_PATH_PROGS(PBBUILD, pbbuild xcodebuild pbxbuild)
+    MOZ_PATH_PROGS(PBBUILD_BIN, pbbuild xcodebuild pbxbuild)
 
     dnl sdp was formerly in /Developer/Tools.  As of Mac OS X 10.4 (Darwin 8),
     dnl it has moved into /usr/bin.
     MOZ_PATH_PROG(SDP, sdp, :, [$PATH:/usr/bin:/Developer/Tools])
     ;;
 esac
 
 AC_SUBST(GCC_VERSION)
@@ -2090,17 +2090,17 @@ ia64*-hpux*)
        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
     else
        DSO_LDOPTS='-b -E'
        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
     fi
     MOZ_FIX_LINK_PATHS=
-    SYSTEM_MAKEDEPEND=
+    MOZ_NATIVE_MAKEDEPEND=
     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
     AC_DEFINE(_LARGEFILE64_SOURCE)
     ;;
 
 *-hpux*)
     DLL_SUFFIX=".sl"
     if test ! "$GNU_CC"; then
     	DSO_LDOPTS='-b -Wl,+s'
@@ -2179,17 +2179,17 @@ ia64*-hpux*)
 *-mingw*)
     DSO_CFLAGS=
     DSO_PIC_CFLAGS=
     DLL_SUFFIX=.dll
     RC=rc.exe
     MC=mc.exe
     # certain versions of cygwin's makedepend barf on the
     # #include <string> vs -I./dist/include/string issue so don't use it
-    SYSTEM_MAKEDEPEND=
+    MOZ_NATIVE_MAKEDEPEND=
     if test -n "$GNU_CC"; then
         CC="$CC -mwindows"
         CXX="$CXX -mwindows"
         CPP="$CPP -mwindows"
         CFLAGS="$CFLAGS -mms-bitfields"
         CXXFLAGS="$CXXFLAGS -mms-bitfields"
         DSO_LDOPTS='-shared'
         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
@@ -2460,17 +2460,17 @@ ia64*-hpux*)
     if test "$ac_os2_declspec" != "yes"; then
         AC_MSG_ERROR([Compiler does not support __declspec(dllexport), install GCC-4.3.2 or newer])
     fi
     ;;
 
 *-solaris*)
     AC_DEFINE(SOLARIS)
     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
-    SYSTEM_MAKEDEPEND=
+    MOZ_NATIVE_MAKEDEPEND=
     MOZ_FIX_LINK_PATHS=
     # $ORIGIN/.. is for shared libraries under components/ to locate shared
     # libraries one level up (e.g. libnspr4.so)
     if test "$SOLARIS_SUNPRO_CC"; then
        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
        LIBS="-lCrun -lCstd -lc $LIBS"
        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
@@ -4033,39 +4033,38 @@ MOZ_ARG_WITH_STRING(system-jpeg,
 _SAVE_CFLAGS=$CFLAGS
 _SAVE_LDFLAGS=$LDFLAGS
 _SAVE_LIBS=$LIBS
 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
 fi
 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
-    SYSTEM_JPEG=
+    MOZ_NATIVE_JPEG=
 else
-    AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [SYSTEM_JPEG=1 JPEG_LIBS="-ljpeg $JPEG_LIBS"], SYSTEM_JPEG=, $JPEG_LIBS)
-fi
-
-if test "$SYSTEM_JPEG" = 1; then
-    LIBS="$JPEG_LIBS $LIBS"
+    AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [MOZ_NATIVE_JPEG=1 MOZ_JPEG_LIBS="-ljpeg"], MOZ_NATIVE_JPEG=)
+fi
+
+if test "$MOZ_NATIVE_JPEG" = 1; then
     AC_TRY_COMPILE([ #include <stdio.h>
                      #include <sys/types.h>
                      #include <jpeglib.h> ],
                    [ #if JPEG_LIB_VERSION < $MOZJPEG
                      #error "Insufficient JPEG library version ($MOZJPEG required)."
                      #endif ],
-                   SYSTEM_JPEG=1,
+                   MOZ_NATIVE_JPEG=1,
                    AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
 fi
 CFLAGS=$_SAVE_CFLAGS
 LDFLAGS=$_SAVE_LDFLAGS
 LIBS=$_SAVE_LIBS
 
-if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$SYSTEM_JPEG" = 1; then
-    JPEG_CFLAGS="-I${JPEG_DIR}/include"
-    JPEG_LIBS="-L${JPEG_DIR}/lib ${JPEG_LIBS}"
+if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_NATIVE_JPEG" = 1; then
+    MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
+    MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_JPEG_LIBS}"
 fi
 
 dnl system ZLIB support
 dnl ========================================================
 MOZ_ARG_WITH_STRING(system-zlib,
 [  --with-system-zlib[=PFX]
                           Use system libz [installed at prefix PFX]],
     ZLIB_DIR=$withval)
@@ -4073,43 +4072,42 @@ MOZ_ARG_WITH_STRING(system-zlib,
 _SAVE_CFLAGS=$CFLAGS
 _SAVE_LDFLAGS=$LDFLAGS
 _SAVE_LIBS=$LIBS
 if test -n "${ZLIB_DIR}" -a "${ZLIB_DIR}" != "yes"; then
     CFLAGS="-I${ZLIB_DIR}/include $CFLAGS"
     LDFLAGS="-L${ZLIB_DIR}/lib $LDFLAGS"
 fi
 if test -z "$ZLIB_DIR" -o "$ZLIB_DIR" = no; then
-    SYSTEM_ZLIB=
+    MOZ_NATIVE_ZLIB=
 else
-    AC_CHECK_LIB(z, gzread, [SYSTEM_ZLIB=1 ZLIB_LIBS="-lz $ZLIB_LIBS"],
-	[SYSTEM_ZLIB= ZLIB_CFLAGS= ZLIB_LIBS=], $ZLIB_LIBS)
-fi
-if test "$SYSTEM_ZLIB" = 1; then
-    LIBS="$ZLIB_LIBS $LIBS"
+    AC_CHECK_LIB(z, gzread, [MOZ_NATIVE_ZLIB=1 MOZ_ZLIB_LIBS="-lz"],
+	[MOZ_NATIVE_ZLIB=])
+fi
+if test "$MOZ_NATIVE_ZLIB" = 1; then
     MOZZLIBNUM=`echo $MOZZLIB | awk -F. '{printf "0x%x\n", ((($1 * 16 + $2) * 16) + $3) * 16 + $4}'`
     AC_TRY_COMPILE([ #include <stdio.h>
                      #include <string.h>
                      #include <zlib.h> ],
                    [ #if ZLIB_VERNUM < $MOZZLIBNUM
                      #error "Insufficient zlib version ($MOZZLIBNUM required)."
                      #endif ],
-                   SYSTEM_ZLIB=1,
+                   MOZ_NATIVE_ZLIB=1,
                    AC_MSG_ERROR([Insufficient zlib version for --with-system-zlib ($MOZZLIB required)]))
 fi
 CFLAGS=$_SAVE_CFLAGS
 LDFLAGS=$_SAVE_LDFLAGS
 LIBS=$_SAVE_LIBS
 
-if test "${ZLIB_DIR}" -a -d "${ZLIB_DIR}" -a "$SYSTEM_ZLIB" = 1; then
-    ZLIB_CFLAGS="-I${ZLIB_DIR}/include"
-    ZLIB_LIBS="-L${ZLIB_DIR}/lib ${ZLIB_LIBS}"
-fi
-
-if test "$MOZ_LINKER" = 1 -a "$SYSTEM_ZLIB" != 1; then
+if test "${ZLIB_DIR}" -a -d "${ZLIB_DIR}" -a "$MOZ_NATIVE_ZLIB" = 1; then
+    MOZ_ZLIB_CFLAGS="-I${ZLIB_DIR}/include"
+    MOZ_ZLIB_LIBS="-L${ZLIB_DIR}/lib ${ZLIB_LIBS}"
+fi
+
+if test "$MOZ_LINKER" = 1 -a "$MOZ_NATIVE_ZLIB" != 1; then
     AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
 fi
 
 dnl system BZIP2 Support
 dnl ========================================================
 MOZ_ARG_WITH_STRING(system-bz2,
 [  --with-system-bz2[=PFX]
                           Use system libbz2 [installed at prefix PFX]],
@@ -4118,94 +4116,88 @@ MOZ_ARG_WITH_STRING(system-bz2,
 _SAVE_CFLAGS=$CFLAGS
 _SAVE_LDFLAGS=$LDFLAGS
 _SAVE_LIBS=$LIBS
 if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
     CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
     LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
 fi
 if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
-    SYSTEM_BZ2=
+    MOZ_NATIVE_BZ2=
 else
-    AC_CHECK_LIB(bz2, BZ2_bzread, [SYSTEM_BZ2=1 BZ2_LIBS="-lbz2"],
-	[SYSTEM_BZ2= BZ2_CFLAGS= BZ2_LIBS=])
+    AC_CHECK_LIB(bz2, BZ2_bzread, [MOZ_NATIVE_BZ2=1 MOZ_BZ2_LIBS="-lbz2"],
+	[MOZ_NATIVE_BZ2= MOZ_BZ2_CFLAGS= MOZ_BZ2_LIBS=])
 fi
 CFLAGS=$_SAVE_CFLAGS
 LDFLAGS=$_SAVE_LDFLAGS
 LIBS=$_SAVE_LIBS
 
-if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$SYSTEM_BZ2" = 1; then
-    BZ2_CFLAGS="-I${BZ2_DIR}/include"
-    BZ2_LIBS="-L${BZ2_DIR}/lib ${BZ2_LIBS}"
+if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$MOZ_NATIVE_BZ2" = 1; then
+    MOZ_BZ2_CFLAGS="-I${BZ2_DIR}/include"
+    MOZ_BZ2_LIBS="-L${BZ2_DIR}/lib ${MOZ_BZ2_LIBS}"
 fi
 
 dnl system PNG Support
 dnl ========================================================
 MOZ_ARG_WITH_STRING(system-png,
 [  --with-system-png[=PFX]
                           Use system libpng [installed at prefix PFX]],
     PNG_DIR=$withval)
 
 _SAVE_CFLAGS=$CFLAGS
 _SAVE_LDFLAGS=$LDFLAGS
 _SAVE_LIBS=$LIBS
-CFLAGS="$ZLIB_CFLAGS $CFLAGS"
-LDFLAGS="$ZLIB_LIBS -lz $LDFLAGS"
 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
 fi
 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
-    SYSTEM_PNG=
+    MOZ_NATIVE_PNG=
 else
-    _SAVE_PNG_LIBS=$PNG_LIBS
-    AC_CHECK_LIB(png, png_get_valid, [SYSTEM_PNG=1 PNG_LIBS="-lpng $PNG_LIBS"],
-                 AC_MSG_ERROR([--with-system-png requested but no working libpng found]),
-                 $PNG_LIBS)
+    AC_CHECK_LIB(png, png_get_valid, [MOZ_NATIVE_PNG=1 MOZ_PNG_LIBS="-lpng"],
+                 AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
     AC_CHECK_LIB(png, png_get_acTL, ,
-                 AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]),
-                 $_SAVE_PNG_LIBS)
-fi
-if test "$SYSTEM_PNG" = 1; then
-    LIBS="$PNG_LIBS $LIBS"
+                 AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
+fi
+if test "$MOZ_NATIVE_PNG" = 1; then
     AC_TRY_COMPILE([ #include <stdio.h>
                      #include <sys/types.h>
                      #include <png.h> ],
                    [ #if PNG_LIBPNG_VER < $MOZPNG
                      #error "Insufficient libpng version ($MOZPNG required)."
                      #endif
                      #ifndef PNG_UINT_31_MAX
                      #error "Insufficient libpng version."
                      #endif ],
-                   SYSTEM_PNG=1,
+                   MOZ_NATIVE_PNG=1,
                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
 fi
 CFLAGS=$_SAVE_CFLAGS
 LDFLAGS=$_SAVE_LDFLAGS
 LIBS=$_SAVE_LIBS
 
-if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$SYSTEM_PNG" = 1; then
-    PNG_CFLAGS="-I${PNG_DIR}/include"
-    PNG_LIBS="-L${PNG_DIR}/lib ${PNG_LIBS}"
+if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_NATIVE_PNG" = 1; then
+    MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
+    MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
 fi
 
 fi # SKIP_LIBRARY_CHECKS
 
 dnl system HunSpell Support
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(system-hunspell,
 [  --enable-system-hunspell
                           Use system hunspell (located with pkgconfig)],
-    SYSTEM_HUNSPELL=1 )
-
-if test -n "$SYSTEM_HUNSPELL"; then
+    MOZ_NATIVE_HUNSPELL=1 )
+
+if test -n "$MOZ_NATIVE_HUNSPELL"; then
     PKG_CHECK_MODULES(MOZ_HUNSPELL, hunspell)
 fi
 
-AC_SUBST(SYSTEM_HUNSPELL)
+AC_SUBST(MOZ_NATIVE_HUNSPELL)
 
 dnl ========================================================
 dnl system libffi Support
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(system-ffi,
 [  --enable-system-ffi       Use system libffi (located with pkgconfig)],
     MOZ_NATIVE_FFI=1 )
 
@@ -5873,26 +5865,26 @@ if test -z "$MOZ_CRASHREPORTER_ENABLE_PE
    MOZ_CRASHREPORTER_ENABLE_PERCENT=100
 fi
 AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT)
 
 dnl ========================================================
 dnl = libjpeg-turbo configuration
 dnl ========================================================
 MOZ_LIBJPEG_TURBO=
-if test -z "$SYSTEM_JPEG"; then
+if test -z "$MOZ_NATIVE_JPEG"; then
     MOZ_LIBJPEG_TURBO=1
 fi
 
 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
     MOZ_LIBJPEG_TURBO=,
     MOZ_LIBJPEG_TURBO=1)
 
-if test "$SYSTEM_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
+if test "$MOZ_NATIVE_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
 fi
 
 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
 dnl files.
 
 if test -n "$MOZ_LIBJPEG_TURBO"; then
 
@@ -8479,31 +8471,22 @@ COMPILE_CFLAGS=`echo \
 	$_DEPEND_CFLAGS \
     $COMPILE_CFLAGS`
 
 COMPILE_CXXFLAGS=`echo \
     $_DEFINES_CXXFLAGS \
 	$_DEPEND_CFLAGS \
     $COMPILE_CXXFLAGS`
 
-AC_SUBST(SYSTEM_MAKEDEPEND)
+AC_SUBST(MOZ_NATIVE_MAKEDEPEND)
 AC_SUBST(SYSTEM_LIBXUL)
-AC_SUBST(SYSTEM_JPEG)
-AC_SUBST(SYSTEM_PNG)
-AC_SUBST(SYSTEM_ZLIB)
-AC_SUBST(SYSTEM_BZ2)
-
-AC_SUBST(JPEG_CFLAGS)
-AC_SUBST(JPEG_LIBS)
-AC_SUBST(ZLIB_CFLAGS)
-AC_SUBST(ZLIB_LIBS)
-AC_SUBST(BZ2_CFLAGS)
-AC_SUBST(BZ2_LIBS)
-AC_SUBST(PNG_CFLAGS)
-AC_SUBST(PNG_LIBS)
+AC_SUBST(MOZ_NATIVE_JPEG)
+AC_SUBST(MOZ_NATIVE_PNG)
+AC_SUBST(MOZ_NATIVE_ZLIB)
+AC_SUBST(MOZ_NATIVE_BZ2)
 
 AC_SUBST(MOZ_FLEXBOX)
 AC_SUBST(MOZ_JPEG_CFLAGS)
 AC_SUBST(MOZ_JPEG_LIBS)
 AC_SUBST(MOZ_ZLIB_CFLAGS)
 AC_SUBST(MOZ_ZLIB_LIBS)
 AC_SUBST(MOZ_BZ2_CFLAGS)
 AC_SUBST(MOZ_BZ2_LIBS)
@@ -8515,23 +8498,30 @@ AC_SUBST(NSPR_LIBS)
 AC_SUBST(MOZ_NATIVE_NSPR)
 
 AC_SUBST(NSS_CFLAGS)
 AC_SUBST(NSS_LIBS)
 AC_SUBST(NSS_DEP_LIBS)
 AC_SUBST(MOZ_NATIVE_NSS)
 AC_SUBST(NSS_DISABLE_DBM)
 
-AC_SUBST(CFLAGS)
-AC_SUBST(CXXFLAGS)
-AC_SUBST(CPPFLAGS)
-AC_SUBST(COMPILE_CFLAGS)
-AC_SUBST(COMPILE_CXXFLAGS)
-AC_SUBST(LDFLAGS)
-AC_SUBST(LIBS)
+OS_CFLAGS="$CFLAGS"
+OS_CXXFLAGS="$CXXFLAGS"
+OS_CPPFLAGS="$CPPFLAGS"
+OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
+OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
+OS_LDFLAGS="$LDFLAGS"
+OS_LIBS="$LIBS"
+AC_SUBST(OS_CFLAGS)
+AC_SUBST(OS_CXXFLAGS)
+AC_SUBST(OS_CPPFLAGS)
+AC_SUBST(OS_COMPILE_CFLAGS)
+AC_SUBST(OS_COMPILE_CXXFLAGS)
+AC_SUBST(OS_LDFLAGS)
+AC_SUBST(OS_LIBS)
 AC_SUBST(CROSS_COMPILE)
 AC_SUBST(WCHAR_CFLAGS)
 
 AC_SUBST(HOST_CC)
 AC_SUBST(HOST_CXX)
 AC_SUBST(HOST_CFLAGS)
 AC_SUBST(HOST_CXXFLAGS)
 AC_SUBST(HOST_LDFLAGS)
@@ -8822,18 +8812,18 @@ EOF
 dnl Probably shouldn't call this manually but we always want the output of DEFS
 rm -f confdefs.h.save
 mv confdefs.h confdefs.h.save
 $FIXED_EGREP -v "$_EGREP_PATTERN" confdefs.h.save > confdefs.h
 if test "$?" != 0; then
   AC_MSG_ERROR([Error outputting confdefs.h])
 fi
 AC_OUTPUT_MAKE_DEFS()
-MOZ_DEFINES=$DEFS
-AC_SUBST(MOZ_DEFINES)
+ACDEFINES=$DEFS
+AC_SUBST(ACDEFINES)
 rm -f confdefs.h
 mv confdefs.h.save confdefs.h
 
 dnl Create a virtualenv where we can install local Python packages
 AC_MSG_RESULT([Creating Python virtualenv])
 rm -rf _virtualenv
 mkdir -p _virtualenv
 MACOSX_DEPLOYMENT_TARGET= PYTHONDONTWRITEBYTECODE= $PYTHON $_topsrcdir/other-licenses/virtualenv/virtualenv.py --system-site-packages ./_virtualenv
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -1567,16 +1567,17 @@ public:
    */
   static nsresult ProcessViewportInfo(nsIDocument *aDocument,
                                       const nsAString &viewportInfo);
 
   static nsIScriptContext* GetContextForEventHandlers(nsINode* aNode,
                                                       nsresult* aRv);
 
   static JSContext *GetCurrentJSContext();
+  static JSContext *GetSafeJSContext();
 
   /**
    * Case insensitive comparison between two strings. However it only ignores
    * case for ASCII characters a-z.
    */
   static bool EqualsIgnoreASCIICase(const nsAString& aStr1,
                                     const nsAString& aStr2);
 
--- a/content/base/public/nsIXMLHttpRequest.idl
+++ b/content/base/public/nsIXMLHttpRequest.idl
@@ -244,26 +244,26 @@ interface nsIXMLHttpRequest : nsISupport
    *             Content-Length header will be added to the HTTP request
    *             with a value given by nsIInputStream.available.  Any
    *             headers included at the top of the stream will be
    *             treated as part of the message body.  The MIME type of
    *             the stream should be specified by setting the Content-
    *             Type header via the setRequestHeader method before
    *             calling send.
    */
-  [implicit_jscontext] void   send([optional] in nsIVariant body);
+  void   send([optional] in nsIVariant body);
 
   /**
    * A variant of the send() method used to send binary data.
    *
    * @param body The request body as a DOM string.  The string data will be
    *             converted to a single-byte string by truncation (i.e., the
    *             high-order byte of each character will be discarded).
    */
-  [implicit_jscontext] void   sendAsBinary(in DOMString body);
+  void   sendAsBinary(in DOMString body);
 
   /**
    * Sets a HTTP request header for HTTP requests. You must call open
    * before setting the request headers.
    *
    * @param header The name of the header to set in the request.
    * @param value The body of the header.
    */
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -5450,16 +5450,23 @@ nsContentUtils::GetCurrentJSContext()
   JSContext *cx = nsnull;
 
   sThreadJSContextStack->Peek(&cx);
 
   return cx;
 }
 
 /* static */
+JSContext *
+nsContentUtils::GetSafeJSContext()
+{
+  return sThreadJSContextStack->GetSafeJSContext();
+}
+
+/* static */
 nsresult
 nsContentUtils::ASCIIToLower(nsAString& aStr)
 {
   PRUnichar* iter = aStr.BeginWriting();
   PRUnichar* end = aStr.EndWriting();
   if (NS_UNLIKELY(!iter || !end)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -2816,17 +2816,20 @@ nsDocument::ElementFromPointHelper(float
                                                       aIgnoreRootScrollFrame);
   if (!ptFrame)
     return NS_OK;
 
   nsIContent* elem = GetContentInThisDocument(ptFrame);
   if (elem && !elem->IsElement()) {
     elem = elem->GetParent();
   }
-  return CallQueryInterface(elem, aReturn);
+  if (elem) {
+    CallQueryInterface(elem, aReturn);
+  }
+  return NS_OK;
 }
 
 nsresult
 nsDocument::NodesFromRectHelper(float aX, float aY,
                                 float aTopSize, float aRightSize,
                                 float aBottomSize, float aLeftSize,
                                 bool aIgnoreRootScrollFrame,
                                 bool aFlushLayout,
@@ -2866,22 +2869,22 @@ nsDocument::NodesFromRectHelper(float aX
 
   nsAutoTArray<nsIFrame*,8> outFrames;
   nsLayoutUtils::GetFramesForArea(rootFrame, rect, outFrames,
                                   true, aIgnoreRootScrollFrame);
 
   // Used to filter out repeated elements in sequence.
   nsIContent* lastAdded = nsnull;
 
-  for (PRInt32 i = 0; i < outFrames.Length(); i++) {
+  for (PRUint32 i = 0; i < outFrames.Length(); i++) {
     nsIContent* node = GetContentInThisDocument(outFrames[i]);
 
     if (node && !node->IsElement() && !node->IsNodeOfType(nsINode::eTEXT)) {
-      // If we have a node that isn't an element or a text node,
-      // replace it with the first parent node.
+      // We have a node that isn't an element or a text node,
+      // use its parent content instead.
       node = node->GetParent();
     }
     if (node && node != lastAdded) {
       elements->AppendElement(node);
       lastAdded = node;
     }
   }
 
@@ -7155,22 +7158,22 @@ nsDocument::DoUnblockOnload()
   }
 }
 
 nsIContent*
 nsDocument::GetContentInThisDocument(nsIFrame* aFrame) const
 {
   for (nsIFrame* f = aFrame; f;
        f = nsLayoutUtils::GetParentOrPlaceholderForCrossDoc(f)) {
-    nsIContent* ptContent = f->GetContent();
-    if (!ptContent || ptContent->IsInAnonymousSubtree())
+    nsIContent* content = f->GetContent();
+    if (!content || content->IsInAnonymousSubtree())
       continue;
 
-    if (ptContent->OwnerDoc() == this) {
-      return ptContent;
+    if (content->OwnerDoc() == this) {
+      return content;
     }
     // We must be in a subdocument so jump directly to the root frame.
     // GetParentOrPlaceholderForCrossDoc gets called immediately to jump up to
     // the containing document.
     f = f->PresContext()->GetPresShell()->GetRootFrame();
   }
 
   return nsnull;
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -1252,19 +1252,22 @@ private:
   // pending pointer lock request; calling this clears the previous pending
   // request.
   static nsresult SetPendingPointerLockRequest(Element* aElement);
 
   // Clears any pending pointer lock request.
   static void ClearPendingPointerLockRequest(bool aDispatchErrorEvents);
 
   /**
-   * Find the (non-anonymous) element in this document that contains the
-   * content (possibly in a subdocument) associated with aFrame. Returns null
-   * if there is no such element.
+   * Find the (non-anonymous) content in this document for aFrame. It will
+   * be aFrame's content node if that content is in this document and not
+   * anonymous. Otherwise, when aFrame is in a subdocument, we use the frame
+   * element containing the subdocument containing aFrame, and/or find the
+   * nearest non-anonymous ancestor in this document.
+   * Returns null if there is no such element.
    */
   nsIContent* GetContentInThisDocument(nsIFrame* aFrame) const;
 
   // Just like EnableStyleSheetsForSet, but doesn't check whether
   // aSheetSet is null and allows the caller to control whether to set
   // aSheetSet as the preferred set in the CSSLoader.
   void EnableStyleSheetsForSetInternal(const nsAString& aSheetSet,
                                        bool aUpdateCSSLoader);
--- a/content/base/src/nsFrameLoader.cpp
+++ b/content/base/src/nsFrameLoader.cpp
@@ -10,16 +10,17 @@
  */
 
 #include "base/basictypes.h"
 
 #include "prenv.h"
 
 #include "nsIDOMHTMLIFrameElement.h"
 #include "nsIDOMHTMLFrameElement.h"
+#include "nsIDOMMozBrowserFrame.h"
 #include "nsIDOMWindow.h"
 #include "nsIPresShell.h"
 #include "nsIContent.h"
 #include "nsIContentViewer.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsPIDOMWindow.h"
 #include "nsIWebNavigation.h"
@@ -647,16 +648,26 @@ AddTreeItemToTreeOwner(nsIDocShellTreeIt
   // we accept "content" and "content-xxx" values.
   // at time of writing, we expect "xxx" to be "primary" or "targetable", but
   // someday it might be an integer expressing priority or something else.
 
   isContent = value.LowerCaseEqualsLiteral("content") ||
     StringBeginsWith(value, NS_LITERAL_STRING("content-"),
                      nsCaseInsensitiveStringComparator());
 
+  // Force mozbrowser frames to always be typeContent, even if the
+  // mozbrowser interfaces are disabled.
+  nsCOMPtr<nsIDOMMozBrowserFrame> mozbrowser =
+    do_QueryInterface(aOwningContent);
+  if (mozbrowser) {
+    bool isMozbrowser = false;
+    mozbrowser->GetMozbrowser(&isMozbrowser);
+    isContent |= isMozbrowser;
+  }
+
   if (isContent) {
     // The web shell's type is content.
 
     aItem->SetItemType(nsIDocShellTreeItem::typeContent);
   } else {
     // Inherit our type from our parent docshell.  If it is
     // chrome, we'll be chrome.  If it is content, we'll be
     // content.
--- a/content/base/src/nsImageLoadingContent.cpp
+++ b/content/base/src/nsImageLoadingContent.cpp
@@ -1009,20 +1009,54 @@ nsImageLoadingContent::PreparePendingReq
   ClearPendingRequest(NS_ERROR_IMAGE_SRC_CHANGED);
 
   mPendingRequestNeedsResetAnimation = mNewRequestsWillNeedAnimationReset;
 
   // Return a reference.
   return mPendingRequest;
 }
 
+namespace {
+
+class ImageRequestAutoLock
+{
+public:
+  ImageRequestAutoLock(imgIRequest* aRequest)
+    : mRequest(aRequest)
+  {
+    if (mRequest) {
+      mRequest->LockImage();
+    }
+  }
+
+  ~ImageRequestAutoLock()
+  {
+    if (mRequest) {
+      mRequest->UnlockImage();
+    }
+  }
+
+private:
+  nsCOMPtr<imgIRequest> mRequest;
+};
+
+} // anonymous namespace
+
 void
 nsImageLoadingContent::MakePendingRequestCurrent()
 {
   MOZ_ASSERT(mPendingRequest);
+
+  // Lock mCurrentRequest for the duration of this method.  We do this because
+  // PrepareCurrentRequest() might unlock mCurrentRequest.  If mCurrentRequest
+  // and mPendingRequest are both requests for the same image, unlocking
+  // mCurrentRequest before we lock mPendingRequest can cause the lock count
+  // to go to 0 and the image to be discarded!
+  ImageRequestAutoLock autoLock(mCurrentRequest);
+
   PrepareCurrentRequest() = mPendingRequest;
   mPendingRequest = nsnull;
   mCurrentRequestNeedsResetAnimation = mPendingRequestNeedsResetAnimation;
   mPendingRequestNeedsResetAnimation = false;
   ResetAnimationIfNeeded();
 }
 
 void
--- a/content/base/src/nsInProcessTabChildGlobal.cpp
+++ b/content/base/src/nsInProcessTabChildGlobal.cpp
@@ -251,17 +251,18 @@ nsInProcessTabChildGlobal::GetOwnerConte
   return mOwner;
 }
 
 nsresult
 nsInProcessTabChildGlobal::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
 {
   aVisitor.mCanHandle = true;
 
-  if (mIsBrowserFrame) {
+  if (mIsBrowserFrame &&
+      (!mOwner || !nsContentUtils::IsInChromeDocshell(mOwner->OwnerDoc()))) {
     if (mOwner) {
       nsPIDOMWindow* innerWindow = mOwner->OwnerDoc()->GetInnerWindow();
       if (innerWindow) {
         aVisitor.mParentTarget = innerWindow->GetParentTarget();
       }
     }
   } else {
     aVisitor.mParentTarget = mOwner;
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -544,42 +544,50 @@ nsXMLHttpRequest::Initialize(nsISupports
     NS_ENSURE_SUCCESS(rv, rv);
   }
   return NS_OK;
 }
 
 nsresult
 nsXMLHttpRequest::InitParameters(JSContext* aCx, const jsval* aParams)
 {
-  XMLHttpRequestParameters* params = new XMLHttpRequestParameters();
-  nsresult rv = params->Init(aCx, aParams);
+  XMLHttpRequestParameters params;
+  nsresult rv = params.Init(aCx, aParams);
   NS_ENSURE_SUCCESS(rv, rv);
 
+  InitParameters(params.mozAnon, params.mozSystem);
+  return NS_OK;
+}
+
+void
+nsXMLHttpRequest::InitParameters(bool aAnon, bool aSystem)
+{
   // Check for permissions.
   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(GetOwner());
-  NS_ENSURE_TRUE(window && window->GetDocShell(), NS_OK);
+  if (!window || !window->GetDocShell()) {
+    return;
+  }
 
   // Chrome is always allowed access, so do the permission check only
   // for non-chrome pages.
   if (!nsContentUtils::IsCallerChrome()) {
     nsCOMPtr<nsIDocument> doc = do_QueryInterface(window->GetExtantDocument());
-    NS_ENSURE_TRUE(doc, NS_OK);
+    if (!doc) {
+      return;
+    }
 
     nsCOMPtr<nsIURI> uri;
     doc->NodePrincipal()->GetURI(getter_AddRefs(uri));
-
     if (!nsContentUtils::URIIsChromeOrInPref(uri, "dom.systemXHR.whitelist")) {
-      return NS_OK;
+      return;
     }
   }
 
-  mIsAnon = params->mozAnon;
-  mIsSystem = params->mozSystem;
-
-  return NS_OK;
+  mIsAnon = aAnon;
+  mIsSystem = aSystem;
 }
 
 void
 nsXMLHttpRequest::ResetResponse()
 {
   mResponseXML = nsnull;
   mResponseBody.Truncate();
   mResponseText.Truncate();
@@ -2491,25 +2499,25 @@ nsXMLHttpRequest::ChangeStateToDone()
   }
   else if (!(mState & XML_HTTP_REQUEST_GOT_FINAL_STOP)) {
     // We're a multipart request, so we're not done. Reset to opened.
     ChangeState(XML_HTTP_REQUEST_OPENED);
   }
 }
 
 NS_IMETHODIMP
-nsXMLHttpRequest::SendAsBinary(const nsAString &aBody, JSContext *aCx)
+nsXMLHttpRequest::SendAsBinary(const nsAString &aBody)
 {
   ErrorResult rv;
-  SendAsBinary(aCx, aBody, rv);
+  SendAsBinary(aBody, rv);
   return rv.ErrorCode();
 }
 
 void
-nsXMLHttpRequest::SendAsBinary(JSContext *aCx, const nsAString &aBody,
+nsXMLHttpRequest::SendAsBinary(const nsAString &aBody,
                                ErrorResult& aRv)
 {
   char *data = static_cast<char*>(NS_Alloc(aBody.Length() + 1));
   if (!data) {
     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
 
@@ -2537,17 +2545,17 @@ nsXMLHttpRequest::SendAsBinary(JSContext
 
   nsCOMPtr<nsIWritableVariant> variant = new nsVariant();
 
   aRv = variant->SetAsISupports(stream);
   if (aRv.Failed()) {
     return;
   }
 
-  aRv = Send(variant, aCx);
+  aRv = Send(variant);
 }
 
 static nsresult
 GetRequestBody(nsIDOMDocument* aDoc, nsIInputStream** aResult,
                nsACString& aContentType, nsACString& aCharset)
 {
   aContentType.AssignLiteral("application/xml");
   nsAutoString inputEncoding;
@@ -2628,17 +2636,17 @@ GetRequestBody(ArrayBuffer* aArrayBuffer
   NS_ENSURE_SUCCESS(rv, rv);
 
   stream.forget(aResult);
 
   return NS_OK;
 }
 
 static nsresult
-GetRequestBody(nsIVariant* aBody, JSContext *aCx, nsIInputStream** aResult,
+GetRequestBody(nsIVariant* aBody, nsIInputStream** aResult,
                nsACString& aContentType, nsACString& aCharset)
 {
   *aResult = nsnull;
 
   PRUint16 dataType;
   nsresult rv = aBody->GetDataType(&dataType);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -2675,22 +2683,37 @@ GetRequestBody(nsIVariant* aBody, JSCont
     // nsIXHRSendable?
     nsCOMPtr<nsIXHRSendable> sendable = do_QueryInterface(supports);
     if (sendable) {
       return GetRequestBody(sendable, aResult, aContentType, aCharset);
     }
 
     // ArrayBuffer?
     jsval realVal;
+    nsCxPusher pusher;
+    JSAutoEnterCompartment ac;
     JSObject* obj;
+
+    // If there's a context on the stack, we can just use it. Otherwise, we need
+    // to use the safe js context (and push it into the stack, so that it's
+    // visible to cx-less functions that we might call here).
+    JSContext* cx = nsContentUtils::GetCurrentJSContext();
+    if (!cx) {
+      cx = nsContentUtils::GetSafeJSContext();
+      if (!pusher.Push(cx)) {
+        return NS_ERROR_FAILURE;
+      }
+    }
+
     nsresult rv = aBody->GetAsJSVal(&realVal);
     if (NS_SUCCEEDED(rv) && !JSVAL_IS_PRIMITIVE(realVal) &&
         (obj = JSVAL_TO_OBJECT(realVal)) &&
-        (JS_IsArrayBufferObject(obj, aCx))) {
-      ArrayBuffer buf(aCx, obj);
+        ac.enter(cx, obj) &&
+        (JS_IsArrayBufferObject(obj, cx))) {
+      ArrayBuffer buf(cx, obj);
       return GetRequestBody(&buf, aResult, aContentType, aCharset);
     }
   }
   else if (dataType == nsIDataType::VTYPE_VOID ||
            dataType == nsIDataType::VTYPE_EMPTY) {
     // Makes us act as if !aBody, don't upload anything
     aContentType.AssignLiteral("text/plain");
     aCharset.AssignLiteral("UTF-8");
@@ -2706,23 +2729,23 @@ GetRequestBody(nsIVariant* aBody, JSCont
   nsString string;
   string.Adopt(data, len);
 
   return GetRequestBody(string, aResult, aContentType, aCharset);
 }
 
 /* static */
 nsresult
-nsXMLHttpRequest::GetRequestBody(nsIVariant* aVariant, JSContext *aCx,
+nsXMLHttpRequest::GetRequestBody(nsIVariant* aVariant,
                                  const Nullable<RequestBody>& aBody,
                                  nsIInputStream** aResult,
                                  nsACString& aContentType, nsACString& aCharset)
 {
   if (aVariant) {
-    return ::GetRequestBody(aVariant, aCx, aResult, aContentType, aCharset);
+    return ::GetRequestBody(aVariant, aResult, aContentType, aCharset);
   }
 
   const RequestBody& body = aBody.Value();
   RequestBody::Value value = body.GetValue();
   switch (body.GetType()) {
     case nsXMLHttpRequest::RequestBody::ArrayBuffer:
     {
       return ::GetRequestBody(value.mArrayBuffer, aResult, aContentType, aCharset);
@@ -2763,23 +2786,23 @@ nsXMLHttpRequest::GetRequestBody(nsIVari
   }
 
   NS_NOTREACHED("Default cases exist for a reason");
   return NS_OK;
 }
 
 /* void send (in nsIVariant aBody); */
 NS_IMETHODIMP
-nsXMLHttpRequest::Send(nsIVariant *aBody, JSContext *aCx)
+nsXMLHttpRequest::Send(nsIVariant *aBody)
 {
-  return Send(aCx, aBody, Nullable<RequestBody>());
+  return Send(aBody, Nullable<RequestBody>());
 }
 
 nsresult
-nsXMLHttpRequest::Send(JSContext *aCx, nsIVariant* aVariant, const Nullable<RequestBody>& aBody)
+nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable<RequestBody>& aBody)
 {
   NS_ENSURE_TRUE(mPrincipal, NS_ERROR_NOT_INITIALIZED);
 
   nsresult rv = CheckInnerWindowCorrectness();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Return error if we're already processing a request
   if (XML_HTTP_REQUEST_SENT & mState) {
@@ -2893,17 +2916,17 @@ nsXMLHttpRequest::Send(JSContext *aCx, n
   mUploadProgressMax = 0;
   if ((aVariant || !aBody.IsNull()) && httpChannel &&
       !method.EqualsLiteral("GET")) {
 
     nsCAutoString charset;
     nsCAutoString defaultContentType;
     nsCOMPtr<nsIInputStream> postDataStream;
 
-    rv = GetRequestBody(aVariant, aCx, aBody, getter_AddRefs(postDataStream),
+    rv = GetRequestBody(aVariant, aBody, getter_AddRefs(postDataStream),
                         defaultContentType, charset);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (postDataStream) {
       // If no content type header was set by the client, we set it to
       // application/xml.
       nsCAutoString contentType;
       if (NS_FAILED(httpChannel->
--- a/content/base/src/nsXMLHttpRequest.h
+++ b/content/base/src/nsXMLHttpRequest.h
@@ -177,34 +177,31 @@ public:
   {
     return GetOwner();
   }
 
   // The WebIDL constructor.
   static already_AddRefed<nsXMLHttpRequest>
   Constructor(JSContext* aCx,
               nsISupports* aGlobal,
-              const mozilla::dom::Optional<jsval>& aParams,
+              const mozilla::dom::Nullable<mozilla::dom::MozXMLHttpRequestParameters>& aParams,
               ErrorResult& aRv)
   {
     nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal);
     nsCOMPtr<nsIScriptObjectPrincipal> principal = do_QueryInterface(aGlobal);
     if (!window || ! principal) {
       aRv.Throw(NS_ERROR_FAILURE);
       return NULL;
     }
 
     nsRefPtr<nsXMLHttpRequest> req = new nsXMLHttpRequest();
     req->Construct(principal->GetPrincipal(), window);
-    if (aParams.WasPassed()) {
-      nsresult rv = req->InitParameters(aCx, &aParams.Value());
-      if (NS_FAILED(rv)) {
-        aRv.Throw(rv);
-        return req.forget();
-      }
+    if (!aParams.IsNull()) {
+      const mozilla::dom::MozXMLHttpRequestParameters& params = aParams.Value();
+      req->InitParameters(params.mozAnon, params.mozSystem);
     }
     return req.forget();
   }
 
   void Construct(nsIPrincipal* aPrincipal,
                  nsPIDOMWindow* aOwnerWindow,
                  nsIURI* aBaseURI = NULL)
   {
@@ -212,16 +209,17 @@ public:
     MOZ_ASSERT_IF(aOwnerWindow, aOwnerWindow->IsInnerWindow());
     mPrincipal = aPrincipal;
     BindToOwner(aOwnerWindow);
     mBaseURI = aBaseURI;
   }
 
   // Initialize XMLHttpRequestParameter object.
   nsresult InitParameters(JSContext* aCx, const jsval* aParams);
+  void InitParameters(bool aAnon, bool aSystem);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIXMLHttpRequest
   NS_DECL_NSIXMLHTTPREQUEST
 
   // nsIJSXMLHttpRequest
   NS_IMETHOD GetOnuploadprogress(nsIDOMEventListener** aOnuploadprogress);
@@ -367,73 +365,70 @@ private:
     }
 
   private:
     Type mType;
     Value mValue;
   };
 
   static nsresult GetRequestBody(nsIVariant* aVariant,
-                                 JSContext* aCx,
                                  const Nullable<RequestBody>& aBody,
                                  nsIInputStream** aResult,
                                  nsACString& aContentType,
                                  nsACString& aCharset);
 
-  // XXXbz once the nsIVariant bits here go away, we can remove the
-  // implicitJSContext bits in Bindings.conf.
-  nsresult Send(JSContext *aCx, nsIVariant* aVariant, const Nullable<RequestBody>& aBody);
-  nsresult Send(JSContext *aCx, const Nullable<RequestBody>& aBody)
+  nsresult Send(nsIVariant* aVariant, const Nullable<RequestBody>& aBody);
+  nsresult Send(const Nullable<RequestBody>& aBody)
   {
-    return Send(aCx, nsnull, aBody);
+    return Send(nsnull, aBody);
   }
-  nsresult Send(JSContext *aCx, const RequestBody& aBody)
+  nsresult Send(const RequestBody& aBody)
   {
-    return Send(aCx, Nullable<RequestBody>(aBody));
+    return Send(Nullable<RequestBody>(aBody));
   }
 
 public:
-  void Send(JSContext *aCx, ErrorResult& aRv)
+  void Send(ErrorResult& aRv)
   {
-    aRv = Send(aCx, Nullable<RequestBody>());
+    aRv = Send(Nullable<RequestBody>());
   }
-  void Send(JSContext *aCx, mozilla::dom::ArrayBuffer& aArrayBuffer, ErrorResult& aRv)
+  void Send(mozilla::dom::ArrayBuffer& aArrayBuffer, ErrorResult& aRv)
   {
-    aRv = Send(aCx, RequestBody(&aArrayBuffer));
+    aRv = Send(RequestBody(&aArrayBuffer));
   }
-  void Send(JSContext *aCx, nsIDOMBlob* aBlob, ErrorResult& aRv)
+  void Send(nsIDOMBlob* aBlob, ErrorResult& aRv)
   {
     NS_ASSERTION(aBlob, "Null should go to string version");
-    aRv = Send(aCx, RequestBody(aBlob));
+    aRv = Send(RequestBody(aBlob));
   }
-  void Send(JSContext *aCx, nsIDocument* aDoc, ErrorResult& aRv)
+  void Send(nsIDocument* aDoc, ErrorResult& aRv)
   {
     NS_ASSERTION(aDoc, "Null should go to string version");
-    aRv = Send(aCx, RequestBody(aDoc));
+    aRv = Send(RequestBody(aDoc));
   }
-  void Send(JSContext *aCx, const nsAString& aString, ErrorResult& aRv)
+  void Send(const nsAString& aString, ErrorResult& aRv)
   {
     if (DOMStringIsNull(aString)) {
-      Send(aCx, aRv);
+      Send(aRv);
     }
     else {
-      aRv = Send(aCx, RequestBody(aString));
+      aRv = Send(RequestBody(aString));
     }
   }
-  void Send(JSContext *aCx, nsIDOMFormData* aFormData, ErrorResult& aRv)
+  void Send(nsIDOMFormData* aFormData, ErrorResult& aRv)
   {
     NS_ASSERTION(aFormData, "Null should go to string version");
-    aRv = Send(aCx, RequestBody(aFormData));
+    aRv = Send(RequestBody(aFormData));
   }
-  void Send(JSContext *aCx, nsIInputStream* aStream, ErrorResult& aRv)
+  void Send(nsIInputStream* aStream, ErrorResult& aRv)
   {
     NS_ASSERTION(aStream, "Null should go to string version");
-    aRv = Send(aCx, RequestBody(aStream));
+    aRv = Send(RequestBody(aStream));
   }
-  void SendAsBinary(JSContext *aCx, const nsAString& aBody, ErrorResult& aRv);
+  void SendAsBinary(const nsAString& aBody, ErrorResult& aRv);
 
   void Abort();
 
   // response
   uint32_t GetStatus();
   void GetStatusText(nsString& aStatusText);
   void GetResponseHeader(const nsACString& aHeader, nsACString& aResult,
                          ErrorResult& aRv);
--- a/content/base/test/TestGetURL.cpp
+++ b/content/base/test/TestGetURL.cpp
@@ -44,17 +44,17 @@ nsresult TestGetURL(const nsCString& aUR
   TEST_ENSURE_SUCCESS(rv, "Couldn't get system principal!");
 
   rv = xhr->Init(systemPrincipal, nsnull, nsnull, nsnull);
   TEST_ENSURE_SUCCESS(rv, "Couldn't initialize the XHR!");
 
   rv = xhr->Open(getString, aURL, false, empty, empty);
   TEST_ENSURE_SUCCESS(rv, "OpenRequest failed!");
 
-  rv = xhr->Send(nsnull, nsnull);
+  rv = xhr->Send(nsnull);
   TEST_ENSURE_SUCCESS(rv, "Send failed!");
 
   nsAutoString response;
   rv = xhr->GetResponseText(response);
   TEST_ENSURE_SUCCESS(rv, "GetResponse failed!");
 
   nsCAutoString responseUTF8 = NS_ConvertUTF16toUTF8(response);
   printf("#BEGIN\n");
--- a/content/base/test/TestNativeXMLHttpRequest.cpp
+++ b/content/base/test/TestNativeXMLHttpRequest.cpp
@@ -53,17 +53,17 @@ nsresult TestNativeXMLHttpRequest()
   TEST_ENSURE_SUCCESS(rv, "Couldn't get system principal!");
 
   rv = xhr->Init(systemPrincipal, nsnull, nsnull, nsnull);
   TEST_ENSURE_SUCCESS(rv, "Couldn't initialize the XHR!");
 
   rv = xhr->Open(getString, testURL, false, empty, empty);
   TEST_ENSURE_SUCCESS(rv, "Open failed!");
 
-  rv = xhr->Send(nsnull, nsnull);
+  rv = xhr->Send(nsnull);
   TEST_ENSURE_SUCCESS(rv, "Send failed!");
 
   nsAutoString response;
   rv = xhr->GetResponseText(response);
   TEST_ENSURE_SUCCESS(rv, "GetResponse failed!");
 
   if (!response.EqualsLiteral(TEST_URL_CONTENT)) {
     fail("Response text does not match!");
--- a/content/base/test/test_XHR_parameters.html
+++ b/content/base/test/test_XHR_parameters.html
@@ -16,27 +16,33 @@
 </div>
 <pre id="test">
 <script class="testbody" type="application/javascript;version=1.8">
 
 function runTests() {
   SimpleTest.waitForExplicitFinish();
 
   let validParameters = [
+    undefined,
+    null,
     {},
     {mozSystem: ""},
     {mozSystem: 0},
     {mozAnon: 1},
     {mozAnon: []},
     {get mozAnon() { return true; }},
   ];
 
   let invalidParameters = [
-    undefined,
-    null,
+    0,
+    7,
+    Math.PI,
+    "string",
+    true,
+    false,
     {get mozSystem() { throw "Bla"; } },
   ];
 
   let havePrivileges = false;
 
   function testValidParameter(value) {
     let xhr;
     try {
--- a/content/events/src/nsDOMUIEvent.cpp
+++ b/content/events/src/nsDOMUIEvent.cpp
@@ -23,17 +23,16 @@
 using namespace mozilla;
 
 nsDOMUIEvent::nsDOMUIEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent)
   : nsDOMEvent(aPresContext, aEvent ?
                static_cast<nsEvent *>(aEvent) :
                static_cast<nsEvent *>(new nsUIEvent(false, 0, 0)))
   , mClientPoint(0, 0), mLayerPoint(0, 0), mPagePoint(0, 0), mMovementPoint(0, 0)
   , mIsPointerLocked(nsEventStateManager::sIsPointerLocked)
-  , mLastScreenPoint(nsEventStateManager::sLastScreenPoint)
   , mLastClientPoint(nsEventStateManager::sLastClientPoint)
 {
   if (aEvent) {
     mEventIsInternal = false;
   }
   else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
@@ -90,58 +89,45 @@ NS_IMPL_RELEASE_INHERITED(nsDOMUIEvent, 
 
 DOMCI_DATA(UIEvent, nsDOMUIEvent)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMUIEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMUIEvent)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(UIEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
+static nsIntPoint
+DevPixelsToCSSPixels(const nsIntPoint& aPoint, nsPresContext* aContext)
+{
+  return nsIntPoint(aContext->DevPixelsToIntCSSPixels(aPoint.x),
+                    aContext->DevPixelsToIntCSSPixels(aPoint.y));
+}
+
 nsIntPoint
 nsDOMUIEvent::GetMovementPoint()
 {
   if (mPrivateDataDuplicated) {
     return mMovementPoint;
   }
 
   if (!mEvent ||
+      !((nsGUIEvent*)mEvent)->widget ||
        (mEvent->eventStructType != NS_MOUSE_EVENT &&
         mEvent->eventStructType != NS_POPUP_EVENT &&
         mEvent->eventStructType != NS_MOUSE_SCROLL_EVENT &&
         mEvent->eventStructType != NS_MOZTOUCH_EVENT &&
         mEvent->eventStructType != NS_DRAG_EVENT &&
         mEvent->eventStructType != NS_SIMPLE_GESTURE_EVENT)) {
     return nsIntPoint(0, 0);
   }
 
-  if (!((nsGUIEvent*)mEvent)->widget) {
-    return mEvent->lastRefPoint;
-  }
-
-  // Calculate the delta between the previous screen point and the current one.
-  nsIntPoint currentPoint = CalculateScreenPoint(mPresContext, mEvent);
-
-  // Adjust previous event's refPoint so it compares to current screenX, screenY
-  nsIntPoint offset = mEvent->lastRefPoint +
-    ((nsGUIEvent*)mEvent)->widget->WidgetToScreenOffset();
-  nscoord factor = mPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
-  nsIntPoint lastPoint = nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
-                                    nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
-
-  return currentPoint - lastPoint;
-}
-
-nsIntPoint
-nsDOMUIEvent::GetScreenPoint()
-{
-  if (mIsPointerLocked) {
-    return mLastScreenPoint;
-  }
-
-  return CalculateScreenPoint(mPresContext, mEvent);
+  // Calculate the delta between the last screen point and the current one.
+  nsIntPoint current = DevPixelsToCSSPixels(mEvent->refPoint, mPresContext);
+  nsIntPoint last = DevPixelsToCSSPixels(mEvent->lastRefPoint, mPresContext);
+  return current - last;
 }
 
 nsIntPoint
 nsDOMUIEvent::GetClientPoint()
 {
   if (mIsPointerLocked) {
     return mLastClientPoint;
   }
--- a/content/events/src/nsDOMUIEvent.h
+++ b/content/events/src/nsDOMUIEvent.h
@@ -86,17 +86,16 @@ public:
     }
 
     return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x),
                       nsPresContext::AppUnitsToIntCSSPixels(pt.y));
   }
 
 protected:
   // Internal helper functions
-  nsIntPoint GetScreenPoint();
   nsIntPoint GetClientPoint();
   nsIntPoint GetMovementPoint();
   nsIntPoint GetLayerPoint();
   nsIntPoint GetPagePoint();
 
   // Allow specializations.
   virtual nsresult Which(PRUint32* aWhich)
   {
@@ -109,17 +108,16 @@ protected:
   nsCOMPtr<nsIDOMWindow> mView;
   PRInt32 mDetail;
   nsIntPoint mClientPoint;
   // Screenpoint is mEvent->refPoint.
   nsIntPoint mLayerPoint;
   nsIntPoint mPagePoint;
   nsIntPoint mMovementPoint;
   bool mIsPointerLocked;
-  nsIntPoint mLastScreenPoint;
   nsIntPoint mLastClientPoint;
 
   typedef mozilla::widget::Modifiers Modifiers;
   static Modifiers ComputeModifierState(const nsAString& aModifiersList);
   bool GetModifierStateInternal(const nsAString& aKey);
 };
 
 #define NS_FORWARD_TO_NSDOMUIEVENT                          \
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -119,17 +119,16 @@ static bool sKeyCausesActivation = true;
 static PRUint32 sESMInstanceCount = 0;
 static PRInt32 sChromeAccessModifier = 0, sContentAccessModifier = 0;
 PRInt32 nsEventStateManager::sUserInputEventDepth = 0;
 bool nsEventStateManager::sNormalLMouseEventInProcess = false;
 nsEventStateManager* nsEventStateManager::sActiveESM = nsnull;
 nsIDocument* nsEventStateManager::sMouseOverDocument = nsnull;
 nsWeakFrame nsEventStateManager::sLastDragOverFrame = nsnull;
 nsIntPoint nsEventStateManager::sLastRefPoint = nsIntPoint(0,0);
-nsIntPoint nsEventStateManager::sLastScreenOffset = nsIntPoint(0,0);
 nsIntPoint nsEventStateManager::sLastScreenPoint = nsIntPoint(0,0);
 nsIntPoint nsEventStateManager::sLastClientPoint = nsIntPoint(0,0);
 bool nsEventStateManager::sIsPointerLocked = false;
 // Reference to the pointer locked element.
 nsWeakPtr nsEventStateManager::sPointerLockedElement;
 // Reference to the document which requested pointer lock.
 nsWeakPtr nsEventStateManager::sPointerLockedDoc;
 nsCOMPtr<nsIContent> nsEventStateManager::sDragOverContent = nsnull;
@@ -3996,48 +3995,79 @@ nsEventStateManager::NotifyMouseOver(nsG
   mLastMouseOverFrame = DispatchMouseEvent(aEvent, NS_MOUSE_ENTER_SYNTH,
                                            aContent, lastMouseOverElement);
   mLastMouseOverElement = aContent;
   
   // Turn recursion protection back off
   mFirstMouseOverEventElement = nsnull;
 }
 
+// Returns the center point of the window's inner content area.
+// This is in widget coordinates, i.e. relative to the widget's top
+// left corner, not in screen coordinates.
+static nsIntPoint
+GetWindowInnerRectCenter(nsPIDOMWindow* aWindow,
+                         nsIWidget* aWidget,
+                         nsPresContext* aContext)
+{
+  NS_ENSURE_TRUE(aWindow && aWidget && aContext, nsIntPoint(0,0));
+
+  float cssInnerX = 0.0;
+  aWindow->GetMozInnerScreenX(&cssInnerX);
+  PRInt32 innerX = PRInt32(NS_round(aContext->CSSPixelsToDevPixels(cssInnerX)));
+
+  float cssInnerY = 0.0;
+  aWindow->GetMozInnerScreenY(&cssInnerY);
+  PRInt32 innerY = PRInt32(NS_round(aContext->CSSPixelsToDevPixels(cssInnerY)));
+ 
+  PRInt32 innerWidth = 0;
+  aWindow->GetInnerWidth(&innerWidth);
+
+  PRInt32 innerHeight = 0;
+  aWindow->GetInnerHeight(&innerHeight);
+ 
+  nsIntRect screen;
+  aWidget->GetScreenBounds(screen);
+
+  return nsIntPoint(innerX - screen.x + innerWidth / 2,
+                    innerY - screen.y + innerHeight / 2);
+}
+
 void
 nsEventStateManager::GenerateMouseEnterExit(nsGUIEvent* aEvent)
 {
   EnsureDocument(mPresContext);
   if (!mDocument)
     return;
 
   // Hold onto old target content through the event and reset after.
   nsCOMPtr<nsIContent> targetBeforeEvent = mCurrentTargetContent;
 
   switch(aEvent->message) {
   case NS_MOUSE_MOVE:
     {
       if (sIsPointerLocked && aEvent->widget) {
-        // Perform mouse lock by recentering the mouse directly, then remembering the deltas.
-        nsIntRect bounds;
-        aEvent->widget->GetScreenBounds(bounds);
-        aEvent->lastRefPoint = GetMouseCoords(bounds);
-
-        // refPoint should not be the centre on mousemove
-        if (aEvent->refPoint.x == aEvent->lastRefPoint.x &&
-            aEvent->refPoint.y == aEvent->lastRefPoint.y) {
-          aEvent->refPoint = sLastRefPoint;
-        } else {
-          aEvent->widget->SynthesizeNativeMouseMove(aEvent->lastRefPoint);
+        // Perform mouse lock by recentering the mouse directly, and storing
+        // the refpoints so movement deltas can be calculated.
+        nsIntPoint center = GetWindowInnerRectCenter(mDocument->GetWindow(),
+                                                     aEvent->widget,
+                                                     mPresContext);
+        aEvent->lastRefPoint = center;
+        if (aEvent->refPoint != center) {
+          // This mouse move doesn't finish at the center of the widget,
+          // dispatch a synthetic mouse move to return the mouse back to
+          // the center.
+          aEvent->widget->SynthesizeNativeMouseMove(center);
         }
       } else {
-        aEvent->lastRefPoint = nsIntPoint(sLastRefPoint.x, sLastRefPoint.y);
+        aEvent->lastRefPoint = sLastRefPoint;
       }
 
       // Update the last known refPoint with the current refPoint.
-      sLastRefPoint = nsIntPoint(aEvent->refPoint.x, aEvent->refPoint.y);
+      sLastRefPoint = aEvent->refPoint;
 
       // Get the target content target (mousemove target == mouseover target)
       nsCOMPtr<nsIContent> targetElement = GetEventTargetContent(aEvent);
       if (!targetElement) {
         // We're always over the document root, even if we're only
         // over dead space in a page (whose frame is not associated with
         // any content) or in print preview dead space
         targetElement = mDocument->GetRootElement();
@@ -4084,69 +4114,51 @@ nsEventStateManager::SetPointerLock(nsIW
   nsMouseWheelTransaction::EndTransaction();
 
   // Deal with DnD events
   nsCOMPtr<nsIDragService> dragService =
     do_GetService("@mozilla.org/widget/dragservice;1");
 
   if (sIsPointerLocked) {
     // Store the last known ref point so we can reposition the pointer after unlock.
-    mPreLockPoint = sLastRefPoint + sLastScreenOffset;
-
-    nsIntRect bounds;
-    aWidget->GetScreenBounds(bounds);
-    sLastRefPoint = GetMouseCoords(bounds);
+    mPreLockPoint = sLastRefPoint;
+
+    // Fire a synthetic mouse move to ensure event state is updated. We first
+    // set the mouse to the center of the window, so that the mouse event
+    // doesn't report any movement.
+    sLastRefPoint = GetWindowInnerRectCenter(aElement->OwnerDoc()->GetWindow(),
+                                             aWidget,
+                                             mPresContext);
     aWidget->SynthesizeNativeMouseMove(sLastRefPoint);
 
     // Retarget all events to this element via capture.
     nsIPresShell::SetCapturingContent(aElement, CAPTURE_POINTERLOCK);
 
     // Suppress DnD
     if (dragService) {
       dragService->Suppress();
     }
   } else {
-    // Unlocking, so return pointer to the original position
-    aWidget->SynthesizeNativeMouseMove(sLastScreenPoint);
+    // Unlocking, so return pointer to the original position by firing a
+    // synthetic mouse event. We first reset sLastRefPoint to its
+    // pre-pointerlock position, so that the synthetic mouse event reports
+    // no movement.
+    sLastRefPoint = mPreLockPoint;
+    aWidget->SynthesizeNativeMouseMove(mPreLockPoint);
 
     // Don't retarget events to this element any more.
     nsIPresShell::SetCapturingContent(nsnull, CAPTURE_POINTERLOCK);
 
     // Unsuppress DnD
     if (dragService) {
       dragService->Unsuppress();
     }
   }
 }
 
-nsIntPoint
-nsEventStateManager::GetMouseCoords(nsIntRect aBounds)
-{
-  NS_ASSERTION(sIsPointerLocked, "GetMouseCoords when not pointer locked!");
-
-  nsCOMPtr<nsIDocument> pointerLockedDoc =
-    do_QueryReferent(nsEventStateManager::sPointerLockedDoc);
-  if (!pointerLockedDoc) {
-    NS_WARNING("GetMouseCoords(): No Document");
-    return nsIntPoint(0, 0);
-  }
-
-  nsCOMPtr<nsPIDOMWindow> domWin = pointerLockedDoc->GetInnerWindow();
-  if (!domWin) {
-    NS_WARNING("GetMouseCoords(): No Window");
-    return nsIntPoint(0, 0);
-  }
-
-  int innerHeight;
-  domWin->GetInnerHeight(&innerHeight);
-
-  return nsIntPoint((aBounds.width / 2) + aBounds.x,
-                    (innerHeight / 2) + (aBounds.y + (aBounds.height - innerHeight)));
-}
-
 void
 nsEventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
                                                nsGUIEvent* aEvent)
 {
   //Hold onto old target content through the event and reset after.
   nsCOMPtr<nsIContent> targetBeforeEvent = mCurrentTargetContent;
 
   switch(aEvent->message) {
--- a/content/events/src/nsEventStateManager.h
+++ b/content/events/src/nsEventStateManager.h
@@ -190,18 +190,29 @@ public:
   static void SetActiveManager(nsEventStateManager* aNewESM,
                                nsIContent* aContent);
 
   // Sets the full-screen event state on aElement to aIsFullScreen.
   static void SetFullScreenState(mozilla::dom::Element* aElement, bool aIsFullScreen);
 
   static bool IsRemoteTarget(nsIContent* aTarget);
 
+  // Holds the point in screen coords that a mouse event was dispatched to,
+  // before we went into pointer lock mode. This is constantly updated while
+  // the pointer is not locked, but we don't update it while the pointer is
+  // locked. This is used by nsDOMEvent::GetScreenCoords() to make mouse
+  // events' screen coord appear frozen at the last mouse position while
+  // the pointer is locked.
   static nsIntPoint sLastScreenPoint;
+
+  // Holds the point in client coords of the last mouse event. Used by
+  // nsDOMEvent::GetClientCoords() to make mouse events' client coords appear
+  // frozen at the last mouse position while the pointer is locked.
   static nsIntPoint sLastClientPoint;
+
   static bool sIsPointerLocked;
   static nsWeakPtr sPointerLockedElement;
   static nsWeakPtr sPointerLockedDoc;
 
 protected:
   friend class MouseEnterLeaveDispatcher;
 
   void UpdateCursor(nsPresContext* aPresContext, nsEvent* aEvent, nsIFrame* aTargetFrame, nsEventStatus* aStatus);
@@ -448,26 +459,30 @@ private:
                                    bool aAddState);
   static void UpdateAncestorState(nsIContent* aStartNode,
                                   nsIContent* aStopBefore,
                                   nsEventStates aState,
                                   bool aAddState);
 
   PRInt32     mLockCursor;
 
-  // Point when mouse was locked, used to reposition after unlocking.
+  // Last mouse event refPoint (the offset from the widget's origin in
+  // device pixels) when mouse was locked, used to restore mouse position
+  // after unlocking.
   nsIntPoint  mPreLockPoint;
 
   nsWeakFrame mCurrentTarget;
   nsCOMPtr<nsIContent> mCurrentTargetContent;
   nsWeakFrame mLastMouseOverFrame;
   nsCOMPtr<nsIContent> mLastMouseOverElement;
   static nsWeakFrame sLastDragOverFrame;
+
+  // Stores the refPoint (the offset from the widget's origin in device
+  // pixels) of the last mouse event.
   static nsIntPoint sLastRefPoint;
-  static nsIntPoint sLastScreenOffset;
 
   // member variables for the d&d gesture state machine
   nsIntPoint mGestureDownPoint; // screen coordinates
   // The content to use as target if we start a d&d (what we drag).
   nsCOMPtr<nsIContent> mGestureDownContent;
   // The content of the frame where the mouse-down event occurred. It's the same
   // as the target in most cases but not always - for example when dragging
   // an <area> of an image map this is the image. (bug 289667)
@@ -529,17 +544,16 @@ public:
   bool mClickHoldContextMenu;
   nsCOMPtr<nsITimer> mClickHoldTimer;
   void CreateClickHoldTimer ( nsPresContext* aPresContext, nsIFrame* inDownFrame,
                               nsGUIEvent* inMouseDownEvent ) ;
   void KillClickHoldTimer ( ) ;
   void FireContextClick ( ) ;
 
   void SetPointerLock(nsIWidget* aWidget, nsIContent* aElement) ;
-  nsIntPoint GetMouseCoords(nsIntRect aBounds);
   static void sClickHoldCallback ( nsITimer* aTimer, void* aESM ) ;
 };
 
 /**
  * This class is used while processing real user input. During this time, popups
  * are allowed. For mousedown events, mouse capturing is also permitted.
  */
 class nsAutoHandlingUserInputStatePusher
--- a/content/html/content/src/nsGenericHTMLFrameElement.cpp
+++ b/content/html/content/src/nsGenericHTMLFrameElement.cpp
@@ -292,17 +292,18 @@ nsGenericHTMLFrameElement::GetReallyIsBr
     return NS_OK;
   }
 
   // Fail if the node principal isn't trusted.
   // TODO: check properly for mozApps rights when mozApps will be less hacky.
   nsIPrincipal *principal = NodePrincipal();
   nsCOMPtr<nsIURI> principalURI;
   principal->GetURI(getter_AddRefs(principalURI));
-  if (!nsContentUtils::URIIsChromeOrInPref(principalURI,
+  if (!nsContentUtils::IsSystemPrincipal(principal) &&
+      !nsContentUtils::URIIsChromeOrInPref(principalURI,
                                            "dom.mozBrowserFramesWhitelist")) {
     return NS_OK;
   }
 
   // Otherwise, succeed.
   *aOut = true;
   return NS_OK;
 }
--- a/content/xul/document/test/Makefile.in
+++ b/content/xul/document/test/Makefile.in
@@ -24,12 +24,14 @@ include $(topsrcdir)/config/rules.mk
 		test_bug468176.xul \
 		test_bug583948.xul \
 		window_bug583948.xul \
 		test_bug497875.xul \
 		bug497875-iframe.xul \
 		test_bug335375.xul \
 		overlay1_bug335375.xul \
 		overlay2_bug335375.xul \
+		test_bug757137.xul \
+		window_bug757137.xul \
 		$(NULL)
 
 libs:: $(_CHROME_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/content/xul/document/test/test_bug757137.xul
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+                 type="text/css"?>
+
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+
+<body xmlns="http://www.w3.org/1999/xhtml">
+  <div id="content" style="display: none"/>
+</body>
+
+<script>
+var Ci = Components.interfaces;
+var chromeWindowInterface = Ci.nsIDOMChromeWindow;
+
+SimpleTest.waitForExplicitFinish();
+
+// Force off out-of-process mozbrowser because we need to grab its
+// |window| synchronously from here.  Out-of-process docshell creation
+// for mozbrowser haves entirely differently.
+// XXX why doesn't pushPrefEnv() work here?
+var ipcTabsWereDisabled;
+try {
+  ipcTabsWereDisabled = SpecialPowers.getBoolPref("dom.ipc.tabs.disabled");
+} catch (e) {
+  ipcTabsWereDisabled = undefined;
+}
+SpecialPowers.setBoolPref("dom.ipc.tabs.disabled", true);
+
+var otherWindow = window.open("window_bug757137.xul", "", "chrome");
+ok(chromeWindowInterface !== null, 'nsIDOMChromeWindow interface is defined');
+var otherChromeWindow = null;
+try {
+  otherChromeWindow = otherWindow.QueryInterface(chromeWindowInterface);
+} catch(e) {
+  ok(false, 'exception when QI to ChromeWindow');
+}
+ok(otherChromeWindow !== null, 'XUL window should QI to ChromeWindow');
+
+otherWindow.onload = function () {
+  var w = otherWindow.document.getElementById('f').contentWindow;
+  ok(w !== null, 'got the |window| for a mozbrowser iframe');
+  var chromeWindow = null;
+  try {
+    var chromeWindow = w.QueryInterface(chromeWindowInterface);
+  } catch(e) { }
+  ok(chromeWindow === null, 'mozbrowser iframe should not get ChromeWindow');
+
+  otherWindow.close();
+  SimpleTest.waitForFocus(function() {
+    if (ipcTabsWereDisabled !== undefined) {
+      SpecialPowers.setBoolPref("dom.ipc.tabs.disabled", ipcTabsWereDisabled);
+    } else {
+      SpecialPowers.clearUserPref("dom.ipc.tabs.disabled");
+    }
+    SimpleTest.finish();
+  });
+};
+</script>
+
+</window>
new file mode 100644
--- /dev/null
+++ b/content/xul/document/test/window_bug757137.xul
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        xmlns:html="http://www.w3.org/1999/xhtml">
+  <html:iframe id="f" mozbrowser="true"
+               src="data:text/html;charset=utf-8,%3C!DOCTYPE html>Hi" />
+</window>
--- a/content/xul/templates/src/nsXULTemplateQueryProcessorXML.cpp
+++ b/content/xul/templates/src/nsXULTemplateQueryProcessorXML.cpp
@@ -189,17 +189,17 @@ nsXULTemplateQueryProcessorXML::GetDatas
 
     nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(req));
     rv = target->AddEventListener(NS_LITERAL_STRING("load"), this, false);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = target->AddEventListener(NS_LITERAL_STRING("error"), this, false);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    rv = req->Send(nsnull, context->GetNativeContext());
+    rv = req->Send(nsnull);
     NS_ENSURE_SUCCESS(rv, rv);
 
     mTemplateBuilder = aBuilder;
     mRequest = req;
 
     *aShouldDelayBuilding = true;
     return NS_OK;
 }
--- a/dom/apps/src/Webapps.js
+++ b/dom/apps/src/Webapps.js
@@ -10,23 +10,42 @@ const Cr = Components.results;
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
   return Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
 });
 
+// Makes sure that we expose correctly chrome JS objects to content.
+function wrapObjectIn(aObject, aCtxt) {
+  let res = Cu.createObjectIn(aCtxt);
+  let propList = { };
+  for (let prop in aObject) {
+    propList[prop] = {
+      enumerable: true,
+      configurable: true,
+      writable: true,
+      value: (typeof(aObject[prop]) == "object") ? wrapObjectIn(aObject[prop], aCtxt)
+                                                 : aObject[prop]
+    }
+  }
+  Object.defineProperties(res, propList);
+  Cu.makeObjectPropsNormal(res);
+  return res;
+};
+
 function convertAppsArray(aApps, aWindow) {
-  let apps = new Array();
+  let apps = Cu.createArrayIn(aWindow);
   for (let i = 0; i < aApps.length; i++) {
     let app = aApps[i];
     apps.push(new WebappsApplication(aWindow, app.origin, app.manifest, app.manifestURL, 
                                      app.receipts, app.installOrigin, app.installTime));
   }
+
   return apps;
 }
 
 function WebappsRegistry() {
 }
 
 WebappsRegistry.prototype = {
   __proto__: DOMRequestIpcHelper.prototype,
@@ -178,18 +197,18 @@ WebappsRegistry.prototype = {
                                     classDescription: "Webapps Registry"})
 }
 
 /**
   * mozIDOMApplication object
   */
 function WebappsApplication(aWindow, aOrigin, aManifest, aManifestURL, aReceipts, aInstallOrigin, aInstallTime) {
   this._origin = aOrigin;
-  this._manifest = aManifest;
   this._manifestURL = aManifestURL;
+  this._manifest = wrapObjectIn(aManifest, aWindow);
   this._receipts = aReceipts;
   this._installOrigin = aInstallOrigin;
   this._installTime = aInstallTime;
 
   this.initHelper(aWindow, ["Webapps:Uninstall:Return:OK", "Webapps:Uninstall:Return:KO"]);
 }
 
 WebappsApplication.prototype = {
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -5880,17 +5880,18 @@ DefineInterfaceConstants(JSContext *cx, 
 #ifdef NS_DEBUG
         NS_ERROR("Non-numeric constant found in interface.");
 #endif
         continue;
       }
     }
 
     if (!::JS_DefineProperty(cx, obj, c->GetName(), v, nsnull, nsnull,
-                             JSPROP_ENUMERATE)) {
+                             JSPROP_ENUMERATE | JSPROP_READONLY |
+                             JSPROP_PERMANENT)) {
       return NS_ERROR_UNEXPECTED;
     }
   }
 
   return NS_OK;
 }
 
 // This code is temporary until we remove support for the constants defined
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -445,19 +445,18 @@ FindEnumStringIndex(JSContext* cx, JS::V
     }
 
     if (equal) {
       *ok = true;
       return i;
     }
   }
 
-  // XXX we don't know whether we're on the main thread, so play it safe
-  *ok = Throw<false>(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
-  return 0;
+  *ok = true;
+  return -1;
 }
 
 inline nsWrapperCache*
 GetWrapperCache(nsWrapperCache* cache)
 {
   return cache;
 }
 
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -241,21 +241,17 @@ DOMInterfaces = {
             'readyState', 'withCredentials', 'abort', 'statusText',
             'getAllResponseHeaders', 'overrideMimeType', 'mozBackgroundRequest',
             'multipart', 'channel', 'upload', 'status', 'mozAnon', 'mozSystem'
         ],
         'getterOnly': [
             'responseType', 'timeout', 'onreadystatechange', 'onuploadprogress'
         ]
     },
-    # XXXbz need a JSContext for send() and sendAsBinary because of
-    # the old nsIVariant-based signatures which actually use it for
-    # typed arrays.  Once those go away, we can nuke them from this
-    # list.
-    'implicitJSContext': [ 'constructor', 'send', 'sendAsBinary' ],
+    'implicitJSContext': [ 'constructor', ],
     'resultNotAddRefed': [ 'upload', 'responseXML' ]
 },
 {
     'workers': True,
     'nativeType': 'mozilla::dom::workers::XMLHttpRequest',
     'headerFile': 'mozilla/dom/workers/bindings/XMLHttpRequest.h',
     'infallible': {
         'all': ['readyState', 'statusText', 'mozAnon', 'mozSystem' ],
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -132,17 +132,17 @@ class CGPrototypeJSClass(CGThing):
         CGThing.__init__(self)
         self.descriptor = descriptor
     def declare(self):
         # We're purely for internal consumption
         return ""
     def define(self):
         return """
 static JSClass PrototypeClass = {
-  "%s Prototype", 0,
+  "%sPrototype", 0,
   JS_PropertyStub,       /* addProperty */
   JS_PropertyStub,       /* delProperty */
   JS_PropertyStub,       /* getProperty */
   JS_StrictPropertyStub, /* setProperty */
   JS_EnumerateStub,
   JS_ResolveStub,
   JS_ConvertStub,
   NULL,                  /* finalize */
@@ -1337,17 +1337,18 @@ nsCOMPtr<${nativeType}> tmp = do_QueryOb
 if (!tmp) {
   ${codeOnFailure}
 }
 ${target} = tmp.forget();""").substitute(self.substitution)
 
 def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
                                     isDefinitelyObject=False,
                                     isMember=False,
-                                    isOptional=False):
+                                    isOptional=False,
+                                    invalidEnumValueFatal=True):
     """
     Get a template for converting a JS value to a native object based on the
     given type and descriptor.  If failureCode is given, then we're actually
     testing whether we can convert the argument to the desired type.  That
     means that failures to convert due to the JS value being the wrong type of
     value need to use failureCode instead of throwing exceptions.  Failures to
     convert that are due to JS exceptions (from toString or valueOf methods) or
     out of memory conditions need to throw exceptions no matter what
@@ -1712,22 +1713,27 @@ for (uint32_t i = 0; i < length; ++i) {
     if type.isEnum():
         if type.nullable():
             raise TypeError("We don't support nullable enumerated arguments "
                             "yet")
         enum = type.inner.identifier.name
         return (
             "{\n"
             "  bool ok;\n"
-            "  ${declName} = static_cast<%(enumtype)s>(FindEnumStringIndex(cx, ${val}, %(values)s, &ok));\n"
+            "  int index = FindEnumStringIndex(cx, ${val}, %(values)s, &ok);\n"
             "  if (!ok) {\n"
             "    return false;\n"
             "  }\n"
+            "  if (index < 0) {\n"
+            "    return %(failureCode)s;\n"
+            "  }\n"
+            "  ${declName} = static_cast<%(enumtype)s>(index);\n"
             "}" % { "enumtype" : enum,
-                      "values" : enum + "Values::strings" },
+                      "values" : enum + "Values::strings",
+                 "failureCode" : "Throw<false>(cx, NS_ERROR_XPC_BAD_CONVERT_JS)" if invalidEnumValueFatal else "true" },
             CGGeneric(enum), None, isOptional)
 
     if type.isCallback():
         if isMember:
             raise TypeError("Can't handle member callbacks; need to sort out "
                             "rooting issues")
         # XXXbz we're going to assume that callback types are always
         # nullable and always have [TreatNonCallableAsNull] for now.
@@ -1760,36 +1766,38 @@ for (uint32_t i = 0; i < length; ++i) {
 
     if type.isDictionary():
         if failureCode is not None:
             raise TypeError("Can't handle dictionaries when failureCode is not None")
 
         if type.nullable():
             typeName = CGDictionary.makeDictionaryName(type.inner.inner,
                                                        descriptorProvider.workers)
-            declType = CGGeneric("Nullable<%s>" % typeName)
-            selfRef = "${declName}.Value()"
+            actualTypeName = "Nullable<%s>" % typeName
+            selfRef = "const_cast<%s&>(${declName}).SetValue()" % actualTypeName
         else:
             typeName = CGDictionary.makeDictionaryName(type.inner,
                                                        descriptorProvider.workers)
-            declType = CGGeneric(typeName)
+            actualTypeName = typeName
             selfRef = "${declName}"
+
+        declType = CGGeneric(actualTypeName)
+
         # If we're optional or a member of something else, the const
         # will come from the Optional or our container.
-        mutableTypeName = declType
         if not isOptional and not isMember:
             declType = CGWrapper(declType, pre="const ")
             selfRef = "const_cast<%s&>(%s)" % (typeName, selfRef)
 
         template = wrapObjectTemplate("if (!%s.Init(cx, &${val}.toObject())) {\n"
                                       "  return false;\n"
                                       "}" % selfRef,
                                       isDefinitelyObject, type,
                                       ("const_cast<%s&>(${declName}).SetNull()" %
-                                       mutableTypeName.define()),
+                                       actualTypeName),
                                       descriptorProvider.workers, None)
 
         return (template, declType, None, isOptional)
 
     if not type.isPrimitive():
         raise TypeError("Need conversion for argument type '%s'" % type)
 
     # XXXbz need to add support for [EnforceRange] and [Clamp]
@@ -1915,17 +1923,18 @@ def convertIDLDefaultValueToJSVal(value)
     return convertConstIDLValueToJSVal(value)
 
 class CGArgumentConverter(CGThing):
     """
     A class that takes an IDL argument object, its index in the
     argument list, and the argv and argc strings and generates code to
     unwrap the argument to the right native type.
     """
-    def __init__(self, argument, index, argv, argc, descriptorProvider):
+    def __init__(self, argument, index, argv, argc, descriptorProvider,
+                 invalidEnumValueFatal=True):
         CGThing.__init__(self)
         self.argument = argument
         # XXXbz should optional jsval args get JSVAL_VOID? What about
         # others?
         replacer = {
             "index" : index,
             "argc" : argc,
             "argv" : argv
@@ -1948,22 +1957,24 @@ class CGArgumentConverter(CGThing):
                 ).substitute(replacer)
             self.replacementVariables["valPtr"] = (
                 "&" + self.replacementVariables["val"])
         self.descriptorProvider = descriptorProvider
         if self.argument.optional and not self.argument.defaultValue:
             self.argcAndIndex = replacer
         else:
             self.argcAndIndex = None
+        self.invalidEnumValueFatal = invalidEnumValueFatal
 
     def define(self):
         return instantiateJSToNativeConversionTemplate(
             getJSToNativeConversionTemplate(self.argument.type,
                                             self.descriptorProvider,
-                                            isOptional=(self.argcAndIndex is not None)),
+                                            isOptional=(self.argcAndIndex is not None),
+                                            invalidEnumValueFatal=self.invalidEnumValueFatal),
             self.replacementVariables,
             self.argcAndIndex).define()
 
 def getWrapTemplateForType(type, descriptorProvider, result, successCode,
                            isCreator):
     """
     Reflect a C++ value stored in "result", of IDL type "type" into JS.  The
     "successCode" is the code to run once we have successfully done the
@@ -2354,17 +2365,18 @@ class CGPerSignatureCall(CGThing):
         self.arguments = arguments
         self.argCount = len(arguments)
         if self.argCount > argConversionStartsAt:
             # Insert our argv in there
             cgThings = [CGGeneric(self.getArgvDecl())]
         else:
             cgThings = []
         cgThings.extend([CGArgumentConverter(arguments[i], i, self.getArgv(),
-                                             self.getArgc(), self.descriptor) for
+                                             self.getArgc(), self.descriptor,
+                                             invalidEnumValueFatal=not setter) for
                          i in range(argConversionStartsAt, self.argCount)])
 
         cgThings.append(CGCallGenerator(
                     self.getErrorReport() if self.isFallible() else None,
                     self.arguments, self.argsPre, returnType,
                     self.extendedAttributes, descriptor, nativeMethodName,
                     static))
         self.cgRoot = CGList(cgThings, "\n")
--- a/dom/bindings/test/Makefile.in
+++ b/dom/bindings/test/Makefile.in
@@ -52,16 +52,17 @@ bindinggen_dependencies := \
 
 $(CPPSRCS): ../%Binding.cpp: $(bindinggen_dependencies) \
                              ../%.webidl \
                              $(NULL)
 	$(MAKE) -C .. $*Binding.h
 	$(MAKE) -C .. $*Binding.cpp
 
 _TEST_FILES = \
+  test_enums.html \
   test_interfaceToString.html \
   test_lookupGetter.html \
   test_InstanceOf.html \
   test_traceProtos.html \
   $(NULL)
 
 
 libs:: $(_TEST_FILES)
--- a/dom/bindings/test/TestBindingHeader.h
+++ b/dom/bindings/test/TestBindingHeader.h
@@ -274,16 +274,19 @@ public:
   void PassOptionalString(const Optional<nsAString>&, ErrorResult&);
   void PassOptionalNullableString(const Optional<nsAString>&, ErrorResult&);
   void PassOptionalNullableStringWithDefaultValue(const nsAString&, ErrorResult&);
 
   // Enumarated types
   void PassEnum(TestEnum, ErrorResult&);
   void PassOptionalEnum(const Optional<TestEnum>&, ErrorResult&);
   TestEnum ReceiveEnum(ErrorResult&);
+  TestEnum GetEnumAttribute(ErrorResult&);
+  TestEnum GetReadonlyEnumAttribute(ErrorResult&);
+  void SetEnumAttribute(TestEnum, ErrorResult&);
 
   // Callback types
   void PassCallback(JSContext*, JSObject*, ErrorResult&);
   void PassNullableCallback(JSContext*, JSObject*, ErrorResult&);
   void PassOptionalCallback(JSContext*, const Optional<JSObject*>&,
                             ErrorResult&);
   void PassOptionalNullableCallback(JSContext*, const Optional<JSObject*>&,
                                     ErrorResult&);
--- a/dom/bindings/test/TestCodeGen.webidl
+++ b/dom/bindings/test/TestCodeGen.webidl
@@ -207,16 +207,18 @@ interface TestInterface {
   // Enumerated types
   void passEnum(TestEnum arg);
   // No support for nullable enums yet
   // void passNullableEnum(TestEnum? arg);
   void passOptionalEnum(optional TestEnum arg);
   // void passOptionalNullableEnum(optional TestEnum? arg);
   // void passOptionalNullableEnumWithDefaultValue(optional TestEnum? arg = null);
   TestEnum receiveEnum();
+  attribute TestEnum enumAttribute;
+  readonly attribute TestEnum readonlyEnumAttribute;
 
   // Callback types
   void passCallback(TestCallback arg);
   void passNullableCallback(TestCallback? arg);
   void passOptionalCallback(optional TestCallback arg);
   void passOptionalNullableCallback(optional TestCallback? arg);
   void passOptionalNullableCallbackWithDefaultValue(optional TestCallback? arg = null);
   TestCallback receiveCallback();
new file mode 100644
--- /dev/null
+++ b/dom/bindings/test/test_enums.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Enums</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+test(function() {
+  var xhr = new XMLHttpRequest();
+  xhr.open("get", "foo")
+  assert_equals(xhr.responseType, "");
+  xhr.responseType = "foo";
+  assert_equals(xhr.responseType, "");
+}, "Assigning an invalid value to an enum attribute should not throw.");
+</script>
--- a/dom/browser-element/BrowserElementChild.js
+++ b/dom/browser-element/BrowserElementChild.js
@@ -61,18 +61,24 @@ BrowserElementChild.prototype = {
     sendAsyncMsg("hello");
 
     BrowserElementPromptService.mapWindowToBrowserElementChild(content, this);
 
     docShell.isBrowserFrame = true;
     docShell.QueryInterface(Ci.nsIWebProgress)
             .addProgressListener(this._progressListener,
                                  Ci.nsIWebProgress.NOTIFY_LOCATION |
+                                 Ci.nsIWebProgress.NOTIFY_SECURITY |
                                  Ci.nsIWebProgress.NOTIFY_STATE_WINDOW);
 
+    // This is necessary to get security web progress notifications.
+    var securityUI = Cc['@mozilla.org/secure_browser_ui;1']
+                       .createInstance(Ci.nsISecureBrowserUI);
+    securityUI.init(content);
+
     // A mozbrowser iframe contained inside a mozapp iframe should return false
     // for nsWindowUtils::IsPartOfApp (unless the mozbrowser iframe is itself
     // also mozapp).  That is, mozapp is transitive down to its children, but
     // mozbrowser serves as a barrier.
     //
     // This is because mozapp iframes have some privileges which we don't want
     // to extend to untrusted mozbrowser content.
     //
@@ -367,16 +373,41 @@ BrowserElementChild.prototype = {
         sendAsyncMsg('loadstart');
       }
 
       if (stateFlags & Ci.nsIWebProgressListener.STATE_STOP) {
         sendAsyncMsg('loadend');
       }
     },
 
+    onSecurityChange: function(webProgress, request, state) {
+      if (webProgress != docShell) {
+        return;
+      }
+
+      var stateDesc;
+      if (state & Ci.nsIWebProgressListener.STATE_IS_SECURE) {
+        stateDesc = 'secure';
+      }
+      else if (state & Ci.nsIWebProgressListener.STATE_IS_BROKEN) {
+        stateDesc = 'broken';
+      }
+      else if (state & Ci.nsIWebProgressListener.STATE_IS_INSECURE) {
+        stateDesc = 'insecure';
+      }
+      else {
+        debug("Unexpected securitychange state!");
+        stateDesc = '???';
+      }
+
+      // XXX Until bug 764496 is fixed, this will always return false.
+      var isEV = !!(state & Ci.nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL);
+
+      sendAsyncMsg('securitychange', {state: stateDesc, extendedValidation: isEV});
+    },
+
     onStatusChange: function(webProgress, request, status, message) {},
     onProgressChange: function(webProgress, request, curSelfProgress,
                                maxSelfProgress, curTotalProgress, maxTotalProgress) {},
-    onSecurityChange: function(webProgress, request, aState) {}
   },
 };
 
 var api = new BrowserElementChild();
--- a/dom/browser-element/BrowserElementParent.js
+++ b/dom/browser-element/BrowserElementParent.js
@@ -141,30 +141,31 @@ function BrowserElementParent(frameLoade
 
   addMessageListener("hello", this._recvHello);
   addMessageListener("locationchange", this._fireEventFromMsg);
   addMessageListener("loadstart", this._fireEventFromMsg);
   addMessageListener("loadend", this._fireEventFromMsg);
   addMessageListener("titlechange", this._fireEventFromMsg);
   addMessageListener("iconchange", this._fireEventFromMsg);
   addMessageListener("close", this._fireEventFromMsg);
+  addMessageListener("securitychange", this._fireEventFromMsg);
   addMessageListener("get-mozapp-manifest-url", this._sendMozAppManifestURL);
   addMessageListener("keyevent", this._fireKeyEvent);
   addMessageListener("showmodalprompt", this._handleShowModalPrompt);
   addMessageListener('got-screenshot', this._recvGotScreenshot);
 
   function defineMethod(name, fn) {
     XPCNativeWrapper.unwrap(self._frameElement)[name] = fn.bind(self);
   }
 
   // Define methods on the frame element.
   defineMethod('getScreenshot', this._getScreenshot);
   defineMethod('setVisible', this._setVisible);
 
-  self._mm.loadFrameScript("chrome://global/content/BrowserElementChild.js",
+  this._mm.loadFrameScript("chrome://global/content/BrowserElementChild.js",
                            /* allowDelayedLoad = */ true);
 }
 
 BrowserElementParent.prototype = {
   get _window() {
     return this._frameElement.ownerDocument.defaultView;
   },
 
--- a/dom/browser-element/mochitest/Makefile.in
+++ b/dom/browser-element/mochitest/Makefile.in
@@ -12,16 +12,17 @@ relativesrcdir  = dom/browser-element/mo
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 # Note: browserElementTestHelpers.js looks at the test's filename to determine
 # whether the test should be OOP.  "_oop_" signals OOP, "_inproc_" signals in
 # process.  Default is OOP.
 
 _TEST_FILES = \
+		file_empty_script.js \
 		file_empty.html \
 		file_focus.html \
 		browserElementTestHelpers.js \
 		test_browserElement_NoAttr.html \
 		test_browserElement_NoPref.html \
 		test_browserElement_NoWhitelist.html \
 		browserElement_LoadEvents.js \
 		test_browserElement_inproc_LoadEvents.html \
@@ -49,16 +50,19 @@ include $(topsrcdir)/config/rules.mk
 		test_browserElement_inproc_Close.html \
 		browserElement_OpenWindow.js \
 		test_browserElement_inproc_OpenWindow.html \
 		file_browserElement_Open1.html \
 		file_browserElement_Open2.html \
 		browserElement_OpenWindowRejected.js \
 		test_browserElement_inproc_OpenWindowRejected.html \
 		file_browserElement_OpenWindowRejected.html \
+		browserElement_SecurityChange.js \
+		test_browserElement_inproc_SecurityChange.html \
+		file_browserElement_SecurityChange.html \
 		$(NULL)
 
 # OOP tests don't work on Windows (bug 763081).
 ifneq ($(OS_ARCH),WINNT)
 _TEST_FILES += \
 		test_browserElement_oop_LoadEvents.html \
 		test_browserElement_oop_DataURI.html \
 		test_browserElement_oop_Titlechange.html \
@@ -68,14 +72,15 @@ ifneq ($(OS_ARCH),WINNT)
 		test_browserElement_oop_SetVisible.html \
 		test_browserElement_oop_KeyEvents.html \
 		test_browserElement_oop_Alert.html \
 		test_browserElement_oop_PromptCheck.html \
 		test_browserElement_oop_PromptConfirm.html \
 		test_browserElement_oop_Close.html \
 		test_browserElement_oop_OpenWindow.html \
 		test_browserElement_oop_OpenWindowRejected.html \
+		test_browserElement_oop_SecurityChange.html \
 		$(NULL)
 endif
 
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/browserElement_SecurityChange.js
@@ -0,0 +1,50 @@
+/* Any copyright is dedicated to the public domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Bug 763694 - Test that <iframe mozbrowser> delivers proper
+// mozbrowsersecuritychange events.
+
+"use strict";
+SimpleTest.waitForExplicitFinish();
+
+function runTest() {
+  browserElementTestHelpers.setEnabledPref(true);
+  browserElementTestHelpers.addToWhitelist();
+
+  var iframe = document.createElement('iframe');
+  iframe.mozbrowser = true;
+
+  var lastSecurityState;
+  iframe.addEventListener('mozbrowsersecuritychange', function(e) {
+    lastSecurityState = e.detail;
+  });
+
+  var filepath = 'tests/dom/browser-element/mochitest/file_browserElement_SecurityChange.html';
+
+  var count = 0;
+  iframe.addEventListener('mozbrowserloadend', function(e) {
+    count++;
+    var nextURL;
+    switch (count) {
+    case 1:
+      is(lastSecurityState.state, 'secure');
+      is(lastSecurityState.extendedValidation, false);
+      iframe.src = "http://example.com/" + filepath;
+      break;
+    case 2:
+      is(lastSecurityState.state, 'insecure');
+      is(lastSecurityState.extendedValidation, false);
+      iframe.src = 'https://example.com:443/' + filepath + '?broken';
+      break;
+    case 3:
+      is(lastSecurityState.state, 'broken');
+      is(lastSecurityState.extendedValidation, false);
+      SimpleTest.finish();
+    }
+  });
+
+  iframe.src = "https://example.com/" + filepath;
+  document.body.appendChild(iframe);
+}
+
+runTest();
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/file_browserElement_SecurityChange.html
@@ -0,0 +1,16 @@
+<html>
+<head>
+<script>
+if (location.search == '?broken') {
+  // Load something non-https.
+  var s = document.createElement('script');
+  s.src = 'http://example.com/dom/browser-element/mochitest/file_empty_script.js';
+  document.head.appendChild(s);
+}
+</script>
+</head>
+
+<body>
+file_browserElement_SecurityChange.html.
+</body>
+</html>
new file mode 100644
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/test_browserElement_inproc_SecurityChange.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test of browser element.</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<script type="application/javascript;version=1.7" src="browserElement_SecurityChange.js">
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/test_browserElement_oop_SecurityChange.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test of browser element.</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<script type="application/javascript;version=1.7" src="browserElement_SecurityChange.js">
+</script>
+</body>
+</html>
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -150,17 +150,17 @@ nsDOMDeviceStorage::SetRootFileForType(c
   }
   f = nsnull;
 #endif
 
   // Picture directory
   if (aType.Equals(NS_LITERAL_STRING("pictures"))) {
 #ifdef MOZ_WIDGET_GONK
     if (aIndex == 0) {
-      NS_NewLocalFile(NS_LITERAL_STRING("/sdcard/Pictures"), false, getter_AddRefs(f));
+      NS_NewLocalFile(NS_LITERAL_STRING("/sdcard/DCIM"), false, getter_AddRefs(f));
     }
 #elif defined (MOZ_WIDGET_COCOA)
     if (aIndex == 0) {
       dirService->Get(NS_OSX_PICTURE_DOCUMENTS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
     }
 #elif defined (XP_UNIX)
     if (aIndex == 0) {
       dirService->Get(NS_UNIX_XDG_PICTURES_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
--- a/dom/imptests/Makefile.in
+++ b/dom/imptests/Makefile.in
@@ -6,20 +6,22 @@ DEPTH = ../..
 topsrcdir = @top_srcdir@
 srcdir = @srcdir@
 VPATH = @srcdir@
 relativesrcdir = dom/imported-tests
 
 DIRS = \
   failures/editing/conformancetest \
   failures/editing/selecttest \
-  failures/webapps/WebStorage/tests/submissions/Ms2ger \
+  failures/html/tests/submission/Opera/microdata \
+  failures/webapps/DOMCore/tests/approved \
+  failures/webapps/DOMCore/tests/submissions/Opera \
   failures/webapps/WebStorage/tests/submissions/Infraware \
-  failures/webapps/DOMCore/tests/submissions/Opera \
-  failures/html/tests/submission/Opera/microdata \
+  failures/webapps/WebStorage/tests/submissions/Ms2ger \
+  failures/webapps/XMLHttpRequest/tests/submissions/Ms2ger \
   $(NULL)
 
 include $(srcdir)/editing.mk
 include $(srcdir)/html.mk
 include $(srcdir)/webapps.mk
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
new file mode 100644
--- /dev/null
+++ b/dom/imptests/failures/webapps/DOMCore/tests/approved/Makefile.in
@@ -0,0 +1,30 @@
+DEPTH = ../../../../../../..
+
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+relativesrcdir = dom/imptests/failures/webapps/DOMCore/tests/approved
+
+DIRS = \
+  $(NULL)
+
+include $(DEPTH)/config/autoconf.mk
+include $(topsrcdir)/config/rules.mk
+
+_TESTS = \
+  test_Range-cloneContents.html.json \
+  test_Range-cloneRange.html.json \
+  test_Range-collapse.html.json \
+  test_Range-commonAncestorContainer.html.json \
+  test_Range-compareBoundaryPoints.html.json \
+  test_Range-comparePoint.html.json \
+  test_Range-deleteContents.html.json \
+  test_Range-extractContents.html.json \
+  test_Range-intersectsNode.html.json \
+  test_Range-isPointInRange.html.json \
+  test_Range-set.html.json \
+  test_interfaces.html.json \
+  $(NULL)
+
+libs:: $(_TESTS)
+	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/dom/imptests/failures/webapps/DOMCore/tests/approved/test_Range-cloneContents.html.json
@@ -0,0 +1,3 @@
+{
+  "Detached Range": true
+}
new file mode 100644
--- /dev/null
+++ b/dom/imptests/failures/webapps/DOMCore/tests/approved/test_Range-cloneRange.html.json
@@ -0,0 +1,3 @@
+{
+  "Range 45 \"detached\"":  true
+}
new file mode 100644
--- /dev/null
+++ b/dom/imptests/failures/webapps/DOMCore/tests/approved/test_Range-collapse.html.json
@@ -0,0 +1,4 @@
+{
+  "Range 45 \"detached\", toStart true":  true,
+  "Range 45 \"detached\", toStart false": true
+}
new file mode 100644
--- /dev/null
+++ b/dom/imptests/failures/webapps/DOMCore/tests/approved/test_Range-commonAncestorContainer.html.json
@@ -0,0 +1,3 @@
+{
+  "0: range [detached]": true
+}
new file mode 100644
--- /dev/null
+++ b/dom/imptests/failures/webapps/DOMCore/tests/approved/test_Range-compareBoundaryPoints.html.json
@@ -0,0 +1,1899 @@
+{
+  "0,0,0: context range 0 [detached], argument range 0 [detached], how 0": true,
+  "0,0,1: context range 0 [detached], argument range 0 [detached], how 1": true,
+  "0,0,2: context range 0 [detached], argument range 0 [detached], how 2": true,
+  "0,0,3: context range 0 [detached], argument range 0 [detached], how 3": true,
+  "0,0,4: context range 0 [detached], argument range 0 [detached], how -1": true,
+  "0,0,5: context range 0 [detached], argument range 0 [detached], how 4": true,
+  "0,0,6: context range 0 [detached], argument range 0 [detached], how 5": true,
+  "0,0,7: context range 0 [detached], argument range 0 [detached], how NaN": true,
+  "0,0,8: context range 0 [detached], argument range 0 [detached], how -0": true,
+  "0,0,9: context range 0 [detached], argument range 0 [detached], how Infinity": true,
+  "0,0,10: context range 0 [detached], argument range 0 [detached], how -Infinity": true,
+  "0,0,11: context range 0 [detached], argument range 0 [detached], how 65535": true,
+  "0,0,12: context range 0 [detached], argument range 0 [detached], how 65536": true,
+  "0,0,13: context range 0 [detached], argument range 0 [detached], how 65537": true,
+  "0,0,14: context range 0 [detached], argument range 0 [detached], how 65538": true,
+  "0,0,15: context range 0 [detached], argument range 0 [detached], how 65539": true,
+  "0,0,16: context range 0 [detached], argument range 0 [detached], how 65540": true,
+  "0,0,17: context range 0 [detached], argument range 0 [detached], how -65537": true,
+  "0,0,18: context range 0 [detached], argument range 0 [detached], how -65536": true,
+  "0,0,19: context range 0 [detached], argument range 0 [detached], how -65535": true,
+  "0,0,20: context range 0 [detached], argument range 0 [detached], how -65534": true,
+  "0,0,21: context range 0 [detached], argument range 0 [detached], how -65533": true,
+  "0,0,22: context range 0 [detached], argument range 0 [detached], how -65532": true,
+  "0,0,23: context range 0 [detached], argument range 0 [detached], how 4294967295": true,
+  "0,0,24: context range 0 [detached], argument range 0 [detached], how 4294967296": true,
+  "0,0,25: context range 0 [detached], argument range 0 [detached], how 4294967297": true,
+  "0,0,26: context range 0 [detached], argument range 0 [detached], how 4294967298": true,
+  "0,0,27: context range 0 [detached], argument range 0 [detached], how 4294967299": true,
+  "0,0,28: context range 0 [detached], argument range 0 [detached], how 4294967300": true,
+  "0,0,29: context range 0 [detached], argument range 0 [detached], how -0.5": true,
+  "0,0,30: context range 0 [detached], argument range 0 [detached], how 0.5": true,
+  "0,0,31: context range 0 [detached], argument range 0 [detached], how 1.5": true,
+  "0,0,32: context range 0 [detached], argument range 0 [detached], how 2.5": true,
+  "0,0,33: context range 0 [detached], argument range 0 [detached], how 3.5": true,
+  "0,0,34: context range 0 [detached], argument range 0 [detached], how 4.5": true,
+  "0,0,35: context range 0 [detached], argument range 0 [detached], how -1.5": true,
+  "0,0,36: context range 0 [detached], argument range 0 [detached], how -0.5": true,
+  "0,0,37: context range 0 [detached], argument range 0 [detached], how 0.5": true,
+  "0,0,38: context range 0 [detached], argument range 0 [detached], how 1.5": true,
+  "0,0,39: context range 0 [detached], argument range 0 [detached], how 2.5": true,
+  "0,0,40: context range 0 [detached], argument range 0 [detached], how 3.5": true,
+  "0,0,41: context range 0 [detached], argument range 0 [detached], how -73.5": true,
+  "0,0,42: context range 0 [detached], argument range 0 [detached], how -72.5": true,
+  "0,0,43: context range 0 [detached], argument range 0 [detached], how -71.5": true,
+  "0,0,44: context range 0 [detached], argument range 0 [detached], how -70.5": true,
+  "0,0,45: context range 0 [detached], argument range 0 [detached], how -69.5": true,
+  "0,0,46: context range 0 [detached], argument range 0 [detached], how -68.5": true,
+  "0,0,47: context range 0 [detached], argument range 0 [detached], how \"0\"": true,
+  "0,0,48: context range 0 [detached], argument range 0 [detached], how \"1\"": true,
+  "0,0,49: context range 0 [detached], argument range 0 [detached], how \"2\"": true,
+  "0,0,50: context range 0 [detached], argument range 0 [detached], how \"3\"": true,
+  "0,0,51: context range 0 [detached], argument range 0 [detached], how \"-1\"": true,
+  "0,0,52: context range 0 [detached], argument range 0 [detached], how \"4\"": true,
+  "0,0,53: context range 0 [detached], argument range 0 [detached], how \"5\"": true,
+  "0,0,54: context range 0 [detached], argument range 0 [detached], how \"NaN\"": true,
+  "0,0,55: context range 0 [detached], argument range 0 [detached], how \"0\"": true,
+  "0,0,56: context range 0 [detached], argument range 0 [detached], how \"Infinity\"": true,
+  "0,0,57: context range 0 [detached], argument range 0 [detached], how \"-Infinity\"": true,
+  "0,0,58: context range 0 [detached], argument range 0 [detached], how \"65535\"": true,
+  "0,0,59: context range 0 [detached], argument range 0 [detached], how \"65536\"": true,
+  "0,0,60: context range 0 [detached], argument range 0 [detached], how \"65537\"": true,
+  "0,0,61: context range 0 [detached], argument range 0 [detached], how \"65538\"": true,
+  "0,0,62: context range 0 [detached], argument range 0 [detached], how \"65539\"": true,
+  "0,0,63: context range 0 [detached], argument range 0 [detached], how \"65540\"": true,
+  "0,0,64: context range 0 [detached], argument range 0 [detached], how \"-65537\"": true,
+  "0,0,65: context range 0 [detached], argument range 0 [detached], how \"-65536\"": true,
+  "0,0,66: context range 0 [detached], argument range 0 [detached], how \"-65535\"": true,
+  "0,0,67: context range 0 [detached], argument range 0 [detached], how \"-65534\"": true,
+  "0,0,68: context range 0 [detached], argument range 0 [detached], how \"-65533\"": true,
+  "0,0,69: context range 0 [detached], argument range 0 [detached], how \"-65532\"": true,
+  "0,0,70: context range 0 [detached], argument range 0 [detached], how \"4294967295\"": true,
+  "0,0,71: context range 0 [detached], argument range 0 [detached], how \"4294967296\"": true,
+  "0,0,72: context range 0 [detached], argument range 0 [detached], how \"4294967297\"": true,
+  "0,0,73: context range 0 [detached], argument range 0 [detached], how \"4294967298\"": true,
+  "0,0,74: context range 0 [detached], argument range 0 [detached], how \"4294967299\"": true,
+  "0,0,75: context range 0 [detached], argument range 0 [detached], how \"4294967300\"": true,
+  "0,0,76: context range 0 [detached], argument range 0 [detached], how \"-0.5\"": true,
+  "0,0,77: context range 0 [detached], argument range 0 [detached], how \"0.5\"": true,
+  "0,0,78: context range 0 [detached], argument range 0 [detached], how \"1.5\"": true,
+  "0,0,79: context range 0 [detached], argument range 0 [detached], how \"2.5\"": true,
+  "0,0,80: context range 0 [detached], argument range 0 [detached], how \"3.5\"": true,
+  "0,0,81: context range 0 [detached], argument range 0 [detached], how \"4.5\"": true,
+  "0,0,82: context range 0 [detached], argument range 0 [detached], how \"-1.5\"": true,
+  "0,0,83: context range 0 [detached], argument range 0 [detached], how \"-0.5\"": true,
+  "0,0,84: context range 0 [detached], argument range 0 [detached], how \"0.5\"": true,
+  "0,0,85: context range 0 [detached], argument range 0 [detached], how \"1.5\"": true,
+  "0,0,86: context range 0 [detached], argument range 0 [detached], how \"2.5\"": true,
+  "0,0,87: context range 0 [detached], argument range 0 [detached], how \"3.5\"": true,
+  "0,0,88: context range 0 [detached], argument range 0 [detached], how \"-73.5\"": true,
+  "0,0,89: context range 0 [detached], argument range 0 [detached], how \"-72.5\"": true,
+  "0,0,90: context range 0 [detached], argument range 0 [detached], how \"-71.5\"": true,
+  "0,0,91: context range 0 [detached], argument range 0 [detached], how \"-70.5\"": true,
+  "0,0,92: context range 0 [detached], argument range 0 [detached], how \"-69.5\"": true,
+  "0,0,93: context range 0 [detached], argument range 0 [detached], how \"-68.5\"": true,
+  "0,0,94: context range 0 [detached], argument range 0 [detached], how \"6.5536e4\"": true,
+  "0,0,95: context range 0 [detached], argument range 0 [detached], how null": true,
+  "0,0,96: context range 0 [detached], argument range 0 [detached], how undefined": true,
+  "0,0,97: context range 0 [detached], argument range 0 [detached], how true": true,
+  "0,0,98: context range 0 [detached], argument range 0 [detached], how false": true,
+  "0,0,99: context range 0 [detached], argument range 0 [detached], how \"\"": true,
+  "0,0,100: context range 0 [detached], argument range 0 [detached], how \"quasit\"": true,
+  "0,1,0: context range 0 [detached], argument range 1 [paras[0].firstChild, 0, paras[0].firstChild, 0], how 0": true,
+  "0,1,1: context range 0 [detached], argument range 1 [paras[0].firstChild, 0, paras[0].firstChild, 0], how 1": true,
+  "0,1,2: context range 0 [detached], argument range 1 [paras[0].firstChild, 0, paras[0].firstChild, 0], how 2": true,
+  "0,1,3: context range 0 [detached], argument range 1 [paras[0].firstChild, 0, paras[0].firstChild, 0], how 3": true,
+  "0,2,0: context range 0 [detached], argument range 2 [paras[0].firstChild, 0, paras[0].firstChild, 1], how 0": true,
+  "0,2,1: context range 0 [detached], argument range 2 [paras[0].firstChild, 0, paras[0].firstChild, 1], how 1": true,
+  "0,2,2: context range 0 [detached], argument range 2 [paras[0].firstChild, 0, paras[0].firstChild, 1], how 2": true,
+  "0,2,3: context range 0 [detached], argument range 2 [paras[0].firstChild, 0, paras[0].firstChild, 1], how 3": true,
+  "0,3,0: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 0": true,
+  "0,3,1: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 1": true,
+  "0,3,2: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 2": true,
+  "0,3,3: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 3": true,
+  "0,3,4: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -1": true,
+  "0,3,5: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 4": true,
+  "0,3,6: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 5": true,
+  "0,3,7: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how NaN": true,
+  "0,3,8: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -0": true,
+  "0,3,9: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how Infinity": true,
+  "0,3,10: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -Infinity": true,
+  "0,3,11: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 65535": true,
+  "0,3,12: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 65536": true,
+  "0,3,13: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 65537": true,
+  "0,3,14: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 65538": true,
+  "0,3,15: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 65539": true,
+  "0,3,16: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 65540": true,
+  "0,3,17: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -65537": true,
+  "0,3,18: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -65536": true,
+  "0,3,19: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -65535": true,
+  "0,3,20: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -65534": true,
+  "0,3,21: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -65533": true,
+  "0,3,22: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -65532": true,
+  "0,3,23: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 4294967295": true,
+  "0,3,24: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 4294967296": true,
+  "0,3,25: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 4294967297": true,
+  "0,3,26: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 4294967298": true,
+  "0,3,27: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 4294967299": true,
+  "0,3,28: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 4294967300": true,
+  "0,3,29: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -0.5": true,
+  "0,3,30: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 0.5": true,
+  "0,3,31: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 1.5": true,
+  "0,3,32: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 2.5": true,
+  "0,3,33: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 3.5": true,
+  "0,3,34: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 4.5": true,
+  "0,3,35: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -1.5": true,
+  "0,3,36: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -0.5": true,
+  "0,3,37: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 0.5": true,
+  "0,3,38: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 1.5": true,
+  "0,3,39: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 2.5": true,
+  "0,3,40: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 3.5": true,
+  "0,3,41: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -73.5": true,
+  "0,3,42: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -72.5": true,
+  "0,3,43: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -71.5": true,
+  "0,3,44: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -70.5": true,
+  "0,3,45: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -69.5": true,
+  "0,3,46: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -68.5": true,
+  "0,3,47: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"0\"": true,
+  "0,3,48: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"1\"": true,
+  "0,3,49: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"2\"": true,
+  "0,3,50: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"3\"": true,
+  "0,3,51: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-1\"": true,
+  "0,3,52: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"4\"": true,
+  "0,3,53: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"5\"": true,
+  "0,3,54: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"NaN\"": true,
+  "0,3,55: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"0\"": true,
+  "0,3,56: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"Infinity\"": true,
+  "0,3,57: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-Infinity\"": true,
+  "0,3,58: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"65535\"": true,
+  "0,3,59: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"65536\"": true,
+  "0,3,60: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"65537\"": true,
+  "0,3,61: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"65538\"": true,
+  "0,3,62: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"65539\"": true,
+  "0,3,63: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"65540\"": true,
+  "0,3,64: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-65537\"": true,
+  "0,3,65: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-65536\"": true,
+  "0,3,66: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-65535\"": true,
+  "0,3,67: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-65534\"": true,
+  "0,3,68: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-65533\"": true,
+  "0,3,69: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-65532\"": true,
+  "0,3,70: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"4294967295\"": true,
+  "0,3,71: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"4294967296\"": true,
+  "0,3,72: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"4294967297\"": true,
+  "0,3,73: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"4294967298\"": true,
+  "0,3,74: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"4294967299\"": true,
+  "0,3,75: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"4294967300\"": true,
+  "0,3,76: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-0.5\"": true,
+  "0,3,77: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"0.5\"": true,
+  "0,3,78: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"1.5\"": true,
+  "0,3,79: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"2.5\"": true,
+  "0,3,80: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"3.5\"": true,
+  "0,3,81: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"4.5\"": true,
+  "0,3,82: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-1.5\"": true,
+  "0,3,83: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-0.5\"": true,
+  "0,3,84: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"0.5\"": true,
+  "0,3,85: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"1.5\"": true,
+  "0,3,86: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"2.5\"": true,
+  "0,3,87: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"3.5\"": true,
+  "0,3,88: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-73.5\"": true,
+  "0,3,89: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-72.5\"": true,
+  "0,3,90: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-71.5\"": true,
+  "0,3,91: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-70.5\"": true,
+  "0,3,92: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-69.5\"": true,
+  "0,3,93: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-68.5\"": true,
+  "0,3,94: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"6.5536e4\"": true,
+  "0,3,95: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how null": true,
+  "0,3,96: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how undefined": true,
+  "0,3,97: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how true": true,
+  "0,3,98: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how false": true,
+  "0,3,99: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"\"": true,
+  "0,3,100: context range 0 [detached], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"quasit\"": true,
+  "0,4,0: context range 0 [detached], argument range 4 [paras[0].firstChild, 2, paras[0].firstChild, 9], how 0": true,
+  "0,4,1: context range 0 [detached], argument range 4 [paras[0].firstChild, 2, paras[0].firstChild, 9], how 1": true,
+  "0,4,2: context range 0 [detached], argument range 4 [paras[0].firstChild, 2, paras[0].firstChild, 9], how 2": true,
+  "0,4,3: context range 0 [detached], argument range 4 [paras[0].firstChild, 2, paras[0].firstChild, 9], how 3": true,
+  "0,5,0: context range 0 [detached], argument range 5 [paras[1].firstChild, 0, paras[1].firstChild, 0], how 0": true,
+  "0,5,1: context range 0 [detached], argument range 5 [paras[1].firstChild, 0, paras[1].firstChild, 0], how 1": true,
+  "0,5,2: context range 0 [detached], argument range 5 [paras[1].firstChild, 0, paras[1].firstChild, 0], how 2": true,
+  "0,5,3: context range 0 [detached], argument range 5 [paras[1].firstChild, 0, paras[1].firstChild, 0], how 3": true,
+  "0,6,0: context range 0 [detached], argument range 6 [paras[1].firstChild, 0, paras[1].firstChild, 1], how 0": true,
+  "0,6,1: context range 0 [detached], argument range 6 [paras[1].firstChild, 0, paras[1].firstChild, 1], how 1": true,
+  "0,6,2: context range 0 [detached], argument range 6 [paras[1].firstChild, 0, paras[1].firstChild, 1], how 2": true,
+  "0,6,3: context range 0 [detached], argument range 6 [paras[1].firstChild, 0, paras[1].firstChild, 1], how 3": true,
+  "0,7,0: context range 0 [detached], argument range 7 [paras[1].firstChild, 2, paras[1].firstChild, 8], how 0": true,
+  "0,7,1: context range 0 [detached], argument range 7 [paras[1].firstChild, 2, paras[1].firstChild, 8], how 1": true,
+  "0,7,2: context range 0 [detached], argument range 7 [paras[1].firstChild, 2, paras[1].firstChild, 8], how 2": true,
+  "0,7,3: context range 0 [detached], argument range 7 [paras[1].firstChild, 2, paras[1].firstChild, 8], how 3": true,
+  "0,8,0: context range 0 [detached], argument range 8 [paras[1].firstChild, 2, paras[1].firstChild, 9], how 0": true,
+  "0,8,1: context range 0 [detached], argument range 8 [paras[1].firstChild, 2, paras[1].firstChild, 9], how 1": true,
+  "0,8,2: context range 0 [detached], argument range 8 [paras[1].firstChild, 2, paras[1].firstChild, 9], how 2": true,
+  "0,8,3: context range 0 [detached], argument range 8 [paras[1].firstChild, 2, paras[1].firstChild, 9], how 3": true,
+  "0,9,0: context range 0 [detached], argument range 9 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], how 0": true,
+  "0,9,1: context range 0 [detached], argument range 9 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], how 1": true,
+  "0,9,2: context range 0 [detached], argument range 9 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], how 2": true,
+  "0,9,3: context range 0 [detached], argument range 9 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], how 3": true,
+  "0,10,0: context range 0 [detached], argument range 10 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 1], how 0": true,
+  "0,10,1: context range 0 [detached], argument range 10 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 1], how 1": true,
+  "0,10,2: context range 0 [detached], argument range 10 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 1], how 2": true,
+  "0,10,3: context range 0 [detached], argument range 10 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 1], how 3": true,
+  "0,11,0: context range 0 [detached], argument range 11 [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8], how 0": true,
+  "0,11,1: context range 0 [detached], argument range 11 [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8], how 1": true,
+  "0,11,2: context range 0 [detached], argument range 11 [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8], how 2": true,
+  "0,11,3: context range 0 [detached], argument range 11 [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8], how 3": true,
+  "0,12,0: context range 0 [detached], argument range 12 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], how 0": true,
+  "0,12,1: context range 0 [detached], argument range 12 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], how 1": true,
+  "0,12,2: context range 0 [detached], argument range 12 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], how 2": true,
+  "0,12,3: context range 0 [detached], argument range 12 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], how 3": true,
+  "0,13,0: context range 0 [detached], argument range 13 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 1], how 0": true,
+  "0,13,1: context range 0 [detached], argument range 13 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 1], how 1": true,
+  "0,13,2: context range 0 [detached], argument range 13 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 1], how 2": true,
+  "0,13,3: context range 0 [detached], argument range 13 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 1], how 3": true,
+  "0,14,0: context range 0 [detached], argument range 14 [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8], how 0": true,
+  "0,14,1: context range 0 [detached], argument range 14 [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8], how 1": true,
+  "0,14,2: context range 0 [detached], argument range 14 [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8], how 2": true,
+  "0,14,3: context range 0 [detached], argument range 14 [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8], how 3": true,
+  "0,15,0: context range 0 [detached], argument range 15 [document.documentElement, 0, document.documentElement, 1], how 0": true,
+  "0,15,1: context range 0 [detached], argument range 15 [document.documentElement, 0, document.documentElement, 1], how 1": true,
+  "0,15,2: context range 0 [detached], argument range 15 [document.documentElement, 0, document.documentElement, 1], how 2": true,
+  "0,15,3: context range 0 [detached], argument range 15 [document.documentElement, 0, document.documentElement, 1], how 3": true,
+  "0,16,0: context range 0 [detached], argument range 16 [document.documentElement, 0, document.documentElement, 2], how 0": true,
+  "0,16,1: context range 0 [detached], argument range 16 [document.documentElement, 0, document.documentElement, 2], how 1": true,
+  "0,16,2: context range 0 [detached], argument range 16 [document.documentElement, 0, document.documentElement, 2], how 2": true,
+  "0,16,3: context range 0 [detached], argument range 16 [document.documentElement, 0, document.documentElement, 2], how 3": true,
+  "0,17,0: context range 0 [detached], argument range 17 [document.documentElement, 1, document.documentElement, 2], how 0": true,
+  "0,17,1: context range 0 [detached], argument range 17 [document.documentElement, 1, document.documentElement, 2], how 1": true,
+  "0,17,2: context range 0 [detached], argument range 17 [document.documentElement, 1, document.documentElement, 2], how 2": true,
+  "0,17,3: context range 0 [detached], argument range 17 [document.documentElement, 1, document.documentElement, 2], how 3": true,
+  "0,18,0: context range 0 [detached], argument range 18 [document.head, 1, document.head, 1], how 0": true,
+  "0,18,1: context range 0 [detached], argument range 18 [document.head, 1, document.head, 1], how 1": true,
+  "0,18,2: context range 0 [detached], argument range 18 [document.head, 1, document.head, 1], how 2": true,
+  "0,18,3: context range 0 [detached], argument range 18 [document.head, 1, document.head, 1], how 3": true,
+  "0,19,0: context range 0 [detached], argument range 19 [document.body, 4, document.body, 5], how 0": true,
+  "0,19,1: context range 0 [detached], argument range 19 [document.body, 4, document.body, 5], how 1": true,
+  "0,19,2: context range 0 [detached], argument range 19 [document.body, 4, document.body, 5], how 2": true,
+  "0,19,3: context range 0 [detached], argument range 19 [document.body, 4, document.body, 5], how 3": true,
+  "0,20,0: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 0": true,
+  "0,20,1: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 1": true,
+  "0,20,2: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 2": true,
+  "0,20,3: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 3": true,
+  "0,20,4: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -1": true,
+  "0,20,5: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 4": true,
+  "0,20,6: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 5": true,
+  "0,20,7: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how NaN": true,
+  "0,20,8: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -0": true,
+  "0,20,9: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how Infinity": true,
+  "0,20,10: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -Infinity": true,
+  "0,20,11: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 65535": true,
+  "0,20,12: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 65536": true,
+  "0,20,13: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 65537": true,
+  "0,20,14: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 65538": true,
+  "0,20,15: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 65539": true,
+  "0,20,16: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 65540": true,
+  "0,20,17: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -65537": true,
+  "0,20,18: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -65536": true,
+  "0,20,19: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -65535": true,
+  "0,20,20: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -65534": true,
+  "0,20,21: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -65533": true,
+  "0,20,22: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -65532": true,
+  "0,20,23: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 4294967295": true,
+  "0,20,24: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 4294967296": true,
+  "0,20,25: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 4294967297": true,
+  "0,20,26: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 4294967298": true,
+  "0,20,27: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 4294967299": true,
+  "0,20,28: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 4294967300": true,
+  "0,20,29: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -0.5": true,
+  "0,20,30: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 0.5": true,
+  "0,20,31: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 1.5": true,
+  "0,20,32: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 2.5": true,
+  "0,20,33: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 3.5": true,
+  "0,20,34: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 4.5": true,
+  "0,20,35: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -1.5": true,
+  "0,20,36: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -0.5": true,
+  "0,20,37: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 0.5": true,
+  "0,20,38: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 1.5": true,
+  "0,20,39: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 2.5": true,
+  "0,20,40: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 3.5": true,
+  "0,20,41: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -73.5": true,
+  "0,20,42: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -72.5": true,
+  "0,20,43: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -71.5": true,
+  "0,20,44: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -70.5": true,
+  "0,20,45: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -69.5": true,
+  "0,20,46: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -68.5": true,
+  "0,20,47: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"0\"": true,
+  "0,20,48: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"1\"": true,
+  "0,20,49: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"2\"": true,
+  "0,20,50: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"3\"": true,
+  "0,20,51: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-1\"": true,
+  "0,20,52: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"4\"": true,
+  "0,20,53: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"5\"": true,
+  "0,20,54: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"NaN\"": true,
+  "0,20,55: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"0\"": true,
+  "0,20,56: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"Infinity\"": true,
+  "0,20,57: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-Infinity\"": true,
+  "0,20,58: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"65535\"": true,
+  "0,20,59: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"65536\"": true,
+  "0,20,60: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"65537\"": true,
+  "0,20,61: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"65538\"": true,
+  "0,20,62: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"65539\"": true,
+  "0,20,63: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"65540\"": true,
+  "0,20,64: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-65537\"": true,
+  "0,20,65: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-65536\"": true,
+  "0,20,66: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-65535\"": true,
+  "0,20,67: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-65534\"": true,
+  "0,20,68: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-65533\"": true,
+  "0,20,69: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-65532\"": true,
+  "0,20,70: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"4294967295\"": true,
+  "0,20,71: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"4294967296\"": true,
+  "0,20,72: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"4294967297\"": true,
+  "0,20,73: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"4294967298\"": true,
+  "0,20,74: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"4294967299\"": true,
+  "0,20,75: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"4294967300\"": true,
+  "0,20,76: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-0.5\"": true,
+  "0,20,77: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"0.5\"": true,
+  "0,20,78: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"1.5\"": true,
+  "0,20,79: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"2.5\"": true,
+  "0,20,80: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"3.5\"": true,
+  "0,20,81: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"4.5\"": true,
+  "0,20,82: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-1.5\"": true,
+  "0,20,83: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-0.5\"": true,
+  "0,20,84: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"0.5\"": true,
+  "0,20,85: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"1.5\"": true,
+  "0,20,86: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"2.5\"": true,
+  "0,20,87: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"3.5\"": true,
+  "0,20,88: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-73.5\"": true,
+  "0,20,89: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-72.5\"": true,
+  "0,20,90: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-71.5\"": true,
+  "0,20,91: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-70.5\"": true,
+  "0,20,92: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-69.5\"": true,
+  "0,20,93: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-68.5\"": true,
+  "0,20,94: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"6.5536e4\"": true,
+  "0,20,95: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how null": true,
+  "0,20,96: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how undefined": true,
+  "0,20,97: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how true": true,
+  "0,20,98: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how false": true,
+  "0,20,99: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"\"": true,
+  "0,20,100: context range 0 [detached], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"quasit\"": true,
+  "0,21,0: context range 0 [detached], argument range 21 [foreignDoc.head, 1, foreignDoc.head, 1], how 0": true,
+  "0,21,1: context range 0 [detached], argument range 21 [foreignDoc.head, 1, foreignDoc.head, 1], how 1": true,
+  "0,21,2: context range 0 [detached], argument range 21 [foreignDoc.head, 1, foreignDoc.head, 1], how 2": true,
+  "0,21,3: context range 0 [detached], argument range 21 [foreignDoc.head, 1, foreignDoc.head, 1], how 3": true,
+  "0,22,0: context range 0 [detached], argument range 22 [foreignDoc.body, 0, foreignDoc.body, 0], how 0": true,
+  "0,22,1: context range 0 [detached], argument range 22 [foreignDoc.body, 0, foreignDoc.body, 0], how 1": true,
+  "0,22,2: context range 0 [detached], argument range 22 [foreignDoc.body, 0, foreignDoc.body, 0], how 2": true,
+  "0,22,3: context range 0 [detached], argument range 22 [foreignDoc.body, 0, foreignDoc.body, 0], how 3": true,
+  "0,23,0: context range 0 [detached], argument range 23 [paras[0], 0, paras[0], 0], how 0": true,
+  "0,23,1: context range 0 [detached], argument range 23 [paras[0], 0, paras[0], 0], how 1": true,
+  "0,23,2: context range 0 [detached], argument range 23 [paras[0], 0, paras[0], 0], how 2": true,
+  "0,23,3: context range 0 [detached], argument range 23 [paras[0], 0, paras[0], 0], how 3": true,
+  "0,24,0: context range 0 [detached], argument range 24 [paras[0], 0, paras[0], 1], how 0": true,
+  "0,24,1: context range 0 [detached], argument range 24 [paras[0], 0, paras[0], 1], how 1": true,
+  "0,24,2: context range 0 [detached], argument range 24 [paras[0], 0, paras[0], 1], how 2": true,
+  "0,24,3: context range 0 [detached], argument range 24 [paras[0], 0, paras[0], 1], how 3": true,
+  "0,25,0: context range 0 [detached], argument range 25 [detachedPara1, 0, detachedPara1, 0], how 0": true,
+  "0,25,1: context range 0 [detached], argument range 25 [detachedPara1, 0, detachedPara1, 0], how 1": true,
+  "0,25,2: context range 0 [detached], argument range 25 [detachedPara1, 0, detachedPara1, 0], how 2": true,
+  "0,25,3: context range 0 [detached], argument range 25 [detachedPara1, 0, detachedPara1, 0], how 3": true,
+  "0,26,0: context range 0 [detached], argument range 26 [detachedPara1, 0, detachedPara1, 1], how 0": true,
+  "0,26,1: context range 0 [detached], argument range 26 [detachedPara1, 0, detachedPara1, 1], how 1": true,
+  "0,26,2: context range 0 [detached], argument range 26 [detachedPara1, 0, detachedPara1, 1], how 2": true,
+  "0,26,3: context range 0 [detached], argument range 26 [detachedPara1, 0, detachedPara1, 1], how 3": true,
+  "0,27,0: context range 0 [detached], argument range 27 [paras[0].firstChild, 0, paras[1].firstChild, 0], how 0": true,
+  "0,27,1: context range 0 [detached], argument range 27 [paras[0].firstChild, 0, paras[1].firstChild, 0], how 1": true,
+  "0,27,2: context range 0 [detached], argument range 27 [paras[0].firstChild, 0, paras[1].firstChild, 0], how 2": true,
+  "0,27,3: context range 0 [detached], argument range 27 [paras[0].firstChild, 0, paras[1].firstChild, 0], how 3": true,
+  "0,28,0: context range 0 [detached], argument range 28 [paras[0].firstChild, 0, paras[1].firstChild, 8], how 0": true,
+  "0,28,1: context range 0 [detached], argument range 28 [paras[0].firstChild, 0, paras[1].firstChild, 8], how 1": true,
+  "0,28,2: context range 0 [detached], argument range 28 [paras[0].firstChild, 0, paras[1].firstChild, 8], how 2": true,
+  "0,28,3: context range 0 [detached], argument range 28 [paras[0].firstChild, 0, paras[1].firstChild, 8], how 3": true,
+  "0,29,0: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 0": true,
+  "0,29,1: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 1": true,
+  "0,29,2: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 2": true,
+  "0,29,3: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 3": true,
+  "0,29,4: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -1": true,
+  "0,29,5: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 4": true,
+  "0,29,6: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 5": true,
+  "0,29,7: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how NaN": true,
+  "0,29,8: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -0": true,
+  "0,29,9: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how Infinity": true,
+  "0,29,10: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -Infinity": true,
+  "0,29,11: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 65535": true,
+  "0,29,12: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 65536": true,
+  "0,29,13: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 65537": true,
+  "0,29,14: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 65538": true,
+  "0,29,15: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 65539": true,
+  "0,29,16: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 65540": true,
+  "0,29,17: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -65537": true,
+  "0,29,18: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -65536": true,
+  "0,29,19: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -65535": true,
+  "0,29,20: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -65534": true,
+  "0,29,21: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -65533": true,
+  "0,29,22: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -65532": true,
+  "0,29,23: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 4294967295": true,
+  "0,29,24: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 4294967296": true,
+  "0,29,25: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 4294967297": true,
+  "0,29,26: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 4294967298": true,
+  "0,29,27: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 4294967299": true,
+  "0,29,28: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 4294967300": true,
+  "0,29,29: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -0.5": true,
+  "0,29,30: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 0.5": true,
+  "0,29,31: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 1.5": true,
+  "0,29,32: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 2.5": true,
+  "0,29,33: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 3.5": true,
+  "0,29,34: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 4.5": true,
+  "0,29,35: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -1.5": true,
+  "0,29,36: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -0.5": true,
+  "0,29,37: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 0.5": true,
+  "0,29,38: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 1.5": true,
+  "0,29,39: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 2.5": true,
+  "0,29,40: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 3.5": true,
+  "0,29,41: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -73.5": true,
+  "0,29,42: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -72.5": true,
+  "0,29,43: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -71.5": true,
+  "0,29,44: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -70.5": true,
+  "0,29,45: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -69.5": true,
+  "0,29,46: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -68.5": true,
+  "0,29,47: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"0\"": true,
+  "0,29,48: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"1\"": true,
+  "0,29,49: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"2\"": true,
+  "0,29,50: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"3\"": true,
+  "0,29,51: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-1\"": true,
+  "0,29,52: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"4\"": true,
+  "0,29,53: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"5\"": true,
+  "0,29,54: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"NaN\"": true,
+  "0,29,55: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"0\"": true,
+  "0,29,56: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"Infinity\"": true,
+  "0,29,57: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-Infinity\"": true,
+  "0,29,58: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"65535\"": true,
+  "0,29,59: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"65536\"": true,
+  "0,29,60: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"65537\"": true,
+  "0,29,61: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"65538\"": true,
+  "0,29,62: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"65539\"": true,
+  "0,29,63: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"65540\"": true,
+  "0,29,64: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-65537\"": true,
+  "0,29,65: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-65536\"": true,
+  "0,29,66: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-65535\"": true,
+  "0,29,67: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-65534\"": true,
+  "0,29,68: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-65533\"": true,
+  "0,29,69: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-65532\"": true,
+  "0,29,70: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"4294967295\"": true,
+  "0,29,71: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"4294967296\"": true,
+  "0,29,72: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"4294967297\"": true,
+  "0,29,73: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"4294967298\"": true,
+  "0,29,74: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"4294967299\"": true,
+  "0,29,75: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"4294967300\"": true,
+  "0,29,76: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-0.5\"": true,
+  "0,29,77: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"0.5\"": true,
+  "0,29,78: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"1.5\"": true,
+  "0,29,79: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"2.5\"": true,
+  "0,29,80: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"3.5\"": true,
+  "0,29,81: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"4.5\"": true,
+  "0,29,82: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-1.5\"": true,
+  "0,29,83: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-0.5\"": true,
+  "0,29,84: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"0.5\"": true,
+  "0,29,85: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"1.5\"": true,
+  "0,29,86: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"2.5\"": true,
+  "0,29,87: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"3.5\"": true,
+  "0,29,88: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-73.5\"": true,
+  "0,29,89: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-72.5\"": true,
+  "0,29,90: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-71.5\"": true,
+  "0,29,91: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-70.5\"": true,
+  "0,29,92: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-69.5\"": true,
+  "0,29,93: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-68.5\"": true,
+  "0,29,94: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"6.5536e4\"": true,
+  "0,29,95: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how null": true,
+  "0,29,96: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how undefined": true,
+  "0,29,97: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how true": true,
+  "0,29,98: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how false": true,
+  "0,29,99: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"\"": true,
+  "0,29,100: context range 0 [detached], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"quasit\"": true,
+  "0,30,0: context range 0 [detached], argument range 30 [paras[0], 0, paras[0].firstChild, 7], how 0": true,
+  "0,30,1: context range 0 [detached], argument range 30 [paras[0], 0, paras[0].firstChild, 7], how 1": true,
+  "0,30,2: context range 0 [detached], argument range 30 [paras[0], 0, paras[0].firstChild, 7], how 2": true,
+  "0,30,3: context range 0 [detached], argument range 30 [paras[0], 0, paras[0].firstChild, 7], how 3": true,
+  "0,31,0: context range 0 [detached], argument range 31 [testDiv, 2, paras[4], 1], how 0": true,
+  "0,31,1: context range 0 [detached], argument range 31 [testDiv, 2, paras[4], 1], how 1": true,
+  "0,31,2: context range 0 [detached], argument range 31 [testDiv, 2, paras[4], 1], how 2": true,
+  "0,31,3: context range 0 [detached], argument range 31 [testDiv, 2, paras[4], 1], how 3": true,
+  "0,32,0: context range 0 [detached], argument range 32 [testDiv, 1, paras[2].firstChild, 5], how 0": true,
+  "0,32,1: context range 0 [detached], argument range 32 [testDiv, 1, paras[2].firstChild, 5], how 1": true,
+  "0,32,2: context range 0 [detached], argument range 32 [testDiv, 1, paras[2].firstChild, 5], how 2": true,
+  "0,32,3: context range 0 [detached], argument range 32 [testDiv, 1, paras[2].firstChild, 5], how 3": true,
+  "0,33,0: context range 0 [detached], argument range 33 [document.documentElement, 1, document.body, 0], how 0": true,
+  "0,33,1: context range 0 [detached], argument range 33 [document.documentElement, 1, document.body, 0], how 1": true,
+  "0,33,2: context range 0 [detached], argument range 33 [document.documentElement, 1, document.body, 0], how 2": true,
+  "0,33,3: context range 0 [detached], argument range 33 [document.documentElement, 1, document.body, 0], how 3": true,
+  "0,34,0: context range 0 [detached], argument range 34 [foreignDoc.documentElement, 1, foreignDoc.body, 0], how 0": true,
+  "0,34,1: context range 0 [detached], argument range 34 [foreignDoc.documentElement, 1, foreignDoc.body, 0], how 1": true,
+  "0,34,2: context range 0 [detached], argument range 34 [foreignDoc.documentElement, 1, foreignDoc.body, 0], how 2": true,
+  "0,34,3: context range 0 [detached], argument range 34 [foreignDoc.documentElement, 1, foreignDoc.body, 0], how 3": true,
+  "0,35,0: context range 0 [detached], argument range 35 [document, 0, document, 1], how 0": true,
+  "0,35,1: context range 0 [detached], argument range 35 [document, 0, document, 1], how 1": true,
+  "0,35,2: context range 0 [detached], argument range 35 [document, 0, document, 1], how 2": true,
+  "0,35,3: context range 0 [detached], argument range 35 [document, 0, document, 1], how 3": true,
+  "0,36,0: context range 0 [detached], argument range 36 [document, 0, document, 2], how 0": true,
+  "0,36,1: context range 0 [detached], argument range 36 [document, 0, document, 2], how 1": true,
+  "0,36,2: context range 0 [detached], argument range 36 [document, 0, document, 2], how 2": true,
+  "0,36,3: context range 0 [detached], argument range 36 [document, 0, document, 2], how 3": true,
+  "0,37,0: context range 0 [detached], argument range 37 [document, 1, document, 2], how 0": true,
+  "0,37,1: context range 0 [detached], argument range 37 [document, 1, document, 2], how 1": true,
+  "0,37,2: context range 0 [detached], argument range 37 [document, 1, document, 2], how 2": true,
+  "0,37,3: context range 0 [detached], argument range 37 [document, 1, document, 2], how 3": true,
+  "0,38,0: context range 0 [detached], argument range 38 [comment, 2, comment, 3], how 0": true,
+  "0,38,1: context range 0 [detached], argument range 38 [comment, 2, comment, 3], how 1": true,
+  "0,38,2: context range 0 [detached], argument range 38 [comment, 2, comment, 3], how 2": true,
+  "0,38,3: context range 0 [detached], argument range 38 [comment, 2, comment, 3], how 3": true,
+  "0,39,0: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 0": true,
+  "0,39,1: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 1": true,
+  "0,39,2: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 2": true,
+  "0,39,3: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 3": true,
+  "0,39,4: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -1": true,
+  "0,39,5: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 4": true,
+  "0,39,6: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 5": true,
+  "0,39,7: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how NaN": true,
+  "0,39,8: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -0": true,
+  "0,39,9: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how Infinity": true,
+  "0,39,10: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -Infinity": true,
+  "0,39,11: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 65535": true,
+  "0,39,12: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 65536": true,
+  "0,39,13: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 65537": true,
+  "0,39,14: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 65538": true,
+  "0,39,15: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 65539": true,
+  "0,39,16: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 65540": true,
+  "0,39,17: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -65537": true,
+  "0,39,18: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -65536": true,
+  "0,39,19: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -65535": true,
+  "0,39,20: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -65534": true,
+  "0,39,21: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -65533": true,
+  "0,39,22: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -65532": true,
+  "0,39,23: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 4294967295": true,
+  "0,39,24: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 4294967296": true,
+  "0,39,25: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 4294967297": true,
+  "0,39,26: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 4294967298": true,
+  "0,39,27: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 4294967299": true,
+  "0,39,28: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 4294967300": true,
+  "0,39,29: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -0.5": true,
+  "0,39,30: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 0.5": true,
+  "0,39,31: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 1.5": true,
+  "0,39,32: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 2.5": true,
+  "0,39,33: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 3.5": true,
+  "0,39,34: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 4.5": true,
+  "0,39,35: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -1.5": true,
+  "0,39,36: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -0.5": true,
+  "0,39,37: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 0.5": true,
+  "0,39,38: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 1.5": true,
+  "0,39,39: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 2.5": true,
+  "0,39,40: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how 3.5": true,
+  "0,39,41: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -73.5": true,
+  "0,39,42: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -72.5": true,
+  "0,39,43: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -71.5": true,
+  "0,39,44: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -70.5": true,
+  "0,39,45: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -69.5": true,
+  "0,39,46: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how -68.5": true,
+  "0,39,47: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"0\"": true,
+  "0,39,48: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"1\"": true,
+  "0,39,49: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"2\"": true,
+  "0,39,50: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"3\"": true,
+  "0,39,51: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-1\"": true,
+  "0,39,52: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"4\"": true,
+  "0,39,53: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"5\"": true,
+  "0,39,54: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"NaN\"": true,
+  "0,39,55: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"0\"": true,
+  "0,39,56: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"Infinity\"": true,
+  "0,39,57: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-Infinity\"": true,
+  "0,39,58: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"65535\"": true,
+  "0,39,59: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"65536\"": true,
+  "0,39,60: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"65537\"": true,
+  "0,39,61: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"65538\"": true,
+  "0,39,62: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"65539\"": true,
+  "0,39,63: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"65540\"": true,
+  "0,39,64: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-65537\"": true,
+  "0,39,65: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-65536\"": true,
+  "0,39,66: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-65535\"": true,
+  "0,39,67: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-65534\"": true,
+  "0,39,68: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-65533\"": true,
+  "0,39,69: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-65532\"": true,
+  "0,39,70: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"4294967295\"": true,
+  "0,39,71: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"4294967296\"": true,
+  "0,39,72: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"4294967297\"": true,
+  "0,39,73: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"4294967298\"": true,
+  "0,39,74: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"4294967299\"": true,
+  "0,39,75: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"4294967300\"": true,
+  "0,39,76: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-0.5\"": true,
+  "0,39,77: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"0.5\"": true,
+  "0,39,78: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"1.5\"": true,
+  "0,39,79: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"2.5\"": true,
+  "0,39,80: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"3.5\"": true,
+  "0,39,81: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"4.5\"": true,
+  "0,39,82: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-1.5\"": true,
+  "0,39,83: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-0.5\"": true,
+  "0,39,84: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"0.5\"": true,
+  "0,39,85: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"1.5\"": true,
+  "0,39,86: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"2.5\"": true,
+  "0,39,87: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"3.5\"": true,
+  "0,39,88: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-73.5\"": true,
+  "0,39,89: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-72.5\"": true,
+  "0,39,90: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-71.5\"": true,
+  "0,39,91: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-70.5\"": true,
+  "0,39,92: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-69.5\"": true,
+  "0,39,93: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"-68.5\"": true,
+  "0,39,94: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"6.5536e4\"": true,
+  "0,39,95: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how null": true,
+  "0,39,96: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how undefined": true,
+  "0,39,97: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how true": true,
+  "0,39,98: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how false": true,
+  "0,39,99: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"\"": true,
+  "0,39,100: context range 0 [detached], argument range 39 [testDiv, 0, comment, 5], how \"quasit\"": true,
+  "0,40,0: context range 0 [detached], argument range 40 [paras[2].firstChild, 4, comment, 2], how 0": true,
+  "0,40,1: context range 0 [detached], argument range 40 [paras[2].firstChild, 4, comment, 2], how 1": true,
+  "0,40,2: context range 0 [detached], argument range 40 [paras[2].firstChild, 4, comment, 2], how 2": true,
+  "0,40,3: context range 0 [detached], argument range 40 [paras[2].firstChild, 4, comment, 2], how 3": true,
+  "0,41,0: context range 0 [detached], argument range 41 [paras[3], 1, comment, 8], how 0": true,
+  "0,41,1: context range 0 [detached], argument range 41 [paras[3], 1, comment, 8], how 1": true,
+  "0,41,2: context range 0 [detached], argument range 41 [paras[3], 1, comment, 8], how 2": true,
+  "0,41,3: context range 0 [detached], argument range 41 [paras[3], 1, comment, 8], how 3": true,
+  "0,42,0: context range 0 [detached], argument range 42 [foreignDoc, 0, foreignDoc, 0], how 0": true,
+  "0,42,1: context range 0 [detached], argument range 42 [foreignDoc, 0, foreignDoc, 0], how 1": true,
+  "0,42,2: context range 0 [detached], argument range 42 [foreignDoc, 0, foreignDoc, 0], how 2": true,
+  "0,42,3: context range 0 [detached], argument range 42 [foreignDoc, 0, foreignDoc, 0], how 3": true,
+  "0,43,0: context range 0 [detached], argument range 43 [foreignDoc, 1, foreignComment, 2], how 0": true,
+  "0,43,1: context range 0 [detached], argument range 43 [foreignDoc, 1, foreignComment, 2], how 1": true,
+  "0,43,2: context range 0 [detached], argument range 43 [foreignDoc, 1, foreignComment, 2], how 2": true,
+  "0,43,3: context range 0 [detached], argument range 43 [foreignDoc, 1, foreignComment, 2], how 3": true,
+  "0,44,0: context range 0 [detached], argument range 44 [foreignDoc.body, 0, foreignTextNode, 36], how 0": true,
+  "0,44,1: context range 0 [detached], argument range 44 [foreignDoc.body, 0, foreignTextNode, 36], how 1": true,
+  "0,44,2: context range 0 [detached], argument range 44 [foreignDoc.body, 0, foreignTextNode, 36], how 2": true,
+  "0,44,3: context range 0 [detached], argument range 44 [foreignDoc.body, 0, foreignTextNode, 36], how 3": true,
+  "0,45,0: context range 0 [detached], argument range 45 [xmlDoc, 0, xmlDoc, 0], how 0": true,
+  "0,45,1: context range 0 [detached], argument range 45 [xmlDoc, 0, xmlDoc, 0], how 1": true,
+  "0,45,2: context range 0 [detached], argument range 45 [xmlDoc, 0, xmlDoc, 0], how 2": true,
+  "0,45,3: context range 0 [detached], argument range 45 [xmlDoc, 0, xmlDoc, 0], how 3": true,
+  "0,46,0: context range 0 [detached], argument range 46 [xmlDoc, 1, xmlComment, 0], how 0": true,
+  "0,46,1: context range 0 [detached], argument range 46 [xmlDoc, 1, xmlComment, 0], how 1": true,
+  "0,46,2: context range 0 [detached], argument range 46 [xmlDoc, 1, xmlComment, 0], how 2": true,
+  "0,46,3: context range 0 [detached], argument range 46 [xmlDoc, 1, xmlComment, 0], how 3": true,
+  "0,47,0: context range 0 [detached], argument range 47 [detachedTextNode, 0, detachedTextNode, 8], how 0": true,
+  "0,47,1: context range 0 [detached], argument range 47 [detachedTextNode, 0, detachedTextNode, 8], how 1": true,
+  "0,47,2: context range 0 [detached], argument range 47 [detachedTextNode, 0, detachedTextNode, 8], how 2": true,
+  "0,47,3: context range 0 [detached], argument range 47 [detachedTextNode, 0, detachedTextNode, 8], how 3": true,
+  "0,48,0: context range 0 [detached], argument range 48 [detachedForeignTextNode, 7, detachedForeignTextNode, 7], how 0": true,
+  "0,48,1: context range 0 [detached], argument range 48 [detachedForeignTextNode, 7, detachedForeignTextNode, 7], how 1": true,
+  "0,48,2: context range 0 [detached], argument range 48 [detachedForeignTextNode, 7, detachedForeignTextNode, 7], how 2": true,
+  "0,48,3: context range 0 [detached], argument range 48 [detachedForeignTextNode, 7, detachedForeignTextNode, 7], how 3": true,
+  "0,49,0: context range 0 [detached], argument range 49 [detachedForeignTextNode, 0, detachedForeignTextNode, 8], how 0": true,
+  "0,49,1: context range 0 [detached], argument range 49 [detachedForeignTextNode, 0, detachedForeignTextNode, 8], how 1": true,
+  "0,49,2: context range 0 [detached], argument range 49 [detachedForeignTextNode, 0, detachedForeignTextNode, 8], how 2": true,
+  "0,49,3: context range 0 [detached], argument range 49 [detachedForeignTextNode, 0, detachedForeignTextNode, 8], how 3": true,
+  "0,50,0: context range 0 [detached], argument range 50 [detachedXmlTextNode, 7, detachedXmlTextNode, 7], how 0": true,
+  "0,50,1: context range 0 [detached], argument range 50 [detachedXmlTextNode, 7, detachedXmlTextNode, 7], how 1": true,
+  "0,50,2: context range 0 [detached], argument range 50 [detachedXmlTextNode, 7, detachedXmlTextNode, 7], how 2": true,
+  "0,50,3: context range 0 [detached], argument range 50 [detachedXmlTextNode, 7, detachedXmlTextNode, 7], how 3": true,
+  "0,51,0: context range 0 [detached], argument range 51 [detachedXmlTextNode, 0, detachedXmlTextNode, 8], how 0": true,
+  "0,51,1: context range 0 [detached], argument range 51 [detachedXmlTextNode, 0, detachedXmlTextNode, 8], how 1": true,
+  "0,51,2: context range 0 [detached], argument range 51 [detachedXmlTextNode, 0, detachedXmlTextNode, 8], how 2": true,
+  "0,51,3: context range 0 [detached], argument range 51 [detachedXmlTextNode, 0, detachedXmlTextNode, 8], how 3": true,
+  "0,52,0: context range 0 [detached], argument range 52 [detachedComment, 3, detachedComment, 4], how 0": true,
+  "0,52,1: context range 0 [detached], argument range 52 [detachedComment, 3, detachedComment, 4], how 1": true,
+  "0,52,2: context range 0 [detached], argument range 52 [detachedComment, 3, detachedComment, 4], how 2": true,
+  "0,52,3: context range 0 [detached], argument range 52 [detachedComment, 3, detachedComment, 4], how 3": true,
+  "0,53,0: context range 0 [detached], argument range 53 [detachedComment, 5, detachedComment, 5], how 0": true,
+  "0,53,1: context range 0 [detached], argument range 53 [detachedComment, 5, detachedComment, 5], how 1": true,
+  "0,53,2: context range 0 [detached], argument range 53 [detachedComment, 5, detachedComment, 5], how 2": true,
+  "0,53,3: context range 0 [detached], argument range 53 [detachedComment, 5, detachedComment, 5], how 3": true,
+  "0,54,0: context range 0 [detached], argument range 54 [detachedForeignComment, 0, detachedForeignComment, 1], how 0": true,
+  "0,54,1: context range 0 [detached], argument range 54 [detachedForeignComment, 0, detachedForeignComment, 1], how 1": true,
+  "0,54,2: context range 0 [detached], argument range 54 [detachedForeignComment, 0, detachedForeignComment, 1], how 2": true,
+  "0,54,3: context range 0 [detached], argument range 54 [detachedForeignComment, 0, detachedForeignComment, 1], how 3": true,
+  "0,55,0: context range 0 [detached], argument range 55 [detachedForeignComment, 4, detachedForeignComment, 4], how 0": true,
+  "0,55,1: context range 0 [detached], argument range 55 [detachedForeignComment, 4, detachedForeignComment, 4], how 1": true,
+  "0,55,2: context range 0 [detached], argument range 55 [detachedForeignComment, 4, detachedForeignComment, 4], how 2": true,
+  "0,55,3: context range 0 [detached], argument range 55 [detachedForeignComment, 4, detachedForeignComment, 4], how 3": true,
+  "0,56,0: context range 0 [detached], argument range 56 [detachedXmlComment, 2, detachedXmlComment, 6], how 0": true,
+  "0,56,1: context range 0 [detached], argument range 56 [detachedXmlComment, 2, detachedXmlComment, 6], how 1": true,
+  "0,56,2: context range 0 [detached], argument range 56 [detachedXmlComment, 2, detachedXmlComment, 6], how 2": true,
+  "0,56,3: context range 0 [detached], argument range 56 [detachedXmlComment, 2, detachedXmlComment, 6], how 3": true,
+  "0,57,0: context range 0 [detached], argument range 57 [docfrag, 0, docfrag, 0], how 0": true,
+  "0,57,1: context range 0 [detached], argument range 57 [docfrag, 0, docfrag, 0], how 1": true,
+  "0,57,2: context range 0 [detached], argument range 57 [docfrag, 0, docfrag, 0], how 2": true,
+  "0,57,3: context range 0 [detached], argument range 57 [docfrag, 0, docfrag, 0], how 3": true,
+  "0,58,0: context range 0 [detached], argument range 58 [foreignDocfrag, 0, foreignDocfrag, 0], how 0": true,
+  "0,58,1: context range 0 [detached], argument range 58 [foreignDocfrag, 0, foreignDocfrag, 0], how 1": true,
+  "0,58,2: context range 0 [detached], argument range 58 [foreignDocfrag, 0, foreignDocfrag, 0], how 2": true,
+  "0,58,3: context range 0 [detached], argument range 58 [foreignDocfrag, 0, foreignDocfrag, 0], how 3": true,
+  "0,59,0: context range 0 [detached], argument range 59 [xmlDocfrag, 0, xmlDocfrag, 0], how 0": true,
+  "0,59,1: context range 0 [detached], argument range 59 [xmlDocfrag, 0, xmlDocfrag, 0], how 1": true,
+  "0,59,2: context range 0 [detached], argument range 59 [xmlDocfrag, 0, xmlDocfrag, 0], how 2": true,
+  "0,59,3: context range 0 [detached], argument range 59 [xmlDocfrag, 0, xmlDocfrag, 0], how 3": true,
+  "0,60,0: context range 0 [detached], argument range same as first range, how 0": true,
+  "0,60,1: context range 0 [detached], argument range same as first range, how 1": true,
+  "0,60,2: context range 0 [detached], argument range same as first range, how 2": true,
+  "0,60,3: context range 0 [detached], argument range same as first range, how 3": true,
+  "1,0,0: context range 1 [paras[0].firstChild, 0, paras[0].firstChild, 0], argument range 0 [detached], how 0": true,
+  "1,0,1: context range 1 [paras[0].firstChild, 0, paras[0].firstChild, 0], argument range 0 [detached], how 1": true,
+  "1,0,2: context range 1 [paras[0].firstChild, 0, paras[0].firstChild, 0], argument range 0 [detached], how 2": true,
+  "1,0,3: context range 1 [paras[0].firstChild, 0, paras[0].firstChild, 0], argument range 0 [detached], how 3": true,
+  "2,0,0: context range 2 [paras[0].firstChild, 0, paras[0].firstChild, 1], argument range 0 [detached], how 0": true,
+  "2,0,1: context range 2 [paras[0].firstChild, 0, paras[0].firstChild, 1], argument range 0 [detached], how 1": true,
+  "2,0,2: context range 2 [paras[0].firstChild, 0, paras[0].firstChild, 1], argument range 0 [detached], how 2": true,
+  "2,0,3: context range 2 [paras[0].firstChild, 0, paras[0].firstChild, 1], argument range 0 [detached], how 3": true,
+  "3,0,0: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 0": true,
+  "3,0,1: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 1": true,
+  "3,0,2: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 2": true,
+  "3,0,3: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 3": true,
+  "3,0,4: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -1": true,
+  "3,0,5: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 4": true,
+  "3,0,6: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 5": true,
+  "3,0,7: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how NaN": true,
+  "3,0,8: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -0": true,
+  "3,0,9: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how Infinity": true,
+  "3,0,10: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -Infinity": true,
+  "3,0,11: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 65535": true,
+  "3,0,12: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 65536": true,
+  "3,0,13: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 65537": true,
+  "3,0,14: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 65538": true,
+  "3,0,15: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 65539": true,
+  "3,0,16: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 65540": true,
+  "3,0,17: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -65537": true,
+  "3,0,18: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -65536": true,
+  "3,0,19: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -65535": true,
+  "3,0,20: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -65534": true,
+  "3,0,21: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -65533": true,
+  "3,0,22: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -65532": true,
+  "3,0,23: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 4294967295": true,
+  "3,0,24: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 4294967296": true,
+  "3,0,25: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 4294967297": true,
+  "3,0,26: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 4294967298": true,
+  "3,0,27: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 4294967299": true,
+  "3,0,28: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 4294967300": true,
+  "3,0,29: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -0.5": true,
+  "3,0,30: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 0.5": true,
+  "3,0,31: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 1.5": true,
+  "3,0,32: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 2.5": true,
+  "3,0,33: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 3.5": true,
+  "3,0,34: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 4.5": true,
+  "3,0,35: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -1.5": true,
+  "3,0,36: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -0.5": true,
+  "3,0,37: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 0.5": true,
+  "3,0,38: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 1.5": true,
+  "3,0,39: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 2.5": true,
+  "3,0,40: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how 3.5": true,
+  "3,0,41: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -73.5": true,
+  "3,0,42: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -72.5": true,
+  "3,0,43: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -71.5": true,
+  "3,0,44: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -70.5": true,
+  "3,0,45: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -69.5": true,
+  "3,0,46: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how -68.5": true,
+  "3,0,47: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"0\"": true,
+  "3,0,48: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"1\"": true,
+  "3,0,49: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"2\"": true,
+  "3,0,50: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"3\"": true,
+  "3,0,51: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-1\"": true,
+  "3,0,52: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"4\"": true,
+  "3,0,53: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"5\"": true,
+  "3,0,54: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"NaN\"": true,
+  "3,0,55: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"0\"": true,
+  "3,0,56: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"Infinity\"": true,
+  "3,0,57: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-Infinity\"": true,
+  "3,0,58: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"65535\"": true,
+  "3,0,59: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"65536\"": true,
+  "3,0,60: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"65537\"": true,
+  "3,0,61: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"65538\"": true,
+  "3,0,62: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"65539\"": true,
+  "3,0,63: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"65540\"": true,
+  "3,0,64: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-65537\"": true,
+  "3,0,65: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-65536\"": true,
+  "3,0,66: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-65535\"": true,
+  "3,0,67: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-65534\"": true,
+  "3,0,68: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-65533\"": true,
+  "3,0,69: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-65532\"": true,
+  "3,0,70: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"4294967295\"": true,
+  "3,0,71: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"4294967296\"": true,
+  "3,0,72: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"4294967297\"": true,
+  "3,0,73: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"4294967298\"": true,
+  "3,0,74: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"4294967299\"": true,
+  "3,0,75: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"4294967300\"": true,
+  "3,0,76: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-0.5\"": true,
+  "3,0,77: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"0.5\"": true,
+  "3,0,78: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"1.5\"": true,
+  "3,0,79: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"2.5\"": true,
+  "3,0,80: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"3.5\"": true,
+  "3,0,81: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"4.5\"": true,
+  "3,0,82: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-1.5\"": true,
+  "3,0,83: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-0.5\"": true,
+  "3,0,84: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"0.5\"": true,
+  "3,0,85: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"1.5\"": true,
+  "3,0,86: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"2.5\"": true,
+  "3,0,87: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"3.5\"": true,
+  "3,0,88: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-73.5\"": true,
+  "3,0,89: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-72.5\"": true,
+  "3,0,90: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-71.5\"": true,
+  "3,0,91: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-70.5\"": true,
+  "3,0,92: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-69.5\"": true,
+  "3,0,93: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"-68.5\"": true,
+  "3,0,94: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"6.5536e4\"": true,
+  "3,0,95: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how null": true,
+  "3,0,96: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how undefined": true,
+  "3,0,97: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how true": true,
+  "3,0,98: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how false": true,
+  "3,0,99: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"\"": true,
+  "3,0,100: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 0 [detached], how \"quasit\"": true,
+  "3,3,4: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -1": true,
+  "3,3,5: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 4": true,
+  "3,3,6: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 5": true,
+  "3,3,11: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 65535": true,
+  "3,3,16: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 65540": true,
+  "3,3,17: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -65537": true,
+  "3,3,22: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -65532": true,
+  "3,3,23: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 4294967295": true,
+  "3,3,28: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 4294967300": true,
+  "3,3,34: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how 4.5": true,
+  "3,3,35: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -1.5": true,
+  "3,3,41: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -73.5": true,
+  "3,3,42: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -72.5": true,
+  "3,3,43: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -71.5": true,
+  "3,3,44: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -70.5": true,
+  "3,3,45: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -69.5": true,
+  "3,3,46: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how -68.5": true,
+  "3,3,51: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-1\"": true,
+  "3,3,52: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"4\"": true,
+  "3,3,53: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"5\"": true,
+  "3,3,58: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"65535\"": true,
+  "3,3,63: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"65540\"": true,
+  "3,3,64: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-65537\"": true,
+  "3,3,69: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-65532\"": true,
+  "3,3,70: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"4294967295\"": true,
+  "3,3,75: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"4294967300\"": true,
+  "3,3,81: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"4.5\"": true,
+  "3,3,82: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-1.5\"": true,
+  "3,3,88: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-73.5\"": true,
+  "3,3,89: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-72.5\"": true,
+  "3,3,90: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-71.5\"": true,
+  "3,3,91: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-70.5\"": true,
+  "3,3,92: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-69.5\"": true,
+  "3,3,93: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], how \"-68.5\"": true,
+  "3,20,4: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -1": true,
+  "3,20,5: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 4": true,
+  "3,20,6: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 5": true,
+  "3,20,11: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 65535": true,
+  "3,20,16: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 65540": true,
+  "3,20,17: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -65537": true,
+  "3,20,22: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -65532": true,
+  "3,20,23: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 4294967295": true,
+  "3,20,28: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 4294967300": true,
+  "3,20,34: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how 4.5": true,
+  "3,20,35: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -1.5": true,
+  "3,20,41: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -73.5": true,
+  "3,20,42: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -72.5": true,
+  "3,20,43: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -71.5": true,
+  "3,20,44: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -70.5": true,
+  "3,20,45: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -69.5": true,
+  "3,20,46: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how -68.5": true,
+  "3,20,51: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-1\"": true,
+  "3,20,52: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"4\"": true,
+  "3,20,53: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"5\"": true,
+  "3,20,58: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"65535\"": true,
+  "3,20,63: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"65540\"": true,
+  "3,20,64: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-65537\"": true,
+  "3,20,69: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-65532\"": true,
+  "3,20,70: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"4294967295\"": true,
+  "3,20,75: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"4294967300\"": true,
+  "3,20,81: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"4.5\"": true,
+  "3,20,82: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-1.5\"": true,
+  "3,20,88: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-73.5\"": true,
+  "3,20,89: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-72.5\"": true,
+  "3,20,90: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-71.5\"": true,
+  "3,20,91: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-70.5\"": true,
+  "3,20,92: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-69.5\"": true,
+  "3,20,93: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1], how \"-68.5\"": true,
+  "3,29,4: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -1": true,
+  "3,29,5: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 4": true,
+  "3,29,6: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 5": true,
+  "3,29,11: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 65535": true,
+  "3,29,16: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 65540": true,
+  "3,29,17: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -65537": true,
+  "3,29,22: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -65532": true,
+  "3,29,23: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 4294967295": true,
+  "3,29,28: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 4294967300": true,
+  "3,29,34: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how 4.5": true,
+  "3,29,35: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -1.5": true,
+  "3,29,41: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -73.5": true,
+  "3,29,42: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -72.5": true,
+  "3,29,43: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -71.5": true,
+  "3,29,44: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -70.5": true,
+  "3,29,45: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -69.5": true,
+  "3,29,46: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how -68.5": true,
+  "3,29,51: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-1\"": true,
+  "3,29,52: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"4\"": true,
+  "3,29,53: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"5\"": true,
+  "3,29,58: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"65535\"": true,
+  "3,29,63: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"65540\"": true,
+  "3,29,64: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-65537\"": true,
+  "3,29,69: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-65532\"": true,
+  "3,29,70: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"4294967295\"": true,
+  "3,29,75: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"4294967300\"": true,
+  "3,29,81: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"4.5\"": true,
+  "3,29,82: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-1.5\"": true,
+  "3,29,88: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-73.5\"": true,
+  "3,29,89: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-72.5\"": true,
+  "3,29,90: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-71.5\"": true,
+  "3,29,91: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-70.5\"": true,
+  "3,29,92: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-69.5\"": true,
+  "3,29,93: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 29 [paras[0].firstChild, 3, paras[3], 1], how \"-68.5\"": true,
+  "3,39,4: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how -1": true,
+  "3,39,5: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how 4": true,
+  "3,39,6: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how 5": true,
+  "3,39,11: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how 65535": true,
+  "3,39,16: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how 65540": true,
+  "3,39,17: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how -65537": true,
+  "3,39,22: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how -65532": true,
+  "3,39,23: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how 4294967295": true,
+  "3,39,28: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how 4294967300": true,
+  "3,39,34: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how 4.5": true,
+  "3,39,35: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how -1.5": true,
+  "3,39,41: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how -73.5": true,
+  "3,39,42: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how -72.5": true,
+  "3,39,43: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how -71.5": true,
+  "3,39,44: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how -70.5": true,
+  "3,39,45: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how -69.5": true,
+  "3,39,46: context range 3 [paras[0].firstChild, 2, paras[0].firstChild, 8], argument range 39 [testDiv, 0, comment, 5], how -68.5": t