Merge TM -> JM
authorBrian Hackett <bhackett1024@gmail.com>
Wed, 09 Mar 2011 09:58:49 -0800
changeset 74744 ab1e10fb626f63ec2a41b593d81d53f8d634a835
parent 74743 db22345e7c04c22cf14b36766fbfe145931c32c3 (current diff)
parent 64259 b16be37906fed4c7e11de6c42cbab6e23345fcd9 (diff)
child 74745 c288ca4152d11a5a2fce09073dc5ce36baca8be0
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
milestone2.0b13pre
Merge TM -> JM
browser/base/content/test/browser_bug628179.js
docshell/test/file_bug615501.html
docshell/test/test_bug615501_1.html
docshell/test/test_bug615501_2.html
docshell/test/test_bug615501_3.html
dom/base/nsDOMClassInfo.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsJSEnvironment.cpp
dom/interfaces/events/nsIDOMPopStateEvent_MOZILLA_2_BRANCH.idl
js/src/Makefile.in
js/src/assembler/assembler/X86Assembler.h
js/src/jit-test/jit_test.py
js/src/jsanalyze.cpp
js/src/jsapi.cpp
js/src/jsapi.h
js/src/jsarray.cpp
js/src/jsatom.cpp
js/src/jscntxt.cpp
js/src/jscntxt.h
js/src/jscompartment.cpp
js/src/jscompartment.h
js/src/jsdbgapi.cpp
js/src/jsemit.h
js/src/jsexn.cpp
js/src/jsfun.cpp
js/src/jsfun.h
js/src/jsgc.cpp
js/src/jsgcinlines.h
js/src/jsinfer.cpp
js/src/jsinfer.h
js/src/jsinferinlines.h
js/src/jsinterp.cpp
js/src/jsinterp.h
js/src/jsinterpinlines.h
js/src/jsiter.cpp
js/src/jsnum.cpp
js/src/jsobj.cpp
js/src/jsobj.h
js/src/jsobjinlines.h
js/src/json.cpp
js/src/jsopcode.tbl
js/src/jsparse.cpp
js/src/jsparse.h
js/src/jsproxy.cpp
js/src/jspubtd.h
js/src/jsreflect.cpp
js/src/jsregexp.cpp
js/src/jsregexpinlines.h
js/src/jsscope.cpp
js/src/jsscopeinlines.h
js/src/jsscript.cpp
js/src/jsscript.h
js/src/jsstr.cpp
js/src/jstracer.cpp
js/src/jstracer.h
js/src/jstypedarray.cpp
js/src/jsval.h
js/src/jsvalue.h
js/src/jswrapper.cpp
js/src/jsxdrapi.h
js/src/jsxml.cpp
js/src/methodjit/Compiler.cpp
js/src/methodjit/Compiler.h
js/src/methodjit/FrameState-inl.h
js/src/methodjit/FrameState.h
js/src/methodjit/InvokeHelpers.cpp
js/src/methodjit/MethodJIT.cpp
js/src/methodjit/MethodJIT.h
js/src/methodjit/MonoIC.cpp
js/src/methodjit/StubCalls.cpp
js/src/methodjit/StubCalls.h
js/src/methodjit/TrampolineCompiler.cpp
js/src/methodjit/TrampolineCompiler.h
js/src/shell/js.cpp
js/src/tests/js1_8/extensions/regress-476871-01.js
js/src/tracejit/Writer.cpp
js/src/tracejit/Writer.h
js/src/xpconnect/shell/xpcshell.cpp
js/src/xpconnect/src/xpcwrappednative.cpp
js/src/xpconnect/wrappers/WrapperFactory.cpp
modules/libpref/src/init/all.js
services/sync/modules/ext/Sync.js
toolkit/themes/winstripe/mozapps/passwordmgr/key-aero-16.png
toolkit/themes/winstripe/mozapps/passwordmgr/key-aero-64.png
toolkit/themes/winstripe/mozapps/passwordmgr/key-aero.png
--- a/accessible/src/base/AccIterator.cpp
+++ b/accessible/src/base/AccIterator.cpp
@@ -99,44 +99,50 @@ AccIterator::IteratorState::IteratorStat
 
 ////////////////////////////////////////////////////////////////////////////////
 // RelatedAccIterator
 ////////////////////////////////////////////////////////////////////////////////
 
 RelatedAccIterator::
   RelatedAccIterator(nsDocAccessible* aDocument, nsIContent* aDependentContent,
                      nsIAtom* aRelAttr) :
-  mRelAttr(aRelAttr), mProviders(nsnull), mBindingParent(nsnull), mIndex(0)
+  mDocument(aDocument), mRelAttr(aRelAttr), mProviders(nsnull),
+  mBindingParent(nsnull), mIndex(0)
 {
   mBindingParent = aDependentContent->GetBindingParent();
   nsIAtom* IDAttr = mBindingParent ?
     nsAccessibilityAtoms::anonid : aDependentContent->GetIDAttributeName();
 
   nsAutoString id;
   if (aDependentContent->GetAttr(kNameSpaceID_None, IDAttr, id))
-    mProviders = aDocument->mDependentIDsHash.Get(id);
+    mProviders = mDocument->mDependentIDsHash.Get(id);
 }
 
 nsAccessible*
 RelatedAccIterator::Next()
 {
   if (!mProviders)
     return nsnull;
 
   while (mIndex < mProviders->Length()) {
     nsDocAccessible::AttrRelProvider* provider = (*mProviders)[mIndex++];
 
     // Return related accessible for the given attribute and if the provider
     // content is in the same binding in the case of XBL usage.
     if (provider->mRelAttr == mRelAttr &&
         (!mBindingParent ||
          mBindingParent == provider->mContent->GetBindingParent())) {
-      nsAccessible* related = GetAccService()->GetAccessible(provider->mContent);
+      nsAccessible* related = mDocument->GetAccessible(provider->mContent);
       if (related)
         return related;
+
+      // If the document content is pointed by relation then return the document
+      // itself.
+      if (provider->mContent == mDocument->GetContent())
+        return mDocument;
     }
   }
 
   return nsnull;
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////
--- a/accessible/src/base/AccIterator.h
+++ b/accessible/src/base/AccIterator.h
@@ -120,16 +120,17 @@ public:
    */
   nsAccessible* Next();
 
 private:
   RelatedAccIterator();
   RelatedAccIterator(const RelatedAccIterator&);
   RelatedAccIterator& operator = (const RelatedAccIterator&);
 
+  nsDocAccessible* mDocument;
   nsIAtom* mRelAttr;
   nsDocAccessible::AttrRelProviderArray* mProviders;
   nsIContent* mBindingParent;
   PRUint32 mIndex;
 };
 
 
 /**
--- a/accessible/src/base/nsAccessNode.cpp
+++ b/accessible/src/base/nsAccessNode.cpp
@@ -301,17 +301,17 @@ already_AddRefed<nsRootAccessible> nsAcc
   }
 
   nsDocAccessible *docAcc = nsAccUtils::GetDocAccessibleFor(root);
   nsRefPtr<nsRootAccessible> rootAcc = do_QueryObject(docAcc);
   return rootAcc.forget();
 }
 
 nsIFrame*
-nsAccessNode::GetFrame()
+nsAccessNode::GetFrame() const
 {
   return mContent ? mContent->GetPrimaryFrame() : nsnull;
 }
 
 bool
 nsAccessNode::IsPrimaryForNode() const
 {
   return true;
--- a/accessible/src/base/nsAccessNode.h
+++ b/accessible/src/base/nsAccessNode.h
@@ -130,20 +130,20 @@ public:
    */
   virtual PRBool Init();
 
   /**
    * Shutdown the access node object.
    */
   virtual void Shutdown();
 
-    /**
-     * Return frame for the given access node object.
-     */
-    virtual nsIFrame* GetFrame();
+  /**
+   * Return frame for the given access node object.
+   */
+  virtual nsIFrame* GetFrame() const;
 
   /**
    * Return DOM node associated with this accessible.
    */
   already_AddRefed<nsIDOMNode> GetDOMNode() const
   {
     nsIDOMNode *DOMNode = nsnull;
     if (GetNode())
--- a/accessible/src/base/nsAccessible.h
+++ b/accessible/src/base/nsAccessible.h
@@ -354,16 +354,18 @@ public:
    * Assert if child not in parent's cache if the cache was initialized at this
    * point.
    */
   void TestChildCache(nsAccessible* aCachedChild) const;
 
   //////////////////////////////////////////////////////////////////////////////
   // Downcasting
 
+  inline bool IsApplication() const { return mFlags & eApplicationAccessible; }
+
   inline bool IsHyperText() const { return mFlags & eHyperTextAccessible; }
   nsHyperTextAccessible* AsHyperText();
 
   inline bool IsTextLeaf() const { return mFlags & eTextLeafAccessible; }
   nsTextAccessible* AsTextLeaf();
 
   //////////////////////////////////////////////////////////////////////////////
   // HyperLinkAccessible
@@ -500,18 +502,19 @@ protected:
   inline void SetChildrenFlag(ChildrenFlags aFlag)
     { mFlags = (mFlags & ~kChildrenFlagsMask) | aFlag; }
 
   /**
    * Flags describing the accessible itself.
    * @note keep these flags in sync with ChildrenFlags
    */
   enum AccessibleTypes {
-    eHyperTextAccessible = 1 << 2,
-    eTextLeafAccessible = 1 << 3
+    eApplicationAccessible = 1 << 2,
+    eHyperTextAccessible = 1 << 3,
+    eTextLeafAccessible = 1 << 4
   };
 
   //////////////////////////////////////////////////////////////////////////////
   // Miscellaneous helpers
 
   /**
    * Return ARIA role (helper method).
    */
--- a/accessible/src/base/nsApplicationAccessible.cpp
+++ b/accessible/src/base/nsApplicationAccessible.cpp
@@ -50,16 +50,17 @@
 #include "nsIDOMWindow.h"
 #include "nsIWindowMediator.h"
 #include "nsServiceManagerUtils.h"
 #include "mozilla/Services.h"
 
 nsApplicationAccessible::nsApplicationAccessible() :
   nsAccessibleWrap(nsnull, nsnull)
 {
+  mFlags |= eApplicationAccessible;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsISupports
 
 NS_IMPL_ISUPPORTS_INHERITED1(nsApplicationAccessible, nsAccessible,
                              nsIAccessibleApplication)
 
--- a/accessible/src/base/nsDocAccessible.cpp
+++ b/accessible/src/base/nsDocAccessible.cpp
@@ -676,17 +676,17 @@ nsDocAccessible::Shutdown()
   mDocument = nsnull;
 
   nsHyperTextAccessibleWrap::Shutdown();
 
   GetAccService()->NotifyOfDocumentShutdown(kungFuDeathGripDoc);
 }
 
 nsIFrame*
-nsDocAccessible::GetFrame()
+nsDocAccessible::GetFrame() const
 {
   nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mWeakShell));
 
   nsIFrame* root = nsnull;
   if (shell)
     root = shell->GetRootFrame();
 
   return root;
@@ -942,16 +942,18 @@ nsDocAccessible::AttributeWillChange(nsI
   // Update dependent IDs cache. Take care of elements that are accessible
   // because dependent IDs cache doesn't contain IDs from non accessible
   // elements.
   if (aModType == nsIDOMMutationEvent::MODIFICATION ||
       aModType == nsIDOMMutationEvent::REMOVAL) {
     nsAccessible* accessible = GetAccessible(aElement);
     if (accessible)
       RemoveDependentIDsFor(accessible, aAttribute);
+    else if (aElement == mContent)
+      RemoveDependentIDsFor(this, aAttribute);
   }
 }
 
 void
 nsDocAccessible::AttributeChanged(nsIDocument *aDocument,
                                   dom::Element* aElement,
                                   PRInt32 aNameSpaceID, nsIAtom* aAttribute,
                                   PRInt32 aModType)
@@ -965,18 +967,22 @@ nsDocAccessible::AttributeChanged(nsIDoc
     return;
 
   // Ignore attribute change if the element doesn't have an accessible (at all
   // or still) iff the element is not a root content of this document accessible
   // (which is treated as attribute change on this document accessible).
   // Note: we don't bail if all the content hasn't finished loading because
   // these attributes are changing for a loaded part of the content.
   nsAccessible* accessible = GetAccessible(aElement);
-  if (!accessible && (mContent != aElement))
-    return;
+  if (!accessible) {
+    if (mContent != aElement)
+      return;
+
+    accessible = this;
+  }
 
   // Fire accessible events iff there's an accessible, otherwise we consider
   // the accessible state wasn't changed, i.e. its state is initial state.
   AttributeChangedImpl(aElement, aNameSpaceID, aAttribute);
 
   // Update dependent IDs cache. Take care of accessible elements because no
   // accessible element means either the element is not accessible at all or
   // its accessible will be created later. It doesn't make sense to keep
--- a/accessible/src/base/nsDocAccessible.h
+++ b/accessible/src/base/nsDocAccessible.h
@@ -103,17 +103,17 @@ public:
   virtual void ScrollPositionDidChange(nscoord aX, nscoord aY);
 
   // nsIDocumentObserver
   NS_DECL_NSIDOCUMENTOBSERVER
 
   // nsAccessNode
   virtual PRBool Init();
   virtual void Shutdown();
-  virtual nsIFrame* GetFrame();
+  virtual nsIFrame* GetFrame() const;
   virtual PRBool IsDefunct();
   virtual nsINode* GetNode() const { return mDocument; }
   virtual nsIDocument* GetDocumentNode() const { return mDocument; }
 
   // nsAccessible
   virtual PRUint32 NativeRole();
   virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
   virtual nsresult GetARIAState(PRUint32 *aState, PRUint32 *aExtraState);
--- a/accessible/src/html/nsHTMLSelectAccessible.cpp
+++ b/accessible/src/html/nsHTMLSelectAccessible.cpp
@@ -866,17 +866,17 @@ nsHTMLComboboxListAccessible::
   nsHTMLSelectListAccessible(aContent, aShell)
 {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsHTMLComboboxAccessible: nsAccessNode
 
 nsIFrame*
-nsHTMLComboboxListAccessible::GetFrame()
+nsHTMLComboboxListAccessible::GetFrame() const
 {
   nsIFrame* frame = nsHTMLSelectListAccessible::GetFrame();
 
   if (frame) {
     nsIComboboxControlFrame* comboBox = do_QueryFrame(frame);
     if (comboBox) {
       return comboBox->GetDropDown();
     }
--- a/accessible/src/html/nsHTMLSelectAccessible.h
+++ b/accessible/src/html/nsHTMLSelectAccessible.h
@@ -223,17 +223,17 @@ class nsHTMLComboboxListAccessible : pub
 public:
 
   nsHTMLComboboxListAccessible(nsIAccessible *aParent, 
                                nsIContent *aContent, 
                                nsIWeakReference* aShell);
   virtual ~nsHTMLComboboxListAccessible() {}
 
   // nsAccessNode
-  virtual nsIFrame* GetFrame();
+  virtual nsIFrame* GetFrame() const;
   virtual bool IsPrimaryForNode() const;
 
   // nsAccessible
   virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState);
   virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
 };
 
 #endif
--- a/accessible/src/msaa/nsAccessibleWrap.cpp
+++ b/accessible/src/msaa/nsAccessibleWrap.cpp
@@ -210,21 +210,23 @@ STDMETHODIMP nsAccessibleWrap::get_accPa
                                                        IID_IAccessible,
                                                        (void**)ppdispParent))) {
         return S_OK;
       }
     }
   }
 
   nsAccessible* xpParentAcc = GetParent();
-  NS_ASSERTION(xpParentAcc,
-               "No parent accessible where we're not direct child of window");
+  if (!xpParentAcc) {
+    if (IsApplication())
+      return S_OK;
 
-  if (!xpParentAcc)
+    NS_ERROR("No parent accessible. Should we really assert here?");
     return E_UNEXPECTED;
+  }
 
   *ppdispParent = NativeAccessible(xpParentAcc);
 
 } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return S_OK;
 }
 
 STDMETHODIMP nsAccessibleWrap::get_accChildCount( long __RPC_FAR *pcountChildren)
@@ -1365,22 +1367,17 @@ STDMETHODIMP
 nsAccessibleWrap::get_windowHandle(HWND *aWindowHandle)
 {
 __try {
   *aWindowHandle = 0;
 
   if (IsDefunct())
     return E_FAIL;
 
-  void *handle = nsnull;
-  nsresult rv = GetOwnerWindow(&handle);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
-
-  *aWindowHandle = reinterpret_cast<HWND>(handle);
+  *aWindowHandle = GetHWNDFor(this);
   return S_OK;
 
 } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return E_FAIL;
 }
 
 STDMETHODIMP
 nsAccessibleWrap::get_indexInParent(long *aIndexInParent)
@@ -1527,27 +1524,31 @@ nsAccessibleWrap::Invoke(DISPID dispIdMe
 // nsIAccessible method
 NS_IMETHODIMP nsAccessibleWrap::GetNativeInterface(void **aOutAccessible)
 {
   *aOutAccessible = static_cast<IAccessible*>(this);
   NS_ADDREF_THIS();
   return NS_OK;
 }
 
+////////////////////////////////////////////////////////////////////////////////
 // nsAccessible
 
 nsresult
 nsAccessibleWrap::HandleAccEvent(AccEvent* aEvent)
 {
   nsresult rv = nsAccessible::HandleAccEvent(aEvent);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return FirePlatformEvent(aEvent);
 }
 
+////////////////////////////////////////////////////////////////////////////////
+// nsAccessibleWrap
+
 nsresult
 nsAccessibleWrap::FirePlatformEvent(AccEvent* aEvent)
 {
   PRUint32 eventType = aEvent->GetEventType();
 
   NS_ENSURE_TRUE(eventType > 0 &&
                  eventType < nsIAccessibleEvent::EVENT_LAST_ENTRY,
                  NS_ERROR_FAILURE);
@@ -1617,21 +1618,45 @@ PRInt32 nsAccessibleWrap::GetChildIDFor(
   // MSAA is only available for 32 bit windows, so it's okay
   // XXX: bug 606080
   return aAccessible ? - NS_PTR_TO_INT32(aAccessible->UniqueID()) : 0;
 }
 
 HWND
 nsAccessibleWrap::GetHWNDFor(nsAccessible *aAccessible)
 {
-  if (!aAccessible)
-    return 0;
+  if (aAccessible) {
+    // Popup lives in own windows, use its HWND until the popup window is
+    // hidden to make old JAWS versions work with collapsed comboboxes (see
+    // discussion in bug 379678).
+    nsIFrame* frame = aAccessible->GetFrame();
+    if (frame) {
+      nsIWidget* widget = frame->GetNearestWidget();
+      PRBool isVisible = PR_FALSE;
+      widget->IsVisible(isVisible);
+      if (isVisible) {
+        nsCOMPtr<nsIPresShell> shell(aAccessible->GetPresShell());
+        nsIViewManager* vm = shell->GetViewManager();
+        if (vm) {
+          nsCOMPtr<nsIWidget> rootWidget;
+          vm->GetRootWidget(getter_AddRefs(rootWidget));
+          // Make sure the accessible belongs to popup. If not then use
+          // document HWND (which might be different from root widget in the
+          // case of window emulation).
+          if (rootWidget != widget)
+            return static_cast<HWND>(widget->GetNativeData(NS_NATIVE_WINDOW));
+        }
+      }
+    }
 
-  nsDocAccessible* document = aAccessible->GetDocAccessible();
-  return document ? static_cast<HWND>(document->GetNativeWindow()) : 0;
+    nsDocAccessible* document = aAccessible->GetDocAccessible();
+    if (document)
+      return static_cast<HWND>(document->GetNativeWindow());
+  }
+  return nsnull;
 }
 
 HRESULT
 nsAccessibleWrap::ConvertToIA2Attributes(nsIPersistentProperties *aAttributes,
                                          BSTR *aIA2Attributes)
 {
   *aIA2Attributes = NULL;
 
--- a/accessible/tests/mochitest/editabletext/editabletext.js
+++ b/accessible/tests/mochitest/editabletext/editabletext.js
@@ -31,29 +31,33 @@ function editableTextTestRun()
 /**
  * Used to test nsIEditableTextAccessible methods.
  */
 function editableTextTest(aID)
 {
   /**
    * setTextContents test.
    */
-  this.setTextContents = function setTextContents(aStr, aResValue)
+  this.setTextContents = function setTextContents(aValue, aTrailChar)
   {
-    var testID = "setTextContents '" + aStr + "' for " + prettyName(aID);
+    var testID = "setTextContents '" + aValue + "' for " + prettyName(aID);
 
     function setTextContentsInvoke()
     {
       var acc = getAccessible(aID, nsIAccessibleEditableText);
-      acc.setTextContents(aStr);
+      acc.setTextContents(aValue);
     }
 
-    this.scheduleTest(aID, null, [0, aStr.length, aStr],
-                      setTextContentsInvoke, getValueChecker(aID, aResValue),
-                      testID);
+    var newValue = aValue + (aTrailChar ? aTrailChar : "");
+    var insertTripple = newValue ? [0, newValue.length, newValue] : null;
+    var oldValue = getValue(aID);
+    var removeTripple = oldValue ? [0, oldValue.length, oldValue] : null;
+
+    this.scheduleTest(aID, removeTripple, insertTripple, setTextContentsInvoke,
+                      getValueChecker(aID, aValue), testID);
   }
 
   /**
    * insertText test.
    */
   this.insertText = function insertText(aStr, aPos, aResStr, aResPos)
   {
     var testID = "insertText '" + aStr + "' at " + aPos + " for " +
@@ -202,34 +206,38 @@ function editableTextTest(aID)
       }
     };
     this.mEventQueue.push(invoker);
   }
 
   //////////////////////////////////////////////////////////////////////////////
   // Implementation details.
 
+  function getValue(aID)
+  {
+    var value = "";
+    var elm = getNode(aID);
+    if (elm instanceof Components.interfaces.nsIDOMNSEditableElement)
+      return elm.value;
+
+    if (elm instanceof Components.interfaces.nsIDOMHTMLDocument)
+      return elm.body.textContent;
+
+    return elm.textContent;
+  }
+
   /**
    * Common checkers.
    */
   function getValueChecker(aID, aValue)
   {
     var checker = {
       check: function valueChecker_check()
       {
-        var value = "";
-        var elm = getNode(aID);
-        if (elm instanceof Components.interfaces.nsIDOMNSEditableElement)
-          value = elm.value;
-        else if (elm instanceof Components.interfaces.nsIDOMHTMLDocument)
-          value = elm.body.textContent;
-        else
-          value = elm.textContent;
-
-        is(value, aValue, "Wrong value " + aValue);
+        is(getValue(aID), aValue, "Wrong value " + aValue);
       }
     };
     return checker;
   }
 
   function getClipboardChecker(aID, aText)
   {
     var checker = {
--- a/accessible/tests/mochitest/editabletext/test_1.html
+++ b/accessible/tests/mochitest/editabletext/test_1.html
@@ -16,36 +16,36 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
   <script type="application/javascript"
           src="editabletext.js"></script>
 
   <script type="application/javascript">
-    function addTestEditable(aID, aTestRun)
+    function addTestEditable(aID, aTestRun, aTrailChar)
     {
       var et = new editableTextTest(aID);
 
       //////////////////////////////////////////////////////////////////////////
+      // setTextContents
+      et.setTextContents("hello");
+      et.setTextContents("olleh", aTrailChar); // due to some reason this reports '\n' in the end
+      et.setTextContents("");
+
+      //////////////////////////////////////////////////////////////////////////
       // insertText
       et.insertText("hello", 0, "hello");
       et.insertText("ma ", 0, "ma hello");
       et.insertText("ma", 2, "mama hello");
       et.insertText(" hello", 10, "mama hello hello");
 
       // XXX: bug 452584
 
       //////////////////////////////////////////////////////////////////////////
-      // setTextContents
-//      et.setTextContents("hello", "hello");
-//      et.setTextContents("olleh", "olleh");
-//      et.setTextContents("", "");
-
-      //////////////////////////////////////////////////////////////////////////
       // deleteText
 //      et.deleteText(0, 5, "hello hello");
 //      et.deleteText(5, 6, "hellohello");
 //      et.deleteText(5, 10, "hello");
 //      et.deleteText(0, 5, "");
 
       //////////////////////////////////////////////////////////////////////////
       // copyNPasteText
@@ -66,18 +66,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     //gA11yEventDumpToConsole = true; // debug stuff
 
     function runTest()
     {
       var testRun = new editableTextTestRun();
 
       addTestEditable("input", testRun);
-      addTestEditable("div", testRun);
-      addTestEditable(getNode("frame").contentDocument, testRun);
+      addTestEditable("div", testRun, '\n');
+      addTestEditable(getNode("frame").contentDocument, testRun, '\n');
 
       testRun.run(); // Will call SimpleTest.finish();
     }
 
     function doTest()
     {
       // Prepare tested elements.
 
--- a/accessible/tests/mochitest/events/docload_wnd.xul
+++ b/accessible/tests/mochitest/events/docload_wnd.xul
@@ -221,17 +221,17 @@
     const Ci = Components.interfaces;
 
     var gTabBrowser = null;
     function doTest()
     {
       gTabBrowser = document.getElementById("content");
 
       gQueue = new gOpenerWnd.eventQueue();
-      gQueue.push(new loadURIInvoker("about:robots"));
+      gQueue.push(new loadURIInvoker("about:"));
       gQueue.push(new clickReloadBtnInvoker());
       gQueue.push(new loadURIInvoker("about:mozilla"));
       gQueue.push(new reloadInvoker());
       gQueue.push(new loadErrorPageInvoker());
       gQueue.onFinish = function() { window.close(); }
       gQueue.invoke();
     }
 
--- a/accessible/tests/mochitest/name/nsRootAcc_wnd.xul
+++ b/accessible/tests/mochitest/name/nsRootAcc_wnd.xul
@@ -83,17 +83,17 @@
 
     var gQueue = null;
 
     const Ci = Components.interfaces;
 
     function doTest()
     {
       var tabBrowser = document.getElementById("content");
-      tabBrowser.loadURI("about:robots");
+      tabBrowser.loadURI("about:");
       tabBrowser.addTab("about:mozilla");
 
       gQueue = new gOpenerWnd.eventQueue();
       gQueue.push(new switchTabInvoker(tabBrowser, window));
       gQueue.onFinish = function() { window.close(); }
       gQueue.invoke();
     }
 
--- a/accessible/tests/mochitest/name/test_nsRootAcc.xul
+++ b/accessible/tests/mochitest/name/test_nsRootAcc.xul
@@ -21,22 +21,22 @@
           src="../events.js"></script>
 
   <script type="application/javascript">
   <![CDATA[
     // var gA11yEventDumpID = "eventdump"; // debug stuff
 
     function doTest()
     {
-      // Actually, just disable this test everywhere -- bug 586818.
+      todo(false, "Disabled test. (Bug 586818)");
       SimpleTest.finish();
       return;
 
       if (LINUX) {
-        todo(false, "Enable test on Linux - see bug 525175.");
+        todo(false, "Skip test on Linux. (Bug 525175)");
         SimpleTest.finish();
         return;
       }
 
       var w = window.openDialog("nsRootAcc_wnd.xul",
                                 "nsRootAcc_name_test", 
                                 "chrome,width=600,height=600");
     }
--- a/accessible/tests/mochitest/relations/test_update.html
+++ b/accessible/tests/mochitest/relations/test_update.html
@@ -15,44 +15,45 @@
   <script type="application/javascript"
           src="../relations.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
 
   <script type="application/javascript">
-    function testRelated(aRelAttr, aHostRelation, aDependentRelation)
+    function testRelated(aRelAttr, aHostRelation, aDependentRelation,
+                         aHostID, aHostNodeID, aDependent1ID, aDependent2ID)
     {
       // no attribute
-      testRelation("dependent1", aDependentRelation, null);
-      testRelation("dependent2", aDependentRelation, null);
+      testRelation(aDependent1ID, aDependentRelation, null);
+      testRelation(aDependent2ID, aDependentRelation, null);
       if (aHostRelation)
-        testRelation("host", aHostRelation, null);
+        testRelation(aHostID, aHostRelation, null);
 
       // set attribute
-      getNode("host").setAttribute(aRelAttr, "dependent1");
-      testRelation("dependent1", aDependentRelation, "host");
-      testRelation("dependent2", aDependentRelation, null);
+      getNode(aHostNodeID).setAttribute(aRelAttr, aDependent1ID);
+      testRelation(aDependent1ID, aDependentRelation, aHostID);
+      testRelation(aDependent2ID, aDependentRelation, null);
       if (aHostRelation)
-        testRelation("host", aHostRelation, "dependent1");
+        testRelation(aHostID, aHostRelation, aDependent1ID);
 
       // change attribute
-      getNode("host").setAttribute(aRelAttr, "dependent2");
-      testRelation("dependent1", aDependentRelation, null);
-      testRelation("dependent2", aDependentRelation, "host");
+      getNode(aHostNodeID).setAttribute(aRelAttr, aDependent2ID);
+      testRelation(aDependent1ID, aDependentRelation, null);
+      testRelation(aDependent2ID, aDependentRelation, aHostID);
       if (aHostRelation)
-        testRelation("host", aHostRelation, "dependent2");
+        testRelation(aHostID, aHostRelation, aDependent2ID);
 
       // remove attribute
-      getNode("host").removeAttribute(aRelAttr);
-      testRelation("dependent1", aDependentRelation, null);
-      testRelation("dependent2", aDependentRelation, null);
+      getNode(aHostNodeID).removeAttribute(aRelAttr);
+      testRelation(aDependent1ID, aDependentRelation, null);
+      testRelation(aDependent2ID, aDependentRelation, null);
       if (aHostRelation)
-        testRelation("host", aHostRelation, null);
+        testRelation(aHostID, aHostRelation, null);
     }
 
     function insertRelated(aHostRelAttr, aDependentID, aInsertHostFirst,
                            aHostRelation, aDependentRelation)
     {
       this.eventSeq = [
         new invokerChecker(EVENT_REORDER, document)
       ];
@@ -126,23 +127,40 @@
 
     //gA11yEventDumpToConsole = true; // debug
 
     var gQueue = null;
 
     function doTest()
     {
       // Relation updates on ARIA attribute changes.
-      testRelated("aria-labelledby", RELATION_LABELLED_BY, RELATION_LABEL_FOR);
+      testRelated("aria-labelledby",
+                  RELATION_LABELLED_BY, RELATION_LABEL_FOR,
+                  "host", "host", "dependent1", "dependent2");
+
       testRelated("aria-describedby",
-                  RELATION_DESCRIBED_BY, RELATION_DESCRIPTION_FOR);
-      testRelated("aria-owns", null, RELATION_NODE_CHILD_OF);
+                  RELATION_DESCRIBED_BY, RELATION_DESCRIPTION_FOR,
+                  "host", "host", "dependent1", "dependent2");
+
+      testRelated("aria-owns",
+                  null, RELATION_NODE_CHILD_OF,
+                  "host", "host", "dependent1", "dependent2");
+
       testRelated("aria-controls",
-                  RELATION_CONTROLLER_FOR, RELATION_CONTROLLED_BY);
-      testRelated("aria-flowto", RELATION_FLOWS_TO, RELATION_FLOWS_FROM);
+                  RELATION_CONTROLLER_FOR, RELATION_CONTROLLED_BY,
+                  "host", "host", "dependent1", "dependent2");
+
+      testRelated("aria-flowto",
+                  RELATION_FLOWS_TO, RELATION_FLOWS_FROM,
+                  "host", "host", "dependent1", "dependent2");
+
+      // Document relation updates on ARIA attribute change.
+      testRelated("aria-labelledby",
+                  RELATION_LABELLED_BY, RELATION_LABEL_FOR,
+                  document, "body", "dependent1", "dependent2");
 
       // Insert related accessibles into tree.
       gQueue = new eventQueue();
       gQueue.push(new insertRelated("aria-labelledby", "dependent3", true,
                                     RELATION_LABELLED_BY, RELATION_LABEL_FOR));
       gQueue.push(new insertRelated("aria-labelledby", "dependent4", false,
                                     RELATION_LABELLED_BY, RELATION_LABEL_FOR));
 
@@ -178,28 +196,33 @@
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 
 </head>
 
-<body>
+<body id="body">
 
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=573469"
      title="Cache relations defined by ARIA attributes">
     Mozilla Bug 573469
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=631068"
      title="Accessible recreation breaks relations">
     Mozilla Bug 631068
   </a>
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=635346"
+     title="Allow relations for document defined on document content">
+    Mozilla Bug 635346
+  </a>
   <br>
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <div id="dependent1">label</div>
   <div id="dependent2">label2</div>
--- a/browser/app/blocklist.xml
+++ b/browser/app/blocklist.xml
@@ -118,10 +118,18 @@
     </versionRange>
   </pluginItem>
   <pluginItem>
     <match name="name" exp="[0-6]\.0\.[01]\d{2}\.\d+"/>
     <match name="filename" exp="npdeploytk.dll"/>
     <versionRange severity="1">
     </versionRange>
   </pluginItem>
+  <pluginItem>
+    <match name="filename" exp="[Nn][Pp][Jj][Pp][Ii]1[56]0_[0-9]+\.[Dd][Ll][Ll]"/>
+    <versionRange>
+      <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}">
+        <versionRange minVersion="3.6a1pre" maxVersion="*"/>
+      </targetApplication>
+    </versionRange>
+  </pluginItem>
 </pluginItems>
 </blocklist>
--- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/install.rdf
+++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/install.rdf
@@ -1,15 +1,15 @@
 <?xml version="1.0"?>
 
 <RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      xmlns:em="http://www.mozilla.org/2004/em-rdf#">
   <Description about="urn:mozilla:install-manifest">
     <em:id>testpilot@labs.mozilla.com</em:id>
-    <em:version>1.0.5</em:version>
+    <em:version>1.0.6</em:version>
     <em:type>2</em:type>
 
     <!-- Target Application this extension can install into, 
          with minimum and maximum supported versions. --> 
     <em:targetApplication>
       <Description>
         <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
         <em:minVersion>3.5</em:minVersion>
--- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js
+++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js
@@ -51,16 +51,17 @@ const FIRST_RUN_PREF ="extensions.testpi
 const RUN_AT_ALL_PREF = "extensions.testpilot.runStudies";
 const POPUP_SHOW_ON_NEW = "extensions.testpilot.popup.showOnNewStudy";
 const POPUP_SHOW_ON_FINISH = "extensions.testpilot.popup.showOnStudyFinished";
 const POPUP_SHOW_ON_RESULTS = "extensions.testpilot.popup.showOnNewResults";
 const POPUP_CHECK_INTERVAL = "extensions.testpilot.popup.delayAfterStartup";
 const POPUP_REMINDER_INTERVAL = "extensions.testpilot.popup.timeBetweenChecks";
 const ALWAYS_SUBMIT_DATA = "extensions.testpilot.alwaysSubmitData";
 const LOG_FILE_NAME = "TestPilotErrorLog.log";
+const RANDOM_DEPLOY_PREFIX = "extensions.testpilot.deploymentRandomizer";
 
 let TestPilotSetup = {
   didReminderAfterStartup: false,
   startupComplete: false,
   _shortTimer: null,
   _longTimer: null,
   _remoteExperimentLoader: null, // TODO make this a lazy initializer too?
   taskList: [],
@@ -689,31 +690,32 @@ let TestPilotSetup = {
   _experimentRequirementsAreMet: function TPS__requirementsMet(experiment) {
     /* Returns true if we we meet the requirements to run this experiment
      * (e.g. meet the minimum Test Pilot version and Firefox version)
      * false if not.
      * Default is always to run the study - return true UNLESS the study
      * specifies a requirement that we don't meet. */
     let logger = this._logger;
     try {
-      let minTpVer, minFxVer, expName, runOrNotFunc;
+      let minTpVer, minFxVer, expName, runOrNotFunc, randomDeployment;
       /* Could be an experiment, which specifies experimentInfo, or survey,
        * which specifies surveyInfo. */
       let info = experiment.experimentInfo ?
                    experiment.experimentInfo :
                    experiment.surveyInfo;
       if (!info) {
         // If neither one is supplied, study lacks metadata required to run
         logger.warn("Study lacks minimum metadata to run.");
         return false;
       }
       minTpVer = info.minTPVersion;
       minFxVer = info.minFXVersion;
       expName =  info.testName;
       runOrNotFunc = info.runOrNotFunc;
+      randomDeployment = info.randomDeployment;
 
       // Minimum test pilot version:
       if (minTpVer && this._isNewerThanMe(minTpVer)) {
         logger.warn("Not loading " + expName);
         logger.warn("Because it requires Test Pilot version " + minTpVer);
 
         // Let user know there is a newer version of Test Pilot available:
         if (!this._isShowingUpdateNotification()) {
@@ -730,16 +732,35 @@ let TestPilotSetup = {
 
       // Minimum firefox version:
       if (minFxVer && this._isNewerThanFirefox(minFxVer)) {
         logger.warn("Not loading " + expName);
         logger.warn("Because it requires Firefox version " + minFxVer);
         return false;
       }
 
+      // Random deployment (used to give study to random subsample of users)
+      if (randomDeployment) {
+        /* Roll a hundred-sided die. Remember what we roll for later reference.  A study
+         * using random subsample deployment will provide a range (say, 0 ~ 30) which means
+         * only users who roll within that range will run the study. */
+        let prefName = RANDOM_DEPLOY_PREFIX + "." + randomDeployment.rolloutCode;
+        let myRoll = this._prefs.getValue(prefName, null);
+        if (myRoll == null) {
+          myRoll = Math.floor(Math.random()*100);
+          this._prefs.setValue(prefName, myRoll);
+        }
+        if (myRoll < randomDeployment.minRoll) {
+          return false;
+        }
+        if (myRoll > randomDeployment.maxRoll) {
+          return false;
+        }
+      }
+
       /* The all-purpose, arbitrary code "Should this study run?" function - if
        * provided, use its return value. */
       if (runOrNotFunc) {
         return runOrNotFunc();
       }
     } catch (e) {
       logger.warn("Error in requirements check " +  e);
     }
--- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js
+++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js
@@ -244,16 +244,33 @@ var TestPilotTask = {
       this.changeStatus(TaskConstants.STATUS_PENDING);
     } else if (this._status == TaskConstants.STATUS_STARTING) {
       this.changeStatus(TaskConstants.STATUS_IN_PROGRESS);
     } else if (this._status == TaskConstants.STATUS_RESULTS) {
       this.changeStatus(TaskConstants.STATUS_ARCHIVED);
     }
 
     this.onDetailPageOpened();
+  },
+
+  getGuid: function TPS_getGuid(id) {
+    // If there is a guid for the task with the given id (not neccessarily this one!)
+    // then use it; if there isn't, generate it and store it.
+    let guid = Application.prefs.getValue(GUID_PREF_PREFIX + id, "");
+    if (guid == "") {
+      let uuidGenerator =
+        Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
+      guid = uuidGenerator.generateUUID().toString();
+      // remove the brackets from the generated UUID
+      if (guid.indexOf("{") == 0) {
+        guid = guid.substring(1, (guid.length - 1));
+      }
+      Application.prefs.setValue(GUID_PREF_PREFIX + id, guid);
+    }
+    return guid;
   }
 };
 
 function TestPilotExperiment(expInfo, dataStore, handlers, webContent, dateOverrideFunc) {
   // All four of these are objects defined in the remote experiment file
   this._init(expInfo, dataStore, handlers, webContent, dateOverrideFunc);
 }
 TestPilotExperiment.prototype = {
@@ -630,24 +647,16 @@ TestPilotExperiment.prototype = {
     }
 
     // If a study is STARTING, and we're in the right date range,
     // then start it, and move it to IN_PROGRESS.
     if ( this._status == TaskConstants.STATUS_STARTING &&
         currentDate >= this._startDate &&
         currentDate <= this._endDate) {
       this._logger.info("Study now starting.");
-      let uuidGenerator =
-        Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
-      let uuid = uuidGenerator.generateUUID().toString();
-      // remove the brackets from the generated UUID
-      if (uuid.indexOf("{") == 0) {
-        uuid = uuid.substring(1, (uuid.length - 1));
-      }
-      Application.prefs.setValue(GUID_PREF_PREFIX + this._id, uuid);
       // clear the data before starting.
       let self = this;
       this._dataStore.wipeAllData(function() {
         // Experiment is now in progress.
         self.changeStatus(TaskConstants.STATUS_IN_PROGRESS, true);
         self.onExperimentStartup();
       });
     }
@@ -737,18 +746,17 @@ TestPilotExperiment.prototype = {
     }
   },
 
   _prependMetadataToJSON: function TestPilotExperiment__prependToJson(callback) {
     let json = {};
     let self = this;
     MetadataCollector.getMetadata(function(md) {
       json.metadata = md;
-      let guid = Application.prefs.getValue(GUID_PREF_PREFIX + self._id, "");
-      json.metadata.task_guid = guid;
+      json.metadata.task_guid = self.getGuid(self._id);
       json.metadata.event_headers = self._dataStore.getPropertyNames();
       self._dataStore.getJSONRows(function(rows) {
                                     json.events = rows;
                                     callback( JSON.stringify(json) );
                                   });
     });
   },
 
@@ -957,23 +965,21 @@ TestPilotBuiltinSurvey.prototype = {
     }
   },
 
   _prependMetadataToJSON: function TestPilotSurvey__prependToJson(callback) {
     let json = {};
     let self = this;
     MetadataCollector.getMetadata(function(md) {
       json.metadata = md;
-      // Include guid of the study that this survey is related to, so we
-      // can match them up server-side.
-      let guid = Application.prefs.getValue(GUID_PREF_PREFIX + self._studyId, "");
-      /* TODO if the guid for that study ID hasn't been set yet, set it!  And
-       * then use it on the study.  That way it won't matter whether the
-       * study or the survey gets run first.*/
-      json.metadata.task_guid = guid;
+      if (self._studyId) {
+        // Include guid of the study that this survey is related to, so we
+        // can match them up server-side.
+        json.metadata.task_guid = self.getGuid(self._studyId);
+      }
       let pref = SURVEY_ANSWER_PREFIX + self._id;
       let surveyAnswers = JSON.parse(Application.prefs.getValue(pref, "{}"));
       json.survey_data = sanitizeJSONStrings(surveyAnswers);
       callback(JSON.stringify(json));
     });
   },
 
   // Upload function for survey -- TODO this duplicates a lot of code
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..bf7a00ff4c3836bc7f822e7bf678c40e0ceeed98
GIT binary patch
literal 2059
zc$_^|3pms3A0HhQx~o`ZC6>eX+c-;`iInA9OfgPqo5`4M&5vEmk&0F}J&BXc=%0}O
z?iC#|MCz}|y_m~Rq*{N{oRmxH{CIkL-{-x5FYo8`{XXw|(fiQB)w*z97!0=B&Gi5o
z8c9&IS*Z>6uX0L#VK5C0^9Ti`czF`&oG3IkltW{n1yNksQXx7DxKw&114PgmCzxyp
z<Wy|~62T00K>FjnFkamKjBuu_h{y019Xdi6Mbh!1NXNZI0RhsFVt`bHAd1C~CI}pm
z%Vr7Cd}$j%B9=wKNCzav%Nqf5IIKt}h_FH9QFv=a7>^po;B$D92rPOxa<49t7aB$&
zA0Yj(2CW>B;ULH*005uQNAqpb9Nq~4i^t;uj16F8gMuVb(Ly#z6`<JBX2>6UOv+C+
zcJvRN5MqEy0kCKc06Een0zX_qPJy2&pv6xb7;FeT9|EZ|5BLHRv>kMzfWDkCkWb|?
zU<Y|rZa9;^pTmx2@IVF+vCEAOGFX=U3-d-Wm^Rbxz`i2_*+f>HYr4Pjlk#NMrOK9m
zzpYZa(;#J1`uXwkeK&@fB{&AK=9#2j%1BtD?6gNQp3hBR$P4pH7_}PWX5X#_2f_GH
zJML|0rp?{Sb6qfN&U6j1H?2W#yS_l|kSpYS?P|Bw=U@APZ|Hau{oJ8Lxb4~G;C<A?
zzn*;3)Wj8TSyzOWpK+3^w0?>31Q6bIkwyZ%M{i|s+dD_)gBYvx8A11aqDbmYLwM~U
z-{zaF{L6@csJaVoY3t}*H!(C6JZG&6R839A2V3=e6q#sKj!*A=+PT<Q>~CrxzxdVG
z#Khzz3WYL1_2t92;*ydHWp{Ts73j9pnd`_7EXq_+&uCfnOGv4OY1wuhbfa~l3td%H
zQzQMonspK#QeSr%`SwVcsH6AMqeozrvR+<LQBl#V0t+8%o0SCeek+hjB*gcrsaZ1F
z*W`qC4jLLrl2LYhm?QYkTUSyM(R%W#4Hmop@iB0Zu^LK=8CwJ1Ve$64xw#oklW6R*
z6jLQ*($1%KR#sNJoao4n>tf%3Yq4`@(XGoWr+RlXxtoJ&(zTsn(_V)gnVQCnZ^TT$
zZhe{9wYj)Y5xM(J!v+(RVJ))~Ommqr?rGPC-2}osMz6b){$ym}K}_W3ftCgPWdnOM
zEJ*mkjOd)498;F!9<y_z>6?imH8B7mQFxKsWA+7gVXbL!w4->SP8jW2!V5Wf&Yt!<
z@0mAz+qOT>mRD3)SFfGY!K&5j6%|eTwUGobRFhbEX8TSFs$QTT?UBpnfaxCY-&Ys*
z=}RC9`!(EztN+P>s-aSxDU<16TD4p=H)2`Rf((exT(MXj--aFuNmxy?)Q<JSP7_pZ
znYIAV&Msbd^=gmtrcJo=6nGkROriP(1Fu5e_5IV`v8AP@SIo`L3%2fNVN4pAv?=K{
z?kfw@F~EBK?<BqAyu7@j{QP{!9cE@H25T}e{GN16idl*mM3TA1Cq-4{<zw}yg>E4s
zO1*<A#=`RY`o-kBy1G04{r&8&PS%U8Oyk6PkCefMipF2I{s4nDC*_WutV2%e%Lp;=
zaY_9jhHD$D2UtgGSLUOKAH=*Z@%w+x$B!QeE@7kOd0`P3G&W}(Keygb_yndiZO}1E
zeAASu_l#12ZM_r}9K0AL5{VLBXR4zH6{Dl0i<|$s+u`e18aPwzNcAtFy!u$U#<{&W
z_s>85%*d-YvY-gw9TZB4iZrEX8!qX^#f`|3iFfZPUMo(0o|tpDKGJH>|8S4NV2p=_
zhJM{en6<>=s+@rI^z_Na)N=+thvjz~($dnd_q~c!>$G>YwY3dG8M3yerA67Sxn%y=
zms?)?R}E%zie!gm;ne9_^%&>w9uuMf^WWRIRXqxY0{AjHc+F|-=+UDWYhx$plUA-$
zzJK(Vmv3-x@6>rkhE4A=U*C;7E3B7^=D{te48lju4dHN6s*pebN#!37tCfLx<CM!2
zv8O;fee8twv6z^cN|L(D*wRIEw(5QT?9J9)N=|tAtSoDwyb-47S@CdX@rNMI@uHKZ
zxMZW?)9Z>I92__pQ)aIUEQ{iB?%&}GF9G941w{+Ao$F>6dfnT5*FZO@NwK{K5%wm|
zd?v>=X_INA#eS*Kl|DQ?Ty6u@K6o%PTHV}r^PsZ8RzB<g{As#XyuSzb{Wb5cII<Pa
z*Is`)>SdPs@klaCCs`l+#xyLTrqZ*SCGJOUAoL^$9&&MMk&M4{tE5<OC&fLRFG|n4
zz4Y>&ZO4&^@(uS+Hg?iRsA;5G!p(iVoqv12S+Ps=Depc{k}swZ`<#A?uO^k}#(F!N
z-ZVHL1P|rAj@jrREJY-}WQ_|_ofkxL8yV7G&q+*CqTt(UNiM<&&X`?K=+aB<@Jq2H
zi+#SMHK=9he>JKTeqxa>M|T;%T>q3Cdt+0;SI=>QRbu!|aoJ&?TT{6YYqNK0NM4J*
zDA{Rd1>&3;_+hfRA>z6(R>XTz9@60XKjx+_qIPHZpxD^Y5uE&?yR>`3eSLjw-lK9o
zJND3Dq2Cw3Nwu`JrjnIgZWnyS&jpM}j);Bg^NrPGnpbpOoP)ljz1^{*b`LB$#luPL
p;Vs^=Eo9N)A4lj*`u=?dY=^qZGVpVj&(a_6=5pvjne*|p{{lz^xaR->
--- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/tests/test_data_store.js
+++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/tests/test_data_store.js
@@ -398,16 +398,31 @@ StubHandlers.prototype = {
   onEnterPrivateBrowsing: function() {
   },
   onExitPrivateBrowsing: function() {
   },
   uninstallAll: function() {
   }
 };
 
+function clearAllPrefsForStudy(studyId) {
+  dump("Looking for prefs to delete...\n");
+  let prefService = Cc["@mozilla.org/preferences-service;1"]
+                     .getService(Ci.nsIPrefService)
+                     .QueryInterface(Ci.nsIPrefBranch2);
+  let prefStem = "extensions.testpilot";
+  let prefNames = prefService.getChildList(prefStem);
+  for each (let prefName in prefNames) {
+    if (prefName.indexOf(studyId) != -1) {
+      dump("Clearing pref " + prefName + "\n");
+      prefService.clearUserPref(prefName);
+    }
+  }
+
+}
 
 function testRecurringStudyStateChange() {
 
   Cu.import("resource://testpilot/modules/tasks.js");
 
   let expInfo = {
     startDate: null,
     duration: 7,
@@ -417,28 +432,17 @@ function testRecurringStudyStateChange()
     summary: "Be sure to wipe all prefs and the store in the setup/teardown",
     thumbnail: "",
     optInRequired: false,
     recursAutomatically: true,
     recurrenceInterval: 30,
     versionNumber: 1
   };
 
-  dump("Looking for prefs to delete...\n");
-  let prefService = Cc["@mozilla.org/preferences-service;1"]
-                     .getService(Ci.nsIPrefService)
-                     .QueryInterface(Ci.nsIPrefBranch2);
-  let prefStem = "extensions.testpilot";
-  let prefNames = prefService.getChildList(prefStem);
-  for each (let prefName in prefNames) {
-    if (prefName.indexOf("unit_test_recur_study") != -1) {
-      dump("Clearing pref " + prefName + "\n");
-      prefService.clearUserPref(prefName);
-    }
-  }
+  clearAllPrefsForStudy("unit_test_recur_study");
 
   const START_DATE = 1292629441000;
   let stubDate = START_DATE;
 
   let stubDateFunction = function() {
     return stubDate;
   };
 
@@ -554,17 +558,18 @@ function runAllTests() {
 
   //testTheDataStore();
   //testFirefoxVersionCheck();
   //testStringSanitizer();
   //testTheCuddlefishPreferencesFilesystem();
   //testRemoteLoader();
   //testRemoteLoaderIndexCache();
   //testRecurringStudyStateChange();
-  testKillSwitch();
+  //testKillSwitch();
+  testSameGUIDs();
   dump("TESTING COMPLETE.  " + testsPassed + " out of " + testsRun +
        " tests passed.");
 }
 
 
 //exports.runAllTests = runAllTests;
 
 
@@ -686,9 +691,96 @@ function testKillSwitch() {
           count += 1;
         }
         cheapAssertEqual(count, 0, "File should be killed!\n");
 
         clearIndexFileCache();
       });
     });
   });
-}
\ No newline at end of file
+}
+
+// To test:  The random subsample deployment... deployment when fx version or test pilot version
+// is or is not sufficient for study... deployment with arbitrary runOrNot func returning true
+// or false.
+
+function testSameGUIDs() {
+
+  // make a study and survey that knows the study as 'related study'.
+
+  // start and submit study first, start and submit survey second: ensure that both have same
+  // submission GUID.
+  Cu.import("resource://testpilot/modules/tasks.js");
+
+  let expInfo = {
+    startDate: null,
+    duration: 7,
+    testName: "Study w Survey n Guid",
+    testId: "unit_test_guid_study",
+    testInfoUrl: "https://testpilot.mozillalabs.com/",
+    summary: "Be sure to wipe all prefs and the store in the setup/teardown",
+    thumbnail: "",
+    optInRequired: false,
+    recursAutomatically: false,
+    recurrenceInterval: 0,
+    versionNumber: 1
+  };
+
+  let surveyInfo = { surveyId: "unit_test_guid_survey",
+      surveyName: "Survey with associated study",
+      surveyUrl: "",
+      summary: "",
+      thumbnail: "",
+      uploadWithExperiment: expInfo.testId,
+      versionNumber: 1,
+      surveyQuestions: {},
+      surveyExplanation: ""
+  };
+
+  clearAllPrefsForStudy("unit_test_guid_study");
+  clearAllPrefsForStudy("unit_test_guid_survey");
+
+  let dataStore = new StubDataStore();
+  let handlers = new StubHandlers();
+  let webContent = new StubWebContent();
+  let experiment = new TestPilotExperiment(expInfo, dataStore, handlers, webContent);
+  let survey = new TestPilotBuiltinSurvey(surveyInfo);
+
+  // Start the study so it will generate a GUID
+  experiment.changeStatus(TaskConstants.STATUS_STARTING, true);
+  experiment.checkDate();
+
+  // Get GUIDs from study and from survey, compare:
+  experiment._prependMetadataToJSON(function(jsonString) {
+    let expGuid = JSON.parse(jsonString).metadata.task_guid;
+    survey._prependMetadataToJSON(function(jsonString) {
+      let surveyGuid = JSON.parse(jsonString).metadata.task_guid;
+      dump("expGuid is " + expGuid + ", surveyGuid is " + surveyGuid + "\n");
+      cheapAssertEqual(expGuid, surveyGuid, "guids should match");
+      cheapAssertEqual((expGuid != ""), true, "guid should be non-empty");
+
+      // Clear everything for next part of test:
+      clearAllPrefsForStudy("unit_test_guid_study");
+      clearAllPrefsForStudy("unit_test_guid_survey");
+
+      let experiment2 = new TestPilotExperiment(expInfo, dataStore, handlers, webContent);
+      let survey2 = new TestPilotBuiltinSurvey(surveyInfo);
+
+      // this time we query the survey for the GUID first, without starting the study:
+      survey2._prependMetadataToJSON(function(jsonString) {
+        let survey2Guid = JSON.parse(jsonString).metadata.task_guid;
+        // after that, start the study:
+        experiment2.changeStatus(TaskConstants.STATUS_STARTING, true);
+        experiment2.checkDate();
+        // experiment and survey should have same GUID again:
+        experiment2._prependMetadataToJSON(function(jsonString) {
+          let exp2Guid = JSON.parse(jsonString).metadata.task_guid;
+          dump("exp2Guid is " + exp2Guid + ", survey2Guid is " + survey2Guid + "\n");
+          cheapAssertEqual(exp2Guid, survey2Guid, "guids should match");
+          cheapAssertEqual((exp2Guid != ""), true, "guid should be non-empty");
+        });
+      });
+    });
+  });
+}
+
+// TODO test for continuity of GUID with recurring study (longitudinal) - i don't think this
+// has actually been working so far because a new GUID is generted every time the study starts up...
\ No newline at end of file
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -57,17 +57,17 @@ pref("browser.hiddenWindowChromeURL", "c
 pref("extensions.logging.enabled", false);
 
 // Preferences for AMO integration
 pref("extensions.getAddons.cache.enabled", true);
 pref("extensions.getAddons.maxResults", 15);
 pref("extensions.getAddons.get.url", "https://services.addons.mozilla.org/%LOCALE%/%APP%/api/%API_VERSION%/search/guid:%IDS%?src=firefox&appOS=%OS%&appVersion=%VERSION%&tMain=%TIME_MAIN%&tFirstPaint=%TIME_FIRST_PAINT%&tSessionRestored=%TIME_SESSION_RESTORED%");
 pref("extensions.getAddons.search.browseURL", "https://addons.mozilla.org/%LOCALE%/%APP%/search?q=%TERMS%");
 pref("extensions.getAddons.search.url", "https://services.addons.mozilla.org/%LOCALE%/%APP%/api/%API_VERSION%/search/%TERMS%/all/%MAX_RESULTS%/%OS%/%VERSION%?src=firefox");
-pref("extensions.webservice.discoverURL", "https://services.addons.mozilla.org/%LOCALE%/%APP%/discovery/%VERSION%/%OS%");
+pref("extensions.webservice.discoverURL", "https://services.addons.mozilla.org/%LOCALE%/%APP%/discovery/pane/%VERSION%/%OS%");
 
 // Blocklist preferences
 pref("extensions.blocklist.enabled", true);
 pref("extensions.blocklist.interval", 86400);
 // Controls what level the blocklist switches from warning about items to forcibly
 // blocking them.
 pref("extensions.blocklist.level", 2);
 pref("extensions.blocklist.url", "https://addons.mozilla.org/blocklist/3/%APP_ID%/%APP_VERSION%/%PRODUCT%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/%PING_COUNT%/%TOTAL_PING_COUNT%/%DAYS_SINCE_LAST_PING%/");
@@ -1007,17 +1007,16 @@ pref("services.sync.prefs.sync.browser.u
 pref("services.sync.prefs.sync.browser.urlbar.default.behavior", true);
 pref("services.sync.prefs.sync.browser.urlbar.maxRichResults", true);
 pref("services.sync.prefs.sync.dom.disable_open_during_load", true);
 pref("services.sync.prefs.sync.dom.disable_window_flip", true);
 pref("services.sync.prefs.sync.dom.disable_window_move_resize", true);
 pref("services.sync.prefs.sync.dom.event.contextmenu.enabled", true);
 pref("services.sync.prefs.sync.extensions.personas.current", true);
 pref("services.sync.prefs.sync.extensions.update.enabled", true);
-pref("services.sync.prefs.sync.general.autoScroll", true);
 pref("services.sync.prefs.sync.general.smoothScroll", true);
 pref("services.sync.prefs.sync.intl.accept_languages", true);
 pref("services.sync.prefs.sync.javascript.enabled", true);
 pref("services.sync.prefs.sync.layout.spellcheckDefault", true);
 pref("services.sync.prefs.sync.lightweightThemes.isThemeSelected", true);
 pref("services.sync.prefs.sync.lightweightThemes.usedThemes", true);
 pref("services.sync.prefs.sync.network.cookie.cookieBehavior", true);
 pref("services.sync.prefs.sync.network.cookie.lifetimePolicy", true);
--- a/browser/base/content/browser-menubar.inc
+++ b/browser/base/content/browser-menubar.inc
@@ -212,21 +212,16 @@
 #endif
 #endif
               </menupopup>
             </menu>
 
             <menu id="view-menu" label="&viewMenu.label;"
                   accesskey="&viewMenu.accesskey;">
               <menupopup id="menu_viewPopup">
-                <menuitem id="menu_tabview"
-                          key="key_tabview"
-                          label="&viewTabGroups.label;"
-                          accesskey="&viewTabGroups.accesskey;"
-                          command="Browser:ToggleTabView"/>
                 <menu id="viewToolbarsMenu"
                       label="&viewToolbarsMenu.label;"
                       accesskey="&viewToolbarsMenu.accesskey;">
                   <menupopup onpopupshowing="onViewToolbarsPopupShowing(event);">
                     <menuseparator/>
                     <menuitem id="menu_tabsOnTop"
                               command="cmd_ToggleTabsOnTop"
                               type="checkbox"
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -987,17 +987,22 @@ var PlacesStarButton = {
 
     this._pendingStmt = PlacesUtils.asyncGetBookmarkIds(this._uri, function (aItemIds, aURI) {
       // Safety check that the bookmarked URI equals the tracked one.
       if (!aURI.equals(this._uri)) {
         Components.utils.reportError("PlacesStarButton did not receive current URI");
         return;
       }
 
-      this._itemIds = aItemIds;
+      // It's possible that onItemAdded gets called before the async statement
+      // calls back.  For such an edge case, retain all unique entries from both
+      // arrays.
+      this._itemIds = this._itemIds.filter(
+        function (id) aItemIds.indexOf(id) == -1
+      ).concat(aItemIds);
       this._updateStateInternal();
 
       // Start observing bookmarks if needed.
       if (!this._hasBookmarksObserver) {
         try {
           PlacesUtils.bookmarks.addObserver(this, false);
           this._hasBookmarksObserver = true;
         } catch(ex) {
@@ -1038,17 +1043,17 @@ var PlacesStarButton = {
   // nsINavBookmarkObserver
   onItemAdded:
   function PSB_onItemAdded(aItemId, aFolder, aIndex, aItemType, aURI)
   {
     if (!this._starIcon) {
       return;
     }
 
-    if (aURI.equals(this._uri)) {
+    if (aURI && aURI.equals(this._uri)) {
       // If a new bookmark has been added to the tracked uri, register it.
       if (this._itemIds.indexOf(aItemId) == -1) {
         this._itemIds.push(aItemId);
         this._updateStateInternal();
       }
     }
   },
 
--- a/browser/base/content/browser-syncui.js
+++ b/browser/base/content/browser-syncui.js
@@ -36,27 +36,33 @@
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
 
 // gSyncUI handles updating the tools menu
 let gSyncUI = {
   init: function SUI_init() {
-    // this will be the first notification fired during init
-    // we can set up everything else later
+    // Proceed to set up the UI if Sync has already started up.
+    // Otherwise we'll do it when Sync is firing up.
+    if (Weave.Status.ready) {
+      this.initUI();
+      return;
+    }
+
     Services.obs.addObserver(this, "weave:service:ready", true);
 
     // Remove the observer if the window is closed before the observer
     // was triggered.
     window.addEventListener("unload", function() {
       window.removeEventListener("unload", arguments.callee, false);
       Services.obs.removeObserver(gSyncUI, "weave:service:ready");
     }, false);
   },
+
   initUI: function SUI_initUI() {
     let obs = ["weave:service:sync:start",
                "weave:service:sync:finish",
                "weave:service:sync:error",
                "weave:service:sync:delayed",
                "weave:service:quota:remaining",
                "weave:service:setup-complete",
                "weave:service:login:start",
@@ -65,29 +71,26 @@ let gSyncUI = {
                "weave:service:logout:finish",
                "weave:service:start-over"];
 
     // If this is a browser window?
     if (gBrowser) {
       obs.push("weave:notification:added");
     }
 
-    let self = this;
     obs.forEach(function(topic) {
-      Services.obs.addObserver(self, topic, true);
-    });
+      Services.obs.addObserver(this, topic, true);
+    }, this);
 
     // Find the alltabs-popup, only if there is a gBrowser
     if (gBrowser) {
       let popup = document.getElementById("alltabs-popup");
       if (popup) {
-        let self = this;
-        popup.addEventListener("popupshowing", function() {
-          self.alltabsPopupShowing();
-        }, true);
+        popup.addEventListener(
+          "popupshowing", this.alltabsPopupShowing.bind(this), true);
       }
 
       if (Weave.Notifications.notifications.length)
         this.initNotifications();
     }
     this.updateUI();
   },
   
@@ -113,22 +116,16 @@ let gSyncUI = {
     let firstSync = "";
     try {
       firstSync = Services.prefs.getCharPref("services.sync.firstSync");
     } catch (e) { }
     return Weave.Status.checkSetup() == Weave.CLIENT_NOT_CONFIGURED ||
            firstSync == "notReady";
   },
 
-  _isLoggedIn: function() {
-    if (this._needsSetup())
-      return false;
-    return Weave.Service.isLoggedIn;
-  },
-
   updateUI: function SUI_updateUI() {
     let needsSetup = this._needsSetup();
     document.getElementById("sync-setup-state").hidden = !needsSetup;
     document.getElementById("sync-syncnow-state").hidden = needsSetup;
 
     if (!gBrowser)
       return;
 
@@ -139,41 +136,39 @@ let gSyncUI = {
     button.removeAttribute("status");
     this._updateLastSyncTime();
     if (needsSetup)
       button.removeAttribute("tooltiptext");
   },
 
   alltabsPopupShowing: function(event) {
     // Should we show the menu item?
+    //XXXphilikon We should remove the check for isLoggedIn here and have
+    //            about:sync-tabs auto-login (bug 583344)
     if (!Weave.Service.isLoggedIn || !Weave.Engines.get("tabs").enabled)
       return;
 
     let label = this._stringBundle.GetStringFromName("tabs.fromOtherComputers.label");
 
     let popup = document.getElementById("alltabs-popup");
     if (!popup)
       return;
     
     let menuitem = document.createElement("menuitem");
     menuitem.setAttribute("id", "sync-tabs-menuitem");
     menuitem.setAttribute("label", label);
     menuitem.setAttribute("class", "alltabs-item");
     menuitem.setAttribute("oncommand", "BrowserOpenSyncTabs();");
 
-    let sep = document.createElement("menuseparator");
-    sep.setAttribute("id", "sync-tabs-sep");
-
     // Fake the tab object on the menu entries, so that we don't have to worry
     // about removing them ourselves. They will just get cleaned up by popup
     // binding.
     menuitem.tab = { "linkedBrowser": { "currentURI": { "spec": label } } };
-    sep.tab = { "linkedBrowser": { "currentURI": { "spec": " " } } };
 
-    popup.insertBefore(sep, popup.firstChild);
+    let sep = document.getElementById("alltabs-popup-separator");
     popup.insertBefore(menuitem, sep);
   },
 
 
   // Functions called by observers
   onActivityStart: function SUI_onActivityStart() {
     if (!gBrowser)
       return;
--- a/browser/base/content/browser-tabview.js
+++ b/browser/base/content/browser-tabview.js
@@ -55,25 +55,25 @@ let TabView = {
   // ----------
   get firstUseExperienced() {
     return this._firstUseExperienced;
   },
 
   // ----------
   set firstUseExperienced(val) {
     if (val != this._firstUseExperienced)
-      Services.prefs.setBoolPref("browser.panorama.experienced_first_use", val);
+      Services.prefs.setBoolPref("browser.panorama.experienced_first_run", val);
   },
 
   // ----------
   init: function TabView_init() {
-    if (!Services.prefs.prefHasUserValue("browser.panorama.experienced_first_use") ||
-        !Services.prefs.getBoolPref("browser.panorama.experienced_first_use")) {
+    if (!Services.prefs.prefHasUserValue("browser.panorama.experienced_first_run") ||
+        !Services.prefs.getBoolPref("browser.panorama.experienced_first_run")) {
       Services.prefs.addObserver(
-        "browser.panorama.experienced_first_use", this, false);
+        "browser.panorama.experienced_first_run", this, false);
     } else {
       this._firstUseExperienced = true;
 
       if ((gBrowser.tabs.length - gBrowser.visibleTabs.length) > 0)
         this._setBrowserKeyHandlers();
 
       // ___ visibility
       let sessionstore =
@@ -99,28 +99,28 @@ let TabView = {
     }
   },
 
   // ----------
   // Observes topic changes.
   observe: function TabView_observe(subject, topic, data) {
     if (topic == "nsPref:changed") {
       Services.prefs.removeObserver(
-        "browser.panorama.experienced_first_use", this);
+        "browser.panorama.experienced_first_run", this);
       this._firstUseExperienced = true;
       this._addToolbarButton();
     }
   },
 
   // ----------
   // Uninitializes TabView.
   uninit: function TabView_uninit() {
     if (!this._firstUseExperienced) {
       Services.prefs.removeObserver(
-        "browser.panorama.experienced_first_use", this);
+        "browser.panorama.experienced_first_run", this);
     }
     if (this._tabShowEventListener) {
       gBrowser.tabContainer.removeEventListener(
         "TabShow", this._tabShowEventListener, true);
     }
   },
 
   // ----------
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -467,17 +467,23 @@ statuspanel {
 
 statuspanel:-moz-locale-dir(ltr)[mirror],
 statuspanel:-moz-locale-dir(rtl):not([mirror]) {
   left: auto;
   right: 0;
 }
 
 statuspanel[type=status] {
-  min-width: 25%;
+  min-width: 23em;
+}
+
+@media all and (max-width: 800px) {
+  statuspanel[type=status] {
+    min-width: 33%;
+  }
 }
 
 statuspanel[type=overLink] {
   direction: ltr;
 }
 
 statuspanel[label=""] {
   -moz-transition: none;
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -4173,16 +4173,17 @@ var XULBrowserWindow = {
 
     // check the current value so we don't trigger an attribute change
     // and cause needless (slow!) UI updates
     if (this.statusText != text) {
       let field = this.statusTextField;
       field.setAttribute("previoustype", field.getAttribute("type"));
       field.setAttribute("type", type);
       field.label = text;
+      field.setAttribute("crop", type == "overLink" ? "center" : "end");
       this.statusText = text;
     }
   },
 
   // Called before links are navigated to to allow us to retarget them if needed.
   onBeforeLinkTraversal: function(originalTarget, linkURI, linkNode, isAppTab) {
     // Don't modify non-default targets or targets that aren't in top-level app
     // tab docshells (isAppTab will be false for app tab subframes).
@@ -4433,17 +4434,20 @@ var XULBrowserWindow = {
       findCommands.forEach(function (elt) {
         if (disableFind)
           elt.setAttribute("disabled", "true");
         else
           elt.removeAttribute("disabled");
       });
 
       if (gFindBarInitialized) {
-        gFindBar.close();
+        if (gFindBar.findMode != gFindBar.FIND_NORMAL) {
+          // Close the Find toolbar if we're in old-style TAF mode
+          gFindBar.close();
+        }
 
         // fix bug 253793 - turn off highlight when page changes
         gFindBar.getElement("highlight").checked = false;
       }
     }
     UpdateBackForwardCommands(gBrowser.webNavigation);
 
     // See bug 358202, when tabs are switched during a drag operation,
@@ -8394,58 +8398,60 @@ var LightWeightThemeWebInstaller = {
 /**
  * Switch to a tab that has a given URI, and focusses its browser window.
  * If a matching tab is in this window, it will be switched to. Otherwise, other
  * windows will be searched.
  *
  * @param aURI
  *        URI to search for
  * @param aOpenNew
- *        True to open a new tab and switch to it, if no existing tab is found
+ *        True to open a new tab and switch to it, if no existing tab is found.
+ *        If no suitable window is found, a new one will be opened.
  * @return True if an existing tab was found, false otherwise
  */
 function switchToTabHavingURI(aURI, aOpenNew) {
+  // This will switch to the tab in aWindow having aURI, if present.
   function switchIfURIInWindow(aWindow) {
-    if (!("gBrowser" in aWindow))
-      return false;
     let browsers = aWindow.gBrowser.browsers;
     for (let i = 0; i < browsers.length; i++) {
       let browser = browsers[i];
       if (browser.currentURI.equals(aURI)) {
         // Focus the matching window & tab
         aWindow.focus();
         aWindow.gBrowser.tabContainer.selectedIndex = i;
         return true;
       }
     }
     return false;
   }
 
   // This can be passed either nsIURI or a string.
   if (!(aURI instanceof Ci.nsIURI))
-    aURI = makeURI(aURI);
+    aURI = Services.io.newURI(aURI, null, null);
+
+  let isBrowserWindow = !!window.gBrowser;
 
   // Prioritise this window.
-  if (switchIfURIInWindow(window))
+  if (isBrowserWindow && switchIfURIInWindow(window))
     return true;
 
   let winEnum = Services.wm.getEnumerator("navigator:browser");
   while (winEnum.hasMoreElements()) {
     let browserWin = winEnum.getNext();
     // Skip closed (but not yet destroyed) windows,
     // and the current window (which was checked earlier).
     if (browserWin.closed || browserWin == window)
       continue;
     if (switchIfURIInWindow(browserWin))
       return true;
   }
 
   // No opened tab has that url.
   if (aOpenNew) {
-    if (isTabEmpty(gBrowser.selectedTab))
+    if (isBrowserWindow && isTabEmpty(gBrowser.selectedTab))
       gBrowser.selectedBrowser.loadURI(aURI.spec);
     else
       openUILinkIn(aURI.spec, "tab");
   }
 
   return false;
 }
 
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -839,17 +839,26 @@
 
       <toolbarbutton id="alltabs-button"
                      class="toolbarbutton-1 chromeclass-toolbar-additional tabs-alltabs-button"
                      type="menu"
                      label="&listAllTabs.label;"
                      tooltiptext="&listAllTabs.label;"
                      removable="true">
         <menupopup id="alltabs-popup"
-                   position="after_end"/>
+                   position="after_end">
+          <menuitem id="menu_tabview"
+                    class="menuitem-iconic"
+                    key="key_tabview"
+                    label="&viewTabGroups.label;"
+                    command="Browser:ToggleTabView"
+                    observes="tabviewGroupsNumber"
+                    keepme="true"/>
+          <menuseparator id="alltabs-popup-separator" keepme="true"/>
+        </menupopup>
       </toolbarbutton>
 
       <toolbarbutton id="tabs-closebutton"
                      class="close-button tabs-closebutton"
                      command="cmd_close"
                      label="&closeTab.label;"
                      tooltiptext="&closeTab.label;"/>
 
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -960,16 +960,22 @@
                     gURLBar.focus();
                     break;
                   } else if (isTabEmpty(this.mCurrentTab)) {
                     focusAndSelectUrlBar();
                     break;
                   }
                 }
 
+                // If the find bar is focused, keep it focused.
+                if (gFindBarInitialized &&
+                    !gFindBar.hidden &&
+                    gFindBar.getElement("findbar-textbox").getAttribute("focused") == "true")
+                  break;
+
                 // Otherwise, focus the content area.
                 let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
                 let newFocusedElement = fm.getFocusedElementForWindow(window.content, true, {});
 
                 // for anchors, use FLAG_SHOWRING so that it is clear what link was
                 // last clicked when switching back to that tab
                 let focusFlags = fm.FLAG_NOSCROLL;
                 if (newFocusedElement &&
@@ -3081,17 +3087,26 @@
 
         if (tab.getAttribute("fadein") == "true")
           this._handleNewTab(tab);
         else if (this.tabbrowser._removingTabs.indexOf(tab) > -1)
           this.tabbrowser._endRemoveTab(tab);
       ]]></handler>
 
       <handler event="dblclick"><![CDATA[
-        // See hack note in the tabbrowser-close-button binding
+#ifdef MOZ_WIDGET_GTK2
+        // Disable this on GTK2 when the menubar is draggable, since (a)
+        // the menubar and tabbbar have unified appearance and should
+        // thus not have different behavior (though this condition alone
+        // applies to more cases) and (b) it interacts badly with the
+        // drag handling that we use for dragging either one.
+        if (this.parentNode._dragBindingAlive)
+          return;
+#endif
+        // See hack note in the tabbrowser-close-tab-button binding
         if (!this._blockDblClick && event.button == 0 &&
             event.originalTarget.localName == "box")
           BrowserOpenTab();
       ]]></handler>
 
       <handler event="click"><![CDATA[
         if (event.button != 1)
           return;
@@ -3685,21 +3700,23 @@
           this._createTabMenuItem(tabs[i]);
         }
         this._updateTabsVisibilityStatus();
       ]]></handler>
 
       <handler event="popuphidden">
       <![CDATA[
         // clear out the menu popup and remove the listeners
-        while (this.hasChildNodes()) {
-          var menuItem = this.lastChild;
-          menuItem.removeEventListener("command", this, false);
-          menuItem.tab.mCorrespondingMenuitem = null;
-          this.removeChild(menuItem);
+        for (let i = this.childNodes.length - 1; i > 0; i--) {
+          let menuItem = this.childNodes[i];
+          if (!menuItem.hasAttribute("keepme")) {
+            menuItem.removeEventListener("command", this, false);
+            menuItem.tab.mCorrespondingMenuitem = null;
+            this.removeChild(menuItem);
+          }
         }
         var tabcontainer = gBrowser.tabContainer;
         tabcontainer.mTabstrip.removeEventListener("scroll", this, false);
         tabcontainer.removeEventListener("TabOpen", this, false);
         tabcontainer.removeEventListener("TabAttrModified", this, false);
         tabcontainer.removeEventListener("TabClose", this, false);
       ]]></handler>
 
@@ -3722,17 +3739,17 @@
     </handlers>
   </binding>
 
   <binding id="statuspanel" display="xul:hbox">
     <content>
       <xul:hbox class="statuspanel-inner">
         <xul:label class="statuspanel-label"
                    role="status"
-                   xbl:inherits="value=label,mirror"
+                   xbl:inherits="value=label,crop,mirror"
                    flex="1"
                    crop="end"/>
       </xul:hbox>
     </content>
 
     <implementation>
       <property name="label">
         <setter><![CDATA[
--- a/browser/base/content/tabview/groupitems.js
+++ b/browser/base/content/tabview/groupitems.js
@@ -737,16 +737,20 @@ GroupItem.prototype = Utils.extend(new I
     let self = this;
 
     this._cancelFadeAwayUndoButtonTimer();
     this.hidden = false;
     this.$undoContainer.remove();
     this.$undoContainer = null;
     this.droppable(true);
 
+    GroupItems.setActiveGroupItem(this);
+    if (this._activeTab)
+      UI.setActiveTab(this._activeTab);
+
     iQ(this.container).show().animate({
       "-moz-transform": "scale(1)",
       "opacity": 1
     }, {
       duration: 170,
       complete: function() {
         self._children.forEach(function(child) {
           iQ(child.container).show();
@@ -801,17 +805,17 @@ GroupItem.prototype = Utils.extend(new I
     // In other words, the group "close" event is fired before all browser
     // tabs in the group are closed.  The below code would fire the group "close"
     // event only after all browser tabs in that group are closed.
     let shouldRemoveTabItems = [];
     let toClose = this._children.concat();
     toClose.forEach(function(child) {
       child.removeSubscriber(self, "close");
 
-      let removed = child.close();
+      let removed = child.close(true);
       if (removed) {
         shouldRemoveTabItems.push(child);
       } else {
         // child.removeSubscriber() must be called before child.close(), 
         // therefore we call child.addSubscriber() if the tab is not removed.
         child.addSubscriber(self, "close", function() {
           self.remove(child);
         });
@@ -1089,17 +1093,17 @@ GroupItem.prototype = Utils.extend(new I
       // if a blank tab is selected while restoring a tab the blank tab gets
       // removed. we need to keep the group alive for the restored tab.
       if (item.tab._tabViewTabIsRemovedAfterRestore)
         options.dontClose = true;
 
       let closed = options.dontClose ? false : this.closeIfEmpty();
       if (closed)
         this._makeClosestTabActive();
-      else if (!options.dontArrage)
+      else if (!options.dontArrange)
         this.arrange({animate: !options.immediately});
 
       this._sendToSubscribers("childRemoved",{ groupItemId: this.id, item: item });
     } catch(e) {
       Utils.log(e);
     }
   },
 
@@ -1121,17 +1125,16 @@ GroupItem.prototype = Utils.extend(new I
   
   // ----------
   // Handles error event for loading app tab's fav icon.
   _onAppTabError : function(event) {
     iQ(".appTabIcon", this.$appTabTray).each(function(icon) {
       let $icon = iQ(icon);
       if ($icon.data("xulTab") == event.target) {
         $icon.attr("src", Utils.defaultFaviconURL);
-        return true;
       }
     });
   },
 
   // ----------
   // Adds the given xul:tab as an app tab in this group's apptab tray
   //
   // Parameters:
@@ -1311,49 +1314,53 @@ GroupItem.prototype = Utils.extend(new I
     if (bbAspect > itemAspect) { // Tall, thin groupItem
       size = TabItems.calcValidSize(new Point(bb.width * scale, -1),
         {hideTitle:true});
      } else { // Short, wide groupItem
       size = TabItems.calcValidSize(new Point(-1, bb.height * scale),
         {hideTitle:true});
      }
 
-
     // x is the left margin that the stack will have, within the content area (bb)
     // y is the vertical margin
     var x = (bb.width - size.x) / 2;
     var y = Math.min(size.x, (bb.height - size.y) / 2);
     var box = new Rect(bb.left + x, bb.top + y, size.x, size.y);
 
     var self = this;
     var children = [];
+
+    // ensure this.topChild is the first item in childrenToArrange
+    let topChildPos = childrenToArrange.indexOf(this.topChild);
+    if (topChildPos > 0) {
+      childrenToArrange.splice(topChildPos, 1);
+      childrenToArrange.unshift(this.topChild);
+    }
+
     childrenToArrange.forEach(function GroupItem__stackArrange_order(child) {
       // Children are still considered stacked even if they're hidden later.
       child.addClass("stacked");
       child.isStacked = true;
       if (numInPile-- > 0) {
-        child.setHidden(false);
-        if (child == self.topChild)
-          children.unshift(child);
-        else
-          children.push(child);
+        children.push(child);
       } else {
         child.setHidden(true);
       }
     });
 
     let angleAccum = 0;
     children.forEach(function GroupItem__stackArrange_apply(child, index) {
       child.setZ(zIndex);
       zIndex--;
 
       // Force a recalculation of height because we've changed how the title
       // is shown.
-      child.setBounds(box, !animate, {force:true});
+      child.setBounds(box, !animate || child.getHidden(), {force:true});
       child.setRotation((UI.rtl ? -1 : 1) * angleAccum);
+      child.setHidden(false);
       angleAccum += angleDelta;
     });
 
     self._isStacked = true;
   },
   
   // ----------
   // Function: _gridArrange
--- a/browser/base/content/tabview/storage.js
+++ b/browser/base/content/tabview/storage.js
@@ -42,30 +42,48 @@
 // ##########
 // Class: Storage
 // Singleton for permanent storage of TabView data.
 let Storage = {
   GROUP_DATA_IDENTIFIER: "tabview-group",
   GROUPS_DATA_IDENTIFIER: "tabview-groups",
   TAB_DATA_IDENTIFIER: "tabview-tab",
   UI_DATA_IDENTIFIER: "tabview-ui",
+  CACHE_CLIENT_IDENTIFIER: "tabview-cache",
+  CACHE_PREFIX: "moz-panorama:",
 
   // ----------
   // Function: init
   // Sets up the object.
   init: function Storage_init() {
     this._sessionStore =
       Cc["@mozilla.org/browser/sessionstore;1"].
         getService(Ci.nsISessionStore);
+    
+    // Create stream-based cache session for tabview
+    let cacheService = 
+      Cc["@mozilla.org/network/cache-service;1"].
+        getService(Ci.nsICacheService);
+    this._cacheSession = cacheService.createSession(
+      this.CACHE_CLIENT_IDENTIFIER, Ci.nsICache.STORE_ON_DISK, true);
+    this.StringInputStream = Components.Constructor(
+      "@mozilla.org/io/string-input-stream;1", "nsIStringInputStream",
+      "setData");
+    this.StorageStream = Components.Constructor(
+      "@mozilla.org/storagestream;1", "nsIStorageStream", 
+      "init");
   },
 
   // ----------
   // Function: uninit
   uninit: function Storage_uninit () {
     this._sessionStore = null;
+    this._cacheSession = null;
+    this.StringInputStream = null;
+    this.StorageStream = null;
   },
 
   // ----------
   // Function: wipe
   // Cleans out all the stored data, leaving empty objects.
   wipe: function Storage_wipe() {
     try {
       var self = this;
@@ -85,46 +103,205 @@ let Storage = {
       this._sessionStore.setWindowValue(gWindow, this.GROUP_DATA_IDENTIFIER,
         JSON.stringify({}));
     } catch (e) {
       Utils.log("Error in wipe: "+e);
     }
   },
 
   // ----------
+  // Function: _openCacheEntry
+  // Opens a cache entry for the given <url> and requests access <access>.
+  // Calls <successCallback>(entry) when the entry was successfully opened with
+  // requested access rights. Otherwise calls <errorCallback>().
+  _openCacheEntry: function Storage__openCacheEntry(url, access, successCallback, errorCallback) {
+    let onCacheEntryAvailable = function (entry, accessGranted, status) {
+      if (entry && access == accessGranted && Components.isSuccessCode(status)) {
+        successCallback(entry);
+      } else {
+        entry && entry.close();
+        errorCallback();
+      }
+    }
+
+    let key = this.CACHE_PREFIX + url;
+
+    // switch to synchronous mode if parent window is about to close
+    if (UI.isDOMWindowClosing) {
+      let entry = this._cacheSession.openCacheEntry(key, access, true);
+      let status = Components.results.NS_OK;
+      onCacheEntryAvailable(entry, entry.accessGranted, status);
+    } else {
+      let listener = new CacheListener(onCacheEntryAvailable);
+      this._cacheSession.asyncOpenCacheEntry(key, access, listener);
+    }
+  },
+
+  // ----------
+  // Function: saveThumbnail
+  // Saves the <imageData> to the cache using the given <url> as key.
+  // Calls <callback>(status) when finished (passing true or false indicating
+  // whether the operation succeeded).
+  saveThumbnail: function Storage_saveThumbnail(url, imageData, callback) {
+    Utils.assert(url, "url");
+    Utils.assert(imageData, "imageData");
+    Utils.assert(typeof callback == "function", "callback arg must be a function");
+
+    let self = this;
+    let StringInputStream = this.StringInputStream;
+
+    let onCacheEntryAvailable = function (entry) {
+      let outputStream = entry.openOutputStream(0);
+
+      let cleanup = function () {
+        outputStream.close();
+        entry.close();
+      }
+
+      // switch to synchronous mode if parent window is about to close
+      if (UI.isDOMWindowClosing) {
+        outputStream.write(imageData, imageData.length);
+        cleanup();
+        callback(true);
+        return;
+      }
+
+      // asynchronous mode
+      let inputStream = new StringInputStream(imageData, imageData.length);
+      gNetUtil.asyncCopy(inputStream, outputStream, function (result) {
+        cleanup();
+        inputStream.close();
+        callback(Components.isSuccessCode(result));
+      });
+    }
+
+    let onCacheEntryUnavailable = function () {
+      callback(false);
+    }
+
+    this._openCacheEntry(url, Ci.nsICache.ACCESS_WRITE,
+        onCacheEntryAvailable, onCacheEntryUnavailable);
+  },
+
+  // ----------
+  // Function: loadThumbnail
+  // Asynchrously loads image data from the cache using the given <url> as key.
+  // Calls <callback>(status, data) when finished, passing true or false
+  // (indicating whether the operation succeeded) and the retrieved image data.
+  loadThumbnail: function Storage_loadThumbnail(url, callback) {
+    Utils.assert(url, "url");
+    Utils.assert(typeof callback == "function", "callback arg must be a function");
+
+    let self = this;
+
+    let onCacheEntryAvailable = function (entry) {
+      let imageChunks = [];
+      let nativeInputStream = entry.openInputStream(0);
+
+      const CHUNK_SIZE = 0x10000; // 65k
+      const PR_UINT32_MAX = 0xFFFFFFFF;
+      let storageStream = new self.StorageStream(CHUNK_SIZE, PR_UINT32_MAX, null);
+      let storageOutStream = storageStream.getOutputStream(0);
+
+      let cleanup = function () {
+        nativeInputStream.close();
+        storageStream.close();
+        storageOutStream.close();
+        entry.close();
+      }
+
+      gNetUtil.asyncCopy(nativeInputStream, storageOutStream, function (result) {
+        // cancel if parent window has already been closed
+        if (typeof UI == "undefined") {
+          cleanup();
+          return;
+        }
+
+        let imageData = null;
+        let isSuccess = Components.isSuccessCode(result);
+
+        if (isSuccess) {
+          let storageInStream = storageStream.newInputStream(0);
+          imageData = gNetUtil.readInputStreamToString(storageInStream,
+            storageInStream.available());
+          storageInStream.close();
+        }
+
+        cleanup();
+        callback(isSuccess, imageData);
+      });
+    }
+
+    let onCacheEntryUnavailable = function () {
+      callback(false);
+    }
+
+    this._openCacheEntry(url, Ci.nsICache.ACCESS_READ,
+        onCacheEntryAvailable, onCacheEntryUnavailable);
+  },
+
+  // ----------
   // Function: saveTab
   // Saves the data for a single tab.
   saveTab: function Storage_saveTab(tab, data) {
     Utils.assert(tab, "tab");
 
+    if (data != null) {
+      let imageData = data.imageData;
+      // Remove imageData from payload
+      delete data.imageData;
+      if (imageData != null) {
+        this.saveThumbnail(data.url, imageData, function (status) {
+          if (status) {
+            // Notify subscribers
+            tab._tabViewTabItem._sendToSubscribers("savedCachedImageData");
+          } else {
+            Utils.log("Error while saving thumbnail: " + e);
+          }
+        });
+      }
+    }
+
     this._sessionStore.setTabValue(tab, this.TAB_DATA_IDENTIFIER,
       JSON.stringify(data));
-
-    // Notify subscribers
-    if (data && data.imageData && tab._tabViewTabItem)
-      tab._tabViewTabItem._sendToSubscribers("savedImageData");
   },
 
   // ----------
   // Function: getTabData
-  // Returns the data object associated with a single tab.
-  getTabData: function Storage_getTabData(tab) {
+  // Load tab data from session store and return it. Asynchrously loads the tab's
+  // thumbnail from the cache and calls <callback>(imageData) when done.
+  getTabData: function Storage_getTabData(tab, callback) {
     Utils.assert(tab, "tab");
+    Utils.assert(typeof callback == "function", "callback arg must be a function");
 
-    var existingData = null;
+    let existingData = null;
+
     try {
-      var tabData = this._sessionStore.getTabValue(tab, this.TAB_DATA_IDENTIFIER);
+      let tabData = this._sessionStore.getTabValue(tab, this.TAB_DATA_IDENTIFIER);
       if (tabData != "") {
         existingData = JSON.parse(tabData);
       }
     } catch (e) {
-      // getWindowValue will fail if the property doesn't exist
+      // getTabValue will fail if the property doesn't exist.
       Utils.log(e);
     }
 
+    if (existingData) {
+      this.loadThumbnail(existingData.url, function (status, imageData) {
+        if (status) {
+          callback(imageData);
+
+          // Notify subscribers
+          tab._tabViewTabItem._sendToSubscribers("loadedCachedImageData");
+        } else {
+          Utils.log("Error while loading thumbnail");
+        }
+      });
+    }
+
     return existingData;
   },
 
   // ----------
   // Function: saveGroupItem
   // Saves the data for a single groupItem, associated with a specific window.
   saveGroupItem: function Storage_saveGroupItem(win, data) {
     var id = data.id;
@@ -219,8 +396,25 @@ let Storage = {
         existingData = JSON.parse(data);
     } catch (e) {
       Utils.log("Error in readData: "+e);
     }
 
     return existingData;
   }
 };
+
+// ##########
+// Class: CacheListener
+// Generic CacheListener for feeding to asynchronous cache calls.
+// Calls <callback>(entry, access, status) when the requested cache entry
+// is available.
+function CacheListener(callback) {
+  Utils.assert(typeof callback == "function", "callback arg must be a function");
+  this.callback = callback;
+};
+
+CacheListener.prototype = {
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsICacheListener]),
+  onCacheEntryAvailable: function (entry, access, status) {
+    this.callback(entry, access, status);
+  }
+};
--- a/browser/base/content/tabview/tabitems.js
+++ b/browser/base/content/tabview/tabitems.js
@@ -323,56 +323,65 @@ TabItem.prototype = Utils.extend(new Ite
   // ----------
   // Function: _reconnect
   // Load the reciever's persistent data from storage. If there is none, 
   // treats it as a new tab. 
   _reconnect: function TabItem__reconnect() {
     Utils.assertThrow(!this._reconnected, "shouldn't already be reconnected");
     Utils.assertThrow(this.tab, "should have a xul:tab");
 
-    let tabData = Storage.getTabData(this.tab);
+    let tabData = null;
+    let self = this;
+    let imageDataCb = function(imageData) {
+      Utils.assertThrow(tabData, "tabData");
+      
+      tabData.imageData = imageData;
+
+      let currentUrl = self.tab.linkedBrowser.currentURI.spec;
+      // If we have a cached image, then show it if the loaded URL matches
+      // what the cache is from, OR the loaded URL is blank, which means
+      // that the page hasn't loaded yet.
+      if (tabData.imageData &&
+          (tabData.url == currentUrl || currentUrl == 'about:blank')) {
+        self.showCachedData(tabData);
+      }
+    };
+    // getTabData returns the sessionstore contents, but passes
+    // a callback to run when the thumbnail is finally loaded.
+    tabData = Storage.getTabData(this.tab, imageDataCb);
     if (tabData && TabItems.storageSanity(tabData)) {
-      if (this.parent)
-        this.parent.remove(this, {immediately: true});
+      if (self.parent)
+        self.parent.remove(self, {immediately: true});
 
-      this.setBounds(tabData.bounds, true);
+      self.setBounds(tabData.bounds, true);
 
       if (Utils.isPoint(tabData.userSize))
-        this.userSize = new Point(tabData.userSize);
+        self.userSize = new Point(tabData.userSize);
 
       if (tabData.groupID) {
         var groupItem = GroupItems.groupItem(tabData.groupID);
         if (groupItem) {
-          groupItem.add(this, {immediately: true});
+          groupItem.add(self, {immediately: true});
 
-          // if it matches the selected tab or no active tab and the browser 
+          // if it matches the selected tab or no active tab and the browser
           // tab is hidden, the active group item would be set.
-          if (this.tab == gBrowser.selectedTab || 
-              (!GroupItems.getActiveGroupItem() && !this.tab.hidden))
-            GroupItems.setActiveGroupItem(this.parent);
+          if (self.tab == gBrowser.selectedTab ||
+              (!GroupItems.getActiveGroupItem() && !self.tab.hidden))
+            GroupItems.setActiveGroupItem(self.parent);
         }
       }
-
-      let currentUrl = this.tab.linkedBrowser.currentURI.spec;
-
-      // If we have a cached image, then show it if the loaded URL matches
-      // what the cache is from, OR the loaded URL is blank, which means
-      // that the page hasn't loaded yet.
-      if (tabData.imageData && (tabData.url == currentUrl ||
-        currentUrl == 'about:blank'))
-        this.showCachedData(tabData);
     } else {
       // create tab by double click is handled in UI_init().
       if (!TabItems.creatingNewOrphanTab)
-        GroupItems.newTab(this, {immediately: true});
+        GroupItems.newTab(self, {immediately: true});
     }
 
-    this._reconnected = true;  
-    this.save();
-    this._sendToSubscribers("reconnected");
+    self._reconnected = true;
+    self.save();
+    self._sendToSubscribers("reconnected");
   },
   
   // ----------
   // Function: setHidden
   // Hide/unhide this item
   setHidden: function TabItem_setHidden(val) {
     if (val)
       this.addClass("tabHidden");
@@ -527,18 +536,34 @@ TabItem.prototype = Utils.extend(new Ite
     this.zIndex = value;
     this.$container.css({zIndex: value});
   },
 
   // ----------
   // Function: close
   // Closes this item (actually closes the tab associated with it, which automatically
   // closes the item.
+  // Parameters:
+  //   groupClose - true if this method is called by group close action.
   // Returns true if this tab is removed.
-  close: function TabItem_close() {
+  close: function TabItem_close(groupClose) {
+    // When the last tab is closed, put a new tab into closing tab's group. If
+    // closing tab doesn't belong to a group and no empty group, create a new 
+    // one for the new tab.
+    if (!groupClose && gBrowser.tabs.length == 1) {
+      if (this.tab._tabViewTabItem.parent) {
+        group = this.tab._tabViewTabItem.parent;
+      } else {
+        let emptyGroups = GroupItems.groupItems.filter(function (groupItem) {
+          return (!groupItem.getChildren().length);
+        });
+        group = (emptyGroups.length ? emptyGroups[0] : GroupItems.newGroup());
+      }
+      group.newTab();
+    }
     // when "TabClose" event is fired, the browser tab is about to close and our 
     // item "close" is fired before the browser tab actually get closed. 
     // Therefore, we need "tabRemoved" event below.
     gBrowser.removeTab(this.tab);
     let tabNotClosed = 
       Array.some(gBrowser.tabs, function(tab) { return tab == this.tab; }, this);
     if (!tabNotClosed)
       this._sendToSubscribers("tabRemoved");
@@ -614,18 +639,17 @@ TabItem.prototype = Utils.extend(new Ite
 
     UI.setActiveTab(this);
     if (this.parent) {
       GroupItems.setActiveGroupItem(this.parent);
     } else {
       GroupItems.setActiveOrphanTab(this);
     }
 
-    this.shouldHideCachedData = true;
-    TabItems._update(this.tab);
+    TabItems._update(this.tab, {force: true});
 
     // Zoom in!
     let tab = this.tab;
 
     function onZoomDone() {
       $canvas.css({ '-moz-transform': null });
       $tabEl.removeClass("front");
 
@@ -683,21 +707,25 @@ TabItem.prototype = Utils.extend(new Ite
       $canvas.css("-moz-transform", null);
 
       GroupItems.setActiveOrphanTab(null);
 
       if (typeof complete == "function")
         complete();
     };
 
-    this.shouldHideCachedData = true;
-    TabItems._update(this.tab);
+    TabItems._update(this.tab, {force: true});
 
     $tab.addClass("front");
 
+    // If we're in a stacked group, make sure we become the
+    // topChild now so that we show the zoom animation correctly.
+    if (this.parent && this.parent.isStacked())
+      this.parent.setTopChild(this);
+
     let animateZoom = gPrefBranch.getBoolPref("animate_zoom");
     if (animateZoom) {
       // The scaleCheat of 2 here is a clever way to speed up the zoom-out
       // code. See getZoomTransform() below.
       let transform = this.getZoomTransform(2);
       TabItems.pausePainting();
 
       $canvas.css({
@@ -924,17 +952,24 @@ let TabItems = {
     } catch(e) {
       Utils.log(e);
     }
   },
 
   // ----------
   // Function: _update
   // Takes in a xul:tab.
-  _update: function TabItems__update(tab) {
+  //
+  // Parameters:
+  //   tab - a xul tab to update
+  //   options - an object with additional parameters, see below
+  //
+  // Possible options:
+  //   force - true to always update the tab item even if it's incomplete
+  _update: function TabItems__update(tab, options) {
     try {
       if (this._pauseUpdateForTest)
         return;
 
       Utils.assertThrow(tab, "tab");
 
       // ___ get the TabItem
       Utils.assertThrow(tab._tabViewTabItem, "must already be linked");
@@ -972,17 +1007,17 @@ let TabItems = {
       let tabUrl = tab.linkedBrowser.currentURI.spec;
       if (tabUrl != tabItem.url) {
         let oldURL = tabItem.url;
         tabItem.url = tabUrl;
         tabItem.save();
       }
 
       // ___ Make sure the tab is complete and ready for updating.
-      if (!this.isComplete(tab)) {
+      if (!this.isComplete(tab) && (!options || !options.force)) {
         // If it's incomplete, stick it on the end of the queue
         this._tabsWaitingForUpdate.push(tab);
         return;
       }
 
       // ___ thumbnail
       let $canvas = tabItem.$canvas;
       if (!tabItem.canvasSizeForced) {
--- a/browser/base/content/tabview/tabview.js
+++ b/browser/base/content/tabview/tabview.js
@@ -18,16 +18,22 @@ XPCOMUtils.defineLazyGetter(this, "gPref
   return Services.prefs.getBranch("browser.panorama.");
 });
 
 XPCOMUtils.defineLazyGetter(this, "gPrivateBrowsing", function() {
   return Cc["@mozilla.org/privatebrowsing;1"].
            getService(Ci.nsIPrivateBrowsingService);
 });
 
+XPCOMUtils.defineLazyGetter(this, "gNetUtil", function() {
+  var obj = {};
+  Cu.import("resource://gre/modules/NetUtil.jsm", obj);
+  return obj.NetUtil;
+});
+
 var gWindow = window.parent;
 var gBrowser = gWindow.gBrowser;
 var gTabView = gWindow.TabView;
 var gTabViewDeck = gWindow.document.getElementById("tab-view-deck");
 var gTabViewFrame = gWindow.document.getElementById("tab-view");
 
 # NB: Certain files need to evaluate before others
 
--- a/browser/base/content/tabview/ui.js
+++ b/browser/base/content/tabview/ui.js
@@ -122,16 +122,21 @@ let UI = {
     transitionMode: "",
     wasInTabView: false 
   },
   
   // Variable: _storageBusyCount
   // Used to keep track of how many calls to storageBusy vs storageReady.
   _storageBusyCount: 0,
 
+  // Variable: isDOMWindowClosing
+  // Tells wether we already received the "domwindowclosed" event and the parent
+  // windows is about to close.
+  isDOMWindowClosing: false,
+
   // ----------
   // Function: init
   // Must be called after the object is created.
   init: function UI_init() {
     try {
       let self = this;
 
       // initialize the direction of the page
@@ -236,16 +241,17 @@ let UI = {
 
       iQ(window).resize(function() {
         self._resize();
       });
 
       // ___ setup observer to save canvas images
       function domWinClosedObserver(subject, topic, data) {
         if (topic == "domwindowclosed" && subject == gWindow) {
+          self.isDOMWindowClosing = true;
           if (self.isTabViewVisible())
             GroupItems.removeHiddenGroups();
           TabItems.saveAll(true);
           self._save();
         }
       }
       Services.obs.addObserver(
         domWinClosedObserver, "domwindowclosed", false);
@@ -1021,16 +1027,20 @@ let UI = {
           }
         }
         event.stopPropagation();
         event.preventDefault();
       } else if (event.keyCode == KeyEvent.DOM_VK_SLASH) {
         // the / event handler for find bar is defined in the findbar.xml
         // binding.  To keep things in its own module, we handle our slash here.
         self.enableSearch(event);
+      } else if (event.keyCode == KeyEvent.DOM_VK_BACK_SPACE) {
+        // prevent navigating backward in the selected tab's history
+        event.stopPropagation();
+        event.preventDefault();
       }
     });
   },
 
   // ----------
   // Function: enableSearch
   // Enables the search feature.
   // Parameters:
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -165,17 +165,17 @@ endif
                  browser_bug596687.js \
                  browser_bug597218.js \
                  browser_bug598923.js \
                  browser_bug599325.js \
                  browser_bug609700.js \
                  browser_bug616836.js \
                  browser_bug623893.js \
                  browser_bug624734.js \
-                 browser_bug628179.js \
+                 browser_findbarClose.js \
                  browser_contextSearchTabPosition.js \
                  browser_ctrlTab.js \
                  browser_customize_popupNotification.js \
                  browser_disablechrome.js \
                  browser_discovery.js \
                  browser_duplicateIDs.js \
                  browser_gestureSupport.js \
                  browser_getshortcutoruri.js \
@@ -253,16 +253,17 @@ endif
 #                 browser_popupUI.js \
 
 ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 _BROWSER_FILES += \
 		browser_bug462289.js \
 		$(NULL)
 else
 _BROWSER_FILES += \
+		browser_bug565667.js \
 		browser_customize.js \
 		$(NULL)
 
 # TODO: Activate after carbon test plugin lands, bug 628651
 # 		browser_maconly_carbon_mismatch_plugin.js \
 
 endif
 
--- a/browser/base/content/test/browser_bug553455.js
+++ b/browser/base/content/test/browser_bug553455.js
@@ -16,24 +16,34 @@ var jar = getJar(croot);
 if (jar) {
   var tmpdir = extractJarToTmp(jar);
   croot = 'file://' + tmpdir.path + '/';
 }
 const CHROMEROOT = croot;
 
 var gApp = document.getElementById("bundle_brand").getString("brandShortName");
 var gVersion = Services.appinfo.version;
+var check_notification;
 
 function wait_for_notification(aCallback) {
   info("Waiting for notification");
-  PopupNotifications.panel.addEventListener("popupshown", function() {
-    PopupNotifications.panel.removeEventListener("popupshown", arguments.callee, false);
+  check_notification = function() {
+    PopupNotifications.panel.removeEventListener("popupshown", check_notification, false);
     info("Saw notification");
     is(PopupNotifications.panel.childNodes.length, 1, "Should be only one notification");
     aCallback(PopupNotifications.panel);
+  };
+  PopupNotifications.panel.addEventListener("popupshown", check_notification, false);
+}
+
+function wait_for_notification_close(aCallback) {
+  info("Waiting for notification to close");
+  PopupNotifications.panel.addEventListener("popuphidden", function() {
+    PopupNotifications.panel.removeEventListener("popuphidden", arguments.callee, false);
+    aCallback();
   }, false);
 }
 
 function wait_for_install_dialog(aCallback) {
   info("Waiting for install dialog");
   Services.wm.addListener({
     onOpenWindow: function(aXULWindow) {
       info("Install dialog opened, waiting for focus");
@@ -79,35 +89,37 @@ function test_disabled_install() {
   // Wait for the disabled notification
   wait_for_notification(function(aPanel) {
     let notification = aPanel.childNodes[0];
     is(notification.id, "xpinstall-disabled-notification", "Should have seen installs disabled");
     is(notification.button.label, "Enable", "Should have seen the right button");
     is(notification.getAttribute("label"),
        "Software installation is currently disabled. Click Enable and try again.");
 
+    wait_for_notification_close(function() {
+      try {
+        Services.prefs.getBoolPref("xpinstall.disabled");
+        ok(false, "xpinstall.disabled should not be set");
+      }
+      catch (e) {
+        ok(true, "xpinstall.disabled should not be set");
+      }
+
+      gBrowser.removeTab(gBrowser.selectedTab);
+
+      AddonManager.getAllInstalls(function(aInstalls) {
+        is(aInstalls.length, 1, "Should have been one install created");
+        aInstalls[0].cancel();
+
+        runNextTest();
+      });
+    });
+
     // Click on Enable
     EventUtils.synthesizeMouseAtCenter(notification.button, {});
-
-    try {
-      Services.prefs.getBoolPref("xpinstall.disabled");
-      ok(false, "xpinstall.disabled should not be set");
-    }
-    catch (e) {
-      ok(true, "xpinstall.disabled should not be set");
-    }
-
-    gBrowser.removeTab(gBrowser.selectedTab);
-
-    AddonManager.getAllInstalls(function(aInstalls) {
-      is(aInstalls.length, 1, "Should have been one install created");
-      aInstalls[0].cancel();
-
-      runNextTest();
-    });
   });
 
   var triggers = encodeURIComponent(JSON.stringify({
     "XPI": "unsigned.xpi"
   }));
   gBrowser.selectedTab = gBrowser.addTab();
   gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
 },
@@ -133,18 +145,18 @@ function test_blocked_install() {
         is(notification.getAttribute("label"),
            "XPI Test will be installed after you restart " + gApp + ".",
            "Should have seen the right message");
 
         AddonManager.getAllInstalls(function(aInstalls) {
         is(aInstalls.length, 1, "Should be one pending install");
           aInstalls[0].cancel();
 
+          wait_for_notification_close(runNextTest);
           gBrowser.removeTab(gBrowser.selectedTab);
-          runNextTest();
         });
       });
 
       aWindow.document.documentElement.acceptDialog();
     });
 
     // Click on Allow
     EventUtils.synthesizeMouse(notification.button, 20, 10, {});
@@ -179,19 +191,19 @@ function test_whitelisted_install() {
         is(notification.getAttribute("label"),
            "XPI Test will be installed after you restart " + gApp + ".",
            "Should have seen the right message");
 
         AddonManager.getAllInstalls(function(aInstalls) {
           is(aInstalls.length, 1, "Should be one pending install");
           aInstalls[0].cancel();
 
+          Services.perms.remove("example.com", "install");
+          wait_for_notification_close(runNextTest);
           gBrowser.removeTab(gBrowser.selectedTab);
-          Services.perms.remove("example.com", "install");
-          runNextTest();
         });
       });
 
       aWindow.document.documentElement.acceptDialog();
     });
   });
 
   var pm = Services.perms;
@@ -214,19 +226,19 @@ function test_failed_download() {
     wait_for_notification(function(aPanel) {
       let notification = aPanel.childNodes[0];
       is(notification.id, "addon-install-failed-notification", "Should have seen the install fail");
       is(notification.getAttribute("label"),
          "The add-on could not be downloaded because of a connection failure " +
          "on example.com.",
          "Should have seen the right message");
 
+      Services.perms.remove("example.com", "install");
+      wait_for_notification_close(runNextTest);
       gBrowser.removeTab(gBrowser.selectedTab);
-      Services.perms.remove("example.com", "install");
-      runNextTest();
     });
   });
 
   var pm = Services.perms;
   pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
 
   var triggers = encodeURIComponent(JSON.stringify({
     "XPI": "missing.xpi"
@@ -245,19 +257,19 @@ function test_corrupt_file() {
     wait_for_notification(function(aPanel) {
       let notification = aPanel.childNodes[0];
       is(notification.id, "addon-install-failed-notification", "Should have seen the install fail");
       is(notification.getAttribute("label"),
          "The add-on downloaded from example.com could not be installed " +
          "because it appears to be corrupt.",
          "Should have seen the right message");
 
+      Services.perms.remove("example.com", "install");
+      wait_for_notification_close(runNextTest);
       gBrowser.removeTab(gBrowser.selectedTab);
-      Services.perms.remove("example.com", "install");
-      runNextTest();
     });
   });
 
   var pm = Services.perms;
   pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
 
   var triggers = encodeURIComponent(JSON.stringify({
     "XPI": "corrupt.xpi"
@@ -276,19 +288,19 @@ function test_incompatible() {
     wait_for_notification(function(aPanel) {
       let notification = aPanel.childNodes[0];
       is(notification.id, "addon-install-failed-notification", "Should have seen the install fail");
       is(notification.getAttribute("label"),
          "XPI Test could not be installed because it is not compatible with " +
          gApp + " " + gVersion + ".",
          "Should have seen the right message");
 
+      Services.perms.remove("example.com", "install");
+      wait_for_notification_close(runNextTest);
       gBrowser.removeTab(gBrowser.selectedTab);
-      Services.perms.remove("example.com", "install");
-      runNextTest();
     });
   });
 
   var pm = Services.perms;
   pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
 
   var triggers = encodeURIComponent(JSON.stringify({
     "XPI": "incompatible.xpi"
@@ -315,19 +327,19 @@ function test_restartless() {
            "Should have seen the right message");
 
         AddonManager.getAllInstalls(function(aInstalls) {
           is(aInstalls.length, 0, "Should be no pending installs");
 
           AddonManager.getAddonByID("restartless-xpi@tests.mozilla.org", function(aAddon) {
             aAddon.uninstall();
 
+            Services.perms.remove("example.com", "install");
+            wait_for_notification_close(runNextTest);
             gBrowser.removeTab(gBrowser.selectedTab);
-            Services.perms.remove("example.com", "install");
-            runNextTest();
           });
         });
       });
 
       aWindow.document.documentElement.acceptDialog();
     });
   });
 
@@ -360,19 +372,19 @@ function test_multiple() {
 
         AddonManager.getAllInstalls(function(aInstalls) {
           is(aInstalls.length, 1, "Should be one pending install");
           aInstalls[0].cancel();
 
           AddonManager.getAddonByID("restartless-xpi@tests.mozilla.org", function(aAddon) {
             aAddon.uninstall();
 
+            Services.perms.remove("example.com", "install");
+            wait_for_notification_close(runNextTest);
             gBrowser.removeTab(gBrowser.selectedTab);
-            Services.perms.remove("example.com", "install");
-            runNextTest();
           });
         });
       });
 
       aWindow.document.documentElement.acceptDialog();
     });
   });
 
@@ -403,41 +415,46 @@ function test_url() {
         is(notification.getAttribute("label"),
            "XPI Test will be installed after you restart " + gApp + ".",
            "Should have seen the right message");
 
         AddonManager.getAllInstalls(function(aInstalls) {
           is(aInstalls.length, 1, "Should be one pending install");
           aInstalls[0].cancel();
 
+          wait_for_notification_close(runNextTest);
           gBrowser.removeTab(gBrowser.selectedTab);
-          runNextTest();
         });
       });
 
       aWindow.document.documentElement.acceptDialog();
     });
   });
 
   gBrowser.selectedTab = gBrowser.addTab();
   gBrowser.loadURI(TESTROOT + "unsigned.xpi");
 },
 
 function test_localfile() {
-  // Wait for the complete notification
-  wait_for_notification(function(aPanel) {
-    let notification = aPanel.childNodes[0];
-    is(notification.id, "addon-install-failed-notification", "Should have seen the install fail");
-    is(notification.getAttribute("label"),
-       "This add-on could not be installed because it appears to be corrupt.",
-       "Should have seen the right message");
+  // Wait for the install to fail
+  Services.obs.addObserver(function() {
+    Services.obs.removeObserver(arguments.callee, "addon-install-failed");
 
-    gBrowser.removeTab(gBrowser.selectedTab);
-    runNextTest();
-  });
+    // Wait for the browser code to add the failure notification
+    executeSoon(function() {
+      let notification = PopupNotifications.panel.childNodes[0];
+      is(notification.id, "addon-install-failed-notification", "Should have seen the install fail");
+      is(notification.getAttribute("label"),
+         "This add-on could not be installed because it appears to be corrupt.",
+         "Should have seen the right message");
+
+      wait_for_notification_close(runNextTest);
+      gBrowser.removeTab(gBrowser.selectedTab);
+    });
+  }, "addon-install-failed", false);
 
   var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
                      .getService(Components.interfaces.nsIChromeRegistry);
   try {
     var path = cr.convertChromeURL(makeURI(CHROMEROOT + "corrupt.xpi")).spec;
   } catch (ex) {
     var path = CHROMEROOT + "corrupt.xpi";
   }
@@ -461,18 +478,18 @@ function test_wronghost() {
       wait_for_notification(function(aPanel) {
         let notification = aPanel.childNodes[0];
         is(notification.id, "addon-install-failed-notification", "Should have seen the install fail");
         is(notification.getAttribute("label"),
            "The add-on downloaded from example.com could not be installed " +
            "because it appears to be corrupt.",
            "Should have seen the right message");
 
+        wait_for_notification_close(runNextTest);
         gBrowser.removeTab(gBrowser.selectedTab);
-        runNextTest();
       });
     });
 
     gBrowser.loadURI(TESTROOT + "corrupt.xpi");
   }, true);
   gBrowser.loadURI(TESTROOT2 + "enabled.html");
 },
 
@@ -506,19 +523,19 @@ function test_reload() {
           gBrowser.removeEventListener("load", arguments.callee, true);
 
           PopupNotifications.panel.removeEventListener("popuphiding", test_fail, false);
 
           AddonManager.getAllInstalls(function(aInstalls) {
             is(aInstalls.length, 1, "Should be one pending install");
             aInstalls[0].cancel();
 
+            Services.perms.remove("example.com", "install");
+            wait_for_notification_close(runNextTest);
             gBrowser.removeTab(gBrowser.selectedTab);
-            Services.perms.remove("example.com", "install");
-            runNextTest();
           });
         }, true);
         gBrowser.loadURI(TESTROOT2 + "enabled.html");
       });
 
       aWindow.document.documentElement.acceptDialog();
     });
   });
@@ -545,30 +562,28 @@ function test_theme() {
       wait_for_notification(function(aPanel) {
         let notification = aPanel.childNodes[0];
         is(notification.id, "addon-install-complete-notification", "Should have seen the install complete");
         is(notification.button.label, "Restart Now", "Should have seen the right button");
         is(notification.getAttribute("label"),
            "Theme Test will be installed after you restart " + gApp + ".",
            "Should have seen the right message");
 
-        gBrowser.removeTab(gBrowser.selectedTab);
-        Services.perms.remove("example.com", "install");
-
         AddonManager.getAddonByID("{972ce4c6-7e08-4474-a285-3208198ce6fd}", function(aAddon) {
           ok(aAddon.userDisabled, "Should be switching away from the default theme.");
           // Undo the pending theme switch
           aAddon.userDisabled = false;
 
           AddonManager.getAddonByID("theme-xpi@tests.mozilla.org", function(aAddon) {
             isnot(aAddon, null, "Test theme will have been installed");
             aAddon.uninstall();
 
             Services.perms.remove("example.com", "install");
-            runNextTest();
+            wait_for_notification_close(runNextTest);
+            gBrowser.removeTab(gBrowser.selectedTab);
           });
         });
       });
 
       aWindow.document.documentElement.acceptDialog();
     });
   });
 
@@ -583,39 +598,38 @@ function test_theme() {
 },
 
 function test_renotify_blocked() {
   // Wait for the blocked notification
   wait_for_notification(function(aPanel) {
     let notification = aPanel.childNodes[0];
     is(notification.id, "addon-install-blocked-notification", "Should have seen the install blocked");
 
-    aPanel.addEventListener("popuphidden", function () {
-      aPanel.removeEventListener("popuphidden", arguments.callee, false);
+    wait_for_notification_close(function () {
       info("Timeouts after this probably mean bug 589954 regressed");
       executeSoon(function () {
         wait_for_notification(function(aPanel) {
           let notification = aPanel.childNodes[0];
           is(notification.id, "addon-install-blocked-notification",
              "Should have seen the install blocked - 2nd time");
 
           AddonManager.getAllInstalls(function(aInstalls) {
           is(aInstalls.length, 2, "Should be two pending installs");
             aInstalls[0].cancel();
             aInstalls[1].cancel();
 
             info("Closing browser tab");
+            wait_for_notification_close(runNextTest);
             gBrowser.removeTab(gBrowser.selectedTab);
-            runNextTest();
           });
         });
 
         gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
       });
-    }, false);
+    });
 
     // hide the panel (this simulates the user dismissing it)
     aPanel.hidePopup();
   });
 
   var triggers = encodeURIComponent(JSON.stringify({
     "XPI": "unsigned.xpi"
   }));
@@ -632,19 +646,17 @@ function test_renotify_installed() {
     // Wait for the install confirmation dialog
     wait_for_install_dialog(function(aWindow) {
       // Wait for the complete notification
       wait_for_notification(function(aPanel) {
         let notification = aPanel.childNodes[0];
         is(notification.id, "addon-install-complete-notification", "Should have seen the install complete");
 
         // Dismiss the notification
-        aPanel.addEventListener("popuphidden", function () {
-          aPanel.removeEventListener("popuphidden", arguments.callee, false);
-
+        wait_for_notification_close(function () {
           // Install another
           executeSoon(function () {
             // Wait for the progress notification
             wait_for_notification(function(aPanel) {
               let notification = aPanel.childNodes[0];
               is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
 
               // Wait for the install confirmation dialog
@@ -655,29 +667,29 @@ function test_renotify_installed() {
                 wait_for_notification(function(aPanel) {
                   let notification = aPanel.childNodes[0];
                   is(notification.id, "addon-install-complete-notification", "Should have seen the second install complete");
 
                   AddonManager.getAllInstalls(function(aInstalls) {
                   is(aInstalls.length, 1, "Should be one pending installs");
                     aInstalls[0].cancel();
 
+                    Services.perms.remove("example.com", "install");
+                    wait_for_notification_close(runNextTest);
                     gBrowser.removeTab(gBrowser.selectedTab);
-                    Services.perms.remove("example.com", "install");
-                    runNextTest();
                   });
                 });
 
                 aWindow.document.documentElement.acceptDialog();
               });
             });
 
             gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
           });
-        }, false);
+        });
 
         // hide the panel (this simulates the user dismissing it)
         aPanel.hidePopup();
       });
 
       aWindow.document.documentElement.acceptDialog();
     });
   });
@@ -730,19 +742,19 @@ function test_cancel_restart() {
           is(notification.getAttribute("label"),
              "XPI Test will be installed after you restart " + gApp + ".",
              "Should have seen the right message");
 
           AddonManager.getAllInstalls(function(aInstalls) {
             is(aInstalls.length, 1, "Should be one pending install");
             aInstalls[0].cancel();
 
+            Services.perms.remove("example.com", "install");
+            wait_for_notification_close(runNextTest);
             gBrowser.removeTab(gBrowser.selectedTab);
-            Services.perms.remove("example.com", "install");
-            runNextTest();
           });
         });
 
         aWindow.document.documentElement.acceptDialog();
       });
 
       // Restart the download
       EventUtils.synthesizeMouse(notification.button, 20, 10, {});
@@ -786,30 +798,36 @@ function test_failed_security() {
     is(PopupNotifications.panel.childNodes.length, 1, "Should be only one notification");
     notification = aPanel.childNodes[0];
     is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
 
     // Wait for it to fail
     Services.obs.addObserver(function() {
       Services.obs.removeObserver(arguments.callee, "addon-install-failed");
 
-      // Wait for the browser code to add the failure notification
-      executeSoon(function() {
-        // Wait for the progress notification to dismiss itself
-        executeSoon(function() {
-          ok(PopupNotifications.isPanelOpen, "Notification should still be open");
-          is(PopupNotifications.panel.childNodes.length, 1, "Should be only one notification");
-          notification = aPanel.childNodes[0];
-          is(notification.id, "addon-install-failed-notification", "Should have seen the install fail");
+      function waitForSingleNotification() {
+        // Notification should never close while we wait
+        ok(PopupNotifications.isPanelOpen, "Notification should still be open");
+        if (PopupNotifications.panel.childNodes.length == 2) {
+          executeSoon(waitForSingleNotification);
+          return;
+        }
 
-          gBrowser.removeTab(gBrowser.selectedTab);
-          Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, true);
-          runNextTest();
-        });
-      });
+        is(PopupNotifications.panel.childNodes.length, 1, "Should be only one notification");
+        notification = aPanel.childNodes[0];
+        is(notification.id, "addon-install-failed-notification", "Should have seen the install fail");
+
+        Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, true);
+        wait_for_notification_close(runNextTest);
+        gBrowser.removeTab(gBrowser.selectedTab);
+      }
+
+      // Allow the browser code to add the failure notification and then wait
+      // for the progress notification to dismiss itself
+      executeSoon(waitForSingleNotification);
     }, "addon-install-failed", false);
   });
 
   var triggers = encodeURIComponent(JSON.stringify({
     "XPI": "redirect.sjs?mode=redirect"
   }));
   gBrowser.selectedTab = gBrowser.addTab();
   gBrowser.loadURI(SECUREROOT + "installtrigger.html?" + triggers);
@@ -817,16 +835,18 @@ function test_failed_security() {
 ];
 
 var gTestStart = null;
 
 function runNextTest() {
   if (gTestStart)
     info("Test part took " + (Date.now() - gTestStart) + "ms");
 
+  ok(!PopupNotifications.isPanelOpen, "Notification should be closed");
+
   AddonManager.getAllInstalls(function(aInstalls) {
     is(aInstalls.length, 0, "Should be no active installs");
 
     if (TESTS.length == 0) {
       finish();
       return;
     }
 
@@ -855,16 +875,17 @@ function test() {
   Services.obs.addObserver(XPInstallObserver, "addon-install-started", false);
   Services.obs.addObserver(XPInstallObserver, "addon-install-blocked", false);
   Services.obs.addObserver(XPInstallObserver, "addon-install-failed", false);
   Services.obs.addObserver(XPInstallObserver, "addon-install-complete", false);
 
   registerCleanupFunction(function() {
     // Make sure no more test parts run in case we were timed out
     TESTS = [];
+    PopupNotifications.panel.removeEventListener("popupshown", check_notification, false);
 
     AddonManager.getAllInstalls(function(aInstalls) {
       aInstalls.forEach(function(aInstall) {
         aInstall.cancel();
       });
     });
 
     Services.prefs.clearUserPref("extensions.logging.enabled");
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/browser_bug565667.js
@@ -0,0 +1,92 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is bug 565667 test.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Paul O’Shannessy <paul@oshannessy.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
+
+function test() {
+  waitForExplicitFinish();
+  // Open the javascript console. It has the mac menu overlay, so browser.js is
+  // loaded in it.
+  let consoleWin = window.open("chrome://global/content/console.xul", "_blank",
+                               "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
+  testWithOpenWindow(consoleWin);
+}
+
+function testWithOpenWindow(consoleWin) {
+  // Add a tab so we don't open the url into the current tab
+  let newTab = gBrowser.addTab("http://example.com");
+  gBrowser.selectedTab = newTab;
+
+  let numTabs = gBrowser.tabs.length;
+
+  waitForFocus(function() {
+    // Sanity check
+    is(fm.activeWindow, consoleWin,
+       "the console window is focused");
+
+    gBrowser.tabContainer.addEventListener("TabOpen", function(aEvent) {
+      gBrowser.tabContainer.removeEventListener("TabOpen", arguments.callee, true);
+      let browser = aEvent.originalTarget.linkedBrowser;
+      browser.addEventListener("pageshow", function(event) {
+        if (event.target.location.href != "about:addons")
+          return;
+        browser.removeEventListener("pageshow", arguments.callee, true);
+
+        is(fm.activeWindow, window,
+           "the browser window was focused");
+        is(browser.currentURI.spec, "about:addons",
+           "about:addons was loaded in the window");
+        is(gBrowser.tabs.length, numTabs + 1,
+           "a new tab was added");
+
+        // Cleanup.
+        executeSoon(function() {
+          consoleWin.close();
+          gBrowser.removeTab(gBrowser.selectedTab);
+          gBrowser.removeTab(newTab);
+          finish();
+        });
+      }, true);
+    }, true);
+
+    // Open the addons manager, uses switchToTabHavingURI.
+    consoleWin.BrowserOpenAddonsMgr();
+  }, consoleWin);
+}
+
+// Ideally we'd also check that the case for no open windows works, but we can't
+// due to limitations with the testing framework.
--- a/browser/base/content/test/browser_disablechrome.js
+++ b/browser/base/content/test/browser_disablechrome.js
@@ -39,26 +39,35 @@ function load_page(aURL, aCanHide, aCall
     gNewBrowser.removeEventListener("pageshow", arguments.callee, false);
 
     if (aCanHide)
       is_chrome_hidden();
     else
       is_chrome_visible();
 
     if (aURL == "about:addons") {
-      gNewBrowser.contentDocument.addEventListener("Initialized", function() {
-        gNewBrowser.contentDocument.removeEventListener("Initialized", arguments.callee, false);
-
+      function check_after_init() {
         if (aCanHide)
           is_chrome_hidden();
         else
           is_chrome_visible();
 
         aCallback();
-      }, false);
+      }
+
+      if (gNewBrowser.contentWindow.gIsInitializing) {
+        gNewBrowser.contentDocument.addEventListener("Initialized", function() {
+          gNewBrowser.contentDocument.removeEventListener("Initialized", arguments.callee, false);
+
+          check_after_init();
+        }, false);
+      }
+      else {
+        check_after_init();
+      }
     }
     else {
       executeSoon(aCallback);
     }
   }, false);
   gNewBrowser.loadURI(aURL);
 }
 
rename from browser/base/content/test/browser_bug628179.js
rename to browser/base/content/test/browser_findbarClose.js
--- a/browser/base/content/test/browser_bug628179.js
+++ b/browser/base/content/test/browser_findbarClose.js
@@ -1,44 +1,18 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-// Tests that the Find bar goes away on tab switch or location change.
+// Tests find bar auto-close behavior
 
 let newTab, iframe;
 
 function test() {
   waitForExplicitFinish();
   newTab = gBrowser.addTab("about:blank");
-  gBrowser.addEventListener("DOMContentLoaded", testFindBarCloseOnTabSwitch,
-                            false);
-}
-
-function testFindBarCloseOnTabSwitch() {
-  gBrowser.removeEventListener("DOMContentLoaded", testFindBarCloseOnTabSwitch,
-                               false);
-
-  gFindBar.open();
-  gBrowser.selectedTab = newTab;
-  ok(gFindBar.hidden, "the Find bar is hidden after switching tabs");
-
-  gFindBar.open();
-  newTab.linkedBrowser.addEventListener("DOMContentLoaded",
-                                        testFindBarCloseOnLocationChange,
-                                        false);
-  newTab.linkedBrowser.contentWindow.location = "http://example.com/";
-}
-
-function testFindBarCloseOnLocationChange() {
-  newTab.linkedBrowser.removeEventListener("DOMContentLoaded",
-                                           testFindBarCloseOnLocationChange,
-                                           false);
-
-  ok(gFindBar.hidden, "the Find bar is hidden after the location changes");
-
   newTab.linkedBrowser.addEventListener("DOMContentLoaded",
     prepareTestFindBarStaysOpenOnSubdocumentLocationChange, false);
   newTab.linkedBrowser.contentWindow.location = "http://example.com/browser/" +
     "browser/base/content/test/test_bug628179.html";
 }
 
 function prepareTestFindBarStaysOpenOnSubdocumentLocationChange() {
   newTab.linkedBrowser.removeEventListener("DOMContentLoaded",
--- a/browser/base/content/test/tabview/Makefile.in
+++ b/browser/base/content/test/tabview/Makefile.in
@@ -73,32 +73,34 @@ include $(topsrcdir)/config/rules.mk
                  browser_tabview_bug597399.js \
                  browser_tabview_bug597980.js \
                  browser_tabview_bug598600.js \
                  browser_tabview_bug599626.js \
                  browser_tabview_bug600645.js \
                  browser_tabview_bug600812.js \
                  browser_tabview_bug602432.js \
                  browser_tabview_bug604098.js \
+                 browser_tabview_bug604699.js \
                  browser_tabview_bug606657.js \
                  browser_tabview_bug606905.js \
                  browser_tabview_bug608037.js \
                  browser_tabview_bug608184.js \
                  browser_tabview_bug608158.js \
                  browser_tabview_bug608405.js \
                  browser_tabview_bug610242.js \
                  browser_tabview_bug612470.js \
                  browser_tabview_bug613541.js \
                  browser_tabview_bug616729.js \
                  browser_tabview_bug616967.js \
                  browser_tabview_bug618816.js \
                  browser_tabview_bug618828.js \
                  browser_tabview_bug619937.js \
                  browser_tabview_bug622835.js \
                  browser_tabview_bug622872.js \
+                 browser_tabview_bug623768.js \
                  browser_tabview_bug624265.js \
                  browser_tabview_bug624931.js \
                  browser_tabview_bug624727.js \
                  browser_tabview_bug624847.js \
                  browser_tabview_bug624953.js \
                  browser_tabview_bug625269.js \
                  browser_tabview_bug625424.js \
                  browser_tabview_bug626368.js \
@@ -108,18 +110,21 @@ include $(topsrcdir)/config/rules.mk
                  browser_tabview_bug627736.js \
                  browser_tabview_bug628165.js \
                  browser_tabview_bug628270.js \
                  browser_tabview_bug629189.js \
                  browser_tabview_bug629195.js \
                  browser_tabview_bug630102.js \
                  browser_tabview_bug630157.js \
                  browser_tabview_bug631662.js \
+                 browser_tabview_bug633788.js \
                  browser_tabview_bug634077.js \
+                 browser_tabview_bug634085.js \
                  browser_tabview_bug634158.js \
+                 browser_tabview_bug635696.js \
                  browser_tabview_dragdrop.js \
                  browser_tabview_exit_button.js \
                  browser_tabview_expander.js \
                  browser_tabview_group.js \
                  browser_tabview_launch.js \
                  browser_tabview_multiwindow_search.js \
                  browser_tabview_orphaned_tabs.js \
                  browser_tabview_privatebrowsing.js \
--- a/browser/base/content/test/tabview/browser_tabview_alltabs.js
+++ b/browser/base/content/test/tabview/browser_tabview_alltabs.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 595395.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 Cu.import("resource:///modules/tabview/AllTabs.jsm");
 
 function test() {
   waitForExplicitFinish();
 
   let newTab = gBrowser.addTab();
 
--- a/browser/base/content/test/tabview/browser_tabview_apptabs.js
+++ b/browser/base/content/test/tabview/browser_tabview_apptabs.js
@@ -1,45 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview app-tab test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- * Ian Gilman <ian@iangilman.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   TabView.toggle();
 }
 
--- a/browser/base/content/test/tabview/browser_tabview_bug580412.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug580412.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Tab View bug 580412 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   if (TabView.isVisible())
     onTabViewWindowLoaded();
   else
--- a/browser/base/content/test/tabview/browser_tabview_bug586553.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug586553.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview bug 586553 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   TabView.toggle();
 }
 
--- a/browser/base/content/test/tabview/browser_tabview_bug587043.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug587043.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 587043.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   TabView.toggle();
 }
 
--- a/browser/base/content/test/tabview/browser_tabview_bug587231.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug587231.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview drag and drop test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Sean Dunn <seanedunn@yahoo.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let activeTab;
 let testTab;
 let testGroup;
 let contentWindow;
 
 function test() {
   waitForExplicitFinish();
--- a/browser/base/content/test/tabview/browser_tabview_bug587351.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug587351.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 587351.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let newTab;
 
 function test() {
   waitForExplicitFinish();
 
   newTab = gBrowser.addTab();
 
--- a/browser/base/content/test/tabview/browser_tabview_bug587503.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug587503.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is bug 587503 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   newWindowWithTabView(onTabViewWindowLoaded);
 }
 
 function onTabViewWindowLoaded(win) {
--- a/browser/base/content/test/tabview/browser_tabview_bug587990.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug587990.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is bug 587990 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let newTab;
 let win;
 
 function test() {
   waitForExplicitFinish();
 
   win = window.openDialog(getBrowserURL(), "_blank", "all,dialog=no", "about:blank");
--- a/browser/base/content/test/tabview/browser_tabview_bug588265.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug588265.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is bug 588265 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", setup, false);
   TabView.toggle();
 }
 
@@ -49,17 +15,17 @@ function setup() {
   is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group");
 
   let groupItemOne = contentWindow.GroupItems.groupItems[0];
   // add a blank tab to group one.
   createNewTabItemInGroupItem(groupItemOne, contentWindow, function() { 
     is(groupItemOne.getChildren().length, 2, "Group one has 2 tab items");
 
     // create group two with a blank tab.
-    let groupItemTwo = createEmptyGroupItem(contentWindow, 250, 250, 40, true);
+    let groupItemTwo = createEmptyGroupItem(contentWindow, 250, 250, 40);
     createNewTabItemInGroupItem(groupItemTwo, contentWindow, function() {
       // start the first test.
       testGroups(groupItemOne, groupItemTwo, contentWindow);
     });
   });
 }
 
 function createNewTabItemInGroupItem(groupItem, contentWindow, callback) {
--- a/browser/base/content/test/tabview/browser_tabview_bug589324.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug589324.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is bug 589324 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   const DUMMY_PAGE_URL = "http://mochi.test:8888/browser/browser/base/content/test/tabview/dummy_page.html";
   const DUMMY_PAGE_URL_2 = "http://mochi.test:8888/";
 
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
   waitForExplicitFinish();
 
--- a/browser/base/content/test/tabview/browser_tabview_bug590606.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug590606.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is bug 590606 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let originalTab;
 let newTabOne;
 
 function test() {
   waitForExplicitFinish();
 
   originalTab = gBrowser.visibleTabs[0];
--- a/browser/base/content/test/tabview/browser_tabview_bug591706.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug591706.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is bug 591706 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   if (TabView.isVisible())
     onTabViewWindowLoaded();
   else
--- a/browser/base/content/test/tabview/browser_tabview_bug595191.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug595191.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview search test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Sean Dunn <seanedunn@yahoo.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   // show the tab view
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   ok(!TabView.isVisible(), "Tab View is hidden");
   TabView.toggle();
--- a/browser/base/content/test/tabview/browser_tabview_bug595436.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug595436.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 595436.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Tim Taubert <tim.taubert@gmx.de>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
   
   window.addEventListener('tabviewshown', onTabViewWindowLoaded, false);
   TabView.toggle();
 }
 
--- a/browser/base/content/test/tabview/browser_tabview_bug595518.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug595518.js
@@ -1,45 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is bug 595518 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- * Ian Gilman <ian@iangilman.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
   
   // show tab view
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   TabView.toggle();
 }
--- a/browser/base/content/test/tabview/browser_tabview_bug595521.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug595521.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 595521.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let fadeAwayUndoButtonDelay;
 let fadeAwayUndoButtonDuration;
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", testCloseLastGroup, false);
--- a/browser/base/content/test/tabview/browser_tabview_bug595560.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug595560.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is bug 595560 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let newTabOne;
 let originalTab;
 
 function test() {
   waitForExplicitFinish();
 
   originalTab = gBrowser.visibleTabs[0];
--- a/browser/base/content/test/tabview/browser_tabview_bug595804.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug595804.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview Option For Not Animating Zoom (Bug 595804) test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 var prefsBranch = Cc["@mozilla.org/preferences-service;1"].
                   getService(Ci.nsIPrefService).
                   getBranch("browser.panorama.");
 
 function animateZoom() prefsBranch.getBoolPref("animate_zoom");
 
 let contentWindow = null;
--- a/browser/base/content/test/tabview/browser_tabview_bug595930.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug595930.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview test for bug 595930.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   TabView.toggle();
 }
 
--- a/browser/base/content/test/tabview/browser_tabview_bug595943.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug595943.js
@@ -1,45 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview bug 959943 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- * Ian Gilman <ian@iangilman.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   // Show TabView
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   TabView.toggle();
 }
--- a/browser/base/content/test/tabview/browser_tabview_bug596781.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug596781.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview bug 596781 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let newTab;
 
 function test() {
   waitForExplicitFinish();
 
   newTab = gBrowser.addTab();
   gBrowser.pinTab(newTab);
--- a/browser/base/content/test/tabview/browser_tabview_bug597248.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug597248.js
@@ -1,110 +1,59 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview bug 597248 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
-let newWin;
-let restoredWin;
 let newTabOne;
 let newTabTwo;
 let restoredNewTabOneLoaded = false;
 let restoredNewTabTwoLoaded = false;
 let frameInitialized = false;
 
 function test() {
   waitForExplicitFinish();
-
-  // open a new window 
-  newWin = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no");
-  newWin.addEventListener("load", function(event) {
-    newWin.removeEventListener("load", arguments.callee, false);
-    setupOne();
-  }, false);
+  newWindowWithTabView(setupOne);
 }
 
-function setupOne() {
-  let loadedCount = 0;
-  let allLoaded = function() {
-    if (++loadedCount == 2) {
-      newWin.addEventListener("tabviewshown", setupTwo, false);
-      newWin.TabView.toggle();
-    }
-  }
-  
-  newTabOne = newWin.gBrowser.tabs[0];
-  newTabTwo = newWin.gBrowser.addTab();
-  load(newTabOne, "http://mochi.test:8888/browser/browser/base/content/test/tabview/search1.html", allLoaded);
-  load(newTabTwo, "http://mochi.test:8888/browser/browser/base/content/test/tabview/dummy_page.html", allLoaded);
+function setupOne(win) {
+  win.TabView.firstUseExperienced = true;
+
+  win.gBrowser.addTab("http://mochi.test:8888/browser/browser/base/content/test/tabview/search1.html");
+  win.gBrowser.addTab("http://mochi.test:8888/browser/browser/base/content/test/tabview/dummy_page.html");
+
+  afterAllTabsLoaded(function () setupTwo(win), win);
 }
 
-function setupTwo() {
-  newWin.removeEventListener("tabviewshown", setupTwo, false);
-
-  let contentWindow = newWin.document.getElementById("tab-view").contentWindow;
+function setupTwo(win) {
+  let contentWindow = win.TabView.getContentWindow();
 
   let tabItems = contentWindow.TabItems.getItems();
-  is(tabItems.length, 2, "There should be 2 tab items before closing");
+  is(tabItems.length, 3, "There should be 3 tab items before closing");
 
   let numTabsToSave = tabItems.length;
 
   // force all canvases to update, and hook in imageData save detection
   tabItems.forEach(function(tabItem) {
     contentWindow.TabItems._update(tabItem.tab);
-    tabItem.addSubscriber(tabItem, "savedImageData", function(item) {
-      item.removeSubscriber(item, "savedImageData");
+    tabItem.addSubscriber(tabItem, "savedCachedImageData", function(item) {
+      item.removeSubscriber(item, "savedCachedImageData");
       --numTabsToSave;
     });
   });
 
   // after the window is closed, restore it.
   let xulWindowDestory = function() {
     Services.obs.removeObserver(
        xulWindowDestory, "xul-window-destroyed", false);
 
-    newWin = null;
     // "xul-window-destroyed" is just fired just before a XUL window is
     // destroyed so restore window and test it after a delay
     executeSoon(function() {
-      restoredWin = undoCloseWindow();
-      restoredWin.addEventListener("load", function(event) {
-        restoredWin.removeEventListener("load", arguments.callee, false);
+      let restoredWin = undoCloseWindow();
+      restoredWin.addEventListener("load", function onLoad(event) {
+        restoredWin.removeEventListener("load", onLoad, false);
 
         // ensure that closed tabs have been saved
         is(numTabsToSave, 0, "All tabs were saved when window was closed.");
 
         // execute code when the frame is initialized.
         let onTabViewFrameInitialized = function() {
           restoredWin.removeEventListener(
             "tabviewframeinitialized", onTabViewFrameInitialized, false);
@@ -117,17 +66,17 @@ function setupTwo() {
           restoredContentWindow.TabItems._pauseUpdateForTest = true;
           */
           restoredWin.close();
           finish();
         }
         restoredWin.addEventListener(
           "tabviewframeinitialized", onTabViewFrameInitialized, false);
 
-        is(restoredWin.gBrowser.tabs.length, 2, "The total number of tabs is 2");
+        is(restoredWin.gBrowser.tabs.length, 3, "The total number of tabs is 3");
 
         /*
         // bug 615954 happens too often so we disable this until we have a fix
         restoredWin.addEventListener("tabviewshown", onTabViewShown, false);
 
         // setup tab variables and listen to the load progress.
         newTabOne = restoredWin.gBrowser.tabs[0];
         newTabTwo = restoredWin.gBrowser.tabs[1];
@@ -135,20 +84,20 @@ function setupTwo() {
         */
       }, false);
     });
   };
 
   Services.obs.addObserver(
     xulWindowDestory, "xul-window-destroyed", false);
 
-  newWin.close();
+  win.close();
 }
 
-let gTabsProgressListener = {
+/*let gTabsProgressListener = {
   onStateChange: function(browser, webProgress, request, stateFlags, status) {
     // ensure about:blank doesn't trigger the code
     if ((stateFlags & Ci.nsIWebProgressListener.STATE_STOP) &&
         (stateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW) &&
          browser.currentURI.spec != "about:blank") {
       if (newTabOne.linkedBrowser == browser)
         restoredNewTabOneLoaded = true;
       else if (newTabTwo.linkedBrowser == browser)
@@ -226,18 +175,9 @@ function updateAndCheck() {
     ok(!tabItem.isShowingCachedData(), 
       "Tab item is not showing cached data anymore. " +
       tabItem.tab.linkedBrowser.currentURI.spec);
   });
 
   // clean up and finish
   restoredWin.close();
   finish();
-}
-
-function load(tab, url, callback) {
-  tab.linkedBrowser.addEventListener("load", function (event) {
-    tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
-    callback();
-  }, true);
-  tab.linkedBrowser.loadURI(url);
-}
-
+}*/
--- a/browser/base/content/test/tabview/browser_tabview_bug597360.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug597360.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Tab View bug 597360 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   TabView.show();
 }
 
--- a/browser/base/content/test/tabview/browser_tabview_bug597399.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug597399.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 597399.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   TabView.toggle();
 }
 
--- a/browser/base/content/test/tabview/browser_tabview_bug598600.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug598600.js
@@ -1,44 +1,11 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview bug598600 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
 let newWin;
 function test() {
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
 
   waitForExplicitFinish();
 
   // open a new window and setup the window state.
   newWin = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no");
--- a/browser/base/content/test/tabview/browser_tabview_bug599626.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug599626.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview bug 599626 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let handleDialog;
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   TabView.toggle();
--- a/browser/base/content/test/tabview/browser_tabview_bug600645.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug600645.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview bug600645 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let newTab;
 
 function test() {
   waitForExplicitFinish();
 
   newTab = gBrowser.addTab();
   gBrowser.pinTab(newTab);
--- a/browser/base/content/test/tabview/browser_tabview_bug600812.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug600812.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 600812.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Tim Taubert <tim.taubert@gmx.de>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   let cw;
 
   let createGroupItem = function () {
     let bounds = new cw.Rect(20, 20, 150, 150);
     let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true});
 
--- a/browser/base/content/test/tabview/browser_tabview_bug604098.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug604098.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 604098.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let originalTab;
 let orphanedTab;
 let contentWindow;
 
 function test() {
   waitForExplicitFinish();
 
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabview/browser_tabview_bug604699.js
@@ -0,0 +1,81 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  let url = "http://non.existant/url";
+  let cw;
+
+  let finishTest = function () {
+    is(1, gBrowser.tabs.length, "there is one tab, only");
+    ok(!TabView.isVisible(), "tabview is not visible");
+    finish();
+  }
+
+  waitForExplicitFinish();
+
+  let testErroneousLoading = function () {
+    cw.Storage.loadThumbnail(url, function (status, data) {
+      ok(!status, "thumbnail entry failed to load");
+      is(null, data, "no thumbnail data received");
+      next();
+    });
+  }
+
+  let testAsynchronousSaving = function () {
+    let saved = false;
+    let data = "thumbnail-data-asynchronous";
+
+    cw.Storage.saveThumbnail(url, data, function (status) {
+      ok(status, "thumbnail entry was saved");
+      ok(saved, "thumbnail was saved asynchronously");
+
+      cw.Storage.loadThumbnail(url, function (status, imageData) {
+        ok(status, "thumbnail entry was loaded");
+        is(imageData, data, "valid thumbnail data received");
+        next();
+      });
+    });
+
+    saved = true;
+  }
+
+  let testSynchronousSaving = function () {
+    let saved = false;
+    let data = "thumbnail-data-synchronous";
+
+    cw.UI.isDOMWindowClosing = true;
+    registerCleanupFunction(function () cw.UI.isDOMWindowClosing = false);
+
+    cw.Storage.saveThumbnail(url, data, function (status) {
+      ok(status, "thumbnail entry was saved");
+      ok(!saved, "thumbnail was saved synchronously");
+
+      cw.Storage.loadThumbnail(url, function (status, imageData) {
+        ok(status, "thumbnail entry was loaded");
+        is(imageData, data, "valid thumbnail data received");
+
+        cw.UI.isDOMWindowClosing = false;
+        next();
+      });
+    });
+
+    saved = true;
+  }
+
+  let tests = [testErroneousLoading, testAsynchronousSaving, testSynchronousSaving];
+
+  let next = function () {
+    let test = tests.shift();
+    if (test)
+      test();
+    else
+      hideTabView(finishTest);
+  }
+
+  showTabView(function () {
+    registerCleanupFunction(function () TabView.hide());
+    cw = TabView.getContentWindow();
+
+    next();
+  });
+}
--- a/browser/base/content/test/tabview/browser_tabview_bug606657.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug606657.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 606657.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Tim Taubert <tim.taubert@gmx.de>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   showTabView(function () {
     let [tab] = gBrowser.tabs;
     let groupId = tab._tabViewTabItem.parent.id;
 
--- a/browser/base/content/test/tabview/browser_tabview_bug606905.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug606905.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 606901.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   let newTabs = []
   // add enough tabs so the close buttons are hidden and then check the closebuttons attribute
   do {
     let newTab = gBrowser.addTab("about:blank", {skipAnimation: true});
--- a/browser/base/content/test/tabview/browser_tabview_bug608158.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug608158.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 608158.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   TabView.toggle();
 }
 
--- a/browser/base/content/test/tabview/browser_tabview_bug608184.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug608184.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 608184.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   let origTab = gBrowser.visibleTabs[0];
   let newTab = gBrowser.addTab();
   gBrowser.selectedTab = newTab;
   let relatedTab = gBrowser.addTab("about:blank", { ownerTab: newTab });
--- a/browser/base/content/test/tabview/browser_tabview_bug610242.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug610242.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is bug 610242 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   newWindowWithTabView(onTabViewWindowLoaded);
 }
 
 function onTabViewWindowLoaded(win) {
--- a/browser/base/content/test/tabview/browser_tabview_bug612470.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug612470.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview bug 612470 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Patrick Walton <pcwalton@mozilla.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Tests that groups behave properly when closing all tabs but app tabs.
 
 let appTab, contentWindow;
 let originalGroup, originalGroupTab, newGroup, newGroupTab;
 
 function test() {
   waitForExplicitFinish();
--- a/browser/base/content/test/tabview/browser_tabview_bug613541.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug613541.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 613541.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Tim Taubert <tim.taubert@gmx.de>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   let cw;
   let currentTest;
 
   let getGroupItem = function (index) {
     return cw.GroupItems.groupItems[index];
   }
--- a/browser/base/content/test/tabview/browser_tabview_bug616729.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug616729.js
@@ -1,66 +1,26 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 616729.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Tim Taubert <tim.taubert@gmx.de>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   let cw;
 
   let createGroupItem = function () {
-    let bounds = new cw.Rect(20, 20, 400, 200);
-    let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true});
-    cw.GroupItems.setActiveGroupItem(groupItem);
-
-    for (let i=0; i<5; i++)
-      gBrowser.loadOneTab('about:blank', {inBackground: true});
-
-    return groupItem;
+    return createGroupItemWithBlankTabs(window, 400, 200, 0, 5);
   }
 
   let assertCorrectItemOrder = function (items) {
     for (let i=1; i<items.length; i++) {
       if (items[i-1].tab._tPos > items[i].tab._tPos) {
         ok(false, 'tabs were correctly reordered');
-        break;
+        return;
       }
     }
+    ok(true, 'tabs were correctly reordered');
   }
 
   let testVariousTabOrders = function () {
     let groupItem = createGroupItem();
     let [tab1, tab2, tab3, tab4, tab5] = groupItem.getChildren();
 
     // prepare tests
     let tests = [];
@@ -127,29 +87,21 @@ function test() {
 
       groupItem.add(child, {index: 1});
       groupItem.reorderTabsBasedOnTabItemOrder();
 
       assertCorrectItemOrder(groupItem.getChildren());
       assertCorrectItemOrder(groupItem2.getChildren());
 
       // cleanup
-      groupItem.addSubscriber(groupItem, 'groupHidden', function () {
-        groupItem.removeSubscriber(groupItem, 'groupHidden');
-        groupItem.closeHidden();
-        groupItem2.closeAll();
+      closeGroupItem(groupItem, function () {
+        closeGroupItem(groupItem2, function () {
+          hideTabView(finish);
+        });
       });
-
-      groupItem2.addSubscriber(groupItem, 'groupHidden', function () {
-        groupItem2.removeSubscriber(groupItem, 'groupHidden');
-        groupItem2.closeHidden();
-        hideTabView(finish);
-      });
-
-      groupItem.closeAll();
     });
   }
 
   waitForExplicitFinish();
 
   showTabView(function () {
     cw = TabView.getContentWindow();
     afterAllTabsLoaded(testVariousTabOrders);
--- a/browser/base/content/test/tabview/browser_tabview_bug616967.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug616967.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 616967.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Tim Taubert <tim.taubert@gmx.de>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   let branch = Services.prefs.getBranch('browser.panorama.');
   branch.setBoolPref('experienced_first_run', false);
   
   newWindowWithTabView(function (win) {
--- a/browser/base/content/test/tabview/browser_tabview_bug618828.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug618828.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 618828.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Tim Taubert <tim.taubert@gmx.de>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   ok(!TabView.isVisible(), 'TabView is hidden');
   let tab = gBrowser.loadOneTab('about:blank#other', {inBackground: true});
 
   TabView._initFrame(function () {
--- a/browser/base/content/test/tabview/browser_tabview_bug619937.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug619937.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Panorama bug 619937 (clicking the background) test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   TabView.toggle();
 }
 
--- a/browser/base/content/test/tabview/browser_tabview_bug622835.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug622835.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 622835.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Tim Taubert <tim.taubert@gmx.de>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   newWindowWithTabView(onTabViewShown);
 }
 
 function onTabViewShown(win) {
--- a/browser/base/content/test/tabview/browser_tabview_bug622872.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug622872.js
@@ -1,45 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is bug 622872 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
   newWindowWithTabView(part1);
 }
 
 // PART 1:
 // 1. Create a new tab (called newTab)
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabview/browser_tabview_bug623768.js
@@ -0,0 +1,45 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  waitForExplicitFinish();
+
+  let newTab = gBrowser.loadOneTab("http://www.example.com/#1",
+                                   { inBackground: false });
+
+  // The executeSoon() call is really needed here because there's callback
+  // waiting to be fired after gBrowser.loadOneTab(). After that the browser is
+  // in a state where loadURI() will create a new entry in the session history
+  // (that is vital for back/forward functionality).
+  afterAllTabsLoaded(function() {
+    executeSoon(function() {
+      ok(!newTab.linkedBrowser.canGoBack, 
+         "Browser should not be able to go back in history");
+
+      newTab.linkedBrowser.loadURI("http://www.example.com/#2");
+
+      afterAllTabsLoaded(function() {
+        ok(newTab.linkedBrowser.canGoBack, 
+           "Browser can go back in history after loading another URL");
+
+        showTabView(function() {
+          let contentWindow = document.getElementById("tab-view").contentWindow;
+
+          EventUtils.synthesizeKey("VK_BACK_SPACE", { type: "keyup" }, contentWindow);
+
+          // check after a delay
+          executeSoon(function() {
+            ok(newTab.linkedBrowser.canGoBack, 
+               "Browser can still go back in history");
+
+            hideTabView(function() {
+              gBrowser.removeTab(newTab);
+              finish();
+            });
+          });
+        });
+      });
+    });
+  });
+}
+
--- a/browser/base/content/test/tabview/browser_tabview_bug624265.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug624265.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview bug 624265 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Tim Taubert <tim.taubert@gmx.de>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let pb = Cc['@mozilla.org/privatebrowsing;1'].
          getService(Ci.nsIPrivateBrowsingService);
 
 function test() {
   let tests = [];
 
   let getContentWindow = function () {
@@ -97,17 +63,18 @@ function test() {
   }
 
   // ----------
   // [623792] duplicating tab via middle click on reload button
   let testDuplicateTab = function () {
     gBrowser.loadOneTab('http://mochi.test:8888/', {inBackground: true});
 
     afterAllTabsLoaded(function () {
-      duplicateTabIn(gBrowser.selectedTab, 'current');
+      // Valid choices for 'where' are window|tabshifted|tab
+      duplicateTabIn(gBrowser.selectedTab, 'tab');
 
       afterAllTabsLoaded(function () {
         assertNumberOfVisibleTabs(3);
         assertOneSingleGroupItem();
         next();
       });
     });
   }
--- a/browser/base/content/test/tabview/browser_tabview_bug624953.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug624953.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview bug 624953 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Tim Taubert <tim.taubert@gmx.de>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   let finishTest = function (groupItem) {
     groupItem.addSubscriber(groupItem, 'groupHidden', function () {
       groupItem.removeSubscriber(groupItem, 'groupHidden');
       groupItem.closeHidden();
--- a/browser/base/content/test/tabview/browser_tabview_bug625269.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug625269.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is bug 625269 test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   newWindowWithTabView(onTabViewWindowLoaded);
 }
 
 function onTabViewWindowLoaded(win) {
--- a/browser/base/content/test/tabview/browser_tabview_bug626368.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug626368.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is a test for bug 626368.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2011
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Tim Taubert <tim.taubert@gmx.de>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   let cw;
 
   let createGroupItem = function () {
     let bounds = new cw.Rect(20, 20, 150, 150);
     let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true});
 
--- a/browser/base/content/test/tabview/browser_tabview_bug626525.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug626525.js
@@ -4,17 +4,17 @@
 let prefsBranch;
 let currentActiveGroupItemId;
 
 function test() {
   waitForExplicitFinish();
 
   // disable the first run pref
   prefsBranch = Services.prefs.getBranch("browser.panorama.");
-  prefsBranch.setBoolPref("experienced_first_use", false);
+  prefsBranch.setBoolPref("experienced_first_run", false);
 
   let win =
     window.openDialog(getBrowserURL(), "_blank", "all,dialog=no", "about:blank");
 
   let onLoad = function() {
     win.removeEventListener("load", onLoad, false);
 
     let theObserver = function(subject, topic, data) {
@@ -62,17 +62,17 @@ function test2(win) {
     test3(win);
   });
 }
 
 // first run has happened, open the tab context menupopup and the tabview menu,
 // move a tab to another group including iframe initialization.  Then,
 // use the key combination to change to the next group.
 function test3(win) {
-  prefsBranch.setBoolPref("experienced_first_use", true);
+  prefsBranch.setBoolPref("experienced_first_run", true);
 
   let newTab = win.gBrowser.addTab("about:blank");
 
   // open the tab context menupopup and the tabview menupopup
   openTabContextPopup(win, newTab);
   win.document.getElementById("context_tabViewMenuPopup").openPopup(
     win.document.getElementById("context_tabViewMenu"), "end_after", 0, 0,
     true, false);
--- a/browser/base/content/test/tabview/browser_tabview_bug627288.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug627288.js
@@ -14,20 +14,28 @@ function test() {
       gBrowser.removeTab(tab);
 
       cw.TabItems.pauseReconnecting();
       tab = gBrowser.loadOneTab('http://mochi.test:8888/', {inBackground: true});
       cw.Storage.saveTab(tab, data);
 
       whenTabAttrModified(tab, function () {
         tabItem = tab._tabViewTabItem;
+
+        // Hook into loadedCachedImageData since loading cached thumbnails 
+        // is asynchronous.
+        tabItem.addSubscriber(tabItem, "loadedCachedImageData", function(item) {
+          item.removeSubscriber(item, "loadedCachedImageData");
+
+          ok(tabItem.isShowingCachedData(), 'tabItem shows cached data');
+
+          testChangeUrlAfterReconnect();
+        });
+
         cw.TabItems.resumeReconnecting();
-        ok(tabItem.isShowingCachedData(), 'tabItem shows cached data');
-
-        testChangeUrlAfterReconnect();
       });
     });
   }
 
   let testChangeUrlAfterReconnect = function () {
     tab.linkedBrowser.loadURI('http://mochi.test:8888/browser/');
 
     whenTabAttrModified(tab, function () {
--- a/browser/base/content/test/tabview/browser_tabview_bug627736.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug627736.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Panorama bug 627736 (post-group close focus) test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
   newWindowWithTabView(onTabViewWindowLoaded);
 }
 
 function onTabViewWindowLoaded(win) {
   ok(win.TabView.isVisible(), "Tab View is visible");
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabview/browser_tabview_bug633788.js
@@ -0,0 +1,31 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  waitForExplicitFinish();
+
+  showTabView(function () {
+    is(gBrowser.tabs.length, 1, "There is only one tab");
+
+    let tab = gBrowser.tabs[0];
+    let tabItem = tab._tabViewTabItem;
+    ok(tabItem.parent, "The tab item belongs to a group");
+    let groupId = tabItem.parent.id;
+
+    tab._tabViewTabItem.close();
+
+    whenTabViewIsHidden(function() {
+      // a new tab with group should be opened
+      is(gBrowser.tabs.length, 1, "There is still one tab");
+      isnot(gBrowser.selectedTab, tab, "The tab is different");
+
+      tab = gBrowser.tabs[0];
+      tabItem = tab._tabViewTabItem;
+      ok(tabItem.parent, "This new tab item belongs to a group");
+
+      is(tabItem.parent.id, groupId, "The group is different");
+
+      finish();
+    });
+  });
+}
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabview/browser_tabview_bug634085.js
@@ -0,0 +1,49 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  let numChildren = 7;
+
+  let assertTopOfStack = function (tabItem) {
+    ok(!tabItem.getHidden(), "tabItem is visible");
+    is(tabItem.zIndex, tabItem.parent.getZ() + numChildren + 1, "zIndex");
+  }
+
+  let testTopOfStack = function (tabItem, callback) {
+    hideTabView(function () {
+      gBrowser.selectedTab = tabItem.tab;
+
+      showTabView(function () {
+        assertTopOfStack(tabItem);
+        callback();
+      });
+    });
+  }
+
+  let finishTest = function () {
+    registerCleanupFunction(function () {
+      is(1, gBrowser.tabs.length, "there is one tab, only");
+      ok(!TabView.isVisible(), "tabview is not visible");
+    });
+
+    finish();
+  }
+
+  waitForExplicitFinish();
+
+  showTabView(function () {
+    let groupItem = createGroupItemWithBlankTabs(window, 150, 150, 10, numChildren);
+
+    registerCleanupFunction(function () {
+      closeGroupItem(groupItem, function () TabView.hide());
+    });
+
+    testTopOfStack(groupItem.getChild(1), function () {
+      testTopOfStack(groupItem.getChild(6), function () {
+        closeGroupItem(groupItem, function () {
+          hideTabView(finishTest);
+        });
+      });
+    });
+  });
+}
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabview/browser_tabview_bug635696.js
@@ -0,0 +1,106 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  let cw;
+
+  let createGroupItem = function () {
+    let groupItem = createGroupItemWithBlankTabs(window, 200, 200, 10, 1);
+
+    let groupItemId = groupItem.id;
+    registerCleanupFunction(function() {
+      let groupItem = cw.GroupItems.groupItem(groupItemId);
+      if (groupItem)
+        groupItem.close();
+    });
+
+    return groupItem;
+  }
+
+  let createOrphan = function () {
+    let tab = gBrowser.loadOneTab('about:blank', {inBackground: true});
+    registerCleanupFunction(function () {
+      if (gBrowser.tabs.length > 1)
+        gBrowser.removeTab(gBrowser.tabs[1])
+    });
+
+    let tabItem = tab._tabViewTabItem;
+    tabItem.parent.remove(tabItem);
+
+    return tabItem;
+  }
+
+  let testSingleGroupItem = function () {
+    let groupItem = cw.GroupItems.groupItems[0];
+    is(cw.GroupItems.getActiveGroupItem(), groupItem, "groupItem is active");
+
+    let tabItem = groupItem.getChild(0);
+    is(cw.UI.getActiveTab(), tabItem, "tabItem is active");
+
+    hideGroupItem(groupItem, function () {
+      is(cw.GroupItems.getActiveGroupItem(), null, "groupItem is not active");
+      unhideGroupItem(groupItem, function () {
+        is(cw.GroupItems.getActiveGroupItem(), groupItem, "groupItem is active again");
+        is(cw.UI.getActiveTab(), tabItem, "tabItem is still active");
+        next();
+      });
+    });
+  }
+
+  let testTwoGroupItems = function () {
+    let groupItem = cw.GroupItems.groupItems[0];
+    let tabItem = groupItem.getChild(0);
+
+    let groupItem2 = createGroupItem();
+    let tabItem2 = groupItem2.getChild(0);
+
+    hideGroupItem(groupItem, function () {
+      is(cw.UI.getActiveTab(), tabItem2, "tabItem2 is active");
+      unhideGroupItem(groupItem, function () {
+        cw.UI.setActiveTab(tabItem);
+        closeGroupItem(groupItem2, next);
+      });
+    });
+  }
+
+  let testOrphanTab = function () {
+    let groupItem = cw.GroupItems.groupItems[0];
+    let tabItem = groupItem.getChild(0);
+    let tabItem2 = createOrphan();
+
+    hideGroupItem(groupItem, function () {
+      is(cw.UI.getActiveTab(), tabItem2, "tabItem2 is active");
+      unhideGroupItem(groupItem, function () {
+        cw.UI.setActiveTab(tabItem);
+        tabItem2.close();
+        next();
+      });
+    });
+  }
+
+  let tests = [testSingleGroupItem, testTwoGroupItems, testOrphanTab];
+
+  let next = function () {
+    let test = tests.shift();
+    if (test)
+      test();
+    else
+      hideTabView(finishTest);
+  }
+
+  let finishTest = function () {
+    is(cw.GroupItems.groupItems.length, 1, "there is one groupItem");
+    is(gBrowser.tabs.length, 1, "there is one tab");
+    ok(!TabView.isVisible(), "tabview is hidden");
+
+    finish();
+  }
+
+  waitForExplicitFinish();
+
+  showTabView(function () {
+    registerCleanupFunction(function () TabView.hide());
+    cw = TabView.getContentWindow();
+    next();
+  });
+}
--- a/browser/base/content/test/tabview/browser_tabview_dragdrop.js
+++ b/browser/base/content/test/tabview/browser_tabview_dragdrop.js
@@ -1,45 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview drag and drop test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   TabView.toggle();
 }
 
--- a/browser/base/content/test/tabview/browser_tabview_exit_button.js
+++ b/browser/base/content/test/tabview/browser_tabview_exit_button.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview exit button test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let contentWindow;
 let appTab;
 let originalTab;
 let exitButton;
 
 // ----------
 function test() {
--- a/browser/base/content/test/tabview/browser_tabview_expander.js
+++ b/browser/base/content/test/tabview/browser_tabview_expander.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Panorama expander test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
   requestLongerTimeout(2);
   newWindowWithTabView(onTabViewWindowLoaded);
 }
 
 function onTabViewWindowLoaded(win) {
--- a/browser/base/content/test/tabview/browser_tabview_firstrun_pref.js
+++ b/browser/base/content/test/tabview/browser_tabview_firstrun_pref.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Tab View first run (Bug 593157) test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 var prefsBranch = Cc["@mozilla.org/preferences-service;1"].
                   getService(Ci.nsIPrefService).
                   getBranch("browser.panorama.");
 
 function test() {
   waitForExplicitFinish();
 
--- a/browser/base/content/test/tabview/browser_tabview_group.js
+++ b/browser/base/content/test/tabview/browser_tabview_group.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview group test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   TabView.toggle();
 }
 
@@ -60,17 +26,17 @@ function onTabViewWindowLoaded() {
 
   testEmptyGroupItem(contentWindow);
 }
 
 function testEmptyGroupItem(contentWindow) {
   let groupItemCount = contentWindow.GroupItems.groupItems.length;
   
   // create empty group item
-  let emptyGroupItem = createEmptyGroupItem(contentWindow, 300, 300, 100, true);
+  let emptyGroupItem = createEmptyGroupItem(contentWindow, 300, 300, 100);
   ok(emptyGroupItem.isEmpty(), "This group is empty");
 
   is(contentWindow.GroupItems.groupItems.length, ++groupItemCount,
      "The number of groups is increased by 1");
 
   emptyGroupItem.addSubscriber(emptyGroupItem, "close", function() {
     emptyGroupItem.removeSubscriber(emptyGroupItem, "close");
 
@@ -84,17 +50,17 @@ function testEmptyGroupItem(contentWindo
   let closeButton = emptyGroupItem.container.getElementsByClassName("close");
   ok(closeButton[0], "Group close button exists");
 
   // click the close button
   EventUtils.synthesizeMouse(closeButton[0], 1, 1, {}, contentWindow);
 }
 
 function testGroupItemWithTabItem(contentWindow) {
-  let groupItem = createEmptyGroupItem(contentWindow, 300, 300, 200, true);
+  let groupItem = createEmptyGroupItem(contentWindow, 300, 300, 200);
   let tabItemCount = 0;
 
   let onTabViewHidden = function() {
     window.removeEventListener("tabviewhidden", onTabViewHidden, false);
 
     is(groupItem.getChildren().length, ++tabItemCount,
        "The number of children in new tab group is increased by 1");
 
--- a/browser/base/content/test/tabview/browser_tabview_launch.js
+++ b/browser/base/content/test/tabview/browser_tabview_launch.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview launch test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let tabViewShownCount = 0;
 
 // ----------
 function test() {
   waitForExplicitFinish();
 
   // verify initial state
--- a/browser/base/content/test/tabview/browser_tabview_layout.js
+++ b/browser/base/content/test/tabview/browser_tabview_layout.js
@@ -1,45 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview layout test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- * Sean Dunn <seanedunn@yahoo.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   // verify initial state
   ok(!TabView.isVisible(), "Tab View starts hidden");
 
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
@@ -68,17 +33,17 @@ function onTabViewWindowLoaded() {
 
 function testEmptyGroupItem(contentWindow) {
   let groupItemCount = contentWindow.GroupItems.groupItems.length;
 
   // Preparation
   //
     
   // create empty group item
-  let emptyGroupItem = createEmptyGroupItem(contentWindow, 253, 335, 100, true);
+  let emptyGroupItem = createEmptyGroupItem(contentWindow, 253, 335, 100);
   ok(emptyGroupItem.isEmpty(), "This group is empty");
 
   is(contentWindow.GroupItems.groupItems.length, ++groupItemCount,
      "The number of groups is increased by 1");
 
   // add four blank items
   contentWindow.GroupItems.setActiveGroupItem(emptyGroupItem);
 
--- a/browser/base/content/test/tabview/browser_tabview_multiwindow_search.js
+++ b/browser/base/content/test/tabview/browser_tabview_multiwindow_search.js
@@ -1,46 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview search test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- * Ehsan Akhgari <ehsan@mozilla.com>
- * Sean Dunn <seanedunn@yahoo.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let newWindows = [];
 
 function test() {
   waitForExplicitFinish();
   let windowOne = openDialog(location, "", "chrome,all,dialog=no", "data:text/html,");
   let windowTwo;
 
--- a/browser/base/content/test/tabview/browser_tabview_orphaned_tabs.js
+++ b/browser/base/content/test/tabview/browser_tabview_orphaned_tabs.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview test for orphaned tabs (bug 595893).
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let tabOne;
 let newWin;
 
 function test() {
   waitForExplicitFinish();
 
   newWin = 
--- a/browser/base/content/test/tabview/browser_tabview_privatebrowsing.js
+++ b/browser/base/content/test/tabview/browser_tabview_privatebrowsing.js
@@ -1,45 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview private browsing test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- * Ian Gilman <ian@iangilman.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let contentWindow = null;
 let normalURLs = []; 
 let pbTabURL = "about:privatebrowsing";
 let groupTitles = [];
 let normalIteration = 0;
 
 let pb = Cc["@mozilla.org/privatebrowsing;1"].
--- a/browser/base/content/test/tabview/browser_tabview_rtl.js
+++ b/browser/base/content/test/tabview/browser_tabview_rtl.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview RTL support test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Ehsan Akhgari <ehsan@mozilla.com> (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let tabViewShownCount = 0;
 
 // ----------
 function test() {
   waitForExplicitFinish();
 
   // verify initial state
--- a/browser/base/content/test/tabview/browser_tabview_search.js
+++ b/browser/base/content/test/tabview/browser_tabview_search.js
@@ -1,45 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview search test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- * Sean Dunn <seanedunn@yahoo.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 let newTabs = [];
 
 // ----------
 function test() {
   waitForExplicitFinish();
 
   // set up our tabs
--- a/browser/base/content/test/tabview/browser_tabview_snapping.js
+++ b/browser/base/content/test/tabview/browser_tabview_snapping.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Tab View snapping test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
 	newWindowWithTabView(onTabViewWindowLoaded);
 }
 
 function onTabViewWindowLoaded(win) {
--- a/browser/base/content/test/tabview/browser_tabview_startup_transitions.js
+++ b/browser/base/content/test/tabview/browser_tabview_startup_transitions.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview Startup Transition (Bug 591705) test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 var prefsBranch = Cc["@mozilla.org/preferences-service;1"].
                   getService(Ci.nsIPrefService).
                   getBranch("browser.panorama.");
 
 function animateZoom() prefsBranch.getBoolPref("animate_zoom");
 
 function registerCleanupFunction() {
--- a/browser/base/content/test/tabview/browser_tabview_undo_group.js
+++ b/browser/base/content/test/tabview/browser_tabview_undo_group.js
@@ -1,44 +1,10 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is tabview undo group test.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
   TabView.toggle();
 }
 
--- a/browser/base/content/test/tabview/head.js
+++ b/browser/base/content/test/tabview/head.js
@@ -1,58 +1,21 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is the utilities for tabview.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Raymond Lee <raymond@appcoast.com>
- * Michael Yoshitaka Erlewine <mitcho@mitcho.com>
- * Tim Taubert <tim.taubert@gmx.de>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
-function createEmptyGroupItem(contentWindow, width, height, padding, noAnimation) {
+function createEmptyGroupItem(contentWindow, width, height, padding, animate) {
   let pageBounds = contentWindow.Items.getPageBounds();
   pageBounds.inset(padding, padding);
 
   let box = new contentWindow.Rect(pageBounds);
   box.width = width;
   box.height = height;
-  
-  let immediately = noAnimation ? true: false;
+
   let emptyGroupItem =
-    new contentWindow.GroupItem([], { bounds: box, immediately: immediately });
+    new contentWindow.GroupItem([], { bounds: box, immediately: !animate });
 
   return emptyGroupItem;
 }
 
 // ----------
 function createGroupItemWithTabs(win, width, height, padding, urls, animate) {
   let contentWindow = win.TabView.getContentWindow();
   let groupItemCount = contentWindow.GroupItems.groupItems.length;
@@ -197,8 +160,36 @@ function whenTabViewIsShown(callback, wi
     return;
   }
 
   win.addEventListener('tabviewshown', function () {
     win.removeEventListener('tabviewshown', arguments.callee, false);
     callback();
   }, false);
 }
+
+// ----------
+function hideGroupItem(groupItem, callback) {
+  if (groupItem.hidden) {
+    callback();
+    return;
+  }
+
+  groupItem.addSubscriber(groupItem, "groupHidden", function () {
+    groupItem.removeSubscriber(groupItem, "groupHidden");
+    callback();
+  });
+  groupItem.closeAll();
+}
+
+// ----------
+function unhideGroupItem(groupItem, callback) {
+  if (!groupItem.hidden) {
+    callback();
+    return;
+  }
+
+  groupItem.addSubscriber(groupItem, "groupShown", function () {
+    groupItem.removeSubscriber(groupItem, "groupShown");
+    callback();
+  });
+  groupItem._unhide();
+}
--- a/browser/base/content/utilityOverlay.js
+++ b/browser/base/content/utilityOverlay.js
@@ -201,17 +201,17 @@ function openLinkIn(url, where, params) 
     saveURL(url, null, null, true, null, aReferrerURI);
     return;
   }
   const Cc = Components.classes;
   const Ci = Components.interfaces;
 
   var w = getTopWin();
   if ((where == "tab" || where == "tabshifted") &&
-      w.document.documentElement.getAttribute("chromehidden")) {
+      w && w.document.documentElement.getAttribute("chromehidden")) {
     w = getTopWin(true);
     aRelatedToCurrent = false;
   }
 
   if (!w || where == "window") {
     var sa = Cc["@mozilla.org/supports-array;1"].
              createInstance(Ci.nsISupportsArray);
 
--- a/browser/components/places/content/browserPlacesViews.js
+++ b/browser/components/places/content/browserPlacesViews.js
@@ -438,17 +438,17 @@ PlacesViewBase.prototype = {
 
     // Here we need the <menu>.
     if (elt.localName == "menupopup")
       elt = elt.parentNode;
 
     elt.setAttribute("scheme", PlacesUIUtils.guessUrlSchemeForUI(aURIString));
   },
 
-  nodeIconChanged: function PT_nodeIconChanged(aPlacesNode) {
+  nodeIconChanged: function PVB_nodeIconChanged(aPlacesNode) {
     let elt = aPlacesNode._DOMElement;
     if (!elt)
       throw "aPlacesNode must have _DOMElement set";
 
     // There's no UI representation for the root node, thus there's nothing to
     // be done when the icon changes.
     if (elt == this._rootElt)
       return;
@@ -461,34 +461,33 @@ PlacesViewBase.prototype = {
     if (!icon)
       elt.removeAttribute("image");
     else if (icon != elt.getAttribute("image"))
       elt.setAttribute("image", icon);
   },
 
   nodeAnnotationChanged:
   function PVB_nodeAnnotationChanged(aPlacesNode, aAnno) {
-    // Ensure the changed annotation is a livemark one.
-    if (/^livemark\//.test(aAnno) &&
-        PlacesUtils.nodeIsLivemarkContainer(aPlacesNode)) {
+    // All livemarks have a feedURI, so use it as our indicator.
+    if (aAnno == "livemark/feedURI") {
       let elt = aPlacesNode._DOMElement;
       if (!elt)
         throw "aPlacesNode must have _DOMElement set";
 
       let menu = elt.parentNode;
       if (!menu.hasAttribute("livemark"))
         menu.setAttribute("livemark", "true");
 
       // Add or remove the livemark status menuitem.
       this._ensureLivemarkStatusMenuItem(elt);
     }
   },
 
   nodeTitleChanged:
-  function PM_nodeTitleChanged(aPlacesNode, aNewTitle) {
+  function PVB_nodeTitleChanged(aPlacesNode, aNewTitle) {
     let elt = aPlacesNode._DOMElement;
     if (!elt)
       throw "aPlacesNode must have _DOMElement set";
 
     // There's no UI representation for the root node, thus there's
     // nothing to be done when the title changes.
     if (elt == this._rootElt)
       return;
@@ -534,17 +533,17 @@ PlacesViewBase.prototype = {
         this._showEmptyMenuItem(parentElt);
 
       if (parentElt._endMarker != -1)
         parentElt._endMarker--;
     }
   },
 
   nodeReplaced:
-  function PBV_nodeReplaced(aParentPlacesNode, aOldPlacesNode, aNewPlacesNode, aIndex) {
+  function PVB_nodeReplaced(aParentPlacesNode, aOldPlacesNode, aNewPlacesNode, aIndex) {
     let parentElt = aParentPlacesNode._DOMElement;
     if (!parentElt)
       throw "aParentPlacesNode node must have _DOMElement set";
 
     if (parentElt._built) {
       let elt = aOldPlacesNode._DOMElement;
       if (!elt)
         throw "aOldPlacesNode must have _DOMElement set";
@@ -1139,16 +1138,42 @@ PlacesToolbar.prototype = {
       }
       this.updateChevron();
       return;
     }
 
     PlacesViewBase.prototype.nodeMoved.apply(this, arguments);
   },
 
+  nodeAnnotationChanged:
+  function PT_nodeAnnotationChanged(aPlacesNode, aAnno) {
+    let elt = aPlacesNode._DOMElement;
+    if (!elt)
+      throw "aPlacesNode must have _DOMElement set";
+
+    if (elt == this._rootElt)
+      return;
+
+    // We're notified for the menupopup, not the containing toolbarbutton.
+    if (elt.localName == "menupopup")
+      elt = elt.parentNode;
+
+    if (elt.parentNode == this._rootElt) {
+      // Node is on the toolbar.
+
+      // All livemarks have a feedURI, so use it as our indicator.
+      if (aAnno == "livemark/feedURI") {
+        elt.setAttribute("livemark", true);
+      }
+      return;
+    }
+
+    PlacesViewBase.prototype.nodeAnnotationChanged.apply(this, arguments);
+  },
+
   nodeTitleChanged: function PT_nodeTitleChanged(aPlacesNode, aNewTitle) {
     let elt = aPlacesNode._DOMElement;
     if (!elt)
       throw "aPlacesNode must have _DOMElement set";
 
     // There's no UI representation for the root node, thus there's
     // nothing to be done when the title changes.
     if (elt == this._rootElt)
--- a/browser/components/places/tests/browser/browser_bookmarksProperties.js
+++ b/browser/components/places/tests/browser/browser_bookmarksProperties.js
@@ -34,19 +34,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /**
  * Tests the bookmarks Properties dialog.
  */
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
 // DOM ids of Places sidebar trees.
 const SIDEBAR_HISTORY_TREE_ID = "historyTree";
 const SIDEBAR_BOOKMARKS_TREE_ID = "bookmarks-view";
 
 const SIDEBAR_HISTORY_ID = "viewHistorySidebar";
 const SIDEBAR_BOOKMARKS_ID = "viewBookmarksSidebar";
 
 // For history sidebar.
--- a/browser/components/places/tests/browser/browser_history_sidebar_search.js
+++ b/browser/components/places/tests/browser/browser_history_sidebar_search.js
@@ -34,20 +34,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /**
  * Bug 392497 - search in history sidebar loses sort
  */
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
          getService(Ci.nsINavHistoryService);
 var bh = hs.QueryInterface(Ci.nsIBrowserHistory);
 var ios = Cc["@mozilla.org/network/io-service;1"].
           getService(Ci.nsIIOService);
 function uri(spec) {
   return ios.newURI(spec, null, null);
 }
--- a/browser/components/places/tests/browser/browser_library_middleclick.js
+++ b/browser/components/places/tests/browser/browser_library_middleclick.js
@@ -34,19 +34,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
  /**
  * Tests middle-clicking items in the Library.
  */
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
 const ENABLE_HISTORY_PREF = "places.history.enabled";
 
 var gLibrary = null;
 var gTests = [];
 var gCurrentTest = null;
 
 // Listener for TabOpen and tabs progress.
 var gTabsListener = {
--- a/browser/components/places/tests/browser/browser_library_views_liveupdate.js
+++ b/browser/components/places/tests/browser/browser_library_views_liveupdate.js
@@ -34,19 +34,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /**
  * Tests Library Left pane view for liveupdate.
  */
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
 var gLibrary = null;
 
 function test() {
   waitForExplicitFinish();
   // This test takes quite some time, and timeouts frequently, so we require
   // more time to run.
   // See Bug 525610.
   requestLongerTimeout(2);
--- a/browser/components/places/tests/browser/browser_markPageAsFollowedLink.js
+++ b/browser/components/places/tests/browser/browser_markPageAsFollowedLink.js
@@ -1,19 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 /**
  * Tests that visits across frames are correctly represented in the database.
  */
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
 const BASE_URL = "http://mochi.test:8888/browser/browser/components/places/tests/browser";
 const PAGE_URL = BASE_URL + "/framedPage.html";
 const LEFT_URL = BASE_URL + "/frameLeft.html";
 const RIGHT_URL = BASE_URL + "/frameRight.html";
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 let gTabLoaded = false;
--- a/browser/components/places/tests/browser/browser_views_liveupdate.js
+++ b/browser/components/places/tests/browser/browser_views_liveupdate.js
@@ -34,19 +34,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /**
  * Tests Places views (menu, toolbar, tree) for liveupdate.
  */
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
 let toolbar = document.getElementById("PersonalToolbar");
 let wasCollapsed = toolbar.collapsed;
 
 function test() {
   // Uncollapse the personal toolbar if needed.
   if (wasCollapsed)
     setToolbarVisibility(toolbar, true);
 
--- a/browser/components/places/tests/perf/Makefile.in
+++ b/browser/components/places/tests/perf/Makefile.in
@@ -45,20 +45,19 @@ include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _CHROME_FILES = \
 	perf_large_delete.xul \
 	$(NULL)
 
 # Disabled due to bad interactions with next tests.
 # browser_ui_locationbar.js
-# Disabled due to random failures.
-# browser_ui_bookmarks_sidebar.js
 _BROWSER_TEST_FILES = \
 	browser_ui_000_data.js \
+	browser_ui_bookmarks_sidebar.js \
 	browser_ui_history_menu.js \
 	browser_ui_history_sidebar.js \
 	browser_ui_history_sidebar_2.js \
 	browser_ui_history_sidebar_3.js \
 	$(NULL)
 
 libs:: $(_CHROME_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)
--- a/browser/components/places/tests/perf/browser_ui_bookmarks_sidebar.js
+++ b/browser/components/places/tests/perf/browser_ui_bookmarks_sidebar.js
@@ -93,40 +93,43 @@ const TEST_REPEAT_COUNT = 6;
 ptests.push({
   name: "open_bookmarks_sidebar",
   times: [],
   run: function() {
     var self = this;
     var start = Date.now();
     var sb = document.getElementById("sidebar");
     sb.addEventListener("load", function() {
-      var duration = Date.now() - start;
       sb.removeEventListener("load", arguments.callee, true);
-      toggleSidebar("viewBookmarksSidebar", false);
-      self.times.push(duration);
-      if (self.times.length == TEST_REPEAT_COUNT)
-        self.finish();
-      else
-        self.run();
+      executeSoon(function() {
+        var duration = Date.now() - start;
+        toggleSidebar("viewBookmarksSidebar", false);
+        self.times.push(duration);
+        if (self.times.length == TEST_REPEAT_COUNT)
+          self.finish();
+        else
+          self.run();
+      });
     }, true);
     toggleSidebar("viewBookmarksSidebar", true);
   },
   finish: function() {
     this.times.sort();  // sort the scores
     this.times.pop();   // remove worst
     this.times.shift(); // remove best
     var totalDuration = this.times.reduce(function(time, total){ return time + total; });
     var avgDuration = totalDuration/this.times.length;
     var report = make_test_report("open_bookmarks_sidebar", avgDuration);
     ok(true, report);
     setTimeout(runNextTest, 0);
   }
 });
 
 function test() {
+  requestLongerTimeout(2);
   // kick off tests
   setTimeout(runNextTest, 0);
 }
 
 function runNextTest() {
   if (ptests.length > 0) {
     ptests.shift().run();
   }
--- a/browser/components/places/tests/perf/browser_ui_history_sidebar.js
+++ b/browser/components/places/tests/perf/browser_ui_history_sidebar.js
@@ -180,16 +180,17 @@ function processTestResult(aTest) {
   aTest.times.shift(); // remove best
   var totalDuration = aTest.times.reduce(function(time, total){ return time + total; });
   var avgDuration = totalDuration/aTest.times.length;
   var report = make_test_report(aTest.name, avgDuration);
   ok(true, report);
 }
 
 function test() {
+  requestLongerTimeout(2);
   // kick off tests
   setTimeout(runNextTest, 0);
 }
 
 function runNextTest() {
   if (ptests.length > 0)
     ptests.shift().run();
   else
--- a/browser/components/places/tests/perf/browser_ui_history_sidebar_2.js
+++ b/browser/components/places/tests/perf/browser_ui_history_sidebar_2.js
@@ -125,16 +125,17 @@ function processTestResult(aTest) {
   aTest.times.shift(); // remove best
   var totalDuration = aTest.times.reduce(function(time, total){ return time + total; });
   var avgDuration = totalDuration/aTest.times.length;
   var report = make_test_report(aTest.name, avgDuration);
   ok(true, report);
 }
 
 function test() {
+  requestLongerTimeout(2);
   // kick off tests
   setTimeout(runNextTest, 0);
 }
 
 function runNextTest() {
   if (ptests.length > 0)
     ptests.shift().run();
   else
--- a/browser/components/places/tests/perf/browser_ui_history_sidebar_3.js
+++ b/browser/components/places/tests/perf/browser_ui_history_sidebar_3.js
@@ -125,16 +125,17 @@ function processTestResult(aTest) {
   aTest.times.shift(); // remove best
   var totalDuration = aTest.times.reduce(function(time, total){ return time + total; });
   var avgDuration = totalDuration/aTest.times.length;
   var report = make_test_report(aTest.name, avgDuration);
   ok(true, report);
 }
 
 function test() {
+  requestLongerTimeout(2);
   // kick off tests
   setTimeout(runNextTest, 0);
 }
 
 function runNextTest() {
   if (ptests.length > 0)
     ptests.shift().run();
   else
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_cookieacceptdialog.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_cookieacceptdialog.js
@@ -87,23 +87,23 @@ function test() {
       isSecure: false,
       expires: time,
       status: 0,
       policy: 0,
       isSession: false,
       expiry: time,
       isHttpOnly: true,
       QueryInterface: function(iid) {
-        const validIIDs = [Components.interfaces.nsISupports,
-                           Components.interfaces.nsICookie,
-                           Components.interfaces.nsICookie2];
+        const validIIDs = [Ci.nsISupports,
+                           Ci.nsICookie,
+                           Ci.nsICookie2];
         for (var i = 0; i < validIIDs.length; ++i)
           if (iid == validIIDs[i])
             return this;
-        throw Components.results.NS_ERROR_NO_INTERFACE;
+        throw Cr.NS_ERROR_NO_INTERFACE;
       }
     };
     cp.cookieDialog(window, cookie, "mozilla.org", 10, false, remember);
   }
 
   checkRememberOption(false, function() {
     pb.privateBrowsingEnabled = true;
     checkRememberOption(true, function() {
--- a/browser/components/privatebrowsing/test/unit/do_test_placesTitleNoUpdate.js
+++ b/browser/components/privatebrowsing/test/unit/do_test_placesTitleNoUpdate.js
@@ -32,18 +32,18 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 // Test to make sure that the visited page titles do not get updated inside the
 // private browsing mode.
 
-Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/PlacesUtils.jsm");
 
 function do_test()
 {
   let pb = Cc[PRIVATEBROWSING_CONTRACT_ID].
            getService(Ci.nsIPrivateBrowsingService);
 
   const TEST_URI = uri("http://mozilla.com/privatebrowsing");
   const TITLE_1 = "Title 1";
--- a/browser/components/privatebrowsing/test/unit/do_test_removeDataFromDomain.js
+++ b/browser/components/privatebrowsing/test/unit/do_test_removeDataFromDomain.js
@@ -571,21 +571,21 @@ function test_cache_cleared()
   pb.removeDataFromDomain("mozilla.org");
   do_test_pending();
 }
 
 function test_storage_cleared()
 {
   function getStorageForURI(aURI)
   {
-    let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"].
-                    getService(Components.interfaces.nsIScriptSecurityManager).
+    let principal = Cc["@mozilla.org/scriptsecuritymanager;1"].
+                    getService(Ci.nsIScriptSecurityManager).
                     getCodebasePrincipal(aURI);
-    let dsm = Components.classes["@mozilla.org/dom/storagemanager;1"].
-              getService(Components.interfaces.nsIDOMStorageManager);
+    let dsm = Cc["@mozilla.org/dom/storagemanager;1"].
+              getService(Ci.nsIDOMStorageManager);
     return dsm.getLocalStorageForPrincipal(principal, "");
   }
 
   let s = [
     getStorageForURI(uri("http://mozilla.org")),
     getStorageForURI(uri("http://my.mozilla.org")),
     getStorageForURI(uri("http://ilovemozilla.org")),
   ];
--- a/browser/components/privatebrowsing/test/unit/test_openLocationLastURL.js
+++ b/browser/components/privatebrowsing/test/unit/test_openLocationLastURL.js
@@ -33,19 +33,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 // Test the correct behavior of the openLocationLastURL.jsm JS module.
 
 function run_test_on_service()
 {
-  let Cc = Components.classes;
-  let Ci = Components.interfaces;
-  let Cu = Components.utils;
   Cu.import("resource:///modules/openLocationLastURL.jsm");
 
   function clearHistory() {
     // simulate clearing the private data
     Cc["@mozilla.org/observer-service;1"].
     getService(Ci.nsIObserverService).
     notifyObservers(null, "browser:purge-session-history", "");
   }
--- a/browser/components/sessionstore/src/nsSessionStore.js
+++ b/browser/components/sessionstore/src/nsSessionStore.js
@@ -674,20 +674,20 @@ SessionStoreService.prototype = {
         if (!aEvent.detail)
           this.onTabClose(win, aEvent.originalTarget);
         this.onTabRemove(win, aEvent.originalTarget);
         break;
       case "TabSelect":
         this.onTabSelect(win);
         break;
       case "TabShow":
-        this.onTabShow(aEvent.originalTarget);
+        this.onTabShow(win, aEvent.originalTarget);
         break;
       case "TabHide":
-        this.onTabHide(aEvent.originalTarget);
+        this.onTabHide(win, aEvent.originalTarget);
         break;
       case "TabPinned":
       case "TabUnpinned":
         this.saveStateDelayed(win);
         break;
     }
   },
 
@@ -1059,34 +1059,42 @@ SessionStoreService.prototype = {
           tab.linkedBrowser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE)
         this.restoreTab(tab);
 
       // attempt to update the current URL we send in a crash report
       this._updateCrashReportURL(aWindow);
     }
   },
 
-  onTabShow: function sss_onTabShow(aTab) {
+  onTabShow: function sss_onTabShow(aWindow, aTab) {
     // If the tab hasn't been restored yet, move it into the right _tabsToRestore bucket
     if (aTab.linkedBrowser.__SS_restoreState &&
         aTab.linkedBrowser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE) {
       this._tabsToRestore.hidden.splice(this._tabsToRestore.hidden.indexOf(aTab));
       // Just put it at the end of the list of visible tabs;
       this._tabsToRestore.visible.push(aTab);
     }
+
+    // Default delay of 2 seconds gives enough time to catch multiple TabShow
+    // events due to changing groups in Panorama.
+    this.saveStateDelayed(aWindow);
   },
 
-  onTabHide: function sss_onTabHide(aTab) {
+  onTabHide: function sss_onTabHide(aWindow, aTab) {
     // If the tab hasn't been restored yet, move it into the right _tabsToRestore bucket
     if (aTab.linkedBrowser.__SS_restoreState &&
         aTab.linkedBrowser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE) {
       this._tabsToRestore.visible.splice(this._tabsToRestore.visible.indexOf(aTab));
       // Just put it at the end of the list of hidden tabs;
       this._tabsToRestore.hidden.push(aTab);
     }
+
+    // Default delay of 2 seconds gives enough time to catch multiple TabHide
+    // events due to changing groups in Panorama.
+    this.saveStateDelayed(aWindow);
   },
 
 /* ........ nsISessionStore API .............. */
 
   getBrowserState: function sss_getBrowserState() {
     return this._toJSONString(this._getCurrentState());
   },
 
--- a/browser/components/sessionstore/test/browser/Makefile.in
+++ b/browser/components/sessionstore/test/browser/Makefile.in
@@ -139,16 +139,17 @@ include $(topsrcdir)/config/rules.mk
 	browser_601955.js \
 	browser_607016.js \
 	browser_615394-SSWindowState_events.js \
 	browser_618151.js \
 	browser_623779.js \
 	browser_624727.js \
 	browser_625257.js \
 	browser_628270.js \
+	browser_635418.js \
 	$(NULL)
 
 ifneq ($(OS_ARCH),Darwin)
 _BROWSER_TEST_FILES += \
 	browser_597071.js \
 	$(NULL)
 endif
 
--- a/browser/components/sessionstore/test/browser/browser_500328.js
+++ b/browser/components/sessionstore/test/browser/browser_500328.js
@@ -39,22 +39,22 @@ function checkState(tab) {
   // from the popState event are as we expect them to be.
   //
   // We also add a node to the document's body when after going back and make
   // sure it's still there after we go forward -- this is to test that the two
   // history entries correspond to the same document.
 
   let popStateCount = 0;
 
-  tab.linkedBrowser.addEventListener("popstate", function(aEvent) {
+  let handler = function(aEvent) {
     let contentWindow = tab.linkedBrowser.contentWindow;
     if (popStateCount == 0) {
       popStateCount++;
-      ok(aEvent.state, "Event should have a state property.");
-      is(JSON.stringify(aEvent.state), JSON.stringify({obj1:1}),
+      //ok(aEvent.state, "Event should have a state property.");
+      is(JSON.stringify(tab.linkedBrowser.contentWindow.history.state), JSON.stringify({obj1:1}),
          "first popstate object.");
 
       // Add a node with id "new-elem" to the document.
       let doc = contentWindow.document;
       ok(!doc.getElementById("new-elem"),
          "doc shouldn't contain new-elem before we add it.");
       let elem = doc.createElement("div");
       elem.id = "new-elem";
@@ -73,20 +73,24 @@ function checkState(tab) {
       let doc = contentWindow.document;
       let newElem = doc.getElementById("new-elem");
       ok(newElem, "doc should contain new-elem.");
       newElem.parentNode.removeChild(newElem);
       ok(!doc.getElementById("new-elem"), "new-elem should be removed.");
 
       // Clean up after ourselves and finish the test.
       tab.linkedBrowser.removeEventListener("popstate", arguments.callee, false);
+      tab.linkedBrowser.removeEventListener("load", arguments.callee, false);
       gBrowser.removeTab(tab);
       finish();
     }
-  }, true);
+  };
+
+  tab.linkedBrowser.addEventListener("load", handler, true);
+  tab.linkedBrowser.addEventListener("popstate", handler, true);
 
   tab.linkedBrowser.contentWindow.history.back();
 }
 
 function test() {
   // Tests session restore functionality of history.pushState and
   // history.replaceState().  (Bug 500328)
 
@@ -110,17 +114,17 @@ function test() {
       // After these push/replaceState calls, the window should have three
       // history entries:
       //   testURL (state object: null)      <-- oldest
       //   testURL (state object: {obj1:1})
       //   page2   (state object: {obj3:3})  <-- newest
       let contentWindow = tab.linkedBrowser.contentWindow;
       let history = contentWindow.history;
       history.pushState({obj1:1}, "title-obj1");
-      history.pushState({obj2:2}, "title-obj2", "page2");
+      history.pushState({obj2:2}, "title-obj2", "?foo");
       history.replaceState({obj3:3}, "title-obj3");
 
       let state = ss.getTabState(tab);
 
       // In order to make sure that setWindowState actually modifies the
       // window's state, we modify the state here.  checkState will fail if
       // this change isn't overwritten by setWindowState.
       history.replaceState({should_be_overwritten:true}, "title-overwritten");
--- a/browser/components/sessionstore/test/browser/browser_581593.js
+++ b/browser/components/sessionstore/test/browser/browser_581593.js
@@ -30,23 +30,21 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-Cu.import("resource://gre/modules/Services.jsm");
 let ss = Cc["@mozilla.org/browser/sessionstore;1"].
          getService(Ci.nsISessionStore);
 
 let stateBackup = ss.getBrowserState();
 
-
 function test() {
   /** Test for bug 581593 **/
   waitForExplicitFinish();
 
   let oldState = { windows: [{ tabs: [{ entries: [{ url: "example.com" }] }] }]};
   let pageData = {
     url: "about:sessionrestore",
     formdata: { "#sessionData": "(" + JSON.stringify(oldState) + ")" }
@@ -82,9 +80,8 @@ function onInput(aEvent) {
   }
   cleanup();
 }
 
 function cleanup() {
   ss.setBrowserState(stateBackup);
   executeSoon(finish);
 }
-
--- a/browser/components/sessionstore/test/browser/browser_586068-cascaded_restore.js
+++ b/browser/components/sessionstore/test/browser/browser_586068-cascaded_restore.js
@@ -30,17 +30,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-Cu.import("resource://gre/modules/Services.jsm");
 let ss = Cc["@mozilla.org/browser/sessionstore;1"].
          getService(Ci.nsISessionStore);
 
 let stateBackup = ss.getBrowserState();
 
 const TAB_STATE_NEEDS_RESTORE = 1;
 const TAB_STATE_RESTORING = 2;
 
@@ -759,9 +758,8 @@ function countTabs() {
     }
   }
   return [needsRestore, isRestoring, wasRestored];
 }
 
 function r() {
   return "" + Date.now() + Math.random();
 }
-
--- a/browser/components/sessionstore/test/browser/browser_589246.js
+++ b/browser/components/sessionstore/test/browser/browser_589246.js
@@ -33,17 +33,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 // Mirrors WINDOW_ATTRIBUTES IN nsSessionStore.js
 const WINDOW_ATTRIBUTES = ["width", "height", "screenX", "screenY", "sizemode"];
 
-Cu.import("resource://gre/modules/Services.jsm");
 let ss = Cc["@mozilla.org/browser/sessionstore;1"].
          getService(Ci.nsISessionStore);
 
 let stateBackup = ss.getBrowserState();
 
 let originalWarnOnClose = gPrefService.getBoolPref("browser.tabs.warnOnClose");
 let originalStartupPage = gPrefService.getIntPref("browser.startup.page");
 let originalWindowType = document.documentElement.getAttribute("windowtype");
@@ -268,9 +267,8 @@ function onWindowUnloaded() {
 
 function afterTestCleanup(aNewWin) {
   executeSoon(function() {
     aNewWin.close();
     document.documentElement.setAttribute("windowtype", originalWindowType);
     runNextTestOrFinish();
   });
 }
-
--- a/browser/components/sessionstore/test/browser/browser_590268.js
+++ b/browser/components/sessionstore/test/browser/browser_590268.js
@@ -32,23 +32,21 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 const NUM_TABS = 12;
 
-Cu.import("resource://gre/modules/Services.jsm");
 let ss = Cc["@mozilla.org/browser/sessionstore;1"].
          getService(Ci.nsISessionStore);
 
 let stateBackup = ss.getBrowserState();
 
-
 function test() {
   /** Test for Bug 590268 - Provide access to sessionstore tab data sooner **/
   waitForExplicitFinish();
 
   let startedTest = false;
 
   // wasLoaded will be used to keep track of tabs that have already had SSTabRestoring
   // fired for them.
@@ -172,9 +170,8 @@ function test() {
   // Restore state
   ss.setBrowserState(JSON.stringify(state));
 }
 
 // Helper function to create a random value
 function r() {
   return "" + Date.now() + Math.random();
 }
-
--- a/browser/components/sessionstore/test/browser/browser_590563.js
+++ b/browser/components/sessionstore/test/browser/browser_590563.js
@@ -1,12 +1,11 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-Cu.import("resource://gre/modules/Services.jsm");
 let ss = Cc["@mozilla.org/browser/sessionstore;1"].
             getService(Ci.nsISessionStore);
 
 let stateBackup = ss.getBrowserState();
 
 function test() {
   waitForExplicitFinish();
 
--- a/browser/components/sessionstore/test/browser/browser_597315.js
+++ b/browser/components/sessionstore/test/browser/browser_597315.js
@@ -30,17 +30,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-Cu.import("resource://gre/modules/Services.jsm");
 let ss = Cc["@mozilla.org/browser/sessionstore;1"].
          getService(Ci.nsISessionStore);
 
 function test() {
   /** Test for Bug 597315 - Frameset history does not work properly when restoring a tab **/
   waitForExplicitFinish();
 
   let testURL = getRootDirectory(gTestPath) + "browser_597315_index.html";
--- a/browser/components/sessionstore/test/browser/browser_599909.js
+++ b/browser/components/sessionstore/test/browser/browser_599909.js
@@ -33,17 +33,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 const TAB_STATE_NEEDS_RESTORE = 1;
 const TAB_STATE_RESTORING = 2;
 
-Cu.import("resource://gre/modules/Services.jsm");
 let ss = Cc["@mozilla.org/browser/sessionstore;1"].
          getService(Ci.nsISessionStore);
 
 let stateBackup = ss.getBrowserState();
 
 function cleanup() {
   // Reset the pref
   try {
--- a/browser/components/sessionstore/test/browser/browser_607016.js
+++ b/browser/components/sessionstore/test/browser/browser_607016.js
@@ -33,17 +33,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 const TAB_STATE_NEEDS_RESTORE = 1;
 const TAB_STATE_RESTORING = 2;
 
-Cu.import("resource://gre/modules/Services.jsm");
 let ss = Cc["@mozilla.org/browser/sessionstore;1"].
          getService(Ci.nsISessionStore);
 
 let stateBackup = ss.getBrowserState();
 
 function cleanup() {
   // Reset the pref
   try {
@@ -148,9 +147,8 @@ function test() {
   window.gBrowser.addTabsProgressListener(progressListener);
   ss.setBrowserState(JSON.stringify(state));
 }
 
 // Helper function to create a random value
 function r() {
   return "" + Date.now() + Math.random();
 }
-
--- a/browser/components/sessionstore/test/browser/browser_615394-SSWindowState_events.js
+++ b/browser/components/sessionstore/test/browser/browser_615394-SSWindowState_events.js
@@ -30,17 +30,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-Cu.import("resource://gre/modules/Services.jsm");
 const ss = Cc["@mozilla.org/browser/sessionstore;1"].
            getService(Ci.nsISessionStore);
 
 const stateBackup = ss.getBrowserState();
 const testState = {
   windows: [{
     tabs: [
       { entries: [{ url: "about:blank" }] },
@@ -385,9 +384,8 @@ function test_undoCloseWindow() {
     reopenedWindow.removeEventListener("SSWindowStateReady", onSSWindowStateReady, false);
     reopenedWindow.gBrowser.tabContainer.removeEventListener("SSTabRestored", onSSTabRestored, false);
 
     reopenedWindow.close();
 
     runNextTest();
   }
 }
-
--- a/browser/components/sessionstore/test/browser/browser_618151.js
+++ b/browser/components/sessionstore/test/browser/browser_618151.js
@@ -30,17 +30,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-Cu.import("resource://gre/modules/Services.jsm");
 const ss = Cc["@mozilla.org/browser/sessionstore;1"].
            getService(Ci.nsISessionStore);
 
 const stateBackup = ss.getBrowserState();
 const testState = {
   windows: [{
     tabs: [
       { entries: [{ url: "about:blank" }] },
@@ -105,9 +104,8 @@ function test_setup() {
     entries: [{ url: "http://example.org" }],
     extData: { foo: "bar" } }));
 }
 
 function test_hang() {
   ok(true, "test didn't time out");
   runNextTest();
 }
-
new file mode 100644
--- /dev/null
+++ b/browser/components/sessionstore/test/browser/browser_635418.js
@@ -0,0 +1,88 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is sessionstore test code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Mehdi Mulani <mmmulani@uwaterloo.ca>
+ * Paul O’Shannessy <paul@oshannessy.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK *****/
+
+// This tests that hiding/showing a tab, on its own, eventually triggers a
+// session store.
+
+function test() {
+  waitForExplicitFinish();
+  // We speed up the interval between session saves to ensure that the test
+  // runs quickly.
+  Services.prefs.setIntPref("browser.sessionstore.interval", 2000);
+
+  // Loading a tab causes a save state and this is meant to catch that event.
+  waitForSaveState(testBug635418_1);
+
+  // Assumption: Only one window is open and it has one tab open.
+  gBrowser.addTab("about:mozilla");
+}
+
+function testBug635418_1() {
+  ok(!gBrowser.tabs[0].hidden, "first tab should not be hidden");
+  ok(!gBrowser.tabs[1].hidden, "second tab should not be hidden");
+
+  waitForSaveState(testBug635418_2);
+
+  // We can't hide the selected tab, so hide the new one
+  gBrowser.hideTab(gBrowser.tabs[1]);
+}
+
+function testBug635418_2() {
+  let state = JSON.parse(SS_SVC.getBrowserState());
+  ok(!state.windows[0].tabs[0].hidden, "first tab should still not be hidden");
+  ok(state.windows[0].tabs[1].hidden, "second tab should be hidden by now");
+
+  waitForSaveState(testBug635418_3);
+  gBrowser.showTab(gBrowser.tabs[1]);
+}
+
+function testBug635418_3() {
+  let state = JSON.parse(SS_SVC.getBrowserState());
+  ok(!state.windows[0].tabs[0].hidden, "first tab should still still not be hidden");
+  ok(!state.windows[0].tabs[1].hidden, "second tab should not be hidden again");
+
+  done();
+}
+
+function done() {
+  gBrowser.removeTab(window.gBrowser.tabs[1]);
+
+  Services.prefs.clearUserPref("browser.sessionstore.interval");
+
+  executeSoon(finish);
+}
--- a/browser/components/sessionstore/test/browser/head.js
+++ b/browser/components/sessionstore/test/browser/head.js
@@ -30,17 +30,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-Cu.import("resource://gre/modules/Services.jsm");
 const SS_SVC = Cc["@mozilla.org/browser/sessionstore;1"].
                getService(Ci.nsISessionStore);
 
 // This assumes that tests will at least have some state/entries
 function waitForBrowserState(aState, aSetStateCallback) {
   let windows = [window];
   let tabsRestored = 0;
   let expectedTabsRestored = 0;
--- a/browser/config/version.txt
+++ b/browser/config/version.txt
@@ -1,1 +1,1 @@
-4.0b12pre
+4.0b13pre
--- a/browser/installer/windows/nsis/defines.nsi.in
+++ b/browser/installer/windows/nsis/defines.nsi.in
@@ -21,20 +21,18 @@
 !define PreReleaseSuffix      "@PRE_RELEASE_SUFFIX@"
 !define BrandFullName         "${BrandFullNameInternal}${PreReleaseSuffix}"
 
 !define NO_UNINSTALL_SURVEY
 
 # LSP_CATEGORIES is the permitted LSP categories for the application. Each LSP
 # category value is ANDed together to set multiple permitted categories.
 # See http://msdn.microsoft.com/en-us/library/ms742253%28VS.85%29.aspx
-# The value below permits the LSP_INSPECTOR, LSP_REDIRECTOR, LSP_PROXY,
-# LSP_FIREWALL, LSP_INBOUND_MODIFY, LSP_OUTBOUND_MODIFY, LSP_CRYPTO_COMPRESS,
-# and LSP_LOCAL_CACHE LSP categories.
-!define LSP_CATEGORIES "0x000000ff"
+# The value below removes all LSP categories previously set.
+!define LSP_CATEGORIES "0x00000000"
 
 # NO_INSTDIR_FROM_REG is defined for pre-releases which have a PreReleaseSuffix
 # (e.g. Alpha X, Beta X, etc.) to prevent finding a non-default installation
 # directory in the registry and using that as the default. This prevents
 # Beta releases built with official branding from finding an existing install
 # of an official release and defaulting to its installation directory.
 !if "@PRE_RELEASE_SUFFIX@" != ""
 !define NO_INSTDIR_FROM_REG
--- a/browser/locales/shipped-locales
+++ b/browser/locales/shipped-locales
@@ -74,8 +74,9 @@ sv-SE
 ta
 ta-LK
 te
 th
 tr
 uk
 zh-CN
 zh-TW
+zu
--- a/browser/themes/gnomestripe/browser/browser.css
+++ b/browser/themes/gnomestripe/browser/browser.css
@@ -67,17 +67,18 @@
   background-color: transparent;
   border-top: none;
 }
 
 #main-window:not([disablechrome]) #navigator-toolbox[tabsontop=true] {
   border-bottom: 1px solid ThreeDShadow;
 }
 
-#navigator-toolbox > toolbar:not(:-moz-lwtheme):not(#toolbar-menubar) {
+#navigator-toolbox[tabsontop=true] > toolbar:not(:-moz-lwtheme):not(#toolbar-menubar):not(#TabsToolbar),
+#navigator-toolbox[tabsontop=false] > toolbar:not(:-moz-lwtheme):not(#toolbar-menubar) {
   -moz-appearance: none;
   border-style: none;
   background-color: -moz-Dialog;
 }
 
 #navigator-toolbox > toolbar:not(#toolbar-menubar):not(#TabsToolbar) {
   padding-top: 1px;
   padding-bottom: 1px;
@@ -623,34 +624,39 @@ toolbar[mode="full"] .toolbarbutton-1 > 
   list-style-image: url("moz-icon://stock/gtk-home?size=toolbar");
 }
 #home-button[disabled="true"] {
   list-style-image: url("moz-icon://stock/gtk-home?size=toolbar&state=disabled");
 }
 
 /* tabview button */
 
-#tabview-button {
+#tabview-button,
+#menu_tabview {
   list-style-image: url(chrome://browser/skin/tabview/tabview.png);
   -moz-image-region: rect(0, 80px, 16px, 64px);
 }
 
-#tabview-button[groups="0"] {
+#tabview-button[groups="0"],
+#menu_tabview[groups="0"] {
   -moz-image-region: rect(0, 16px, 16px, 0);
 }
 
-#tabview-button[groups="1"] {
+#tabview-button[groups="1"],
+#menu_tabview[groups="1"] {
   -moz-image-region: rect(0, 32px, 16px, 16px);
 }
 
-#tabview-button[groups="2"] {
+#tabview-button[groups="2"],
+#menu_tabview[groups="2"] {
   -moz-image-region: rect(0, 48px, 16px, 32px);
 }
 
-#tabview-button[groups="3"] {
+#tabview-button[groups="3"],
+#menu_tabview[groups="3"] {
   -moz-image-region: rect(0, 64px, 16px, 48px);
 }
 
 #downloads-button {
   -moz-image-region: rect(0px 24px 24px 0px);
 }
 
 #history-button {
@@ -1375,60 +1381,67 @@ richlistitem[type~="action"][actiontype=
 
 /* Tabstrip */
 
 #TabsToolbar {
   min-height: 0;
   padding: 0;
 }
 
-#TabsToolbar:not(:-moz-lwtheme),
+#TabsToolbar[tabsontop=true]:not(:-moz-lwtheme) {
+  -moz-appearance: menubar;
+  color: -moz-menubartext;
+}
+
+#TabsToolbar[tabsontop=true]:not(:-moz-lwtheme):-moz-system-metric(menubar-drag) {
+  -moz-binding: url("chrome://global/content/bindings/toolbar.xml#toolbar-drag");
+}
+
 #TabsToolbar[tabsontop=false] {
   background-image:
     -moz-linear-gradient(bottom, rgba(0,0,0,.3) 1px, rgba(0,0,0,.05) 1px, transparent 50%);
 }
 
 .tabbrowser-tab,
 .tabs-newtab-button {
   position: static;
   -moz-appearance: none;
   background: -moz-linear-gradient(hsla(0,0%,100%,.2), hsla(0,0%,45%,.2) 2px, hsla(0,0%,32%,.2) 80%);
   background-origin: border-box;
   background-position: 1px 2px;
   background-size: 100% -moz-calc(100% - 2px);
   background-repeat: no-repeat;
+  color: inherit;
   margin: 0;
   padding: 0;
   -moz-border-image: url(tabbrowser/tab.png) 4 5 3 6 / 4px 5px 3px 6px repeat stretch;
   border-radius: 10px 8px 0 0;
   min-height: 25px; /* reserve space for the sometimes hidden close button */
 }
 
 .tabbrowser-tab:hover,
 .tabs-newtab-button:hover {
   background-image: -moz-linear-gradient(hsla(0,0%,100%,.6), hsla(0,0%,100%,.2) 4px, hsla(0,0%,75%,.2) 80%);
 }
 
 .tabbrowser-tab[selected="true"] {
   background-image: -moz-linear-gradient(@selectedTabHighlight@, @toolbarHighlight@ 32%),
                     -moz-linear-gradient(-moz-dialog, -moz-dialog);
+  color: -moz-dialogtext;
 }
 
 #main-window[tabsontop=false]:not([disablechrome]) .tabbrowser-tab[selected=true]:not(:-moz-lwtheme) {
   background-image: -moz-linear-gradient(bottom, rgba(0,0,0,.3) 1px, transparent 1px),
                     -moz-linear-gradient(@selectedTabHighlight@, @toolbarHighlight@ 32%),
                     -moz-linear-gradient(-moz-dialog, -moz-dialog);
 }
 
-.tabbrowser-tab:-moz-lwtheme {
-  color: inherit;
-}
-
 .tabbrowser-tab[selected="true"]:-moz-lwtheme {
   background-image: -moz-linear-gradient(@selectedTabHighlight@, @toolbarHighlight@ 32%);
+  color: inherit;
 }
 
 .tabbrowser-tab:-moz-lwtheme-brighttext:not([selected="true"]),
 .tabs-newtab-button:-moz-lwtheme-brighttext {
   background-image: -moz-linear-gradient(hsla(0,0%,60%,.6), hsla(0,0%,40%,.6) 4px, hsla(0,0%,30%,.6) 80%);
 }
 
 .tabbrowser-tab:-moz-lwtheme-brighttext:not([selected="true"]):hover,
@@ -1723,16 +1736,20 @@ toolbar[mode="text"] toolbarbutton.chevr
 }
 
 /* Application button menu */
 
 .splitmenu-menuitem {
   -moz-margin-end: 1px;
 }
 
+#appmenu-toolbar-button:not(:hover):not([open]):not(:-moz-lwtheme) {
+  color: inherit;
+}
+
 #appmenu-toolbar-button > .toolbarbutton-text,
 #appmenu-toolbar-button > .toolbarbutton-menu-dropmarker {
   margin-top: -2px !important;
   margin-bottom: -2px !important;
 }
 #appmenuSecondaryPane {
   -moz-border-start: 1px solid ThreeDShadow;
 }
--- a/browser/themes/gnomestripe/browser/tabview/tabview.css
+++ b/browser/themes/gnomestripe/browser/tabview/tabview.css
@@ -155,17 +155,17 @@ html[dir=rtl] .expander {
 }
 
 html[dir=rtl] .stacked .thumb {
   box-shadow: rgba(0,0,0,.2) -1px 1px 4px;
 }
 
 .stack-trayed .tab-title {
   text-shadow: rgba(0,0,0,1) 1px 1px 1.5px;
-  color: WindowText;
+  color: #EEE;
   font-size: 11px;
 }
 
 html[dir=rtl] .stack-trayed .tab-title {
   text-shadow: rgba(0,0,0,1) -1px 1px 1.5px;
 }
 
 .stack-trayed .thumb {
@@ -223,16 +223,20 @@ html[dir=rtl] .groupItem {
     rgba(0,0,0,0.8) 2px 2px 8px;
 }
 
 html[dir=rtl] .groupItem.activeGroupItem {
   box-shadow:
     rgba(0,0,0,0.8) -2px 2px 8px;
 }
 
+.groupItem .close {
+  z-index: 10;
+}
+
 .phantom {
   border: 1px solid rgba(190,190,190,1);
 }
 
 .dragRegion {
   background: rgba(248,248,248,0.4);
 }
 
--- a/browser/themes/pinstripe/browser/browser.css
+++ b/browser/themes/pinstripe/browser/browser.css
@@ -562,18 +562,22 @@ toolbar[mode="icons"] #forward-button {
 #home-button.bookmark-item > .toolbarbutton-icon {
   display: -moz-box !important;
   -moz-margin-start: -2px;
   -moz-margin-end: 3px;
 }
 
 /* tabview button */
 
+#tabview-button,
+#menu_tabview {
+  list-style-image: url(chrome://browser/skin/tabview/tabview.png);
+}
+
 #tabview-button {
-  list-style-image: url(chrome://browser/skin/tabview/tabview.png);
   -moz-image-region: rect(0, 100px, 20px, 80px);
 }
 
 #tabview-button[groups="0"] {
   -moz-image-region: rect(0, 20px, 20px, 0);
 }
 
 #tabview-button[groups="1"] {
@@ -583,16 +587,36 @@ toolbar[mode="icons"] #forward-button {
 #tabview-button[groups="2"] {
   -moz-image-region: rect(0, 60px, 20px, 40px);
 }
 
 #tabview-button[groups="3"] {
   -moz-image-region: rect(0, 80px, 20px, 60px);
 }
 
+#menu_tabview {
+  -moz-image-region: rect(2px, 98px, 18px, 82px);
+}
+
+#menu_tabview[groups="0"] {
+  -moz-image-region: rect(2px, 18px, 18px, 2px);
+}
+
+#menu_tabview[groups="1"] {
+  -moz-image-region: rect(2px, 38px, 18px, 22px);
+}
+
+#menu_tabview[groups="2"] {
+  -moz-image-region: rect(2px, 58px, 18px, 42px);
+}
+
+#menu_tabview[groups="3"] {
+  -moz-image-region: rect(2px, 78px, 18px, 62px);
+}
+
 /* download manager button */
 
 #downloads-button {
   -moz-image-region: rect(0, 140px, 20px, 120px);
 }
 
 /* history sidebar button */
 
--- a/browser/themes/pinstripe/browser/tabview/tabview.css
+++ b/browser/themes/pinstripe/browser/tabview/tabview.css
@@ -191,22 +191,22 @@ html[dir=rtl] .stack-trayed .tab-title {
 }
 
 /* Tab GroupItem
 ----------------------------------*/
 
 .tabInGroupItem {
   box-shadow: none;
   border-color: transparent;
-  background-color: transparent;
+  background-color: rgb(240,240,240);
   margin: 8px;
 }
 
 .tabInGroupItem .favicon {
-  background-color: #EBEBEB;
+  background-color: rgb(240,240,240);
 }
 
 .groupItem {
   cursor: move;
   background-color: rgb(240,240,240);
   border-radius: 0.4em;
   box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
   border: 1px solid rgba(255, 255, 255, 0.5);
@@ -217,16 +217,20 @@ html[dir=rtl] .stack-trayed .tab-title {
     rgba(0,0,0,0.8) 2px 2px 8px;
 }
 
 html[dir=rtl] .groupItem.activeGroupItem {
   box-shadow:
     rgba(0,0,0,0.8) -2px 2px 8px;
 }
 
+.groupItem .close {
+  z-index: 10;
+}
+
 .phantom {
   border: 1px solid rgba(255, 255, 255, 0.5);
 }
 
 .dragRegion {
   background: rgba(235, 235, 235, 0.4);
 }
 
--- a/browser/themes/winstripe/browser/browser-aero.css
+++ b/browser/themes/winstripe/browser/browser-aero.css
@@ -165,29 +165,25 @@
   #main-window[sizemode=normal]:not([inFullscreen=true])[tabsontop=true] #nav-bar:not(:-moz-lwtheme),
   #main-window[sizemode=normal][tabsontop=true] > #nav-bar[collapsed=true]:not([customizing]) + toolbar:not(:-moz-lwtheme),
   #main-window[sizemode=normal][tabsontop=true] > #nav-bar[collapsed=true]:not([customizing]) + #customToolbars + #PersonalToolbar:not(:-moz-lwtheme) {
     border-top: 1px solid @toolbarShadowColor@;
     border-top-left-radius: 3.5px;
     border-top-right-radius: 3.5px;
     background-clip: padding-box;
   }
-  #main-window[sizemode=normal]:not([inFullscreen=true])[disablechrome] #navigator-toolbox::after {
-    visibility: visible;
-    background-color: @toolbarShadowColor@;
+  #main-window[sizemode=normal]:not([inFullscreen]):not([disablechrome]) #TabsToolbar[tabsontop=true]:not(:-moz-lwtheme) {
+    margin-bottom: -1px;
+    background-image: none !important;
   }
-  #main-window[sizemode=normal]:not([inFullscreen=true]) #TabsToolbar[tabsontop=true]:not(:-moz-lwtheme),
-  #main-window[sizemode=normal]:not([inFullscreen=true])[disablechrome] #TabsToolbar {
-    margin-bottom: -1px;
+  #main-window[sizemode=normal]:not([inFullscreen]):not([disablechrome]) #tabbrowser-tabs[tabsontop=true] > .tabbrowser-arrowscrollbox > .arrowscrollbox-scrollbox > .scrollbox-innerbox:not(:-moz-lwtheme) {
     position: relative;
-    background-image: none !important;
   }
 
   #navigator-toolbox[tabsontop=false] > #PersonalToolbar {
-    padding-top: 0 !important;
     margin-top: 2px;
     border-top: 1px solid @toolbarShadowColor@;
   }
   #navigator-toolbox[tabsontop=false] > #PersonalToolbar:not(:-moz-lwtheme) {
     background-image: -moz-linear-gradient(@toolbarHighlight@, rgba(255,255,255,0));
   }
 
   #main-window[sizemode="normal"] #TabsToolbar[tabsontop="true"]:not([inFullscreen="true"]):not(:-moz-lwtheme) {
@@ -284,17 +280,17 @@
   #main-window:-moz-system-metric(windows-default-theme) {
     background-color: rgb(185,209,234);
   }
   #main-window:-moz-system-metric(windows-default-theme):-moz-window-inactive {
     background-color: rgb(215,228,242);
   }
 
   #toolbar-menubar:not([autohide=true]):not(:-moz-lwtheme):-moz-system-metric(windows-default-theme),
-  #main-window:not([tabsintitlebar]) #TabsToolbar[tabsontop=true]:not(:-moz-lwtheme):-moz-system-metric(windows-default-theme),
+  #TabsToolbar[tabsontop=true]:not(:-moz-lwtheme):-moz-system-metric(windows-default-theme),
   #navigator-toolbox[tabsontop=false] > toolbar:not(#toolbar-menubar):not(:-moz-lwtheme):-moz-system-metric(windows-default-theme) {
     -moz-binding: url("chrome://global/content/bindings/toolbar.xml#toolbar-drag");
     background-color: transparent;
   }
   #toolbar-menubar[autohide=true]:-moz-system-metric(windows-default-theme) {
     background-color: transparent;
   }
 
--- a/browser/themes/winstripe/browser/browser.css
+++ b/browser/themes/winstripe/browser/browser.css
@@ -110,22 +110,16 @@
   #main-window[tabsintitlebar] #titlebar-content:-moz-lwtheme {
     -moz-binding: url("chrome://global/content/bindings/general.xml#windowdragbox");
     visibility: visible;
   }
 %ifdef WINSTRIPE_AERO
 }
 %endif
 
-#navigator-toolbox[iconsize="small"] > #nav-bar,
-#navigator-toolbox > toolbar:not(#nav-bar):not(#toolbar-menubar):not(#TabsToolbar)[iconsize="small"] {
-  padding-top: 1px;
-  padding-bottom: 1px;
-}
-
 #navigator-toolbox[tabsontop="true"] > #nav-bar,
 #navigator-toolbox[tabsontop="true"]:not([customizing]) > #nav-bar[collapsed="true"] + toolbar,
 #navigator-toolbox[tabsontop="true"]:not([customizing]) > #nav-bar[collapsed="true"] + #customToolbars + #PersonalToolbar {
   background-image: -moz-linear-gradient(@toolbarHighlight@, rgba(255,255,255,0));
 }
 
 #personal-bookmarks {
   min-height: 24px;
@@ -217,16 +211,19 @@
   height: auto;
   padding: 0;
   margin: 0;
   -moz-margin-start: .5em;
 }
 
 .splitmenu-menuitem {
   -moz-margin-end: 1px;
+%ifdef WINSTRIPE_AERO
+  -moz-padding-end: 0.5em;
+%endif
 }
 
 .splitmenu-menu {
   -moz-box-pack: end;
 }
 
 .appmenu-edit-button {
   -moz-appearance: none;
@@ -584,16 +581,26 @@ menuitem.bookmark-item {
   opacity: .4;
 }
 
 #nav-bar {
   /* force iconsize="small" on this toolbar */
   counter-reset: smallicons;
 }
 
+#navigator-toolbox[iconsize=small] > #nav-bar {
+  padding-top: 1px;
+  padding-bottom: 1px;
+}
+
+#navigator-toolbox[iconsize=large][mode=icons] > #nav-bar {
+  padding-left: 2px;
+  padding-right: 2px;
+}
+
 #nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-button,
 #nav-bar .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker,
 #nav-bar .toolbarbutton-1 {
   -moz-appearance: none;
   padding: 1px 5px;
   background: rgba(151,152,153,.05)
               -moz-linear-gradient(rgba(251,252,253,.95), rgba(246,247,248,.47) 49%, 
                                    rgba(231,232,233,.45) 51%, rgba(225,226,229,.3));
@@ -870,18 +877,22 @@ toolbar[mode="full"] .toolbarbutton-1 > 
   list-style-image: url("chrome://browser/skin/Toolbar.png");
 }
 #home-button {
   -moz-image-region: rect(0, 90px, 18px, 72px);
 }
 
 /* tabview button */
 
+#tabview-button,
+#menu_tabview {
+  list-style-image: url(chrome://browser/skin/tabview/tabview.png);
+}
+
 #tabview-button {
-  list-style-image: url(chrome://browser/skin/tabview/tabview.png);
   -moz-image-region: rect(0, 90px, 18px, 72px);
 }
 
 #tabview-button[groups="0"] {
   -moz-image-region: rect(0, 18px, 18px, 0);
 }
 
 #tabview-button[groups="1"] {
@@ -891,16 +902,36 @@ toolbar[mode="full"] .toolbarbutton-1 > 
 #tabview-button[groups="2"] {
   -moz-image-region: rect(0, 54px, 18px, 36px);
 }
 
 #tabview-button[groups="3"] {
   -moz-image-region: rect(0, 72px, 18px, 54px);
 }
 
+#menu_tabview {
+  -moz-image-region: rect(1px, 89px, 17px, 73px);
+}
+
+#menu_tabview[groups="0"] {
+  -moz-image-region: rect(1px, 17px, 17px, 1px);
+}
+
+#menu_tabview[groups="1"] {
+  -moz-image-region: rect(1px, 35px, 17px, 19px);
+}
+
+#menu_tabview[groups="2"] {
+  -moz-image-region: rect(1px, 53px, 17px, 37px);
+}
+
+#menu_tabview[groups="3"] {
+  -moz-image-region: rect(1px, 71px, 17px, 55px);
+}
+
 /* download manager button */
 
 #downloads-button {
   -moz-image-region: rect(0, 108px, 18px, 90px);
 }
 
 /* history sidebar button */
 
--- a/browser/themes/winstripe/browser/tabview/tabview.css
+++ b/browser/themes/winstripe/browser/tabview/tabview.css
@@ -246,16 +246,20 @@ html[dir=rtl] .groupItem {
     rgba(0,0,0,0.8) 2px 2px 8px;
 }
 
 html[dir=rtl] .groupItem.activeGroupItem {
   box-shadow:
     rgba(0,0,0,0.8) -2px 2px 8px;
 }
 
+.groupItem .close {
+  z-index: 10;
+}
+
 .dragRegion {
   background: rgba(224, 234, 245, 0.4);
 }
 
 .overlay {
   background-color: rgba(0,0,0,.7) !important;
   box-shadow: 3px 3px 5.5px rgba(0,0,0,.5);
   border-radius: 0.4em;
--- a/build/mobile/devicemanager.py
+++ b/build/mobile/devicemanager.py
@@ -275,16 +275,19 @@ class DeviceManager:
     return '\n'.join(retVal)
   
 
   # external function
   # returns:
   #  success: True
   #  failure: False
   def pushFile(self, localname, destname):
+    if (os.name == "nt"):
+      destname = destname.replace('\\', '/')
+
     if (self.debug >= 3): print "in push file with: " + localname + ", and: " + destname
     if (self.validateFile(destname, localname) == True):
       if (self.debug >= 3): print "files are validated"
       return True
 
     if self.mkDirs(destname) == None:
       print "unable to make dirs: " + destname
       return False
@@ -481,21 +484,27 @@ class DeviceManager:
           #android returns <userID> <procID> <procName>
           files += [[pidproc[1], pidproc[2], pidproc[0]]]     
     return files
 
   # external function
   # returns:
   #  success: pid
   #  failure: None
-  def fireProcess(self, appname):
+  def fireProcess(self, appname, failIfRunning=False):
+    if (not appname):
+      if (self.debug >= 1): print "WARNING: fireProcess called with no command to run"
+      return None
+
     if (self.debug >= 2): print "FIRE PROC: '" + appname + "'"
-    
+
     if (self.processExist(appname) != None):
       print "WARNING: process %s appears to be running already\n" % appname
+      if (failIfRunning):
+        return None
     
     try:
       data = self.verifySendCMD(['exec ' + appname])
     except(DMError):
       return None
 
     # wait up to 30 seconds for process to start up
     timeslept = 0
@@ -508,29 +517,33 @@ class DeviceManager:
 
     if (self.debug >= 4): print "got pid: %s for process: %s" % (process, appname)
     return process
 
   # external function
   # returns:
   #  success: output filename
   #  failure: None
-  def launchProcess(self, cmd, outputFile = "process.txt", cwd = '', env = ''):
+  def launchProcess(self, cmd, outputFile = "process.txt", cwd = '', env = '', failIfRunning=False):
+    if not cmd:
+      if (self.debug >= 1): print "WARNING: launchProcess called without command to run"
+      return None
+
     cmdline = subprocess.list2cmdline(cmd)
     if (outputFile == "process.txt" or outputFile == None):
       outputFile = self.getDeviceRoot();
       if outputFile is None:
         return None
       outputFile += "/process.txt"
       cmdline += " > " + outputFile
     
     # Prepend our env to the command 
     cmdline = '%s %s' % (self.formatEnvString(env), cmdline)
 
-    if self.fireProcess(cmdline) is None:
+    if self.fireProcess(cmdline, failIfRunning) is None:
       return None
     return outputFile
   
   # loops until 'process' has exited or 'timeout' seconds is reached
   # loop sleeps for 'interval' seconds between iterations
   # external function
   # returns:
   #  success: [file contents, None]
@@ -1068,17 +1081,17 @@ class DeviceManager:
     # Format the process output
     if 'process' in result:
       proclist = []
       for l in result['process']:
         if l:
           proclist.append(l.split('\t'))
       result['process'] = proclist
 
-    print "results: " + str(result)
+    if (self.debug >= 3): print "results: " + str(result)
     return result
 
   """
   Installs the application onto the device
   Application bundle - path to the application bundle on the device
   Destination - destination directory of where application should be
                 installed to (optional)
   Returns None for success, or output if known failure
@@ -1149,33 +1162,33 @@ class DeviceManager:
       # Then we pass '' for processName
       cmd += "'' " + appBundlePath
     else:
       cmd += processName + ' ' + appBundlePath
 
     if (destPath):
       cmd += " " + destPath
 
-    if (self.debug > 3): print "INFO: updateApp using command: " + str(cmd)
-
     if (ipAddr is not None):
       ip, port = self.getCallbackIpAndPort(ipAddr, port)
       cmd += " %s %s" % (ip, port)
       # Set up our callback server
       callbacksvr = callbackServer(ip, port, self.debug)
 
+    if (self.debug >= 3): print "INFO: updateApp using command: " + str(cmd)
+
     try:
       status = self.verifySendCMD([cmd])
     except(DMError):
       return None
 
     if ipAddr is not None:
       status = callbacksvr.disconnect()
 
-    if (self.debug > 3): print "INFO: updateApp: got status back: " + str(status)
+    if (self.debug >= 3): print "INFO: updateApp: got status back: " + str(status)
 
     return status
 
   """
     return the current time on the device
   """
   # external function
   # returns:
@@ -1204,54 +1217,106 @@ class DeviceManager:
     else:
       port = nettools.findOpenPort(ip, 30000)
     return ip, port
 
   """
     Returns a properly formatted env string for the agent.
     Input - env, which is either None, '', or a dict
     Output - a quoted string of the form: '"envvar1=val1,envvar2=val2..."'
-    If env is None or '' return '""' (empty quoted string)
+    If env is None or '' return '' (empty quoted string)
   """
   def formatEnvString(self, env):
     if (env == None or env == ''):
-      return '""'
+      return ''
+
+    retVal = '"%s"' % ','.join(map(lambda x: '%s=%s' % (x[0], x[1]), env.iteritems()))
+    if (retVal == '""'):
+      return ''
+
+    return retVal
+
+  """
+    adjust the screen resolution on the device, REBOOT REQUIRED
+    NOTE: this only works on a tegra ATM
+    success: True
+    failure: False
+
+    supported resolutions: 640x480, 800x600, 1024x768, 1152x864, 1200x1024, 1440x900, 1680x1050, 1920x1080
+  """
+  def adjustResolution(self, width=1680, height=1050, type='hdmi'):
+    if self.getInfo('os')['os'][0].split()[0] != 'harmony-eng':
+      if (self.debug >= 2): print "WARNING: unable to adjust screen resolution on non Tegra device"
+      return False
+
+    results = self.getInfo('screen')
+    parts = results['screen'][0].split(':')
+    if (self.debug >= 3): print "INFO: we have a current resolution of %s, %s" % (parts[1].split()[0], parts[2].split()[0])
 
-    return '"%s"' % ','.join(map(lambda x: '%s=%s' % (x[0], x[1]), env.iteritems()))
+    #verify screen type is valid, and set it to the proper value (https://bugzilla.mozilla.org/show_bug.cgi?id=632895#c4)
+    screentype = -1
+    if (type == 'hdmi'):
+      screentype = 5
+    elif (type == 'vga' or type == 'crt'):
+      screentype = 3
+    else:
+      return False
+
+    #verify we have numbers
+    if not (isinstance(width, int) and isinstance(height, int)):
+      return False
+
+    if (width < 100 or width > 9999):
+      return False
+
+    if (height < 100 or height > 9999):
+      return False
+
+    if (self.debug >= 3): print "INFO: adjusting screen resolution to %s, %s and rebooting" % (width, height)
+    try:
+      self.verifySendCMD(["exec setprop persist.tegra.dpy%s.mode.width %s" % (screentype, width)])
+      self.verifySendCMD(["exec setprop persist.tegra.dpy%s.mode.height %s" % (screentype, height)])
+    except(DMError):
+      return False
+
+    if (self.reboot(True) == None):
+      return False
+
+    return True
 
 gCallbackData = ''
 
 class myServer(SocketServer.TCPServer):
   allow_reuse_address = True
 
 class callbackServer():
   def __init__(self, ip, port, debuglevel):
     self.ip = ip
     self.port = port
     self.connected = False
     self.debug = debuglevel
-    if (self.debug > 3) : print "Creating server with " + str(ip) + ":" + str(port)
+    if (self.debug >= 3) : print "Creating server with " + str(ip) + ":" + str(port)
     self.server = myServer((ip, port), self.myhandler)
     self.server_thread = Thread(target=self.server.serve_forever) 
     self.server_thread.setDaemon(True)
     self.server_thread.start()
 
   def disconnect(self, step = 60, timeout = 600):
     t = 0
-    if (self.debug > 3): print "Calling disconnect on callback server"
+    if (self.debug >= 3): print "Calling disconnect on callback server"
     while t < timeout:
       if (gCallbackData):
         # Got the data back
-        if (self.debug > 3): print "Got data back from agent: " + str(gCallbackData)
+        if (self.debug >= 3): print "Got data back from agent: " + str(gCallbackData)
         break
       time.sleep(step)
       t += step
 
     try:
-      if (self.debug > 3): print "Shutting down server now"
+      if (self.debug >= 3): print "Shutting down server now"
       self.server.shutdown()
     except:
       print "Unable to shutdown callback server - check for a connection on port: " + str(self.port)
     return gCallbackData
 
   class myhandler(SocketServer.BaseRequestHandler):
     def handle(self):
       global gCallbackData
--- a/build/mobile/remoteautomation.py
+++ b/build/mobile/remoteautomation.py
@@ -114,28 +114,31 @@ class RemoteAutomation(Automation):
 #        return app, ['--environ:NO_EM_RESTART=1'] + args
         return app, args
 
     def getLanIp(self):
         nettools = NetworkTools()
         return nettools.getLanIp()
 
     def Process(self, cmd, stdout = None, stderr = None, env = None, cwd = '.'):
-        if stdout == None or stdout == -1:
+        if stdout == None or stdout == -1 or stdout == subprocess.PIPE:
           stdout = self._remoteLog
 
         return self.RProcess(self._devicemanager, cmd, stdout, stderr, env, cwd)
 
     # be careful here as this inner class doesn't have access to outer class members    
     class RProcess(object):
         # device manager process
         dm = None
         def __init__(self, dm, cmd, stdout = None, stderr = None, env = None, cwd = '.'):
             self.dm = dm
-            self.proc = dm.launchProcess(cmd, stdout, cwd, env)
+            self.stdoutlen = 0
+            self.proc = dm.launchProcess(cmd, stdout, cwd, env, True)
+            if (self.proc is None):
+              raise Exception("unable to launch process")
             exepath = cmd[0]
             name = exepath.split('/')[-1]
             self.procName = name
 
             # Setting timeout at 1 hour since on a remote device this takes much longer
             self.timeout = 3600
             time.sleep(15)
 
@@ -143,26 +146,33 @@ class RemoteAutomation(Automation):
         def pid(self):
             hexpid = self.dm.processExist(self.procName)
             if (hexpid == None):
                 hexpid = "0x0"
             return int(hexpid, 0)
     
         @property
         def stdout(self):
-            return self.dm.getFile(self.proc)
+            t = self.dm.getFile(self.proc)
+            if t == None: return ''
+            tlen = len(t)
+            retVal = t[self.stdoutlen:]
+            self.stdoutlen = tlen
+            return retVal.strip('\n').strip()
  
         def wait(self, timeout = None):
             timer = 0
             interval = 5
 
             if timeout == None:
                 timeout = self.timeout
 
             while (self.dm.processExist(self.procName)):
+                t = self.stdout
+                if t != '': print t
                 time.sleep(interval)
                 timer += interval
                 if (timer > timeout):
                     break
 
             if (timer >= timeout):
                 return 1
             return 0
--- a/build/unix/elfhack/Makefile.in
+++ b/build/unix/elfhack/Makefile.in
@@ -83,17 +83,17 @@ test$(DLL_SUFFIX): test.$(OBJ_SUFFIX) el
 	@rm -f $@.bak
 	$(CURDIR)/elfhack -b $@
 	# Fail if the backup file doesn't exist
 	[ -f "$@.bak" ]
 	# Fail if the new library doesn't contain less relocations
 	[ $$(objdump -R $@.bak | wc -l) -gt $$(objdump -R $@ | wc -l) ]
 
 dummy: dummy.$(OBJ_SUFFIX) test$(DLL_SUFFIX)
-	$(CC) -o $@ $^
+	$(CC) $(LDFLAGS) -o $@ $^
 
 libs:: dummy
 	# Will either crash or return exit code 1 if elfhack is broken
 	LD_LIBRARY_PATH=$(CURDIR) $(CURDIR)/dummy
 
 CSRCS += test.c dummy.c
 
 GARBAGE += dummy test$(DLL_SUFFIX) test$(DLL_SUFFIX).bak
@@ -111,8 +111,9 @@ GARBAGE_DIRS += inject
 # on mozilla buildbots
 OS_CXXFLAGS := $(filter-out -pedantic,$(OS_CXXFLAGS))
 
 include $(topsrcdir)/config/rules.mk
 
 inject/%.$(OBJ_SUFFIX): DEFINES += -DBITS=$(if $(HAVE_64BIT_OS),64,32)
 inject/%.$(OBJ_SUFFIX): CFLAGS := -O2 -fno-stack-protector $(filter -m% -I%,$(CFLAGS))
 inject/$(CPU)-noinit.$(OBJ_SUFFIX): DEFINES += -DNOINIT
+test.$(OBJ_SUFFIX): CFLAGS := -O0
--- a/config/config.mk
+++ b/config/config.mk
@@ -214,18 +214,22 @@ OS_LDFLAGS += $(MOZ_MEMORY_LDFLAGS)
 endif
 
 # MOZ_DEBUG_SYMBOLS generates debug symbols in separate PDB files.
 # Used for generating an optimized build with debugging symbols.
 # Used in the Windows nightlies to generate symbols for crash reporting.
 ifdef MOZ_DEBUG_SYMBOLS
 OS_CXXFLAGS += -Zi -UDEBUG -DNDEBUG
 OS_CFLAGS += -Zi -UDEBUG -DNDEBUG
+ifdef HAVE_64BIT_OS
+OS_LDFLAGS += -DEBUG -OPT:REF,ICF
+else
 OS_LDFLAGS += -DEBUG -OPT:REF
 endif
+endif
 
 ifdef MOZ_QUANTIFY
 # -FIXED:NO is needed for Quantify to work, but it increases the size
 # of executables, so only use it if building for Quantify.
 WIN32_EXE_LDFLAGS += -FIXED:NO
 
 # We need -OPT:NOICF to prevent identical methods from being merged together.
 # Otherwise, Quantify doesn't know which method was actually called when it's
@@ -234,17 +238,21 @@ OS_LDFLAGS += -OPT:NOICF
 endif
 
 #
 # Handle trace-malloc in optimized builds.
 # No opt to give sane callstacks.
 #
 ifdef NS_TRACE_MALLOC
 MOZ_OPTIMIZE_FLAGS=-Zi -Od -UDEBUG -DNDEBUG
+ifdef HAVE_64BIT_OS
+OS_LDFLAGS = -DEBUG -PDB:NONE -OPT:REF,ICF
+else
 OS_LDFLAGS = -DEBUG -PDB:NONE -OPT:REF
+endif
 endif # NS_TRACE_MALLOC
 
 endif # MOZ_DEBUG
 endif # WINNT && !GNU_CC
 
 #
 # Build using PIC by default
 # Do not use PIC if not building a shared lib (see exceptions below)
--- a/config/milestone.txt
+++ b/config/milestone.txt
@@ -5,9 +5,9 @@
 #    x.x.x.x
 #    x.x.x+
 #
 # Referenced by milestone.pl.
 # Hopefully I'll be able to automate replacement of *all*
 # hardcoded milestones in the tree from these two files.
 #--------------------------------------------------------
 
-2.0b12pre
+2.0b13pre
--- a/configure.in
+++ b/configure.in
@@ -1839,16 +1839,84 @@ dnl ====================================
 dnl = Use profiling compile flags
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(profiling,
 [  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
     MOZ_PROFILING=1,
     MOZ_PROFILING= )
 
 dnl ========================================================
+dnl = Use Valgrind
+dnl ========================================================
+MOZ_ARG_ENABLE_BOOL(valgrind,
+[  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
+    MOZ_VALGRIND=1,
+    MOZ_VALGRIND= )
+if test -n "$MOZ_VALGRIND"; then
+    AC_CHECK_HEADER([valgrind/valgrind.h], [],
+        AC_MSG_ERROR(
+            [--enable-valgrind specified but Valgrind is not installed]))
+    AC_DEFINE(MOZ_VALGRIND)
+fi
+
+dnl ========================================================
+dnl jprof
+dnl ========================================================
+MOZ_ARG_ENABLE_BOOL(jprof,
+[  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
+    MOZ_JPROF=1,
+    MOZ_JPROF= )
+if test -n "$MOZ_JPROF"; then
+    MOZ_PROFILING=1
+    AC_DEFINE(MOZ_JPROF)
+fi
+
+dnl ========================================================
+dnl shark
+dnl ========================================================
+MOZ_ARG_ENABLE_BOOL(shark,
+[  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.],
+    MOZ_SHARK=1,
+    MOZ_SHARK= )
+if test -n "$MOZ_SHARK"; then
+    MOZ_PROFILING=1
+    AC_DEFINE(MOZ_SHARK)
+fi
+
+dnl ========================================================
+dnl callgrind
+dnl ========================================================
+MOZ_ARG_ENABLE_BOOL(callgrind,
+[  --enable-callgrind      Enable callgrind profiling],
+    MOZ_CALLGRIND=1,
+    MOZ_CALLGRIND= )
+if test -n "$MOZ_CALLGRIND"; then
+    AC_DEFINE(MOZ_CALLGRIND)
+fi
+
+dnl ========================================================
+dnl vtune
+dnl ========================================================
+MOZ_ARG_ENABLE_BOOL(vtune,
+[  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.],
+    MOZ_VTUNE=1,
+    MOZ_VTUNE= )
+if test -n "$MOZ_VTUNE"; then
+    MOZ_PROFILING=1
+    AC_DEFINE(MOZ_VTUNE)
+fi
+
+dnl ========================================================
+dnl Profiling
+dnl ========================================================
+if test -n "$MOZ_PROFILING"; then
+    AC_DEFINE(MOZ_PROFILING)
+fi
+
+dnl ========================================================
 dnl System overrides of the defaults for host
 dnl ========================================================
 case "$host" in
 *-beos*)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE -DNO_X11"
     HOST_NSPR_MDCPUCFG='\"md/_beos.cfg\"'
     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
     ;;
@@ -3590,33 +3658,37 @@ fi # $no_x
 AC_SUBST(XCFLAGS)
 AC_SUBST(XLDFLAGS)
 AC_SUBST(XLIBS)
 AC_SUBST(XEXT_LIBS)
 AC_SUBST(XT_LIBS)
 AC_SUBST(XSS_LIBS)
 
 AC_MSG_CHECKING(for ARM SIMD support in compiler)
-AC_TRY_COMPILE([],
+# We try to link so that this also fails when
+# building with LTO.
+AC_TRY_LINK([],
                [asm("uqadd8 r1, r1, r2");],
                result="yes", result="no")
 AC_MSG_RESULT("$result")
 if test "$result" = "yes"; then
     AC_DEFINE(HAVE_ARM_SIMD)
     HAVE_ARM_SIMD=1
 fi
 AC_SUBST(HAVE_ARM_SIMD)
 
 AC_MSG_CHECKING(for ARM NEON support in compiler)
 _SAVE_CFLAGS="$CFLAGS"
 if test "$GNU_CC"; then
   # gcc needs -mfpu=neon to recognize NEON instructions
   CFLAGS="$CFLAGS -mfpu=neon -mfloat-abi=softfp"
 fi
-AC_TRY_COMPILE([],
+# We try to link so that this also fails when
+# building with LTO.
+AC_TRY_LINK([],
                [asm("vadd.i8 d0, d0, d0");],
                result="yes", result="no")
 AC_MSG_RESULT("$result")
 if test "$result" = "yes"; then
     AC_DEFINE(HAVE_ARM_NEON)
     HAVE_ARM_NEON=1
 fi
 CFLAGS="$_SAVE_CFLAGS"
@@ -7664,84 +7736,16 @@ MOZ_ARG_ENABLE_BOOL(gctimer,
 [  --enable-gctimer        Enable GC timer (default=no)],
     MOZ_GCTIMER=1,
     MOZ_GCTIMER= )
 if test -n "$MOZ_GCTIMER"; then
     AC_DEFINE(MOZ_GCTIMER)
 fi
 
 dnl ========================================================
-dnl = Use Valgrind
-dnl ========================================================
-MOZ_ARG_ENABLE_BOOL(valgrind,
-[  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
-    MOZ_VALGRIND=1,
-    MOZ_VALGRIND= )
-if test -n "$MOZ_VALGRIND"; then
-    AC_CHECK_HEADER([valgrind/valgrind.h], [],
-        AC_MSG_ERROR(
-            [--enable-valgrind specified but Valgrind is not installed]))
-    AC_DEFINE(MOZ_VALGRIND)
-fi
-
-dnl ========================================================
-dnl jprof
-dnl ========================================================
-MOZ_ARG_ENABLE_BOOL(jprof,
-[  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
-    MOZ_JPROF=1,
-    MOZ_JPROF= )
-if test -n "$MOZ_JPROF"; then
-    MOZ_PROFILING=1
-    AC_DEFINE(MOZ_JPROF)
-fi
-
-dnl ========================================================
-dnl shark
-dnl ========================================================
-MOZ_ARG_ENABLE_BOOL(shark,
-[  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.],
-    MOZ_SHARK=1,
-    MOZ_SHARK= )
-if test -n "$MOZ_SHARK"; then
-    MOZ_PROFILING=1
-    AC_DEFINE(MOZ_SHARK)
-fi
-
-dnl ========================================================
-dnl callgrind
-dnl ========================================================
-MOZ_ARG_ENABLE_BOOL(callgrind,
-[  --enable-callgrind      Enable callgrind profiling],
-    MOZ_CALLGRIND=1,
-    MOZ_CALLGRIND= )
-if test -n "$MOZ_CALLGRIND"; then
-    AC_DEFINE(MOZ_CALLGRIND)
-fi
-
-dnl ========================================================
-dnl vtune
-dnl ========================================================
-MOZ_ARG_ENABLE_BOOL(vtune,
-[  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.],
-    MOZ_VTUNE=1,
-    MOZ_VTUNE= )
-if test -n "$MOZ_VTUNE"; then
-    MOZ_PROFILING=1
-    AC_DEFINE(MOZ_VTUNE)
-fi
-
-dnl ========================================================
-dnl Profiling
-dnl ========================================================
-if test -n "$MOZ_PROFILING"; then
-    AC_DEFINE(MOZ_PROFILING)
-fi
-
-dnl ========================================================
 dnl Zealous JavaScript GC
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(gczeal,
 [  --enable-gczeal         Enable zealous JavaScript GCing],
     JS_GC_ZEAL=1,
     JS_GC_ZEAL= )
 if test -n "$JS_GC_ZEAL"; then
     AC_DEFINE(JS_GC_ZEAL)
@@ -7815,17 +7819,17 @@ MOZ_ARG_ENABLE_BOOL(elf-dynstr-gc,
 [  --enable-elf-dynstr-gc  Enable elf dynstr garbage collector (opt builds only)],
     USE_ELF_DYNSTR_GC=1,
     USE_ELF_DYNSTR_GC= )
 
 dnl ========================================================
 dnl = --disable-elf-hack
 dnl ========================================================
 
-USE_ELF_HACK=1
+USE_ELF_HACK=
 MOZ_ARG_DISABLE_BOOL(elf-hack,
 [  --disable-elf-hack      Disable elf hacks],
     USE_ELF_HACK=,
     USE_ELF_HACK=1)
 
 dnl ========================================================
 dnl = 
 dnl = Profiling and Instrumenting
@@ -8354,17 +8358,17 @@ MOZ_ARG_ENABLE_BOOL(static,
     BUILD_STATIC_LIBS=)
 
 MOZ_ARG_ENABLE_BOOL(libxul,
 [  --enable-libxul         Enable building of libxul],
     MOZ_ENABLE_LIBXUL=1,
     MOZ_ENABLE_LIBXUL=)
 
 # split JS out by default to avoid VS2005 PGO crash (bug 591836).
-if test "$OS_ARCH" = "WINNT"; then
+if test "$OS_ARCH" = "WINNT" -a "$CPU_ARCH" != "x86_64" ; then
   ENABLE_SHARED_JS=1
 fi
 
 MOZ_ARG_ENABLE_BOOL(shared-js,
 [  --enable-shared-js
                           Create a shared JavaScript library.],
     ENABLE_SHARED_JS=1,
     ENABLE_SHARED_JS=)
@@ -9670,8 +9674,9 @@ fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_
 dnl Prevent the regeneration of autoconf.mk forcing rebuilds of the world
 dnl Needs to be at the end to respect possible changes from NSPR configure
 if cmp -s config/autoconf.mk config/autoconf.mk.orig; then
   echo "config/autoconf.mk is unchanged"
   mv -f config/autoconf.mk.orig config/autoconf.mk 2> /dev/null
 else
   rm -f config/autoconf.mk.orig 2> /dev/null
 fi
+
--- a/content/base/public/nsDOMFile.h
+++ b/content/base/public/nsDOMFile.h
@@ -148,16 +148,17 @@ public:
   NS_IMETHOD GetName(nsAString&);
   NS_IMETHOD GetSize(PRUint64*);
   NS_IMETHOD GetInternalStream(nsIInputStream**);
   NS_IMETHOD GetMozFullPathInternal(nsAString&);
   NS_IMETHOD Slice(PRUint64 aStart, PRUint64 aLength,
                    const nsAString& aContentType, nsIDOMBlob **aBlob);
 
 protected:
+  friend class DataOwnerAdapter; // Needs to see DataOwner
   class DataOwner {
   public:
     NS_INLINE_DECL_REFCOUNTING(DataOwner)
     DataOwner(void* aMemoryBuffer)
       : mData(aMemoryBuffer)
     {
     }
     ~DataOwner() {
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -50,16 +50,17 @@
 #include "mozFlushType.h"
 #include "nsIAtom.h"