diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/debian/changelog firefox-trunk-13.0~a1~hg20120222r87313/debian/changelog --- firefox-trunk-13.0~a1~hg20120221r87204/debian/changelog 2012-02-22 03:49:32.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/debian/changelog 2012-02-22 03:50:39.000000000 +0000 @@ -1,4 +1,4 @@ -firefox-trunk (13.0~a1~hg20120221r87204-0ubuntu1~umd2~natty) natty; urgency=low +firefox-trunk (13.0~a1~hg20120222r87313-0ubuntu1~umd1~natty) natty; urgency=low [ Chris Coulson ] * Update globalmenu-extension to 2.5 prerelease r276 @@ -16,6 +16,7 @@ - update debian/patches/change-moz-app-name.patch - update debian/patches/ubuntu-codes-google.patch - update debian/patches/revert-bmo621446-investigation.patch + - update debian/patches/use-new-yasm-in-lucid.patch * Clean up the file exclude list and add comments for excluded files - update debian/build/create-tarball.py * Make it easy to run Firefox in valgrind for builds that are compiled @@ -27,7 +28,7 @@ - update debian/usr.bin.firefox.apparmor.10.04 - update debian/usr.bin.firefox.apparmor.10.10 - -- Chris Coulson Tue, 21 Feb 2012 16:09:33 +0000 + -- Chris Coulson Tue, 21 Feb 2012 21:00:07 +0000 firefox-trunk (12.0~a1~hg20120131r85707-0ubuntu1) precise; urgency=low diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/debian/patches/use-new-yasm-in-lucid.patch firefox-trunk-13.0~a1~hg20120222r87313/debian/patches/use-new-yasm-in-lucid.patch --- firefox-trunk-13.0~a1~hg20120221r87204/debian/patches/use-new-yasm-in-lucid.patch 2012-02-22 03:49:32.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/debian/patches/use-new-yasm-in-lucid.patch 2012-02-22 03:50:39.000000000 +0000 @@ -2,9 +2,11 @@ Author: Chris Coulson Forwarded: not-needed ---- a/configure.in -+++ b/configure.in -@@ -4735,7 +4735,7 @@ dnl Detect yasm +Index: mozilla/configure.in +=================================================================== +--- mozilla.orig/configure.in 2012-02-21 02:03:59.000000000 +0000 ++++ mozilla/configure.in 2012-02-21 21:23:28.896760911 +0000 +@@ -4403,7 +4403,7 @@ dnl ====================== AC_MSG_CHECKING([for YASM assembler]) @@ -13,7 +15,7 @@ if test -n "$YASM"; then dnl Pull out yasm's version string -@@ -4743,7 +4743,7 @@ if test -n "$YASM"; then +@@ -4411,7 +4411,7 @@ _YASM_VER_FILTER='s|.* \([0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\).*|\1|p' changequote([,]) @@ -22,12 +24,38 @@ _YASM_MAJOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $1 }'` _YASM_MINOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $2 }'` _YASM_RELEASE=` echo ${YASM_VERSION} | $AWK -F\. '{ print $3 }'` -@@ -6425,7 +6425,7 @@ dnl --disable-libjpeg-turbo wasn't passe - dnl doesn't exist or we have too old of a version. +@@ -6235,7 +6235,7 @@ + dnl it doesn't exist or we have too old of a version. if test -n "$LIBJPEG_TURBO_X86_ASM" -o -n "$LIBJPEG_TURBO_X64_ASM" ; then - AC_MSG_CHECKING([for YASM assembler]) + AC_MSG_CHECKING([for Yasm assembler]) - AC_CHECK_PROGS(LIBJPEG_TURBO_AS, yasm, "") + AC_CHECK_PROGS(LIBJPEG_TURBO_AS, yasm-1, "") if test -z "$LIBJPEG_TURBO_AS" ; then - AC_MSG_ERROR([yasm is required to build with libjpeg-turbo's optimized JPEG decoding routines, but you do not appear to have yasm installed. Either install it or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder. See https://developer.mozilla.org/en/YASM for more details.]) + AC_MSG_ERROR([Yasm is required to build with libjpeg-turbo's optimized JPEG decoding routines, but you do not appear to have Yasm installed. Either install it or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder. See https://developer.mozilla.org/en/YASM for more details.]) +Index: mozilla/config/config.mk +=================================================================== +--- mozilla.orig/config/config.mk 2012-02-21 02:03:58.000000000 +0000 ++++ mozilla/config/config.mk 2012-02-21 21:23:28.896760911 +0000 +@@ -176,7 +176,7 @@ + endif + + ifneq (,$(MOZ_DEBUG)$(MOZ_DEBUG_SYMBOLS)) +- ifeq ($(AS),yasm) ++ ifeq ($(AS),yasm-1) + ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_) + _DEBUG_ASFLAGS += -g cv8 + else +Index: mozilla/js/src/config/config.mk +=================================================================== +--- mozilla.orig/js/src/config/config.mk 2012-02-21 21:26:52.224757298 +0000 ++++ mozilla/js/src/config/config.mk 2012-02-21 21:27:13.112756927 +0000 +@@ -176,7 +176,7 @@ + endif + + ifneq (,$(MOZ_DEBUG)$(MOZ_DEBUG_SYMBOLS)) +- ifeq ($(AS),yasm) ++ ifeq ($(AS),yasm-1) + ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_) + _DEBUG_ASFLAGS += -g cv8 + else diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/src/base/Makefile.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/src/base/Makefile.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/src/base/Makefile.in 2012-02-21 02:03:18.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/src/base/Makefile.in 2012-02-22 02:03:33.000000000 +0000 @@ -76,6 +76,7 @@ nsTextAccessible.cpp \ nsTextEquivUtils.cpp \ nsTextAttrs.cpp \ + StyleInfo.cpp \ TextUpdater.cpp \ $(NULL) @@ -107,6 +108,7 @@ -I$(srcdir)/../html \ -I$(srcdir)/../xul \ -I$(srcdir)/../../../layout/generic \ + -I$(srcdir)/../../../layout/style \ -I$(srcdir)/../../../layout/xul/base/src \ -I$(srcdir)/../xforms \ $(NULL) diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/src/base/nsAccessible.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/src/base/nsAccessible.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/src/base/nsAccessible.cpp 2012-02-21 02:03:18.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/src/base/nsAccessible.cpp 2012-02-22 02:03:33.000000000 +0000 @@ -44,19 +44,18 @@ #include "AccGroupInfo.h" #include "AccIterator.h" #include "nsAccUtils.h" -#include "nsDocAccessible.h" -#include "nsEventShell.h" - #include "nsAccEvent.h" #include "nsAccessibleRelation.h" #include "nsAccessibilityService.h" #include "nsAccTreeWalker.h" #include "nsIAccessibleRelation.h" +#include "nsEventShell.h" #include "nsRootAccessible.h" #include "nsTextEquivUtils.h" #include "Relation.h" #include "Role.h" #include "States.h" +#include "StyleInfo.h" #include "nsIDOMCSSValue.h" #include "nsIDOMCSSPrimitiveValue.h" @@ -852,7 +851,9 @@ // Get accessible for the node with the point or the first accessible in // the DOM parent chain. - nsAccessible* accessible = accDocument->GetAccessibleOrContainer(content); + nsDocAccessible* contentDocAcc = GetAccService()-> + GetDocAccessible(content->OwnerDoc()); + nsAccessible* accessible = contentDocAcc->GetAccessibleOrContainer(content); if (!accessible) return fallbackAnswer; @@ -1442,49 +1443,40 @@ startContent = parentDoc->FindContentForSubDocument(doc); } - // Expose 'display' attribute. + if (!mContent->IsElement()) + return NS_OK; + + // CSS style based object attributes. nsAutoString value; - nsresult rv = GetComputedStyleValue(EmptyString(), - NS_LITERAL_STRING("display"), - value); - if (NS_SUCCEEDED(rv)) - nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::display, value); + StyleInfo styleInfo(mContent->AsElement(), mDoc->PresShell()); + + // Expose 'display' attribute. + styleInfo.Display(value); + nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::display, value); // Expose 'text-align' attribute. - rv = GetComputedStyleValue(EmptyString(), NS_LITERAL_STRING("text-align"), - value); - if (NS_SUCCEEDED(rv)) - nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textAlign, value); + styleInfo.TextAlign(value); + nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textAlign, value); // Expose 'text-indent' attribute. - rv = GetComputedStyleValue(EmptyString(), NS_LITERAL_STRING("text-indent"), - value); - if (NS_SUCCEEDED(rv)) - nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textIndent, value); + styleInfo.TextIndent(value); + nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textIndent, value); // Expose 'margin-left' attribute. - rv = GetComputedStyleValue(EmptyString(), NS_LITERAL_STRING("margin-left"), - value); - if (NS_SUCCEEDED(rv)) - nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::marginLeft, value); + styleInfo.MarginLeft(value); + nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::marginLeft, value); // Expose 'margin-right' attribute. - rv = GetComputedStyleValue(EmptyString(), NS_LITERAL_STRING("margin-right"), - value); - if (NS_SUCCEEDED(rv)) - nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::marginRight, value); + styleInfo.MarginRight(value); + nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::marginRight, value); // Expose 'margin-top' attribute. - rv = GetComputedStyleValue(EmptyString(), NS_LITERAL_STRING("margin-top"), - value); - if (NS_SUCCEEDED(rv)) - nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::marginTop, value); + styleInfo.MarginTop(value); + nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::marginTop, value); // Expose 'margin-bottom' attribute. - rv = GetComputedStyleValue(EmptyString(), NS_LITERAL_STRING("margin-bottom"), - value); - if (NS_SUCCEEDED(rv)) - nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::marginBottom, value); + styleInfo.MarginBottom(value); + nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::marginBottom, value); // Expose draggable object attribute? nsCOMPtr htmlElement = do_QueryInterface(mContent); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/src/base/StyleInfo.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/src/base/StyleInfo.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/src/base/StyleInfo.cpp 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/src/base/StyleInfo.cpp 2012-02-22 02:03:33.000000000 +0000 @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:expandtab:shiftwidth=2:tabstop=2: */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2012 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Alexander Surkov (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 ***** */ + +#include "StyleInfo.h" + +#include "mozilla/dom/Element.h" +#include "nsComputedDOMStyle.h" + +using namespace mozilla; +using namespace mozilla::a11y; + +StyleInfo::StyleInfo(dom::Element* aElement, nsIPresShell* aPresShell) : + mElement(aElement) +{ + mStyleContext = + nsComputedDOMStyle::GetStyleContextForElementNoFlush(aElement, + nsnull, + aPresShell); +} + +void +StyleInfo::Display(nsAString& aValue) +{ + aValue.Truncate(); + AppendASCIItoUTF16( + nsCSSProps::ValueToKeyword(mStyleContext->GetStyleDisplay()->mDisplay, + nsCSSProps::kDisplayKTable), aValue); +} + +void +StyleInfo::TextAlign(nsAString& aValue) +{ + aValue.Truncate(); + AppendASCIItoUTF16( + nsCSSProps::ValueToKeyword(mStyleContext->GetStyleText()->mTextAlign, + nsCSSProps::kTextAlignKTable), aValue); +} + +void +StyleInfo::TextIndent(nsAString& aValue) +{ + aValue.Truncate(); + + const nsStyleCoord& styleCoord = + mStyleContext->GetStyleText()->mTextIndent; + + nscoord coordVal; + switch (styleCoord.GetUnit()) { + case eStyleUnit_Coord: + coordVal = styleCoord.GetCoordValue(); + break; + + case eStyleUnit_Percent: + { + nsIFrame* frame = mElement->GetPrimaryFrame(); + nsIFrame* containerFrame = frame->GetContainingBlock(); + nscoord percentageBase = containerFrame->GetContentRect().width; + coordVal = NSCoordSaturatingMultiply(percentageBase, + styleCoord.GetPercentValue()); + break; + } + } + + aValue.AppendFloat(nsPresContext::AppUnitsToFloatCSSPixels(coordVal)); + aValue.AppendLiteral("px"); +} + +void +StyleInfo::Margin(css::Side aSide, nsAString& aValue) +{ + aValue.Truncate(); + + nscoord coordVal = mElement->GetPrimaryFrame()->GetUsedMargin().Side(aSide); + aValue.AppendFloat(nsPresContext::AppUnitsToFloatCSSPixels(coordVal)); + aValue.AppendLiteral("px"); +} diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/src/base/StyleInfo.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/src/base/StyleInfo.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/src/base/StyleInfo.h 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/src/base/StyleInfo.h 2012-02-22 02:03:33.000000000 +0000 @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:expandtab:shiftwidth=2:tabstop=2: */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2012 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Alexander Surkov (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 _mozilla_a11y_style_h_ +#define _mozilla_a11y_style_h_ + +#include "mozilla/gfx/Types.h" +#include "nsStyleContext.h" + +namespace mozilla { +namespace a11y { + +class StyleInfo +{ +public: + StyleInfo(dom::Element* aElement, nsIPresShell* aPresShell); + ~StyleInfo() { }; + + void Display(nsAString& aValue); + void TextAlign(nsAString& aValue); + void TextIndent(nsAString& aValue); + void MarginLeft(nsAString& aValue) { Margin(css::eSideLeft, aValue); } + void MarginRight(nsAString& aValue) { Margin(css::eSideRight, aValue); } + void MarginTop(nsAString& aValue) { Margin(css::eSideTop, aValue); } + void MarginBottom(nsAString& aValue) { Margin(css::eSideBottom, aValue); } + +private: + StyleInfo() MOZ_DELETE; + StyleInfo(const StyleInfo&) MOZ_DELETE; + StyleInfo& operator = (const StyleInfo&) MOZ_DELETE; + + void Margin(css::Side aSide, nsAString& aValue); + + dom::Element* mElement; + nsRefPtr mStyleContext; +}; + +} // namespace a11y +} // namespace mozilla + +#endif diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/attributes/Makefile.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/attributes/Makefile.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/attributes/Makefile.in 2012-02-21 02:03:19.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/attributes/Makefile.in 2012-02-22 02:03:34.000000000 +0000 @@ -48,6 +48,7 @@ _TEST_FILES =\ test_obj.html \ test_obj_css.html \ + test_obj_css.xul \ test_obj_group.html \ test_obj_group.xul \ test_obj_group_tree.xul \ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/attributes/test_obj_css.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/attributes/test_obj_css.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/attributes/test_obj_css.html 2012-02-21 02:03:19.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/attributes/test_obj_css.html 2012-02-22 02:03:34.000000000 +0000 @@ -18,36 +18,65 @@ src="../attributes.js"> + + + + + Mozilla Bug 714579 +
+ +

+ +
+    
+ + + + + + + + + + + + + + +
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/attributes.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/attributes.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/attributes.js 2012-02-21 02:03:19.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/attributes.js 2012-02-22 02:03:34.000000000 +0000 @@ -28,6 +28,26 @@ } /** + * Test CSS based object attributes. + */ +function testCSSAttrs(aID) +{ + var node = document.getElementById(aID); + var computedStyle = document.defaultView.getComputedStyle(node, ""); + + var attrs = { + "display": computedStyle.display, + "text-align": computedStyle.textAlign, + "text-indent": computedStyle.textIndent, + "margin-left": computedStyle.marginLeft, + "margin-right": computedStyle.marginRight, + "margin-top": computedStyle.marginTop, + "margin-bottom": computedStyle.marginBottom + }; + testAttrs(aID, attrs, true); +} + +/** * Test group object attributes (posinset, setsize and level) and * nsIAccessible::groupPosition() method. * diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/hittest/Makefile.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/hittest/Makefile.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/hittest/Makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/hittest/Makefile.in 2012-02-22 02:03:35.000000000 +0000 @@ -0,0 +1,55 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Mozilla Foundation. +# Portions created by the Initial Developer are Copyright (C) 2012 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Hubert Figuière +# +# 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 ***** + +DEPTH = ../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +relativesrcdir = accessible/hittest + +include $(DEPTH)/config/autoconf.mk +include $(topsrcdir)/config/rules.mk + +_TEST_FILES = \ + test_general.html \ + test_general.xul \ + test_browser.html \ + $(NULL) + +libs:: $(_TEST_FILES) + $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/a11y/$(relativesrcdir) diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/hittest/test_browser.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/hittest/test_browser.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/hittest/test_browser.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/hittest/test_browser.html 2012-02-22 02:03:35.000000000 +0000 @@ -0,0 +1,64 @@ + + + + nsIAccessible::childAtPoint() from browser tests + + + + + + + + + + + + Mozilla Bug 726097 + +
+
imgitem
+
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/hittest/test_general.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/hittest/test_general.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/hittest/test_general.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/hittest/test_general.html 2012-02-22 02:03:35.000000000 +0000 @@ -0,0 +1,89 @@ + + + + nsIAccessible::childAtPoint() tests + + + + + + + + + + + + Mozilla Bug 491657 +

+ +
+  
+ +
+
imgitem
+
+ + button1button2 + + textbox1textbox2 + +
+
+
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/hittest/test_general.xul firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/hittest/test_general.xul --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/hittest/test_general.xul 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/hittest/test_general.xul 2012-02-22 02:03:35.000000000 +0000 @@ -0,0 +1,71 @@ + + + + + + + + + + + + Mozilla Bug 471493 +
+

+ +
+      
+ + + + + + + + + +
+ +
+ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/Makefile.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/Makefile.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/Makefile.in 2012-02-21 02:03:19.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/Makefile.in 2012-02-22 02:03:34.000000000 +0000 @@ -49,6 +49,7 @@ elm \ events \ focus \ + hittest \ hyperlink \ hypertext \ name \ @@ -96,8 +97,6 @@ test_aria_roles.xul \ test_aria_token_attrs.html \ test_bug420863.html \ - test_childAtPoint.html \ - test_childAtPoint.xul \ test_descr.html \ test_nsIAccessibleDocument.html \ test_nsIAccessibleImage.html \ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/test_childAtPoint.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/test_childAtPoint.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/test_childAtPoint.html 2012-02-21 02:03:25.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/test_childAtPoint.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ - - - - nsIAccessible::childAtPoint() tests - - - - - - - - - - - - Mozilla Bug 491657 -

- -
-  
- -
-
imgitem
-
- - button1button2 - - textbox1textbox2 - -
-
-
- - - diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/test_childAtPoint.xul firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/test_childAtPoint.xul --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/accessible/tests/mochitest/test_childAtPoint.xul 2012-02-21 02:03:25.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/accessible/tests/mochitest/test_childAtPoint.xul 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ - - - - - - - - - - - - Mozilla Bug 471493 -
-

- -
-      
- - - - - - - - - -
- -
- diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/b2g/installer/package-manifest.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/b2g/installer/package-manifest.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/b2g/installer/package-manifest.in 2012-02-21 02:03:26.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/b2g/installer/package-manifest.in 2012-02-22 02:03:38.000000000 +0000 @@ -151,6 +151,9 @@ @BINPATH@/components/dom_system_b2g.xpt #endif @BINPATH@/components/dom_battery.xpt +#ifdef MOZ_B2G_BT +@BINPATH@/components/dom_bluetooth.xpt +#endif @BINPATH@/components/dom_canvas.xpt @BINPATH@/components/dom_core.xpt @BINPATH@/components/dom_css.xpt diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/base/content/browser-places.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/base/content/browser-places.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/base/content/browser-places.js 2012-02-21 02:03:29.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/base/content/browser-places.js 2012-02-22 02:03:40.000000000 +0000 @@ -562,7 +562,7 @@ undoMenu.removeAttribute("disabled"); // populate menu - var undoItems = eval("(" + this._ss.getClosedTabData(window) + ")"); + var undoItems = JSON.parse(this._ss.getClosedTabData(window)); for (var i = 0; i < undoItems.length; i++) { var m = document.createElement("menuitem"); m.setAttribute("label", undoItems[i].title); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/base/content/browser.xul firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/base/content/browser.xul --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/base/content/browser.xul 2012-02-21 02:03:29.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/base/content/browser.xul 2012-02-22 02:03:41.000000000 +0000 @@ -1055,11 +1055,7 @@ - - - - - + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/base/content/syncSetup.xul firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/base/content/syncSetup.xul --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/base/content/syncSetup.xul 2012-02-21 02:03:29.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/base/content/syncSetup.xul 2012-02-22 02:03:42.000000000 +0000 @@ -195,7 +195,7 @@ oncommand="gSyncSetup.onServerCommand()" oninput="gSyncSetup.onServerInput()"> - @@ -335,7 +335,7 @@ oncommand="gSyncSetup.onExistingServerCommand()" oninput="gSyncSetup.onExistingServerInput()"> - diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/components/nsBrowserContentHandler.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/components/nsBrowserContentHandler.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/components/nsBrowserContentHandler.js 2012-02-21 02:03:34.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/components/nsBrowserContentHandler.js 2012-02-22 02:03:45.000000000 +0000 @@ -52,7 +52,6 @@ const nsIDOMChromeWindow = Components.interfaces.nsIDOMChromeWindow; const nsIDOMWindow = Components.interfaces.nsIDOMWindow; const nsIFileURL = Components.interfaces.nsIFileURL; -const nsIHttpProtocolHandler = Components.interfaces.nsIHttpProtocolHandler; const nsIInterfaceRequestor = Components.interfaces.nsIInterfaceRequestor; const nsINetUtil = Components.interfaces.nsINetUtil; const nsIPrefBranch = Components.interfaces.nsIPrefBranch; @@ -65,13 +64,12 @@ const nsIWebNavigationInfo = Components.interfaces.nsIWebNavigationInfo; const nsIBrowserSearchService = Components.interfaces.nsIBrowserSearchService; const nsICommandLineValidator = Components.interfaces.nsICommandLineValidator; -const nsIXULAppInfo = Components.interfaces.nsIXULAppInfo; const NS_BINDING_ABORTED = Components.results.NS_BINDING_ABORTED; const NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001; const NS_ERROR_ABORT = Components.results.NS_ERROR_ABORT; -const URI_INHERITS_SECURITY_CONTEXT = nsIHttpProtocolHandler +const URI_INHERITS_SECURITY_CONTEXT = Components.interfaces.nsIHttpProtocolHandler .URI_INHERITS_SECURITY_CONTEXT; function shouldLoadURI(aURI) { @@ -137,16 +135,14 @@ if (savedmstone == "ignore") return OVERRIDE_NONE; - var mstone = Components.classes["@mozilla.org/network/protocol;1?name=http"] - .getService(nsIHttpProtocolHandler).misc; + var mstone = Services.appinfo.platformVersion; var savedBuildID = null; try { savedBuildID = prefb.getCharPref("browser.startup.homepage_override.buildID"); } catch (e) {} - var buildID = Components.classes["@mozilla.org/xre/app-info;1"] - .getService(nsIXULAppInfo).platformBuildID; + var buildID = Services.appinfo.platformBuildID; if (mstone != savedmstone) { // Bug 462254. Previous releases had a default pref to suppress the EULA diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/components/sessionstore/test/browser_526613.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/components/sessionstore/test/browser_526613.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/components/sessionstore/test/browser_526613.js 2012-02-21 02:03:38.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/components/sessionstore/test/browser_526613.js 2012-02-22 02:03:52.000000000 +0000 @@ -64,7 +64,7 @@ let testState = { windows: [ { tabs: [{ entries: [{ url: "http://example.com/" }] }], selected: 1 }, - { tabs: [{ entries: [{ url: "about:robots" }] }], selected: 1 }, + { tabs: [{ entries: [{ url: "about:mozilla" }] }], selected: 1 }, ], // make sure the first window is focused, otherwise when restoring the // old state, the first window is closed and the test harness gets unloaded diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/installer/package-manifest.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/installer/package-manifest.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/installer/package-manifest.in 2012-02-21 02:03:43.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/installer/package-manifest.in 2012-02-22 02:03:58.000000000 +0000 @@ -150,6 +150,9 @@ @BINPATH@/components/dom_system_b2g.xpt #endif @BINPATH@/components/dom_battery.xpt +#ifdef MOZ_B2G_BT +@BINPATH@/components/dom_bluetooth.xpt +#endif @BINPATH@/components/dom_canvas.xpt @BINPATH@/components/dom_core.xpt @BINPATH@/components/dom_css.xpt diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/locales/en-US/chrome/browser/syncSetup.dtd firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/locales/en-US/chrome/browser/syncSetup.dtd --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/locales/en-US/chrome/browser/syncSetup.dtd 2012-02-21 02:03:44.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/locales/en-US/chrome/browser/syncSetup.dtd 2012-02-22 02:03:59.000000000 +0000 @@ -12,7 +12,7 @@ - + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/themes/winstripe/browser.css firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/themes/winstripe/browser.css --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/browser/themes/winstripe/browser.css 2012-02-21 02:03:48.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/browser/themes/winstripe/browser.css 2012-02-22 02:04:04.000000000 +0000 @@ -686,17 +686,22 @@ @navbarLargeIcons@ .toolbarbutton-1 { -moz-appearance: none; padding: 1px 5px; - background: rgba(151,152,153,.05) - -moz-linear-gradient(rgba(251,252,253,.95), rgba(246,247,248,.47) 49%, - rgba(231,232,233,.45) 51%, rgba(225,226,229,.3)); - background-clip: padding-box; + background: hsla(210,48%,90%,.1) + -moz-linear-gradient(rgba(255,255,255,.8), rgba(255,255,255,.45) 49%, + rgba(255,255,255,.35) 51%, rgba(255,255,255,.1)) + padding-box; border-radius: 2.5px; border: 1px solid; - border-color: rgba(0,0,0,.12) rgba(0,0,0,.19) rgba(0,0,0,.38); - box-shadow: 0 0 0 1px rgba(255,255,255,.3) inset, - 0 0 0 2px rgba(255,255,255,.1) inset; + border-color: hsla(210,54%,20%,.13) hsla(210,54%,20%,.16) hsla(210,54%,20%,.2); + box-shadow: 0 1px 0 rgba(255,255,255,.3) inset, + 0 0 0 1px rgba(255,255,255,.3) inset, + 0 1px 0 hsla(210,54%,20%,.02), + /* allows winstripe-keyhole-forward-mask to be used for non-hover as well as hover: */ + 0 0 2px hsla(210,54%,20%,0); color: black; text-shadow: 0 0 2px white; + -moz-transition-property: background-color, border-color, box-shadow; + -moz-transition-duration: 250ms; } @navbarLargeIcons@ .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker { @@ -755,16 +760,13 @@ @navbarLargeIcons@ .toolbarbutton-1 > .toolbarbutton-menubutton-button:not([disabled="true"]):not(:active):hover, @navbarLargeIcons@ .toolbarbutton-1:not([open="true"]):not(:active):hover > .toolbarbutton-menubutton-dropmarker:not([disabled="true"]), -@navbarLargeIcons@ .toolbarbutton-1:not([type="menu-button"]):not([disabled="true"]):not([checked="true"]):not([open="true"]):not(:active):hover, -@navbarLargeIcons@ #back-button:not([disabled="true"]):not([open]):not(:active):hover > .toolbarbutton-icon { - background-color: hsla(190,60%,70%,.5); - border-color: hsla(190,50%,65%,.8) hsla(190,50%,50%,.8) hsla(190,50%,40%,.8); - box-shadow: 0 0 0 1px rgba(255,255,255,.3) inset, - 0 0 0 1.5px rgba(255,255,255,.1) inset, - 0 0 3.5px hsl(190,90%,80%); - -moz-transition: background-color .4s ease-in, - border-color .3s ease-in, - box-shadow .3s ease-in; +@navbarLargeIcons@ .toolbarbutton-1:not([type="menu-button"]):not([disabled="true"]):not([checked="true"]):not([open="true"]):not(:active):hover { + background-color: hsla(210,48%,96%,.75); + border-color: hsla(210,54%,20%,.3) hsla(210,54%,20%,.35) hsla(210,54%,20%,.4); + box-shadow: 0 1px 0 rgba(255,255,255,.3) inset, + 0 0 0 1px rgba(255,255,255,.3) inset, + 0 1px 0 hsla(210,54%,20%,.03), + 0 0 2px hsla(210,54%,20%,.1); } @navbarLargeIcons@ .toolbarbutton-1 > .toolbarbutton-menubutton-button:not([disabled="true"]):hover:active, @@ -773,12 +775,15 @@ @navbarLargeIcons@ .toolbarbutton-1:not([type="menu-button"]):not([disabled="true"]):hover:active, @navbarLargeIcons@ .toolbarbutton-1:not([type="menu-button"])[checked="true"], @navbarLargeIcons@ .toolbarbutton-1[open="true"] { - background-color: transparent; - border-color: rgba(0,0,0,.65) rgba(0,0,0,.55) rgba(0,0,0,.5); - box-shadow: 0 0 6.5px rgba(0,0,0,.4) inset, - 0 0 2px rgba(0,0,0,.4) inset, - 0 1px 0 rgba(255,255,255,.4); + background-color: hsla(210,54%,20%,.2); + border-color: hsla(210,54%,20%,.3) hsla(210,54%,20%,.35) hsla(210,54%,20%,.4); + box-shadow: 0 1px 1px rgba(0,0,0,.1) inset, + 0 0 2px rgba(0,0,0,.3) inset, + /* allows winstripe-keyhole-forward-mask to be used for non-hover as well as hover: */ + 0 1px 0 hsla(210,54%,20%,0), + 0 0 2px hsla(210,54%,20%,0); text-shadow: none; + -moz-transition: none; } @navbarLargeIcons@ .toolbarbutton-1[checked="true"]:not(:active):hover { @@ -904,28 +909,33 @@ border-radius: 10000px; padding: 5px; border: none; - background-image: -moz-linear-gradient(rgba(251,252,253,.97), rgba(246,247,248,.5) 49%, - rgba(231,232,233,.45) 51%, rgba(225,226,229,.2)); - box-shadow: 0 0 0 1px rgba(255,255,255,.3) inset, - 0 0 0 2px rgba(255,255,255,.1) inset, - 0 0 0 1px rgba(0,0,0,.15), - 0 1px 0 rgba(0,0,0,.4); + background: hsla(210,48%,90%,.1) + -moz-linear-gradient(rgba(255,255,255,.88), rgba(255,255,255,.45) 49%, + rgba(255,255,255,.35) 51%, rgba(255,255,255,.67)); + box-shadow: 0 1px 0 rgba(255,255,255,.3) inset, + 0 0 0 1px rgba(255,255,255,.3) inset, + 0 1px 0 hsla(210,54%,20%,.02), + 0 0 0 1px rgba(0,0,0,.15); + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 250ms; } @navbarLargeIcons@ #back-button:not([disabled="true"]):not([open="true"]):not(:active):hover > .toolbarbutton-icon { - box-shadow: 0 0 0 1px rgba(255,255,255,.3) inset, - 0 0 0 2px rgba(255,255,255,.1) inset, - 0 0 0 1px hsla(190,50%,40%,.3), - 0 1px 0 rgba(0,0,0,.4), - 0 0 5px 1px hsl(190,90%,80%); + background-color: hsla(210,48%,96%,.75); + box-shadow: 0 1px 0 rgba(255,255,255,.3) inset, + 0 0 0 1px rgba(255,255,255,.1) inset, + 0 1px 0 hsla(210,54%,20%,.03), + 0 0 0 1px rgba(0,0,0,.2), + 0 0 2px 1px hsla(210,54%,20%,.2); } @navbarLargeIcons@ #back-button:not([disabled="true"]):hover:active > .toolbarbutton-icon, @navbarLargeIcons@ #back-button[open="true"] > .toolbarbutton-icon { - box-shadow: 0 0 6.5px rgba(0,0,0,.4) inset, - 0 0 2px rgba(0,0,0,.4) inset, - 0 0 0 1px rgba(0,0,0,.65), - 0 2px 0 rgba(255,255,255,.4); + background-color: hsla(210,54%,20%,.2); + box-shadow: 0 1px 1px rgba(0,0,0,.1) inset, + 0 0 2px rgba(0,0,0,.3) inset, + 0 0 0 1px rgba(0,0,0,.2); + -moz-transition: none; } @navbarLargeIcons@[currentset*="unified-back-forward-button"], @@ -947,13 +957,6 @@ padding-right: 3px; } -@navbarLargeIcons@ #forward-button:not([disabled="true"]):not(:active):hover { - /*mask: url(keyhole-forward-mask.svg#mask-hover);*/ - mask: url(chrome://browser/content/browser.xul#winstripe-keyhole-forward-mask-hover); - /* Don't animate the box shadow, as the blur and spread radii affect the mask. */ - -moz-transition: background-color .4s ease-in; -} - .unified-nav-back[_moz-menuactive]:-moz-locale-dir(ltr), .unified-nav-forward[_moz-menuactive]:-moz-locale-dir(rtl) { list-style-image: url("chrome://browser/skin/menu-back.png") !important; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/build/mobile/devicemanagerADB.py firefox-trunk-13.0~a1~hg20120222r87313/mozilla/build/mobile/devicemanagerADB.py --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/build/mobile/devicemanagerADB.py 2012-02-21 02:03:50.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/build/mobile/devicemanagerADB.py 2012-02-22 02:04:07.000000000 +0000 @@ -33,7 +33,7 @@ self.verifyRunAs(packageName) except: self.useRunAs = False - self.packageName = None + self.packageName = packageName try: self.verifyZip() except: @@ -684,7 +684,13 @@ if (packageName and self.isCpAvailable() and devroot): tmpDir = self.getTempDir() - self.checkCmd(["shell", "run-as", packageName, "mkdir", devroot + "/sanity"]) + # The problem here is that run-as doesn't cause a non-zero exit code + # when failing because of a non-existent or non-debuggable package :( + runAsOut = self.runCmd(["shell", "run-as", packageName, "mkdir", devroot + "/sanity"]).communicate()[0] + if runAsOut.startswith("run-as:") and ("not debuggable" in runAsOut[0] or + "is unknown" in runAsOut[0]): + raise DMError("run-as failed sanity check") + self.checkCmd(["push", os.path.abspath(sys.argv[0]), tmpDir + "/tmpfile"]) if self.useDDCopy: self.checkCmd(["shell", "run-as", packageName, "dd", "if=" + tmpDir + "/tmpfile", "of=" + devroot + "/sanity/tmpfile"]) diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/build/mobile/devicemanagerSUT.py firefox-trunk-13.0~a1~hg20120222r87313/mozilla/build/mobile/devicemanagerSUT.py --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/build/mobile/devicemanagerSUT.py 2012-02-21 02:03:50.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/build/mobile/devicemanagerSUT.py 2012-02-22 02:04:07.000000000 +0000 @@ -209,17 +209,18 @@ self._sock = None return None + data += temp + # If something goes wrong in the agent it will send back a string that # starts with '##AGENT-ERROR##' - if (self.agentErrorRE.match(temp)): - data = temp + if self.agentErrorRE.match(data): break - data += temp - for line in data.splitlines(): - if (promptre.match(line)): + if promptre.match(line): found = True + data = self._stripPrompt(data) + break # If we violently lose the connection to the device, this loop tends to spin, # this guard prevents that @@ -238,7 +239,7 @@ # internal function # take a data blob and strip instances of the prompt '$>\x00' - def stripPrompt(self, data): + def _stripPrompt(self, data): promptre = re.compile(self.prompt_regex + '.*') retVal = [] lines = data.split('\n') @@ -293,7 +294,7 @@ validated = False if (retVal): - retline = self.stripPrompt(retVal).strip() + retline = retVal.strip() if (retline == None): # Then we failed to get back a hash from agent, try manual validation validated = self.validateFile(destname, localname) @@ -379,11 +380,9 @@ except(DMError): return False - retVal = self.stripPrompt(data) - data = retVal.split('\n') found = False - for d in data: - if (dirre.match(d)): + for d in data.splitlines(): + if (dirre.match(d)): found = True return found @@ -417,8 +416,7 @@ except(DMError): return [] - retVal = self.stripPrompt(data) - files = filter(lambda x: x, retVal.split('\n')) + files = filter(lambda x: x, data.splitlines()) if len(files) == 1 and files[0] == '': # special case on the agent: empty directories return just the string "" return [] @@ -460,11 +458,9 @@ except DMError: return [] - retVal = self.stripPrompt(data) - lines = retVal.split('\n') files = [] - for line in lines: - if (line.strip() != ''): + for line in data.splitlines(): + if line: pidproc = line.strip().split() if (len(pidproc) == 2): files += [[pidproc[0], pidproc[1]]] @@ -552,7 +548,7 @@ except(DMError): return None - return self.stripPrompt(data).strip('\n') + return data.strip() # external function # returns: @@ -564,7 +560,7 @@ except(DMError): return None - return self.stripPrompt(data) + return data # external function # returns: @@ -754,7 +750,8 @@ # return the string ": No such file or directory". # However, I've seen AGENT-WARNING returned before. return False - retVal = self.stripPrompt(data).strip() + + retVal = data.strip() if not retVal: raise FileError('isdir returned null') return retVal == 'TRUE' @@ -787,9 +784,9 @@ except(DMError): return None - retVal = self.stripPrompt(data) - if (retVal != None): - retVal = retVal.strip('\n') + retVal = None + if data: + retVal = data.strip() if (self.debug >= 3): print "remote hash returned: '" + retVal + "'" return retVal @@ -815,8 +812,8 @@ data = self.verifySendCMD(['testroot']) except: return None - - deviceRoot = self.stripPrompt(data).strip('\n') + '/tests' + + deviceRoot = data.strip() + '/tests' if (not self.dirExists(deviceRoot)): if (self.mkDir(deviceRoot) == None): @@ -829,9 +826,8 @@ data = self.verifySendCMD(['getapproot '+packageName]) except: return None - - appRoot = self.stripPrompt(data).strip('\n') - return appRoot + + return data.strip() # external function # returns: @@ -925,7 +921,6 @@ data = self.verifySendCMD(['info ' + d]) if (data is None): continue - data = self.stripPrompt(data) data = collapseSpaces.sub(' ', data) result[d] = data.split('\n') @@ -1055,7 +1050,7 @@ except(DMError): return None - return self.stripPrompt(data).strip('\n') + return data.strip() """ Connect the ipaddress and port for a callback ping. Defaults to current IP address diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/build/unix/build-toolchain/build-gcc.py firefox-trunk-13.0~a1~hg20120222r87313/mozilla/build/unix/build-toolchain/build-gcc.py --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/build/unix/build-toolchain/build-gcc.py 2012-02-21 02:03:55.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/build/unix/build-toolchain/build-gcc.py 2012-02-22 02:04:10.000000000 +0000 @@ -80,10 +80,16 @@ ["--disable-profile", "--enable-add-ons=nptl", "--without-selinux", - "--enable-kernel=2.6.18", + "--enable-kernel=%s" % linux_version, "--libdir=%s/lib64" % inst_dir, "--prefix=%s" % inst_dir]) +def build_linux_headers(inst_dir): + run_in(linux_source_dir, [old_make, "headers_check"]) + run_in(linux_source_dir, [old_make, "INSTALL_HDR_PATH=dest", + "headers_install"]) + shutil.move(linux_source_dir + "/dest", inst_dir) + def build_one_stage(env, stage_dir, is_stage_one): def f(): build_one_stage_aux(stage_dir, is_stage_one) @@ -108,6 +114,7 @@ "--with-mpfr=%s" % lib_inst_dir]) tool_inst_dir = stage_dir + '/inst' + build_linux_headers(tool_inst_dir) binutils_build_dir = stage_dir + '/binutils' build_package(binutils_source_dir, binutils_build_dir, @@ -119,17 +126,15 @@ "--with-gmp=%s" % lib_inst_dir, "--with-mpfr=%s" % lib_inst_dir, "--with-mpc=%s" % lib_inst_dir, + "--enable-languages=c,c++", + "--disable-multilib", "--disable-bootstrap"] if is_stage_one: - gcc_configure_args.append("--enable-languages=c") - gcc_configure_args.append("--disable-multilib") # We build the stage1 gcc without shared libraries. Otherwise its # libgcc.so would depend on the system libc.so, which causes problems # when it tries to use that libgcc.so and the libc we are about to # build. gcc_configure_args.append("--disable-shared") - else: - gcc_configure_args.append("--enable-languages=c,c++") build_package(gcc_source_dir, gcc_build_dir, gcc_configure_args) @@ -155,6 +160,7 @@ binutils_version = "2.21.1" glibc_version = "2.5.1" +linux_version = "2.6.18" tar_version = "1.26" make_version = "3.81" gcc_version = "4.5.2" @@ -166,6 +172,8 @@ binutils_version glibc_source_uri = "http://ftp.gnu.org/gnu/glibc/glibc-%s.tar.bz2" % \ glibc_version +linux_source_uri = "http://www.kernel.org/pub/linux/kernel/v2.6/linux-%s.tar.bz2" % \ + linux_version tar_source_uri = "http://ftp.gnu.org/gnu/tar/tar-%s.tar.bz2" % \ tar_version make_source_uri = "http://ftp.gnu.org/gnu/make/make-%s.tar.bz2" % \ @@ -180,6 +188,7 @@ binutils_source_tar = download_uri(binutils_source_uri) glibc_source_tar = download_uri(glibc_source_uri) +linux_source_tar = download_uri(linux_source_uri) tar_source_tar = download_uri(tar_source_uri) make_source_tar = download_uri(make_source_uri) mpc_source_tar = download_uri(mpc_source_uri) @@ -189,6 +198,7 @@ binutils_source_dir = build_source_dir('binutils-', binutils_version) glibc_source_dir = build_source_dir('glibc-', glibc_version) +linux_source_dir = build_source_dir('linux-', linux_version) tar_source_dir = build_source_dir('tar-', tar_version) make_source_dir = build_source_dir('make-', make_version) mpc_source_dir = build_source_dir('mpc-', mpc_version) @@ -201,6 +211,7 @@ extract(binutils_source_tar, source_dir) patch('binutils-deterministic.patch', 1, binutils_source_dir) extract(glibc_source_tar, source_dir) + extract(linux_source_tar, source_dir) patch('glibc-deterministic.patch', 1, glibc_source_dir) run_in(glibc_source_dir, ["autoconf"]) extract(tar_source_tar, source_dir) diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/build/unix/elfhack/elf.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/build/unix/elfhack/elf.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/build/unix/elfhack/elf.cpp 2012-02-21 02:03:55.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/build/unix/elfhack/elf.cpp 2012-02-22 02:04:10.000000000 +0000 @@ -265,6 +265,15 @@ file.seekg(ehdr->e_phoff); for (int i = 0; i < ehdr->e_phnum; i++) { Elf_Phdr phdr(file, e_ident[EI_CLASS], e_ident[EI_DATA]); + if (phdr.p_type == PT_LOAD) { + // Default alignment for PT_LOAD on x86-64 prevents elfhack from + // doing anything useful. However, the system doesn't actually + // require such a big alignment, so in order for elfhack to work + // efficiently, reduce alignment when it's originally the default + // one. + if ((ehdr->e_machine == EM_X86_64) && (phdr.p_align == 0x200000)) + phdr.p_align = 0x1000; + } ElfSegment *segment = new ElfSegment(&phdr); // Some segments aren't entirely filled (if at all) by sections // For those, we use fake sections @@ -503,12 +512,17 @@ if (previous->getType() != SHT_NOBITS) offset += previous->getSize(); + Elf32_Word align = 0x1000; + for (std::vector::iterator seg = segments.begin(); seg != segments.end(); seg++) + align = std::max(align, (*seg)->getAlign()); + + Elf32_Word mask = align - 1; // SHF_TLS is used for .tbss which is some kind of special case. if (((getType() != SHT_NOBITS) || (getFlags() & SHF_TLS)) && (getFlags() & SHF_ALLOC)) { - if ((getAddr() & 4095) < (offset & 4095)) - offset = (offset | 4095) + (getAddr() & 4095) + 1; + if ((getAddr() & mask) < (offset & mask)) + offset = (offset | mask) + (getAddr() & mask) + 1; else - offset = (offset & ~4095) + (getAddr() & 4095); + offset = (offset & ~mask) + (getAddr() & mask); } if ((getType() != SHT_NOBITS) && (offset & (getAddrAlign() - 1))) offset = (offset | (getAddrAlign() - 1)) + 1; @@ -632,7 +646,7 @@ phdr.p_vaddr = 0; phdr.p_paddr = phdr.p_vaddr + v_p_diff; phdr.p_flags = flags; - phdr.p_align = 0x1000; + phdr.p_align = getAlign(); phdr.p_filesz = (unsigned int)-1; phdr.p_memsz = (unsigned int)-1; ElfSegment *segment = new ElfSegment(&phdr); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/build/unix/elfhack/elfhack.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/build/unix/elfhack/elfhack.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/build/unix/elfhack/elfhack.cpp 2012-02-21 02:03:55.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/build/unix/elfhack/elfhack.cpp 2012-02-22 02:04:10.000000000 +0000 @@ -501,7 +501,7 @@ return rename(name, fname.c_str()); } -void do_file(const char *name, bool backup = false) +void do_file(const char *name, bool backup = false, bool force = false) { std::ifstream file(name, std::ios::in|std::ios::binary); Elf *elf = new Elf(file); @@ -531,7 +531,7 @@ break; } if (exit == 0) { - if (elf->getSize() >= size) { + if (!force && (elf->getSize() >= size)) { fprintf(stderr, "No gain. Skipping\n"); } else if (backup && backup_file(name) != 0) { fprintf(stderr, "Couln't create backup file\n"); @@ -548,14 +548,17 @@ { int arg; bool backup = false; + bool force = false; char *lastSlash = rindex(argv[0], '/'); if (lastSlash != NULL) rundir = strndup(argv[0], lastSlash - argv[0]); for (arg = 1; arg < argc; arg++) { - if (strcmp(argv[arg], "-b") == 0) + if (strcmp(argv[arg], "-f") == 0) + force = true; + else if (strcmp(argv[arg], "-b") == 0) backup = true; else - do_file(argv[arg], backup); + do_file(argv[arg], backup, force); } free(rundir); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/build/unix/elfhack/elfxx.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/build/unix/elfhack/elfxx.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/build/unix/elfhack/elfxx.h 2012-02-21 02:03:55.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/build/unix/elfhack/elfxx.h 2012-02-22 02:04:10.000000000 +0000 @@ -444,7 +444,7 @@ unsigned int getType() { return type; } unsigned int getFlags() { return flags; } - unsigned int getAlign() { return type == PT_LOAD ? 0x1000 : align; /* TODO: remove this gross hack */ } + unsigned int getAlign() { return align; } ElfSection *getFirstSection() { return sections.empty() ? NULL : sections.front(); } int getVPDiff() { return v_p_diff; } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/build/unix/elfhack/Makefile.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/build/unix/elfhack/Makefile.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/build/unix/elfhack/Makefile.in 2012-02-21 02:03:55.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/build/unix/elfhack/Makefile.in 2012-02-22 02:04:10.000000000 +0000 @@ -95,7 +95,7 @@ @echo === --disable-elf-hack until this is fixed. @echo === @rm -f $@.bak - $(CURDIR)/elfhack -b $@ + $(CURDIR)/elfhack -b -f $@ # Fail if the backup file doesn't exist [ -f "$@.bak" ] # Fail if the new library doesn't contain less relocations diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/config/autoconf.mk.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/config/autoconf.mk.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/config/autoconf.mk.in 2012-02-21 02:03:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/config/autoconf.mk.in 2012-02-22 02:04:13.000000000 +0000 @@ -294,6 +294,7 @@ MOZ_NATIVE_NSS = @MOZ_NATIVE_NSS@ MOZ_B2G_RIL = @MOZ_B2G_RIL@ +MOZ_B2G_BT = @MOZ_B2G_BT@ BUILD_CTYPES = @BUILD_CTYPES@ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/config/milestone.pl firefox-trunk-13.0~a1~hg20120222r87313/mozilla/config/milestone.pl --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/config/milestone.pl 2012-02-21 02:03:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/config/milestone.pl 2012-02-22 02:04:14.000000000 +0000 @@ -51,6 +51,7 @@ $MICRO_VERSION $opt_debug $opt_template + $opt_uaversion $opt_help ); @@ -60,7 +61,7 @@ require "Moz/Milestone.pm"; -&GetOptions('topsrcdir=s' => \$TOPSRCDIR, 'srcdir=s' => \$SRCDIR, 'objdir=s' => \$OBJDIR, 'debug', 'help', 'template'); +&GetOptions('topsrcdir=s' => \$TOPSRCDIR, 'srcdir=s' => \$SRCDIR, 'objdir=s' => \$OBJDIR, 'debug', 'help', 'template', 'uaversion'); if (defined($opt_help)) { &usage(); @@ -100,13 +101,19 @@ warn("$0: No such file $TFILE!\n"); } } +} elsif(defined($opt_uaversion)) { + my $uaversion = Moz::Milestone::getMilestoneMajor($milestone) . "." . + Moz::Milestone::getMilestoneMinor($milestone); + # strip off trailing pre-release indicators + $uaversion =~ s/[a-z]+\d*$//; + print "$uaversion\n"; } else { print "$milestone\n"; } sub usage() { print < win = GetWindow(); + win.forget(aDefaultView); + return NS_OK; } NS_IMETHODIMP @@ -8120,7 +8118,7 @@ PRInt32 newHandle = ++mFrameRequestCallbackCounter; bool alreadyRegistered = !mFrameRequestCallbacks.IsEmpty(); - FrameRequest *request = + DebugOnly request = mFrameRequestCallbacks.AppendElement(FrameRequest(aCallback, newHandle)); NS_ASSERTION(request, "This is supposed to be infallible!"); if (!alreadyRegistered && mPresShell && IsEventHandlingEnabled()) { @@ -8303,11 +8301,8 @@ NS_ENSURE_ARG_POINTER(aImage); // Get the old count. It should exist and be > 0. - PRUint32 count; -#ifdef DEBUG - bool found = -#endif - mImageTracker.Get(aImage, &count); + PRUint32 count = 0; + DebugOnly found = mImageTracker.Get(aImage, &count); NS_ABORT_IF_FALSE(found, "Removing image that wasn't in the tracker!"); NS_ABORT_IF_FALSE(count > 0, "Entry in the cache tracker with count 0!"); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/base/src/nsFrameMessageManager.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/base/src/nsFrameMessageManager.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/base/src/nsFrameMessageManager.cpp 2012-02-21 02:04:08.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/base/src/nsFrameMessageManager.cpp 2012-02-22 02:04:15.000000000 +0000 @@ -349,7 +349,8 @@ { public: MMListenerRemover(nsFrameMessageManager* aMM) - : mMM(aMM), mWasHandlingMessage(aMM->mHandlingMessage) + : mWasHandlingMessage(aMM->mHandlingMessage) + , mMM(aMM) { mMM->mHandlingMessage = true; } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/base/src/nsXMLHttpRequest.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/base/src/nsXMLHttpRequest.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/base/src/nsXMLHttpRequest.cpp 2012-02-21 02:04:09.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/base/src/nsXMLHttpRequest.cpp 2012-02-22 02:04:15.000000000 +0000 @@ -1280,8 +1280,10 @@ mState |= aFlag; // If we're in the destructor, don't risk dispatching an event. - if (mState & XML_HTTP_REQUEST_DELETED) + if (mState & XML_HTTP_REQUEST_DELETED) { + mState &= ~XML_HTTP_REQUEST_SYNCLOOPING; return; + } if (!(mState & (XML_HTTP_REQUEST_UNSENT | XML_HTTP_REQUEST_OPENED | @@ -1317,54 +1319,47 @@ return NS_OK; } -/* string getAllResponseHeaders (); */ +/* DOMString getAllResponseHeaders(); */ NS_IMETHODIMP -nsXMLHttpRequest::GetAllResponseHeaders(char **_retval) +nsXMLHttpRequest::GetAllResponseHeaders(nsAString& aResponseHeaders) { - NS_ENSURE_ARG_POINTER(_retval); - *_retval = nsnull; + aResponseHeaders.Truncate(); // If the state is UNSENT or OPENED, // return the empty string and terminate these steps. if (mState & (XML_HTTP_REQUEST_UNSENT | XML_HTTP_REQUEST_OPENED | XML_HTTP_REQUEST_SENT)) { - *_retval = ToNewCString(EmptyString()); return NS_OK; } if (mState & XML_HTTP_REQUEST_USE_XSITE_AC) { - *_retval = ToNewCString(EmptyString()); return NS_OK; } - nsCOMPtr httpChannel = GetCurrentHttpChannel(); - - if (httpChannel) { + if (nsCOMPtr httpChannel = GetCurrentHttpChannel()) { nsRefPtr visitor = new nsHeaderVisitor(); - nsresult rv = httpChannel->VisitResponseHeaders(visitor); - if (NS_SUCCEEDED(rv)) - *_retval = ToNewCString(visitor->Headers()); - } else if (mChannel) { - // Even non-http channels supply content type. - nsCString value; - if (NS_SUCCEEDED(mChannel->GetContentType(value))) { - nsCString headers; - headers.Append("Content-Type: "); - headers.Append(value); - if (NS_SUCCEEDED(mChannel->GetContentCharset(value)) && - !value.IsEmpty()) { - headers.Append(";charset="); - headers.Append(value); - } - headers.Append('\n'); - *_retval = ToNewCString(headers); + if (NS_SUCCEEDED(httpChannel->VisitResponseHeaders(visitor))) { + aResponseHeaders = NS_ConvertUTF8toUTF16(visitor->Headers()); } + return NS_OK; } - if (!*_retval) { - *_retval = ToNewCString(EmptyString()); + if (!mChannel) { + return NS_OK; } + // Even non-http channels supply content type. + nsCAutoString value; + if (NS_SUCCEEDED(mChannel->GetContentType(value))) { + aResponseHeaders.AppendLiteral("Content-Type: "); + aResponseHeaders.Append(NS_ConvertUTF8toUTF16(value)); + if (NS_SUCCEEDED(mChannel->GetContentCharset(value)) && + !value.IsEmpty()) { + aResponseHeaders.AppendLiteral(";charset="); + aResponseHeaders.Append(NS_ConvertUTF8toUTF16(value)); + } + aResponseHeaders.Append('\n'); + } return NS_OK; } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/canvas/src/CustomQS_WebGL.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/canvas/src/CustomQS_WebGL.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/canvas/src/CustomQS_WebGL.h 2012-02-21 02:04:11.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/canvas/src/CustomQS_WebGL.h 2012-02-22 02:04:19.000000000 +0000 @@ -445,7 +445,7 @@ JS_GetProperty(cx, argv5, "data", &js_data); if (js_width == JSVAL_VOID || js_height == JSVAL_VOID || - js_data == JSVAL_VOID) + !js_data.isObject()) { xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 5); return JS_FALSE; @@ -566,7 +566,7 @@ JS_GetProperty(cx, argv6, "data", &js_data); if (js_width == JSVAL_VOID || js_height == JSVAL_VOID || - js_data == JSVAL_VOID) + !js_data.isObject()) { xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 6); return JS_FALSE; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/canvas/src/Makefile.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/canvas/src/Makefile.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/canvas/src/Makefile.in 2012-02-21 02:04:11.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/canvas/src/Makefile.in 2012-02-22 02:04:19.000000000 +0000 @@ -68,6 +68,7 @@ WebGLContext.cpp \ WebGLContextGL.cpp \ WebGLContextUtils.cpp \ + WebGLContextReporter.cpp \ WebGLContextValidate.cpp \ WebGLExtensionStandardDerivatives.cpp \ WebGLExtensionLoseContext.cpp \ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/canvas/src/WebGLContext.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/canvas/src/WebGLContext.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/canvas/src/WebGLContext.cpp 2012-02-21 02:04:11.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/canvas/src/WebGLContext.cpp 2012-02-22 02:04:19.000000000 +0000 @@ -75,133 +75,6 @@ using namespace mozilla::gl; using namespace mozilla::layers; -WebGLMemoryReporter* WebGLMemoryReporter::sUniqueInstance = nsnull; - -NS_MEMORY_REPORTER_IMPLEMENT(WebGLTextureMemoryUsed, - "webgl-texture-memory", - KIND_OTHER, - UNITS_BYTES, - WebGLMemoryReporter::GetTextureMemoryUsed, - "Memory used by WebGL textures. The OpenGL implementation is free to store these textures in either video memory or main memory. This measurement is only a lower bound, actual memory usage may be higher for example if the storage is strided.") - -NS_MEMORY_REPORTER_IMPLEMENT(WebGLTextureCount, - "webgl-texture-count", - KIND_OTHER, - UNITS_COUNT, - WebGLMemoryReporter::GetTextureCount, - "Number of WebGL textures.") - -NS_MEMORY_REPORTER_IMPLEMENT(WebGLBufferMemoryUsed, - "webgl-buffer-memory", - KIND_OTHER, - UNITS_BYTES, - WebGLMemoryReporter::GetBufferMemoryUsed, - "Memory used by WebGL buffers. The OpenGL implementation is free to store these buffers in either video memory or main memory. This measurement is only a lower bound, actual memory usage may be higher for example if the storage is strided.") - -NS_MEMORY_REPORTER_IMPLEMENT(WebGLBufferCacheMemoryUsed, - "explicit/webgl/buffer-cache-memory", - KIND_HEAP, - UNITS_BYTES, - WebGLMemoryReporter::GetBufferCacheMemoryUsed, - "Memory used by WebGL buffer caches. The WebGL implementation caches the contents of element array buffers only. This adds up with the webgl-buffer-memory value, but contrary to it, this one represents bytes on the heap, not managed by OpenGL.") - -NS_MEMORY_REPORTER_IMPLEMENT(WebGLBufferCount, - "webgl-buffer-count", - KIND_OTHER, - UNITS_COUNT, - WebGLMemoryReporter::GetBufferCount, - "Number of WebGL buffers.") - -NS_MEMORY_REPORTER_IMPLEMENT(WebGLRenderbufferMemoryUsed, - "webgl-renderbuffer-memory", - KIND_OTHER, - UNITS_BYTES, - WebGLMemoryReporter::GetRenderbufferMemoryUsed, - "Memory used by WebGL renderbuffers. The OpenGL implementation is free to store these renderbuffers in either video memory or main memory. This measurement is only a lower bound, actual memory usage may be higher for example if the storage is strided.") - -NS_MEMORY_REPORTER_IMPLEMENT(WebGLRenderbufferCount, - "webgl-renderbuffer-count", - KIND_OTHER, - UNITS_COUNT, - WebGLMemoryReporter::GetRenderbufferCount, - "Number of WebGL renderbuffers.") - -NS_MEMORY_REPORTER_IMPLEMENT(WebGLShaderSourcesSize, - "explicit/webgl/shader-sources-size", - KIND_HEAP, - UNITS_BYTES, - WebGLMemoryReporter::GetShaderSourcesSize, - "Combined size of WebGL shader ASCII sources, cached on the heap. This should always be at most a few kilobytes, or dozen kilobytes for very shader-intensive WebGL demos.") - -NS_MEMORY_REPORTER_IMPLEMENT(WebGLShaderTranslationLogsSize, - "explicit/webgl/shader-translationlogs-size", - KIND_HEAP, - UNITS_BYTES, - WebGLMemoryReporter::GetShaderTranslationLogsSize, - "Combined size of WebGL shader ASCII translation logs, cached on the heap.") - -NS_MEMORY_REPORTER_IMPLEMENT(WebGLShaderCount, - "webgl-shader-count", - KIND_OTHER, - UNITS_COUNT, - WebGLMemoryReporter::GetShaderCount, - "Number of WebGL shaders.") - -NS_MEMORY_REPORTER_IMPLEMENT(WebGLContextCount, - "webgl-context-count", - KIND_OTHER, - UNITS_COUNT, - WebGLMemoryReporter::GetContextCount, - "Number of WebGL contexts.") - -WebGLMemoryReporter* WebGLMemoryReporter::UniqueInstance() -{ - if (!sUniqueInstance) { - sUniqueInstance = new WebGLMemoryReporter; - } - return sUniqueInstance; -} - -WebGLMemoryReporter::WebGLMemoryReporter() - : mTextureMemoryUsageReporter(new NS_MEMORY_REPORTER_NAME(WebGLTextureMemoryUsed)) - , mTextureCountReporter(new NS_MEMORY_REPORTER_NAME(WebGLTextureCount)) - , mBufferMemoryUsageReporter(new NS_MEMORY_REPORTER_NAME(WebGLBufferMemoryUsed)) - , mBufferCacheMemoryUsageReporter(new NS_MEMORY_REPORTER_NAME(WebGLBufferCacheMemoryUsed)) - , mBufferCountReporter(new NS_MEMORY_REPORTER_NAME(WebGLBufferCount)) - , mRenderbufferMemoryUsageReporter(new NS_MEMORY_REPORTER_NAME(WebGLRenderbufferMemoryUsed)) - , mRenderbufferCountReporter(new NS_MEMORY_REPORTER_NAME(WebGLRenderbufferCount)) - , mShaderSourcesSizeReporter(new NS_MEMORY_REPORTER_NAME(WebGLShaderSourcesSize)) - , mShaderTranslationLogsSizeReporter(new NS_MEMORY_REPORTER_NAME(WebGLShaderTranslationLogsSize)) - , mShaderCountReporter(new NS_MEMORY_REPORTER_NAME(WebGLShaderCount)) - , mContextCountReporter(new NS_MEMORY_REPORTER_NAME(WebGLContextCount)) -{ - NS_RegisterMemoryReporter(mTextureMemoryUsageReporter); - NS_RegisterMemoryReporter(mTextureCountReporter); - NS_RegisterMemoryReporter(mBufferMemoryUsageReporter); - NS_RegisterMemoryReporter(mBufferCacheMemoryUsageReporter); - NS_RegisterMemoryReporter(mBufferCountReporter); - NS_RegisterMemoryReporter(mRenderbufferMemoryUsageReporter); - NS_RegisterMemoryReporter(mRenderbufferCountReporter); - NS_RegisterMemoryReporter(mShaderSourcesSizeReporter); - NS_RegisterMemoryReporter(mShaderTranslationLogsSizeReporter); - NS_RegisterMemoryReporter(mShaderCountReporter); - NS_RegisterMemoryReporter(mContextCountReporter); -} - -WebGLMemoryReporter::~WebGLMemoryReporter() -{ - NS_UnregisterMemoryReporter(mTextureMemoryUsageReporter); - NS_UnregisterMemoryReporter(mTextureCountReporter); - NS_UnregisterMemoryReporter(mBufferMemoryUsageReporter); - NS_UnregisterMemoryReporter(mBufferCacheMemoryUsageReporter); - NS_UnregisterMemoryReporter(mBufferCountReporter); - NS_UnregisterMemoryReporter(mRenderbufferMemoryUsageReporter); - NS_UnregisterMemoryReporter(mRenderbufferCountReporter); - NS_UnregisterMemoryReporter(mShaderSourcesSizeReporter); - NS_UnregisterMemoryReporter(mShaderTranslationLogsSizeReporter); - NS_UnregisterMemoryReporter(mShaderCountReporter); - NS_UnregisterMemoryReporter(mContextCountReporter); -} nsresult NS_NewCanvasRenderingContextWebGL(nsIDOMWebGLRenderingContext** aResult); @@ -289,7 +162,7 @@ mPixelStorePackAlignment = 4; mPixelStoreUnpackAlignment = 4; - WebGLMemoryReporter::AddWebGLContext(this); + WebGLMemoryMultiReporterWrapper::AddWebGLContext(this); mAllowRestore = true; mRobustnessTimerRunning = false; @@ -303,7 +176,7 @@ WebGLContext::~WebGLContext() { DestroyResourcesAndContext(); - WebGLMemoryReporter::RemoveWebGLContext(this); + WebGLMemoryMultiReporterWrapper::RemoveWebGLContext(this); TerminateRobustnessTimer(); mContextRestorer = nsnull; } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/canvas/src/WebGLContext.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/canvas/src/WebGLContext.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/canvas/src/WebGLContext.h 2012-02-21 02:04:11.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/canvas/src/WebGLContext.h 2012-02-22 02:04:19.000000000 +0000 @@ -55,8 +55,8 @@ #include "nsHTMLCanvasElement.h" #include "nsWeakReference.h" #include "nsIDOMHTMLElement.h" -#include "nsIJSNativeInitializer.h" #include "nsIMemoryReporter.h" +#include "nsIJSNativeInitializer.h" #include "nsContentUtils.h" #include "GLContextProvider.h" @@ -514,7 +514,7 @@ public nsITimerCallback, public WebGLRectangleObject { - friend class WebGLMemoryReporter; + friend class WebGLMemoryMultiReporterWrapper; friend class WebGLExtensionLoseContext; friend class WebGLContextUserData; @@ -1055,6 +1055,10 @@ mContext->mBuffers.RemoveElement(mMonotonicHandle); } + size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const { + return aMallocSizeOf(this) + aMallocSizeOf(mData); + } + bool HasEverBeenBound() { return mHasEverBeenBound; } void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; } GLuint GLName() const { return mGLName; } @@ -1627,6 +1631,12 @@ ~WebGLShader() { DeleteOnce(); } + + size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) { + return aMallocSizeOf(this) + + mSource.SizeOfExcludingThisIfUnshared(aMallocSizeOf) + + mTranslationLog.SizeOfExcludingThisIfUnshared(aMallocSizeOf); + } void Delete() { mSource.Truncate(); @@ -2515,30 +2525,21 @@ return GetConcreteObject(info, aInterface, &aConcreteObject, isNull, isDeleted, false); } -class WebGLMemoryReporter +class WebGLMemoryMultiReporterWrapper { - WebGLMemoryReporter(); - ~WebGLMemoryReporter(); - static WebGLMemoryReporter* sUniqueInstance; + WebGLMemoryMultiReporterWrapper(); + ~WebGLMemoryMultiReporterWrapper(); + static WebGLMemoryMultiReporterWrapper* sUniqueInstance; - // here we store plain pointers, not RefPtrs: we don't want the WebGLMemoryReporter unique instance to keep alive all + // here we store plain pointers, not RefPtrs: we don't want the + // WebGLMemoryMultiReporterWrapper unique instance to keep alive all // WebGLContexts ever created. typedef nsTArray ContextsArrayType; ContextsArrayType mContexts; - nsCOMPtr mTextureMemoryUsageReporter; - nsCOMPtr mTextureCountReporter; - nsCOMPtr mBufferMemoryUsageReporter; - nsCOMPtr mBufferCacheMemoryUsageReporter; - nsCOMPtr mBufferCountReporter; - nsCOMPtr mRenderbufferMemoryUsageReporter; - nsCOMPtr mRenderbufferCountReporter; - nsCOMPtr mShaderSourcesSizeReporter; - nsCOMPtr mShaderTranslationLogsSizeReporter; - nsCOMPtr mShaderCountReporter; - nsCOMPtr mContextCountReporter; + nsCOMPtr mReporter; - static WebGLMemoryReporter* UniqueInstance(); + static WebGLMemoryMultiReporterWrapper* UniqueInstance(); static ContextsArrayType & Contexts() { return UniqueInstance()->mContexts; } @@ -2552,7 +2553,7 @@ ContextsArrayType & contexts = Contexts(); contexts.RemoveElement(c); if (contexts.IsEmpty()) { - delete sUniqueInstance; + delete sUniqueInstance; sUniqueInstance = nsnull; } } @@ -2561,8 +2562,8 @@ const ContextsArrayType & contexts = Contexts(); PRInt64 result = 0; for(size_t i = 0; i < contexts.Length(); ++i) - for (size_t t = 0; t < contexts[i]->mTextures.Length(); ++t) - result += contexts[i]->mTextures[t]->MemoryUsage(); + for (size_t j = 0; j < contexts[i]->mTextures.Length(); ++j) + result += contexts[i]->mTextures[j]->MemoryUsage(); return result; } @@ -2578,20 +2579,12 @@ const ContextsArrayType & contexts = Contexts(); PRInt64 result = 0; for(size_t i = 0; i < contexts.Length(); ++i) - for (size_t b = 0; b < contexts[i]->mBuffers.Length(); ++b) - result += contexts[i]->mBuffers[b]->ByteLength(); + for (size_t j = 0; j < contexts[i]->mBuffers.Length(); ++j) + result += contexts[i]->mBuffers[j]->ByteLength(); return result; } - static PRInt64 GetBufferCacheMemoryUsed() { - const ContextsArrayType & contexts = Contexts(); - PRInt64 result = 0; - for(size_t i = 0; i < contexts.Length(); ++i) - for (size_t b = 0; b < contexts[i]->mBuffers.Length(); ++b) - if (contexts[i]->mBuffers[b]->Target() == LOCAL_GL_ELEMENT_ARRAY_BUFFER) - result += contexts[i]->mBuffers[b]->ByteLength(); - return result; - } + static PRInt64 GetBufferCacheMemoryUsed(); static PRInt64 GetBufferCount() { const ContextsArrayType & contexts = Contexts(); @@ -2605,8 +2598,8 @@ const ContextsArrayType & contexts = Contexts(); PRInt64 result = 0; for(size_t i = 0; i < contexts.Length(); ++i) - for (size_t r = 0; r < contexts[i]->mRenderbuffers.Length(); ++r) - result += contexts[i]->mRenderbuffers[r]->MemoryUsage(); + for (size_t j = 0; j < contexts[i]->mRenderbuffers.Length(); ++j) + result += contexts[i]->mRenderbuffers[j]->MemoryUsage(); return result; } @@ -2618,23 +2611,7 @@ return result; } - static PRInt64 GetShaderSourcesSize() { - const ContextsArrayType & contexts = Contexts(); - PRInt64 result = 0; - for(size_t i = 0; i < contexts.Length(); ++i) - for (size_t s = 0; s < contexts[i]->mShaders.Length(); ++s) - result += contexts[i]->mShaders[s]->Source().Length(); - return result; - } - - static PRInt64 GetShaderTranslationLogsSize() { - const ContextsArrayType & contexts = Contexts(); - PRInt64 result = 0; - for(size_t i = 0; i < contexts.Length(); ++i) - for (size_t s = 0; s < contexts[i]->mShaders.Length(); ++s) - result += contexts[i]->mShaders[s]->TranslationLog().Length(); - return result; - } + static PRInt64 GetShaderSize(); static PRInt64 GetShaderCount() { const ContextsArrayType & contexts = Contexts(); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/canvas/src/WebGLContextReporter.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/canvas/src/WebGLContextReporter.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/canvas/src/WebGLContextReporter.cpp 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/canvas/src/WebGLContextReporter.cpp 2012-02-22 02:04:19.000000000 +0000 @@ -0,0 +1,218 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Mozilla Corporation. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * + * 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 ***** */ + +#include "WebGLContext.h" +#include "nsIMemoryReporter.h" + +using namespace mozilla; + + +class WebGLMemoryMultiReporter : public nsIMemoryMultiReporter +{ + public: + NS_DECL_ISUPPORTS + NS_DECL_NSIMEMORYMULTIREPORTER +}; + +NS_IMPL_ISUPPORTS1(WebGLMemoryMultiReporter, nsIMemoryMultiReporter) + +NS_IMETHODIMP +WebGLMemoryMultiReporter::GetName(nsACString &aName) +{ + aName.AssignLiteral("webgl"); + return NS_OK; +} + +NS_IMETHODIMP +WebGLMemoryMultiReporter::GetExplicitNonHeap(PRInt64 *aAmount) +{ + // WebGLMemoryMultiReporterWrapper has no KIND_NONHEAP measurements. + *aAmount = 0; + return NS_OK; +} + +NS_IMETHODIMP +WebGLMemoryMultiReporter::CollectReports(nsIMemoryMultiReporterCallback* aCb, + nsISupports* aClosure) +{ + aCb->Callback( + EmptyCString(), + NS_LITERAL_CSTRING("webgl-texture-memory"), + nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_BYTES, + WebGLMemoryMultiReporterWrapper::GetTextureMemoryUsed(), + NS_LITERAL_CSTRING("Memory used by WebGL textures.The OpenGL" + " implementation is free to store these textures in either video" + " memory or main memory. This measurement is only a lower bound," + " actual memory usage may be higher for example if the storage" + " is strided."), + aClosure); + + aCb->Callback( + EmptyCString(), + NS_LITERAL_CSTRING("webgl-texture-count"), + nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT, + WebGLMemoryMultiReporterWrapper::GetTextureCount(), + NS_LITERAL_CSTRING("Number of WebGL textures."), + aClosure); + + aCb->Callback( + EmptyCString(), + NS_LITERAL_CSTRING("webgl-buffer-memory"), + nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_BYTES, + WebGLMemoryMultiReporterWrapper::GetBufferMemoryUsed(), + NS_LITERAL_CSTRING("Memory used by WebGL buffers. The OpenGL" + " implementation is free to store these buffers in either video" + " memory or main memory. This measurement is only a lower bound," + " actual memory usage may be higher for example if the storage" + " is strided."), + aClosure); + + aCb->Callback( + EmptyCString(), + NS_LITERAL_CSTRING("explicit/webgl/buffer-cache-memory"), + nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES, + WebGLMemoryMultiReporterWrapper::GetBufferCacheMemoryUsed(), + NS_LITERAL_CSTRING("Memory used by WebGL buffer caches. The WebGL" + " implementation caches the contents of element array buffers" + " only.This adds up with the webgl-buffer-memory value, but" + " contrary to it, this one represents bytes on the heap," + " not managed by OpenGL."), + aClosure); + + aCb->Callback( + EmptyCString(), NS_LITERAL_CSTRING("webgl-buffer-count"), + nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT, + WebGLMemoryMultiReporterWrapper::GetBufferCount(), + NS_LITERAL_CSTRING("Number of WebGL buffers."), + aClosure); + + aCb->Callback( + EmptyCString(), + NS_LITERAL_CSTRING("webgl-renderbuffer-memory"), + nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_BYTES, + WebGLMemoryMultiReporterWrapper::GetRenderbufferMemoryUsed(), + NS_LITERAL_CSTRING("Memory used by WebGL renderbuffers. The OpenGL" + " implementation is free to store these renderbuffers in either" + " video memory or main memory. This measurement is only a lower" + " bound, actual memory usage may be higher for example if the" + " storage is strided."), + aClosure); + + aCb->Callback( + EmptyCString(), + NS_LITERAL_CSTRING("webgl-renderbuffer-count"), + nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT, + WebGLMemoryMultiReporterWrapper::GetRenderbufferCount(), + NS_LITERAL_CSTRING("Number of WebGL renderbuffers."), + aClosure); + + aCb->Callback( + EmptyCString(), + NS_LITERAL_CSTRING("explicit/webgl/shader"), + nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES, + WebGLMemoryMultiReporterWrapper::GetShaderSize(), + NS_LITERAL_CSTRING("Combined size of WebGL shader ASCII sources and" + " translation logs cached on the heap."), + aClosure); + + aCb->Callback( + EmptyCString(), + NS_LITERAL_CSTRING("webgl-shader-count"), + nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT, + WebGLMemoryMultiReporterWrapper::GetShaderCount(), + NS_LITERAL_CSTRING("Number of WebGL shaders."), + aClosure); + + aCb->Callback( + EmptyCString(), + NS_LITERAL_CSTRING("webgl-context-count"), + nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT, + WebGLMemoryMultiReporterWrapper::GetContextCount(), + NS_LITERAL_CSTRING("Number of WebGL contexts."), + aClosure); + + return NS_OK; +} + +WebGLMemoryMultiReporterWrapper* WebGLMemoryMultiReporterWrapper::sUniqueInstance = nsnull; + +WebGLMemoryMultiReporterWrapper* WebGLMemoryMultiReporterWrapper::UniqueInstance() +{ + if (!sUniqueInstance) { + sUniqueInstance = new WebGLMemoryMultiReporterWrapper; + } + return sUniqueInstance; +} + +WebGLMemoryMultiReporterWrapper::WebGLMemoryMultiReporterWrapper() +{ + mReporter = new WebGLMemoryMultiReporter; + NS_RegisterMemoryMultiReporter(mReporter); +} + +WebGLMemoryMultiReporterWrapper::~WebGLMemoryMultiReporterWrapper() +{ + NS_UnregisterMemoryMultiReporter(mReporter); +} + +NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(WebGLBufferMallocSizeOfFun, "webgl-buffer") + +PRInt64 +WebGLMemoryMultiReporterWrapper::GetBufferCacheMemoryUsed() { + const ContextsArrayType & contexts = Contexts(); + PRInt64 result = 0; + for (size_t i = 0; i < contexts.Length(); ++i) { + for (size_t j = 0; j < contexts[i]->mBuffers.Length(); ++j) + if (contexts[i]->mBuffers[j]->Target() == LOCAL_GL_ELEMENT_ARRAY_BUFFER) + result += contexts[i]->mBuffers[j]->SizeOfIncludingThis(WebGLBufferMallocSizeOfFun); + } + return result; +} + +NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(WebGLShaderMallocSizeOfFun, "webgl-shader") + +PRInt64 +WebGLMemoryMultiReporterWrapper::GetShaderSize() { + const ContextsArrayType & contexts = Contexts(); + PRInt64 result = 0; + for (size_t i = 0; i < contexts.Length(); ++i) { + for (size_t j = 0; j < contexts[i]->mShaders.Length(); ++j) + result += contexts[i]->mShaders[j]->SizeOfIncludingThis(WebGLShaderMallocSizeOfFun); + } + return result; +} diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/html/content/src/nsHTMLTableElement.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/html/content/src/nsHTMLTableElement.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/html/content/src/nsHTMLTableElement.cpp 2012-02-21 02:04:21.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/html/content/src/nsHTMLTableElement.cpp 2012-02-22 02:04:32.000000000 +0000 @@ -901,7 +901,7 @@ if (aNamespaceID == kNameSpaceID_None) { if (aAttribute == nsGkAtoms::cellspacing || aAttribute == nsGkAtoms::cellpadding) { - return aResult.ParseSpecialIntValue(aValue); + return aResult.ParseNonNegativeIntValue(aValue); } if (aAttribute == nsGkAtoms::cols || aAttribute == nsGkAtoms::border) { @@ -971,19 +971,10 @@ // cellspacing const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::cellspacing); nsCSSValue* borderSpacing = aData->ValueForBorderSpacing(); - if (value && value->Type() == nsAttrValue::eInteger) { - if (borderSpacing->GetUnit() == eCSSUnit_Null) { - borderSpacing-> - SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel); - } - } - else if (value && value->Type() == nsAttrValue::ePercent && - eCompatibility_NavQuirks == mode) { - // in quirks mode, treat a % cellspacing value a pixel value. - if (borderSpacing->GetUnit() == eCSSUnit_Null) { - borderSpacing-> - SetFloatValue(100.0f * value->GetPercentValue(), eCSSUnit_Pixel); - } + if (value && value->Type() == nsAttrValue::eInteger && + borderSpacing->GetUnit() == eCSSUnit_Null) { + borderSpacing-> + SetFloatValue(float(value->GetIntegerValue()), eCSSUnit_Pixel); } } if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Table)) { @@ -1159,39 +1150,29 @@ { if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Padding)) { const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::cellpadding); - if (value) { - nsAttrValue::ValueType valueType = value->Type(); - if (valueType == nsAttrValue::eInteger || - valueType == nsAttrValue::ePercent) { - // We have cellpadding. This will override our padding values if we - // don't have any set. - nsCSSValue padVal; - if (valueType == nsAttrValue::eInteger) - padVal.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel); - else { - // when we support % cellpadding in standard mode, uncomment the - // following - float pctVal = value->GetPercentValue(); - //if (eCompatibility_NavQuirks == mode) { - // in quirks mode treat a pct cellpadding value as a pixel value - padVal.SetFloatValue(100.0f * pctVal, eCSSUnit_Pixel); - //} - //else { - // padVal.SetPercentValue(pctVal); - //} - } - nsCSSValue* paddingLeft = aData->ValueForPaddingLeftValue(); - if (paddingLeft->GetUnit() == eCSSUnit_Null) - *paddingLeft = padVal; - nsCSSValue* paddingRight = aData->ValueForPaddingRightValue(); - if (paddingRight->GetUnit() == eCSSUnit_Null) - *paddingRight = padVal; - nsCSSValue* paddingTop = aData->ValueForPaddingTop(); - if (paddingTop->GetUnit() == eCSSUnit_Null) - *paddingTop = padVal; - nsCSSValue* paddingBottom = aData->ValueForPaddingBottom(); - if (paddingBottom->GetUnit() == eCSSUnit_Null) - *paddingBottom = padVal; + if (value && value->Type() == nsAttrValue::eInteger) { + // We have cellpadding. This will override our padding values if we + // don't have any set. + nsCSSValue padVal(float(value->GetIntegerValue()), eCSSUnit_Pixel); + + nsCSSValue* paddingLeft = aData->ValueForPaddingLeftValue(); + if (paddingLeft->GetUnit() == eCSSUnit_Null) { + *paddingLeft = padVal; + } + + nsCSSValue* paddingRight = aData->ValueForPaddingRightValue(); + if (paddingRight->GetUnit() == eCSSUnit_Null) { + *paddingRight = padVal; + } + + nsCSSValue* paddingTop = aData->ValueForPaddingTop(); + if (paddingTop->GetUnit() == eCSSUnit_Null) { + *paddingTop = padVal; + } + + nsCSSValue* paddingBottom = aData->ValueForPaddingBottom(); + if (paddingBottom->GetUnit() == eCSSUnit_Null) { + *paddingBottom = padVal; } } } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/media/nsBuiltinDecoder.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/media/nsBuiltinDecoder.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/media/nsBuiltinDecoder.cpp 2012-02-21 02:04:22.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/media/nsBuiltinDecoder.cpp 2012-02-22 02:04:35.000000000 +0000 @@ -327,7 +327,9 @@ PRInt32 range = 0; if (!IsInRanges(seekable, aTime, range)) { if (range != -1) { - if (range + 1 < length) { + // |range + 1| can't be negative, because the only possible negative value + // for |range| is -1. + if (PRUint32(range + 1) < length) { double leftBound, rightBound; res = seekable.End(range, &leftBound); NS_ENSURE_SUCCESS(res, NS_OK); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/media/nsBuiltinDecoderStateMachine.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/media/nsBuiltinDecoderStateMachine.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/media/nsBuiltinDecoderStateMachine.cpp 2012-02-21 02:04:22.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/media/nsBuiltinDecoderStateMachine.cpp 2012-02-22 02:04:35.000000000 +0000 @@ -49,6 +49,7 @@ #include "mozilla/Preferences.h" #include "mozilla/StdInt.h" +#include "mozilla/Util.h" using namespace mozilla; using namespace mozilla::layers; @@ -307,9 +308,8 @@ ReentrantMonitorAutoEnter mon(mMonitor); if (mStateMachineCount == 0) { NS_ASSERTION(!mStateMachineThread, "Should have null state machine thread!"); - nsresult res = NS_NewThread(&mStateMachineThread, - nsnull); - NS_ABORT_IF_FALSE(NS_SUCCEEDED(res), "Can't create media state machine thread"); + DebugOnly rv = NS_NewThread(&mStateMachineThread, nsnull); + NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv), "Can't create media state machine thread"); } mStateMachineCount++; } @@ -866,11 +866,11 @@ ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); PRInt64 unplayedFrames = audioDuration % minWriteFrames; if (minWriteFrames > 1 && unplayedFrames > 0) { - // Sound is written by libsydneyaudio to the hardware in blocks of - // frames of size minWriteFrames. So if the number of frames we've - // written isn't an exact multiple of minWriteFrames, we'll have - // left over audio data which hasn't yet been written to the hardware, - // and so that audio will not start playing. Write silence to ensure + // Sound is written by libsydneyaudio to the hardware in blocks of + // frames of size minWriteFrames. So if the number of frames we've + // written isn't an exact multiple of minWriteFrames, we'll have + // left over audio data which hasn't yet been written to the hardware, + // and so that audio will not start playing. Write silence to ensure // the last block gets pushed to hardware, so that playback starts. PRInt64 framesToWrite = minWriteFrames - unplayedFrames; if (framesToWrite < PR_UINT32_MAX / channels) { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/xbl/src/nsXBLDocumentInfo.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/xbl/src/nsXBLDocumentInfo.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/xbl/src/nsXBLDocumentInfo.cpp 2012-02-21 02:04:29.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/xbl/src/nsXBLDocumentInfo.cpp 2012-02-22 02:04:41.000000000 +0000 @@ -194,7 +194,7 @@ nsXBLDocGlobalObject_getProperty, nsXBLDocGlobalObject_setProperty, JS_EnumerateStub, nsXBLDocGlobalObject_resolve, JS_ConvertStub, nsXBLDocGlobalObject_finalize, - NULL, nsXBLDocGlobalObject_checkAccess, NULL, NULL, NULL, NULL, + nsXBLDocGlobalObject_checkAccess, NULL, NULL, NULL, TraceXPCGlobal }; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp 2012-02-21 02:04:32.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp 2012-02-22 02:04:45.000000000 +0000 @@ -146,7 +146,7 @@ XPCONNECT_GLOBAL_FLAGS, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, nsXULPDGlobalObject_resolve, JS_ConvertStub, - nsXULPDGlobalObject_finalize, NULL, NULL, NULL, NULL, NULL, NULL, + nsXULPDGlobalObject_finalize, NULL, NULL, NULL, NULL, TraceXPCGlobal }; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/docshell/base/nsAboutRedirector.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/docshell/base/nsAboutRedirector.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/docshell/base/nsAboutRedirector.cpp 2012-02-21 02:04:40.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/docshell/base/nsAboutRedirector.cpp 2012-02-22 02:04:47.000000000 +0000 @@ -86,6 +86,9 @@ nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT | nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::HIDE_FROM_ABOUTABOUT }, + // aboutMemory.xhtml implements about:compartments + { "compartments", "chrome://global/content/aboutMemory.xhtml", + nsIAboutModule::ALLOW_SCRIPT }, { "memory", "chrome://global/content/aboutMemory.xhtml", nsIAboutModule::ALLOW_SCRIPT }, { "addons", "chrome://mozapps/content/extensions/extensions.xul", diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/docshell/build/nsDocShellModule.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/docshell/build/nsDocShellModule.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/docshell/build/nsDocShellModule.cpp 2012-02-21 02:04:41.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/docshell/build/nsDocShellModule.cpp 2012-02-22 02:04:47.000000000 +0000 @@ -210,6 +210,7 @@ { NS_ABOUT_MODULE_CONTRACTID_PREFIX "buildconfig", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "license", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "neterror", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, + { NS_ABOUT_MODULE_CONTRACTID_PREFIX "compartments", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "memory", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "addons", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "newaddon", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/base/Navigator.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/base/Navigator.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/base/Navigator.cpp 2012-02-21 02:04:41.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/base/Navigator.cpp 2012-02-22 02:04:51.000000000 +0000 @@ -80,6 +80,10 @@ #ifdef MOZ_B2G_RIL #include "TelephonyFactory.h" #endif +#ifdef MOZ_B2G_BT +#include "nsIDOMBluetoothAdapter.h" +#include "BluetoothAdapter.h" +#endif // This should not be in the namespace. DOMCI_DATA(Navigator, mozilla::dom::Navigator) @@ -133,6 +137,9 @@ NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorTelephony) #endif NS_INTERFACE_MAP_ENTRY(nsIDOMMozNavigatorNetwork) +#ifdef MOZ_B2G_BT + NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorBluetooth) +#endif NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Navigator) NS_INTERFACE_MAP_END @@ -182,6 +189,12 @@ mConnection->Shutdown(); mConnection = nsnull; } + +#ifdef MOZ_B2G_BT + if (mBluetooth) { + mBluetooth = nsnull; + } +#endif } nsPIDOMWindow * @@ -1112,6 +1125,30 @@ return NS_OK; } +#ifdef MOZ_B2G_BT +//***************************************************************************** +// nsNavigator::nsIDOMNavigatorBluetooth +//***************************************************************************** + +NS_IMETHODIMP +Navigator::GetMozBluetooth(nsIDOMBluetoothAdapter** aBluetooth) +{ + nsCOMPtr bluetooth = mBluetooth; + + if (!bluetooth) { + nsCOMPtr window = do_QueryReferent(mWindow); + NS_ENSURE_TRUE(window, NS_ERROR_FAILURE); + + mBluetooth = new bluetooth::BluetoothAdapter(); + + bluetooth = mBluetooth; + } + + bluetooth.forget(aBluetooth); + return NS_OK; +} +#endif //MOZ_B2G_BT + PRInt64 Navigator::SizeOf() const { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/base/Navigator.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/base/Navigator.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/base/Navigator.h 2012-02-21 02:04:41.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/base/Navigator.h 2012-02-22 02:04:51.000000000 +0000 @@ -65,6 +65,11 @@ class nsIDOMTelephony; #endif +#ifdef MOZ_B2G_BT +#include "nsIDOMNavigatorBluetooth.h" +#endif + +class nsIDOMAdapter; //***************************************************************************** // Navigator: Script "navigator" object //***************************************************************************** @@ -98,6 +103,9 @@ , public nsIDOMNavigatorTelephony #endif , public nsIDOMMozNavigatorNetwork +#ifdef MOZ_B2G_BT + , public nsIDOMNavigatorBluetooth +#endif { public: Navigator(nsPIDOMWindow *aInnerWindow); @@ -115,6 +123,10 @@ #endif NS_DECL_NSIDOMMOZNAVIGATORNETWORK +#ifdef MOZ_B2G_BT + NS_DECL_NSIDOMNAVIGATORBLUETOOTH +#endif + static void Init(); void Invalidate(); @@ -146,6 +158,9 @@ nsCOMPtr mTelephony; #endif nsRefPtr mConnection; +#ifdef MOZ_B2G_BT + nsCOMPtr mBluetooth; +#endif nsWeakPtr mWindow; }; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/base/nsDOMClassInfoClasses.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/base/nsDOMClassInfoClasses.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/base/nsDOMClassInfoClasses.h 2012-02-21 02:04:42.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/base/nsDOMClassInfoClasses.h 2012-02-22 02:04:51.000000000 +0000 @@ -540,4 +540,8 @@ DOMCI_CLASS(CallEvent) #endif +#ifdef MOZ_B2G_BT +DOMCI_CLASS(BluetoothAdapter) +#endif + DOMCI_CLASS(DOMError) diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/base/nsDOMClassInfo.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/base/nsDOMClassInfo.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/base/nsDOMClassInfo.cpp 2012-02-21 02:04:42.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/base/nsDOMClassInfo.cpp 2012-02-22 02:04:51.000000000 +0000 @@ -532,6 +532,10 @@ #include "CallEvent.h" #endif +#ifdef MOZ_B2G_BT +#include "BluetoothAdapter.h" +#endif + #include "DOMError.h" using namespace mozilla; @@ -1627,6 +1631,11 @@ DOM_DEFAULT_SCRIPTABLE_FLAGS) #endif +#ifdef MOZ_B2G_BT + NS_DEFINE_CLASSINFO_DATA(BluetoothAdapter, nsDOMGenericSH, + DOM_DEFAULT_SCRIPTABLE_FLAGS) +#endif + NS_DEFINE_CLASSINFO_DATA(DOMError, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) }; @@ -2423,6 +2432,9 @@ #endif DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMMozNavigatorNetwork, network::IsAPIEnabled()) +#ifdef MOZ_B2G_BT + DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorBluetooth) +#endif DOM_CLASSINFO_MAP_END DOM_CLASSINFO_MAP_BEGIN(Plugin, nsIDOMPlugin) @@ -3153,6 +3165,12 @@ DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver, \ nsDOMTouchEvent::PrefEnabled()) +#define DOM_CLASSINFO_SVG_TEXT_CONTENT_ELEMENT_MAP_ENTRIES \ + DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextContentElement) \ + DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests) \ + DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable) \ + DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES + #define DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES \ DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLocatable) \ DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransformable) \ @@ -3185,12 +3203,8 @@ DOM_CLASSINFO_MAP_BEGIN(SVGAltGlyphElement, nsIDOMSVGAltGlyphElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextPositioningElement) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextContentElement) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable) - DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES + DOM_CLASSINFO_SVG_TEXT_CONTENT_ELEMENT_MAP_ENTRIES DOM_CLASSINFO_MAP_END DOM_CLASSINFO_MAP_BEGIN(SVGAnimateElement, nsIDOMSVGAnimateElement) @@ -3431,6 +3445,12 @@ DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES DOM_CLASSINFO_MAP_END + DOM_CLASSINFO_MAP_BEGIN(SVGForeignObjectElement, nsIDOMSVGForeignObjectElement) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGForeignObjectElement) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests) + DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES + DOM_CLASSINFO_MAP_END + DOM_CLASSINFO_MAP_BEGIN(SVGGElement, nsIDOMSVGGElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGGElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests) @@ -3546,7 +3566,6 @@ DOM_CLASSINFO_MAP_END DOM_CLASSINFO_MAP_BEGIN(SVGSVGElement, nsIDOMSVGSVGElement) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSVGElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLocatable) @@ -3579,12 +3598,8 @@ DOM_CLASSINFO_MAP_END DOM_CLASSINFO_MAP_BEGIN(SVGTextPathElement, nsIDOMSVGTextPathElement) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextContentElement) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable) - DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES + DOM_CLASSINFO_SVG_TEXT_CONTENT_ELEMENT_MAP_ENTRIES DOM_CLASSINFO_MAP_END DOM_CLASSINFO_MAP_BEGIN(SVGTitleElement, nsIDOMSVGTitleElement) @@ -3595,11 +3610,7 @@ DOM_CLASSINFO_MAP_BEGIN(SVGTSpanElement, nsIDOMSVGTSpanElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextPositioningElement) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextContentElement) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable) - DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES + DOM_CLASSINFO_SVG_TEXT_CONTENT_ELEMENT_MAP_ENTRIES DOM_CLASSINFO_MAP_END DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(SVGUnknownElement, nsIDOMSVGElement) @@ -3930,11 +3941,6 @@ DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(SVGForeignObjectElement, nsIDOMSVGForeignObjectElement) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGForeignObjectElement) - DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(XULCommandEvent, nsIDOMXULCommandEvent) DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULCommandEvent) DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES @@ -4365,6 +4371,12 @@ DOM_CLASSINFO_MAP_END #endif +#ifdef MOZ_B2G_BT + DOM_CLASSINFO_MAP_BEGIN(BluetoothAdapter, nsIDOMBluetoothAdapter) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothAdapter) + DOM_CLASSINFO_MAP_END +#endif + DOM_CLASSINFO_MAP_BEGIN(DOMError, nsIDOMDOMError) DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMError) DOM_CLASSINFO_MAP_END diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/base/nsDOMWindowUtils.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/base/nsDOMWindowUtils.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/base/nsDOMWindowUtils.cpp 2012-02-21 02:04:42.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/base/nsDOMWindowUtils.cpp 2012-02-22 02:04:51.000000000 +0000 @@ -603,7 +603,7 @@ } event.touches.SetCapacity(aCount); PRInt32 appPerDev = presContext->AppUnitsPerDevPixel(); - for (int i = 0; i < aCount; ++i) { + for (PRUint32 i = 0; i < aCount; ++i) { nsIntPoint pt(0, 0); pt.x = NSAppUnitsToIntPixels(nsPresContext::CSSPixelsToAppUnits(aXs[i]) + offset.x, diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/base/nsGlobalWindowCommands.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/base/nsGlobalWindowCommands.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/base/nsGlobalWindowCommands.cpp 2012-02-21 02:04:42.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/base/nsGlobalWindowCommands.cpp 2012-02-22 02:04:51.000000000 +0000 @@ -285,7 +285,7 @@ } } - for (int i = 0; i < mozilla::ArrayLength(browseCommands); i++) { + for (size_t i = 0; i < ArrayLength(browseCommands); i++) { bool forward = !strcmp(aCommandName, browseCommands[i].forward); if (forward || !strcmp(aCommandName, browseCommands[i].reverse)) { if (caretOn && browseCommands[i].move && diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/bluetooth/BluetoothAdapter.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/bluetooth/BluetoothAdapter.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/bluetooth/BluetoothAdapter.cpp 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/bluetooth/BluetoothAdapter.cpp 2012-02-22 02:04:51.000000000 +0000 @@ -0,0 +1,39 @@ +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ +/* vim: set ts=2 et sw=2 tw=40: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "BluetoothAdapter.h" +#include "nsDOMClassInfo.h" + +USING_BLUETOOTH_NAMESPACE + +BluetoothAdapter::BluetoothAdapter() : mPower(false) +{ +} + +NS_INTERFACE_MAP_BEGIN(BluetoothAdapter) + NS_INTERFACE_MAP_ENTRY(nsIDOMBluetoothAdapter) + NS_INTERFACE_MAP_ENTRY(nsISupports) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(BluetoothAdapter) +NS_INTERFACE_MAP_END + +NS_IMPL_ADDREF(BluetoothAdapter) +NS_IMPL_RELEASE(BluetoothAdapter) + +DOMCI_DATA(BluetoothAdapter, BluetoothAdapter) + +NS_IMETHODIMP +BluetoothAdapter::GetPower(bool* aPower) +{ + *aPower = mPower; + return NS_OK; +} + +NS_IMETHODIMP +BluetoothAdapter::SetPower(bool aPower) +{ + mPower = aPower; + return NS_OK; +} diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/bluetooth/BluetoothAdapter.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/bluetooth/BluetoothAdapter.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/bluetooth/BluetoothAdapter.h 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/bluetooth/BluetoothAdapter.h 2012-02-22 02:04:51.000000000 +0000 @@ -0,0 +1,28 @@ +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ +/* vim: set ts=2 et sw=2 tw=40: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_bluetooth_bluetoothadapter_h__ +#define mozilla_dom_bluetooth_bluetoothadapter_h__ + +#include "BluetoothCommon.h" +#include "nsIDOMBluetoothAdapter.h" + +BEGIN_BLUETOOTH_NAMESPACE + +class BluetoothAdapter : public nsIDOMBluetoothAdapter +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIDOMBLUETOOTHADAPTER + + BluetoothAdapter(); + +protected: + bool mPower; +}; + +END_BLUETOOTH_NAMESPACE +#endif diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/bluetooth/BluetoothCommon.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/bluetooth/BluetoothCommon.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/bluetooth/BluetoothCommon.h 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/bluetooth/BluetoothCommon.h 2012-02-22 02:04:51.000000000 +0000 @@ -0,0 +1,19 @@ +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ +/* vim: set ts=2 et sw=2 tw=40: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_bluetooth_bluetoothcommon_h__ +#define mozilla_dom_bluetooth_bluetoothcommon_h__ + +#define BEGIN_BLUETOOTH_NAMESPACE \ + namespace mozilla { namespace dom { namespace bluetooth { +#define END_BLUETOOTH_NAMESPACE \ + } /* namespace bluetooth */ } /* namespace dom */ } /* namespace mozilla */ +#define USING_BLUETOOTH_NAMESPACE \ + using namespace mozilla::dom::bluetooth; + +class nsIDOMBluetooth; + +#endif // mozilla_dom_bluetooth_bluetoothcommon_h__ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/bluetooth/Makefile.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/bluetooth/Makefile.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/bluetooth/Makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/bluetooth/Makefile.in 2012-02-22 02:04:51.000000000 +0000 @@ -0,0 +1,30 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + +DEPTH = ../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = dom +LIBRARY_NAME = dombluetooth_s +XPIDL_MODULE = dom_bluetooth +LIBXUL_LIBRARY = 1 +FORCE_STATIC_LIB = 1 + +include $(topsrcdir)/dom/dom-config.mk + +CPPSRCS = \ + BluetoothAdapter.cpp \ + $(NULL) + +XPIDLSRCS = \ + nsIDOMNavigatorBluetooth.idl \ + nsIDOMBluetoothAdapter.idl \ + $(NULL) + +include $(topsrcdir)/config/rules.mk + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/bluetooth/nsIDOMBluetoothAdapter.idl firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/bluetooth/nsIDOMBluetoothAdapter.idl --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/bluetooth/nsIDOMBluetoothAdapter.idl 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/bluetooth/nsIDOMBluetoothAdapter.idl 2012-02-22 02:04:51.000000000 +0000 @@ -0,0 +1,13 @@ +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ +/* vim: set ts=2 et sw=2 tw=40: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsISupports.idl" + +[scriptable, builtinclass, uuid(29689a22-45ff-4ccf-b552-5364ce3a3642)] +interface nsIDOMBluetoothAdapter : nsISupports +{ + attribute boolean power; +}; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/bluetooth/nsIDOMNavigatorBluetooth.idl firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/bluetooth/nsIDOMNavigatorBluetooth.idl --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/bluetooth/nsIDOMNavigatorBluetooth.idl 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/bluetooth/nsIDOMNavigatorBluetooth.idl 2012-02-22 02:04:51.000000000 +0000 @@ -0,0 +1,15 @@ +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ +/* vim: set ts=2 et sw=2 tw=40: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsISupports.idl" + +interface nsIDOMBluetoothAdapter; + +[scriptable, uuid(677f2c2d-c4d1-41ea-addc-21d30d0d3858)] +interface nsIDOMNavigatorBluetooth : nsISupports +{ + readonly attribute nsIDOMBluetoothAdapter mozBluetooth; +}; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/dom-config.mk firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/dom-config.mk --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/dom-config.mk 2012-02-21 02:04:42.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/dom-config.mk 2012-02-22 02:04:51.000000000 +0000 @@ -31,5 +31,9 @@ $(NULL) endif +ifdef MOZ_B2G_BT +DOM_SRCDIRS += dom/bluetooth +endif + LOCAL_INCLUDES += $(DOM_SRCDIRS:%=-I$(topsrcdir)/%) DEFINES += -D_IMPL_NS_LAYOUT diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/indexedDB/FileManager.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/indexedDB/FileManager.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/indexedDB/FileManager.cpp 2012-02-21 02:04:42.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/indexedDB/FileManager.cpp 2012-02-22 02:04:52.000000000 +0000 @@ -42,7 +42,9 @@ #include "mozIStorageServiceQuotaManagement.h" #include "mozIStorageStatement.h" #include "nsISimpleEnumerator.h" + #include "mozStorageCID.h" +#include "mozStorageHelper.h" #include "nsContentUtils.h" #include "FileInfo.h" @@ -93,6 +95,8 @@ NS_ENSURE_SUCCESS(rv, rv); } + mozStorageTransaction transaction(aConnection, false); + rv = aConnection->ExecuteSimpleSQL(NS_LITERAL_CSTRING( "CREATE VIRTUAL TABLE fs USING filesystem;" )); @@ -151,6 +155,7 @@ rv = aDirectory->GetPath(mDirectoryPath); NS_ENSURE_SUCCESS(rv, rv); + transaction.Commit(); return NS_OK; } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/indexedDB/IDBIndex.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/indexedDB/IDBIndex.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/indexedDB/IDBIndex.cpp 2012-02-21 02:04:42.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/indexedDB/IDBIndex.cpp 2012-02-22 02:04:52.000000000 +0000 @@ -308,8 +308,6 @@ NS_ASSERTION(aObjectStore, "Null pointer!"); NS_ASSERTION(aIndexInfo, "Null pointer!"); - IDBDatabase* database = aObjectStore->Transaction()->Database(); - nsRefPtr index = new IDBIndex(); index->mObjectStore = aObjectStore; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/Makefile.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/Makefile.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/Makefile.in 2012-02-21 02:04:41.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/Makefile.in 2012-02-22 02:04:51.000000000 +0000 @@ -97,6 +97,11 @@ $(NULL) endif +ifdef MOZ_B2G_BT +DIRS += \ + bluetooth \ + $(NULL) +endif TEST_DIRS += tests ifneq (,$(filter gtk2 cocoa windows android qt os2,$(MOZ_WIDGET_TOOLKIT))) TEST_DIRS += plugins/test diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/plugins/base/Makefile.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/plugins/base/Makefile.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/plugins/base/Makefile.in 2012-02-21 02:04:48.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/plugins/base/Makefile.in 2012-02-22 02:04:55.000000000 +0000 @@ -132,10 +132,6 @@ endif endif -ifdef MOZ_JAVA_COMPOSITOR -DEFINES += -DMOZ_JAVA_COMPOSITOR -endif - LOCAL_INCLUDES += \ -DSK_BUILD_FOR_ANDROID_NDK \ -I$(topsrcdir)/widget/android \ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/plugins/base/nsJSNPRuntime.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/plugins/base/nsJSNPRuntime.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/plugins/base/nsJSNPRuntime.cpp 2012-02-21 02:04:48.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/plugins/base/nsJSNPRuntime.cpp 2012-02-22 02:04:56.000000000 +0000 @@ -184,8 +184,8 @@ NPObjWrapper_GetProperty, NPObjWrapper_SetProperty, (JSEnumerateOp)NPObjWrapper_newEnumerate, (JSResolveOp)NPObjWrapper_NewResolve, NPObjWrapper_Convert, - NPObjWrapper_Finalize, nsnull, nsnull, NPObjWrapper_Call, - NPObjWrapper_Construct, nsnull, nsnull + NPObjWrapper_Finalize, nsnull, NPObjWrapper_Call, + NPObjWrapper_Construct }; typedef struct NPObjectMemberPrivate { @@ -213,8 +213,8 @@ JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, NPObjectMember_Convert, - NPObjectMember_Finalize, nsnull, nsnull, NPObjectMember_Call, - nsnull, nsnull, nsnull, NPObjectMember_Trace, nsnull + NPObjectMember_Finalize, nsnull, NPObjectMember_Call, + nsnull, nsnull, NPObjectMember_Trace }; static void diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/system/b2g/Makefile.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/system/b2g/Makefile.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/system/b2g/Makefile.in 2012-02-21 02:04:52.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/system/b2g/Makefile.in 2012-02-22 02:05:01.000000000 +0000 @@ -7,6 +7,8 @@ srcdir = @srcdir@ VPATH = @srcdir@ +relativesrcdir = dom/system/b2g + include $(DEPTH)/config/autoconf.mk MODULE = dom @@ -53,4 +55,8 @@ systemlibs.js \ $(NULL) +ifdef ENABLE_TESTS +XPCSHELL_TESTS = tests +endif + include $(topsrcdir)/config/rules.mk diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/system/b2g/RadioInterfaceLayer.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/system/b2g/RadioInterfaceLayer.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/system/b2g/RadioInterfaceLayer.js 2012-02-21 02:04:52.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/system/b2g/RadioInterfaceLayer.js 2012-02-22 02:05:01.000000000 +0000 @@ -319,15 +319,15 @@ }, handleSmsSent: function handleSmsSent(message) { - let message = gSmsService.createSmsMessage(-1, - DOM_SMS_DELIVERY_SENT, - message.SMSC, - message.number, - message.body, - Date.now()); + let sms = gSmsService.createSmsMessage(-1, + DOM_SMS_DELIVERY_SENT, + null, + message.number, + message.body, + Date.now()); //TODO At this point we should save the sms into the DB (bug 712809) - //TODO handle errors (bug XXX) - gSmsRequestManager.notifySmsSent(message.requestId, message); + //TODO handle errors (bug 727319) + gSmsRequestManager.notifySmsSent(message.requestId, sms); }, /** diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/system/b2g/ril_worker.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/system/b2g/ril_worker.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/system/b2g/ril_worker.js 2012-02-21 02:04:52.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/system/b2g/ril_worker.js 2012-02-22 02:05:01.000000000 +0000 @@ -64,7 +64,10 @@ importScripts("ril_consts.js", "systemlibs.js"); -let DEBUG = false; +// We leave this as 'undefined' instead of setting it to 'false'. That +// way an outer scope can define it to 'true' (e.g. for testing purposes) +// without us overriding that here. +let DEBUG; const INT32_MAX = 2147483647; const UINT8_SIZE = 1; @@ -108,6 +111,9 @@ // How many bytes we've read for this parcel so far. this.readIncoming = 0; + // How many bytes available as parcel data. + this.readAvailable = 0; + // Size of the incoming parcel. If this is zero, we're expecting a new // parcel. this.currentParcelSize = 0; @@ -192,13 +198,22 @@ * These are all little endian, apart from readParcelSize(); */ - readUint8: function readUint8() { + readUint8Unchecked: function readUint8Unchecked() { let value = this.incomingBytes[this.incomingReadIndex]; this.incomingReadIndex = (this.incomingReadIndex + 1) % this.INCOMING_BUFFER_LENGTH; return value; }, + readUint8: function readUint8() { + if (!this.readAvailable) { + throw new Error("Trying to read data beyond the parcel end!"); + } + + this.readAvailable--; + return this.readUint8Unchecked(); + }, + readUint16: function readUint16() { return this.readUint8() | this.readUint8() << 8; }, @@ -251,8 +266,10 @@ }, readParcelSize: function readParcelSize() { - return this.readUint8() << 24 | this.readUint8() << 16 | - this.readUint8() << 8 | this.readUint8(); + return this.readUint8Unchecked() << 24 | + this.readUint8Unchecked() << 16 | + this.readUint8Unchecked() << 8 | + this.readUint8Unchecked(); }, /** @@ -412,6 +429,7 @@ if (DEBUG) debug("We have at least one complete parcel."); try { + this.readAvailable = this.currentParcelSize; this.processParcel(); } catch (ex) { if (DEBUG) debug("Parcel handling threw " + ex + "\n" + ex.stack); @@ -427,6 +445,7 @@ this.incomingReadIndex = expectedAfterIndex; } this.readIncoming -= this.currentParcelSize; + this.readAvailable = 0; this.currentParcelSize = 0; } }, @@ -436,13 +455,11 @@ */ processParcel: function processParcel() { let response_type = this.readUint32(); - let length = this.readIncoming - UINT32_SIZE; let request_type, options; if (response_type == RESPONSE_TYPE_SOLICITED) { let token = this.readUint32(); let error = this.readUint32(); - length -= 2 * UINT32_SIZE; options = this.tokenRequestMap[token]; request_type = options.rilRequestType; @@ -462,14 +479,13 @@ this.lastSolicitedToken = token; } else if (response_type == RESPONSE_TYPE_UNSOLICITED) { request_type = this.readUint32(); - length -= UINT32_SIZE; if (DEBUG) debug("Unsolicited response for request type " + request_type); } else { if (DEBUG) debug("Unknown response type: " + response_type); return; } - RIL.handleParcel(request_type, length, options); + RIL.handleParcel(request_type, this.readAvailable, options); }, /** diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/system/b2g/tests/header_helpers.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/system/b2g/tests/header_helpers.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/system/b2g/tests/header_helpers.js 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/system/b2g/tests/header_helpers.js 2012-02-22 02:05:01.000000000 +0000 @@ -0,0 +1,148 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; + + +let subscriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Ci.mozIJSSubScriptLoader); + +/** + * Start a new RIL worker. + * + * @param custom_ns + * Namespace with symbols to be injected into the new worker + * namespace. + * + * @return an object that represents the worker's namespace. + * + * @note that this does not start an actual worker thread. The worker + * is executed on the main thread, within a separate namespace object. + */ +function newWorker(custom_ns) { + let worker_ns = { + importScripts: function fakeImportScripts() { + Array.slice(arguments).forEach(function (script) { + subscriptLoader.loadSubScript("resource://gre/modules/" + script, this); + }, this); + }, + + postRILMessage: function fakePostRILMessage(message) { + }, + + postMessage: function fakepostMessage(message) { + }, + + // Define these variables inside the worker scope so ES5 strict mode + // doesn't flip out. + onmessage: undefined, + onerror: undefined, + + DEBUG: true + }; + // The 'self' variable in a worker points to the worker's own namespace. + worker_ns.self = worker_ns; + + // Copy the custom definitions over. + for (let key in custom_ns) { + worker_ns[key] = custom_ns[key]; + } + + // Load the RIL worker itself. + worker_ns.importScripts("ril_worker.js"); + + return worker_ns; +} + +/** + * Create a parcel suitable for postRILMessage(). + * + * @param fakeParcelSize + * Value to be written to parcel size field for testing + * incorrect/incomplete parcel reading. Replaced with correct + * one determined length of data if negative. + * @param response + * Response code of the incoming parcel. + * @param request + * Request code of the incoming parcel. + * @param data + * Extra data to be appended. + * + * @return an Uint8Array carrying all parcel data. + */ +function newIncomingParcel(fakeParcelSize, response, request, data) { + const UINT32_SIZE = 4; + const PARCEL_SIZE_SIZE = 4; + + let realParcelSize = data.length + 2 * UINT32_SIZE; + let buffer = new ArrayBuffer(realParcelSize + PARCEL_SIZE_SIZE); + let bytes = new Uint8Array(buffer); + + let writeIndex = 0; + function writeUint8(value) { + bytes[writeIndex] = value; + ++writeIndex; + } + + function writeUint32(value) { + writeUint8(value & 0xff); + writeUint8((value >> 8) & 0xff); + writeUint8((value >> 16) & 0xff); + writeUint8((value >> 24) & 0xff); + } + + function writeParcelSize(value) { + writeUint8((value >> 24) & 0xff); + writeUint8((value >> 16) & 0xff); + writeUint8((value >> 8) & 0xff); + writeUint8(value & 0xff); + } + + if (fakeParcelSize < 0) { + fakeParcelSize = realParcelSize; + } + writeParcelSize(fakeParcelSize); + + writeUint32(response); + writeUint32(request); + + // write parcel data + for (let ii = 0; ii < data.length; ++ii) { + writeUint8(data[ii]); + } + + return bytes; +} + +/** + * Test whether specified function throws exception with expected + * result. + * + * @param func + * Function to be tested. + * @param result + * Expected result. null for no throws. + * @param stack + * Optional stack object to be printed. null for + * Components#stack#caller. + */ +function do_check_throws(func, result, stack) +{ + if (!stack) + stack = Components.stack.caller; + + try { + func(); + } catch (exc) { + if (exc.result == result) + return; + do_throw("expected result " + result + ", caught " + exc, stack); + } + + if (result) { + do_throw("expected result " + result + ", none thrown", stack); + } +} + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/system/b2g/tests/test_ril_worker_buf.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/system/b2g/tests/test_ril_worker_buf.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/system/b2g/tests/test_ril_worker_buf.js 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/system/b2g/tests/test_ril_worker_buf.js 2012-02-22 02:05:01.000000000 +0000 @@ -0,0 +1,84 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function run_test() { + run_next_test(); +} + +/** + * Add test function with specified parcel and request handler. + * + * @param parcel + * Incoming parcel to be tested. + * @param handler + * Handler to be invoked as RIL request handler. + */ +function add_test_incoming_parcel(parcel, handler) { + add_test(function test_incoming_parcel() { + let worker = newWorker({ + postRILMessage: function fakePostRILMessage(data) { + // do nothing + }, + postMessage: function fakePostMessage(message) { + // do nothing + } + }); + + if (!parcel) { + parcel = newIncomingParcel(-1, + worker.RESPONSE_TYPE_UNSOLICITED, + worker.REQUEST_REGISTRATION_STATE, + [0, 0, 0, 0]); + } + + // supports only requests less or equal than UINT8_MAX(255). + let request = parcel[worker.PARCEL_SIZE_SIZE + worker.UINT32_SIZE]; + worker.RIL[request] = function ril_request_handler() { + handler(worker); + worker.postMessage(); + }; + + worker.onRILMessage(parcel); + + // end of incoming parcel's trip, let's do next test. + run_next_test(); + }); +} + +// Test normal parcel handling. +add_test_incoming_parcel(null, + function test_normal_parcel_handling(worker) { + do_check_throws(function normal_handler(worker) { + // reads exactly the same size, should not throw anything. + worker.Buf.readUint32(); + }); + } +); + +// Test parcel under read. +add_test_incoming_parcel(null, + function test_parcel_under_read(worker) { + do_check_throws(function under_read_handler() { + // reads less than parcel size, should not throw. + worker.Buf.readUint16(); + }, false); + } +); + +// Test parcel over read. +add_test_incoming_parcel(null, + function test_parcel_over_read(worker) { + let buf = worker.Buf; + + // read all data available + while (buf.readAvailable > 0) { + buf.readUint8(); + } + + do_check_throws(function over_read_handler() { + // reads more than parcel size, should throw an error. + buf.readUint8(); + }, new Error("Trying to read data beyond the parcel end!").result); + } +); + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/system/b2g/tests/xpcshell.ini firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/system/b2g/tests/xpcshell.ini --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/system/b2g/tests/xpcshell.ini 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/system/b2g/tests/xpcshell.ini 2012-02-22 02:05:01.000000000 +0000 @@ -0,0 +1,5 @@ +[DEFAULT] +head = header_helpers.js +tail = + +[test_ril_worker_buf.js] diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/wifi/nsWifiWorker.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/wifi/nsWifiWorker.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/wifi/nsWifiWorker.js 2012-02-21 02:05:03.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/wifi/nsWifiWorker.js 2012-02-22 02:05:25.000000000 +0000 @@ -732,7 +732,7 @@ manager.reassociate = reassociateCommand; var networkConfigurationFields = ["ssid", "bssid", "psk", "wep_key0", "wep_key1", "wep_key2", "wep_key3", - "wep_tx_keyidx", "priority", "key_mgmt", "scan_ssid"]; + "wep_tx_keyidx", "priority", "key_mgmt", "scan_ssid", "disabled"]; manager.getNetworkConfiguration = function(config, callback) { var netId = config.netId; @@ -879,35 +879,27 @@ // TODO Remove me in favor of UI and a way to select a network. debug("Haven't connected to a network, trying a default (for now)"); - var name = "Mozilla"; - var net = self.networks[name]; - if (net && (net.flags && net.flags !== "[IBSS]")) { - debug("Network Mozilla exists, but is encrypted"); - net = null; - } - - var config = Object.create(null); - if (!net) { - name = "Mozilla Guest"; - net = self.networks[name]; - if (!net || (net.flags && net.flags !== "[IBSS]")) { - debug("Can't find either network, trying to force 'Mozilla Guest'"); - config.scan_ssid = 1; - } - } - - config.ssid = '"' + name + '"'; - config.key_mgmt = "NONE"; - WifiManager.addNetwork(config, function(ok) { - if (!ok) { - debug("Unable to add the network!"); - return; - } + var configs = [ + { "ssid": '"mozilla demo"', "key_mgmt": "NONE", "disabled": 0 }, + { "ssid": '"Mozilla"', "key_mgmt": "NONE", "disabled": 0 }, + { "ssid": '"Mozilla Guest"', "key_mgmt": "NONE", "scan_ssid": 1, "disabled": 0 }, + ]; + + var i = 0; + function addThem() { + WifiManager.addNetwork(configs[i++], function(ok) { + if (!ok) { + debug("Unable to add the network!"); + return; + } - WifiManager.enableNetwork(config.netId, false, function(ok) { - debug((ok ? "Successfully enabled " : "Didn't enable ") + name); + if (i < configs.length) { + addThem(); + return; + } }); - }); + } + addThem(); } this.waitForScan(connectToMozilla); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/Events.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/Events.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/Events.cpp 2012-02-21 02:05:03.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/Events.cpp 2012-02-22 02:05:25.000000000 +0000 @@ -50,7 +50,7 @@ #include "WorkerPrivate.h" #define PROPERTY_FLAGS \ - JSPROP_ENUMERATE | JSPROP_SHARED + (JSPROP_ENUMERATE | JSPROP_SHARED) #define FUNCTION_FLAGS \ JSPROP_ENUMERATE diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/Exceptions.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/Exceptions.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/Exceptions.cpp 2012-02-21 02:05:03.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/Exceptions.cpp 2012-02-22 02:05:25.000000000 +0000 @@ -50,7 +50,7 @@ #include "WorkerInlines.h" #define PROPERTY_FLAGS \ - JSPROP_ENUMERATE | JSPROP_SHARED + (JSPROP_ENUMERATE | JSPROP_SHARED) #define CONSTANT_FLAGS \ JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_PERMANENT | JSPROP_READONLY diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/File.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/File.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/File.cpp 2012-02-21 02:05:03.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/File.cpp 2012-02-22 02:05:25.000000000 +0000 @@ -53,7 +53,7 @@ #include "WorkerPrivate.h" #define PROPERTY_FLAGS \ - JSPROP_ENUMERATE | JSPROP_SHARED + (JSPROP_ENUMERATE | JSPROP_SHARED) USING_WORKERS_NAMESPACE diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/Location.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/Location.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/Location.cpp 2012-02-21 02:05:03.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/Location.cpp 2012-02-22 02:05:25.000000000 +0000 @@ -44,7 +44,7 @@ #include "nsTraceRefcnt.h" #define PROPERTY_FLAGS \ - JSPROP_ENUMERATE | JSPROP_SHARED + (JSPROP_ENUMERATE | JSPROP_SHARED) USING_WORKERS_NAMESPACE diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/Navigator.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/Navigator.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/Navigator.cpp 2012-02-21 02:05:03.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/Navigator.cpp 2012-02-22 02:05:25.000000000 +0000 @@ -46,7 +46,7 @@ #include "RuntimeService.h" #define PROPERTY_FLAGS \ - JSPROP_ENUMERATE | JSPROP_SHARED + (JSPROP_ENUMERATE | JSPROP_SHARED) USING_WORKERS_NAMESPACE diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/Worker.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/Worker.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/Worker.cpp 2012-02-21 02:05:03.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/Worker.cpp 2012-02-22 02:05:25.000000000 +0000 @@ -48,7 +48,7 @@ #include "WorkerInlines.h" #define PROPERTY_FLAGS \ - JSPROP_ENUMERATE | JSPROP_SHARED + (JSPROP_ENUMERATE | JSPROP_SHARED) #define FUNCTION_FLAGS \ JSPROP_ENUMERATE @@ -302,8 +302,8 @@ "Worker", JSCLASS_HAS_PRIVATE | JSCLASS_IMPLEMENTS_BARRIERS, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, - JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize, NULL, NULL, NULL, - NULL, NULL, NULL, Trace, NULL + JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize, + NULL, NULL, NULL, NULL, Trace, }; JSPropertySpec Worker::sProperties[] = { @@ -417,8 +417,8 @@ "ChromeWorker", JSCLASS_HAS_PRIVATE | JSCLASS_IMPLEMENTS_BARRIERS, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, - JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize, NULL, NULL, NULL, - NULL, NULL, NULL, Trace, NULL + JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize, + NULL, NULL, NULL, NULL, Trace }; WorkerPrivate* diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/WorkerScope.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/WorkerScope.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/WorkerScope.cpp 2012-02-21 02:05:04.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/WorkerScope.cpp 2012-02-22 02:05:25.000000000 +0000 @@ -68,7 +68,7 @@ #include "WorkerInlines.h" #define PROPERTY_FLAGS \ - JSPROP_ENUMERATE | JSPROP_SHARED + (JSPROP_ENUMERATE | JSPROP_SHARED) #define FUNCTION_FLAGS \ JSPROP_ENUMERATE @@ -802,7 +802,7 @@ JSCLASS_GLOBAL_FLAGS | JSCLASS_HAS_PRIVATE | JSCLASS_IMPLEMENTS_BARRIERS | JSCLASS_NEW_RESOLVE, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, reinterpret_cast(Resolve), JS_ConvertStub, - Finalize, NULL, NULL, NULL, NULL, NULL, NULL, Trace, NULL + Finalize, NULL, NULL, NULL, NULL, Trace }; JSPropertySpec DedicatedWorkerGlobalScope::sProperties[] = { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/XMLHttpRequest.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/XMLHttpRequest.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/XMLHttpRequest.cpp 2012-02-21 02:05:04.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/XMLHttpRequest.cpp 2012-02-22 02:05:25.000000000 +0000 @@ -48,13 +48,13 @@ #include "WorkerInlines.h" #define PROPERTY_FLAGS \ - JSPROP_ENUMERATE | JSPROP_SHARED + (JSPROP_ENUMERATE | JSPROP_SHARED) #define FUNCTION_FLAGS \ JSPROP_ENUMERATE #define CONSTANT_FLAGS \ - JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_PERMANENT | JSPROP_READONLY + (JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_PERMANENT | JSPROP_READONLY) USING_WORKERS_NAMESPACE @@ -223,7 +223,7 @@ JSCLASS_HAS_PRIVATE | JSCLASS_IMPLEMENTS_BARRIERS | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT), JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize, - NULL, NULL, NULL, NULL, NULL, NULL, Trace, NULL + NULL, NULL, NULL, NULL, Trace }; JSPropertySpec XMLHttpRequestUpload::sProperties[] = { @@ -772,7 +772,7 @@ JSCLASS_HAS_PRIVATE | JSCLASS_IMPLEMENTS_BARRIERS | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT), JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize, - NULL, NULL, NULL, NULL, NULL, NULL, Trace, NULL + NULL, NULL, NULL, NULL, Trace }; JSPropertySpec XMLHttpRequest::sProperties[] = { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/XMLHttpRequestPrivate.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/XMLHttpRequestPrivate.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/dom/workers/XMLHttpRequestPrivate.cpp 2012-02-21 02:05:04.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/dom/workers/XMLHttpRequestPrivate.cpp 2012-02-22 02:05:25.000000000 +0000 @@ -916,11 +916,11 @@ class GetAllResponseHeadersRunnable : public WorkerThreadProxySyncRunnable { - nsCString& mResponseHeaders; + nsString& mResponseHeaders; public: GetAllResponseHeadersRunnable(WorkerPrivate* aWorkerPrivate, Proxy* aProxy, - nsCString& aResponseHeaders) + nsString& aResponseHeaders) : WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy), mResponseHeaders(aResponseHeaders) { } @@ -929,7 +929,7 @@ MainThreadRun() { nsresult rv = - mProxy->mXHR->GetAllResponseHeaders(getter_Copies(mResponseHeaders)); + mProxy->mXHR->GetAllResponseHeaders(mResponseHeaders); return GetDOMExceptionCodeFromResult(rv); } }; @@ -1613,15 +1613,15 @@ return nsnull; } - nsCString responseHeaders; + nsString responseHeaders; nsRefPtr runnable = new GetAllResponseHeadersRunnable(mWorkerPrivate, mProxy, responseHeaders); if (!runnable->Dispatch(aCx)) { return nsnull; } - return JS_NewStringCopyN(aCx, responseHeaders.get(), - responseHeaders.Length()); + return JS_NewUCStringCopyN(aCx, responseHeaders.get(), + responseHeaders.Length()); } JSString* diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/gl/GLContext.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/gl/GLContext.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/gl/GLContext.cpp 2012-02-21 02:05:44.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/gl/GLContext.cpp 2012-02-22 02:05:45.000000000 +0000 @@ -558,6 +558,9 @@ { MakeCurrent(); const GLubyte *extensions = fGetString(LOCAL_GL_EXTENSIONS); + if (!extensions) + return; + char *exts = strdup((char *)extensions); #ifdef DEBUG diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/Makefile.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/Makefile.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/Makefile.in 2012-02-21 02:05:59.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/Makefile.in 2012-02-22 02:05:56.000000000 +0000 @@ -54,7 +54,7 @@ nsIFontEnumerator.idl \ nsIScriptableRegion.idl \ $(NULL) - + EXPORTS = \ gfxCore.h \ gfxCrashReporterUtils.h \ @@ -103,34 +103,6 @@ CPPSRCS += X11Util.cpp endif -ifeq ($(MOZ_WIDGET_TOOLKIT),android) -CPPSRCS += nsSystemFontsAndroid.cpp -endif - -ifeq ($(MOZ_WIDGET_TOOLKIT),gonk) -CPPSRCS += nsSystemFontsAndroid.cpp -endif - -ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) -CMMSRCS = nsSystemFontsMac.mm -endif - -ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2) -CPPSRCS += nsSystemFontsGTK2.cpp -endif - -ifeq ($(MOZ_WIDGET_TOOLKIT),os2) -CPPSRCS += nsSystemFontsOS2.cpp -endif - -ifeq ($(MOZ_WIDGET_TOOLKIT),qt) -CPPSRCS += nsSystemFontsQt.cpp -endif - -ifeq ($(MOZ_WIDGET_TOOLKIT),windows) -CPPSRCS += nsSystemFontsWin.cpp -endif - include $(topsrcdir)/config/rules.mk CXXFLAGS += $(TK_CFLAGS) $(MOZ_CAIRO_CFLAGS) diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsDeviceContext.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsDeviceContext.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsDeviceContext.cpp 2012-02-21 02:05:59.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsDeviceContext.cpp 2012-02-22 02:05:56.000000000 +0000 @@ -54,39 +54,18 @@ #include "gfxImageSurface.h" -#ifdef MOZ_ENABLE_GTK2 -#include "nsSystemFontsGTK2.h" +#if !XP_MACOSX #include "gfxPDFSurface.h" +#endif + +#ifdef MOZ_ENABLE_GTK2 #include "gfxPSSurface.h" -static nsSystemFontsGTK2 *gSystemFonts = nsnull; #elif XP_WIN -#include "nsSystemFontsWin.h" #include "gfxWindowsSurface.h" -#include "gfxPDFSurface.h" -static nsSystemFontsWin *gSystemFonts = nsnull; #elif defined(XP_OS2) -#include "nsSystemFontsOS2.h" #include "gfxOS2Surface.h" -#include "gfxPDFSurface.h" -static nsSystemFontsOS2 *gSystemFonts = nsnull; #elif XP_MACOSX -#include "nsSystemFontsMac.h" #include "gfxQuartzSurface.h" -static nsSystemFontsMac *gSystemFonts = nsnull; -#elif defined(MOZ_WIDGET_QT) -#include "nsSystemFontsQt.h" -#include "gfxPDFSurface.h" -static nsSystemFontsQt *gSystemFonts = nsnull; -#elif defined(MOZ_WIDGET_ANDROID) -#include "nsSystemFontsAndroid.h" -#include "gfxPDFSurface.h" -static nsSystemFontsAndroid *gSystemFonts = nsnull; -#elif defined(MOZ_WIDGET_GONK) -#include "nsSystemFontsAndroid.h" -#include "gfxPDFSurface.h" -static nsSystemFontsAndroid *gSystemFonts = nsnull; -#else -#error Need to declare gSystemFonts! #endif using namespace mozilla; @@ -452,55 +431,6 @@ return NS_OK; } -/* static */ void -nsDeviceContext::ClearCachedSystemFonts() -{ - if (gSystemFonts) { - delete gSystemFonts; - gSystemFonts = nsnull; - } -} - -nsresult -nsDeviceContext::GetSystemFont(nsSystemFontID aID, nsFont *aFont) const -{ - if (!gSystemFonts) { -#ifdef MOZ_ENABLE_GTK2 - gSystemFonts = new nsSystemFontsGTK2(); -#elif XP_WIN - gSystemFonts = new nsSystemFontsWin(); -#elif XP_OS2 - gSystemFonts = new nsSystemFontsOS2(); -#elif XP_MACOSX - gSystemFonts = new nsSystemFontsMac(); -#elif defined(MOZ_WIDGET_QT) - gSystemFonts = new nsSystemFontsQt(); -#elif defined(ANDROID) - gSystemFonts = new nsSystemFontsAndroid(); -#else -#error Need to know how to create gSystemFonts, fix me! -#endif - } - - nsString fontName; - gfxFontStyle fontStyle; - nsresult rv = gSystemFonts->GetSystemFont(aID, &fontName, &fontStyle); - NS_ENSURE_SUCCESS(rv, rv); - - aFont->name = fontName; - aFont->style = fontStyle.style; - aFont->systemFont = fontStyle.systemFont; - aFont->variant = NS_FONT_VARIANT_NORMAL; - aFont->weight = fontStyle.weight; - aFont->stretch = fontStyle.stretch; - aFont->decorations = NS_FONT_DECORATION_NONE; - aFont->size = NSFloatPixelsToAppUnits(fontStyle.size, UnscaledAppUnitsPerDevPixel()); - //aFont->langGroup = fontStyle.langGroup; - aFont->sizeAdjust = fontStyle.sizeAdjust; - - return rv; -} - nsresult nsDeviceContext::GetDepth(PRUint32& aDepth) { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsDeviceContext.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsDeviceContext.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsDeviceContext.h 2012-02-21 02:05:59.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsDeviceContext.h 2012-02-22 02:05:56.000000000 +0000 @@ -51,29 +51,6 @@ class nsFontCache; class gfxUserFontSet; -typedef enum { - eSystemFont_Caption, // css2 - eSystemFont_Icon, - eSystemFont_Menu, - eSystemFont_MessageBox, - eSystemFont_SmallCaption, - eSystemFont_StatusBar, - - eSystemFont_Window, // css3 - eSystemFont_Document, - eSystemFont_Workspace, - eSystemFont_Desktop, - eSystemFont_Info, - eSystemFont_Dialog, - eSystemFont_Button, - eSystemFont_PullDownMenu, - eSystemFont_List, - eSystemFont_Field, - - eSystemFont_Tooltips, // moz - eSystemFont_Widget -} nsSystemFontID; - class nsDeviceContext { public: @@ -151,22 +128,6 @@ { return mAppUnitsPerDevNotScaledPixel; } /** - * Fill in an nsFont based on the ID of a system font. This function - * may or may not fill in the size, so the size should be set to a - * reasonable default before calling. - * - * @param aID The system font ID. - * @param aInfo The font structure to be filled in. - * @return error status - */ - nsresult GetSystemFont(nsSystemFontID aID, nsFont *aFont) const; - - /** - * Clear cached system fonts (refresh from theme when requested). - */ - static void ClearCachedSystemFonts(); - - /** * Get the nsFontMetrics that describe the properties of * an nsFont. * @param aFont font description to obtain metrics for diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsAndroid.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsAndroid.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsAndroid.cpp 2012-02-21 02:06:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsAndroid.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** 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 Android port - * - * The Initial Developer of the Original Code is mozilla.org. - * Portions created by the Initial Developer are Copyright (C) 2009 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Vladimir Vukicevic - * - * 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 ***** */ - -#include "nsSystemFontsAndroid.h" -#include "gfxPlatform.h" - -#define DEFAULT_FONT "Droid Sans" - -nsSystemFontsAndroid::nsSystemFontsAndroid() - : mDefaultFontName(NS_LITERAL_STRING(DEFAULT_FONT)) - , mButtonFontName(NS_LITERAL_STRING(DEFAULT_FONT)) - , mFieldFontName(NS_LITERAL_STRING(DEFAULT_FONT)) - , mMenuFontName(NS_LITERAL_STRING(DEFAULT_FONT)) -{ -} - -nsSystemFontsAndroid::~nsSystemFontsAndroid() -{ -} - -nsresult -nsSystemFontsAndroid::GetSystemFontInfo(const char *aClassName, nsString *aFontName, - gfxFontStyle *aFontStyle) const -{ - aFontStyle->style = FONT_STYLE_NORMAL; - aFontStyle->systemFont = true; - *aFontName = NS_LITERAL_STRING("Droid Sans"); - aFontStyle->weight = 400; - aFontStyle->stretch = NS_FONT_STRETCH_NORMAL; - aFontStyle->size = 9.0 * 96.0f / 72.0f; - return NS_OK; -} - - -nsresult -nsSystemFontsAndroid::GetSystemFont(nsSystemFontID anID, nsString *aFontName, - gfxFontStyle *aFontStyle) const -{ - switch (anID) { - case eSystemFont_Menu: // css2 - case eSystemFont_PullDownMenu: // css3 - *aFontName = mMenuFontName; - *aFontStyle = mMenuFontStyle; - break; - - case eSystemFont_Field: // css3 - case eSystemFont_List: // css3 - *aFontName = mFieldFontName; - *aFontStyle = mFieldFontStyle; - break; - - case eSystemFont_Button: // css3 - *aFontName = mButtonFontName; - *aFontStyle = mButtonFontStyle; - break; - - case eSystemFont_Caption: // css2 - case eSystemFont_Icon: // css2 - case eSystemFont_MessageBox: // css2 - case eSystemFont_SmallCaption: // css2 - case eSystemFont_StatusBar: // css2 - case eSystemFont_Window: // css3 - case eSystemFont_Document: // css3 - case eSystemFont_Workspace: // css3 - case eSystemFont_Desktop: // css3 - case eSystemFont_Info: // css3 - case eSystemFont_Dialog: // css3 - case eSystemFont_Tooltips: // moz - case eSystemFont_Widget: // moz - *aFontName = mDefaultFontName; - *aFontStyle = mDefaultFontStyle; - break; - } - - return NS_OK; -} - diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsAndroid.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsAndroid.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsAndroid.h 2012-02-21 02:06:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsAndroid.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** 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 Android port - * - * The Initial Developer of the Original Code is mozilla.org. - * Portions created by the Initial Developer are Copyright (C) 2009 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Vladimir Vukicevic - * - * 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 ***** */ - -#ifndef _NS_SYSTEMFONTSANDROID_H_ -#define _NS_SYSTEMFONTSANDROID_H_ - -#include "gfxFont.h" -#include "nsDeviceContext.h" - -class nsSystemFontsAndroid -{ -public: - nsSystemFontsAndroid(); - ~nsSystemFontsAndroid(); - - nsresult GetSystemFont(nsSystemFontID anID, nsString *aFontName, - gfxFontStyle *aFontStyle) const; - -private: - - nsresult GetSystemFontInfo(const char *aClassName, nsString *aFontName, - gfxFontStyle *aFontStyle) const; - - /* - * The following system font constants exist: - * - * css2: http://www.w3.org/TR/REC-CSS2/fonts.html#x27 - * eSystemFont_Caption, eSystemFont_Icon, eSystemFont_Menu, - * eSystemFont_MessageBox, eSystemFont_SmallCaption, - * eSystemFont_StatusBar, - * // css3 - * eSystemFont_Window, eSystemFont_Document, - * eSystemFont_Workspace, eSystemFont_Desktop, - * eSystemFont_Info, eSystemFont_Dialog, - * eSystemFont_Button, eSystemFont_PullDownMenu, - * eSystemFont_List, eSystemFont_Field, - * // moz - * eSystemFont_Tooltips, eSystemFont_Widget - */ - nsString mDefaultFontName, mButtonFontName, mFieldFontName, mMenuFontName; - gfxFontStyle mDefaultFontStyle, mButtonFontStyle, mFieldFontStyle, mMenuFontStyle; -}; - -#endif /* _NS_SYSTEMFONTSANDROID_H_ */ - diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsGTK2.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsGTK2.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsGTK2.cpp 2012-02-21 02:06:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsGTK2.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,287 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** 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 thebes gfx - * - * The Initial Developer of the Original Code is mozilla.org. - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Vladimir Vukicevic - * Stuart Parmenter - * - * 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 ***** */ - -// for strtod() -#include - -#include "nsSystemFontsGTK2.h" -#include "prlink.h" - -#include -#include - -#ifdef MOZ_PANGO -#include -#include -#endif - -#include -#include "gfxPlatformGtk.h" - -// Glue to avoid build/runtime dependencies on Pango > 1.6 -#if defined(MOZ_PANGO) && !defined(THEBES_USE_PANGO_CAIRO) -static gboolean -(* PTR_pango_font_description_get_size_is_absolute)(PangoFontDescription*) - = nsnull; - -static void InitPangoLib() -{ - static bool initialized = false; - if (initialized) - return; - initialized = true; - - PRLibrary *pangoLib = nsnull; - PTR_pango_font_description_get_size_is_absolute = - (gboolean (*)(PangoFontDescription*)) - PR_FindFunctionSymbolAndLibrary("pango_font_description_get_size_is_absolute", - &pangoLib); - if (pangoLib) - PR_UnloadLibrary(pangoLib); -} - -static void -ShutdownPangoLib() -{ -} - -static gboolean -MOZ_pango_font_description_get_size_is_absolute(PangoFontDescription *desc) -{ - if (PTR_pango_font_description_get_size_is_absolute) { - return PTR_pango_font_description_get_size_is_absolute(desc); - } - - // In old versions of pango, this was always false. - return false; -} -#else -static inline void InitPangoLib() -{ -} - -static inline void ShutdownPangoLib() -{ -} - -#ifdef MOZ_PANGO -static inline gboolean -MOZ_pango_font_description_get_size_is_absolute(PangoFontDescription *desc) -{ - pango_font_description_get_size_is_absolute(desc); -} -#endif -#endif - -nsSystemFontsGTK2::nsSystemFontsGTK2() - : mDefaultFontName(NS_LITERAL_STRING("sans-serif")) - , mButtonFontName(NS_LITERAL_STRING("sans-serif")) - , mFieldFontName(NS_LITERAL_STRING("sans-serif")) - , mMenuFontName(NS_LITERAL_STRING("sans-serif")) -{ - InitPangoLib(); - - /* - * Much of the widget creation code here is similar to the code in - * nsLookAndFeel::InitColors(). - */ - - // mDefaultFont - GtkWidget *label = gtk_label_new("M"); - GtkWidget *parent = gtk_fixed_new(); - GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP); - - gtk_container_add(GTK_CONTAINER(parent), label); - gtk_container_add(GTK_CONTAINER(window), parent); - - gtk_widget_ensure_style(label); - - GetSystemFontInfo(label, &mDefaultFontName, &mDefaultFontStyle); - - gtk_widget_destroy(window); // no unref, windows are different - - // mFieldFont - GtkWidget *entry = gtk_entry_new(); - parent = gtk_fixed_new(); - window = gtk_window_new(GTK_WINDOW_POPUP); - - gtk_container_add(GTK_CONTAINER(parent), entry); - gtk_container_add(GTK_CONTAINER(window), parent); - gtk_widget_ensure_style(entry); - - GetSystemFontInfo(entry, &mFieldFontName, &mFieldFontStyle); - - gtk_widget_destroy(window); // no unref, windows are different - - // mMenuFont - GtkWidget *accel_label = gtk_accel_label_new("M"); - GtkWidget *menuitem = gtk_menu_item_new(); - GtkWidget *menu = gtk_menu_new(); - g_object_ref_sink(GTK_OBJECT(menu)); - - gtk_container_add(GTK_CONTAINER(menuitem), accel_label); - gtk_menu_shell_append((GtkMenuShell *)GTK_MENU(menu), menuitem); - - gtk_widget_ensure_style(accel_label); - - GetSystemFontInfo(accel_label, &mMenuFontName, &mMenuFontStyle); - - g_object_unref(menu); - - // mButtonFont - parent = gtk_fixed_new(); - GtkWidget *button = gtk_button_new(); - label = gtk_label_new("M"); - window = gtk_window_new(GTK_WINDOW_POPUP); - - gtk_container_add(GTK_CONTAINER(button), label); - gtk_container_add(GTK_CONTAINER(parent), button); - gtk_container_add(GTK_CONTAINER(window), parent); - - gtk_widget_ensure_style(label); - - GetSystemFontInfo(label, &mButtonFontName, &mButtonFontStyle); - - gtk_widget_destroy(window); // no unref, windows are different -} - -nsSystemFontsGTK2::~nsSystemFontsGTK2() -{ - ShutdownPangoLib(); -} - -nsresult -nsSystemFontsGTK2::GetSystemFontInfo(GtkWidget *aWidget, nsString *aFontName, - gfxFontStyle *aFontStyle) const -{ -#ifdef MOZ_PANGO - GtkSettings *settings = gtk_widget_get_settings(aWidget); - - aFontStyle->style = FONT_STYLE_NORMAL; - - gchar *fontname; - g_object_get(settings, "gtk-font-name", &fontname, NULL); - - PangoFontDescription *desc; - desc = pango_font_description_from_string(fontname); - - aFontStyle->systemFont = true; - - g_free(fontname); - - NS_NAMED_LITERAL_STRING(quote, "\""); - NS_ConvertUTF8toUTF16 family(pango_font_description_get_family(desc)); - *aFontName = quote + family + quote; - - aFontStyle->weight = pango_font_description_get_weight(desc); - - // FIXME: Set aFontStyle->stretch correctly! - aFontStyle->stretch = NS_FONT_STRETCH_NORMAL; - - float size = float(pango_font_description_get_size(desc)) / PANGO_SCALE; - - // |size| is now either pixels or pango-points (not Mozilla-points!) - - if (!MOZ_pango_font_description_get_size_is_absolute(desc)) { - // |size| is in pango-points, so convert to pixels. - size *= float(gfxPlatformGtk::GetDPI()) / POINTS_PER_INCH_FLOAT; - } - - // |size| is now pixels - - aFontStyle->size = size; - - pango_font_description_free(desc); - -#else - /* FIXME: DFB FT2 Hardcoding the system font info for now.. */ - aFontStyle->style = FONT_STYLE_NORMAL; - aFontStyle->systemFont = true; - - NS_NAMED_LITERAL_STRING(fontname, "\"Sans\""); - *aFontName = fontname; - aFontStyle->weight = 400; - aFontStyle->size = 40/3; - -#endif - - return NS_OK; -} - -nsresult -nsSystemFontsGTK2::GetSystemFont(nsSystemFontID anID, nsString *aFontName, - gfxFontStyle *aFontStyle) const -{ - switch (anID) { - case eSystemFont_Menu: // css2 - case eSystemFont_PullDownMenu: // css3 - *aFontName = mMenuFontName; - *aFontStyle = mMenuFontStyle; - break; - - case eSystemFont_Field: // css3 - case eSystemFont_List: // css3 - *aFontName = mFieldFontName; - *aFontStyle = mFieldFontStyle; - break; - - case eSystemFont_Button: // css3 - *aFontName = mButtonFontName; - *aFontStyle = mButtonFontStyle; - break; - - case eSystemFont_Caption: // css2 - case eSystemFont_Icon: // css2 - case eSystemFont_MessageBox: // css2 - case eSystemFont_SmallCaption: // css2 - case eSystemFont_StatusBar: // css2 - case eSystemFont_Window: // css3 - case eSystemFont_Document: // css3 - case eSystemFont_Workspace: // css3 - case eSystemFont_Desktop: // css3 - case eSystemFont_Info: // css3 - case eSystemFont_Dialog: // css3 - case eSystemFont_Tooltips: // moz - case eSystemFont_Widget: // moz - *aFontName = mDefaultFontName; - *aFontStyle = mDefaultFontStyle; - break; - } - - return NS_OK; -} diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsGTK2.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsGTK2.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsGTK2.h 2012-02-21 02:06:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsGTK2.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** 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 thebes gfx - * - * The Initial Developer of the Original Code is mozilla.org. - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Vladimir Vukicevic - * Stuart Parmenter - * - * 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 ***** */ - -#ifndef _NS_SYSTEMFONTSGTK2_H_ -#define _NS_SYSTEMFONTSGTK2_H_ - -#include "gfxFont.h" -#include "nsDeviceContext.h" - -typedef struct _GtkWidget GtkWidget; - -class nsSystemFontsGTK2 -{ -public: - nsSystemFontsGTK2(); - ~nsSystemFontsGTK2(); - - nsresult GetSystemFont(nsSystemFontID anID, nsString *aFontName, - gfxFontStyle *aFontStyle) const; - -private: - - nsresult GetSystemFontInfo(GtkWidget *aWidget, nsString *aFontName, - gfxFontStyle *aFontStyle) const; - - /* - * The following system font constants exist: - * - * css2: http://www.w3.org/TR/REC-CSS2/fonts.html#x27 - * eSystemFont_Caption, eSystemFont_Icon, eSystemFont_Menu, - * eSystemFont_MessageBox, eSystemFont_SmallCaption, - * eSystemFont_StatusBar, - * // css3 - * eSystemFont_Window, eSystemFont_Document, - * eSystemFont_Workspace, eSystemFont_Desktop, - * eSystemFont_Info, eSystemFont_Dialog, - * eSystemFont_Button, eSystemFont_PullDownMenu, - * eSystemFont_List, eSystemFont_Field, - * // moz - * eSystemFont_Tooltips, eSystemFont_Widget - */ - nsString mDefaultFontName, mButtonFontName, mFieldFontName, mMenuFontName; - gfxFontStyle mDefaultFontStyle, mButtonFontStyle, mFieldFontStyle, mMenuFontStyle; -}; - -#endif /* _NS_SYSTEMFONTSGTK2_H_ */ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsMac.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsMac.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsMac.h 2012-02-21 02:06:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsMac.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Corporation code. - * - * The Initial Developer of the Original Code is Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2006 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Vladimir Vukicevic - * - * 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 ***** */ - -#ifndef _NS_SYSTEMFONTSMAC_H_ -#define _NS_SYSTEMFONTSMAC_H_ - -#include "gfxFont.h" -#include "nsDeviceContext.h" - -class nsSystemFontsMac -{ -public: - nsSystemFontsMac(); - nsresult GetSystemFont(nsSystemFontID anID, nsString *aFontName, - gfxFontStyle *aFontStyle) const; -}; - -#endif /* _NS_SYSTEMFONTSMAC_H_ */ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsMac.mm firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsMac.mm --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsMac.mm 2012-02-21 02:06:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsMac.mm 1970-01-01 00:00:00.000000000 +0000 @@ -1,167 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Corporation code. - * - * The Initial Developer of the Original Code is Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2006-2009 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Vladimir Vukicevic - * Jonathan Kew - * - * 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 ***** */ - -#include "nsSystemFontsMac.h" -#include - -nsSystemFontsMac::nsSystemFontsMac() -{ -} - -// copied from gfxQuartzFontCache.mm, maybe should go in a Cocoa utils file somewhere -static void GetStringForNSString(const NSString *aSrc, nsAString& aDest) -{ - aDest.SetLength([aSrc length]); - [aSrc getCharacters:aDest.BeginWriting()]; -} - -nsresult -nsSystemFontsMac::GetSystemFont(nsSystemFontID aID, nsString *aFontName, - gfxFontStyle *aFontStyle) const -{ - // hack for now - if (aID == eSystemFont_Window || - aID == eSystemFont_Document) - { - aFontStyle->style = FONT_STYLE_NORMAL; - aFontStyle->weight = FONT_WEIGHT_NORMAL; - aFontStyle->stretch = NS_FONT_STRETCH_NORMAL; - - aFontName->AssignLiteral("sans-serif"); - aFontStyle->size = 14; - aFontStyle->systemFont = true; - - return NS_OK; - } - -/* possibilities, see NSFont Class Reference: - [NSFont boldSystemFontOfSize: 0.0] - [NSFont controlContentFontOfSize: 0.0] - [NSFont labelFontOfSize: 0.0] - [NSFont menuBarFontOfSize: 0.0] - [NSFont menuFontOfSize: 0.0] - [NSFont messageFontOfSize: 0.0] - [NSFont paletteFontOfSize: 0.0] - [NSFont systemFontOfSize: 0.0] - [NSFont titleBarFontOfSize: 0.0] - [NSFont toolTipsFontOfSize: 0.0] - [NSFont userFixedPitchFontOfSize: 0.0] - [NSFont userFontOfSize: 0.0] - [NSFont systemFontOfSize: [NSFont smallSystemFontSize]] - [NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]] -*/ - - NSFont *font = nsnull; - switch (aID) { - // css2 - case eSystemFont_Caption: - font = [NSFont systemFontOfSize:0.0]; - break; - case eSystemFont_Icon: // used in urlbar; tried labelFont, but too small - font = [NSFont controlContentFontOfSize:0.0]; - break; - case eSystemFont_Menu: - font = [NSFont systemFontOfSize:0.0]; - break; - case eSystemFont_MessageBox: - font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; - break; - case eSystemFont_SmallCaption: - font = [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]]; - break; - case eSystemFont_StatusBar: - font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; - break; - // css3 - //case eSystemFont_Window: = 'sans-serif' - //case eSystemFont_Document: = 'sans-serif' - case eSystemFont_Workspace: - font = [NSFont controlContentFontOfSize:0.0]; - break; - case eSystemFont_Desktop: - font = [NSFont controlContentFontOfSize:0.0]; - break; - case eSystemFont_Info: - font = [NSFont controlContentFontOfSize:0.0]; - break; - case eSystemFont_Dialog: - font = [NSFont systemFontOfSize:0.0]; - break; - case eSystemFont_Button: - font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; - break; - case eSystemFont_PullDownMenu: - font = [NSFont menuBarFontOfSize:0.0]; - break; - case eSystemFont_List: - font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; - break; - case eSystemFont_Field: - font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; - break; - // moz - case eSystemFont_Tooltips: - font = [NSFont toolTipsFontOfSize:0.0]; - break; - case eSystemFont_Widget: - font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; - break; - default: - // should never hit this - return NS_ERROR_FAILURE; - } - - NS_ASSERTION(font != nsnull, "failed to find a system font!"); - - GetStringForNSString([font familyName], *aFontName); - aFontStyle->size = [font pointSize]; - - NSFontSymbolicTraits traits = [[font fontDescriptor] symbolicTraits]; - if (traits & NSFontBoldTrait) - aFontStyle->weight = FONT_WEIGHT_BOLD; - if (traits & NSFontItalicTrait) - aFontStyle->style = FONT_STYLE_ITALIC; - aFontStyle->stretch = - (traits & NSFontExpandedTrait) ? - NS_FONT_STRETCH_EXPANDED : (traits & NSFontCondensedTrait) ? - NS_FONT_STRETCH_CONDENSED : NS_FONT_STRETCH_NORMAL; - - aFontStyle->systemFont = true; - - return NS_OK; -} diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsOS2.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsOS2.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsOS2.cpp 2012-02-21 02:06:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsOS2.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,275 +0,0 @@ -/* vim: set sw=4 sts=4 et cin: */ -/* ***** 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 OS/2 system font code in Thebes. - * - * The Initial Developer of the Original Code is - * Peter Weilbacher . - * Portions created by the Initial Developer are Copyright (C) 2006 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Developers of code taken from nsDeviceContextOS2: - * John Fairhurst, - * Henry Sobotka - * IBM Corp. - * - * 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 ***** */ - -#include "nsSystemFontsOS2.h" - -#define INCL_WINWINDOWMGR -#define INCL_WINSHELLDATA -#define INCL_DOSNLS -#define INCL_DOSERRORS -#include - -#include - -/************************ - * Helper functions * - ************************/ -static BOOL bIsDBCS; -static BOOL bIsDBCSSet = FALSE; - -/* Helper function to determine if we are running on DBCS */ -BOOL IsDBCS() -{ - if (!bIsDBCSSet) { - // the following lines of code determine whether the system is a DBCS country - APIRET rc; - COUNTRYCODE ctrycodeInfo = {0}; - CHAR achDBCSInfo[12] = {0}; // DBCS environmental vector - ctrycodeInfo.country = 0; // current country - ctrycodeInfo.codepage = 0; // current codepage - - rc = DosQueryDBCSEnv(sizeof(achDBCSInfo), &ctrycodeInfo, achDBCSInfo); - if (rc == NO_ERROR) { - // Non-DBCS countries will have four bytes in the first four bytes of the - // DBCS environmental vector - if (achDBCSInfo[0] != 0 || achDBCSInfo[1] != 0 || - achDBCSInfo[2] != 0 || achDBCSInfo[3] != 0) - { - bIsDBCS = TRUE; - } else { - bIsDBCS = FALSE; - } - } else { - bIsDBCS = FALSE; - } /* endif */ - bIsDBCSSet = TRUE; - } /* endif */ - return bIsDBCS; -} - -/* Helper function to query font from INI file */ -void QueryFontFromINI(char* fontType, char* fontName, ULONG ulLength) -{ - ULONG ulMaxNameL = ulLength; - - /* We had to switch to using PrfQueryProfileData because */ - /* some users have binary font data in their INI files */ - BOOL rc = PrfQueryProfileData(HINI_USER, (PCSZ)"PM_SystemFonts", (PCSZ)fontType, - fontName, &ulMaxNameL); - /* If there was no entry in the INI, default to something */ - if (rc == FALSE) { - /* Different values for DBCS vs. SBCS */ - /* WarpSans is only available on Warp 4, we exclude Warp 3 now */ - if (!IsDBCS()) { - strcpy(fontName, "9.WarpSans"); - } else { - strcpy(fontName, "9.WarpSans Combined"); - } - } else { - /* null terminate fontname */ - fontName[ulMaxNameL] = '\0'; - } -} - -/************************/ - -nsSystemFontsOS2::nsSystemFontsOS2() -{ -#ifdef DEBUG_thebes - printf("nsSystemFontsOS2::nsSystemFontsOS2()\n"); -#endif -} - -/* - * Query the font used for various CSS properties (aID) from the system. - * For OS/2, only very few fonts are defined in the system, so most of the IDs - * resolve to the same system font. - * The font queried will give back a string like - * 9.WarpSans Bold - * 12.Times New Roman Bold Italic - * 10.Times New Roman.Strikeout.Underline - * 20.Bitstream Vera Sans Mono Obli - * (always restricted to 32 chars, at least before the second dot) - * We use the value before the dot as the font size (in pt, and convert it to - * px using the screen resolution) and then try to use the rest of the string - * to determine the font style from it. - */ -nsresult nsSystemFontsOS2::GetSystemFont(nsSystemFontID aID, nsString* aFontName, - gfxFontStyle *aFontStyle) const -{ -#ifdef DEBUG_thebes - printf("nsSystemFontsOS2::GetSystemFont: "); -#endif - char szFontNameSize[MAXNAMEL]; - - switch (aID) - { - case eSystemFont_Icon: - QueryFontFromINI("IconText", szFontNameSize, MAXNAMEL); -#ifdef DEBUG_thebes - printf("IconText "); -#endif - break; - - case eSystemFont_Menu: - QueryFontFromINI("Menus", szFontNameSize, MAXNAMEL); -#ifdef DEBUG_thebes - printf("Menus "); -#endif - break; - - case eSystemFont_Caption: - case eSystemFont_MessageBox: - case eSystemFont_SmallCaption: - case eSystemFont_StatusBar: - case eSystemFont_Tooltips: - case eSystemFont_Widget: - - case eSystemFont_Window: // css3 - case eSystemFont_Document: - case eSystemFont_Workspace: - case eSystemFont_Desktop: - case eSystemFont_Info: - case eSystemFont_Dialog: - case eSystemFont_Button: - case eSystemFont_PullDownMenu: - case eSystemFont_List: - case eSystemFont_Field: - QueryFontFromINI("WindowText", szFontNameSize, MAXNAMEL); -#ifdef DEBUG_thebes - printf("WindowText "); -#endif - break; - - default: - NS_WARNING("None of the listed font types, using WarpSans"); - if (!IsDBCS()) { - strcpy(szFontNameSize, "9.WarpSans"); - } else { - strcpy(szFontNameSize, "9.WarpSans Combined"); - } - } // switch -#ifdef DEBUG_thebes - printf(" (%s)\n", szFontNameSize); -#endif - - char *szFacename = strchr(szFontNameSize, '.'); - if (!szFacename || (*(szFacename++) == '\0')) - return NS_ERROR_FAILURE; - - // local DPI for size will be taken into account below - aFontStyle->size = atof(szFontNameSize); - - // determine DPI resolution of screen device to compare compute - // font size in pixels - HPS ps = WinGetScreenPS(HWND_DESKTOP); - HDC dc = GpiQueryDevice(ps); - // effective vertical resolution in DPI - LONG vertScreenRes = 120; // assume 120 dpi as default - DevQueryCaps(dc, CAPS_VERTICAL_FONT_RES, 1, &vertScreenRes); - WinReleasePS(ps); - - // now scale to make pixels from points (1 pt = 1/72in) - aFontStyle->size *= vertScreenRes / 72.0; - - NS_ConvertUTF8toUTF16 fontFace(szFacename); - int pos = 0; - - // this is a system font in any case - aFontStyle->systemFont = true; - - // bold fonts should have " Bold" in their names, at least we hope that they - // do, otherwise it's bad luck - NS_NAMED_LITERAL_CSTRING(spcBold, " Bold"); - if ((pos = fontFace.Find(spcBold.get(), false, 0, -1)) > -1) { - aFontStyle->weight = FONT_WEIGHT_BOLD; - // strip the attribute, now that we have set it in the gfxFontStyle - fontFace.Cut(pos, spcBold.Length()); - } else { - aFontStyle->weight = FONT_WEIGHT_NORMAL; - } - - // FIXME: Set aFontStyle->stretch correctly! - aFontStyle->stretch = NS_FONT_STRETCH_NORMAL; - - // similar hopes for italic and oblique fonts... - NS_NAMED_LITERAL_CSTRING(spcItalic, " Italic"); - NS_NAMED_LITERAL_CSTRING(spcOblique, " Oblique"); - NS_NAMED_LITERAL_CSTRING(spcObli, " Obli"); - if ((pos = fontFace.Find(spcItalic.get(), false, 0, -1)) > -1) { - aFontStyle->style = FONT_STYLE_ITALIC; - fontFace.Cut(pos, spcItalic.Length()); - } else if ((pos = fontFace.Find(spcOblique.get(), false, 0, -1)) > -1) { - // oblique fonts are rare on OS/2 and not specially supported by - // the GPI system, but at least we are trying... - aFontStyle->style = FONT_STYLE_OBLIQUE; - fontFace.Cut(pos, spcOblique.Length()); - } else if ((pos = fontFace.Find(spcObli.get(), false, 0, -1)) > -1) { - // especially oblique often gets cut by the 32 char limit to "Obli", - // so search for that, too (anything shorter would be ambiguous) - aFontStyle->style = FONT_STYLE_OBLIQUE; - // In this case, assume that this is the last property in the line - // and cut off everything else, too - // This is needed in case it was really Obliq or Obliqu... - fontFace.Cut(pos, fontFace.Length()); - } else { - aFontStyle->style = FONT_STYLE_NORMAL; - } - - // just throw away any modifiers that are separated by dots (which are either - // .Strikeout, .Underline, or .Outline, none of which have a corresponding - // gfxFont property) - if ((pos = fontFace.Find(".", false, 0, -1)) > -1) { - fontFace.Cut(pos, fontFace.Length()); - } - -#ifdef DEBUG_thebes - printf(" after=%s\n", NS_LossyConvertUTF16toASCII(fontFace).get()); - printf(" style: %s %s %s\n", - (aFontStyle->weight == FONT_WEIGHT_BOLD) ? "BOLD" : "", - (aFontStyle->style == FONT_STYLE_ITALIC) ? "ITALIC" : "", - (aFontStyle->style == FONT_STYLE_OBLIQUE) ? "OBLIQUE" : ""); -#endif - NS_NAMED_LITERAL_STRING(quote, "\""); // seems like we need quotes around the font name - *aFontName = quote + fontFace + quote; - - return NS_OK; -} diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsOS2.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsOS2.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsOS2.h 2012-02-21 02:06:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsOS2.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -/* vim: set sw=4 sts=4 et cin: */ -/* ***** 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 OS/2 system font code in Thebes. - * - * The Initial Developer of the Original Code is - * Peter Weilbacher . - * Portions created by the Initial Developer are Copyright (C) 2006 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * John Fairhurst, } original developers of - * Henry Sobotka } code taken from - * IBM Corp. } nsDeviceContextOS2 - * - * 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 ***** */ - -#ifndef _NS_SYSTEMFONTSOS2_H_ -#define _NS_SYSTEMFONTSOS2_H_ - -#include "gfxFont.h" -#include "nsDeviceContext.h" - -class nsSystemFontsOS2 -{ -public: - nsSystemFontsOS2(); - nsresult GetSystemFont(nsSystemFontID aID, nsString* aFontName, - gfxFontStyle *aFontStyle) const; -}; - -#endif /* _NS_SYSTEMFONTSOS2_H_ */ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsQt.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsQt.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsQt.cpp 2012-02-21 02:06:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsQt.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,134 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** 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 thebes gfx - * - * The Initial Developer of the Original Code is mozilla.org. - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Vladimir Vukicevic - * Stuart Parmenter - * - * 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 ***** */ - -// Qt headers must be included before anything that might pull in our -// malloc wrappers. -#include -#include - -#include "nsSystemFontsQt.h" -#include "gfxQtPlatform.h" - -nsSystemFontsQt::nsSystemFontsQt() - : mDefaultFontName(NS_LITERAL_STRING("sans-serif")) - , mButtonFontName(NS_LITERAL_STRING("sans-serif")) - , mFieldFontName(NS_LITERAL_STRING("sans-serif")) - , mMenuFontName(NS_LITERAL_STRING("sans-serif")) -{ - // What about using QFontInfo? is it faster or what? - GetSystemFontInfo("Qlabel", &mDefaultFontName, &mDefaultFontStyle); - - GetSystemFontInfo("QlineEdit", &mFieldFontName, &mFieldFontStyle); - - GetSystemFontInfo("QAction", &mMenuFontName, &mMenuFontStyle); - - GetSystemFontInfo("QPushButton", &mButtonFontName, &mButtonFontStyle); -} - -nsSystemFontsQt::~nsSystemFontsQt() -{ - // No implementation needed -} - -nsresult -nsSystemFontsQt::GetSystemFontInfo(const char *aClassName, nsString *aFontName, - gfxFontStyle *aFontStyle) const -{ - QFont qFont = QApplication::font(aClassName); - - aFontStyle->style = FONT_STYLE_NORMAL; - aFontStyle->systemFont = true; - NS_NAMED_LITERAL_STRING(quote, "\""); - nsString family((PRUnichar*)qFont.family().data()); - *aFontName = quote + family + quote; - aFontStyle->weight = qFont.weight(); - // FIXME: Set aFontStyle->stretch correctly! - aFontStyle->stretch = NS_FONT_STRETCH_NORMAL; - // use pixel size directly if it is set, otherwise compute from point size - if (qFont.pixelSize() != -1) { - aFontStyle->size = qFont.pixelSize(); - } else { - aFontStyle->size = qFont.pointSizeF() * 96.0f / 72.0f; - } - return NS_OK; -} - - -nsresult -nsSystemFontsQt::GetSystemFont(nsSystemFontID anID, nsString *aFontName, - gfxFontStyle *aFontStyle) const -{ - switch (anID) { - case eSystemFont_Menu: // css2 - case eSystemFont_PullDownMenu: // css3 - *aFontName = mMenuFontName; - *aFontStyle = mMenuFontStyle; - break; - - case eSystemFont_Field: // css3 - case eSystemFont_List: // css3 - *aFontName = mFieldFontName; - *aFontStyle = mFieldFontStyle; - break; - - case eSystemFont_Button: // css3 - *aFontName = mButtonFontName; - *aFontStyle = mButtonFontStyle; - break; - - case eSystemFont_Caption: // css2 - case eSystemFont_Icon: // css2 - case eSystemFont_MessageBox: // css2 - case eSystemFont_SmallCaption: // css2 - case eSystemFont_StatusBar: // css2 - case eSystemFont_Window: // css3 - case eSystemFont_Document: // css3 - case eSystemFont_Workspace: // css3 - case eSystemFont_Desktop: // css3 - case eSystemFont_Info: // css3 - case eSystemFont_Dialog: // css3 - case eSystemFont_Tooltips: // moz - case eSystemFont_Widget: // moz - *aFontName = mDefaultFontName; - *aFontStyle = mDefaultFontStyle; - break; - } - - return NS_OK; -} - diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsQt.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsQt.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsQt.h 2012-02-21 02:06:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsQt.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** 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 thebes gfx - * - * The Initial Developer of the Original Code is mozilla.org. - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Vladimir Vukicevic - * Stuart Parmenter - * - * 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 ***** */ - -#ifndef _NS_SYSTEMFONTSQT_H_ -#define _NS_SYSTEMFONTSQT_H_ - -#include "gfxFont.h" -#include "nsDeviceContext.h" - -class nsSystemFontsQt -{ -public: - nsSystemFontsQt(); - ~nsSystemFontsQt(); - - nsresult GetSystemFont(nsSystemFontID anID, nsString *aFontName, - gfxFontStyle *aFontStyle) const; - -private: - - nsresult GetSystemFontInfo(const char *aClassName, nsString *aFontName, - gfxFontStyle *aFontStyle) const; - - /* - * The following system font constants exist: - * - * css2: http://www.w3.org/TR/REC-CSS2/fonts.html#x27 - * eSystemFont_Caption, eSystemFont_Icon, eSystemFont_Menu, - * eSystemFont_MessageBox, eSystemFont_SmallCaption, - * eSystemFont_StatusBar, - * // css3 - * eSystemFont_Window, eSystemFont_Document, - * eSystemFont_Workspace, eSystemFont_Desktop, - * eSystemFont_Info, eSystemFont_Dialog, - * eSystemFont_Button, eSystemFont_PullDownMenu, - * eSystemFont_List, eSystemFont_Field, - * // moz - * eSystemFont_Tooltips, eSystemFont_Widget - */ - nsString mDefaultFontName, mButtonFontName, mFieldFontName, mMenuFontName; - gfxFontStyle mDefaultFontStyle, mButtonFontStyle, mFieldFontStyle, mMenuFontStyle; -}; - -#endif /* _NS_SYSTEMFONTSQT_H_ */ - diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsWin.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsWin.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsWin.cpp 2012-02-21 02:06:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsWin.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,246 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** 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 thebes gfx - * - * The Initial Developer of the Original Code is mozilla.org. - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Vladimir Vukicevic - * Stuart Parmenter - * - * 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 ***** */ - -#include "nsSystemFontsWin.h" -#include "gfxWindowsSurface.h" - -nsresult nsSystemFontsWin::CopyLogFontToNSFont(HDC* aHDC, const LOGFONTW* ptrLogFont, - nsString *aFontName, - gfxFontStyle *aFontStyle) const -{ - PRUnichar name[LF_FACESIZE]; - name[0] = 0; - memcpy(name, ptrLogFont->lfFaceName, LF_FACESIZE*sizeof(PRUnichar)); - *aFontName = name; - - // Do Style - aFontStyle->style = FONT_STYLE_NORMAL; - if (ptrLogFont->lfItalic) - { - aFontStyle->style = FONT_STYLE_ITALIC; - } - // XXX What about oblique? - - // Do Weight - aFontStyle->weight = (ptrLogFont->lfWeight == FW_BOLD ? - FONT_WEIGHT_BOLD : FONT_WEIGHT_NORMAL); - - // FIXME: Set aFontStyle->stretch correctly! - aFontStyle->stretch = NS_FONT_STRETCH_NORMAL; - - // XXX mPixelScale is currently hardcoded to 1 in thebes gfx... - float mPixelScale = 1.0f; - // Do Point Size - // - // The lfHeight is in pixel and it needs to be adjusted for the - // device it will be "displayed" on - // Screens and Printers will differe in DPI - // - // So this accounts for the difference in the DeviceContexts - // The mPixelScale will be a "1" for the screen and could be - // any value when going to a printer, for example mPixleScale is - // 6.25 when going to a 600dpi printer. - // round, but take into account whether it is negative - float pixelHeight = -ptrLogFont->lfHeight; - if (pixelHeight < 0) { - HFONT hFont = ::CreateFontIndirectW(ptrLogFont); - if (!hFont) - return NS_ERROR_OUT_OF_MEMORY; - HGDIOBJ hObject = ::SelectObject(*aHDC, hFont); - TEXTMETRIC tm; - ::GetTextMetrics(*aHDC, &tm); - ::SelectObject(*aHDC, hObject); - ::DeleteObject(hFont); - pixelHeight = tm.tmAscent; - } - - pixelHeight *= mPixelScale; - - // we have problem on Simplified Chinese system because the system - // report the default font size is 8 points. but if we use 8, the text - // display very ugly. force it to be at 9 points (12 pixels) on that - // system (cp936), but leave other sizes alone. - if ((pixelHeight < 12) && - (936 == ::GetACP())) - pixelHeight = 12; - - aFontStyle->size = pixelHeight; - return NS_OK; -} - -nsresult nsSystemFontsWin::GetSysFontInfo(HDC aHDC, nsSystemFontID anID, - nsString *aFontName, - gfxFontStyle *aFontStyle) const -{ - HGDIOBJ hGDI; - - LOGFONTW logFont; - LOGFONTW* ptrLogFont = NULL; - - NONCLIENTMETRICSW ncm; - - BOOL status; - if (anID == eSystemFont_Icon) - { - status = ::SystemParametersInfoW(SPI_GETICONTITLELOGFONT, - sizeof(logFont), - (PVOID)&logFont, - 0); - } - else - { - ncm.cbSize = sizeof(NONCLIENTMETRICSW); - status = ::SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, - sizeof(ncm), - (PVOID)&ncm, - 0); - } - - if (!status) - { - return NS_ERROR_FAILURE; - } - - switch (anID) - { - // Caption in CSS is NOT the same as Caption on Windows - //case eSystemFont_Caption: - // ptrLogFont = &ncm.lfCaptionFont; - // break; - - case eSystemFont_Icon: - ptrLogFont = &logFont; - break; - - case eSystemFont_Menu: - ptrLogFont = &ncm.lfMenuFont; - break; - - case eSystemFont_MessageBox: - ptrLogFont = &ncm.lfMessageFont; - break; - - case eSystemFont_SmallCaption: - ptrLogFont = &ncm.lfSmCaptionFont; - break; - - case eSystemFont_StatusBar: - case eSystemFont_Tooltips: - ptrLogFont = &ncm.lfStatusFont; - break; - - case eSystemFont_Widget: - - case eSystemFont_Window: // css3 - case eSystemFont_Document: - case eSystemFont_Workspace: - case eSystemFont_Desktop: - case eSystemFont_Info: - case eSystemFont_Dialog: - case eSystemFont_Button: - case eSystemFont_PullDownMenu: - case eSystemFont_List: - case eSystemFont_Field: - case eSystemFont_Caption: - hGDI = ::GetStockObject(DEFAULT_GUI_FONT); - if (hGDI != NULL) - { - if (::GetObjectW(hGDI, sizeof(logFont), &logFont) > 0) - { - ptrLogFont = &logFont; - } - } - break; - } // switch - - if (nsnull == ptrLogFont) - { - return NS_ERROR_FAILURE; - } - - aFontStyle->systemFont = true; - - return CopyLogFontToNSFont(&aHDC, ptrLogFont, aFontName, aFontStyle); -} - -nsresult nsSystemFontsWin::GetSystemFont(nsSystemFontID anID, - nsString *aFontName, - gfxFontStyle *aFontStyle) const -{ - nsresult status = NS_OK; - - switch (anID) { - case eSystemFont_Caption: - case eSystemFont_Icon: - case eSystemFont_Menu: - case eSystemFont_MessageBox: - case eSystemFont_SmallCaption: - case eSystemFont_StatusBar: - case eSystemFont_Tooltips: - case eSystemFont_Widget: - - case eSystemFont_Window: // css3 - case eSystemFont_Document: - case eSystemFont_Workspace: - case eSystemFont_Desktop: - case eSystemFont_Info: - case eSystemFont_Dialog: - case eSystemFont_Button: - case eSystemFont_PullDownMenu: - case eSystemFont_List: - case eSystemFont_Field: - { - HWND hwnd = nsnull; - HDC tdc = GetDC(hwnd); - - status = GetSysFontInfo(tdc, anID, aFontName, aFontStyle); - - ReleaseDC(hwnd, tdc); - - break; - } - } - - return status; -} - -nsSystemFontsWin::nsSystemFontsWin() -{ - -} - diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsWin.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsWin.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsSystemFontsWin.h 2012-02-21 02:06:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsSystemFontsWin.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** 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 thebes gfx - * - * The Initial Developer of the Original Code is mozilla.org. - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Vladimir Vukicevic - * Stuart Parmenter - * - * 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 ***** */ - -#ifndef _NS_SYSTEMFONTSWIN_H_ -#define _NS_SYSTEMFONTSWIN_H_ - -#include "gfxFont.h" -#include "nsDeviceContext.h" -#include // need HDC and LOGFONTW - -class nsSystemFontsWin -{ -public: - nsSystemFontsWin(); - - nsresult GetSystemFont(nsSystemFontID anID, nsString *aFontName, - gfxFontStyle *aFontStyle) const; -private: - nsresult CopyLogFontToNSFont(HDC* aHDC, const LOGFONTW* ptrLogFont, - nsString *aFontName, gfxFontStyle *aFontStyle) const; - nsresult GetSysFontInfo(HDC aHDC, nsSystemFontID anID, - nsString *aFontName, - gfxFontStyle *aFontStyle) const; -}; - -#endif /* _NS_SYSTEMFONTSWIN_H_ */ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsThebesGfxFactory.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsThebesGfxFactory.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/src/nsThebesGfxFactory.cpp 2012-02-21 02:06:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/src/nsThebesGfxFactory.cpp 2012-02-22 02:05:56.000000000 +0000 @@ -43,7 +43,6 @@ #include "nsThebesFontEnumerator.h" #include "nsScriptableRegion.h" -#include "nsDeviceContext.h" #include "gfxPlatform.h" // This class doesn't do anything; its only purpose is to give @@ -100,7 +99,6 @@ static void nsThebesGfxModuleDtor() { - nsDeviceContext::ClearCachedSystemFonts(); gfxPlatform::Shutdown(); } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/thebes/gfxFont.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/thebes/gfxFont.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/thebes/gfxFont.cpp 2012-02-21 02:06:03.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/thebes/gfxFont.cpp 2012-02-22 02:05:57.000000000 +0000 @@ -743,25 +743,16 @@ if (aMatchData->mFontToMatch) { const gfxFontStyle *style = aMatchData->mFontToMatch->GetStyle(); - - // italics + + // matching italics takes precedence over weight bool wantItalic = ((style->style & (FONT_STYLE_ITALIC | FONT_STYLE_OBLIQUE)) != 0); if (fe->IsItalic() == wantItalic) { - rank += 5; + rank += 10; } - - // weight - PRInt32 targetWeight = style->ComputeWeight() * 100; - PRInt32 entryWeight = fe->Weight(); - if (entryWeight == targetWeight) { - rank += 5; - } else { - PRUint32 diffWeight = abs(entryWeight - targetWeight); - if (diffWeight <= 100) // favor faces close in weight - rank += 2; - } + // measure of closeness of weight to the desired value + rank += 9 - abs(fe->Weight() / 100 - style->ComputeWeight()); } else { // if no font to match, prefer non-bold, non-italic fonts if (!fe->IsItalic()) { @@ -1117,6 +1108,7 @@ void gfxFontCache::NotifyExpired(gfxFont *aFont) { + aFont->ClearCachedWords(); RemoveObject(aFont); DestroyFont(aFont); } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/thebes/gfxHarfBuzzShaper.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/thebes/gfxHarfBuzzShaper.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/gfx/thebes/gfxHarfBuzzShaper.cpp 2012-02-21 02:06:03.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/gfx/thebes/gfxHarfBuzzShaper.cpp 2012-02-22 02:05:57.000000000 +0000 @@ -50,13 +50,13 @@ #include "gfxHarfBuzzShaper.h" #include "gfxFontUtils.h" #include "gfxUnicodeProperties.h" +#include "nsUnicodeNormalizer.h" #include "harfbuzz/hb-unicode.h" #include "harfbuzz/hb-ot.h" #include "cairo.h" -#include "nsUnicodeRange.h" #include "nsCRT.h" #if defined(XP_WIN) @@ -700,6 +700,140 @@ return gfxUnicodeProperties::GetEastAsianWidth(aCh); } +// Hebrew presentation forms with dagesh, for characters 0x05D0..0x05EA; +// note that some letters do not have a dagesh presForm encoded +static const PRUnichar sDageshForms[0x05EA - 0x05D0 + 1] = { + 0xFB30, // ALEF + 0xFB31, // BET + 0xFB32, // GIMEL + 0xFB33, // DALET + 0xFB34, // HE + 0xFB35, // VAV + 0xFB36, // ZAYIN + 0, // HET + 0xFB38, // TET + 0xFB39, // YOD + 0xFB3A, // FINAL KAF + 0xFB3B, // KAF + 0xFB3C, // LAMED + 0, // FINAL MEM + 0xFB3E, // MEM + 0, // FINAL NUN + 0xFB40, // NUN + 0xFB41, // SAMEKH + 0, // AYIN + 0xFB43, // FINAL PE + 0xFB44, // PE + 0, // FINAL TSADI + 0xFB46, // TSADI + 0xFB47, // QOF + 0xFB48, // RESH + 0xFB49, // SHIN + 0xFB4A // TAV +}; + +static hb_bool_t +HBUnicodeCompose(hb_unicode_funcs_t *ufuncs, + hb_codepoint_t a, + hb_codepoint_t b, + hb_codepoint_t *ab, + void *user_data) +{ + hb_bool_t found = nsUnicodeNormalizer::Compose(a, b, ab); + + if (!found && (b & 0x1fff80) == 0x0580) { + // special-case Hebrew presentation forms that are excluded from + // standard normalization, but wanted for old fonts + switch (b) { + case 0x05B4: // HIRIQ + if (a == 0x05D9) { // YOD + *ab = 0xFB1D; + found = true; + } + break; + case 0x05B7: // patah + if (a == 0x05F2) { // YIDDISH YOD YOD + *ab = 0xFB1F; + found = true; + } else if (a == 0x05D0) { // ALEF + *ab = 0xFB2E; + found = true; + } + break; + case 0x05B8: // QAMATS + if (a == 0x05D0) { // ALEF + *ab = 0xFB2F; + found = true; + } + break; + case 0x05B9: // HOLAM + if (a == 0x05D5) { // VAV + *ab = 0xFB4B; + found = true; + } + break; + case 0x05BC: // DAGESH + if (a >= 0x05D0 && a <= 0x05EA) { + *ab = sDageshForms[a - 0x05D0]; + found = (*ab != 0); + } else if (a == 0xFB2A) { // SHIN WITH SHIN DOT + *ab = 0xFB2C; + found = true; + } else if (a == 0xFB2B) { // SHIN WITH SIN DOT + *ab = 0xFB2D; + found = true; + } + break; + case 0x05BF: // RAFE + switch (a) { + case 0x05D1: // BET + *ab = 0xFB4C; + found = true; + break; + case 0x05DB: // KAF + *ab = 0xFB4D; + found = true; + break; + case 0x05E4: // PE + *ab = 0xFB4E; + found = true; + break; + } + break; + case 0x05C1: // SHIN DOT + if (a == 0x05E9) { // SHIN + *ab = 0xFB2A; + found = true; + } else if (a == 0xFB49) { // SHIN WITH DAGESH + *ab = 0xFB2C; + found = true; + } + break; + case 0x05C2: // SIN DOT + if (a == 0x05E9) { // SHIN + *ab = 0xFB2B; + found = true; + } else if (a == 0xFB49) { // SHIN WITH DAGESH + *ab = 0xFB2D; + found = true; + } + break; + } + } + + return found; +} + +static hb_bool_t +HBUnicodeDecompose(hb_unicode_funcs_t *ufuncs, + hb_codepoint_t ab, + hb_codepoint_t *a, + hb_codepoint_t *b, + void *user_data) +{ + return nsUnicodeNormalizer::DecomposeNonRecursively(ab, a, b); +} + /* * gfxFontShaper override to initialize the text run using HarfBuzz */ @@ -753,6 +887,12 @@ hb_unicode_funcs_set_eastasian_width_func(sHBUnicodeFuncs, HBGetEastAsianWidth, nsnull, nsnull); + hb_unicode_funcs_set_compose_func(sHBUnicodeFuncs, + HBUnicodeCompose, + nsnull, nsnull); + hb_unicode_funcs_set_decompose_func(sHBUnicodeFuncs, + HBUnicodeDecompose, + nsnull, nsnull); } mHBFace = hb_face_create_for_tables(HBGetTable, this, nsnull); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/intl/unicharutil/public/Makefile.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/intl/unicharutil/public/Makefile.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/intl/unicharutil/public/Makefile.in 2012-02-21 02:06:30.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/intl/unicharutil/public/Makefile.in 2012-02-22 02:06:18.000000000 +0000 @@ -48,6 +48,7 @@ nsICaseConversion.h \ nsIUGenCategory.h \ nsUnicharUtilCIID.h \ + nsUnicodeNormalizer.h \ $(NULL) include $(topsrcdir)/config/rules.mk diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/intl/unicharutil/public/nsUnicodeNormalizer.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/intl/unicharutil/public/nsUnicodeNormalizer.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/intl/unicharutil/public/nsUnicodeNormalizer.h 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/intl/unicharutil/public/nsUnicodeNormalizer.h 2012-02-22 02:06:18.000000000 +0000 @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** 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 Unicode case conversion helpers. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp.. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * 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 ***** */ + +#ifndef nsUnicodeNormalizer_h__ +#define nsUnicodeNormalizer_h__ + +#include "nscore.h" +#include "nsISupports.h" + +#include "nsIUnicodeNormalizer.h" + +nsresult NS_NewUnicodeNormalizer(nsISupports** oResult); + + +class nsUnicodeNormalizer : public nsIUnicodeNormalizer { +public: + nsUnicodeNormalizer(); + virtual ~nsUnicodeNormalizer(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD NormalizeUnicodeNFD( const nsAString& aSrc, nsAString& aDest); + NS_IMETHOD NormalizeUnicodeNFC( const nsAString& aSrc, nsAString& aDest); + NS_IMETHOD NormalizeUnicodeNFKD( const nsAString& aSrc, nsAString& aDest); + NS_IMETHOD NormalizeUnicodeNFKC( const nsAString& aSrc, nsAString& aDest); + + // low-level access to the composition data needed for HarfBuzz callbacks + static bool Compose(PRUint32 a, PRUint32 b, PRUint32 *ab); + static bool DecomposeNonRecursively(PRUint32 comp, PRUint32 *c1, PRUint32 *c2); +}; + +#endif //nsUnicodeNormalizer_h__ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/intl/unicharutil/src/nsUnicodeNormalizer.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/intl/unicharutil/src/nsUnicodeNormalizer.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/intl/unicharutil/src/nsUnicodeNormalizer.cpp 2012-02-21 02:06:30.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/intl/unicharutil/src/nsUnicodeNormalizer.cpp 2012-02-22 02:06:18.000000000 +0000 @@ -713,3 +713,30 @@ return mdn_normalize(true, true, aSrc, aDest); } +bool +nsUnicodeNormalizer::Compose(PRUint32 a, PRUint32 b, PRUint32 *ab) +{ + return mdn__unicode_compose(a, b, ab) == NS_OK; +} + +bool +nsUnicodeNormalizer::DecomposeNonRecursively(PRUint32 c, PRUint32 *c1, PRUint32 *c2) +{ + // We can't use mdn__unicode_decompose here, because that does a recursive + // decomposition that may yield more than two characters, but the harfbuzz + // callback wants just a single-step decomp that is guaranteed to produce + // no more than two characters. So we do a low-level lookup in the table + // of decomp sequences. + const PRUint32 *seq; + PRUint32 seqidx = decompose_char(c, &seq); + if (seqidx == 0 || ((seqidx & DECOMP_COMPAT) != 0)) { + return false; + } + *c1 = *seq & ~END_BIT; + if (*seq & END_BIT) { + *c2 = 0; + } else { + *c2 = *++seq & ~END_BIT; + } + return true; +} diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/intl/unicharutil/src/nsUnicodeNormalizer.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/intl/unicharutil/src/nsUnicodeNormalizer.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/intl/unicharutil/src/nsUnicodeNormalizer.h 2012-02-21 02:06:30.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/intl/unicharutil/src/nsUnicodeNormalizer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** 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 Unicode case conversion helpers. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp.. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * 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 ***** */ - -#ifndef nsUnicodeNormalizer_h__ -#define nsUnicodeNormalizer_h__ - -#include "nscore.h" -#include "nsISupports.h" - -#include "nsIUnicodeNormalizer.h" - -nsresult NS_NewUnicodeNormalizer(nsISupports** oResult); - - -class nsUnicodeNormalizer : public nsIUnicodeNormalizer { -public: - nsUnicodeNormalizer(); - virtual ~nsUnicodeNormalizer(); - - NS_DECL_ISUPPORTS - - NS_IMETHOD NormalizeUnicodeNFD( const nsAString& aSrc, nsAString& aDest); - NS_IMETHOD NormalizeUnicodeNFC( const nsAString& aSrc, nsAString& aDest); - NS_IMETHOD NormalizeUnicodeNFKD( const nsAString& aSrc, nsAString& aDest); - NS_IMETHOD NormalizeUnicodeNFKC( const nsAString& aSrc, nsAString& aDest); -}; - -#endif //nsUnicodeNormalizer_h__ - diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/ipc/ObjectWrapperParent.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/ipc/ObjectWrapperParent.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/ipc/ObjectWrapperParent.cpp 2012-02-21 02:06:44.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/ipc/ObjectWrapperParent.cpp 2012-02-22 02:06:34.000000000 +0000 @@ -172,13 +172,11 @@ (JSResolveOp) ObjectWrapperParent::CPOW_NewResolve, ObjectWrapperParent::CPOW_Convert, ObjectWrapperParent::CPOW_Finalize, - nsnull, // reserved1 nsnull, // checkAccess ObjectWrapperParent::CPOW_Call, ObjectWrapperParent::CPOW_Construct, - nsnull, // xdrObject ObjectWrapperParent::CPOW_HasInstance, - nsnull, // mark + nsnull, // trace { ObjectWrapperParent::CPOW_Equality, nsnull, // outerObject diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/builtin/MapObject.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/builtin/MapObject.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/builtin/MapObject.cpp 2012-02-21 02:06:45.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/builtin/MapObject.cpp 2012-02-22 02:06:34.000000000 +0000 @@ -45,6 +45,7 @@ #include "jsobj.h" #include "vm/GlobalObject.h" +#include "vm/MethodGuard.h" #include "vm/Stack.h" #include "jsobjinlines.h" @@ -156,11 +157,9 @@ JS_ResolveStub, JS_ConvertStub, finalize, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ mark }; @@ -307,11 +306,9 @@ JS_ResolveStub, JS_ConvertStub, finalize, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ mark }; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/builtin/RegExp.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/builtin/RegExp.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/builtin/RegExp.cpp 2012-02-21 02:06:45.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/builtin/RegExp.cpp 2012-02-22 02:06:34.000000000 +0000 @@ -42,6 +42,7 @@ #include "builtin/RegExp.h" +#include "vm/MethodGuard-inl.h" #include "vm/RegExpObject-inl.h" #include "vm/RegExpStatics-inl.h" diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/config/milestone.pl firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/config/milestone.pl --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/config/milestone.pl 2012-02-21 02:06:45.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/config/milestone.pl 2012-02-22 02:06:34.000000000 +0000 @@ -51,6 +51,7 @@ $MICRO_VERSION $opt_debug $opt_template + $opt_uaversion $opt_help ); @@ -60,7 +61,7 @@ require "Moz/Milestone.pm"; -&GetOptions('topsrcdir=s' => \$TOPSRCDIR, 'srcdir=s' => \$SRCDIR, 'objdir=s' => \$OBJDIR, 'debug', 'help', 'template'); +&GetOptions('topsrcdir=s' => \$TOPSRCDIR, 'srcdir=s' => \$SRCDIR, 'objdir=s' => \$OBJDIR, 'debug', 'help', 'template', 'uaversion'); if (defined($opt_help)) { &usage(); @@ -100,13 +101,19 @@ warn("$0: No such file $TFILE!\n"); } } +} elsif(defined($opt_uaversion)) { + my $uaversion = Moz::Milestone::getMilestoneMajor($milestone) . "." . + Moz::Milestone::getMilestoneMinor($milestone); + # strip off trailing pre-release indicators + $uaversion =~ s/[a-z]+\d*$//; + print "$uaversion\n"; } else { print "$milestone\n"; } sub usage() { print <data = data; } -JS_PUBLIC_API(size_t) -JS::SystemCompartmentCount(const JSRuntime *rt) -{ - size_t n = 0; - for (size_t i = 0; i < rt->compartments.length(); i++) { - if (rt->compartments[i]->isSystemCompartment) { - ++n; - } - } - return n; -} - -JS_PUBLIC_API(size_t) -JS::UserCompartmentCount(const JSRuntime *rt) -{ - size_t n = 0; - for (size_t i = 0; i < rt->compartments.length(); i++) { - if (!rt->compartments[i]->isSystemCompartment) { - ++n; - } - } - return n; -} - #ifdef JS_THREADSAFE static void StartRequest(JSContext *cx) @@ -4314,11 +4291,9 @@ JS_ResolveStub, JS_ConvertStub, prop_iter_finalize, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ prop_iter_trace }; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsapi.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsapi.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsapi.h 2012-02-21 02:06:57.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsapi.h 2012-02-22 02:06:48.000000000 +0000 @@ -1351,13 +1351,6 @@ jsval *vp); /* - * Encode or decode an object, given an XDR state record representing external - * data. See jsxdrapi.h. - */ -typedef JSBool -(* JSXDRObjectOp)(JSXDRState *xdr, JSObject **objp); - -/* * Check whether v is an instance of obj. Return false on error or exception, * true on success with JS_TRUE in *bp if v is an instance of obj, JS_FALSE in * *bp otherwise. @@ -2690,6 +2683,18 @@ JS_BEGIN_EXTERN_C #endif +typedef void (*JSIterateCompartmentCallback)(JSContext *cx, void *data, + JSCompartment *compartment); + +/* + * This function calls |compartmentCallback| on every compartment. Beware that + * there is no guarantee that the compartment will survive after the callback + * returns. + */ +extern JS_PUBLIC_API(void) +JS_IterateCompartments(JSContext *cx, void *data, + JSIterateCompartmentCallback compartmentCallback); + extern JS_PUBLIC_API(JSObject *) JS_GetGlobalObject(JSContext *cx); @@ -3385,15 +3390,12 @@ JSFinalizeOp finalize; /* Optionally non-null members start here. */ - JSClassInternal reserved0; JSCheckAccessOp checkAccess; JSNative call; JSNative construct; - JSXDRObjectOp xdrObject; JSHasInstanceOp hasInstance; JSTraceOp trace; - JSClassInternal reserved1; void *reserved[40]; }; @@ -3477,8 +3479,8 @@ & JSCLASS_CACHED_PROTO_MASK)) /* Initializer for unused members of statically initialized JSClass structs. */ -#define JSCLASS_NO_INTERNAL_MEMBERS 0,{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} -#define JSCLASS_NO_OPTIONAL_MEMBERS 0,0,0,0,0,0,0,JSCLASS_NO_INTERNAL_MEMBERS +#define JSCLASS_NO_INTERNAL_MEMBERS {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} +#define JSCLASS_NO_OPTIONAL_MEMBERS 0,0,0,0,0,JSCLASS_NO_INTERNAL_MEMBERS extern JS_PUBLIC_API(jsint) JS_IdArrayLength(JSContext *cx, JSIdArray *ida); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsapi-tests/testCustomIterator.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsapi-tests/testCustomIterator.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsapi-tests/testCustomIterator.cpp 2012-02-21 02:06:56.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsapi-tests/testCustomIterator.cpp 2012-02-22 02:06:48.000000000 +0000 @@ -35,11 +35,9 @@ JS_ResolveStub, JS_ConvertStub, NULL, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ NULL, /* mark */ { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsapi-tests/testExtendedEq.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsapi-tests/testExtendedEq.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsapi-tests/testExtendedEq.cpp 2012-02-21 02:06:56.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsapi-tests/testExtendedEq.cpp 2012-02-22 02:06:48.000000000 +0000 @@ -26,11 +26,9 @@ JS_ResolveStub, NULL, /* convert */ NULL, /* finalize */ - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ NULL, /* mark */ { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsapi-tests/testNewObject.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsapi-tests/testNewObject.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsapi-tests/testNewObject.cpp 2012-02-21 02:06:56.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsapi-tests/testNewObject.cpp 2012-02-22 02:06:48.000000000 +0000 @@ -86,7 +86,7 @@ 0, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, NULL, - NULL, NULL, NULL, constructHook, NULL, NULL, NULL, NULL + NULL, NULL, constructHook }; JSObject *ctor = JS_NewObject(cx, &cls, NULL, NULL); CHECK(ctor); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsarray.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsarray.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsarray.cpp 2012-02-21 02:06:57.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsarray.cpp 2012-02-22 02:06:48.000000000 +0000 @@ -127,6 +127,7 @@ #include "methodjit/StubCalls-inl.h" #include "vm/ArgumentsObject.h" +#include "vm/MethodGuard.h" #include "ds/Sort.h" @@ -1224,11 +1225,9 @@ JS_ResolveStub, JS_ConvertStub, NULL, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ array_trace, /* trace */ { @@ -1288,11 +1287,9 @@ JS_ResolveStub, JS_ConvertStub, NULL, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ NULL, /* trace */ { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsbool.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsbool.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsbool.cpp 2012-02-21 02:06:57.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsbool.cpp 2012-02-22 02:06:48.000000000 +0000 @@ -53,13 +53,15 @@ #include "jsobj.h" #include "jsstr.h" -#include "vm/BooleanObject-inl.h" #include "vm/GlobalObject.h" #include "jsinferinlines.h" #include "jsobjinlines.h" #include "jsstrinlines.h" +#include "vm/BooleanObject-inl.h" +#include "vm/MethodGuard-inl.h" + using namespace js; using namespace js::types; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsclass.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsclass.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsclass.h 2012-02-21 02:06:57.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsclass.h 2012-02-22 02:06:48.000000000 +0000 @@ -265,11 +265,9 @@ JSFinalizeOp finalize; \ \ /* Optionally non-null members start here. */ \ - JSClassInternal reserved0; \ JSCheckAccessOp checkAccess; \ JSNative call; \ JSNative construct; \ - JSXDRObjectOp xdrObject; \ JSHasInstanceOp hasInstance; \ JSTraceOp trace @@ -372,11 +370,9 @@ JS_STATIC_ASSERT(offsetof(JSClass, resolve) == offsetof(Class, resolve)); JS_STATIC_ASSERT(offsetof(JSClass, convert) == offsetof(Class, convert)); JS_STATIC_ASSERT(offsetof(JSClass, finalize) == offsetof(Class, finalize)); -JS_STATIC_ASSERT(offsetof(JSClass, reserved0) == offsetof(Class, reserved0)); JS_STATIC_ASSERT(offsetof(JSClass, checkAccess) == offsetof(Class, checkAccess)); JS_STATIC_ASSERT(offsetof(JSClass, call) == offsetof(Class, call)); JS_STATIC_ASSERT(offsetof(JSClass, construct) == offsetof(Class, construct)); -JS_STATIC_ASSERT(offsetof(JSClass, xdrObject) == offsetof(Class, xdrObject)); JS_STATIC_ASSERT(offsetof(JSClass, hasInstance) == offsetof(Class, hasInstance)); JS_STATIC_ASSERT(offsetof(JSClass, trace) == offsetof(Class, trace)); JS_STATIC_ASSERT(sizeof(JSClass) == sizeof(Class)); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsdate.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsdate.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsdate.cpp 2012-02-21 02:06:57.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsdate.cpp 2012-02-22 02:06:48.000000000 +0000 @@ -79,6 +79,7 @@ #include "jsobjinlines.h" #include "jsstrinlines.h" +#include "vm/MethodGuard-inl.h" #include "vm/Stack-inl.h" using namespace mozilla; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsexn.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsexn.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsexn.cpp 2012-02-21 02:06:57.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsexn.cpp 2012-02-22 02:06:48.000000000 +0000 @@ -104,11 +104,9 @@ (JSResolveOp)exn_resolve, JS_ConvertStub, exn_finalize, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ exn_trace }; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsfun.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsfun.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsfun.cpp 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsfun.cpp 2012-02-22 02:06:48.000000000 +0000 @@ -71,8 +71,9 @@ #include "frontend/BytecodeCompiler.h" #include "frontend/BytecodeEmitter.h" #include "frontend/TokenStream.h" -#include "vm/ScopeObject.h" #include "vm/Debugger.h" +#include "vm/MethodGuard.h" +#include "vm/ScopeObject.h" #if JS_HAS_GENERATORS # include "jsiter.h" @@ -91,8 +92,8 @@ #include "jsinferinlines.h" #include "jsobjinlines.h" #include "jsscriptinlines.h" -#include "vm/ScopeObject-inl.h" #include "vm/ArgumentsObject-inl.h" +#include "vm/ScopeObject-inl.h" #include "vm/Stack-inl.h" using namespace mozilla; @@ -563,11 +564,9 @@ reinterpret_cast(args_resolve), JS_ConvertStub, args_finalize, /* finalize */ - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ args_trace, { @@ -599,11 +598,9 @@ reinterpret_cast(strictargs_resolve), JS_ConvertStub, args_finalize, /* finalize */ - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ args_trace, { @@ -953,11 +950,9 @@ (JSResolveOp)call_resolve, NULL, /* convert: Leave it NULL so we notice if calls ever escape */ NULL, /* finalize */ - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ call_trace }; @@ -1349,7 +1344,7 @@ /* XXX store parent and proto, if defined */ JSBool -js_XDRFunctionObject(JSXDRState *xdr, JSObject **objp) +js::XDRFunctionObject(JSXDRState *xdr, JSObject **objp) { JSContext *cx; JSFunction *fun; @@ -1392,7 +1387,7 @@ if (!JS_XDRUint32(xdr, &flagsword)) return false; - if (!js_XDRScript(xdr, &script)) + if (!XDRScript(xdr, &script)) return false; if (xdr->mode == JSXDR_DECODE) { @@ -1410,11 +1405,7 @@ return true; } -#else /* !JS_HAS_XDR */ - -#define js_XDRFunctionObject NULL - -#endif /* !JS_HAS_XDR */ +#endif /* JS_HAS_XDR */ /* * [[HasInstance]] internal method for Function objects: fetch the .prototype @@ -1509,11 +1500,9 @@ (JSResolveOp)fun_resolve, JS_ConvertStub, fun_finalize, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, fun_hasInstance, fun_trace }; @@ -2231,7 +2220,7 @@ JS_ASSERT(script->compartment() != cx->compartment); clone->script().init(NULL); - JSScript *cscript = js_CloneScript(cx, script); + JSScript *cscript = CloneScript(cx, script); if (!cscript) return NULL; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsfun.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsfun.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsfun.h 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsfun.h 2012-02-22 02:06:48.000000000 +0000 @@ -437,8 +437,12 @@ inline bool js_IsNamedLambda(JSFunction *fun) { return (fun->flags & JSFUN_LAMBDA) && fun->atom; } +namespace js { + extern JSBool -js_XDRFunctionObject(JSXDRState *xdr, JSObject **objp); +XDRFunctionObject(JSXDRState *xdr, JSObject **objp); + +} /* namespace js */ extern JSBool js_fun_apply(JSContext *cx, uintN argc, js::Value *vp); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsgc.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsgc.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsgc.cpp 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsgc.cpp 2012-02-22 02:06:48.000000000 +0000 @@ -3790,30 +3790,8 @@ }; void -IterateCompartments(JSContext *cx, void *data, - IterateCompartmentCallback compartmentCallback) -{ - CHECK_REQUEST(cx); - - JSRuntime *rt = cx->runtime; - JS_ASSERT(!rt->gcRunning); - - AutoLockGC lock(rt); - AutoHeapSession session(cx); -#ifdef JS_THREADSAFE - rt->gcHelperThread.waitBackgroundSweepEnd(); -#endif - AutoUnlockGC unlock(rt); - - AutoCopyFreeListToArenas copy(rt); - for (CompartmentsIter c(rt); !c.done(); c.next()) { - (*compartmentCallback)(cx, data, c); - } -} - -void IterateCompartmentsArenasCells(JSContext *cx, void *data, - IterateCompartmentCallback compartmentCallback, + JSIterateCompartmentCallback compartmentCallback, IterateArenaCallback arenaCallback, IterateCellCallback cellCallback) { @@ -4558,6 +4536,22 @@ } /* namespace js */ +JS_PUBLIC_API(void) +JS_IterateCompartments(JSContext *cx, void *data, + JSIterateCompartmentCallback compartmentCallback) +{ + CHECK_REQUEST(cx); + + JSRuntime *rt = cx->runtime; + JS_ASSERT(!rt->gcRunning); + + AutoLockGC lock(rt); + AutoHeapSession session(cx); + + for (CompartmentsIter c(rt); !c.done(); c.next()) + (*compartmentCallback)(cx, data, c); +} + #if JS_HAS_XML_SUPPORT extern size_t sE4XObjectsCreated; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsgc.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsgc.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsgc.h 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsgc.h 2012-02-22 02:06:48.000000000 +0000 @@ -1896,7 +1896,6 @@ void MarkStackRangeConservatively(JSTracer *trc, Value *begin, Value *end); -typedef void (*IterateCompartmentCallback)(JSContext *cx, void *data, JSCompartment *compartment); typedef void (*IterateChunkCallback)(JSContext *cx, void *data, gc::Chunk *chunk); typedef void (*IterateArenaCallback)(JSContext *cx, void *data, gc::Arena *arena, JSGCTraceKind traceKind, size_t thingSize); @@ -1904,19 +1903,13 @@ JSGCTraceKind traceKind, size_t thingSize); /* - * This function calls |compartmentCallback| on every compartment. - */ -extern JS_FRIEND_API(void) -IterateCompartments(JSContext *cx, void *data, - IterateCompartmentCallback compartmentCallback); -/* * This function calls |compartmentCallback| on every compartment, * |arenaCallback| on every in-use arena, and |cellCallback| on every in-use * cell in the GC heap. */ extern JS_FRIEND_API(void) IterateCompartmentsArenasCells(JSContext *cx, void *data, - IterateCompartmentCallback compartmentCallback, + JSIterateCompartmentCallback compartmentCallback, IterateArenaCallback arenaCallback, IterateCellCallback cellCallback); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsiter.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsiter.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsiter.cpp 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsiter.cpp 2012-02-22 02:06:48.000000000 +0000 @@ -76,6 +76,7 @@ #include "jsinferinlines.h" #include "jsobjinlines.h" +#include "vm/MethodGuard-inl.h" #include "vm/Stack-inl.h" #include "vm/String-inl.h" @@ -99,11 +100,9 @@ JS_ResolveStub, JS_ConvertStub, iterator_finalize, - NULL, /* reserved */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ iterator_trace, { @@ -126,11 +125,9 @@ JS_ResolveStub, JS_ConvertStub, NULL, /* finalize */ - NULL, /* reserved */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ NULL, /* trace */ { @@ -1339,11 +1336,9 @@ JS_ResolveStub, JS_ConvertStub, NULL, /* finalize */ - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ stopiter_hasInstance }; @@ -1428,11 +1423,9 @@ JS_ResolveStub, JS_ConvertStub, generator_finalize, - NULL, /* reserved */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ generator_trace, { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/js.msg firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/js.msg --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/js.msg 2012-02-21 02:06:55.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/js.msg 2012-02-22 02:06:48.000000000 +0000 @@ -124,7 +124,7 @@ MSG_DEF(JSMSG_CANT_CONVERT_TO, 38, 2, JSEXN_TYPEERR, "can't convert {0} to {1}") MSG_DEF(JSMSG_NO_PROPERTIES, 39, 1, JSEXN_TYPEERR, "{0} has no properties") MSG_DEF(JSMSG_CANT_FIND_CLASS, 40, 1, JSEXN_TYPEERR, "can't find class id {0}") -MSG_DEF(JSMSG_CANT_XDR_CLASS, 41, 1, JSEXN_TYPEERR, "can't XDR class {0}") +MSG_DEF(JSMSG_UNUSED41 , 41, 0, JSEXN_NONE, "") MSG_DEF(JSMSG_BYTECODE_TOO_BIG, 42, 2, JSEXN_INTERNALERR, "bytecode {0} too large (limit {1})") MSG_DEF(JSMSG_UNKNOWN_FORMAT, 43, 1, JSEXN_INTERNALERR, "unknown bytecode format {0}") MSG_DEF(JSMSG_TOO_MANY_CON_ARGS, 44, 0, JSEXN_SYNTAXERR, "too many constructor arguments") diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsnum.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsnum.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsnum.cpp 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsnum.cpp 2012-02-22 02:06:48.000000000 +0000 @@ -72,6 +72,7 @@ #include "jslibmath.h" #include "vm/GlobalObject.h" +#include "vm/MethodGuard.h" #include "jsatominlines.h" #include "jsinferinlines.h" @@ -79,6 +80,7 @@ #include "jsobjinlines.h" #include "jsstrinlines.h" +#include "vm/MethodGuard-inl.h" #include "vm/NumberObject-inl.h" #include "vm/String-inl.h" diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsobj.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsobj.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsobj.cpp 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsobj.cpp 2012-02-22 02:06:48.000000000 +0000 @@ -90,9 +90,7 @@ #include "jsscriptinlines.h" #include "jsstrinlines.h" -#include "vm/BooleanObject-inl.h" -#include "vm/NumberObject-inl.h" -#include "vm/StringObject-inl.h" +#include "vm/MethodGuard-inl.h" #if JS_HAS_GENERATORS #include "jsiter.h" @@ -6181,88 +6179,6 @@ return obj; } -#if JS_HAS_XDR - -JSBool -js_XDRObject(JSXDRState *xdr, JSObject **objp) -{ - JSContext *cx; - JSAtom *atom; - Class *clasp; - uint32_t classId, classDef; - JSProtoKey protoKey; - JSObject *proto; - - cx = xdr->cx; - atom = NULL; - if (xdr->mode == JSXDR_ENCODE) { - clasp = (*objp)->getClass(); - classId = JS_XDRFindClassIdByName(xdr, clasp->name); - classDef = !classId; - if (classDef) { - if (!JS_XDRRegisterClass(xdr, Jsvalify(clasp), &classId)) - return JS_FALSE; - protoKey = JSCLASS_CACHED_PROTO_KEY(clasp); - if (protoKey != JSProto_Null) { - classDef |= (protoKey << 1); - } else { - atom = js_Atomize(cx, clasp->name, strlen(clasp->name)); - if (!atom) - return JS_FALSE; - } - } - } else { - clasp = NULL; /* quell GCC overwarning */ - classDef = 0; - } - - /* - * XDR a flag word, which could be 0 for a class use, in which case no - * name follows, only the id in xdr's class registry; 1 for a class def, - * in which case the flag word is followed by the class name transferred - * from or to atom; or a value greater than 1, an odd number that when - * divided by two yields the JSProtoKey for class. In the last case, as - * in the 0 classDef case, no name is transferred via atom. - */ - if (!JS_XDRUint32(xdr, &classDef)) - return JS_FALSE; - if (classDef == 1 && !js_XDRAtom(xdr, &atom)) - return JS_FALSE; - - if (!JS_XDRUint32(xdr, &classId)) - return JS_FALSE; - - if (xdr->mode == JSXDR_DECODE) { - if (classDef) { - /* NB: we know that JSProto_Null is 0 here, for backward compat. */ - protoKey = (JSProtoKey) (classDef >> 1); - if (!js_GetClassPrototype(cx, NULL, protoKey, &proto, clasp)) - return JS_FALSE; - clasp = proto->getClass(); - if (!JS_XDRRegisterClass(xdr, Jsvalify(clasp), &classId)) - return JS_FALSE; - } else { - clasp = Valueify(JS_XDRFindClassById(xdr, classId)); - if (!clasp) { - char numBuf[12]; - JS_snprintf(numBuf, sizeof numBuf, "%ld", (long)classId); - JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, - JSMSG_CANT_FIND_CLASS, numBuf); - return JS_FALSE; - } - } - } - - if (!clasp->xdrObject) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, - JSMSG_CANT_XDR_CLASS, clasp->name); - return JS_FALSE; - } - return clasp->xdrObject(xdr, objp); -} - -#endif /* JS_HAS_XDR */ - #ifdef DEBUG void js_PrintObjectSlotName(JSTracer *trc, char *buf, size_t bufsize) @@ -6361,49 +6277,6 @@ return JS_FALSE; } -void -js::ReportIncompatibleMethod(JSContext *cx, CallReceiver call, Class *clasp) -{ - Value &thisv = call.thisv(); - -#ifdef DEBUG - if (thisv.isObject()) { - JS_ASSERT(thisv.toObject().getClass() != clasp || - !thisv.toObject().getProto() || - thisv.toObject().getProto()->getClass() != clasp); - } else if (thisv.isString()) { - JS_ASSERT(clasp != &StringClass); - } else if (thisv.isNumber()) { - JS_ASSERT(clasp != &NumberClass); - } else if (thisv.isBoolean()) { - JS_ASSERT(clasp != &BooleanClass); - } else { - JS_ASSERT(thisv.isUndefined() || thisv.isNull()); - } -#endif - - if (JSFunction *fun = js_ValueToFunction(cx, &call.calleev(), 0)) { - JSAutoByteString funNameBytes; - if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO, - clasp->name, funName, InformalValueTypeName(thisv)); - } - } -} - -bool -js::HandleNonGenericMethodClassMismatch(JSContext *cx, CallArgs args, Native native, Class *clasp) -{ - if (args.thisv().isObject()) { - JSObject &thisObj = args.thisv().toObject(); - if (thisObj.isProxy()) - return Proxy::nativeCall(cx, &thisObj, clasp, native, args); - } - - ReportIncompatibleMethod(cx, args, clasp); - return false; -} - #ifdef DEBUG /* diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsobj.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsobj.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsobj.h 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsobj.h 2012-02-22 02:06:48.000000000 +0000 @@ -1960,9 +1960,6 @@ } /* namespace js */ -extern JSBool -js_XDRObject(JSXDRState *xdr, JSObject **objp); - extern void js_PrintObjectSlotName(JSTracer *trc, char *buf, size_t bufsize); @@ -2030,71 +2027,6 @@ extern const char * InformalValueTypeName(const Value &v); -/* - * Report an error if call.thisv is not compatible with the specified class. - * - * NB: most callers should be calling or NonGenericMethodGuard, - * HandleNonGenericMethodClassMismatch, or BoxedPrimitiveMethodGuard (so that - * transparent proxies are handled correctly). Thus, any caller of this - * function better have a good explanation for why proxies are being handled - * correctly (e.g., by IsCallable) or are not an issue (E4X). - */ -extern void -ReportIncompatibleMethod(JSContext *cx, CallReceiver call, Class *clasp); - -/* - * A non-generic method is specified to report an error if args.thisv is not an - * object with a specific [[Class]] internal property (ES5 8.6.2). - * NonGenericMethodGuard performs this checking. Canonical usage is: - * - * CallArgs args = ... - * bool ok; - * JSObject *thisObj = NonGenericMethodGuard(cx, args, clasp, &ok); - * if (!thisObj) - * return ok; - * - * Specifically: if obj is a proxy, NonGenericMethodGuard will call the - * object's ProxyHandler's nativeCall hook (which may recursively call - * args.callee in args.thisv's compartment). Thus, there are three possible - * post-conditions: - * - * 1. thisv is an object of the given clasp: the caller may proceed; - * - * 2. there was an error: the caller must return 'false'; - * - * 3. thisv wrapped an object of the given clasp and the native was reentered - * and completed succesfully: the caller must return 'true'. - * - * Case 1 is indicated by a non-NULL return value; case 2 by a NULL return - * value with *ok == false; and case 3 by a NULL return value with *ok == true. - * - * NB: since this guard may reenter the native, the guard must be placed before - * any effectful operations are performed. - */ -inline JSObject * -NonGenericMethodGuard(JSContext *cx, CallArgs args, Native native, Class *clasp, bool *ok); - -/* - * NonGenericMethodGuard tests args.thisv's class using 'clasp'. If more than - * one class is acceptable (viz., isDenseArray() || isSlowArray()), the caller - * may test the class and delegate to HandleNonGenericMethodClassMismatch to - * handle the proxy case and error reporting. The 'clasp' argument is only used - * for error reporting (clasp->name). - */ -extern bool -HandleNonGenericMethodClassMismatch(JSContext *cx, CallArgs args, Native native, Class *clasp); - -/* - * Implement the extraction of a primitive from a value as needed for the - * toString, valueOf, and a few other methods of the boxed primitives classes - * Boolean, Number, and String (e.g., ES5 15.6.4.2). If 'true' is returned, the - * extracted primitive is stored in |*v|. If 'false' is returned, the caller - * must immediately 'return *ok'. For details, see NonGenericMethodGuard. - */ -template -inline bool -BoxedPrimitiveMethodGuard(JSContext *cx, CallArgs args, Native native, T *v, bool *ok); - } /* namespace js */ #endif /* jsobj_h___ */ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsobjinlines.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsobjinlines.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsobjinlines.h 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsobjinlines.h 2012-02-22 02:06:48.000000000 +0000 @@ -1915,74 +1915,6 @@ return true; } -namespace detail { - -template class PrimitiveBehavior { }; - -template<> -class PrimitiveBehavior { - public: - static inline bool isType(const Value &v) { return v.isString(); } - static inline JSString *extract(const Value &v) { return v.toString(); } - static inline JSString *extract(JSObject &obj) { return obj.asString().unbox(); } - static inline Class *getClass() { return &StringClass; } -}; - -template<> -class PrimitiveBehavior { - public: - static inline bool isType(const Value &v) { return v.isBoolean(); } - static inline bool extract(const Value &v) { return v.toBoolean(); } - static inline bool extract(JSObject &obj) { return obj.asBoolean().unbox(); } - static inline Class *getClass() { return &BooleanClass; } -}; - -template<> -class PrimitiveBehavior { - public: - static inline bool isType(const Value &v) { return v.isNumber(); } - static inline double extract(const Value &v) { return v.toNumber(); } - static inline double extract(JSObject &obj) { return obj.asNumber().unbox(); } - static inline Class *getClass() { return &NumberClass; } -}; - -} /* namespace detail */ - -inline JSObject * -NonGenericMethodGuard(JSContext *cx, CallArgs args, Native native, Class *clasp, bool *ok) -{ - const Value &thisv = args.thisv(); - if (thisv.isObject()) { - JSObject &obj = thisv.toObject(); - if (obj.getClass() == clasp) { - *ok = true; /* quell gcc overwarning */ - return &obj; - } - } - - *ok = HandleNonGenericMethodClassMismatch(cx, args, native, clasp); - return NULL; -} - -template -inline bool -BoxedPrimitiveMethodGuard(JSContext *cx, CallArgs args, Native native, T *v, bool *ok) -{ - typedef detail::PrimitiveBehavior Behavior; - - const Value &thisv = args.thisv(); - if (Behavior::isType(thisv)) { - *v = Behavior::extract(thisv); - return true; - } - - if (!NonGenericMethodGuard(cx, args, native, Behavior::getClass(), ok)) - return false; - - *v = Behavior::extract(thisv.toObject()); - return true; -} - inline bool ObjectClassIs(JSObject &obj, ESClassValue classValue, JSContext *cx) { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsproxy.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsproxy.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsproxy.cpp 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsproxy.cpp 2012-02-22 02:06:49.000000000 +0000 @@ -50,6 +50,8 @@ #include "jsproxy.h" #include "jsscope.h" +#include "vm/MethodGuard.h" + #include "jsatominlines.h" #include "jsinferinlines.h" #include "jsobjinlines.h" @@ -1320,11 +1322,9 @@ JS_ResolveStub, proxy_Convert, proxy_Finalize, /* finalize */ - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ proxy_HasInstance, /* hasInstance */ proxy_TraceObject, /* trace */ JS_NULL_CLASS_EXT, @@ -1376,11 +1376,9 @@ JS_ResolveStub, JS_ConvertStub, proxy_Finalize, /* finalize */ - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ proxy_TraceObject, /* trace */ { @@ -1454,11 +1452,9 @@ JS_ResolveStub, JS_ConvertStub, NULL, /* finalize */ - NULL, /* reserved0 */ NULL, /* checkAccess */ proxy_Call, proxy_Construct, - NULL, /* xdrObject */ FunctionClass.hasInstance, proxy_TraceFunction, /* trace */ JS_NULL_CLASS_EXT, @@ -1732,7 +1728,6 @@ JS_ResolveStub, JS_ConvertStub, NULL, /* finalize */ - NULL, /* reserved0 */ NULL, /* checkAccess */ callable_Call, callable_Construct, diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsscript.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsscript.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsscript.cpp 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsscript.cpp 2012-02-22 02:06:49.000000000 +0000 @@ -336,26 +336,114 @@ #endif /* JS_CRASH_DIAGNOSTICS */ -} /* namespace js */ - #if JS_HAS_XDR -enum ScriptBits { - NoScriptRval, - SavedCallerFun, - StrictModeCode, - UsesEval, - UsesArguments -}; +static bool +XDRScriptConst(JSXDRState *xdr, HeapValue *vp) +{ + /* + * A script constant can be an arbitrary primitive value as they are used + * to implement JSOP_LOOKUPSWITCH. But they cannot be objects, see + * bug 407186. + */ + enum ConstTag { + SCRIPT_INT = 0, + SCRIPT_DOUBLE = 1, + SCRIPT_STRING = 2, + SCRIPT_TRUE = 3, + SCRIPT_FALSE = 4, + SCRIPT_NULL = 5, + SCRIPT_VOID = 6 + }; + uint32_t tag; + if (xdr->mode == JSXDR_ENCODE) { + if (vp->isInt32()) { + tag = SCRIPT_INT; + } else if (vp->isDouble()) { + tag = SCRIPT_DOUBLE; + } else if (vp->isString()) { + tag = SCRIPT_STRING; + } else if (vp->isTrue()) { + tag = SCRIPT_TRUE; + } else if (vp->isFalse()) { + tag = SCRIPT_FALSE; + } else if (vp->isNull()) { + tag = SCRIPT_NULL; + } else { + JS_ASSERT(vp->isUndefined()); + tag = SCRIPT_VOID; + } + } + + if (!JS_XDRUint32(xdr, &tag)) + return false; + + switch (tag) { + case SCRIPT_INT: { + uint32_t i; + if (xdr->mode == JSXDR_ENCODE) + i = uint32_t(vp->toInt32()); + if (!JS_XDRUint32(xdr, &i)) + return JS_FALSE; + if (xdr->mode == JSXDR_DECODE) + vp->init(Int32Value(int32_t(i))); + break; + } + case SCRIPT_DOUBLE: { + double d; + if (xdr->mode == JSXDR_ENCODE) + d = vp->toDouble(); + if (!JS_XDRDouble(xdr, &d)) + return false; + if (xdr->mode == JSXDR_DECODE) + vp->init(DoubleValue(d)); + break; + } + case SCRIPT_STRING: { + JSString *str; + if (xdr->mode == JSXDR_ENCODE) + str = vp->toString(); + if (!JS_XDRString(xdr, &str)) + return false; + if (xdr->mode == JSXDR_DECODE) + vp->init(StringValue(str)); + break; + } + case SCRIPT_TRUE: + if (xdr->mode == JSXDR_DECODE) + vp->init(BooleanValue(true)); + break; + case SCRIPT_FALSE: + if (xdr->mode == JSXDR_DECODE) + vp->init(BooleanValue(false)); + break; + case SCRIPT_NULL: + if (xdr->mode == JSXDR_DECODE) + vp->init(NullValue()); + break; + case SCRIPT_VOID: + if (xdr->mode == JSXDR_DECODE) + vp->init(UndefinedValue()); + break; + } + return true; +} + static const char * SaveScriptFilename(JSContext *cx, const char *filename); JSBool -js_XDRScript(JSXDRState *xdr, JSScript **scriptp) +XDRScript(JSXDRState *xdr, JSScript **scriptp) { - JSScript *oldscript; - JSBool ok; + enum ScriptBits { + NoScriptRval, + SavedCallerFun, + StrictModeCode, + UsesEval, + UsesArguments + }; + uint32_t length, lineno, nslots; uint32_t natoms, nsrcnotes, ntrynotes, nobjects, nregexps, nconsts, i; uint32_t prologLength, version, encodedClosedCount; @@ -366,23 +454,26 @@ uint32_t scriptBits = 0; JSContext *cx = xdr->cx; - JSScript *script = *scriptp; + JSScript *script; nsrcnotes = ntrynotes = natoms = nobjects = nregexps = nconsts = 0; jssrcnote *notes = NULL; XDRScriptState *state = xdr->state; JS_ASSERT(state); - /* Should not XDR scripts optimized for a single global object. */ - JS_ASSERT_IF(script, !JSScript::isValidOffset(script->globalsOffset)); - /* XDR arguments, local vars, and upvars. */ uint16_t nargs, nvars, nupvars; #if defined(DEBUG) || defined(__GNUC__) /* quell GCC overwarning */ + script = NULL; nargs = nvars = nupvars = Bindings::BINDING_COUNT_LIMIT; #endif uint32_t argsVars, paddingUpvars; if (xdr->mode == JSXDR_ENCODE) { + script = *scriptp; + + /* Should not XDR scripts optimized for a single global object. */ + JS_ASSERT(!JSScript::isValidOffset(script->globalsOffset)); + nargs = script->bindings.countArgs(); nvars = script->bindings.countVars(); nupvars = script->bindings.countUpvars(); @@ -586,22 +677,13 @@ script->usesArguments = true; } - /* - * Control hereafter must goto error on failure, in order for the - * DECODE case to destroy script. - */ - oldscript = xdr->script; - - xdr->script = script; - ok = JS_XDRBytes(xdr, (char *)script->code, length * sizeof(jsbytecode)); - - if (!ok) - goto error; + if (!JS_XDRBytes(xdr, (char *)script->code, length * sizeof(jsbytecode))) + return false; if (!JS_XDRBytes(xdr, (char *)notes, nsrcnotes * sizeof(jssrcnote)) || !JS_XDRUint32(xdr, &lineno) || !JS_XDRUint32(xdr, &nslots)) { - goto error; + return false; } if (xdr->mode == JSXDR_DECODE && state->filename) { @@ -612,7 +694,7 @@ state->filename = filename; state->filenameSaved = true; if (!filename) - goto error; + return false; } script->filename = state->filename; } @@ -624,23 +706,23 @@ encodeable = script->principals && callbacks && callbacks->principalsTranscoder; if (!JS_XDRUint32(xdr, &encodeable)) - goto error; + return false; if (encodeable) { if (!callbacks || !callbacks->principalsTranscoder) { JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_DECODE_PRINCIPALS); - goto error; + return false; } if (!callbacks->principalsTranscoder(xdr, &script->principals)) - goto error; + return false; if (xdr->mode == JSXDR_ENCODE) sameOriginPrincipals = script->principals == script->originPrincipals; if (!JS_XDRUint32(xdr, &sameOriginPrincipals)) - goto error; + return false; if (sameOriginPrincipals) { if (xdr->mode == JSXDR_DECODE) { @@ -649,7 +731,7 @@ } } else { if (!callbacks->principalsTranscoder(xdr, &script->originPrincipals)) - goto error; + return false; } } @@ -661,7 +743,7 @@ for (i = 0; i != natoms; ++i) { if (!js_XDRAtom(xdr, &script->atoms[i])) - goto error; + return false; } /* @@ -679,37 +761,35 @@ isBlock = obj->isBlock() ? 1 : 0; } if (!JS_XDRUint32(xdr, &isBlock)) - goto error; + return false; if (isBlock == 0) { JSObject *tmp = *objp; - if (!js_XDRFunctionObject(xdr, &tmp)) - goto error; + if (!XDRFunctionObject(xdr, &tmp)) + return false; *objp = tmp; } else { JS_ASSERT(isBlock == 1); StaticBlockObject *tmp = static_cast(objp->get()); - if (!js_XDRStaticBlockObject(xdr, &tmp)) - goto error; + if (!XDRStaticBlockObject(xdr, script, &tmp)) + return false; *objp = tmp; } } for (i = 0; i != nupvars; ++i) { if (!JS_XDRUint32(xdr, reinterpret_cast(&script->upvars()->vector[i]))) - goto error; + return false; } for (i = 0; i != nregexps; ++i) { - JSObject *tmp = script->regexps()->vector[i]; - if (!js_XDRRegExpObject(xdr, &tmp)) - goto error; - script->regexps()->vector[i] = tmp; + if (!XDRScriptRegExpObject(xdr, &script->regexps()->vector[i])) + return false; } for (i = 0; i != nClosedArgs; ++i) { if (!JS_XDRUint32(xdr, &script->closedSlots[i])) - goto error; + return false; } for (i = 0; i != nClosedVars; ++i) { if (!JS_XDRUint32(xdr, &script->closedSlots[nClosedArgs + i])) - goto error; + return false; } if (ntrynotes != 0) { @@ -734,7 +814,7 @@ if (!JS_XDRUint32(xdr, &kindAndDepth) || !JS_XDRUint32(xdr, &tn->start) || !JS_XDRUint32(xdr, &tn->length)) { - goto error; + return false; } if (xdr->mode == JSXDR_DECODE) { tn->kind = uint8_t(kindAndDepth >> 16); @@ -743,28 +823,27 @@ } while (tn != tnfirst); } - for (i = 0; i != nconsts; ++i) { - Value tmp = script->consts()->vector[i]; - if (!JS_XDRValue(xdr, &tmp)) - goto error; - script->consts()->vector[i] = tmp; + if (nconsts) { + HeapValue *vector = script->consts()->vector; + for (i = 0; i != nconsts; ++i) { + if (!XDRScriptConst(xdr, &vector[i])) + return false; + } } - if (xdr->mode == JSXDR_DECODE && cx->hasRunOption(JSOPTION_PCCOUNT)) - (void) script->initCounts(cx); - - xdr->script = oldscript; - return JS_TRUE; + if (xdr->mode == JSXDR_DECODE) { + if (cx->hasRunOption(JSOPTION_PCCOUNT)) + (void) script->initCounts(cx); + *scriptp = script; + } - error: - if (xdr->mode == JSXDR_DECODE) - *scriptp = NULL; - xdr->script = oldscript; - return JS_FALSE; + return true; } #endif /* JS_HAS_XDR */ +} /* namespace js */ + bool JSScript::initCounts(JSContext *cx) { @@ -817,6 +896,7 @@ } } +namespace js { /* * Shared script filename management. @@ -846,6 +926,8 @@ return (*p)->filename; } +} /* namespace js */ + /* * Back up from a saved filename by its offset within its hash table entry. */ @@ -1623,8 +1705,6 @@ *origin = script->originPrincipals; } -} /* namespace js */ - class DisablePrincipalsTranscoding { JSSecurityCallbacks *callbacks; JSPrincipalsTranscoder temp; @@ -1670,7 +1750,7 @@ }; JSScript * -js_CloneScript(JSContext *cx, JSScript *script) +CloneScript(JSContext *cx, JSScript *script) { JS_ASSERT(cx->compartment != script->compartment()); @@ -1686,7 +1766,7 @@ #ifdef DEBUG wstate.filename = script->filename; #endif - if (!js_XDRScript(w, &script)) + if (!XDRScript(w, &script)) return NULL; uint32_t nbytes; @@ -1709,7 +1789,7 @@ rstate.filenameSaved = true; JSScript *newScript = NULL; - if (!js_XDRScript(r, &newScript)) + if (!XDRScript(r, &newScript)) return NULL; // set the proper principals for the script's new compartment @@ -1726,6 +1806,8 @@ return newScript; } +} /* namespace js */ + void JSScript::copyClosedSlotsTo(JSScript *other) { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsscript.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsscript.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsscript.h 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsscript.h 2012-02-22 02:06:49.000000000 +0000 @@ -848,8 +848,8 @@ /* * New-script-hook calling is factored from NewScriptFromEmitter so that it - * and callers of js_XDRScript can share this code. In the case of callers - * of js_XDRScript, the hook should be invoked only after successful decode + * and callers of XDRScript can share this code. In the case of callers + * of XDRScript, the hook should be invoked only after successful decode * of any owning function (the fun parameter) or script object (null fun). */ extern JS_FRIEND_API(void) @@ -928,10 +928,8 @@ inline void CurrentScriptFileLineOrigin(JSContext *cx, uintN *linenop, LineOption = NOT_CALLED_FROM_JSOP_EVAL); -} - extern JSScript * -js_CloneScript(JSContext *cx, JSScript *script); +CloneScript(JSContext *cx, JSScript *script); /* * NB: after a successful JSXDR_DECODE, js_XDRScript callers must do any @@ -939,6 +937,8 @@ * js_CallNewScriptHook. */ extern JSBool -js_XDRScript(JSXDRState *xdr, JSScript **scriptp); +XDRScript(JSXDRState *xdr, JSScript **scriptp); + +} #endif /* jsscript_h___ */ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsstr.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsstr.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsstr.cpp 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsstr.cpp 2012-02-22 02:06:49.000000000 +0000 @@ -81,6 +81,7 @@ #include "jsobjinlines.h" #include "jsautooplen.h" // generated headers last +#include "vm/MethodGuard-inl.h" #include "vm/RegExpObject-inl.h" #include "vm/RegExpStatics-inl.h" #include "vm/StringObject-inl.h" diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jstypedarray.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jstypedarray.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jstypedarray.cpp 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jstypedarray.cpp 2012-02-22 02:06:49.000000000 +0000 @@ -67,6 +67,8 @@ #include "jsobjinlines.h" #include "jstypedarrayinlines.h" +#include "vm/MethodGuard-inl.h" + using namespace mozilla; using namespace js; using namespace js::gc; @@ -2192,11 +2194,9 @@ JS_ResolveStub, JS_ConvertStub, NULL, /* finalize */ - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ ArrayBuffer::obj_trace, JS_NULL_CLASS_EXT, @@ -2310,11 +2310,9 @@ JS_ResolveStub, \ JS_ConvertStub, \ NULL, /* finalize */ \ - NULL, /* reserved0 */ \ NULL, /* checkAccess */ \ NULL, /* call */ \ NULL, /* construct */ \ - NULL, /* xdrObject */ \ NULL, /* hasInstance */ \ _typedArray::obj_trace, /* trace */ \ { \ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsweakmap.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsweakmap.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsweakmap.cpp 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsweakmap.cpp 2012-02-22 02:06:49.000000000 +0000 @@ -54,6 +54,8 @@ #include "jsgcinlines.h" #include "jsobjinlines.h" +#include "vm/MethodGuard-inl.h" + using namespace js; namespace js { @@ -119,16 +121,14 @@ JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NOT_NONNULL_OBJECT); return NULL; } - JSObject *key = &vp->toObject(); - if (!key) - return NULL; + JSObject &key = vp->toObject(); // If the key is from another compartment, and we store the wrapper as the key // the wrapper might be GC-ed since it is not strong referenced (Bug 673468). // To avoid this we always use the unwrapped object as the key instead of its // security wrapper. This also means that if the keys are ever exposed they must // be re-wrapped (see: JS_NondeterministicGetWeakMapKeys). - return JS_UnwrapObject(key); + return JS_UnwrapObject(&key); } static JSBool @@ -349,12 +349,10 @@ JS_ResolveStub, JS_ConvertStub, WeakMap_finalize, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ NULL, /* xdrObject */ - NULL, /* hasInstance */ WeakMap_mark }; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsxdrapi.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsxdrapi.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsxdrapi.cpp 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsxdrapi.cpp 2012-02-22 02:06:49.000000000 +0000 @@ -51,7 +51,6 @@ #include "jsapi.h" #include "jscntxt.h" #include "jsnum.h" -#include "jsobj.h" /* js_XDRObject */ #include "jsscript.h" /* js_XDRScript */ #include "jsstr.h" #include "jsxdrapi.h" @@ -237,11 +236,7 @@ { xdr->mode = mode; xdr->cx = cx; - xdr->registry = NULL; - xdr->numclasses = xdr->maxclasses = 0; - xdr->reghash = NULL; xdr->userdata = NULL; - xdr->script = NULL; xdr->state = NULL; } @@ -307,11 +302,6 @@ { JSContext *cx = xdr->cx; xdr->ops->finalize(xdr); - if (xdr->registry) { - cx->free_(xdr->registry); - if (xdr->reghash) - JS_DHashTableDestroy((JSDHashTable *) xdr->reghash); - } cx->free_(xdr); } @@ -493,131 +483,17 @@ return JS_XDRString(xdr, strp); } -static JSBool -XDRDoubleValue(JSXDRState *xdr, jsdouble *dp) +JS_PUBLIC_API(JSBool) +JS_XDRDouble(JSXDRState *xdr, jsdouble *dp) { jsdpun u; u.d = (xdr->mode == JSXDR_ENCODE) ? *dp : 0.0; if (!JS_XDRUint32(xdr, &u.s.lo) || !JS_XDRUint32(xdr, &u.s.hi)) - return JS_FALSE; + return false; if (xdr->mode == JSXDR_DECODE) *dp = u.d; - return JS_TRUE; -} - -JS_PUBLIC_API(JSBool) -JS_XDRDouble(JSXDRState *xdr, jsdouble *dp) -{ - jsdouble d = (xdr->mode == JSXDR_ENCODE) ? *dp : 0.0; - if (!XDRDoubleValue(xdr, &d)) - return JS_FALSE; - if (xdr->mode == JSXDR_DECODE) - *dp = d; - return JS_TRUE; -} - -enum XDRValueTag { - XDRTAG_OBJECT = 0, - XDRTAG_INT = 1, - XDRTAG_DOUBLE = 2, - XDRTAG_STRING = 3, - XDRTAG_SPECIAL = 4, - XDRTAG_XDRNULL = 5, - XDRTAG_XDRVOID = 6 -}; - -static XDRValueTag -GetXDRTag(jsval v) -{ - if (JSVAL_IS_NULL(v)) - return XDRTAG_XDRNULL; - if (JSVAL_IS_VOID(v)) - return XDRTAG_XDRVOID; - if (JSVAL_IS_OBJECT(v)) - return XDRTAG_OBJECT; - if (JSVAL_IS_INT(v)) - return XDRTAG_INT; - if (JSVAL_IS_DOUBLE(v)) - return XDRTAG_DOUBLE; - if (JSVAL_IS_STRING(v)) - return XDRTAG_STRING; - JS_ASSERT(JSVAL_IS_BOOLEAN(v)); - return XDRTAG_SPECIAL; -} - -static JSBool -XDRValueBody(JSXDRState *xdr, uint32_t type, jsval *vp) -{ - switch (type) { - case XDRTAG_XDRNULL: - *vp = JSVAL_NULL; - break; - case XDRTAG_XDRVOID: - *vp = JSVAL_VOID; - break; - case XDRTAG_STRING: { - JSString *str; - if (xdr->mode == JSXDR_ENCODE) - str = JSVAL_TO_STRING(*vp); - if (!JS_XDRString(xdr, &str)) - return JS_FALSE; - if (xdr->mode == JSXDR_DECODE) - *vp = STRING_TO_JSVAL(str); - break; - } - case XDRTAG_DOUBLE: { - double d = xdr->mode == JSXDR_ENCODE ? JSVAL_TO_DOUBLE(*vp) : 0; - if (!JS_XDRDouble(xdr, &d)) - return JS_FALSE; - if (xdr->mode == JSXDR_DECODE) - *vp = DOUBLE_TO_JSVAL(d); - break; - } - case XDRTAG_OBJECT: { - JSObject *obj; - if (xdr->mode == JSXDR_ENCODE) - obj = JSVAL_TO_OBJECT(*vp); - if (!js_XDRObject(xdr, &obj)) - return JS_FALSE; - if (xdr->mode == JSXDR_DECODE) - *vp = OBJECT_TO_JSVAL(obj); - break; - } - case XDRTAG_SPECIAL: { - uint32_t b; - if (xdr->mode == JSXDR_ENCODE) - b = (uint32_t) JSVAL_TO_BOOLEAN(*vp); - if (!JS_XDRUint32(xdr, &b)) - return JS_FALSE; - if (xdr->mode == JSXDR_DECODE) - *vp = BOOLEAN_TO_JSVAL(!!b); - break; - } - default: { - uint32_t i; - - JS_ASSERT(type == XDRTAG_INT); - if (xdr->mode == JSXDR_ENCODE) - i = (uint32_t) JSVAL_TO_INT(*vp); - if (!JS_XDRUint32(xdr, &i)) - return JS_FALSE; - if (xdr->mode == JSXDR_DECODE) - *vp = INT_TO_JSVAL((int32_t) i); - break; - } - } - return JS_TRUE; -} - -JS_PUBLIC_API(JSBool) -JS_XDRValue(JSXDRState *xdr, jsval *vp) -{ - uint32_t type; - - if (xdr->mode == JSXDR_ENCODE) - type = GetXDRTag(*vp); - return JS_XDRUint32(xdr, &type) && XDRValueBody(xdr, type, vp); + return true; } extern JSBool @@ -697,7 +573,7 @@ if (!JS_XDRCStringOrNull(xdr, (char **) &fstate.filename)) return false; - return js_XDRFunctionObject(xdr, objp); + return XDRFunctionObject(xdr, objp); } JS_PUBLIC_API(JSBool) @@ -738,7 +614,7 @@ if (!JS_XDRCStringOrNull(xdr, (char **) &state.filename)) return false; - if (!js_XDRScript(xdr, &script)) + if (!XDRScript(xdr, &script)) return false; if (xdr->mode == JSXDR_DECODE) { @@ -752,107 +628,4 @@ return true; } -#define CLASS_REGISTRY_MIN 8 -#define CLASS_INDEX_TO_ID(i) ((i)+1) -#define CLASS_ID_TO_INDEX(id) ((id)-1) - -typedef struct JSRegHashEntry { - JSDHashEntryHdr hdr; - const char *name; - uint32_t index; -} JSRegHashEntry; - -JS_PUBLIC_API(JSBool) -JS_XDRRegisterClass(JSXDRState *xdr, JSClass *clasp, uint32_t *idp) -{ - uintN numclasses, maxclasses; - JSClass **registry; - - numclasses = xdr->numclasses; - maxclasses = xdr->maxclasses; - if (numclasses == maxclasses) { - maxclasses = (maxclasses == 0) ? CLASS_REGISTRY_MIN : maxclasses << 1; - registry = (JSClass **) - xdr->cx->realloc_(xdr->registry, maxclasses * sizeof(JSClass *)); - if (!registry) - return JS_FALSE; - xdr->registry = registry; - xdr->maxclasses = maxclasses; - } else { - JS_ASSERT(numclasses && numclasses < maxclasses); - registry = xdr->registry; - } - - registry[numclasses] = clasp; - if (xdr->reghash) { - JSRegHashEntry *entry = (JSRegHashEntry *) - JS_DHashTableOperate((JSDHashTable *) xdr->reghash, - clasp->name, JS_DHASH_ADD); - if (!entry) { - JS_ReportOutOfMemory(xdr->cx); - return JS_FALSE; - } - entry->name = clasp->name; - entry->index = numclasses; - } - *idp = CLASS_INDEX_TO_ID(numclasses); - xdr->numclasses = ++numclasses; - return JS_TRUE; -} - -JS_PUBLIC_API(uint32_t) -JS_XDRFindClassIdByName(JSXDRState *xdr, const char *name) -{ - uintN i, numclasses; - - numclasses = xdr->numclasses; - if (numclasses >= 10) { - JSRegHashEntry *entry; - - /* Bootstrap reghash from registry on first overpopulated Find. */ - if (!xdr->reghash) { - xdr->reghash = - JS_NewDHashTable(JS_DHashGetStubOps(), NULL, - sizeof(JSRegHashEntry), - JS_DHASH_DEFAULT_CAPACITY(numclasses)); - if (xdr->reghash) { - for (i = 0; i < numclasses; i++) { - JSClass *clasp = xdr->registry[i]; - entry = (JSRegHashEntry *) - JS_DHashTableOperate((JSDHashTable *) xdr->reghash, - clasp->name, JS_DHASH_ADD); - entry->name = clasp->name; - entry->index = i; - } - } - } - - /* If we managed to create reghash, use it for O(1) Find. */ - if (xdr->reghash) { - entry = (JSRegHashEntry *) - JS_DHashTableOperate((JSDHashTable *) xdr->reghash, - name, JS_DHASH_LOOKUP); - if (JS_DHASH_ENTRY_IS_BUSY(&entry->hdr)) - return CLASS_INDEX_TO_ID(entry->index); - } - } - - /* Only a few classes, or we couldn't malloc reghash: use linear search. */ - for (i = 0; i < numclasses; i++) { - if (!strcmp(name, xdr->registry[i]->name)) - return CLASS_INDEX_TO_ID(i); - } - return 0; -} - -JS_PUBLIC_API(JSClass *) -JS_XDRFindClassById(JSXDRState *xdr, uint32_t id) -{ - uintN i = CLASS_ID_TO_INDEX(id); - - if (i >= xdr->numclasses) - return NULL; - return xdr->registry[i]; -} - #endif /* JS_HAS_XDR */ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsxdrapi.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsxdrapi.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsxdrapi.h 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsxdrapi.h 2012-02-22 02:06:49.000000000 +0000 @@ -125,12 +125,7 @@ JSXDRMode mode; JSXDROps *ops; JSContext *cx; - JSClass **registry; - uintN numclasses; - uintN maxclasses; - void *reghash; void *userdata; - JSScript *script; js::XDRScriptState *state; }; @@ -183,23 +178,11 @@ JS_XDRDouble(JSXDRState *xdr, jsdouble *dp); extern JS_PUBLIC_API(JSBool) -JS_XDRValue(JSXDRState *xdr, jsval *vp); - -extern JS_PUBLIC_API(JSBool) JS_XDRFunctionObject(JSXDRState *xdr, JSObject **objp); extern JS_PUBLIC_API(JSBool) JS_XDRScript(JSXDRState *xdr, JSScript **scriptp); -extern JS_PUBLIC_API(JSBool) -JS_XDRRegisterClass(JSXDRState *xdr, JSClass *clasp, uint32_t *lp); - -extern JS_PUBLIC_API(uint32_t) -JS_XDRFindClassIdByName(JSXDRState *xdr, const char *name); - -extern JS_PUBLIC_API(JSClass *) -JS_XDRFindClassById(JSXDRState *xdr, uint32_t id); - /* * Magic numbers. */ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsxml.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsxml.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/jsxml.cpp 2012-02-21 02:06:58.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/jsxml.cpp 2012-02-22 02:06:49.000000000 +0000 @@ -70,6 +70,7 @@ #include "frontend/Parser.h" #include "frontend/TokenStream.h" #include "vm/GlobalObject.h" +#include "vm/MethodGuard.h" #include "jsatominlines.h" #include "jsinferinlines.h" @@ -232,11 +233,9 @@ JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ NULL, /* mark */ { @@ -348,11 +347,9 @@ JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ NULL, /* mark */ { @@ -5379,11 +5376,9 @@ JS_ResolveStub, xml_convert, xml_finalize, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ xml_hasInstance, xml_trace, JS_NULL_CLASS_EXT, @@ -7931,11 +7926,9 @@ JS_ResolveStub, JS_ConvertStub, xmlfilter_finalize, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ xmlfilter_trace }; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/Makefile.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/Makefile.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/Makefile.in 2012-02-21 02:06:44.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/Makefile.in 2012-02-22 02:06:34.000000000 +0000 @@ -153,6 +153,7 @@ ScopeObject.cpp \ Debugger.cpp \ GlobalObject.cpp \ + MethodGuard.cpp \ Stack.cpp \ String.cpp \ BytecodeCompiler.cpp \ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/MemoryMetrics.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/MemoryMetrics.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/MemoryMetrics.cpp 2012-02-21 02:06:44.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/MemoryMetrics.cpp 2012-02-22 02:06:34.000000000 +0000 @@ -55,10 +55,10 @@ using namespace js; static void -CompartmentStatsCallback(JSContext *cx, void *vdata, JSCompartment *compartment) +StatsCompartmentCallback(JSContext *cx, void *data, JSCompartment *compartment) { // Append a new CompartmentStats to the vector. - RuntimeStats *rtStats = static_cast(vdata); + RuntimeStats *rtStats = static_cast(data); // CollectRuntimeStats reserves enough space. MOZ_ALWAYS_TRUE(rtStats->compartmentStatsVector.growBy(1)); @@ -75,30 +75,21 @@ } static void -ExplicitNonHeapCompartmentCallback(JSContext *cx, void *data, JSCompartment *compartment) -{ -#ifdef JS_METHODJIT - size_t *n = static_cast(data); - *n += compartment->sizeOfMjitCode(); -#endif -} - -static void -ChunkCallback(JSContext *cx, void *vdata, gc::Chunk *chunk) +StatsChunkCallback(JSContext *cx, void *data, gc::Chunk *chunk) { // Nb: This function is only called for dirty chunks, which is why we // increment gcHeapChunkDirtyDecommitted. - RuntimeStats *rtStats = static_cast(vdata); + RuntimeStats *rtStats = static_cast(data); for (size_t i = 0; i < gc::ArenasPerChunk; i++) if (chunk->decommittedArenas.get(i)) rtStats->gcHeapChunkDirtyDecommitted += gc::ArenaSize; } static void -ArenaCallback(JSContext *cx, void *vdata, gc::Arena *arena, - JSGCTraceKind traceKind, size_t thingSize) +StatsArenaCallback(JSContext *cx, void *data, gc::Arena *arena, + JSGCTraceKind traceKind, size_t thingSize) { - RuntimeStats *rtStats = static_cast(vdata); + RuntimeStats *rtStats = static_cast(data); rtStats->currCompartmentStats->gcHeapArenaHeaders += sizeof(gc::ArenaHeader); size_t allocationSpace = arena->thingsSpan(thingSize); @@ -107,15 +98,15 @@ // We don't call the callback on unused things. So we compute the // unused space like this: arenaUnused = maxArenaUnused - arenaUsed. // We do this by setting arenaUnused to maxArenaUnused here, and then - // subtracting thingSize for every used cell, in CellCallback(). + // subtracting thingSize for every used cell, in StatsCellCallback(). rtStats->currCompartmentStats->gcHeapArenaUnused += allocationSpace; } static void -CellCallback(JSContext *cx, void *vdata, void *thing, JSGCTraceKind traceKind, - size_t thingSize) +StatsCellCallback(JSContext *cx, void *data, void *thing, JSGCTraceKind traceKind, + size_t thingSize) { - RuntimeStats *rtStats = static_cast(vdata); + RuntimeStats *rtStats = static_cast(data); CompartmentStats *cStats = rtStats->currCompartmentStats; switch (traceKind) { case JSTRACE_OBJECT: @@ -185,7 +176,7 @@ break; } } - // Yes, this is a subtraction: see ArenaCallback() for details. + // Yes, this is a subtraction: see StatsArenaCallback() for details. cStats->gcHeapArenaUnused -= thingSize; } @@ -210,9 +201,9 @@ rtStats->gcHeapChunkTotal = size_t(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) * gc::ChunkSize; - IterateCompartmentsArenasCells(cx, rtStats, CompartmentStatsCallback, - ArenaCallback, CellCallback); - IterateChunks(cx, rtStats, ChunkCallback); + IterateCompartmentsArenasCells(cx, rtStats, StatsCompartmentCallback, + StatsArenaCallback, StatsCellCallback); + IterateChunks(cx, rtStats, StatsChunkCallback); rtStats->runtimeObject = rtStats->mallocSizeOf(rt); @@ -308,6 +299,15 @@ return true; } +static void +ExplicitNonHeapCompartmentCallback(JSContext *cx, void *data, JSCompartment *compartment) +{ +#ifdef JS_METHODJIT + size_t *n = static_cast(data); + *n += compartment->sizeOfMjitCode(); +#endif +} + JS_PUBLIC_API(bool) GetExplicitNonHeapForRuntime(JSRuntime *rt, int64_t *amount, JSMallocSizeOfFun mallocSizeOf) @@ -325,7 +325,7 @@ // explicit//mjit-code size_t n = 0; - IterateCompartments(cx, &n, ExplicitNonHeapCompartmentCallback); + JS_IterateCompartments(cx, &n, ExplicitNonHeapCompartmentCallback); *amount += n; // explicit/runtime/regexp-code @@ -346,6 +346,28 @@ return true; } +JS_PUBLIC_API(size_t) +SystemCompartmentCount(const JSRuntime *rt) +{ + size_t n = 0; + for (size_t i = 0; i < rt->compartments.length(); i++) { + if (rt->compartments[i]->isSystemCompartment) + ++n; + } + return n; +} + +JS_PUBLIC_API(size_t) +UserCompartmentCount(const JSRuntime *rt) +{ + size_t n = 0; + for (size_t i = 0; i < rt->compartments.length(); i++) { + if (!rt->compartments[i]->isSystemCompartment) + ++n; + } + return n; +} + } // namespace JS #endif // JS_THREADSAFE diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/methodjit/PolyIC.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/methodjit/PolyIC.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/methodjit/PolyIC.cpp 2012-02-21 02:06:59.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/methodjit/PolyIC.cpp 2012-02-22 02:06:49.000000000 +0000 @@ -1760,28 +1760,35 @@ BindNameLabels &labels = pic.bindNameLabels(); + if (!IsCacheableNonGlobalScope(scopeChain)) + return disable("non-cacheable obj at start of scope chain"); + /* Guard on the shape of the scope chain. */ masm.loadPtr(Address(JSFrameReg, StackFrame::offsetOfScopeChain()), pic.objReg); masm.loadShape(pic.objReg, pic.shapeReg); Jump firstShape = masm.branchPtr(Assembler::NotEqual, pic.shapeReg, ImmPtr(scopeChain->lastProperty())); - /* Walk up the scope chain. */ - JSObject *tobj = scopeChain; - Address parent(pic.objReg, ScopeObject::offsetOfEnclosingScope()); - while (tobj && tobj != obj) { - if (!IsCacheableNonGlobalScope(tobj)) - return disable("non-cacheable obj in scope chain"); - masm.loadPayload(parent, pic.objReg); - masm.loadShape(pic.objReg, pic.shapeReg); - Jump shapeTest = masm.branchPtr(Assembler::NotEqual, pic.shapeReg, - ImmPtr(tobj->lastProperty())); - if (!fails.append(shapeTest)) - return error(); - tobj = &tobj->asScope().enclosingScope(); + if (scopeChain != obj) { + /* Walk up the scope chain. */ + JSObject *tobj = &scopeChain->asScope().enclosingScope(); + Address parent(pic.objReg, ScopeObject::offsetOfEnclosingScope()); + while (tobj) { + if (!IsCacheableNonGlobalScope(tobj)) + return disable("non-cacheable obj in scope chain"); + masm.loadPayload(parent, pic.objReg); + masm.loadShape(pic.objReg, pic.shapeReg); + Jump shapeTest = masm.branchPtr(Assembler::NotEqual, pic.shapeReg, + ImmPtr(tobj->lastProperty())); + if (!fails.append(shapeTest)) + return error(); + if (tobj == obj) + break; + tobj = &tobj->asScope().enclosingScope(); + } + if (tobj != obj) + return disable("indirect hit"); } - if (tobj != obj) - return disable("indirect hit"); Jump done = masm.jump(); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/shell/jsworkers.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/shell/jsworkers.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/shell/jsworkers.cpp 2012-02-21 02:06:59.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/shell/jsworkers.cpp 2012-02-22 02:06:50.000000000 +0000 @@ -1270,16 +1270,14 @@ "ThreadPool", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, jsFinalize, - NULL, NULL, NULL, NULL, - NULL, NULL, jsTraceThreadPool, NULL + NULL, NULL, NULL, NULL, jsTraceThreadPool }; JSClass Worker::jsWorkerClass = { "Worker", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, jsFinalize, - NULL, NULL, NULL, NULL, - NULL, NULL, jsTraceWorker, NULL + NULL, NULL, NULL, NULL, jsTraceWorker }; JSFunctionSpec Worker::jsMethods[3] = { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/Debugger.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/Debugger.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/Debugger.cpp 2012-02-21 02:07:30.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/Debugger.cpp 2012-02-22 02:07:17.000000000 +0000 @@ -1328,11 +1328,9 @@ JSCLASS_HAS_RESERVED_SLOTS(JSSLOT_DEBUG_COUNT), JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Debugger::finalize, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ Debugger::traceObject }; @@ -1861,11 +1859,9 @@ JSCLASS_HAS_RESERVED_SLOTS(JSSLOT_DEBUGSCRIPT_COUNT), JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, NULL, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ DebuggerScript_trace }; @@ -2965,11 +2961,9 @@ JSCLASS_HAS_RESERVED_SLOTS(JSSLOT_DEBUGOBJECT_COUNT), JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, NULL, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ DebuggerObject_trace }; @@ -3609,11 +3603,9 @@ JSCLASS_HAS_RESERVED_SLOTS(JSSLOT_DEBUGENV_COUNT), JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, NULL, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ DebuggerEnv_trace }; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/MethodGuard.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/MethodGuard.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/MethodGuard.cpp 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/MethodGuard.cpp 2012-02-22 02:07:17.000000000 +0000 @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=99: + * + * ***** 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 method-guard code. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2012 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * 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 ***** */ + +#include "jsproxy.h" + +#include "MethodGuard.h" +#include "Stack.h" + +#include "jsfuninlines.h" +#include "jsobjinlines.h" + +using namespace js; + +void +js::ReportIncompatibleMethod(JSContext *cx, CallReceiver call, Class *clasp) +{ + Value &thisv = call.thisv(); + +#ifdef DEBUG + if (thisv.isObject()) { + JS_ASSERT(thisv.toObject().getClass() != clasp || + !thisv.toObject().getProto() || + thisv.toObject().getProto()->getClass() != clasp); + } else if (thisv.isString()) { + JS_ASSERT(clasp != &StringClass); + } else if (thisv.isNumber()) { + JS_ASSERT(clasp != &NumberClass); + } else if (thisv.isBoolean()) { + JS_ASSERT(clasp != &BooleanClass); + } else { + JS_ASSERT(thisv.isUndefined() || thisv.isNull()); + } +#endif + + if (JSFunction *fun = js_ValueToFunction(cx, &call.calleev(), 0)) { + JSAutoByteString funNameBytes; + if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) { + JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO, + clasp->name, funName, InformalValueTypeName(thisv)); + } + } +} + +bool +js::HandleNonGenericMethodClassMismatch(JSContext *cx, CallArgs args, Native native, Class *clasp) +{ + if (args.thisv().isObject()) { + JSObject &thisObj = args.thisv().toObject(); + if (thisObj.isProxy()) + return Proxy::nativeCall(cx, &thisObj, clasp, native, args); + } + + ReportIncompatibleMethod(cx, args, clasp); + return false; +} diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/MethodGuard.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/MethodGuard.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/MethodGuard.h 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/MethodGuard.h 2012-02-22 02:07:17.000000000 +0000 @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=99: + * + * ***** 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 method-guard code. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2012 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * 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 ***** */ + +/* Method prologue type-checking and unwrapping of the this parameter. */ + +#ifndef MethodGuard_h___ +#define MethodGuard_h___ + +#include "jsobj.h" + +namespace js { + +/* + * Report an error if call.thisv is not compatible with the specified class. + * + * NB: most callers should be calling or NonGenericMethodGuard, + * HandleNonGenericMethodClassMismatch, or BoxedPrimitiveMethodGuard (so that + * transparent proxies are handled correctly). Thus, any caller of this + * function better have a good explanation for why proxies are being handled + * correctly (e.g., by IsCallable) or are not an issue (E4X). + */ +extern void +ReportIncompatibleMethod(JSContext *cx, CallReceiver call, Class *clasp); + +/* + * A non-generic method is specified to report an error if args.thisv is not an + * object with a specific [[Class]] internal property (ES5 8.6.2). + * NonGenericMethodGuard performs this checking. Canonical usage is: + * + * CallArgs args = ... + * bool ok; + * JSObject *thisObj = NonGenericMethodGuard(cx, args, clasp, &ok); + * if (!thisObj) + * return ok; + * + * Specifically: if obj is a proxy, NonGenericMethodGuard will call the + * object's ProxyHandler's nativeCall hook (which may recursively call + * args.callee in args.thisv's compartment). Thus, there are three possible + * post-conditions: + * + * 1. thisv is an object of the given clasp: the caller may proceed; + * + * 2. there was an error: the caller must return 'false'; + * + * 3. thisv wrapped an object of the given clasp and the native was reentered + * and completed succesfully: the caller must return 'true'. + * + * Case 1 is indicated by a non-NULL return value; case 2 by a NULL return + * value with *ok == false; and case 3 by a NULL return value with *ok == true. + * + * NB: since this guard may reenter the native, the guard must be placed before + * any effectful operations are performed. + */ +inline JSObject * +NonGenericMethodGuard(JSContext *cx, CallArgs args, Native native, Class *clasp, bool *ok); + +/* + * NonGenericMethodGuard tests args.thisv's class using 'clasp'. If more than + * one class is acceptable (viz., isDenseArray() || isSlowArray()), the caller + * may test the class and delegate to HandleNonGenericMethodClassMismatch to + * handle the proxy case and error reporting. The 'clasp' argument is only used + * for error reporting (clasp->name). + */ +extern bool +HandleNonGenericMethodClassMismatch(JSContext *cx, CallArgs args, Native native, Class *clasp); + +/* + * Implement the extraction of a primitive from a value as needed for the + * toString, valueOf, and a few other methods of the boxed primitives classes + * Boolean, Number, and String (e.g., ES5 15.6.4.2). If 'true' is returned, the + * extracted primitive is stored in |*v|. If 'false' is returned, the caller + * must immediately 'return *ok'. For details, see NonGenericMethodGuard. + */ +template +inline bool +BoxedPrimitiveMethodGuard(JSContext *cx, CallArgs args, Native native, T *v, bool *ok); + +} /* namespace js */ + +#endif /* MethodGuard_h___ */ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/MethodGuard-inl.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/MethodGuard-inl.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/MethodGuard-inl.h 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/MethodGuard-inl.h 2012-02-22 02:07:17.000000000 +0000 @@ -0,0 +1,125 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=99: + * + * ***** 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 method-guard code. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2012 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * 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 MethodGuard_inl_h___ +#define MethodGuard_inl_h___ + +#include "jsobj.h" + +#include "MethodGuard.h" + +#include "jsobjinlines.h" + +#include "BooleanObject-inl.h" +#include "NumberObject-inl.h" +#include "StringObject-inl.h" + +namespace js { + +namespace detail { + +template class PrimitiveBehavior { }; + +template<> +class PrimitiveBehavior { + public: + static inline bool isType(const Value &v) { return v.isBoolean(); } + static inline bool extract(const Value &v) { return v.toBoolean(); } + static inline bool extract(JSObject &obj) { return obj.asBoolean().unbox(); } + static inline Class *getClass() { return &BooleanClass; } +}; + +template<> +class PrimitiveBehavior { + public: + static inline bool isType(const Value &v) { return v.isNumber(); } + static inline double extract(const Value &v) { return v.toNumber(); } + static inline double extract(JSObject &obj) { return obj.asNumber().unbox(); } + static inline Class *getClass() { return &NumberClass; } +}; + +template<> +class PrimitiveBehavior { + public: + static inline bool isType(const Value &v) { return v.isString(); } + static inline JSString *extract(const Value &v) { return v.toString(); } + static inline JSString *extract(JSObject &obj) { return obj.asString().unbox(); } + static inline Class *getClass() { return &StringClass; } +}; + +} /* namespace detail */ + +inline JSObject * +NonGenericMethodGuard(JSContext *cx, CallArgs args, Native native, Class *clasp, bool *ok) +{ + const Value &thisv = args.thisv(); + if (thisv.isObject()) { + JSObject &obj = thisv.toObject(); + if (obj.getClass() == clasp) { + *ok = true; /* quell gcc overwarning */ + return &obj; + } + } + + *ok = HandleNonGenericMethodClassMismatch(cx, args, native, clasp); + return NULL; +} + +template +inline bool +BoxedPrimitiveMethodGuard(JSContext *cx, CallArgs args, Native native, T *v, bool *ok) +{ + typedef detail::PrimitiveBehavior Behavior; + + const Value &thisv = args.thisv(); + if (Behavior::isType(thisv)) { + *v = Behavior::extract(thisv); + return true; + } + + if (!NonGenericMethodGuard(cx, args, native, Behavior::getClass(), ok)) + return false; + + *v = Behavior::extract(thisv.toObject()); + return true; +} + +} /* namespace js */ + +#endif /* MethodGuard_inl_h___ */ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/RegExpObject.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/RegExpObject.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/RegExpObject.cpp 2012-02-21 02:07:30.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/RegExpObject.cpp 2012-02-22 02:07:17.000000000 +0000 @@ -352,15 +352,9 @@ JS_ResolveStub, JS_ConvertStub, NULL, /* finalize */ - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ -#if JS_HAS_XDR - js_XDRRegExpObject, -#else - NULL -#endif NULL, /* hasInstance */ regexp_trace }; @@ -746,8 +740,8 @@ #if JS_HAS_XDR # include "jsxdrapi.h" -JSBool -js_XDRRegExpObject(JSXDRState *xdr, JSObject **objp) +bool +js::XDRScriptRegExpObject(JSXDRState *xdr, HeapPtrObject *objp) { JSAtom *source = 0; uint32_t flagsword = 0; @@ -770,7 +764,7 @@ return false; if (!reobj->clearType(xdr->cx)) return false; - *objp = reobj; + objp->init(reobj); } return true; } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/RegExpObject.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/RegExpObject.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/RegExpObject.h 2012-02-21 02:07:30.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/RegExpObject.h 2012-02-22 02:07:17.000000000 +0000 @@ -464,9 +464,9 @@ inline RegExpShared * RegExpToShared(JSContext *cx, JSObject &obj); -} /* namespace js */ +bool +XDRScriptRegExpObject(JSXDRState *xdr, HeapPtrObject *objp); -JSBool -js_XDRRegExpObject(JSXDRState *xdr, JSObject **objp); +} /* namespace js */ #endif diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/RegExpStatics.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/RegExpStatics.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/RegExpStatics.cpp 2012-02-21 02:07:30.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/RegExpStatics.cpp 2012-02-22 02:07:17.000000000 +0000 @@ -80,11 +80,9 @@ JS_ResolveStub, JS_ConvertStub, resc_finalize, - NULL, /* reserved0 */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ resc_trace }; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/ScopeObject.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/ScopeObject.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/ScopeObject.cpp 2012-02-21 02:07:30.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/ScopeObject.cpp 2012-02-22 02:07:17.000000000 +0000 @@ -382,11 +382,9 @@ JS_ResolveStub, JS_ConvertStub, NULL, /* finalize */ - NULL, /* reserved */ NULL, /* checkAccess */ NULL, /* call */ NULL, /* construct */ - NULL, /* xdrObject */ NULL, /* hasInstance */ NULL, /* trace */ JS_NULL_CLASS_EXT, @@ -617,7 +615,7 @@ } bool -js_XDRStaticBlockObject(JSXDRState *xdr, StaticBlockObject **objp) +js::XDRStaticBlockObject(JSXDRState *xdr, JSScript *script, StaticBlockObject **objp) { JSContext *cx = xdr->cx; @@ -627,8 +625,8 @@ uint32_t depthAndCount = 0; if (xdr->mode == JSXDR_ENCODE) { obj = *objp; - parentId = JSScript::isValidOffset(xdr->script->objectsOffset) - ? FindObjectIndex(xdr->script->objects(), obj->enclosingBlock()) + parentId = JSScript::isValidOffset(script->objectsOffset) + ? FindObjectIndex(script->objects(), obj->enclosingBlock()) : NO_PARENT_INDEX; uint32_t depth = obj->stackDepth(); JS_ASSERT(depth <= UINT16_MAX); @@ -654,7 +652,7 @@ */ obj->setEnclosingBlock(parentId == NO_PARENT_INDEX ? NULL - : &xdr->script->getObject(parentId)->asStaticBlock()); + : &script->getObject(parentId)->asStaticBlock()); } AutoObjectRooter tvr(cx, obj); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/ScopeObject.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/ScopeObject.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/src/vm/ScopeObject.h 2012-02-21 02:07:30.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/src/vm/ScopeObject.h 2012-02-22 02:07:17.000000000 +0000 @@ -256,9 +256,9 @@ const Value &closedSlot(unsigned i); }; -} /* namespace js */ - extern bool -js_XDRStaticBlockObject(JSXDRState *xdr, js::StaticBlockObject **objp); +XDRStaticBlockObject(JSXDRState *xdr, JSScript *script, StaticBlockObject **objp); + +} /* namespace js */ #endif /* ScopeObject_h___ */ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/shell/xpcshell.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/shell/xpcshell.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/shell/xpcshell.cpp 2012-02-21 02:07:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/shell/xpcshell.cpp 2012-02-22 02:07:17.000000000 +0000 @@ -1760,6 +1760,10 @@ setbuf(stdout, 0); #endif +#ifdef XRE_HAS_DLL_BLOCKLIST + XRE_SetupDllBlocklist(); +#endif + gErrFile = stderr; gOutFile = stdout; gInFile = stdin; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/dombindingsgen.py firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/dombindingsgen.py --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/dombindingsgen.py 2012-02-21 02:07:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/dombindingsgen.py 2012-02-22 02:07:18.000000000 +0000 @@ -444,11 +444,9 @@ " JS_ResolveStub,\n" " JS_ConvertStub,\n" " JS_FinalizeStub,\n" -" NULL, /* reserved0 */\n" " NULL, /* checkAccess */\n" " NULL, /* call */\n" " NULL, /* construct */\n" -" NULL, /* xdrObject */\n" " interface_hasInstance\n" "};\n" "\n") diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/XPCComponents.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/XPCComponents.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/XPCComponents.cpp 2012-02-21 02:07:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/XPCComponents.cpp 2012-02-22 02:07:17.000000000 +0000 @@ -2907,7 +2907,7 @@ XPCONNECT_GLOBAL_FLAGS, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, sandbox_enumerate, sandbox_resolve, sandbox_convert, sandbox_finalize, - NULL, NULL, NULL, NULL, NULL, NULL, TraceXPCGlobal + NULL, NULL, NULL, NULL, TraceXPCGlobal }; static JSFunctionSpec SandboxFunctions[] = { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/XPCJSRuntime.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/XPCJSRuntime.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/XPCJSRuntime.cpp 2012-02-21 02:07:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/XPCJSRuntime.cpp 2012-02-22 02:07:18.000000000 +0000 @@ -1211,7 +1211,7 @@ namespace xpc { void* -GetCompartmentName(JSContext *cx, JSCompartment *c) +GetCompartmentNameHelper(JSContext *cx, JSCompartment *c, bool getAddress) { nsCString* name = new nsCString(); if (js::IsAtomsCompartmentFor(cx, c)) { @@ -1220,10 +1220,10 @@ if (principals->codebase) { name->Assign(principals->codebase); - // If it's the system compartment, append the address. - // This means that multiple system compartments (and there - // can be many) can be distinguished. - if (js::IsSystemCompartment(c)) { + // If it's the system compartment and |getAddress| is true, append + // the address. This means that multiple system compartments (and + // there can be many) can be distinguished. + if (getAddress && js::IsSystemCompartment(c)) { xpc::CompartmentPrivate *compartmentPrivate = static_cast(JS_GetCompartmentPrivate(cx, c)); if (compartmentPrivate && @@ -1251,6 +1251,18 @@ return name; } +void* +GetCompartmentName(JSContext *cx, JSCompartment *c) +{ + return GetCompartmentNameHelper(cx, c, /* get address = */false); +} + +void* +GetCompartmentNameAndAddress(JSContext *cx, JSCompartment *c) +{ + return GetCompartmentNameHelper(cx, c, /* get address = */true); +} + void DestroyCompartmentName(void *string) { @@ -1372,7 +1384,7 @@ // Nb: js-system-compartment-count + js-user-compartment-count could be // different to the number of compartments reported by -// XPConnectJSCompartmentsMultiReporter if a garbage collection occurred +// JSMemoryMultiReporter if a garbage collection occurred // between them being consulted. We could move these reporters into // XPConnectJSCompartmentCount to avoid that problem, but then we couldn't // easily report them via telemetry, so we live with the small risk of @@ -1705,7 +1717,7 @@ // gcTotal is the sum of everything we've reported for the GC heap. It // should equal rtStats.gcHeapChunkTotal. - JS_ASSERT(gcTotal == rtStats.gcHeapChunkTotal); + JS_ASSERT(size_t(gcTotal) == rtStats.gcHeapChunkTotal); } } // namespace memory @@ -1714,7 +1726,77 @@ NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(JsMallocSizeOf, "js") -class XPConnectJSCompartmentsMultiReporter : public nsIMemoryMultiReporter +class JSCompartmentsMultiReporter : public nsIMemoryMultiReporter +{ + public: + NS_DECL_ISUPPORTS + + NS_IMETHOD GetName(nsACString &name) + { + name.AssignLiteral("compartments"); + return NS_OK; + } + + typedef js::Vector Paths; + + static void CompartmentCallback(JSContext *cx, void* data, JSCompartment *c) + { + Paths *paths = static_cast(data); + nsCString *name = + static_cast(xpc::GetCompartmentName(cx, c)); + nsCString path; + if (js::IsSystemCompartment(c)) + path = NS_LITERAL_CSTRING("compartments/system/") + *name; + else + path = NS_LITERAL_CSTRING("compartments/user/") + *name; + if (!paths->append(path)) + return; // silent failure, but it's very unlikely + + xpc::DestroyCompartmentName(name); + } + + NS_IMETHOD CollectReports(nsIMemoryMultiReporterCallback *callback, + nsISupports *closure) + { + // First we collect the compartment paths. Then we report them. Doing + // the two steps interleaved is a bad idea, because calling |callback| + // from within CompartmentCallback() leads to all manner of assertions. + + // Collect. + XPCJSRuntime *xpcrt = nsXPConnect::GetRuntimeInstance(); + JSContext *cx = JS_NewContext(xpcrt->GetJSRuntime(), 0); + if (!cx) + return NS_ERROR_OUT_OF_MEMORY; + + Paths paths; + JS_IterateCompartments(cx, &paths, CompartmentCallback); + JS_DestroyContextNoGC(cx); + + // Report. + for (size_t i = 0; i < paths.length(); i++) + // These ones don't need a description, hence the "". + ReportMemory(paths[i], + nsIMemoryReporter::KIND_OTHER, + nsIMemoryReporter::UNITS_COUNT, + 1, "", callback, closure); + + return NS_OK; + } + + NS_IMETHOD + GetExplicitNonHeap(PRInt64 *n) + { + // This reporter does neither "explicit" nor NONHEAP measurements. + *n = 0; + return NS_OK; + } +}; + +NS_IMPL_THREADSAFE_ISUPPORTS1(JSCompartmentsMultiReporter + , nsIMemoryMultiReporter + ) + +class JSMemoryMultiReporter : public nsIMemoryMultiReporter { public: NS_DECL_ISUPPORTS @@ -1735,7 +1817,7 @@ // the callback. Separating these steps is important because the // callback may be a JS function, and executing JS while getting these // stats seems like a bad idea. - JS::RuntimeStats rtStats(JsMallocSizeOf, xpc::GetCompartmentName, + JS::RuntimeStats rtStats(JsMallocSizeOf, xpc::GetCompartmentNameAndAddress, xpc::DestroyCompartmentName); if (!JS::CollectRuntimeStats(xpcrt->GetJSRuntime(), &rtStats)) return NS_ERROR_FAILURE; @@ -1861,7 +1943,7 @@ } }; -NS_IMPL_THREADSAFE_ISUPPORTS1(XPConnectJSCompartmentsMultiReporter +NS_IMPL_THREADSAFE_ISUPPORTS1(JSMemoryMultiReporter , nsIMemoryMultiReporter ) @@ -2001,7 +2083,8 @@ NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(XPConnectJSGCHeap)); NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(XPConnectJSSystemCompartmentCount)); NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(XPConnectJSUserCompartmentCount)); - NS_RegisterMemoryMultiReporter(new XPConnectJSCompartmentsMultiReporter); + NS_RegisterMemoryMultiReporter(new JSMemoryMultiReporter); + NS_RegisterMemoryMultiReporter(new JSCompartmentsMultiReporter); } if (!JS_DHashTableInit(&mJSHolders, JS_DHashGetStubOps(), nsnull, @@ -2087,7 +2170,7 @@ ok = mozilla::dom::binding::DefineStaticJSVals(cx); if (!ok) return false; - + ok = DefineStaticDictionaryJSVals(cx); } if (!ok) diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/xpcpublic.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/xpcpublic.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/xpcpublic.h 2012-02-21 02:07:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/xpcpublic.h 2012-02-22 02:07:18.000000000 +0000 @@ -219,7 +219,8 @@ * Note, the ownership of the string buffer may be moved from str to rval. * If that happens, str will point to an empty string after this call. */ -bool StringToJsval(JSContext *cx, nsString &str, JS::Value *rval); +bool StringToJsval(JSContext *cx, nsAString &str, JS::Value *rval); +bool NonVoidStringToJsval(JSContext *cx, nsAString &str, JS::Value *rval); void *GetCompartmentName(JSContext *cx, JSCompartment *c); void DestroyCompartmentName(void *string); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/XPCQuickStubs.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/XPCQuickStubs.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/XPCQuickStubs.cpp 2012-02-21 02:07:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/XPCQuickStubs.cpp 2012-02-22 02:07:18.000000000 +0000 @@ -1048,14 +1048,20 @@ namespace xpc { bool -StringToJsval(JSContext *cx, nsString &str, JS::Value *rval) +StringToJsval(JSContext *cx, nsAString &str, JS::Value *rval) { // From the T_DOMSTRING case in XPCConvert::NativeData2JS. if (str.IsVoid()) { *rval = JSVAL_NULL; return true; } + return NonVoidStringToJsval(cx, str, rval); +} +bool +NonVoidStringToJsval(JSContext *cx, nsAString &str, JS::Value *rval) +{ + MOZ_ASSERT(!str.IsVoid()); nsStringBuffer* sharedBuffer; jsval jsstr = XPCStringConvert::ReadableToJSVal(cx, str, &sharedBuffer); if (JSVAL_IS_NULL(jsstr)) diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/XPCString.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/XPCString.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/XPCString.cpp 2012-02-21 02:07:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/XPCString.cpp 2012-02-22 02:07:18.000000000 +0000 @@ -55,8 +55,6 @@ #include "xpcprivate.h" #include "nsStringBuffer.h" -static int sDOMStringFinalizerIndex = -1; - static void FinalizeDOMString(const JSStringFinalizer *fin, jschar *chars) { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/XPCThreadContext.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/XPCThreadContext.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/XPCThreadContext.cpp 2012-02-21 02:07:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/XPCThreadContext.cpp 2012-02-22 02:07:18.000000000 +0000 @@ -177,7 +177,7 @@ XPCONNECT_GLOBAL_FLAGS, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, SafeGlobalResolve, JS_ConvertStub, SafeFinalize, - NULL, NULL, NULL, NULL, NULL, NULL, TraceXPCGlobal + NULL, NULL, NULL, NULL, TraceXPCGlobal }; // We just use the same reporter as the component loader diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/XPCWrappedNativeJSOps.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/XPCWrappedNativeJSOps.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/XPCWrappedNativeJSOps.cpp 2012-02-21 02:07:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/XPCWrappedNativeJSOps.cpp 2012-02-22 02:07:18.000000000 +0000 @@ -832,11 +832,9 @@ XPC_WN_NoHelper_Finalize, // finalize /* Optionally non-null members start here. */ - nsnull, // reserved0 nsnull, // checkAccess nsnull, // call nsnull, // construct - nsnull, // xdrObject; nsnull, // hasInstance XPC_WN_NoHelper_Trace, // trace @@ -1697,11 +1695,9 @@ XPC_WN_Shared_Proto_Finalize, // finalize; /* Optionally non-null members start here. */ - nsnull, // reserved0; nsnull, // checkAccess; nsnull, // call; nsnull, // construct; - nsnull, // xdrObject; nsnull, // hasInstance; XPC_WN_Shared_Proto_Trace, // trace; @@ -1724,11 +1720,9 @@ XPC_WN_Shared_Proto_Finalize, // finalize; /* Optionally non-null members start here. */ - nsnull, // reserved0; nsnull, // checkAccess; nsnull, // call; nsnull, // construct; - nsnull, // xdrObject; nsnull, // hasInstance; XPC_WN_Shared_Proto_Trace, // trace; @@ -1814,11 +1808,9 @@ XPC_WN_Shared_Proto_Finalize, // finalize; /* Optionally non-null members start here. */ - nsnull, // reserved0; nsnull, // checkAccess; nsnull, // call; nsnull, // construct; - nsnull, // xdrObject; nsnull, // hasInstance; XPC_WN_Shared_Proto_Trace, // trace; @@ -1841,11 +1833,9 @@ XPC_WN_Shared_Proto_Finalize, // finalize; /* Optionally non-null members start here. */ - nsnull, // reserved0; nsnull, // checkAccess; nsnull, // call; nsnull, // construct; - nsnull, // xdrObject; nsnull, // hasInstance; XPC_WN_Shared_Proto_Trace, // trace; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/XPCWrappedNativeScope.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/XPCWrappedNativeScope.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/js/xpconnect/src/XPCWrappedNativeScope.cpp 2012-02-21 02:07:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/js/xpconnect/src/XPCWrappedNativeScope.cpp 2012-02-22 02:07:18.000000000 +0000 @@ -214,11 +214,9 @@ nsnull, // finalize; /* Optionally non-null members start here. */ - nsnull, // reserved0; nsnull, // checkAccess; nsnull, // call; nsnull, // construct; - nsnull, // xdrObject; nsnull, // hasInstance; nsnull, // trace; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/l10n/ast/toolkit/chrome/mozapps/downloads/downloads.properties firefox-trunk-13.0~a1~hg20120222r87313/mozilla/l10n/ast/toolkit/chrome/mozapps/downloads/downloads.properties --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/l10n/ast/toolkit/chrome/mozapps/downloads/downloads.properties 2012-02-21 02:12:44.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/l10n/ast/toolkit/chrome/mozapps/downloads/downloads.properties 2012-02-22 02:12:32.000000000 +0000 @@ -63,7 +63,7 @@ timePair2=%1$S %2$S # LOCALIZATION NOTE (timeLeftSingle): #1 time left # example: 1 minute remaining; 11 hours remaining -timeLeftSingle2=%1$S restante(s) +timeLeftSingle2=%1$S restantes # LOCALIZATION NOTE (timeLeftDouble): #1 time left; #2 time left sub units # example: 11 hours, 2 minutes remaining; 1 day, 22 hours remaining timeLeftDouble2=%1$S, %2$S restantes diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/l10n/changesets firefox-trunk-13.0~a1~hg20120222r87313/mozilla/l10n/changesets --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/l10n/changesets 2012-02-21 02:28:30.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/l10n/changesets 2012-02-22 02:28:51.000000000 +0000 @@ -2,7 +2,7 @@ ak 33:b63976a41857 ar 222:65864671440e as 42:91f05eea7266 -ast 212:c85b88a5be25 +ast 213:169fc00f177e be 181:0fbae0bd8344 bg 47:0f6af4c0a77e bn-BD 51:f232fa9979dc @@ -13,7 +13,7 @@ cs 999:a02266b4e1f4 cy 89:3698a70073dd da 169:a2d98b075593 -de 1968:cb3c61727483 +de 1970:fa8527e92bd4 el 185:d86245461831 en-GB 121:31ce81db0475 en-ZA 24:b992b0b8e48b @@ -30,7 +30,7 @@ fy-NL 592:8dee92c9687c ga-IE 216:a25558725a45 gd 202:e24ff7030420 -gl 463:486e9a160e11 +gl 466:d99457e2fb29 gu-IN 227:55b51acae085 he 268:aa010a58427e hi-IN 134:60c8e64bb657 @@ -68,7 +68,7 @@ pt-PT 1343:0668decaea2a rm 129:2284b6f87ef0 ro 200:07fa294e5b25 -ru 1144:51f733e836a9 +ru 1145:83114c4ca0f3 si 273:dba62aee0e50 sk 215:a0e759e83e31 sl 194:b642fabfa55e diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/l10n/gl/browser/chrome/browser/devtools/gclicommands.properties firefox-trunk-13.0~a1~hg20120222r87313/mozilla/l10n/gl/browser/chrome/browser/devtools/gclicommands.properties --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/l10n/gl/browser/chrome/browser/devtools/gclicommands.properties 2012-02-21 02:17:50.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/l10n/gl/browser/chrome/browser/devtools/gclicommands.properties 2012-02-22 02:17:52.000000000 +0000 @@ -131,3 +131,23 @@ # 'console close' command. This string is designed to be shown in a menu # alongside the command name, which is why it should be as short as possible. consolecloseDesc=Pechar a consola + +# LOCALIZATION NOTE (editDesc) A very short description of the 'edit' +# command. See editManual for a fuller description of what it does. This +# string is designed to be shown in a menu alongside the command name, which +# is why it should be as short as possible. +editDesc=Axustar un recurso da páxina + +# LOCALIZATION NOTE (editManual) A fuller description of the 'edit' command, +# displayed when the user asks for help on what it does. +editManual=Editar un dos recursos que é parte desta páxina (ou quizais algún recurso web xenérico?) + +# LOCALIZATION NOTE (editResourceDesc) A very short string to describe the +# 'resource' parameter to the 'edit' command, which is displayed in a dialog +# when the user is using this command. +editResourceDesc=URL para editar + +# LOCALIZATION NOTE (editLineToJumpToDesc) A very short string to describe the +# 'line' parameter to the 'edit' command, which is displayed in a dialog +# when the user is using this command. +editLineToJumpToDesc=Liña á que ir diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/l10n/gl/toolkit/chrome/global/aboutSupport.dtd firefox-trunk-13.0~a1~hg20120222r87313/mozilla/l10n/gl/toolkit/chrome/global/aboutSupport.dtd --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/l10n/gl/toolkit/chrome/global/aboutSupport.dtd 2012-02-21 02:18:01.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/l10n/gl/toolkit/chrome/global/aboutSupport.dtd 2012-02-22 02:17:57.000000000 +0000 @@ -41,6 +41,9 @@ + + + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/base/FrameLayerBuilder.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/base/FrameLayerBuilder.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/base/FrameLayerBuilder.cpp 2012-02-21 02:07:32.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/base/FrameLayerBuilder.cpp 2012-02-22 02:07:18.000000000 +0000 @@ -1434,8 +1434,8 @@ NS_ASSERTION(ownLayer->Manager() == mManager, "Wrong manager"); NS_ASSERTION(!ownLayer->HasUserData(&gLayerManagerUserData), "We shouldn't have a FrameLayerBuilder-managed layer here!"); - NS_ASSERTION(aClip.mHaveClipRect || - aClip.mRoundedClipRects.IsEmpty(), + NS_ASSERTION(aClip.mHaveClipRect || + aClip.mRoundedClipRects.IsEmpty(), "If we have rounded rects, we must have a clip rect"); // It has its own layer. Update that layer's clip and visible rects. if (aClip.mHaveClipRect) { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/base/nsPresShell.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/base/nsPresShell.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/base/nsPresShell.cpp 2012-02-21 02:07:33.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/base/nsPresShell.cpp 2012-02-22 02:07:23.000000000 +0000 @@ -5347,6 +5347,12 @@ void PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll) { + // If drag session has started, we shouldn't synthesize mousemove event. + nsCOMPtr dragSession = nsContentUtils::GetDragSession(); + if (dragSession) { + return; + } + // allow new event to be posted while handling this one only if the // source of the event is a scroll (to prevent infinite reflow loops) if (aFromScroll) { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/base/nsStyleConsts.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/base/nsStyleConsts.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/base/nsStyleConsts.h 2012-02-21 02:07:34.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/base/nsStyleConsts.h 2012-02-22 02:07:23.000000000 +0000 @@ -475,22 +475,22 @@ #define NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED NS_FONT_STRETCH_ULTRA_EXPANDED // See nsStyleFont - system fonts -#define NS_STYLE_FONT_CAPTION 1 // css2 +#define NS_STYLE_FONT_CAPTION 1 // css2 #define NS_STYLE_FONT_ICON 2 #define NS_STYLE_FONT_MENU 3 #define NS_STYLE_FONT_MESSAGE_BOX 4 #define NS_STYLE_FONT_SMALL_CAPTION 5 #define NS_STYLE_FONT_STATUS_BAR 6 -#define NS_STYLE_FONT_WINDOW 7 // css3 -#define NS_STYLE_FONT_DOCUMENT 8 -#define NS_STYLE_FONT_WORKSPACE 9 -#define NS_STYLE_FONT_DESKTOP 10 -#define NS_STYLE_FONT_INFO 11 -#define NS_STYLE_FONT_DIALOG 12 -#define NS_STYLE_FONT_BUTTON 13 -#define NS_STYLE_FONT_PULL_DOWN_MENU 14 -#define NS_STYLE_FONT_LIST 15 -#define NS_STYLE_FONT_FIELD 16 +#define NS_STYLE_FONT_WINDOW 7 // css3 +#define NS_STYLE_FONT_DOCUMENT 8 +#define NS_STYLE_FONT_WORKSPACE 9 +#define NS_STYLE_FONT_DESKTOP 10 +#define NS_STYLE_FONT_INFO 11 +#define NS_STYLE_FONT_DIALOG 12 +#define NS_STYLE_FONT_BUTTON 13 +#define NS_STYLE_FONT_PULL_DOWN_MENU 14 +#define NS_STYLE_FONT_LIST 15 +#define NS_STYLE_FONT_FIELD 16 // defaults per MathML spec #define NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER 0.71f diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/build/Makefile.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/build/Makefile.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/build/Makefile.in 2012-02-21 02:07:37.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/build/Makefile.in 2012-02-22 02:07:24.000000000 +0000 @@ -148,6 +148,10 @@ $(NULL) endif +ifdef MOZ_B2G_BT #{ +SHARED_LIBRARY_LIBS += $(DEPTH)/dom/bluetooth/$(LIB_PREFIX)dombluetooth_s.$(LIB_SUFFIX) +endif #} + ifdef MOZ_B2G_RIL #{ SHARED_LIBRARY_LIBS += $(DEPTH)/dom/system/b2g/$(LIB_PREFIX)domsystemb2g_s.$(LIB_SUFFIX) endif #} @@ -272,5 +276,8 @@ LOCAL_INCLUDES += -I$(topsrcdir)/dom/system/b2g endif #} +ifdef MOZ_B2G_BT #{ +LOCAL_INCLUDES += -I$(topsrcdir)/dom/bluetooth +endif #} DEFINES += -D_IMPL_NS_LAYOUT diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/generic/nsBlockFrame.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/generic/nsBlockFrame.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/generic/nsBlockFrame.cpp 2012-02-21 02:07:46.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/generic/nsBlockFrame.cpp 2012-02-22 02:07:26.000000000 +0000 @@ -1550,22 +1550,33 @@ return NS_OK; } +/** + * Test whether lines are certain to be aligned left so that we can make + * resizing optimizations + */ +bool static inline IsAlignedLeft(const PRUint8 aAlignment, + const PRUint8 aDirection, + const PRUint8 aUnicodeBidi) +{ + return (NS_STYLE_TEXT_ALIGN_LEFT == aAlignment || + ((NS_STYLE_TEXT_ALIGN_DEFAULT == aAlignment && + NS_STYLE_DIRECTION_LTR == aDirection) || + (NS_STYLE_TEXT_ALIGN_END == aAlignment && + NS_STYLE_DIRECTION_RTL == aDirection)) && + !(NS_STYLE_UNICODE_BIDI_PLAINTEXT & aUnicodeBidi)); +} + nsresult nsBlockFrame::PrepareResizeReflow(nsBlockReflowState& aState) { const nsStyleText* styleText = GetStyleText(); + const nsStyleTextReset* styleTextReset = GetStyleTextReset(); // See if we can try and avoid marking all the lines as dirty bool tryAndSkipLines = // The text must be left-aligned. - (NS_STYLE_TEXT_ALIGN_LEFT == styleText->mTextAlign || - (NS_STYLE_TEXT_ALIGN_DEFAULT == styleText->mTextAlign && - NS_STYLE_DIRECTION_LTR == - aState.mReflowState.mStyleVisibility->mDirection && - !(NS_STYLE_UNICODE_BIDI_PLAINTEXT & - GetStyleTextReset()->mUnicodeBidi)) || - (NS_STYLE_TEXT_ALIGN_END == styleText->mTextAlign && - NS_STYLE_DIRECTION_RTL == - aState.mReflowState.mStyleVisibility->mDirection)) && + IsAlignedLeft(styleText->mTextAlign, + aState.mReflowState.mStyleVisibility->mDirection, + styleTextReset->mUnicodeBidi) && // The left content-edge must be a constant distance from the left // border-edge. !GetStylePadding()->mPadding.GetLeft().HasPercent(); @@ -1600,16 +1611,23 @@ } #endif + // The last line might not be aligned left even if the rest of the block is + bool skipLastLine = NS_STYLE_TEXT_ALIGN_AUTO == styleText->mTextAlignLast || + IsAlignedLeft(styleText->mTextAlignLast, + aState.mReflowState.mStyleVisibility->mDirection, + styleTextReset->mUnicodeBidi); + for (line_iterator line = begin_lines(), line_end = end_lines(); line != line_end; ++line) { // We let child blocks make their own decisions the same // way we are here. + bool isLastLine = line == mLines.back() && !GetNextInFlow(); if (line->IsBlock() || line->HasFloats() || - ((line != mLines.back() || GetNextInFlow()) // not the last line - && !line->HasBreakAfter()) || + (!isLastLine && !line->HasBreakAfter()) || + ((isLastLine || !line->IsLineWrapped()) && !skipLastLine) || line->ResizeReflowOptimizationDisabled() || line->IsImpactedByFloat() || (line->mBounds.XMost() > newAvailWidth)) { @@ -1625,13 +1643,14 @@ #ifdef DEBUG if (gNoisyReflow && !line->IsDirty()) { IndentBy(stdout, gNoiseIndent + 1); - printf("skipped: line=%p next=%p %s %s%s%s breakTypeBefore/After=%d/%d xmost=%d\n", + printf("skipped: line=%p next=%p %s %s%s%s%s breakTypeBefore/After=%d/%d xmost=%d\n", static_cast(line.get()), static_cast((line.next() != end_lines() ? line.next().get() : nsnull)), line->IsBlock() ? "block" : "inline", line->HasBreakAfter() ? "has-break-after " : "", line->HasFloats() ? "has-floats " : "", line->IsImpactedByFloat() ? "impacted " : "", + skipLastLine ? "last-line-left-aligned " : "", line->GetBreakTypeBefore(), line->GetBreakTypeAfter(), line->mBounds.XMost()); } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-1a.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-1a.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-1a.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-1a.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,52 @@ + + + + background-position: right 25% bottom 75% + + + +
+
+
+
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-1b.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-1b.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-1b.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-1b.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,52 @@ + + + + background-position: left 75% top 25% + + + +
+
+
+
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-1c.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-1c.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-1c.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-1c.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,52 @@ + + + + background-position: left 75% bottom 75% + + + +
+
+
+
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-1-ref.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-1-ref.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-1-ref.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-1-ref.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,28 @@ + + + + background-position: right 25% bottom 75% reference + + + +
+
+
+
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-2a.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-2a.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-2a.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-2a.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,25 @@ + + + + background-position: center bottom 75% + + + +
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-2b.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-2b.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-2b.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-2b.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,25 @@ + + + + background-position: 25% 25% + + + +
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-2-ref.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-2-ref.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-2-ref.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-2-ref.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,25 @@ + + + + background-position: left 25% bottom 75% reference + + + +
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-3a.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-3a.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-3a.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-3a.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,25 @@ + + + + background-position: center bottom 75% + + + +
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-3b.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-3b.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-3b.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-3b.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,25 @@ + + + + background-position: center 25% + + + +
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-3-ref.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-3-ref.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-3-ref.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-3-ref.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,25 @@ + + + + background-position: center bottom 75% reference + + + +
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-4a.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-4a.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-4a.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-4a.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,25 @@ + + + + background-position: left center + + + +
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-4b.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-4b.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-4b.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-4b.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,25 @@ + + + + background-position: left + + + +
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-4c.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-4c.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-4c.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-4c.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,25 @@ + + + + background-position: left bottom 50% + + + +
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-4-ref.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-4-ref.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-4-ref.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-4-ref.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,25 @@ + + + + background-position: left center reference + + + +
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-5.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-5.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-5.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-5.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,23 @@ + + + + background: url(aqua-32x32.png) left no-repeat reference + + + +
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-5-ref.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-5-ref.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-5-ref.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-5-ref.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,25 @@ + + + + background: url(aqua-32x32.png) left no-repeat reference + + + +
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-6.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-6.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-6.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-6.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,25 @@ + + + + background-position: top, bottom + + + +
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-6-ref.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-6-ref.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-6-ref.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-6-ref.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,33 @@ + + + + background-position: top, bottom reference + + + +
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-7.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-7.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-7.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-7.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,43 @@ + + + + background-position: left 25% bottom + + + +
+
+
+
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-7-ref.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-7-ref.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-7-ref.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-7-ref.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,28 @@ + + + + background-position: left 25% bottom reference + + + +
+
+
+
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-8.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-8.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-8.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-8.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,43 @@ + + + + background-position: left 25% bottom + + + +
+
+
+
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-8-ref.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-8-ref.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/background-position-8-ref.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/background-position-8-ref.html 2012-02-22 02:07:28.000000000 +0000 @@ -0,0 +1,28 @@ + + + + background-position: left 25% bottom reference + + + +
+
+
+
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/reftest.list firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/reftest.list --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/backgrounds/reftest.list 2012-02-21 02:07:50.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/backgrounds/reftest.list 2012-02-22 02:07:28.000000000 +0000 @@ -32,6 +32,21 @@ == background-clip-1.html background-clip-1-ref.html == background-clip-2.html background-clip-2-ref.html +== background-position-1a.html background-position-1-ref.html +== background-position-1b.html background-position-1-ref.html +== background-position-1c.html background-position-1-ref.html +== background-position-2a.html background-position-2-ref.html +== background-position-2b.html background-position-2-ref.html +== background-position-3a.html background-position-3-ref.html +== background-position-3b.html background-position-3-ref.html +== background-position-4a.html background-position-4-ref.html +== background-position-4b.html background-position-4-ref.html +== background-position-4c.html background-position-4-ref.html +== background-position-5.html background-position-5-ref.html +== background-position-6.html background-position-6-ref.html +== background-position-7.html background-position-7-ref.html +== background-position-8.html background-position-8-ref.html + == background-size-auto-auto.html background-size-auto-ref.html == background-size-auto.html background-size-auto-ref.html == background-size-contain.html background-size-contain-ref.html diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/svg/conditions-07.svg firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/svg/conditions-07.svg --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/svg/conditions-07.svg 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/svg/conditions-07.svg 2012-02-22 02:08:09.000000000 +0000 @@ -0,0 +1,40 @@ + + + Test conditional processing DOM interface for foreignObject + + + + + + + + + + + + + + + + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/svg/reftest.list firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/svg/reftest.list --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/svg/reftest.list 2012-02-21 02:08:21.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/svg/reftest.list 2012-02-22 02:08:10.000000000 +0000 @@ -42,6 +42,7 @@ == conditions-04.svg pass.svg == conditions-05.svg about:blank == conditions-06.svg pass.svg +== conditions-07.svg pass.svg == currentColor-01.svg pass.svg == currentColor-02.svg pass.svg == currentColor-03.svg pass.svg diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/text/726392-1.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/text/726392-1.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/text/726392-1.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/text/726392-1.html 2012-02-22 02:08:18.000000000 +0000 @@ -0,0 +1,66 @@ + + + + + Bug 726392 + + + +
+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+ + + + + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/text/726392-1-ref.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/text/726392-1-ref.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/text/726392-1-ref.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/text/726392-1-ref.html 2012-02-22 02:08:18.000000000 +0000 @@ -0,0 +1,53 @@ + + + + + Bug 726392 + + + +

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+

test

+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/text/726392-2.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/text/726392-2.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/text/726392-2.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/text/726392-2.html 2012-02-22 02:08:18.000000000 +0000 @@ -0,0 +1,66 @@ + + + + + Bug 726392 + + + +
+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+
+ + + + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/text/726392-2-ref.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/text/726392-2-ref.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/text/726392-2-ref.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/text/726392-2-ref.html 2012-02-22 02:08:18.000000000 +0000 @@ -0,0 +1,53 @@ + + + + + Bug 726392 + + + +

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+

בדיקה

+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/text/726392-3.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/text/726392-3.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/text/726392-3.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/text/726392-3.html 2012-02-22 02:08:18.000000000 +0000 @@ -0,0 +1,94 @@ + + + + + Bug 726392 + + + +
+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+
+ + + + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/text/726392-3-ref.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/text/726392-3-ref.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/text/726392-3-ref.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/text/726392-3-ref.html 2012-02-22 02:08:18.000000000 +0000 @@ -0,0 +1,83 @@ + + + + + Bug 726392 + + + +
+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+

test +test

+
+ + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/text/reftest.list firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/text/reftest.list --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/reftests/text/reftest.list 2012-02-21 02:08:29.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/reftests/text/reftest.list 2012-02-22 02:08:18.000000000 +0000 @@ -136,6 +136,10 @@ # check ligature in Arial Bold on Windows, for bug 644184; may fail on other platforms depending on fonts random-if(!winWidget) == arial-bold-lam-alef-1.html arial-bold-lam-alef-1-ref.html +== 726392-1.html 726392-1-ref.html +== 726392-2.html 726392-2-ref.html +== 726392-3.html 726392-3-ref.html + # tests to compare graphite to opentype (will trivially pass when graphite not enabled) HTTP(..) == graphite-05-ot-only.html graphite-05-ref.html HTTP(..) != graphite-05-ot-only.html graphite-05-fail.html diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/style/Declaration.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/style/Declaration.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/style/Declaration.cpp 2012-02-21 02:08:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/style/Declaration.cpp 2012-02-22 02:08:19.000000000 +0000 @@ -411,9 +411,9 @@ const nsCSSValueList *attachment = data->ValueFor(eCSSProperty_background_attachment)-> GetListValue(); - const nsCSSValuePairList *position = + const nsCSSValueList *position = data->ValueFor(eCSSProperty_background_position)-> - GetPairListValue(); + GetListValue(); const nsCSSValueList *clip = data->ValueFor(eCSSProperty_background_clip)-> GetListValue(); @@ -437,11 +437,9 @@ attachment->mValue.AppendToString(eCSSProperty_background_attachment, aValue); aValue.Append(PRUnichar(' ')); - position->mXValue.AppendToString(eCSSProperty_background_position, - aValue); - aValue.Append(PRUnichar(' ')); - position->mYValue.AppendToString(eCSSProperty_background_position, - aValue); + position->mValue.AppendToString(eCSSProperty_background_position, + aValue); + NS_ABORT_IF_FALSE(clip->mValue.GetUnit() == eCSSUnit_Enumerated && origin->mValue.GetUnit() == eCSSUnit_Enumerated, "should not be inherit/initial within list and " diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/style/nsCSSParser.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/style/nsCSSParser.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/style/nsCSSParser.cpp 2012-02-21 02:08:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/style/nsCSSParser.cpp 2012-02-22 02:08:20.000000000 +0000 @@ -460,12 +460,12 @@ nsCSSValueList* mAttachment; nsCSSValueList* mClip; nsCSSValueList* mOrigin; - nsCSSValuePairList* mPosition; + nsCSSValueList* mPosition; nsCSSValuePairList* mSize; BackgroundParseState( nsCSSValue& aColor, nsCSSValueList* aImage, nsCSSValueList* aRepeat, nsCSSValueList* aAttachment, nsCSSValueList* aClip, - nsCSSValueList* aOrigin, nsCSSValuePairList* aPosition, + nsCSSValueList* aOrigin, nsCSSValueList* aPosition, nsCSSValuePairList* aSize) : mColor(aColor), mImage(aImage), mRepeat(aRepeat), mAttachment(aAttachment), mClip(aClip), mOrigin(aOrigin), @@ -476,8 +476,14 @@ bool ParseValueList(nsCSSProperty aPropID); // a single value prop-id bool ParseBackgroundPosition(); + + // ParseBoxPositionValues parses the CSS 2.1 background-position syntax, + // which is still used by some properties. See ParseBackgroundPositionValues + // for the css3-background syntax. bool ParseBoxPositionValues(nsCSSValuePair& aOut, bool aAcceptsInherit, - bool aAllowExplicitCenter = true); + bool aAllowExplicitCenter = true); // deprecated + bool ParseBackgroundPositionValues(nsCSSValue& aOut, bool aAcceptsInherit); + bool ParseBackgroundSize(); bool ParseBackgroundSizeValues(nsCSSValuePair& aOut); bool ParseBorderColor(); @@ -4946,8 +4952,6 @@ // | contain | cover // // : , [, ]* - - bool CSSParserImpl::ParseGradient(nsCSSValue& aValue, bool aIsRadial, bool aIsRepeating) @@ -5646,7 +5650,9 @@ #define BG_LEFT NS_STYLE_BG_POSITION_LEFT #define BG_RIGHT NS_STYLE_BG_POSITION_RIGHT #define BG_CTB (BG_CENTER | BG_TOP | BG_BOTTOM) +#define BG_TB (BG_TOP | BG_BOTTOM) #define BG_CLR (BG_CENTER | BG_LEFT | BG_RIGHT) +#define BG_LR (BG_LEFT | BG_RIGHT) bool CSSParserImpl::ParseSingleValueProperty(nsCSSValue& aValue, @@ -5858,7 +5864,7 @@ nsCSSValue image, repeat, attachment, clip, origin, position, size; BackgroundParseState state(color, image.SetListValue(), repeat.SetListValue(), attachment.SetListValue(), clip.SetListValue(), - origin.SetListValue(), position.SetPairListValue(), + origin.SetListValue(), position.SetListValue(), size.SetPairListValue()); for (;;) { @@ -5888,7 +5894,7 @@ state.mClip = state.mClip->mNext; state.mOrigin->mNext = new nsCSSValueList; state.mOrigin = state.mOrigin->mNext; - state.mPosition->mNext = new nsCSSValuePairList; + state.mPosition->mNext = new nsCSSValueList; state.mPosition = state.mPosition->mNext; state.mSize->mNext = new nsCSSValuePairList; state.mSize = state.mSize->mNext; @@ -5926,8 +5932,10 @@ eCSSUnit_Enumerated); aState.mOrigin->mValue.SetIntValue(NS_STYLE_BG_ORIGIN_PADDING, eCSSUnit_Enumerated); - aState.mPosition->mXValue.SetPercentValue(0.0f); - aState.mPosition->mYValue.SetPercentValue(0.0f); + nsRefPtr positionArr = nsCSSValue::Array::Create(4); + aState.mPosition->mValue.SetArrayValue(positionArr, eCSSUnit_Array); + positionArr->Item(1).SetPercentValue(0.0f); + positionArr->Item(3).SetPercentValue(0.0f); aState.mSize->mXValue.SetAutoValue(); aState.mSize->mYValue.SetAutoValue(); @@ -5988,12 +5996,9 @@ if (havePosition) return false; havePosition = true; - nsCSSValuePair scratch; - if (!ParseBoxPositionValues(scratch, false)) { + if (!ParseBackgroundPositionValues(aState.mPosition->mValue, false)) { return false; } - aState.mPosition->mXValue = scratch.mXValue; - aState.mPosition->mYValue = scratch.mYValue; } else if (nsCSSProps::FindKeyword(keyword, nsCSSProps::kBackgroundOriginKTable, dummy)) { if (haveOrigin) @@ -6043,12 +6048,9 @@ if (havePosition) return false; havePosition = true; - nsCSSValuePair scratch; - if (!ParseBoxPositionValues(scratch, false)) { + if (!ParseBackgroundPositionValues(aState.mPosition->mValue, false)) { return false; } - aState.mPosition->mXValue = scratch.mXValue; - aState.mPosition->mYValue = scratch.mYValue; } else { if (haveColor) return false; @@ -6109,24 +6111,23 @@ return false; } } else { - nsCSSValuePair valuePair; - if (!ParseBoxPositionValues(valuePair, false)) { + nsCSSValue itemValue; + if (!ParseBackgroundPositionValues(itemValue, false)) { return false; } - nsCSSValuePairList* item = value.SetPairListValue(); + nsCSSValueList* item = value.SetListValue(); for (;;) { - item->mXValue = valuePair.mXValue; - item->mYValue = valuePair.mYValue; + item->mValue = itemValue; if (CheckEndProperty()) { break; } if (!ExpectSymbol(',', true)) { return false; } - if (!ParseBoxPositionValues(valuePair, false)) { + if (!ParseBackgroundPositionValues(itemValue, false)) { return false; } - item->mNext = new nsCSSValuePairList; + item->mNext = new nsCSSValueList; item = item->mNext; } } @@ -6135,6 +6136,12 @@ } /** + * BoxPositionMaskToCSSValue and ParseBoxPositionValues are used + * for parsing the CSS 2.1 background-position syntax (which has at + * most two values). (Compare to the css3-background syntax which + * takes up to four values.) Some current CSS specifications that + * use background-position-like syntax still use this old syntax. + ** * Parses two values that correspond to positions in a box. These can be * values corresponding to percentages of the box, raw offsets, or keywords * like "top," "left center," etc. @@ -6228,6 +6235,188 @@ return true; } +bool CSSParserImpl::ParseBackgroundPositionValues(nsCSSValue& aOut, + bool aAcceptsInherit) +{ + // css3-background allows positions to be defined as offsets + // from an edge. There can be 2 keywords and 2 offsets given. These + // four 'values' are stored in an array in the following order: + // [keyword offset keyword offset]. If a keyword or offset isn't + // parsed the value of the corresponding array element is set + // to eCSSUnit_Null by a call to nsCSSValue::Reset(). + if (aAcceptsInherit && ParseVariant(aOut, VARIANT_INHERIT, nsnull)) { + return true; + } + + nsRefPtr value = nsCSSValue::Array::Create(4); + aOut.SetArrayValue(value, eCSSUnit_Array); + + // The following clarifies organisation of the array. + nsCSSValue &xEdge = value->Item(0), + &xOffset = value->Item(1), + &yEdge = value->Item(2), + &yOffset = value->Item(3); + + // Parse all the values into the array. + PRUint32 valueCount = 0; + for (PRInt32 i = 0; i < 4; i++) { + if (!ParseVariant(value->Item(i), VARIANT_LPCALC | VARIANT_KEYWORD, + nsCSSProps::kBackgroundPositionKTable)) { + break; + } + ++valueCount; + } + + switch (valueCount) { + case 4: + // "If three or four values are given, then each or + // represents an offset and must be preceded by a keyword, which specifies + // from which edge the offset is given." + if (eCSSUnit_Enumerated != xEdge.GetUnit() || + BG_CENTER == xEdge.GetIntValue() || + eCSSUnit_Enumerated == xOffset.GetUnit() || + eCSSUnit_Enumerated != yEdge.GetUnit() || + BG_CENTER == yEdge.GetIntValue() || + eCSSUnit_Enumerated == yOffset.GetUnit()) { + return false; + } + break; + case 3: + // "If three or four values are given, then each or + // represents an offset and must be preceded by a keyword, which specifies + // from which edge the offset is given." ... "If three values are given, + // the missing offset is assumed to be zero." + if (eCSSUnit_Enumerated != value->Item(1).GetUnit()) { + // keyword offset keyword + // Second value is non-keyword, thus first value must be a non-center + // keyword. + if (eCSSUnit_Enumerated != value->Item(0).GetUnit() || + BG_CENTER == value->Item(0).GetIntValue()) { + return false; + } + + // Remaining value must be a keyword. + if (eCSSUnit_Enumerated != value->Item(2).GetUnit()) { + return false; + } + + yOffset.Reset(); // Everything else is in the correct position. + } else if (eCSSUnit_Enumerated != value->Item(2).GetUnit()) { + // keyword keyword offset + // Third value is non-keyword, thus second value must be non-center + // keyword. + if (BG_CENTER == value->Item(1).GetIntValue()) { + return false; + } + + // Remaining value must be a keyword. + if (eCSSUnit_Enumerated != value->Item(0).GetUnit()) { + return false; + } + + // Move the values to the correct position in the array. + value->Item(3) = value->Item(2); // yOffset + value->Item(2) = value->Item(1); // yEdge + value->Item(1).Reset(); // xOffset + } else { + return false; + } + break; + case 2: + // "If two values are given and at least one value is not a keyword, then + // the first value represents the horizontal position (or offset) and the + // second represents the vertical position (or offset)" + if (eCSSUnit_Enumerated == value->Item(0).GetUnit()) { + if (eCSSUnit_Enumerated == value->Item(1).GetUnit()) { + // keyword keyword + value->Item(2) = value->Item(1); // move yEdge to correct position + xOffset.Reset(); + yOffset.Reset(); + } else { + // keyword offset + // First value must represent horizontal position. + if ((BG_TOP | BG_BOTTOM) & value->Item(0).GetIntValue()) { + return false; + } + value->Item(3) = value->Item(1); // move yOffset to correct position + xOffset.Reset(); + yEdge.Reset(); + } + } else { + if (eCSSUnit_Enumerated == value->Item(1).GetUnit()) { + // offset keyword + // Second value must represent vertical position. + if ((BG_LEFT | BG_RIGHT) & value->Item(1).GetIntValue()) { + return false; + } + value->Item(2) = value->Item(1); // move yEdge to correct position + value->Item(1) = value->Item(0); // move xOffset to correct position + xEdge.Reset(); + yOffset.Reset(); + } else { + // offset offset + value->Item(3) = value->Item(1); // move yOffset to correct position + value->Item(1) = value->Item(0); // move xOffset to correct position + xEdge.Reset(); + yEdge.Reset(); + } + } + break; + case 1: + // "If only one value is specified, the second value is assumed to be + // center." + if (eCSSUnit_Enumerated == value->Item(0).GetUnit()) { + xOffset.Reset(); + } else { + value->Item(1) = value->Item(0); // move xOffset to correct position + xEdge.Reset(); + } + yEdge.SetIntValue(NS_STYLE_BG_POSITION_CENTER, eCSSUnit_Enumerated); + yOffset.Reset(); + break; + default: + return false; + } + + // For compatibility with CSS2.1 code the edges can be unspecified. + // Unspecified edges are recorded as NULL. + NS_ASSERTION((eCSSUnit_Enumerated == xEdge.GetUnit() || + eCSSUnit_Null == xEdge.GetUnit()) && + (eCSSUnit_Enumerated == yEdge.GetUnit() || + eCSSUnit_Null == yEdge.GetUnit()) && + eCSSUnit_Enumerated != xOffset.GetUnit() && + eCSSUnit_Enumerated != yOffset.GetUnit(), + "Unexpected units"); + + // Keywords in first and second pairs can not both be vertical or + // horizontal keywords. (eg. left right, bottom top). Additionally, + // non-center keyword can not be duplicated (eg. left left). + PRInt32 xEdgeEnum = + xEdge.GetUnit() == eCSSUnit_Enumerated ? xEdge.GetIntValue() : 0; + PRInt32 yEdgeEnum = + yEdge.GetUnit() == eCSSUnit_Enumerated ? yEdge.GetIntValue() : 0; + if ((xEdgeEnum | yEdgeEnum) == (BG_LEFT | BG_RIGHT) || + (xEdgeEnum | yEdgeEnum) == (BG_TOP | BG_BOTTOM) || + (xEdgeEnum & yEdgeEnum & ~BG_CENTER)) { + return false; + } + + // The values could be in an order that is different than expected. + // eg. x contains vertical information, y contains horizontal information. + // Swap if incorrect order. + if (xEdgeEnum & (BG_TOP | BG_BOTTOM) || + yEdgeEnum & (BG_LEFT | BG_RIGHT)) { + nsCSSValue swapEdge = xEdge; + nsCSSValue swapOffset = xOffset; + xEdge = yEdge; + xOffset = yOffset; + yEdge = swapEdge; + yOffset = swapOffset; + } + + return true; +} + // This function is very similar to ParseBackgroundList and // ParseBackgroundPosition. bool diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/style/nsRuleNode.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/style/nsRuleNode.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/style/nsRuleNode.cpp 2012-02-21 02:08:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/style/nsRuleNode.cpp 2012-02-22 02:08:20.000000000 +0000 @@ -2681,71 +2681,74 @@ aFont->mLanguage); // -moz-system-font: enum (never inherit!) - nsFont systemFont; + PR_STATIC_ASSERT( + NS_STYLE_FONT_CAPTION == LookAndFeel::eFont_Caption && + NS_STYLE_FONT_ICON == LookAndFeel::eFont_Icon && + NS_STYLE_FONT_MENU == LookAndFeel::eFont_Menu && + NS_STYLE_FONT_MESSAGE_BOX == LookAndFeel::eFont_MessageBox && + NS_STYLE_FONT_SMALL_CAPTION == LookAndFeel::eFont_SmallCaption && + NS_STYLE_FONT_STATUS_BAR == LookAndFeel::eFont_StatusBar && + NS_STYLE_FONT_WINDOW == LookAndFeel::eFont_Window && + NS_STYLE_FONT_DOCUMENT == LookAndFeel::eFont_Document && + NS_STYLE_FONT_WORKSPACE == LookAndFeel::eFont_Workspace && + NS_STYLE_FONT_DESKTOP == LookAndFeel::eFont_Desktop && + NS_STYLE_FONT_INFO == LookAndFeel::eFont_Info && + NS_STYLE_FONT_DIALOG == LookAndFeel::eFont_Dialog && + NS_STYLE_FONT_BUTTON == LookAndFeel::eFont_Button && + NS_STYLE_FONT_PULL_DOWN_MENU == LookAndFeel::eFont_PullDownMenu && + NS_STYLE_FONT_LIST == LookAndFeel::eFont_List && + NS_STYLE_FONT_FIELD == LookAndFeel::eFont_Field); + + // Fall back to defaultVariableFont. + nsFont systemFont = *defaultVariableFont; const nsCSSValue* systemFontValue = aRuleData->ValueForSystemFont(); if (eCSSUnit_Enumerated == systemFontValue->GetUnit()) { - nsSystemFontID sysID; - switch (systemFontValue->GetIntValue()) { - case NS_STYLE_FONT_CAPTION: sysID = eSystemFont_Caption; break; // css2 - case NS_STYLE_FONT_ICON: sysID = eSystemFont_Icon; break; - case NS_STYLE_FONT_MENU: sysID = eSystemFont_Menu; break; - case NS_STYLE_FONT_MESSAGE_BOX: sysID = eSystemFont_MessageBox; break; - case NS_STYLE_FONT_SMALL_CAPTION: sysID = eSystemFont_SmallCaption; break; - case NS_STYLE_FONT_STATUS_BAR: sysID = eSystemFont_StatusBar; break; - case NS_STYLE_FONT_WINDOW: sysID = eSystemFont_Window; break; // css3 - case NS_STYLE_FONT_DOCUMENT: sysID = eSystemFont_Document; break; - case NS_STYLE_FONT_WORKSPACE: sysID = eSystemFont_Workspace; break; - case NS_STYLE_FONT_DESKTOP: sysID = eSystemFont_Desktop; break; - case NS_STYLE_FONT_INFO: sysID = eSystemFont_Info; break; - case NS_STYLE_FONT_DIALOG: sysID = eSystemFont_Dialog; break; - case NS_STYLE_FONT_BUTTON: sysID = eSystemFont_Button; break; - case NS_STYLE_FONT_PULL_DOWN_MENU:sysID = eSystemFont_PullDownMenu; break; - case NS_STYLE_FONT_LIST: sysID = eSystemFont_List; break; - case NS_STYLE_FONT_FIELD: sysID = eSystemFont_Field; break; - } - - // GetSystemFont sets the font face but not necessarily the size - // XXX Or at least it used to -- no longer true for thebes. Maybe - // it should be again, though. - systemFont.size = defaultVariableFont->size; - - if (NS_FAILED(aPresContext->DeviceContext()->GetSystemFont(sysID, - &systemFont))) { - systemFont.name = defaultVariableFont->name; - } - - // XXXldb All of this platform-specific stuff should be in the - // nsDeviceContext implementations, not here. + gfxFontStyle fontStyle; + LookAndFeel::FontID fontID = + (LookAndFeel::FontID)systemFontValue->GetIntValue(); + if (LookAndFeel::GetFont(fontID, systemFont.name, fontStyle)) { + systemFont.style = fontStyle.style; + systemFont.systemFont = fontStyle.systemFont; + systemFont.variant = NS_FONT_VARIANT_NORMAL; + systemFont.weight = fontStyle.weight; + systemFont.stretch = fontStyle.stretch; + systemFont.decorations = NS_FONT_DECORATION_NONE; + systemFont.size = NSFloatPixelsToAppUnits(fontStyle.size, + aPresContext->DeviceContext()-> + UnscaledAppUnitsPerDevPixel()); + //systemFont.langGroup = fontStyle.langGroup; + systemFont.sizeAdjust = fontStyle.sizeAdjust; #ifdef XP_WIN - // - // As far as I can tell the system default fonts and sizes for - // on MS-Windows for Buttons, Listboxes/Comboxes and Text Fields are - // all pre-determined and cannot be changed by either the control panel - // or programmtically. - // - switch (sysID) { - // Fields (text fields) - // Button and Selects (listboxes/comboboxes) - // We use whatever font is defined by the system. Which it appears - // (and the assumption is) it is always a proportional font. Then we - // always use 2 points smaller than what the browser has defined as - // the default proportional font. - case eSystemFont_Field: - case eSystemFont_Button: - case eSystemFont_List: + // XXXldb This platform-specific stuff should be in the + // LookAndFeel implementation, not here. + // XXXzw Should we even still *have* this code? It looks to be making + // old, probably obsolete assumptions. + + // As far as I can tell the system default fonts and sizes + // on MS-Windows for Buttons, Listboxes/Comboxes and Text Fields are + // all pre-determined and cannot be changed by either the control panel + // or programmtically. + switch (fontID) { + // Fields (text fields) + // Button and Selects (listboxes/comboboxes) + // We use whatever font is defined by the system. Which it appears + // (and the assumption is) it is always a proportional font. Then we + // always use 2 points smaller than what the browser has defined as + // the default proportional font. + case LookAndFeel::eFont_Field: + case LookAndFeel::eFont_Button: + case LookAndFeel::eFont_List: // Assumption: system defined font is proportional systemFont.size = - NS_MAX(defaultVariableFont->size - nsPresContext::CSSPointsToAppUnits(2), 0); + NS_MAX(defaultVariableFont->size - + nsPresContext::CSSPointsToAppUnits(2), 0); break; - } + } #endif - } else { - // In case somebody explicitly used -moz-use-system-font. - systemFont = *defaultVariableFont; + } } - // font-family: string list, enum, inherit const nsCSSValue* familyValue = aRuleData->ValueForFontFamily(); NS_ASSERTION(eCSSUnit_Enumerated != familyValue->GetUnit(), @@ -4794,62 +4797,93 @@ } }; -struct BackgroundPositionAxis { - nsCSSValue nsCSSValuePairList::*specified; - nsStyleBackground::Position::PositionCoord - nsStyleBackground::Position::*result; -}; +/* Helper function for + * BackgroundItemComputer + * It computes a single PositionCoord from an nsCSSValue object + * (contained in a list). + */ +typedef nsStyleBackground::Position::PositionCoord PositionCoord; +static void +ComputeBackgroundPositionCoord(nsStyleContext* aStyleContext, + const nsCSSValue& aEdge, + const nsCSSValue& aOffset, + PositionCoord* aResult, + bool& aCanStoreInRuleTree) +{ + if (eCSSUnit_Percent == aOffset.GetUnit()) { + aResult->mLength = 0; + aResult->mPercent = aOffset.GetPercentValue(); + aResult->mHasPercent = true; + } else if (aOffset.IsLengthUnit()) { + aResult->mLength = CalcLength(aOffset, aStyleContext, + aStyleContext->PresContext(), + aCanStoreInRuleTree); + aResult->mPercent = 0.0f; + aResult->mHasPercent = false; + } else if (aOffset.IsCalcUnit()) { + LengthPercentPairCalcOps ops(aStyleContext, + aStyleContext->PresContext(), + aCanStoreInRuleTree); + nsRuleNode::ComputedCalc vals = ComputeCalc(aOffset, ops); + aResult->mLength = vals.mLength; + aResult->mPercent = vals.mPercent; + aResult->mHasPercent = ops.mHasPercent; + } else { + aResult->mLength = 0; + aResult->mPercent = 0.0f; + aResult->mHasPercent = false; + NS_ASSERTION(aOffset.GetUnit() == eCSSUnit_Null, "unexpected unit"); + } -static const BackgroundPositionAxis gBGPosAxes[] = { - { &nsCSSValuePairList::mXValue, - &nsStyleBackground::Position::mXPosition }, - { &nsCSSValuePairList::mYValue, - &nsStyleBackground::Position::mYPosition } -}; + if (eCSSUnit_Enumerated == aEdge.GetUnit()) { + int sign; + if (aEdge.GetIntValue() & (NS_STYLE_BG_POSITION_BOTTOM | + NS_STYLE_BG_POSITION_RIGHT)) { + sign = -1; + } else { + sign = 1; + } + aResult->mPercent = GetFloatFromBoxPosition(aEdge.GetIntValue()) + + sign * aResult->mPercent; + aResult->mLength = sign * aResult->mLength; + aResult->mHasPercent = true; + } else { + NS_ASSERTION(eCSSUnit_Null == aEdge.GetUnit(), "unexpected unit"); + } +} template <> -struct BackgroundItemComputer +struct BackgroundItemComputer { static void ComputeValue(nsStyleContext* aStyleContext, - const nsCSSValuePairList* aSpecifiedValue, + const nsCSSValueList* aSpecifiedValue, nsStyleBackground::Position& aComputedValue, bool& aCanStoreInRuleTree) { - nsStyleBackground::Position &position = aComputedValue; - for (const BackgroundPositionAxis *axis = gBGPosAxes, - *axis_end = ArrayEnd(gBGPosAxes); - axis < axis_end; ++axis) { - const nsCSSValue &specified = aSpecifiedValue->*(axis->specified); - if (eCSSUnit_Percent == specified.GetUnit()) { - (position.*(axis->result)).mLength = 0; - (position.*(axis->result)).mPercent = specified.GetPercentValue(); - (position.*(axis->result)).mHasPercent = true; - } - else if (specified.IsLengthUnit()) { - (position.*(axis->result)).mLength = - CalcLength(specified, aStyleContext, aStyleContext->PresContext(), - aCanStoreInRuleTree); - (position.*(axis->result)).mPercent = 0.0f; - (position.*(axis->result)).mHasPercent = false; - } - else if (specified.IsCalcUnit()) { - LengthPercentPairCalcOps ops(aStyleContext, - aStyleContext->PresContext(), - aCanStoreInRuleTree); - nsRuleNode::ComputedCalc vals = ComputeCalc(specified, ops); - (position.*(axis->result)).mLength = vals.mLength; - (position.*(axis->result)).mPercent = vals.mPercent; - (position.*(axis->result)).mHasPercent = ops.mHasPercent; - } - else if (eCSSUnit_Enumerated == specified.GetUnit()) { - (position.*(axis->result)).mLength = 0; - (position.*(axis->result)).mPercent = - GetFloatFromBoxPosition(specified.GetIntValue()); - (position.*(axis->result)).mHasPercent = true; - } else { - NS_NOTREACHED("unexpected unit"); - } - } + NS_ASSERTION(aSpecifiedValue->mValue.GetUnit() == eCSSUnit_Array, "bg-position not an array"); + + nsRefPtr bgPositionArray = + aSpecifiedValue->mValue.GetArrayValue(); + const nsCSSValue &xEdge = bgPositionArray->Item(0); + const nsCSSValue &xOffset = bgPositionArray->Item(1); + const nsCSSValue &yEdge = bgPositionArray->Item(2); + const nsCSSValue &yOffset = bgPositionArray->Item(3); + + NS_ASSERTION((eCSSUnit_Enumerated == xEdge.GetUnit() || + eCSSUnit_Null == xEdge.GetUnit()) && + (eCSSUnit_Enumerated == yEdge.GetUnit() || + eCSSUnit_Null == yEdge.GetUnit()) && + eCSSUnit_Enumerated != xOffset.GetUnit() && + eCSSUnit_Enumerated != yOffset.GetUnit(), + "Invalid background position"); + + ComputeBackgroundPositionCoord(aStyleContext, xEdge, xOffset, + &aComputedValue.mXPosition, + aCanStoreInRuleTree); + + ComputeBackgroundPositionCoord(aStyleContext, yEdge, yOffset, + &aComputedValue.mYPosition, + aCanStoreInRuleTree); } }; @@ -5186,12 +5220,12 @@ // background-position: enum, length, percent (flags), inherit [pair list] nsStyleBackground::Position initialPosition; initialPosition.SetInitialValues(); - SetBackgroundPairList(aContext, *aRuleData->ValueForBackgroundPosition(), - bg->mLayers, - parentBG->mLayers, &nsStyleBackground::Layer::mPosition, - initialPosition, parentBG->mPositionCount, - bg->mPositionCount, maxItemCount, rebuild, - canStoreInRuleTree); + SetBackgroundList(aContext, *aRuleData->ValueForBackgroundPosition(), + bg->mLayers, + parentBG->mLayers, &nsStyleBackground::Layer::mPosition, + initialPosition, parentBG->mPositionCount, + bg->mPositionCount, maxItemCount, rebuild, + canStoreInRuleTree); // background-size: enum, length, auto, inherit, initial [pair list] nsStyleBackground::Size initialSize; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/style/nsStyleAnimation.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/style/nsStyleAnimation.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/style/nsStyleAnimation.cpp 2012-02-21 02:08:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/style/nsStyleAnimation.cpp 2012-02-22 02:08:20.000000000 +0000 @@ -56,6 +56,7 @@ #include #include "gfxMatrix.h" #include "gfxQuaternion.h" +#include "nsPrintfCString.h" using namespace mozilla; @@ -630,6 +631,59 @@ case eUnit_Transform: { return false; } + case eUnit_BackgroundPosition: { + const nsCSSValueList *position1 = aStartValue.GetCSSValueListValue(); + const nsCSSValueList *position2 = aEndValue.GetCSSValueListValue(); + + double squareDistance = 0.0; + NS_ABORT_IF_FALSE(!position1 == !position2, "lists should be same length"); + + while (position1 && position2) { + NS_ASSERTION(position1->mValue.GetUnit() == eCSSUnit_Array && + position2->mValue.GetUnit() == eCSSUnit_Array, + "Expected two arrays"); + + CalcValue calcVal[4]; + + nsCSSValue::Array* bgArray = position1->mValue.GetArrayValue(); + NS_ABORT_IF_FALSE(bgArray->Count() == 4, "Invalid background-position"); + NS_ASSERTION(bgArray->Item(0).GetUnit() == eCSSUnit_Null && + bgArray->Item(2).GetUnit() == eCSSUnit_Null, + "Invalid list used"); + for (int i = 0; i < 2; ++i) { + NS_ABORT_IF_FALSE(bgArray->Item(i*2+1).GetUnit() != eCSSUnit_Null, + "Invalid background-position"); + calcVal[i] = ExtractCalcValue(bgArray->Item(i*2+1)); + } + + bgArray = position2->mValue.GetArrayValue(); + NS_ABORT_IF_FALSE(bgArray->Count() == 4, "Invalid background-position"); + NS_ASSERTION(bgArray->Item(0).GetUnit() == eCSSUnit_Null && + bgArray->Item(2).GetUnit() == eCSSUnit_Null, + "Invalid list used"); + for (int i = 0; i < 2; ++i) { + NS_ABORT_IF_FALSE(bgArray->Item(i*2+1).GetUnit() != eCSSUnit_Null, + "Invalid background-position"); + calcVal[i+2] = ExtractCalcValue(bgArray->Item(i*2+1)); + } + + for (int i = 0; i < 2; ++i) { + float difflen = calcVal[i+2].mLength - calcVal[i].mLength; + float diffpct = calcVal[i+2].mPercent - calcVal[i].mPercent; + squareDistance += difflen * difflen + diffpct * diffpct; + } + + position1 = position1->mNext; + position2 = position2->mNext; + } + // fail if lists differ in length. + if (position1 || position2) { + return false; + } + + aDistance = sqrt(squareDistance); + return true; + } case eUnit_CSSValuePairList: { const nsCSSValuePairList *list1 = aStartValue.GetCSSValuePairListValue(); const nsCSSValuePairList *list2 = aEndValue.GetCSSValuePairListValue(); @@ -803,6 +857,42 @@ } static bool +AddCSSValuePixelPercentCalc(const PRUint32 aValueRestrictions, + const nsCSSUnit aCommonUnit, + double aCoeff1, const nsCSSValue &aValue1, + double aCoeff2, const nsCSSValue &aValue2, + nsCSSValue &aResult) +{ + switch (aCommonUnit) { + case eCSSUnit_Pixel: + AddCSSValuePixel(aCoeff1, aValue1, + aCoeff2, aValue2, + aResult, aValueRestrictions); + break; + case eCSSUnit_Percent: + AddCSSValuePercent(aCoeff1, aValue1, + aCoeff2, aValue2, + aResult, aValueRestrictions); + break; + case eCSSUnit_Calc: + AddCSSValueCanonicalCalc(aCoeff1, aValue1, + aCoeff2, aValue2, + aResult); + break; + default: + NS_ABORT_IF_FALSE(false, + nsPrintfCString(32, + "unexpected unit %d, from %d and %d", + aCommonUnit, + aValue1.GetUnit(), + aValue2.GetUnit()).get()); + return false; + } + + return true; +} + +static bool AddShadowItems(double aCoeff1, const nsCSSValue &aValue1, double aCoeff2, const nsCSSValue &aValue2, nsCSSValueList **&aResultTail) @@ -1728,24 +1818,11 @@ PRUint32 restrictions = nsCSSProps::ValueRestrictions(aProperty); for (PRUint32 i = 0; i < 2; ++i) { nsCSSValue nsCSSValuePair::*member = pairValues[i]; - switch (unit[i]) { - case eCSSUnit_Pixel: - AddCSSValuePixel(aCoeff1, pair1->*member, aCoeff2, pair2->*member, - result->*member, restrictions); - break; - case eCSSUnit_Percent: - AddCSSValuePercent(aCoeff1, pair1->*member, - aCoeff2, pair2->*member, - result->*member, restrictions); - break; - case eCSSUnit_Calc: - AddCSSValueCanonicalCalc(aCoeff1, pair1->*member, - aCoeff2, pair2->*member, - result->*member); - break; - default: - NS_ABORT_IF_FALSE(false, "unexpected unit"); - return false; + if (!AddCSSValuePixelPercentCalc(restrictions, unit[i], + aCoeff1, pair1->*member, + aCoeff2, pair2->*member, + result->*member) ) { + return false; } } @@ -1783,24 +1860,11 @@ PRUint32 restrictions = nsCSSProps::ValueRestrictions(aProperty); for (PRUint32 i = 0; i < 3; ++i) { nsCSSValue nsCSSValueTriplet::*member = tripletValues[i]; - switch (unit[i]) { - case eCSSUnit_Pixel: - AddCSSValuePixel(aCoeff1, &triplet1->*member, aCoeff2, &triplet2->*member, - result->*member, restrictions); - break; - case eCSSUnit_Percent: - AddCSSValuePercent(aCoeff1, &triplet1->*member, - aCoeff2, &triplet2->*member, - result->*member, restrictions); - break; - case eCSSUnit_Calc: - AddCSSValueCanonicalCalc(aCoeff1, &triplet1->*member, - aCoeff2, &triplet2->*member, - result->*member); - break; - default: - NS_ABORT_IF_FALSE(false, "unexpected unit"); - return false; + if (!AddCSSValuePixelPercentCalc(restrictions, unit[i], + aCoeff1, &triplet1->*member, + aCoeff2, &triplet2->*member, + result->*member) ) { + return false; } } @@ -2024,6 +2088,58 @@ eUnit_Transform); return true; } + case eUnit_BackgroundPosition: { + const nsCSSValueList *position1 = aValue1.GetCSSValueListValue(); + const nsCSSValueList *position2 = aValue2.GetCSSValueListValue(); + nsAutoPtr result; + nsCSSValueList **resultTail = getter_Transfers(result); + while (position1 && position2) { + nsCSSValueList *item = new nsCSSValueList; + if (!item) { + return false; + } + *resultTail = item; + resultTail = &item->mNext; + + nsCSSValue::Array* bgPos1 = position1->mValue.GetArrayValue(); + nsCSSValue::Array* bgPos2 = position2->mValue.GetArrayValue(); + nsCSSValue::Array* bgPosRes = nsCSSValue::Array::Create(4); + item->mValue.SetArrayValue(bgPosRes, eCSSUnit_Array); + + PRUint32 restrictions = nsCSSProps::ValueRestrictions(aProperty); + + /* Only iterate over elements 1 and 3. The background position is + * 'uncomputed' to only those elements. + */ + for (int i = 1; i < 4; i+=2) { + const nsCSSValue& v1 = bgPos1->Item(i); + const nsCSSValue& v2 = bgPos2->Item(i); + nsCSSValue& vr = bgPosRes->Item(i); + + nsCSSUnit unit = GetCommonUnit(aProperty, v1.GetUnit(), v2.GetUnit()); + + if (!AddCSSValuePixelPercentCalc(restrictions, unit, aCoeff1, v1, + aCoeff2, v2, vr) ) { + if (v1 != v2) { + return false; + } + vr = v1; + } + } + + position1 = position1->mNext; + position2 = position2->mNext; + } + + // Check for different lengths + if (position1 || position2) { + return false; + } + + aResultValue.SetAndAdoptCSSValueListValue(result.forget(), + eUnit_BackgroundPosition); + return true; + } case eUnit_CSSValuePairList: { const nsCSSValuePairList *list1 = aValue1.GetCSSValuePairListValue(); const nsCSSValuePairList *list2 = aValue2.GetCSSValuePairListValue(); @@ -2051,22 +2167,12 @@ if (unit == eCSSUnit_Null) { return false; } - switch (unit) { - case eCSSUnit_Pixel: - AddCSSValuePixel(aCoeff1, v1, aCoeff2, v2, vr, restrictions); - break; - case eCSSUnit_Percent: - AddCSSValuePercent(aCoeff1, v1, aCoeff2, v2, vr, restrictions); - break; - case eCSSUnit_Calc: - AddCSSValueCanonicalCalc(aCoeff1, v1, aCoeff2, v2, vr); - break; - default: - if (v1 != v2) { - return false; - } - vr = v1; - break; + if (!AddCSSValuePixelPercentCalc(restrictions, unit, aCoeff1, v1, + aCoeff2, v2, vr) ) { + if (v1 != v2) { + return false; + } + vr = v1; } } list1 = list1->mNext; @@ -2301,6 +2407,7 @@ case eUnit_Dasharray: case eUnit_Shadow: case eUnit_Transform: + case eUnit_BackgroundPosition: aSpecifiedValue. SetDependentListValue(aComputedValue.GetCSSValueListValue()); break; @@ -2764,38 +2871,44 @@ case eCSSProperty_background_position: { const nsStyleBackground *bg = static_cast(styleStruct); - nsAutoPtr result; - nsCSSValuePairList **resultTail = getter_Transfers(result); + nsAutoPtr result; + nsCSSValueList **resultTail = getter_Transfers(result); NS_ABORT_IF_FALSE(bg->mPositionCount > 0, "unexpected count"); for (PRUint32 i = 0, i_end = bg->mPositionCount; i != i_end; ++i) { - nsCSSValuePairList *item = new nsCSSValuePairList; + nsCSSValueList *item = new nsCSSValueList; *resultTail = item; resultTail = &item->mNext; + nsRefPtr bgArray = nsCSSValue::Array::Create(4); + item->mValue.SetArrayValue(bgArray.get(), eCSSUnit_Array); const nsStyleBackground::Position &pos = bg->mLayers[i].mPosition; // XXXbz is there a good reason we can't just // SetCalcValue(&pos.mXPosition, item->mXValue) here? + nsCSSValue &xValue = bgArray->Item(1), + &yValue = bgArray->Item(3); if (!pos.mXPosition.mHasPercent) { NS_ABORT_IF_FALSE(pos.mXPosition.mPercent == 0.0f, "Shouldn't have mPercent!"); - nscoordToCSSValue(pos.mXPosition.mLength, item->mXValue); + nscoordToCSSValue(pos.mXPosition.mLength, xValue); } else if (pos.mXPosition.mLength == 0) { - item->mXValue.SetPercentValue(pos.mXPosition.mPercent); + xValue.SetPercentValue(pos.mXPosition.mPercent); } else { - SetCalcValue(&pos.mXPosition, item->mXValue); + SetCalcValue(&pos.mXPosition, xValue); } + if (!pos.mYPosition.mHasPercent) { NS_ABORT_IF_FALSE(pos.mYPosition.mPercent == 0.0f, "Shouldn't have mPercent!"); - nscoordToCSSValue(pos.mYPosition.mLength, item->mYValue); + nscoordToCSSValue(pos.mYPosition.mLength, yValue); } else if (pos.mYPosition.mLength == 0) { - item->mYValue.SetPercentValue(pos.mYPosition.mPercent); + yValue.SetPercentValue(pos.mYPosition.mPercent); } else { - SetCalcValue(&pos.mYPosition, item->mYValue); + SetCalcValue(&pos.mYPosition, yValue); } } - aComputedValue.SetAndAdoptCSSValuePairListValue(result.forget()); + aComputedValue.SetAndAdoptCSSValueListValue(result.forget(), + eUnit_BackgroundPosition); break; } @@ -3146,6 +3259,7 @@ case eUnit_Dasharray: case eUnit_Shadow: case eUnit_Transform: + case eUnit_BackgroundPosition: NS_ABORT_IF_FALSE(mUnit == eUnit_Shadow || aOther.mValue.mCSSValueList, "value lists other than shadows may not be null"); if (aOther.mValue.mCSSValueList) { @@ -3371,6 +3485,7 @@ case eUnit_Dasharray: case eUnit_Shadow: case eUnit_Transform: + case eUnit_BackgroundPosition: return *mValue.mCSSValueList == *aOther.mValue.mCSSValueList; case eUnit_CSSValuePairList: return *mValue.mCSSValuePairList == *aOther.mValue.mCSSValuePairList; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/style/nsStyleAnimation.h firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/style/nsStyleAnimation.h --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/style/nsStyleAnimation.h 2012-02-21 02:08:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/style/nsStyleAnimation.h 2012-02-22 02:08:20.000000000 +0000 @@ -264,6 +264,7 @@ eUnit_Dasharray, // nsCSSValueList* (never null) eUnit_Shadow, // nsCSSValueList* (may be null) eUnit_Transform, // nsCSSValueList* (never null) + eUnit_BackgroundPosition, // nsCSSValueList* (never null) eUnit_CSSValuePairList, // nsCSSValuePairList* (never null) eUnit_UnparsedString // nsStringBuffer* (never null) }; @@ -421,7 +422,7 @@ } static bool IsCSSValueListUnit(Unit aUnit) { return aUnit == eUnit_Dasharray || aUnit == eUnit_Shadow || - aUnit == eUnit_Transform; + aUnit == eUnit_Transform || aUnit == eUnit_BackgroundPosition; } static bool IsCSSValuePairListUnit(Unit aUnit) { return aUnit == eUnit_CSSValuePairList; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/style/test/property_database.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/style/test/property_database.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/style/test/property_database.js 2012-02-21 02:08:31.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/style/test/property_database.js 2012-02-22 02:08:23.000000000 +0000 @@ -1565,7 +1565,7 @@ domProp: "backgroundPosition", inherited: false, type: CSS_TYPE_LONGHAND, - initial_values: [ "top left", "left top", "0% 0%", "0% top", "left 0%" ], + initial_values: [ "top 0% left 0%", "top 0% left", "top left", "left top", "0% 0%", "0% top", "left 0%" ], other_values: [ "top", "left", "right", "bottom", "center", "center bottom", "bottom center", "center right", "right center", "center top", "top center", "center left", "left center", "right bottom", "bottom right", "50%", "top left, top left", "top left, top right", "top right, top left", "left top, 0% 0%", "10% 20%, 30%, 40%", "top left, bottom right", "right bottom, left top", "0%", "0px", "30px", "0%, 10%, 20%, 30%", "top, top, top, top, top", "-moz-calc(20px)", "-moz-calc(20px) 10px", @@ -1577,9 +1577,30 @@ "-moz-calc(20px + 50%) -moz-calc(50% - 10px)", "-moz-calc(-20px) -moz-calc(-50%)", "-moz-calc(-20%) -moz-calc(-50%)", - "0px 0px" - ], - invalid_values: [ "50% left", "top 50%" ] + "0px 0px", + "right 20px top 60px", + "right 20px bottom 60px", + "left 20px top 60px", + "left 20px bottom 60px", + "right -50px top -50px", + "left -50px bottom -50px", + "right 20px top -50px", + "right -20px top 50px", + "right 3em bottom 10px", + "bottom 3em right 10px", + "top 3em right 10px", + "left 15px", + "10px top", + "left top 15px", + "left 10px top", + "left 20%", + "right 20%" + ], + invalid_values: [ "center 10px center 4px", "center 10px center", + "top 20%", "bottom 20%", "50% left", "top 50%", + "50% bottom 10%", "right 10% 50%", "left right", + "top bottom", "left 10% right", + "top 20px bottom 20px", "left left" ] }, "background-repeat": { domProp: "backgroundRepeat", diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp 2012-02-21 02:08:32.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp 2012-02-22 02:08:26.000000000 +0000 @@ -918,8 +918,7 @@ NS_GET_A(color) / 255.0 * opacity)); } - *aStrokePattern = nsnull; - strokePattern.swap(*aStrokePattern); + strokePattern.forget(aStrokePattern); } if (SetupCairoFill(aContext)) { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mobile/android/base/db/BrowserContract.java.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mobile/android/base/db/BrowserContract.java.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mobile/android/base/db/BrowserContract.java.in 2012-02-21 02:08:47.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mobile/android/base/db/BrowserContract.java.in 2012-02-22 02:08:37.000000000 +0000 @@ -102,6 +102,8 @@ public static final class Bookmarks implements CommonColumns, URLColumns, ImageColumns, SyncColumns { private Bookmarks() {} + public static final int FIXED_ROOT_ID = 0; + public static final String MOBILE_FOLDER_GUID = "mobile"; public static final String PLACES_FOLDER_GUID = "places"; public static final String MENU_FOLDER_GUID = "menu"; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mobile/android/base/db/BrowserProvider.java.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mobile/android/base/db/BrowserProvider.java.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mobile/android/base/db/BrowserProvider.java.in 2012-02-21 02:08:47.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mobile/android/base/db/BrowserProvider.java.in 2012-02-22 02:08:37.000000000 +0000 @@ -42,7 +42,9 @@ import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Random; import org.mozilla.gecko.GeckoAppShell; @@ -65,6 +67,7 @@ import android.content.Context; import android.content.UriMatcher; import android.database.Cursor; +import android.database.DatabaseUtils; import android.database.MatrixCursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; @@ -80,7 +83,7 @@ static final String DATABASE_NAME = "browser.db"; - static final int DATABASE_VERSION = 1; + static final int DATABASE_VERSION = 2; // Maximum age of deleted records to be cleaned up (20 days in ms) static final long MAX_AGE_OF_DELETED_RECORDS = 86400000 * 20; @@ -92,6 +95,8 @@ static final String TABLE_HISTORY = "history"; static final String TABLE_IMAGES = "images"; + static final String TABLE_BOOKMARKS_TMP = TABLE_BOOKMARKS + "_tmp"; + static final String VIEW_BOOKMARKS_WITH_IMAGES = "bookmarks_with_images"; static final String VIEW_HISTORY_WITH_IMAGES = "history_with_images"; @@ -244,11 +249,17 @@ super(context, databasePath, null, DATABASE_VERSION); } - @Override - public void onCreate(SQLiteDatabase db) { - debug("Creating browser.db: " + db.getPath()); - + private void createBookmarksTable(SQLiteDatabase db) { debug("Creating " + TABLE_BOOKMARKS + " table"); + + // Android versions older than Froyo ship with an sqlite + // that doesn't support foreign keys. + String foreignKeyOnParent = null; + if (Build.VERSION.SDK_INT >= 8) { + foreignKeyOnParent = ", FOREIGN KEY (" + Bookmarks.PARENT + + ") REFERENCES " + TABLE_BOOKMARKS + "(" + Bookmarks._ID + ")"; + } + db.execSQL("CREATE TABLE " + TABLE_BOOKMARKS + "(" + Bookmarks._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + Bookmarks.TITLE + " TEXT," + @@ -263,6 +274,7 @@ Bookmarks.DATE_MODIFIED + " INTEGER," + Bookmarks.GUID + " TEXT," + Bookmarks.IS_DELETED + " INTEGER NOT NULL DEFAULT 0" + + (foreignKeyOnParent != null ? foreignKeyOnParent : "") + ");"); db.execSQL("CREATE INDEX bookmarks_url_index ON " + TABLE_BOOKMARKS + "(" @@ -271,7 +283,9 @@ + Bookmarks.GUID + ")"); db.execSQL("CREATE INDEX bookmarks_modified_index ON " + TABLE_BOOKMARKS + "(" + Bookmarks.DATE_MODIFIED + ")"); + } + private void createHistoryTable(SQLiteDatabase db) { debug("Creating " + TABLE_HISTORY + " table"); db.execSQL("CREATE TABLE " + TABLE_HISTORY + "(" + History._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + @@ -293,7 +307,9 @@ + History.DATE_MODIFIED + ")"); db.execSQL("CREATE INDEX history_visited_index ON " + TABLE_HISTORY + "(" + History.DATE_LAST_VISITED + ")"); + } + private void createImagesTable(SQLiteDatabase db) { debug("Creating " + TABLE_IMAGES + " table"); db.execSQL("CREATE TABLE " + TABLE_IMAGES + " (" + Images._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + @@ -313,39 +329,213 @@ + Images.GUID + ")"); db.execSQL("CREATE INDEX images_modified_index ON " + TABLE_IMAGES + "(" + Images.DATE_MODIFIED + ")"); + } + private void createBookmarksWithImagesView(SQLiteDatabase db) { db.execSQL("CREATE VIEW IF NOT EXISTS " + VIEW_BOOKMARKS_WITH_IMAGES + " AS " + "SELECT " + qualifyColumn(TABLE_BOOKMARKS, "*") + ", " + Images.FAVICON + ", " + Images.THUMBNAIL + " FROM " + TABLE_BOOKMARKS_JOIN_IMAGES); + } + private void createHistoryWithImagesView(SQLiteDatabase db) { db.execSQL("CREATE VIEW IF NOT EXISTS " + VIEW_HISTORY_WITH_IMAGES + " AS " + "SELECT " + qualifyColumn(TABLE_HISTORY, "*") + ", " + Images.FAVICON + ", " + Images.THUMBNAIL + " FROM " + TABLE_HISTORY_JOIN_IMAGES); + } + + @Override + public void onCreate(SQLiteDatabase db) { + debug("Creating browser.db: " + db.getPath()); + + createBookmarksTable(db); + createHistoryTable(db); + createImagesTable(db); - createMobileBookmarksFolder(db); + createBookmarksWithImagesView(db); + createHistoryWithImagesView(db); - // FIXME: Create default bookmarks here + createOrUpdateSpecialFolder(db, Bookmarks.PLACES_FOLDER_GUID, + R.string.bookmarks_folder_places, 0); + + createOrUpdateAllSpecialFolders(db); + + // FIXME: Create default bookmarks here (bug 728224) } - private void createMobileBookmarksFolder(SQLiteDatabase db) { + private void createOrUpdateAllSpecialFolders(SQLiteDatabase db) { + createOrUpdateSpecialFolder(db, Bookmarks.MOBILE_FOLDER_GUID, + R.string.bookmarks_folder_mobile, 0); + createOrUpdateSpecialFolder(db, Bookmarks.TOOLBAR_FOLDER_GUID, + R.string.bookmarks_folder_toolbar, 1); + createOrUpdateSpecialFolder(db, Bookmarks.MENU_FOLDER_GUID, + R.string.bookmarks_folder_menu, 2); + createOrUpdateSpecialFolder(db, Bookmarks.TAGS_FOLDER_GUID, + R.string.bookmarks_folder_tags, 3); + createOrUpdateSpecialFolder(db, Bookmarks.UNFILED_FOLDER_GUID, + R.string.bookmarks_folder_unfiled, 4); + } + + private void createOrUpdateSpecialFolder(SQLiteDatabase db, + String guid, int titleId, int position) { ContentValues values = new ContentValues(); - values.put(Bookmarks.GUID, Bookmarks.MOBILE_FOLDER_GUID); + values.put(Bookmarks.GUID, guid); values.put(Bookmarks.IS_FOLDER, 1); - values.put(Bookmarks.POSITION, 0); + values.put(Bookmarks.POSITION, position); + + if (guid.equals(Bookmarks.PLACES_FOLDER_GUID)) + values.put(Bookmarks._ID, Bookmarks.FIXED_ROOT_ID); // Set the parent to 0, which sync assumes is the root - values.put(Bookmarks.PARENT, 0); + values.put(Bookmarks.PARENT, Bookmarks.FIXED_ROOT_ID); - String title = mContext.getResources().getString(R.string.bookmarks_folder_mobile); + String title = mContext.getResources().getString(titleId); values.put(Bookmarks.TITLE, title); long now = System.currentTimeMillis(); values.put(Bookmarks.DATE_CREATED, now); values.put(Bookmarks.DATE_MODIFIED, now); - db.insertOrThrow(TABLE_BOOKMARKS, Bookmarks.GUID, values); + int updated = db.update(TABLE_BOOKMARKS, values, + Bookmarks.GUID + " = ?", + new String[] { guid }); + + if (updated == 0) { + db.insert(TABLE_BOOKMARKS, Bookmarks.GUID, values); + debug("Inserted special folder: " + guid); + } else { + debug("Updated special folder: " + guid); + } + } + + private boolean isSpecialFolder(ContentValues values) { + String guid = values.getAsString(Bookmarks.GUID); + if (guid == null) + return false; + + return guid.equals(Bookmarks.MOBILE_FOLDER_GUID) || + guid.equals(Bookmarks.MENU_FOLDER_GUID) || + guid.equals(Bookmarks.TOOLBAR_FOLDER_GUID) || + guid.equals(Bookmarks.UNFILED_FOLDER_GUID) || + guid.equals(Bookmarks.TAGS_FOLDER_GUID); + } + + private void migrateBookmarkFolder(SQLiteDatabase db, int folderId) { + Cursor c = null; + + debug("Migrating bookmark folder with id = " + folderId); + + String selection = Bookmarks.PARENT + " = " + folderId; + String[] selectionArgs = null; + + boolean isRootFolder = (folderId == Bookmarks.FIXED_ROOT_ID); + + // If we're loading the root folder, we have to account for + // any previously created special folder that was created without + // setting a parent id (e.g. mobile folder) and making sure we're + // not adding any infinite recursion as root's parent is root itself. + if (isRootFolder) { + selection = Bookmarks.GUID + " != ?" + " AND (" + + selection + " OR " + Bookmarks.PARENT + " = NULL)"; + selectionArgs = new String[] { Bookmarks.PLACES_FOLDER_GUID }; + } + + List subFolders = new ArrayList(); + List invalidSpecialEntries = new ArrayList(); + + try { + c = db.query(TABLE_BOOKMARKS_TMP, + null, + selection, + selectionArgs, + null, null, null); + + // The key point here is that bookmarks should be added in + // parent order to avoid any problems with the foreign key + // in Bookmarks.PARENT. + while (c.moveToNext()) { + ContentValues values = new ContentValues(); + + // We're using a null projection in the query which + // means we're getting all columns from the table. + // It's safe to simply transform the row into the + // values to be inserted on the new table. + DatabaseUtils.cursorRowToContentValues(c, values); + + boolean isSpecialFolder = isSpecialFolder(values); + + // The mobile folder used to be created with PARENT = NULL. + // We want fix that here. + if (values.getAsLong(Bookmarks.PARENT) == null && isSpecialFolder) + values.put(Bookmarks.PARENT, Bookmarks.FIXED_ROOT_ID); + + if (isRootFolder && !isSpecialFolder) { + invalidSpecialEntries.add(values); + continue; + } + + debug("Migrating bookmark: " + values.getAsString(Bookmarks.TITLE)); + db.insert(TABLE_BOOKMARKS, Bookmarks.URL, values); + + Integer isFolder = values.getAsInteger(Bookmarks.IS_FOLDER); + if (isFolder != null && isFolder == 1) + subFolders.add(values.getAsInteger(Bookmarks._ID)); + } + } finally { + if (c != null) + c.close(); + } + + // At this point is safe to assume that the mobile folder is + // in the new table given that we've always created it on + // database creation time. + final int nInvalidSpecialEntries = invalidSpecialEntries.size(); + if (nInvalidSpecialEntries > 0) { + Long mobileFolderId = guidToID(db, Bookmarks.MOBILE_FOLDER_GUID); + + debug("Found " + nInvalidSpecialEntries + " invalid special folder entries"); + for (int i = 0; i < nInvalidSpecialEntries; i++) { + ContentValues values = invalidSpecialEntries.get(i); + values.put(Bookmarks.PARENT, mobileFolderId); + + db.insert(TABLE_BOOKMARKS, Bookmarks.URL, values); + } + } + + final int nSubFolders = subFolders.size(); + for (int i = 0; i < nSubFolders; i++) { + int subFolderId = subFolders.get(i); + migrateBookmarkFolder(db, subFolderId); + } + } + + private void upgradeDatabaseFrom1to2(SQLiteDatabase db) { + debug("Renaming bookmarks table to " + TABLE_BOOKMARKS_TMP); + db.execSQL("ALTER TABLE " + TABLE_BOOKMARKS + + " RENAME TO " + TABLE_BOOKMARKS_TMP); + + debug("Dropping views and indexes related to " + TABLE_BOOKMARKS); + db.execSQL("DROP VIEW IF EXISTS " + VIEW_BOOKMARKS_WITH_IMAGES); + + db.execSQL("DROP INDEX IF EXISTS bookmarks_url_index"); + db.execSQL("DROP INDEX IF EXISTS bookmarks_guid_index"); + db.execSQL("DROP INDEX IF EXISTS bookmarks_modified_index"); + + createBookmarksTable(db); + createBookmarksWithImagesView(db); + + createOrUpdateSpecialFolder(db, Bookmarks.PLACES_FOLDER_GUID, + R.string.bookmarks_folder_places, 0); + + migrateBookmarkFolder(db, Bookmarks.FIXED_ROOT_ID); + + // Ensure all special folders exist and have the + // right folder hierarchy. + createOrUpdateAllSpecialFolders(db); + + debug("Dropping bookmarks temporary table"); + db.execSQL("DROP TABLE IF EXISTS " + TABLE_BOOKMARKS_TMP); } @Override @@ -353,7 +543,19 @@ debug("Upgrading browser.db: " + db.getPath() + " from " + oldVersion + " to " + newVersion); - // Do nothing for now + db.beginTransaction(); + + // We have to do incremental upgrades until we reach the current + // database schema version. + for (int v = oldVersion + 1; v <= newVersion; v++) { + switch(v) { + case 2: + upgradeDatabaseFrom1to2(db); + break; + } + } + + db.endTransaction(); } @Override @@ -384,6 +586,26 @@ } } + private Long guidToID(SQLiteDatabase db, String guid) { + Cursor c = null; + + try { + c = db.query(TABLE_BOOKMARKS, + new String[] { Bookmarks._ID }, + Bookmarks.GUID + " = ?", + new String[] { guid }, + null, null, null); + + if (c == null || !c.moveToFirst()) + return null; + + return c.getLong(c.getColumnIndex(Bookmarks._ID)); + } finally { + if (c != null) + c.close(); + } + } + private DatabaseHelper getDatabaseHelperForProfile(String profile) { // Each profile has a separate browser.db database. The target // profile is provided using a URI query argument in each request @@ -681,11 +903,17 @@ case BOOKMARKS: { trace("Insert on BOOKMARKS: " + uri); + // Generate values if not specified. Don't overwrite + // if specified by caller. long now = System.currentTimeMillis(); - values.put(Bookmarks.DATE_CREATED, now); - values.put(Bookmarks.DATE_MODIFIED, now); + if (!values.containsKey(Bookmarks.DATE_CREATED)) { + values.put(Bookmarks.DATE_CREATED, now); + } + + if (!values.containsKey(Bookmarks.DATE_MODIFIED)) { + values.put(Bookmarks.DATE_MODIFIED, now); + } - // Generate GUID for new bookmark. Don't override specified GUIDs. if (!values.containsKey(Bookmarks.GUID)) { values.put(Bookmarks.GUID, Utils.generateGuid()); } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mobile/android/base/GeckoApp.java firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mobile/android/base/GeckoApp.java --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mobile/android/base/GeckoApp.java 2012-02-21 02:08:46.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mobile/android/base/GeckoApp.java 2012-02-22 02:08:35.000000000 +0000 @@ -573,6 +573,9 @@ } public void run() { + if (mSoftwareLayerClient == null) + return; + synchronized (mSoftwareLayerClient) { if (!Tabs.getInstance().isSelectedTab(mThumbnailTab)) return; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mobile/android/base/GeckoBatteryManager.java firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mobile/android/base/GeckoBatteryManager.java --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mobile/android/base/GeckoBatteryManager.java 2012-02-21 02:08:46.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mobile/android/base/GeckoBatteryManager.java 2012-02-22 02:08:35.000000000 +0000 @@ -47,6 +47,7 @@ import android.content.Intent; import android.os.BatteryManager; +import android.os.Build; import android.os.SystemClock; public class GeckoBatteryManager @@ -77,7 +78,14 @@ boolean previousCharging = isCharging(); double previousLevel = getLevel(); - if (intent.getBooleanExtra(BatteryManager.EXTRA_PRESENT, false)) { + // NOTE: it might not be common (in 2012) but technically, Android can run + // on a device that has no battery so we want to make sure it's not the case + // before bothering checking for battery state. + // However, the Galaxy Nexus phone advertizes itself as battery-less which + // force us to special-case the logic. + // See the Google bug: https://code.google.com/p/android/issues/detail?id=22035 + if (intent.getBooleanExtra(BatteryManager.EXTRA_PRESENT, false) || + Build.MODEL.equals("Galaxy Nexus")) { int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1); if (plugged == -1) { sCharging = kDefaultCharging; @@ -140,7 +148,7 @@ } else { sLevel = kDefaultLevel; sCharging = kDefaultCharging; - sRemainingTime = kDefaultRemainingTime; + sRemainingTime = 0; } /* diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mobile/android/base/ProfileMigrator.java firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mobile/android/base/ProfileMigrator.java --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mobile/android/base/ProfileMigrator.java 2012-02-21 02:08:46.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mobile/android/base/ProfileMigrator.java 2012-02-22 02:08:36.000000000 +0000 @@ -37,32 +37,45 @@ package org.mozilla.gecko; +import org.mozilla.gecko.db.BrowserContract; +import org.mozilla.gecko.db.BrowserContract.Bookmarks; +import org.mozilla.gecko.db.BrowserContract.History; +import org.mozilla.gecko.db.BrowserContract.ImageColumns; +import org.mozilla.gecko.db.BrowserContract.Images; +import org.mozilla.gecko.db.BrowserContract.URLColumns; +import org.mozilla.gecko.db.BrowserContract.SyncColumns; import org.mozilla.gecko.db.BrowserDB; import org.mozilla.gecko.sqlite.ByteBufferInputStream; import org.mozilla.gecko.sqlite.SQLiteBridge; import org.mozilla.gecko.sqlite.SQLiteBridgeException; import android.content.ContentResolver; +import android.content.ContentUris; +import android.content.ContentValues; import android.database.Cursor; import android.database.SQLException; +import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.provider.Browser; import android.util.Log; +import android.net.Uri; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.File; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; -import java.util.Map; -import java.util.HashMap; import java.util.Date; -import java.util.List; +import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; - +import java.util.List; +import java.util.Map; +import java.util.Set; public class ProfileMigrator { private static final String LOGTAG = "ProfMigr"; @@ -73,40 +86,90 @@ These queries are derived from the low-level Places schema https://developer.mozilla.org/en/The_Places_database */ - private final String bookmarkQuery = "SELECT places.url AS a_url, " - + "places.title AS a_title FROM " - + "(moz_places as places JOIN moz_bookmarks as bookmarks ON " - + "places.id = bookmarks.fk) WHERE places.hidden <> 1 " - + "ORDER BY bookmarks.dateAdded"; + private final String kRootQuery = + "SELECT root_name, folder_id FROM moz_bookmarks_roots"; + private final String kRootName = "root_name"; + private final String kRootFolderId = "folder_id"; + + private final String kBookmarkQuery = + "SELECT places.url AS p_url," + + " bookmark.guid AS b_guid," + + " bookmark.id AS b_id," + + " bookmark.title AS b_title," + + " bookmark.type AS b_type," + + " bookmark.parent AS b_parent," + + " bookmark.dateAdded AS b_added," + + " bookmark.lastModified AS b_modified," + + " bookmark.position AS b_position," + + " favicon.data AS f_data," + + " favicon.mime_type AS f_mime_type," + + " favicon.url AS f_url," + + " favicon.guid AS f_guid " + + "FROM ((moz_bookmarks AS bookmark " + + " LEFT OUTER JOIN moz_places AS places " + + " ON places.id = bookmark.fk) " + + " LEFT OUTER JOIN moz_favicons AS favicon " + + " ON places.favicon_id = favicon.id) " + + // Bookmark folders don't have a places entry. + "WHERE (places.hidden IS NULL " + + " OR places.hidden <> 1) " + + // This gives us a better chance of adding a folder before + // adding its contents and hence avoiding extra iterations below. + "ORDER BY bookmark.id"; + // Result column of relevant data - private final String bookmarkUrl = "a_url"; - private final String bookmarkTitle = "a_title"; + private final String kBookmarkUrl = "p_url"; + private final String kBookmarkTitle = "b_title"; + private final String kBookmarkGuid = "b_guid"; + private final String kBookmarkId = "b_id"; + private final String kBookmarkType = "b_type"; + private final String kBookmarkParent = "b_parent"; + private final String kBookmarkAdded = "b_added"; + private final String kBookmarkModified = "b_modified"; + private final String kBookmarkPosition = "b_position"; + private final String kFaviconData = "f_data"; + private final String kFaviconMime = "f_mime_type"; + private final String kFaviconUrl = "f_url"; + private final String kFaviconGuid = "f_guid"; + + // Helper constants + private static final int kPlacesTypeBookmark = 1; + private static final int kPlacesTypeFolder = 2; /* The sort criterion here corresponds to the one used for the - Awesomebar results. It's an simplification of Frecency. + Awesomebar results. It's a simplification of Frecency. We must divide date by 1000 due to the micro (Places) vs milli (Android) distiction. */ - private final String historyQuery = - "SELECT places.url AS a_url, places.title AS a_title," - + "MAX(history.visit_date) AS a_date, COUNT(*) AS a_visits, " + private final String kHistoryQuery = + "SELECT places.url AS p_url, " + + " places.title AS p_title, " + + " MAX(history.visit_date) AS h_date, " + + " COUNT(*) AS h_visits, " + // see BrowserDB.filterAllSites for this formula - + "MAX(1, (((MAX(history.visit_date)/1000) - ?) / 86400000 + 120)) AS a_recent, " - + "favicon.data AS a_favicon_data, favicon.mime_type AS a_favicon_mime " - + "FROM (moz_historyvisits AS history JOIN moz_places AS places " - + "ON places.id = history.place_id " + " MAX(1, (((MAX(history.visit_date)/1000) - ?) / 86400000 + 120)) AS a_recent, " + + " favicon.data AS f_data, " + + " favicon.mime_type AS f_mime_type, " + + " places.guid AS p_guid, " + + " favicon.url AS f_url, " + + " favicon.guid AS f_guid " + + "FROM (moz_historyvisits AS history " + + " JOIN moz_places AS places " + + " ON places.id = history.place_id " + // Add favicon data if a favicon is present for this URL. - + "LEFT OUTER JOIN moz_favicons AS favicon " - + "ON places.favicon_id = favicon.id) " - + "WHERE places.hidden <> 1 " - + "GROUP BY a_url ORDER BY a_visits * a_recent DESC LIMIT ?"; - private final String historyUrl = "a_url"; - private final String historyTitle = "a_title"; - private final String historyDate = "a_date"; - private final String historyVisits = "a_visits"; - private final String faviconData = "a_favicon_data"; - private final String faviconMime = "a_favicon_mime"; + " LEFT OUTER JOIN moz_favicons AS favicon " + + " ON places.favicon_id = favicon.id) " + + "WHERE places.hidden <> 1 " + + "GROUP BY p_url " + + "ORDER BY h_visits * a_recent " + + "DESC LIMIT ?"; + + private final String kHistoryUrl = "p_url"; + private final String kHistoryTitle = "p_title"; + private final String kHistoryGuid = "p_guid"; + private final String kHistoryDate = "h_date"; + private final String kHistoryVisits = "h_visits"; public ProfileMigrator(ContentResolver cr, File profileDir) { mProfileDir = profileDir; @@ -114,10 +177,66 @@ } public void launch() { - new PlacesTask().run(); + new PlacesRunnable().run(); } - private class PlacesTask implements Runnable { + private class PlacesRunnable implements Runnable { + private Map mRerootMap; + + protected Uri getBookmarksUri() { + return Bookmarks.CONTENT_URI; + } + + protected Uri getHistoryUri() { + return History.CONTENT_URI; + } + + protected Uri getImagesUri() { + return Images.CONTENT_URI; + } + + private long getFolderId(String guid) { + Cursor c = null; + + try { + c = mCr.query(getBookmarksUri(), + new String[] { Bookmarks._ID }, + Bookmarks.GUID + " = ?", + new String [] { guid }, + null); + if (c.moveToFirst()) + return c.getLong(c.getColumnIndexOrThrow(Bookmarks._ID)); + } finally { + if (c != null) + c.close(); + } + // Default fallback + return Bookmarks.FIXED_ROOT_ID; + } + + // We want to know the id of special root folders in the places DB, + // and replace them by the corresponding root id in the Android DB. + protected void calculateReroot(SQLiteBridge db) { + mRerootMap = new HashMap(); + + try { + ArrayList queryResult = db.query(kRootQuery); + final int rootCol = db.getColumnIndex(kRootName); + final int folderCol = db.getColumnIndex(kRootFolderId); + + for (Object[] resultRow: queryResult) { + String name = (String)resultRow[rootCol]; + long placesFolderId = Integer.parseInt((String)resultRow[folderCol]); + mRerootMap.put(placesFolderId, getFolderId(name)); + Log.v(LOGTAG, "Name: " + name + ", pid=" + placesFolderId + + ", nid=" + mRerootMap.get(placesFolderId)); + } + } catch (SQLiteBridgeException e) { + Log.e(LOGTAG, "Failed to get bookmark roots: ", e); + return; + } + } + // Get a list of the last times an URL was accessed protected Map gatherBrowserDBHistory() { Map history = new HashMap(); @@ -163,9 +282,119 @@ } if (allowUpdate) { - BrowserDB.updateVisitedHistory(mCr, url); - // The above records one visit. Subtract that one visit here. - BrowserDB.updateHistoryEntry(mCr, url, title, date, visits - 1); + updateBrowserHistory(url, title, date, visits); + } + } + + protected void updateBrowserHistory(String url, String title, + long date, int visits) { + Cursor cursor = null; + + try { + final String[] projection = new String[] { + History._ID, + History.VISITS + }; + + cursor = mCr.query(getHistoryUri(), + projection, + History.URL + " = ?", + new String[] { url }, + null); + + ContentValues values = new ContentValues(); + values.put(History.DATE_LAST_VISITED, date); + + if (cursor.moveToFirst()) { + int visitsCol = cursor.getColumnIndexOrThrow(History.VISITS); + int oldVisits = cursor.getInt(visitsCol); + + values.put(History.VISITS, oldVisits + visits); + if (title != null) { + values.put(History.TITLE, title); + } + + int idCol = cursor.getColumnIndexOrThrow(History._ID); + // We use default profile anyway + Uri historyUri = ContentUris.withAppendedId(getHistoryUri(), + cursor.getLong(idCol)); + + mCr.update(historyUri, values, null, null); + } else { + values.put(History.URL, url); + values.put(History.VISITS, visits); + if (title != null) { + values.put(History.TITLE, title); + } else { + values.put(History.TITLE, url); + } + + mCr.insert(getHistoryUri(), values); + } + } finally { + if (cursor != null) + cursor.close(); + } + } + + protected BitmapDrawable decodeImageData(ByteBuffer data) { + ByteBufferInputStream byteStream = new ByteBufferInputStream(data); + BitmapDrawable image = + (BitmapDrawable)Drawable.createFromStream(byteStream, "src"); + return image; + } + + protected void addFavicon(String url, String faviconUrl, String faviconGuid, + String mime, ByteBuffer data) { + // Some GIFs can cause us to lock up completely + // without exceptions or anything. Not cool. + if (mime == null || mime.compareTo("image/gif") == 0) { + return; + } + BitmapDrawable image = null; + // Decode non-PNG images. + if (mime.compareTo("image/png") != 0) { + image = decodeImageData(data); + // Can't decode, give up. + if (image == null) { + Log.i(LOGTAG, "Cannot decode image type " + mime + + " for URL=" + url); + } + } + try { + ContentValues values = new ContentValues(); + + // Recompress decoded images to PNG. + if (image != null) { + Bitmap bitmap = image.getBitmap(); + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); + values.put(Images.FAVICON, stream.toByteArray()); + } else { + // PNG images can be passed directly. Well, aside + // from having to convert them into a byte[]. + byte[] byteArray = new byte[data.remaining()]; + data.get(byteArray); + values.put(Images.FAVICON, byteArray); + } + + values.put(Images.URL, url); + values.put(Images.FAVICON_URL, faviconUrl); + // Restore deleted record if possible + values.put(Images.IS_DELETED, 0); + values.put(Images.GUID, faviconGuid); + + int updated = mCr.update(getImagesUri(), + values, + Images.URL + " = ?", + new String[] { url }); + + if (updated == 0) { + mCr.insert(getImagesUri(), values); + } + } catch (SQLException e) { + Log.i(LOGTAG, "Migrating favicon failed: " + mime + " URL: " + url + + " error:" + e.getMessage()); } } @@ -184,35 +413,37 @@ Integer.toString(BrowserDB.getMaxHistoryCount()) }; ArrayList queryResult = - db.query(historyQuery, queryParams); - final int urlCol = db.getColumnIndex(historyUrl); - final int titleCol = db.getColumnIndex(historyTitle); - final int dateCol = db.getColumnIndex(historyDate); - final int visitsCol = db.getColumnIndex(historyVisits); - final int faviconMimeCol = db.getColumnIndex(faviconMime); - final int faviconDataCol = db.getColumnIndex(faviconData); + db.query(kHistoryQuery, queryParams); + final int urlCol = db.getColumnIndex(kHistoryUrl); + final int titleCol = db.getColumnIndex(kHistoryTitle); + final int dateCol = db.getColumnIndex(kHistoryDate); + final int visitsCol = db.getColumnIndex(kHistoryVisits); + final int faviconMimeCol = db.getColumnIndex(kFaviconMime); + final int faviconDataCol = db.getColumnIndex(kFaviconData); + final int faviconUrlCol = db.getColumnIndex(kFaviconUrl); + final int faviconGuidCol = db.getColumnIndex(kFaviconGuid); for (Object[] resultRow: queryResult) { String url = (String)resultRow[urlCol]; String title = (String)resultRow[titleCol]; long date = Long.parseLong((String)(resultRow[dateCol])) / (long)1000; int visits = Integer.parseInt((String)(resultRow[visitsCol])); - addHistory(browserDBHistory, url, title, date, visits); - placesHistory.add(url); - - String mime = (String)resultRow[faviconMimeCol]; - if (mime != null) { - // Some GIFs can cause us to lock up completely - // without exceptions or anything. Not cool. - if (mime.compareTo("image/gif") != 0) { - ByteBuffer dataBuff = - (ByteBuffer)resultRow[faviconDataCol]; - addFavicon(url, mime, dataBuff); - } + ByteBuffer faviconDataBuff = (ByteBuffer)resultRow[faviconDataCol]; + String faviconMime = (String)resultRow[faviconMimeCol]; + String faviconUrl = (String)resultRow[faviconUrlCol]; + String faviconGuid = (String)resultRow[faviconGuidCol]; + + try { + placesHistory.add(url); + addFavicon(url, faviconUrl, faviconGuid, + faviconMime, faviconDataBuff); + addHistory(browserDBHistory, url, title, date, visits); + } catch (Exception e) { + Log.e(LOGTAG, "Error adding history entry: ", e); } } } catch (SQLiteBridgeException e) { - Log.i(LOGTAG, "Failed to get bookmarks: " + e.getMessage()); + Log.e(LOGTAG, "Failed to get history: ", e); return; } // GlobalHistory access communicates with Gecko @@ -226,45 +457,161 @@ }); } - protected void addBookmark(String url, String title) { - if (!BrowserDB.isBookmark(mCr, url)) { - if (title == null) { - title = url; - } - BrowserDB.addBookmark(mCr, title, url); + protected void addBookmark(String url, String title, String guid, + long parent, long added, + long modified, long position, + boolean folder) { + ContentValues values = new ContentValues(); + if (title == null && url != null) { + title = url; + } + if (title != null) { + values.put(Bookmarks.TITLE, title); + } + if (url != null) { + values.put(Bookmarks.URL, url); + } + if (guid != null) { + values.put(SyncColumns.GUID, guid); + } + values.put(SyncColumns.DATE_CREATED, added); + values.put(SyncColumns.DATE_MODIFIED, modified); + values.put(Bookmarks.POSITION, position); + // Restore deleted record if possible + values.put(Bookmarks.IS_DELETED, 0); + if (mRerootMap.containsKey(parent)) { + parent = mRerootMap.get(parent); + } + values.put(Bookmarks.PARENT, parent); + values.put(Bookmarks.IS_FOLDER, (folder ? 1 : 0)); + + int updated = 0; + if (url != null) { + updated = mCr.update(getBookmarksUri(), + values, + Bookmarks.URL + " = ?", + new String[] { url }); + } + if (updated == 0) { + mCr.insert(getBookmarksUri(), values); } } protected void migrateBookmarks(SQLiteBridge db) { try { - ArrayList queryResult = db.query(bookmarkQuery); - final int urlCol = db.getColumnIndex(bookmarkUrl); - final int titleCol = db.getColumnIndex(bookmarkTitle); + ArrayList queryResult = db.query(kBookmarkQuery); + final int urlCol = db.getColumnIndex(kBookmarkUrl); + final int titleCol = db.getColumnIndex(kBookmarkTitle); + final int guidCol = db.getColumnIndex(kBookmarkGuid); + final int idCol = db.getColumnIndex(kBookmarkId); + final int typeCol = db.getColumnIndex(kBookmarkType); + final int parentCol = db.getColumnIndex(kBookmarkParent); + final int addedCol = db.getColumnIndex(kBookmarkAdded); + final int modifiedCol = db.getColumnIndex(kBookmarkModified); + final int positionCol = db.getColumnIndex(kBookmarkPosition); + final int faviconMimeCol = db.getColumnIndex(kFaviconMime); + final int faviconDataCol = db.getColumnIndex(kFaviconData); + final int faviconUrlCol = db.getColumnIndex(kFaviconUrl); + final int faviconGuidCol = db.getColumnIndex(kFaviconGuid); + + // The keys are places IDs. + Set openFolders = new HashSet(); + Set knownFolders = new HashSet(mRerootMap.keySet()); + + // We iterate over all bookmarks, and add all bookmarks that + // have their parent folders present. If there are bookmarks + // that we can't add, we remember what these are and try again + // on the next iteration. The number of iterations scales + // according to the depth of the folders. + Set processedBookmarks = new HashSet(); + int iterations = 0; + do { + // Reset the set of missing folders that block us from + // adding entries. + openFolders.clear(); + + int added = 0; + int skipped = 0; + + for (Object[] resultRow: queryResult) { + long id = Long.parseLong((String)resultRow[idCol]); + + // Already processed? if so just skip + if (processedBookmarks.contains(id)) + continue; + + int type = Integer.parseInt((String)resultRow[typeCol]); + long parent = Long.parseLong((String)resultRow[parentCol]); + + // Places has an explicit root folder, id=1 parent=0. + // Skip that. + if (id == 1 && parent == 0 && type == kPlacesTypeFolder) + continue; + + String url = (String)resultRow[urlCol]; + String title = (String)resultRow[titleCol]; + String guid = (String)resultRow[guidCol]; + long dateadded = + Long.parseLong((String)resultRow[addedCol]) / (long)1000; + long datemodified = + Long.parseLong((String)resultRow[modifiedCol]) / (long)1000; + long position = Long.parseLong((String)resultRow[positionCol]); + ByteBuffer faviconDataBuff = (ByteBuffer)resultRow[faviconDataCol]; + String faviconMime = (String)resultRow[faviconMimeCol]; + String faviconUrl = (String)resultRow[faviconUrlCol]; + String faviconGuid = (String)resultRow[faviconGuidCol]; + + // Is the parent for this bookmark already added? + // If so, we can add the bookmark itself. + if (knownFolders.contains(parent)) { + try { + boolean isFolder = (type == kPlacesTypeFolder); + addBookmark(url, title, guid, parent, + dateadded, datemodified, + position, isFolder); + addFavicon(url, faviconUrl, faviconGuid, + faviconMime, faviconDataBuff); + if (isFolder) { + long newFolderId = getFolderId(guid); + // Remap the folder IDs for parents. + mRerootMap.put(id, newFolderId); + knownFolders.add(id); + Log.d(LOGTAG, "Added folder: " + id); + } + processedBookmarks.add(id); + } catch (Exception e) { + Log.e(LOGTAG, "Error adding bookmark: ", e); + } + added++; + } else { + // We have to postpone until parent is processed; + openFolders.add(parent); + skipped++; + } + } - for (Object[] resultRow: queryResult) { - String url = (String)resultRow[urlCol]; - String title = (String)resultRow[titleCol]; - addBookmark(url, title); - } + // Now check if any of the new folders we added was a folder + // that we were blocked on, by intersecting openFolders and + // knownFolders. If this is empty, we're done because the next + // iteration can't make progress. + boolean changed = openFolders.retainAll(knownFolders); + + // If there are no folders that we can add next iteration, + // but there were still folders before the intersection, + // those folders are orphans. Report this situation here. + if (openFolders.isEmpty() && changed) { + Log.w(LOGTAG, "Orphaned bookmarks found, not imported"); + } + iterations++; + Log.i(LOGTAG, "Iteration = " + iterations + ", added " + added + + " bookmark(s), skipped " + skipped + " bookmark(s)"); + } while (!openFolders.isEmpty()); } catch (SQLiteBridgeException e) { - Log.i(LOGTAG, "Failed to get bookmarks: " + e.getMessage()); + Log.e(LOGTAG, "Failed to get bookmarks: ", e); return; } } - protected void addFavicon(String url, String mime, ByteBuffer data) { - ByteBufferInputStream byteStream = new ByteBufferInputStream(data); - BitmapDrawable image = (BitmapDrawable) Drawable.createFromStream(byteStream, "src"); - if (image != null) { - try { - BrowserDB.updateFaviconForUrl(mCr, url, image); - } catch (SQLException e) { - Log.i(LOGTAG, "Migrating favicon failed: " + mime + " URL: " + url - + " error:" + e.getMessage()); - } - } - } - protected void migratePlaces(File aFile) { String dbPath = aFile.getPath() + "/places.sqlite"; String dbPathWal = aFile.getPath() + "/places.sqlite-wal"; @@ -283,6 +630,7 @@ GeckoAppShell.ensureSQLiteLibsLoaded(GeckoApp.mAppContext.getApplication().getPackageResourcePath()); try { db = new SQLiteBridge(dbPath); + calculateReroot(db); migrateBookmarks(db); migrateHistory(db); db.close(); @@ -297,7 +645,7 @@ if (db != null) { db.close(); } - Log.i(LOGTAG, "Error on places database:" + e.getMessage()); + Log.e(LOGTAG, "Error on places database:", e); return; } } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mobile/android/chrome/content/browser.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mobile/android/chrome/content/browser.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mobile/android/chrome/content/browser.js 2012-02-21 02:08:57.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mobile/android/chrome/content/browser.js 2012-02-22 02:08:45.000000000 +0000 @@ -2087,7 +2087,7 @@ let minScale = this.getPageZoomLevel(screenW); viewportH = Math.max(viewportH, screenH / minScale); - let oldBrowserWidth = parseInt(this.browser.style.width); + let oldBrowserWidth = parseInt(this.browser.style.minWidth); this.setBrowserSize(viewportW, viewportH); // Avoid having the scroll position jump around after device rotation. @@ -2111,7 +2111,7 @@ if ("defaultZoom" in md && md.defaultZoom) return md.defaultZoom; - let browserWidth = parseInt(this.browser.style.width); + let browserWidth = parseInt(this.browser.style.minWidth); return gScreenWidth / browserWidth; }, @@ -2125,8 +2125,10 @@ }, setBrowserSize: function(aWidth, aHeight) { - this.browser.style.width = aWidth + "px"; - this.browser.style.height = aHeight + "px"; + // Using min width/height so as not to conflict with the fullscreen style rule. + // See Bug #709813. + this.browser.style.minWidth = aWidth + "px"; + this.browser.style.minHeight = aHeight + "px"; }, getRequestLoadContext: function(aRequest) { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mobile/xul/installer/package-manifest.in firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mobile/xul/installer/package-manifest.in --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mobile/xul/installer/package-manifest.in 2012-02-21 02:09:03.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mobile/xul/installer/package-manifest.in 2012-02-22 02:08:50.000000000 +0000 @@ -157,6 +157,9 @@ @BINPATH@/components/dom_system_b2g.xpt #endif @BINPATH@/components/dom_battery.xpt +#ifdef MOZ_B2G_BT +@BINPATH@/components/dom_bluetooth.xpt +#endif @BINPATH@/components/dom_canvas.xpt @BINPATH@/components/dom_core.xpt @BINPATH@/components/dom_css.xpt diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mozglue/linker/CustomElf.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mozglue/linker/CustomElf.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/mozglue/linker/CustomElf.cpp 2012-02-21 02:09:14.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/mozglue/linker/CustomElf.cpp 2012-02-22 02:09:06.000000000 +0000 @@ -628,7 +628,8 @@ symptr = GetSymbolPtrInDeps(strtab.GetStringAt(sym.st_name)); if (symptr == NULL) { - log("%s: Error: relocation to NULL @0x%08" PRIxAddr, GetPath(), rel->r_offset); + log("%s: Error: relocation to NULL @0x%08" PRIxAddr " for symbol \"%s\"", + GetPath(), rel->r_offset, strtab.GetStringAt(sym.st_name)); return false; } /* Apply relocation */ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/netwerk/protocol/http/nsHttpHandler.cpp firefox-trunk-13.0~a1~hg20120222r87313/mozilla/netwerk/protocol/http/nsHttpHandler.cpp --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/netwerk/protocol/http/nsHttpHandler.cpp 2012-02-21 02:09:16.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/netwerk/protocol/http/nsHttpHandler.cpp 2012-02-22 02:09:09.000000000 +0000 @@ -270,7 +270,7 @@ PrefsChanged(prefBranch, nsnull); } - mMisc.AssignLiteral("rv:" MOZILLA_VERSION); + mMisc.AssignLiteral("rv:" MOZILLA_UAVERSION); nsCOMPtr appInfo = do_GetService("@mozilla.org/xre/app-info;1"); @@ -308,7 +308,7 @@ if (NS_FAILED(rv)) return rv; #ifdef ANDROID - mProductSub.AssignLiteral(MOZ_APP_UA_VERSION); + mProductSub.AssignLiteral(MOZILLA_UAVERSION); #else mProductSub.AssignLiteral(MOZ_UA_BUILDID); #endif diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/modules/engines/addons.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/modules/engines/addons.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/modules/engines/addons.js 2012-02-21 02:10:03.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/modules/engines/addons.js 2012-02-22 02:09:48.000000000 +0000 @@ -317,12 +317,12 @@ * Provides core Store API to create/install an add-on from a record. */ create: function create(record) { - // Ideally, we'd set syncGUID and userDisabled on install. For now, we - // make the changes post-installation. - // TODO Set syncGUID and userDisabled in one step, during install. - let cb = Async.makeSpinningCallback(); - this.installAddonsFromIDs([record.addonID], cb); + this.installAddons([{ + id: record.addonID, + syncGUID: record.id, + enabled: record.enabled + }], cb); // This will throw if there was an error. This will get caught by the sync // engine and the record will try to be applied later. @@ -342,12 +342,6 @@ } this._log.info("Add-on installed: " + record.addonID); - this._log.info("Setting add-on Sync GUID to remote: " + record.id); - addon.syncGUID = record.id; - - cb = Async.makeSpinningCallback(); - this.updateUserDisabled(addon, !record.enabled, cb); - cb.wait(); }, /** @@ -682,6 +676,13 @@ /** * Installs an add-on from an AddonSearchResult instance. * + * The options argument defines extra options to control the install. + * Recognized keys in this map are: + * + * syncGUID - Sync GUID to use for the new add-on. + * enabled - Boolean indicating whether the add-on should be enabled upon + * install. + * * When complete it calls a callback with 2 arguments, error and result. * * If error is falsy, result is an object. If error is truthy, result is @@ -695,11 +696,13 @@ * * @param addon * AddonSearchResult to install add-on from. + * @param options + * Object with additional metadata describing how to install add-on. * @param cb * Function to be invoked with result of operation. */ installAddonFromSearchResult: - function installAddonFromSearchResult(addon, cb) { + function installAddonFromSearchResult(addon, options, cb) { this._log.info("Trying to install add-on from search result: " + addon.id); this.getInstallFromSearchResult(addon, function(error, install) { @@ -715,8 +718,28 @@ try { this._log.info("Installing " + addon.id); + let log = this._log; let listener = { + onInstallStarted: function(install) { + if (!options) { + return; + } + + if (options.syncGUID) { + log.info("Setting syncGUID of " + install.name +": " + + options.syncGUID); + install.addon.syncGUID = options.syncGUID; + } + + // We only need to change userDisabled if it is disabled because + // enabled is the default. + if ("enabled" in options && !options.enabled) { + log.info("Marking add-on as disabled for install: " + + install.name); + install.addon.userDisabled = true; + } + }, onInstallEnded: function(install, addon) { install.removeListener(listener); @@ -892,7 +915,14 @@ }, /** - * Installs multiple add-ons specified by their IDs. + * Installs multiple add-ons specified by metadata. + * + * The first argument is an array of objects. Each object must have the + * following keys: + * + * id - public ID of the add-on to install. + * syncGUID - syncGUID for new add-on. + * enabled - boolean indicating whether the add-on should be enabled. * * The callback will be called when activity on all add-ons is complete. The * callback receives 2 arguments, error and result. @@ -908,16 +938,21 @@ * errors Array of errors encountered. Only has elements if error is * truthy. * - * @param ids - * Array of add-on string IDs to install. + * @param installs + * Array of objects describing add-ons to install. * @param cb * Function to be called when all actions are complete. */ - installAddonsFromIDs: function installAddonsFromIDs(ids, cb) { + installAddons: function installAddons(installs, cb) { if (!cb) { throw new Error("Invalid argument: cb is not defined."); } + let ids = []; + for each (let addon in installs) { + ids.push(addon.id); + } + AddonRepository.getAddonsByIDs(ids, { searchSucceeded: function searchSucceeded(addons, addonsLength, total) { this._log.info("Found " + addonsLength + "/" + ids.length + @@ -1009,7 +1044,15 @@ // Start all the installs asynchronously. They will report back to us // as they finish, eventually triggering the global callback. for each (let addon in toInstall) { - this.installAddonFromSearchResult(addon, installCallback); + let options = {}; + for each (let install in installs) { + if (install.id == addon.id) { + options = install; + break; + } + } + + this.installAddonFromSearchResult(addon, options, installCallback); } }.bind(this), diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/tps/test_addon_nonrestartless_xpi.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/tps/test_addon_nonrestartless_xpi.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/tps/test_addon_nonrestartless_xpi.js 2012-02-21 02:10:05.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/tps/test_addon_nonrestartless_xpi.js 2012-02-22 02:09:48.000000000 +0000 @@ -45,7 +45,7 @@ // Now we disable the add-on Phase("phase05", [ - [Sync], + [EnsureTracking], [Addons.setEnabled, [id], STATE_DISABLED], [Sync] ]); @@ -62,6 +62,7 @@ // Now we re-enable it again. Phase("phase09", [ + [EnsureTracking], [Addons.setEnabled, [id], STATE_ENABLED], [Sync] ]); @@ -77,7 +78,9 @@ ]); // And we uninstall it + Phase("phase13", [ + [EnsureTracking], [Addons.verify, [id], STATE_ENABLED], [Addons.uninstall, [id]], [Sync] diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/tps/test_addon_restartless_xpi.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/tps/test_addon_restartless_xpi.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/tps/test_addon_restartless_xpi.js 2012-02-21 02:10:05.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/tps/test_addon_restartless_xpi.js 2012-02-22 02:09:49.000000000 +0000 @@ -33,6 +33,7 @@ // Now disable and see that is is synced. Phase("phase03", [ + [EnsureTracking], [Addons.setEnabled, [id], STATE_DISABLED], [Addons.verify, [id], STATE_DISABLED], [Sync] @@ -44,6 +45,7 @@ // Enable and see it is synced. Phase("phase05", [ + [EnsureTracking], [Addons.setEnabled, [id], STATE_ENABLED], [Addons.verify, [id], STATE_ENABLED], [Sync] @@ -55,6 +57,7 @@ // Uninstall and see it is synced. Phase("phase07", [ + [EnsureTracking], [Addons.verify, [id], STATE_ENABLED], [Addons.uninstall, [id]], [Addons.verifyNot, [id]], diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/addon1-search.xml firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/addon1-search.xml --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/addon1-search.xml 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/addon1-search.xml 2012-02-22 02:09:51.000000000 +0000 @@ -0,0 +1,27 @@ + + + + Non-Restartless Test Extension + Extension + addon1@tests.mozilla.org + addon11 + 1.0 + + + Firefox + 1 + 3.6 + * + xpcshell@tests.mozilla.org + + ALL + + http://127.0.0.1:8888/addon1.xpi + + 2009-09-14T04:47:42Z + + + 2011-09-05T20:42:09Z + + + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_addons_engine.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_addons_engine.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_addons_engine.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_addons_engine.js 2012-02-22 02:09:52.000000000 +0000 @@ -8,6 +8,12 @@ Cu.import("resource://services-sync/addonsreconciler.js"); Cu.import("resource://services-sync/async.js"); Cu.import("resource://services-sync/engines/addons.js"); +Cu.import("resource://services-sync/ext/Preferences.js"); +Cu.import("resource://services-sync/service.js"); + +let prefs = new Preferences(); +prefs.set("extensions.getAddons.get.url", + "http://localhost:8888/search/guid:%IDS%"); loadAddonTestFunctions(); startupManager(); @@ -134,12 +140,109 @@ advance_test(); }); +add_test(function test_disabled_install_semantics() { + _("Ensure that syncing a disabled add-on preserves proper state."); + + // This is essentially a test for bug 712542, which snuck into the original + // add-on sync drop. It ensures that when an add-on is installed that the + // disabled state and incoming syncGUID is preserved, even on the next sync. + + Svc.Prefs.set("addons.ignoreRepositoryChecking", true); + + const USER = "foo"; + const PASSWORD = "password"; + const PASSPHRASE = "abcdeabcdeabcdeabcdeabcdea"; + const ADDON_ID = "addon1@tests.mozilla.org"; + + Service.username = USER; + Service.password = PASSWORD; + Service.passphrase = PASSPHRASE; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; + + generateNewKeys(); + + let contents = { + meta: {global: {engines: {addons: {version: engine.version, + syncID: engine.syncID}}}}, + crypto: {}, + addons: {} + }; + + let server = new SyncServer(); + server.registerUser(USER, "password"); + server.createContents(USER, contents); + server.start(); + + let amoServer = new nsHttpServer(); + amoServer.registerFile("/search/guid:addon1%40tests.mozilla.org", + do_get_file("addon1-search.xml")); + + let installXPI = ExtensionsTestPath("/addons/test_install1.xpi"); + amoServer.registerFile("/addon1.xpi", do_get_file(installXPI)); + amoServer.start(8888); + + // Insert an existing record into the server. + let id = Utils.makeGUID(); + let now = Date.now() / 1000; + + let record = encryptPayload({ + id: id, + applicationID: Services.appinfo.ID, + addonID: ADDON_ID, + enabled: false, + deleted: false, + source: "amo", + }); + let wbo = new ServerWBO(id, record, now - 2); + server.insertWBO(USER, "addons", wbo); + + _("Performing sync of add-ons engine."); + engine._sync(); + + // At this point the non-restartless extension should be staged for install. + + // Don't need this server any more. + let cb = Async.makeSpinningCallback(); + amoServer.stop(cb); + cb.wait(); + + // We ensure the reconciler has recorded the proper ID and enabled state. + let addon = reconciler.getAddonStateFromSyncGUID(id); + do_check_neq(null, addon); + do_check_eq(false, addon.enabled); + + // We fake an app restart and perform another sync, just to make sure things + // are sane. + restartManager(); + + engine._sync(); + + // The client should not upload a new record. The old record should be + // retained and unmodified. + let collection = server.getCollection(USER, "addons"); + do_check_eq(1, collection.count()); + + let payload = collection.payloads()[0]; + do_check_neq(null, collection.wbo(id)); + do_check_eq(ADDON_ID, payload.addonID); + do_check_false(payload.enabled); + + server.stop(advance_test); +}); + function run_test() { initTestLogging("Trace"); - Log4Moz.repository.getLogger("Sync.Engine.Addons").level = Log4Moz.Level.Trace; + Log4Moz.repository.getLogger("Sync.Engine.Addons").level = + Log4Moz.Level.Trace; + Log4Moz.repository.getLogger("Sync.Store.Addons").level = Log4Moz.Level.Trace; + Log4Moz.repository.getLogger("Sync.Tracker.Addons").level = + Log4Moz.Level.Trace; Log4Moz.repository.getLogger("Sync.AddonsRepository").level = Log4Moz.Level.Trace; + new SyncTestingInfrastructure(); + reconciler.startListening(); advance_test(); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_addons_store.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_addons_store.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_addons_store.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_addons_store.js 2012-02-22 02:09:52.000000000 +0000 @@ -454,7 +454,7 @@ let installCalled = false; store.__proto__.installAddonFromSearchResult = - function testInstallAddon(addon, cb) { + function testInstallAddon(addon, metadata, cb) { do_check_eq("http://127.0.0.1:8888/require.xpi?src=sync", addon.sourceURI.spec); @@ -472,7 +472,7 @@ let server = createAndStartHTTPServer(HTTP_PORT); let installCallback = Async.makeSpinningCallback(); - store.installAddonsFromIDs(["rewrite@tests.mozilla.org"], installCallback); + store.installAddons([{id: "rewrite@tests.mozilla.org"}], installCallback); installCallback.wait(); do_check_true(installCalled); @@ -492,7 +492,7 @@ const ID = "missing-sourceuri@tests.mozilla.org"; let cb = Async.makeSpinningCallback(); - store.installAddonsFromIDs([ID], cb); + store.installAddons([{id: ID}], cb); let result = cb.wait(); do_check_true("installedIDs" in result); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_bookmark_engine.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_bookmark_engine.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_bookmark_engine.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_bookmark_engine.js 2012-02-22 02:09:52.000000000 +0000 @@ -93,7 +93,8 @@ add_test(function test_processIncoming_error_orderChildren() { _("Ensure that _orderChildren() is called even when _processIncoming() throws an error."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); let engine = new BookmarksEngine(); @@ -166,8 +167,8 @@ _("Ensure that restoring from a backup will reupload all records."); let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("username", "foo"); - Service.serverURL = "http://localhost:8080/"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; let engine = new BookmarksEngine(); let store = engine._store; @@ -334,8 +335,8 @@ let syncTesting = new SyncTestingInfrastructure(); Svc.Prefs.set("username", "foo"); - Service.serverURL = "http://localhost:8080/"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; let engine = new BookmarksEngine(); let store = engine._store; @@ -377,7 +378,8 @@ _("Ensure that failures building the GUID map cause early death."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); let engine = new BookmarksEngine(); let store = engine._store; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_bookmark_smart_bookmarks.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_bookmark_smart_bookmarks.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_bookmark_smart_bookmarks.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_bookmark_smart_bookmarks.js 2012-02-22 02:09:52.000000000 +0000 @@ -107,8 +107,8 @@ _("Sync record to the server."); Svc.Prefs.set("username", "foo"); - Service.serverURL = "http://localhost:8080/"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; let server = serverForFoo(engine); let collection = server.user("foo").collection("bookmarks"); @@ -193,8 +193,8 @@ _("Prepare sync."); Svc.Prefs.set("username", "foo"); - Service.serverURL = "http://localhost:8080/"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; let server = serverForFoo(engine); let collection = server.user("foo").collection("bookmarks"); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_clients_engine.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_clients_engine.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_clients_engine.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_clients_engine.js 2012-02-22 02:09:52.000000000 +0000 @@ -54,8 +54,8 @@ try { let passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.serverURL = "http://localhost:8080/"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; Service.login("foo", "ilovejane", passphrase); generateNewKeys(); @@ -164,7 +164,9 @@ add_test(function test_sync() { _("Ensure that Clients engine uploads a new client record once a week."); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); generateNewKeys(); @@ -402,7 +404,9 @@ add_test(function test_command_sync() { _("Ensure that commands are synced across clients."); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); Clients._store.wipe(); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_collections_recovery.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_collections_recovery.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_collections_recovery.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_collections_recovery.js 2012-02-22 02:09:52.000000000 +0000 @@ -19,8 +19,8 @@ }; } - Service.serverURL = "http://localhost:8080/"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; Service.username = "johndoe"; Service.password = "ilovejane"; Service.passphrase = "a-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa"; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_corrupt_keys.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_corrupt_keys.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_corrupt_keys.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_corrupt_keys.js 2012-02-22 02:09:52.000000000 +0000 @@ -55,8 +55,8 @@ Weave.Service.password = "ilovejane"; Weave.Service.passphrase = passphrase; - Weave.Service.serverURL = "http://localhost:8080/"; - Weave.Service.clusterURL = "http://localhost:8080/"; + Weave.Service.serverURL = TEST_SERVER_URL; + Weave.Service.clusterURL = TEST_CLUSTER_URL; Engines.register(HistoryEngine); Weave.Service._registerEngines(); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_engine_abort.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_engine_abort.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_engine_abort.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_engine_abort.js 2012-02-22 02:09:52.000000000 +0000 @@ -4,7 +4,8 @@ add_test(function test_processIncoming_abort() { _("An abort exception, raised in applyIncoming, will abort _processIncoming."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); generateNewKeys(); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_errorhandler.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_errorhandler.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_errorhandler.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_errorhandler.js 2012-02-22 02:09:52.000000000 +0000 @@ -9,6 +9,7 @@ Svc.DefaultPrefs.set("registerEngines", ""); Cu.import("resource://services-sync/service.js"); +const TEST_MAINTENANCE_URL = "http://localhost:8080/maintenance/"; const logsdir = FileUtils.getDir("ProfD", ["weave", "logs"], true); const LOG_PREFIX_SUCCESS = "success-"; const LOG_PREFIX_ERROR = "error-"; @@ -120,8 +121,10 @@ Service.username = "johndoe"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.serverURL = "http://localhost:8080/"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; + + return generateAndUploadKeys(); } @@ -219,7 +222,8 @@ // Give ourselves a clusterURL so that the temporary 401 no-error situation // doesn't come into play. - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; // Test dontIgnoreErrors, non-network, non-prolonged, login error reported Status.resetSync(); @@ -510,7 +514,8 @@ Service.username = "johndoe"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; Svc.Obs.add("weave:ui:login:error", function onSyncError() { Svc.Obs.remove("weave:ui:login:error", onSyncError); @@ -548,7 +553,8 @@ Service.username = "johndoe"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; Svc.Obs.add("weave:ui:login:error", function onSyncError() { Svc.Obs.remove("weave:ui:login:error", onSyncError); @@ -627,7 +633,8 @@ Service.username = "johndoe"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; Svc.Obs.add("weave:ui:login:error", function onSyncError() { Svc.Obs.remove("weave:ui:login:error", onSyncError); @@ -704,7 +711,8 @@ Service.username = "johndoe"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; // Test network errors are not reported. Svc.Obs.add("weave:ui:clear-error", function onClearError() { @@ -777,7 +785,8 @@ setUp(); Service.username = "broken.info"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; let backoffInterval; Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) { @@ -816,7 +825,8 @@ setUp(); Service.username = "broken.meta"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; let backoffInterval; Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) { @@ -855,7 +865,8 @@ setUp(); Service.username = "broken.keys"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; // Force re-download of keys CollectionKeys.clear(); @@ -922,7 +933,8 @@ setUp(); Service.username = "broken.info"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; let backoffInterval; Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) { @@ -954,7 +966,8 @@ setUp(); Service.username = "broken.meta"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; let backoffInterval; Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) { @@ -986,7 +999,8 @@ setUp(); Service.username = "broken.keys"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; // Force re-download of keys CollectionKeys.clear(); @@ -1022,7 +1036,8 @@ Service.username = "broken.keys"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; let backoffInterval; Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) { @@ -1057,7 +1072,8 @@ Service.username = "broken.wipe"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; let backoffInterval; Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) { @@ -1091,7 +1107,8 @@ Service.username = "broken.wipe"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; generateAndUploadKeys(); let engine = Engines.get("catapult"); @@ -1158,7 +1175,8 @@ setUp(); Service.username = "broken.info"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; let backoffInterval; Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) { @@ -1191,7 +1209,8 @@ setUp(); Service.username = "broken.meta"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; let backoffInterval; Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) { @@ -1224,7 +1243,8 @@ setUp(); Service.username = "broken.keys"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; // Force re-download of keys CollectionKeys.clear(); @@ -1261,7 +1281,8 @@ Service.username = "broken.keys"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; let backoffInterval; Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) { @@ -1296,7 +1317,8 @@ Service.username = "broken.wipe"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; let backoffInterval; Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) { @@ -1330,7 +1352,8 @@ Service.username = "broken.wipe"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; generateAndUploadKeys(); let engine = Engines.get("catapult"); @@ -1397,7 +1420,8 @@ setUp(); Service.username = "broken.info"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; let backoffInterval; Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) { @@ -1430,7 +1454,8 @@ setUp(); Service.username = "broken.meta"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; let backoffInterval; Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) { @@ -1463,7 +1488,8 @@ setUp(); Service.username = "broken.keys"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; // Force re-download of keys CollectionKeys.clear(); @@ -1500,7 +1526,8 @@ Service.username = "broken.keys"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; let backoffInterval; Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) { @@ -1535,7 +1562,8 @@ Service.username = "broken.wipe"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.clusterURL = "http://localhost:8080/maintenance/"; + Service.serverURL = TEST_MAINTENANCE_URL; + Service.clusterURL = TEST_MAINTENANCE_URL; let backoffInterval; Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_errorhandler_sync_checkServerError.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_errorhandler_sync_checkServerError.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_errorhandler_sync_checkServerError.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_errorhandler_sync_checkServerError.js 2012-02-22 02:09:52.000000000 +0000 @@ -51,7 +51,8 @@ Service.username = "johndoe"; Service.password = "ilovejane"; Service.passphrase = "aabcdeabcdeabcdeabcdeabcde"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; new FakeCryptoService(); } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_history_engine.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_history_engine.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_history_engine.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_history_engine.js 2012-02-22 02:09:52.000000000 +0000 @@ -12,7 +12,8 @@ let FAKE_DOWNLOAD_LIMIT = 100; - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); Svc.Prefs.set("client.type", "mobile"); PlacesUtils.history.removeAllPages(); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_hmac_error.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_hmac_error.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_hmac_error.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_hmac_error.js 2012-02-22 02:09:52.000000000 +0000 @@ -18,8 +18,8 @@ hmacErrorCount = 0; // Do not instantiate SyncTestingInfrastructure; we need real crypto. - Service.serverURL = "http://localhost:8080/"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; Service.username = "foo"; Service.password = "foo"; Service.passphrase = "aabcdeabcdeabcdeabcdeabcde"; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_interval_triggers.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_interval_triggers.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_interval_triggers.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_interval_triggers.js 2012-02-22 02:09:52.000000000 +0000 @@ -35,7 +35,8 @@ Service.username = "johndoe"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; generateNewKeys(); let serverKeys = CollectionKeys.asWBO("crypto", "keys"); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_jpakeclient.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_jpakeclient.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_jpakeclient.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_jpakeclient.js 2012-02-22 02:09:52.000000000 +0000 @@ -166,7 +166,7 @@ const POLLINTERVAL = 50; function run_test() { - Svc.Prefs.set("jpake.serverURL", "http://localhost:8080/"); + Svc.Prefs.set("jpake.serverURL", TEST_SERVER_URL); Svc.Prefs.set("jpake.pollInterval", POLLINTERVAL); Svc.Prefs.set("jpake.maxTries", 2); Svc.Prefs.set("jpake.firstMsgMaxTries", 5); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_node_reassignment.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_node_reassignment.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_node_reassignment.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_node_reassignment.js 2012-02-22 02:09:52.000000000 +0000 @@ -76,8 +76,8 @@ Service.username = "johndoe"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; Service.password = "ilovejane"; - Service.serverURL = "http://localhost:8080/"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; do_check_eq(Service.userAPI, "http://localhost:8080/user/1.0/"); let server = new SyncServer(); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_resource_async.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_resource_async.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_resource_async.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_resource_async.js 2012-02-22 02:09:52.000000000 +0000 @@ -4,6 +4,9 @@ Cu.import("resource://services-sync/resource.js"); Cu.import("resource://services-sync/util.js"); +const RES_UPLOAD_URL = "http://localhost:8080/upload"; +const RES_HEADERS_URL = "http://localhost:8080/headers"; + let logger; let fetched = false; @@ -322,7 +325,7 @@ add_test(function test_put_string() { _("PUT to a resource (string)"); - let res_upload = new AsyncResource("http://localhost:8080/upload"); + let res_upload = new AsyncResource(RES_UPLOAD_URL); res_upload.put(JSON.stringify(sample_data), function(error, content) { do_check_eq(error, null); do_check_eq(content, "Valid data upload via PUT"); @@ -334,7 +337,7 @@ add_test(function test_put_object() { _("PUT to a resource (object)"); - let res_upload = new AsyncResource("http://localhost:8080/upload"); + let res_upload = new AsyncResource(RES_UPLOAD_URL); res_upload.put(sample_data, function (error, content) { do_check_eq(error, null); do_check_eq(content, "Valid data upload via PUT"); @@ -346,7 +349,7 @@ add_test(function test_put_data_string() { _("PUT without data arg (uses resource.data) (string)"); - let res_upload = new AsyncResource("http://localhost:8080/upload"); + let res_upload = new AsyncResource(RES_UPLOAD_URL); res_upload.data = JSON.stringify(sample_data); res_upload.put(function (error, content) { do_check_eq(error, null); @@ -359,7 +362,7 @@ add_test(function test_put_data_object() { _("PUT without data arg (uses resource.data) (object)"); - let res_upload = new AsyncResource("http://localhost:8080/upload"); + let res_upload = new AsyncResource(RES_UPLOAD_URL); res_upload.data = sample_data; res_upload.put(function (error, content) { do_check_eq(error, null); @@ -372,7 +375,7 @@ add_test(function test_post_string() { _("POST to a resource (string)"); - let res_upload = new AsyncResource("http://localhost:8080/upload"); + let res_upload = new AsyncResource(RES_UPLOAD_URL); res_upload.post(JSON.stringify(sample_data), function (error, content) { do_check_eq(error, null); do_check_eq(content, "Valid data upload via POST"); @@ -384,7 +387,7 @@ add_test(function test_post_object() { _("POST to a resource (object)"); - let res_upload = new AsyncResource("http://localhost:8080/upload"); + let res_upload = new AsyncResource(RES_UPLOAD_URL); res_upload.post(sample_data, function (error, content) { do_check_eq(error, null); do_check_eq(content, "Valid data upload via POST"); @@ -396,7 +399,7 @@ add_test(function test_post_data_string() { _("POST without data arg (uses resource.data) (string)"); - let res_upload = new AsyncResource("http://localhost:8080/upload"); + let res_upload = new AsyncResource(RES_UPLOAD_URL); res_upload.data = JSON.stringify(sample_data); res_upload.post(function (error, content) { do_check_eq(error, null); @@ -409,7 +412,7 @@ add_test(function test_post_data_object() { _("POST without data arg (uses resource.data) (object)"); - let res_upload = new AsyncResource("http://localhost:8080/upload"); + let res_upload = new AsyncResource(RES_UPLOAD_URL); res_upload.data = sample_data; res_upload.post(function (error, content) { do_check_eq(error, null); @@ -458,7 +461,7 @@ add_test(function test_get_no_headers() { _("GET: no special request headers"); - let res_headers = new AsyncResource("http://localhost:8080/headers"); + let res_headers = new AsyncResource(RES_HEADERS_URL); res_headers.get(function (error, content) { do_check_eq(error, null); do_check_eq(content, '{}'); @@ -468,7 +471,7 @@ add_test(function test_put_default_content_type() { _("PUT: Content-Type defaults to text/plain"); - let res_headers = new AsyncResource("http://localhost:8080/headers"); + let res_headers = new AsyncResource(RES_HEADERS_URL); res_headers.put('data', function (error, content) { do_check_eq(error, null); do_check_eq(content, JSON.stringify({"content-type": "text/plain"})); @@ -478,7 +481,7 @@ add_test(function test_post_default_content_type() { _("POST: Content-Type defaults to text/plain"); - let res_headers = new AsyncResource("http://localhost:8080/headers"); + let res_headers = new AsyncResource(RES_HEADERS_URL); res_headers.post('data', function (error, content) { do_check_eq(error, null); do_check_eq(content, JSON.stringify({"content-type": "text/plain"})); @@ -488,7 +491,7 @@ add_test(function test_setHeader() { _("setHeader(): setting simple header"); - let res_headers = new AsyncResource("http://localhost:8080/headers"); + let res_headers = new AsyncResource(RES_HEADERS_URL); res_headers.setHeader('X-What-Is-Weave', 'awesome'); do_check_eq(res_headers.headers['x-what-is-weave'], 'awesome'); res_headers.get(function (error, content) { @@ -500,7 +503,7 @@ add_test(function test_setHeader_overwrite() { _("setHeader(): setting multiple headers, overwriting existing header"); - let res_headers = new AsyncResource("http://localhost:8080/headers"); + let res_headers = new AsyncResource(RES_HEADERS_URL); res_headers.setHeader('X-WHAT-is-Weave', 'more awesomer'); res_headers.setHeader('X-Another-Header', 'hello world'); do_check_eq(res_headers.headers['x-what-is-weave'], 'more awesomer'); @@ -516,7 +519,7 @@ add_test(function test_headers_object() { _("Setting headers object"); - let res_headers = new AsyncResource("http://localhost:8080/headers"); + let res_headers = new AsyncResource(RES_HEADERS_URL); res_headers.headers = {}; res_headers.get(function (error, content) { do_check_eq(error, null); @@ -527,7 +530,7 @@ add_test(function test_put_override_content_type() { _("PUT: override default Content-Type"); - let res_headers = new AsyncResource("http://localhost:8080/headers"); + let res_headers = new AsyncResource(RES_HEADERS_URL); res_headers.setHeader('Content-Type', 'application/foobar'); do_check_eq(res_headers.headers['content-type'], 'application/foobar'); res_headers.put('data', function (error, content) { @@ -539,7 +542,7 @@ add_test(function test_post_override_content_type() { _("POST: override default Content-Type"); - let res_headers = new AsyncResource("http://localhost:8080/headers"); + let res_headers = new AsyncResource(RES_HEADERS_URL); res_headers.setHeader('Content-Type', 'application/foobar'); res_headers.post('data', function (error, content) { do_check_eq(error, null); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_resource_ua.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_resource_ua.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_resource_ua.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_resource_ua.js 2012-02-22 02:09:52.000000000 +0000 @@ -2,6 +2,8 @@ Cu.import("resource://services-sync/resource.js"); Cu.import("resource://services-sync/service.js"); +const TEST_GET_URL = "http://localhost:8080/1.1/johndoe/storage/meta/global"; + function test_resource_user_agent() { let meta_global = new ServerWBO('global'); @@ -23,8 +25,8 @@ "/1.1/johndoe/storage/meta/global": uaHandler(meta_global.handler()), }); - Weave.Service.serverURL = "http://localhost:8080/"; - Weave.Service.clusterURL = "http://localhost:8080/"; + Weave.Service.serverURL = TEST_SERVER_URL; + Weave.Service.clusterURL = TEST_CLUSTER_URL; Weave.Service.username = "johndoe"; Weave.Service.password = "ilovejane"; @@ -43,7 +45,7 @@ function test_desktop_post(next) { _("Testing direct Resource POST."); - let r = new AsyncResource("http://localhost:8080/1.1/johndoe/storage/meta/global"); + let r = new AsyncResource(TEST_GET_URL); r.post("foo=bar", function (error, content) { _("User-Agent: " + ua); do_check_eq(ua, expectedUA + ".desktop"); @@ -55,7 +57,7 @@ function test_desktop_get(next) { _("Testing async."); Svc.Prefs.set("client.type", "desktop"); - let r = new AsyncResource("http://localhost:8080/1.1/johndoe/storage/meta/global"); + let r = new AsyncResource(TEST_GET_URL); r.get(function(error, content) { _("User-Agent: " + ua); do_check_eq(ua, expectedUA + ".desktop"); @@ -67,7 +69,7 @@ function test_mobile_get(next) { _("Testing mobile."); Svc.Prefs.set("client.type", "mobile"); - let r = new AsyncResource("http://localhost:8080/1.1/johndoe/storage/meta/global"); + let r = new AsyncResource(TEST_GET_URL); r.get(function (error, content) { _("User-Agent: " + ua); do_check_eq(ua, expectedUA + ".mobile"); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_restrequest.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_restrequest.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_restrequest.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_restrequest.js 2012-02-22 02:09:52.000000000 +0000 @@ -5,6 +5,8 @@ Cu.import("resource://services-sync/log4moz.js"); Cu.import("resource://gre/modules/NetUtil.jsm"); +const TEST_RESOURCE_URL = TEST_SERVER_URL + "resource"; + function run_test() { Log4Moz.repository.getLogger("Sync.RESTRequest").level = Log4Moz.Level.Trace; initTestLogging(); @@ -89,7 +91,7 @@ let handler = httpd_handler(200, "OK", "Huzzah!"); let server = httpd_setup({"/resource": handler}); - let uri = "http://localhost:8080/resource"; + let uri = TEST_RESOURCE_URL; let request = new RESTRequest(uri).get(function (error) { do_check_eq(error, null); @@ -111,7 +113,7 @@ let handler = httpd_handler(200, "OK", "Huzzah!"); let server = httpd_setup({"/resource": handler}); - let request = new RESTRequest("http://localhost:8080/resource"); + let request = new RESTRequest(TEST_RESOURCE_URL); do_check_eq(request.status, request.NOT_SENT); request.onProgress = request.onComplete = function () { @@ -160,7 +162,7 @@ let handler = httpd_handler(200, "OK", "Got it!"); let server = httpd_setup({"/resource": handler}); - let request = new RESTRequest("http://localhost:8080/resource"); + let request = new RESTRequest(TEST_RESOURCE_URL); do_check_eq(request.status, request.NOT_SENT); request.onProgress = request.onComplete = function () { @@ -209,7 +211,7 @@ let handler = httpd_handler(200, "OK", "Got it!"); let server = httpd_setup({"/resource": handler}); - let request = new RESTRequest("http://localhost:8080/resource"); + let request = new RESTRequest(TEST_RESOURCE_URL); do_check_eq(request.status, request.NOT_SENT); request.onProgress = request.onComplete = function () { @@ -258,7 +260,7 @@ let handler = httpd_handler(200, "OK", "Got it!"); let server = httpd_setup({"/resource": handler}); - let request = new RESTRequest("http://localhost:8080/resource"); + let request = new RESTRequest(TEST_RESOURCE_URL); do_check_eq(request.status, request.NOT_SENT); request.onProgress = request.onComplete = function () { @@ -304,7 +306,7 @@ let handler = httpd_handler(404, "Not Found", "Cannae find it!"); let server = httpd_setup({"/resource": handler}); - let request = new RESTRequest("http://localhost:8080/resource"); + let request = new RESTRequest(TEST_RESOURCE_URL); request.get(function (error) { do_check_eq(error, null); @@ -330,7 +332,7 @@ injson: "format", number: 42 }; - let request = new RESTRequest("http://localhost:8080/resource"); + let request = new RESTRequest(TEST_RESOURCE_URL); request.put(sample_data, function (error) { do_check_eq(error, null); @@ -360,7 +362,7 @@ injson: "format", number: 42 }; - let request = new RESTRequest("http://localhost:8080/resource"); + let request = new RESTRequest(TEST_RESOURCE_URL); request.post(sample_data, function (error) { do_check_eq(error, null); @@ -384,7 +386,7 @@ let handler = httpd_handler(200, "OK"); let server = httpd_setup({"/resource": handler}); - let request = new RESTRequest("http://localhost:8080/resource"); + let request = new RESTRequest(TEST_RESOURCE_URL); request.setHeader("Content-Type", "application/lolcat"); request.put("O HAI!!1!", function (error) { do_check_eq(error, null); @@ -409,7 +411,7 @@ let handler = httpd_handler(200, "OK"); let server = httpd_setup({"/resource": handler}); - let request = new RESTRequest("http://localhost:8080/resource"); + let request = new RESTRequest(TEST_RESOURCE_URL); request.setHeader("Content-Type", "application/lolcat"); request.post("O HAI!!1!", function (error) { do_check_eq(error, null); @@ -439,7 +441,7 @@ "connection", "pragma", "cache-control", "content-length"]; - new RESTRequest("http://localhost:8080/resource").get(function (error) { + new RESTRequest(TEST_RESOURCE_URL).get(function (error) { do_check_eq(error, null); do_check_eq(this.response.status, 200); @@ -465,7 +467,7 @@ let server = httpd_setup({"/resource": handler}); let request = new RESTRequest("http://localhost:8080/the-wrong-resource"); - request.uri = Utils.makeURI("http://localhost:8080/resource"); + request.uri = Utils.makeURI(TEST_RESOURCE_URL); request.get(function (error) { do_check_eq(error, null); do_check_eq(this.response.status, 200); @@ -480,7 +482,7 @@ let handler = httpd_handler(200, "OK"); let server = httpd_setup({"/resource": handler}); - let request = new RESTRequest("http://localhost:8080/resource"); + let request = new RESTRequest(TEST_RESOURCE_URL); request.setHeader("X-What-Is-Weave", "awesome"); request.setHeader("X-WHAT-is-Weave", "more awesomer"); @@ -509,7 +511,7 @@ response.setStatusLine(request.httpVersion, 200, "OK"); } let server = httpd_setup({"/resource": handler}); - let request = new RESTRequest("http://localhost:8080/resource"); + let request = new RESTRequest(TEST_RESOURCE_URL); request.get(function (error) { do_check_eq(error, null); @@ -529,7 +531,7 @@ * (e.g. NS_ERROR_CONNECTION_REFUSED). */ add_test(function test_connection_refused() { - let request = new RESTRequest("http://localhost:8080/resource"); + let request = new RESTRequest(TEST_RESOURCE_URL); request.onProgress = function onProgress() { do_throw("Shouldn't have called request.onProgress()!"); }; @@ -551,7 +553,7 @@ } let server = httpd_setup({"/resource": handler}); - let request = new RESTRequest("http://localhost:8080/resource"); + let request = new RESTRequest(TEST_RESOURCE_URL); // Aborting a request that hasn't been sent yet is pointless and will throw. do_check_throws(function () { @@ -591,7 +593,7 @@ }; server.start(8080); - let request = new RESTRequest("http://localhost:8080/resource"); + let request = new RESTRequest(TEST_RESOURCE_URL); request.timeout = 0.1; // 100 milliseconds request.get(function (error) { do_check_eq(error.result, Cr.NS_ERROR_NET_TIMEOUT); @@ -609,7 +611,7 @@ let handler = httpd_handler(200, "OK", "Foobar"); let server = httpd_setup({"/resource": handler}); - let request = new RESTRequest("http://localhost:8080/resource"); + let request = new RESTRequest(TEST_RESOURCE_URL); request.onProgress = function onProgress() { it.does.not.exist(); }; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_score_triggers.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_score_triggers.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_score_triggers.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_score_triggers.js 2012-02-22 02:09:52.000000000 +0000 @@ -46,7 +46,8 @@ Service.username = "johndoe"; Service.password = "ilovejane"; Service.passphrase = "sekrit"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; new FakeCryptoService(); } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_changePassword.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_changePassword.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_changePassword.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_changePassword.js 2012-02-22 02:09:52.000000000 +0000 @@ -26,7 +26,8 @@ } try { - Weave.Service.serverURL = "http://localhost:8080/"; + Weave.Service.serverURL = TEST_SERVER_URL; + Weave.Service.clusterURL = TEST_CLUSTER_URL; Weave.Service.username = "johndoe"; Weave.Service.password = "ilovejane"; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_checkAccount.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_checkAccount.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_checkAccount.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_checkAccount.js 2012-02-22 02:09:52.000000000 +0000 @@ -12,7 +12,7 @@ "/user/1.0/vuuf3eqgloxpxmzph27f5a6ve7gzlrms": httpd_handler(200, "OK", "1") }); try { - Service.serverURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; _("A 404 will be recorded as 'generic-server-error'"); do_check_eq(Service.checkAccount("jimdoe"), "generic-server-error"); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_cluster.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_cluster.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_cluster.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_cluster.js 2012-02-22 02:09:52.000000000 +0000 @@ -15,7 +15,7 @@ _("Test Service._findCluster()"); let server; try { - Service.serverURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; Service.username = "johndoe"; _("_findCluster() throws on network errors (e.g. connection refused)."); @@ -73,7 +73,7 @@ "/user/1.0/jimdoe/node/weave": httpd_handler(200, "OK", "null") }); try { - Service.serverURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; Service.username = "johndoe"; _("Check initial state."); @@ -105,7 +105,7 @@ "/user/1.0/janedoe/node/weave": httpd_handler(200, "OK", "http://weave.cluster.url/") }); try { - Service.serverURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; Service.username = "johndoe"; _("Check initial state."); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_createAccount.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_createAccount.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_createAccount.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_createAccount.js 2012-02-22 02:09:52.000000000 +0000 @@ -26,7 +26,7 @@ "/user/1.0/vz6fhecgw5t3sgx3a4cektoiokyczkqd": send(500, "Server Error", "Server Error") }); try { - Service.serverURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; _("Create an account."); let res = Service.createAccount("john@doe.com", "mysecretpw", diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_detect_upgrade.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_detect_upgrade.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_detect_upgrade.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_detect_upgrade.js 2012-02-22 02:09:52.000000000 +0000 @@ -63,8 +63,8 @@ Status.resetSync(); _("Logging in."); - Weave.Service.serverURL = "http://localhost:8080/"; - Weave.Service.clusterURL = "http://localhost:8080/"; + Weave.Service.serverURL = TEST_SERVER_URL; + Weave.Service.clusterURL = TEST_CLUSTER_URL; Weave.Service.login("johndoe", "ilovejane", passphrase); do_check_true(Weave.Service.isLoggedIn); @@ -99,8 +99,8 @@ _("Syncing afresh..."); Weave.Service.logout(); CollectionKeys.clear(); - Weave.Service.serverURL = "http://localhost:8080/"; - Weave.Service.clusterURL = "http://localhost:8080/"; + Weave.Service.serverURL = TEST_SERVER_URL; + Weave.Service.clusterURL = TEST_CLUSTER_URL; meta_global.payload = JSON.stringify({"syncID": "foooooooooooooobbbbbbbbbbbb", "storageVersion": STORAGE_VERSION}); collections.meta = Date.now() / 1000; @@ -239,8 +239,8 @@ Weave.Service.password = "ilovejane"; Weave.Service.passphrase = passphrase; - Weave.Service.serverURL = "http://localhost:8080/"; - Weave.Service.clusterURL = "http://localhost:8080/"; + Weave.Service.serverURL = TEST_SERVER_URL; + Weave.Service.clusterURL = TEST_CLUSTER_URL; // // Test an upgrade where the contents of the server would cause us to error diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_getStorageInfo.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_getStorageInfo.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_getStorageInfo.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_getStorageInfo.js 2012-02-22 02:09:52.000000000 +0000 @@ -13,7 +13,8 @@ function run_test() { Service.username = "johndoe"; Service.password = "ilovejane"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; Log4Moz.repository.getLogger("Sync.Service").level = Log4Moz.Level.Trace; Log4Moz.repository.getLogger("Sync.StorageRequest").level = Log4Moz.Level.Trace; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_login.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_login.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_login.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_login.js 2012-02-22 02:09:52.000000000 +0000 @@ -39,8 +39,8 @@ }); function setup() { - Service.serverURL = "http://localhost:8080/"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; let janeHelper = track_collections_helper(); let janeU = janeHelper.with_updated_collection; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_passwordUTF8.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_passwordUTF8.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_passwordUTF8.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_passwordUTF8.js 2012-02-22 02:09:52.000000000 +0000 @@ -65,7 +65,7 @@ Service.username = "johndoe"; Service.password = JAPANESE; Service.passphrase = "cantentsveryrelevantabbbb"; - Service.serverURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; try { _("Try to log in with the password."); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_startOver.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_startOver.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_startOver.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_startOver.js 2012-02-22 02:09:52.000000000 +0000 @@ -71,7 +71,9 @@ Service.startOver(); do_check_false(engine.removed); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); + do_check_false(engine.removed); Service.startOver(); do_check_true(engine.removed); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_sync_401.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_sync_401.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_sync_401.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_sync_401.js 2012-02-22 02:09:52.000000000 +0000 @@ -32,8 +32,8 @@ try { _("Set up test fixtures."); - Weave.Service.serverURL = "http://localhost:8080/"; - Weave.Service.clusterURL = "http://localhost:8080/"; + Weave.Service.serverURL = TEST_SERVER_URL; + Weave.Service.clusterURL = TEST_CLUSTER_URL; Weave.Service.username = "johndoe"; Weave.Service.password = "ilovejane"; Weave.Service.passphrase = "foo"; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_sync_remoteSetup.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_sync_remoteSetup.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_sync_remoteSetup.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_sync_remoteSetup.js 2012-02-22 02:09:52.000000000 +0000 @@ -61,8 +61,8 @@ try { _("Log in."); - Weave.Service.serverURL = "http://localhost:8080/"; - Weave.Service.clusterURL = "http://localhost:8080/"; + Weave.Service.serverURL = TEST_SERVER_URL; + Weave.Service.clusterURL = TEST_CLUSTER_URL; _("Checking Status.sync with no credentials."); Weave.Service.verifyAndFetchSymmetricKeys(); @@ -77,8 +77,8 @@ let syncKey = Weave.Service.passphrase; Weave.Service.startOver(); - Weave.Service.serverURL = "http://localhost:8080/"; - Weave.Service.clusterURL = "http://localhost:8080/"; + Weave.Service.serverURL = TEST_SERVER_URL; + Weave.Service.clusterURL = TEST_CLUSTER_URL; Weave.Service.login("johndoe", "ilovejane", syncKey); do_check_true(Weave.Service.isLoggedIn); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_sync_updateEnabledEngines.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_sync_updateEnabledEngines.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_sync_updateEnabledEngines.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_sync_updateEnabledEngines.js 2012-02-22 02:09:52.000000000 +0000 @@ -69,7 +69,8 @@ Service.username = "johndoe"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; // So that we can poke at meta/global. new FakeCryptoService(); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_verifyLogin.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_verifyLogin.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_verifyLogin.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_verifyLogin.js 2012-02-22 02:09:52.000000000 +0000 @@ -44,7 +44,7 @@ }); try { - Service.serverURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; _("Force the initial state."); Status.service = STATUS_OK; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_wipeServer.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_wipeServer.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_service_wipeServer.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_service_wipeServer.js 2012-02-22 02:09:52.000000000 +0000 @@ -29,7 +29,8 @@ function setUpTestFixtures() { let cryptoService = new FakeCryptoService(); - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; Service.username = "johndoe"; Service.passphrase = "aabcdeabcdeabcdeabcdeabcde"; } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_syncengine.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_syncengine.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_syncengine.js 2012-02-21 02:10:06.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_syncengine.js 2012-02-22 02:09:52.000000000 +0000 @@ -158,7 +158,8 @@ function test_wipeServer() { _("SyncEngine.wipeServer deletes server data and resets the client."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); let engine = makeSteamEngine(); const PAYLOAD = 42; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_syncengine_sync.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_syncengine_sync.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_syncengine_sync.js 2012-02-21 02:10:07.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_syncengine_sync.js 2012-02-22 02:09:52.000000000 +0000 @@ -29,8 +29,8 @@ }; const USER = "foo"; - Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", USER); let server = new SyncServer(); @@ -65,7 +65,8 @@ _("SyncEngine._syncStartup resets sync and wipes server data if there's no or an outdated global record"); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); // Some server side data that's going to be wiped @@ -118,7 +119,8 @@ _("SyncEngine._syncStartup "); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); let global = new ServerWBO('global', {engines: {rotary: {version: 23456}}}); let server = httpd_setup({ @@ -148,7 +150,8 @@ _("SyncEngine._syncStartup resets sync if syncIDs don't match"); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); let server = sync_httpd_setup({}); @@ -185,7 +188,8 @@ _("SyncEngine._processIncoming working with an empty server backend"); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); let collection = new ServerCollection(); @@ -210,7 +214,8 @@ _("SyncEngine._processIncoming creates new records from server data"); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); generateNewKeys(); @@ -271,7 +276,8 @@ _("SyncEngine._processIncoming updates local records"); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); let collection = new ServerCollection(); @@ -590,7 +596,8 @@ _("SyncEngine._processIncoming doesn't fetch everything at once on mobile clients"); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); Svc.Prefs.set("client.type", "mobile"); @@ -659,7 +666,8 @@ add_test(function test_processIncoming_store_toFetch() { _("If processIncoming fails in the middle of a batch on mobile, state is saved in toFetch and lastSync."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); Svc.Prefs.set("client.type", "mobile"); @@ -726,7 +734,8 @@ add_test(function test_processIncoming_resume_toFetch() { _("toFetch and previousFailed items left over from previous syncs are fetched on the next sync, along with new items."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); const LASTSYNC = Date.now() / 1000; @@ -794,7 +803,8 @@ add_test(function test_processIncoming_applyIncomingBatchSize_smaller() { _("Ensure that a number of incoming items less than applyIncomingBatchSize is still applied."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); // Engine that doesn't like the first and last record it's given. @@ -848,7 +858,7 @@ add_test(function test_processIncoming_applyIncomingBatchSize_multiple() { _("Ensure that incoming items are applied according to applyIncomingBatchSize."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); const APPLY_BATCH_SIZE = 10; @@ -900,7 +910,8 @@ add_test(function test_processIncoming_notify_count() { _("Ensure that failed records are reported only once."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); const APPLY_BATCH_SIZE = 5; @@ -986,7 +997,8 @@ add_test(function test_processIncoming_previousFailed() { _("Ensure that failed records are retried."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); Svc.Prefs.set("client.type", "mobile"); @@ -1071,7 +1083,8 @@ add_test(function test_processIncoming_failed_records() { _("Ensure that failed records from _reconcile and applyIncomingBatch are refetched."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); // Let's create three and a bit batches worth of server side records. @@ -1205,7 +1218,8 @@ _("Ensure that records failing to decrypt are either replaced or refetched."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); // Some good and some bogus records. One doesn't contain valid JSON, @@ -1282,7 +1296,8 @@ _("SyncEngine._uploadOutgoing uploads new records to server"); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); let collection = new ServerCollection(); collection._wbos.flying = new ServerWBO('flying'); @@ -1340,7 +1355,8 @@ _("SyncEngine._uploadOutgoing doesn't clear the tracker of objects that failed to upload."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); let collection = new ServerCollection(); // We only define the "flying" WBO on the server, not the "scotsman" @@ -1402,7 +1418,8 @@ _("SyncEngine._uploadOutgoing uploads in batches of MAX_UPLOAD_RECORDS"); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); let collection = new ServerCollection(); @@ -1473,7 +1490,8 @@ _("SyncEngine._syncFinish deletes server records slated for deletion (list of record IDs)."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); let collection = new ServerCollection(); collection._wbos.flying = new ServerWBO( @@ -1514,7 +1532,8 @@ _("SyncEngine._syncFinish deletes server records in batches of 100 (list of record IDs)."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); let collection = new ServerCollection(); @@ -1585,7 +1604,8 @@ _("SyncEngine.sync() keeps changedIDs that couldn't be uploaded."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); let collection = new ServerCollection(); @@ -1658,7 +1678,8 @@ add_test(function test_canDecrypt_noCryptoKeys() { _("SyncEngine.canDecrypt returns false if the engine fails to decrypt items on the server, e.g. due to a missing crypto key collection."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); // Wipe CollectionKeys so we can test the desired scenario. @@ -1686,7 +1707,8 @@ add_test(function test_canDecrypt_true() { _("SyncEngine.canDecrypt returns true if the engine can decrypt the items on the server."); let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); // Set up CollectionKeys, as service.js does. @@ -1714,7 +1736,8 @@ add_test(function test_syncapplied_observer() { let syncTesting = new SyncTestingInfrastructure(); - Svc.Prefs.set("clusterURL", "http://localhost:8080/"); + Svc.Prefs.set("serverURL", TEST_SERVER_URL); + Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL); Svc.Prefs.set("username", "foo"); const NUMBER_OF_RECORDS = 10; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_syncscheduler.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_syncscheduler.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_syncscheduler.js 2012-02-21 02:10:07.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_syncscheduler.js 2012-02-22 02:09:52.000000000 +0000 @@ -52,7 +52,7 @@ Service.username = "johndoe"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.clusterURL = "http://localhost:8080/"; + Service.clusterURL = TEST_CLUSTER_URL; generateNewKeys(); let serverKeys = CollectionKeys.asWBO("crypto", "keys"); @@ -667,7 +667,7 @@ let server = sync_httpd_setup(); setUp(); - Service.serverURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; Service.sync(); do_check_eq(Status.sync, NO_SYNC_NODE_FOUND); @@ -852,8 +852,8 @@ Service.username = "johndoe"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.serverURL = "http://localhost:8080/"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; Service.persistLogin(); Status.resetSync(); // reset Status.login @@ -896,8 +896,8 @@ Service.username = "johndoe"; Service.password = "ilovejane"; Service.passphrase = "abcdeabcdeabcdeabcdeabcdea"; - Service.serverURL = "http://localhost:8080/"; - Service.clusterURL = "http://localhost:8080/"; + Service.serverURL = TEST_SERVER_URL; + Service.clusterURL = TEST_CLUSTER_URL; Service.persistLogin(); Status.resetSync(); // reset Status.login diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_syncstoragerequest.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_syncstoragerequest.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tests/unit/test_syncstoragerequest.js 2012-02-21 02:10:07.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tests/unit/test_syncstoragerequest.js 2012-02-22 02:09:52.000000000 +0000 @@ -7,6 +7,8 @@ Cu.import("resource://services-sync/constants.js"); Cu.import("resource://services-sync/log4moz.js"); +const STORAGE_REQUEST_RESOURCE_URL = TEST_SERVER_URL + "resource"; + function run_test() { Log4Moz.repository.getLogger("Sync.RESTRequest").level = Log4Moz.Level.Trace; initTestLogging(); @@ -22,7 +24,7 @@ " FxSync/" + WEAVE_VERSION + "." + Services.appinfo.appBuildID + ".desktop"; - let request = new SyncStorageRequest("http://localhost:8080/resource"); + let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL); request.onComplete = function onComplete(error) { do_check_eq(error, null); do_check_eq(this.response.status, 200); @@ -41,7 +43,7 @@ " FxSync/" + WEAVE_VERSION + "." + Services.appinfo.appBuildID + ".mobile"; - let request = new SyncStorageRequest("http://localhost:8080/resource"); + let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL); request.get(function (error) { do_check_eq(error, null); do_check_eq(this.response.status, 200); @@ -59,7 +61,7 @@ id.password = "ilovejane"; ID.set("WeaveID", id); - let request = new SyncStorageRequest("http://localhost:8080/resource"); + let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL); request.get(function (error) { do_check_eq(error, null); do_check_eq(this.response.status, 200); @@ -82,7 +84,7 @@ let server = httpd_setup({"/resource": handler}); do_check_eq(SyncStorageRequest.serverTime, undefined); - let request = new SyncStorageRequest("http://localhost:8080/resource"); + let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL); request.get(function (error) { do_check_eq(error, null); do_check_eq(this.response.status, 200); @@ -108,7 +110,7 @@ backoffInterval = subject; }); - let request = new SyncStorageRequest("http://localhost:8080/resource"); + let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL); request.get(function (error) { do_check_eq(error, null); do_check_eq(this.response.status, 200); @@ -133,7 +135,7 @@ quotaValue = subject; }); - let request = new SyncStorageRequest("http://localhost:8080/resource"); + let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL); request.get(function (error) { do_check_eq(error, null); do_check_eq(this.response.status, 200); @@ -158,7 +160,7 @@ } Svc.Obs.add("weave:service:quota:remaining", onQuota); - let request = new SyncStorageRequest("http://localhost:8080/resource"); + let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL); request.get(function (error) { do_check_eq(error, null); do_check_eq(this.response.status, 400); @@ -177,7 +179,7 @@ } let server = httpd_setup({"/resource": handler}); - let request = new SyncStorageRequest("http://localhost:8080/resource"); + let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL); // Aborting a request that hasn't been sent yet is pointless and will throw. do_check_throws(function () { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tps/extensions/tps/modules/addons.jsm firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tps/extensions/tps/modules/addons.jsm --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tps/extensions/tps/modules/addons.jsm 2012-02-21 02:10:07.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tps/extensions/tps/modules/addons.jsm 2012-02-22 02:09:53.000000000 +0000 @@ -133,7 +133,7 @@ // API is broken, it should ideally be caught by an xpcshell test. But, if // TPS tests fail, it's all the same: a genuite reported error. let store = Engines.get("addons")._store; - store.installAddonsFromIDs([this.id], cb); + store.installAddons([{id: this.id}], cb); let result = cb.wait(); Logger.AssertEqual(1, result.installedIDs.length, "Exactly 1 add-on was installed."); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tps/extensions/tps/modules/tps.jsm firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tps/extensions/tps/modules/tps.jsm --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/services/sync/tps/extensions/tps/modules/tps.jsm 2012-02-21 02:10:07.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/services/sync/tps/extensions/tps/modules/tps.jsm 2012-02-22 02:09:53.000000000 +0000 @@ -93,6 +93,7 @@ let TPS = { _waitingForSync: false, + _isTracking: false, _test: null, _currentAction: -1, _currentPhase: -1, @@ -148,6 +149,15 @@ }, 1000, this, "postsync"); } break; + + case "weave:engine:start-tracking": + this._isTracking = true; + break; + + case "weave:engine:stop-tracking": + this._isTracking = false; + break; + case "sessionstore-windows-restored": Utils.nextTick(this.RunNextTestAction, this); break; @@ -533,7 +543,31 @@ return; } - // setup observers + // Wait for Sync service to become ready. + if (!Weave.Status.ready) { + this.waitForEvent("weave:service:ready"); + } + + // Always give Sync an extra tick to initialize. If we waited for the + // service:ready event, this is required to ensure all handlers have + // executed. + Utils.nextTick(this._executeTestPhase.bind(this, file, phase, settings)); + } catch(e) { + this.DumpError("Exception caught: " + Utils.exceptionStr(e)); + return; + } + }, + + /** + * Executes a single test phase. + * + * This is called by RunTestPhase() after the environment is validated. + */ + _executeTestPhase: function _executeTestPhase(file, phase, settings) { + try { + // TODO Unregister observers on unload (bug 721283). + Services.obs.addObserver(this, "weave:engine:start-tracking", true); + Services.obs.addObserver(this, "weave:engine:stop-tracking", true); Services.obs.addObserver(this, "weave:service:sync:finish", true); Services.obs.addObserver(this, "weave:service:sync:error", true); Services.obs.addObserver(this, "sessionstore-windows-restored", true); @@ -670,6 +704,41 @@ }, /** + * Synchronously wait for the named event to be observed. + * + * When the event is observed, the function will wait an extra tick before + * returning. + * + * @param name + * String event to wait for. + */ + waitForEvent:function waitForEvent(name) { + Logger.logInfo("Waiting for " + name + "..."); + let cb = Async.makeSpinningCallback(); + Svc.Obs.add(name, cb); + cb.wait(); + Svc.Obs.remove(name, cb); + Logger.logInfo(name + " observed!"); + + let cb = Async.makeSpinningCallback(); + Utils.nextTick(cb); + cb.wait(); + }, + + /** + * Waits for Sync to start tracking before returning. + */ + waitForTracking: function waitForTracking() { + if (!this._isTracking) { + this.waitForEvent("weave:engine:start-tracking"); + } + + let cb = Async.makeSyncCallback(); + Utils.nextTick(cb); + Async.waitForSyncCallback(cb); + }, + + /** * Reset the client and server to an empty/pure state. * * All data on the server is wiped and replaced with new keys and local @@ -689,6 +758,8 @@ Service.wipeServer(); Service.resetClient(); Service.login(); + + this.waitForTracking(); }, Login: function Login(force) { @@ -734,6 +805,8 @@ Logger.AssertEqual(Weave.Status.service, Weave.STATUS_OK, "Weave status not OK"); Weave.Svc.Obs.notify("weave:service:setup-complete"); this._loggedIn = true; + + this.waitForTracking(); }, Sync: function TPS__Sync(options) { @@ -767,6 +840,14 @@ this.Login(); Weave.Service.wipeServer(); }, + + /** + * Action which ensures changes are being tracked before returning. + */ + EnsureTracking: function EnsureTracking() { + this.Login(false); + this.waitForTracking(); + } }; var Addons = { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/mochitest/runtests.py firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/mochitest/runtests.py --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/mochitest/runtests.py 2012-02-21 02:10:17.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/mochitest/runtests.py 2012-02-22 02:09:55.000000000 +0000 @@ -248,6 +248,11 @@ help = "JSON list of tests that we want to not run, cannot be specified with --run-only-tests.") defaults["excludeTests"] = None + self.add_option("--failure-file", + action = "store", type="string", dest = "failureFile", + help = "Filename of the output file where we can store a .json list of failures to be run in the future with --run-only-tests.") + defaults["failureFile"] = None + # -h, --help are automatically handled by OptionParser self.set_defaults(**defaults) @@ -314,13 +319,13 @@ if options.runOnlyTests != None and options.excludeTests != None: self.error("We can only support --run-only-tests OR --exclude-tests, not both.") - if (options.runOnlyTests): - if (not os.path.exists(os.path.join(os.path.dirname(__file__), options.runOnlyTests))): - self.error("unable to find --run-only-tests file '%s'" % (options.runOnlyTests)); + if options.runOnlyTests: + if not os.path.exists(os.path.abspath(options.runOnlyTests)): + self.error("unable to find --run-only-tests file '%s'" % options.runOnlyTests); - if (options.excludeTests): - if (not os.path.exists(os.path.join(os.path.dirname(__file__), options.excludeTests))): - self.error("unable to find --exclude-tests file '%s'" % (options.excludeTests)); + if options.excludeTests: + if not os.path.exists(os.path.abspath(options.excludeTests)): + self.error("unable to find --exclude-tests file '%s'" % options.excludeTests); return options @@ -594,6 +599,8 @@ self.urlOpts.append("testname=%s" % ("/").join([self.TEST_PATH, options.testPath])) if options.runOnlyTests: self.urlOpts.append("runOnlyTests=%s" % options.runOnlyTests) + if options.failureFile: + self.urlOpts.append("failureFile=%s" % options.failureFile) elif options.excludeTests: self.urlOpts.append("excludeTests=%s" % options.excludeTests) diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/mochitest/tests/SimpleTest/setup.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/mochitest/tests/SimpleTest/setup.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/mochitest/tests/SimpleTest/setup.js 2012-02-21 02:10:18.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/mochitest/tests/SimpleTest/setup.js 2012-02-22 02:09:55.000000000 +0000 @@ -118,6 +118,10 @@ TestRunner.onComplete = SpecialPowers.quit; } +if (params.failureFile) { + TestRunner.setFailureFile(params.failureFile); +} + // logFile to write our results if (params.logFile) { var spl = new SpecialPowersLogger(params.logFile); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/mochitest/tests/SimpleTest/SimpleTest.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/mochitest/tests/SimpleTest/SimpleTest.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/mochitest/tests/SimpleTest/SimpleTest.js 2012-02-21 02:10:18.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/mochitest/tests/SimpleTest/SimpleTest.js 2012-02-22 02:09:55.000000000 +0000 @@ -274,6 +274,7 @@ var msg = [resultString, url, diagnostic].join(" | "); if (parentRunner) { if (isError) { + parentRunner.addFailedTest(url); parentRunner.error(msg); } else { parentRunner.log(msg); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/mochitest/tests/SimpleTest/TestRunner.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/mochitest/tests/SimpleTest/TestRunner.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/mochitest/tests/SimpleTest/TestRunner.js 2012-02-21 02:10:18.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/mochitest/tests/SimpleTest/TestRunner.js 2012-02-22 02:09:55.000000000 +0000 @@ -133,6 +133,28 @@ TestRunner.onComplete = null; /** + * Adds a failed test case to a list so we can rerun only the failed tests + **/ +TestRunner._failedTests = {}; +TestRunner._failureFile = ""; + +TestRunner.addFailedTest = function(testName) { + if (TestRunner._failedTests[testName] == undefined) { + TestRunner._failedTests[testName] = ""; + } +}; + +TestRunner.setFailureFile = function(fileName) { + TestRunner._failureFile = fileName; +} + +TestRunner.generateFailureList = function() { + var failures = new SpecialPowersLogger(TestRunner._failureFile); + failures.log(JSON.stringify(TestRunner._failedTests)); + failures.close(); +}; + +/** * If logEnabled is true, this is the logger that will be used. **/ TestRunner.logger = LogController; @@ -346,6 +368,7 @@ if (TestRunner.onComplete) TestRunner.onComplete(); } + TestRunner.generateFailureList(); } }; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/peptest/extension/resource/mozmill/driver/controller.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/peptest/extension/resource/mozmill/driver/controller.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/peptest/extension/resource/mozmill/driver/controller.js 2012-02-21 02:10:20.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/peptest/extension/resource/mozmill/driver/controller.js 2012-02-22 02:09:56.000000000 +0000 @@ -67,12 +67,12 @@ init : function waitForEvents_init(node, events) { if (node.getNode != undefined) node = node.getNode(); - + this.events = events; this.node = node; node.firedEvents = {}; this.registry = {}; - + for each(e in events) { var listener = function(event) { this.firedEvents[event.type] = true; @@ -92,7 +92,7 @@ utils.waitFor(function() { return this.node.firedEvents[e] == true; }, "Timeout happened before event '" + ex +"' was fired.", timeout, interval); - + this.node.removeEventListener(e, this.registry[e], true); } } @@ -281,10 +281,10 @@ } // constructs a MozMillElement from the controller's window -MozMillController.prototype.__defineGetter__("windowElement", function() { - if (this._windowElement == undefined) - this._windowElement = new mozelement.MozMillElement(undefined, undefined, {'element': this.window}); - return this._windowElement; +MozMillController.prototype.__defineGetter__("rootElement", function() { + if (this._rootElement == undefined) + this._rootElement = new mozelement.MozMillElement(undefined, undefined, {'element': this.window.document.documentElement}); + return this._rootElement; }); MozMillController.prototype.sleep = utils.sleep; @@ -308,7 +308,7 @@ /** * Take a screenshot of specified node - * + * * @param {element} node * the window or DOM element to capture * @param {string} name @@ -322,7 +322,7 @@ if (!node) { throw new Error("node is undefined"); } - + // Unwrap the node and highlights if ("getNode" in node) node = node.getNode(); if (highlights) { @@ -332,7 +332,7 @@ } } } - + // If save is false, a dataURL is used // Include both in the report anyway to avoid confusion and make the report easier to parse var filepath, dataURL; @@ -419,7 +419,7 @@ this.window.setTimeout(broker.sendMessage, timeout, 'userShutdown', 0); } -MozMillController.prototype.restartApplication = function (next, resetProfile) +MozMillController.prototype.restartApplication = function (next, resetProfile) { // restart the application via the python runner // - next : name of the next test function to run after restart @@ -433,7 +433,7 @@ utils.getMethodInWindows('goQuitApplication')(); } -MozMillController.prototype.stopApplication = function (resetProfile) +MozMillController.prototype.stopApplication = function (resetProfile) { // stop the application via the python runner // - resetProfile : whether to reset the profile after shutdown @@ -488,7 +488,7 @@ //Assert that a specified node exists MozMillController.prototype.assertNode = function (el) { logDeprecatedAssert("assertNode"); - + //this.window.focus(); var element = el.getNode(); if (!element){ @@ -502,7 +502,7 @@ // Assert that a specified node doesn't exist MozMillController.prototype.assertNodeNotExist = function (el) { logDeprecatedAssert("assertNodeNotExist"); - + //this.window.focus(); try { var element = el.getNode(); @@ -523,7 +523,7 @@ //Assert that a form element contains the expected value MozMillController.prototype.assertValue = function (el, value) { logDeprecatedAssert("assertValue"); - + //this.window.focus(); var n = el.getNode(); @@ -550,7 +550,7 @@ //Assert that a provided value is selected in a select element MozMillController.prototype.assertSelected = function (el, value) { logDeprecatedAssert("assertSelected"); - + //this.window.focus(); var n = el.getNode(); var validator = value; @@ -566,7 +566,7 @@ //Assert that a provided checkbox is checked MozMillController.prototype.assertChecked = function (el) { logDeprecatedAssert("assertChecked"); - + //this.window.focus(); var element = el.getNode(); @@ -581,7 +581,7 @@ // Assert that a provided checkbox is not checked MozMillController.prototype.assertNotChecked = function (el) { logDeprecatedAssert("assertNotChecked"); - + var element = el.getNode(); if (!element) { @@ -596,7 +596,7 @@ return false; }; -/** +/** * Assert that an element's javascript property exists or has a particular value * * if val is undefined, will return true if the property exists. @@ -604,7 +604,7 @@ */ MozMillController.prototype.assertJSProperty = function(el, attrib, val) { logDeprecatedAssert("assertJSProperty"); - + var element = el.getNode(); if (!element){ throw new Error("could not find element " + el.getInfo()); @@ -615,13 +615,13 @@ if (res) { broker.pass({'function':'Controller.assertJSProperty("' + el.getInfo() + '") : ' + val}); } else { - throw new Error("Controller.assertJSProperty(" + el.getInfo() + ") : " + + throw new Error("Controller.assertJSProperty(" + el.getInfo() + ") : " + (val === undefined ? "property '" + attrib + "' doesn't exist" : val + " == " + value)); } return res; }; -/** +/** * Assert that an element's javascript property doesn't exist or doesn't have a particular value * * if val is undefined, will return true if the property doesn't exist. @@ -629,7 +629,7 @@ */ MozMillController.prototype.assertNotJSProperty = function(el, attrib, val) { logDeprecatedAssert("assertNotJSProperty"); - + var element = el.getNode(); if (!element){ throw new Error("could not find element " + el.getInfo()); @@ -646,7 +646,7 @@ return res; }; -/** +/** * Assert that an element's dom property exists or has a particular value * * if val is undefined, will return true if the property exists. @@ -654,7 +654,7 @@ */ MozMillController.prototype.assertDOMProperty = function(el, attrib, val) { logDeprecatedAssert("assertDOMProperty"); - + var element = el.getNode(); if (!element){ throw new Error("could not find element " + el.getInfo()); @@ -664,18 +664,18 @@ if (res && val !== undefined) { value = element.getAttribute(attrib); res = (String(value) == String(val)); - } - + } + if (res) { broker.pass({'function':'Controller.assertDOMProperty("' + el.getInfo() + '") : ' + val}); } else { - throw new Error("Controller.assertDOMProperty(" + el.getInfo() + ") : " + + throw new Error("Controller.assertDOMProperty(" + el.getInfo() + ") : " + (val === undefined ? "property '" + attrib + "' doesn't exist" : val + " == " + value)); } return res; }; -/** +/** * Assert that an element's dom property doesn't exist or doesn't have a particular value * * if val is undefined, will return true if the property doesn't exist. @@ -683,7 +683,7 @@ */ MozMillController.prototype.assertNotDOMProperty = function(el, attrib, val) { logDeprecatedAssert("assertNotDOMProperty"); - + var element = el.getNode(); if (!element){ throw new Error("could not find element " + el.getInfo()); @@ -693,11 +693,11 @@ if (res && val !== undefined) { value = element.getAttribute(attrib); res = (String(value) == String(val)); - } + } if (!res) { broker.pass({'function':'Controller.assertNotDOMProperty("' + el.getInfo() + '") : ' + val}); } else { - throw new Error("Controller.assertNotDOMProperty(" + el.getInfo() + ") : " + + throw new Error("Controller.assertNotDOMProperty(" + el.getInfo() + ") : " + (val == undefined ? "property '" + attrib + "' exists" : val + " == " + value)); } return !res; @@ -720,7 +720,7 @@ // for broken images (in Safari only) but works reliably MozMillController.prototype.assertImageLoaded = function (el) { logDeprecatedAssert("assertImageLoaded"); - + //this.window.focus(); var img = el.getNode(); if (!img || img.tagName != 'IMG') { @@ -959,16 +959,16 @@ * Use the MozMillElement object instead (https://developer.mozilla.org/en/Mozmill/Mozmill_Element_Object) */ MozMillController.prototype.select = function (elem, index, option, value) { - return elem.select(index, option, value); + return elem.select(index, option, value); }; MozMillController.prototype.keypress = function(aTarget, aKey, aModifiers, aExpectedEvent) { - if (aTarget == null) { aTarget = this.windowElement; } + if (aTarget == null) { aTarget = this.rootElement; } return aTarget.keypress(aKey, aModifiers, aExpectedEvent); } MozMillController.prototype.type = function (aTarget, aText, aExpectedEvent) { - if (aTarget == null) { aTarget = this.windowElement; } + if (aTarget == null) { aTarget = this.rootElement; } var that = this; var retval = true; diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/peptest/extension/resource/mozmill/driver/mozelement.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/peptest/extension/resource/mozmill/driver/mozelement.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/peptest/extension/resource/mozmill/driver/mozelement.js 2012-02-21 02:10:20.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/peptest/extension/resource/mozmill/driver/mozelement.js 2012-02-22 02:09:56.000000000 +0000 @@ -36,7 +36,7 @@ * * ***** END LICENSE BLOCK ***** */ -var EXPORTED_SYMBOLS = ["Elem", "Selector", "ID", "Link", "XPath", "Name", "Lookup", +var EXPORTED_SYMBOLS = ["Elem", "Selector", "ID", "Link", "XPath", "Name", "Lookup", "MozMillElement", "MozMillCheckBox", "MozMillRadio", "MozMillDropList", "MozMillTextBox", "subclasses", ]; @@ -55,9 +55,10 @@ * Returns an new instance of a MozMillElement * The type of the element is automatically determined */ -function createInstance(locatorType, locator, elem) { +function createInstance(locatorType, locator, elem, document) { if (elem) { - var args = {"element":elem}; + var args = { "element": elem, + "document": document }; for (var i = 0; i < subclasses.length; ++i) { if (subclasses[i].isType(elem)) { return new subclasses[i](locatorType, locator, args); @@ -72,28 +73,28 @@ return createInstance("Elem", node, node); }; -var Selector = function(_document, selector, index) { - return createInstance("Selector", selector, elementslib.Selector(_document, selector, index)); +var Selector = function(document, selector, index) { + return createInstance("Selector", selector, elementslib.Selector(document, selector, index), document); }; -var ID = function(_document, nodeID) { - return createInstance("ID", nodeID, elementslib.ID(_document, nodeID)); +var ID = function(document, nodeID) { + return createInstance("ID", nodeID, elementslib.ID(document, nodeID), document); }; -var Link = function(_document, linkName) { - return createInstance("Link", linkName, elementslib.Link(_document, linkName)); +var Link = function(document, linkName) { + return createInstance("Link", linkName, elementslib.Link(document, linkName), document); }; -var XPath = function(_document, expr) { - return createInstance("XPath", expr, elementslib.XPath(_document, expr)); +var XPath = function(document, expr) { + return createInstance("XPath", expr, elementslib.XPath(document, expr), document); }; -var Name = function(_document, nName) { - return createInstance("Name", nName, elementslib.Name(_document, nName)); +var Name = function(document, nName) { + return createInstance("Name", nName, elementslib.Name(document, nName), document); }; -var Lookup = function(_document, expression) { - return createInstance("Lookup", expression, elementslib.Lookup(_document, expression)); +var Lookup = function(document, expression) { + return createInstance("Lookup", expression, elementslib.Lookup(document, expression), document); }; @@ -121,7 +122,7 @@ MozMillElement.prototype.__defineGetter__("element", function() { if (this._element == undefined) { if (elementslib[this._locatorType]) { - this._element = elementslib[this._locatorType](this._document, this._locator); + this._element = elementslib[this._locatorType](this._document, this._locator); } else if (this._locatorType == "Elem") { this._element = this._locator; } else { @@ -479,7 +480,7 @@ if (!this.element) { throw new Error("could not find element " + this.getInfo()); } - + if (this.element.localName.toLowerCase() == "radiogroup") { var element = this.element.getElementsByTagName("radio")[index || 0]; new MozMillRadio("Elem", element).click(); @@ -487,7 +488,7 @@ var element = this.element; this.click(); } - + utils.waitFor(function() { // If we have a XUL element, unwrap its XPCNativeWrapper if (element.namespaceURI == "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul") { @@ -581,7 +582,7 @@ this.element = utils.unwrapNode(this.element); // Get the list of menuitems menuitems = this.element.getElementsByTagName("menupopup")[0].getElementsByTagName("menuitem"); - + var item = null; if (indx != undefined) { diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/peptest/extension/resource/mozmill/stdlib/EventUtils.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/peptest/extension/resource/mozmill/stdlib/EventUtils.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/peptest/extension/resource/mozmill/stdlib/EventUtils.js 2012-02-21 02:10:21.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/peptest/extension/resource/mozmill/stdlib/EventUtils.js 2012-02-22 02:09:56.000000000 +0000 @@ -698,7 +698,7 @@ { var utils = _getDOMWindowUtils(aWindow); if (!utils) { - return nsnull; + return null; } return utils.sendQueryContentEvent(utils.QUERY_SELECTED_TEXT, 0, 0, 0, 0); } @@ -718,7 +718,7 @@ { var utils = _getDOMWindowUtils(aWindow); if (!utils) { - return nsnull; + return null; } return utils.sendQueryContentEvent(utils.QUERY_TEXT_CONTENT, aOffset, aLength, 0, 0); @@ -737,7 +737,7 @@ { var utils = _getDOMWindowUtils(aWindow); if (!utils) { - return nsnull; + return null; } return utils.sendQueryContentEvent(utils.QUERY_CARET_RECT, aOffset, 0, 0, 0); @@ -758,7 +758,7 @@ { var utils = _getDOMWindowUtils(aWindow); if (!utils) { - return nsnull; + return null; } return utils.sendQueryContentEvent(utils.QUERY_TEXT_RECT, aOffset, aLength, 0, 0); @@ -775,7 +775,7 @@ { var utils = _getDOMWindowUtils(aWindow); if (!utils) { - return nsnull; + return null; } return utils.sendQueryContentEvent(utils.QUERY_EDITOR_RECT, 0, 0, 0, 0); } @@ -792,7 +792,7 @@ { var utils = _getDOMWindowUtils(aWindow); if (!utils) { - return nsnull; + return null; } return utils.sendQueryContentEvent(utils.QUERY_CHARACTER_AT_POINT, 0, 0, aX, aY); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/peptest/extension/resource/pep/api.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/peptest/extension/resource/pep/api.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/peptest/extension/resource/pep/api.js 2012-02-21 02:10:21.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/peptest/extension/resource/pep/api.js 2012-02-22 02:09:56.000000000 +0000 @@ -37,38 +37,82 @@ var EXPORTED_SYMBOLS = ['PepAPI']; var results = {}; Components.utils.import('resource://pep/results.js', results); -var log = {}; Components.utils.import('resource://pep/logger.js', log); -var utils = {}; Components.utils.import('resource://pep/utils.js', utils); +var log = {}; Components.utils.import('resource://pep/logger.js', log); +var utils = {}; Components.utils.import('resource://pep/utils.js', utils); +var mozmill = {}; Components.utils.import('resource://mozmill/driver/mozmill.js', mozmill); +var securableModule = {}; +Components.utils.import('resource://mozmill/stdlib/securable-module.js', securableModule); const wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); + .getService(Components.interfaces.nsIWindowMediator); +const ios = Components.classes["@mozilla.org/network/io-service;1"] + .getService(Components.interfaces.nsIIOService); /** * This is the API exposed to tests - * Any properties of this object will be directly injected into test scope + * Any properties of this object will be injected into test scope + * under the 'pep' namespace. */ function PepAPI(test) { this.test = test; this.log = new Log(this.test.name); this.resultHandler = new results.ResultHandler(this.test.name); + + this.file = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + this.file.initWithPath(this.test.path); } +/** + * Performs an action during which responsiveness is measured + */ PepAPI.prototype.performAction = function(actionName, func) { this.resultHandler.startAction(actionName); func(); this.resultHandler.endAction(); }; +/** + * Returns the most recently used window of windowType + */ PepAPI.prototype.getWindow = function(windowType) { if (windowType === undefined) { windowType = "navigator:browser"; } - return wm.getMostRecentWindow(windowType); }; +/** + * Load a file on the local filesystem + * module - path on the local file of the module to load (no extension) + */ +PepAPI.prototype.require = function(module) { + let loader = new securableModule.Loader({ + rootPaths: [ios.newFileURI(this.file.parent).spec], + defaultPrincipal: "system", + globals: { Cc: Components.classes, + Ci: Components.interfaces, + Cr: Components.results, + Cu: Components.utils, + // mozmill scopes for compatibility with mozmill shared libraries + // https://developer.mozilla.org/en/Mozmill_Tests/Shared_Modules + mozmill: mozmill, + // quick hack to keep backwards compatibility with mozmill 1.5.x + elementslib: mozmill.findElement, + findElement: mozmill.findElement, + persisted: {}, + }, + }); + return loader.require(module); +}; + +/** + * Sleep for a number of milliseconds + */ PepAPI.prototype.sleep = function(milliseconds) { utils.sleep(milliseconds); }; -// Logging wrapper for tests +/** + * Logging wrapper for tests + */ function Log(testName) { this.testName = testName; } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/peptest/runpeptests.py firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/peptest/runpeptests.py --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/peptest/runpeptests.py 2012-02-21 02:10:21.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/peptest/runpeptests.py 2012-02-22 02:09:56.000000000 +0000 @@ -36,6 +36,7 @@ from optparse import OptionParser from mozprofile import FirefoxProfile, ThunderbirdProfile, Profile +from mozprofile.permissions import ServerLocations from mozrunner import FirefoxRunner, ThunderbirdRunner, Runner from mozhttpd import MozHttpd from manifestparser import TestManifest @@ -68,8 +69,22 @@ self.logger = mozlog.getLogger('PEP') # create the profile + enable_proxy = False + locations = ServerLocations() + if self.options.proxyLocations: + if not self.options.serverPath: + self.logger.warning('Can\'t set up proxy without server path') + else: + enable_proxy = True + locations.read(self.options.proxyLocations, False) + locations.add_host(host='127.0.0.1', + port=self.options.serverPort, + options='primary,privileged') + self.profile = self.profile_class(profile=self.options.profilePath, - addons=[os.path.join(here, 'extension')]) + addons=[os.path.join(here, 'extension')], + locations=locations, + proxy=enable_proxy) # fork a server to serve the test related files if self.options.serverPath: @@ -143,7 +158,8 @@ return self.logger.debug('Starting server on port ' + str(self.options.serverPort)) self.server = MozHttpd(port=self.options.serverPort, - docroot=self.options.serverPath) + docroot=self.options.serverPath, + proxy_host_dirs=self.options.proxyHostDirs) self.server.start(block=False) def stop(self): @@ -302,6 +318,20 @@ help="path to the profile to use. " "If none specified, a temporary profile is created") + self.add_option("--proxy", + action="store", type="string", dest="proxyLocations", + default=None, + help="path to a server-location file specifying " + "domains to proxy. --server-path must also be " + "specified.") + + self.add_option("--proxy-host-dirs", + action="store_true", dest="proxyHostDirs", + default=False, + help="proxied requests are served from directories " + "named by requested host. --proxy must also be " + "specified.") + self.add_option("--server-port", action="store", type="int", dest="serverPort", default=8888, diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/examples/example_tests.ini firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/examples/example_tests.ini --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/examples/example_tests.ini 2012-02-21 02:10:21.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/examples/example_tests.ini 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -[test_contextMenu.js] -[test_openBlankTab.js] -[test_openBookmarksMenu.js] -failThreshold = 40 -[test_searchGoogle.js] -[test_openWindow.js] -[test_resizeWindow.js] diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/examples/test_contextMenu.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/examples/test_contextMenu.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/examples/test_contextMenu.js 2012-02-21 02:10:21.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/examples/test_contextMenu.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is peptest. - * - * 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): - * Andrew Halberstadt - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - - -/** - * This test is designed to test responsiveness while performing actions - * on various context menus in both content and chrome. - */ - -// Import mozmill and initialize a controller -Components.utils.import("resource://mozmill/driver/mozmill.js"); -let c = getBrowserController(); - -// Open mozilla.org and wait for the page to load -c.open("http://mozilla.org"); -c.waitForPageLoad(); - -// Grab reference to element on page (this is the element in this case) -let page = findElement.ID(c.tabs.activeTab, 'header'); -// Perform our first action, reload. -// It is very important to only place things that we -// are interested in testing inside of a performAction call -pep.performAction('content_reload', function() { - page.rightClick(); - page.keypress('r'); -}); -c.waitForPageLoad(); - -c.open("http://google.com"); -c.waitForPageLoad(); - -page = findElement.ID(c.tabs.activeTab, 'main'); -// Perform our second action, go back -pep.performAction('content_back', function() { - page.rightClick(); - page.keypress('b'); -}); -// Bug 699400 - waitForPageLoad times out when pressing back button -c.sleep(100); - -page = findElement.ID(c.tabs.activeTab, 'home'); -// Perform our third action, scroll through context menu -pep.performAction('content_scroll', function() { - page.rightClick(); - for (let i = 0; i < 15; ++i) { - page.keypress('VK_DOWN'); - // Sleep to better emulate a user - c.sleep(10); - } -}); - -// Now test context menus in chrome -let bar = findElement.ID(c.window.document, "appmenu-toolbar-button"); -bar.click(); -pep.performAction('chrome_menu', function() { - bar.rightClick(); - bar.keypress('m'); -}); - -pep.performAction('chrome_addon', function() { - bar.rightClick(); - bar.keypress('a'); -}); - -pep.performAction('chrome_scroll', function() { - bar.rightClick(); - for (let i = 0; i < 15; ++i) { - page.keypress('VK_DOWN'); - // Sleep to better emulate a user - c.sleep(10); - } -}); - diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/examples/test_openBlankTab.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/examples/test_openBlankTab.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/examples/test_openBlankTab.js 2012-02-21 02:10:21.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/examples/test_openBlankTab.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is peptest. - * - * 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): - * Andrew Halberstadt - * - * 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 ***** */ - -// Initialize mozmill -Components.utils.import('resource://mozmill/driver/mozmill.js'); -let c = getBrowserController(); - -c.open('http://mozilla.org'); -c.waitForPageLoad(); - -// Only put things you want to test for responsiveness inside a perfom action call -let page = findElement.ID(c.tabs.activeTab, "home"); -pep.performAction('open_blank_tab', function() { - page.keypress('t', {'ctrlKey': true}); -}); - -pep.performAction('close_blank_tab', function() { - page.keypress('w', {'ctrlKey': true}); -}); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/examples/test_openBookmarksMenu.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/examples/test_openBookmarksMenu.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/examples/test_openBookmarksMenu.js 2012-02-21 02:10:21.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/examples/test_openBookmarksMenu.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is peptest. - * - * 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): - * Andrew Halberstadt - * - * 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 ***** */ - -// Import mozmill and initialize a controller -Components.utils.import('resource://mozmill/driver/mozmill.js'); -let c = getBrowserController(); - -c.open('http://mozilla.org'); -c.waitForPageLoad(); - -let bookmark = findElement.ID(c.window.document, "bookmarksMenu"); -pep.performAction('scroll_bookmarks', function() { - bookmark.click(); - for (let i = 0; i < 15; ++i) { - bookmark.keypress('VK_DOWN'); - // Sleep to better emulate a user - c.sleep(10); - } -}); - -let showall = findElement.ID(c.window.document, "bookmarksShowAll"); -pep.performAction('show_all_bookmarks', function() { - showall.click(); -}); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/examples/test_openWindow.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/examples/test_openWindow.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/examples/test_openWindow.js 2012-02-21 02:10:21.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/examples/test_openWindow.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is peptest. - * - * 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): - * Andrew Halberstadt - * - * 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 ***** */ - -// Import mozmill and initialize a controller -Components.utils.import("resource://mozmill/driver/mozmill.js"); -let controller = getBrowserController(); - -let win = findElement.ID(controller.window.document, 'main-window'); -pep.performAction("open_window", function() { - win.keypress("n", {"ctrlKey":true}); -}); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/examples/test_resizeWindow.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/examples/test_resizeWindow.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/examples/test_resizeWindow.js 2012-02-21 02:10:21.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/examples/test_resizeWindow.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is peptest. - * - * 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): - * Andrew Halberstadt - * - * 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 ***** */ - -// Most of the other example tests use Mozmill to perform various -// automation. Note that this is not necessary. -// -// This test will check responsiveness while resizing the window - -let window = pep.getWindow(); -let width = window.outerWidth; -let height = window.outerHeight; - -pep.performAction('resize_by', function() { - window.resizeBy(100, 100); -}); - -pep.performAction('resize_to', function() { - window.resizeTo(800, 600); -}); - -// Tests should clean up after themselves -window.resizeTo(width, height); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/examples/test_searchGoogle.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/examples/test_searchGoogle.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/examples/test_searchGoogle.js 2012-02-21 02:10:21.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/examples/test_searchGoogle.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is peptest. - * - * 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): - * Andrew Halberstadt - * - * 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 ***** */ - -// Import mozmill and initialize a controller -Components.utils.import("resource://mozmill/driver/mozmill.js"); -let controller = getBrowserController(); - -controller.open("http://google.ca"); -controller.waitForPageLoad(); - -let textbox = findElement.ID(controller.tabs.activeTab, 'lst-ib'); -let button = findElement.Name(controller.tabs.activeTab, 'btnK'); -pep.performAction('enterText', function() { - textbox.sendKeys('foobar'); - button.click(); -}); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/firefox_all.ini firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/firefox_all.ini --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/firefox_all.ini 2012-02-21 02:10:21.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/firefox_all.ini 2012-02-22 02:09:56.000000000 +0000 @@ -1,2 +1,6 @@ -# All Firefox tests - include other manifests here -[include:examples/example_tests.ini] +[test_contextMenu.js] +[test_openBlankTab.js] +[test_openBookmarksMenu.js] +failThreshold = 40 +[test_openWindow.js] +[test_resizeWindow.js] diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/server/index.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/server/index.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/server/index.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/server/index.html 2012-02-22 02:09:56.000000000 +0000 @@ -0,0 +1,6 @@ + + +This is a big test! + + + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/server/mozilla.org/index.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/server/mozilla.org/index.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/server/mozilla.org/index.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/server/mozilla.org/index.html 2012-02-22 02:09:56.000000000 +0000 @@ -0,0 +1,6 @@ + + +Test mozilla home page. + + + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/server/mozilla.org/index.html.orig firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/server/mozilla.org/index.html.orig --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/server/mozilla.org/index.html.orig 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/server/mozilla.org/index.html.orig 2012-02-22 02:09:56.000000000 +0000 @@ -0,0 +1,8 @@ + + + + + + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/server/mozillians.org/index.html firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/server/mozillians.org/index.html --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/server/mozillians.org/index.html 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/server/mozillians.org/index.html 2012-02-22 02:09:56.000000000 +0000 @@ -0,0 +1,6 @@ + + +Test mozillians home page. + + + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/server-locations.txt firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/server-locations.txt --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/server-locations.txt 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/server-locations.txt 2012-02-22 02:09:56.000000000 +0000 @@ -0,0 +1,3 @@ +http://mozilla.org privileged +http://mozillians.org privileged + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/test_contextMenu.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/test_contextMenu.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/test_contextMenu.js 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/test_contextMenu.js 2012-02-22 02:09:56.000000000 +0000 @@ -0,0 +1,106 @@ +/* ***** 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 peptest. + * + * 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): + * Andrew Halberstadt + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + + +/** + * This test is designed to test responsiveness while performing actions + * on various context menus in both content and chrome. + */ + +Components.utils.import("resource://mozmill/driver/mozmill.js"); +let c = getBrowserController(); + +// Open mozilla.org and wait for the page to load +c.open("http://mozilla.org"); +c.waitForPageLoad(); + +// Perform our first action, reload. +// It is very important to only place things that we +// are interested in testing inside of a performAction call +pep.performAction('content_reload', function() { + // controller.rootElement is the global window object + // wrapped inside of a MozMillElement + c.rootElement.rightClick(); + c.rootElement.keypress('r'); +}); +c.waitForPageLoad(); + +c.open("http://mozillians.org"); +c.waitForPageLoad(); + +// Perform our second action, go back +pep.performAction('content_back', function() { + c.rootElement.rightClick(); + c.rootElement.keypress('b'); +}); +// Bug 699400 - waitForPageLoad times out when pressing back button +c.sleep(500); + +// get a reference to the element with id 'home' +page = findElement.ID(c.tabs.activeTab, 'home'); +// Perform our third action, scroll through context menu +pep.performAction('content_scroll', function() { + page.rightClick(); + for (let i = 0; i < 15; ++i) { + page.keypress('VK_DOWN'); + // Sleep to better emulate a user + c.sleep(10); + } +}); + +// Now test context menus in chrome +let bar = findElement.ID(c.window.document, "appmenu-toolbar-button"); +bar.click(); +pep.performAction('chrome_menu', function() { + bar.rightClick(); + bar.keypress('m'); +}); + +pep.performAction('chrome_addon', function() { + bar.rightClick(); + bar.keypress('a'); +}); + +pep.performAction('chrome_scroll', function() { + bar.rightClick(); + for (let i = 0; i < 15; ++i) { + page.keypress('VK_DOWN'); + // Sleep to better emulate a user + c.sleep(10); + } +}); + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/test_openBlankTab.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/test_openBlankTab.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/test_openBlankTab.js 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/test_openBlankTab.js 2012-02-22 02:09:56.000000000 +0000 @@ -0,0 +1,52 @@ +/* ***** 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 peptest. + * + * 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): + * Andrew Halberstadt + * + * 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 ***** */ + +// Initialize mozmill +Components.utils.import('resource://mozmill/driver/mozmill.js'); +let c = getBrowserController(); + +c.open('http://mozilla.org'); +c.waitForPageLoad(); + +// Only put things you want to test for responsiveness inside a perfom action call +pep.performAction('open_blank_tab', function() { + c.rootElement.keypress('t', {'ctrlKey': true}); +}); + +pep.performAction('close_blank_tab', function() { + c.rootElement.keypress('w', {'ctrlKey': true}); +}); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/test_openBookmarksMenu.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/test_openBookmarksMenu.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/test_openBookmarksMenu.js 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/test_openBookmarksMenu.js 2012-02-22 02:09:56.000000000 +0000 @@ -0,0 +1,58 @@ +/* ***** 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 peptest. + * + * 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): + * Andrew Halberstadt + * + * 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 ***** */ + +// Import mozmill and initialize a controller +Components.utils.import('resource://mozmill/driver/mozmill.js'); +let c = getBrowserController(); + +c.open('http://mozilla.org'); +c.waitForPageLoad(); + +let bookmark = findElement.ID(c.window.document, "bookmarksMenu"); +pep.performAction('scroll_bookmarks', function() { + bookmark.click(); + for (let i = 0; i < 15; ++i) { + bookmark.keypress('VK_DOWN'); + // Sleep to better emulate a user + c.sleep(10); + } +}); + +let showall = findElement.ID(c.window.document, "bookmarksShowAll"); +pep.performAction('show_all_bookmarks', function() { + showall.click(); +}); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/test_openWindow.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/test_openWindow.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/test_openWindow.js 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/test_openWindow.js 2012-02-22 02:09:56.000000000 +0000 @@ -0,0 +1,44 @@ +/* ***** 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 peptest. + * + * 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): + * Andrew Halberstadt + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +Components.utils.import("resource://mozmill/driver/mozmill.js"); +let controller = getBrowserController(); + +let win = findElement.ID(controller.window.document, 'main-window'); +pep.performAction("open_window", function() { + win.keypress("n", {"ctrlKey":true}); +}); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/test_resizeWindow.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/test_resizeWindow.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/test_resizeWindow.js 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/test_resizeWindow.js 2012-02-22 02:09:56.000000000 +0000 @@ -0,0 +1,56 @@ +/* ***** 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 peptest. + * + * 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): + * Andrew Halberstadt + * + * 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 ***** */ + +// Most of the other example tests use Mozmill to perform various +// automation. Note that this is not necessary. +// +// This test will check responsiveness while resizing the window + +let window = pep.getWindow(); +let width = window.outerWidth; +let height = window.outerHeight; + +pep.performAction('resize_by', function() { + window.resizeBy(100, 100); +}); + +pep.performAction('resize_to', function() { + window.resizeTo(800, 600); +}); + +// Tests should clean up after themselves +window.resizeTo(width, height); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/test_searchGoogle.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/test_searchGoogle.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/peptest/tests/firefox/test_searchGoogle.js 1970-01-01 00:00:00.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/peptest/tests/firefox/test_searchGoogle.js 2012-02-22 02:09:56.000000000 +0000 @@ -0,0 +1,50 @@ +/* ***** 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 peptest. + * + * 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): + * Andrew Halberstadt + * + * 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 ***** */ + +// Import mozmill and initialize a controller +Components.utils.import("resource://mozmill/driver/mozmill.js"); +let controller = getBrowserController(); + +controller.open("http://google.com"); +controller.waitForPageLoad(); + +let textbox = findElement.ID(controller.tabs.activeTab, 'lst-ib'); +let button = findElement.Name(controller.tabs.activeTab, 'btnK'); +pep.performAction('enter_text', function() { + textbox.sendKeys('foobar'); + button.click(); +}); diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/testsuite-targets.mk firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/testsuite-targets.mk --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/testsuite-targets.mk 2012-02-21 02:10:21.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/testsuite-targets.mk 2012-02-22 02:09:57.000000000 +0000 @@ -65,6 +65,14 @@ rm -f ./$@.log && \ $(PYTHON) _tests/testing/mochitest/runtests.py --autorun --close-when-done \ --console-level=INFO --log-file=./$@.log --file-level=INFO \ + --failure-file=$(call core_abspath,_tests/testing/mochitest/makefailures.json) \ + $(SYMBOLS_PATH) $(TEST_PATH_ARG) $(EXTRA_TEST_ARGS) + +RERUN_MOCHITEST = \ + rm -f ./$@.log && \ + $(PYTHON) _tests/testing/mochitest/runtests.py --autorun --close-when-done \ + --console-level=INFO --log-file=./$@.log --file-level=INFO \ + --run-only-tests=makefailures.json \ $(SYMBOLS_PATH) $(TEST_PATH_ARG) $(EXTRA_TEST_ARGS) RUN_MOCHITEST_REMOTE = \ @@ -88,6 +96,7 @@ if test "$$errors" ; then \ echo "$@ failed:"; \ echo "$$errors"; \ + echo "To rerun your failures please run 'make mochitest-plain-rerun-failures'"; \ exit 1; \ else \ echo "$@ passed"; \ @@ -120,6 +129,10 @@ $(RUN_MOCHITEST) $(CHECK_TEST_ERROR) +mochitest-plain-rerun-failures: + $(RERUN_MOCHITEST) + $(CHECK_TEST_ERROR) + # Allow mochitest-1 ... mochitest-5 for developer ease mochitest-1 mochitest-2 mochitest-3 mochitest-4 mochitest-5: mochitest-%: echo "mochitest: $* / 5" @@ -258,8 +271,12 @@ # Runs peptest, for usage see: https://developer.mozilla.org/en/Peptest#Running_Tests RUN_PEPTEST = \ rm -f ./$@.log && \ - $(PYTHON) _tests/peptest/runtests.py --binary=$(browser_path) $(PEPTEST_PATH_ARG) \ - --log-file=./$@.log $(SYMBOLS_PATH) $(EXTRA_TEST_ARGS) + $(PYTHON) _tests/peptest/runtests.py --binary=$(browser_path) \ + $(PEPTEST_PATH_ARG) \ + --proxy=_tests/peptest/tests/firefox/server-locations.txt \ + --proxy-host-dirs \ + --server-path=_tests/peptest/tests/firefox/server \ + --log-file=./$@.log $(SYMBOLS_PATH) $(EXTRA_TEST_ARGS) peptest: $(RUN_PEPTEST) diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/xpcshell/xpcshell.ini firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/xpcshell/xpcshell.ini --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/testing/xpcshell/xpcshell.ini 2012-02-21 02:10:24.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/testing/xpcshell/xpcshell.ini 2012-02-22 02:09:57.000000000 +0000 @@ -8,6 +8,7 @@ [include:dom/plugins/test/unit/xpcshell.ini] [include:dom/sms/tests/xpcshell.ini] [include:dom/src/json/test/unit/xpcshell.ini] +[include:dom/system/b2g/tests/xpcshell.ini] [include:dom/tests/unit/xpcshell.ini] [include:dom/indexedDB/test/unit/xpcshell.ini] [include:content/xtf/test/unit/xpcshell.ini] diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/toolkit/components/aboutmemory/content/aboutMemory.css firefox-trunk-13.0~a1~hg20120222r87313/mozilla/toolkit/components/aboutmemory/content/aboutMemory.css --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/toolkit/components/aboutmemory/content/aboutMemory.css 2012-02-21 02:10:24.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/toolkit/components/aboutmemory/content/aboutMemory.css 2012-02-22 02:09:57.000000000 +0000 @@ -35,17 +35,19 @@ * * ***** END LICENSE BLOCK ***** */ +/* This file is used for both about:memory and about:compartments. */ + body.verbose { /* override setting in about.css */ max-width: 100% !important; } -body.non-verbose pre.tree { +body.non-verbose pre.entries { overflow-x: hidden; text-overflow: ellipsis; } -.sectionHeader { +h2 { background: #ddd; padding-left: .1em; } diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/toolkit/components/aboutmemory/content/aboutMemory.js firefox-trunk-13.0~a1~hg20120222r87313/mozilla/toolkit/components/aboutmemory/content/aboutMemory.js --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/toolkit/components/aboutmemory/content/aboutMemory.js 2012-02-21 02:10:24.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/toolkit/components/aboutmemory/content/aboutMemory.js 2012-02-22 02:09:57.000000000 +0000 @@ -36,16 +36,18 @@ * * ***** END LICENSE BLOCK ***** */ +// This file is used for both about:memory and about:compartments. + "use strict"; +//--------------------------------------------------------------------------- +// Code shared by about:memory and about:compartments +//--------------------------------------------------------------------------- + const Cc = Components.classes; const Ci = Components.interfaces; const Cu = Components.utils; -const gVerbose = location.href === "about:memory?verbose"; - -var gAddedObserver = false; - const KIND_NONHEAP = Ci.nsIMemoryReporter.KIND_NONHEAP; const KIND_HEAP = Ci.nsIMemoryReporter.KIND_HEAP; const KIND_OTHER = Ci.nsIMemoryReporter.KIND_OTHER; @@ -54,133 +56,97 @@ const UNITS_COUNT_CUMULATIVE = Ci.nsIMemoryReporter.UNITS_COUNT_CUMULATIVE; const UNITS_PERCENTAGE = Ci.nsIMemoryReporter.UNITS_PERCENTAGE; -const kUnknown = -1; // used for _amount if a memory reporter failed +// Because about:memory and about:compartments are non-standard URLs, +// location.search is undefined, so we have to use location.href here. +const gVerbose = location.href === "about:memory?verbose" || + location.href === "about:compartments?verbose"; + +let gChildMemoryListener = undefined; + +// This is a useful function and an efficient way to implement it. +String.prototype.startsWith = + function(s) { return this.lastIndexOf(s, 0) === 0; } + +//--------------------------------------------------------------------------- // Forward slashes in URLs in paths are represented with backslashes to avoid -// being mistaken for path separators. Paths/names/descriptions where this -// hasn't been undone are prefixed with "unsafe"; the rest are prefixed with -// "safe". -function makeSafe(aUnsafeStr) +// being mistaken for path separators. Paths/names where this hasn't been +// undone are prefixed with "unsafe"; the rest are prefixed with "safe". +function flipBackslashes(aUnsafeStr) { return aUnsafeStr.replace(/\\/g, '/'); } -const kTreeUnsafeDescriptions = { - 'explicit' : - "This tree covers explicit memory allocations by the application, " + - "both at the operating system level (via calls to functions such as " + - "VirtualAlloc, vm_allocate, and mmap), and at the heap allocation level " + - "(via functions such as malloc, calloc, realloc, memalign, operator " + - "new, and operator new[]). It excludes memory that is mapped implicitly " + - "such as code and data segments, and thread stacks. It also excludes " + - "heap memory that has been freed by the application but is still being " + - "held onto by the heap allocator. It is not guaranteed to cover every " + - "explicit allocation, but it does cover most (including the entire " + - "heap), and therefore it is the single best number to focus on when " + - "trying to reduce memory usage.", - - 'resident': - "This tree shows how much space in physical memory each of the " + - "process's mappings is currently using (the mapping's 'resident set size', " + - "or 'RSS'). This is a good measure of the 'cost' of the mapping, although " + - "it does not take into account the fact that shared libraries may be mapped " + - "by multiple processes but appear only once in physical memory. " + - "Note that the 'resident' value here might not equal the value for " + - "'resident' under 'Other Measurements' because the two measurements are not " + - "taken at exactly the same time.", - - 'pss': - "This tree shows how much space in physical memory can be 'blamed' on this " + - "process. For each mapping, its 'proportional set size' (PSS) is the " + - "mapping's resident size divided by the number of processes which use the " + - "mapping. So if a mapping is private to this process, its PSS should equal " + - "its RSS. But if a mapping is shared between three processes, its PSS in " + - "each of the processes would be 1/3 its RSS.", - - 'vsize': - "This tree shows how much virtual addres space each of the process's " + - "mappings takes up (the mapping's 'vsize'). A mapping may have a large " + - "vsize but use only a small amount of physical memory; the resident set size " + - "of a mapping is a better measure of the mapping's 'cost'. Note that the " + - "'vsize' value here might not equal the value for 'vsize' under 'Other " + - "Measurements' because the two measurements are not taken at exactly the " + - "same time.", +function assert(aCond, aMsg) +{ + if (!aCond) { + reportAssertionFailure(aMsg) + throw("aboutMemory.js assertion failed: " + aMsg); + } +} - 'swap': - "This tree shows how much space in the swap file each of the process's " + - "mappings is currently using. Mappings which are not in the swap file " + - "(i.e., nodes which would have a value of 0 in this tree) are omitted." -}; +function reportAssertionFailure(aMsg) +{ + var debug = Cc["@mozilla.org/xpcom/debug;1"].getService(Ci.nsIDebug2); + if (debug.isDebugBuild) { + debug.assertion(aMsg, "false", "aboutMemory.js", 0); + } +} -const kTreeNames = { - 'explicit': 'Explicit Allocations', - 'resident': 'Resident Set Size (RSS) Breakdown', - 'pss': 'Proportional Set Size (PSS) Breakdown', - 'vsize': 'Virtual Size Breakdown', - 'swap': 'Swap Usage Breakdown', - 'other': 'Other Measurements' -}; +function debug(x) +{ + appendElementWithText(document.body, "div", "legend", JSON.stringify(x)); +} -const kMapTreePaths = - ['smaps/resident', 'smaps/pss', 'smaps/vsize', 'smaps/swap']; +//--------------------------------------------------------------------------- -function onLoad() +function addChildObserversAndUpdate(aUpdateFn) { - var os = Cc["@mozilla.org/observer-service;1"]. + let os = Cc["@mozilla.org/observer-service;1"]. getService(Ci.nsIObserverService); os.notifyObservers(null, "child-memory-reporter-request", null); - os.addObserver(ChildMemoryListener, "child-memory-reporter-update", false); - gAddedObserver = true; + gChildMemoryListener = aUpdateFn; + os.addObserver(gChildMemoryListener, "child-memory-reporter-update", false); + + gChildMemoryListener(); +} - update(); +function onLoad() +{ + if (location.href.startsWith("about:memory")) { + document.title = "about:memory"; + onLoadAboutMemory(); + } else if (location.href.startsWith("about:compartments")) { + document.title = "about:compartments"; + onLoadAboutCompartments(); + } else { + assert(false, "Unknown location"); + } } function onUnload() { // We need to check if the observer has been added before removing; in some // circumstances (eg. reloading the page quickly) it might not have because - // onLoad might not fire. - if (gAddedObserver) { - var os = Cc["@mozilla.org/observer-service;1"]. + // onLoadAbout{Memory,Compartments} might not fire. + if (gChildMemoryListener) { + let os = Cc["@mozilla.org/observer-service;1"]. getService(Ci.nsIObserverService); - os.removeObserver(ChildMemoryListener, "child-memory-reporter-update"); + os.removeObserver(gChildMemoryListener, "child-memory-reporter-update"); } } -function ChildMemoryListener(aSubject, aTopic, aData) -{ - update(); -} - -function doGlobalGC() -{ - Cu.forceGC(); - var os = Cc["@mozilla.org/observer-service;1"] - .getService(Ci.nsIObserverService); - os.notifyObservers(null, "child-gc-request", null); - update(); -} - -function doCC() -{ - window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindowUtils) - .cycleCollect(); - var os = Cc["@mozilla.org/observer-service;1"] - .getService(Ci.nsIObserverService); - os.notifyObservers(null, "child-cc-request", null); - update(); -} - // For maximum effect, this returns to the event loop between each // notification. See bug 610166 comment 12 for an explanation. // Ideally a single notification would be enough. -function sendHeapMinNotifications() +function minimizeMemoryUsage3x(fAfter) { + let i = 0; + function runSoon(f) { - var tm = Cc["@mozilla.org/thread-manager;1"] + let tm = Cc["@mozilla.org/thread-manager;1"] .getService(Ci.nsIThreadManager); tm.mainThread.dispatch({ run: f }, Ci.nsIThread.DISPATCH_NORMAL); @@ -188,128 +154,98 @@ function sendHeapMinNotificationsInner() { - var os = Cc["@mozilla.org/observer-service;1"] + let os = Cc["@mozilla.org/observer-service;1"] .getService(Ci.nsIObserverService); os.notifyObservers(null, "memory-pressure", "heap-minimize"); - if (++j < 3) + if (++i < 3) runSoon(sendHeapMinNotificationsInner); else - runSoon(update); + runSoon(fAfter); } - var j = 0; sendHeapMinNotificationsInner(); } -function Reporter(aUnsafePath, aKind, aUnits, aAmount, aUnsafeDesc) -{ - this._unsafePath = aUnsafePath; - this._kind = aKind; - this._units = aUnits; - this._amount = aAmount; - this._unsafeDescription = aUnsafeDesc; - // this._nMerged is only defined if > 1 - // this._done is defined and set to true when the reporter's amount is read -} - -Reporter.prototype = { - // Sum the values (accounting for possible kUnknown amounts), and mark |this| - // as a dup. We mark dups because it's useful to know when a reporter is - // duplicated; it might be worth investigating and splitting up to have - // non-duplicated names. - merge: function(r) { - if (this._amount !== kUnknown && r._amount !== kUnknown) { - this._amount += r._amount; - } else if (this._amount === kUnknown && r._amount !== kUnknown) { - this._amount = r._amount; - } - this._nMerged = this._nMerged ? this._nMerged + 1 : 2; - }, - - treeNameMatches: function(aTreeName) { - // Nb: the '/' must be present, because we have a KIND_OTHER reporter - // called "explicit" which is not part of the "explicit" tree. - return this._unsafePath.indexOf(aTreeName) === 0 && - this._unsafePath.charAt(aTreeName.length) === '/'; - } -}; - -function getReportersByProcess(aMgr) +//--------------------------------------------------------------------------- + +/** + * Iterates over each reporter and multi-reporter. + * + * @param aMgr + * The memory reporter manager. + * @param aIgnoreSingle + * Function that indicates if we should skip a single reporter, based + * on its path. + * @param aIgnoreMulti + * Function that indicates if we should skip a multi-reporter, based on + * its name. + * @param aHandleReport + * The function that's called for each report. + */ +function processMemoryReporters(aMgr, aIgnoreSingle, aIgnoreMulti, + aHandleReport) { - // Process each memory reporter: - // - Make a copy of it into a sub-table indexed by its process. Each copy - // is a Reporter object. After this point we never use the original memory - // reporter again. + // Process each memory reporter with aHandleReport. // // - Note that copying rOrig.amount (which calls a C++ function under the // IDL covers) to r._amount for every reporter now means that the // results as consistent as possible -- measurements are made all at // once before most of the memory required to generate this page is // allocated. - var reportersByProcess = {}; - - function addReporter(aProcess, aUnsafePath, aKind, aUnits, aAmount, - aUnsafeDesc) - { - var process = aProcess === "" ? "Main" : aProcess; - var r = new Reporter(aUnsafePath, aKind, aUnits, aAmount, aUnsafeDesc); - if (!reportersByProcess[process]) { - reportersByProcess[process] = {}; - } - var reporters = reportersByProcess[process]; - var reporter = reporters[r._unsafePath]; - if (reporter) { - // Already an entry; must be a duplicated reporter. This can happen - // legitimately. Merge them. - reporter.merge(r); - } else { - reporters[r._unsafePath] = r; - } - } + // + // - After this point we never use the original memory report again. - // Process vanilla reporters first, then multi-reporters. - var e = aMgr.enumerateReporters(); + let e = aMgr.enumerateReporters(); while (e.hasMoreElements()) { - var rOrig = e.getNext().QueryInterface(Ci.nsIMemoryReporter); + let rOrig = e.getNext().QueryInterface(Ci.nsIMemoryReporter); + let unsafePath = rOrig.path; try { - addReporter(rOrig.process, rOrig.path, rOrig.kind, rOrig.units, - rOrig.amount, rOrig.description); + if (!aIgnoreSingle(unsafePath)) { + aHandleReport(rOrig.process, unsafePath, rOrig.kind, rOrig.units, + rOrig.amount, rOrig.description); + } } - catch(e) { - debug("An error occurred when collecting results from the memory reporter " + - rOrig.path + ": " + e); + catch (e) { + debug("Bad memory reporter " + unsafePath + ": " + e); } } - var e = aMgr.enumerateMultiReporters(); + let e = aMgr.enumerateMultiReporters(); while (e.hasMoreElements()) { - var mrOrig = e.getNext().QueryInterface(Ci.nsIMemoryMultiReporter); - // Ignore the "smaps" reporters in non-verbose mode. - if (!gVerbose && mrOrig.name === "smaps") { - continue; - } - + let mrOrig = e.getNext().QueryInterface(Ci.nsIMemoryMultiReporter); + let name = mrOrig.name; try { - mrOrig.collectReports(addReporter, null); + if (!aIgnoreMulti(name)) { + mrOrig.collectReports(aHandleReport, null); + } } - catch(e) { - debug("An error occurred when collecting a multi-reporter's results: " + e); + catch (e) { + debug("Bad memory multi-reporter " + name + ": " + e); } } +} + +//--------------------------------------------------------------------------- - return reportersByProcess; +function clearBody() +{ + let oldBody = document.body; + let body = oldBody.cloneNode(false); + oldBody.parentNode.replaceChild(body, oldBody); + body.classList.add(gVerbose ? 'verbose' : 'non-verbose'); + return body; } function appendTextNode(aP, aText) { - var e = document.createTextNode(aText); + let e = document.createTextNode(aText); aP.appendChild(e); return e; } function appendElement(aP, aTagName, aClassName) { - var e = document.createElement(aTagName); + let e = document.createElement(aTagName); if (aClassName) { e.className = aClassName; } @@ -319,40 +255,135 @@ function appendElementWithText(aP, aTagName, aClassName, aText) { - var e = appendElement(aP, aTagName, aClassName); + let e = appendElement(aP, aTagName, aClassName); appendTextNode(e, aText); return e; } +//--------------------------------------------------------------------------- +// Code specific to about:memory +//--------------------------------------------------------------------------- + +const kUnknown = -1; // used for an unknown _amount + +const kTreeDescriptions = { + 'explicit' : +"This tree covers explicit memory allocations by the application, both at the \ +operating system level (via calls to functions such as VirtualAlloc, \ +vm_allocate, and mmap), and at the heap allocation level (via functions such \ +as malloc, calloc, realloc, memalign, operator new, and operator new[]).\ +\n\n\ +It excludes memory that is mapped implicitly such as code and data segments, \ +and thread stacks. It also excludes heap memory that has been freed by the \ +application but is still being held onto by the heap allocator. \ +\n\n\ +It is not guaranteed to cover every explicit allocation, but it does cover \ +most (including the entire heap), and therefore it is the single best number \ +to focus on when trying to reduce memory usage.", + + 'resident': +"This tree shows how much space in physical memory each of the process's \ +mappings is currently using (the mapping's 'resident set size', or 'RSS'). \ +This is a good measure of the 'cost' of the mapping, although it does not \ +take into account the fact that shared libraries may be mapped by multiple \ +processes but appear only once in physical memory. \ +\n\n\ +Note that the 'resident' value here might not equal the value for 'resident' \ +under 'Other Measurements' because the two measurements are not taken at \ +exactly the same time.", + + 'pss': +"This tree shows how much space in physical memory can be 'blamed' on this \ +process. For each mapping, its 'proportional set size' (PSS) is the \ +mapping's resident size divided by the number of processes which use the \ +mapping. So if a mapping is private to this process, its PSS should equal \ +its RSS. But if a mapping is shared between three processes, its PSS in each \ +of the processes would be 1/3 its RSS.", + + 'vsize': +"This tree shows how much virtual addres space each of the process's mappings \ +takes up (the mapping's 'vsize'). A mapping may have a large vsize but use \ +only a small amount of physical memory; the resident set size of a mapping is \ +a better measure of the mapping's 'cost'. \ +\n\n\ +Note that the 'vsize' value here might not equal the value for 'vsize' under \ +'Other Measurements' because the two measurements are not taken at exactly \ +the same time.", + + 'swap': +"This tree shows how much space in the swap file each of the process's \ +mappings is currently using. Mappings which are not in the swap file (i.e., \ +nodes which would have a value of 0 in this tree) are omitted." +}; + +const kTreeNames = { + 'explicit': 'Explicit Allocations', + 'resident': 'Resident Set Size (RSS) Breakdown', + 'pss': 'Proportional Set Size (PSS) Breakdown', + 'vsize': 'Virtual Size Breakdown', + 'swap': 'Swap Usage Breakdown', + 'other': 'Other Measurements' +}; + +const kMapTreePaths = + ['smaps/resident', 'smaps/pss', 'smaps/vsize', 'smaps/swap']; + +//--------------------------------------------------------------------------- + +function onLoadAboutMemory() +{ + addChildObserversAndUpdate(updateAboutMemory); +} + +function doGlobalGC() +{ + Cu.forceGC(); + let os = Cc["@mozilla.org/observer-service;1"] + .getService(Ci.nsIObserverService); + os.notifyObservers(null, "child-gc-request", null); + updateAboutMemory(); +} + +function doCC() +{ + window.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindowUtils) + .cycleCollect(); + let os = Cc["@mozilla.org/observer-service;1"] + .getService(Ci.nsIObserverService); + os.notifyObservers(null, "child-cc-request", null); + updateAboutMemory(); +} + +//--------------------------------------------------------------------------- + /** * Top-level function that does the work of generating the page. */ -function update() +function updateAboutMemory() { - // First, clear the page contents. Necessary because update() might be - // called more than once due to ChildMemoryListener. - var oldContent = document.getElementById("content"); - var content = oldContent.cloneNode(false); - oldContent.parentNode.replaceChild(content, oldContent); - content.classList.add(gVerbose ? 'verbose' : 'non-verbose'); + // First, clear the page contents. Necessary because updateAboutMemory() + // might be called more than once due to the "child-memory-reporter-update" + // observer. + let body = clearBody(); - var mgr = Cc["@mozilla.org/memory-reporter-manager;1"]. + let mgr = Cc["@mozilla.org/memory-reporter-manager;1"]. getService(Ci.nsIMemoryReporterManager); // Generate output for one process at a time. Always start with the // Main process. - var reportersByProcess = getReportersByProcess(mgr); - var hasMozMallocUsableSize = mgr.hasMozMallocUsableSize; - appendProcessElements(content, "Main", reportersByProcess["Main"], - hasMozMallocUsableSize); - for (var process in reportersByProcess) { + let reportsByProcess = getReportsByProcess(mgr); + let hasMozMallocUsableSize = mgr.hasMozMallocUsableSize; + appendProcessReportsElements(body, "Main", reportsByProcess["Main"], + hasMozMallocUsableSize); + for (let process in reportsByProcess) { if (process !== "Main") { - appendProcessElements(content, process, reportersByProcess[process], - hasMozMallocUsableSize); + appendProcessReportsElements(body, process, reportsByProcess[process], + hasMozMallocUsableSize); } } - appendElement(content, "hr"); + appendElement(body, "hr"); // Memory-related actions. const UpDesc = "Re-measure."; @@ -366,7 +397,7 @@ function appendButton(aTitle, aOnClick, aText, aId) { - var b = appendElementWithText(content, "button", "", aText); + let b = appendElementWithText(body, "button", "", aText); b.title = aTitle; b.onclick = aOnClick if (aId) { @@ -375,36 +406,119 @@ } // The "Update" button has an id so it can be clicked in a test. - appendButton(UpDesc, update, "Update", "updateButton"); - appendButton(GCDesc, doGlobalGC, "GC"); - appendButton(CCDesc, doCC, "CC"); - appendButton(MPDesc, sendHeapMinNotifications, "Minimize memory usage"); + appendButton(UpDesc, updateAboutMemory, "Update", "updateButton"); + appendButton(GCDesc, doGlobalGC, "GC"); + appendButton(CCDesc, doCC, "CC"); + appendButton(MPDesc, function() { minimizeMemoryUsage3x(updateAboutMemory); }, + "Minimize memory usage"); - var div1 = appendElement(content, "div"); - var a; + let div1 = appendElement(body, "div"); if (gVerbose) { - var a = appendElementWithText(div1, "a", "option", "Less verbose"); + let a = appendElementWithText(div1, "a", "option", "Less verbose"); a.href = "about:memory"; } else { - var a = appendElementWithText(div1, "a", "option", "More verbose"); + let a = appendElementWithText(div1, "a", "option", "More verbose"); a.href = "about:memory?verbose"; } - var div2 = appendElement(content, "div"); - a = appendElementWithText(div2, "a", "option", "Troubleshooting information"); + let div2 = appendElement(body, "div"); + let a = appendElementWithText(div2, "a", "option", + "Troubleshooting information"); a.href = "about:support"; - var legendText1 = "Click on a non-leaf node in a tree to expand ('++') " + + let legendText1 = "Click on a non-leaf node in a tree to expand ('++') " + "or collapse ('--') its children."; - var legendText2 = "Hover the pointer over the name of a memory reporter " + + let legendText2 = "Hover the pointer over the name of a memory report " + "to see a description of what it measures."; - appendElementWithText(content, "div", "legend", legendText1); - appendElementWithText(content, "div", "legend", legendText2); + appendElementWithText(body, "div", "legend", legendText1); + appendElementWithText(body, "div", "legend", legendText2); +} + +//--------------------------------------------------------------------------- + +function Report(aUnsafePath, aKind, aUnits, aAmount, aDescription) +{ + this._unsafePath = aUnsafePath; + this._kind = aKind; + this._units = aUnits; + this._amount = aAmount; + this._description = aDescription; + // this._nMerged is only defined if > 1 + // this._done is defined and set to true when the Report's amount is read } +Report.prototype = { + // Sum the values (accounting for possible kUnknown amounts), and mark |this| + // as a dup. We mark dups because it's useful to know when a report is + // duplicated; it might be worth investigating and splitting up to have + // non-duplicated names. + merge: function(r) { + if (this._amount !== kUnknown && r._amount !== kUnknown) { + this._amount += r._amount; + } else if (this._amount === kUnknown && r._amount !== kUnknown) { + this._amount = r._amount; + } + this._nMerged = this._nMerged ? this._nMerged + 1 : 2; + }, + + treeNameMatches: function(aTreeName) { + // Nb: the '/' must be present, because we have a KIND_OTHER reporter + // called "explicit" which is not part of the "explicit" tree. + return this._unsafePath.startsWith(aTreeName) && + this._unsafePath.charAt(aTreeName.length) === '/'; + } +}; + +function getReportsByProcess(aMgr) +{ + // Ignore the "smaps" multi-reporter in non-verbose mode, and the + // "compartments" multi-reporter all the time. (Note that reports from these + // multi-reporters can reach here as single reports if they were in the child + // process.) + + function ignoreSingle(aPath) + { + return (aPath.startsWith("smaps/") && !gVerbose) || + (aPath.startsWith("compartments/")) + } + + function ignoreMulti(aName) + { + return ((aName === "smaps" && !gVerbose) || + (aName === "compartments")); + } + + let reportsByProcess = {}; + + function handleReport(aProcess, aUnsafePath, aKind, aUnits, aAmount, + aDescription) + { + let process = aProcess === "" ? "Main" : aProcess; + let r = new Report(aUnsafePath, aKind, aUnits, aAmount, aDescription); + if (!reportsByProcess[process]) { + reportsByProcess[process] = {}; + } + let reports = reportsByProcess[process]; + let rOld = reports[r._unsafePath]; + if (rOld) { + // Already an entry; must be a duplicated report. This can happen + // legitimately. Merge them. + rOld.merge(r); + } else { + reports[r._unsafePath] = r; + } + } + + processMemoryReporters(aMgr, ignoreSingle, ignoreMulti, handleReport); + + return reportsByProcess; +} + +//--------------------------------------------------------------------------- + // There are two kinds of TreeNode. -// - Leaf TreeNodes correspond to Reporters and have more properties. +// - Leaf TreeNodes correspond to Reports and have more properties. // - Non-leaf TreeNodes are just scaffolding nodes for the tree; their values // are derived from their children. function TreeNode(aUnsafeName) @@ -414,20 +528,20 @@ this._kids = []; // Leaf TreeNodes have these properties added immediately after construction: // - _amount (which is never |kUnknown|) - // - _unsafeDescription + // - _description // - _kind // - _nMerged (only defined if > 1) // - _isUnknown (only defined if true) // // Non-leaf TreeNodes have these properties added later: // - _amount (which is never |kUnknown|) - // - _unsafeDescription + // - _description // - _hideKids (only defined if true) } TreeNode.prototype = { findKid: function(aUnsafeName) { - for (var i = 0; i < this._kids.length; i++) { + for (let i = 0; i < this._kids.length; i++) { if (this._kids[i]._unsafeName === aUnsafeName) { return this._kids[i]; } @@ -445,65 +559,65 @@ }; /** - * From a list of memory reporters, builds a tree that mirrors the tree - * structure that will be shown as output. + * From a table of Reports, builds a tree that mirrors the tree structure that + * will be shown as output. * - * @param aReporters - * The table of Reporters, indexed by _unsafePath. + * @param aReports + * The table of Reports, indexed by _unsafePath. * @param aTreeName * The name of the tree being built. * @return The built tree. */ -function buildTree(aReporters, aTreeName) +function buildTree(aReports, aTreeName) { - // We want to process all reporters that begin with |aTreeName|. First we + // We want to process all reports that begin with |aTreeName|. First we // build the tree but only fill the properties that we can with a top-down // traversal. - // There should always be at least one matching reporter when |aTreeName| is - // "explicit". But there may be zero for "smaps" trees; if that happens, - // bail. - var foundReporter = false; - for (var unsafePath in aReporters) { - if (aReporters[unsafePath].treeNameMatches(aTreeName)) { - foundReporter = true; + // There should always be at least one matching Report object when + // |aTreeName| is "explicit". But there may be zero for "smaps" trees; if + // that happens, bail. + let foundReport = false; + for (let unsafePath in aReports) { + if (aReports[unsafePath].treeNameMatches(aTreeName)) { + foundReport = true; break; } } - if (!foundReporter) { - assert(aTreeName !== 'explicit'); + if (!foundReport) { + assert(aTreeName !== 'explicit', "aTreeName !== 'explicit'"); return null; } - var t = new TreeNode("falseRoot"); - for (var unsafePath in aReporters) { + let t = new TreeNode("falseRoot"); + for (let unsafePath in aReports) { // Add any missing nodes in the tree implied by the unsafePath. - var r = aReporters[unsafePath]; + let r = aReports[unsafePath]; if (r.treeNameMatches(aTreeName)) { assert(r._kind === KIND_HEAP || r._kind === KIND_NONHEAP, - "reporters in the tree must have KIND_HEAP or KIND_NONHEAP"); + "reports in the tree must have KIND_HEAP or KIND_NONHEAP"); assert(r._units === UNITS_BYTES, "r._units === UNITS_BYTES"); - var unsafeNames = r._unsafePath.split('/'); - var u = t; - for (var i = 0; i < unsafeNames.length; i++) { - var unsafeName = unsafeNames[i]; - var uMatch = u.findKid(unsafeName); + let unsafeNames = r._unsafePath.split('/'); + let u = t; + for (let i = 0; i < unsafeNames.length; i++) { + let unsafeName = unsafeNames[i]; + let uMatch = u.findKid(unsafeName); if (uMatch) { u = uMatch; } else { - var v = new TreeNode(unsafeName); + let v = new TreeNode(unsafeName); u._kids.push(v); u = v; } } - // Fill in extra details in the leaf node from the Reporter. + // Fill in extra details in the leaf node from the Report object. if (r._amount !== kUnknown) { u._amount = r._amount; } else { u._amount = 0; u._isUnknown = true; } - u._unsafeDescription = r._unsafeDescription; + u._description = r._description; u._kind = r._kind; if (r._nMerged) { u._nMerged = r._nMerged; @@ -524,16 +638,16 @@ // Leaf node. Has already been filled in. assert(aT._kind !== undefined, "aT._kind is undefined for leaf node"); } else { - // Non-leaf node. Derive its _amount and _unsafeDescription entirely + // Non-leaf node. Derive its _amount and _description entirely // from its children. assert(aT._kind === undefined, "aT._kind is defined for non-leaf node"); - var childrenBytes = 0; - for (var i = 0; i < aT._kids.length; i++) { + let childrenBytes = 0; + for (let i = 0; i < aT._kids.length; i++) { childrenBytes += fillInNonLeafNodes(aT._kids[i]); } aT._amount = childrenBytes; - aT._unsafeDescription = - "The sum of all entries below '" + aT._unsafeName + "'."; + aT._description = "The sum of all entries below '" + + flipBackslashes(aT._unsafeName) + "'."; } assert(aT._amount !== kUnknown, "aT._amount !== kUnknown"); return aT._amount; @@ -543,8 +657,8 @@ // Reduce the depth of the tree by the number of occurrences of '/' in // aTreeName. (Thus the tree named 'foo/bar/baz' will be rooted at 'baz'.) - var slashCount = 0; - for (var i = 0; i < aTreeName.length; i++) { + let slashCount = 0; + for (let i = 0; i < aTreeName.length; i++) { if (aTreeName[i] == '/') { assert(t._kids.length == 1, "Not expecting multiple kids here."); t = t._kids[0]; @@ -552,7 +666,7 @@ } // Set the (unsafe) description on the root node. - t._unsafeDescription = kTreeUnsafeDescriptions[t._unsafeName]; + t._description = kTreeDescriptions[t._unsafeName]; return t; } @@ -561,13 +675,13 @@ * Ignore all the memory reports that belong to a "smaps" tree; this involves * explicitly marking them as done. * - * @param aReporters - * The table of Reporters, indexed by _unsafePath. + * @param aReports + * The table of Reports, indexed by _unsafePath. */ -function ignoreSmapsTrees(aReporters) +function ignoreSmapsTrees(aReports) { - for (var unsafePath in aReporters) { - var r = aReporters[unsafePath]; + for (let unsafePath in aReports) { + let r = aReports[unsafePath]; if (r.treeNameMatches("smaps")) { r._done = true; } @@ -579,22 +693,22 @@ * * @param aT * The tree. - * @param aReporters - * Table of Reporters for this process, indexed by _unsafePath. + * @param aReports + * Table of Reports for this process, indexed by _unsafePath. * @return A boolean indicating if "heap-allocated" is known for the process. */ -function fixUpExplicitTree(aT, aReporters) +function fixUpExplicitTree(aT, aReports) { - // Determine how many bytes are reported by heap reporters. + // Determine how many bytes are in heap reports. function getKnownHeapUsedBytes(aT) { - var n = 0; + let n = 0; if (aT._kids.length === 0) { // Leaf node. assert(aT._kind !== undefined, "aT._kind is undefined for leaf node"); n = aT._kind === KIND_HEAP ? aT._amount : 0; } else { - for (var i = 0; i < aT._kids.length; i++) { + for (let i = 0; i < aT._kids.length; i++) { n += getKnownHeapUsedBytes(aT._kids[i]); } } @@ -604,11 +718,11 @@ // A special case: compute the derived "heap-unclassified" value. Don't // mark "heap-allocated" when we get its size because we want it to appear // in the "Other Measurements" list. - var heapAllocatedReporter = aReporters["heap-allocated"]; - assert(heapAllocatedReporter, "no 'heap-allocated' reporter"); - var heapAllocatedBytes = heapAllocatedReporter._amount; - var heapUnclassifiedT = new TreeNode("heap-unclassified"); - var hasKnownHeapAllocated = heapAllocatedBytes !== kUnknown; + let heapAllocatedReport = aReports["heap-allocated"]; + assert(heapAllocatedReport, "no 'heap-allocated' report"); + let heapAllocatedBytes = heapAllocatedReport._amount; + let heapUnclassifiedT = new TreeNode("heap-unclassified"); + let hasKnownHeapAllocated = heapAllocatedBytes !== kUnknown; if (hasKnownHeapAllocated) { heapUnclassifiedT._amount = heapAllocatedBytes - getKnownHeapUsedBytes(aT); @@ -618,8 +732,8 @@ } // This kindToString() ensures the "(Heap)" prefix is set without having to // set the _kind property, which would mean that there is a corresponding - // Reporter for this TreeNode (which isn't true) - heapUnclassifiedT._unsafeDescription = kindToString(KIND_HEAP) + + // Report object for this TreeNode object (which isn't true) + heapUnclassifiedT._description = kindToString(KIND_HEAP) + "Memory not classified by a more specific reporter. This includes " + "slop bytes due to internal fragmentation in the heap allocator " + "(caused when the allocator rounds up request sizes)."; @@ -661,29 +775,30 @@ // _hideKids property and process all children. if (isInsignificant(aT._kids[0])) { aT._hideKids = true; - for (var i = 0; i < aT._kids.length; i++) { + for (let i = 0; i < aT._kids.length; i++) { sortTreeAndInsertAggregateNodes(aTotalBytes, aT._kids[i]); } return; } // Look at all children except the last one. - for (var i = 0; i < aT._kids.length - 1; i++) { + let i; + for (i = 0; i < aT._kids.length - 1; i++) { if (isInsignificant(aT._kids[i])) { // This child is below the significance threshold. If there are other // (smaller) children remaining, move them under an aggregate node. - var i0 = i; - var nAgg = aT._kids.length - i0; + let i0 = i; + let nAgg = aT._kids.length - i0; // Create an aggregate node. - var aggT = new TreeNode("(" + nAgg + " tiny)"); - var aggBytes = 0; + let aggT = new TreeNode("(" + nAgg + " tiny)"); + let aggBytes = 0; for ( ; i < aT._kids.length; i++) { aggBytes += aT._kids[i]._amount; aggT._kids.push(aT._kids[i]); } aggT._hideKids = true; aggT._amount = aggBytes; - aggT._unsafeDescription = + aggT._description = nAgg + " sub-trees that are below the " + kSignificanceThresholdPerc + "% significance threshold."; aT._kids.splice(i0, nAgg, aggT); @@ -706,9 +821,9 @@ } // Global variable indicating if we've seen any invalid values for this -// process; it holds the unsafePaths of any such reporters. It is reset for +// process; it holds the unsafePaths of any such reports. It is reset for // each new process. -var gUnsafePathsWithInvalidValuesForThisProcess = []; +let gUnsafePathsWithInvalidValuesForThisProcess = []; function appendWarningElements(aP, aHasKnownHeapAllocated, aHasMozMallocUsableSize) @@ -738,19 +853,19 @@ } if (gUnsafePathsWithInvalidValuesForThisProcess.length > 0) { - var div = appendElement(aP, "div"); + let div = appendElement(aP, "div"); appendElementWithText(div, "p", "", "WARNING: the following values are negative or unreasonably large."); appendTextNode(div, "\n"); - var ul = appendElement(div, "ul"); - for (var i = 0; + let ul = appendElement(div, "ul"); + for (let i = 0; i < gUnsafePathsWithInvalidValuesForThisProcess.length; i++) { appendTextNode(ul, " "); appendElementWithText(ul, "li", "", - makeSafe(gUnsafePathsWithInvalidValuesForThisProcess[i])); + flipBackslashes(gUnsafePathsWithInvalidValuesForThisProcess[i])); appendTextNode(ul, "\n"); } @@ -763,38 +878,38 @@ } /** - * Appends the elements for a single process. + * Appends the elements for a single process's Reports. * * @param aP * The parent DOM node. * @param aProcess * The name of the process. - * @param aReporters - * Table of Reporters for this process, indexed by _unsafePath. + * @param aReports + * Table of Reports for this process, indexed by _unsafePath. * @param aHasMozMallocUsableSize * Boolean indicating if moz_malloc_usable_size works. * @return The generated text. */ -function appendProcessElements(aP, aProcess, aReporters, - aHasMozMallocUsableSize) +function appendProcessReportsElements(aP, aProcess, aReports, + aHasMozMallocUsableSize) { appendElementWithText(aP, "h1", "", aProcess + " Process"); appendTextNode(aP, "\n\n"); // gives nice spacing when we cut and paste // We'll fill this in later. - var warningsDiv = appendElement(aP, "div", "accuracyWarning"); + let warningsDiv = appendElement(aP, "div", "accuracyWarning"); - var explicitTree = buildTree(aReporters, 'explicit'); - var hasKnownHeapAllocated = fixUpExplicitTree(explicitTree, aReporters); + let explicitTree = buildTree(aReports, 'explicit'); + let hasKnownHeapAllocated = fixUpExplicitTree(explicitTree, aReports); sortTreeAndInsertAggregateNodes(explicitTree._amount, explicitTree); appendTreeElements(aP, explicitTree, aProcess); // We only show these breakdown trees in verbose mode. if (gVerbose) { kMapTreePaths.forEach(function(t) { - var tree = buildTree(aReporters, t); + let tree = buildTree(aReports, t); - // |tree| will be null if we don't have any reporters for the given + // |tree| will be null if we don't have any reports for the given // unsafePath. if (tree) { sortTreeAndInsertAggregateNodes(tree._amount, tree); @@ -803,15 +918,15 @@ } }); } else { - // Although we skip the "smaps" multi-reporter in getReportersByProcess(), + // Although we skip the "smaps" multi-reporter in getReportsByProcess(), // we might get some smaps reports from a child process, and they must be // explicitly ignored. - ignoreSmapsTrees(aReporters); + ignoreSmapsTrees(aReports); } // We have to call appendOtherElements after we process all the trees, - // because it looks at all the reporters which aren't part of a tree. - appendOtherElements(aP, aReporters); + // because it looks at all the reports which aren't part of a tree. + appendOtherElements(aP, aReports); // Add any warnings about inaccuracies due to platform limitations. // These must be computed after generating all the text. The newlines give @@ -851,14 +966,14 @@ */ function formatInt(aN, aExtra) { - var neg = false; + let neg = false; if (hasNegativeSign(aN)) { neg = true; aN = -aN; } - var s = []; + let s = []; while (true) { - var k = aN % 1000; + let k = aN % 1000; aN = Math.floor(aN / 1000); if (aN > 0) { if (k < 10) { @@ -891,14 +1006,14 @@ */ function formatBytes(aBytes) { - var unit = gVerbose ? " B" : " MB"; + let unit = gVerbose ? " B" : " MB"; - var s; + let s; if (gVerbose) { s = formatInt(aBytes, unit); } else { - var mbytes = (aBytes / (1024 * 1024)).toFixed(2); - var a = String(mbytes).split("."); + let mbytes = (aBytes / (1024 * 1024)).toFixed(2); + let a = String(mbytes).split("."); // If the argument to formatInt() is -0, it will print the negative sign. s = formatInt(Number(a[0])) + "." + a[1] + unit; } @@ -930,9 +1045,9 @@ */ function pad(aS, aN, aC) { - var padding = ""; - var n2 = aN - aS.length; - for (var i = 0; i < n2; i++) { + let padding = ""; + let n2 = aN - aS.length; + for (let i = 0; i < n2; i++) { padding += aC; } return padding + aS; @@ -970,10 +1085,10 @@ const kHideKids = 1; const kShowKids = 2; -function appendMrNameSpan(aP, aKind, aKidsState, aUnsafeDesc, aUnsafeName, +function appendMrNameSpan(aP, aKind, aKidsState, aDescription, aUnsafeName, aIsUnknown, aIsInvalid, aNMerged) { - var text = ""; + let text = ""; if (aKidsState === kNoKids) { appendElementWithText(aP, "span", "mrSep", kDoubleHorizontalSep); } else if (aKidsState === kHideKids) { @@ -986,23 +1101,23 @@ assert(false, "bad aKidsState"); } - var nameSpan = appendElementWithText(aP, "span", "mrName", - makeSafe(aUnsafeName)); - nameSpan.title = kindToString(aKind) + makeSafe(aUnsafeDesc); + let nameSpan = appendElementWithText(aP, "span", "mrName", + flipBackslashes(aUnsafeName)); + nameSpan.title = kindToString(aKind) + aDescription; if (aIsUnknown) { - var noteSpan = appendElementWithText(aP, "span", "mrNote", " [*]"); + let noteSpan = appendElementWithText(aP, "span", "mrNote", " [*]"); noteSpan.title = "Warning: this memory reporter was unable to compute a useful value. "; } if (aIsInvalid) { - var noteSpan = appendElementWithText(aP, "span", "mrNote", " [?!]"); + let noteSpan = appendElementWithText(aP, "span", "mrNote", " [?!]"); noteSpan.title = "Warning: this value is invalid and indicates a bug in one or more " + "memory reporters. "; } if (aNMerged) { - var noteSpan = appendElementWithText(aP, "span", "mrNote", + let noteSpan = appendElementWithText(aP, "span", "mrNote", " [" + aNMerged + "]"); noteSpan.title = "This value is the sum of " + aNMerged + @@ -1016,7 +1131,7 @@ // for compartments that have been closed. This doesn't seem like a big deal, // because the number is limited by the number of entries the user has changed // from their original state. -var gTogglesBySafeTreeId = {}; +let gTogglesBySafeTreeId = {}; function assertClassListContains(e, className) { assert(e, "undefined " + className); @@ -1032,24 +1147,24 @@ // this line must immediately follow. Assertions check this. // |aEvent.target| will be one of the five spans. Get the outer span. - var outerSpan = aEvent.target.parentNode; + let outerSpan = aEvent.target.parentNode; assertClassListContains(outerSpan, "hasKids"); // Toggle visibility of the '++' and '--' separators. - var plusSpan = outerSpan.childNodes[2]; - var minusSpan = outerSpan.childNodes[3]; + let plusSpan = outerSpan.childNodes[2]; + let minusSpan = outerSpan.childNodes[3]; assertClassListContains(plusSpan, "mrSep"); assertClassListContains(minusSpan, "mrSep"); plusSpan .classList.toggle("hidden"); minusSpan.classList.toggle("hidden"); // Toggle visibility of the span containing this node's children. - var subTreeSpan = outerSpan.nextSibling; + let subTreeSpan = outerSpan.nextSibling; assertClassListContains(subTreeSpan, "kids"); subTreeSpan.classList.toggle("hidden"); // Record/unrecord that this sub-tree was toggled. - var safeTreeId = outerSpan.id; + let safeTreeId = outerSpan.id; if (gTogglesBySafeTreeId[safeTreeId]) { delete gTogglesBySafeTreeId[safeTreeId]; } else { @@ -1066,16 +1181,16 @@ } else if (aElement.classList.contains("hasKids")) { // Unhide the '--' separator and hide the '++' separator. - var plusSpan = aElement.childNodes[2]; - var minusSpan = aElement.childNodes[3]; + let plusSpan = aElement.childNodes[2]; + let minusSpan = aElement.childNodes[3]; assertClassListContains(plusSpan, "mrSep"); assertClassListContains(minusSpan, "mrSep"); plusSpan.classList.add("hidden"); minusSpan.classList.remove("hidden"); - expandPathToThisElement(aElement.parentNode); // kids or pre.tree + expandPathToThisElement(aElement.parentNode); // kids or pre.entries } else { - assertClassListContains(aElement, "tree"); + assertClassListContains(aElement, "entries"); } } @@ -1092,9 +1207,9 @@ */ function appendTreeElements(aPOuter, aT, aProcess) { - var treeBytes = aT._amount; - var rootStringLength = aT.toString().length; - var isExplicitTree = aT._unsafeName == 'explicit'; + let treeBytes = aT._amount; + let rootStringLength = aT.toString().length; + let isExplicitTree = aT._unsafeName == 'explicit'; /** * Appends the elements for a particular tree, without a heading. @@ -1122,36 +1237,37 @@ { function repeatStr(aA, aC, aN) { - for (var i = 0; i < aN; i++) { + for (let i = 0; i < aN; i++) { aA.push(aC); } } - var unsafePath = aUnsafePrePath + aT._unsafeName; + let unsafePath = aUnsafePrePath + aT._unsafeName; // Indent more if this entry is narrower than its parent, and update // aIndentGuide accordingly. - var tString = aT.toString(); - var extraIndentArray = []; - var extraIndentLength = Math.max(aParentStringLength - tString.length, 0); + let tString = aT.toString(); + let extraIndentArray = []; + let extraIndentLength = Math.max(aParentStringLength - tString.length, 0); if (extraIndentLength > 0) { repeatStr(extraIndentArray, kHorizontal, extraIndentLength); aIndentGuide[aIndentGuide.length - 1]._depth += extraIndentLength; } - var indentText = aBaseIndentText + extraIndentArray.join(""); + let indentText = aBaseIndentText + extraIndentArray.join(""); appendElementWithText(aP, "span", "treeLine", indentText); // Generate the percentage; detect and record invalid values at the same // time. - var percText = ""; - var tIsInvalid = false; + let percText = ""; + let tIsInvalid = false; if (aT._amount === treeBytes) { percText = "100.0"; } else { - var perc = (100 * aT._amount / treeBytes); - if (!(0 <= perc && perc <= 100)) { + if (!(0 <= aT._amount && aT._amount <= treeBytes)) { tIsInvalid = true; gUnsafePathsWithInvalidValuesForThisProcess.push(unsafePath); + reportAssertionFailure("Invalid value for " + + flipBackslashes(unsafePath)); } percText = (100 * aT._amount / treeBytes).toFixed(2); percText = pad(percText, 5, '0'); @@ -1160,14 +1276,15 @@ // For non-leaf nodes, the entire sub-tree is put within a span so it can // be collapsed if the node is clicked on. - var d; - var hasKids = aT._kids.length > 0; - var kidsState; + let d; + let hasKids = aT._kids.length > 0; + let kidsState; + let showSubtrees; if (hasKids) { // Determine if we should show the sub-tree below this entry; this // involves reinstating any previous toggling of the sub-tree. - var safeTreeId = makeSafe(aProcess + ":" + unsafePath); - var showSubtrees = !aT._hideKids; + let safeTreeId = flipBackslashes(aProcess + ":" + unsafePath); + showSubtrees = !aT._hideKids; if (gTogglesBySafeTreeId[safeTreeId]) { showSubtrees = !showSubtrees; } @@ -1184,10 +1301,10 @@ appendMrValueSpan(d, tString, tIsInvalid); appendElementWithText(d, "span", "mrPerc", percText); - // We don't want to show '(nonheap)' on a tree like 'map/vsize', since the - // whole tree is non-heap. - var kind = isExplicitTree ? aT._kind : undefined; - appendMrNameSpan(d, kind, kidsState, aT._unsafeDescription, aT._unsafeName, + // We don't want to show '(nonheap)' on a tree like 'smaps/vsize', since + // the whole tree is non-heap. + let kind = isExplicitTree ? aT._kind : undefined; + appendMrNameSpan(d, kind, kidsState, aT._description, aT._unsafeName, aT._isUnknown, tIsInvalid, aT._nMerged); appendTextNode(d, "\n"); @@ -1201,14 +1318,15 @@ // The 'kids' class is just used for sanity checking in toggle(). d = appendElement(aP, "span", showSubtrees ? "kids" : "kids hidden"); - for (var i = 0; i < aT._kids.length; i++) { + for (let i = 0; i < aT._kids.length; i++) { // 3 is the standard depth, the callee adjusts it if necessary. aIndentGuide.push({ _isLastKid: (i === aT._kids.length - 1), _depth: 3 }); // Generate the base indent. - var baseIndentArray = []; + let baseIndentArray = []; if (aIndentGuide.length > 0) { - for (var j = 0; j < aIndentGuide.length - 1; j++) { + let j; + for (j = 0; j < aIndentGuide.length - 1; j++) { baseIndentArray.push(aIndentGuide[j]._isLastKid ? " " : kVertical); repeatStr(baseIndentArray, " ", aIndentGuide[j]._depth - 1); } @@ -1217,7 +1335,7 @@ repeatStr(baseIndentArray, kHorizontal, aIndentGuide[j]._depth - 1); } - var baseIndentText = baseIndentArray.join(""); + let baseIndentText = baseIndentArray.join(""); appendTreeElements2(d, unsafePath + "/", aT._kids[i], aIndentGuide, baseIndentText, tString.length); aIndentGuide.pop(); @@ -1227,12 +1345,14 @@ appendSectionHeader(aPOuter, kTreeNames[aT._unsafeName]); - var pre = appendElement(aPOuter, "pre", "tree"); + let pre = appendElement(aPOuter, "pre", "entries"); appendTreeElements2(pre, /* prePath = */"", aT, [], "", rootStringLength); appendTextNode(aPOuter, "\n"); // gives nice spacing when we cut and paste } -function OtherReporter(aUnsafePath, aUnits, aAmount, aUnsafeDesc, aNMerged) +//--------------------------------------------------------------------------- + +function OtherReport(aUnsafePath, aUnits, aAmount, aDescription, aNMerged) { // Nb: _kind is not needed, it's always KIND_OTHER. this._unsafePath = aUnsafePath; @@ -1243,11 +1363,11 @@ } else { this._amount = aAmount; } - this._unsafeDescription = aUnsafeDesc; + this._description = aDescription; this._asString = this.toString(); } -OtherReporter.prototype = { +OtherReport.prototype = { toString: function() { switch (this._units) { case UNITS_BYTES: return formatBytes(this._amount); @@ -1255,12 +1375,12 @@ case UNITS_COUNT_CUMULATIVE: return formatInt(this._amount); case UNITS_PERCENTAGE: return formatPercentage(this._amount); default: - assert(false, "bad units in OtherReporter.toString"); + assert(false, "bad units in OtherReport.toString"); } }, isInvalid: function() { - var n = this._amount; + let n = this._amount; switch (this._units) { case UNITS_BYTES: case UNITS_COUNT: @@ -1268,12 +1388,12 @@ case UNITS_PERCENTAGE: return (n !== kUnknown && !(0 <= n && n <= 10000)); default: - assert(false, "bad units in OtherReporter.isInvalid"); + assert(false, "bad units in OtherReport.isInvalid"); } } }; -OtherReporter.compare = function(a, b) { +OtherReport.compare = function(a, b) { return a._unsafePath < b._unsafePath ? -1 : a._unsafePath > b._unsafePath ? 1 : 0; @@ -1284,50 +1404,52 @@ * * @param aP * The parent DOM node. - * @param aReportersByProcess - * Table of Reporters for this process, indexed by _unsafePath. + * @param aReportsByProcess + * Table of Reports for this process, indexed by _unsafePath. * @param aProcess - * The process these reporters correspond to. + * The process these Reports correspond to. * @return The generated text. */ -function appendOtherElements(aP, aReportersByProcess) +function appendOtherElements(aP, aReportsByProcess) { appendSectionHeader(aP, kTreeNames['other']); - var pre = appendElement(aP, "pre", "tree"); + let pre = appendElement(aP, "pre", "entries"); - // Generate an array of Reporter-like elements, stripping out all the - // Reporters that have already been handled. Also find the width of the + // Generate an array of Report-like elements, stripping out all the + // Reports that have already been handled. Also find the width of the // widest element, so we can format things nicely. - var maxStringLength = 0; - var otherReporters = []; - for (var unsafePath in aReportersByProcess) { - var r = aReportersByProcess[unsafePath]; + let maxStringLength = 0; + let otherReports = []; + for (let unsafePath in aReportsByProcess) { + let r = aReportsByProcess[unsafePath]; if (!r._done) { assert(r._kind === KIND_OTHER, - "_kind !== KIND_OTHER for " + makeSafe(r._unsafePath)); - assert(r._nMerged === undefined); // we don't allow dup'd OTHER reporters - var o = new OtherReporter(r._unsafePath, r._units, r._amount, - r._unsafeDescription); - otherReporters.push(o); + "_kind !== KIND_OTHER for " + flipBackslashes(r._unsafePath)); + assert(r._nMerged === undefined, "dup'd OTHER report"); + let o = new OtherReport(r._unsafePath, r._units, r._amount, + r._description); + otherReports.push(o); if (o._asString.length > maxStringLength) { maxStringLength = o._asString.length; } } } - otherReporters.sort(OtherReporter.compare); + otherReports.sort(OtherReport.compare); // Generate text for the not-yet-printed values. - var text = ""; - for (var i = 0; i < otherReporters.length; i++) { - var o = otherReporters[i]; - var oIsInvalid = o.isInvalid(); + let text = ""; + for (let i = 0; i < otherReports.length; i++) { + let o = otherReports[i]; + let oIsInvalid = o.isInvalid(); if (oIsInvalid) { gUnsafePathsWithInvalidValuesForThisProcess.push(o._unsafePath); + reportAssertionFailure("Invalid value for " + + flipBackslashes(o._unsafePath)); } appendMrValueSpan(pre, pad(o._asString, maxStringLength, ' '), oIsInvalid); - appendMrNameSpan(pre, KIND_OTHER, kNoKids, o._unsafeDescription, - o._unsafePath, o._isUnknown, oIsInvalid); + appendMrNameSpan(pre, KIND_OTHER, kNoKids, o._description, o._unsafePath, + o._isUnknown, oIsInvalid); appendTextNode(pre, "\n"); } @@ -1336,19 +1458,198 @@ function appendSectionHeader(aP, aText) { - appendElementWithText(aP, "h2", "sectionHeader", aText); + appendElementWithText(aP, "h2", "", aText); appendTextNode(aP, "\n"); } -function assert(aCond, aMsg) +//----------------------------------------------------------------------------- +// Code specific to about:compartments +//----------------------------------------------------------------------------- + +function onLoadAboutCompartments() +{ + // Minimize memory usage before generating the page in an attempt to collect + // any dead compartments. + minimizeMemoryUsage3x( + function() { addChildObserversAndUpdate(updateAboutCompartments); }); +} + +/** + * Top-level function that does the work of generating the page. + */ +function updateAboutCompartments() { - if (!aCond) { - throw("assertion failed: " + aMsg); + // First, clear the page contents. Necessary because + // updateAboutCompartments() might be called more than once due to the + // "child-memory-reporter-update" observer. + let body = clearBody(); + + let mgr = Cc["@mozilla.org/memory-reporter-manager;1"]. + getService(Ci.nsIMemoryReporterManager); + + // Generate output for one process at a time. Always start with the + // Main process. + let compartmentsByProcess = getCompartmentsByProcess(mgr); + appendProcessCompartmentsElements(body, "Main", + compartmentsByProcess["Main"]); + for (let process in compartmentsByProcess) { + if (process !== "Main") { + appendProcessCompartmentsElements(body, process, + compartmentsByProcess[process]); + } } + + appendElement(body, "hr"); + + let div1 = appendElement(body, "div"); + let a; + if (gVerbose) { + let a = appendElementWithText(div1, "a", "option", "Less verbose"); + a.href = "about:compartments"; + } else { + let a = appendElementWithText(div1, "a", "option", "More verbose"); + a.href = "about:compartments?verbose"; + } + + // Dispatch a "bodygenerated" event to indicate that the DOM has finished + // generating. This is used by tests. + let e = document.createEvent("Event"); + e.initEvent("bodygenerated", false, false); + document.dispatchEvent(e); } -function debug(x) +//--------------------------------------------------------------------------- + +function Compartment(aUnsafeName, aIsSystemCompartment) { - var content = document.getElementById("content"); - appendElementWithText(content, "div", "legend", JSON.stringify(x)); + this._unsafeName = aUnsafeName; + this._isSystemCompartment = aIsSystemCompartment; + // this._nMerged is only defined if > 1 } + +Compartment.prototype = { + merge: function(r) { + this._nMerged = this._nMerged ? this._nMerged + 1 : 2; + } +}; + +function getCompartmentsByProcess(aMgr) +{ + // Ignore anything that didn't come from the "compartments" multi-reporter. + // (Note that some such reports can reach here as single reports if they were + // in the child process.) + + function ignoreSingle(aPath) + { + return !aPath.startsWith("compartments/"); + } + + function ignoreMulti(aName) + { + return aName !== "compartments"; + } + + let compartmentsByProcess = {}; + + function handleReport(aProcess, aUnsafePath, aKind, aUnits, aAmount, + aDescription) + { + let process = aProcess === "" ? "Main" : aProcess; + + assert(aKind === KIND_OTHER, "bad kind"); + assert(aUnits === UNITS_COUNT, "bad units"); + assert(aAmount === 1, "bad amount"); + assert(aDescription === "", "bad description"); + + let unsafeNames = aUnsafePath.split('/'); + + let isSystemCompartment; + if (unsafeNames[0] === "compartments" && unsafeNames[1] == "system" && + unsafeNames.length == 3) + { + isSystemCompartment = true; + + } else if (unsafeNames[0] === "compartments" && unsafeNames[1] == "user" && + unsafeNames.length == 3) + { + isSystemCompartment = false; + // These null principal compartments are user compartments according to + // the JS engine, but they look odd being shown with content + // compartments, so we put them in the system compartments list. + if (unsafeNames[2].startsWith("moz-nullprincipal:{")) { + isSystemCompartment = true; + } + + } else { + assert(false, "bad compartments path: " + aUnsafePath); + } + let c = new Compartment(unsafeNames[2], isSystemCompartment); + + if (!compartmentsByProcess[process]) { + compartmentsByProcess[process] = {}; + } + let compartments = compartmentsByProcess[process]; + let cOld = compartments[c._unsafeName]; + if (cOld) { + // Already an entry; must be a duplicated compartment. This can happen + // legitimately. Merge them. + cOld.merge(c); + } else { + compartments[c._unsafeName] = c; + } + } + + processMemoryReporters(aMgr, ignoreSingle, ignoreMulti, handleReport); + + return compartmentsByProcess; +} + +//--------------------------------------------------------------------------- + +function appendProcessCompartmentsElementsHelper(aP, aCompartments, aKindString) +{ + appendElementWithText(aP, "h2", "", aKindString + " Compartments\n"); + + let compartmentTextArray = []; + let uPre = appendElement(aP, "pre", "entries"); + for (let name in aCompartments) { + let c = aCompartments[name]; + let isSystemKind = aKindString === "System"; + if (c._isSystemCompartment === isSystemKind) { + let text = flipBackslashes(c._unsafeName); + if (c._nMerged) { + text += " [" + c._nMerged + "]"; + } + text += "\n"; + compartmentTextArray.push(text); + } + } + compartmentTextArray.sort(); + + for (var i = 0; i < compartmentTextArray.length; i++) { + appendElementWithText(uPre, "span", "", compartmentTextArray[i]); + } + + appendTextNode(aP, "\n"); // gives nice spacing when we cut and paste +} + +/** + * Appends the elements for a single process. + * + * @param aP + * The parent DOM node. + * @param aProcess + * The name of the process. + * @param aCompartments + * Table of Compartments for this process, indexed by _unsafeName. + * @return The generated text. + */ +function appendProcessCompartmentsElements(aP, aProcess, aCompartments) +{ + appendElementWithText(aP, "h1", "", aProcess + " Process"); + appendTextNode(aP, "\n\n"); // gives nice spacing when we cut and paste + + appendProcessCompartmentsElementsHelper(aP, aCompartments, "User"); + appendProcessCompartmentsElementsHelper(aP, aCompartments, "System"); +} + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/toolkit/components/aboutmemory/content/aboutMemory.xhtml firefox-trunk-13.0~a1~hg20120222r87313/mozilla/toolkit/components/aboutmemory/content/aboutMemory.xhtml --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/toolkit/components/aboutmemory/content/aboutMemory.xhtml 2012-02-21 02:10:24.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/toolkit/components/aboutmemory/content/aboutMemory.xhtml 2012-02-22 02:09:57.000000000 +0000 @@ -37,13 +37,15 @@ - - ***** END LICENSE BLOCK ***** --> + + - about:memory + - + + + + + + + + + + + + diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/toolkit/components/aboutmemory/tests/test_aboutmemory2.xul firefox-trunk-13.0~a1~hg20120222r87313/mozilla/toolkit/components/aboutmemory/tests/test_aboutmemory2.xul --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/toolkit/components/aboutmemory/tests/test_aboutmemory2.xul 2012-02-21 02:10:24.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/toolkit/components/aboutmemory/tests/test_aboutmemory2.xul 2012-02-22 02:09:57.000000000 +0000 @@ -17,22 +17,22 @@ diff -Nru firefox-trunk-13.0~a1~hg20120221r87204/mozilla/toolkit/components/aboutmemory/tests/test_aboutmemory.xul firefox-trunk-13.0~a1~hg20120222r87313/mozilla/toolkit/components/aboutmemory/tests/test_aboutmemory.xul --- firefox-trunk-13.0~a1~hg20120221r87204/mozilla/toolkit/components/aboutmemory/tests/test_aboutmemory.xul 2012-02-21 02:10:24.000000000 +0000 +++ firefox-trunk-13.0~a1~hg20120222r87313/mozilla/toolkit/components/aboutmemory/tests/test_aboutmemory.xul 2012-02-22 02:09:57.000000000 +0000 @@ -14,21 +14,21 @@ window.alert(1)", OTHER, 666 * MB), f("2nd", "other1", OTHER, 111 * MB), + // Even though the "smaps" reporter is a multi-reporter, if its in a + // child process it'll be passed to the main process as single reports. + // The fact that we skip the "smaps" multi-reporter in the main + // process won't cause these to be skipped; the fall-back skipping will + // be hit instead. + f("2nd", "smaps/vsize/e", NONHEAP, 24*4*KB), + f("2nd", "smaps/vsize/f", NONHEAP, 24*4*KB), // kUnknown should be handled gracefully for "heap-allocated", non-leaf // reporters, leaf-reporters, "other" reporters, and duplicated reporters. @@ -205,28 +231,10 @@ f("5th", "explicit/b/c/g/h", NONHEAP, 10 * KB), f("5th", "explicit/b/c/i/j", NONHEAP, 5 * KB) ]; - var fakeMultiReporters2 = [ - // Because this multi-reporter is in a child process, the fact that we - // skip the "smaps" multi-reporter in the parent process won't cause - // these to be skipped; the fall-back skipping will be hit instead. - { name: "smaps", - collectReports: function(cbObj, closure) { - // The amounts are given in pages, so multiply here by 4kb. - function f(p, a) { cbObj.callback("2nd", p, NONHEAP, BYTES, a * 4 * KB, "(desc)", closure); } - f("smaps/vsize/a", 24); - f("smaps/vsize/b", 24); - }, - explicitNonHeap: 0 - } - ]; - for (var i = 0; i < fakeReporters2.length; i++) { + for (let i = 0; i < fakeReporters2.length; i++) { mgr.registerReporter(fakeReporters2[i]); } - for (var i = 0; i < fakeMultiReporters2.length; i++) { - mgr.registerMultiReporter(fakeMultiReporters2[i]); - } fakeReporters = fakeReporters.concat(fakeReporters2); - fakeMultiReporters = fakeMultiReporters.concat(fakeMultiReporters2); ]]> @@ -235,7 +243,7 @@