Merge mozilla-central into mozilla-inbound
authorBenoit Girard <b56girard@gmail.com>
Mon, 26 Sep 2011 15:58:51 -0400
changeset 77609 e377ae930496ae87be823a759fa4d3a433f0e5ca
parent 77582 24bc89c8bcbe0ba51b8dff660bdd59cfcbb47c09 (current diff)
parent 77608 03188e4fd2000d87c692e13d900f98a01a694439 (diff)
child 77610 2b866e479765e90a7217347657e64313683cb844
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
milestone9.0a1
Merge mozilla-central into mozilla-inbound
--- a/editor/libeditor/text/nsPlaintextDataTransfer.cpp
+++ b/editor/libeditor/text/nsPlaintextDataTransfer.cpp
@@ -63,16 +63,17 @@
 #include "nsCopySupport.h"
 
 // Misc
 #include "nsEditorUtils.h"
 #include "nsContentCID.h"
 #include "nsISelectionPrivate.h"
 #include "nsFrameSelection.h"
 #include "nsEventDispatcher.h"
+#include "nsContentUtils.h"
 
 NS_IMETHODIMP nsPlaintextEditor::PrepareTransferable(nsITransferable **transferable)
 {
   // Create generic Transferable for getting the data
   nsresult rv = CallCreateInstance("@mozilla.org/widget/transferable;1", transferable);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Get the nsITransferable interface for getting the data from the clipboard
@@ -131,16 +132,20 @@ NS_IMETHODIMP nsPlaintextEditor::InsertT
   {
     nsAutoTxnsConserveSelection dontSpazMySelection(this);
     nsCOMPtr<nsISupportsString> textDataObj ( do_QueryInterface(genericDataObj) );
     if (textDataObj && len > 0)
     {
       nsAutoString stuffToPaste;
       textDataObj->GetData(stuffToPaste);
       NS_ASSERTION(stuffToPaste.Length() <= (len/2), "Invalid length!");
+
+      // Sanitize possible carriage returns in the string to be inserted
+      nsContentUtils::PlatformToDOMLineBreaks(stuffToPaste);
+
       nsAutoEditBatch beginBatching(this);
       rv = InsertTextAt(stuffToPaste, aDestinationNode, aDestOffset, aDoDeleteSelection);
     }
   }
   NS_Free(bestFlavor);
       
   // Try to scroll the selection into view if the paste/drop succeeded
 
--- a/editor/libeditor/text/tests/Makefile.in
+++ b/editor/libeditor/text/tests/Makefile.in
@@ -58,16 +58,17 @@ include $(topsrcdir)/config/rules.mk
 		test_bug602130.html \
 		test_bug603556.html \
 		test_bug604532.html \
 		test_bug625452.html \
 		test_bug629172.html \
 		test_bug638596.html \
 		test_bug641466.html \
 		test_bug645914.html \
+		test_bug681229.html \
 		$(NULL)
 
 # disables the key handling test on gtk2 because gtk2 overrides some key events
 # on our editor, and the combinations depend on the system.
 ifneq ($(MOZ_WIDGET_TOOLKIT),gtk2)
 _TEST_FILES += \
 		test_texteditor_keyevent_handling.html \
 		$(NULL)
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/text/tests/test_bug681229.html
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=681229
+-->
+<head>
+  <title>Test for Bug 681229</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.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=681229">Mozilla Bug 681229</a>
+<p id="display"></p>
+<div id="content">
+<textarea spellcheck="false"></textarea>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 681229 **/
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(function() {
+  var t = document.querySelector("textarea");
+  t.focus();
+
+  const kValue = "a\r\nb";
+  const kExpectedValue = (navigator.platform.indexOf("Win") == 0) ?
+    "a\nb" : kValue;
+
+  SimpleTest.waitForClipboard(kExpectedValue,
+    function() {
+      SpecialPowers.copyString(kValue);
+    },
+    function() {
+      synthesizeKey("V", {accelKey: true});
+      is(t.value, "a\nb", "The carriage return has been correctly sanitized");
+      SimpleTest.finish();
+    },
+    function() {
+      SimpleTest.finish();
+    }
+  );
+});
+
+</script>
+</pre>
+</body>
+</html>
--- a/embedding/android/GeckoAppShell.java
+++ b/embedding/android/GeckoAppShell.java
@@ -858,36 +858,57 @@ public class GeckoAppShell
     // On some devices, access to the clipboard service needs to happen
     // on a thread with a looper, so dispatch this to our looper thread
     // Note: the main looper won't work because it may be blocked on the
     // gecko thread, which is most likely this thread
     static String getClipboardText() {
         getHandler().post(new Runnable() { 
             public void run() {
                 Context context = GeckoApp.surfaceView.getContext();
-                android.text.ClipboardManager cm = (android.text.ClipboardManager)
-                    context.getSystemService(Context.CLIPBOARD_SERVICE);
+                String text = null;
+                if (android.os.Build.VERSION.SDK_INT >= 11) {
+                    android.content.ClipboardManager cm = (android.content.ClipboardManager)
+                        context.getSystemService(Context.CLIPBOARD_SERVICE);
+                    if (cm.hasPrimaryClip()) {
+                        ClipData clip = cm.getPrimaryClip();
+                        if (clip != null) {
+                            ClipData.Item item = clip.getItemAt(0);
+                            text = item.coerceToText(context).toString();
+                        }
+                    }
+                } else {
+                    android.text.ClipboardManager cm = (android.text.ClipboardManager)
+                        context.getSystemService(Context.CLIPBOARD_SERVICE);
+                    if (cm.hasText())
+                        text = cm.getText().toString();
+                }
                 try {
-                    sClipboardQueue.put(cm.hasText() ? cm.getText().toString() : "");
+                    sClipboardQueue.put(text != null ? text : "");
                 } catch (InterruptedException ie) {}
             }});
         try {
             String ret = sClipboardQueue.take();
             return ret == "" ? null : ret;
         } catch (InterruptedException ie) {}
         return null;
     }
 
     static void setClipboardText(final String text) {
         getHandler().post(new Runnable() { 
             public void run() {
                 Context context = GeckoApp.surfaceView.getContext();
-                android.text.ClipboardManager cm = (android.text.ClipboardManager)
-                    context.getSystemService(Context.CLIPBOARD_SERVICE);
-                cm.setText(text);
+                if (android.os.Build.VERSION.SDK_INT >= 11) {
+                    android.content.ClipboardManager cm = (android.content.ClipboardManager)
+                        context.getSystemService(Context.CLIPBOARD_SERVICE);
+                    cm.setPrimaryClip(ClipData.newPlainText("Text", text));
+                } else {
+                    android.text.ClipboardManager cm = (android.text.ClipboardManager)
+                        context.getSystemService(Context.CLIPBOARD_SERVICE);
+                    cm.setText(text);
+                }
             }});
     }
 
     public static void showAlertNotification(String aImageUrl, String aAlertTitle, String aAlertText,
                                              String aAlertCookie, String aAlertName) {
         Log.i("GeckoAppJava", "GeckoAppShell.showAlertNotification\n" +
             "- image = '" + aImageUrl + "'\n" +
             "- title = '" + aAlertTitle + "'\n" +
--- a/js/src/jsbool.cpp
+++ b/js/src/jsbool.cpp
@@ -50,29 +50,29 @@
 #include "jsinfer.h"
 #include "jsversion.h"
 #include "jslock.h"
 #include "jsnum.h"
 #include "jsobj.h"
 #include "jsstr.h"
 #include "jsvector.h"
 
+#include "vm/GlobalObject.h"
+
 #include "jsinferinlines.h"
 #include "jsinterpinlines.h"
 #include "jsobjinlines.h"
 #include "jsstrinlines.h"
 
 using namespace js;
 using namespace js::types;
 
 Class js::BooleanClass = {
     "Boolean",
-    JSCLASS_HAS_RESERVED_SLOTS(1) |
-    JSCLASS_HAS_CACHED_PROTO(JSProto_Boolean),
-    JS_PropertyStub,         /* addProperty */
+    JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_HAS_CACHED_PROTO(JSProto_Boolean),    JS_PropertyStub,         /* addProperty */
     JS_PropertyStub,         /* delProperty */
     JS_PropertyStub,         /* getProperty */
     JS_StrictPropertyStub,   /* setProperty */
     JS_EnumerateStub,
     JS_ResolveStub,
     JS_ConvertStub
 };
 
@@ -147,22 +147,40 @@ Boolean(JSContext *cx, uintN argc, Value
         vp->setBoolean(b);
     }
     return true;
 }
 
 JSObject *
 js_InitBooleanClass(JSContext *cx, JSObject *obj)
 {
-    JSObject *proto = js_InitClass(cx, obj, NULL, &BooleanClass, Boolean, 1,
-                                   NULL, boolean_methods, NULL, NULL);
-    if (!proto)
+    JS_ASSERT(obj->isNative());
+
+    GlobalObject *global = obj->asGlobal();
+
+    JSObject *booleanProto = global->createBlankPrototype(cx, &BooleanClass);
+    if (!booleanProto)
         return NULL;
-    proto->setPrimitiveThis(BooleanValue(false));
-    return proto;
+    booleanProto->setPrimitiveThis(BooleanValue(false));
+
+    JSFunction *ctor = global->createConstructor(cx, Boolean, &BooleanClass,
+                                                 CLASS_ATOM(cx, Boolean), 1);
+    if (!ctor)
+        return NULL;
+
+    if (!LinkConstructorAndPrototype(cx, ctor, booleanProto))
+        return NULL;
+
+    if (!DefinePropertiesAndBrand(cx, booleanProto, NULL, boolean_methods))
+        return NULL;
+
+    if (!DefineConstructorAndPrototype(cx, global, JSProto_Boolean, ctor, booleanProto))
+        return NULL;
+
+    return booleanProto;
 }
 
 JSString *
 js_BooleanToString(JSContext *cx, JSBool b)
 {
     return cx->runtime->atomState.booleanAtoms[b ? 1 : 0];
 }
 
--- a/js/src/jsdate.cpp
+++ b/js/src/jsdate.cpp
@@ -67,16 +67,18 @@
 #include "jscntxt.h"
 #include "jsdate.h"
 #include "jsinterp.h"
 #include "jsnum.h"
 #include "jsobj.h"
 #include "jsstr.h"
 #include "jslibmath.h"
 
+#include "vm/GlobalObject.h"
+
 #include "jsinferinlines.h"
 #include "jsobjinlines.h"
 
 #include "vm/Stack-inl.h"
 
 using namespace js;
 using namespace js::types;
 
@@ -2600,44 +2602,62 @@ js_Date(JSContext *cx, uintN argc, Value
     vp->setObject(*obj);
 
     return true;
 }
 
 JSObject *
 js_InitDateClass(JSContext *cx, JSObject *obj)
 {
-    /* set static LocalTZA */
+    JS_ASSERT(obj->isNative());
+
+    /* Set the static LocalTZA. */
     LocalTZA = -(PRMJ_LocalGMTDifference() * msPerSecond);
-    JSObject *proto = js_InitClass(cx, obj, NULL, &DateClass, js_Date, MAXARGS,
-                                   NULL, date_methods, NULL, date_static_methods);
-    if (!proto)
+
+    GlobalObject *global = obj->asGlobal();
+
+    JSObject *dateProto = global->createBlankPrototype(cx, &DateClass);
+    if (!dateProto)
         return NULL;
-
-    AutoObjectRooter tvr(cx, proto);
-
-    SetDateToNaN(cx, proto);
+    SetDateToNaN(cx, dateProto);
+
+    JSFunction *ctor = global->createConstructor(cx, js_Date, &DateClass,
+                                                 CLASS_ATOM(cx, Date), MAXARGS);
+    if (!ctor)
+        return NULL;
+
+    if (!LinkConstructorAndPrototype(cx, ctor, dateProto))
+        return NULL;
+
+    if (!DefinePropertiesAndBrand(cx, ctor, NULL, date_static_methods))
+        return NULL;
 
     /*
-     * ES5 B.2.6:
-     *   The Function object that is the initial value of
-     *   Date.prototype.toGMTString is the same Function
-     *   object that is the initial value of
-     *   Date.prototype.toUTCString.
+     * Define all Date.prototype.* functions, then brand for trace-jitted code.
+     * Date.prototype.toGMTString has the same initial value as
+     * Date.prototype.toUTCString.
      */
-    AutoValueRooter toUTCStringFun(cx);
+    if (!JS_DefineFunctions(cx, dateProto, date_methods))
+        return NULL;
+    Value toUTCStringFun;
     jsid toUTCStringId = ATOM_TO_JSID(cx->runtime->atomState.toUTCStringAtom);
     jsid toGMTStringId = ATOM_TO_JSID(cx->runtime->atomState.toGMTStringAtom);
-    if (!js_GetProperty(cx, proto, toUTCStringId, toUTCStringFun.addr()) ||
-        !js_DefineProperty(cx, proto, toGMTStringId, toUTCStringFun.addr(),
-                           JS_PropertyStub, JS_StrictPropertyStub, 0)) {
+    if (!js_GetProperty(cx, dateProto, toUTCStringId, &toUTCStringFun) ||
+        !js_DefineProperty(cx, dateProto, toGMTStringId, &toUTCStringFun,
+                           JS_PropertyStub, JS_StrictPropertyStub, 0))
+    {
         return NULL;
     }
-
-    return proto;
+    if (!cx->typeInferenceEnabled())
+        dateProto->brand(cx);
+
+    if (!DefineConstructorAndPrototype(cx, global, JSProto_Date, ctor, dateProto))
+        return NULL;
+
+    return dateProto;
 }
 
 JS_FRIEND_API(JSObject *)
 js_NewDateObjectMsec(JSContext *cx, jsdouble msec_time)
 {
     JSObject *obj = NewBuiltinClassInstance(cx, &DateClass);
     if (!obj || !obj->ensureSlots(cx, JSObject::DATE_CLASS_RESERVED_SLOTS))
         return NULL;
--- a/js/src/jsnum.cpp
+++ b/js/src/jsnum.cpp
@@ -70,23 +70,26 @@
 #include "jsopcode.h"
 #include "jsprf.h"
 #include "jsscope.h"
 #include "jsstr.h"
 #include "jstracer.h"
 #include "jsvector.h"
 #include "jslibmath.h"
 
+#include "vm/GlobalObject.h"
+
 #include "jsatominlines.h"
 #include "jsinferinlines.h"
 #include "jsinterpinlines.h"
 #include "jsnuminlines.h"
 #include "jsobjinlines.h"
 #include "jsstrinlines.h"
 
+#include "vm/NumberObject-inl.h"
 #include "vm/String-inl.h"
 
 using namespace js;
 using namespace js::types;
 
 #ifndef JS_HAVE_STDINT_H /* Native support is innocent until proven guilty. */
 
 JS_STATIC_ASSERT(uint8_t(-1) == UINT8_MAX);
@@ -1094,49 +1097,62 @@ FinishRuntimeNumberState(JSRuntime *rt)
     Foreground::free_(storage);
 }
 
 } /* namespace js */
 
 JSObject *
 js_InitNumberClass(JSContext *cx, JSObject *obj)
 {
-    JSObject *proto, *ctor;
-    JSRuntime *rt;
+    JS_ASSERT(obj->isNative());
 
     /* XXX must do at least once per new thread, so do it per JSContext... */
     FIX_FPU();
 
-    proto = js_InitClass(cx, obj, NULL, &NumberClass, Number, 1,
-                         NULL, number_methods, NULL, NULL);
-    if (!proto || !(ctor = JS_GetConstructor(cx, proto)))
+    GlobalObject *global = obj->asGlobal();
+
+    JSObject *numberProto = global->createBlankPrototype(cx, &NumberClass);
+    if (!numberProto)
         return NULL;
-    proto->setPrimitiveThis(Int32Value(0));
+    numberProto->asNumber()->setPrimitiveValue(0);
 
-    if (!JS_DefineFunctions(cx, obj, number_functions))
+    JSFunction *ctor = global->createConstructor(cx, Number, &NumberClass,
+                                                 CLASS_ATOM(cx, Number), 1);
+    if (!ctor)
         return NULL;
 
+    if (!LinkConstructorAndPrototype(cx, ctor, numberProto))
+        return NULL;
+
+    /* Add numeric constants (MAX_VALUE, NaN, &c.) to the Number constructor. */
     if (!JS_DefineConstDoubles(cx, ctor, number_constants))
         return NULL;
 
-    /* ECMA 15.1.1.1 */
-    rt = cx->runtime;
-    if (!JS_DefineProperty(cx, obj, js_NaN_str, rt->NaNValue,
-                           JS_PropertyStub, JS_StrictPropertyStub,
-                           JSPROP_PERMANENT | JSPROP_READONLY)) {
+    if (!DefinePropertiesAndBrand(cx, numberProto, NULL, number_methods))
+        return NULL;
+
+    if (!JS_DefineFunctions(cx, global, number_functions))
+        return NULL;
+
+    /* ES5 15.1.1.1, 15.1.1.2 */
+    if (!DefineNativeProperty(cx, global, ATOM_TO_JSID(cx->runtime->atomState.NaNAtom),
+                              cx->runtime->NaNValue, JS_PropertyStub, JS_StrictPropertyStub,
+                              JSPROP_PERMANENT | JSPROP_READONLY, 0, 0) ||
+        !DefineNativeProperty(cx, global, ATOM_TO_JSID(cx->runtime->atomState.InfinityAtom),
+                              cx->runtime->positiveInfinityValue,
+                              JS_PropertyStub, JS_StrictPropertyStub,
+                              JSPROP_PERMANENT | JSPROP_READONLY, 0, 0))
+    {
         return NULL;
     }
 
-    /* ECMA 15.1.1.2 */
-    if (!JS_DefineProperty(cx, obj, js_Infinity_str, rt->positiveInfinityValue,
-                           JS_PropertyStub, JS_StrictPropertyStub,
-                           JSPROP_PERMANENT | JSPROP_READONLY)) {
+    if (!DefineConstructorAndPrototype(cx, global, JSProto_Number, ctor, numberProto))
         return NULL;
-    }
-    return proto;
+
+    return numberProto;
 }
 
 namespace v8 {
 namespace internal {
 extern char* DoubleToCString(double v, char* buffer, int buflen);
 }
 }
 
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -84,16 +84,17 @@
 #include "jswrapper.h"
 
 #include "jsarrayinlines.h"
 #include "jsinterpinlines.h"
 #include "jsscopeinlines.h"
 #include "jsscriptinlines.h"
 #include "jsobjinlines.h"
 
+#include "vm/NumberObject-inl.h"
 #include "vm/StringObject-inl.h"
 
 #if JS_HAS_GENERATORS
 #include "jsiter.h"
 #endif
 
 #if JS_HAS_XML_SUPPORT
 #include "jsxml.h"
@@ -6758,20 +6759,21 @@ js_GetClassPrototype(JSContext *cx, JSOb
     return FindClassPrototype(cx, scopeobj, protoKey, protop, clasp);
 }
 
 JSObject *
 PrimitiveToObject(JSContext *cx, const Value &v)
 {
     if (v.isString())
         return StringObject::create(cx, v.toString());
-
-    JS_ASSERT(v.isNumber() || v.isBoolean());
-    Class *clasp = v.isNumber() ? &NumberClass : &BooleanClass;
-    JSObject *obj = NewBuiltinClassInstance(cx, clasp);
+    if (v.isNumber())
+        return NumberObject::create(cx, v.toNumber());
+
+    JS_ASSERT(v.isBoolean());
+    JSObject *obj = NewBuiltinClassInstance(cx, &BooleanClass);
     if (!obj)
         return NULL;
 
     obj->setPrimitiveThis(v);
     return obj;
 }
 
 JSBool
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -375,16 +375,17 @@ extern Class StringClass;
 extern Class StrictArgumentsObjectClass;
 extern Class WeakMapClass;
 extern Class WithClass;
 extern Class XMLFilterClass;
 
 class ArgumentsObject;
 class GlobalObject;
 class NormalArgumentsObject;
+class NumberObject;
 class StrictArgumentsObject;
 class StringObject;
 
 }  /* namespace js */
 
 /*
  * JSObject struct, with members sized to fit in 32 bytes on 32-bit targets,
  * 64 bytes on 64-bit systems. The JSFunction struct is an extension of this
@@ -1047,16 +1048,17 @@ struct JSObject : js::gc::Cell {
     inline void setPrimitiveThis(const js::Value &pthis);
 
     static size_t getPrimitiveThisOffset() {
         /* All primitive objects have their value in a fixed slot. */
         return getFixedSlotOffset(JSSLOT_PRIMITIVE_THIS);
     }
 
   public:
+    inline js::NumberObject *asNumber();
     inline js::StringObject *asString();
 
     /*
      * Array-specific getters and setters (for both dense and slow arrays).
      */
 
     inline uint32 getArrayLength() const;
     inline void setArrayLength(JSContext *cx, uint32 length);
--- a/js/src/jsweakmap.cpp
+++ b/js/src/jsweakmap.cpp
@@ -44,16 +44,18 @@
 #include "jscntxt.h"
 #include "jsgc.h"
 #include "jshashtable.h"
 #include "jsobj.h"
 #include "jsgc.h"
 #include "jsgcmark.h"
 #include "jsweakmap.h"
 
+#include "vm/GlobalObject.h"
+
 #include "jsgcinlines.h"
 #include "jsobjinlines.h"
 
 using namespace js;
 
 namespace js {
 
 bool
@@ -285,17 +287,32 @@ static JSFunctionSpec weak_map_methods[]
     JS_FN("delete", WeakMap_delete, 1, 0),
     JS_FN("set",    WeakMap_set, 2, 0),
     JS_FS_END
 };
 
 JSObject *
 js_InitWeakMapClass(JSContext *cx, JSObject *obj)
 {
-    JSObject *proto = js_InitClass(cx, obj, NULL, &WeakMapClass, WeakMap_construct, 0,
-                                   NULL, weak_map_methods, NULL, NULL);
-    if (!proto)
+    JS_ASSERT(obj->isNative());
+
+    GlobalObject *global = obj->asGlobal();
+
+    JSObject *weakMapProto = global->createBlankPrototype(cx, &WeakMapClass);
+    if (!weakMapProto)
+        return NULL;
+    weakMapProto->setPrivate(NULL);
+
+    JSFunction *ctor = global->createConstructor(cx, WeakMap_construct, &WeakMapClass,
+                                                 CLASS_ATOM(cx, WeakMap), 0);
+    if (!ctor)
         return NULL;
 
-    proto->setPrivate(NULL);
+    if (!LinkConstructorAndPrototype(cx, ctor, weakMapProto))
+        return NULL;
 
-    return proto;
+    if (!DefinePropertiesAndBrand(cx, weakMapProto, NULL, weak_map_methods))
+        return NULL;
+
+    if (!DefineConstructorAndPrototype(cx, global, JSProto_WeakMap, ctor, weakMapProto))
+        return NULL;
+    return weakMapProto;
 }
new file mode 100644
--- /dev/null
+++ b/js/src/vm/NumberObject-inl.h
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ * vim: set ts=8 sw=4 et tw=78:
+ *
+ * ***** 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 SpiderMonkey string object code.
+ *
+ * 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):
+ *   Jeff Walden <jwalden+code@mit.edu> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of 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 ***** */
+
+#ifndef NumberObject_inl_h___
+#define NumberObject_inl_h___
+
+#include "NumberObject.h"
+
+inline js::NumberObject *
+JSObject::asNumber()
+{
+    JS_ASSERT(isNumber());
+    return static_cast<js::NumberObject *>(const_cast<JSObject *>(this));
+}
+
+namespace js {
+
+inline NumberObject *
+NumberObject::create(JSContext *cx, jsdouble d)
+{
+    JSObject *obj = NewBuiltinClassInstance(cx, &NumberClass);
+    if (!obj)
+        return NULL;
+    NumberObject *numobj = obj->asNumber();
+    numobj->setPrimitiveValue(d);
+    return numobj;
+}
+
+inline NumberObject *
+NumberObject::createWithProto(JSContext *cx, jsdouble d, JSObject &proto)
+{
+    JSObject *obj = NewObjectWithClassProto(cx, &NumberClass, &proto,
+                                            gc::GetGCObjectKind(RESERVED_SLOTS));
+    if (!obj)
+        return NULL;
+    NumberObject *numobj = obj->asNumber();
+    numobj->setPrimitiveValue(d);
+    return numobj;
+}
+
+} // namespace js
+
+#endif /* NumberObject_inl_h__ */
new file mode 100644
--- /dev/null
+++ b/js/src/vm/NumberObject.h
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ * vim: set ts=8 sw=4 et tw=78:
+ *
+ * ***** 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 SpiderMonkey string object code.
+ *
+ * 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):
+ *   Jeff Walden <jwalden+code@mit.edu> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of 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 ***** */
+
+#ifndef NumberObject_h___
+#define NumberObject_h___
+
+#include "jsnum.h"
+
+namespace js {
+
+class NumberObject : public ::JSObject
+{
+    /* Stores this Number object's [[PrimitiveValue]]. */
+    static const uintN PRIMITIVE_VALUE_SLOT = 0;
+
+  public:
+    static const uintN RESERVED_SLOTS = 1;
+
+    /*
+     * Creates a new Number object boxing the given number.  The object's
+     * [[Prototype]] is determined from context.
+     */
+    static inline NumberObject *create(JSContext *cx, jsdouble d);
+
+    /*
+     * Identical to create(), but uses |proto| as [[Prototype]].  This method
+     * must not be used to create |Number.prototype|.
+     */
+    static inline NumberObject *createWithProto(JSContext *cx, jsdouble d, JSObject &proto);
+
+    Value unbox() const {
+        JS_ASSERT(getSlot(PRIMITIVE_VALUE_SLOT).isNumber());
+        return getSlot(PRIMITIVE_VALUE_SLOT);
+    }
+
+  private:
+    inline void setPrimitiveValue(jsdouble d) {
+        setSlot(PRIMITIVE_VALUE_SLOT, NumberValue(d));
+    }
+
+    /* For access to init, as Number.prototype is special. */
+    friend JSObject *
+    ::js_InitNumberClass(JSContext *cx, JSObject *global);
+
+  private:
+    NumberObject();
+    NumberObject &operator=(const NumberObject &so);
+};
+
+} // namespace js
+
+#endif /* NumberObject_h__ */
--- a/mobile/modules/contacts.jsm
+++ b/mobile/modules/contacts.jsm
@@ -33,18 +33,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 let EXPORTED_SYMBOLS = ["Contacts"];
 
 const Cu = Components.utils;
 
-Cu.import("resource://gre/modules/ctypes.jsm");
-
 let Contacts = {
   _providers: [],
   _contacts: [],
 
   _load: function _load() {
     this._contacts = [];
 
     this._providers.forEach(function(provider) {
@@ -83,16 +81,17 @@ let Contacts = {
     }
     return results;
   }
 };
 
 #ifndef ANDROID
 #ifndef XP_MACOSX
 #ifdef XP_UNIX
+Cu.import("resource://gre/modules/ctypes.jsm");
 Cu.import("resource:///modules/linuxTypes.jsm");
 
 function EBookProvider() {
   EBook.init();
 }
 
 EBookProvider.prototype = {
   getContacts: function() {
--- a/mobile/themes/core/honeycomb/browser.css
+++ b/mobile/themes/core/honeycomb/browser.css
@@ -372,18 +372,19 @@ toolbarbutton.urlbar-button {
   -moz-transform: translateY(0.45em);
   -moz-padding-end: 32px; /* correct position and alignment */
 }
 
 #tool-tabs .toolbarbutton-text {
   color: @color_text_toolbutton_inverse@;
   display: -moz-box;
   font-size: @font_small@ !important;
-  -moz-transform: translateY(-0.56em);
-  -moz-padding-end: 33px; /* correct position and alignment */
+  font-weight: bold !important;
+  -moz-transform: translateY(-0.50em);
+  -moz-padding-end: 32px; /* correct position and alignment */
 }
 
 #tool-menu {
   list-style-image: url("chrome://browser/skin/images/menu-hdpi.png");
   -moz-margin-end: 0px;
 }
 
 .tool-star {
--- a/testing/mochitest/specialpowers/content/specialpowers.js
+++ b/testing/mochitest/specialpowers/content/specialpowers.js
@@ -413,16 +413,22 @@ SpecialPowers.prototype = {
 
   getNodeBaseURIObject: function(aNode) {
       return aNode.baseURIObject;
   },
 
   getDocumentURIObject: function(aDocument) {
       return aDocument.documentURIObject;
   },
+
+  copyString: function(str) {
+    Cc["@mozilla.org/widget/clipboardhelper;1"].
+      getService(Ci.nsIClipboardHelper).
+      copyString(str);
+  },
 };
 
 // Expose everything but internal APIs (starting with underscores) to
 // web content.
 SpecialPowers.prototype.__exposedProps__ = {};
 for each (i in Object.keys(SpecialPowers.prototype).filter(function(v) {return v.charAt(0) != "_";})) {
   SpecialPowers.prototype.__exposedProps__[i] = "r";
 }
--- a/toolkit/components/aboutmemory/content/aboutMemory.js
+++ b/toolkit/components/aboutmemory/content/aboutMemory.js
@@ -274,23 +274,34 @@ function getReportersByProcess()
       reporters[r._path] = r;
     }
   }
 
   // Process vanilla reporters first, then multi-reporters.
   var e = mgr.enumerateReporters();
   while (e.hasMoreElements()) {
     var rOrig = e.getNext().QueryInterface(Ci.nsIMemoryReporter);
-    addReporter(rOrig.process, rOrig.path, rOrig.kind, rOrig.units,
-                rOrig.amount, rOrig.description);
+    try {
+      addReporter(rOrig.process, rOrig.path, rOrig.kind, rOrig.units,
+                  rOrig.amount, rOrig.description);
+    }
+    catch(e) {
+      debug("An error occurred when collecting results from the memory reporter " +
+            rOrig.path + ": " + e);
+    }
   }
   var e = mgr.enumerateMultiReporters();
   while (e.hasMoreElements()) {
     var mrOrig = e.getNext().QueryInterface(Ci.nsIMemoryMultiReporter);
-    mrOrig.collectReports(addReporter, null);
+    try {
+      mrOrig.collectReports(addReporter, null);
+    }
+    catch(e) {
+      debug("An error occurred when collecting a multi-reporter's results: " + e);
+    }
   }
 
   return reportersByProcess;
 }
 
 /**
  * Top-level function that does the work of generating the page.
  */
@@ -1068,9 +1079,8 @@ function assert(aCond, aMsg)
 
 function debug(x)
 {
   var content = $("content");
   var div = document.createElement("div");
   div.innerHTML = JSON.stringify(x);
   content.appendChild(div);
 }
-
--- a/toolkit/components/passwordmgr/nsLoginManager.js
+++ b/toolkit/components/passwordmgr/nsLoginManager.js
@@ -283,20 +283,28 @@ LoginManager.prototype = {
                 return;
 
             var domWin = aWebProgress.DOMWindow;
             var domDoc = domWin.document;
 
             // Only process things which might have HTML forms.
             if (!(domDoc instanceof Ci.nsIDOMHTMLDocument))
                 return;
-
-            this._pwmgr.log("onStateChange accepted: req = " +
-                            (aRequest ?  aRequest.name : "(null)") +
-                            ", flags = 0x" + aStateFlags.toString(16));
+            if (this._pwmgr._debug) {
+                let requestName = "(null)";
+                if (aRequest) {
+                    try {
+                        requestName = aRequest.name;
+                    } catch (ex if ex.result == Components.results.NS_ERROR_NOT_IMPLEMENTED) {
+                        // do nothing - leave requestName = "(null)"
+                    }
+                }
+                this._pwmgr.log("onStateChange accepted: req = " + requestName +
+                                ", flags = 0x" + aStateFlags.toString(16));
+            }
 
             // Fastback doesn't fire DOMContentLoaded, so process forms now.
             if (aStateFlags & Ci.nsIWebProgressListener.STATE_RESTORING) {
                 this._pwmgr.log("onStateChange: restoring document");
                 return this._pwmgr._fillDocument(domDoc);
             }
 
             // Add event listener to process page when DOM is complete.
--- a/toolkit/crashreporter/client/crashreporter_win.cpp
+++ b/toolkit/crashreporter/client/crashreporter_win.cpp
@@ -442,17 +442,18 @@ static DWORD WINAPI SendThreadProc(LPVOI
 
   return 0;
 }
 
 static void EndCrashReporterDialog(HWND hwndDlg, int code)
 {
   // Save the current values to the registry
   wchar_t email[MAX_EMAIL_LENGTH];
-  GetDlgItemText(hwndDlg, IDC_EMAILTEXT, email, sizeof(email));
+  GetDlgItemTextW(hwndDlg, IDC_EMAILTEXT, email,
+                  sizeof(email) / sizeof(email[0]));
   SetStringKey(gCrashReporterKey.c_str(), EMAIL_VALUE, email);
 
   SetBoolKey(gCrashReporterKey.c_str(), INCLUDE_URL_VALUE,
              IsDlgButtonChecked(hwndDlg, IDC_INCLUDEURLCHECK) != 0);
   SetBoolKey(gCrashReporterKey.c_str(), EMAIL_ME_VALUE,
              IsDlgButtonChecked(hwndDlg, IDC_EMAILMECHECK) != 0);
   SetBoolKey(gCrashReporterKey.c_str(), SUBMIT_REPORT_VALUE,
              IsDlgButtonChecked(hwndDlg, IDC_SUBMITREPORTCHECK) != 0);
@@ -585,30 +586,32 @@ static void UpdateURL(HWND hwndDlg)
     gQueryParameters.erase(L"URL");
   }
 }
 
 static void UpdateEmail(HWND hwndDlg)
 {
   if (IsDlgButtonChecked(hwndDlg, IDC_EMAILMECHECK)) {
     wchar_t email[MAX_EMAIL_LENGTH];
-    GetDlgItemText(hwndDlg, IDC_EMAILTEXT, email, sizeof(email));
+    GetDlgItemTextW(hwndDlg, IDC_EMAILTEXT, email,
+                    sizeof(email) / sizeof(email[0]));
     gQueryParameters[L"Email"] = email;
     if (IsDlgButtonChecked(hwndDlg, IDC_SUBMITREPORTCHECK))
       EnableWindow(GetDlgItem(hwndDlg, IDC_EMAILTEXT), true);
   } else {
     gQueryParameters.erase(L"Email");
     EnableWindow(GetDlgItem(hwndDlg, IDC_EMAILTEXT), false);
   }
 }
 
 static void UpdateComment(HWND hwndDlg)
 {
   wchar_t comment[MAX_COMMENT_LENGTH + 1];
-  GetDlgItemText(hwndDlg, IDC_COMMENTTEXT, comment, sizeof(comment));
+  GetDlgItemTextW(hwndDlg, IDC_COMMENTTEXT, comment,
+                  sizeof(comment) / sizeof(comment[0]));
   if (wcslen(comment) > 0)
     gQueryParameters[L"Comments"] = comment;
   else
     gQueryParameters.erase(L"Comments");
 }
 
 /*
  * Dialog procedure for the "view report" dialog.