From 45de4f8f740ca35fc7427a8ad3878e655f211e5d Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 18 Jun 2013 15:31:22 -0700 Subject: [PATCH 01/90] Bumping gaia.json for 2 gaia-central revision(s) ======== https://hg.mozilla.org/integration/gaia-central/rev/7ea9d3380972 Author: Fabien Cazenave Desc: Merge pull request #10471 from masap/20130619 Bug 884565 - [WiFi] Fix WPS regression by Bug 879193, r=kaze ======== https://hg.mozilla.org/integration/gaia-central/rev/cd918664a27d Author: masap Desc: Bug 884565 - [WiFi] Fix WPS regression by Bug 879193 --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 2c89343222fb..6ff582771b3a 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "fc8faac211332ebdbbea8bf11f3ca2deba541cee", + "revision": "7ea9d33809727e684400b31472f23614b26516ec", "repo_path": "/integration/gaia-central" } From a8e069da0cd383d44061e83c89bfcdc1b8f8888a Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 18 Jun 2013 15:46:21 -0700 Subject: [PATCH 02/90] Bumping gaia.json for 2 gaia-central revision(s) ======== https://hg.mozilla.org/integration/gaia-central/rev/4488e32f5bac Author: Fabien Cazenave Desc: Merge pull request #10351 from fabi1cazenave/mmsUnknownAttachments-bug875408 Bug 875408 - [MMS] Display unknown file types, r=julienw ======== https://hg.mozilla.org/integration/gaia-central/rev/aeeeaa16c55d Author: Fabien Cazenave Desc: Bug 875408 - [MMS] Display unknown file types and corrupted attachments --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 6ff582771b3a..5129393b65e4 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "7ea9d33809727e684400b31472f23614b26516ec", + "revision": "4488e32f5bacc77a63d5838eeb474193ae71d5c2", "repo_path": "/integration/gaia-central" } From a5e9caadeed4eb87c4f426eaa779a00a8bd7de15 Mon Sep 17 00:00:00 2001 From: Nikhil Marathe Date: Tue, 18 Jun 2013 17:01:32 -0700 Subject: [PATCH 03/90] Bug 881424 - Set B2G SimplePush serverURL to Mozilla Push Server. r=jrconlin --- b2g/app/b2g.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index d2740eb3a81b..2de8d2f4a8f9 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -402,7 +402,7 @@ pref("services.push.enabled", true); // This preference should be used in UX to enable/disable push. pref("services.push.connection.enabled", true); // serverURL to be assigned by services team -pref("services.push.serverURL", ""); +pref("services.push.serverURL", "wss://push.services.mozilla.com/"); pref("services.push.userAgentID", ""); // Exponential back-off start is 5 seconds like in HTTP/1.1. // Maximum back-off is pingInterval. From d8e7e161f66f9aad32083c0f93824ed8bb393a5d Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 18 Jun 2013 18:46:21 -0700 Subject: [PATCH 04/90] Bumping gaia.json for 1 gaia-central revision(s) ======== https://hg.mozilla.org/integration/gaia-central/rev/60b99121e72a Author: Rick Waldron Desc: Bug 883058 - [SMS/MMS] One contact with very long name can be scrolled in recipient field r=gnarf https://bugzilla.mozilla.org/show_bug.cgi?id=883058 - Removes rule about a single contact prohibiting pull down - Height of recipient-list itself is informative enough to determine "pullable" status - http://en.wikipedia.org/wiki/Taumatawhakatangihangakoauauotamateapokaiwhenuakitanatahu Signed-off-by: Rick Waldron --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 5129393b65e4..849c8eed96a5 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "4488e32f5bacc77a63d5838eeb474193ae71d5c2", + "revision": "60b99121e72a7a7eab1198b7df16c13dc0f25d45", "repo_path": "/integration/gaia-central" } From 50e6c6630103c91f91e716a98ee85fc97e0f4752 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 18 Jun 2013 19:01:21 -0700 Subject: [PATCH 05/90] Bumping gaia.json for 1 gaia-central revision(s) ======== https://hg.mozilla.org/integration/gaia-central/rev/56e34384094a Author: Rick Waldron Desc: Bug 884639 - [SMS][MMS] Fix lint error caused by bug 875408 patch https://bugzilla.mozilla.org/show_bug.cgi?id=884639 Signed-off-by: Rick Waldron --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 849c8eed96a5..f559e01d8bc5 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "60b99121e72a7a7eab1198b7df16c13dc0f25d45", + "revision": "56e34384094ad3a6f77ca3a59cbf01e674ecbef1", "repo_path": "/integration/gaia-central" } From 5c259090f7033b35cb92ef9bbaa5f6609f8be0e4 Mon Sep 17 00:00:00 2001 From: Chia-hung Tai Date: Tue, 18 Jun 2013 18:17:43 +0800 Subject: [PATCH 06/90] Bug 884146 - B2G MMS: Can not receive MMS from Far-stone sim card. r=vyang --- dom/mobilemessage/src/ril/MmsService.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dom/mobilemessage/src/ril/MmsService.js b/dom/mobilemessage/src/ril/MmsService.js index 639e06d6b733..6e8c64733360 100644 --- a/dom/mobilemessage/src/ril/MmsService.js +++ b/dom/mobilemessage/src/ril/MmsService.js @@ -402,7 +402,7 @@ MmsProxyFilter.prototype = { // Fall-through, reutrn the MMS proxy info. if (DEBUG) debug("applyFilter: MMSC is matched: " + JSON.stringify({ url: this.url, - roxyInfo: gMmsConnection.proxyInfo })); + proxyInfo: gMmsConnection.proxyInfo })); return gMmsConnection.proxyInfo ? gMmsConnection.proxyInfo : proxyInfo; } }; @@ -460,8 +460,6 @@ XPCOMUtils.defineLazyGetter(this, "gMmsTransactionHelper", function () { xhr.setRequestHeader("Content-Type", "application/vnd.wap.mms-message"); xhr.setRequestHeader("Content-Length", istream.available()); - } else { - xhr.setRequestHeader("Content-Length", 0); } // UAProf headers. @@ -504,7 +502,8 @@ XPCOMUtils.defineLazyGetter(this, "gMmsTransactionHelper", function () { break; } default: { - if (DEBUG) debug("xhr done, but status = " + xhr.status); + if (DEBUG) debug("xhr done, but status = " + xhr.status + + ", statusText = " + xhr.statusText); break; } } From a6251505d0cb6133001e6f6ce3aa59f5ec6fa13a Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 18 Jun 2013 19:16:24 -0700 Subject: [PATCH 07/90] Bumping gaia.json for 2 gaia-central revision(s) ======== https://hg.mozilla.org/integration/gaia-central/rev/8e33f6f8ca04 Author: Arthur Chen Desc: Merge pull request #10454 from crh0716/883759 Bug 883759 - Hangup the waiting call when receiving CHLD=0 ======== https://hg.mozilla.org/integration/gaia-central/rev/7a6445a10114 Author: crh0716 Desc: Bug 883759 - Hangup the waiting call when receiving CHLD=0 --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index f559e01d8bc5..ea80a4ad336e 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "56e34384094ad3a6f77ca3a59cbf01e674ecbef1", + "revision": "8e33f6f8ca04479184f91e0add42b34a01986f4b", "repo_path": "/integration/gaia-central" } From 83039abc8cc7729bb3f85b8375500186035e0d48 Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Wed, 19 Jun 2013 10:18:39 +0800 Subject: [PATCH 08/90] Bug 883798 - B2G SMS: test cases should initialize all necessary preferences and/or settings. r=gene --- dom/mobilemessage/tests/marionette/test_getmessage.js | 5 ++++- dom/mobilemessage/tests/marionette/test_outgoing.js | 2 ++ dom/mobilemessage/tests/marionette/test_outgoing_delete.js | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dom/mobilemessage/tests/marionette/test_getmessage.js b/dom/mobilemessage/tests/marionette/test_getmessage.js index 4107fd843ccd..f4a5d7e6802c 100644 --- a/dom/mobilemessage/tests/marionette/test_getmessage.js +++ b/dom/mobilemessage/tests/marionette/test_getmessage.js @@ -4,6 +4,7 @@ MARIONETTE_TIMEOUT = 60000; SpecialPowers.setBoolPref("dom.sms.enabled", true); +SpecialPowers.setBoolPref("dom.sms.requestStatusReport", true); SpecialPowers.addPermission("sms", true, document); const REMOTE = "5559997777"; // the remote number @@ -213,7 +214,9 @@ function deleteMsgs() { function cleanUp() { sms.onreceived = null; SpecialPowers.removePermission("sms", document); - SpecialPowers.setBoolPref("dom.sms.enabled", false); + SpecialPowers.clearUserPref("dom.sms.enabled", false); + SpecialPowers.clearUserPref("dom.sms.requestStatusReport"); + finish(); } diff --git a/dom/mobilemessage/tests/marionette/test_outgoing.js b/dom/mobilemessage/tests/marionette/test_outgoing.js index cac0e9ae7f7d..bee9d1de4b86 100644 --- a/dom/mobilemessage/tests/marionette/test_outgoing.js +++ b/dom/mobilemessage/tests/marionette/test_outgoing.js @@ -5,6 +5,7 @@ MARIONETTE_TIMEOUT = 60000; SpecialPowers.setBoolPref("dom.sms.enabled", true); SpecialPowers.setBoolPref("dom.sms.strict7BitEncoding", false); +SpecialPowers.setBoolPref("dom.sms.requestStatusReport", true); SpecialPowers.addPermission("sms", true, document); const SENDER = "15555215554"; // the emulator's number @@ -185,6 +186,7 @@ function cleanUp() { SpecialPowers.removePermission("sms", document); SpecialPowers.clearUserPref("dom.sms.enabled"); SpecialPowers.clearUserPref("dom.sms.strict7BitEncoding"); + SpecialPowers.clearUserPref("dom.sms.requestStatusReport"); finish(); } diff --git a/dom/mobilemessage/tests/marionette/test_outgoing_delete.js b/dom/mobilemessage/tests/marionette/test_outgoing_delete.js index 931803a33e31..32fc8aafe78b 100644 --- a/dom/mobilemessage/tests/marionette/test_outgoing_delete.js +++ b/dom/mobilemessage/tests/marionette/test_outgoing_delete.js @@ -4,6 +4,7 @@ MARIONETTE_TIMEOUT = 60000; SpecialPowers.setBoolPref("dom.sms.enabled", true); +SpecialPowers.setBoolPref("dom.sms.requestStatusReport", true); SpecialPowers.addPermission("sms", true, document); const SENDER = "15555215554"; // the emulator's number @@ -152,7 +153,8 @@ function verifySmsDeleted(smsId) { function cleanUp() { sms.onsent = null; SpecialPowers.removePermission("sms", document); - SpecialPowers.setBoolPref("dom.sms.enabled", false); + SpecialPowers.clearUserPref("dom.sms.enabled", false); + SpecialPowers.clearUserPref("dom.sms.requestStatusReport"); finish(); } From 8d9cdb4c81e56f64f0ed63565a1ca570bfc0cc98 Mon Sep 17 00:00:00 2001 From: Kyle Machulis Date: Tue, 18 Jun 2013 21:26:22 -0700 Subject: [PATCH 09/90] Bug 877859 - Change configure.in for new valgrind include path; r=mwu --- CLOBBER | 2 +- configure.in | 4 ++-- js/src/configure.in | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CLOBBER b/CLOBBER index e13b4758de5f..e99f4f4a4058 100644 --- a/CLOBBER +++ b/CLOBBER @@ -17,4 +17,4 @@ # # Modifying this file will now automatically clobber the buildbot machines \o/ # -Bug 704356 needed to clobber for the removal of jspropertycache.cpp +Bug 877859 Valgrind header location updates for FxOS Valgrind diff --git a/configure.in b/configure.in index f60c913a13de..8e6e022ba883 100644 --- a/configure.in +++ b/configure.in @@ -204,7 +204,7 @@ if test -n "$gonkdir" ; then case "$ANDROID_VERSION" in 15) - GONK_INCLUDES="-I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/frameworks/base/include -I$gonkdir/frameworks/base/services/camera -I$gonkdir/frameworks/base/include/media/stagefright -I$gonkdir/frameworks/base/include/media/stagefright/openmax -I$gonkdir/frameworks/base/media/libstagefright/rtsp -I$gonkdir/frameworks/base/media/libstagefright/include -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib -I$gonkdir/dalvik/libnativehelper/include/nativehelper -I$gonkdir/external/valgrind" + GONK_INCLUDES="-I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/frameworks/base/include -I$gonkdir/frameworks/base/services/camera -I$gonkdir/frameworks/base/include/media/stagefright -I$gonkdir/frameworks/base/include/media/stagefright/openmax -I$gonkdir/frameworks/base/media/libstagefright/rtsp -I$gonkdir/frameworks/base/media/libstagefright/include -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib -I$gonkdir/dalvik/libnativehelper/include/nativehelper" MOZ_B2G_BT=1 MOZ_B2G_CAMERA=1 MOZ_OMX_DECODER=1 @@ -218,7 +218,7 @@ if test -n "$gonkdir" ; then AC_MSG_ERROR([Unsupported platform version: $ANDROID_VERSION]) ;; esac - CPPFLAGS="-DANDROID -isystem $gonkdir/bionic/libc/$ARCH_DIR/include -isystem $gonkdir/bionic/libc/include/ -isystem $gonkdir/bionic/libc/kernel/common -isystem $gonkdir/bionic/libc/kernel/$ARCH_DIR -isystem $gonkdir/bionic/libm/include -I$gonkdir/system -I$gonkdir/system/core/include -isystem $gonkdir/bionic -I$gonkdir/hardware/libhardware/include $GONK_INCLUDES $CPPFLAGS" + CPPFLAGS="-DANDROID -isystem $gonkdir/bionic/libc/$ARCH_DIR/include -isystem $gonkdir/bionic/libc/include/ -isystem $gonkdir/bionic/libc/kernel/common -isystem $gonkdir/bionic/libc/kernel/$ARCH_DIR -isystem $gonkdir/bionic/libm/include -I$gonkdir/system -I$gonkdir/system/core/include -isystem $gonkdir/bionic -I$gonkdir/hardware/libhardware/include -I$gonkdir/external/valgrind/fxos-include $GONK_INCLUDES $CPPFLAGS" CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS" CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions -Wno-psabi $CXXFLAGS $STLPORT_CPPFLAGS" dnl Add -llog by default, since we use it all over the place. diff --git a/js/src/configure.in b/js/src/configure.in index 5f1ade086fe1..36583b80c101 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -188,7 +188,7 @@ if test -n "$gonkdir" ; then ;; esac - CPPFLAGS="-DANDROID -isystem $gonkdir/bionic/libc/$ARCH_DIR/include -isystem $gonkdir/bionic/libc/include/ -isystem $gonkdir/bionic/libc/kernel/common -isystem $gonkdir/bionic/libc/kernel/$ARCH_DIR -isystem $gonkdir/bionic/libm/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/system/core/include -isystem $gonkdir/bionic $CPPFLAGS -I$gonkdir/external/valgrind" + CPPFLAGS="-DANDROID -isystem $gonkdir/bionic/libc/$ARCH_DIR/include -isystem $gonkdir/bionic/libc/include/ -isystem $gonkdir/bionic/libc/kernel/common -isystem $gonkdir/bionic/libc/kernel/$ARCH_DIR -isystem $gonkdir/bionic/libm/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/system/core/include -isystem $gonkdir/bionic $CPPFLAGS -I$gonkdir/external/valgrind/fxos-include" CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS" CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions -Wno-psabi $CXXFLAGS $STLPORT_CPPFLAGS" LIBS="$LIBS $STLPORT_LIBS" From 67d0fb534324acfef2dd186bfd76519f39781aa0 Mon Sep 17 00:00:00 2001 From: Ben Tian Date: Tue, 18 Jun 2013 15:42:10 +0800 Subject: [PATCH 10/90] Bug 883505 - [Bluetooth] Support for CHLD=0 of HFP, r=echou --- dom/bluetooth/BluetoothHfpManager.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/dom/bluetooth/BluetoothHfpManager.cpp b/dom/bluetooth/BluetoothHfpManager.cpp index 3b1aff117a4e..000b9722d935 100644 --- a/dom/bluetooth/BluetoothHfpManager.cpp +++ b/dom/bluetooth/BluetoothHfpManager.cpp @@ -837,7 +837,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket, NS_ASSERTION(vgm >= 0 && vgm <= 15, "Received invalid VGM value"); mCurrentVgm = vgm; } else if (msg.Find("AT+CHLD=?") != -1) { - SendLine("+CHLD: (1,2)"); + SendLine("+CHLD: (0,1,2)"); } else if (msg.Find("AT+CHLD=") != -1) { ParseAtCommand(msg, 8, atCommandValues); @@ -847,14 +847,16 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket, } /** - * The following two cases are supported: + * The following three cases are supported: + * AT+CHLD=0 - Releases all held calls or sets User Determined User Busy + * (UDUB) for a waiting call * AT+CHLD=1 - Releases active calls and accepts the other (held or * waiting) call * AT+CHLD=2 - Places active calls on hold and accepts the other (held * or waiting) call * * The following cases are NOT supported yet: - * AT+CHLD=0, AT+CHLD=1, AT+CHLD=2, AT+CHLD=3, AT+CHLD=4 + * AT+CHLD=1, AT+CHLD=2, AT+CHLD=3, AT+CHLD=4 * Please see 4.33.2 in Bluetooth hands-free profile 1.6 for more * information. */ @@ -863,9 +865,14 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket, if (atCommandValues[0].Length() > 1) { NS_WARNING("No index should be included in command [AT+CHLD]"); valid = false; - } else if (chld == '0' || chld == '3' || chld == '4') { + } else if (chld == '3' || chld == '4') { NS_WARNING("The value of command [AT+CHLD] is not supported"); valid = false; + } else if (chld == '0') { + // We need to rename these dialer commands for better readability + // and expandability. + // See bug 884190 for more information. + NotifyDialer(NS_LITERAL_STRING("CHLD=0")); } else if (chld == '1') { NotifyDialer(NS_LITERAL_STRING("CHUP+ATA")); } else if (chld == '2') { From 3b930f90ab7f98c68dfacfd520b5609b6b3e745e Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 19 Jun 2013 00:16:22 -0700 Subject: [PATCH 11/90] Bumping gaia.json for 2 gaia-central revision(s) ======== https://hg.mozilla.org/integration/gaia-central/rev/5b2d2e3dec75 Author: Rudy Lu Desc: Merge pull request #10465 from elad661/gaia-keyboard-nun-sofit Bug #884329 - Add missing Nun Sofit to the Hebrew keyboard layout. r=rudylu ======== https://hg.mozilla.org/integration/gaia-central/rev/30f5af8dea94 Author: Elad Alfassa Desc: Bug #884329 - [Keyboard] Add missing Nun Sofit to the Hebrew keyboard layout For some reason we had Vav twice and no Nun Sofit. More information: https://en.wikipedia.org/wiki/%D7%9F#Hebrew_Nun This fixes bug #884329 --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index ea80a4ad336e..c9ec19744c86 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "8e33f6f8ca04479184f91e0add42b34a01986f4b", + "revision": "5b2d2e3dec7582dc96d8a7d05a688384509e137b", "repo_path": "/integration/gaia-central" } From ec5028a72c11ae0749bd2703362900b1fc061b40 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Tue, 16 Apr 2013 16:42:35 +0200 Subject: [PATCH 12/90] Bug 880167: Replace SendDiscoveryTask by non-blocking implementation r=echou,gyeh This patch replaces SendDiscoveryTask by a non-blocking implementation that does not use the Bluetooth command thread. The request gets send directly to the DBus, and its reply gets processed in the DBus thread itself. --- dom/bluetooth/linux/BluetoothDBusService.cpp | 73 ++++++++------------ 1 file changed, 30 insertions(+), 43 deletions(-) diff --git a/dom/bluetooth/linux/BluetoothDBusService.cpp b/dom/bluetooth/linux/BluetoothDBusService.cpp index 7f437f602369..823aba3f5bda 100644 --- a/dom/bluetooth/linux/BluetoothDBusService.cpp +++ b/dom/bluetooth/linux/BluetoothDBusService.cpp @@ -227,42 +227,6 @@ GetPairedDevicesFilter(const BluetoothValue& aValue) return false; } -class SendDiscoveryTask : public nsRunnable -{ -public: - SendDiscoveryTask(const char* aMessageName, - BluetoothReplyRunnable* aRunnable) - : mMessageName(aMessageName) - , mRunnable(aRunnable) - { - MOZ_ASSERT(aMessageName); - MOZ_ASSERT(aRunnable); - } - - nsresult Run() - { - MOZ_ASSERT(!NS_IsMainThread()); - - DBusMessage *reply = - dbus_func_args(gThreadConnection->GetConnection(), - NS_ConvertUTF16toUTF8(sAdapterPath).get(), - DBUS_ADAPTER_IFACE, mMessageName, - DBUS_TYPE_INVALID); - - if (reply) { - dbus_message_unref(reply); - } - - DispatchBluetoothReply(mRunnable, BluetoothValue(true), EmptyString()); - - return NS_OK; - } - -private: - const char* mMessageName; - nsRefPtr mRunnable; -}; - class DistributeBluetoothSignalTask : public nsRunnable { public: @@ -418,7 +382,7 @@ ExtractHandles(DBusMessage *aReply, nsTArray& aOutHandles) } } -// static +// static bool BluetoothDBusService::AddServiceRecords(const char* serviceName, unsigned long long uuidMsb, @@ -1832,6 +1796,23 @@ BluetoothDBusService::GetDefaultAdapterPathInternal( return NS_OK; } +static void +OnSendDiscoveryMessageReply(DBusMessage *aReply, void *aData) +{ + MOZ_ASSERT(!NS_IsMainThread()); + + nsAutoString errorStr; + + if (!aReply) { + errorStr.AssignLiteral("SendDiscovery failed"); + } + + nsRefPtr runnable = + dont_AddRef(static_cast(aData)); + + DispatchBluetoothReply(runnable.get(), BluetoothValue(true), errorStr); +} + nsresult BluetoothDBusService::SendDiscoveryMessage(const char* aMessageName, BluetoothReplyRunnable* aRunnable) @@ -1844,11 +1825,17 @@ BluetoothDBusService::SendDiscoveryMessage(const char* aMessageName, return NS_OK; } - nsRefPtr task(new SendDiscoveryTask(aMessageName, aRunnable)); - if (NS_FAILED(mBluetoothCommandThread->Dispatch(task, NS_DISPATCH_NORMAL))) { - NS_WARNING("Cannot dispatch firmware loading task!"); - return NS_ERROR_FAILURE; - } + nsRefPtr runnable(aRunnable); + + bool success = dbus_func_args_async(mConnection, -1, + OnSendDiscoveryMessageReply, + static_cast(aRunnable), + NS_ConvertUTF16toUTF8(sAdapterPath).get(), + DBUS_ADAPTER_IFACE, aMessageName, + DBUS_TYPE_INVALID); + NS_ENSURE_TRUE(success, NS_ERROR_FAILURE); + + runnable.forget(); return NS_OK; } @@ -2662,7 +2649,7 @@ public: mServiceUuid, channel, mManager)); - NS_DispatchToMainThread(r); + NS_DispatchToMainThread(r); return NS_OK; } From 09024c54897f8cc7d98880af07d97cb4417f8c44 Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Tue, 18 Jun 2013 21:48:45 +0300 Subject: [PATCH 13/90] Bug 847611 - Paris bindings for autogenerated events, r=peterv --- dom/base/nsWrapperCache.h | 2 +- dom/bindings/Bindings.conf | 1 + .../tests/approved/test_interfaces.html.json | 6 - .../Ms2ger/test_missing_arguments.html.json | 3 +- dom/interfaces/events/nsIDOMCloseEvent.idl | 2 +- .../events/nsIDOMDeviceLightEvent.idl | 2 +- .../interfaces/nsIDOMCFStateChangeEvent.idl | 2 +- .../interfaces/nsIDOMUSSDReceivedEvent.idl | 2 +- dom/webidl/BlobEvent.webidl | 17 + dom/webidl/BluetoothDeviceEvent.webidl | 17 + dom/webidl/CFStateChangeEvent.webidl | 30 +- dom/webidl/CallEvent.webidl | 17 + dom/webidl/CloseEvent.webidl | 35 ++ dom/webidl/CustomEvent.webidl | 20 +- dom/webidl/DOMTransactionEvent.webidl | 23 + dom/webidl/DataErrorEvent.webidl | 16 + dom/webidl/DeviceLightEvent.webidl | 16 + dom/webidl/DeviceOrientationEvent.webidl | 32 ++ dom/webidl/DeviceProximityEvent.webidl | 20 + dom/webidl/DeviceStorageChangeEvent.webidl | 18 + dom/webidl/DummyBinding.webidl | 2 - dom/webidl/ElementReplaceEvent.webidl | 23 + dom/webidl/GamepadAxisMoveEvent.webidl | 18 + dom/webidl/GamepadButtonEvent.webidl | 16 + dom/webidl/GamepadEvent.webidl | 16 + dom/webidl/HashChangeEvent.webidl | 26 + dom/webidl/IccCardLockErrorEvent.webidl | 18 + dom/webidl/MozApplicationEvent.webidl | 17 + dom/webidl/MozCellBroadcastEvent.webidl | 17 + dom/webidl/MozContactChangeEvent.webidl | 18 + dom/webidl/MozMmsEvent.webidl | 17 + dom/webidl/MozSettingsEvent.webidl | 19 + dom/webidl/MozSmsEvent.webidl | 17 + dom/webidl/MozVoicemailEvent.webidl | 17 + dom/webidl/MozWifiConnectionInfoEvent.webidl | 25 + dom/webidl/MozWifiStatusChangeEvent.webidl | 19 + dom/webidl/PageTransitionEvent.webidl | 23 + dom/webidl/PopStateEvent.webidl | 24 + dom/webidl/PopupBlockedEvent.webidl | 33 ++ dom/webidl/ProgressEvent.webidl | 20 + dom/webidl/SmartCardEvent.webidl | 16 + dom/webidl/SpeechRecognitionError.webidl | 27 + dom/webidl/SpeechRecognitionEvent.webidl | 23 + dom/webidl/SpeechSynthesisEvent.webidl | 14 +- dom/webidl/StorageEvent.webidl | 42 ++ dom/webidl/StyleRuleChangeEvent.webidl | 19 + ...tyleSheetApplicableStateChangeEvent.webidl | 18 + dom/webidl/StyleSheetChangeEvent.webidl | 18 + dom/webidl/USSDReceivedEvent.webidl | 12 +- dom/webidl/UserProximityEvent.webidl | 16 + dom/webidl/WebIDL.mk | 66 ++- js/xpconnect/src/Makefile.in | 16 +- js/xpconnect/src/event_impl_gen.conf.in | 9 + js/xpconnect/src/event_impl_gen.py | 543 +++++++++++++++--- 54 files changed, 1401 insertions(+), 104 deletions(-) create mode 100644 dom/webidl/BlobEvent.webidl create mode 100644 dom/webidl/BluetoothDeviceEvent.webidl create mode 100644 dom/webidl/CallEvent.webidl create mode 100644 dom/webidl/CloseEvent.webidl create mode 100644 dom/webidl/DOMTransactionEvent.webidl create mode 100644 dom/webidl/DataErrorEvent.webidl create mode 100644 dom/webidl/DeviceLightEvent.webidl create mode 100644 dom/webidl/DeviceOrientationEvent.webidl create mode 100644 dom/webidl/DeviceProximityEvent.webidl create mode 100644 dom/webidl/DeviceStorageChangeEvent.webidl create mode 100644 dom/webidl/ElementReplaceEvent.webidl create mode 100644 dom/webidl/GamepadAxisMoveEvent.webidl create mode 100644 dom/webidl/GamepadButtonEvent.webidl create mode 100644 dom/webidl/GamepadEvent.webidl create mode 100644 dom/webidl/HashChangeEvent.webidl create mode 100644 dom/webidl/IccCardLockErrorEvent.webidl create mode 100644 dom/webidl/MozApplicationEvent.webidl create mode 100644 dom/webidl/MozCellBroadcastEvent.webidl create mode 100644 dom/webidl/MozContactChangeEvent.webidl create mode 100644 dom/webidl/MozMmsEvent.webidl create mode 100644 dom/webidl/MozSettingsEvent.webidl create mode 100644 dom/webidl/MozSmsEvent.webidl create mode 100644 dom/webidl/MozVoicemailEvent.webidl create mode 100644 dom/webidl/MozWifiConnectionInfoEvent.webidl create mode 100644 dom/webidl/MozWifiStatusChangeEvent.webidl create mode 100644 dom/webidl/PageTransitionEvent.webidl create mode 100644 dom/webidl/PopStateEvent.webidl create mode 100644 dom/webidl/PopupBlockedEvent.webidl create mode 100644 dom/webidl/ProgressEvent.webidl create mode 100644 dom/webidl/SmartCardEvent.webidl create mode 100644 dom/webidl/SpeechRecognitionError.webidl create mode 100644 dom/webidl/SpeechRecognitionEvent.webidl create mode 100644 dom/webidl/StorageEvent.webidl create mode 100644 dom/webidl/StyleRuleChangeEvent.webidl create mode 100644 dom/webidl/StyleSheetApplicableStateChangeEvent.webidl create mode 100644 dom/webidl/StyleSheetChangeEvent.webidl create mode 100644 dom/webidl/UserProximityEvent.webidl diff --git a/dom/base/nsWrapperCache.h b/dom/base/nsWrapperCache.h index f7e1a513dd96..44d3c054afcd 100644 --- a/dom/base/nsWrapperCache.h +++ b/dom/base/nsWrapperCache.h @@ -123,7 +123,7 @@ public: void SetIsDOMBinding() { - MOZ_ASSERT(!mWrapper && !GetWrapperFlags(), + MOZ_ASSERT(!mWrapper && !(GetWrapperFlags() & ~WRAPPER_IS_DOM_BINDING), "This flag should be set before creating any wrappers."); SetWrapperFlags(WRAPPER_IS_DOM_BINDING); } diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index c035cd57b2cc..6059f3ccc872 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1620,6 +1620,7 @@ addExternalIface('Counter') addExternalIface('CSSRule') addExternalIface('DeviceAcceleration', headerFile='nsIDOMDeviceMotionEvent.h', notflattened=True) addExternalIface('DeviceRotationRate', headerFile='nsIDOMDeviceMotionEvent.h', notflattened=True) +addExternalIface('mozIDOMApplication', nativeType='mozIDOMApplication', headerFile='nsIDOMApplicationRegistry.h') addExternalIface('CSSRuleList') addExternalIface('DOMStringList') addExternalIface('RTCDataChannel', nativeType='nsIDOMDataChannel') diff --git a/dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json b/dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json index b2dc56fd4b1e..ff304deff331 100644 --- a/dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json +++ b/dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json @@ -34,12 +34,6 @@ "Event interface: new Event(\"foo\") must have own property \"isTrusted\"": true, "Event interface: new Event(\"foo\") must inherit property \"timeStamp\" with the proper type (15)": true, "CustomEvent interface: existence and properties of interface object": true, - "CustomEvent interface constructor": true, - "CustomEvent interface: existence and properties of interface prototype object": true, - "CustomEvent interface: existence and properties of interface prototype object's \"constructor\" property": true, - "CustomEvent interface: attribute detail": true, - "Stringification of new CustomEvent(\"foo\")": "debug", - "CustomEvent interface: calling initCustomEvent(DOMString,boolean,boolean,any) on new CustomEvent(\"foo\") with too few arguments must throw TypeError": true, "Event interface: new CustomEvent(\"foo\") must have own property \"isTrusted\"": true, "Event interface: new CustomEvent(\"foo\") must inherit property \"timeStamp\" with the proper type (15)": true, "MutationObserver interface: operation observe(Node,MutationObserverInit)": true, diff --git a/dom/imptests/failures/webapps/WebStorage/tests/submissions/Ms2ger/test_missing_arguments.html.json b/dom/imptests/failures/webapps/WebStorage/tests/submissions/Ms2ger/test_missing_arguments.html.json index 35810a3d3793..42a36331b75e 100644 --- a/dom/imptests/failures/webapps/WebStorage/tests/submissions/Ms2ger/test_missing_arguments.html.json +++ b/dom/imptests/failures/webapps/WebStorage/tests/submissions/Ms2ger/test_missing_arguments.html.json @@ -8,6 +8,5 @@ "Should throw TypeError for function \"function () { sessionStorage.getItem(); }\".": true, "Should throw TypeError for function \"function () { sessionStorage.setItem(); }\".": true, "Should throw TypeError for function \"function () { sessionStorage.setItem(\"a\"); }\".": true, - "Should throw TypeError for function \"function () { sessionStorage.removeItem(); }\".": true, - "Should throw TypeError for function \"function () { new StorageEvent(); }\".": true + "Should throw TypeError for function \"function () { sessionStorage.removeItem(); }\".": true } diff --git a/dom/interfaces/events/nsIDOMCloseEvent.idl b/dom/interfaces/events/nsIDOMCloseEvent.idl index 722e5e78230a..6c9a788cf6d8 100644 --- a/dom/interfaces/events/nsIDOMCloseEvent.idl +++ b/dom/interfaces/events/nsIDOMCloseEvent.idl @@ -6,7 +6,7 @@ #include "nsIDOMEvent.idl" /** - * The nsIDOMCloseEvent interface is the interface to the event + * The CloseEvent interface is the interface to the event * close on a WebSocket object. * * For more information on this interface, please see diff --git a/dom/interfaces/events/nsIDOMDeviceLightEvent.idl b/dom/interfaces/events/nsIDOMDeviceLightEvent.idl index c7b50d8f1ed7..d8641f3ee359 100644 --- a/dom/interfaces/events/nsIDOMDeviceLightEvent.idl +++ b/dom/interfaces/events/nsIDOMDeviceLightEvent.idl @@ -17,5 +17,5 @@ interface nsIDOMDeviceLightEvent : nsIDOMEvent dictionary DeviceLightEventInit : EventInit { - double value; + double value = Infinity; }; diff --git a/dom/network/interfaces/nsIDOMCFStateChangeEvent.idl b/dom/network/interfaces/nsIDOMCFStateChangeEvent.idl index dfe2db1522dd..0b8d9fd93df6 100644 --- a/dom/network/interfaces/nsIDOMCFStateChangeEvent.idl +++ b/dom/network/interfaces/nsIDOMCFStateChangeEvent.idl @@ -10,7 +10,7 @@ interface nsIDOMCFStateChangeEvent : nsIDOMEvent /** * Indicates about errors while setting up the Call forwarding rule. */ - readonly attribute bool success; + readonly attribute boolean success; /** * Indicates what to do with the rule. diff --git a/dom/network/interfaces/nsIDOMUSSDReceivedEvent.idl b/dom/network/interfaces/nsIDOMUSSDReceivedEvent.idl index 93618c5e7019..b859890ad87e 100644 --- a/dom/network/interfaces/nsIDOMUSSDReceivedEvent.idl +++ b/dom/network/interfaces/nsIDOMUSSDReceivedEvent.idl @@ -19,6 +19,6 @@ interface nsIDOMUSSDReceivedEvent : nsIDOMEvent dictionary USSDReceivedEventInit : EventInit { - DOMString message; + DOMString? message; boolean sessionEnded; }; diff --git a/dom/webidl/BlobEvent.webidl b/dom/webidl/BlobEvent.webidl new file mode 100644 index 000000000000..770a071455f1 --- /dev/null +++ b/dom/webidl/BlobEvent.webidl @@ -0,0 +1,17 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ +interface Blob; + +[Constructor(DOMString type, optional BlobEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface BlobEvent : Event +{ + readonly attribute Blob? data; +}; + +dictionary BlobEventInit : EventInit +{ + Blob? data = null; +}; diff --git a/dom/webidl/BluetoothDeviceEvent.webidl b/dom/webidl/BluetoothDeviceEvent.webidl new file mode 100644 index 000000000000..744e0861e513 --- /dev/null +++ b/dom/webidl/BluetoothDeviceEvent.webidl @@ -0,0 +1,17 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ +interface BluetoothDevice; + +[Constructor(DOMString type, optional BluetoothDeviceEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface BluetoothDeviceEvent : Event +{ + readonly attribute BluetoothDevice? device; +}; + +dictionary BluetoothDeviceEventInit : EventInit +{ + BluetoothDevice? device = null; +}; diff --git a/dom/webidl/CFStateChangeEvent.webidl b/dom/webidl/CFStateChangeEvent.webidl index 6e425c84ba7b..998ff80b6d97 100644 --- a/dom/webidl/CFStateChangeEvent.webidl +++ b/dom/webidl/CFStateChangeEvent.webidl @@ -1,12 +1,26 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* 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/. */ + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ -dictionary CFStateChangeEventDict { - boolean success = false; - short action = -1; - short reason = -1; - DOMString? number = null; - short timeSeconds = -1; - short serviceClass = -1; +[Constructor(DOMString type, optional CFStateChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface CFStateChangeEvent : Event +{ + readonly attribute boolean success; + readonly attribute unsigned short action; + readonly attribute unsigned short reason; + readonly attribute DOMString? number; + readonly attribute unsigned short timeSeconds; + readonly attribute unsigned short serviceClass; +}; + +dictionary CFStateChangeEventInit : EventInit +{ + boolean success = false; + unsigned short action = 0; + unsigned short reason = 0; + DOMString number = ""; + unsigned short timeSeconds = 0; + unsigned short serviceClass = 0; }; diff --git a/dom/webidl/CallEvent.webidl b/dom/webidl/CallEvent.webidl new file mode 100644 index 000000000000..83db7db030ca --- /dev/null +++ b/dom/webidl/CallEvent.webidl @@ -0,0 +1,17 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ +interface TelephonyCall; + +[Constructor(DOMString type, optional CallEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface CallEvent : Event +{ + readonly attribute TelephonyCall? call; +}; + +dictionary CallEventInit : EventInit +{ + TelephonyCall? call = null; +}; diff --git a/dom/webidl/CloseEvent.webidl b/dom/webidl/CloseEvent.webidl new file mode 100644 index 000000000000..220da9c34b88 --- /dev/null +++ b/dom/webidl/CloseEvent.webidl @@ -0,0 +1,35 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + * + * The nsIDOMCloseEvent interface is the interface to the event + * close on a WebSocket object. + * + * For more information on this interface, please see + * http://www.whatwg.org/specs/web-apps/current-work/multipage/network.html#closeevent + */ + +[Constructor(DOMString type, optional CloseEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface CloseEvent : Event +{ + readonly attribute boolean wasClean; + readonly attribute unsigned short code; + readonly attribute DOMString? reason; + + // initCloseEvent is a Gecko specific deprecated method. + [Throws] + void initCloseEvent(DOMString type, + boolean canBubble, + boolean cancelable, + boolean wasClean, + unsigned short code, + DOMString? reason); +}; + +dictionary CloseEventInit : EventInit +{ + boolean wasClean = false; + unsigned short code = 0; + DOMString reason = ""; +}; diff --git a/dom/webidl/CustomEvent.webidl b/dom/webidl/CustomEvent.webidl index 9cf373250915..e4c541b523a2 100644 --- a/dom/webidl/CustomEvent.webidl +++ b/dom/webidl/CustomEvent.webidl @@ -6,15 +6,25 @@ * The origin of this IDL file is * http://www.w3.org/TR/2012/WD-dom-20120105/ * - * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C * liability, trademark and document use rules apply. */ -[Constructor(DOMString type, optional CustomEventInit eventInitDict)] -interface CustomEvent : Event { +[Constructor(DOMString type, optional CustomEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface CustomEvent : Event +{ + [Throws] readonly attribute any detail; + + // initCustomEvent is a Gecko specific deprecated method. + [Throws] + void initCustomEvent(DOMString type, + boolean canBubble, + boolean cancelable, + any detail); }; -dictionary CustomEventInit : EventInit { - any detail; +dictionary CustomEventInit : EventInit +{ + any detail = null; }; diff --git a/dom/webidl/DOMTransactionEvent.webidl b/dom/webidl/DOMTransactionEvent.webidl new file mode 100644 index 000000000000..959ca2483db5 --- /dev/null +++ b/dom/webidl/DOMTransactionEvent.webidl @@ -0,0 +1,23 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional DOMTransactionEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface DOMTransactionEvent : Event +{ + [Throws] + readonly attribute any transactions; + + [Throws] + void initDOMTransactionEvent(DOMString type, + boolean canBubble, + boolean cancelable, + any transactions); +}; + +dictionary DOMTransactionEventInit : EventInit +{ + any transactions = null; +}; diff --git a/dom/webidl/DataErrorEvent.webidl b/dom/webidl/DataErrorEvent.webidl new file mode 100644 index 000000000000..2e66a2578655 --- /dev/null +++ b/dom/webidl/DataErrorEvent.webidl @@ -0,0 +1,16 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional DataErrorEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface DataErrorEvent : Event +{ + readonly attribute DOMString? message; +}; + +dictionary DataErrorEventInit : EventInit +{ + DOMString message = ""; +}; diff --git a/dom/webidl/DeviceLightEvent.webidl b/dom/webidl/DeviceLightEvent.webidl new file mode 100644 index 000000000000..c238b77e2c60 --- /dev/null +++ b/dom/webidl/DeviceLightEvent.webidl @@ -0,0 +1,16 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional DeviceLightEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface DeviceLightEvent : Event +{ + readonly attribute double value; +}; + +dictionary DeviceLightEventInit : EventInit +{ + unrestricted double value = Infinity; +}; diff --git a/dom/webidl/DeviceOrientationEvent.webidl b/dom/webidl/DeviceOrientationEvent.webidl new file mode 100644 index 000000000000..8e3ad7adbf92 --- /dev/null +++ b/dom/webidl/DeviceOrientationEvent.webidl @@ -0,0 +1,32 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional DeviceOrientationEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface DeviceOrientationEvent : Event +{ + readonly attribute double alpha; + readonly attribute double beta; + readonly attribute double gamma; + readonly attribute boolean absolute; + + // initDeviceOrientationEvent is a Gecko specific deprecated method. + [Throws] + void initDeviceOrientationEvent(DOMString type, + boolean canBubble, + boolean cancelable, + double alpha, + double beta, + double gamma, + boolean absolute); +}; + +dictionary DeviceOrientationEventInit : EventInit +{ + double alpha = 0; + double beta = 0; + double gamma = 0; + boolean absolute = false; +}; diff --git a/dom/webidl/DeviceProximityEvent.webidl b/dom/webidl/DeviceProximityEvent.webidl new file mode 100644 index 000000000000..44ff14b55f8e --- /dev/null +++ b/dom/webidl/DeviceProximityEvent.webidl @@ -0,0 +1,20 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional DeviceProximityEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface DeviceProximityEvent : Event +{ + readonly attribute double value; + readonly attribute double min; + readonly attribute double max; +}; + +dictionary DeviceProximityEventInit : EventInit +{ + unrestricted double value = Infinity; + unrestricted double min = -Infinity; + unrestricted double max = Infinity; +}; diff --git a/dom/webidl/DeviceStorageChangeEvent.webidl b/dom/webidl/DeviceStorageChangeEvent.webidl new file mode 100644 index 000000000000..494501250840 --- /dev/null +++ b/dom/webidl/DeviceStorageChangeEvent.webidl @@ -0,0 +1,18 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional DeviceStorageChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface DeviceStorageChangeEvent : Event +{ + readonly attribute DOMString? path; + readonly attribute DOMString? reason; +}; + +dictionary DeviceStorageChangeEventInit : EventInit +{ + DOMString path = ""; + DOMString reason = ""; +}; diff --git a/dom/webidl/DummyBinding.webidl b/dom/webidl/DummyBinding.webidl index d8f3981e9bab..7bdfbbe7dd3f 100644 --- a/dom/webidl/DummyBinding.webidl +++ b/dom/webidl/DummyBinding.webidl @@ -10,8 +10,6 @@ interface DummyInterface { readonly attribute OnErrorEventHandlerNonNull onErrorEventHandler; FilePropertyBag fileBag(); - CFStateChangeEventDict cfstateChangeEvent(); - USSDReceivedEventDict ussdReceivedEvent(); InspectorRGBTriple rgbTriple(); Function getFunction(); void funcSocketsDict(optional SocketsDict arg); diff --git a/dom/webidl/ElementReplaceEvent.webidl b/dom/webidl/ElementReplaceEvent.webidl new file mode 100644 index 000000000000..6090657f29fd --- /dev/null +++ b/dom/webidl/ElementReplaceEvent.webidl @@ -0,0 +1,23 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional ElementReplaceEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface ElementReplaceEvent : Event +{ + readonly attribute Element? upgrade; + + // initElementReplaceEvent is a Gecko specific deprecated method. + [Throws] + void initElementReplaceEvent(DOMString type, + boolean canBubble, + boolean cancelable, + Element? upgrade); +}; + +dictionary ElementReplaceEventInit : EventInit +{ + Element? upgrade = null; +}; diff --git a/dom/webidl/GamepadAxisMoveEvent.webidl b/dom/webidl/GamepadAxisMoveEvent.webidl new file mode 100644 index 000000000000..d22789d0ff3d --- /dev/null +++ b/dom/webidl/GamepadAxisMoveEvent.webidl @@ -0,0 +1,18 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional GamepadAxisMoveEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface GamepadAxisMoveEvent : GamepadEvent +{ + readonly attribute unsigned long axis; + readonly attribute double value; +}; + +dictionary GamepadAxisMoveEventInit : GamepadEventInit +{ + unsigned long axis = 0; + double value = 0; +}; diff --git a/dom/webidl/GamepadButtonEvent.webidl b/dom/webidl/GamepadButtonEvent.webidl new file mode 100644 index 000000000000..2e4352d554f8 --- /dev/null +++ b/dom/webidl/GamepadButtonEvent.webidl @@ -0,0 +1,16 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional GamepadButtonEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface GamepadButtonEvent : GamepadEvent +{ + readonly attribute unsigned long button; +}; + +dictionary GamepadButtonEventInit : GamepadEventInit +{ + unsigned long button = 0; +}; diff --git a/dom/webidl/GamepadEvent.webidl b/dom/webidl/GamepadEvent.webidl new file mode 100644 index 000000000000..c559b482b382 --- /dev/null +++ b/dom/webidl/GamepadEvent.webidl @@ -0,0 +1,16 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional GamepadEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface GamepadEvent : Event +{ + readonly attribute Gamepad? gamepad; +}; + +dictionary GamepadEventInit : EventInit +{ + Gamepad? gamepad = null; +}; diff --git a/dom/webidl/HashChangeEvent.webidl b/dom/webidl/HashChangeEvent.webidl new file mode 100644 index 000000000000..a43b4a244074 --- /dev/null +++ b/dom/webidl/HashChangeEvent.webidl @@ -0,0 +1,26 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional HashChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface HashChangeEvent : Event +{ + readonly attribute DOMString? oldURL; + readonly attribute DOMString? newURL; + + // initHashChangeEvent is a Gecko specific deprecated method. + [Throws] + void initHashChangeEvent(DOMString type, + boolean canBubble, + boolean cancelable, + DOMString? oldURL, + DOMString? newURL); +}; + +dictionary HashChangeEventInit : EventInit +{ + DOMString oldURL = ""; + DOMString newURL = ""; +}; diff --git a/dom/webidl/IccCardLockErrorEvent.webidl b/dom/webidl/IccCardLockErrorEvent.webidl new file mode 100644 index 000000000000..4b64f6954415 --- /dev/null +++ b/dom/webidl/IccCardLockErrorEvent.webidl @@ -0,0 +1,18 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional IccCardLockErrorEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface IccCardLockErrorEvent : Event +{ + readonly attribute DOMString? lockType; + readonly attribute long retryCount; +}; + +dictionary IccCardLockErrorEventInit : EventInit +{ + DOMString lockType = ""; + long retryCount = 0; +}; diff --git a/dom/webidl/MozApplicationEvent.webidl b/dom/webidl/MozApplicationEvent.webidl new file mode 100644 index 000000000000..b37d606e0960 --- /dev/null +++ b/dom/webidl/MozApplicationEvent.webidl @@ -0,0 +1,17 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ +interface mozIDOMApplication; + +[Constructor(DOMString type, optional MozApplicationEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface MozApplicationEvent : Event +{ + readonly attribute mozIDOMApplication? application; +}; + +dictionary MozApplicationEventInit : EventInit +{ + mozIDOMApplication? application = null; +}; diff --git a/dom/webidl/MozCellBroadcastEvent.webidl b/dom/webidl/MozCellBroadcastEvent.webidl new file mode 100644 index 000000000000..b82ebf097c5e --- /dev/null +++ b/dom/webidl/MozCellBroadcastEvent.webidl @@ -0,0 +1,17 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ +interface MozCellBroadcastMessage; + +[Constructor(DOMString type, optional MozCellBroadcastEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface MozCellBroadcastEvent : Event +{ + readonly attribute MozCellBroadcastMessage? message; +}; + +dictionary MozCellBroadcastEventInit : EventInit +{ + MozCellBroadcastMessage? message = null; +}; diff --git a/dom/webidl/MozContactChangeEvent.webidl b/dom/webidl/MozContactChangeEvent.webidl new file mode 100644 index 000000000000..d31087276727 --- /dev/null +++ b/dom/webidl/MozContactChangeEvent.webidl @@ -0,0 +1,18 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional MozContactChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface MozContactChangeEvent : Event +{ + readonly attribute DOMString? contactID; + readonly attribute DOMString? reason; +}; + +dictionary MozContactChangeEventInit : EventInit +{ + DOMString contactID = ""; + DOMString reason = ""; +}; diff --git a/dom/webidl/MozMmsEvent.webidl b/dom/webidl/MozMmsEvent.webidl new file mode 100644 index 000000000000..4883a63a72f6 --- /dev/null +++ b/dom/webidl/MozMmsEvent.webidl @@ -0,0 +1,17 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ +interface MozMmsMessage; + +[Constructor(DOMString type, optional MozMmsEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface MozMmsEvent : Event +{ + readonly attribute MozMmsMessage? message; +}; + +dictionary MozMmsEventInit : EventInit +{ + MozMmsMessage? message = null; +}; diff --git a/dom/webidl/MozSettingsEvent.webidl b/dom/webidl/MozSettingsEvent.webidl new file mode 100644 index 000000000000..a534f3ae8357 --- /dev/null +++ b/dom/webidl/MozSettingsEvent.webidl @@ -0,0 +1,19 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional MozSettingsEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface MozSettingsEvent : Event +{ + readonly attribute DOMString? settingName; + [Throws] + readonly attribute any settingValue; +}; + +dictionary MozSettingsEventInit : EventInit +{ + DOMString settingName = ""; + any settingValue = null; +}; diff --git a/dom/webidl/MozSmsEvent.webidl b/dom/webidl/MozSmsEvent.webidl new file mode 100644 index 000000000000..e7d2db66779d --- /dev/null +++ b/dom/webidl/MozSmsEvent.webidl @@ -0,0 +1,17 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ +interface MozSmsMessage; + +[Constructor(DOMString type, optional MozSmsEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface MozSmsEvent : Event +{ + readonly attribute MozSmsMessage? message; +}; + +dictionary MozSmsEventInit : EventInit +{ + MozSmsMessage? message = null; +}; diff --git a/dom/webidl/MozVoicemailEvent.webidl b/dom/webidl/MozVoicemailEvent.webidl new file mode 100644 index 000000000000..119b03f18b53 --- /dev/null +++ b/dom/webidl/MozVoicemailEvent.webidl @@ -0,0 +1,17 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ +interface MozVoicemailStatus; + +[Constructor(DOMString type, optional MozVoicemailEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface MozVoicemailEvent : Event +{ + readonly attribute MozVoicemailStatus? status; +}; + +dictionary MozVoicemailEventInit : EventInit +{ + MozVoicemailStatus? status = null; +}; diff --git a/dom/webidl/MozWifiConnectionInfoEvent.webidl b/dom/webidl/MozWifiConnectionInfoEvent.webidl new file mode 100644 index 000000000000..6caca8e8fb4c --- /dev/null +++ b/dom/webidl/MozWifiConnectionInfoEvent.webidl @@ -0,0 +1,25 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional MozWifiConnectionInfoEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface MozWifiConnectionInfoEvent : Event +{ + [Throws] + readonly attribute any network; + readonly attribute short signalStrength; + readonly attribute short relSignalStrength; + readonly attribute long linkSpeed; + readonly attribute DOMString? ipAddress; +}; + +dictionary MozWifiConnectionInfoEventInit : EventInit +{ + any network = null; + short signalStrength = 0; + short relSignalStrength = 0; + long linkSpeed = 0; + DOMString ipAddress = ""; +}; diff --git a/dom/webidl/MozWifiStatusChangeEvent.webidl b/dom/webidl/MozWifiStatusChangeEvent.webidl new file mode 100644 index 000000000000..a3fc99fb47e8 --- /dev/null +++ b/dom/webidl/MozWifiStatusChangeEvent.webidl @@ -0,0 +1,19 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional MozWifiStatusChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface MozWifiStatusChangeEvent : Event +{ + [Throws] + readonly attribute any network; + readonly attribute DOMString? status; +}; + +dictionary MozWifiStatusChangeEventInit : EventInit +{ + any network = null; + DOMString status = ""; +}; diff --git a/dom/webidl/PageTransitionEvent.webidl b/dom/webidl/PageTransitionEvent.webidl new file mode 100644 index 000000000000..2925602995a8 --- /dev/null +++ b/dom/webidl/PageTransitionEvent.webidl @@ -0,0 +1,23 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional PageTransitionEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface PageTransitionEvent : Event +{ + readonly attribute boolean persisted; + + // initPageTransitionEvent is a Gecko specific deprecated method. + [Throws] + void initPageTransitionEvent(DOMString type, + boolean canBubble, + boolean cancelable, + boolean persisted); +}; + +dictionary PageTransitionEventInit : EventInit +{ + boolean persisted = false; +}; diff --git a/dom/webidl/PopStateEvent.webidl b/dom/webidl/PopStateEvent.webidl new file mode 100644 index 000000000000..f1b5c8fa84c6 --- /dev/null +++ b/dom/webidl/PopStateEvent.webidl @@ -0,0 +1,24 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional PopStateEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface PopStateEvent : Event +{ + [Throws] + readonly attribute any state; + + // initPopStateEvent is a Gecko specific deprecated method. + [Throws] + void initPopStateEvent(DOMString type, + boolean canBubble, + boolean cancelable, + any state); +}; + +dictionary PopStateEventInit : EventInit +{ + any state = null; +}; diff --git a/dom/webidl/PopupBlockedEvent.webidl b/dom/webidl/PopupBlockedEvent.webidl new file mode 100644 index 000000000000..16f6ca453f4c --- /dev/null +++ b/dom/webidl/PopupBlockedEvent.webidl @@ -0,0 +1,33 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ +interface Window; +interface URI; + +[Constructor(DOMString type, optional PopupBlockedEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface PopupBlockedEvent : Event +{ + readonly attribute Window? requestingWindow; + readonly attribute URI? popupWindowURI; + readonly attribute DOMString? popupWindowName; + readonly attribute DOMString? popupWindowFeatures; + + [Throws] + void initPopupBlockedEvent(DOMString type, + boolean canBubble, + boolean cancelable, + Window? requestingWindow, + URI? popupWindowURI, + DOMString? popupWindowName, + DOMString? popupWindowFeatures); +}; + +dictionary PopupBlockedEventInit : EventInit +{ + Window? requestingWindow = null; + URI? popupWindowURI = null; + DOMString popupWindowName = ""; + DOMString popupWindowFeatures = ""; +}; diff --git a/dom/webidl/ProgressEvent.webidl b/dom/webidl/ProgressEvent.webidl new file mode 100644 index 000000000000..997f88719b52 --- /dev/null +++ b/dom/webidl/ProgressEvent.webidl @@ -0,0 +1,20 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional ProgressEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface ProgressEvent : Event +{ + readonly attribute boolean lengthComputable; + readonly attribute unsigned long long loaded; + readonly attribute unsigned long long total; +}; + +dictionary ProgressEventInit : EventInit +{ + boolean lengthComputable = false; + unsigned long long loaded = 0; + unsigned long long total = 0; +}; diff --git a/dom/webidl/SmartCardEvent.webidl b/dom/webidl/SmartCardEvent.webidl new file mode 100644 index 000000000000..f2515b02d82d --- /dev/null +++ b/dom/webidl/SmartCardEvent.webidl @@ -0,0 +1,16 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional SmartCardEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface SmartCardEvent : Event +{ + readonly attribute DOMString? tokenName; +}; + +dictionary SmartCardEventInit : EventInit +{ + DOMString tokenName = ""; +}; diff --git a/dom/webidl/SpeechRecognitionError.webidl b/dom/webidl/SpeechRecognitionError.webidl new file mode 100644 index 000000000000..91725a59128c --- /dev/null +++ b/dom/webidl/SpeechRecognitionError.webidl @@ -0,0 +1,27 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional SpeechRecognitionErrorInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface SpeechRecognitionError : Event +{ + const unsigned long NO_SPEECH = 0; + const unsigned long ABORTED = 1; + const unsigned long AUDIO_CAPTURE = 2; + const unsigned long NETWORK = 3; + const unsigned long NOT_ALLOWED = 4; + const unsigned long SERVICE_NOT_ALLOWED = 5; + const unsigned long BAD_GRAMMAR = 6; + const unsigned long LANGUAGE_NOT_SUPPORTED = 7; + + readonly attribute unsigned long error; + readonly attribute DOMString? message; +}; + +dictionary SpeechRecognitionErrorInit : EventInit +{ + unsigned long error = 0; + DOMString message = ""; +}; diff --git a/dom/webidl/SpeechRecognitionEvent.webidl b/dom/webidl/SpeechRecognitionEvent.webidl new file mode 100644 index 000000000000..b64db97aae8c --- /dev/null +++ b/dom/webidl/SpeechRecognitionEvent.webidl @@ -0,0 +1,23 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ +interface nsISupports; + +[Constructor(DOMString type, optional SpeechRecognitionEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface SpeechRecognitionEvent : Event +{ + readonly attribute unsigned long resultIndex; + readonly attribute nsISupports? results; + readonly attribute DOMString? interpretation; + readonly attribute Document? emma; +}; + +dictionary SpeechRecognitionEventInit : EventInit +{ + unsigned long resultIndex = 0; + nsISupports? results = null; + DOMString interpretation = ""; + Document? emma = null; +}; diff --git a/dom/webidl/SpeechSynthesisEvent.webidl b/dom/webidl/SpeechSynthesisEvent.webidl index 15902ab0c64f..33219ecaf664 100644 --- a/dom/webidl/SpeechSynthesisEvent.webidl +++ b/dom/webidl/SpeechSynthesisEvent.webidl @@ -9,10 +9,18 @@ * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C * liability, trademark and document use rules apply. */ -interface Event; -interface SpeechSynthesisEvent : Event { +[Constructor(DOMString type, optional SpeechSynthesisEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface SpeechSynthesisEvent : Event +{ readonly attribute unsigned long charIndex; readonly attribute float elapsedTime; - readonly attribute DOMString name; + readonly attribute DOMString? name; +}; + +dictionary SpeechSynthesisEventInit : EventInit +{ + unsigned long charIndex = 0; + float elapsedTime = 0; + DOMString name = ""; }; diff --git a/dom/webidl/StorageEvent.webidl b/dom/webidl/StorageEvent.webidl new file mode 100644 index 000000000000..b74779252f45 --- /dev/null +++ b/dom/webidl/StorageEvent.webidl @@ -0,0 +1,42 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + * + * Interface for a client side storage. See + * http://dev.w3.org/html5/webstorage/#the-storage-event + * for more information. + * + * Event sent to a window when a storage area changes. + */ +interface Storage; + +[Constructor(DOMString type, optional StorageEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface StorageEvent : Event +{ + readonly attribute DOMString? key; + readonly attribute DOMString? oldValue; + readonly attribute DOMString? newValue; + readonly attribute DOMString? url; + readonly attribute Storage? storageArea; + + // initStorageEvent is a Gecko specific deprecated method. + [Throws] + void initStorageEvent(DOMString type, + boolean canBubble, + boolean cancelable, + DOMString? key, + DOMString? oldValue, + DOMString? newValue, + DOMString? url, + Storage? storageArea); +}; + +dictionary StorageEventInit : EventInit +{ + DOMString? key = null; + DOMString? oldValue = null; + DOMString? newValue = null; + DOMString url = ""; + Storage? storageArea = null; +}; diff --git a/dom/webidl/StyleRuleChangeEvent.webidl b/dom/webidl/StyleRuleChangeEvent.webidl new file mode 100644 index 000000000000..1e211edddf9e --- /dev/null +++ b/dom/webidl/StyleRuleChangeEvent.webidl @@ -0,0 +1,19 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ +interface CSSRule; + +[Constructor(DOMString type, optional StyleRuleChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface StyleRuleChangeEvent : Event +{ + readonly attribute CSSStyleSheet? stylesheet; + readonly attribute CSSRule? rule; +}; + +dictionary StyleRuleChangeEventInit : EventInit +{ + CSSStyleSheet? stylesheet = null; + CSSRule? rule = null; +}; diff --git a/dom/webidl/StyleSheetApplicableStateChangeEvent.webidl b/dom/webidl/StyleSheetApplicableStateChangeEvent.webidl new file mode 100644 index 000000000000..483a386cdf7d --- /dev/null +++ b/dom/webidl/StyleSheetApplicableStateChangeEvent.webidl @@ -0,0 +1,18 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional StyleSheetApplicableStateChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface StyleSheetApplicableStateChangeEvent : Event +{ + readonly attribute CSSStyleSheet? stylesheet; + readonly attribute boolean applicable; +}; + +dictionary StyleSheetApplicableStateChangeEventInit : EventInit +{ + CSSStyleSheet? stylesheet = null; + boolean applicable = false; +}; diff --git a/dom/webidl/StyleSheetChangeEvent.webidl b/dom/webidl/StyleSheetChangeEvent.webidl new file mode 100644 index 000000000000..b6019d83145d --- /dev/null +++ b/dom/webidl/StyleSheetChangeEvent.webidl @@ -0,0 +1,18 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional StyleSheetChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface StyleSheetChangeEvent : Event +{ + readonly attribute CSSStyleSheet? stylesheet; + readonly attribute boolean documentSheet; +}; + +dictionary StyleSheetChangeEventInit : EventInit +{ + CSSStyleSheet? stylesheet = null; + boolean documentSheet = false; +}; diff --git a/dom/webidl/USSDReceivedEvent.webidl b/dom/webidl/USSDReceivedEvent.webidl index cda66e66851b..b7fa9098f66e 100644 --- a/dom/webidl/USSDReceivedEvent.webidl +++ b/dom/webidl/USSDReceivedEvent.webidl @@ -4,7 +4,15 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ -dictionary USSDReceivedEventDict { +[Constructor(DOMString type, optional USSDReceivedEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface USSDReceivedEvent : Event +{ + readonly attribute DOMString? message; + readonly attribute boolean sessionEnded; +}; + +dictionary USSDReceivedEventInit : EventInit +{ DOMString? message = null; boolean sessionEnded = false; -}; \ No newline at end of file +}; diff --git a/dom/webidl/UserProximityEvent.webidl b/dom/webidl/UserProximityEvent.webidl new file mode 100644 index 000000000000..8b64b81c9be2 --- /dev/null +++ b/dom/webidl/UserProximityEvent.webidl @@ -0,0 +1,16 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ + +[Constructor(DOMString type, optional UserProximityEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +interface UserProximityEvent : Event +{ + readonly attribute boolean near; +}; + +dictionary UserProximityEventInit : EventInit +{ + boolean near = false; +}; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 17b57365b89b..2ce7c97dcb9c 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -32,7 +32,6 @@ webidl_files = \ CanvasRenderingContext2D.webidl \ CaretPosition.webidl \ CDATASection.webidl \ - CFStateChangeEvent.webidl \ ChannelMergerNode.webidl \ ChannelSplitterNode.webidl \ CharacterData.webidl \ @@ -344,7 +343,6 @@ webidl_files = \ WheelEvent.webidl \ UndoManager.webidl \ URLUtils.webidl \ - USSDReceivedEvent.webidl \ VideoStreamTrack.webidl \ WaveShaperNode.webidl \ WaveTable.webidl \ @@ -391,6 +389,7 @@ webidl_files += \ SpeechSynthesisUtterance.webidl \ SpeechSynthesisVoice.webidl \ SpeechSynthesis.webidl \ + SpeechSynthesisEvent.webidl \ $(NULL) endif @@ -406,6 +405,69 @@ webidl_files += \ $(NULL) endif +webidl_files += \ + ProgressEvent.webidl \ + StorageEvent.webidl \ + DeviceProximityEvent.webidl \ + MozSettingsEvent.webidl \ + UserProximityEvent.webidl \ + CustomEvent.webidl \ + PageTransitionEvent.webidl \ + DOMTransactionEvent.webidl \ + PopStateEvent.webidl \ + HashChangeEvent.webidl \ + CloseEvent.webidl \ + MozContactChangeEvent.webidl \ + DeviceOrientationEvent.webidl \ + DeviceLightEvent.webidl \ + MozApplicationEvent.webidl \ + SmartCardEvent.webidl \ + StyleRuleChangeEvent.webidl \ + StyleSheetChangeEvent.webidl \ + StyleSheetApplicableStateChangeEvent.webidl \ + ElementReplaceEvent.webidl \ + MozSmsEvent.webidl \ + MozMmsEvent.webidl \ + DeviceStorageChangeEvent.webidl \ + PopupBlockedEvent.webidl \ + BlobEvent.webidl \ + $(NULL) + +ifdef MOZ_B2G_BT +webidl_files += \ + BluetoothDeviceEvent.webidl \ + $(NULL) +endif + +ifdef MOZ_B2G_RIL +webidl_files += \ + CallEvent.webidl \ + CFStateChangeEvent.webidl \ + DataErrorEvent.webidl \ + IccCardLockErrorEvent.webidl \ + MozWifiStatusChangeEvent.webidl \ + MozWifiConnectionInfoEvent.webidl \ + MozCellBroadcastEvent.webidl \ + MozVoicemailEvent.webidl \ + USSDReceivedEvent.webidl \ + $(NULL) +endif + +ifdef MOZ_GAMEPAD +webidl_files += \ + GamepadEvent.webidl \ + GamepadButtonEvent.webidl \ + GamepadAxisMoveEvent.webidl \ + $(NULL) +endif + +ifdef MOZ_WEBSPEECH +webidl_files += \ + SpeechRecognitionEvent.webidl \ + SpeechRecognitionError.webidl \ + $(NULL) +endif + ifdef ENABLE_TESTS test_webidl_files := \ TestCodeGen.webidl \ diff --git a/js/xpconnect/src/Makefile.in b/js/xpconnect/src/Makefile.in index f76cd151ec28..bd92293ba6a1 100644 --- a/js/xpconnect/src/Makefile.in +++ b/js/xpconnect/src/Makefile.in @@ -117,7 +117,10 @@ GeneratedEvents.h: $(srcdir)/dictionary_helper_gen.conf \ --header-output GeneratedEvents.h \ event_impl_gen.conf +GeneratedEventClasses.h: GeneratedEvents.cpp + GeneratedEvents.cpp: DictionaryHelpers.h \ + GeneratedEvents.h \ $(srcdir)/dictionary_helper_gen.conf \ event_impl_gen.conf \ $(srcdir)/dictionary_helper_gen.py \ @@ -130,13 +133,23 @@ GeneratedEvents.cpp: DictionaryHelpers.h \ -I$(LIBXUL_DIST)/sdk/bin \ $(srcdir)/event_impl_gen.py \ -I $(DEPTH)/dist/idl \ - --header-output GeneratedEvents.h \ + --class-declarations GeneratedEventClasses.h \ --stub-output GeneratedEvents.cpp \ --makedepend-output $(MDDEPDIR)/event_impl_gen.pp \ event_impl_gen.conf +GeneratedEvents-webidl: event_impl_gen.conf + $(PYTHON) $(topsrcdir)/config/pythonpath.py \ + $(PLY_INCLUDE) \ + -I$(LIBXUL_DIST)/sdk/bin \ + $(srcdir)/event_impl_gen.py \ + -I $(DEPTH)/dist/idl \ + --webidltarget=$(top_srcdir)/dom/webidl \ + event_impl_gen.conf + _EXTRA_EXPORT_FILES = \ DictionaryHelpers.h \ + GeneratedEventClasses.h \ $(NULL) libs:: $(_EXTRA_EXPORT_FILES) @@ -149,6 +162,7 @@ GARBAGE += \ DictionaryHelpers.cpp \ GeneratedEvents.h \ GeneratedEvents.cpp \ + GeneratedEventClasses.h \ event_impl_gen.conf \ xpidl_debug \ $(MDDEPDIR)/dom_qsgen.pp \ diff --git a/js/xpconnect/src/event_impl_gen.conf.in b/js/xpconnect/src/event_impl_gen.conf.in index c0b5709421ef..b12a11c952bc 100644 --- a/js/xpconnect/src/event_impl_gen.conf.in +++ b/js/xpconnect/src/event_impl_gen.conf.in @@ -75,3 +75,12 @@ exclude_automatic_type_include = [ 'mozIDOMApplication', 'nsIDOMBlob' ] + +""" Map xpidl interface names to implementation classes. The third column is the canonical interface. """ +xpidl_to_native = [ + ['nsIDOMDocument', 'nsIDocument', 'nsIDocument'], + ['nsIDOMElement', 'mozilla::dom::Element', 'mozilla::dom::Element'], + ['nsIDOMCSSStyleSheet', 'nsCSSStyleSheet', 'nsIStyleSheet'], + ['nsIDOMGamepad', 'nsDOMGamepad', 'nsIDOMGamepad'] + ] + diff --git a/js/xpconnect/src/event_impl_gen.py b/js/xpconnect/src/event_impl_gen.py index fdbefadc67ca..28fd074da207 100644 --- a/js/xpconnect/src/event_impl_gen.py +++ b/js/xpconnect/src/event_impl_gen.py @@ -23,22 +23,24 @@ def findIDL(includePath, interfaceFileName): "in include path %r" % (interfaceFileName, includePath)) +eventFileNameToIdl = {}; + def loadIDL(parser, includePath, filename): + global eventFileNameToIdl + if filename in eventFileNameToIdl: + return eventFileNameToIdl[filename] + idlFile = findIDL(includePath, filename) if not idlFile in makeutils.dependencies: makeutils.dependencies.append(idlFile) idl = p.parse(open(idlFile).read(), idlFile) idl.resolve(includePath, p) + eventFileNameToIdl[filename] = idl return idl def loadEventIDL(parser, includePath, eventname): eventidl = ("nsIDOM%s.idl" % eventname) - idlFile = findIDL(includePath, eventidl) - if not idlFile in makeutils.dependencies: - makeutils.dependencies.append(idlFile) - idl = p.parse(open(idlFile).read(), idlFile) - idl.resolve(includePath, p) - return idl + return loadIDL(parser, includePath, eventidl) class Configuration: def __init__(self, filename): @@ -47,6 +49,7 @@ class Configuration: self.simple_events = config.get('simple_events', []) self.special_includes = config.get('special_includes', []) self.exclude_automatic_type_include = config.get('exclude_automatic_type_include', []) + self.xpidl_to_native = config.get('xpidl_to_native', []) def readConfigFile(filename): return Configuration(filename) @@ -54,6 +57,12 @@ def readConfigFile(filename): def firstCap(str): return str[0].upper() + str[1:] +def getBaseName(iface): + basename = ("%s" % iface.base[6:]) + if (basename == "Event"): + basename = "nsDOMEvent" + return basename + def print_header_file(fd, conf): fd.write("#if defined MOZ_GENERATED_EVENT_LIST\n") for e in conf.simple_events: @@ -84,6 +93,138 @@ def print_header_file(fd, conf): fd.write("\n#endif\n") fd.write("#endif\n") +def print_classes_file(fd, conf): + fd.write("#ifndef _gen_mozilla_idl_generated_event_declarations_h_\n") + fd.write("#define _gen_mozilla_idl_generated_event_declarations_h_\n\n") + + fd.write("#include \"nsDOMEvent.h\"\n"); + includes = [] + for s in conf.special_includes: + if not s in includes: + includes.append(strip_end(s, ".h")) + + for e in conf.simple_events: + if not e in includes: + includes.append(("nsIDOM%s" % e)) + + attrnames = [] + for e in conf.simple_events: + idl = loadEventIDL(p, options.incdirs, e) + collect_names_and_non_primitive_attribute_types(idl, attrnames, includes) + + for c in includes: + if not c in conf.exclude_automatic_type_include: + fd.write("#include \"%s.h\"\n" % c) + + for e in conf.simple_events: + fd.write('#include "mozilla/dom/%sBinding.h"\n' % e); + + fd.write("namespace mozilla {\n") + fd.write("namespace dom {\n") + for e in conf.simple_events: + idl = loadEventIDL(p, options.incdirs, e) + for pr in idl.productions: + if pr.kind == 'interface': + print_class_declaration(e, pr, fd, conf) + fd.write("} // namespace dom\n") + fd.write("} // namespace mozilla\n\n") + fd.write("#endif\n"); + +def print_class_declaration(eventname, iface, fd, conf): + classname = ("%s" % eventname) + basename = getBaseName(iface) + attributes = [] + ccattributes = [] + for member in iface.members: + if isinstance(member, xpidl.Attribute): + attributes.append(member) + if (member.realtype.nativeType('in').endswith('*')): + ccattributes.append(member); + + baseinterfaces = [] + baseiface = iface.idl.getName(iface.base, iface.location) + while baseiface.name != "nsIDOMEvent": + baseinterfaces.append(baseiface) + baseiface = baseiface.idl.getName(baseiface.base, baseiface.location) + baseinterfaces.reverse() + + allattributes = [] + for baseiface in baseinterfaces: + for member in baseiface.members: + if isinstance(member, xpidl.Attribute): + allattributes.append(member) + allattributes.extend(attributes); + + fd.write("\nclass %s : public %s, public %s\n" % (classname, basename, iface.name)) + fd.write("{\n") + fd.write("public:\n") + fd.write(" %s(mozilla::dom::EventTarget* aOwner, " % classname) + fd.write("nsPresContext* aPresContext = nullptr, nsEvent* aEvent = nullptr);\n"); + fd.write(" virtual ~%s();\n\n" % classname) + fd.write(" NS_DECL_ISUPPORTS_INHERITED\n") + fd.write(" NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(%s, %s)\n" % (classname, basename)) + fd.write(" NS_FORWARD_TO_NSDOMEVENT\n") + + for baseiface in baseinterfaces: + baseimpl = ("%s" % baseiface.name[6:]) + if (baseimpl == "Event"): + baseimpl = "nsDOMEvent" + fd.write(" NS_FORWARD_%s(%s::)\n" % (baseiface.name.upper(), baseimpl)) + + fd.write(" NS_DECL_%s\n" % iface.name.upper()) + fd.write(" virtual nsresult InitFromCtor(const nsAString& aType, JSContext* aCx, jsval* aVal);\n\n") + + hasVariant = False + for a in allattributes: + if a.type == "nsIVariant": + hasVariant = True + break; + fd.write(" static already_AddRefed<%s> Constructor(const GlobalObject& aGlobal, " % eventname) + if hasVariant: + fd.write("JSContext* aCx, ") + fd.write("const nsAString& aType, ") + fd.write("const %sInit& aParam, " % eventname) + fd.write("ErrorResult& aRv);\n\n") + + fd.write(" virtual JSObject* WrapObject(JSContext* aCx, JS::Handle aScope) MOZ_OVERRIDE\n") + fd.write(" {\n") + fd.write(" return mozilla::dom::%sBinding::Wrap(aCx, aScope, this);\n" % eventname) + fd.write(" }\n\n") + + for a in attributes: + """xpidl methods take care of string member variables!""" + firstCapName = firstCap(a.name) + cleanNativeType = a.realtype.nativeType('in').strip('* ') + if a.realtype.nativeType('in').count("nsAString"): + continue + elif a.realtype.nativeType('in').count("nsIVariant"): + fd.write(" JS::Value Get%s(JSContext* aCx, ErrorResult& aRv);\n\n" % firstCapName); + elif a.realtype.nativeType('in').endswith('*'): + fd.write(" already_AddRefed<%s> Get%s()\n" % (xpidl_to_native(cleanNativeType, conf), firstCapName)) + fd.write(" {\n"); + fd.write(" nsCOMPtr<%s> %s = do_QueryInterface(m%s);\n" % (xpidl_to_canonical(cleanNativeType, conf), a.name, firstCapName)) + fd.write(" return %s.forget().downcast<%s>();\n" % (a.name, xpidl_to_native(cleanNativeType, conf))) + fd.write(" }\n\n"); + else: + fd.write(" %s %s()\n" % (cleanNativeType, firstCapName)) + fd.write(" {\n"); + fd.write(" return m%s;\n" % firstCapName) + fd.write(" }\n\n"); + + fd.write(" void ") + fd.write("Init%s(" % eventname) + if hasVariant: + fd.write("JSContext* aCx, ") + fd.write("const nsAString& aType, bool aCanBubble, bool aCancelable") + for a in allattributes: + writeNativeAttributeParams(fd, a, conf) + fd.write(", ErrorResult& aRv);\n\n") + + fd.write("protected:\n") + for a in attributes: + fd.write(" %s\n" % attributeVariableTypeAndName(a)) + fd.write("};\n") + def collect_names_and_non_primitive_attribute_types(idl, attrnames, forwards): for p in idl.productions: if p.kind == 'interface' or p.kind == 'dictionary': @@ -114,39 +255,20 @@ def collect_names_and_non_primitive_attribute_types_from_interface(iface, attrna def print_cpp(idl, fd, conf, eventname): for p in idl.productions: if p.kind == 'interface': - write_cpp(eventname, p, fd) + write_cpp(eventname, p, fd, conf) def print_cpp_file(fd, conf): fd.write("/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n") - fd.write('#include "GeneratedEvents.h"\n') + fd.write('#include "GeneratedEventClasses.h"\n') + fd.write('#include "xpcprivate.h"\n'); fd.write('#include "nsDOMClassInfoID.h"\n') fd.write('#include "nsPresContext.h"\n') fd.write('#include "nsGUIEvent.h"\n') fd.write('#include "nsDOMEvent.h"\n'); fd.write('#include "mozilla/dom/EventTarget.h"\n'); - includes = [] - for s in conf.special_includes: - if not s in includes: - includes.append(strip_end(s, ".h")) - - for e in conf.simple_events: - if not e in includes: - includes.append(("nsIDOM%s" % e)) - - attrnames = [] for e in conf.simple_events: idl = loadEventIDL(p, options.incdirs, e) - collect_names_and_non_primitive_attribute_types(idl, attrnames, includes) - - for c in includes: - if not c in conf.exclude_automatic_type_include: - fd.write("#include \"%s.h\"\n" % c) - - for e in conf.simple_events: - idlname = ("nsIDOM%s.idl" % e) - idl = p.parse(open(findIDL(options.incdirs, idlname)).read(), idlname) - idl.resolve(options.incdirs, p) print_cpp(idl, fd, conf, e) def init_value(attribute): @@ -197,9 +319,20 @@ def writeAttributeGetter(fd, classname, a): elif a.realtype.nativeType('in').count("nsACString"): fd.write(" a%s = m%s;\n" % (firstCap(a.name), firstCap(a.name))) else: - fd.write(" *a%s = m%s;\n" % (firstCap(a.name), firstCap(a.name))) + fd.write(" *a%s = %s();\n" % (firstCap(a.name), firstCap(a.name))) fd.write(" return NS_OK;\n"); fd.write("}\n\n"); + if a.realtype.nativeType('in').count("nsIVariant"): + fd.write("JS::Value\n") + fd.write("%s::Get%s(JSContext* aCx, ErrorResult& aRv)\n" % (classname, firstCap(a.name))) + fd.write("{\n") + fd.write(" JS::Rooted retVal(aCx, JS::NullValue());\n"); + fd.write(" nsresult rv = NS_ERROR_UNEXPECTED;\n") + fd.write(" if (m%s && !XPCVariant::VariantDataToJS(m%s, &rv, retVal.address())) {\n" % (firstCap(a.name), firstCap(a.name))) + fd.write(" aRv.Throw(NS_ERROR_FAILURE);\n") + fd.write(" }\n") + fd.write(" return retVal;\n"); + fd.write("}\n\n") def writeAttributeParams(fd, a): if a.realtype.nativeType('in').endswith('*'): @@ -211,9 +344,21 @@ def writeAttributeParams(fd, a): else: fd.write(", %s a%s" % (a.realtype.nativeType('in'), firstCap(a.name))) -def write_cpp(eventname, iface, fd): - classname = ("nsDOM%s" % eventname) - basename = ("ns%s" % iface.base[3:]) +def writeNativeAttributeParams(fd, a, conf): + if a.type == "nsIVariant": + fd.write(", JS::Value a%s" % firstCap(a.name)); + elif a.realtype.nativeType('in').endswith('*'): + fd.write(", %s* a%s" % (xpidl_to_native(a.realtype.nativeType('in').strip('* '), conf), firstCap(a.name))) + elif a.realtype.nativeType('in').count("nsAString"): + fd.write(", const nsAString& a%s" % firstCap(a.name)) + elif a.realtype.nativeType('in').count("nsACString"): + fd.write(", const nsACString& a%s" % firstCap(a.name)) + else: + fd.write(", %s a%s" % (a.realtype.nativeType('in'), firstCap(a.name))) + +def write_cpp(eventname, iface, fd, conf): + classname = ("%s" % eventname) + basename = getBaseName(iface) attributes = [] ccattributes = [] for member in iface.members: @@ -235,31 +380,23 @@ def write_cpp(eventname, iface, fd): if isinstance(member, xpidl.Attribute): baseattributes.append(member) + allattributes = [] + allattributes.extend(baseattributes); + allattributes.extend(attributes); - fd.write("\nclass %s : public %s, public %s\n" % (classname, basename, iface.name)) - fd.write("{\n") - fd.write("public:\n") - fd.write(" %s(mozilla::dom::EventTarget* aOwner, " % classname) - fd.write("nsPresContext* aPresContext = nullptr, nsEvent* aEvent = nullptr)\n"); - fd.write(" : %s(aOwner, aPresContext, aEvent)" % basename) + fd.write("namespace mozilla {\n") + fd.write("namespace dom {\n\n") + + fd.write("%s::%s(mozilla::dom::EventTarget* aOwner, " % (classname, classname)) + fd.write("nsPresContext* aPresContext, nsEvent* aEvent)\n"); + fd.write(": %s(aOwner, aPresContext, aEvent)" % basename) for a in attributes: - fd.write(",\n m%s(%s)" % (firstCap(a.name), init_value(a))) - fd.write("\n {}\n") - fd.write(" virtual ~%s() {}\n\n" % classname) - fd.write(" NS_DECL_ISUPPORTS_INHERITED\n") - fd.write(" NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(%s, %s)\n" % (classname, basename)) - fd.write(" NS_FORWARD_TO_NSDOMEVENT\n") + fd.write(",\n m%s(%s)" % (firstCap(a.name), init_value(a))) + fd.write("\n{\n") + fd.write(" SetIsDOMBinding();\n") + fd.write("}\n\n") - for baseiface in baseinterfaces: - baseimpl = ("ns%s" % baseiface.name[3:]) - fd.write(" NS_FORWARD_%s(%s::)\n" % (baseiface.name.upper(), baseimpl)) - - fd.write(" NS_DECL_%s\n" % iface.name.upper()) - fd.write(" virtual nsresult InitFromCtor(const nsAString& aType, JSContext* aCx, jsval* aVal);\n") - fd.write("protected:\n") - for a in attributes: - fd.write(" %s\n" % attributeVariableTypeAndName(a)) - fd.write("};\n\n") + fd.write("%s::~%s() {}\n\n" % (classname, classname)) fd.write("NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(%s, %s)\n" % (classname, basename)) for c in ccattributes: @@ -272,8 +409,11 @@ def write_cpp(eventname, iface, fd): fd.write("NS_IMPL_ADDREF_INHERITED(%s, %s)\n" % (classname, basename)) fd.write("NS_IMPL_RELEASE_INHERITED(%s, %s)\n\n" % (classname, basename)) - - fd.write("DOMCI_DATA(%s, %s)\n\n" % (eventname, classname)) + fd.write("} // namespace dom\n") + fd.write("} // namespace mozilla\n\n") + fd.write("DOMCI_DATA(%s, mozilla::dom::%s)\n\n" % (eventname, classname)) + fd.write("namespace mozilla {\n") + fd.write("namespace dom {\n\n") fd.write("NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(%s)\n" % classname) fd.write(" NS_INTERFACE_MAP_ENTRY(nsIDOM%s)\n" % eventname) @@ -287,22 +427,46 @@ def write_cpp(eventname, iface, fd): fd.write(" nsresult rv = d.Init(aCx, aVal);\n") fd.write(" NS_ENSURE_SUCCESS(rv, rv);\n") fd.write(" return Init%s(aType, d.bubbles, d.cancelable" % eventname) - for a in baseattributes: - fd.write(", d.%s" % a.name) - for a in attributes: + for a in allattributes: fd.write(", d.%s" % a.name) fd.write(");\n") fd.write("}\n\n") + hasVariant = False + for a in allattributes: + if a.type == "nsIVariant": + hasVariant = True + break; + + fd.write("already_AddRefed<%s>\n" % eventname) + fd.write("%s::Constructor(const GlobalObject& aGlobal, " % eventname) + if hasVariant: + fd.write("JSContext* aCx, "); + fd.write("const nsAString& aType, ") + fd.write("const %sInit& aParam, " % eventname) + fd.write("ErrorResult& aRv)\n") + fd.write("{\n") + fd.write(" nsCOMPtr t = do_QueryInterface(aGlobal.Get());\n") + fd.write(" nsRefPtr<%s> e = new %s(t, nullptr, nullptr);\n" % (eventname, eventname)) + fd.write(" bool trusted = e->Init(t);\n") + fd.write(" e->Init%s(" % eventname) + if hasVariant: + fd.write("aCx, "); + fd.write("aType, aParam.mBubbles, aParam.mCancelable") + for a in allattributes: + fd.write(", aParam.m%s" % firstCap(a.name)) + fd.write(", aRv);\n") + fd.write(" e->SetTrusted(trusted);\n") + fd.write(" return e.forget();\n") + fd.write("}\n\n") + fd.write("NS_IMETHODIMP\n") fd.write("%s::Init%s(" % (classname, eventname)) fd.write("const nsAString& aType, bool aCanBubble, bool aCancelable") - for a in baseattributes: - writeAttributeParams(fd, a) - for a in attributes: + for a in allattributes: writeAttributeParams(fd, a) fd.write(")\n{\n") - fd.write(" nsresult rv = %s::Init%s(aType, aCanBubble, aCancelable" % (basename, basename[5:])) + fd.write(" nsresult rv = %s::Init%s(aType, aCanBubble, aCancelable" % (basename, ("%s" % iface.base[6:]))) for a in baseattributes: fd.write(", a%s" % firstCap(a.name)) fd.write(");\n"); @@ -312,17 +476,249 @@ def write_cpp(eventname, iface, fd): fd.write(" return NS_OK;\n") fd.write("}\n\n") + fd.write("void\n") + fd.write("%s::Init%s(" % (classname, eventname)) + if hasVariant: + fd.write("JSContext* aCx, ") + fd.write("const nsAString& aType, bool aCanBubble, bool aCancelable") + for a in allattributes: + writeNativeAttributeParams(fd, a, conf) + fd.write(", ErrorResult& aRv") + fd.write(")\n") + fd.write("{\n"); + for a in allattributes: + if a.type == "nsIVariant": + fd.write(" nsCOMPtr %s = dont_AddRef(XPCVariant::newVariant(aCx, a%s));\n" % (a.name, firstCap(a.name))) + fd.write(" if (!%s) {\n" % a.name) + fd.write(" aRv.Throw(NS_ERROR_FAILURE);\n") + fd.write(" return;\n") + fd.write(" }\n") + elif a.realtype.nativeType('in').endswith('*'): + xpidl_t = a.realtype.nativeType('in').strip('* ') + native_t = xpidl_to_native(xpidl_t, conf) + if xpidl_t != native_t: + fd.write(" nsCOMPtr<%s> %s = do_QueryInterface(static_cast<%s*>(a%s));\n" % (xpidl_t, a.name, xpidl_to_canonical(xpidl_t, conf), firstCap(a.name))) + fd.write(" aRv = Init%s(" % classname); + fd.write("aType, aCanBubble, aCancelable") + for a in allattributes: + if a.realtype.nativeType('in').endswith('*'): + xpidl_t = a.realtype.nativeType('in').strip('* ') + native_t = xpidl_to_native(xpidl_t, conf) + if xpidl_t != native_t or a.type == "nsIVariant": + fd.write(", %s" % a.name) + continue + fd.write(", a%s" % firstCap(a.name)) + fd.write(");\n}\n\n"); + for a in attributes: writeAttributeGetter(fd, classname, a) + fd.write("} // namespace dom\n") + fd.write("} // namespace mozilla\n\n") + fd.write("nsresult\n") fd.write("NS_NewDOM%s(nsIDOMEvent** aInstance, " % eventname) fd.write("mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext = nullptr, nsEvent* aEvent = nullptr)\n") fd.write("{\n") - fd.write(" %s* it = new %s(aOwner, aPresContext, aEvent);\n" % (classname, classname)) + fd.write(" mozilla::dom::%s* it = new mozilla::dom::%s(aOwner, aPresContext, aEvent);\n" % (classname, classname)) fd.write(" return CallQueryInterface(it, aInstance);\n") fd.write("}\n\n") +def toWebIDLType(attribute, inType=False, onlyInterface=False): + if attribute.type == "nsIVariant": + return "any"; + if attribute.type == "nsISupports": + return "%s%s" % (attribute.type, "" if onlyInterface else "?") + if attribute.type.count("nsIDOM"): + return "%s%s" % (attribute.type[6:], "" if onlyInterface else "?") + if attribute.type.count("nsI"): + return "%s%s" % (attribute.type[3:], "" if onlyInterface else "?") + if attribute.realtype.nativeType('in').endswith('*') or attribute.realtype.nativeType('in').count("nsAString"): + return "%s%s" % (attribute.type, "" if onlyInterface else "?") + return attribute.type + +def write_webidl(eventname, iface, fd, conf, idl): + basename = ("%s" % iface.base[6:]) + attributes = [] + ccattributes = [] + consts = [] + hasInit = False + initMethod = "init%s" % eventname; + for member in iface.members: + if isinstance(member, xpidl.Attribute): + attributes.append(member) + if (member.realtype.nativeType('in').endswith('*')): + ccattributes.append(member); + elif isinstance(member, xpidl.Method) and member.name == initMethod: + if not member.noscript and not member.notxpcom: + hasInit = True + elif isinstance(member, xpidl.ConstMember): + consts.append(member); + else: + raise BaseException("Unsupported idl member %s::%s" % (eventname, member.name)) + + baseinterfaces = [] + baseiface = iface.idl.getName(iface.base, iface.location) + while baseiface.name != "nsIDOMEvent": + baseinterfaces.append(baseiface) + baseiface = baseiface.idl.getName(baseiface.base, baseiface.location) + baseinterfaces.reverse() + + allattributes = [] + for baseiface in baseinterfaces: + for member in baseiface.members: + if isinstance(member, xpidl.Attribute): + allattributes.append(member) + allattributes.extend(attributes) + + fd.write( +"""/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + */ +""") + + neededInterfaces = [] + for a in attributes: + if a.realtype.nativeType('in').endswith('*'): + nativeType = a.realtype.nativeType('in').strip('* ') + mappingForWebIDL = False + for xp in conf.xpidl_to_native: + if xp[0] == nativeType: + mappingForWebIDL = True + break; + if not mappingForWebIDL: + webidlType = toWebIDLType(a, False, True) + if (not webidlType in neededInterfaces and webidlType != "any"): + neededInterfaces.append(webidlType); + + for i in neededInterfaces: + fd.write("interface %s;\n" % i) + + fd.write("\n"); + fd.write("[Constructor(DOMString type, optional %sInit eventInitDict), HeaderFile=\"GeneratedEventClasses.h\"]\n" % eventname); + fd.write("interface %s : %s\n" % (eventname, basename)) + fd.write("{\n") + + for c in consts: + fd.write(" const %s %s = %s;\n" % (c.type, c.name, c.getValue())) + if len(consts): + fd.write("\n") + + for a in attributes: + if a.realtype.nativeType('in').count("nsIVariant"): + fd.write(" [Throws]\n") + fd.write(" readonly attribute %s %s;\n" % (toWebIDLType(a), a.name)) + elif a.realtype.nativeType('in').endswith('*') or a.realtype.nativeType('in').count("nsAString"): + fd.write(" readonly attribute %s %s;\n" % (toWebIDLType(a), a.name)) + else: + fd.write(" readonly attribute %s %s;\n" % (a.type, a.name)) + if hasInit: + fd.write("\n [Throws]\n") + m = " void %s(" % initMethod + fd.write(m) + indent = "".join(" " for i in range(len(m))) + indent = ",\n%s" % indent + fd.write("DOMString type") + fd.write(indent); + fd.write("boolean canBubble") + fd.write(indent); + fd.write("boolean cancelable") + for a in baseattributes + attributes: + fd.write(indent); + fd.write("%s %s" % (toWebIDLType(a, True), a.name)) + fd.write(");\n"); + fd.write("};\n\n") + + dname = "%sInit" % eventname + for p in idl.productions: + if p.kind == "dictionary" and p.name == dname: + fd.write("dictionary %s : %sInit\n" % (dname, basename)) + fd.write("{\n") + # We want to keep the same ordering what interface has. + for ifaceattribute in attributes: + for member in p.members: + if member.name == ifaceattribute.name: + a = member + if a.realtype.nativeType('in').endswith('*'): + fd.write(" %s %s = null;\n" % (toWebIDLType(a, True), a.name)) + elif a.realtype.nativeType('in').count("nsAString"): + if a.defvalue is None: + if a.nullable: + fd.write(" %s? %s = null;\n" % (a.type, a.name)) + else: + fd.write(" %s %s = \"\";\n" % (a.type, a.name)) + else: + if a.nullable: + fd.write(" %s? %s = \"%s\";\n" % (a.type, a.name, a.defvalue)) + else: + fd.write(" %s %s = \"%s\";\n" % (a.type, a.name, a.defvalue)) + else: + if a.defvalue is None: + if a.type == "boolean": + fd.write(" %s %s = false;\n" % (a.type, a.name)) + else: + fd.write(" %s %s = 0;\n" % (a.type, a.name)) + # Infinity is not supported by all the types, but + # WebIDL parser will then complain about the wrong values. + elif a.defvalue == "Infinity": + fd.write(" unrestricted %s %s = Infinity;\n" % (a.type, a.name)) + elif a.defvalue == "-Infinity": + fd.write(" unrestricted %s %s = -Infinity;\n" % (a.type, a.name)) + else: + fd.write(" %s %s = %s;\n" % (a.type, a.name, a.defvalue)) + continue + fd.write("};\n") + return + + # There is no dictionary defined in the .idl file. Generate one based on + # the interface. + fd.write("dictionary %s : %sInit\n" % (dname, basename)) + fd.write("{\n") + for a in attributes: + if a.realtype.nativeType('in').endswith('*'): + fd.write(" %s %s = null;\n" % (toWebIDLType(a, True), a.name)) + elif a.realtype.nativeType('in').count("nsAString"): + fd.write(" %s? %s = \"\";\n" % (a.type, a.name)) + elif a.type == "boolean": + fd.write(" %s %s = false;\n" % (a.type, a.name)) + else: + fd.write(" %s %s = 0;\n" % (a.type, a.name)) + fd.write("};\n") + +def print_webidl_file(idl, fd, conf, eventname): + for p in idl.productions: + if p.kind == 'interface': + write_webidl(eventname, p, fd, conf, idl) + +def xpidl_to_native(xpidl, conf): + for x in conf.xpidl_to_native: + if x[0] == xpidl: + return x[1] + return xpidl + +def xpidl_to_canonical(xpidl, conf): + for x in conf.xpidl_to_native: + if x[0] == xpidl: + return x[2] + return xpidl + +def native_to_xpidl(native, conf): + for x in conf.xpidl_to_native: + if x[1] == native: + return x[0] + return native + +def print_webidl_files(webidlDir, conf): + for e in conf.simple_events: + idl = loadEventIDL(p, options.incdirs, e) + webidl = "%s/%s.webidl" % (webidlDir, e) + if not os.path.exists(webidl): + fd = open(webidl, 'w') + print_webidl_file(idl, fd, conf, e) + fd.close(); + if __name__ == '__main__': from optparse import OptionParser o = OptionParser(usage="usage: %prog [options] configfile") @@ -337,6 +733,10 @@ if __name__ == '__main__': help="gnumake dependencies output file", metavar="FILE") o.add_option('--cachedir', dest='cachedir', default=None, help="Directory in which to cache lex/parse tables.") + o.add_option('--class-declarations', type='string', default=None, + help="Class declarations", metavar="FILE") + o.add_option('--webidltarget', dest='webidltarget', default=None, + help="Directory in which to store generated WebIDL files.") (options, filenames) = o.parse_args() if len(filenames) != 1: o.error("Exactly one config filename is needed.") @@ -352,6 +752,14 @@ if __name__ == '__main__': conf = readConfigFile(filename) + if options.header_output is not None: + outfd = open(options.header_output, 'w') + print_header_file(outfd, conf) + outfd.close() + if options.class_declarations is not None: + outfd = open(options.class_declarations, 'w') + print_classes_file(outfd, conf) + outfd.close() if options.stub_output is not None: makeutils.targets.append(options.stub_output) outfd = open(options.stub_output, 'w') @@ -359,8 +767,7 @@ if __name__ == '__main__': outfd.close() if options.makedepend_output is not None: makeutils.writeMakeDependOutput(options.makedepend_output) - if options.header_output is not None: - outfd = open(options.header_output, 'w') - print_header_file(outfd, conf) - outfd.close() + + if options.webidltarget is not None: + print_webidl_files(options.webidltarget, conf) From f1dc3f5c2d615c28ca6008709933d55861c1ff21 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Tue, 18 Jun 2013 12:22:56 -0700 Subject: [PATCH 14/90] Bug 879809 - Don't export MOZBUILD_BACKEND_CHECKED to independent build systems; r=ted --- config/rules.mk | 20 ++++++++++---------- js/src/config/rules.mk | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/config/rules.mk b/config/rules.mk index 5f97168a1a3a..deb86b3e8dce 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -416,15 +416,20 @@ ifdef MOZ_UPDATE_XTERM UPDATE_TITLE = printf "\033]0;%s in %s\007" $(1) $(shell $(BUILD_TOOLS)/print-depth-path.sh)/$(2) ; endif -define SUBMAKE # $(call SUBMAKE,target,directory) +# Static directories are largely independent of our build system. But, they +# could share the same build mechanism (like moz.build files). We need to +# prevent leaking of our backend state to these independent build systems. This +# is why MOZBUILD_BACKEND_CHECKED isn't exported to make invocations for static +# directories. +define SUBMAKE # $(call SUBMAKE,target,directory,static) +@$(UPDATE_TITLE) -+$(MAKE) $(if $(2),-C $(2)) $(1) ++$(if $(3), MOZBUILD_BACKEND_CHECKED=,) $(MAKE) $(if $(2),-C $(2)) $(1) endef # The extra line is important here! don't delete it define TIER_DIR_SUBMAKE @echo "BUILDSTATUS TIERDIR_START $(2)" -$(call SUBMAKE,$(1),$(2)) +$(call SUBMAKE,$(1),$(2),$(3)) @echo "BUILDSTATUS TIERDIR_FINISH $(2)" endef # Ths empty line is important. @@ -441,11 +446,6 @@ LOOP_OVER_PARALLEL_DIRS = \ $(foreach dir,$(PARALLEL_DIRS),$(call SUBMAKE,$@,$(dir))) endif -ifneq (,$(strip $(STATIC_DIRS))) -LOOP_OVER_STATIC_DIRS = \ - $(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,$@,$(dir))) -endif - ifneq (,$(strip $(TOOL_DIRS))) LOOP_OVER_TOOL_DIRS = \ $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,$@,$(dir))) @@ -671,7 +671,7 @@ else default all:: ifneq (,$(strip $(STATIC_DIRS))) - $(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,,$(dir))) + $(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,,$(dir),1)) endif $(MAKE) export $(MAKE) libs @@ -715,7 +715,7 @@ endif @echo "BUILDSTATUS DIRS $$($$@_dirs)" ifneq (,$(tier_$(1)_staticdirs)) @echo "BUILDSTATUS SUBTIER_START $(1) static" - $$(foreach dir,$$($$@_staticdirs),$$(call TIER_DIR_SUBMAKE,,$$(dir))) + $$(foreach dir,$$($$@_staticdirs),$$(call TIER_DIR_SUBMAKE,,$$(dir),1)) @echo "BUILDSTATUS SUBTIER_FINISH $(1) static" endif ifneq (,$(tier_$(1)_dirs)) diff --git a/js/src/config/rules.mk b/js/src/config/rules.mk index 5f97168a1a3a..deb86b3e8dce 100644 --- a/js/src/config/rules.mk +++ b/js/src/config/rules.mk @@ -416,15 +416,20 @@ ifdef MOZ_UPDATE_XTERM UPDATE_TITLE = printf "\033]0;%s in %s\007" $(1) $(shell $(BUILD_TOOLS)/print-depth-path.sh)/$(2) ; endif -define SUBMAKE # $(call SUBMAKE,target,directory) +# Static directories are largely independent of our build system. But, they +# could share the same build mechanism (like moz.build files). We need to +# prevent leaking of our backend state to these independent build systems. This +# is why MOZBUILD_BACKEND_CHECKED isn't exported to make invocations for static +# directories. +define SUBMAKE # $(call SUBMAKE,target,directory,static) +@$(UPDATE_TITLE) -+$(MAKE) $(if $(2),-C $(2)) $(1) ++$(if $(3), MOZBUILD_BACKEND_CHECKED=,) $(MAKE) $(if $(2),-C $(2)) $(1) endef # The extra line is important here! don't delete it define TIER_DIR_SUBMAKE @echo "BUILDSTATUS TIERDIR_START $(2)" -$(call SUBMAKE,$(1),$(2)) +$(call SUBMAKE,$(1),$(2),$(3)) @echo "BUILDSTATUS TIERDIR_FINISH $(2)" endef # Ths empty line is important. @@ -441,11 +446,6 @@ LOOP_OVER_PARALLEL_DIRS = \ $(foreach dir,$(PARALLEL_DIRS),$(call SUBMAKE,$@,$(dir))) endif -ifneq (,$(strip $(STATIC_DIRS))) -LOOP_OVER_STATIC_DIRS = \ - $(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,$@,$(dir))) -endif - ifneq (,$(strip $(TOOL_DIRS))) LOOP_OVER_TOOL_DIRS = \ $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,$@,$(dir))) @@ -671,7 +671,7 @@ else default all:: ifneq (,$(strip $(STATIC_DIRS))) - $(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,,$(dir))) + $(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,,$(dir),1)) endif $(MAKE) export $(MAKE) libs @@ -715,7 +715,7 @@ endif @echo "BUILDSTATUS DIRS $$($$@_dirs)" ifneq (,$(tier_$(1)_staticdirs)) @echo "BUILDSTATUS SUBTIER_START $(1) static" - $$(foreach dir,$$($$@_staticdirs),$$(call TIER_DIR_SUBMAKE,,$$(dir))) + $$(foreach dir,$$($$@_staticdirs),$$(call TIER_DIR_SUBMAKE,,$$(dir),1)) @echo "BUILDSTATUS SUBTIER_FINISH $(1) static" endif ifneq (,$(tier_$(1)_dirs)) From 257553f813aea225a7ea1247d4c2032f0fceed2a Mon Sep 17 00:00:00 2001 From: Jim Chen Date: Tue, 18 Jun 2013 15:49:14 -0400 Subject: [PATCH 15/90] Bug 880650 - Clean up hiding/showing VKB in the awesome screen; r=cpeterson --- mobile/android/base/AndroidManifest.xml.in | 2 +- mobile/android/base/AwesomeBar.java | 8 ++------ mobile/android/base/AwesomeBarTabs.java | 1 - .../android/base/resources/layout/awesomebar_search.xml | 1 - 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/mobile/android/base/AndroidManifest.xml.in b/mobile/android/base/AndroidManifest.xml.in index 7104da143c35..e5ec47c8d1b6 100644 --- a/mobile/android/base/AndroidManifest.xml.in +++ b/mobile/android/base/AndroidManifest.xml.in @@ -229,7 +229,7 @@ + android:windowSoftInputMode="stateUnspecified|adjustResize"/> - Date: Tue, 18 Jun 2013 15:49:14 -0400 Subject: [PATCH 16/90] Bug 880650 - Add selectAll call to URL bar initialization; r=cpeterson --- mobile/android/base/AwesomeBar.java | 1 + 1 file changed, 1 insertion(+) diff --git a/mobile/android/base/AwesomeBar.java b/mobile/android/base/AwesomeBar.java index f71a9ce0a6fb..bfc0de266fdd 100644 --- a/mobile/android/base/AwesomeBar.java +++ b/mobile/android/base/AwesomeBar.java @@ -142,6 +142,7 @@ public class AwesomeBar extends GeckoActivity String currentUrl = intent.getStringExtra(CURRENT_URL_KEY); if (currentUrl != null) { mText.setText(currentUrl); + mText.selectAll(); } mTarget = intent.getStringExtra(TARGET_KEY); From d8d660431d7e4088a45e9687f114105839b10285 Mon Sep 17 00:00:00 2001 From: Jim Chen Date: Tue, 18 Jun 2013 15:49:14 -0400 Subject: [PATCH 17/90] Bug 880650 - Don't try to dismiss VKB during testBookmarksTab; r=adrian.tamas --- mobile/android/base/tests/BaseTest.java.in | 3 --- 1 file changed, 3 deletions(-) diff --git a/mobile/android/base/tests/BaseTest.java.in b/mobile/android/base/tests/BaseTest.java.in index 21573e996e9c..c6593fcbe784 100644 --- a/mobile/android/base/tests/BaseTest.java.in +++ b/mobile/android/base/tests/BaseTest.java.in @@ -692,7 +692,6 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2 { mActions.sendKeys(addedText); mSolo.clickOnText("OK"); waitForText("Bookmark updated"); - toggleVKB(); // close the VKB } public boolean checkBookmarkEdit(int bookmarkIndex, String addedText, ListView list) { @@ -712,12 +711,10 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2 { if (mSolo.searchText(addedText)) { clickOnButton("Cancel"); waitForText("about:home"); - toggleVKB(); // close the VKB return true; } else { clickOnButton("Cancel"); waitForText("about:home"); - toggleVKB(); // close the VKB return false; } } From b07368ea2ef4b6959678ae1af1d624bf14b5c754 Mon Sep 17 00:00:00 2001 From: Wan-Teh Chang Date: Tue, 18 Jun 2013 13:01:22 -0700 Subject: [PATCH 18/90] Bug 881841: update to NSS_3_15_1_BETA2. r=wtc. --- security/nss/TAG-INFO | 2 +- security/nss/cmd/certutil/certutil.c | 7 +- security/nss/cmd/checkcert/checkcert.c | 6 +- security/nss/cmd/crlutil/crlutil.c | 6 +- security/nss/cmd/derdump/derdump.c | 2 +- security/nss/cmd/lib/secutil.c | 10 +- security/nss/cmd/lib/secutil.h | 3 +- .../libpkix/pkix/top/test_validatechain_bc.c | 2 +- .../nss/cmd/libpkix/sample_apps/build_chain.c | 2 +- .../nss/cmd/libpkix/sample_apps/dumpcert.c | 2 +- .../nss/cmd/libpkix/sample_apps/dumpcrl.c | 2 +- .../cmd/libpkix/sample_apps/validate_chain.c | 2 +- .../nss/cmd/libpkix/testutil/testutil_nss.c | 4 +- security/nss/cmd/ocspclnt/ocspclnt.c | 2 +- security/nss/cmd/p7content/p7content.c | 2 +- security/nss/cmd/p7sign/p7sign.c | 5 +- security/nss/cmd/p7verify/p7verify.c | 3 +- security/nss/cmd/pk1sign/pk1sign.c | 3 +- security/nss/cmd/pp/pp.c | 2 +- security/nss/cmd/selfserv/selfserv.c | 2 +- security/nss/cmd/shlibsign/shlibsign.c | 8 +- security/nss/cmd/signver/signver.c | 2 +- security/nss/cmd/vfychain/vfychain.c | 2 +- security/nss/coreconf/coreconf.dep | 1 - security/nss/lib/freebl/win_rand.c | 73 +--- .../nss/lib/libpkix/pkix/top/pkix_build.c | 23 +- security/nss/lib/pk11wrap/secmod.h | 2 +- security/nss/lib/ssl/config.mk | 4 - security/nss/lib/ssl/derive.c | 65 +++- security/nss/lib/ssl/ssl3con.c | 335 +++++++++--------- security/nss/lib/ssl/sslimpl.h | 35 +- security/nss/lib/ssl/sslsock.c | 9 +- .../chains/scenarios/nameconstraints.cfg | 22 ++ security/nss/tests/chains/scenarios/scenarios | 1 + .../libpkix/certs/NameConstraints.ca.cert | Bin 0 -> 626 bytes .../certs/NameConstraints.intermediate.cert | Bin 0 -> 662 bytes .../certs/NameConstraints.server1.cert | Bin 0 -> 660 bytes .../certs/NameConstraints.server2.cert | Bin 0 -> 643 bytes .../certs/NameConstraints.server3.cert | Bin 0 -> 660 bytes security/nss/tests/libpkix/certs/make-nc | 103 ++++++ 40 files changed, 450 insertions(+), 304 deletions(-) create mode 100644 security/nss/tests/chains/scenarios/nameconstraints.cfg create mode 100644 security/nss/tests/libpkix/certs/NameConstraints.ca.cert create mode 100644 security/nss/tests/libpkix/certs/NameConstraints.intermediate.cert create mode 100644 security/nss/tests/libpkix/certs/NameConstraints.server1.cert create mode 100644 security/nss/tests/libpkix/certs/NameConstraints.server2.cert create mode 100644 security/nss/tests/libpkix/certs/NameConstraints.server3.cert create mode 100755 security/nss/tests/libpkix/certs/make-nc diff --git a/security/nss/TAG-INFO b/security/nss/TAG-INFO index f5742036e806..4c0a6b7adcd8 100644 --- a/security/nss/TAG-INFO +++ b/security/nss/TAG-INFO @@ -1 +1 @@ -NSS_3_15_1_BETA1 +NSS_3_15_1_BETA2 diff --git a/security/nss/cmd/certutil/certutil.c b/security/nss/cmd/certutil/certutil.c index ba62799eec88..6603e80e1068 100644 --- a/security/nss/cmd/certutil/certutil.c +++ b/security/nss/cmd/certutil/certutil.c @@ -3158,7 +3158,8 @@ merge_fail: certutil.commands[cmd_AddEmailCert].activated) { PRBool isCreate = certutil.commands[cmd_CreateNewCert].activated; rv = SECU_ReadDERFromFile(isCreate ? &certReqDER : &certDER, inFile, - certutil.options[opt_ASCIIForIO].activated); + certutil.options[opt_ASCIIForIO].activated, + PR_TRUE); if (rv) goto shutdown; } @@ -3229,6 +3230,10 @@ merge_fail: if (certutil.commands[cmd_CreateAndAddCert].activated || certutil.commands[cmd_AddCert].activated || certutil.commands[cmd_AddEmailCert].activated) { + if (strstr(certutil.options[opt_Trust].arg, "u")) { + fprintf(stderr, "Notice: Trust flag u is set automatically if the " + "private key is present.\n"); + } rv = AddCert(slot, certHandle, name, certutil.options[opt_Trust].arg, &certDER, diff --git a/security/nss/cmd/checkcert/checkcert.c b/security/nss/cmd/checkcert/checkcert.c index 0cdd2cc28291..63beea5876ed 100644 --- a/security/nss/cmd/checkcert/checkcert.c +++ b/security/nss/cmd/checkcert/checkcert.c @@ -302,7 +302,7 @@ int main(int argc, char **argv) exit(1); } - if (SECU_ReadDERFromFile(&derCert, inFile, ascii) != SECSuccess) { + if (SECU_ReadDERFromFile(&derCert, inFile, ascii, PR_FALSE) != SECSuccess) { printf("Couldn't read input certificate as DER binary or base64\n"); exit(1); } @@ -315,8 +315,8 @@ int main(int argc, char **argv) if (issuerCertFile) { CERTSignedData *issuerCertSD=0; - if (SECU_ReadDERFromFile(&derIssuerCert, issuerCertFile, issuerAscii) - != SECSuccess) { + if (SECU_ReadDERFromFile(&derIssuerCert, issuerCertFile, issuerAscii, + PR_FALSE) != SECSuccess) { printf("Couldn't read issuer certificate as DER binary or base64.\n"); exit(1); } diff --git a/security/nss/cmd/crlutil/crlutil.c b/security/nss/cmd/crlutil/crlutil.c index 301746b5d116..dd9f4932eec2 100644 --- a/security/nss/cmd/crlutil/crlutil.c +++ b/security/nss/cmd/crlutil/crlutil.c @@ -232,7 +232,7 @@ SECStatus ImportCRL (CERTCertDBHandle *certHandle, char *url, int type, /* Read in the entire file specified with the -f argument */ - rv = SECU_ReadDERFromFile(&crlDER, inFile, PR_FALSE); + rv = SECU_ReadDERFromFile(&crlDER, inFile, PR_FALSE, PR_FALSE); if (rv != SECSuccess) { SECU_PrintError(progName, "unable to read input file"); return (SECFailure); @@ -291,7 +291,7 @@ SECStatus DumpCRL(PRFileDesc *inFile) crlDER.data = NULL; /* Read in the entire file specified with the -f argument */ - rv = SECU_ReadDERFromFile(&crlDER, inFile, PR_FALSE); + rv = SECU_ReadDERFromFile(&crlDER, inFile, PR_FALSE, PR_FALSE); if (rv != SECSuccess) { SECU_PrintError(progName, "unable to read input file"); return (SECFailure); @@ -386,7 +386,7 @@ CreateModifiedCRLCopy(PLArenaPool *arena, CERTCertDBHandle *certHandle, } if (inFile != NULL) { - rv = SECU_ReadDERFromFile(&crlDER, inFile, PR_FALSE); + rv = SECU_ReadDERFromFile(&crlDER, inFile, PR_FALSE, PR_FALSE); if (rv != SECSuccess) { SECU_PrintError(progName, "unable to read input file"); PORT_FreeArena(modArena, PR_FALSE); diff --git a/security/nss/cmd/derdump/derdump.c b/security/nss/cmd/derdump/derdump.c index 49d415c1ce7a..3184b1b48b9d 100644 --- a/security/nss/cmd/derdump/derdump.c +++ b/security/nss/cmd/derdump/derdump.c @@ -87,7 +87,7 @@ int main(int argc, char **argv) return -1; } - rv = SECU_ReadDERFromFile(&der, inFile, PR_FALSE); + rv = SECU_ReadDERFromFile(&der, inFile, PR_FALSE, PR_FALSE); if (rv == SECSuccess) { rv = DER_PrettyPrint(outFile, &der, raw); if (rv == SECSuccess) diff --git a/security/nss/cmd/lib/secutil.c b/security/nss/cmd/lib/secutil.c index 4b22702502a2..96273daa0fb9 100644 --- a/security/nss/cmd/lib/secutil.c +++ b/security/nss/cmd/lib/secutil.c @@ -494,7 +494,8 @@ SECU_GetClientAuthData(void *arg, PRFileDesc *fd, } SECStatus -SECU_ReadDERFromFile(SECItem *der, PRFileDesc *inFile, PRBool ascii) +SECU_ReadDERFromFile(SECItem *der, PRFileDesc *inFile, PRBool ascii, + PRBool warnOnPrivateKeyInAsciiFile) { SECStatus rv; if (ascii) { @@ -512,6 +513,11 @@ SECU_ReadDERFromFile(SECItem *der, PRFileDesc *inFile, PRBool ascii) return SECFailure; } + if (warnOnPrivateKeyInAsciiFile && strstr(asc, "PRIVATE KEY")) { + fprintf(stderr, "Warning: ignoring private key. Consider to use " + "pk12util.\n"); + } + /* check for headers and trailers and remove them */ if ((body = strstr(asc, "-----BEGIN")) != NULL) { char *trailer = NULL; @@ -3551,7 +3557,7 @@ SECU_FindCertByNicknameOrFilename(CERTCertDBHandle *handle, if (!fd) { return NULL; } - rv = SECU_ReadDERFromFile(&item, fd, ascii); + rv = SECU_ReadDERFromFile(&item, fd, ascii, PR_FALSE); PR_Close(fd); if (rv != SECSuccess || !item.len) { PORT_Free(item.data); diff --git a/security/nss/cmd/lib/secutil.h b/security/nss/cmd/lib/secutil.h index 022a4d5a8773..71a7f59b8cf5 100644 --- a/security/nss/cmd/lib/secutil.h +++ b/security/nss/cmd/lib/secutil.h @@ -160,7 +160,8 @@ SECU_displayVerifyLog(FILE *outfile, CERTVerifyLog *log, /* Read in a DER from a file, may be ascii */ extern SECStatus -SECU_ReadDERFromFile(SECItem *der, PRFileDesc *inFile, PRBool ascii); +SECU_ReadDERFromFile(SECItem *der, PRFileDesc *inFile, PRBool ascii, + PRBool warnOnPrivateKeyInAsciiFile); /* Print integer value and hex */ extern void SECU_PrintInteger(FILE *out, const SECItem *i, const char *m, diff --git a/security/nss/cmd/libpkix/pkix/top/test_validatechain_bc.c b/security/nss/cmd/libpkix/pkix/top/test_validatechain_bc.c index 29e483f4f26d..cbbfd73a3146 100644 --- a/security/nss/cmd/libpkix/pkix/top/test_validatechain_bc.c +++ b/security/nss/cmd/libpkix/pkix/top/test_validatechain_bc.c @@ -61,7 +61,7 @@ createCert(char *inFileName) pkixTestErrorMsg = "Unable to open cert file"; goto cleanup; } else { - rv = SECU_ReadDERFromFile(&certDER, inFile, PR_FALSE); + rv = SECU_ReadDERFromFile(&certDER, inFile, PR_FALSE, PR_FALSE); if (!rv){ buf = (void *)certDER.data; len = certDER.len; diff --git a/security/nss/cmd/libpkix/sample_apps/build_chain.c b/security/nss/cmd/libpkix/sample_apps/build_chain.c index 11f3005f79af..fa717d9ae5a1 100644 --- a/security/nss/cmd/libpkix/sample_apps/build_chain.c +++ b/security/nss/cmd/libpkix/sample_apps/build_chain.c @@ -66,7 +66,7 @@ createCert(char *inFileName) pkixTestErrorMsg = "Unable to open cert file"; goto cleanup; } else { - rv = SECU_ReadDERFromFile(&certDER, inFile, PR_FALSE); + rv = SECU_ReadDERFromFile(&certDER, inFile, PR_FALSE, PR_FALSE); if (!rv){ buf = (void *)certDER.data; len = certDER.len; diff --git a/security/nss/cmd/libpkix/sample_apps/dumpcert.c b/security/nss/cmd/libpkix/sample_apps/dumpcert.c index 4ee14d695709..55350776356a 100644 --- a/security/nss/cmd/libpkix/sample_apps/dumpcert.c +++ b/security/nss/cmd/libpkix/sample_apps/dumpcert.c @@ -55,7 +55,7 @@ createCert(char *inFileName) printFailure("Unable to open cert file"); goto cleanup; } else { - rv = SECU_ReadDERFromFile(&certDER, inFile, PR_FALSE); + rv = SECU_ReadDERFromFile(&certDER, inFile, PR_FALSE, PR_FALSE); if (!rv){ buf = (void *)certDER.data; len = certDER.len; diff --git a/security/nss/cmd/libpkix/sample_apps/dumpcrl.c b/security/nss/cmd/libpkix/sample_apps/dumpcrl.c index 1f2522ec1a26..cfb84bd4adf6 100644 --- a/security/nss/cmd/libpkix/sample_apps/dumpcrl.c +++ b/security/nss/cmd/libpkix/sample_apps/dumpcrl.c @@ -57,7 +57,7 @@ createCRL(char *inFileName) printFailure("Unable to open crl file"); goto cleanup; } else { - rv = SECU_ReadDERFromFile(&crlDER, inFile, PR_FALSE); + rv = SECU_ReadDERFromFile(&crlDER, inFile, PR_FALSE, PR_FALSE); if (!rv){ buf = (void *)crlDER.data; len = crlDER.len; diff --git a/security/nss/cmd/libpkix/sample_apps/validate_chain.c b/security/nss/cmd/libpkix/sample_apps/validate_chain.c index d9c2a229c2d9..56343a6f6ea4 100644 --- a/security/nss/cmd/libpkix/sample_apps/validate_chain.c +++ b/security/nss/cmd/libpkix/sample_apps/validate_chain.c @@ -65,7 +65,7 @@ createCert(char *inFileName) pkixTestErrorMsg = "Unable to open cert file"; goto cleanup; } else { - rv = SECU_ReadDERFromFile(&certDER, inFile, PR_FALSE); + rv = SECU_ReadDERFromFile(&certDER, inFile, PR_FALSE, PR_FALSE); if (!rv){ buf = (void *)certDER.data; len = certDER.len; diff --git a/security/nss/cmd/libpkix/testutil/testutil_nss.c b/security/nss/cmd/libpkix/testutil/testutil_nss.c index 666190c42c13..4f7cc4096696 100755 --- a/security/nss/cmd/libpkix/testutil/testutil_nss.c +++ b/security/nss/cmd/libpkix/testutil/testutil_nss.c @@ -89,7 +89,7 @@ createCert( pkixTestErrorMsg = "Unable to open cert file"; goto cleanup; } else { - rv = SECU_ReadDERFromFile(&certDER, certFile, PR_FALSE); + rv = SECU_ReadDERFromFile(&certDER, certFile, PR_FALSE, PR_FALSE); if (!rv){ buf = (void *)certDER.data; len = certDER.len; @@ -154,7 +154,7 @@ createCRL( pkixTestErrorMsg = "Unable to open crl file"; goto cleanup; } else { - rv = SECU_ReadDERFromFile(&crlDER, inFile, PR_FALSE); + rv = SECU_ReadDERFromFile(&crlDER, inFile, PR_FALSE, PR_FALSE); if (!rv){ buf = (void *)crlDER.data; len = crlDER.len; diff --git a/security/nss/cmd/ocspclnt/ocspclnt.c b/security/nss/cmd/ocspclnt/ocspclnt.c index ea2a4ce3a781..e302bb5b83ed 100644 --- a/security/nss/cmd/ocspclnt/ocspclnt.c +++ b/security/nss/cmd/ocspclnt/ocspclnt.c @@ -485,7 +485,7 @@ find_certificate(CERTCertDBHandle *handle, const char *name, PRBool ascii) return NULL; } - if (SECU_ReadDERFromFile(&der, certFile, ascii) == SECSuccess) { + if (SECU_ReadDERFromFile(&der, certFile, ascii, PR_FALSE) == SECSuccess) { cert = CERT_DecodeCertFromPackage((char*)der.data, der.len); SECITEM_FreeItem(&der, PR_FALSE); } diff --git a/security/nss/cmd/p7content/p7content.c b/security/nss/cmd/p7content/p7content.c index 59c0ff2cc78f..15f725397a56 100644 --- a/security/nss/cmd/p7content/p7content.c +++ b/security/nss/cmd/p7content/p7content.c @@ -78,7 +78,7 @@ DecodeAndPrintFile(FILE *out, PRFileDesc *in, char *progName) SEC_PKCS7ContentInfo *cinfo = NULL; SEC_PKCS7DecoderContext *dcx; - if (SECU_ReadDERFromFile(&derdata, in, PR_FALSE)) { + if (SECU_ReadDERFromFile(&derdata, in, PR_FALSE, PR_FALSE)) { SECU_PrintError(progName, "error converting der"); return -1; } diff --git a/security/nss/cmd/p7sign/p7sign.c b/security/nss/cmd/p7sign/p7sign.c index df664df1cfc3..d41e1c762b17 100644 --- a/security/nss/cmd/p7sign/p7sign.c +++ b/security/nss/cmd/p7sign/p7sign.c @@ -96,7 +96,8 @@ SignFile(FILE *outFile, PRFileDesc *inFile, CERTCertificate *cert, return -1; /* suck the file in */ - if (SECU_ReadDERFromFile(&data2sign, inFile, PR_FALSE) != SECSuccess) + if (SECU_ReadDERFromFile(&data2sign, inFile, PR_FALSE, + PR_FALSE) != SECSuccess) return -1; if (!encapsulated) { @@ -147,7 +148,7 @@ main(int argc, char **argv) PRFileDesc *inFile; char *keyName = NULL; CERTCertDBHandle *certHandle; - CERTCertificate *cert; + CERTCertificate *cert = NULL; PRBool encapsulated = PR_FALSE; PLOptState *optstate; PLOptStatus status; diff --git a/security/nss/cmd/p7verify/p7verify.c b/security/nss/cmd/p7verify/p7verify.c index 5394a51891c0..1d87ac39ec83 100644 --- a/security/nss/cmd/p7verify/p7verify.c +++ b/security/nss/cmd/p7verify/p7verify.c @@ -133,7 +133,8 @@ HashDecodeAndVerify(FILE *out, FILE *content, PRFileDesc *signature, SECItem digest; unsigned char buffer[32]; - if (SECU_ReadDERFromFile(&derdata, signature, PR_FALSE) != SECSuccess) { + if (SECU_ReadDERFromFile(&derdata, signature, PR_FALSE, + PR_FALSE) != SECSuccess) { SECU_PrintError(progName, "error reading signature file"); return -1; } diff --git a/security/nss/cmd/pk1sign/pk1sign.c b/security/nss/cmd/pk1sign/pk1sign.c index 291388bd70cc..5750cdb2d981 100644 --- a/security/nss/cmd/pk1sign/pk1sign.c +++ b/security/nss/cmd/pk1sign/pk1sign.c @@ -116,7 +116,8 @@ SignFile(FILE *outFile, PRFileDesc *inFile, CERTCertificate *cert) return -1; /* suck the file in */ - if (SECU_ReadDERFromFile(&data2sign, inFile, PR_FALSE) != SECSuccess) + if (SECU_ReadDERFromFile(&data2sign, inFile, PR_FALSE, + PR_FALSE) != SECSuccess) return -1; privKey = NULL; diff --git a/security/nss/cmd/pp/pp.c b/security/nss/cmd/pp/pp.c index ab58c8747f33..1e84889f6cff 100644 --- a/security/nss/cmd/pp/pp.c +++ b/security/nss/cmd/pp/pp.c @@ -105,7 +105,7 @@ int main(int argc, char **argv) } SECU_RegisterDynamicOids(); - rv = SECU_ReadDERFromFile(&der, inFile, ascii); + rv = SECU_ReadDERFromFile(&der, inFile, ascii, PR_FALSE); if (rv != SECSuccess) { fprintf(stderr, "%s: SECU_ReadDERFromFile failed\n", progName); exit(1); diff --git a/security/nss/cmd/selfserv/selfserv.c b/security/nss/cmd/selfserv/selfserv.c index c757a1c28b5c..11f301558d9a 100644 --- a/security/nss/cmd/selfserv/selfserv.c +++ b/security/nss/cmd/selfserv/selfserv.c @@ -1028,7 +1028,7 @@ reload_crl(PRFileDesc *crlFile) return SECFailure; } - rv = SECU_ReadDERFromFile(crlDer, crlFile, PR_FALSE); + rv = SECU_ReadDERFromFile(crlDer, crlFile, PR_FALSE, PR_FALSE); if (rv != SECSuccess) { errWarn("Unable to read input file."); PORT_Free(crlDer); diff --git a/security/nss/cmd/shlibsign/shlibsign.c b/security/nss/cmd/shlibsign/shlibsign.c index 82087b5db0be..51604414fd10 100644 --- a/security/nss/cmd/shlibsign/shlibsign.c +++ b/security/nss/cmd/shlibsign/shlibsign.c @@ -701,6 +701,7 @@ int main(int argc, char **argv) int i; PRBool verify = PR_FALSE; static PRBool FIPSMODE = PR_FALSE; + PRBool successful = PR_FALSE; #ifdef USES_LINKS int ret; @@ -1245,6 +1246,8 @@ int main(int argc, char **argv) } #endif + successful = PR_TRUE; + cleanup: if (pFunctionList) { /* C_Finalize will automatically logout, close session, */ @@ -1281,5 +1284,8 @@ cleanup: } PR_Cleanup(); - return crv; + if (crv != CKR_OK) + return crv; + + return (successful) ? 0 : 1; } diff --git a/security/nss/cmd/signver/signver.c b/security/nss/cmd/signver/signver.c index cc9aaeb600a7..cd63a3c88d36 100644 --- a/security/nss/cmd/signver/signver.c +++ b/security/nss/cmd/signver/signver.c @@ -204,7 +204,7 @@ int main(int argc, char **argv) /* read in the input files' contents */ rv = SECU_ReadDERFromFile(&pkcs7der, signFile, - signver.options[opt_ASCII].activated); + signver.options[opt_ASCII].activated, PR_FALSE); if (signFile != PR_STDIN) PR_Close(signFile); if (rv != SECSuccess) { diff --git a/security/nss/cmd/vfychain/vfychain.c b/security/nss/cmd/vfychain/vfychain.c index ddbf379cdb1f..4d41be8f55ab 100644 --- a/security/nss/cmd/vfychain/vfychain.c +++ b/security/nss/cmd/vfychain/vfychain.c @@ -184,7 +184,7 @@ getCert(const char *name, PRBool isAscii, const char * progName) return cert; } - rv = SECU_ReadDERFromFile(&item, fd, isAscii); + rv = SECU_ReadDERFromFile(&item, fd, isAscii, PR_FALSE); PR_Close(fd); if (rv != SECSuccess) { fprintf(stderr, "%s: SECU_ReadDERFromFile failed\n", progName); diff --git a/security/nss/coreconf/coreconf.dep b/security/nss/coreconf/coreconf.dep index 590d1bfaeee3..5182f75552c8 100644 --- a/security/nss/coreconf/coreconf.dep +++ b/security/nss/coreconf/coreconf.dep @@ -10,4 +10,3 @@ */ #error "Do not include this header file." - diff --git a/security/nss/lib/freebl/win_rand.c b/security/nss/lib/freebl/win_rand.c index 0100ac446ecc..2ddac8d75287 100644 --- a/security/nss/lib/freebl/win_rand.c +++ b/security/nss/lib/freebl/win_rand.c @@ -366,40 +366,6 @@ void RNG_FileForRNG(const char *filename) } -/* - * CryptoAPI requires Windows NT 4.0 or Windows 95 OSR2 and later. - * Until we drop support for Windows 95, we need to emulate some - * definitions and declarations in and look up the - * functions in advapi32.dll at run time. - */ - -#ifndef WIN64 -typedef unsigned long HCRYPTPROV; -#endif - -#define CRYPT_VERIFYCONTEXT 0xF0000000 - -#define PROV_RSA_FULL 1 - -typedef BOOL -(WINAPI *CryptAcquireContextAFn)( - HCRYPTPROV *phProv, - LPCSTR pszContainer, - LPCSTR pszProvider, - DWORD dwProvType, - DWORD dwFlags); - -typedef BOOL -(WINAPI *CryptReleaseContextFn)( - HCRYPTPROV hProv, - DWORD dwFlags); - -typedef BOOL -(WINAPI *CryptGenRandomFn)( - HCRYPTPROV hProv, - DWORD dwLen, - BYTE *pbBuffer); - /* * Windows XP and Windows Server 2003 and later have RtlGenRandom, * which must be looked up by the name SystemFunction036. @@ -413,50 +379,19 @@ size_t RNG_SystemRNG(void *dest, size_t maxLen) { HMODULE hModule; RtlGenRandomFn pRtlGenRandom; - CryptAcquireContextAFn pCryptAcquireContextA; - CryptReleaseContextFn pCryptReleaseContext; - CryptGenRandomFn pCryptGenRandom; - HCRYPTPROV hCryptProv; size_t bytes = 0; usedWindowsPRNG = PR_FALSE; hModule = LoadLibrary("advapi32.dll"); if (hModule == NULL) { - return rng_systemFromNoise(dest,maxLen); + return bytes; } pRtlGenRandom = (RtlGenRandomFn) GetProcAddress(hModule, "SystemFunction036"); - if (pRtlGenRandom) { - if (pRtlGenRandom(dest, maxLen)) { - bytes = maxLen; - usedWindowsPRNG = PR_TRUE; - } else { - bytes = rng_systemFromNoise(dest,maxLen); - } - goto done; + if (pRtlGenRandom && pRtlGenRandom(dest, maxLen)) { + bytes = maxLen; + usedWindowsPRNG = PR_TRUE; } - pCryptAcquireContextA = (CryptAcquireContextAFn) - GetProcAddress(hModule, "CryptAcquireContextA"); - pCryptReleaseContext = (CryptReleaseContextFn) - GetProcAddress(hModule, "CryptReleaseContext"); - pCryptGenRandom = (CryptGenRandomFn) - GetProcAddress(hModule, "CryptGenRandom"); - if (!pCryptAcquireContextA || !pCryptReleaseContext || !pCryptGenRandom) { - bytes = rng_systemFromNoise(dest,maxLen); - goto done; - } - if (pCryptAcquireContextA(&hCryptProv, NULL, NULL, - PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { - if (pCryptGenRandom(hCryptProv, maxLen, dest)) { - bytes = maxLen; - usedWindowsPRNG = PR_TRUE; - } - pCryptReleaseContext(hCryptProv, 0); - } - if (bytes == 0) { - bytes = rng_systemFromNoise(dest,maxLen); - } -done: FreeLibrary(hModule); return bytes; } diff --git a/security/nss/lib/libpkix/pkix/top/pkix_build.c b/security/nss/lib/libpkix/pkix/top/pkix_build.c index 71fa2e984bc5..c35163a480b2 100755 --- a/security/nss/lib/libpkix/pkix/top/pkix_build.c +++ b/security/nss/lib/libpkix/pkix/top/pkix_build.c @@ -1021,9 +1021,11 @@ pkix_Build_ValidationCheckers( PKIX_ProcessingParams *procParams = NULL; PKIX_PL_Cert *trustedCert = NULL; PKIX_PL_PublicKey *trustedPubKey = NULL; + PKIX_PL_CertNameConstraints *trustedNC = NULL; PKIX_CertChainChecker *sigChecker = NULL; PKIX_CertChainChecker *policyChecker = NULL; PKIX_CertChainChecker *userChecker = NULL; + PKIX_CertChainChecker *nameConstraintsChecker = NULL; PKIX_CertChainChecker *checker = NULL; PKIX_CertSelector *certSelector = NULL; PKIX_List *userCheckerExtOIDs = NULL; @@ -1192,7 +1194,7 @@ pkix_Build_ValidationCheckers( } } - /* Inabling post chain building signature check on the certs. */ + /* Enabling post chain building signature check on the certs. */ PKIX_CHECK(PKIX_TrustAnchor_GetTrustedCert (anchor, &trustedCert, plContext), PKIX_TRUSTANCHORGETTRUSTEDCERTFAILED); @@ -1214,6 +1216,23 @@ pkix_Build_ValidationCheckers( plContext), PKIX_LISTAPPENDITEMFAILED); + /* Enabling post chain building name constraints check on the certs. */ + PKIX_CHECK(PKIX_TrustAnchor_GetNameConstraints + (anchor, &trustedNC, plContext), + PKIX_TRUSTANCHORGETNAMECONSTRAINTSFAILED); + + PKIX_CHECK(pkix_NameConstraintsChecker_Initialize + (trustedNC, numChainCerts, &nameConstraintsChecker, + plContext), + PKIX_NAMECONSTRAINTSCHECKERINITIALIZEFAILED); + + PKIX_CHECK(PKIX_List_AppendItem + (checkers, + (PKIX_PL_Object *)nameConstraintsChecker, + plContext), + PKIX_LISTAPPENDITEMFAILED); + + PKIX_DECREF(state->reversedCertChain); PKIX_INCREF(reversedCertChain); state->reversedCertChain = reversedCertChain; @@ -1240,6 +1259,8 @@ cleanup: PKIX_DECREF(trustedPubKey); PKIX_DECREF(certSelector); PKIX_DECREF(sigChecker); + PKIX_DECREF(trustedNC); + PKIX_DECREF(nameConstraintsChecker); PKIX_DECREF(policyChecker); PKIX_DECREF(userChecker); PKIX_DECREF(userCheckerExtOIDs); diff --git a/security/nss/lib/pk11wrap/secmod.h b/security/nss/lib/pk11wrap/secmod.h index c83d7e39fdf4..05573349f43b 100644 --- a/security/nss/lib/pk11wrap/secmod.h +++ b/security/nss/lib/pk11wrap/secmod.h @@ -2,7 +2,7 @@ * 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 _SECMOD_H_ -#define _SEDMOD_H_ +#define _SECMOD_H_ #include "seccomon.h" #include "secmodt.h" #include "prinrval.h" diff --git a/security/nss/lib/ssl/config.mk b/security/nss/lib/ssl/config.mk index 1a717fa908b0..da8b9ef77164 100644 --- a/security/nss/lib/ssl/config.mk +++ b/security/nss/lib/ssl/config.mk @@ -7,10 +7,6 @@ ifdef NISCC_TEST DEFINES += -DNISCC_TEST endif -ifdef NSS_SURVIVE_DOUBLE_BYPASS_FAILURE -DEFINES += -DNSS_SURVIVE_DOUBLE_BYPASS_FAILURE -endif - ifdef NSS_NO_PKCS11_BYPASS DEFINES += -DNO_PKCS11_BYPASS else diff --git a/security/nss/lib/ssl/derive.c b/security/nss/lib/ssl/derive.c index 420e6781ef38..35cfe25122f9 100644 --- a/security/nss/lib/ssl/derive.c +++ b/security/nss/lib/ssl/derive.c @@ -81,9 +81,11 @@ ssl3_KeyAndMacDeriveBypass( unsigned int effKeySize; /* effective size of cipher keys */ unsigned int macSize; /* size of MAC secret */ unsigned int IVSize; /* size of IV */ + PRBool explicitIV = PR_FALSE; SECStatus rv = SECFailure; SECStatus status = SECSuccess; PRBool isFIPS = PR_FALSE; + PRBool isTLS12 = pwSpec->version >= SSL_LIBRARY_VERSION_TLS_1_2; SECItem srcr; SECItem crsr; @@ -115,7 +117,13 @@ ssl3_KeyAndMacDeriveBypass( if (keySize == 0) { effKeySize = IVSize = 0; /* only MACing */ } - block_needed = 2 * (macSize + effKeySize + ((!isExport) * IVSize)); + if (cipher_def->type == type_block && + pwSpec->version >= SSL_LIBRARY_VERSION_TLS_1_1) { + /* Block ciphers in >= TLS 1.1 use a per-record, explicit IV. */ + explicitIV = PR_TRUE; + } + block_needed = + 2 * (macSize + effKeySize + ((!isExport && !explicitIV) * IVSize)); /* * clear out our returned keys so we can recover on failure @@ -150,8 +158,13 @@ ssl3_KeyAndMacDeriveBypass( keyblk.data = key_block; keyblk.len = block_needed; - status = TLS_PRF(&pwSpec->msItem, "key expansion", &srcr, &keyblk, - isFIPS); + if (isTLS12) { + status = TLS_P_hash(HASH_AlgSHA256, &pwSpec->msItem, + "key expansion", &srcr, &keyblk, isFIPS); + } else { + status = TLS_PRF(&pwSpec->msItem, "key expansion", &srcr, &keyblk, + isFIPS); + } if (status != SECSuccess) { goto key_and_mac_derive_fail; } @@ -239,22 +252,34 @@ ssl3_KeyAndMacDeriveBypass( i += keySize; if (IVSize > 0) { - /* - ** client_write_IV[CipherSpec.IV_size] - */ - buildSSLKey(&key_block[i], IVSize, &pwSpec->client.write_iv_item, \ - "Domestic Client Write IV"); - i += IVSize; + if (explicitIV) { + static unsigned char zero_block[32]; + PORT_Assert(IVSize <= sizeof zero_block); + buildSSLKey(&zero_block[0], IVSize, \ + &pwSpec->client.write_iv_item, \ + "Domestic Client Write IV"); + buildSSLKey(&zero_block[0], IVSize, \ + &pwSpec->server.write_iv_item, \ + "Domestic Server Write IV"); + } else { + /* + ** client_write_IV[CipherSpec.IV_size] + */ + buildSSLKey(&key_block[i], IVSize, \ + &pwSpec->client.write_iv_item, \ + "Domestic Client Write IV"); + i += IVSize; - /* - ** server_write_IV[CipherSpec.IV_size] - */ - buildSSLKey(&key_block[i], IVSize, &pwSpec->server.write_iv_item, \ - "Domestic Server Write IV"); - i += IVSize; + /* + ** server_write_IV[CipherSpec.IV_size] + */ + buildSSLKey(&key_block[i], IVSize, \ + &pwSpec->server.write_iv_item, \ + "Domestic Server Write IV"); + i += IVSize; + } } PORT_Assert(i <= block_bytes); - } else if (!isTLS) { /* ** Generate SSL3 Export write keys and IVs. @@ -417,6 +442,7 @@ ssl3_MasterKeyDeriveBypass( unsigned char * key_block = pwSpec->key_block; SECStatus rv = SECSuccess; PRBool isFIPS = PR_FALSE; + PRBool isTLS12 = pwSpec->version >= SSL_LIBRARY_VERSION_TLS_1_2; SECItem crsr; @@ -452,7 +478,12 @@ ssl3_MasterKeyDeriveBypass( master.data = key_block; master.len = SSL3_MASTER_SECRET_LENGTH; - rv = TLS_PRF(pms, "master secret", &crsr, &master, isFIPS); + if (isTLS12) { + rv = TLS_P_hash(HASH_AlgSHA256, pms, "master secret", &crsr, + &master, isFIPS); + } else { + rv = TLS_PRF(pms, "master secret", &crsr, &master, isFIPS); + } if (rv != SECSuccess) { PORT_SetError(SSL_ERROR_SESSION_KEY_GEN_FAILURE); } diff --git a/security/nss/lib/ssl/ssl3con.c b/security/nss/lib/ssl/ssl3con.c index 959f65b5133b..f5087be84f3b 100644 --- a/security/nss/lib/ssl/ssl3con.c +++ b/security/nss/lib/ssl/ssl3con.c @@ -58,7 +58,6 @@ static SECStatus ssl3_SendFinished( sslSocket *ss, PRInt32 flags); static SECStatus ssl3_SendServerHello( sslSocket *ss); static SECStatus ssl3_SendServerHelloDone( sslSocket *ss); static SECStatus ssl3_SendServerKeyExchange( sslSocket *ss); -static SECStatus ssl3_NewHandshakeHashes( sslSocket *ss); static SECStatus ssl3_UpdateHandshakeHashes( sslSocket *ss, const unsigned char *b, unsigned int l); @@ -1060,6 +1059,9 @@ ssl3_ComputeCommonKeyHash(SECOidTag hashAlg, } else if (hashAlg == SEC_OID_SHA384) { SHA384_HashBuf(hashes->u.raw, hashBuf, bufLen); hashes->len = SHA384_LENGTH; + } else if (hashAlg == SEC_OID_SHA512) { + SHA512_HashBuf(hashes->u.raw, hashBuf, bufLen); + hashes->len = SHA512_LENGTH; } else { PORT_SetError(SSL_ERROR_UNSUPPORTED_HASH_ALGORITHM); return SECFailure; @@ -1523,7 +1525,8 @@ ssl3_InitCompressionContext(ssl3CipherSpec *pwSpec) } #ifndef NO_PKCS11_BYPASS -/* Initialize encryption and MAC contexts for pending spec. +/* Initialize encryption contexts for pending spec. + * MAC contexts are set up when computing the mac, not here. * Master Secret already is derived in spec->msItem * Caller holds Spec write lock. */ @@ -1539,7 +1542,6 @@ ssl3_InitPendingContextsBypass(sslSocket *ss) unsigned int optArg1 = 0; unsigned int optArg2 = 0; PRBool server_encrypts = ss->sec.isServer; - CK_ULONG macLength; SSLCipherAlgorithm calg; SSLCompressionMethod compression_method; SECStatus rv; @@ -1550,11 +1552,6 @@ ssl3_InitPendingContextsBypass(sslSocket *ss) pwSpec = ss->ssl3.pwSpec; cipher_def = pwSpec->cipher_def; - macLength = pwSpec->mac_size; - - /* MAC setup is done when computing the mac, not here. - * Now setup the crypto contexts. - */ calg = cipher_def->calg; compression_method = pwSpec->compression_method; @@ -3436,18 +3433,6 @@ ssl3_DeriveMasterSecret(sslSocket *ss, PK11SymKey *pms) */ rv = PK11_ExtractKeyValue(pwSpec->master_secret); if (rv != SECSuccess) { -#if defined(NSS_SURVIVE_DOUBLE_BYPASS_FAILURE) - /* The double bypass failed. - * Attempt to revert to an all PKCS#11, non-bypass method. - * Do we need any unacquired locks here? - */ - ss->opt.bypassPKCS11 = 0; - rv = ssl3_NewHandshakeHashes(ss); - if (rv == SECSuccess) { - rv = ssl3_UpdateHandshakeHashes(ss, ss->ssl3.hs.messages.buf, - ss->ssl3.hs.messages.len); - } -#endif return rv; } /* This returns the address of the secItem inside the key struct, @@ -3617,34 +3602,90 @@ loser: return SECFailure; } -/* ssl3_InitTLS12HandshakeHash creates a handshake hash context for TLS 1.2, - * if needed, and hashes in any buffered messages in ss->ssl3.hs.messages. */ +/* ssl3_InitHandshakeHashes creates handshake hash contexts and hashes in + * buffered messages in ss->ssl3.hs.messages. */ static SECStatus -ssl3_InitTLS12HandshakeHash(sslSocket *ss) +ssl3_InitHandshakeHashes(sslSocket *ss) { - if (ss->version >= SSL_LIBRARY_VERSION_TLS_1_2 && - ss->ssl3.hs.tls12_handshake_hash == NULL) { - /* If we ever support ciphersuites where the PRF hash isn't SHA-256 - * then this will need to be updated. */ - ss->ssl3.hs.tls12_handshake_hash = - PK11_CreateDigestContext(SEC_OID_SHA256); - if (!ss->ssl3.hs.tls12_handshake_hash || - PK11_DigestBegin(ss->ssl3.hs.tls12_handshake_hash) != SECSuccess) { - ssl_MapLowLevelError(SSL_ERROR_DIGEST_FAILURE); - return SECFailure; + SSL_TRC(30,("%d: SSL3[%d]: start handshake hashes", SSL_GETPID(), ss->fd)); + + PORT_Assert(ss->ssl3.hs.hashType == handshake_hash_unknown); +#ifndef NO_PKCS11_BYPASS + if (ss->opt.bypassPKCS11) { + PORT_Assert(!ss->ssl3.hs.sha_obj && !ss->ssl3.hs.sha_clone); + if (ss->version >= SSL_LIBRARY_VERSION_TLS_1_2) { + /* If we ever support ciphersuites where the PRF hash isn't SHA-256 + * then this will need to be updated. */ + ss->ssl3.hs.sha_obj = HASH_GetRawHashObject(HASH_AlgSHA256); + if (!ss->ssl3.hs.sha_obj) { + ssl_MapLowLevelError(SSL_ERROR_DIGEST_FAILURE); + return SECFailure; + } + ss->ssl3.hs.sha_clone = (void (*)(void *, void *))SHA256_Clone; + ss->ssl3.hs.hashType = handshake_hash_single; + ss->ssl3.hs.sha_obj->begin(ss->ssl3.hs.sha_cx); + } else { + ss->ssl3.hs.hashType = handshake_hash_combo; + MD5_Begin((MD5Context *)ss->ssl3.hs.md5_cx); + SHA1_Begin((SHA1Context *)ss->ssl3.hs.sha_cx); + } + } else +#endif + { + PORT_Assert(!ss->ssl3.hs.md5 && !ss->ssl3.hs.sha); + /* + * note: We should probably lookup an SSL3 slot for these + * handshake hashes in hopes that we wind up with the same slots + * that the master secret will wind up in ... + */ + if (ss->version >= SSL_LIBRARY_VERSION_TLS_1_2) { + /* If we ever support ciphersuites where the PRF hash isn't SHA-256 + * then this will need to be updated. */ + ss->ssl3.hs.sha = PK11_CreateDigestContext(SEC_OID_SHA256); + if (ss->ssl3.hs.sha == NULL) { + ssl_MapLowLevelError(SSL_ERROR_SHA_DIGEST_FAILURE); + return SECFailure; + } + ss->ssl3.hs.hashType = handshake_hash_single; + + if (PK11_DigestBegin(ss->ssl3.hs.sha) != SECSuccess) { + ssl_MapLowLevelError(SSL_ERROR_DIGEST_FAILURE); + return SECFailure; + } + } else { + /* Both ss->ssl3.hs.md5 and ss->ssl3.hs.sha should be NULL or + * created successfully. */ + ss->ssl3.hs.md5 = PK11_CreateDigestContext(SEC_OID_MD5); + if (ss->ssl3.hs.md5 == NULL) { + ssl_MapLowLevelError(SSL_ERROR_MD5_DIGEST_FAILURE); + return SECFailure; + } + ss->ssl3.hs.sha = PK11_CreateDigestContext(SEC_OID_SHA1); + if (ss->ssl3.hs.sha == NULL) { + PK11_DestroyContext(ss->ssl3.hs.md5, PR_TRUE); + ss->ssl3.hs.md5 = NULL; + ssl_MapLowLevelError(SSL_ERROR_SHA_DIGEST_FAILURE); + return SECFailure; + } + ss->ssl3.hs.hashType = handshake_hash_combo; + + if (PK11_DigestBegin(ss->ssl3.hs.md5) != SECSuccess) { + ssl_MapLowLevelError(SSL_ERROR_MD5_DIGEST_FAILURE); + return SECFailure; + } + if (PK11_DigestBegin(ss->ssl3.hs.sha) != SECSuccess) { + ssl_MapLowLevelError(SSL_ERROR_SHA_DIGEST_FAILURE); + return SECFailure; + } } } - if (ss->ssl3.hs.tls12_handshake_hash && ss->ssl3.hs.messages.len > 0) { - if (PK11_DigestOp(ss->ssl3.hs.tls12_handshake_hash, - ss->ssl3.hs.messages.buf, - ss->ssl3.hs.messages.len) != SECSuccess) { - ssl_MapLowLevelError(SSL_ERROR_DIGEST_FAILURE); + if (ss->ssl3.hs.messages.len > 0) { + if (ssl3_UpdateHandshakeHashes(ss, ss->ssl3.hs.messages.buf, + ss->ssl3.hs.messages.len) != + SECSuccess) { return SECFailure; } - } - - if (ss->ssl3.hs.messages.buf && !ss->opt.bypassPKCS11) { PORT_Free(ss->ssl3.hs.messages.buf); ss->ssl3.hs.messages.buf = NULL; ss->ssl3.hs.messages.len = 0; @@ -3659,83 +3700,30 @@ ssl3_RestartHandshakeHashes(sslSocket *ss) { SECStatus rv = SECSuccess; + SSL_TRC(30,("%d: SSL3[%d]: reset handshake hashes", + SSL_GETPID(), ss->fd )); + ss->ssl3.hs.hashType = handshake_hash_unknown; ss->ssl3.hs.messages.len = 0; #ifndef NO_PKCS11_BYPASS - if (ss->opt.bypassPKCS11) { - MD5_Begin((MD5Context *)ss->ssl3.hs.md5_cx); - SHA1_Begin((SHA1Context *)ss->ssl3.hs.sha_cx); - } else + ss->ssl3.hs.sha_obj = NULL; + ss->ssl3.hs.sha_clone = NULL; #endif - { - if (ss->ssl3.hs.tls12_handshake_hash) { - rv = PK11_DigestBegin(ss->ssl3.hs.tls12_handshake_hash); - if (rv != SECSuccess) { - ssl_MapLowLevelError(SSL_ERROR_DIGEST_FAILURE); - return rv; - } - } - rv = PK11_DigestBegin(ss->ssl3.hs.md5); - if (rv != SECSuccess) { - ssl_MapLowLevelError(SSL_ERROR_MD5_DIGEST_FAILURE); - return rv; - } - rv = PK11_DigestBegin(ss->ssl3.hs.sha); - if (rv != SECSuccess) { - ssl_MapLowLevelError(SSL_ERROR_SHA_DIGEST_FAILURE); - return rv; - } - } - return rv; -} - -static SECStatus -ssl3_NewHandshakeHashes(sslSocket *ss) -{ - PK11Context *md5 = NULL; - PK11Context *sha = NULL; - - /* - * note: We should probably lookup an SSL3 slot for these - * handshake hashes in hopes that we wind up with the same slots - * that the master secret will wind up in ... - */ - SSL_TRC(30,("%d: SSL3[%d]: start handshake hashes", SSL_GETPID(), ss->fd)); - PORT_Assert(!ss->ssl3.hs.messages.buf && !ss->ssl3.hs.messages.space); - ss->ssl3.hs.messages.buf = NULL; - ss->ssl3.hs.messages.space = 0; - - ss->ssl3.hs.md5 = md5 = PK11_CreateDigestContext(SEC_OID_MD5); - ss->ssl3.hs.sha = sha = PK11_CreateDigestContext(SEC_OID_SHA1); - ss->ssl3.hs.tls12_handshake_hash = NULL; - if (md5 == NULL) { - ssl_MapLowLevelError(SSL_ERROR_MD5_DIGEST_FAILURE); - goto loser; - } - if (sha == NULL) { - ssl_MapLowLevelError(SSL_ERROR_SHA_DIGEST_FAILURE); - goto loser; - } - if (SECSuccess == ssl3_RestartHandshakeHashes(ss)) { - return SECSuccess; - } - -loser: - if (md5 != NULL) { - PK11_DestroyContext(md5, PR_TRUE); + if (ss->ssl3.hs.md5) { + PK11_DestroyContext(ss->ssl3.hs.md5,PR_TRUE); ss->ssl3.hs.md5 = NULL; } - if (sha != NULL) { - PK11_DestroyContext(sha, PR_TRUE); + if (ss->ssl3.hs.sha) { + PK11_DestroyContext(ss->ssl3.hs.sha,PR_TRUE); ss->ssl3.hs.sha = NULL; } - return SECFailure; - + return rv; } /* * Handshake messages */ -/* Called from ssl3_AppendHandshake() +/* Called from ssl3_InitHandshakeHashes() +** ssl3_AppendHandshake() ** ssl3_StartHandshakeHash() ** ssl3_HandleV2ClientHello() ** ssl3_HandleHandshakeMessage() @@ -3749,31 +3737,27 @@ ssl3_UpdateHandshakeHashes(sslSocket *ss, const unsigned char *b, PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) ); - PRINT_BUF(90, (NULL, "MD5 & SHA handshake hash input:", b, l)); - - if ((ss->version == 0 || ss->version >= SSL_LIBRARY_VERSION_TLS_1_2) && - !ss->opt.bypassPKCS11 && - ss->ssl3.hs.tls12_handshake_hash == NULL) { - /* For TLS 1.2 connections we need to buffer the handshake messages - * until we have established which PRF hash function to use. */ - rv = sslBuffer_Append(&ss->ssl3.hs.messages, b, l); - if (rv != SECSuccess) { - return rv; - } + /* We need to buffer the handshake messages until we have established + * which handshake hash function to use. */ + if (ss->ssl3.hs.hashType == handshake_hash_unknown) { + return sslBuffer_Append(&ss->ssl3.hs.messages, b, l); } + PRINT_BUF(90, (NULL, "handshake hash input:", b, l)); + #ifndef NO_PKCS11_BYPASS if (ss->opt.bypassPKCS11) { - MD5_Update((MD5Context *)ss->ssl3.hs.md5_cx, b, l); - SHA1_Update((SHA1Context *)ss->ssl3.hs.sha_cx, b, l); -#if defined(NSS_SURVIVE_DOUBLE_BYPASS_FAILURE) - rv = sslBuffer_Append(&ss->ssl3.hs.messages, b, l); -#endif + if (ss->ssl3.hs.hashType == handshake_hash_single) { + ss->ssl3.hs.sha_obj->update(ss->ssl3.hs.sha_cx, b, l); + } else { + MD5_Update((MD5Context *)ss->ssl3.hs.md5_cx, b, l); + SHA1_Update((SHA1Context *)ss->ssl3.hs.sha_cx, b, l); + } return rv; } #endif - if (ss->ssl3.hs.tls12_handshake_hash) { - rv = PK11_DigestOp(ss->ssl3.hs.tls12_handshake_hash, b, l); + if (ss->ssl3.hs.hashType == handshake_hash_single) { + rv = PK11_DigestOp(ss->ssl3.hs.sha, b, l); if (rv != SECSuccess) { ssl_MapLowLevelError(SSL_ERROR_DIGEST_FAILURE); return rv; @@ -3901,10 +3885,6 @@ ssl3_AppendHandshakeHeader(sslSocket *ss, SSL3HandshakeType t, PRUint32 length) SSL_TRC(30,("%d: SSL3[%d]: append handshake header: type %s", SSL_GETPID(), ss->fd, ssl3_DecodeHandshakeType(t))); - PRINT_BUF(60, (ss, "MD5 handshake hash:", - (unsigned char*)ss->ssl3.hs.md5_cx, MD5_LENGTH)); - PRINT_BUF(95, (ss, "SHA handshake hash:", - (unsigned char*)ss->ssl3.hs.sha_cx, SHA1_LENGTH)); rv = ssl3_AppendHandshakeNumber(ss, t, 1); if (rv != SECSuccess) { @@ -4235,7 +4215,27 @@ ssl3_ComputeHandshakeHashes(sslSocket * ss, hashes->hashAlg = SEC_OID_UNKNOWN; #ifndef NO_PKCS11_BYPASS - if (ss->opt.bypassPKCS11) { + if (ss->opt.bypassPKCS11 && + ss->ssl3.hs.hashType == handshake_hash_single) { + /* compute them without PKCS11 */ + PRUint64 sha_cx[MAX_MAC_CONTEXT_LLONGS]; + + if (!spec->msItem.data) { + PORT_SetError(SSL_ERROR_RX_UNEXPECTED_HANDSHAKE); + return SECFailure; + } + + ss->ssl3.hs.sha_clone(sha_cx, ss->ssl3.hs.sha_cx); + ss->ssl3.hs.sha_obj->end(sha_cx, hashes->u.raw, &hashes->len, + sizeof(hashes->u.raw)); + + PRINT_BUF(60, (NULL, "SHA-256: result", hashes->u.raw, hashes->len)); + + /* If we ever support ciphersuites where the PRF hash isn't SHA-256 + * then this will need to be updated. */ + hashes->hashAlg = SEC_OID_SHA256; + rv = SECSuccess; + } else if (ss->opt.bypassPKCS11) { /* compute them without PKCS11 */ PRUint64 md5_cx[MAX_MAC_CONTEXT_LLONGS]; PRUint64 sha_cx[MAX_MAC_CONTEXT_LLONGS]; @@ -4320,7 +4320,8 @@ ssl3_ComputeHandshakeHashes(sslSocket * ss, #undef shacx } else #endif - if (ss->ssl3.hs.tls12_handshake_hash) { + if (ss->ssl3.hs.hashType == handshake_hash_single) { + /* compute hashes with PKCS11 */ PK11Context *h; unsigned int stateLen; unsigned char stackBuf[1024]; @@ -4331,7 +4332,7 @@ ssl3_ComputeHandshakeHashes(sslSocket * ss, return SECFailure; } - h = ss->ssl3.hs.tls12_handshake_hash; + h = ss->ssl3.hs.sha; stateBuf = PK11_SaveContextAlloc(h, stackBuf, sizeof(stackBuf), &stateLen); if (stateBuf == NULL) { @@ -4352,8 +4353,7 @@ ssl3_ComputeHandshakeHashes(sslSocket * ss, tls12_loser: if (stateBuf) { - if (PK11_RestoreContext(ss->ssl3.hs.tls12_handshake_hash, stateBuf, - stateLen) != SECSuccess) { + if (PK11_RestoreContext(h, stateBuf, stateLen) != SECSuccess) { ssl_MapLowLevelError(SSL_ERROR_DIGEST_FAILURE); rv = SECFailure; } @@ -4362,7 +4362,7 @@ tls12_loser: } } } else { - /* compute hases with PKCS11 */ + /* compute hashes with PKCS11 */ PK11Context * md5; PK11Context * sha = NULL; unsigned char *md5StateBuf = NULL; @@ -4527,6 +4527,10 @@ ssl3_StartHandshakeHash(sslSocket *ss, unsigned char * buf, int length) if (rv != SECSuccess) { goto done; /* ssl3_InitState has set the error code. */ } + rv = ssl3_RestartHandshakeHashes(ss); + if (rv != SECSuccess) { + goto done; + } PORT_Memset(&ss->ssl3.hs.client_random, 0, SSL3_RANDOM_LENGTH); PORT_Memcpy( @@ -4586,8 +4590,6 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending) */ PORT_Memset(&ss->xtnData, 0, sizeof(TLSExtensionData)); - SSL_TRC(30,("%d: SSL3[%d]: reset handshake hashes", - SSL_GETPID(), ss->fd )); rv = ssl3_RestartHandshakeHashes(ss); if (rv != SECSuccess) { return rv; @@ -5846,12 +5848,8 @@ ssl3_HandleServerHello(sslSocket *ss, SSL3Opaque *b, PRUint32 length) SSL_GETPID(), ss->fd)); PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) ); + PORT_Assert( ss->ssl3.initialized ); - rv = ssl3_InitState(ss); - if (rv != SECSuccess) { - errCode = PORT_GetError(); /* ssl3_InitState has set the error code. */ - goto alert_loser; - } if (ss->ssl3.hs.ws != wait_server_hello) { errCode = SSL_ERROR_RX_UNEXPECTED_SERVER_HELLO; desc = unexpected_message; @@ -5904,7 +5902,7 @@ ssl3_HandleServerHello(sslSocket *ss, SSL3Opaque *b, PRUint32 length) } isTLS = (ss->version > SSL_LIBRARY_VERSION_3_0); - rv = ssl3_InitTLS12HandshakeHash(ss); + rv = ssl3_InitHandshakeHashes(ss); if (rv != SECSuccess) { desc = internal_error; errCode = PORT_GetError(); @@ -7071,6 +7069,7 @@ ssl3_HandleClientHello(sslSocket *ss, SSL3Opaque *b, PRUint32 length) PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss)); + PORT_Assert( ss->ssl3.initialized ); /* Get peer name of client */ rv = ssl_GetPeerInfo(ss); @@ -7098,11 +7097,6 @@ ssl3_HandleClientHello(sslSocket *ss, SSL3Opaque *b, PRUint32 length) PORT_Memset(&ss->xtnData, 0, sizeof(TLSExtensionData)); ss->statelessResume = PR_FALSE; - rv = ssl3_InitState(ss); - if (rv != SECSuccess) { - return rv; /* ssl3_InitState has set the error code. */ - } - if ((ss->ssl3.hs.ws != wait_client_hello) && (ss->ssl3.hs.ws != idle_handshake)) { desc = unexpected_message; @@ -7141,7 +7135,7 @@ ssl3_HandleClientHello(sslSocket *ss, SSL3Opaque *b, PRUint32 length) goto alert_loser; } - rv = ssl3_InitTLS12HandshakeHash(ss); + rv = ssl3_InitHandshakeHashes(ss); if (rv != SECSuccess) { desc = internal_error; errCode = PORT_GetError(); @@ -7868,6 +7862,11 @@ ssl3_HandleV2ClientHello(sslSocket *ss, unsigned char *buffer, int length) ssl_ReleaseSSL3HandshakeLock(ss); return rv; /* ssl3_InitState has set the error code. */ } + rv = ssl3_RestartHandshakeHashes(ss); + if (rv != SECSuccess) { + ssl_ReleaseSSL3HandshakeLock(ss); + return rv; + } if (ss->ssl3.hs.ws != wait_client_hello) { desc = unexpected_message; @@ -7889,7 +7888,7 @@ ssl3_HandleV2ClientHello(sslSocket *ss, unsigned char *buffer, int length) goto alert_loser; } - rv = ssl3_InitTLS12HandshakeHash(ss); + rv = ssl3_InitHandshakeHashes(ss); if (rv != SECSuccess) { desc = internal_error; errCode = PORT_GetError(); @@ -8624,6 +8623,7 @@ ssl3_HandleRSAClientKeyExchange(sslSocket *ss, PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) ); PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss) ); + PORT_Assert( ss->ssl3.prSpec == ss->ssl3.pwSpec ); enc_pms.data = b; enc_pms.len = length; @@ -9632,7 +9632,12 @@ ssl3_TLSPRFWithMasterSecret(ssl3CipherSpec *spec, const char *label, inData.len = valLen; outData.data = out; outData.len = outLen; - rv = TLS_PRF(&spec->msItem, label, &inData, &outData, isFIPS); + if (spec->version >= SSL_LIBRARY_VERSION_TLS_1_2) { + rv = TLS_P_hash(HASH_AlgSHA256, &spec->msItem, label, &inData, + &outData, isFIPS); + } else { + rv = TLS_PRF(&spec->msItem, label, &inData, &outData, isFIPS); + } PORT_Assert(rv != SECSuccess || outData.len == outLen); #endif } @@ -10142,10 +10147,6 @@ ssl3_HandleHandshakeMessage(sslSocket *ss, SSL3Opaque *b, PRUint32 length) } SSL_TRC(30,("%d: SSL3[%d]: handle handshake message: %s", SSL_GETPID(), ss->fd, ssl3_DecodeHandshakeType(ss->ssl3.hs.msg_type))); - PRINT_BUF(60, (ss, "MD5 handshake hash:", - (unsigned char*)ss->ssl3.hs.md5_cx, MD5_LENGTH)); - PRINT_BUF(95, (ss, "SHA handshake hash:", - (unsigned char*)ss->ssl3.hs.sha_cx, SHA1_LENGTH)); hdr[0] = (PRUint8)ss->ssl3.hs.msg_type; hdr[1] = (PRUint8)(length >> 16); @@ -10154,8 +10155,6 @@ ssl3_HandleHandshakeMessage(sslSocket *ss, SSL3Opaque *b, PRUint32 length) /* Start new handshake hashes when we start a new handshake */ if (ss->ssl3.hs.msg_type == client_hello) { - SSL_TRC(30,("%d: SSL3[%d]: reset handshake hashes", - SSL_GETPID(), ss->fd )); rv = ssl3_RestartHandshakeHashes(ss); if (rv != SECSuccess) { return rv; @@ -11094,8 +11093,6 @@ ssl3_InitCipherSpec(sslSocket *ss, ssl3CipherSpec *spec) /* Called from: ssl3_SendRecord ** ssl3_StartHandshakeHash() <- ssl2_BeginClientHandshake() ** ssl3_SendClientHello() -** ssl3_HandleServerHello() -** ssl3_HandleClientHello() ** ssl3_HandleV2ClientHello() ** ssl3_HandleRecord() ** @@ -11106,7 +11103,6 @@ ssl3_InitCipherSpec(sslSocket *ss, ssl3CipherSpec *spec) static SECStatus ssl3_InitState(sslSocket *ss) { - SECStatus rv; PORT_Assert( ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss)); if (ss->ssl3.initialized) @@ -11139,12 +11135,12 @@ ssl3_InitState(sslSocket *ss) dtls_SetMTU(ss, 0); /* Set the MTU to the highest plateau */ } - rv = ssl3_NewHandshakeHashes(ss); - if (rv == SECSuccess) { - ss->ssl3.initialized = PR_TRUE; - } + PORT_Assert(!ss->ssl3.hs.messages.buf && !ss->ssl3.hs.messages.space); + ss->ssl3.hs.messages.buf = NULL; + ss->ssl3.hs.messages.space = 0; - return rv; + ss->ssl3.initialized = PR_TRUE; + return SECSuccess; } /* Returns a reference counted object that contains a key pair. @@ -11439,8 +11435,12 @@ ssl3_DestroySSL3Info(sslSocket *ss) /* clean up handshake */ #ifndef NO_PKCS11_BYPASS if (ss->opt.bypassPKCS11) { - SHA1_DestroyContext((SHA1Context *)ss->ssl3.hs.sha_cx, PR_FALSE); - MD5_DestroyContext((MD5Context *)ss->ssl3.hs.md5_cx, PR_FALSE); + if (ss->ssl3.hs.hashType == handshake_hash_combo) { + SHA1_DestroyContext((SHA1Context *)ss->ssl3.hs.sha_cx, PR_FALSE); + MD5_DestroyContext((MD5Context *)ss->ssl3.hs.md5_cx, PR_FALSE); + } else if (ss->ssl3.hs.hashType == handshake_hash_single) { + ss->ssl3.hs.sha_obj->destroy(ss->ssl3.hs.sha_cx, PR_FALSE); + } } #endif if (ss->ssl3.hs.md5) { @@ -11449,9 +11449,6 @@ ssl3_DestroySSL3Info(sslSocket *ss) if (ss->ssl3.hs.sha) { PK11_DestroyContext(ss->ssl3.hs.sha,PR_TRUE); } - if (ss->ssl3.hs.tls12_handshake_hash) { - PK11_DestroyContext(ss->ssl3.hs.tls12_handshake_hash,PR_TRUE); - } if (ss->ssl3.hs.clientSigAndHash) { PORT_Free(ss->ssl3.hs.clientSigAndHash); } diff --git a/security/nss/lib/ssl/sslimpl.h b/security/nss/lib/ssl/sslimpl.h index b0abfd5972a2..90e9567c172f 100644 --- a/security/nss/lib/ssl/sslimpl.h +++ b/security/nss/lib/ssl/sslimpl.h @@ -487,7 +487,9 @@ typedef PRUint16 DTLSEpoch; typedef void (*DTLSTimerCb)(sslSocket *); -#define MAX_MAC_CONTEXT_BYTES 400 +#define MAX_MAC_CONTEXT_BYTES 400 /* 400 is large enough for MD5, SHA-1, and + * SHA-256. For SHA-384 support, increase + * it to 712. */ #define MAX_MAC_CONTEXT_LLONGS (MAX_MAC_CONTEXT_BYTES / 8) #define MAX_CIPHER_CONTEXT_BYTES 2080 @@ -766,6 +768,12 @@ typedef struct DTLSQueuedMessageStr { PRUint16 len; /* The data length */ } DTLSQueuedMessage; +typedef enum { + handshake_hash_unknown = 0, + handshake_hash_combo = 1, /* The MD5/SHA-1 combination */ + handshake_hash_single = 2 /* A single hash */ +} SSL3HandshakeHashType; + /* ** This is the "hs" member of the "ssl3" struct. ** This entire struct is protected by ssl3HandshakeLock @@ -774,11 +782,31 @@ typedef struct SSL3HandshakeStateStr { SSL3Random server_random; SSL3Random client_random; SSL3WaitState ws; + + /* This group of members is used for handshake running hashes. */ + SSL3HandshakeHashType hashType; + sslBuffer messages; /* Accumulated handshake messages */ +#ifndef NO_PKCS11_BYPASS + /* Bypass mode: + * SSL 3.0 - TLS 1.1 use both |md5_cx| and |sha_cx|. |md5_cx| is used for + * MD5 and |sha_cx| for SHA-1. + * TLS 1.2 and later use only |sha_cx|, for SHA-256. NOTE: When we support + * SHA-384, increase MAX_MAC_CONTEXT_BYTES to 712. */ PRUint64 md5_cx[MAX_MAC_CONTEXT_LLONGS]; PRUint64 sha_cx[MAX_MAC_CONTEXT_LLONGS]; - PK11Context * md5; /* handshake running hashes */ + const SECHashObject * sha_obj; + /* The function prototype of sha_obj->clone() does not match the prototype + * of the freebl _Clone functions, so we need a dedicated function + * pointer for the _Clone function. */ + void (*sha_clone)(void *dest, void *src); +#endif + /* PKCS #11 mode: + * SSL 3.0 - TLS 1.1 use both |md5| and |sha|. |md5| is used for MD5 and + * |sha| for SHA-1. + * TLS 1.2 and later use only |sha|, for SHA-256. */ + PK11Context * md5; PK11Context * sha; - PK11Context * tls12_handshake_hash; + const ssl3KEADef * kea_def; ssl3CipherSuite cipher_suite; const ssl3CipherSuiteDef *suite_def; @@ -796,7 +824,6 @@ const ssl3CipherSuiteDef *suite_def; PRBool sendingSCSV; /* instead of empty RI */ sslBuffer msgState; /* current state for handshake messages*/ /* protected by recvBufLock */ - sslBuffer messages; /* Accumulated handshake messages */ PRUint16 finishedBytes; /* size of single finished below */ union { TLSFinished tFinished[2]; /* client, then server */ diff --git a/security/nss/lib/ssl/sslsock.c b/security/nss/lib/ssl/sslsock.c index 2733f5e9dbf9..cd4a7a73e05c 100644 --- a/security/nss/lib/ssl/sslsock.c +++ b/security/nss/lib/ssl/sslsock.c @@ -782,10 +782,7 @@ SSL_OptionSet(PRFileDesc *fd, PRInt32 which, PRBool on) rv = SECFailure; } else { if (PR_FALSE != on) { - /* PKCS#11 bypass is not supported with TLS 1.2. */ - if (ss->vrange.max >= SSL_LIBRARY_VERSION_TLS_1_2) { - ss->opt.bypassPKCS11 = PR_FALSE; - } else if (PR_SUCCESS == SSL_BypassSetup() ) { + if (PR_SUCCESS == SSL_BypassSetup() ) { #ifdef NO_PKCS11_BYPASS ss->opt.bypassPKCS11 = PR_FALSE; #else @@ -1880,10 +1877,6 @@ SSL_VersionRangeSet(PRFileDesc *fd, const SSLVersionRange *vrange) ssl_GetSSL3HandshakeLock(ss); ss->vrange = *vrange; - /* PKCS#11 bypass is not supported with TLS 1.2. */ - if (ss->vrange.max >= SSL_LIBRARY_VERSION_TLS_1_2) { - ss->opt.bypassPKCS11 = PR_FALSE; - } ssl_ReleaseSSL3HandshakeLock(ss); ssl_Release1stHandshakeLock(ss); diff --git a/security/nss/tests/chains/scenarios/nameconstraints.cfg b/security/nss/tests/chains/scenarios/nameconstraints.cfg new file mode 100644 index 000000000000..823e83d02022 --- /dev/null +++ b/security/nss/tests/chains/scenarios/nameconstraints.cfg @@ -0,0 +1,22 @@ +# 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/. + +scenario TrustAnchors + +db trustanchors + +import NameConstraints.ca:x:CT,C,C + +verify NameConstraints.server1:x + cert NameConstraints.intermediate:x + result fail + +verify NameConstraints.server2:x + cert NameConstraints.intermediate:x + result fail + +verify NameConstraints.server3:x + cert NameConstraints.intermediate:x + result pass + diff --git a/security/nss/tests/chains/scenarios/scenarios b/security/nss/tests/chains/scenarios/scenarios index 3eda34fd72c7..1aa62d4c317c 100644 --- a/security/nss/tests/chains/scenarios/scenarios +++ b/security/nss/tests/chains/scenarios/scenarios @@ -53,3 +53,4 @@ revoc.cfg ocsp.cfg crldp.cfg trustanchors.cfg +nameconstraints.cfg diff --git a/security/nss/tests/libpkix/certs/NameConstraints.ca.cert b/security/nss/tests/libpkix/certs/NameConstraints.ca.cert new file mode 100644 index 0000000000000000000000000000000000000000..9e859a0aa00112279ac86c30416915f18bccff52 GIT binary patch literal 626 zcmXqLV#+gUV!Xb9nTe5!iILHOmyJ`a&7D}zCbA-4f18*?ZNn=n&ou%WPl zAc(^u%;lVzlbM!Zl$V)kC}to65@Z+V_02EMD@n}EQwYmUEjJW05CDmD33EF6yN3oV z_yq?WiWmri#F&M-fjotf)Z!8aXGa4$ab81X0~13d0|Ns?Lz5_RUL#~Kom|m4AKCYe ztPISJy$lA8olK353{RMki$w4}^z!simwersx4BC)Kw)b1q#r`(6FX*cJ^I#e5i*$} zd3y83(`}Bo>LPn>tjc)IJJ-0RAD_RuKRU9>J^y-Hj(n1ixkl!W-8zxhi4LLtziwRo zcOm^<;_L0-o_^F$D@uFOBPJuZt=?v1cC&4+_sPh~^PF#7TE!W2ZK^sGGb01zVgmy` zU<7a`w0SVL{cvJrWMN@uVqiDm0S2k8Fbk^zGb7`F18xwHA0)-dhU_6=bTR{d!t-WY zSf(-mk&_<5nHG~$mn~`W{;`}Tp>fiB>phL9J1wLqB)5qCEqcMZg7^2=$ln*Ym6WAD zQ)s>{IxqfK@tIkzzvHg#5;^~wZK7P5S4nD)8Ph(s9-e)H*16Z}JSIsU_ej^{ZoQHG fsk&)9Ut!bH9cQmOtE{(d2*^1eXuX@Y?S>Tq-gCuX literal 0 HcmV?d00001 diff --git a/security/nss/tests/libpkix/certs/NameConstraints.intermediate.cert b/security/nss/tests/libpkix/certs/NameConstraints.intermediate.cert new file mode 100644 index 0000000000000000000000000000000000000000..6fe77d198a640ce72c1b15c1d42235fb749fdc7e GIT binary patch literal 662 zcmXqLVwz;o#Q1vwGZP~d6QhU$FB_*;n@8JsUPeY%RtAFziMiSCW{Srx2EzT5c$0AOI5Q66SRBcMlC# z@Cyz$6fqD2i7^Xv19=J|sl_D<&W;9h;=G2&2BwBa1_lO(h9*(syhg?b#&E7d4wYRY zV;}`_g)qn!o_QsyMY*XdnTaK-AlEd`M-Bx>RtDzAUIv54PNv32hH1-eI_^#Fd}N>!v-NziMtqFBG}SyYF(-P3_X1jeLvmM;l9cFW>&@yZgC(qw4z5t$)pC zT$0!lTeAI~W`k{{`^(j@;^N-z?fG`wpJQ@xiI1z-xBRcsTTa*AxZ}ZBxr@O*zc{-s zt1Z>pR_*o@twjQ7b2S&s&yu>##LURRxY)Ex3jBLoB1x7hD(3giV zrY@4riMYGbXA^JjbE{=1TU*&Dnx4Bgn~&ue_lgRKmsc4#Tzz!o*>~G>wrd@iSsYZC zuy8qla%IKsO&=LtIP0%XO43u>q{1%t$VJ#@zFxIj5`%|T?^5Plaar+kE6M^iwV6B~ htY`nQXM2>kfXqjaui;l`SVZkMRbTLBx&@=ziMiSCW{Srx2EzT5c$0AOI5Q66SRBcMlC# z@Cyz$lrfM3i7^Wc19=Lbc_pbuxv43ci6yBD&W;9h;=G2&24;pv1_lO(h9*(syhg@A z28?TvN@drG8VEyN!&8!4T%wnmR|fP|ib3Oii^c57CTBTUVGNfPdT-~nSJ(&qjOd7aOv!Sr5Y&zTK&A{_6()v%L5)w ze$`Ww^meJ_!R4!8x!)8BRuyr)tNpJ>Nb&gfFEN~*cb4+^33zDj+RFLv;=GF!R)5n{ z>RM=0V58aJ{_OB(*T)zCoZFsV-W2$giJ6gsaj~a?yMZ{+>9T?>0tS3dsLmH;<4kDt zU~K#0#K_3P!py{Wz<>v&R+y3TKMRuqg8?^)#}ATX-hu2>V1zRRy*Sy_SHd7;DpURY zy|EGps}j~d++{l>YnAvV$t|94A2!aJ|FL&Vu*#>6%bqV>`H1Pi0l#6~YnQN@M)wZ1 z#IWmMd~bNzVvR=pg-gqYSDs7WRKT^7ue)Erzpl|E#=9loU7tsaQOY{L{2%+Ffa^b6 ZuY`0bT@(}fTXNR$+2vl*w;vWg0svK?*Cqe} literal 0 HcmV?d00001 diff --git a/security/nss/tests/libpkix/certs/NameConstraints.server2.cert b/security/nss/tests/libpkix/certs/NameConstraints.server2.cert new file mode 100644 index 0000000000000000000000000000000000000000..feac1139294801703731fb01204b5de0165fae2d GIT binary patch literal 643 zcmXqLVyZW2VtlcHnTe5!iBZ#lmyJ`a&7D}zCfA-4f18*?ZNn=n&ou%WPl zAc(^u%;lVzlbM!Zl$V)kC}to65@Z+V_02EMD@n}EQwYmUEjJW05CDmD33EF6yN3oV z_yq?W${0w2#F&MJfjkAzypq(S+|-oJ#FA76XGa4$ab81X12aP-0|Ns?Lz5_RUL#{5 z1I9JTrLt>e4Wz-Y;Sov9%P+}DEs8HmEiTc^%qs)>F2$g6K5}p{vNA9?_A(eWb}}_K zGHjZk;&iZY#zN*77b*{O#1)5}zT@^#?bnSp5~|7#(<=VCh$HN}_wJY(~IZCsV5ziMiSCW{Srx2EzT5c$0AOI5Q66SRBcMlC# z@Cyz$lrfM3i7^Wc19=Lbc_pbuxv43ci6yBD&W;9h;=G2&24;pv1_lO(h9*(syhg@A z28?TvN@drG8VEyN!&8!4T%wm+k(gVMlWNd7A2}EpSs9ocdl?KGJDD0A8J=m`=w-Bf ziqDREYj?Haug7i{o6=3&cQ|D4I3*e35j4wTuK%g+x1E@3og6+yDj05l$EJJK%3)WH zdeNgLx0c>jK6d`e68no+C4-x%aWrW?^kMNXF7;W^rKFrT*VMw`fNN-ge2&eoyvQ@L zf7_jGpC>Qwh(Bf1f5B_lg8NDLP6V%KVrFDuT pwfile + +certutil -d . -N -f pwfile + +certutil -S -z noise -g 1024 -d . -n ca -s "CN=NSS Test CA,O=BOGUS NSS,L=Mountain View,ST=California,C=US" -t C,C,C -x -m 1 -w -2 -v 120 -1 -2 -5 < NameConstraints.ca.cert +certutil -d . -L -n ica -r > NameConstraints.intermediate.cert +certutil -d . -L -n server1 -r > NameConstraints.server1.cert +certutil -d . -L -n server2 -r > NameConstraints.server2.cert +certutil -d . -L -n server3 -r > NameConstraints.server3.cert + +echo "Created multiple files in subdirectory tmp: NameConstraints.ca.cert NameConstraints.intermediate.cert NameConstraints.server1.cert NameConstraints.server2.cert NameConstraints.server3.cert" From 44d26ad07a8d0564f9f7e48fa54d4d0a3630f091 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Wed, 12 Jun 2013 23:57:51 -0400 Subject: [PATCH 19/90] Bug 880836. Add MaskSurface() to Azure. r=bas This gives a substantial performance improvement over the more general Mask(): Test (MaskSurface10x10): 1.93042ms +/- 0.305028 Test (MaskSurface100x100): 2.33435ms +/- 1.00807 Test (MaskSurface500x500): 28.0472ms +/- 0.820744 Test (MaskSurface1000x1000): 107.656ms +/- 6.44615 Test (Mask10x10): 13.5237ms +/- 0.0932034 Test (Mask100x100): 14.0742ms +/- 1.21005 Test (Mask500x500): 96.5596ms +/- 1.81415 Test (Mask1000x1000): 356.891ms +/- 9.30592 --HG-- extra : rebase_source : a3031305302fb4abe93aa480df35ed0936d68cd8 --- gfx/2d/2D.h | 15 ++++ gfx/2d/DrawTargetCG.cpp | 32 +++++++ gfx/2d/DrawTargetCG.h | 4 + gfx/2d/DrawTargetCairo.cpp | 49 +++++++++++ gfx/2d/DrawTargetD2D.cpp | 140 +++++++++++++++++++----------- gfx/2d/DrawTargetD2D.h | 8 ++ gfx/2d/DrawTargetDual.cpp | 12 +++ gfx/2d/DrawTargetDual.h | 7 +- gfx/thebes/gfxContext.cpp | 9 +- layout/reftests/bugs/reftest.list | 2 +- 10 files changed, 220 insertions(+), 58 deletions(-) diff --git a/gfx/2d/2D.h b/gfx/2d/2D.h index 423820279205..f0ccef614ae9 100644 --- a/gfx/2d/2D.h +++ b/gfx/2d/2D.h @@ -706,6 +706,21 @@ public: const Pattern &aMask, const DrawOptions &aOptions = DrawOptions()) = 0; + /* + * This takes a source pattern and a mask, and composites the source pattern + * onto the destination surface using the alpha channel of the mask source. + * The operation is bound by the extents of the mask. + * + * aSource Source pattern + * aMask Mask surface + * aOffset a transformed offset that the surface is masked at + * aOptions Drawing options + */ + virtual void MaskSurface(const Pattern &aSource, + SourceSurface *aMask, + Point aOffset, + const DrawOptions &aOptions = DrawOptions()) { MOZ_ASSERT(0); }; + /* * Push a clip to the DrawTarget. * diff --git a/gfx/2d/DrawTargetCG.cpp b/gfx/2d/DrawTargetCG.cpp index f0785504728d..2777f250ced5 100644 --- a/gfx/2d/DrawTargetCG.cpp +++ b/gfx/2d/DrawTargetCG.cpp @@ -300,6 +300,38 @@ DrawTargetCG::DrawSurface(SourceSurface *aSurface, CGImageRelease(subimage); } +void +DrawTargetCG::MaskSurface(const Pattern &aSource, + SourceSurface *aMask, + Point aOffset, + const DrawOptions &aDrawOptions) +{ + MarkChanged(); + + CGImageRef image; + CGContextSaveGState(mCg); + + CGContextSetBlendMode(mCg, ToBlendMode(aDrawOptions.mCompositionOp)); + UnboundnessFixer fixer; + CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp); + CGContextSetAlpha(cg, aDrawOptions.mAlpha); + + CGContextConcatCTM(cg, GfxMatrixToCGAffineTransform(mTransform)); + image = GetImageFromSourceSurface(aMask); + + CGContextScaleCTM(cg, 1, -1); + + IntSize size = aMask->GetSize(); + CGContextClipToMask(cg, CGRectMake(aOffset.x, aOffset.y, size.width, size.height), image); + + FillRect(Rect(0, 0, size.width, size.height), aSource, aDrawOptions); + + fixer.Fix(mCg); + + CGContextRestoreGState(mCg); + +} + static CGColorRef ColorToCGColor(CGColorSpaceRef aColorSpace, const Color& aColor) { CGFloat components[4] = {aColor.r, aColor.g, aColor.b, aColor.a}; diff --git a/gfx/2d/DrawTargetCG.h b/gfx/2d/DrawTargetCG.h index e952a6ed6da8..9ddf29bbdcb9 100644 --- a/gfx/2d/DrawTargetCG.h +++ b/gfx/2d/DrawTargetCG.h @@ -96,6 +96,10 @@ public: const Rect &aSource, const DrawSurfaceOptions &aSurfOptions = DrawSurfaceOptions(), const DrawOptions &aOptions = DrawOptions()); + virtual void MaskSurface(const Pattern &aSource, + SourceSurface *aMask, + Point aOffset, + const DrawOptions &aOptions = DrawOptions()); virtual void FillRect(const Rect &aRect, const Pattern &aPattern, diff --git a/gfx/2d/DrawTargetCairo.cpp b/gfx/2d/DrawTargetCairo.cpp index 2918ce6d6ed7..6e7f6efe0ad3 100644 --- a/gfx/2d/DrawTargetCairo.cpp +++ b/gfx/2d/DrawTargetCairo.cpp @@ -676,6 +676,55 @@ DrawTargetCairo::Mask(const Pattern &aSource, cairo_pattern_destroy(mask); cairo_pattern_destroy(source); } +#if 0 +DrawTargetCairo::MaskSurface(SourceSurface *aSurface, + const Rect &aDest, + const Rect &aSource, + const DrawSurfaceOptions &aSurfOptions, + const DrawOptions &aOptions) +{ + AutoPrepareForDrawing prep(this, mContext); + + float sx = aSource.Width() / aDest.Width(); + float sy = aSource.Height() / aDest.Height(); + + cairo_matrix_t src_mat; + cairo_matrix_init_translate(&src_mat, aSource.X(), aSource.Y()); + cairo_matrix_scale(&src_mat, sx, sy); + + cairo_surface_t* surf = GetCairoSurfaceForSourceSurface(aSurface); + cairo_pattern_t* pat = cairo_pattern_create_for_surface(surf); + cairo_surface_destroy(surf); + + cairo_pattern_set_matrix(pat, &src_mat); + cairo_pattern_set_filter(pat, GfxFilterToCairoFilter(aSurfOptions.mFilter)); + cairo_pattern_set_extend(pat, CAIRO_EXTEND_PAD); + + cairo_translate(mContext, aDest.X(), aDest.Y()); + + if (IsOperatorBoundByMask(aOptions.mCompositionOp)) { + cairo_new_path(mContext); + cairo_rectangle(mContext, 0, 0, aDest.Width(), aDest.Height()); + cairo_clip(mContext); + cairo_set_source(mContext, pat); + } else { + cairo_push_group(mContext); + cairo_new_path(mContext); + cairo_rectangle(mContext, 0, 0, aDest.Width(), aDest.Height()); + cairo_set_source(mContext, pat); + cairo_fill(mContext); + cairo_pop_group_to_source(mContext); + } + + cairo_set_operator(mContext, GfxOpToCairoOp(aOptions.mCompositionOp)); + DrawPattern(aPattern, StrokeOptions(), aOptions, DRAW_FILL); + + cairo_paint_with_alpha(mContext, aOptions.mAlpha); + + cairo_pattern_destroy(pat); +} + +#endif void DrawTargetCairo::PushClip(const Path *aPath) diff --git a/gfx/2d/DrawTargetD2D.cpp b/gfx/2d/DrawTargetD2D.cpp index a38e1a41cf02..d41883fa5d8a 100644 --- a/gfx/2d/DrawTargetD2D.cpp +++ b/gfx/2d/DrawTargetD2D.cpp @@ -257,6 +257,63 @@ DrawTargetD2D::AddDependencyOnSource(SourceSurfaceD2DTarget* aSource) } } +TemporaryRef +DrawTargetD2D::GetBitmapForSurface(SourceSurface *aSurface, + Rect &aSource) +{ + RefPtr bitmap; + + switch (aSurface->GetType()) { + + case SURFACE_D2D1_BITMAP: + { + SourceSurfaceD2D *srcSurf = static_cast(aSurface); + bitmap = srcSurf->GetBitmap(); + } + break; + case SURFACE_D2D1_DRAWTARGET: + { + SourceSurfaceD2DTarget *srcSurf = static_cast(aSurface); + bitmap = srcSurf->GetBitmap(mRT); + AddDependencyOnSource(srcSurf); + } + break; + default: + { + RefPtr srcSurf = aSurface->GetDataSurface(); + + if (!srcSurf) { + gfxDebug() << "Not able to deal with non-data source surface."; + return nullptr; + } + + if (aSource.width > mRT->GetMaximumBitmapSize() || + aSource.height > mRT->GetMaximumBitmapSize()) { + gfxDebug() << "Bitmap source larger than texture size specified. DrawBitmap will silently fail."; + // Don't know how to deal with this yet. + return nullptr; + } + + int stride = srcSurf->Stride(); + + unsigned char *data = srcSurf->GetData() + + (uint32_t)aSource.y * stride + + (uint32_t)aSource.x * BytesPerPixel(srcSurf->GetFormat()); + + D2D1_BITMAP_PROPERTIES props = + D2D1::BitmapProperties(D2D1::PixelFormat(DXGIFormat(srcSurf->GetFormat()), AlphaMode(srcSurf->GetFormat()))); + mRT->CreateBitmap(D2D1::SizeU(UINT32(aSource.width), UINT32(aSource.height)), data, stride, props, byRef(bitmap)); + + // subtract the integer part leaving the fractional part + aSource.x -= (uint32_t)aSource.x; + aSource.y -= (uint32_t)aSource.y; + } + break; + } + + return bitmap; +} + void DrawTargetD2D::DrawSurface(SourceSurface *aSurface, const Rect &aDest, @@ -274,62 +331,45 @@ DrawTargetD2D::DrawSurface(SourceSurface *aSurface, Rect srcRect = aSource; - switch (aSurface->GetType()) { - - case SURFACE_D2D1_BITMAP: - { - SourceSurfaceD2D *srcSurf = static_cast(aSurface); - bitmap = srcSurf->GetBitmap(); - - if (!bitmap) { - return; - } - } - break; - case SURFACE_D2D1_DRAWTARGET: - { - SourceSurfaceD2DTarget *srcSurf = static_cast(aSurface); - bitmap = srcSurf->GetBitmap(mRT); - AddDependencyOnSource(srcSurf); - } - break; - default: - { - RefPtr srcSurf = aSurface->GetDataSurface(); - - if (!srcSurf) { - gfxDebug() << "Not able to deal with non-data source surface."; - return; - } - - if (aSource.width > rt->GetMaximumBitmapSize() || - aSource.height > rt->GetMaximumBitmapSize()) { - gfxDebug() << "Bitmap source larger than texture size specified. DrawBitmap will silently fail."; - // Don't know how to deal with this yet. - return; - } - - int stride = srcSurf->Stride(); - - unsigned char *data = srcSurf->GetData() + - (uint32_t)aSource.y * stride + - (uint32_t)aSource.x * BytesPerPixel(srcSurf->GetFormat()); - - D2D1_BITMAP_PROPERTIES props = - D2D1::BitmapProperties(D2D1::PixelFormat(DXGIFormat(srcSurf->GetFormat()), AlphaMode(srcSurf->GetFormat()))); - mRT->CreateBitmap(D2D1::SizeU(UINT32(aSource.width), UINT32(aSource.height)), data, stride, props, byRef(bitmap)); - - srcRect.x -= (uint32_t)aSource.x; - srcRect.y -= (uint32_t)aSource.y; - } - break; + bitmap = GetBitmapForSurface(aSurface, srcRect); + if (!bitmap) { + return; } - + rt->DrawBitmap(bitmap, D2DRect(aDest), aOptions.mAlpha, D2DFilter(aSurfOptions.mFilter), D2DRect(srcRect)); FinalizeRTForOperation(aOptions.mCompositionOp, ColorPattern(Color()), aDest); } +void +DrawTargetD2D::MaskSurface(const Pattern &aSource, + SourceSurface *aMask, + Point aOffset, + const DrawOptions &aOptions) +{ + RefPtr bitmap; + + ID2D1RenderTarget *rt = GetRTForOperation(aOptions.mCompositionOp, ColorPattern(Color())); + + PrepareForDrawing(rt); + + // FillOpacityMask only works if the antialias mode is MODE_ALIASED + rt->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED); + + IntSize size = aMask->GetSize(); + Rect maskRect = Rect(0.f, 0.f, size.width, size.height); + bitmap = GetBitmapForSurface(aMask, maskRect); + if (!bitmap) { + return; + } + + Rect dest = Rect(aOffset.x, aOffset.y, size.width, size.height); + RefPtr brush = CreateBrushForPattern(aSource, aOptions.mAlpha); + rt->FillOpacityMask(bitmap, brush, D2D1_OPACITY_MASK_CONTENT_GRAPHICS, D2DRect(dest), D2DRect(maskRect)); + + FinalizeRTForOperation(aOptions.mCompositionOp, ColorPattern(Color()), dest); +} + void DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface, const Point &aDest, diff --git a/gfx/2d/DrawTargetD2D.h b/gfx/2d/DrawTargetD2D.h index 1e8ed6350d7c..83048a418df5 100644 --- a/gfx/2d/DrawTargetD2D.h +++ b/gfx/2d/DrawTargetD2D.h @@ -63,6 +63,11 @@ public: Float aSigma, CompositionOp aOperator); virtual void ClearRect(const Rect &aRect); + virtual void MaskSurface(const Pattern &aSource, + SourceSurface *aMask, + Point aOffset, + const DrawOptions &aOptions = DrawOptions()); + virtual void CopySurface(SourceSurface *aSurface, const IntRect &aSourceRect, @@ -142,6 +147,9 @@ public: static uint64_t mVRAMUsageSS; private: + TemporaryRef + DrawTargetD2D::GetBitmapForSurface(SourceSurface *aSurface, + Rect &aSource); friend class AutoSaveRestoreClippedOut; friend class SourceSurfaceD2DTarget; diff --git a/gfx/2d/DrawTargetDual.cpp b/gfx/2d/DrawTargetDual.cpp index 1235a85fd102..1ee556cd4db6 100644 --- a/gfx/2d/DrawTargetDual.cpp +++ b/gfx/2d/DrawTargetDual.cpp @@ -97,6 +97,18 @@ DrawTargetDual::DrawSurfaceWithShadow(SourceSurface *aSurface, const Point &aDes mB->DrawSurfaceWithShadow(surface.mB, aDest, aColor, aOffset, aSigma, aOp); } +void +DrawTargetDual::MaskSurface(const Pattern &aSource, + SourceSurface *aMask, + Point aOffset, + const DrawOptions &aOptions) +{ + DualPattern source(aSource); + DualSurface mask(aMask); + mA->MaskSurface(*source.mA, mask.mA, aOffset, aOptions); + mB->MaskSurface(*source.mB, mask.mA, aOffset, aOptions); +} + void DrawTargetDual::CopySurface(SourceSurface *aSurface, const IntRect &aSourceRect, const IntPoint &aDestination) diff --git a/gfx/2d/DrawTargetDual.h b/gfx/2d/DrawTargetDual.h index b2fb0b3a5153..8f519603a199 100644 --- a/gfx/2d/DrawTargetDual.h +++ b/gfx/2d/DrawTargetDual.h @@ -59,7 +59,12 @@ public: virtual void DrawSurface(SourceSurface *aSurface, const Rect &aDest, const Rect & aSource, const DrawSurfaceOptions &aSurfOptions, const DrawOptions &aOptions); - + + virtual void MaskSurface(const Pattern &aSource, + SourceSurface *aMask, + Point aOffset, + const DrawOptions &aOptions = DrawOptions()); + virtual void DrawSurfaceWithShadow(SourceSurface *aSurface, const Point &aDest, const Color &aColor, const Point &aOffset, Float aSigma, CompositionOp aOp); diff --git a/gfx/thebes/gfxContext.cpp b/gfx/thebes/gfxContext.cpp index 70683a33ba30..3913637dd934 100644 --- a/gfx/thebes/gfxContext.cpp +++ b/gfx/thebes/gfxContext.cpp @@ -1397,7 +1397,6 @@ gfxContext::GetPattern() // masking - void gfxContext::Mask(gfxPattern *pattern) { @@ -1463,12 +1462,10 @@ gfxContext::Mask(gfxASurface *surface, const gfxPoint& offset) gfxPoint pt = surface->GetDeviceOffset(); // We clip here to bind to the mask surface bounds, see above. - mDT->PushClipRect(Rect(offset.x - pt.x, offset.y - pt.y, sourceSurf->GetSize().width, sourceSurf->GetSize().height)); - mDT->Mask(GeneralPattern(this), - SurfacePattern(sourceSurf, EXTEND_CLAMP, - Matrix(1.0f, 0, 0, 1.0f, Float(offset.x - pt.x), Float(offset.y - pt.y))), + mDT->MaskSurface(GeneralPattern(this), + sourceSurf, + Point(offset.x - pt.x, offset.y - pt.y), DrawOptions(1.0f, CurrentState().op, CurrentState().aaMode)); - mDT->PopClip(); } } diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index d3d7c09d45e3..adda9f35751a 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -1716,7 +1716,7 @@ skip-if(B2G) == 751012-1b.html 751012-1-ref.html random-if(Android) == 753329-1.html about:blank == 758561-1.html 758561-1-ref.html fuzzy-if(true,1,19) fails-if(d2d) == 759036-1.html 759036-1-ref.html -fuzzy-if(true,17,5859) == 759036-2.html 759036-2-ref.html +fuzzy-if(true,17,5860) == 759036-2.html 759036-2-ref.html == 776265-1a.html 776265-1-ref.html == 776265-1b.html 776265-1-ref.html == 776265-1c.html 776265-1-ref.html From 14bc8b71cf75f35776a8fcaeb73bd17d4489b070 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Thu, 13 Jun 2013 20:20:15 -0700 Subject: [PATCH 20/90] Bug 883071 - Don't send opted-out SSIDs when querying Google Location Service. r=dougt --- dom/system/NetworkGeolocationProvider.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dom/system/NetworkGeolocationProvider.js b/dom/system/NetworkGeolocationProvider.js index 149cba2ee800..6cb0678e42ca 100755 --- a/dom/system/NetworkGeolocationProvider.js +++ b/dom/system/NetworkGeolocationProvider.js @@ -213,10 +213,15 @@ WifiGeoPositionProvider.prototype = { if (accessToken !== "") providerUrl = providerUrl + "&access_token="+accessToken; - function sort(a, b) { + function bySignal(a, b) { return b.signal - a.signal; }; + function noOptOut(ap) { + let optOut = (ap.ssid === "" || ap.ssid.endsWith("_nomap")); + return !optOut; + }; + function encode(ap) { // make sure that the ssid doesn't contain any | chars. ap.ssid = ap.ssid.replace("|", "\\|"); @@ -225,7 +230,10 @@ WifiGeoPositionProvider.prototype = { }; if (accessPoints) { - providerUrl = providerUrl + accessPoints.sort(sort).map(encode).join(""); + providerUrl += accessPoints.filter(noOptOut) + .sort(bySignal) + .map(encode) + .join(""); } providerUrl = encodeURI(providerUrl); From fa4134fee1567b262582381d35e25f54cf0769e8 Mon Sep 17 00:00:00 2001 From: Luke Wagner Date: Tue, 18 Jun 2013 13:22:58 -0700 Subject: [PATCH 21/90] Bug 853239 - warn on a statement expression use (r=jorendorff) --HG-- extra : rebase_source : dcf55a0ac3312f5d8750c9a0ccbdd1968925dbd5 --- js/src/frontend/BytecodeCompiler.cpp | 2 +- js/src/frontend/Parser.cpp | 16 ++++++++---- js/src/frontend/Parser.h | 2 +- js/src/jit-test/lib/asm.js | 26 +++++++++++++++++++ .../tests/asm.js/testUseAsmWarnings.js | 14 ++++++++++ js/src/js.msg | 2 +- 6 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 js/src/jit-test/tests/asm.js/testUseAsmWarnings.js diff --git a/js/src/frontend/BytecodeCompiler.cpp b/js/src/frontend/BytecodeCompiler.cpp index fd042416185b..d290bf64076a 100644 --- a/js/src/frontend/BytecodeCompiler.cpp +++ b/js/src/frontend/BytecodeCompiler.cpp @@ -268,7 +268,7 @@ frontend::CompileScript(JSContext *cx, HandleObject scopeChain, TokenStream::Position pos(parser.keepAtoms); parser.tokenStream.tell(&pos); - ParseNode *pn = parser.statement(); + ParseNode *pn = parser.statement(canHaveDirectives); if (!pn) { if (parser.hadAbortedSyntaxParse()) { // Parsing inner functions lazily may lead the parser into an diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index 06e4bbcb23d2..a63fbbfe748a 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -2521,7 +2521,7 @@ Parser::statements() } break; } - Node next = statement(); + Node next = statement(canHaveDirectives); if (!next) { if (tokenStream.isEOF()) tokenStream.setUnexpectedEOF(); @@ -4501,7 +4501,7 @@ Parser::expressionStatement() template typename ParseHandler::Node -Parser::statement() +Parser::statement(bool canHaveDirectives) { Node pn; @@ -4781,7 +4781,14 @@ Parser::statement() case TOK_ERROR: return null(); - case TOK_NAME: { + case TOK_STRING: + if (!canHaveDirectives && tokenStream.currentToken().atom() == context->names().useAsm) { + if (!report(ParseWarning, false, null(), JSMSG_USE_ASM_DIRECTIVE_FAIL)) + return null(); + } + return expressionStatement(); + + case TOK_NAME: if (tokenStream.peekToken() == TOK_COLON) return labeledStatement(); if (tokenStream.currentToken().name() == context->names().module @@ -4789,8 +4796,7 @@ Parser::statement() { return moduleDecl(); } - } - /* FALL THROUGH */ + return expressionStatement(); default: return expressionStatement(); diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index bd4d8a600bd6..0fb3e84372f8 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -372,7 +372,7 @@ struct Parser : private AutoGCRooter, public StrictModeGetter public: /* Public entry points for parsing. */ - Node statement(); + Node statement(bool canHaveDirectives = false); bool maybeParseDirective(Node pn, bool *cont); // Parse a function, given only its body. Used for the Function constructor. diff --git a/js/src/jit-test/lib/asm.js b/js/src/jit-test/lib/asm.js index 5bee8b9deb01..812cc71cc7ce 100644 --- a/js/src/jit-test/lib/asm.js +++ b/js/src/jit-test/lib/asm.js @@ -4,6 +4,7 @@ const ASM_OK_STRING = "successfully compiled asm.js code"; const ASM_TYPE_FAIL_STRING = "asm.js type error:"; +const ASM_DIRECTIVE_FAIL_STRING = "\"use asm\" is only meaningful in the Directive Prologue of a function body"; const USE_ASM = "'use asm';"; const HEAP_IMPORTS = "var i8=new glob.Int8Array(b);var u8=new glob.Uint8Array(b);"+ @@ -19,6 +20,31 @@ function asmCompile() return f; } +function assertAsmDirectiveFail(str) +{ + if (!isAsmJSCompilationAvailable()) + return; + + // Turn on warnings-as-errors + var oldOpts = options("werror"); + assertEq(oldOpts.indexOf("werror"), -1); + + // Verify an error is thrown + var caught = false; + try { + eval(str); + } catch (e) { + if ((''+e).indexOf(ASM_DIRECTIVE_FAIL_STRING) == -1) + throw new Error("Didn't catch the expected directive failure error; instead caught: " + e); + caught = true; + } + if (!caught) + throw new Error("Didn't catch the directive failure error"); + + // Turn warnings-as-errors back off + options("werror"); +} + function assertAsmTypeFail() { if (!isAsmJSCompilationAvailable()) diff --git a/js/src/jit-test/tests/asm.js/testUseAsmWarnings.js b/js/src/jit-test/tests/asm.js/testUseAsmWarnings.js new file mode 100644 index 000000000000..46a15d7524f7 --- /dev/null +++ b/js/src/jit-test/tests/asm.js/testUseAsmWarnings.js @@ -0,0 +1,14 @@ +load(libdir + "asm.js"); + +assertAsmDirectiveFail("'use asm'"); +assertAsmDirectiveFail("eval('\"use asm\";');"); +assertAsmDirectiveFail("{ eval('\"use asm\";'); }"); +assertAsmDirectiveFail("if (Math) { 'use asm'; }"); +assertAsmDirectiveFail("function f(){ { 'use asm'; } }"); +assertAsmDirectiveFail("function f(){ ; 'use asm'; } }"); +assertAsmDirectiveFail("function f(){ 1; 'use asm'; } }"); +assertAsmDirectiveFail("function f(){ var x; 'use asm'; } }"); +assertAsmDirectiveFail("function f(){ if (Math) { 'use asm'; } }"); +assertAsmDirectiveFail("(function(){ eval('\"use asm\";') })()"); +assertAsmDirectiveFail("new Function('{\"use asm\";}')"); +assertAsmDirectiveFail("new Function('if (Math){\"use asm\";}')"); diff --git a/js/src/js.msg b/js/src/js.msg index 5fb4ecc2ba33..40470351fa18 100644 --- a/js/src/js.msg +++ b/js/src/js.msg @@ -391,7 +391,7 @@ MSG_DEF(JSMSG_DATE_NOT_FINITE, 337, 0, JSEXN_RANGEERR, "date value is not MSG_DEF(JSMSG_MODULE_STATEMENT, 338, 0, JSEXN_SYNTAXERR, "module declarations may only appear at the top level of a program or module body") MSG_DEF(JSMSG_CURLY_BEFORE_MODULE, 339, 0, JSEXN_SYNTAXERR, "missing { before module body") MSG_DEF(JSMSG_CURLY_AFTER_MODULE, 340, 0, JSEXN_SYNTAXERR, "missing } after module body") -MSG_DEF(JSMSG_USE_ASM_DIRECTIVE_FAIL, 341, 0, JSEXN_SYNTAXERR, "'use asm' directive only works on function code") +MSG_DEF(JSMSG_USE_ASM_DIRECTIVE_FAIL, 341, 0, JSEXN_SYNTAXERR, "\"use asm\" is only meaningful in the Directive Prologue of a function body") MSG_DEF(JSMSG_USE_ASM_TYPE_FAIL, 342, 1, JSEXN_TYPEERR, "asm.js type error: {0}") MSG_DEF(JSMSG_USE_ASM_LINK_FAIL, 343, 1, JSEXN_TYPEERR, "asm.js link error: {0}") MSG_DEF(JSMSG_USE_ASM_TYPE_OK, 344, 1, JSEXN_ERR, "successfully compiled asm.js code ({0})") From a2b2d149355dac851772442a29f2176b4ba1418b Mon Sep 17 00:00:00 2001 From: Jason Orendorff Date: Tue, 18 Jun 2013 15:35:22 -0500 Subject: [PATCH 22/90] Back out rev 5d35dc039af7 (bug 875433) due to Web compatibility issues (bug 881782, bug 883914). rs=Waldo on IRC. --- .../tests/collections/Array-iterator-surfaces.js | 4 ---- js/src/jsarray.cpp | 9 +-------- 2 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 js/src/jit-test/tests/collections/Array-iterator-surfaces.js diff --git a/js/src/jit-test/tests/collections/Array-iterator-surfaces.js b/js/src/jit-test/tests/collections/Array-iterator-surfaces.js deleted file mode 100644 index e4779ee581f7..000000000000 --- a/js/src/jit-test/tests/collections/Array-iterator-surfaces.js +++ /dev/null @@ -1,4 +0,0 @@ -// Array.prototype.iterator is the same function object as .values. - -assertEq(Array.prototype.values, Array.prototype.iterator); -assertEq(Array.prototype.iterator.name, "values"); diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index d5d3ee41d1f4..14b93f57c743 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -2720,6 +2720,7 @@ static const JSFunctionSpec array_methods[] = { {"some", {NULL, NULL}, 1,0, "ArraySome"}, {"every", {NULL, NULL}, 1,0, "ArrayEvery"}, + JS_FN("iterator", JS_ArrayIterator, 0,0), JS_FS_END }; @@ -2838,14 +2839,6 @@ js_InitArrayClass(JSContext *cx, HandleObject obj) if (!DefineConstructorAndPrototype(cx, global, JSProto_Array, ctor, arrayProto)) return NULL; - JSFunction *fun = JS_DefineFunction(cx, arrayProto, "values", JS_ArrayIterator, 0, 0); - if (!fun) - return NULL; - - RootedValue funval(cx, ObjectValue(*fun)); - if (!JS_DefineProperty(cx, arrayProto, "iterator", funval, NULL, NULL, 0)) - return NULL; - return arrayProto; } From f76df80267942cdd39bb5abc94cf3a48abe944ae Mon Sep 17 00:00:00 2001 From: Arnaud Sourioux Date: Tue, 18 Jun 2013 17:25:50 -0400 Subject: [PATCH 23/90] Bug 702080 - Replace GetDisplayDocument with IsResourceDoc when needed. r=bz --- content/base/src/nsFrameLoader.cpp | 6 +++--- layout/generic/nsFrame.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/content/base/src/nsFrameLoader.cpp b/content/base/src/nsFrameLoader.cpp index c63724cadd78..c4735ed3aaa5 100644 --- a/content/base/src/nsFrameLoader.cpp +++ b/content/base/src/nsFrameLoader.cpp @@ -298,7 +298,7 @@ nsFrameLoader::Create(Element* aOwner, bool aNetworkCreated) { NS_ENSURE_TRUE(aOwner, nullptr); nsIDocument* doc = aOwner->OwnerDoc(); - NS_ENSURE_TRUE(!doc->GetDisplayDocument() && + NS_ENSURE_TRUE(!doc->IsResourceDoc() && ((!doc->IsLoadedAsData() && aOwner->GetCurrentDoc()) || doc->IsStaticDocument()), nullptr); @@ -1792,7 +1792,7 @@ nsFrameLoader::GetWindowDimensions(nsRect& aRect) return NS_ERROR_FAILURE; } - if (doc->GetDisplayDocument()) { + if (doc->IsResourceDoc()) { return NS_ERROR_FAILURE; } @@ -1967,7 +1967,7 @@ nsFrameLoader::TryRemoteBrowser() return false; } - if (doc->GetDisplayDocument()) { + if (doc->IsResourceDoc()) { // Don't allow subframe loads in external reference documents return false; } diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index c799e5ed43bc..82c95975446f 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -4883,7 +4883,7 @@ nsIFrame::SchedulePaint(uint32_t aFlags) // No need to schedule a paint for an external document since they aren't // painted directly. - if (!pres || (pres->Document() && pres->Document()->GetDisplayDocument())) { + if (!pres || (pres->Document() && pres->Document()->IsResourceDoc())) { return; } From a9a29634bb19ac434c25ed2d5cd70a647f3e6711 Mon Sep 17 00:00:00 2001 From: Stefan Mirea Date: Tue, 18 Jun 2013 11:06:20 -0700 Subject: [PATCH 24/90] Bug 867902 - Remove old saved FHR payload from disk. r=gps --- services/healthreport/healthreporter.jsm | 69 ++++++++++++++----- .../tests/xpcshell/test_healthreporter.js | 36 ++++++++++ 2 files changed, 87 insertions(+), 18 deletions(-) diff --git a/services/healthreport/healthreporter.jsm b/services/healthreport/healthreporter.jsm index 3fdc91250d35..918cd0d033d3 100644 --- a/services/healthreport/healthreporter.jsm +++ b/services/healthreport/healthreporter.jsm @@ -101,6 +101,10 @@ HealthReporterState.prototype = Object.freeze({ return this._s.remoteIDs; }, + get _lastPayloadPath() { + return OS.Path.join(this._stateDir, "lastpayload.json"); + }, + init: function () { return Task.spawn(function init() { try { @@ -116,6 +120,7 @@ HealthReporterState.prototype = Object.freeze({ v: 1, remoteIDs: [], lastPingTime: 0, + removedOutdatedLastpayload: false, }; }.bind(this); @@ -138,21 +143,13 @@ HealthReporterState.prototype = Object.freeze({ if (typeof(this._s) != "object") { this._log.warn("Read state is not an object. Resetting state."); - this._s = { - v: 1, - remoteIDs: [], - lastPingTime: 0, - }; + resetObjectState(); yield this.save(); } if (this._s.v != 1) { this._log.warn("Unknown version in state file: " + this._s.v); - this._s = { - v: 1, - remoteIDs: [], - lastPingTime: 0, - }; + resetObjectState(); // We explicitly don't save here in the hopes an application re-upgrade // comes along and fixes us. } @@ -343,16 +340,52 @@ AbstractHealthReporter.prototype = Object.freeze({ }, _onStateInitialized: function () { - // As soon as we have could storage, we need to register cleanup or - // else bad things happen on shutdown. - Services.obs.addObserver(this, "quit-application", false); - Services.obs.addObserver(this, "profile-before-change", false); + return Task.spawn(function onStateInitialized () { + try { + if (!this._state._s.removedOutdatedLastpayload) { + yield this._deleteOldLastPayload(); + this._state._s.removedOutdatedLastpayload = true; + // Normally we should save this to a file but it directly conflicts with + // the "application re-upgrade" decision in HealthReporterState::init() + // which specifically does not save the state to a file. + } + } catch (ex) { + this._log.error("Error deleting last payload: " + + CommonUtils.exceptionStr(ex)); + } + // As soon as we have could storage, we need to register cleanup or + // else bad things happen on shutdown. + Services.obs.addObserver(this, "quit-application", false); + Services.obs.addObserver(this, "profile-before-change", false); - this._storageInProgress = true; - TelemetryStopwatch.start(this._dbOpenHistogram, this); + this._storageInProgress = true; + TelemetryStopwatch.start(this._dbOpenHistogram, this); - Metrics.Storage(this._dbName).then(this._onStorageCreated.bind(this), - this._onInitError.bind(this)); + Metrics.Storage(this._dbName).then(this._onStorageCreated.bind(this), + this._onInitError.bind(this)); + }.bind(this)); + }, + + + /** + * Removes the outdated lastpaylaod.json and lastpayload.json.tmp files + * @see Bug #867902 + * @return a promise for when all the files have been deleted + */ + _deleteOldLastPayload: function () { + let paths = [this._state._lastPayloadPath, this._state._lastPayloadPath + ".tmp"]; + return Task.spawn(function removeAllFiles () { + for (let path of paths) { + try { + OS.File.remove(path); + } catch (ex) { + if (!ex.becauseNoSuchFile) { + this._log.error("Exception when removing outdated payload files: " + + CommonUtils.exceptionStr(ex)); + } + } + } + }.bind(this)); }, // Called when storage has been opened. diff --git a/services/healthreport/tests/xpcshell/test_healthreporter.js b/services/healthreport/tests/xpcshell/test_healthreporter.js index a3d30d96e677..6b0ef721f56f 100644 --- a/services/healthreport/tests/xpcshell/test_healthreporter.js +++ b/services/healthreport/tests/xpcshell/test_healthreporter.js @@ -285,6 +285,42 @@ add_task(function test_collect_daily() { } }); +add_task(function test_remove_old_lastpayload() { + let reporter = getJustReporter("remove-old-lastpayload"); + let lastPayloadPath = reporter._state._lastPayloadPath; + let paths = [lastPayloadPath, lastPayloadPath + ".tmp"]; + let createFiles = function () { + return Task.spawn(function createFiles() { + for (let path of paths) { + yield OS.File.writeAtomic(path, "delete-me", {tmpPath: path + ".tmp"}); + do_check_true(yield OS.File.exists(path)); + } + }); + }; + try { + do_check_true(!reporter._state.removedOutdatedLastpayload); + yield createFiles(); + yield reporter.init(); + for (let path of paths) { + do_check_false(yield OS.File.exists(path)); + } + yield reporter._state.save(); + reporter._shutdown(); + + let o = yield CommonUtils.readJSON(reporter._state._filename); + do_check_true(o.removedOutdatedLastpayload); + + yield createFiles(); + reporter = getJustReporter("remove-old-lastpayload"); + yield reporter.init(); + for (let path of paths) { + do_check_true(yield OS.File.exists(path)); + } + } finally { + reporter._shutdown(); + } +}); + add_task(function test_json_payload_simple() { let reporter = yield getReporter("json_payload_simple"); From f966391be298482f35298b6f5740b3223ecf0d9b Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Tue, 18 Jun 2013 17:27:04 -0400 Subject: [PATCH 25/90] Bug 879228 - [browserconsole] tune console.jsm to ease Addon SDK integration. r=msucan --- toolkit/devtools/Console.jsm | 116 ++++++++++++++++++++++++++++++++--- 1 file changed, 106 insertions(+), 10 deletions(-) diff --git a/toolkit/devtools/Console.jsm b/toolkit/devtools/Console.jsm index 89629c5c5677..d3bb3c3c031c 100644 --- a/toolkit/devtools/Console.jsm +++ b/toolkit/devtools/Console.jsm @@ -20,7 +20,7 @@ * implementation isn't always required (or even well defined) */ -this.EXPORTED_SYMBOLS = [ "console" ]; +this.EXPORTED_SYMBOLS = [ "console", "ConsoleAPI" ]; const Cu = Components.utils; @@ -272,6 +272,41 @@ function logProperty(aProp, aValue) { return reply; } +const LOG_LEVELS = { + "all": Number.MIN_VALUE, + "debug": 2, + "log": 3, + "info": 3, + "trace": 3, + "timeEnd": 3, + "time": 3, + "group": 3, + "groupEnd": 3, + "dir": 3, + "dirxml": 3, + "warn": 4, + "error": 5, + "off": Number.MAX_VALUE, +}; + +/** + * Helper to tell if a console message of `aLevel` type + * should be logged in stdout and sent to consoles given + * the current maximum log level being defined in `console.maxLogLevel` + * + * @param {string} aLevel + * Console message log level + * @param {string} aMaxLevel {string} + * String identifier (See LOG_LEVELS for possible + * values) that allows to filter which messages + * are logged based on their log level + * @return {boolean} + * Should this message be logged or not? + */ +function shouldLog(aLevel, aMaxLevel) { + return LOG_LEVELS[aMaxLevel] <= LOG_LEVELS[aLevel]; +} + /** * Parse a stack trace, returning an array of stack frame objects, where * each has filename/lineNumber/functionName members @@ -388,6 +423,25 @@ function stopTimer(aName, aTimestamp) { return { name: aName, duration: duration }; } +/** + * Dump a new message header to stdout by taking care of adding an eventual + * prefix + * + * @param {object} aConsole + * ConsoleAPI instance + * @param {string} aLevel + * The string identifier for the message log level + * @param {string} aMessage + * The string message to print to stdout + */ +function dumpMessage(aConsole, aLevel, aMessage) { + aConsole.dump( + "console." + aLevel + ": " + + aConsole.prefix + + aMessage + "\n" + ); +} + /** * Create a function which will output a concise level of output when used * as a logging function @@ -401,13 +455,16 @@ function stopTimer(aName, aTimestamp) { */ function createDumper(aLevel) { return function() { + if (!shouldLog(aLevel, this.maxLogLevel)) { + return; + } let args = Array.prototype.slice.call(arguments, 0); let frame = getStack(Components.stack.caller, 1)[0]; sendConsoleAPIMessage(aLevel, frame, args); let data = args.map(function(arg) { return stringify(arg); }); - dump("console." + aLevel + ": " + data.join(", ") + "\n"); + dumpMessage(this, aLevel, data.join(", ")); }; } @@ -424,13 +481,16 @@ function createDumper(aLevel) { */ function createMultiLineDumper(aLevel) { return function() { - dump("console." + aLevel + ": \n"); + if (!shouldLog(aLevel, this.maxLogLevel)) { + return; + } + dumpMessage(this, aLevel, ""); let args = Array.prototype.slice.call(arguments, 0); let frame = getStack(Components.stack.caller, 1)[0]; sendConsoleAPIMessage(aLevel, frame, args); args.forEach(function(arg) { - dump(log(arg)); - }); + this.dump(log(arg)); + }, this); }; } @@ -496,9 +556,32 @@ function sendConsoleAPIMessage(aLevel, aFrame, aArgs, aOptions = {}) /** * This creates a console object that somewhat replicates Firebug's console - * object. + * object + * + * @param {object} aConsoleOptions + * Optional dictionary with a set of runtime console options: + * - prefix {string} : An optional prefix string to be printed before + * the actual logged message + * - maxLogLevel {string} : String identifier (See LOG_LEVELS for + * possible values) that allows to filter which + * messages are logged based on their log level. + * If falsy value, all messages will be logged. + * If wrong value that doesn't match any key of + * LOG_LEVELS, no message will be logged + * - dump {function} : An optional function to intercept all strings + * written to stdout + * @return {object} + * A console API instance object */ -this.console = { +function ConsoleAPI(aConsoleOptions = {}) { + // Normalize console options to set default values + // in order to avoid runtime checks on each console method call. + this.dump = aConsoleOptions.dump || dump; + this.prefix = aConsoleOptions.prefix || ""; + this.maxLogLevel = aConsoleOptions.maxLogLevel || "all"; +} + +ConsoleAPI.prototype = { debug: createMultiLineDumper("debug"), log: createDumper("log"), info: createDumper("info"), @@ -507,11 +590,14 @@ this.console = { exception: createMultiLineDumper("error"), trace: function Console_trace() { + if (!shouldLog("trace", this.maxLogLevel)) { + return; + } let args = Array.prototype.slice.call(arguments, 0); let trace = getStack(Components.stack.caller); sendConsoleAPIMessage("trace", trace[0], args, { stacktrace: trace }); - dump("console.trace:\n" + formatTrace(trace) + "\n"); + dumpMessage(this, "trace", "\n" + formatTrace(trace)); }, clear: function Console_clear() {}, @@ -521,18 +607,28 @@ this.console = { groupEnd: createDumper("groupEnd"), time: function Console_time() { + if (!shouldLog("time", this.maxLogLevel)) { + return; + } let args = Array.prototype.slice.call(arguments, 0); let frame = getStack(Components.stack.caller, 1)[0]; let timer = startTimer(args[0]); sendConsoleAPIMessage("time", frame, args, { timer: timer }); - dump("console.time: '" + timer.name + "' @ " + (new Date()) + "\n"); + dumpMessage(this, "time", + "'" + timer.name + "' @ " + (new Date())); }, timeEnd: function Console_timeEnd() { + if (!shouldLog("timeEnd", this.maxLogLevel)) { + return; + } let args = Array.prototype.slice.call(arguments, 0); let frame = getStack(Components.stack.caller, 1)[0]; let timer = stopTimer(args[0]); sendConsoleAPIMessage("timeEnd", frame, args, { timer: timer }); - dump("console.timeEnd: '" + timer.name + "' " + timer.duration + "ms\n"); + dumpMessage(this, "timeEnd", + "'" + timer.name + "' " + timer.duration + "ms"); }, }; + +const console = new ConsoleAPI(); From 1f70d6040206bf70beaf7b5f651f5d7be628fd7b Mon Sep 17 00:00:00 2001 From: Michael Harrison Date: Tue, 18 Jun 2013 17:27:33 -0400 Subject: [PATCH 26/90] Bug 883777 - Reduce the width of the DNT preference "Learn More" link. r=dao --- browser/components/preferences/in-content/privacy.xul | 2 +- browser/components/preferences/privacy.xul | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/browser/components/preferences/in-content/privacy.xul b/browser/components/preferences/in-content/privacy.xul index 14bb769cf9e3..514c35626bfb 100644 --- a/browser/components/preferences/in-content/privacy.xul +++ b/browser/components/preferences/in-content/privacy.xul @@ -71,7 +71,7 @@ -