Merge MC -> JM
authorBrian Hackett <bhackett1024@gmail.com>
Sun, 14 Aug 2011 19:51:16 -0700
changeset 77434 8e7da0684155b3cb4a52f6e16bdcea1de173a280
parent 77433 1876d7b33e2f56230ac74d3c00bc6da4d42756bd (current diff)
parent 76292 8994b863880374b787d95beca4e6f038eac9cbf6 (diff)
child 77435 9cea788e8c07db2610b5c2408add1d5dac82bff0
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone8.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge MC -> JM
browser/base/content/browser.js
dom/base/nsDOMClassInfo.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsJSEnvironment.cpp
dom/workers/test/test_404.html
dom/workers/test/test_chromeWorker.html
dom/workers/test/test_chromeWorker.xul
dom/workers/test/test_chromeWorkerJSM.xul
dom/workers/test/test_close.html
dom/workers/test/test_closeOnGC.html
dom/workers/test/test_errorPropagation.html
dom/workers/test/test_fibonacci.html
dom/workers/test/test_importScripts.html
dom/workers/test/test_json.html
dom/workers/test/test_longThread.html
dom/workers/test/test_navigator.html
dom/workers/test/test_recursion.html
dom/workers/test/test_relativeLoad.html
dom/workers/test/test_simpleThread.html
dom/workers/test/test_suspend.html
dom/workers/test/test_terminate.html
dom/workers/test/test_threadErrors.html
dom/workers/test/test_threadTimeouts.html
dom/workers/test/test_throwingOnerror.html
dom/workers/test/test_xhr.html
dom/workers/test/test_xhrAbort.html
js/src/Makefile.in
js/src/assembler/assembler/ARMAssembler.cpp
js/src/assembler/assembler/ARMAssembler.h
js/src/assembler/assembler/MacroAssemblerARM.h
js/src/assembler/assembler/MacroAssemblerX86Common.h
js/src/config/autoconf.mk.in
js/src/configure.in
js/src/jit-test/jit_test.py
js/src/jit-test/tests/basic/testBug653396.js
js/src/jit-test/tests/basic/testCompileScript.js
js/src/jit-test/tests/jaeger/bug563000/simple-trap-1.js
js/src/jit-test/tests/jaeger/bug563000/trap-from-add-inline.js
js/src/jit-test/tests/jaeger/bug563000/trap-from-add-ool.js
js/src/jit-test/tests/jaeger/bug563000/trap-self.js
js/src/jit-test/tests/jaeger/bug563000/untrap-self.js
js/src/jsanalyze.cpp
js/src/jsapi-tests/Makefile.in
js/src/jsapi-tests/testConservativeGC.cpp
js/src/jsapi-tests/testThreadGC.cpp
js/src/jsapi-tests/testThreads.cpp
js/src/jsapi.cpp
js/src/jsapi.h
js/src/jsarray.cpp
js/src/jsarray.h
js/src/jsatom.cpp
js/src/jsbuiltins.h
js/src/jsclone.cpp
js/src/jscntxt.cpp
js/src/jscntxt.h
js/src/jscntxtinlines.h
js/src/jscompartment.cpp
js/src/jscompartment.h
js/src/jsdate.cpp
js/src/jsdbgapi.cpp
js/src/jsemit.cpp
js/src/jsemit.h
js/src/jsexn.cpp
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
js/src/jsfun.cpp
js/src/jsfun.h
js/src/jsgc.cpp
js/src/jsgc.h
js/src/jsgcinlines.h
js/src/jsgcmark.cpp
js/src/jshashtable.h
js/src/jsinfer.cpp
js/src/jsinterp.cpp
js/src/jsinterpinlines.h
js/src/jsiter.cpp
js/src/jsmath.cpp
js/src/jsnum.cpp
js/src/jsobj.cpp
js/src/jsobj.h
js/src/jsobjinlines.h
js/src/json.cpp
js/src/jsopcode.cpp
js/src/jsopcode.h
js/src/jsopcode.tbl
js/src/jsparse.cpp
js/src/jsparse.h
js/src/jsprobes.cpp
js/src/jspropertycache.cpp
js/src/jsproxy.cpp
js/src/jsprvtd.h
js/src/jsreflect.cpp
js/src/jsregexp.cpp
js/src/jsscope.cpp
js/src/jsscopeinlines.h
js/src/jsscript.cpp
js/src/jsscript.h
js/src/jsscriptinlines.h
js/src/jsstr.cpp
js/src/jstracer.cpp
js/src/jstracer.h
js/src/jstypedarray.cpp
js/src/jstypedarray.h
js/src/jstypedarrayinlines.h
js/src/jsval.h
js/src/jsvalue.h
js/src/jswrapper.cpp
js/src/jswrapper.h
js/src/jsxdrapi.h
js/src/jsxml.cpp
js/src/methodjit/BaseAssembler.h
js/src/methodjit/Compiler.cpp
js/src/methodjit/Compiler.h
js/src/methodjit/FastArithmetic.cpp
js/src/methodjit/FrameState.cpp
js/src/methodjit/ICLabels.h
js/src/methodjit/InvokeHelpers.cpp
js/src/methodjit/Logging.h
js/src/methodjit/LoopState.cpp
js/src/methodjit/MachineRegs.h
js/src/methodjit/MethodJIT.cpp
js/src/methodjit/MethodJIT.h
js/src/methodjit/MonoIC.cpp
js/src/methodjit/NunboxAssembler.h
js/src/methodjit/PolyIC.cpp
js/src/methodjit/PolyIC.h
js/src/methodjit/Retcon.cpp
js/src/methodjit/StubCalls.cpp
js/src/methodjit/StubCalls.h
js/src/methodjit/TrampolineCompiler.cpp
js/src/methodjit/TypedArrayIC.h
js/src/shell/Makefile.in
js/src/shell/js.cpp
js/src/tests/e4x/XML/jstests.list
js/src/tests/js1_8_5/extensions/jstests.list
js/src/tests/js1_8_5/regress/jstests.list
js/src/tracejit/Writer.cpp
js/src/tracejit/Writer.h
js/src/vm/Debugger.cpp
js/src/vm/GlobalObject.cpp
js/src/vm/Stack-inl.h
js/src/vm/Stack.cpp
js/src/vm/Stack.h
js/src/xpconnect/shell/xpcshell.cpp
js/src/xpconnect/src/nsXPConnect.cpp
js/src/xpconnect/src/xpcinlines.h
js/src/xpconnect/src/xpcjsruntime.cpp
js/src/xpconnect/src/xpcprivate.h
js/src/xpconnect/src/xpcwrappednative.cpp
js/src/xpconnect/src/xpcwrappednativescope.cpp
js/src/xpconnect/wrappers/WrapperFactory.cpp
layout/mathml/nsMathMLmoverFrame.cpp
layout/mathml/nsMathMLmoverFrame.h
layout/mathml/nsMathMLmunderFrame.cpp
layout/mathml/nsMathMLmunderFrame.h
modules/libpref/src/init/all.js
parser/html/nsAHtml5FragmentParser.h
--- a/accessible/src/base/AccEvent.cpp
+++ b/accessible/src/base/AccEvent.cpp
@@ -226,24 +226,27 @@ AccStateChangeEvent::
   AccEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE, aAccessible,
            aIsFromUserInput, eAllowDupes),
   mState(aState), mIsEnabled(aIsEnabled)
 {
 }
 
 AccStateChangeEvent::
   AccStateChangeEvent(nsINode* aNode, PRUint64 aState, PRBool aIsEnabled):
-  AccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aNode),
+  AccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aNode,
+           eAutoDetect, eAllowDupes),
   mState(aState), mIsEnabled(aIsEnabled)
 {
 }
 
 AccStateChangeEvent::
   AccStateChangeEvent(nsINode* aNode, PRUint64 aState) :
-  AccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aNode), mState(aState)
+  AccEvent(::nsIAccessibleEvent::EVENT_STATE_CHANGE, aNode,
+           eAutoDetect, eAllowDupes),
+  mState(aState)
 {
   // Use GetAccessibleForNode() because we do not want to store an accessible
   // since it leads to problems with delayed events in the case when
   // an accessible gets reorder event before delayed event is processed.
   nsAccessible *accessible = GetAccessibleForNode();
   mIsEnabled = accessible && ((accessible->State() & mState) != 0);
 }
 
--- a/accessible/src/base/nsAccUtils.cpp
+++ b/accessible/src/base/nsAccUtils.cpp
@@ -52,16 +52,17 @@
 #include "nsXULTreeGridAccessible.h"
 
 #include "nsIDOMXULContainerElement.h"
 #include "nsIDOMXULSelectCntrlEl.h"
 #include "nsIDOMXULSelectCntrlItemEl.h"
 #include "nsWhitespaceTokenizer.h"
 #include "nsComponentManagerUtils.h"
 
+namespace dom = mozilla::dom;
 using namespace mozilla::a11y;
 
 void
 nsAccUtils::GetAccAttr(nsIPersistentProperties *aAttributes,
                        nsIAtom *aAttrName, nsAString& aAttrValue)
 {
   aAttrValue.Truncate();
 
@@ -330,16 +331,34 @@ nsAccUtils::HasDefinedARIAToken(nsIConte
                             nsAccessibilityAtoms::_empty, eCaseMatters) ||
       aContent->AttrValueIs(kNameSpaceID_None, aAtom,
                             nsAccessibilityAtoms::_undefined, eCaseMatters)) {
         return PR_FALSE;
   }
   return PR_TRUE;
 }
 
+nsIAtom*
+nsAccUtils::GetARIAToken(dom::Element* aElement, nsIAtom* aAttr)
+{
+  if (!nsAccUtils::HasDefinedARIAToken(aElement, aAttr))
+    return nsAccessibilityAtoms::_empty;
+
+  static nsIContent::AttrValuesArray tokens[] =
+    { &nsAccessibilityAtoms::_false, &nsAccessibilityAtoms::_true,
+      &nsAccessibilityAtoms::mixed, nsnull};
+
+  PRInt32 idx = aElement->FindAttrValueIn(kNameSpaceID_None,
+                                          aAttr, tokens, eCaseMatters);
+  if (idx >= 0)
+    return *(tokens[idx]);
+
+  return nsnull;
+}
+
 nsAccessible *
 nsAccUtils::GetAncestorWithRole(nsAccessible *aDescendant, PRUint32 aRole)
 {
   nsAccessible *document = aDescendant->GetDocAccessible();
   nsAccessible *parent = aDescendant;
   while ((parent = parent->Parent())) {
     PRUint32 testRole = parent->Role();
     if (testRole == aRole)
--- a/accessible/src/base/nsAccUtils.h
+++ b/accessible/src/base/nsAccUtils.h
@@ -45,17 +45,17 @@
 #include "nsIAccessibleRole.h"
 #include "nsIAccessibleText.h"
 #include "nsIAccessibleTable.h"
 
 #include "nsARIAMap.h"
 #include "nsAccessibilityService.h"
 #include "nsCoreUtils.h"
 
-#include "nsIContent.h"
+#include "mozilla/dom/Element.h"
 #include "nsIDocShell.h"
 #include "nsIDOMNode.h"
 #include "nsIPersistentProperties2.h"
 #include "nsIPresShell.h"
 #include "nsPoint.h"
 
 class nsAccessNode;
 class nsAccessible;
@@ -146,16 +146,21 @@ public:
    * property is not present, or is "" or "undefined". Do not call 
    * this method for properties of type string, decimal, IDREF or IDREFS.
    * 
    * Return PR_TRUE if the ARIA property is defined, otherwise PR_FALSE
    */
   static PRBool HasDefinedARIAToken(nsIContent *aContent, nsIAtom *aAtom);
 
   /**
+   * Return atomic value of ARIA attribute of boolean or NMTOKEN type.
+   */
+  static nsIAtom* GetARIAToken(mozilla::dom::Element* aElement, nsIAtom* aAttr);
+
+  /**
    * Return document accessible for the given presshell.
    */
   static nsDocAccessible *GetDocAccessibleFor(nsIWeakReference *aWeakShell)
   {
     nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(aWeakShell));
     return presShell ?
       GetAccService()->GetDocAccessible(presShell->GetDocument()) : nsnull;
   }
--- a/accessible/src/base/nsAccessibilityAtomList.h
+++ b/accessible/src/base/nsAccessibilityAtomList.h
@@ -60,16 +60,17 @@ ACCESSIBILITY_ATOM(button, "button")
 ACCESSIBILITY_ATOM(checkbox, "checkbox")
 ACCESSIBILITY_ATOM(col, "col")
 ACCESSIBILITY_ATOM(_empty, "")
 ACCESSIBILITY_ATOM(_false, "false")
 ACCESSIBILITY_ATOM(image, "image")
 ACCESSIBILITY_ATOM(menu, "menu")
 ACCESSIBILITY_ATOM(menuButton, "menu-button")
 ACCESSIBILITY_ATOM(multiple, "multiple")
+ACCESSIBILITY_ATOM(mixed, "mixed")
 ACCESSIBILITY_ATOM(open, "open")
 ACCESSIBILITY_ATOM(password, "password")
 ACCESSIBILITY_ATOM(radio, "radio")
 ACCESSIBILITY_ATOM(reset, "reset")
 ACCESSIBILITY_ATOM(row, "row")
 ACCESSIBILITY_ATOM(submit, "submit")
 ACCESSIBILITY_ATOM(_true, "true")
 ACCESSIBILITY_ATOM(_undefined, "undefined")
--- a/accessible/src/base/nsDocAccessible.cpp
+++ b/accessible/src/base/nsDocAccessible.cpp
@@ -79,18 +79,16 @@
 #endif
 
 namespace dom = mozilla::dom;
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Static member initialization
 
-PRUint64 nsDocAccessible::gLastFocusedAccessiblesState = 0;
-
 static nsIAtom** kRelationAttrs[] =
 {
   &nsAccessibilityAtoms::aria_labelledby,
   &nsAccessibilityAtoms::aria_describedby,
   &nsAccessibilityAtoms::aria_owns,
   &nsAccessibilityAtoms::aria_controls,
   &nsAccessibilityAtoms::aria_flowto,
   &nsAccessibilityAtoms::_for,
@@ -913,31 +911,43 @@ NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(ns
 NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsDocAccessible)
 
 void
 nsDocAccessible::AttributeWillChange(nsIDocument *aDocument,
                                      dom::Element* aElement,
                                      PRInt32 aNameSpaceID,
                                      nsIAtom* aAttribute, PRInt32 aModType)
 {
-  // XXX TODO: bugs 467143, 472142, 472143.
-  // Here we will want to cache whatever state we are potentially interested in,
-  // such as the existence of aria-pressed for button (so we know if we need to
-  // newly expose it as a toggle button) etc.
+  nsAccessible* accessible = GetAccessible(aElement);
+  if (!accessible) {
+    if (aElement != mContent)
+      return;
+
+    accessible = this;
+  }
 
   // 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);
+  if (aModType != nsIDOMMutationEvent::ADDITION)
+    RemoveDependentIDsFor(accessible, aAttribute);
+
+  // Store the ARIA attribute old value so that it can be used after
+  // attribute change. Note, we assume there's no nested ARIA attribute
+  // changes. If this happens then we should end up with keeping a stack of
+  // old values.
+
+  // XXX TODO: bugs 472142, 472143.
+  // Here we will want to cache whatever attribute values we are interested
+  // in, such as the existence of aria-pressed for button (so we know if we
+  // need to newly expose it as a toggle button) etc.
+  if (aAttribute == nsAccessibilityAtoms::aria_checked ||
+      aAttribute == nsAccessibilityAtoms::aria_pressed) {
+    mARIAAttrOldValue = (aModType != nsIDOMMutationEvent::ADDITION) ?
+      nsAccUtils::GetARIAToken(aElement, aAttribute) : nsnull;
   }
 }
 
 void
 nsDocAccessible::AttributeChanged(nsIDocument *aDocument,
                                   dom::Element* aElement,
                                   PRInt32 aNameSpaceID, nsIAtom* aAttribute,
                                   PRInt32 aModType)
@@ -971,20 +981,16 @@ nsDocAccessible::AttributeChanged(nsIDoc
   // 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
   // dependent IDs for non accessible elements. For the second case we'll update
   // dependent IDs cache when its accessible is created.
   if (aModType == nsIDOMMutationEvent::MODIFICATION ||
       aModType == nsIDOMMutationEvent::ADDITION) {
     AddDependentIDsFor(accessible, aAttribute);
   }
-
-  // If it was the focused node, cache the new state.
-  if (aElement == gLastFocusedNode)
-    gLastFocusedAccessiblesState = accessible->State();
 }
 
 // nsDocAccessible protected member
 void
 nsDocAccessible::AttributeChangedImpl(nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute)
 {
   // Fire accessible event after short timer, because we need to wait for
   // DOM attribute & resulting layout to actually change. Otherwise,
@@ -1040,18 +1046,18 @@ nsDocAccessible::AttributeChangedImpl(ns
       aAttribute == nsAccessibilityAtoms::aria_label ||
       aAttribute == nsAccessibilityAtoms::aria_labelledby) {
     FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE,
                                aContent);
     return;
   }
 
   if (aAttribute == nsAccessibilityAtoms::aria_busy) {
-    PRBool isOn = !aContent->AttrValueIs(aNameSpaceID, aAttribute,
-                                         nsAccessibilityAtoms::_true, eCaseMatters);
+    PRBool isOn = aContent->AttrValueIs(aNameSpaceID, aAttribute,
+                                        nsAccessibilityAtoms::_true, eCaseMatters);
     nsRefPtr<AccEvent> event = new AccStateChangeEvent(aContent, states::BUSY, isOn);
     FireDelayedAccessibleEvent(event);
     return;
   }
 
   if (aAttribute == nsAccessibilityAtoms::selected ||
       aAttribute == nsAccessibilityAtoms::aria_selected) {
     // ARIA or XUL selection
@@ -1153,34 +1159,28 @@ nsDocAccessible::ARIAAttributeChanged(ns
     return;
   }
 
   // The following ARIA attributes only take affect when dynamic content role is present
   if (aAttribute == nsAccessibilityAtoms::aria_checked ||
       aAttribute == nsAccessibilityAtoms::aria_pressed) {
     const PRUint32 kState = (aAttribute == nsAccessibilityAtoms::aria_checked) ?
                             states::CHECKED : states::PRESSED;
-    nsRefPtr<AccEvent> event =
-      new AccStateChangeEvent(aContent, kState);
+    nsRefPtr<AccEvent> event = new AccStateChangeEvent(aContent, kState);
     FireDelayedAccessibleEvent(event);
-    if (aContent == gLastFocusedNode) {
-      // State changes for MIXED state currently only supported for focused item, because
-      // otherwise we would need access to the old attribute value in this listener.
-      // This is because we don't know if the previous value of aria-checked or aria-pressed was "mixed"
-      // without caching that info.
-      nsAccessible *accessible = event->GetAccessible();
-      if (accessible) {
-        PRBool wasMixed = (gLastFocusedAccessiblesState & states::MIXED) != 0;
-        PRBool isMixed  =
-          (accessible->State() & states::MIXED) != 0;
-        if (wasMixed != isMixed) {
-          nsRefPtr<AccEvent> event =
-            new AccStateChangeEvent(aContent, states::MIXED, isMixed);
-          FireDelayedAccessibleEvent(event);
-        }
+
+    nsAccessible* accessible = event->GetAccessible();
+    if (accessible) {
+      bool wasMixed = (mARIAAttrOldValue == nsAccessibilityAtoms::mixed);
+      bool isMixed = aContent->AttrValueIs(kNameSpaceID_None, aAttribute,
+                                           nsAccessibilityAtoms::mixed, eCaseMatters);
+      if (isMixed != wasMixed) {
+        nsRefPtr<AccEvent> event =
+          new AccStateChangeEvent(aContent, states::MIXED, isMixed);
+        FireDelayedAccessibleEvent(event);
       }
     }
     return;
   }
 
   if (aAttribute == nsAccessibilityAtoms::aria_readonly) {
     nsRefPtr<AccEvent> event =
       new AccStateChangeEvent(aContent, states::READONLY);
--- a/accessible/src/base/nsDocAccessible.h
+++ b/accessible/src/base/nsDocAccessible.h
@@ -562,17 +562,21 @@ protected:
    */
   PRUint32 mLoadState;
 
   /**
    * Type of document load event fired after the document is loaded completely.
    */
   PRUint32 mLoadEventType;
 
-  static PRUint64 gLastFocusedAccessiblesState;
+  /**
+   * Keep the ARIA attribute old value that is initialized by
+   * AttributeWillChange and used by AttributeChanged notifications.
+   */
+  nsIAtom* mARIAAttrOldValue;
 
   nsTArray<nsRefPtr<nsDocAccessible> > mChildDocuments;
 
   /**
    * A storage class for pairing content with one of its relation attributes.
    */
   class AttrRelProvider
   {
--- a/accessible/src/base/nsRootAccessible.cpp
+++ b/accessible/src/base/nsRootAccessible.cpp
@@ -350,18 +350,16 @@ nsRootAccessible::FireAccessibleFocusEve
   // aForceEvent == PR_TRUE
   nsINode* focusNode = focusAccessible->GetNode();
   if (gLastFocusedNode == focusNode && !aForceEvent)
     return;
 
   nsDocAccessible* focusDocument = focusAccessible->GetDocAccessible();
   NS_ASSERTION(focusDocument, "No document while accessible is in document?!");
 
-  gLastFocusedAccessiblesState = focusAccessible->State();
-
   // Fire menu start/end events for ARIA menus.
   if (focusAccessible->ARIARole() == nsIAccessibleRole::ROLE_MENUITEM) {
     // The focus is inside a menu.
     if (!mCurrentARIAMenubar) {
       // Entering ARIA menu. Fire menu start event.
       nsAccessible* menuBarAccessible =
         nsAccUtils::GetAncestorWithRole(focusAccessible,
                                         nsIAccessibleRole::ROLE_MENUBAR);
@@ -663,17 +661,16 @@ nsRootAccessible::ProcessDOMEvent(nsIDOM
             return;
         }
       }
     }
     FireAccessibleFocusEvent(accessible, origTargetContent);
   }
   else if (eventType.EqualsLiteral("blur")) {
     NS_IF_RELEASE(gLastFocusedNode);
-    gLastFocusedAccessiblesState = 0;
   }
   else if (eventType.EqualsLiteral("AlertActive")) { 
     nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_ALERT, accessible);
   }
   else if (eventType.EqualsLiteral("popupshown")) {
     HandlePopupShownEvent(accessible);
   }
   else if (eventType.EqualsLiteral("DOMMenuInactive")) {
--- a/accessible/src/msaa/nsAccessibleWrap.cpp
+++ b/accessible/src/msaa/nsAccessibleWrap.cpp
@@ -802,18 +802,21 @@ STDMETHODIMP nsAccessibleWrap::accLocati
 }
 
 STDMETHODIMP nsAccessibleWrap::accNavigate(
       /* [in] */ long navDir,
       /* [optional][in] */ VARIANT varStart,
       /* [retval][out] */ VARIANT __RPC_FAR *pvarEndUpAt)
 {
 __try {
+  if (!pvarEndUpAt)
+    return E_INVALIDARG;
+
   nsAccessible *xpAccessibleStart = GetXPAccessibleFor(varStart);
-  if (!xpAccessibleStart)
+  if (!xpAccessibleStart || IsDefunct())
     return E_FAIL;
 
   VariantInit(pvarEndUpAt);
 
   nsCOMPtr<nsIAccessible> xpAccessibleResult;
   PRUint32 xpRelation = 0;
 
   switch(navDir) {
--- a/accessible/tests/mochitest/actions/test_anchors.html
+++ b/accessible/tests/mochitest/actions/test_anchors.html
@@ -3,18 +3,16 @@
 <head>
   <title>nsIAccessible actions testing for HTML links that
    scroll the page to named anchors</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
   <script type="application/javascript"
           src="../actions.js"></script>
--- a/accessible/tests/mochitest/actions/test_aria.html
+++ b/accessible/tests/mochitest/actions/test_aria.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>nsIAccessible actions testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
   <script type="application/javascript"
           src="../actions.js"></script>
--- a/accessible/tests/mochitest/actions/test_general.html
+++ b/accessible/tests/mochitest/actions/test_general.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>nsIAccessible actions testing on HTML elements</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
   <script type="application/javascript"
           src="../actions.js"></script>
--- a/accessible/tests/mochitest/actions/test_general.xul
+++ b/accessible/tests/mochitest/actions/test_general.xul
@@ -4,18 +4,16 @@
                  type="text/css"?>
 <?xml-stylesheet href="../nsIAccessible_name.css"
                  type="text/css"?>
 
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="nsIAccessible actions testing">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../events.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/actions/test_inputs.html
+++ b/accessible/tests/mochitest/actions/test_inputs.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>nsIAccessible actions testing for inputs</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
   <script type="application/javascript"
           src="../actions.js"></script>
--- a/accessible/tests/mochitest/actions/test_keys.html
+++ b/accessible/tests/mochitest/actions/test_keys.html
@@ -2,18 +2,16 @@
 
 <head>
   <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
   <title>Keyboard shortcuts tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
 
   <script type="application/javascript">
     function testKeyboardShortcut(aAccOrElmOrID, aKey)
     {
--- a/accessible/tests/mochitest/actions/test_keys_menu.xul
+++ b/accessible/tests/mochitest/actions/test_keys_menu.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL access keys and shortcut keys tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../events.js" />
 
--- a/accessible/tests/mochitest/actions/test_link.html
+++ b/accessible/tests/mochitest/actions/test_link.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>nsIAccessible actions testing on HTML links (HTML:a)</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
   <script type="application/javascript"
           src="../actions.js"></script>
--- a/accessible/tests/mochitest/actions/test_media.html
+++ b/accessible/tests/mochitest/actions/test_media.html
@@ -3,18 +3,16 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=483573
 -->
 <head>
   <title>HTML5 audio/video tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
   <script type="application/javascript"
           src="../actions.js"></script>
--- a/accessible/tests/mochitest/actions/test_tree.xul
+++ b/accessible/tests/mochitest/actions/test_tree.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL tree actions tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
--- a/accessible/tests/mochitest/actions/test_treegrid.xul
+++ b/accessible/tests/mochitest/actions/test_treegrid.xul
@@ -3,18 +3,16 @@
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 <?xml-stylesheet href="../treeview.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL tree actions tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
--- a/accessible/tests/mochitest/attributes/test_obj.html
+++ b/accessible/tests/mochitest/attributes/test_obj.html
@@ -6,18 +6,16 @@ https://bugzilla.mozilla.org/show_bug.cg
 https://bugzilla.mozilla.org/show_bug.cgi?id=558036
 -->
 <head>
   <title>Group attributes tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../attributes.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/attributes/test_obj_css.html
+++ b/accessible/tests/mochitest/attributes/test_obj_css.html
@@ -4,18 +4,16 @@ https://bugzilla.mozilla.org/show_bug.cg
 https://bugzilla.mozilla.org/show_bug.cgi?id=460932
 -->
 <head>
   <title>CSS-like attributes tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../attributes.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/attributes/test_obj_group.html
+++ b/accessible/tests/mochitest/attributes/test_obj_group.html
@@ -1,18 +1,16 @@
 <html>
 
 <head>
   <title>Group attributes tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../attributes.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/attributes/test_obj_group.xul
+++ b/accessible/tests/mochitest/attributes/test_obj_group.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessibility Group Attributes ('level', 'setsize', 'posinset') Test.">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../events.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/attributes/test_obj_group_tree.xul
+++ b/accessible/tests/mochitest/attributes/test_obj_group_tree.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL tree attributes tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
--- a/accessible/tests/mochitest/attributes/test_text.html
+++ b/accessible/tests/mochitest/attributes/test_text.html
@@ -1,18 +1,16 @@
 <html>
 
 <head>
   <title>Text attributes tests</title>
   <meta charset="utf-8" />
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../attributes.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/editabletext/test_1.html
+++ b/accessible/tests/mochitest/editabletext/test_1.html
@@ -4,18 +4,16 @@
 https://bugzilla.mozilla.org/show_bug.cgi?id=452161
 -->
 <head>
   <title>nsIAccessibleEditableText chrome tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
   <script type="application/javascript"
           src="editabletext.js"></script>
--- a/accessible/tests/mochitest/editabletext/test_2.html
+++ b/accessible/tests/mochitest/editabletext/test_2.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>nsIAccessibleEditableText chrome tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
   <script type="application/javascript"
           src="editabletext.js"></script>
--- a/accessible/tests/mochitest/events.js
+++ b/accessible/tests/mochitest/events.js
@@ -597,20 +597,21 @@ function eventQueue(aEventType)
     var target2 = (aEvent instanceof nsIDOMEvent) ?
       aEvent.originalTarget : aEvent.DOMNode;
     return target1 == target2;
   }
 
   this.isAlreadyCaught = function eventQueue_isAlreadyCaught(aIdx, aEvent)
   {
     // We don't have stored info about handled event other than its type and
-    // target, thus we should filter text change events since they may occur
-    // on the same element because of complex changes.
+    // target, thus we should filter text change and state change events since
+    // they may occur on the same element because of complex changes.
     return this.compareEvents(aIdx, aEvent) &&
-      !(aEvent instanceof nsIAccessibleTextChangeEvent);
+      !(aEvent instanceof nsIAccessibleTextChangeEvent) &&
+      !(aEvent instanceof nsIAccessibleStateChangeEvent);
   }
 
   this.checkEvent = function eventQueue_checkEvent(aIdx, aEvent)
   {
     var eventItem = this.mEventSeq[aIdx];
     if ("check" in eventItem)
       eventItem.check(aEvent);
 
@@ -1036,16 +1037,82 @@ function caretMoveChecker(aCaretOffset)
   this.check = function caretMoveChecker_check(aEvent)
   {
     is(aEvent.QueryInterface(nsIAccessibleCaretMoveEvent).caretOffset,
        aCaretOffset,
        "Wrong caret offset for " + prettyName(aEvent.accessible));
   }
 }
 
+/**
+ * State change checker.
+ */
+function stateChangeChecker(aState, aIsExtraState, aIsEnabled,
+                            aTargetOrFunc, aTargetFuncArg)
+{
+  this.__proto__ = new invokerChecker(EVENT_STATE_CHANGE, aTargetOrFunc,
+                                      aTargetFuncArg);
+
+  this.check = function stateChangeChecker_check(aEvent)
+  {
+    var event = null;
+    try {
+      var event = aEvent.QueryInterface(nsIAccessibleStateChangeEvent);
+    } catch (e) {
+      ok(false, "State change event was expected");
+    }
+
+    if (!event)
+      return;
+
+    is(event.state, aState, "Wrong state of the statechange event.");
+    is(event.isExtraState(), aIsExtraState,
+       "Wrong extra state bit of the statechange event.");
+    is(event.isEnabled(), aIsEnabled,
+      "Wrong state of statechange event state");
+
+    var state = aIsEnabled ? (aIsExtraState ? 0 : aState) : 0;
+    var extraState = aIsEnabled ? (aIsExtraState ? aState : 0) : 0;
+    var unxpdState = aIsEnabled ? 0 : (aIsExtraState ? 0 : aState);
+    var unxpdExtraState = aIsEnabled ? 0 : (aIsExtraState ? aState : 0);
+    testStates(event.accessible, state, extraState, unxpdState, unxpdExtraState);
+  }
+}
+
+/**
+ * Expanded state change checker.
+ */
+function expandedStateChecker(aIsEnabled, aTargetOrFunc, aTargetFuncArg)
+{
+  this.__proto__ = new invokerChecker(EVENT_STATE_CHANGE, aTargetOrFunc,
+                                      aTargetFuncArg);
+
+  this.check = function expandedStateChecker_check(aEvent)
+  {
+    var event = null;
+    try {
+      var event = aEvent.QueryInterface(nsIAccessibleStateChangeEvent);
+    } catch (e) {
+      ok(false, "State change event was expected");
+    }
+
+    if (!event)
+      return;
+
+    is(event.state, STATE_EXPANDED, "Wrong state of the statechange event.");
+    is(event.isExtraState(), false,
+       "Wrong extra state bit of the statechange event.");
+    is(event.isEnabled(), aIsEnabled,
+      "Wrong state of statechange event state");
+
+    testStates(event.accessible,
+               (aIsEnabled ? STATE_EXPANDED : STATE_COLLAPSED));
+  }
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // Private implementation details.
 ////////////////////////////////////////////////////////////////////////////////
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // General
 
--- a/accessible/tests/mochitest/events/test_aria_alert.html
+++ b/accessible/tests/mochitest/events/test_aria_alert.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>ARIA alert event testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/events/test_aria_menu.html
+++ b/accessible/tests/mochitest/events/test_aria_menu.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>ARIA menu events testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
--- a/accessible/tests/mochitest/events/test_aria_objattr.html
+++ b/accessible/tests/mochitest/events/test_aria_objattr.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Accessible ARIA object attribute changes</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/events/test_aria_statechange.html
+++ b/accessible/tests/mochitest/events/test_aria_statechange.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>ARIA state change event testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
@@ -21,97 +19,163 @@
   <script type="application/javascript">
 
 
     /**
      * Do tests.
      */
     var gQueue = null;
 
-    // Debug stuff.
-    //gA11yEventDumpID = "eventdump";
-    // gA11yEventDumpToConsole = true;
+    //gA11yEventDumpID = "eventdump"; // debugging
+    //gA11yEventDumpToConsole = true; // debugging
 
-    function expandNode(aNodeOrID, bExpand)
+    function expandNode(aID, aIsExpanded)
     {
-      this.DOMNode = getNode(aNodeOrID);
+      this.DOMNode = getNode(aID);
 
-      this.invoke = function expandNode_invoke() {
-        // Note: this should fire an EVENT_STATE_CHANGE
-        this.DOMNode.setAttribute("aria-expanded", bExpand);
+      this.eventSeq = [
+        new expandedStateChecker(aIsExpanded, this.DOMNode)
+      ];
+
+      this.invoke = function expandNode_invoke()
+      {
+        this.DOMNode.setAttribute("aria-expanded",
+                                  (aIsExpanded ? "true" : "false"));
       };
 
-      this.check = function expandNode_check() {
-        testStates(aNodeOrID,
-                   bExpand ? STATE_EXPANDED : STATE_COLLAPSED,
-                   EXT_STATE_EXPANDABLE);
+      this.getID = function expandNode_getID()
+      {
+        return prettyName(aID) + " aria-expanded changed to '" + aIsExpanded + "'";
+      };
+    }
+
+    function busyify(aID, aIsBusy)
+    {
+      this.DOMNode = getNode(aID);
+
+      this.eventSeq = [
+        new stateChangeChecker(STATE_BUSY, kOrdinalState, aIsBusy, this.DOMNode)
+      ];
+
+      this.invoke = function busyify_invoke()
+      {
+        this.DOMNode.setAttribute("aria-busy", (aIsBusy ? "true" : "false"));
       };
 
-      this.getID = function expandNode_getID() {
-        return prettyName(aNodeOrID) + " aria-expanded changed";
+      this.getID = function busyify_getID()
+      {
+        return prettyName(aID) + " aria-busy changed to '" + aIsBusy + "'";
       };
     }
 
-    function busyify(aNodeOrID, aBusy)
+    function setAttrOfMixedType(aID, aAttr, aState, aValue)
     {
-      this.DOMNode = getNode(aNodeOrID);
+      this.DOMNode = getNode(aID);
+
+      this.eventSeq = [
+        new stateChangeChecker(aState, kOrdinalState,
+                               aValue == "true", this.DOMNode)
+      ];
 
-      this.invoke = function busyify_invoke() {
-        this.DOMNode.setAttribute("aria-busy", aBusy);
+      if (hasState(aID, STATE_MIXED) || aValue == "mixed") {
+        this.eventSeq.push(
+          new stateChangeChecker(STATE_MIXED, kOrdinalState,
+                                 aValue == "mixed", this.DOMNode)
+        );
+      }
+
+      this.invoke = function setAttrOfMixedType_invoke()
+      {
+        this.DOMNode.setAttribute(aAttr, aValue);
       };
 
-      this.check = function busyify_check(event) {
-        testStates(aNodeOrID,
-                   (aBusy ? STATE_BUSY : 0), 0,
-                   (aBusy ? 0 : STATE_BUSY), 0);
+      this.getID = function setAttrOfMixedType_getID()
+      {
+        return prettyName(aID) + " " + aAttr + " changed to '" + aValue + "'";
       };
+    }
 
-      this.getID = function busyify_getID() {
-        return prettyName(aNodeOrID) + " aria-busy changed to " + aBusy;
-      };
+    function setPressed(aID, aValue)
+    {
+      this.__proto__ =
+        new setAttrOfMixedType(aID, "aria-pressed", STATE_PRESSED, aValue);
+    }
+
+    function setChecked(aID, aValue)
+    {
+      this.__proto__ =
+        new setAttrOfMixedType(aID, "aria-checked", STATE_CHECKED, aValue);
+    }
+
+    function buildQueueForAttrOfMixedType(aQueue, aID, aInvokerFunc)
+    {
+      var list = [ "", "undefined", "false", "true", "mixed" ];
+      for (var i = 0; i < list.length; i++) {
+        for (var j = i + 1; j < list.length; j++) {
+          // XXX: changes from/to "undefined"/"" shouldn't fire state change
+          // events, bug 472142.
+          aQueue.push(new aInvokerFunc(aID, list[i]));
+          aQueue.push(new aInvokerFunc(aID, list[j]));
+        }
+      }
     }
 
     function doTests()
     {
-      gQueue = new eventQueue(EVENT_STATE_CHANGE);
+      gQueue = new eventQueue();
 
       gQueue.push(new expandNode("section", true));
       gQueue.push(new expandNode("section", false));
       gQueue.push(new expandNode("div", true));
       gQueue.push(new expandNode("div", false));
 
       gQueue.push(new busyify("aria_doc", true));
       gQueue.push(new busyify("aria_doc", false));
+
+      buildQueueForAttrOfMixedType(gQueue, "pressable", setPressed);
+      buildQueueForAttrOfMixedType(gQueue, "checkable", setChecked);
+
       gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTests);
   </script>
 </head>
 
 <body>
 
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=551684"
      title="No statechange event for aria-expanded on native HTML elements, is fired on ARIA widgets">
     Mozilla Bug 551684
-  </a>
-
+  </a><br>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=648133"
      title="fire state change event for aria-busy"
     Mozilla Bug 648133
+  </a><br>
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=467143"
+     title="mixed state change event is fired for focused accessible only"
+    Mozilla Bug 467143
   </a>
+
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
   <div id="eventdump"></div>
 
   <!-- aria-expanded -->
   <div id="section" role="section" aria-expanded="false">expandable section</div>
   <div id="div" aria-expanded="false">expandable native div</div>
 
   <!-- aria-busy -->
   <div id="aria_doc" role="document" tabindex="0">A document</div>
+
+  <!-- aria-pressed -->
+  <div id="pressable" role="button"></div>
+
+  <!-- aria-checked -->
+  <div id="checkable" role="checkbox"></div>
 </body>
 </html>
--- a/accessible/tests/mochitest/events/test_attrs.html
+++ b/accessible/tests/mochitest/events/test_attrs.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Event object attributes tests</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/events/test_caretmove.html
+++ b/accessible/tests/mochitest/events/test_caretmove.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Accessible caret move events testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/events/test_caretmove.xul
+++ b/accessible/tests/mochitest/events/test_caretmove.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Caret move event testing">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/events/test_coalescence.html
+++ b/accessible/tests/mochitest/events/test_coalescence.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Accessible mutation events coalescence testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/events/test_contextmenu.html
+++ b/accessible/tests/mochitest/events/test_contextmenu.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Context menu tests</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
--- a/accessible/tests/mochitest/events/test_docload.html
+++ b/accessible/tests/mochitest/events/test_docload.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Accessible events testing for document</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
--- a/accessible/tests/mochitest/events/test_docload.xul
+++ b/accessible/tests/mochitest/events/test_docload.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessibility Loading Document Events Test.">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
--- a/accessible/tests/mochitest/events/test_dragndrop.html
+++ b/accessible/tests/mochitest/events/test_dragndrop.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Accessible drag and drop event testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
 
   <script type="application/javascript"
--- a/accessible/tests/mochitest/events/test_flush.html
+++ b/accessible/tests/mochitest/events/test_flush.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Flush delayed events testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/events/test_focus.html
+++ b/accessible/tests/mochitest/events/test_focus.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Accessible focus testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/events/test_focus.xul
+++ b/accessible/tests/mochitest/events/test_focus.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible focus event testing">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/events/test_focus_name.html
+++ b/accessible/tests/mochitest/events/test_focus_name.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Accessible name testing on focus</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/events/test_focusdoc.html
+++ b/accessible/tests/mochitest/events/test_focusdoc.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Accessible document focus event testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-    src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
       src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   
   <script type="application/javascript"
       src="../common.js"></script>
   <script type="application/javascript"
     src="../events.js"></script>
     <script type="application/javascript"
       src="../states.js"></script>
--- a/accessible/tests/mochitest/events/test_menu.xul
+++ b/accessible/tests/mochitest/events/test_menu.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible menu events testing for XUL menu">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/events/test_mutation.html
+++ b/accessible/tests/mochitest/events/test_mutation.html
@@ -7,18 +7,16 @@
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <style>
     div.displayNone a { display:none; }
     div.visibilityHidden a { visibility:hidden; }
 </style>
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/events/test_mutation.xhtml
+++ b/accessible/tests/mochitest/events/test_mutation.xhtml
@@ -10,18 +10,16 @@
     <binding id="button">
       <content>
         <button xmlns="http://www.w3.org/1999/xhtml">a button</button>
       </content>
     </binding>
   </bindings>
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/events/test_scroll.xul
+++ b/accessible/tests/mochitest/events/test_scroll.xul
@@ -8,18 +8,16 @@
 <?xml-stylesheet href="chrome://navigator/content/navigator.css"
                  type="text/css"?>
 
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="chrome://mochitests/content/a11y/accessible/treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
--- a/accessible/tests/mochitest/events/test_selection.html
+++ b/accessible/tests/mochitest/events/test_selection.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Accessible selection event testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/events/test_statechange.html
+++ b/accessible/tests/mochitest/events/test_statechange.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Accessible state change event testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
--- a/accessible/tests/mochitest/events/test_text.html
+++ b/accessible/tests/mochitest/events/test_text.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Accessible mutation events testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/events/test_text_alg.html
+++ b/accessible/tests/mochitest/events/test_text_alg.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Accessible text update algorithm testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/events/test_textattrchange.html
+++ b/accessible/tests/mochitest/events/test_textattrchange.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Text attribute changed event for misspelled text</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/events/test_tree.xul
+++ b/accessible/tests/mochitest/events/test_tree.xul
@@ -6,18 +6,16 @@
 <!--
   Bug 368835 - fire TreeViewChanged/TreeRowCountChanged events.
   Bug 308564 - no accessibility events when data in a tree row changes.
 -->
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="DOM TreeViewChanged/TreeRowCountChanged and a11y name change events.">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
--- a/accessible/tests/mochitest/events/test_valuechange.html
+++ b/accessible/tests/mochitest/events/test_valuechange.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Accessible value change events testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
 
   <script type="application/javascript"
--- a/accessible/tests/mochitest/focus/test_focusedChild.html
+++ b/accessible/tests/mochitest/focus/test_focusedChild.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>nsIAccessible::focusedChild testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/focus/test_takeFocus.html
+++ b/accessible/tests/mochitest/focus/test_takeFocus.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>nsIAccessible::takeFocus testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/hyperlink/test_general.html
+++ b/accessible/tests/mochitest/hyperlink/test_general.html
@@ -3,18 +3,16 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=418368
 -->
 <head>
   <title>nsIHyperLinkAccessible chrome tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
--- a/accessible/tests/mochitest/hyperlink/test_general.xul
+++ b/accessible/tests/mochitest/hyperlink/test_general.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="test for nsIAccessibleHyperLink interface on XUL:label elements">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/hypertext/test_general.html
+++ b/accessible/tests/mochitest/hypertext/test_general.html
@@ -3,18 +3,16 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=428248
 -->
 <head>
   <title>nsIHyper>TextAccessible chrome tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
 
   <script type="application/javascript">
     var gParagraphAcc;
 
--- a/accessible/tests/mochitest/hypertext/test_update.html
+++ b/accessible/tests/mochitest/hypertext/test_update.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>nsIHyper>TextAccessible in dynamic tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/name/test_button.html
+++ b/accessible/tests/mochitest/name/test_button.html
@@ -1,17 +1,15 @@
 <html>
 
 <head>
   <title>nsIAccessible::name calculation for HTML buttons</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../name.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/name/test_general.html
+++ b/accessible/tests/mochitest/name/test_general.html
@@ -1,18 +1,16 @@
 <html>
 
 <head>
   <title>nsIAccessible::name calculation</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../name.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/name/test_general.xul
+++ b/accessible/tests/mochitest/name/test_general.xul
@@ -4,18 +4,16 @@
                  type="text/css"?>
 <?xml-stylesheet href="general.css"
                  type="text/css"?>
 
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessibility Name Calculating Test.">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
--- a/accessible/tests/mochitest/name/test_link.html
+++ b/accessible/tests/mochitest/name/test_link.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>nsIAccessible::name calculation for HTML links (html:a)</title>
 
   <link rel="stylesheet"
         type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../name.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/name/test_list.html
+++ b/accessible/tests/mochitest/name/test_list.html
@@ -1,18 +1,16 @@
 <html>
 
 <head>
   <title>nsIAccessible::name calculation for HTML li</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../name.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/name/test_markup.html
+++ b/accessible/tests/mochitest/name/test_markup.html
@@ -1,17 +1,15 @@
 <html>
 
 <head>
   <title>nsIAccessible::name calculation for elements</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
   <script type="application/javascript"
           src="../name.js"></script>
--- a/accessible/tests/mochitest/name/test_nsRootAcc.xul
+++ b/accessible/tests/mochitest/name/test_nsRootAcc.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessibility Name Calculating Test.">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
--- a/accessible/tests/mochitest/name/test_tree.xul
+++ b/accessible/tests/mochitest/name/test_tree.xul
@@ -4,18 +4,16 @@
                  type="text/css"?>
 <?xml-stylesheet href="general.css"
                  type="text/css"?>
 
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessibility Name Calculating Test.">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js"></script>
--- a/accessible/tests/mochitest/relations/test_general.html
+++ b/accessible/tests/mochitest/relations/test_general.html
@@ -1,17 +1,15 @@
 <html>
 
 <head>
   <title>nsIAccessible::getAccessibleRelated() tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../relations.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
--- a/accessible/tests/mochitest/relations/test_general.xul
+++ b/accessible/tests/mochitest/relations/test_general.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="nsIAccessible::getAccessibleRelated() tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../relations.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/relations/test_tabbrowser.xul
+++ b/accessible/tests/mochitest/relations/test_tabbrowser.xul
@@ -8,18 +8,16 @@
                  type="text/css"?>
 <!-- SeaMonkey tabbrowser -->
 <?xml-stylesheet href="chrome://navigator/content/navigator.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL tabbrowser relation tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/relations/test_tree.xul
+++ b/accessible/tests/mochitest/relations/test_tree.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL tree relations tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
--- a/accessible/tests/mochitest/relations/test_update.html
+++ b/accessible/tests/mochitest/relations/test_update.html
@@ -1,18 +1,16 @@
 <html>
 
 <head>
   <title>Test updating of accessible relations</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../relations.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
--- a/accessible/tests/mochitest/selectable/test_aria.html
+++ b/accessible/tests/mochitest/selectable/test_aria.html
@@ -4,18 +4,16 @@
   <title>nsIAccessibleSelectable ARIA widgets testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   </style>
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
--- a/accessible/tests/mochitest/selectable/test_listbox.xul
+++ b/accessible/tests/mochitest/selectable/test_listbox.xul
@@ -2,18 +2,16 @@
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 <?xml-stylesheet href="../treeview.css" type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="XUL tree selectable tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/selectable/test_menu.xul
+++ b/accessible/tests/mochitest/selectable/test_menu.xul
@@ -2,18 +2,16 @@
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 <?xml-stylesheet href="../treeview.css" type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="XUL tree selectable tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/selectable/test_menulist.xul
+++ b/accessible/tests/mochitest/selectable/test_menulist.xul
@@ -2,18 +2,16 @@
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 <?xml-stylesheet href="../treeview.css" type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="XUL tree selectable tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/selectable/test_select.html
+++ b/accessible/tests/mochitest/selectable/test_select.html
@@ -4,18 +4,16 @@
   <title>nsIAccessibleSelectable HTML select testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   </style>
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
--- a/accessible/tests/mochitest/selectable/test_tree.xul
+++ b/accessible/tests/mochitest/selectable/test_tree.xul
@@ -3,18 +3,16 @@
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 <?xml-stylesheet href="../treeview.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="XUL tree selectable tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
--- a/accessible/tests/mochitest/states.js
+++ b/accessible/tests/mochitest/states.js
@@ -40,16 +40,18 @@ const EXT_STATE_EXPANDABLE = nsIAccessib
 const EXT_STATE_HORIZONTAL = nsIAccessibleStates.EXT_STATE_HORIZONTAL;
 const EXT_STATE_MULTI_LINE = nsIAccessibleStates.EXT_STATE_MULTI_LINE;
 const EXT_STATE_SINGLE_LINE = nsIAccessibleStates.EXT_STATE_SINGLE_LINE;
 const EXT_STATE_STALE = nsIAccessibleStates.EXT_STATE_STALE;
 const EXT_STATE_SUPPORTS_AUTOCOMPLETION =
   nsIAccessibleStates.EXT_STATE_SUPPORTS_AUTOCOMPLETION;
 const EXT_STATE_VERTICAL = nsIAccessibleStates.EXT_STATE_VERTICAL;
 
+const kOrdinalState = 0;
+const kExtraState = 1;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Test functions
 
 /**
  * Tests the states and extra states of the given accessible.
  * Also tests for unwanted states and extra states.
  * In addition, the function performs a few plausibility checks derived from the
--- a/accessible/tests/mochitest/states/test_aria.html
+++ b/accessible/tests/mochitest/states/test_aria.html
@@ -12,18 +12,16 @@
       left: -5000px;
       top: -5000px;
       height: 100px;
       width: 100px;
     }
   </style>
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
--- a/accessible/tests/mochitest/states/test_aria_imgmap.html
+++ b/accessible/tests/mochitest/states/test_aria_imgmap.html
@@ -1,17 +1,15 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Test usemap elements and ARIA</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
--- a/accessible/tests/mochitest/states/test_aria_tabs.html
+++ b/accessible/tests/mochitest/states/test_aria_tabs.html
@@ -3,18 +3,16 @@
 
 <head>
   <title>Test ARIA tab accessible selected state</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/states/test_comboboxes.xul
+++ b/accessible/tests/mochitest/states/test_comboboxes.xul
@@ -3,18 +3,16 @@
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 <?xml-stylesheet href="chrome://browser/content/browser.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="nsIAccessible interface for xul:menulist test.">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/states/test_doc.html
+++ b/accessible/tests/mochitest/states/test_doc.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>states of document</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/states/test_docarticle.html
+++ b/accessible/tests/mochitest/states/test_docarticle.html
@@ -1,18 +1,16 @@
 <html>
 <head>
   <title>states of document article</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/states/test_editablebody.html
+++ b/accessible/tests/mochitest/states/test_editablebody.html
@@ -3,18 +3,16 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=454997
 -->
 <head>
   <title>nsIAccessible states tests of contenteditable body</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/states/test_frames.html
+++ b/accessible/tests/mochitest/states/test_frames.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>frame based document testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/states/test_inputs.html
+++ b/accessible/tests/mochitest/states/test_inputs.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>HTML input states</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/states/test_inputs.xul
+++ b/accessible/tests/mochitest/states/test_inputs.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL input control state tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../states.js" />
 
--- a/accessible/tests/mochitest/states/test_link.html
+++ b/accessible/tests/mochitest/states/test_link.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>HTML link states testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
--- a/accessible/tests/mochitest/states/test_popup.xul
+++ b/accessible/tests/mochitest/states/test_popup.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="XUL popup attribute test">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../states.js" />
 
--- a/accessible/tests/mochitest/states/test_stale.html
+++ b/accessible/tests/mochitest/states/test_stale.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Stale state testing</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/states/test_textbox.xul
+++ b/accessible/tests/mochitest/states/test_textbox.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="nsIAccessible XUL textboxes states tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/states/test_tree.xul
+++ b/accessible/tests/mochitest/states/test_tree.xul
@@ -3,18 +3,16 @@
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 <?xml-stylesheet href="../treeview.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL tree states tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
--- a/accessible/tests/mochitest/table/test_headers_ariagrid.html
+++ b/accessible/tests/mochitest/table/test_headers_ariagrid.html
@@ -2,18 +2,16 @@
 <html>
 <head>
   <title>Table header information cells for ARIA grid</title>
   <meta http-equiv="content-type" content="text/html; charset=UTF-8">
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../table.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/table/test_headers_listbox.xul
+++ b/accessible/tests/mochitest/table/test_headers_listbox.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Table header information cells for XUL listbox">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../table.js"></script>
 
--- a/accessible/tests/mochitest/table/test_headers_table.html
+++ b/accessible/tests/mochitest/table/test_headers_table.html
@@ -2,18 +2,16 @@
 <html>
 <head>
   <title>Table header information cells for HTML table</title>
   <meta http-equiv="content-type" content="text/html; charset=UTF-8">
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../table.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/table/test_headers_tree.xul
+++ b/accessible/tests/mochitest/table/test_headers_tree.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Table header information cells for XUL tree">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
--- a/accessible/tests/mochitest/table/test_indexes_ariagrid.html
+++ b/accessible/tests/mochitest/table/test_indexes_ariagrid.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Table indexes for ARIA grid tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../attributes.js"></script>
   <script type="application/javascript"
           src="../table.js"></script>
--- a/accessible/tests/mochitest/table/test_indexes_listbox.xul
+++ b/accessible/tests/mochitest/table/test_indexes_listbox.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Table indices of accessible table for XUL listbox">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../table.js"></script>
 
--- a/accessible/tests/mochitest/table/test_indexes_table.html
+++ b/accessible/tests/mochitest/table/test_indexes_table.html
@@ -4,18 +4,16 @@
 https://bugzilla.mozilla.org/show_bug.cgi?id=410052
 -->
 <head>
   <title>Table indexes chrome tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../table.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/table/test_indexes_tree.xul
+++ b/accessible/tests/mochitest/table/test_indexes_tree.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible Table indexes tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
--- a/accessible/tests/mochitest/table/test_layoutguess.html
+++ b/accessible/tests/mochitest/table/test_layoutguess.html
@@ -1,18 +1,16 @@
 <html>
 <!-- https://bugzilla.mozilla.org/show_bug.cgi?id=495388 -->
 <head>
   <title>test nsHTMLTableAccessible::IsProbablyForLayout implementation</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../attributes.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/table/test_sels_ariagrid.html
+++ b/accessible/tests/mochitest/table/test_sels_ariagrid.html
@@ -4,18 +4,16 @@
 https://bugzilla.mozilla.org/show_bug.cgi?id=410052
 -->
 <head>
   <title>nsIAccesible selection methods testing for ARIA grid</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
   <script type="application/javascript"
           src="../table.js"></script>
--- a/accessible/tests/mochitest/table/test_sels_listbox.xul
+++ b/accessible/tests/mochitest/table/test_sels_listbox.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="nsIAccessibleTable selection methods on xul:listbox test.">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../table.js"></script>
 
--- a/accessible/tests/mochitest/table/test_sels_table.html
+++ b/accessible/tests/mochitest/table/test_sels_table.html
@@ -2,18 +2,16 @@
 <html>
  <head>
   <meta http-equiv="content-type" content="text/html; charset=UTF-8">
   <title>nsIAccesible selection methods testing for HTML table</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
   <script type="application/javascript"
           src="../table.js"></script>
--- a/accessible/tests/mochitest/table/test_sels_tree.xul
+++ b/accessible/tests/mochitest/table/test_sels_tree.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible Table selection tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
--- a/accessible/tests/mochitest/table/test_struct_ariagrid.html
+++ b/accessible/tests/mochitest/table/test_struct_ariagrid.html
@@ -2,18 +2,16 @@
 <html>
 
 <head>
   <title>Table accessible tree and table interface tests for ARIA grid</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../table.js"></script>
--- a/accessible/tests/mochitest/table/test_struct_ariatreegrid.html
+++ b/accessible/tests/mochitest/table/test_struct_ariatreegrid.html
@@ -2,18 +2,16 @@
 <html>
 
 <head>
   <title>Table accessible tree and table interface tests for ARIA tree grid</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../table.js"></script>
--- a/accessible/tests/mochitest/table/test_struct_listbox.xul
+++ b/accessible/tests/mochitest/table/test_struct_listbox.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Table accessible tree and table interface tests for XUL listboxes">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
--- a/accessible/tests/mochitest/table/test_struct_table.html
+++ b/accessible/tests/mochitest/table/test_struct_table.html
@@ -2,18 +2,16 @@
 <html>
 
 <head>
   <title>Table accessible tree and table interface tests for HTML tables</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../table.js"></script>
--- a/accessible/tests/mochitest/table/test_struct_tree.xul
+++ b/accessible/tests/mochitest/table/test_struct_tree.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Table accessible tree and table interface tests for XUL trees">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
--- a/accessible/tests/mochitest/table/test_table_1.html
+++ b/accessible/tests/mochitest/table/test_table_1.html
@@ -1,16 +1,14 @@
 <!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
 <html>
  <head>
   <meta http-equiv="content-type" content="text/html; charset=UTF-8">
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
 
   <script type="application/javascript">
 
 function doTest()
--- a/accessible/tests/mochitest/table/test_table_2.html
+++ b/accessible/tests/mochitest/table/test_table_2.html
@@ -1,16 +1,14 @@
 <!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
 <html>
  <head>
   <meta http-equiv="content-type" content="text/html; charset=UTF-8">
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
 
   <script type="text/javascript">
--- a/accessible/tests/mochitest/test_aria_activedescendant.html
+++ b/accessible/tests/mochitest/test_aria_activedescendant.html
@@ -3,18 +3,16 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=429547
 -->
 <head>
   <title>aria-activedescendant property chrome tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="common.js"></script>
 
   <script type="application/javascript">
     const ELEMENT_NODE = nsIDOMNode.ELEMENT_NODE;
 
--- a/accessible/tests/mochitest/test_aria_role_article.html
+++ b/accessible/tests/mochitest/test_aria_role_article.html
@@ -3,18 +3,16 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=429666
 -->
 <head>
   <title>Expose ROLE_DOCUMENT for ARIA landmarks that inherit from document chrome tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="common.js"></script>
   <script type="application/javascript"
           src="role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/test_aria_role_equation.html
+++ b/accessible/tests/mochitest/test_aria_role_equation.html
@@ -3,18 +3,16 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=428479
 -->
 <head>
   <title>ARIA role math chrome tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="common.js"></script>
   <script type="application/javascript"
           src="role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/test_aria_roles.html
+++ b/accessible/tests/mochitest/test_aria_roles.html
@@ -6,18 +6,16 @@ https://bugzilla.mozilla.org/show_bug.cg
 https://bugzilla.mozilla.org/show_bug.cgi?id=520188
 https://bugzilla.mozilla.org/show_bug.cgi?id=529289
 -->
 <head>
   <title>Test weak ARIA roles</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="common.js"></script>
   <script type="application/javascript"
           src="role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/test_aria_roles.xul
+++ b/accessible/tests/mochitest/test_aria_roles.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessibility Name Calculating Test.">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="common.js"></script>
 
   <script type="application/javascript">
   <![CDATA[
--- a/accessible/tests/mochitest/test_aria_token_attrs.html
+++ b/accessible/tests/mochitest/test_aria_token_attrs.html
@@ -3,18 +3,16 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=452388
 -->
 <head>
   <title>An NMTOKEN based ARIA property is undefined if the ARIA attribute is not present, or is set to "" or "undefined"</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="common.js"></script>
   <script type="application/javascript"
           src="role.js"></script>
   <script type="application/javascript"
       src="states.js"></script>
--- a/accessible/tests/mochitest/test_bug420863.html
+++ b/accessible/tests/mochitest/test_bug420863.html
@@ -3,18 +3,16 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=420863
 -->
 <head>
   <title>Table indexes chrome tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="common.js"></script>
   <script type="application/javascript"
           src="events.js"></script>
   <script type="application/javascript"
           src="actions.js"></script>
--- a/accessible/tests/mochitest/test_childAtPoint.html
+++ b/accessible/tests/mochitest/test_childAtPoint.html
@@ -1,17 +1,15 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>nsIAccessible::childAtPoint() tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="common.js"></script>
   <script type="application/javascript"
           src="layout.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/test_childAtPoint.xul
+++ b/accessible/tests/mochitest/test_childAtPoint.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="nsIAccessible::getChildAtPoint and getDeepestChildAtPoint">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="treeview.js" />
 
   <script type="application/javascript"
           src="common.js" />
--- a/accessible/tests/mochitest/test_descr.html
+++ b/accessible/tests/mochitest/test_descr.html
@@ -1,17 +1,15 @@
 <html>
 
 <head>
   <title>nsIAccessible::description tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="common.js"></script>
 
   <script type="application/javascript">
     function testDescr(aAccOrElmOrID, aDescr)
     {
       var acc = getAccessible(aAccOrElmOrID);
--- a/accessible/tests/mochitest/test_elm_landmarks.html
+++ b/accessible/tests/mochitest/test_elm_landmarks.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>HTML landmark tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="common.js"></script>
   <script type="application/javascript"
           src="role.js"></script>
   <script type="application/javascript"
           src="attributes.js"></script>
--- a/accessible/tests/mochitest/test_elm_listbox.xul
+++ b/accessible/tests/mochitest/test_elm_listbox.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="XUL listbox element test.">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="common.js"></script>
   <script type="application/javascript"
           src="role.js"></script>
 
--- a/accessible/tests/mochitest/test_elm_nsApplicationAcc.html
+++ b/accessible/tests/mochitest/test_elm_nsApplicationAcc.html
@@ -1,17 +1,15 @@
 <html>
 
 <head>
   <title>application accessible name</title>
   <link rel="stylesheet" type="text/css" 
          href="chrome://mochikit/content/tests/SimpleTest/test.css" />
   <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript" 
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript" 
           src="common.js"></script>
   <script type="application/javascript" 
           src="role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/test_elm_plugin.html
+++ b/accessible/tests/mochitest/test_elm_plugin.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Plugin tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="common.js"></script>
   <script type="application/javascript"
           src="role.js"></script>
   <script type="application/javascript"
           src="states.js"></script>
--- a/accessible/tests/mochitest/test_nsIAccessNode_utils.html
+++ b/accessible/tests/mochitest/test_nsIAccessNode_utils.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>nsIAccessNode util methods testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="common.js"></script>
 
   <script type="application/javascript">
     function doTest()
     {
       var elmObj = {};
--- a/accessible/tests/mochitest/test_nsIAccessibleDocument.html
+++ b/accessible/tests/mochitest/test_nsIAccessibleDocument.html
@@ -1,17 +1,16 @@
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=441737
 -->
 <head>
   <title>nsIAccessibleDocument chrome tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
-  <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
     src="common.js"></script>
   <script type="application/javascript"
     src="role.js"></script>
   <script type="application/javascript"
     src="states.js"></script>
--- a/accessible/tests/mochitest/test_nsIAccessibleImage.html
+++ b/accessible/tests/mochitest/test_nsIAccessibleImage.html
@@ -3,18 +3,16 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=429659
 -->
 <head>
   <title>nsIAccessibleImage chrome tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="common.js"></script>
   <script type="application/javascript"
           src="role.js"></script>
   <script type="application/javascript"
           src="attributes.js"></script>
--- a/accessible/tests/mochitest/test_nsIAccessible_selects.html
+++ b/accessible/tests/mochitest/test_nsIAccessible_selects.html
@@ -1,17 +1,15 @@
 <html>
 
 <head>
   <title>nsIAccessible selects tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="common.js"></script>
   <script type="application/javascript"
           src="role.js"></script>
   <script type="application/javascript"
           src="states.js"></script>
   <script type="application/javascript"
--- a/accessible/tests/mochitest/test_nsOuterDocAccessible.html
+++ b/accessible/tests/mochitest/test_nsOuterDocAccessible.html
@@ -2,18 +2,16 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=441519
 -->
 <head>
   <title>nsOuterDocAccessible chrome tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="common.js"></script>
   <script type="application/javascript"
           src="states.js"></script>
   <script type="application/javascript"
           src="role.js"></script>
--- a/accessible/tests/mochitest/test_role_nsHyperTextAcc.html
+++ b/accessible/tests/mochitest/test_role_nsHyperTextAcc.html
@@ -1,17 +1,15 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>test nsHyperTextAccessible accesible objects creation and their roles</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="common.js"></script>
   <script type="application/javascript"
           src="role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/test_text_caret.html
+++ b/accessible/tests/mochitest/test_text_caret.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>Text accessible caret testing</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="common.js"></script>
   <script type="application/javascript"
           src="events.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/test_textboxes.html
+++ b/accessible/tests/mochitest/test_textboxes.html
@@ -3,18 +3,16 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=442648
 -->
 <head>
   <title>nsIAccessible textboxes chrome tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="common.js"></script>
   <script type="application/javascript"
           src="role.js"></script>
   <script type="application/javascript"
           src="states.js"></script>
--- a/accessible/tests/mochitest/test_textboxes.xul
+++ b/accessible/tests/mochitest/test_textboxes.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="nsIAccessible XUL textboxes chrome tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="common.js" />
   <script type="application/javascript"
           src="role.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/text/test_doc.html
+++ b/accessible/tests/mochitest/text/test_doc.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>nsIAccessibleText getText related function tests for document accessible</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../text.js"></script>
   <script type="application/javascript">
     
     function doTest()
--- a/accessible/tests/mochitest/text/test_hypertext.html
+++ b/accessible/tests/mochitest/text/test_hypertext.html
@@ -7,18 +7,16 @@
 
   <style>
     h6.gencontent:before {
       content: "aga"
     }
   </style>
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../text.js"></script>
 
   <script type="application/javascript">
     function doTest()
--- a/accessible/tests/mochitest/text/test_passwords.html
+++ b/accessible/tests/mochitest/text/test_passwords.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>nsIAccessibleText getText related function tests for text and password inputs</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../text.js"></script>
 
   <script type="application/javascript">
     function doTest()
--- a/accessible/tests/mochitest/text/test_singleline.html
+++ b/accessible/tests/mochitest/text/test_singleline.html
@@ -1,17 +1,15 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>nsIAccessibleText getText related function tests for html:input,html:div and html:textarea</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../text.js"></script>
   <script type="application/javascript">
     
     function doTest()
--- a/accessible/tests/mochitest/text/test_whitespaces.html
+++ b/accessible/tests/mochitest/text/test_whitespaces.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>getText... methods tests on string with whitespaces for plain text containers</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="../common.js"></script>
 
   <script type="application/javascript"
           src="../text.js"></script>
   <script type="application/javascript">
     
--- a/accessible/tests/mochitest/text/test_words.html
+++ b/accessible/tests/mochitest/text/test_words.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>nsIAccessibleText getText related function tests for html:input,html:div and html:textarea</title>
   <meta charset="utf-8" />
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../text.js"></script>
   <script type="application/javascript">
     
     function doTest()
--- a/accessible/tests/mochitest/tree/test_applicationacc.xul
+++ b/accessible/tests/mochitest/tree/test_applicationacc.xul
@@ -2,18 +2,16 @@
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible Application Accessible hierarchy tests">
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js" />
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/tree/test_aria_globals.html
+++ b/accessible/tests/mochitest/tree/test_aria_globals.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Test Global ARIA States and Accessible Creation</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/tree/test_aria_imgmap.html
+++ b/accessible/tests/mochitest/tree/test_aria_imgmap.html
@@ -1,17 +1,15 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Test usemap elements and ARIA</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
--- a/accessible/tests/mochitest/tree/test_aria_presentation.html
+++ b/accessible/tests/mochitest/tree/test_aria_presentation.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Test accessible tree when ARIA role presentation is used</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
--- a/accessible/tests/mochitest/tree/test_button.xul
+++ b/accessible/tests/mochitest/tree/test_button.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL button hierarchy tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
 
--- a/accessible/tests/mochitest/tree/test_combobox.xul
+++ b/accessible/tests/mochitest/tree/test_combobox.xul
@@ -2,18 +2,16 @@
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL menulist and textbox @autocomplete hierarchy tests">
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js" />
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/tree/test_cssoverflow.html
+++ b/accessible/tests/mochitest/tree/test_cssoverflow.html
@@ -8,18 +8,16 @@
 
   <style>
     a.link:focus {
       overflow: scroll;
     }
   </style>
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/tree/test_dochierarchy.html
+++ b/accessible/tests/mochitest/tree/test_dochierarchy.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Test document hierarchy</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
--- a/accessible/tests/mochitest/tree/test_dockids.html
+++ b/accessible/tests/mochitest/tree/test_dockids.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Test document hierarchy</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
--- a/accessible/tests/mochitest/tree/test_filectrl.html
+++ b/accessible/tests/mochitest/tree/test_filectrl.html
@@ -3,18 +3,16 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=483573
 -->
 <head>
   <title>File Input Control tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/tree/test_formctrl.html
+++ b/accessible/tests/mochitest/tree/test_formctrl.html
@@ -2,18 +2,16 @@
 <html>
 
 <head>
   <title>HTML form controls tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/tree/test_formctrl.xul
+++ b/accessible/tests/mochitest/tree/test_formctrl.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL checkbox and radio hierarchy tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
 
--- a/accessible/tests/mochitest/tree/test_gencontent.html
+++ b/accessible/tests/mochitest/tree/test_gencontent.html
@@ -11,18 +11,16 @@
       content: "START"
     }
     .gentext:after {
       content: "END"
     }
   </style>
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/tree/test_groupbox.xul
+++ b/accessible/tests/mochitest/tree/test_groupbox.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL groupbox hierarchy tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
 
--- a/accessible/tests/mochitest/tree/test_iframe.html
+++ b/accessible/tests/mochitest/tree/test_iframe.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Outer document accessible tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/tree/test_img.html
+++ b/accessible/tests/mochitest/tree/test_img.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>HTML img tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/tree/test_invalidationlist.html
+++ b/accessible/tests/mochitest/tree/test_invalidationlist.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Test document hierarchy</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
--- a/accessible/tests/mochitest/tree/test_list.html
+++ b/accessible/tests/mochitest/tree/test_list.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>HTML ul/li element tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/tree/test_media.html
+++ b/accessible/tests/mochitest/tree/test_media.html
@@ -3,18 +3,16 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=483573
 -->
 <head>
   <title>HTML5 audio/video tests</title>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
--- a/accessible/tests/mochitest/tree/test_select.html
+++ b/accessible/tests/mochitest/tree/test_select.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>HTML select control tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/tree/test_tabbox.xul
+++ b/accessible/tests/mochitest/tree/test_tabbox.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL tabbox hierarchy tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
 
--- a/accessible/tests/mochitest/tree/test_tabbrowser.xul
+++ b/accessible/tests/mochitest/tree/test_tabbrowser.xul
@@ -10,18 +10,16 @@
 
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL tabbrowser hierarchy tests">
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js" />
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
   <script type="application/javascript"
           src="../events.js" />
--- a/accessible/tests/mochitest/tree/test_table.html
+++ b/accessible/tests/mochitest/tree/test_table.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>HTML table tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/tree/test_tree.xul
+++ b/accessible/tests/mochitest/tree/test_tree.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL tree hierarchy tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../treeview.js" />
 
   <script type="application/javascript"
           src="../common.js" />
--- a/accessible/tests/mochitest/tree/test_txtcntr.html
+++ b/accessible/tests/mochitest/tree/test_txtcntr.html
@@ -2,18 +2,16 @@
 <html>
 
 <head>
   <title>HTML text containers tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/tree/test_txtctrl.html
+++ b/accessible/tests/mochitest/tree/test_txtctrl.html
@@ -2,18 +2,16 @@
 <html>
 
 <head>
   <title>HTML text controls tests</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/tree/test_txtctrl.xul
+++ b/accessible/tests/mochitest/tree/test_txtctrl.xul
@@ -2,18 +2,16 @@
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL textbox and textarea hierarchy tests">
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js" />
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
   <script type="application/javascript"
           src="../events.js" />
--- a/accessible/tests/mochitest/treeupdate/test_ariadialog.html
+++ b/accessible/tests/mochitest/treeupdate/test_ariadialog.html
@@ -3,18 +3,16 @@
 
 <head>
   <title>Table creation in ARIA dialog test</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/treeupdate/test_colorpicker.xul
+++ b/accessible/tests/mochitest/treeupdate/test_colorpicker.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL button hierarchy tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/treeupdate/test_contextmenu.xul
+++ b/accessible/tests/mochitest/treeupdate/test_contextmenu.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="menu tree and events">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/treeupdate/test_doc.html
+++ b/accessible/tests/mochitest/treeupdate/test_doc.html
@@ -2,18 +2,16 @@
 <html>
 
 <head>
   <title>Test document root content mutations</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../states.js"></script>
--- a/accessible/tests/mochitest/treeupdate/test_gencontent.html
+++ b/accessible/tests/mochitest/treeupdate/test_gencontent.html
@@ -11,18 +11,16 @@
       content: "START"
     }
     .gentext:after {
       content: "END"
     }
   </style>
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/treeupdate/test_list.html
+++ b/accessible/tests/mochitest/treeupdate/test_list.html
@@ -2,18 +2,16 @@
 <html>
 
 <head>
   <title>Test HTML li and listitem bullet accessible cache</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/treeupdate/test_list_editabledoc.html
+++ b/accessible/tests/mochitest/treeupdate/test_list_editabledoc.html
@@ -2,18 +2,16 @@
 <html>
 
 <head>
   <title>Test HTML li and listitem bullet accessible insertion into editable document</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/treeupdate/test_menu.xul
+++ b/accessible/tests/mochitest/treeupdate/test_menu.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL menu hierarchy tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/treeupdate/test_menubutton.xul
+++ b/accessible/tests/mochitest/treeupdate/test_menubutton.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Accessible XUL button hierarchy tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
   <script type="application/javascript"
--- a/accessible/tests/mochitest/treeupdate/test_recreation.html
+++ b/accessible/tests/mochitest/treeupdate/test_recreation.html
@@ -3,18 +3,16 @@
 
 <head>
   <title>Test accessible recreation</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/treeupdate/test_select.html
+++ b/accessible/tests/mochitest/treeupdate/test_select.html
@@ -1,18 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
   <title>Add select options test</title>
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
 
   <script type="application/javascript">
--- a/accessible/tests/mochitest/treeupdate/test_textleaf.html
+++ b/accessible/tests/mochitest/treeupdate/test_textleaf.html
@@ -3,18 +3,16 @@
 
 <head>
   <title>Test accessible recreation</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/treeupdate/test_visibility.html
+++ b/accessible/tests/mochitest/treeupdate/test_visibility.html
@@ -3,18 +3,16 @@
 
 <head>
   <title>Style visibility tree update test</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/treeupdate/test_whitespace.html
+++ b/accessible/tests/mochitest/treeupdate/test_whitespace.html
@@ -3,18 +3,16 @@
 
 <head>
   <title>Whitespace text accessible creation/desctruction</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
--- a/accessible/tests/mochitest/value/test_general.html
+++ b/accessible/tests/mochitest/value/test_general.html
@@ -12,18 +12,16 @@
       left: -5000px;
       top: -5000px;
       height: 100px;
       width: 100px;
     }
   </style>
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
 
   <script type="application/javascript"
 	  src="chrome://mochikit/content/chrome-harness.js"></script>
 
--- a/accessible/tests/mochitest/value/test_progress.html
+++ b/accessible/tests/mochitest/value/test_progress.html
@@ -2,18 +2,16 @@
 
 <head>
   <title>nsIAccessible value testing for progress element</title>
 
   <link rel="stylesheet" type="text/css"
         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
   <script type="application/javascript"
           src="../value.js"></script>
 
   <script type="application/javascript"
--- a/accessible/tests/mochitest/value/test_progress.xul
+++ b/accessible/tests/mochitest/value/test_progress.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                  type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="XUL progressmeter tests">
 
-  <script type="application/javascript" 
-          src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../value.js" />
 
--- a/browser/app/blocklist.xml
+++ b/browser/app/blocklist.xml
@@ -1,13 +1,13 @@
 <?xml version="1.0"?>
-<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1311096050000">
+<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1311891123000">
   <emItems>
       <emItem  blockID="i41" id="{99079a25-328f-4bd4-be04-00955acaa0a7}">
-                        <versionRange  minVersion="0.1" maxVersion="4.3.0.00" severity="1">
+                        <versionRange  minVersion="0.1" maxVersion="4.3.1.00" severity="1">
                     </versionRange>
                   </emItem>
       <emItem  blockID="i8" id="{B13721C7-F507-4982-B2E5-502A71474FED}">
                         <versionRange  minVersion=" " severity="1">
                     </versionRange>
                   </emItem>
       <emItem  blockID="i38" id="{B7082FAA-CB62-4872-9106-E42DD88EDE45}">
                         <versionRange  minVersion="0.1" maxVersion="3.3.0.*">
@@ -25,17 +25,17 @@
                         <versionRange  minVersion="1.1b1" maxVersion="1.1b1">
                     </versionRange>
                   </emItem>
       <emItem  blockID="i16" id="{27182e60-b5f3-411c-b545-b44205977502}">
                         <versionRange  minVersion="1.0" maxVersion="1.0">
                     </versionRange>
                   </emItem>
       <emItem  blockID="i39" id="{c2d64ff7-0ab8-4263-89c9-ea3b0f8f050c}">
-                        <versionRange  minVersion="0.1" maxVersion="4.3.0.00" severity="1">
+                        <versionRange  minVersion="0.1" maxVersion="4.3.1.00" severity="1">
                     </versionRange>
                   </emItem>
       <emItem  blockID="i10" id="{8CE11043-9A15-4207-A565-0C94C42D590D}">
                         </emItem>
       <emItem  blockID="i1" id="mozilla_cc@internetdownloadmanager.com">
                         <versionRange  minVersion="2.1" maxVersion="3.3">
                       <targetApplication  id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}">
                               <versionRange  minVersion="3.0a1" maxVersion="*" />
@@ -56,17 +56,17 @@
       <emItem  blockID="i4" id="{4B3803EA-5230-4DC3-A7FC-33638F3D3542}">
                         <versionRange  minVersion="1.2" maxVersion="1.2">
                       <targetApplication  id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}">
                               <versionRange  minVersion="3.0a1" maxVersion="*" />
                           </targetApplication>
                     </versionRange>
                   </emItem>
       <emItem  blockID="i40" id="{28387537-e3f9-4ed7-860c-11e69af4a8a0}">
-                        <versionRange  minVersion="0.1" maxVersion="4.3.0.00" severity="1">
+                        <versionRange  minVersion="0.1" maxVersion="4.3.1.00" severity="1">
                     </versionRange>
                   </emItem>
       <emItem  blockID="i23" id="firefox@bandoo.com">
                         <versionRange  minVersion="5.0" maxVersion="5.0" severity="1">
                       <targetApplication  id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}">
                               <versionRange  minVersion="3.7a1pre" maxVersion="*" />
                           </targetApplication>
                     </versionRange>
--- a/browser/app/profile/extensions/Makefile.in
+++ b/browser/app/profile/extensions/Makefile.in
@@ -53,17 +53,17 @@ EXTENSIONS = \
   testpilot@labs.mozilla.com \
   $(NULL)
 
 define _INSTALL_EXTENSION
 $(NSINSTALL) -D $(dir) && \
   $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(srcdir)/$(dir)/install.rdf.in > $(dir)/install.rdf && \
   cd $(dir) && \
   $(ZIP) -r9XD $(DISTROEXT)/$(dir).xpi install.rdf && \
-  cd $(srcdir)/$(dir) && \
+  cd $(call core_abspath,$(srcdir)/$(dir)) && \
   $(ZIP) -r9XD $(DISTROEXT)/$(dir).xpi * -x install.rdf.in
 
 endef # do not remove the blank line!
 
 libs::
 	$(NSINSTALL) -D $(DISTROEXT)
 	$(foreach dir,$(EXTENSIONS),$(_INSTALL_EXTENSION))
 endif
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -69,16 +69,21 @@ pref("extensions.blocklist.interval", 86
 // 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%/");
 pref("extensions.blocklist.detailsURL", "https://www.mozilla.com/%LOCALE%/blocklist/");
 pref("extensions.blocklist.itemURL", "https://addons.mozilla.org/%LOCALE%/%APP%/blocked/%blockID%");
 
 pref("extensions.update.autoUpdateDefault", true);
 
+// Disable add-ons installed into the shared user and shared system areas by
+// default. This does not include the application directory. See the SCOPE
+// constants in AddonManager.jsm for values to use here
+pref("extensions.autoDisableScopes", 10);
+
 // Dictionary download preference
 pref("browser.dictionaries.download.url", "https://addons.mozilla.org/%LOCALE%/firefox/dictionaries/");
 
 // The minimum delay in seconds for the timer to fire.
 // default=2 minutes
 pref("app.update.timerMinimumDelay", 120);
 
 // App-specific update preferences
@@ -1035,16 +1040,27 @@ pref("devtools.hud.loglimit.exception", 
 pref("devtools.hud.loglimit.console", 200);
 
 // The developer tools editor configuration:
 // - tabsize: how many spaces to use when a Tab character is displayed.
 // - expandtab: expand Tab characters to spaces.
 pref("devtools.editor.tabsize", 4);
 pref("devtools.editor.expandtab", true);
 
+// Tells which component you want to use for source editing in developer tools.
+//
+// Available components:
+//   "textarea" - this is a basic text editor, like an HTML <textarea>.
+//
+//   "orion" - this is the Orion source code editor from the Eclipse project. It
+//   provides programmer-specific editor features such as syntax highlighting,
+//   indenting and bracket recognition. It may not be appropriate for all
+//   locales (esp. RTL) or a11y situations.
+pref("devtools.editor.component", "textarea");
+
 // Whether the character encoding menu is under the main Firefox button. This
 // preference is a string so that localizers can alter it.
 pref("browser.menu.showCharacterEncoding", "chrome://browser/locale/browser.properties");
 
 // Allow using tab-modal prompts when possible.
 pref("prompts.tab_modal.enabled", true);
 // Whether the Panorama should animate going in/out of tabs
 pref("browser.panorama.animate_zoom", true);
--- a/browser/base/content/tabview/groupitems.js
+++ b/browser/base/content/tabview/groupitems.js
@@ -527,20 +527,17 @@ GroupItem.prototype = Utils.extend(new I
   // Parameters:
   //   rect - a <Rect> giving the new bounds
   //   immediately - true if it should not animate; default false
   //   options - an object with additional parameters, see below
   //
   // Possible options:
   //   force - true to always update the DOM even if the bounds haven't changed; default false
   setBounds: function GroupItem_setBounds(inRect, immediately, options) {
-    if (!Utils.isRect(inRect)) {
-      Utils.trace('GroupItem.setBounds: rect is not a real rectangle!', inRect);
-      return;
-    }
+      Utils.assert(Utils.isRect(inRect), 'GroupItem.setBounds: rect is not a real rectangle!');
 
     // Validate and conform passed in size
     let validSize = GroupItems.calcValidSize(
       new Point(inRect.width, inRect.height));
     let rect = new Rect(inRect.left, inRect.top, validSize.x, validSize.y);
 
     if (!options)
       options = {};
--- a/browser/base/content/tabview/tabitems.js
+++ b/browser/base/content/tabview/tabitems.js
@@ -340,20 +340,17 @@ TabItem.prototype = Utils.extend(new Ite
   // Parameters:
   //   rect - a <Rect> giving the new bounds
   //   immediately - true if it should not animate; default false
   //   options - an object with additional parameters, see below
   //
   // Possible options:
   //   force - true to always update the DOM even if the bounds haven't changed; default false
   setBounds: function TabItem_setBounds(inRect, immediately, options) {
-    if (!Utils.isRect(inRect)) {
-      Utils.trace('TabItem.setBounds: rect is not a real rectangle!', inRect);
-      return;
-    }
+    Utils.assert(Utils.isRect(inRect), 'TabItem.setBounds: rect is not a real rectangle!');
 
     if (!options)
       options = {};
 
     // force the input size to be valid
     let validSize = TabItems.calcValidSize(
       new Point(inRect.width, inRect.height), 
       {hideTitle: (this.isStacked || options.hideTitle === true)});
@@ -448,18 +445,17 @@ TabItem.prototype = Utils.extend(new Ite
     }
 
     this._hasBeenDrawn = true;
 
     UI.clearShouldResizeItems();
 
     rect = this.getBounds(); // ensure that it's a <Rect>
 
-    if (!Utils.isRect(this.bounds))
-      Utils.trace('TabItem.setBounds: this.bounds is not a real rectangle!', this.bounds);
+    Utils.assert(Utils.isRect(this.bounds), 'TabItem.setBounds: this.bounds is not a real rectangle!');
 
     if (!this.parent && this.tab.parentNode != null)
       this.setTrenches(rect);
 
     this.save();
   },
 
   // ----------
--- a/browser/base/content/test/browser_sanitizeDialog.js
+++ b/browser/base/content/test/browser_sanitizeDialog.js
@@ -47,20 +47,16 @@
  * the sanitize timespan code.
  *
  * Some of this code, especially the history creation parts, was taken from
  * browser/base/content/test/browser_sanitize-timespans.js.
  */
 
 Cc["@mozilla.org/moz/jssubscript-loader;1"].
   getService(Ci.mozIJSSubScriptLoader).
-  loadSubScript("chrome://mochikit/content/MochiKit/packed.js");
-
-Cc["@mozilla.org/moz/jssubscript-loader;1"].
-  getService(Ci.mozIJSSubScriptLoader).
   loadSubScript("chrome://browser/content/sanitize.js");
 
 const dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
 const bhist = Cc["@mozilla.org/browser/global-history;2"].
               getService(Ci.nsIBrowserHistory);
 const formhist = Cc["@mozilla.org/satchel/form-history;1"].
                  getService(Ci.nsIFormHistory2);
--- a/browser/base/content/test/browser_sanitizeDialog_treeView.js
+++ b/browser/base/content/test/browser_sanitizeDialog_treeView.js
@@ -46,20 +46,16 @@
  * the sanitize timespan code.
  *
  * Some of this code, especially the history creation parts, was taken from
  * browser/base/content/test/browser_sanitize-timespans.js.
  */
 
 Cc["@mozilla.org/moz/jssubscript-loader;1"].
   getService(Ci.mozIJSSubScriptLoader).
-  loadSubScript("chrome://mochikit/content/MochiKit/packed.js");
-
-Cc["@mozilla.org/moz/jssubscript-loader;1"].
-  getService(Ci.mozIJSSubScriptLoader).
   loadSubScript("chrome://browser/content/sanitize.js");
 
 const dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
 const bhist = Cc["@mozilla.org/browser/global-history;2"].
               getService(Ci.nsIBrowserHistory);
 const formhist = Cc["@mozilla.org/satchel/form-history;1"].
                  getService(Ci.nsIFormHistory2);
--- a/browser/base/content/test/browser_tab_dragdrop2_frame1.xul
+++ b/browser/base/content/test/browser_tab_dragdrop2_frame1.xul
@@ -2,18 +2,16 @@
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
 <!--
   XUL Widget Test for panels
   -->
 <window title="Titlebar" width="200" height="200"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js" />
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 
 <tree id="tree" seltype="single" width="100" height="100">
   <treecols>
     <treecol flex="1"/>
     <treecol flex="1"/>
--- a/browser/base/content/test/test_bug364677.html
+++ b/browser/base/content/test/test_bug364677.html
@@ -1,16 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=364677
 -->
 <head>
   <title>Test for Bug 364677</title>
-  <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=364677">Mozilla Bug 364677</a>
 <p id="display"><iframe id="testFrame" src="bug364677-data.xml"></iframe></p>
 <div id="content" style="display: none">
 
--- a/browser/base/content/test/test_bug395533.html
+++ b/browser/base/content/test/test_bug395533.html
@@ -1,16 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=395533
 -->
 <head>
   <title>Test for Bug 395533</title>
-  <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=395533">Mozilla Bug 395533</a>
 <p id="display"><iframe id="testFrame" src="bug395533-data.txt"></iframe></p>
 <div id="content" style="display: none">
   
--- a/browser/base/content/test/test_bug452451.html
+++ b/browser/base/content/test/test_bug452451.html
@@ -1,16 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=452451
 -->
 <head>
   <title>Test for Bug 452451</title>
-  <script type="application/javascript" src="/MochiKit/packed.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=452451">Mozilla Bug 452451</a>
 <p id="display"></p>
 <pre id="test">
 <script type="application/javascript">
--- a/browser/base/content/test/test_contextmenu.html
+++ b/browser/base/content/test/test_contextmenu.html
@@ -1,13 +1,12 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Tests for browser context menu</title>
-  <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>  
   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 Browser context menu tests.
 <p id="display"></p>
 
@@ -584,16 +583,17 @@ function startTest() {
     img    = subwindow.document.getElementById("test-image");
     canvas = subwindow.document.getElementById("test-canvas");
     video_ok   = subwindow.document.getElementById("test-video-ok");
     video_bad  = subwindow.document.getElementById("test-video-bad");
     video_bad2 = subwindow.document.getElementById("test-video-bad2");
     iframe = subwindow.document.getElementById("test-iframe");
     textarea = subwindow.document.getElementById("test-textarea");
     contenteditable = subwindow.document.getElementById("test-contenteditable");
+    contenteditable.focus(); // content editable needs to be focused to enable spellcheck
     inputspell = subwindow.document.getElementById("test-input-spellcheck");
     pagemenu = subwindow.document.getElementById("test-pagemenu");
 
     contextMenu.addEventListener("popupshown", function() { runTest(++testNum); }, false);
     runTest(1);
 }
 
 // We open this in a separate window, because the Mochitests run inside a frame.
--- a/browser/base/content/test/test_feed_discovery.html
+++ b/browser/base/content/test/test_feed_discovery.html
@@ -1,16 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=377611
 -->
 <head>
   <title>Test for feed discovery</title>
-  <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=377611">Mozilla Bug 377611</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   
--- a/browser/base/content/test/test_offlineNotification.html
+++ b/browser/base/content/test/test_offlineNotification.html
@@ -1,16 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=462856
 -->
 <head>
   <title>Test offline app notification</title>
-  <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body onload="loaded()">
 <p id="display">
 <!-- Load the test frame twice from the same domain,
      to make sure we get notifications for both -->
 <iframe name="testFrame" src="offlineChild.html"></iframe>
--- a/browser/components/feeds/test/chrome/test_423060.xul
+++ b/browser/components/feeds/test/chrome/test_423060.xul
@@ -1,18 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet
   href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
 <window title="Make sure feed preview works when a default reader is selected"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
-   src="chrome://mochikit/content/MochiKit/packed.js"></script>
-  <script type="application/javascript"
    src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" />
 
   <script type="application/javascript">
     SimpleTest.waitForExplicitFinish();
 
     const Cc = Components.classes;
--- a/browser/components/feeds/test/test_bug368464.html
+++ b/browser/components/feeds/test/test_bug368464.html
@@ -1,16 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=368464
 -->
 <head>
   <title>Test that RSS 0.90 isn't sniffed</title>
-  <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=368464">Mozilla Bug 368464</a>
 <p id="display"><iframe id="testFrame" src="bug368464-data.xml"></iframe></p>
 <div id="content" style="display: none">
 
--- a/browser/components/feeds/test/test_bug408328.html
+++ b/browser/components/feeds/test/test_bug408328.html
@@ -1,16 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=408328
 -->
 <head>
   <title>Test feed preview safe-linkification</title>
-  <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=408328">Mozilla Bug 408328</a>
 <p id="display"><iframe id="testFrame" src="bug408328-data.xml"></iframe></p>
 <div id="content" style="display: none">
   
--- a/browser/components/feeds/test/test_bug494328.html
+++ b/browser/components/feeds/test/test_bug494328.html
@@ -1,16 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=494328
 -->
 <head>
   <title>Test for bug 494328</title>
-  <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=494328">Mozilla Bug 494328</a>
 <p id="display"><iframe id="testFrame" src="bug494328-data.xml"></iframe></p>
 <div id="content" style="display: none">
   
--- a/browser/components/feeds/test/test_bug589543.html
+++ b/browser/components/feeds/test/test_bug589543.html
@@ -1,16 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=589543
 -->
 <head>
   <title>Test feed preview subscribe UI</title>
-  <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=589543">Mozilla Bug 589543</a>
 <p id="display"><iframe id="testFrame" src="bug589543-data.xml"></iframe></p>
 <div id="content" style="display: none">
 </div>
--- a/browser/components/feeds/test/test_registerHandler.html
+++ b/browser/components/feeds/test/test_registerHandler.html
@@ -1,16 +1,15 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=402788
 -->
 <head>
   <title>Test for Bug 402788</title>
-  <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=402788">Mozilla Bug 402788</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -46,16 +46,17 @@ const Ci = Components.interfaces;
 const Cc = Components.classes;
 const Cr = Components.results;
 const Cu = Components.utils;
 
 const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/AddonManager.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "NetUtil", function() {
   Cu.import("resource://gre/modules/NetUtil.jsm");
   return NetUtil;
 });
 
 XPCOMUtils.defineLazyGetter(this, "PlacesUtils", function() {
   Cu.import("resource://gre/modules/PlacesUtils.jsm");
@@ -394,16 +395,31 @@ BrowserGlue.prototype = {
     if (this._isPlacesDatabaseLocked) {
       this._showPlacesLockedNotificationBox();
     }
 
     // If there are plugins installed that are outdated, and the user hasn't
     // been warned about them yet, open the plugins update page.
     if (Services.prefs.getBoolPref(PREF_PLUGINS_NOTIFYUSER))
       this._showPluginUpdatePage();
+
+    // For any add-ons that were installed disabled and can be enabled offer
+    // them to the user
+    var win = this.getMostRecentBrowserWindow();
+    var browser = win.gBrowser;
+    var changedIDs = AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_INSTALLED);
+    AddonManager.getAddonsByIDs(changedIDs, function(aAddons) {
+      aAddons.forEach(function(aAddon) {
+        // If the add-on isn't user disabled or can't be enabled then skip it
+        if (!aAddon.userDisabled || !(aAddon.permissions & AddonManager.PERM_CAN_ENABLE))
+          return;
+
+        browser.selectedTab = browser.addTab("about:newaddon?id=" + aAddon.id);
+      })
+    });
   },
 
   _onQuitRequest: function BG__onQuitRequest(aCancelQuit, aQuitType) {
     // If user has already dismissed quit request, then do nothing
     if ((aCancelQuit instanceof Ci.nsISupportsPRBool) && aCancelQuit.data)
       return;
 
     // There are several cases where we won't show a dialog here:
--- a/browser/components/places/tests/browser/browser_library_batch_delete.js
+++ b/browser/components/places/tests/browser/browser_library_batch_delete.js
@@ -75,17 +75,17 @@ gTests.push({
     // Now select the "keepme" folder in the right pane and delete it.
     PO._content.selectNode(PO._content.result.root.getChild(0));
     is(PO._content.selectedNode.title, "keepme",
        "Found folder in content pane");
     // Test live update.
     PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
                                          makeURI(TEST_URL),
                                          PlacesUtils.bookmarks.DEFAULT_INDEX,
-                                         "bm" + i);
+                                         "bm");
     is(PO._content.result.root.childCount, 2,
        "Right pane was correctly updated");
     nextTest();
   }
 });
 
 //------------------------------------------------------------------------------
 
--- a/browser/components/places/tests/chrome/test_0_bug510634.xul
+++ b/browser/components/places/tests/chrome/test_0_bug510634.xul
@@ -44,18 +44,16 @@
 <?xml-stylesheet href="chrome://browser/skin/places/places.css"?>
 <?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="510634: Wrong icons on bookmarks sidebar"
         onload="runTest();">
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js" />
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <body xmlns="http://www.w3.org/1999/xhtml" />
 
   <tree id="tree"
         type="places"
         flex="1">
     <treecols>
--- a/browser/components/places/tests/chrome/test_0_multiple_left_pane.xul
+++ b/browser/components/places/tests/chrome/test_0_multiple_left_pane.xul
@@ -49,18 +49,16 @@
 
 <?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Test handling of multiple left pane folders"
         onload="runTest();">
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js" />
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <body xmlns="http://www.w3.org/1999/xhtml">
     <p id="display"></p>
     <div id="content" style="display: none"></div>
     <pre id="test"></pre>
   </body>
 
--- a/browser/components/places/tests/chrome/test_bug427633_no_newfolder_if_noip.xul
+++ b/browser/components/places/tests/chrome/test_bug427633_no_newfolder_if_noip.xul
@@ -52,18 +52,16 @@
   %editBookmarkOverlayDTD;
 ]>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Bug 427633 - Disable creating a New Folder in the bookmarks dialogs if insertionPoint is invalid"
         onload="runTest();">
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js" />
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="chrome://browser/content/places/editBookmarkOverlay.js"/>
 
   <body xmlns="http://www.w3.org/1999/xhtml" />
 
   <vbox id="editBookmarkPanelContent"/>
 
--- a/browser/components/places/tests/chrome/test_bug485100-change-case-loses-tag.xul
+++ b/browser/components/places/tests/chrome/test_bug485100-change-case-loses-tag.xul
@@ -53,18 +53,16 @@
   %editBookmarkOverlayDTD;
 ]>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="485100: Exchanging a letter of a tag name with its big/small equivalent removes tag from bookmark"
         onload="runTest();">
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js" />
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="chrome://browser/content/places/editBookmarkOverlay.js"/>
 
   <body xmlns="http://www.w3.org/1999/xhtml" />
 
   <vbox id="editBookmarkPanelContent"/>
 
--- a/browser/components/places/tests/chrome/test_bug549192.xul
+++ b/browser/components/places/tests/chrome/test_bug549192.xul
@@ -13,18 +13,16 @@
 <?xml-stylesheet href="chrome://browser/skin/places/places.css"?>
 <?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="549192:  History view not updated after deleting entry"
         onload="runTest();">
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js" />
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <body xmlns="http://www.w3.org/1999/xhtml" />
 
   <tree id="tree"
         type="places"
         flatList="true"
         flex="1">
--- a/browser/components/places/tests/chrome/test_bug549491.xul
+++ b/browser/components/places/tests/chrome/test_bug549491.xul
@@ -13,18 +13,16 @@
 <?xml-stylesheet href="chrome://browser/skin/places/places.css"?>
 <?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="549491: 'The root node is never visible' exception when details of the root node are modified "
         onload="runTest();">
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js" />
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <body xmlns="http://www.w3.org/1999/xhtml" />
 
   <tree id="tree"
         type="places"
         flatList="true"
         flex="1">
--- a/browser/components/places/tests/chrome/test_bug631374_tags_selector_scroll.xul
+++ b/browser/components/places/tests/chrome/test_bug631374_tags_selector_scroll.xul
@@ -19,18 +19,16 @@
   %editBookmarkOverlayDTD;
 ]>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="Bug 631374 - Editing tags in the selector scrolls up the listbox"
         onload="runTest();">
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js" />
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="chrome://browser/content/places/editBookmarkOverlay.js"/>
 
   <body xmlns="http://www.w3.org/1999/xhtml" />
 
   <vbox id="editBookmarkPanelContent"/>
 
--- a/browser/components/places/tests/chrome/test_editBookmarkOverlay_tags_liveUpdate.xul
+++ b/browser/components/places/tests/chrome/test_editBookmarkOverlay_tags_liveUpdate.xul
@@ -19,18 +19,16 @@
   %editBookmarkOverlayDTD;
 ]>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="485100: Exchanging a letter of a tag name with its big/small equivalent removes tag from bookmark"
         onload="runTest();">
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js" />
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript"
           src="chrome://browser/content/places/editBookmarkOverlay.js"/>
 
   <body xmlns="http://www.w3.org/1999/xhtml" />
 
   <vbox id="editBookmarkPanelContent"/>
 
--- a/browser/components/places/tests/chrome/test_treeview_date.xul
+++ b/browser/components/places/tests/chrome/test_treeview_date.xul
@@ -44,18 +44,16 @@
 <?xml-stylesheet href="chrome://browser/skin/places/places.css"?>
 <?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         title="435322: Places tree view's formatting"
         onload="runTest();">
 
   <script type="application/javascript"
-          src="chrome://mochikit/content/MochiKit/packed.js" />
-  <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <body xmlns="http://www.w3.org/1999/xhtml" />
 
   <tree id="tree"
         type="places"
         flatList="true"
         flex="1">
--- a/browser/components/preferences/aboutPermissions.xul
+++ b/browser/components/preferences/aboutPermissions.xul
@@ -53,17 +53,17 @@
       onload="AboutPermissions.init();"
       onunload="AboutPermissions.cleanUp();"
       disablefastfind="true"
       role="application">
 
   <script type="application/javascript"
           src="chrome://browser/content/preferences/aboutPermissions.js"/>
 
-  <hbox flex="1" id="permissions-content">
+  <hbox flex="1" id="permissions-content" class="main-content">
 
     <vbox id="sites-box">
       <textbox id="sites-filter"
                emptytext="&sites.search;"
                oncommand="AboutPermissions.filterSitesList();"
                type="search"/>
       <richlistbox id="sites-list"
                    flex="1"
--- a/browser/devtools/Makefile.in
+++ b/browser/devtools/Makefile.in
@@ -43,15 +43,16 @@ VPATH   = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 include $(topsrcdir)/config/config.mk
 
 DIRS = \
   webconsole \
   scratchpad \
+  sourceeditor \
   $(NULL)
 
 ifdef ENABLE_TESTS
 # DIRS += test # no tests yet
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/browser/devtools/jar.mn
+++ b/browser/devtools/jar.mn
@@ -1,4 +1,6 @@
 browser.jar:
     content/browser/NetworkPanel.xhtml            (webconsole/NetworkPanel.xhtml)
 *   content/browser/scratchpad.xul                (scratchpad/scratchpad.xul)
 *   content/browser/scratchpad.js                 (scratchpad/scratchpad.js)
+    content/browser/orion.js                      (sourceeditor/orion/orion.js)
+    content/browser/orion.css                     (sourceeditor/orion/orion.css)
--- a/browser/devtools/scratchpad/scratchpad.js
+++ b/browser/devtools/scratchpad/scratchpad.js
@@ -43,35 +43,35 @@
  * Original version history can be found here:
  * https://github.com/mozilla/workspace
  *
  * Copied and relicensed from the Public Domain.
  * See bug 653934 for details.
  * https://bugzilla.mozilla.org/show_bug.cgi?id=653934
  */
 
+"use strict";
+
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/NetUtil.jsm");
 Cu.import("resource:///modules/PropertyPanel.jsm");
+Cu.import("resource:///modules/source-editor.jsm");
 
 const SCRATCHPAD_CONTEXT_CONTENT = 1;
 const SCRATCHPAD_CONTEXT_BROWSER = 2;
 const SCRATCHPAD_WINDOW_URL = "chrome://browser/content/scratchpad.xul";
 const SCRATCHPAD_L10N = "chrome://browser/locale/scratchpad.properties";
 const SCRATCHPAD_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
 const DEVTOOLS_CHROME_ENABLED = "devtools.chrome.enabled";
 
-const PREF_TABSIZE = "devtools.editor.tabsize";
-const PREF_EXPANDTAB = "devtools.editor.expandtab";
-
 /**
  * The scratchpad object handles the Scratchpad window functionality.
  */
 var Scratchpad = {
   /**
    * The script execution context. This tells Scratchpad in which context the
    * script shall execute.
    *
@@ -79,34 +79,62 @@ var Scratchpad = {
    *   - SCRATCHPAD_CONTEXT_CONTENT to execute code in the context of the current
    *   tab content window object.
    *   - SCRATCHPAD_CONTEXT_BROWSER to execute code in the context of the
    *   currently active chrome window object.
    */
   executionContext: SCRATCHPAD_CONTEXT_CONTENT,
 
   /**
-   * Retrieve the xul:textbox DOM element. This element holds the source code
-   * the user writes and executes.
-   */
-  get textbox() document.getElementById("scratchpad-textbox"),
-
-  /**
    * Retrieve the xul:statusbarpanel DOM element. The status bar tells the
    * current code execution context.
    */
   get statusbarStatus() document.getElementById("scratchpad-status"),
 
   /**
-   * Get the selected text from the textbox.
+   * Get the selected text from the editor.
+   *
+   * @return string
+   *         The selected text.
+   */
+  get selectedText() this.editor.getSelectedText(),
+
+  /**
+   * Get the editor content, in the given range. If no range is given you get
+   * the entire editor content.
+   *
+   * @param number [aStart=0]
+   *        Optional, start from the given offset.
+   * @param number [aEnd=content char count]
+   *        Optional, end offset for the text you want. If this parameter is not
+   *        given, then the text returned goes until the end of the editor
+   *        content.
+   * @return string
+   *         The text in the given range.
    */
-  get selectedText()
+  getText: function SP_getText(aStart, aEnd)
   {
-    return this.textbox.value.substring(this.textbox.selectionStart,
-                                        this.textbox.selectionEnd);
+    return this.editor.getText(aStart, aEnd);
+  },
+
+  /**
+   * Replace text in the source editor with the given text, in the given range.
+   *
+   * @param string aText
+   *        The text you want to put into the editor.
+   * @param number [aStart=0]
+   *        Optional, the start offset, zero based, from where you want to start
+   *        replacing text in the editor.
+   * @param number [aEnd=char count]
+   *        Optional, the end offset, zero based, where you want to stop
+   *        replacing text in the editor.
+   */
+  setText: function SP_setText(aText, aStart, aEnd)
+  {
+    this.editor.setText(aText, aStart, aEnd);
   },
 
   /**
    * Get the most recent chrome window of type navigator:browser.
    */
   get browserWindow() Services.wm.getMostRecentWindow("navigator:browser"),
 
   /**
@@ -119,21 +147,16 @@ var Scratchpad = {
    * Get the gBrowser object of the most recent browser window.
    */
   get gBrowser()
   {
     let recentWin = this.browserWindow;
     return recentWin ? recentWin.gBrowser : null;
   },
 
-  insertIntro: function SP_insertIntro()
-  {
-    this.textbox.value = this.strings.GetStringFromName("scratchpadIntro");
-  },
-
   /**
    * Cached Cu.Sandbox object for the active tab content window object.
    */
   _contentSandbox: null,
 
   /**
    * Get the Cu.Sandbox object for the active tab content window object. Note
    * that the returned object is cached for later reuse. The cached object is
@@ -192,35 +215,46 @@ var Scratchpad = {
 
       this._previousBrowserWindow = this.browserWindow;
     }
 
     return this._chromeSandbox;
   },
 
   /**
-   * Drop the textbox selection.
+   * Drop the editor selection.
    */
   deselect: function SP_deselect()
   {
-    this.textbox.selectionEnd = this.textbox.selectionStart;
+    this.editor.dropSelection();
   },
 
   /**
-   * Select a specific range in the Scratchpad xul:textbox.
+   * Select a specific range in the Scratchpad editor.
    *
    * @param number aStart
    *        Selection range start.
    * @param number aEnd
    *        Selection range end.
    */
   selectRange: function SP_selectRange(aStart, aEnd)
   {
-    this.textbox.selectionStart = aStart;
-    this.textbox.selectionEnd = aEnd;
+    this.editor.setSelection(aStart, aEnd);
+  },
+
+  /**
+   * Get the current selection range.
+   *
+   * @return object
+   *         An object with two properties, start and end, that give the
+   *         selection range (zero based offsets).
+   */
+  getSelectionRange: function SP_getSelection()
+  {
+    return this.editor.getSelection();
   },
 
   /**
    * Evaluate a string in the active tab content window.
    *
    * @param string aString
    *        The script you want evaluated.
    * @return mixed
@@ -288,70 +322,65 @@ var Scratchpad = {
   evalForContext: function SP_evaluateForContext(aString)
   {
     return this.executionContext == SCRATCHPAD_CONTEXT_CONTENT ?
            this.evalInContentSandbox(aString) :
            this.evalInChromeSandbox(aString);
   },
 
   /**
-   * Execute the selected text (if any) or the entire textbox content in the
+   * Execute the selected text (if any) or the entire editor content in the
    * current context.
    */
   run: function SP_run()
   {
-    let selection = this.selectedText || this.textbox.value;
+    let selection = this.selectedText || this.getText();
     let result = this.evalForContext(selection);
     this.deselect();
     return [selection, result];
   },
 
   /**
-   * Execute the selected text (if any) or the entire textbox content in the
+   * Execute the selected text (if any) or the entire editor content in the
    * current context. The resulting object is opened up in the Property Panel
    * for inspection.
    */
   inspect: function SP_inspect()
   {
     let [selection, result] = this.run();
 
     if (result) {
       this.openPropertyPanel(selection, result);
     }
   },
 
   /**
-   * Execute the selected text (if any) or the entire textbox content in the
-   * current context. The evaluation result is inserted into the textbox after
-   * the selected text, or at the end of the textbox value if there is no
+   * Execute the selected text (if any) or the entire editor content in the
+   * current context. The evaluation result is inserted into the editor after
+   * the selected text, or at the end of the editor content if there is no
    * selected text.
    */
   display: function SP_display()
   {
-    let selectionStart = this.textbox.selectionStart;
-    let selectionEnd = this.textbox.selectionEnd;
-    if (selectionStart == selectionEnd) {
-      selectionEnd = this.textbox.value.length;
-    }
+    let selection = this.getSelectionRange();
+    let insertionPoint = selection.start != selection.end ?
+                         selection.end : // after selected text
+                         this.editor.getCharCount(); // after text end
 
-    let [selection, result] = this.run();
+    let [selectedText, result] = this.run();
     if (!result) {
       return;
     }
 
-    let firstPiece = this.textbox.value.slice(0, selectionEnd);
-    let lastPiece = this.textbox.value.
-                    slice(selectionEnd, this.textbox.value.length);
-
     let newComment = "/*\n" + result.toString() + "\n*/";
 
-    this.textbox.value = firstPiece + newComment + lastPiece;
+    this.setText(newComment, insertionPoint, insertionPoint);
 
-    // Select the added comment.
-    this.selectRange(firstPiece.length, firstPiece.length + newComment.length);
+    // Select the new comment.
+    this.selectRange(insertionPoint, insertionPoint + newComment.length);
   },
 
   /**
    * Open the Property Panel to inspect the given object.
    *
    * @param string aEvalString
    *        The string that was evaluated. This is re-used when the user updates
    *        the properties list, by clicking the Update button.
@@ -437,22 +466,22 @@ var Scratchpad = {
         !window.confirm(this.strings.
                         GetStringFromName("export.fileOverwriteConfirmation"))) {
       return;
     }
 
     let fs = Cc["@mozilla.org/network/file-output-stream;1"].
              createInstance(Ci.nsIFileOutputStream);
     let modeFlags = 0x02 | 0x08 | 0x20;
-    fs.init(aFile, modeFlags, 0644, fs.DEFER_OPEN);
+    fs.init(aFile, modeFlags, 420 /* 0644 */, fs.DEFER_OPEN);
 
     let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
                     createInstance(Ci.nsIScriptableUnicodeConverter);
     converter.charset = "UTF-8";
-    let input = converter.convertToInputStream(this.textbox.value);
+    let input = converter.convertToInputStream(this.getText());
 
     let self = this;
     NetUtil.asyncCopy(input, fs, function(aStatus) {
       if (!aSilentError && !Components.isSuccessCode(aStatus)) {
         window.alert(self.strings.GetStringFromName("saveFile.failed"));
       }
 
       if (aCallback) {
@@ -483,17 +512,17 @@ var Scratchpad = {
 
     let self = this;
     NetUtil.asyncFetch(channel, function(aInputStream, aStatus) {
       let content = null;
 
       if (Components.isSuccessCode(aStatus)) {
         content = NetUtil.readInputStreamToString(aInputStream,
                                                   aInputStream.available());
-        self.textbox.value = content;
+        self.setText(content);
       }
       else if (!aSilentError) {
         window.alert(self.strings.GetStringFromName("openFile.failed"));
       }
 
       if (aCallback) {
         aCallback.call(self, aStatus, content);
       }
@@ -535,17 +564,17 @@ var Scratchpad = {
   saveFileAs: function SP_saveFileAs()
   {
     let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
     fp.init(window, this.strings.GetStringFromName("saveFileAs"),
             Ci.nsIFilePicker.modeSave);
     fp.defaultString = "scratchpad.js";
     if (fp.show() != Ci.nsIFilePicker.returnCancel) {
       document.title = this.filename = fp.file.path;
-      this.exportToFile(fp.file);
+      this.exportToFile(fp.file, true);
     }
   },
 
   /**
    * Open the Error Console.
    */
   openErrorConsole: function SP_openErrorConsole()
   {
@@ -610,83 +639,142 @@ var Scratchpad = {
    */
   getWindowId: function SP_getWindowId(aWindow)
   {
     return aWindow.QueryInterface(Ci.nsIInterfaceRequestor).
            getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
   },
 
   /**
-   * The Scratchpad window DOMContentLoaded event handler.
+   * The Scratchpad window DOMContentLoaded event handler. This method
+   * initializes the Scratchpad window and source editor.
+   *
+   * @param nsIDOMEvent aEvent
    */
-  onLoad: function SP_onLoad()
+  onLoad: function SP_onLoad(aEvent)
   {
+    if (aEvent.target != document) {
+      return;
+    }
+
     let chromeContextMenu = document.getElementById("sp-menu-browser");
     let errorConsoleMenu = document.getElementById("sp-menu-errorConsole");
     let errorConsoleCommand = document.getElementById("sp-cmd-errorConsole");
     let chromeContextCommand = document.getElementById("sp-cmd-browserContext");
 
     let chrome = Services.prefs.getBoolPref(DEVTOOLS_CHROME_ENABLED);
     if (chrome) {
       chromeContextMenu.removeAttribute("hidden");
       errorConsoleMenu.removeAttribute("hidden");
       errorConsoleCommand.removeAttribute("disabled");
       chromeContextCommand.removeAttribute("disabled");
     }
 
-    let tabsize = Services.prefs.getIntPref(PREF_TABSIZE);
-    if (tabsize < 1) {
-      // tabsize is invalid, clear back to the default value.
-      Services.prefs.clearUserPref(PREF_TABSIZE);
-      tabsize = Services.prefs.getIntPref(PREF_TABSIZE);
-    }
+    this.editor = new SourceEditor();
 
-    let expandtab = Services.prefs.getBoolPref(PREF_EXPANDTAB);
-    this._tabCharacter = expandtab ? (new Array(tabsize + 1)).join(" ") : "\t";
-    this.textbox.style.MozTabSize = tabsize;
-
-    // Force LTR direction (otherwise the textbox inherits the locale direction)
-    this.textbox.style.direction = "ltr";
+    let config = {
+      mode: SourceEditor.MODES.JAVASCRIPT,
+      showLineNumbers: true,
+      placeholderText: this.strings.GetStringFromName("scratchpadIntro"),
+    };
 
-    this.insertIntro();
-
-    // Make the Tab key work.
-    this.textbox.addEventListener("keypress", this.onKeypress.bind(this), false);
-
-    this.textbox.focus();
+    let editorPlaceholder = document.getElementById("scratchpad-editor");
+    this.editor.init(editorPlaceholder, config, this.onEditorLoad.bind(this));
   },
 
   /**
-   * The textbox keypress event handler which allows users to indent code using
-   * the Tab key.
-   *
-   * @param nsIDOMEvent aEvent
+   * The load event handler for the source editor. This method does post-load
+   * editor initialization.
    */
-  onKeypress: function SP_onKeypress(aEvent)
+  onEditorLoad: function SP_onEditorLoad()
   {
-    if (aEvent.keyCode == aEvent.DOM_VK_TAB) {
-      this.insertTextAtCaret(this._tabCharacter);
-      aEvent.preventDefault();
-    }
+    this.editor.addEventListener(SourceEditor.EVENTS.CONTEXT_MENU,
+                                 this.onContextMenu);
+    this.editor.focus();
+    this.editor.setCaretOffset(this.editor.getCharCount());
   },
 
   /**
    * Insert text at the current caret location.
    *
    * @param string aText
+   *        The text you want to insert.
    */
   insertTextAtCaret: function SP_insertTextAtCaret(aText)
   {
-    let firstPiece = this.textbox.value.substring(0, this.textbox.selectionStart);
-    let lastPiece = this.textbox.value.substring(this.textbox.selectionEnd);
-    this.textbox.value = firstPiece + aText + lastPiece;
+    let caretOffset = this.editor.getCaretOffset();
+    this.setText(aText, caretOffset, caretOffset);
+    this.editor.setCaretOffset(caretOffset + aText.length);
+  },
+
+  /**
+   * The contextmenu event handler for the source editor. This method opens the
+   * Scratchpad context menu popup at the pointer location.
+   *
+   * @param object aEvent
+   *        An event object coming from the SourceEditor. This object needs to
+   *        hold the screenX and screenY properties.
+   */
+  onContextMenu: function SP_onContextMenu(aEvent)
+  {
+    let menu = document.getElementById("scratchpad-text-popup");
+    if (menu.state == "closed") {
+      menu.openPopupAtScreen(aEvent.screenX, aEvent.screenY, true);
+    }
+  },
+
+  /**
+   * The popupshowing event handler for the Edit menu. This method updates the
+   * enabled/disabled state of the Undo and Redo commands, based on the editor
+   * state such that the menu items render correctly for the user when the menu
+   * shows.
+   */
+  onEditPopupShowing: function SP_onEditPopupShowing()
+  {
+    let undo = document.getElementById("sp-cmd-undo");
+    undo.setAttribute("disabled", !this.editor.canUndo());
 
-    let newCaretPosition = firstPiece.length + aText.length;
-    this.selectRange(newCaretPosition, newCaretPosition);
+    let redo = document.getElementById("sp-cmd-redo");
+    redo.setAttribute("disabled", !this.editor.canRedo());
+  },
+
+  /**
+   * Undo the last action of the user.
+   */
+  undo: function SP_undo()
+  {
+    this.editor.undo();
+  },
+
+  /**
+   * Redo the previously undone action.
+   */
+  redo: function SP_redo()
+  {
+    this.editor.redo();
+  },
+
+  /**
+   * The Scratchpad window unload event handler. This method unloads/destroys
+   * the source editor.
+   *
+   * @param nsIDOMEvent aEvent
+   */
+  onUnload: function SP_onUnload(aEvent)
+  {
+    if (aEvent.target != document) {
+      return;
+    }
+
+    this.resetContext();
+    this.editor.removeEventListener(SourceEditor.EVENTS.CONTEXT_MENU,
+                                    this.onContextMenu);
+    this.editor.destroy();
+    this.editor = null;
   },
 };
 
 XPCOMUtils.defineLazyGetter(Scratchpad, "strings", function () {
   return Services.strings.createBundle(SCRATCHPAD_L10N);
 });
 
 addEventListener("DOMContentLoaded", Scratchpad.onLoad.bind(Scratchpad), false);
-
+addEventListener("unload", Scratchpad.onUnload.bind(Scratchpad), false);
--- a/browser/devtools/scratchpad/scratchpad.xul
+++ b/browser/devtools/scratchpad/scratchpad.xul
@@ -73,16 +73,18 @@
   <command id="sp-cmd-run" oncommand="Scratchpad.run();"/>
   <command id="sp-cmd-inspect" oncommand="Scratchpad.inspect();"/>
   <command id="sp-cmd-display" oncommand="Scratchpad.display();"/>
   <command id="sp-cmd-contentContext" oncommand="Scratchpad.setContentContext();"/>
   <command id="sp-cmd-browserContext" oncommand="Scratchpad.setBrowserContext();" disabled="true"/>
   <command id="sp-cmd-resetContext" oncommand="Scratchpad.resetContext();"/>
   <command id="sp-cmd-errorConsole" oncommand="Scratchpad.openErrorConsole();" disabled="true"/>
   <command id="sp-cmd-webConsole" oncommand="Scratchpad.openWebConsole();"/>
+  <command id="sp-cmd-undo" oncommand="Scratchpad.undo();" disabled="true"/>
+  <command id="sp-cmd-redo" oncommand="Scratchpad.redo();" disabled="true"/>
 </commandset>
 
 <keyset id="sp-keyset">
   <key id="sp-key-window"
        key="&newWindowCmd.commandkey;"
        command="sp-cmd-newWindow"
        modifiers="accel"/>
   <key id="sp-key-open"
@@ -111,18 +113,20 @@
 
   <key id="key_copy"
        key="&copyCmd.key;"
        modifiers="accel"/>
   <key id="key_paste"
        key="&pasteCmd.key;"
        modifiers="accel"/>
   <key id="key_selectAll" key="&selectAllCmd.key;" modifiers="accel"/>
-  <key id="key_undo" key="&undoCmd.key;" modifiers="accel"/>
-  <key id="key_redo" key="&undoCmd.key;" modifiers="accel,shift"/>
+  <key id="key_undo" key="&undoCmd.key;" modifiers="accel"
+       oncommand="Scratchpad.undo();"/>
+  <key id="key_redo" key="&undoCmd.key;" modifiers="accel,shift"
+       oncommand="Scratchpad.redo();"/>
   <key id="sp-key-run"
        key="&run.key;"
        command="sp-cmd-run"
        modifiers="accel"/>
   <key id="sp-key-inspect"
        key="&inspect.key;"
        command="sp-cmd-inspect"
        modifiers="accel"/>
@@ -180,29 +184,28 @@
                 key="sp-key-close"
                 accesskey="&closeCmd.accesskey;"
                 command="sp-cmd-close"/>
     </menupopup>
   </menu>
 
   <menu id="sp-edit-menu" label="&editMenu.label;"
         accesskey="&editMenu.accesskey;">
-    <menupopup id="sp-menu_editpopup">
+    <menupopup id="sp-menu_editpopup"
+               onpopupshowing="Scratchpad.onEditPopupShowing()">
       <menuitem id="sp-menu-undo"
                 label="&undoCmd.label;"
                 key="key_undo"
                 accesskey="&undoCmd.accesskey;"
-                disabled="true"
-                command="cmd_undo"/>
+                command="sp-cmd-undo"/>
       <menuitem id="sp-menu-redo"
                 label="&redoCmd.label;"
                 key="key_redo"
-                disabled="true"
                 accesskey="&redoCmd.accesskey;"
-                command="cmd_redo"/>
+                command="sp-cmd-redo"/>
       <menuseparator/>
       <menuitem id="sp-menu-cut"
                 label="&cutCmd.label;"
                 key="key_cut"
                 accesskey="&cutCmd.accesskey;"
                 command="cmd_cut"/>
       <menuitem id="sp-menu-copy"
                 label="&copyCmd.label;"
@@ -324,21 +327,17 @@
     <menuitem id="sp-text-display"
               label="&display.label;"
               accesskey="&display.accesskey;"
               key="sp-key-display"
               command="sp-cmd-display"/>
   </menupopup>
 </popupset>
 
-<textbox id="scratchpad-textbox"
-         class="monospace"
-         multiline="true"
-         flex="1"
-         context="scratchpad-text-popup"
-         placeholder="&textbox.placeholder1;" />
+<hbox id="scratchpad-editor" flex="1" context="scratchpad-text-popup" />
+
 <statusbar id="scratchpad-statusbar" align="end">
   <statusbarpanel id="scratchpad-status"
                   label="&contentContext.label;"
                   class="statusbarpanel-iconic-text"/>
   <spacer flex="1"/>
 </statusbar>
 </window>
--- a/browser/devtools/scratchpad/test/browser_scratchpad_bug_660560_tab.js
+++ b/browser/devtools/scratchpad/test/browser_scratchpad_bug_660560_tab.js
@@ -26,89 +26,66 @@ function test()
 
 function runTests()
 {
   gScratchpadWindow.removeEventListener("load", arguments.callee, false);
 
   let sp = gScratchpadWindow.Scratchpad;
   ok(sp, "Scratchpad object exists in new window");
 
-  is(gScratchpadWindow.document.activeElement, sp.textbox.inputField,
-     "The textbox has focus");
+  ok(sp.editor.hasFocus(), "the editor has focus");
 
-  is(sp.textbox.style.MozTabSize, 5, "-moz-tab-size is correct");
-
-  sp.textbox.value = "window.foo;";
-  sp.selectRange(1, 3);
+  sp.setText("window.foo;");
+  sp.editor.setCaretOffset(0);
 
   EventUtils.synthesizeKey("VK_TAB", {}, gScratchpadWindow);
 
-  is(sp.textbox.value, "w     dow.foo;",
-     "Tab key added 5 spaces");
+  is(sp.getText(), "     window.foo;", "Tab key added 5 spaces");
+
+  is(sp.editor.getCaretOffset(), 5, "caret location is correct");
+
+  sp.editor.setCaretOffset(6);
 
-  is(sp.textbox.selectionStart, 6, "caret location is correct");
+  EventUtils.synthesizeKey("VK_TAB", {}, gScratchpadWindow);
 
-  is(sp.textbox.selectionStart, sp.textbox.selectionEnd,
-     "caret location is correct, confirmed");
+  is(sp.getText(), "     w    indow.foo;",
+     "Tab key added 4 spaces");
+
+  is(sp.editor.getCaretOffset(), 10, "caret location is correct");
 
   // Test the new insertTextAtCaret() method.
 
   sp.insertTextAtCaret("omg");
 
-  is(sp.textbox.value, "w     omgdow.foo;", "insertTextAtCaret() works");
+  is(sp.getText(), "     w    omgindow.foo;", "insertTextAtCaret() works");
 
-  is(sp.textbox.selectionStart, 9, "caret location is correct after update");
-
-  is(sp.textbox.selectionStart, sp.textbox.selectionEnd,
-     "caret location is correct, confirmed");
+  is(sp.editor.getCaretOffset(), 13, "caret location is correct after update");
 
   gScratchpadWindow.close();
 
   Services.prefs.setIntPref("devtools.editor.tabsize", 6);
   Services.prefs.setBoolPref("devtools.editor.expandtab", false);
   gScratchpadWindow = Scratchpad.openScratchpad();
   gScratchpadWindow.addEventListener("load", runTests2, false);
 }
 
 function runTests2()
 {
   gScratchpadWindow.removeEventListener("load", arguments.callee, false);
 
   let sp = gScratchpadWindow.Scratchpad;
 
-  is(sp.textbox.style.MozTabSize, 6, "-moz-tab-size is correct");
-
-  sp.textbox.value = "window.foo;";
-  sp.selectRange(1, 3);
+  sp.setText("window.foo;");
+  sp.editor.setCaretOffset(0);
 
   EventUtils.synthesizeKey("VK_TAB", {}, gScratchpadWindow);
 
-  is(sp.textbox.value, "w\tdow.foo;", "Tab key added the tab character");
-
-  is(sp.textbox.selectionStart, 2, "caret location is correct");
-
-  is(sp.textbox.selectionStart, sp.textbox.selectionEnd,
-     "caret location is correct, confirmed");
-
-  gScratchpadWindow.close();
+  is(sp.getText(), "\twindow.foo;", "Tab key added the tab character");
 
-  // check with an invalid tabsize value.
-  Services.prefs.setIntPref("devtools.editor.tabsize", 0);
-  Services.prefs.setBoolPref("devtools.editor.expandtab", true);
-  gScratchpadWindow = Scratchpad.openScratchpad();
-  gScratchpadWindow.addEventListener("load", runTests3, false);
-}
-
-function runTests3()
-{
-  gScratchpadWindow.removeEventListener("load", arguments.callee, false);
-
-  let sp = gScratchpadWindow.Scratchpad;
-
-  is(sp.textbox.style.MozTabSize, 4, "-moz-tab-size is correct");
+  is(sp.editor.getCaretOffset(), 1, "caret location is correct");
 
   Services.prefs.clearUserPref("devtools.editor.tabsize");
   Services.prefs.clearUserPref("devtools.editor.expandtab");
 
   gScratchpadWindow.close();
   gScratchpadWindow = null;
 
   gBrowser.removeCurrentTab();
--- a/browser/devtools/scratchpad/test/browser_scratchpad_contexts.js
+++ b/browser/devtools/scratchpad/test/browser_scratchpad_contexts.js
@@ -43,18 +43,17 @@ function runTests()
      "content menuitem is checked");
 
   ok(!chromeMenu.hasAttribute("checked"),
      "chrome menuitem is not checked");
 
   is(statusbar.getAttribute("label"), contentMenu.getAttribute("label"),
      "statusbar label is correct");
 
-  ok(sp.textbox, "textbox exists");
-  sp.textbox.value = "window.foobarBug636725 = 'aloha';";
+  sp.setText("window.foobarBug636725 = 'aloha';");
 
   ok(!content.wrappedJSObject.foobarBug636725,
      "no content.foobarBug636725");
 
   sp.run();
 
   is(content.wrappedJSObject.foobarBug636725, "aloha",
      "content.foobarBug636725 has been set");
@@ -68,50 +67,56 @@ function runTests()
      "chrome menuitem is checked");
 
   ok(!contentMenu.hasAttribute("checked"),
      "content menuitem is not checked");
 
   is(statusbar.getAttribute("label"), chromeMenu.getAttribute("label"),
      "statusbar label is correct");
 
-  sp.textbox.value = "window.foobarBug636725 = 'aloha2';";
+  sp.setText("2'", 31, 33);
+
+  ok(sp.getText(), "window.foobarBug636725 = 'aloha2';",
+     "setText() worked");
 
   ok(!window.foobarBug636725, "no window.foobarBug636725");
 
   sp.run();
 
   is(window.foobarBug636725, "aloha2", "window.foobarBug636725 has been set");
 
-  sp.textbox.value = "window.gBrowser";
+  sp.setText("gBrowser", 7);
+
+  ok(sp.getText(), "window.gBrowser",
+     "setText() worked with no end for the replace range");
 
   is(typeof sp.run()[1].addTab, "function",
      "chrome context has access to chrome objects");
 
   // Check that the sandbox is cached.
 
-  sp.textbox.value = "typeof foobarBug636725cache;";
+  sp.setText("typeof foobarBug636725cache;");
   is(sp.run()[1], "undefined", "global variable does not exist");
 
-  sp.textbox.value = "var foobarBug636725cache = 'foo';";
+  sp.setText("var foobarBug636725cache = 'foo';");
   sp.run();
 
-  sp.textbox.value = "typeof foobarBug636725cache;";
+  sp.setText("typeof foobarBug636725cache;");
   is(sp.run()[1], "string",
      "global variable exists across two different executions");
 
   sp.resetContext();
 
   is(sp.run()[1], "undefined",
      "global variable no longer exists after calling resetContext()");
 
-  sp.textbox.value = "var foobarBug636725cache2 = 'foo';";
+  sp.setText("var foobarBug636725cache2 = 'foo';");
   sp.run();
 
-  sp.textbox.value = "typeof foobarBug636725cache2;";
+  sp.setText("typeof foobarBug636725cache2;");
   is(sp.run()[1], "string",
      "global variable exists across two different executions");
 
   sp.setContentContext();
 
   is(sp.executionContext, gScratchpadWindow.SCRATCHPAD_CONTEXT_CONTENT,
      "executionContext is content");
 
--- a/browser/devtools/scratchpad/test/browser_scratchpad_execute_print.js
+++ b/browser/devtools/scratchpad/test/browser_scratchpad_execute_print.js
@@ -23,93 +23,111 @@ function test()
 function runTests()
 {
   gScratchpadWindow.removeEventListener("load", arguments.callee, false);
 
   let sp = gScratchpadWindow.Scratchpad;
 
   content.wrappedJSObject.foobarBug636725 = 1;
 
-  ok(sp.textbox, "textbox exists");
-  sp.textbox.value = "++window.foobarBug636725";
+  sp.setText("++window.foobarBug636725");
 
   let exec = sp.run();
-  is(exec[0], sp.textbox.value, "execute()[0] is correct");
+  is(exec[0], sp.getText(), "run()[0] is correct");
   is(exec[1], content.wrappedJSObject.foobarBug636725,
-     "execute()[1] is correct");
+     "run()[1] is correct");
 
-  is(sp.textbox.value, "++window.foobarBug636725",
-     "execute() does not change the textbox value");
+  is(sp.getText(), "++window.foobarBug636725",
+     "run() does not change the editor content");
 
   is(content.wrappedJSObject.foobarBug636725, 2,
-     "execute() updated window.foobarBug636725");
+     "run() updated window.foobarBug636725");
 
   sp.display();
 
   is(content.wrappedJSObject.foobarBug636725, 3,
-     "print() updated window.foobarBug636725");
+     "display() updated window.foobarBug636725");
 
-  is(sp.textbox.value, "++window.foobarBug636725/*\n3\n*/",
-     "print() shows evaluation result in the textbox");
+  is(sp.getText(), "++window.foobarBug636725/*\n3\n*/",
+     "display() shows evaluation result in the textbox");
 
   is(sp.selectedText, "/*\n3\n*/", "selectedText is correct");
-  is(sp.textbox.selectionStart, 24, "selectionStart is correct");
-  is(sp.textbox.selectionEnd, 31, "selectionEnd is correct");
+  let selection = sp.getSelectionRange();
+  is(selection.start, 24, "selection.start is correct");
+  is(selection.end, 31, "selection.end is correct");
 
-  // Test selection execute() and print().
+  // Test selection run() and display().
 
-  sp.textbox.value = "window.foobarBug636725 = 'a';\n" +
-                     "window.foobarBug636725 = 'b';";
+  sp.setText("window.foobarBug636725 = 'a';\n" +
+             "window.foobarBug636725 = 'b';");
 
   sp.selectRange(1, 2);
 
-  is(sp.textbox.selectionStart, 1, "selectionStart is 1");
-  is(sp.textbox.selectionEnd, 2, "selectionEnd is 2");
+  selection = sp.getSelectionRange();
+
+  is(selection.start, 1, "selection.start is 1");
+  is(selection.end, 2, "selection.end is 2");
 
   sp.selectRange(0, 29);
 
-  is(sp.textbox.selectionStart, 0, "selectionStart is 0");
-  is(sp.textbox.selectionEnd, 29, "selectionEnd is 29");
+  selection = sp.getSelectionRange();
+
+  is(selection.start, 0, "selection.start is 0");
+  is(selection.end, 29, "selection.end is 29");
 
   exec = sp.run();
 
   is(exec[0], "window.foobarBug636725 = 'a';",
-     "execute()[0] is correct");
+     "run()[0] is correct");
   is(exec[1], "a",
-     "execute()[1] is correct");
+     "run()[1] is correct");
 
-  is(sp.textbox.value, "window.foobarBug636725 = 'a';\n" +
-                       "window.foobarBug636725 = 'b';",
-     "execute() does not change the textbox value");
+  is(sp.getText(), "window.foobarBug636725 = 'a';\n" +
+                   "window.foobarBug636725 = 'b';",
+     "run() does not change the textbox value");
 
   is(content.wrappedJSObject.foobarBug636725, "a",
-     "execute() worked for the selected range");
+     "run() worked for the selected range");
 
-  sp.textbox.value = "window.foobarBug636725 = 'c';\n" +
-                     "window.foobarBug636725 = 'b';";
+  sp.setText("window.foobarBug636725 = 'c';\n" +
+             "window.foobarBug636725 = 'b';");
 
   sp.selectRange(0, 22);
 
   sp.display();
 
   is(content.wrappedJSObject.foobarBug636725, "a",
-     "print() worked for the selected range");
+     "display() worked for the selected range");
 
-  is(sp.textbox.value, "window.foobarBug636725" +
-                       "/*\na\n*/" +
-                       " = 'c';\n" +
-                       "window.foobarBug636725 = 'b';",
-     "print() shows evaluation result in the textbox");
+  is(sp.getText(), "window.foobarBug636725" +
+                   "/*\na\n*/" +
+                   " = 'c';\n" +
+                   "window.foobarBug636725 = 'b';",
+     "display() shows evaluation result in the textbox");
 
   is(sp.selectedText, "/*\na\n*/", "selectedText is correct");
-  is(sp.textbox.selectionStart, 22, "selectionStart is correct");
-  is(sp.textbox.selectionEnd, 29, "selectionEnd is correct");
+
+  selection = sp.getSelectionRange();
+  is(selection.start, 22, "selection.start is correct");
+  is(selection.end, 29, "selection.end is correct");
 
   sp.deselect();
 
   ok(!sp.selectedText, "selectedText is empty");
-  is(sp.textbox.selectionStart, sp.textbox.selectionEnd, "deselect() works");
+
+  selection = sp.getSelectionRange();
+  is(selection.start, selection.end, "deselect() works");
+
+  // Test undo/redo.
+
+  sp.setText("foo1");
+  sp.setText("foo2");
+  is(sp.getText(), "foo2", "editor content updated");
+  sp.undo();
+  is(sp.getText(), "foo1", "undo() works");
+  sp.redo();
+  is(sp.getText(), "foo2", "redo() works");
 
   gScratchpadWindow.close();
   gScratchpadWindow = null;
   gBrowser.removeCurrentTab();
   finish();
 }
--- a/browser/devtools/scratchpad/test/browser_scratchpad_files.js
+++ b/browser/devtools/scratchpad/test/browser_scratchpad_files.js
@@ -69,37 +69,37 @@ function tempFileSaved(aStatus)
 function fileImported(aStatus, aFileContent)
 {
   ok(Components.isSuccessCode(aStatus),
      "the temporary file was imported successfully with Scratchpad");
 
   is(aFileContent, gFileContent,
      "received data is correct");
 
-  is(gScratchpad.textbox.value, gFileContent,
-     "the textbox.value is correct");
+  is(gScratchpad.getText(), gFileContent,
+     "the editor content is correct");
 
   // Save the file after changes.
   gFileContent += "// omg, saved!";
-  gScratchpad.textbox.value = gFileContent;
+  gScratchpad.setText(gFileContent);
 
   gScratchpad.exportToFile(gFile.QueryInterface(Ci.nsILocalFile), true, true,
                           fileExported);
 }
 
 function fileExported(aStatus)
 {
   ok(Components.isSuccessCode(aStatus),
      "the temporary file was exported successfully with Scratchpad");
 
   let oldContent = gFileContent;
 
   // Attempt another file save, with confirmation which returns false.
   gFileContent += "// omg, saved twice!";
-  gScratchpad.textbox.value = gFileContent;
+  gScratchpad.setText(gFileContent);
 
   let oldConfirm = gScratchpadWindow.confirm;
   let askedConfirmation = false;
   gScratchpadWindow.confirm = function() {
     askedConfirmation = true;
     return false;
   };
 
--- a/browser/devtools/scratchpad/test/browser_scratchpad_inspect.js
+++ b/browser/devtools/scratchpad/test/browser_scratchpad_inspect.js
@@ -22,18 +22,17 @@ function test()
 }
 
 function runTests()
 {
   gScratchpadWindow.removeEventListener("load", arguments.callee, false);
 
   let sp = gScratchpadWindow.Scratchpad;
 
-  ok(sp.textbox, "textbox exists");
-  sp.textbox.value = "document";
+  sp.setText("document");
 
   sp.inspect();
 
   let propPanel = document.querySelector(".scratchpad_propertyPanel");
   ok(propPanel, "property panel is open");
 
   propPanel.addEventListener("popupshown", function() {
     propPanel.removeEventListener("popupshown", arguments.callee, false);
--- a/browser/devtools/scratchpad/test/browser_scratchpad_tab_switch.js
+++ b/browser/devtools/scratchpad/test/browser_scratchpad_tab_switch.js
@@ -53,18 +53,17 @@ function runTests()
      "content menuitem is checked");
 
   ok(!browserMenu.hasAttribute("checked"),
      "chrome menuitem is not checked");
 
   is(statusbar.getAttribute("label"), contentMenu.getAttribute("label"),
      "statusbar label is correct");
 
-  ok(sp.textbox, "textbox exists");
-  sp.textbox.value = "window.foosbug653108 = 'aloha';";
+  sp.setText("window.foosbug653108 = 'aloha';");
 
   ok(!content.wrappedJSObject.foosbug653108,
      "no content.foosbug653108");
 
   sp.run();
 
   is(content.wrappedJSObject.foosbug653108, "aloha",
      "content.foosbug653108 has been set");
@@ -73,36 +72,36 @@ function runTests()
   gBrowser.selectedTab = tab1;
 }
 
 function runTests2() {
   gBrowser.tabContainer.removeEventListener("TabSelect", runTests2, true);
 
   ok(!window.foosbug653108, "no window.foosbug653108");
 
-  sp.textbox.value = "window.foosbug653108";
+  sp.setText("window.foosbug653108");
   let result = sp.run();
 
   isnot(result, "aloha", "window.foosbug653108 is not aloha");
 
-  sp.textbox.value = "window.foosbug653108 = 'ahoyhoy';";
+  sp.setText("window.foosbug653108 = 'ahoyhoy';");
   sp.run();
 
   is(content.wrappedJSObject.foosbug653108, "ahoyhoy",
      "content.foosbug653108 has been set 2");
 
   gBrowser.selectedBrowser.addEventListener("load", runTests3, true);
   content.location = "data:text/html,test context switch in Scratchpad location 2";
 }
 
 function runTests3() {
   gBrowser.selectedBrowser.removeEventListener("load", runTests3, true);
   // Check that the sandbox is not cached.
 
-  sp.textbox.value = "typeof foosbug653108;";
+  sp.setText("typeof foosbug653108;");
   is(sp.run()[1], "undefined", "global variable does not exist");
 
   gScratchpadWindow.close();
   gScratchpadWindow = null;
   tab1 = null;
   tab2 = null;
   sp = null;
   gBrowser.removeCurrentTab();
--- a/browser/devtools/scratchpad/test/browser_scratchpad_ui.js
+++ b/browser/devtools/scratchpad/test/browser_scratchpad_ui.js
@@ -36,16 +36,18 @@ function runTests()
     "sp-text-run": "run",
     "sp-text-inspect": "inspect",
     "sp-text-display": "display",
     "sp-menu-content": "setContentContext",
     "sp-menu-browser": "setBrowserContext",
     "sp-menu-resetContext": "resetContext",
     "sp-menu-errorConsole": "openErrorConsole",
     "sp-menu-webConsole": "openWebConsole",
+    "sp-menu-undo": "undo",
+    "sp-menu-redo": "redo",
   };
 
   let lastMethodCalled = null;
   sp.__noSuchMethod__ = function(aMethodName) {
     lastMethodCalled = aMethodName;
   };
 
   for (let id in methodsAndItems) {
new file mode 100644
--- /dev/null
+++ b/browser/devtools/sourceeditor/Makefile.in
@@ -0,0 +1,57 @@
+#
+# ***** 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 Source Editor.
+#
+# 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):
+#   Rob Campbell <rcampbell@mozilla.com>
+#   Mihai Sucan <mihai.sucan@gmail.com>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH		= ../../..
+topsrcdir	= @top_srcdir@
+srcdir		= @srcdir@
+VPATH		= @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+ifdef ENABLE_TESTS
+	DIRS += test
+endif
+
+EXTRA_JS_MODULES = \
+	source-editor.jsm \
+	source-editor-orion.jsm \
+	source-editor-textarea.jsm \
+	$(NULL)
+
+include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/browser/devtools/sourceeditor/orion/LICENSE
@@ -0,0 +1,29 @@
+Eclipse Distribution License - v 1.0
+
+Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors.
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+  list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright notice, this
+  list of conditions and the following disclaimer in the documentation and/or
+  other materials provided with the distribution.
+* Neither the name of the Eclipse Foundation, Inc. nor the names of its
+  contributors may be used to endorse or promote products derived from this
+  software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
new file mode 100755
--- /dev/null
+++ b/browser/devtools/sourceeditor/orion/Makefile.dryice.js
@@ -0,0 +1,81 @@
+#!/usr/bin/env node
+/* vim:set ts=2 sw=2 sts=2 et tw=80:
+ * ***** 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 Source Editor component.
+ *
+ * The Initial Developer of the Original Code is
+ * The Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Mihai Sucan <mihai.sucan@gmail.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 *****/
+
+var copy = require('dryice').copy;
+
+const ORION_EDITOR = "org.eclipse.orion.client.editor/web";
+
+var js_src = copy.createDataObject();
+
+copy({
+  source: [
+    ORION_EDITOR + "/orion/textview/keyBinding.js",
+    ORION_EDITOR + "/orion/textview/rulers.js",
+    ORION_EDITOR + "/orion/textview/undoStack.js",
+    ORION_EDITOR + "/orion/textview/textModel.js",
+    ORION_EDITOR + "/orion/textview/textView.js",
+    ORION_EDITOR + "/orion/editor/htmlGrammar.js",
+    ORION_EDITOR + "/orion/editor/textMateStyler.js",
+    ORION_EDITOR + "/examples/textview/textStyler.js",
+  ],
+  dest: js_src,
+});
+
+copy({
+    source: js_src,
+    dest: "orion.js",
+});
+
+var css_src = copy.createDataObject();
+
+copy({
+  source: [
+    ORION_EDITOR + "/orion/textview/textview.css",
+    ORION_EDITOR + "/orion/textview/rulers.css",
+    ORION_EDITOR + "/examples/textview/textstyler.css",
+    ORION_EDITOR + "/examples/editor/htmlStyles.css",
+  ],
+  dest: css_src,
+});
+
+copy({
+    source: css_src,
+    dest: "orion.css",
+});
+
new file mode 100644
--- /dev/null
+++ b/browser/devtools/sourceeditor/orion/README
@@ -0,0 +1,20 @@
+# Introduction
+
+This is the Orion editor packaged for Mozilla.
+
+The Orion editor web site: http://www.eclipse.org/orion
+
+# Upgrade
+
+To upgrade Orion to a newer version see the UPGRADE file.
+
+Orion version: git clone from 2011-07-06 (after the 0.2 release)
+               commit hash b19bc0b0f4e2843823bb1b8c8b4a64395c59e617
+
+# License
+
+The following files are licensed according to the contents in the LICENSE
+file:
+  orion.js
+  orion.css
+
new file mode 100644
--- /dev/null
+++ b/browser/devtools/sourceeditor/orion/UPGRADE
@@ -0,0 +1,20 @@
+Upgrade notes:
+
+1. Get the Orion client source code from:
+http://www.eclipse.org/orion
+
+2. Install Dryice from:
+https://github.com/mozilla/dryice
+
+You also need nodejs for Dryice to run:
+http://nodejs.org
+
+3. Copy Makefile.dryice.js to:
+org.eclipse.orion.client/bundles/
+
+4. Execute Makefile.dryice.js. You should get orion.js and orion.css.
+
+5. Copy the two files back here.
+
+6. Make a new build of Firefox.
+
new file mode 100644
--- /dev/null
+++ b/browser/devtools/sourceeditor/orion/orion.css
@@ -0,0 +1,115 @@
+.view {
+	background-color: white;
+}
+
+.viewContainer {
+	font-family: monospace;
+	font-size: 10pt;
+}
+
+.viewContent {
+}.ruler_annotation {
+	background-color: #e1ebfb;
+	width: 16px;
+}
+
+.ruler_annotation_todo {
+}
+
+.ruler_annotation_todo_overview {
+	background-color: lightgreen;
+	border: 1px solid green;
+}
+
+.ruler_annotation_breakpoint {
+}
+
+.ruler_annotation_breakpoint_overview {
+	background-color: lightblue;
+	border: 1px solid blue;
+}
+
+.ruler_lines {
+	background-color: #e1ebfb;
+	border-right: 1px solid #b1badf;
+	text-align: right;
+}
+
+.ruler_overview {
+	background-color: #e1ebfb;
+}
+
+.ruler_lines_even {
+	background-color: #e1ebfb;
+}
+
+.ruler_lines_odd {
+	background-color: white;
+}
+
+.token_comment {
+	color: green;
+}
+
+.token_javadoc {
+	color: #00008F;
+}
+
+.token_string {
+	color: blue;
+}
+
+.token_keyword {
+	color: darkred;
+	font-weight: bold;
+}
+
+.token_bracket_outline {
+	outline: 1px solid red;
+}
+
+.token_bracket {
+	color: white;
+	background-color: grey;
+}
+
+.token_space {
+	background-image: url('/examples/textview/images/white_space.png');
+	background-repeat: no-repeat;
+ 	background-position: center center;
+}
+
+.token_tab {
+	background-image: url('/examples/textview/images/white_tab.png');
+	background-repeat: no-repeat;
+ 	background-position: left center;
+}
+
+.line_caret {
+	background-color: #EAF2FE;
+}/* Styling for html syntax highlighting */
+.entity-name-tag {
+	color: #3f7f7f;
+}
+
+.entity-other-attribute-name {
+	color: #7f007f;
+}
+
+.punctuation-definition-comment {
+	color: #3f5fbf;
+}
+
+.comment {
+	color: #3f5fbf
+}
+
+.string-quoted {
+	color: #2a00ff;
+	font-style: italic;
+}
+
+.invalid {
+	color: red;
+	font-weight: bold;
+}
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/browser/devtools/sourceeditor/orion/orion.js
@@ -0,0 +1,8390 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials are made 
+ * available under the terms of the Eclipse Public License v1.0 
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 
+ * 
+ * Contributors: 
+ *		Felipe Heidrich (IBM Corporation) - initial API and implementation
+ *		Silenio Quarti (IBM Corporation) - initial API and implementation
+ ******************************************************************************/
+
+/*global window define */
+
+/**
+ * @namespace The global container for Orion APIs.
+ */ 
+var orion = orion || {};
+/**
+ * @namespace The container for textview APIs.
+ */ 
+orion.textview = orion.textview || {};
+
+/**
+ * Constructs a new key binding with the given key code and modifiers.
+ * 
+ * @param {String|Number} keyCode the key code.
+ * @param {Boolean} mod1 the primary modifier (usually Command on Mac and Control on other platforms).
+ * @param {Boolean} mod2 the secondary modifier (usually Shift).
+ * @param {Boolean} mod3 the third modifier (usually Alt).
+ * @param {Boolean} mod4 the fourth modifier (usually Control on the Mac).
+ * 
+ * @class A KeyBinding represents of a key code and a modifier state that can be triggered by the user using the keyboard.
+ * @name orion.textview.KeyBinding
+ * 
+ * @property {String|Number} keyCode The key code.
+ * @property {Boolean} mod1 The primary modifier (usually Command on Mac and Control on other platforms).
+ * @property {Boolean} mod2 The secondary modifier (usually Shift).
+ * @property {Boolean} mod3 The third modifier (usually Alt).
+ * @property {Boolean} mod4 The fourth modifier (usually Control on the Mac).
+ *
+ * @see orion.textview.TextView#setKeyBinding
+ */
+orion.textview.KeyBinding = (function() {
+	var isMac = window.navigator.platform.indexOf("Mac") !== -1;
+	/** @private */
+	function KeyBinding (keyCode, mod1, mod2, mod3, mod4) {
+		if (typeof(keyCode) === "string") {
+			this.keyCode = keyCode.toUpperCase().charCodeAt(0);
+		} else {
+			this.keyCode = keyCode;
+		}
+		this.mod1 = mod1 !== undefined && mod1 !== null ? mod1 : false;
+		this.mod2 = mod2 !== undefined && mod2 !== null ? mod2 : false;
+		this.mod3 = mod3 !== undefined && mod3 !== null ? mod3 : false;
+		this.mod4 = mod4 !== undefined && mod4 !== null ? mod4 : false;
+	}
+	KeyBinding.prototype = /** @lends orion.textview.KeyBinding.prototype */ {
+		/**
+		 * Returns whether this key binding matches the given key event.
+		 * 
+		 * @param e the key event.
+		 * @returns {Boolean} <code>true</code> whether the key binding matches the key event.
+		 */
+		match: function (e) {
+			if (this.keyCode === e.keyCode) {
+				var mod1 = isMac ? e.metaKey : e.ctrlKey;
+				if (this.mod1 !== mod1) { return false; }
+				if (this.mod2 !== e.shiftKey) { return false; }
+				if (this.mod3 !== e.altKey) { return false; }
+				if (isMac && this.mod4 !== e.ctrlKey) { return false; }
+				return true;
+			}
+			return false;
+		},
+		/**
+		 * Returns whether this key binding is the same as the given parameter.
+		 * 
+		 * @param {orion.textview.KeyBinding} kb the key binding to compare with.
+		 * @returns {Boolean} whether or not the parameter and the receiver describe the same key binding.
+		 */
+		equals: function(kb) {
+			if (!kb) { return false; }
+			if (this.keyCode !== kb.keyCode) { return false; }
+			if (this.mod1 !== kb.mod1) { return false; }
+			if (this.mod2 !== kb.mod2) { return false; }
+			if (this.mod3 !== kb.mod3) { return false; }
+			if (this.mod4 !== kb.mod4) { return false; }
+			return true;
+		} 
+	};
+	return KeyBinding;
+}());
+
+if (typeof window !== "undefined" && typeof window.define !== "undefined") {
+	define([], function() {
+		return orion.textview;
+	});
+}
+
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials are made 
+ * available under the terms of the Eclipse Public License v1.0 
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 
+ * 
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+/*global window define */
+
+/**
+ * @namespace The global container for Orion APIs.
+ */ 
+var orion = orion || {};
+/**
+ * @namespace The container for textview APIs.
+ */ 
+orion.textview = orion.textview || {};
+
+/**
+ * Contructs a new ruler. 
+ * <p>
+ * The default implementation does not implement all the methods in the interface
+ * and is useful only for objects implementing rulers.
+ * <p/>
+ * 
+ * @param {String} [rulerLocation="left"] the location for the ruler.
+ * @param {String} [rulerOverview="page"] the overview for the ruler.
+ * @param {orion.textview.Style} [rulerStyle] the style for the ruler. 
+ * 
+ * @class This interface represents a ruler for the text view.
+ * <p>
+ * A Ruler is a graphical element that is placed either on the left or on the right side of 
+ * the view. It can be used to provide the view with per line decoration such as line numbering,
+ * bookmarks, breakpoints, folding disclosures, etc. 
+ * </p><p>
+ * There are two types of rulers: page and document. A page ruler only shows the content for the lines that are
+ * visible, while a document ruler always shows the whole content.
+ * </p>
+ * <b>See:</b><br/>
+ * {@link orion.textview.LineNumberRuler}<br/>
+ * {@link orion.textview.AnnotationRuler}<br/>
+ * {@link orion.textview.OverviewRuler}<br/> 
+ * {@link orion.textview.TextView}<br/>
+ * {@link orion.textview.TextView#addRuler}
+ * </p>		 
+ * @name orion.textview.Ruler
+ */
+orion.textview.Ruler = (function() {
+	/** @private */
+	function Ruler (rulerLocation, rulerOverview, rulerStyle) {
+		this._location = rulerLocation || "left";
+		this._overview = rulerOverview || "page";
+		this._rulerStyle = rulerStyle;
+		this._view = null;
+	}
+	Ruler.prototype = /** @lends orion.textview.Ruler.prototype */ {
+		/**
+		 * Sets the view for the ruler.
+		 *
+		 * @param {orion.textview.TextView} view the text view.
+		 */
+		setView: function (view) {
+			if (this._onModelChanged && this._view) {
+				this._view.removeEventListener("ModelChanged", this, this._onModelChanged); 
+			}
+			this._view = view;
+			if (this._onModelChanged && this._view) {
+				this._view.addEventListener("ModelChanged", this, this._onModelChanged);
+			}
+		},
+		/**
+		 * Returns the ruler location.
+		 *
+		 * @returns {String} the ruler location, which is either "left" or "right".
+		 *
+		 * @see #getOverview
+		 */
+		getLocation: function() {
+			return this._location;
+		},
+		/**
+		 * Returns the ruler overview type.
+		 *
+		 * @returns {String} the overview type, which is either "page" or "document".
+		 *
+		 * @see #getLocation
+		 */
+		getOverview: function() {
+			return this._overview;
+		},
+		/**
+		 * Returns the CSS styling information for the decoration of a given line.
+		 * <p>
+		 * If the line index is <code>-1</code>, the CSS styling information for the decoration
+		 * that determines the width of the ruler should be returned. If the line is
+		 * <code>undefined</code>, the ruler styling information should be returned.
+		 * </p>
+		 *
+		 * @param {Number} lineIndex the line index
+		 * @returns {orion.textview.Style} the CSS styling for ruler, given line, or generic line.
+		 *
+		 * @see #getHTML
+		 */
+		getStyle: function(lineIndex) {
+		},
+		/**
+		 * Returns the HTML content for the decoration of a given line.
+		 * <p>
+		 * If the line index is <code>-1</code>, the HTML content for the decoration
+		 * that determines the width of the ruler should be returned.
+		 * </p>
+		 *
+		 * @param {Number} lineIndex the line index
+		 * @returns {String} the HTML content for a given line, or generic line.
+		 *
+		 * @see #getStyle
+		 */
+		getHTML: function(lineIndex) {
+		},
+		/**
+		 * Returns the indices of the lines that have decoration.
+		 * <p>
+		 * This function is only called for rulers with "document" overview type.
+		 * </p>
+		 * 
+		 * @returns {Number[]} an array of line indices.
+		 */
+		getAnnotations: function() {
+		},
+		/**
+		 * This event is sent when the user clicks a line decoration.
+		 *
+		 * @event
+		 * @param {Number} lineIndex the line index of the clicked decoration.
+		 * @param {DOMEvent} e the click event.
+		 */
+		onClick: function(lineIndex, e) {
+		},
+		/**
+		 * This event is sent when the user double clicks a line decoration.
+		 *
+		 * @event
+		 * @param {Number} lineIndex the line index of the double clicked decoration.
+		 * @param {DOMEvent} e the double click event.
+		 */
+		onDblClick: function(lineIndex, e) {
+		}
+	};
+	return Ruler;
+}());
+
+/**
+ * Contructs a new line numbering ruler. 
+ *
+ * @param {String} [rulerLocation="left"] the location for the ruler.
+ * @param {orion.textview.Style} [rulerStyle=undefined] the style for the ruler.
+ * @param {orion.textview.Style} [oddStyle={backgroundColor: "white"}] the style for lines with odd line index.
+ * @param {orion.textview.Style} [evenStyle={backgroundColor: "white"}] the style for lines with even line index.
+ *
+ * @augments orion.textview.Ruler
+ * @class This objects implements a line numbering ruler.
+ *
+ * <p><b>See:</b><br/>
+ * {@link orion.textview.Ruler}
+ * </p>
+ * @name orion.textview.LineNumberRuler
+ */
+orion.textview.LineNumberRuler = (function() {
+	/** @private */
+	function LineNumberRuler (rulerLocation, rulerStyle, oddStyle, evenStyle) {
+		orion.textview.Ruler.call(this, rulerLocation, "page", rulerStyle);
+		this._oddStyle = oddStyle || {style: {backgroundColor: "white"}};
+		this._evenStyle = evenStyle || {style: {backgroundColor: "white"}};
+		this._numOfDigits = 0;
+	}
+	LineNumberRuler.prototype = new orion.textview.Ruler(); 
+	/** @ignore */
+	LineNumberRuler.prototype.getStyle = function(lineIndex) {
+		if (lineIndex === undefined) {
+			return this._rulerStyle;
+		} else {
+			return lineIndex & 1 ? this._oddStyle : this._evenStyle;
+		}
+	};
+	/** @ignore */
+	LineNumberRuler.prototype.getHTML = function(lineIndex) {
+		if (lineIndex === -1) {
+			var model = this._view.getModel();
+			return model.getLineCount();
+		} else {
+			return lineIndex + 1;
+		}
+	};
+	/** @ignore */
+	LineNumberRuler.prototype._onModelChanged = function(e) {
+		var start = e.start;
+		var model = this._view.getModel();
+		var lineCount = model.getLineCount();
+		var numOfDigits = (lineCount+"").length;
+		if (this._numOfDigits !== numOfDigits) {
+			this._numOfDigits = numOfDigits;
+			var startLine = model.getLineAtOffset(start);
+			this._view.redrawLines(startLine, lineCount, this);
+		}
+	};
+	return LineNumberRuler;
+}());
+/** 
+ * @class This is class represents an annotation for the AnnotationRuler. 
+ * <p> 
+ * <b>See:</b><br/> 
+ * {@link orion.textview.AnnotationRuler}
+ * </p> 
+ * 
+ * @name orion.textview.Annotation 
+ * 
+ * @property {String} [html=""] The html content for the annotation, typically contains an image.
+ * @property {orion.textview.Style} [style] the style for the annotation.
+ * @property {orion.textview.Style} [overviewStyle] the style for the annotation in the overview ruler.
+ */ 
+/**
+ * Contructs a new annotation ruler. 
+ *
+ * @param {String} [rulerLocation="left"] the location for the ruler.
+ * @param {orion.textview.Style} [rulerStyle=undefined] the style for the ruler.
+ * @param {orion.textview.Annotation} [defaultAnnotation] the default annotation.
+ *
+ * @augments orion.textview.Ruler
+ * @class This objects implements an annotation ruler.
+ *
+ * <p><b>See:</b><br/>
+ * {@link orion.textview.Ruler}<br/>
+ * {@link orion.textview.Annotation}
+ * </p>
+ * @name orion.textview.AnnotationRuler
+ */
+orion.textview.AnnotationRuler = (function() {
+	/** @private */
+	function AnnotationRuler (rulerLocation, rulerStyle, defaultAnnotation) {
+		orion.textview.Ruler.call(this, rulerLocation, "page", rulerStyle);
+		this._defaultAnnotation = defaultAnnotation;
+		this._annotations = [];
+	}
+	AnnotationRuler.prototype = new orion.textview.Ruler();
+	/**
+	 * Removes all annotations in the ruler.
+	 *
+	 * @name clearAnnotations
+	 * @methodOf orion.textview.AnnotationRuler.prototype
+	 */
+	AnnotationRuler.prototype.clearAnnotations = function() {
+		this._annotations = [];
+		var lineCount = this._view.getModel().getLineCount();
+		this._view.redrawLines(0, lineCount, this);
+		if (this._overviewRuler) {
+			this._view.redrawLines(0, lineCount, this._overviewRuler);
+		}
+	};
+	/**
+	 * Returns the annotation for the given line index.
+	 *
+	 * @param {Number} lineIndex the line index
+	 *
+	 * @returns {orion.textview.Annotation} the annotation for the given line, or undefined
+	 *
+	 * @name getAnnotation
+	 * @methodOf orion.textview.AnnotationRuler.prototype
+	 * @see #setAnnotation
+	 */
+	AnnotationRuler.prototype.getAnnotation = function(lineIndex) {
+		return this._annotations[lineIndex];
+	};
+	/** @ignore */
+	AnnotationRuler.prototype.getAnnotations = function() {
+		var lines = [];
+		for (var prop in this._annotations) {
+			var i = prop >>> 0;
+			if (this._annotations[i] !== undefined) {
+				lines.push(i);
+			}
+		}
+		return lines;
+	};
+	/** @ignore */
+	AnnotationRuler.prototype.getStyle = function(lineIndex) {
+		switch (lineIndex) {
+			case undefined:
+				return this._rulerStyle;
+			case -1:
+				return this._defaultAnnotation ? this._defaultAnnotation.style : null;
+			default:
+				return this._annotations[lineIndex] && this._annotations[lineIndex].style ? this._annotations[lineIndex].style : null;
+		}
+	};
+	/** @ignore */	
+	AnnotationRuler.prototype.getHTML = function(lineIndex) {
+		if (lineIndex === -1) {
+			return this._defaultAnnotation ? this._defaultAnnotation.html : "";
+		} else {
+			return this._annotations[lineIndex] && this._annotations[lineIndex].html ? this._annotations[lineIndex].html : "";
+		}
+	};
+	/**
+	 * Sets the annotation in the given line index.
+	 *
+	 * @param {Number} lineIndex the line index
+	 * @param {orion.textview.Annotation} annotation the annotation
+	 *
+	 * @name setAnnotation
+	 * @methodOf orion.textview.AnnotationRuler.prototype
+	 * @see #getAnnotation
+	 * @see #clearAnnotations
+	 */
+	AnnotationRuler.prototype.setAnnotation = function(lineIndex, annotation) {
+		if (lineIndex === undefined) { return; }
+		this._annotations[lineIndex] = annotation;
+		this._view.redrawLines(lineIndex, lineIndex + 1, this);
+		if (this._overviewRuler) {
+			this._view.redrawLines(lineIndex, lineIndex + 1, this._overviewRuler);
+		}
+	};
+	/** @ignore */
+	AnnotationRuler.prototype._onModelChanged = function(e) {
+		var start = e.start;
+		var removedLineCount = e.removedLineCount;
+		var addedLineCount = e.addedLineCount;
+		var linesChanged = addedLineCount - removedLineCount;
+		if (linesChanged) {
+			var model = this._view.getModel();
+			var startLine = model.getLineAtOffset(start);
+			var newLines = [], lines = this._annotations;
+			var changed = false;
+			for (var prop in lines) {
+				var i = prop >>> 0;
+				if (!(startLine < i && i < startLine + removedLineCount)) {
+					var newIndex = i;
+					if (i > startLine) {
+						newIndex += linesChanged;
+						changed = true;
+					}
+					newLines[newIndex] = lines[i];
+				} else {
+					changed = true;
+				}
+			}
+			this._annotations = newLines;
+			if (changed) {
+				var lineCount = model.getLineCount();
+				this._view.redrawLines(startLine, lineCount, this);
+				//TODO redraw overview (batch it for performance)
+				if (this._overviewRuler) {
+					this._view.redrawLines(0, lineCount, this._overviewRuler);
+				}
+			}
+		}
+	};
+	return AnnotationRuler;
+}());
+
+/**
+ * Contructs an overview ruler. 
+ * <p>
+ * The overview ruler is used in conjunction with a AnnotationRuler, for each annotation in the 
+ * AnnotationRuler this ruler displays a mark in the overview. Clicking on the mark causes the 
+ * view to scroll to the annotated line.
+ * </p>
+ *
+ * @param {String} [rulerLocation="left"] the location for the ruler.
+ * @param {orion.textview.Style} [rulerStyle=undefined] the style for the ruler.
+ * @param {orion.textview.AnnotationRuler} [annotationRuler] the annotation ruler for the overview.
+ *
+ * @augments orion.textview.Ruler
+ * @class This objects implements an overview ruler.
+ *
+ * <p><b>See:</b><br/>
+ * {@link orion.textview.AnnotationRuler} <br/>
+ * {@link orion.textview.Ruler} 
+ * </p>
+ * @name orion.textview.OverviewRuler
+ */
+orion.textview.OverviewRuler = (function() {
+	/** @private */
+	function OverviewRuler (rulerLocation, rulerStyle, annotationRuler) {
+		orion.textview.Ruler.call(this, rulerLocation, "document", rulerStyle);
+		this._annotationRuler = annotationRuler;
+		if (annotationRuler) {
+			annotationRuler._overviewRuler = this;
+		}
+	}
+	OverviewRuler.prototype = new orion.textview.Ruler();
+	/** @ignore */
+	OverviewRuler.prototype.getAnnotations = function() {
+		return this._annotationRuler.getAnnotations();
+	};
+	/** @ignore */	
+	OverviewRuler.prototype.getStyle = function(lineIndex) {
+		var result, style;
+		if (lineIndex === undefined) {
+			result = this._rulerStyle || {};
+			style = result.style || (result.style = {});
+			style.lineHeight = "1px";
+			style.fontSize = "1px";
+			style.width = "14px";
+		} else {
+			if (lineIndex !== -1) {
+				var annotation = this._annotationRuler.getAnnotation(lineIndex);
+				result = annotation.overviewStyle || {};
+			} else {
+				result = {};
+			}
+			style = result.style || (result.style = {});
+			style.cursor = "pointer";
+			style.width = "8px";
+			style.height = "3px";
+			style.left = "2px";
+		}
+		return result;
+	};
+	/** @ignore */
+	OverviewRuler.prototype.getHTML = function(lineIndex) {
+		return "&nbsp;";
+	};
+	/** @ignore */	
+	OverviewRuler.prototype.onClick = function(lineIndex, e) {
+		if (lineIndex === undefined) { return; }
+		this._view.setTopIndex(lineIndex);
+	};
+	return OverviewRuler;
+}());
+
+if (typeof window !== "undefined" && typeof window.define !== "undefined") {
+	define([], function() {
+		return orion.textview;
+	});
+}
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials are made 
+ * available under the terms of the Eclipse Public License v1.0 
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 
+ * 
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+/*global window define */
+
+/**
+ * @namespace The global container for Orion APIs.
+ */ 
+var orion = orion || {};
+/**
+ * @namespace The container for textview APIs.
+ */ 
+orion.textview = orion.textview || {};
+
+/**
+ * Constructs a new UndoStack on a text view.
+ *
+ * @param {orion.textview.TextView} view the text view for the undo stack.
+ * @param {Number} [size=100] the size for the undo stack.
+ *
+ * @name orion.textview.UndoStack
+ * @class The UndoStack is used to record the history of a text model associated to an view. Every
+ * change to the model is added to stack, allowing the application to undo and redo these changes.
+ *
+ * <p>
+ * <b>See:</b><br/>
+ * {@link orion.textview.TextView}<br/>
+ * </p>
+ */
+orion.textview.UndoStack = (function() {
+	/** 
+	 * Constructs a new Change object.
+	 * 
+	 * @class 
+	 * @name orion.textview.Change
+	 * @private
+	 */
+	var Change = (function() {
+		function Change(offset, text, previousText) {
+			this.offset = offset;
+			this.text = text;
+			this.previousText = previousText;
+		}
+		Change.prototype = {
+			/** @ignore */
+			undo: function (view, select) {
+				this._doUndoRedo(this.offset, this.previousText, this.text, view, select);
+			},
+			/** @ignore */
+			redo: function (view, select) {
+				this._doUndoRedo(this.offset, this.text, this.previousText, view, select);
+			},
+			_doUndoRedo: function(offset, text, previousText, view, select) {
+				view.setText(text, offset, offset + previousText.length);
+				if (select) {
+					view.setSelection(offset, offset + text.length);
+				}
+			}
+		};
+		return Change;
+	}());
+
+	/** 
+	 * Constructs a new CompoundChange object.
+	 * 
+	 * @class 
+	 * @name orion.textview.CompoundChange
+	 * @private
+	 */
+	var CompoundChange = (function() {
+		function CompoundChange (selection, caret) {
+			this.selection = selection;
+			this.caret = caret;
+			this.changes = [];
+		}
+		CompoundChange.prototype = {
+			/** @ignore */
+			add: function (change) {
+				this.changes.push(change);
+			},
+			/** @ignore */
+			undo: function (view, select) {
+				for (var i=this.changes.length - 1; i >= 0; i--) {
+					this.changes[i].undo(view, false);
+				}
+				if (select) {
+					var start = this.selection.start;
+					var end = this.selection.end;
+					view.setSelection(this.caret ? start : end, this.caret ? end : start);
+				}
+			},
+			/** @ignore */
+			redo: function (view, select) {
+				for (var i = 0; i < this.changes.length; i++) {
+					this.changes[i].redo(view, false);
+				}
+				if (select) {
+					var start = this.selection.start;
+					var end = this.selection.end;
+					view.setSelection(this.caret ? start : end, this.caret ? end : start);
+				}
+			}
+		};
+		return CompoundChange;
+	}());
+
+	/** @private */
+	function UndoStack (view, size) {
+		this.view = view;
+		this.size = size !== undefined ? size : 100;
+		this.reset();
+		view.addEventListener("ModelChanging", this, this._onModelChanging);
+		view.addEventListener("Destroy", this, this._onDestroy);
+	}
+	UndoStack.prototype = /** @lends orion.textview.UndoStack.prototype */ {
+		/**
+		 * Adds a change to the stack.
+		 * 
+		 * @param change the change to add.
+		 * @param {Number} change.offset the offset of the change
+		 * @param {String} change.text the new text of the change
+		 * @param {String} change.previousText the previous text of the change
+		 */
+		add: function (change) {
+			if (this.compoundChange) {
+				this.compoundChange.add(change);
+			} else {
+				var length = this.stack.length;
+				this.stack.splice(this.index, length-this.index, change);
+				this.index++;
+				if (this.stack.length > this.size) {
+					this.stack.shift();
+					this.index--;
+					this.cleanIndex--;
+				}
+			}
+		},
+		/** 
+		 * Marks the current state of the stack as clean.
+		 *
+		 * <p>
+		 * This function is typically called when the content of view associated with the stack is saved.
+		 * </p>
+		 *
+		 * @see #isClean
+		 */
+		markClean: function() {
+			this.endCompoundChange();
+			this._commitUndo();
+			this.cleanIndex = this.index;
+		},
+		/**
+		 * Returns true if current state of stack is the same
+		 * as the state when markClean() was called.
+		 *
+		 * <p>
+		 * For example, the application calls markClean(), then calls undo() four times and redo() four times.
+		 * At this point isClean() returns true.  
+		 * </p>
+		 * <p>
+		 * This function is typically called to determine if the content of the view associated with the stack
+		 * has changed since the last time it was saved.
+		 * </p>
+		 *
+		 * @return {Boolean} returns if the state is the same as the state when markClean() was called.
+		 *
+		 * @see #markClean
+		 */
+		isClean: function() {
+			return this.cleanIndex === this.getSize().undo;
+		},
+		/**
+		 * Returns true if there is at least one change to undo.
+		 *
+		 * @return {Boolean} returns true if there is at least one change to undo.
+		 *
+		 * @see #canRedo
+		 * @see #undo
+		 */
+		canUndo: function() {
+			return this.getSize().undo > 0;
+		},
+		/**
+		 * Returns true if there is at least one change to redo.
+		 *
+		 * @return {Boolean} returns true if there is at least one change to redo.
+		 *
+		 * @see #canUndo
+		 * @see #redo
+		 */
+		canRedo: function() {
+			return this.getSize().redo > 0;
+		},
+		/**
+		 * Finishes a compound change.
+		 *
+		 * @see #startCompoundChange
+		 */
+		endCompoundChange: function() {
+			this.compoundChange = undefined;
+		},
+		/**
+		 * Returns the sizes of the stack.
+		 *
+		 * @return {object} a object where object.undo is the number of changes that can be un-done, 
+		 *  and object.redo is the number of changes that can be re-done.
+		 *
+		 * @see #canUndo
+		 * @see #canRedo
+		 */
+		getSize: function() {
+			var index = this.index;
+			var length = this.stack.length;
+			if (this._undoStart !== undefined) {
+				index++;
+			}
+			return {undo: index, redo: (length - index)};
+		},
+		/**
+		 * Undo the last change in the stack.
+		 *
+		 * @return {Boolean} returns true if a change was un-done.
+		 *
+		 * @see #redo
+		 * @see #canUndo
+		 */
+		undo: function() {
+			this._commitUndo();
+			if (this.index <= 0) {
+				return false;
+			}
+			var change = this.stack[--this.index];
+			this._ignoreUndo = true;
+			change.undo(this.view, true);
+			this._ignoreUndo = false;
+			return true;
+		},
+		/**
+		 * Redo the last change in the stack.
+		 *
+		 * @return {Boolean} returns true if a change was re-done.
+		 *
+		 * @see #undo
+		 * @see #canRedo
+		 */
+		redo: function() {
+			this._commitUndo();
+			if (this.index >= this.stack.length) {
+				return false;
+			}
+			var change = this.stack[this.index++];
+			this._ignoreUndo = true;
+			change.redo(this.view, true);
+			this._ignoreUndo = false;
+			return true;
+		},
+		/**
+		 * Reset the stack to its original state. All changes in the stack are thrown away.
+		 */
+		reset: function() {
+			this.index = this.cleanIndex = 0;
+			this.stack = [];
+			this._undoStart = undefined;
+			this._undoText = "";
+			this._ignoreUndo = false;
+			this._compoundChange = undefined;
+		},
+		/**
+		 * Starts a compound change. 
+		 * <p>
+		 * All changes added to stack from the time startCompoundChange() is called
+		 * to the time that endCompoundChange() is called are compound on one change that can be un-done or re-done
+		 * with one single call to undo() or redo().
+		 * </p>
+		 *
+		 * @see #endCompoundChange
+		 */
+		startCompoundChange: function() {
+			this._commitUndo();
+			var change = new CompoundChange(this.view.getSelection(), this.view.getCaretOffset());
+			this.add(change);
+			this.compoundChange = change;
+		},
+		_commitUndo: function () {
+			if (this._undoStart !== undefined) {
+				if (this._undoStart < 0) {
+					this.add(new Change(-this._undoStart, "", this._undoText, ""));
+				} else {
+					this.add(new Change(this._undoStart, this._undoText, ""));
+				}
+				this._undoStart = undefined;
+				this._undoText = "";
+			}
+		},
+		_onDestroy: function() {
+			this.view.removeEventListener("ModelChanging", this, this._onModelChanging);
+			this.view.removeEventListener("Destroy", this, this._onDestroy);
+		},
+		_onModelChanging: function(e) {
+			var newText = e.text;
+			var start = e.start;
+			var removedCharCount = e.removedCharCount;
+			var addedCharCount = e.addedCharCount;
+			if (this._ignoreUndo) {
+				return;
+			}
+			if (this._undoStart !== undefined && 
+				!((addedCharCount === 1 && removedCharCount === 0 && start === this._undoStart + this._undoText.length) ||
+					(addedCharCount === 0 && removedCharCount === 1 && (((start + 1) === -this._undoStart) || (start === -this._undoStart)))))
+			{
+				this._commitUndo();
+			}
+			if (!this.compoundChange) {
+				if (addedCharCount === 1 && removedCharCount === 0) {
+					if (this._undoStart === undefined) {
+						this._undoStart = start;
+					}
+					this._undoText = this._undoText + newText;
+					return;
+				} else if (addedCharCount === 0 && removedCharCount === 1) {
+					var deleting = this._undoText.length > 0 && -this._undoStart === start;
+					this._undoStart = -start;
+					if (deleting) {
+						this._undoText = this._undoText + this.view.getText(start, start + removedCharCount);
+					} else {
+						this._undoText = this.view.getText(start, start + removedCharCount) + this._undoText;
+					}
+					return;
+				}
+			}
+			this.add(new Change(start, newText, this.view.getText(start, start + removedCharCount)));
+		}
+	};
+	return UndoStack;
+}());
+
+if (typeof window !== "undefined" && typeof window.define !== "undefined") {
+	define([], function() {
+		return orion.textview;
+	});
+}
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials are made 
+ * available under the terms of the Eclipse Public License v1.0 
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 
+ * 
+ * Contributors: 
+ *		Felipe Heidrich (IBM Corporation) - initial API and implementation
+ *		Silenio Quarti (IBM Corporation) - initial API and implementation
+ ******************************************************************************/
+ 
+/*global window define */
+
+/**
+ * @namespace The global container for Orion APIs.
+ */ 
+var orion = orion || {};
+/**
+ * @namespace The container for textview APIs.
+ */ 
+orion.textview = orion.textview || {};
+
+/**
+ * Constructs a new TextModel with the given text and default line delimiter.
+ *
+ * @param {String} [text=""] the text that the model will store
+ * @param {String} [lineDelimiter=platform delimiter] the line delimiter used when inserting new lines to the model.
+ *
+ * @name orion.textview.TextModel
+ * @class The TextModel is an interface that provides text for the view. Applications may
+ * implement the TextModel interface to provide a custom store for the view content. The
+ * view interacts with its text model in order to access and update the text that is being
+ * displayed and edited in the view. This is the default implementation.
+ * <p>
+ * <b>See:</b><br/>
+ * {@link orion.textview.TextView}<br/>
+ * {@link orion.textview.TextView#setModel}
+ * </p>
+ */
+orion.textview.TextModel = (function() {
+	var isWindows = window.navigator.platform.indexOf("Win") !== -1;
+
+	/** @private */
+	function TextModel(text, lineDelimiter) {
+		this._listeners = [];
+		this._lineDelimiter = lineDelimiter ? lineDelimiter : (isWindows ? "\r\n" : "\n"); 
+		this._lastLineIndex = -1;
+		this._text = [""];
+		this._lineOffsets = [0];
+		this.setText(text);
+	}
+
+	TextModel.prototype = /** @lends orion.textview.TextModel.prototype */ {
+		/**
+		 * Adds a listener to the model.
+		 * 
+		 * @param {Object} listener the listener to add.
+		 * @param {Function} [listener.onChanged] see {@link #onChanged}.
+		 * @param {Function} [listener.onChanging] see {@link #onChanging}.
+		 * 
+		 * @see removeListener
+		 */
+		addListener: function(listener) {
+			this._listeners.push(listener);
+		},
+		/**
+		 * Removes a listener from the model.
+		 * 
+		 * @param {Object} listener the listener to remove
+		 * 
+		 * @see #addListener
+		 */
+		removeListener: function(listener) {
+			for (var i = 0; i < this._listeners.length; i++) {
+				if (this._listeners[i] === listener) {
+					this._listeners.splice(i, 1);
+					return;
+				}
+			}
+		},
+		/**
+		 * Returns the number of characters in the model.
+		 *
+		 * @returns {Number} the number of characters in the model.
+		 */
+		getCharCount: function() {
+			var count = 0;
+			for (var i = 0; i<this._text.length; i++) {
+				count += this._text[i].length;
+			}
+			return count;
+		},
+		/**
+		 * Returns the text of the line at the given index.
+		 * <p>
+		 * The valid indices are 0 to line count exclusive.  Returns <code>null</code> 
+		 * if the index is out of range. 
+		 * </p>
+		 *
+		 * @param {Number} lineIndex the zero based index of the line.
+		 * @param {Boolean} [includeDelimiter=false] whether or not to include the line delimiter. 
+		 * @returns {String} the line text or <code>null</code> if out of range.
+		 *
+		 * @see #getLineAtOffset
+		 */
+		getLine: function(lineIndex, includeDelimiter) {
+			var lineCount = this.getLineCount();
+			if (!(0 <= lineIndex && lineIndex < lineCount)) {
+				return null;
+			}
+			var start = this._lineOffsets[lineIndex];
+			if (lineIndex + 1 < lineCount) {
+				var text = this.getText(start, this._lineOffsets[lineIndex + 1]);
+				if (includeDelimiter) {
+					return text;
+				}
+				var end = text.length, c;
+				while (((c = text.charCodeAt(end - 1)) === 10) || (c === 13)) {
+					end--;
+				}
+				return text.substring(0, end);
+			} else {
+				return this.getText(start); 
+			}
+		},
+		/**
+		 * Returns the line index at the given character offset.
+		 * <p>
+		 * The valid offsets are 0 to char count inclusive. The line index for
+		 * char count is <code>line count - 1</code>. Returns <code>-1</code> if
+		 * the offset is out of range.
+		 * </p>
+		 *
+		 * @param {Number} offset a character offset.
+		 * @returns {Number} the zero based line index or <code>-1</code> if out of range.
+		 */
+		getLineAtOffset: function(offset) {
+			if (!(0 <= offset && offset <= this.getCharCount())) {
+				return -1;
+			}
+			var lineCount = this.getLineCount();
+			var charCount = this.getCharCount();
+			if (offset === charCount) {
+				return lineCount - 1; 
+			}
+			var lineStart, lineEnd;
+			var index = this._lastLineIndex;
+			if (0 <= index && index < lineCount) {
+				lineStart = this._lineOffsets[index];
+				lineEnd = index + 1 < lineCount ? this._lineOffsets[index + 1] : charCount;
+				if (lineStart <= offset && offset < lineEnd) {
+					return index;
+				}
+			}
+			var high = lineCount;
+			var low = -1;
+			while (high - low > 1) {
+				index = Math.floor((high + low) / 2);
+				lineStart = this._lineOffsets[index];
+				lineEnd = index + 1 < lineCount ? this._lineOffsets[index + 1] : charCount;
+				if (offset <= lineStart) {
+					high = index;
+				} else if (offset < lineEnd) {
+					high = index;
+					break;
+				} else {
+					low = index;
+				}
+			}
+			this._lastLineIndex = high;
+			return high;
+		},
+		/**
+		 * Returns the number of lines in the model.
+		 * <p>
+		 * The model always has at least one line.
+		 * </p>
+		 *
+		 * @returns {Number} the number of lines.
+		 */
+		getLineCount: function() {
+			return this._lineOffsets.length;
+		},
+		/**
+		 * Returns the line delimiter that is used by the view
+		 * when inserting new lines. New lines entered using key strokes 
+		 * and paste operations use this line delimiter.
+		 *
+		 * @return {String} the line delimiter that is used by the view when inserting new lines.
+		 */
+		getLineDelimiter: function() {
+			return this._lineDelimiter;
+		},
+		/**
+		 * Returns the end character offset for the given line. 
+		 * <p>
+		 * The end offset is not inclusive. This means that when the line delimiter is included, the 
+		 * offset is either the start offset of the next line or char count. When the line delimiter is
+		 * not included, the offset is the offset of the line delimiter.
+		 * </p>
+		 * <p>
+		 * The valid indices are 0 to line count exclusive.  Returns <code>-1</code> 
+		 * if the index is out of range. 
+		 * </p>
+		 *
+		 * @param {Number} lineIndex the zero based index of the line.
+		 * @param {Boolean} [includeDelimiter=false] whether or not to include the line delimiter. 
+		 * @return {Number} the line end offset or <code>-1</code> if out of range.
+		 *
+		 * @see #getLineStart
+		 */
+		getLineEnd: function(lineIndex, includeDelimiter) {
+			var lineCount = this.getLineCount();
+			if (!(0 <= lineIndex && lineIndex < lineCount)) {
+				return -1;
+			}
+			if (lineIndex + 1 < lineCount) {
+				var end = this._lineOffsets[lineIndex + 1];
+				if (includeDelimiter) {
+					return end;
+				}
+				var text = this.getText(Math.max(this._lineOffsets[lineIndex], end - 2), end);
+				var i = text.length, c;
+				while (((c = text.charCodeAt(i - 1)) === 10) || (c === 13)) {
+					i--;
+				}
+				return end - (text.length - i);
+			} else {
+				return this.getCharCount();
+			}
+		},
+		/**
+		 * Returns the start character offset for the given line.
+		 * <p>
+		 * The valid indices are 0 to line count exclusive.  Returns <code>-1</code> 
+		 * if the index is out of range. 
+		 * </p>
+		 *
+		 * @param {Number} lineIndex the zero based index of the line.
+		 * @return {Number} the line start offset or <code>-1</code> if out of range.
+		 *
+		 * @see #getLineEnd
+		 */
+		getLineStart: function(lineIndex) {
+			if (!(0 <= lineIndex && lineIndex < this.getLineCount())) {
+				return -1;
+			}
+			return this._lineOffsets[lineIndex];
+		},
+		/**
+		 * Returns the text for the given range.
+		 * <p>
+		 * The end offset is not inclusive. This means that character at the end offset
+		 * is not included in the returned text.
+		 * </p>
+		 *
+		 * @param {Number} [start=0] the zero based start offset of text range.
+		 * @param {Number} [end=char count] the zero based end offset of text range.
+		 *
+		 * @see #setText
+		 */
+		getText: function(start, end) {
+			if (start === undefined) { start = 0; }
+			if (end === undefined) { end = this.getCharCount(); }
+			var offset = 0, chunk = 0, length;
+			while (chunk<this._text.length) {
+				length = this._text[chunk].length; 
+				if (start <= offset + length) { break; }
+				offset += length;
+				chunk++;
+			}
+			var firstOffset = offset;
+			var firstChunk = chunk;
+			while (chunk<this._text.length) {
+				length = this._text[chunk].length; 
+				if (end <= offset + length) { break; }
+				offset += length;
+				chunk++;
+			}
+			var lastOffset = offset;
+			var lastChunk = chunk;
+			if (firstChunk === lastChunk) {
+				return this._text[firstChunk].substring(start - firstOffset, end - lastOffset);
+			}
+			var beforeText = this._text[firstChunk].substring(start - firstOffset);
+			var afterText = this._text[lastChunk].substring(0, end - lastOffset);
+			return beforeText + this._text.slice(firstChunk+1, lastChunk).join("") + afterText; 
+		},
+		/**
+		 * Notifies all listeners that the text is about to change.
+		 * <p>
+		 * This notification is intended to be used only by the view. Application clients should
+		 * use {@link orion.textview.TextView#event:onModelChanging}.
+		 * </p>
+		 * <p>
+		 * NOTE: This method is not meant to called directly by application code. It is called internally by the TextModel
+		 * as part of the implementation of {@link #setText}. This method is included in the public API for documentation
+		 * purposes and to allow integration with other toolkit frameworks.
+		 * </p>
+		 *
+		 * @param {String} text the text that is about to be inserted in the model.
+		 * @param {Number} start the character offset in the model where the change will occur.
+		 * @param {Number} removedCharCount the number of characters being removed from the model.
+		 * @param {Number} addedCharCount the number of characters being added to the model.
+		 * @param {Number} removedLineCount the number of lines being removed from the model.
+		 * @param {Number} addedLineCount the number of lines being added to the model.
+		 */
+		onChanging: function(text, start, removedCharCount, addedCharCount, removedLineCount, addedLineCount) {
+			for (var i = 0; i < this._listeners.length; i++) {
+				var l = this._listeners[i]; 
+				if (l && l.onChanging) { 
+					l.onChanging(text, start, removedCharCount, addedCharCount, removedLineCount, addedLineCount);
+				}
+			}
+		},
+		/**
+		 * Notifies all listeners that the text has changed.
+		 * <p>
+		 * This notification is intended to be used only by the view. Application clients should
+		 * use {@link orion.textview.TextView#event:onModelChanged}.
+		 * </p>
+		 * <p>
+		 * NOTE: This method is not meant to called directly by application code. It is called internally by the TextModel
+		 * as part of the implementation of {@link #setText}. This method is included in the public API for documentation
+		 * purposes and to allow integration with other toolkit frameworks.
+		 * </p>
+		 *
+		 * @param {Number} start the character offset in the model where the change occurred.
+		 * @param {Number} removedCharCount the number of characters removed from the model.
+		 * @param {Number} addedCharCount the number of characters added to the model.
+		 * @param {Number} removedLineCount the number of lines removed from the model.
+		 * @param {Number} addedLineCount the number of lines added to the model.
+		 */
+		onChanged: function(start, removedCharCount, addedCharCount, removedLineCount, addedLineCount) {
+			for (var i = 0; i < this._listeners.length; i++) {
+				var l = this._listeners[i]; 
+				if (l && l.onChanged) { 
+					l.onChanged(start, removedCharCount, addedCharCount, removedLineCount, addedLineCount);
+				}
+			}
+		},
+		/**
+		 * Replaces the text in the given range with the given text.
+		 * <p>
+		 * The end offset is not inclusive. This means that the character at the 
+		 * end offset is not replaced.
+		 * </p>
+		 * <p>
+		 * The text model must notify the listeners before and after the
+		 * the text is changed by calling {@link #onChanging} and {@link #onChanged}
+		 * respectively. 
+		 * </p>
+		 *
+		 * @param {String} [text=""] the new text.
+		 * @param {Number} [start=0] the zero based start offset of text range.
+		 * @param {Number} [end=char count] the zero based end offset of text range.
+		 *
+		 * @see #getText
+		 */
+		setText: function(text, start, end) {
+			if (text === undefined) { text = ""; }
+			if (start === undefined) { start = 0; }
+			if (end === undefined) { end = this.getCharCount(); }
+			var startLine = this.getLineAtOffset(start);
+			var endLine = this.getLineAtOffset(end);
+			var eventStart = start;
+			var removedCharCount = end - start;
+			var removedLineCount = endLine - startLine;
+			var addedCharCount = text.length;
+			var addedLineCount = 0;
+			var lineCount = this.getLineCount();
+			
+			var cr = 0, lf = 0, index = 0;
+			var newLineOffsets = [];
+			while (true) {
+				if (cr !== -1 && cr <= index) { cr = text.indexOf("\r", index); }
+				if (lf !== -1 && lf <= index) { lf = text.indexOf("\n", index); }
+				if (lf === -1 && cr === -1) { break; }
+				if (cr !== -1 && lf !== -1) {
+					if (cr + 1 === lf) {
+						index = lf + 1;
+					} else {
+						index = (cr < lf ? cr : lf) + 1;
+					}
+				} else if (cr !== -1) {
+					index = cr + 1;
+				} else {
+					index = lf + 1;
+				}
+				newLineOffsets.push(start + index);
+				addedLineCount++;
+			}
+		
+			this.onChanging(text, eventStart, removedCharCount, addedCharCount, removedLineCount, addedLineCount);
+			
+			//TODO this should be done the loops below to avoid getText()
+			if (newLineOffsets.length === 0) {
+				var startLineOffset = this.getLineStart(startLine), endLineOffset;
+				if (endLine + 1 < lineCount) {
+					endLineOffset = this.getLineStart(endLine + 1);
+				} else {
+					endLineOffset = this.getCharCount();
+				}
+				if (start !== startLineOffset) {
+					text = this.getText(startLineOffset, start) + text;
+					start = startLineOffset;
+				}
+				if (end !== endLineOffset) {
+					text = text + this.getText(end, endLineOffset);
+					end = endLineOffset;
+				}
+			}
+			
+			var changeCount = addedCharCount - removedCharCount;
+			for (var j = startLine + removedLineCount + 1; j < lineCount; j++) {
+				this._lineOffsets[j] += changeCount;
+			}
+			var args = [startLine + 1, removedLineCount].concat(newLineOffsets);
+			Array.prototype.splice.apply(this._lineOffsets, args);
+			
+			var offset = 0, chunk = 0, length;
+			while (chunk<this._text.length) {
+				length = this._text[chunk].length; 
+				if (start <= offset + length) { break; }
+				offset += length;
+				chunk++;
+			}
+			var firstOffset = offset;
+			var firstChunk = chunk;
+			while (chunk<this._text.length) {
+				length = this._text[chunk].length; 
+				if (end <= offset + length) { break; }
+				offset += length;
+				chunk++;
+			}
+			var lastOffset = offset;
+			var lastChunk = chunk;
+			var firstText = this._text[firstChunk];
+			var lastText = this._text[lastChunk];
+			var beforeText = firstText.substring(0, start - firstOffset);
+			var afterText = lastText.substring(end - lastOffset);
+			var params = [firstChunk, lastChunk - firstChunk + 1];
+			if (beforeText) { params.push(beforeText); }
+			if (text) { params.push(text); }
+			if (afterText) { params.push(afterText); }
+			Array.prototype.splice.apply(this._text, params);
+			if (this._text.length === 0) { this._text = [""]; }
+			
+			this.onChanged(eventStart, removedCharCount, addedCharCount, removedLineCount, addedLineCount);
+		}
+	};
+	
+	return TextModel;
+}());
+
+if (typeof window !== "undefined" && typeof window.define !== "undefined") {
+	define([], function() {
+		return orion.textview;
+	});
+}
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials are made 
+ * available under the terms of the Eclipse Public License v1.0 
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 
+ * 
+ * Contributors: 
+ *		Felipe Heidrich (IBM Corporation) - initial API and implementation
+ *		Silenio Quarti (IBM Corporation) - initial API and implementation
+ *		Mihai Sucan (Mozilla Foundation) - fix for Bugs 334583, 348471, 349485, 350595.
+ ******************************************************************************/
+
+/*global window document navigator setTimeout clearTimeout XMLHttpRequest define */
+
+/**
+ * @namespace The global container for Orion APIs.
+ */ 
+var orion = orion || {};
+/**
+ * @namespace The container for textview APIs.
+ */ 
+orion.textview = orion.textview || {};
+
+/**
+ * Constructs a new text view.
+ * 
+ * @param options the view options.
+ * @param {String|DOMElement} options.parent the parent element for the view, it can be either a DOM element or an ID for a DOM element.
+ * @param {orion.textview.TextModel} [options.model] the text model for the view. If this options is not set the view creates an empty {@link orion.textview.TextModel}.
+ * @param {Boolean} [options.readonly=false] whether or not the view is read-only.
+ * @param {Boolean} [options.fullSelection=true] whether or not the view is in full selection mode.
+ * @param {String|String[]} [options.stylesheet] one or more stylesheet URIs for the view.
+ * @param {Number} [options.tabSize] The number of spaces in a tab.
+ * 
+ * @class A TextView is a user interface for editing text.
+ * @name orion.textview.TextView
+ */
+orion.textview.TextView = (function() {
+
+	/** @private */
+	function addHandler(node, type, handler, capture) {
+		if (typeof node.addEventListener === "function") {
+			node.addEventListener(type, handler, capture === true);
+		} else {
+			node.attachEvent("on" + type, handler);
+		}
+	}
+	/** @private */
+	function removeHandler(node, type, handler, capture) {
+		if (typeof node.removeEventListener === "function") {
+			node.removeEventListener(type, handler, capture === true);
+		} else {
+			node.detachEvent("on" + type, handler);
+		}
+	}
+	var isIE = document.selection && window.ActiveXObject && /MSIE/.test(navigator.userAgent) ? document.documentMode : undefined;
+	var isFirefox = parseFloat(navigator.userAgent.split("Firefox/")[1] || navigator.userAgent.split("Minefield/")[1]) || undefined;
+	var isOpera = navigator.userAgent.indexOf("Opera") !== -1;
+	var isChrome = navigator.userAgent.indexOf("Chrome") !== -1;
+	var isSafari = navigator.userAgent.indexOf("Safari") !== -1;
+	var isWebkit = navigator.userAgent.indexOf("WebKit") !== -1;
+	var isPad = navigator.userAgent.indexOf("iPad") !== -1;
+	var isMac = navigator.platform.indexOf("Mac") !== -1;
+	var isWindows = navigator.platform.indexOf("Win") !== -1;
+	var isLinux = navigator.platform.indexOf("Linux") !== -1;
+	var isW3CEvents = typeof window.document.documentElement.addEventListener === "function";
+	var isRangeRects = (!isIE || isIE >= 9) && typeof window.document.createRange().getBoundingClientRect === "function";
+	var platformDelimiter = isWindows ? "\r\n" : "\n";
+	
+	/** 
+	 * Constructs a new Selection object.
+	 * 
+	 * @class A Selection represents a range of selected text in the view.
+	 * @name orion.textview.Selection
+	 */
+	var Selection = (function() {
+		/** @private */
+		function Selection (start, end, caret) {
+			/**
+			 * The selection start offset.
+			 *
+			 * @name orion.textview.Selection#start
+			 */
+			this.start = start;
+			/**
+			 * The selection end offset.
+			 *
+			 * @name orion.textview.Selection#end
+			 */
+			this.end = end;
+			/** @private */
+			this.caret = caret; //true if the start, false if the caret is at end
+		}
+		Selection.prototype = /** @lends orion.textview.Selection.prototype */ {
+			/** @private */
+			clone: function() {
+				return new Selection(this.start, this.end, this.caret);
+			},
+			/** @private */
+			collapse: function() {
+				if (this.caret) {
+					this.end = this.start;
+				} else {
+					this.start = this.end;
+				}
+			},
+			/** @private */
+			extend: function (offset) {
+				if (this.caret) {
+					this.start = offset;
+				} else {
+					this.end = offset;
+				}
+				if (this.start > this.end) {
+					var tmp = this.start;
+					this.start = this.end;
+					this.end = tmp;
+					this.caret = !this.caret;
+				}
+			},
+			/** @private */
+			setCaret: function(offset) {
+				this.start = offset;
+				this.end = offset;
+				this.caret = false;
+			},
+			/** @private */
+			getCaret: function() {
+				return this.caret ? this.start : this.end;
+			},
+			/** @private */
+			toString: function() {
+				return "start=" + this.start + " end=" + this.end + (this.caret ? " caret is at start" : " caret is at end");
+			},
+			/** @private */
+			isEmpty: function() {
+				return this.start === this.end;
+			},
+			/** @private */
+			equals: function(object) {
+				return this.caret === object.caret && this.start === object.start && this.end === object.end;
+			}
+		};
+		return Selection;
+	}());
+
+	/** 
+	 * Constructs a new EventTable object.
+	 * 
+	 * @class 
+	 * @name orion.textview.EventTable
+	 * @private
+	 */
+	var EventTable = (function() {
+		/** @private */
+		function EventTable(){
+		    this._listeners = {};
+		}
+		EventTable.prototype = /** @lends EventTable.prototype */ {
+			/** @private */
+			addEventListener: function(type, context, func, data) {
+				if (!this._listeners[type]) {
+					this._listeners[type] = [];
+				}
+				var listener = {
+						context: context,
+						func: func,
+						data: data
+				};
+				this._listeners[type].push(listener);
+			},
+			/** @private */
+			sendEvent: function(type, event) {
+				var listeners = this._listeners[type];
+				if (listeners) {
+					for (var i=0, len=listeners.length; i < len; i++){
+						var l = listeners[i];
+						if (l && l.context && l.func) {
+							l.func.call(l.context, event, l.data);
+						}
+					}
+				}
+			},
+			/** @private */
+			removeEventListener: function(type, context, func, data){
+				var listeners = this._listeners[type];
+				if (listeners) {
+					for (var i=0, len=listeners.length; i < len; i++){
+						var l = listeners[i];
+						if (l.context === context && l.func === func && l.data === data) {
+							listeners.splice(i, 1);
+							break;
+						}
+					}
+				}
+			}
+		};
+		return EventTable;
+	}());
+	
+	/** @private */
+	function TextView (options) {
+		this._init(options);
+	}
+	
+	TextView.prototype = /** @lends orion.textview.TextView.prototype */ {
+		/**
+		 * Adds an event listener to the text view.
+		 * 
+		 * @param {String} type the event type. The supported events are:
+		 * <ul>
+		 * <li>"Modify" See {@link #onModify} </li>
+		 * <li>"Selection" See {@link #onSelection} </li>
+		 * <li>"Scroll" See {@link #onScroll} </li>
+		 * <li>"Verify" See {@link #onVerify} </li>
+		 * <li>"Destroy" See {@link #onDestroy} </li>
+		 * <li>"LineStyle" See {@link #onLineStyle} </li>
+		 * <li>"ModelChanging" See {@link #onModelChanging} </li>
+		 * <li>"ModelChanged" See {@link #onModelChanged} </li>
+		 * </ul>
+		 * @param {Object} context the context of the function.
+		 * @param {Function} func the function that will be executed when the event happens. 
+		 *   The function should take an event as the first parameter and optional data as the second parameter.
+		 * @param {Object} [data] optional data passed to the function.
+		 * 
+		 * @see #removeEventListener
+		 */
+		addEventListener: function(type, context, func, data) {
+			this._eventTable.addEventListener(type, context, func, data);
+		},
+		/**
+		 * Adds a ruler to the text view.
+		 *
+		 * @param {orion.textview.Ruler} ruler the ruler.
+		 */
+		addRuler: function (ruler) {
+			var document = this._frameDocument;
+			var body = document.body;
+			var side = ruler.getLocation();
+			var rulerParent = side === "left" ? this._leftDiv : this._rightDiv;
+			if (!rulerParent) {
+				rulerParent = document.createElement("DIV");
+				rulerParent.style.overflow = "hidden";
+				rulerParent.style.MozUserSelect = "none";
+				rulerParent.style.WebkitUserSelect = "none";
+				if (isIE) {
+					rulerParent.attachEvent("onselectstart", function() {return false;});
+				}
+				rulerParent.style.position = "absolute";
+				rulerParent.style.top = "0px";
+				rulerParent.style.cursor = "default";
+				body.appendChild(rulerParent);
+				if (side === "left") {
+					this._leftDiv = rulerParent;
+					rulerParent.className = "viewLeftRuler";
+				} else {
+					this._rightDiv = rulerParent;
+					rulerParent.className = "viewRightRuler";
+				}
+				var table = document.createElement("TABLE");
+				rulerParent.appendChild(table);
+				table.cellPadding = "0px";
+				table.cellSpacing = "0px";
+				table.border = "0px";
+				table.insertRow(0);
+				var self = this;
+				addHandler(rulerParent, "click", function(e) { self._handleRulerEvent(e); });
+				addHandler(rulerParent, "dblclick", function(e) { self._handleRulerEvent(e); });
+			}
+			var div = document.createElement("DIV");
+			div._ruler = ruler;
+			div.rulerChanged = true;
+			div.style.position = "relative";
+			var row = rulerParent.firstChild.rows[0];
+			var index = row.cells.length;
+			var cell = row.insertCell(index);
+			cell.vAlign = "top";
+			cell.appendChild(div);
+			ruler.setView(this);
+			this._updatePage();
+		},
+		/**
+		 * Converts the given rectangle from one coordinate spaces to another.
+		 * <p>The supported coordinate spaces are:
+		 * <ul>
+		 *   <li>"document" - relative to document, the origin is the top-left corner of first line</li>
+		 *   <li>"page" - relative to html page that contains the text view</li>
+		 *   <li>"view" - relative to text view, the origin is the top-left corner of the view container</li>
+		 * </ul>
+		 * </p>
+		 * <p>All methods in the view that take or return a position are in the document coordinate space.</p>
+		 *
+		 * @param rect the rectangle to convert.
+		 * @param rect.x the x of the rectangle.
+		 * @param rect.y the y of the rectangle.
+		 * @param rect.width the width of the rectangle.
+		 * @param rect.height the height of the rectangle.
+		 * @param {String} from the source coordinate space.
+		 * @param {String} to the destination coordinate space.
+		 *
+		 * @see #getLocationAtOffset
+		 * @see #getOffsetAtLocation
+		 * @see #getTopPixel
+		 * @see #setTopPixel
+		 */
+		convert: function(rect, from, to) {
+			var scroll = this._getScroll();
+			var viewPad = this._getViewPadding();
+			var frame = this._frame.getBoundingClientRect();
+			var viewRect = this._viewDiv.getBoundingClientRect();
+			switch(from) {
+				case "document":
+					if (rect.x !== undefined) {
+						rect.x += - scroll.x + viewRect.left + viewPad.left;
+					}
+					if (rect.y !== undefined) {
+						rect.y += - scroll.y + viewRect.top + viewPad.top;
+					}
+					break;
+				case "page":
+					if (rect.x !== undefined) {
+						rect.x += - frame.left;
+					}
+					if (rect.y !== undefined) {
+						rect.y += - frame.top;
+					}
+					break;
+			}
+			//At this point rect is in the widget coordinate space
+			switch (to) {
+				case "document":
+					if (rect.x !== undefined) {
+						rect.x += scroll.x - viewRect.left - viewPad.left;
+					}
+					if (rect.y !== undefined) {
+						rect.y += scroll.y - viewRect.top - viewPad.top;
+					}
+					break;
+				case "page":
+					if (rect.x !== undefined) {
+						rect.x += frame.left;
+					}
+					if (rect.y !== undefined) {
+						rect.y += frame.top;
+					}
+					break;
+			}
+		},
+		/**
+		 * Destroys the text view. 
+		 * <p>
+		 * Removes the view from the page and frees all resources created by the view.
+		 * Calling this function causes the "Destroy" event to be fire so that all components
+		 * attached to view can release their references.
+		 * </p>
+		 *
+		 * @see #onDestroy
+		 */
+		destroy: function() {
+			this._setGrab(null);
+			this._unhookEvents();
+			
+			/* Destroy rulers*/
+			var destroyRulers = function(rulerDiv) {
+				if (!rulerDiv) {
+					return;
+				}
+				var cells = rulerDiv.firstChild.rows[0].cells;
+				for (var i = 0; i < cells.length; i++) {
+					var div = cells[i].firstChild;
+					div._ruler.setView(null);
+				}
+			};
+			destroyRulers (this._leftDiv);
+			destroyRulers (this._rightDiv);
+
+			/* Destroy timers */
+			if (this._autoScrollTimerID) {
+				clearTimeout(this._autoScrollTimerID);
+				this._autoScrollTimerID = null;
+			}
+			if (this._updateTimer) {
+				clearTimeout(this._updateTimer);
+				this._updateTimer = null;
+			}
+			
+			/* Destroy DOM */
+			var parent = this._parent;
+			var frame = this._frame;
+			parent.removeChild(frame);
+			
+			if (isPad) {
+				parent.removeChild(this._touchDiv);
+				this._touchDiv = null;
+				this._selDiv1 = null;
+				this._selDiv2 = null;
+				this._selDiv3 = null;
+				this._textArea = null;
+			}
+			
+			var e = {};
+			this.onDestroy(e);
+			
+			this._parent = null;
+			this._parentDocument = null;
+			this._model = null;
+			this._selection = null;
+			this._doubleClickSelection = null;
+			this._eventTable = null;
+			this._frame = null;
+			this._frameDocument = null;
+			this._frameWindow = null;
+			this._scrollDiv = null;
+			this._viewDiv = null;
+			this._clientDiv = null;
+			this._overlayDiv = null;
+			this._keyBindings = null;
+			this._actions = null;
+		},
+		/**
+		 * Gives focus to the text view.
+		 */
+		focus: function() {
+			/*
+			* Feature in Chrome. When focus is called in the clientDiv without
+			* setting selection the browser will set the selection to the first dom 
+			* element, which can be above the client area. When this happen the 
+			* browser also scrolls the window to show that element.
+			* The fix is to call _updateDOMSelection() before calling focus().
+			*/
+			this._updateDOMSelection();
+			if (isPad) {
+				this._textArea.focus();
+			} else {
+				if (isOpera) { this._clientDiv.blur(); }
+				this._clientDiv.focus();
+			}
+			/*
+			* Feature in Safari. When focus is called the browser selects the clientDiv
+			* itself. The fix is to call _updateDOMSelection() after calling focus().
+			*/
+			this._updateDOMSelection();
+		},
+		/**
+		 * Returns all action names defined in the text view.
+		 * <p>
+		 * There are two types of actions, the predefined actions of the view 
+		 * and the actions added by application code.
+		 * </p>
+		 * <p>
+		 * The predefined actions are:
+		 * <ul>
+		 *   <li>Navigation actions. These actions move the caret collapsing the selection.</li>
+		 *     <ul>
+		 *       <li>"lineUp" - moves the caret up by one line</li>
+		 *       <li>"lineDown" - moves the caret down by one line</li>
+		 *       <li>"lineStart" - moves the caret to beginning of the current line</li>
+		 *       <li>"lineEnd" - moves the caret to end of the current line </li>
+		 *       <li>"charPrevious" - moves the caret to the previous character</li>
+		 *       <li>"charNext" - moves the caret to the next character</li>
+		 *       <li>"pageUp" - moves the caret up by one page</li>
+		 *       <li>"pageDown" - moves the caret down by one page</li>
+		 *       <li>"wordPrevious" - moves the caret to the previous word</li>
+		 *       <li>"wordNext" - moves the caret to the next word</li>
+		 *       <li>"textStart" - moves the caret to the beginning of the document</li>
+		 *       <li>"textEnd" - moves the caret to the end of the document</li>
+		 *     </ul>
+		 *   <li>Selection actions. These actions move the caret extending the selection.</li>
+		 *     <ul>
+		 *       <li>"selectLineUp" - moves the caret up by one line</li>
+		 *       <li>"selectLineDown" - moves the caret down by one line</li>
+		 *       <li>"selectLineStart" - moves the caret to beginning of the current line</li>
+		 *       <li>"selectLineEnd" - moves the caret to end of the current line </li>
+		 *       <li>"selectCharPrevious" - moves the caret to the previous character</li>
+		 *       <li>"selectCharNext" - moves the caret to the next character</li>
+		 *       <li>"selectPageUp" - moves the caret up by one page</li>
+		 *       <li>"selectPageDown" - moves the caret down by one page</li>
+		 *       <li>"selectWordPrevious" - moves the caret to the previous word</li>
+		 *       <li>"selectWordNext" - moves the caret to the next word</li>
+		 *       <li>"selectTextStart" - moves the caret to the beginning of the document</li>
+		 *       <li>"selectTextEnd" - moves the caret to the end of the document</li>
+		 *       <li>"selectAll" - selects the entire document</li>
+		 *     </ul>
+		 *   <li>Edit actions. These actions modify the text view text</li>
+		 *     <ul>
+		 *       <li>"deletePrevious" - deletes the character preceding the caret</li>
+		 *       <li>"deleteNext" - deletes the charecter following the caret</li>
+		 *       <li>"deleteWordPrevious" - deletes the word preceding the caret</li>
+		 *       <li>"deleteWordNext" - deletes the word following the caret</li>
+		 *       <li>"tab" - inserts a tab character at the caret</li>
+		 *       <li>"enter" - inserts a line delimiter at the caret</li>
+		 *     </ul>
+		 *   <li>Clipboard actions.</li>
+		 *     <ul>
+		 *       <li>"copy" - copies the selected text to the clipboard</li>
+		 *       <li>"cut" - copies the selected text to the clipboard and deletes the selection</li>
+		 *       <li>"paste" - replaces the selected text with the clipboard contents</li>
+		 *     </ul>
+		 * </ul>
+		 * </p>
+		 *
+		 * @param {Boolean} [defaultAction=false] whether or not the predefined actions are included.
+		 * @returns {String[]} an array of action names defined in the text view.
+		 *
+		 * @see #invokeAction
+		 * @see #setAction
+		 * @see #setKeyBinding
+		 * @see #getKeyBindings
+		 */
+		getActions: function (defaultAction) {
+			var result = [];
+			var actions = this._actions;
+			for (var i = 0; i < actions.length; i++) {
+				if (!defaultAction && actions[i].defaultHandler) { continue; }
+				result.push(actions[i].name);
+			}
+			return result;
+		},
+		/**
+		 * Returns the bottom index.
+		 * <p>
+		 * The bottom index is the line that is currently at the bottom of the view.  This
+		 * line may be partially visible depending on the vertical scroll of the view. The parameter
+		 * <code>fullyVisible</code> determines whether to return only fully visible lines. 
+		 * </p>
+		 *
+		 * @param {Boolean} [fullyVisible=false] if <code>true</code>, returns the index of the last fully visible line. This
+		 *    parameter is ignored if the view is not big enough to show one line.
+		 * @returns {Number} the index of the bottom line.
+		 *
+		 * @see #getTopIndex
+		 * @see #setTopIndex
+		 */
+		getBottomIndex: function(fullyVisible) {
+			return this._getBottomIndex(fullyVisible);
+		},
+		/**
+		 * Returns the bottom pixel.
+		 * <p>
+		 * The bottom pixel is the pixel position that is currently at
+		 * the bottom edge of the view.  This position is relative to the
+		 * beginning of the document.
+		 * </p>
+		 *
+		 * @returns {Number} the bottom pixel.
+		 *
+		 * @see #getTopPixel
+		 * @see #setTopPixel
+		 * @see #convert
+		 */
+		getBottomPixel: function() {
+			return this._getScroll().y + this._getClientHeight();
+		},
+		/**
+		 * Returns the caret offset relative to the start of the document.
+		 *
+		 * @returns the caret offset relative to the start of the document.
+		 *
+		 * @see #setCaretOffset
+		 * @see #setSelection
+		 * @see #getSelection
+		 */
+		getCaretOffset: function () {
+			var s = this._getSelection();
+			return s.getCaret();
+		},
+		/**
+		 * Returns the client area.
+		 * <p>
+		 * The client area is the portion in pixels of the document that is visible. The
+		 * client area position is relative to the beginning of the document.
+		 * </p>
+		 *
+		 * @returns the client area rectangle {x, y, width, height}.
+		 *
+		 * @see #getTopPixel
+		 * @see #getBottomPixel
+		 * @see #getHorizontalPixel
+		 * @see #convert
+		 */
+		getClientArea: function() {
+			var scroll = this._getScroll();
+			return {x: scroll.x, y: scroll.y, width: this._getClientWidth(), height: this._getClientHeight()};
+		},
+		/**
+		 * Returns the horizontal pixel.
+		 * <p>
+		 * The horizontal pixel is the pixel position that is currently at
+		 * the left edge of the view.  This p