Merge b-i to m-c, a=merge
authorPhil Ringnalda <philringnalda@gmail.com>
Sun, 17 May 2015 09:05:23 -0700
changeset 244208 35918b0441b4ea614185fe2df5e8de4db9fb28d9
parent 244203 c08fea2b1d59a7c41d014b582f9e86dcc8f51d6a (diff)
parent 244207 dd3f4aa297108e73d2873bbda44774810bae3420 (current diff)
child 244209 579df6b63b9e5a26b2bc68b08df27833f2a860ec
child 244215 5f81902ee93e5bb5c76d511954dc30eae4e214f8
child 244243 42259ecc8e7621dd243415035596c07356ab07ee
push id28770
push userphilringnalda@gmail.com
push dateSun, 17 May 2015 16:05:32 +0000
treeherdermozilla-central@35918b0441b4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone41.0a1
first release with
nightly linux32
35918b0441b4 / 41.0a1 / 20150518030202 / files
nightly linux64
35918b0441b4 / 41.0a1 / 20150518030202 / files
nightly mac
35918b0441b4 / 41.0a1 / 20150518030202 / files
nightly win32
35918b0441b4 / 41.0a1 / 20150518030202 / files
nightly win64
35918b0441b4 / 41.0a1 / 20150518030202 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge b-i to m-c, a=merge
--- a/accessible/atk/Platform.cpp
+++ b/accessible/atk/Platform.cpp
@@ -356,18 +356,17 @@ dbus_done:
   if (reply)
     dbus_message_unref(reply);
 
   if (dbusSuccess)
     return sShouldEnable;
 #endif
 
   //check gconf-2 setting
-static const char sGconfAccessibilityKey[] =
-    "/desktop/gnome/interface/accessibility";
+#define GCONF_A11Y_KEY "/desktop/gnome/interface/accessibility"
   nsresult rv = NS_OK;
   nsCOMPtr<nsIGConfService> gconf =
     do_GetService(NS_GCONFSERVICE_CONTRACTID, &rv);
   if (NS_SUCCEEDED(rv) && gconf)
-    gconf->GetBool(NS_LITERAL_CSTRING(sGconfAccessibilityKey), &sShouldEnable);
+    gconf->GetBool(NS_LITERAL_CSTRING(GCONF_A11Y_KEY), &sShouldEnable);
 
   return sShouldEnable;
 }
--- a/caps/nsPrincipal.cpp
+++ b/caps/nsPrincipal.cpp
@@ -704,18 +704,16 @@ nsPrincipal::IsOnCSSUnprefixingWhitelist
       IsOnCSSUnprefixingWhitelistImpl(mCodebase));
   }
 
   return *mIsOnCSSUnprefixingWhitelist;
 }
 
 /************************************************************************************************************************/
 
-static const char EXPANDED_PRINCIPAL_SPEC[] = "[Expanded Principal]";
-
 NS_IMPL_CLASSINFO(nsExpandedPrincipal, nullptr, nsIClassInfo::MAIN_THREAD_ONLY,
                   NS_EXPANDEDPRINCIPAL_CID)
 NS_IMPL_QUERY_INTERFACE_CI(nsExpandedPrincipal,
                            nsIPrincipal,
                            nsIExpandedPrincipal)
 NS_IMPL_CI_INTERFACE_GETTER(nsExpandedPrincipal,
                              nsIPrincipal,
                              nsIExpandedPrincipal)
--- a/caps/nsSystemPrincipal.cpp
+++ b/caps/nsSystemPrincipal.cpp
@@ -24,22 +24,22 @@ NS_IMPL_CLASSINFO(nsSystemPrincipal, nul
                   NS_SYSTEMPRINCIPAL_CID)
 NS_IMPL_QUERY_INTERFACE_CI(nsSystemPrincipal,
                            nsIPrincipal,
                            nsISerializable)
 NS_IMPL_CI_INTERFACE_GETTER(nsSystemPrincipal,
                             nsIPrincipal,
                             nsISerializable)
 
-static const char SYSTEM_PRINCIPAL_SPEC[] = "[System Principal]";
+#define SYSTEM_PRINCIPAL_SPEC "[System Principal]"
 
 void
 nsSystemPrincipal::GetScriptLocation(nsACString &aStr)
 {
-    aStr.Assign(SYSTEM_PRINCIPAL_SPEC);
+    aStr.AssignLiteral(SYSTEM_PRINCIPAL_SPEC);
 }
 
 ///////////////////////////////////////
 // Methods implementing nsIPrincipal //
 ///////////////////////////////////////
 
 NS_IMETHODIMP
 nsSystemPrincipal::Equals(nsIPrincipal *other, bool *result)
--- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
@@ -2160,17 +2160,17 @@ BluetoothDaemonInterface::CreateRandomAd
  * If any step fails, we roll-back the procedure and signal an error to the
  * caller.
  */
 void
 BluetoothDaemonInterface::Init(
   BluetoothNotificationHandler* aNotificationHandler,
   BluetoothResultHandler* aRes)
 {
-  static const char BASE_SOCKET_NAME[] = "bluetoothd";
+#define BASE_SOCKET_NAME "bluetoothd"
   static unsigned long POSTFIX_LENGTH = 16;
 
   // If we could not cleanup properly before and an old
   // instance of the daemon is still running, we kill it
   // here.
   unused << NS_WARN_IF(property_set("ctl.stop", "bluetoothd"));
 
   sNotificationHandler = aNotificationHandler;
@@ -2200,17 +2200,17 @@ BluetoothDaemonInterface::Init(
   // previously failed cleanup. It also makes it hard for malicious
   // external programs to capture the socket name or connect before
   // the daemon can do so. If no random postfix can be generated, we
   // simply use the base name as-is.
   nsresult rv = CreateRandomAddressString(NS_LITERAL_CSTRING(BASE_SOCKET_NAME),
                                           POSTFIX_LENGTH,
                                           mListenSocketName);
   if (NS_FAILED(rv)) {
-    mListenSocketName = BASE_SOCKET_NAME;
+    mListenSocketName.AssignLiteral(BASE_SOCKET_NAME);
   }
 
   bool success = mListenSocket->Listen(
     new BluetoothDaemonSocketConnector(mListenSocketName), mCmdChannel);
   if (!success) {
     OnConnectError(CMD_CHANNEL);
     return;
   }
--- a/dom/events/test/test_bug1013412.html
+++ b/dom/events/test/test_bug1013412.html
@@ -88,16 +88,23 @@ function runTest() {
     return;
   }
   var scrollbox = document.getElementById('scrollbox');
   is(content.scrollTop < content.scrollTopMax, true, "We should not have scrolled to the bottom of the scrollframe");
   is(rotationAdjusted, true, "The rotation should have been adjusted");
   SimpleTest.finish();
 }
 
+function startTest() {
+  // If we allow smooth scrolling the "smooth" scrolling may cause the page to
+  // glide past the scrollbox (which is supposed to stop the scrolling) and so
+  // we might end up at the bottom of the page.
+  SpecialPowers.pushPrefEnv({"set": [["general.smoothScroll", false]]}, runTest);
+}
+
 SimpleTest.waitForExplicitFinish();
-SimpleTest.waitForFocus(runTest, window);
+SimpleTest.waitForFocus(startTest, window);
 
 </script>
 </pre>
 
 </body>
 </html>
--- a/dom/fetch/Fetch.cpp
+++ b/dom/fetch/Fetch.cpp
@@ -1522,17 +1522,17 @@ FetchBody<Derived>::ContinueConsumeBody(
       autoFree.Reset();
       return;
     }
     case CONSUME_FORMDATA: {
       nsCString data;
       data.Adopt(reinterpret_cast<char*>(aResult), aResultLength);
       autoFree.Reset();
 
-      NS_NAMED_LITERAL_CSTRING(formDataMimeType, NS_LITERAL_CSTRING("multipart/form-data"));
+      NS_NAMED_LITERAL_CSTRING(formDataMimeType, "multipart/form-data");
 
       // Allow semicolon separated boundary/encoding suffix like multipart/form-data; boundary=
       // but disallow multipart/form-datafoobar.
       bool isValidFormDataMimeType = StringBeginsWith(mMimeType, formDataMimeType);
 
       if (isValidFormDataMimeType && mMimeType.Length() > formDataMimeType.Length()) {
         isValidFormDataMimeType = mMimeType[formDataMimeType.Length()] == ';';
       }
@@ -1545,17 +1545,17 @@ FetchBody<Derived>::ContinueConsumeBody(
           localPromise->MaybeReject(result);
           return;
         }
 
         nsRefPtr<nsFormData> fd = parser.FormData();
         MOZ_ASSERT(fd);
         localPromise->MaybeResolve(fd);
       } else {
-        NS_NAMED_LITERAL_CSTRING(urlDataMimeType, NS_LITERAL_CSTRING("application/x-www-form-urlencoded"));
+        NS_NAMED_LITERAL_CSTRING(urlDataMimeType, "application/x-www-form-urlencoded");
         bool isValidUrlEncodedMimeType = StringBeginsWith(mMimeType, urlDataMimeType);
 
         if (isValidUrlEncodedMimeType && mMimeType.Length() > urlDataMimeType.Length()) {
           isValidUrlEncodedMimeType = mMimeType[urlDataMimeType.Length()] == ';';
         }
 
         if (isValidUrlEncodedMimeType) {
           nsRefPtr<URLSearchParams> params = new URLSearchParams();
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -211,40 +211,34 @@ const uint32_t kConnectionIdleCheckpoint
 
 // The length of time that database connections will be held open after all
 // transactions and checkpointing  have completed.
 const uint32_t kConnectionIdleCloseMS = 10 * 1000; // 10 seconds
 
 // The length of time that idle threads will stay alive before being shut down.
 const uint32_t kConnectionThreadIdleMS = 30 * 1000; // 30 seconds
 
-const char kSavepointClause[] = "SAVEPOINT sp;";
+#define SAVEPOINT_CLAUSE "SAVEPOINT sp;"
 
 const uint32_t kFileCopyBufferSize = 32768;
 
-const char kJournalDirectoryName[] = "journals";
+#define JOURNAL_DIRECTORY_NAME "journals"
 
 const char kFileManagerDirectoryNameSuffix[] = ".files";
 const char kSQLiteJournalSuffix[] = ".sqlite-journal";
 const char kSQLiteSHMSuffix[] = ".sqlite-shm";
 const char kSQLiteWALSuffix[] = ".sqlite-wal";
 
 const char kPrefIndexedDBEnabled[] = "dom.indexedDB.enabled";
 
 #define IDB_PREFIX "indexedDB"
 
-#ifdef MOZ_CHILD_PERMISSIONS
-const char kPermissionString[] = IDB_PREFIX;
-#endif // MOZ_CHILD_PERMISSIONS
-
-const char kPermissionStringChromeBase[] = IDB_PREFIX "-chrome-";
-const char kPermissionStringChromeReadSuffix[] = "-read";
-const char kPermissionStringChromeWriteSuffix[] = "-write";
-
-#undef IDB_PREFIX
+#define PERMISSION_STRING_CHROME_BASE IDB_PREFIX "-chrome-"
+#define PERMISSION_STRING_CHROME_READ_SUFFIX "-read"
+#define PERMISSION_STRING_CHROME_WRITE_SUFFIX "-write"
 
 enum AppId {
   kNoAppId = nsIScriptSecurityManager::NO_APP_ID,
   kUnknownAppId = nsIScriptSecurityManager::UNKNOWN_APP_ID
 };
 
 #ifdef DEBUG
 
@@ -4375,28 +4369,16 @@ public:
 
     return mUpdateRefcountFunction;
   }
 
   nsresult
   GetCachedStatement(const nsACString& aQuery,
                      CachedStatement* aCachedStatement);
 
-  template <size_t N>
-  nsresult
-  GetCachedStatement(const char (&aQuery)[N],
-                     CachedStatement* aCachedStatement)
-  {
-    static_assert(N > 1, "Must have a non-empty string!");
-    AssertIsOnConnectionThread();
-    MOZ_ASSERT(aCachedStatement);
-
-    return GetCachedStatement(NS_LITERAL_CSTRING(aQuery), aCachedStatement);
-  }
-
   nsresult
   BeginWriteTransaction();
 
   void
   RollbackWriteTransaction();
 
   void
   FinishWriteTransaction();
@@ -8342,17 +8324,17 @@ DatabaseConnection::~DatabaseConnection(
 
 nsresult
 DatabaseConnection::Init()
 {
   AssertIsOnConnectionThread();
   MOZ_ASSERT(!mInWriteTransaction);
 
   CachedStatement stmt;
-  nsresult rv = GetCachedStatement("BEGIN", &stmt);
+  nsresult rv = GetCachedStatement(NS_LITERAL_CSTRING("BEGIN"), &stmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = stmt->Execute();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -8409,17 +8391,17 @@ DatabaseConnection::BeginWriteTransactio
   MOZ_ASSERT(!mInWriteTransaction);
 
   PROFILER_LABEL("IndexedDB",
                  "DatabaseConnection::BeginWriteTransaction",
                  js::ProfileEntry::Category::STORAGE);
 
   // Release our read locks.
   CachedStatement rollbackStmt;
-  nsresult rv = GetCachedStatement("ROLLBACK", &rollbackStmt);
+  nsresult rv = GetCachedStatement(NS_LITERAL_CSTRING("ROLLBACK"), &rollbackStmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = rollbackStmt->Execute();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -8437,17 +8419,17 @@ DatabaseConnection::BeginWriteTransactio
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     mUpdateRefcountFunction.swap(function);
   }
 
   CachedStatement beginStmt;
-  rv = GetCachedStatement("BEGIN IMMEDIATE", &beginStmt);
+  rv = GetCachedStatement(NS_LITERAL_CSTRING("BEGIN IMMEDIATE"), &beginStmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = beginStmt->Execute();
   if (rv == NS_ERROR_STORAGE_BUSY) {
     NS_WARNING("Received NS_ERROR_STORAGE_BUSY when attempting to start write "
                "transaction, retrying for up to 10 seconds");
@@ -8486,17 +8468,17 @@ DatabaseConnection::RollbackWriteTransac
                  "DatabaseConnection::RollbackWriteTransaction",
                  js::ProfileEntry::Category::STORAGE);
 
   if (!mInWriteTransaction) {
     return;
   }
 
   DatabaseConnection::CachedStatement stmt;
-  nsresult rv = GetCachedStatement("ROLLBACK", &stmt);
+  nsresult rv = GetCachedStatement(NS_LITERAL_CSTRING("ROLLBACK"), &stmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
 
   // This may fail if SQLite already rolled back the transaction so ignore any
   // errors.
   unused << stmt->Execute();
 }
@@ -8517,17 +8499,17 @@ DatabaseConnection::FinishWriteTransacti
 
   if (!mInWriteTransaction) {
     return;
   }
 
   mInWriteTransaction = false;
 
   CachedStatement stmt;
-  nsresult rv = GetCachedStatement("BEGIN", &stmt);
+  nsresult rv = GetCachedStatement(NS_LITERAL_CSTRING("BEGIN"), &stmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
 
   rv = stmt->Execute();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
@@ -8541,17 +8523,17 @@ DatabaseConnection::StartSavepoint()
   MOZ_ASSERT(mUpdateRefcountFunction);
   MOZ_ASSERT(mInWriteTransaction);
 
   PROFILER_LABEL("IndexedDB",
                  "DatabaseConnection::StartSavepoint",
                  js::ProfileEntry::Category::STORAGE);
 
   CachedStatement stmt;
-  nsresult rv = GetCachedStatement(kSavepointClause, &stmt);
+  nsresult rv = GetCachedStatement(NS_LITERAL_CSTRING(SAVEPOINT_CLAUSE), &stmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = stmt->Execute();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -8575,17 +8557,17 @@ DatabaseConnection::ReleaseSavepoint()
   MOZ_ASSERT(mInWriteTransaction);
 
   PROFILER_LABEL("IndexedDB",
                  "DatabaseConnection::ReleaseSavepoint",
                  js::ProfileEntry::Category::STORAGE);
 
   CachedStatement stmt;
   nsresult rv = GetCachedStatement(
-    NS_LITERAL_CSTRING("RELEASE ") + NS_LITERAL_CSTRING(kSavepointClause),
+    NS_LITERAL_CSTRING("RELEASE " SAVEPOINT_CLAUSE),
     &stmt);
   if (NS_SUCCEEDED(rv)) {
     rv = stmt->Execute();
     if (NS_SUCCEEDED(rv)) {
       mUpdateRefcountFunction->ReleaseSavepoint();
 
 #ifdef DEBUG
       MOZ_ASSERT(mDEBUGSavepointCount);
@@ -8613,17 +8595,17 @@ DatabaseConnection::RollbackSavepoint()
   MOZ_ASSERT(mDEBUGSavepointCount);
   mDEBUGSavepointCount--;
 #endif
 
   mUpdateRefcountFunction->RollbackSavepoint();
 
   CachedStatement stmt;
   nsresult rv = GetCachedStatement(
-    NS_LITERAL_CSTRING("ROLLBACK TO ") + NS_LITERAL_CSTRING(kSavepointClause),
+    NS_LITERAL_CSTRING("ROLLBACK TO " SAVEPOINT_CLAUSE),
     &stmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // This may fail if SQLite already rolled back the savepoint so ignore any
   // errors.
   unused << stmt->Execute();
@@ -8635,32 +8617,24 @@ nsresult
 DatabaseConnection::Checkpoint(bool aIdle)
 {
   AssertIsOnConnectionThread();
 
   PROFILER_LABEL("IndexedDB",
                  "DatabaseConnection::Checkpoint",
                  js::ProfileEntry::Category::STORAGE);
 
-  nsAutoCString checkpointMode;
-  if (aIdle) {
+  CachedStatement stmt;
+  nsresult rv =
+    GetCachedStatement(aIdle ?
     // When idle we want to reclaim disk space.
-    checkpointMode.AssignLiteral("TRUNCATE");
-  } else {
+      NS_LITERAL_CSTRING("PRAGMA wal_checkpoint(TRUNCATE)") :
     // We're being called at the end of a READ_WRITE_FLUSH transaction so make
     // sure that the database is completely checkpointed and flushed to disk.
-    checkpointMode.AssignLiteral("FULL");
-  }
-
-  CachedStatement stmt;
-  nsresult rv =
-    GetCachedStatement(
-      NS_LITERAL_CSTRING("PRAGMA wal_checkpoint(") +
-      checkpointMode +
-      NS_LITERAL_CSTRING(")"),
+      NS_LITERAL_CSTRING("PRAGMA wal_checkpoint(FULL)"),
       &stmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = stmt->Execute();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -9240,20 +9214,20 @@ DatabaseUpdateFunction::UpdateInternal(i
   DatabaseConnection* connection = mFunction->mConnection;
   MOZ_ASSERT(connection);
   connection->AssertIsOnConnectionThread();
 
   MOZ_ASSERT(connection->GetStorageConnection());
 
   nsresult rv;
   if (!mUpdateStatement) {
-    rv = connection->GetCachedStatement(
+    rv = connection->GetCachedStatement(NS_LITERAL_CSTRING(
       "UPDATE file "
       "SET refcount = refcount + :delta "
-      "WHERE id = :id",
+      "WHERE id = :id"),
       &mUpdateStatement);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
   mozStorageStatementScoper updateScoper(mUpdateStatement);
 
@@ -9275,20 +9249,20 @@ DatabaseUpdateFunction::UpdateInternal(i
   int32_t rows;
   rv = connection->GetStorageConnection()->GetAffectedRows(&rows);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (rows > 0) {
     if (!mSelectStatement) {
-      rv = connection->GetCachedStatement(
+      rv = connection->GetCachedStatement(NS_LITERAL_CSTRING(
         "SELECT id "
         "FROM file "
-        "WHERE id = :id",
+        "WHERE id = :id"),
         &mSelectStatement);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
 
     mozStorageStatementScoper selectScoper(mSelectStatement);
 
@@ -9308,19 +9282,19 @@ DatabaseUpdateFunction::UpdateInternal(i
       // just before commit
       mFunction->mJournalsToCreateBeforeCommit.AppendElement(aId);
     }
 
     return NS_OK;
   }
 
   if (!mInsertStatement) {
-    rv = connection->GetCachedStatement(
+    rv = connection->GetCachedStatement(NS_LITERAL_CSTRING(
       "INSERT INTO file (id, refcount) "
-      "VALUES(:id, :delta)",
+      "VALUES(:id, :delta)"),
       &mInsertStatement);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
   mozStorageStatementScoper insertScoper(mInsertStatement);
 
@@ -14265,18 +14239,17 @@ FileManager::Init(nsIFile* aDirectory,
   }
 
   nsCOMPtr<nsIFile> journalDirectory;
   rv = aDirectory->Clone(getter_AddRefs(journalDirectory));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  NS_ConvertASCIItoUTF16 dirName(NS_LITERAL_CSTRING(kJournalDirectoryName));
-  rv = journalDirectory->Append(dirName);
+  rv = journalDirectory->Append(NS_LITERAL_STRING(JOURNAL_DIRECTORY_NAME));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = journalDirectory->Exists(&exists);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -14518,18 +14491,17 @@ FileManager::InitDirectory(nsIFile* aDir
   }
 
   nsCOMPtr<nsIFile> journalDirectory;
   rv = aDirectory->Clone(getter_AddRefs(journalDirectory));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  NS_ConvertASCIItoUTF16 dirName(NS_LITERAL_CSTRING(kJournalDirectoryName));
-  rv = journalDirectory->Append(dirName);
+  rv = journalDirectory->Append(NS_LITERAL_STRING(JOURNAL_DIRECTORY_NAME));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = journalDirectory->Exists(&exists);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -14702,17 +14674,17 @@ FileManager::GetUsage(nsIFile* aDirector
     MOZ_ASSERT(file);
 
     nsString leafName;
     rv = file->GetLeafName(leafName);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
-    if (leafName.EqualsLiteral(kJournalDirectoryName)) {
+    if (leafName.EqualsLiteral(JOURNAL_DIRECTORY_NAME)) {
       continue;
     }
 
     int64_t fileSize;
     rv = file->GetFileSize(&fileSize);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
@@ -15271,17 +15243,17 @@ QuotaClient::GetUsageForDirectoryInterna
         }
       } else {
         nsString leafName;
         rv = file->GetLeafName(leafName);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
 
-        if (!leafName.EqualsLiteral(kJournalDirectoryName)) {
+        if (!leafName.EqualsLiteral(JOURNAL_DIRECTORY_NAME)) {
           NS_WARNING("Unknown directory found!");
         }
       }
 
       continue;
     }
 
     int64_t fileSize;
@@ -16039,29 +16011,29 @@ DatabaseOperationBase::InsertIndexTableR
     const IndexDataValue& info = aIndexValues[index];
 
     DatabaseConnection::CachedStatement& stmt =
       info.mUnique ? insertUniqueStmt : insertStmt;
 
     if (stmt) {
       stmt.Reset();
     } else if (info.mUnique) {
-      rv = aConnection->GetCachedStatement(
+      rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "INSERT INTO unique_index_data "
           "(index_id, value, object_store_id, object_data_key) "
-          "VALUES (:index_id, :value, :object_store_id, :object_data_key);",
+          "VALUES (:index_id, :value, :object_store_id, :object_data_key);"),
         &stmt);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     } else {
-      rv = aConnection->GetCachedStatement(
+      rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "INSERT OR IGNORE INTO index_data "
           "(index_id, value, object_data_key, object_store_id) "
-          "VALUES (:index_id, :value, :object_data_key, :object_store_id);",
+          "VALUES (:index_id, :value, :object_data_key, :object_store_id);"),
         &stmt);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
 
     rv = stmt->BindInt64ByName(indexIdString, info.mIndexId);
     if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -16141,30 +16113,30 @@ DatabaseOperationBase::DeleteIndexDataTa
     const IndexDataValue& indexValue = aIndexValues[index];
 
     DatabaseConnection::CachedStatement& stmt =
       indexValue.mUnique ? deleteUniqueStmt : deleteStmt;
 
     if (stmt) {
       stmt.Reset();
     } else if (indexValue.mUnique) {
-      rv = aConnection->GetCachedStatement(
+      rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "DELETE FROM unique_index_data "
           "WHERE index_id = :index_id "
-          "AND value = :value;",
+          "AND value = :value;"),
         &stmt);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     } else {
-      rv = aConnection->GetCachedStatement(
+      rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "DELETE FROM index_data "
           "WHERE index_id = :index_id "
           "AND value = :value "
-          "AND object_data_key = :object_data_key;",
+          "AND object_data_key = :object_data_key;"),
         &stmt);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
 
     rv = stmt->BindInt64ByName(indexIdString, indexValue.mIndexId);
     if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -16217,21 +16189,21 @@ DatabaseOperationBase::DeleteObjectStore
   NS_NAMED_LITERAL_CSTRING(objectStoreIdString, "object_store_id");
   NS_NAMED_LITERAL_CSTRING(keyString, "key");
 
   nsresult rv;
   Key objectStoreKey;
   DatabaseConnection::CachedStatement selectStmt;
 
   if (singleRowOnly) {
-    rv = aConnection->GetCachedStatement(
+    rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
       "SELECT index_data_values "
         "FROM object_data "
         "WHERE object_store_id = :object_store_id "
-        "AND key = :key;",
+        "AND key = :key;"),
       &selectStmt);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     objectStoreKey = aKeyRange.get_SerializedKeyRange().lower();
 
     rv = objectStoreKey.BindToStatement(selectStmt, keyString);
@@ -16294,20 +16266,20 @@ DatabaseOperationBase::DeleteObjectStore
     rv = DeleteIndexDataTableRows(aConnection, objectStoreKey, indexValues);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     if (deleteStmt) {
       MOZ_ALWAYS_TRUE(NS_SUCCEEDED(deleteStmt->Reset()));
     } else {
-      rv = aConnection->GetCachedStatement(
+      rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "DELETE FROM object_data "
           "WHERE object_store_id = :object_store_id "
-          "AND key = :key;",
+          "AND key = :key;"),
         &deleteStmt);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
 
     rv = deleteStmt->BindInt64ByName(objectStoreIdString, aObjectStoreId);
     if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -16358,21 +16330,21 @@ DatabaseOperationBase::UpdateIndexValues
                                               &indexDataValuesLength);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   MOZ_ASSERT(!indexDataValuesLength == !(indexDataValues.get()));
 
   DatabaseConnection::CachedStatement updateStmt;
-  rv = aConnection->GetCachedStatement(
+  rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
     "UPDATE object_data "
       "SET index_data_values = :index_data_values "
       "WHERE object_store_id = :object_store_id "
-      "AND key = :key;",
+      "AND key = :key;"),
     &updateStmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   NS_NAMED_LITERAL_CSTRING(indexDataValuesString, "index_data_values");
 
   if (indexDataValues) {
@@ -16419,20 +16391,20 @@ DatabaseOperationBase::ObjectStoreHasInd
 {
   MOZ_ASSERT(aConnection);
   aConnection->AssertIsOnConnectionThread();
   MOZ_ASSERT(aObjectStoreId);
 
   DatabaseConnection::CachedStatement stmt;
 
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
-    aConnection->GetCachedStatement(
+    aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
       "SELECT id "
         "FROM object_store_index "
-        "WHERE object_store_id = :object_store_id;",
+        "WHERE object_store_id = :object_store_id;"),
       &stmt)));
 
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
     stmt->BindInt64ByName(NS_LITERAL_CSTRING("object_store_id"),
                           aObjectStoreId)));
 
   bool hasResult;
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(stmt->ExecuteStep(&hasResult)));
@@ -16781,20 +16753,20 @@ FactoryOp::CheckPermission(ContentParent
   if (principalInfo.type() == PrincipalInfo::TSystemPrincipalInfo) {
     MOZ_ASSERT(mState == State_Initial);
     MOZ_ASSERT(persistenceType == PERSISTENCE_TYPE_PERSISTENT);
 
     if (aContentParent) {
       // Check to make sure that the child process has access to the database it
       // is accessing.
       NS_NAMED_LITERAL_CSTRING(permissionStringBase,
-                               kPermissionStringChromeBase);
+                               PERMISSION_STRING_CHROME_BASE);
       NS_ConvertUTF16toUTF8 databaseName(mCommonParams.metadata().name());
-      NS_NAMED_LITERAL_CSTRING(readSuffix, kPermissionStringChromeReadSuffix);
-      NS_NAMED_LITERAL_CSTRING(writeSuffix, kPermissionStringChromeWriteSuffix);
+      NS_NAMED_LITERAL_CSTRING(readSuffix, PERMISSION_STRING_CHROME_READ_SUFFIX);
+      NS_NAMED_LITERAL_CSTRING(writeSuffix, PERMISSION_STRING_CHROME_WRITE_SUFFIX);
 
       const nsAutoCString permissionStringWrite =
         permissionStringBase + databaseName + writeSuffix;
       const nsAutoCString permissionStringRead =
         permissionStringBase + databaseName + readSuffix;
 
       bool canWrite =
         CheckAtLeastOneAppHasPermission(aContentParent, permissionStringWrite);
@@ -16873,17 +16845,17 @@ FactoryOp::CheckPermission(ContentParent
 #ifdef MOZ_CHILD_PERMISSIONS
     if (aContentParent) {
       if (NS_WARN_IF(!AssertAppPrincipal(aContentParent, principal))) {
         IDB_REPORT_INTERNAL_ERR();
         return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
       }
 
       uint32_t intPermission =
-        mozilla::CheckPermission(aContentParent, principal, kPermissionString);
+        mozilla::CheckPermission(aContentParent, principal, IDB_PREFIX);
 
       permission =
         PermissionRequestBase::PermissionValueForIntPermission(intPermission);
     } else
 #endif // MOZ_CHILD_PERMISSIONS
     {
       rv = PermissionRequestBase::GetCurrentPermission(principal, &permission);
       if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -18366,28 +18338,27 @@ VersionChangeOp::DoDatabaseWork(Database
                IDB_LOG_ID_STRING(mBackgroundChildLoggingId),
                mLoggingSerialNumber);
 
   nsresult rv = aConnection->BeginWriteTransaction();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  NS_NAMED_LITERAL_CSTRING(version, "version");
-
   DatabaseConnection::CachedStatement updateStmt;
   rv = aConnection->GetCachedStatement(
     NS_LITERAL_CSTRING("UPDATE database "
-                       "SET version = :") + version,
+                       "SET version = :version"),
     &updateStmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  rv = updateStmt->BindInt64ByName(version, int64_t(mRequestedVersion));
+  rv = updateStmt->BindInt64ByName(NS_LITERAL_CSTRING("version"),
+                                   int64_t(mRequestedVersion));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = updateStmt->Execute();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -19419,31 +19390,31 @@ CommitOp::AssertForeignKeyConsistency(Da
 {
   MOZ_ASSERT(aConnection);
   MOZ_ASSERT(mTransaction);
   mTransaction->AssertIsOnConnectionThread();
   MOZ_ASSERT(mTransaction->GetMode() != IDBTransaction::READ_ONLY);
 
   DatabaseConnection::CachedStatement pragmaStmt;
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
-    aConnection->GetCachedStatement("PRAGMA foreign_keys;", &pragmaStmt)));
+    aConnection->GetCachedStatement(NS_LITERAL_CSTRING("PRAGMA foreign_keys;"), &pragmaStmt)));
 
   bool hasResult;
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(pragmaStmt->ExecuteStep(&hasResult)));
 
   MOZ_ASSERT(hasResult);
 
   int32_t foreignKeysEnabled;
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(pragmaStmt->GetInt32(0, &foreignKeysEnabled)));
 
   MOZ_ASSERT(foreignKeysEnabled, "Database doesn't have foreign keys enabled!");
 
   DatabaseConnection::CachedStatement checkStmt;
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
-    aConnection->GetCachedStatement("PRAGMA foreign_key_check;", &checkStmt)));
+    aConnection->GetCachedStatement(NS_LITERAL_CSTRING("PRAGMA foreign_key_check;"), &checkStmt)));
 
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(checkStmt->ExecuteStep(&hasResult)));
 
   MOZ_ASSERT(!hasResult, "Database has inconsisistent foreign keys!");
 }
 
 #endif // DEBUG
 
@@ -19486,17 +19457,17 @@ CommitOp::Run()
           mResultCode = WriteAutoIncrementCounts();
           NS_WARN_IF_FALSE(NS_SUCCEEDED(mResultCode),
                            "WriteAutoIncrementCounts() failed!");
 
           if (NS_SUCCEEDED(mResultCode)) {
             AssertForeignKeyConsistency(connection);
 
             DatabaseConnection::CachedStatement stmt;
-            mResultCode = connection->GetCachedStatement("COMMIT", &stmt);
+            mResultCode = connection->GetCachedStatement(NS_LITERAL_CSTRING("COMMIT"), &stmt);
             NS_WARN_IF_FALSE(NS_SUCCEEDED(mResultCode),
                              "Failed to get 'COMMIT' statement!");
 
             if (NS_SUCCEEDED(mResultCode)) {
               mResultCode = stmt->Execute();
               NS_WARN_IF_FALSE(NS_SUCCEEDED(mResultCode), "Commit failed!");
 
               if (mTransaction->GetMode() == IDBTransaction::READ_WRITE_FLUSH &&
@@ -19637,20 +19608,20 @@ CreateObjectStoreOp::DoDatabaseWork(Data
 
 #ifdef DEBUG
   {
     // Make sure that we're not creating an object store with the same name as
     // another that already exists. This should be impossible because we should
     // have thrown an error long before now...
     DatabaseConnection::CachedStatement stmt;
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
-      aConnection->GetCachedStatement(
+      aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "SELECT name "
           "FROM object_store "
-          "WHERE name = :name;",
+          "WHERE name = :name;"),
         &stmt)));
 
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
       stmt->BindStringByName(NS_LITERAL_CSTRING("name"), mMetadata.name())));
 
     bool hasResult;
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(stmt->ExecuteStep(&hasResult)));
     MOZ_ASSERT(!hasResult);
@@ -19659,19 +19630,19 @@ CreateObjectStoreOp::DoDatabaseWork(Data
 
   DatabaseConnection::AutoSavepoint autoSave;
   nsresult rv = autoSave.Start(Transaction());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   DatabaseConnection::CachedStatement stmt;
-  rv = aConnection->GetCachedStatement(
+  rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
     "INSERT INTO object_store (id, auto_increment, name, key_path) "
-    "VALUES (:id, :auto_increment, :name, :key_path)",
+    "VALUES (:id, :auto_increment, :name, :key_path)"),
     &stmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mMetadata.id());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -19737,19 +19708,19 @@ DeleteObjectStoreOp::DoDatabaseWork(Data
 
   NS_NAMED_LITERAL_CSTRING(objectStoreIdString, "object_store_id");
 
 #ifdef DEBUG
   {
     // Make sure |mIsLastObjectStore| is telling the truth.
     DatabaseConnection::CachedStatement stmt;
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
-      aConnection->GetCachedStatement(
+      aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "SELECT id "
-          "FROM object_store;",
+          "FROM object_store;"),
         &stmt)));
 
     bool foundThisObjectStore = false;
     bool foundOtherObjectStore = false;
 
     while (true) {
       bool hasResult;
       MOZ_ALWAYS_TRUE(NS_SUCCEEDED(stmt->ExecuteStep(&hasResult)));
@@ -19784,66 +19755,66 @@ DeleteObjectStoreOp::DoDatabaseWork(Data
   nsresult rv = autoSave.Start(Transaction());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (mIsLastObjectStore) {
     // We can just delete everything if this is the last object store.
     DatabaseConnection::CachedStatement stmt;
-    rv = aConnection->GetCachedStatement(
-      "DELETE FROM index_data;",
+    rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
+      "DELETE FROM index_data;"),
       &stmt);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     rv = stmt->Execute();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
-    rv = aConnection->GetCachedStatement(
-      "DELETE FROM unique_index_data;",
+    rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
+      "DELETE FROM unique_index_data;"),
       &stmt);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     rv = stmt->Execute();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
-    rv = aConnection->GetCachedStatement(
-      "DELETE FROM object_data;",
+    rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
+      "DELETE FROM object_data;"),
       &stmt);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     rv = stmt->Execute();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
-    rv = aConnection->GetCachedStatement(
-      "DELETE FROM object_store_index;",
+    rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
+      "DELETE FROM object_store_index;"),
       &stmt);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     rv = stmt->Execute();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
-    rv = aConnection->GetCachedStatement(
-      "DELETE FROM object_store;",
+    rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
+      "DELETE FROM object_store;"),
       &stmt);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     rv = stmt->Execute();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
@@ -19855,19 +19826,19 @@ DeleteObjectStoreOp::DoDatabaseWork(Data
         mMetadata->mCommonMetadata.id(),
         void_t());
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
 
       // Now clean up the object store index table.
       DatabaseConnection::CachedStatement stmt;
-      rv = aConnection->GetCachedStatement(
+      rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "DELETE FROM object_store_index "
-          "WHERE object_store_id = :object_store_id;",
+          "WHERE object_store_id = :object_store_id;"),
         &stmt);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
 
       rv = stmt->BindInt64ByName(objectStoreIdString,
                                  mMetadata->mCommonMetadata.id());
       if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -19877,19 +19848,19 @@ DeleteObjectStoreOp::DoDatabaseWork(Data
       rv = stmt->Execute();
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     } else {
       // We only have to worry about object data if this object store has no
       // indexes.
       DatabaseConnection::CachedStatement stmt;
-      rv = aConnection->GetCachedStatement(
+      rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "DELETE FROM object_data "
-          "WHERE object_store_id = :object_store_id;",
+          "WHERE object_store_id = :object_store_id;"),
         &stmt);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
 
       rv = stmt->BindInt64ByName(objectStoreIdString,
                                  mMetadata->mCommonMetadata.id());
       if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -19898,19 +19869,19 @@ DeleteObjectStoreOp::DoDatabaseWork(Data
 
       rv = stmt->Execute();
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
 
     DatabaseConnection::CachedStatement stmt;
-    rv = aConnection->GetCachedStatement(
+    rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
       "DELETE FROM object_store "
-        "WHERE id = :object_store_id;",
+        "WHERE id = :object_store_id;"),
       &stmt);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     rv = stmt->BindInt64ByName(objectStoreIdString,
                                mMetadata->mCommonMetadata.id());
     if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -20022,21 +19993,21 @@ CreateIndexOp::InsertDataFromObjectStore
   MOZ_ASSERT(!IndexedDatabaseManager::InLowDiskSpaceMode());
   MOZ_ASSERT(mMaybeUniqueIndexTable);
 
   nsCOMPtr<mozIStorageConnection> storageConnection =
     aConnection->GetStorageConnection();
   MOZ_ASSERT(storageConnection);
 
   DatabaseConnection::CachedStatement stmt;
-  nsresult rv = aConnection->GetCachedStatement(
+  nsresult rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
     "UPDATE object_data "
       "SET index_data_values = update_index_data_values "
         "(key, index_data_values, file_ids, data) "
-      "WHERE object_store_id = :object_store_id;",
+      "WHERE object_store_id = :object_store_id;"),
     &stmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("object_store_id"),
                              mObjectStoreId);
   if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -20103,21 +20074,21 @@ CreateIndexOp::DoDatabaseWork(DatabaseCo
 
 #ifdef DEBUG
   {
     // Make sure that we're not creating an index with the same name and object
     // store as another that already exists. This should be impossible because
     // we should have thrown an error long before now...
     DatabaseConnection::CachedStatement stmt;
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
-      aConnection->GetCachedStatement(
+      aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "SELECT name "
           "FROM object_store_index "
           "WHERE object_store_id = :osid "
-          "AND name = :name;",
+          "AND name = :name;"),
         &stmt)));
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
       stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), mObjectStoreId)));
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
       stmt->BindStringByName(NS_LITERAL_CSTRING("name"), mMetadata.name())));
 
     bool hasResult;
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(stmt->ExecuteStep(&hasResult)));
@@ -20128,20 +20099,20 @@ CreateIndexOp::DoDatabaseWork(DatabaseCo
 
   DatabaseConnection::AutoSavepoint autoSave;
   nsresult rv = autoSave.Start(Transaction());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   DatabaseConnection::CachedStatement stmt;
-  rv = aConnection->GetCachedStatement(
+  rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
     "INSERT INTO object_store_index (id, name, key_path, unique_index, "
                                     "multientry, object_store_id) "
-    "VALUES (:id, :name, :key_path, :unique, :multientry, :osid)",
+    "VALUES (:id, :name, :key_path, :unique, :multientry, :osid)"),
     &stmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mMetadata.id());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -20533,21 +20504,21 @@ DeleteIndexOp::RemoveReferencesToIndex(
   PROFILER_LABEL("IndexedDB",
                  "DeleteIndexOp::RemoveReferencesToIndex",
                  js::ProfileEntry::Category::STORAGE);
 
   if (mIsLastIndex) {
     // There is no need to parse the previous entry in the index_data_values
     // column if this is the last index. Simply set it to NULL.
     DatabaseConnection::CachedStatement stmt;
-    nsresult rv = aConnection->GetCachedStatement(
+    nsresult rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
       "UPDATE object_data "
         "SET index_data_values = NULL "
         "WHERE object_store_id = :object_store_id "
-        "AND key = :key;",
+        "AND key = :key;"),
       &stmt);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("object_store_id"),
                                mObjectStoreId);
     if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -20631,20 +20602,20 @@ DeleteIndexOp::DoDatabaseWork(DatabaseCo
   MOZ_ASSERT(aConnection);
   aConnection->AssertIsOnConnectionThread();
 
 #ifdef DEBUG
   {
     // Make sure |mIsLastIndex| is telling the truth.
     DatabaseConnection::CachedStatement stmt;
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
-      aConnection->GetCachedStatement(
+      aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "SELECT id "
           "FROM object_store_index "
-          "WHERE object_store_id = :object_store_id;",
+          "WHERE object_store_id = :object_store_id;"),
         &stmt)));
 
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
       stmt->BindInt64ByName(NS_LITERAL_CSTRING("object_store_id"),
                             mObjectStoreId)));
 
     bool foundThisIndex = false;
     bool foundOtherIndex = false;
@@ -20684,59 +20655,59 @@ DeleteIndexOp::DoDatabaseWork(DatabaseCo
 
   DatabaseConnection::CachedStatement selectStmt;
 
   // mozStorage warns that these statements trigger a sort operation but we
   // don't care because this is a very rare call and we expect it to be slow.
   // The cost of having an index on this field is too high.
   if (mUnique) {
     if (mIsLastIndex) {
-      rv = aConnection->GetCachedStatement(
+      rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "/* do not warn (bug someone else) */ "
         "SELECT value, object_data_key "
           "FROM unique_index_data "
           "WHERE index_id = :index_id "
-          "ORDER BY object_data_key ASC;",
+          "ORDER BY object_data_key ASC;"),
         &selectStmt);
     } else {
-      rv = aConnection->GetCachedStatement(
+      rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "/* do not warn (bug out) */ "
         "SELECT unique_index_data.value, "
                "unique_index_data.object_data_key, "
                "object_data.index_data_values "
           "FROM unique_index_data "
           "JOIN object_data "
           "ON unique_index_data.object_data_key = object_data.key "
           "WHERE unique_index_data.index_id = :index_id "
           "AND object_data.object_store_id = :object_store_id "
-          "ORDER BY unique_index_data.object_data_key ASC;",
+          "ORDER BY unique_index_data.object_data_key ASC;"),
         &selectStmt);
     }
   } else {
     if (mIsLastIndex) {
-      rv = aConnection->GetCachedStatement(
+      rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "/* do not warn (bug me not) */ "
         "SELECT value, object_data_key "
           "FROM index_data "
           "WHERE index_id = :index_id "
           "AND object_store_id = :object_store_id "
-          "ORDER BY object_data_key ASC;",
+          "ORDER BY object_data_key ASC;"),
         &selectStmt);
     } else {
-      rv = aConnection->GetCachedStatement(
+      rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "/* do not warn (bug off) */ "
         "SELECT index_data.value, "
                "index_data.object_data_key, "
                "object_data.index_data_values "
           "FROM index_data "
           "JOIN object_data "
           "ON index_data.object_data_key = object_data.key "
           "WHERE index_data.index_id = :index_id "
           "AND object_data.object_store_id = :object_store_id "
-          "ORDER BY index_data.object_data_key ASC;",
+          "ORDER BY index_data.object_data_key ASC;"),
         &selectStmt);
     }
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   NS_NAMED_LITERAL_CSTRING(indexIdString, "index_id");
@@ -20827,27 +20798,27 @@ DeleteIndexOp::DoDatabaseWork(DatabaseCo
       }
     }
 
     // Now delete the index row.
     if (deleteIndexRowStmt) {
         MOZ_ALWAYS_TRUE(NS_SUCCEEDED(deleteIndexRowStmt->Reset()));
     } else {
       if (mUnique) {
-        rv = aConnection->GetCachedStatement(
+        rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
           "DELETE FROM unique_index_data "
             "WHERE index_id = :index_id "
-            "AND value = :value;",
+            "AND value = :value;"),
           &deleteIndexRowStmt);
       } else {
-        rv = aConnection->GetCachedStatement(
+        rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
           "DELETE FROM index_data "
             "WHERE index_id = :index_id "
             "AND value = :value "
-            "AND object_data_key = :object_data_key;",
+            "AND object_data_key = :object_data_key;"),
           &deleteIndexRowStmt);
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
 
     rv = deleteIndexRowStmt->BindInt64ByName(indexIdString, mIndexId);
@@ -20885,19 +20856,19 @@ DeleteIndexOp::DoDatabaseWork(DatabaseCo
                                  lastObjectStoreKey,
                                  lastIndexValues);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
   DatabaseConnection::CachedStatement deleteStmt;
-  rv = aConnection->GetCachedStatement(
+  rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
     "DELETE FROM object_store_index "
-      "WHERE id = :index_id;",
+      "WHERE id = :index_id;"),
     &deleteStmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = deleteStmt->BindInt64ByName(indexIdString, mIndexId);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -21019,21 +20990,21 @@ ObjectStoreAddOrPutRequestOp::RemoveOldI
 {
   AssertIsOnConnectionThread();
   MOZ_ASSERT(aConnection);
   MOZ_ASSERT(mOverwrite);
   MOZ_ASSERT(!mResponse.IsUnset());
   MOZ_ASSERT(mObjectStoreHasIndexes);
 
   DatabaseConnection::CachedStatement indexValuesStmt;
-  nsresult rv = aConnection->GetCachedStatement(
+  nsresult rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
     "SELECT index_data_values "
       "FROM object_data "
       "WHERE object_store_id = :object_store_id "
-      "AND key = :key;",
+      "AND key = :key;"),
     &indexValuesStmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = indexValuesStmt->BindInt64ByName(NS_LITERAL_CSTRING("object_store_id"),
                                         mParams.objectStoreId());
   if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -21268,26 +21239,26 @@ ObjectStoreAddOrPutRequestOp::DoDatabase
   }
 
   // The "|| keyUnset" here is mostly a debugging tool. If a key isn't
   // specified we should never have a collision and so it shouldn't matter
   // if we allow overwrite or not. By not allowing overwrite we raise
   // detectable errors rather than corrupting data.
   DatabaseConnection::CachedStatement stmt;
   if (!mOverwrite || keyUnset) {
-    rv = aConnection->GetCachedStatement(
+    rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
       "INSERT INTO object_data "
         "(object_store_id, key, file_ids, data) "
-        "VALUES (:osid, :key, :file_ids, :data);",
+        "VALUES (:osid, :key, :file_ids, :data);"),
       &stmt);
   } else {
-    rv = aConnection->GetCachedStatement(
+    rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
       "INSERT OR REPLACE INTO object_data "
         "(object_store_id, key, file_ids, data) "
-        "VALUES (:osid, :key, :file_ids, :data);",
+        "VALUES (:osid, :key, :file_ids, :data);"),
     &stmt);
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), osid);
   if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -22032,19 +22003,19 @@ ObjectStoreClearRequestOp::DoDatabaseWor
     rv = DeleteObjectStoreDataTableRowsWithIndexes(aConnection,
                                                    mParams.objectStoreId(),
                                                    void_t());
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   } else {
     DatabaseConnection::CachedStatement stmt;
-    rv = aConnection->GetCachedStatement(
+    rv = aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
       "DELETE FROM object_data "
-        "WHERE object_store_id = :object_store_id;",
+        "WHERE object_store_id = :object_store_id;"),
       &stmt);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("object_store_id"),
                                mParams.objectStoreId());
     if (NS_WARN_IF(NS_FAILED(rv))) {
--- a/dom/quota/QuotaManager.cpp
+++ b/dom/quota/QuotaManager.cpp
@@ -106,22 +106,22 @@ static_assert(
   "Enum values should match.");
 
 namespace {
 
 const char kChromeOrigin[] = "chrome";
 const char kAboutHomeOrigin[] = "moz-safe-about:home";
 const char kIndexedDBOriginPrefix[] = "indexeddb://";
 
-const char kIndexedDBDirectoryName[] = "indexedDB";
-const char kStorageDirectoryName[] = "storage";
-const char kPersistentDirectoryName[] = "persistent";
-const char kPermanentDirectoryName[] = "permanent";
-const char kTemporaryDirectoryName[] = "temporary";
-const char kDefaultDirectoryName[] = "default";
+#define INDEXEDDB_DIRECTORY_NAME "indexedDB"
+#define STORAGE_DIRECTORY_NAME "storage"
+#define PERSISTENT_DIRECTORY_NAME "persistent"
+#define PERMANENT_DIRECTORY_NAME "permanent"
+#define TEMPORARY_DIRECTORY_NAME "temporary"
+#define DEFAULT_DIRECTORY_NAME "default"
 
 enum AppId {
   kNoAppId = nsIScriptSecurityManager::NO_APP_ID,
   kUnknownAppId = nsIScriptSecurityManager::UNKNOWN_APP_ID
 };
 
 } // anonymous namespace
 
@@ -796,29 +796,28 @@ bool
 IsTreatedAsTemporary(PersistenceType aPersistenceType,
                      bool aIsApp)
 {
   return !IsTreatedAsPersistent(aPersistenceType, aIsApp);
 }
 
 nsresult
 CloneStoragePath(nsIFile* aBaseDir,
-                 const nsACString& aStorageName,
+                 const nsAString& aStorageName,
                  nsAString& aStoragePath)
 {
   nsresult rv;
 
   nsCOMPtr<nsIFile> storageDir;
   rv = aBaseDir->Clone(getter_AddRefs(storageDir));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  NS_ConvertASCIItoUTF16 dirName(aStorageName);
-  rv = storageDir->Append(dirName);
+  rv = storageDir->Append(aStorageName);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = storageDir->GetPath(aStoragePath);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -1422,39 +1421,38 @@ QuotaManager::Init()
                                 getter_AddRefs(baseDir));
     if (NS_FAILED(rv)) {
       rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
                                   getter_AddRefs(baseDir));
     }
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = CloneStoragePath(baseDir,
-                          NS_LITERAL_CSTRING(kIndexedDBDirectoryName),
+                          NS_LITERAL_STRING(INDEXEDDB_DIRECTORY_NAME),
                           mIndexedDBPath);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    NS_ConvertASCIItoUTF16 dirName(NS_LITERAL_CSTRING(kStorageDirectoryName));
-    rv = baseDir->Append(dirName);
+    rv = baseDir->Append(NS_LITERAL_STRING(STORAGE_DIRECTORY_NAME));
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = baseDir->GetPath(mStoragePath);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = CloneStoragePath(baseDir,
-                          NS_LITERAL_CSTRING(kPermanentDirectoryName),
+                          NS_LITERAL_STRING(PERMANENT_DIRECTORY_NAME),
                           mPermanentStoragePath);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = CloneStoragePath(baseDir,
-                          NS_LITERAL_CSTRING(kTemporaryDirectoryName),
+                          NS_LITERAL_STRING(TEMPORARY_DIRECTORY_NAME),
                           mTemporaryStoragePath);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = CloneStoragePath(baseDir,
-                          NS_LITERAL_CSTRING(kDefaultDirectoryName),
+                          NS_LITERAL_STRING(DEFAULT_DIRECTORY_NAME),
                           mDefaultStoragePath);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Make a lazy thread for any IO we need (like clearing or enumerating the
     // contents of storage directories).
     mIOThread = new LazyIdleThread(DEFAULT_THREAD_TIMEOUT_MS,
                                    NS_LITERAL_CSTRING("Storage I/O"),
                                    LazyIdleThread::ManualShutdown);
@@ -2128,18 +2126,17 @@ QuotaManager::MaybeUpgradeIndexedDBDirec
 
   nsCOMPtr<nsIFile> persistentStorageDir =
     do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = persistentStorageDir->InitWithPath(mStoragePath);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  NS_ConvertASCIItoUTF16 dirName(NS_LITERAL_CSTRING(kPersistentDirectoryName));
-  rv = persistentStorageDir->Append(dirName);
+  rv = persistentStorageDir->Append(NS_LITERAL_STRING(PERSISTENT_DIRECTORY_NAME));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = persistentStorageDir->Exists(&exists);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (exists) {
     NS_WARNING("indexedDB directory shouldn't exist after the upgrade!");
     return NS_OK;
@@ -2150,17 +2147,17 @@ QuotaManager::MaybeUpgradeIndexedDBDirec
   NS_ENSURE_SUCCESS(rv, rv);
 
   // MoveTo() is atomic if the move happens on the same volume which should
   // be our case, so even if we crash in the middle of the operation nothing
   // breaks next time we try to initialize.
   // However there's a theoretical possibility that the indexedDB directory
   // is on different volume, but it should be rare enough that we don't have
   // to worry about it.
-  rv = indexedDBDir->MoveTo(storageDir, dirName);
+  rv = indexedDBDir->MoveTo(storageDir, NS_LITERAL_STRING(PERSISTENT_DIRECTORY_NAME));
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 nsresult
 QuotaManager::MaybeUpgradePersistentStorageDirectory()
 {
@@ -2174,18 +2171,17 @@ QuotaManager::MaybeUpgradePersistentStor
     return rv;
   }
 
   rv = persistentStorageDir->InitWithPath(mStoragePath);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  NS_ConvertASCIItoUTF16 dirName(NS_LITERAL_CSTRING(kPersistentDirectoryName));
-  rv = persistentStorageDir->Append(dirName);
+  rv = persistentStorageDir->Append(NS_LITERAL_STRING(PERSISTENT_DIRECTORY_NAME));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   bool exists;
   rv = persistentStorageDir->Exists(&exists);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -2270,18 +2266,17 @@ QuotaManager::MaybeUpgradePersistentStor
 
     rv = helper->CreateOrUpgradeMetadataFiles(/* aCreate */ false);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
   // And finally rename persistent to default.
-  NS_ConvertASCIItoUTF16 defDirName(NS_LITERAL_CSTRING(kDefaultDirectoryName));
-  rv = persistentStorageDir->RenameTo(nullptr, defDirName);
+  rv = persistentStorageDir->RenameTo(nullptr, NS_LITERAL_STRING(DEFAULT_DIRECTORY_NAME));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   return NS_OK;
 }
 
 nsresult
@@ -2480,17 +2475,17 @@ QuotaManager::GetStorageId(PersistenceTy
 {
   nsAutoCString str;
   str.AppendInt(aPersistenceType);
   str.Append('*');
   str.Append(aOrigin);
   str.Append('*');
   str.AppendInt(aClientType);
   str.Append('*');
-  str.Append(NS_ConvertUTF16toUTF8(aName));
+  AppendUTF16toUTF8(aName, str);
 
   aDatabaseId = str;
 }
 
 // static
 nsresult
 QuotaManager::GetInfoFromURI(nsIURI* aURI,
                              uint32_t aAppId,
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -351,20 +351,20 @@ nsPermissionManager::AppClearDataObserve
 {
   nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
   observerService->AddObserver(new AppClearDataObserver(), "webapps-clear-data", /* holdsWeak= */ false);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsPermissionManager Implementation
 
-static const char kPermissionsFileName[] = "permissions.sqlite";
+#define PERMISSIONS_FILE_NAME "permissions.sqlite"
 #define HOSTS_SCHEMA_VERSION 4
 
-static const char kHostpermFileName[] = "hostperm.1";
+#define HOSTPERM_FILE_NAME "hostperm.1"
 
 // Default permissions are read from a URL - this is the preference we read
 // to find that URL. If not set, don't use any default permissions.
 static const char kDefaultsUrlPrefName[] = "permissions.manager.defaultsUrl";
 
 static const char kPermissionChangeNotification[] = PERM_CHANGE_NOTIFICATION;
 
 NS_IMPL_ISUPPORTS(nsPermissionManager, nsIPermissionManager, nsIObserver, nsISupportsWeakReference)
@@ -448,17 +448,17 @@ nsPermissionManager::InitDB(bool aRemove
 {
   nsCOMPtr<nsIFile> permissionsFile;
   nsresult rv = NS_GetSpecialDirectory(NS_APP_PERMISSION_PARENT_DIR, getter_AddRefs(permissionsFile));
   if (NS_FAILED(rv)) {
     rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(permissionsFile));
   }
   NS_ENSURE_SUCCESS(rv, NS_ERROR_UNEXPECTED);
 
-  rv = permissionsFile->AppendNative(NS_LITERAL_CSTRING(kPermissionsFileName));
+  rv = permissionsFile->AppendNative(NS_LITERAL_CSTRING(PERMISSIONS_FILE_NAME));
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (aRemoveFile) {
     bool exists = false;
     rv = permissionsFile->Exists(&exists);
     NS_ENSURE_SUCCESS(rv, rv);
     if (exists) {
       rv = permissionsFile->Remove(false);
@@ -1856,17 +1856,17 @@ nsresult
 nsPermissionManager::Import()
 {
   nsresult rv;
 
   nsCOMPtr<nsIFile> permissionsFile;
   rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(permissionsFile));
   if (NS_FAILED(rv)) return rv;
 
-  rv = permissionsFile->AppendNative(NS_LITERAL_CSTRING(kHostpermFileName));
+  rv = permissionsFile->AppendNative(NS_LITERAL_CSTRING(HOSTPERM_FILE_NAME));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIInputStream> fileInputStream;
   rv = NS_NewLocalFileInputStream(getter_AddRefs(fileInputStream),
                                   permissionsFile);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = _DoImport(fileInputStream, mDBConn);
--- a/gfx/2d/Logging.h
+++ b/gfx/2d/Logging.h
@@ -241,17 +241,17 @@ public:
 
   void Flush() {
     if (MOZ_LIKELY(!LogIt())) return;
 
     std::string str = mMessage.str();
     if (!str.empty()) {
       WriteLog(str);
     }
-    mMessage.clear();
+    mMessage.str("");
   }
 
   Log &operator <<(char aChar) {
     if (MOZ_UNLIKELY(LogIt())) {
       mMessage << aChar;
     }
     return *this;
   }
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/reftests/async-scrollbar-1-h-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html class="reftest-wait"><head>
+<meta name="viewport" content="width=device-width">
+</head>
+<body onload="scrollTo(450,0); document.documentElement.classList.remove('reftest-wait')">
+<div style="width: 9000px; height: 10px; background: white;"></div>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/reftests/async-scrollbar-1-h-rtl-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html class="reftest-wait"><head>
+<meta name="viewport" content="width=device-width">
+<style> html { direction: rtl; } </style>
+</head>
+<body onload="scrollTo(-450,0); document.documentElement.classList.remove('reftest-wait')">
+<div style="width: 9000px; height: 10px; background: white;"></div>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/reftests/async-scrollbar-1-h-rtl.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html class="reftest-wait"
+      reftest-async-scroll
+      reftest-async-scroll-x="-449" reftest-async-scroll-y="0"><head>
+<meta name="viewport" content="width=device-width">
+<style> html { direction: rtl; } </style>
+</head>
+<!-- Doing scrollTo(-1,0) is to activate the right arrow in the scrollbar
+     for non-overlay scrollbar environments -->
+<body onload="scrollTo(-1,0); document.documentElement.classList.remove('reftest-wait')">
+<div style="width: 9000px; height: 10px; background: white"></div>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/reftests/async-scrollbar-1-h.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html class="reftest-wait"
+      reftest-async-scroll
+      reftest-async-scroll-x="449" reftest-async-scroll-y="0"><head>
+<meta name="viewport" content="width=device-width">
+</head>
+<!-- Doing scrollTo(1,0) is to activate the left arrow in the scrollbar
+     for non-overlay scrollbar environments -->
+<body onload="scrollTo(1,0); document.documentElement.classList.remove('reftest-wait')">
+<div style="width: 9000px; height: 10px; background: white"></div>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/reftests/async-scrollbar-1-v-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html class="reftest-wait"><head>
+<meta name="viewport" content="width=device-width">
+</head>
+<body onload="scrollTo(0,10000); document.documentElement.classList.remove('reftest-wait')">
+<div style="width: 10px; height: 20000px; background: white;"></div>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/reftests/async-scrollbar-1-v-rtl-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html class="reftest-wait"><head>
+<meta name="viewport" content="width=device-width">
+<style> html { direction: rtl; } </style>
+</head>
+<body onload="scrollTo(0,10000); document.documentElement.classList.remove('reftest-wait')">
+<div style="width: 10px; height: 20000px; background: white;"></div>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/reftests/async-scrollbar-1-v-rtl.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html class="reftest-wait"
+      reftest-async-scroll
+      reftest-async-scroll-x="0" reftest-async-scroll-y="9999"><head>
+<meta name="viewport" content="width=device-width">
+<style> html { direction: rtl; } </style>
+</head>
+<!-- Doing scrollTo(0,1) is to activate the up arrow in the scrollbar
+     for non-overlay scrollbar environments -->
+<body onload="scrollTo(0,1); document.documentElement.classList.remove('reftest-wait')">
+<div style="width: 10px; height: 20000px; background: white;"></div>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/reftests/async-scrollbar-1-v.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html class="reftest-wait"
+      reftest-async-scroll
+      reftest-async-scroll-x="0" reftest-async-scroll-y="9999"><head>
+<meta name="viewport" content="width=device-width">
+</head>
+<!-- Doing scrollTo(0,1) is to activate the up arrow in the scrollbar
+     for non-overlay scrollbar environments -->
+<body onload="scrollTo(0,1); document.documentElement.classList.remove('reftest-wait')">
+<div style="width: 10px; height: 20000px; background: white;"></div>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/reftests/async-scrollbar-1-vh-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html class="reftest-wait"><head>
+<meta name="viewport" content="width=device-width">
+</head>
+<body onload="scrollTo(450,10000); document.documentElement.classList.remove('reftest-wait')">
+<div style="width: 9000px; height: 20000px; background: white;"></div>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/reftests/async-scrollbar-1-vh-rtl-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html class="reftest-wait"><head>
+<meta name="viewport" content="width=device-width">
+<style> html { direction: rtl; } </style>
+</head>
+<body onload="scrollTo(-450,10000); document.documentElement.classList.remove('reftest-wait')">
+<div style="width: 9000px; height: 20000px; background: white;"></div>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/reftests/async-scrollbar-1-vh-rtl.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html class="reftest-wait"
+      reftest-async-scroll
+      reftest-async-scroll-x="-440" reftest-async-scroll-y="9999"><head>
+<meta name="viewport" content="width=device-width">
+<style> html { direction: rtl; } </style>
+</head>
+<!-- Doing scrollTo(-10,1) is to activate the right/up arrows in the scrollbars
+     for non-overlay scrollbar environments -->
+<body onload="scrollTo(-10,1); document.documentElement.classList.remove('reftest-wait')">
+<div style="width: 9000px; height: 20000px; background: white;"></div>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/reftests/async-scrollbar-1-vh.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html class="reftest-wait"
+      reftest-async-scroll
+      reftest-async-scroll-x="449" reftest-async-scroll-y="9999"><head>
+<meta name="viewport" content="width=device-width">
+</head>
+<!-- Doing scrollTo(1,1) is to activate the left/up arrows in the scrollbars
+     for non-overlay scrollbar environments -->
+<body onload="scrollTo(1,1); document.documentElement.classList.remove('reftest-wait')">
+<div style="width: 9000px; height: 20000px; background: white;"></div>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/reftests/reftest.list
@@ -0,0 +1,8 @@
+# The following tests test the async positioning of the scrollbars.
+# Basic root-frame scrollbar with async scrolling
+skip-if(!asyncPanZoom) == async-scrollbar-1-v.html async-scrollbar-1-v-ref.html
+skip-if(!asyncPanZoom) == async-scrollbar-1-h.html async-scrollbar-1-h-ref.html
+skip-if(!asyncPanZoom) == async-scrollbar-1-vh.html async-scrollbar-1-vh-ref.html
+skip-if(!asyncPanZoom) == async-scrollbar-1-v-rtl.html async-scrollbar-1-v-rtl-ref.html
+skip-if(!asyncPanZoom) == async-scrollbar-1-h-rtl.html async-scrollbar-1-h-rtl-ref.html
+skip-if(!asyncPanZoom) == async-scrollbar-1-vh-rtl.html async-scrollbar-1-vh-rtl-ref.html
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -826,27 +826,28 @@ ApplyAsyncTransformToScrollbarForContent
   // regular transform, we need to make sure to unapply the async transform in
   // the same coordinate space. This requires applying the content transform
   // and then unapplying it after unapplying the async transform.
   if (aScrollbarIsDescendant) {
     Matrix4x4 asyncUntransform = (asyncTransform * apzc->GetOverscrollTransform()).Inverse();
     Matrix4x4 contentTransform = aContent.GetTransform();
     Matrix4x4 contentUntransform = contentTransform.Inverse();
 
-    compensation = compensation
-                 * contentTransform
-                 * asyncUntransform
-                 * contentUntransform;
+    Matrix4x4 asyncCompensation = contentTransform
+                                * asyncUntransform
+                                * contentUntransform;
+
+    compensation = compensation * asyncCompensation;
 
     // We also need to make a corresponding change on the clip rect of all the
     // layers on the ancestor chain from the scrollbar layer up to but not
     // including the layer with the async transform. Otherwise the scrollbar
     // shifts but gets clipped and so appears to flicker.
     for (Layer* ancestor = aScrollbar; ancestor != aContent.GetLayer(); ancestor = ancestor->GetParent()) {
-      TransformClipRect(ancestor, compensation);
+      TransformClipRect(ancestor, asyncCompensation);
     }
   }
   transform = transform * compensation;
 
   SetShadowTransform(aScrollbar, transform);
 }
 
 static LayerMetricsWrapper
--- a/js/src/jsapi-tests/testMutedErrors.cpp
+++ b/js/src/jsapi-tests/testMutedErrors.cpp
@@ -1,15 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jsfriendapi.h"
 #include "jsapi-tests/tests.h"
 
+using mozilla::UniquePtr;
+
 static bool sErrorReportMuted = false;
 BEGIN_TEST(testMutedErrors)
 {
     CHECK(testOuter("function f() {return 1}; f;"));
     CHECK(testOuter("function outer() { return (function () {return 2}); }; outer();"));
     CHECK(testOuter("eval('(function() {return 3})');"));
     CHECK(testOuter("(function (){ return eval('(function() {return 4})'); })()"));
     CHECK(testOuter("(function (){ return eval('(function() { return eval(\"(function(){return 5})\") })()'); })()"));
@@ -40,35 +42,32 @@ ErrorReporter(JSContext* cx, const char*
 {
     sErrorReportMuted = report->isMuted;
 }
 
 bool
 eval(const char* asciiChars, bool mutedErrors, JS::MutableHandleValue rval)
 {
     size_t len = strlen(asciiChars);
-    char16_t* chars = new char16_t[len+1];
+    UniquePtr<char16_t[]> chars(new char16_t[len+1]);
     for (size_t i = 0; i < len; ++i)
         chars[i] = asciiChars[i];
     chars[len] = 0;
 
     JS::RootedObject global(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
     CHECK(global);
     JSAutoCompartment ac(cx, global);
     CHECK(JS_InitStandardClasses(cx, global));
 
 
     JS::CompileOptions options(cx);
     options.setMutedErrors(mutedErrors)
            .setFileAndLine("", 0);
 
-    bool ok = JS::Evaluate(cx, options, chars, len, rval);
-
-    delete[] chars;
-    return ok;
+    return JS::Evaluate(cx, options, chars.get(), len, rval);
 }
 
 bool
 testOuter(const char* asciiChars)
 {
     CHECK(testInner(asciiChars, false));
     CHECK(testInner(asciiChars, true));
     return true;
--- a/layout/base/AccessibleCaret.cpp
+++ b/layout/base/AccessibleCaret.cpp
@@ -21,30 +21,44 @@ using namespace dom;
   AC_LOG_BASE("AccessibleCaret (%p): " message, this, ##__VA_ARGS__);
 
 #undef AC_LOGV
 #define AC_LOGV(message, ...)                                                  \
   AC_LOGV_BASE("AccessibleCaret (%p): " message, this, ##__VA_ARGS__);
 
 NS_IMPL_ISUPPORTS(AccessibleCaret::DummyTouchListener, nsIDOMEventListener)
 
+float AccessibleCaret::sWidth = 0.0f;
+float AccessibleCaret::sHeight = 0.0f;
+float AccessibleCaret::sMarginLeft = 0.0f;
+float AccessibleCaret::sBarWidth = 0.0f;
+
 // -----------------------------------------------------------------------------
 // Implementation of AccessibleCaret methods
 
 AccessibleCaret::AccessibleCaret(nsIPresShell* aPresShell)
   : mPresShell(aPresShell)
 {
   // Check all resources required.
   MOZ_ASSERT(mPresShell);
   MOZ_ASSERT(RootFrame());
   MOZ_ASSERT(mPresShell->GetDocument());
   MOZ_ASSERT(mPresShell->GetCanvasFrame());
   MOZ_ASSERT(mPresShell->GetCanvasFrame()->GetCustomContentContainer());
 
   InjectCaretElement(mPresShell->GetDocument());
+
+  static bool prefsAdded = false;
+  if (!prefsAdded) {
+    Preferences::AddFloatVarCache(&sWidth, "layout.accessiblecaret.width");
+    Preferences::AddFloatVarCache(&sHeight, "layout.accessiblecaret.height");
+    Preferences::AddFloatVarCache(&sMarginLeft, "layout.accessiblecaret.margin-left");
+    Preferences::AddFloatVarCache(&sBarWidth, "layout.accessiblecaret.bar.width");
+    prefsAdded = true;
+  }
 }
 
 AccessibleCaret::~AccessibleCaret()
 {
   RemoveCaretElement(mPresShell->GetDocument());
 }
 
 void
@@ -210,60 +224,81 @@ AccessibleCaret::SetPosition(nsIFrame* a
   nsLayoutUtils::TransformRect(aFrame, RootFrame(), imaginaryCaretRect);
 
   if (imaginaryCaretRect.IsEqualEdges(mImaginaryCaretRect)) {
     return PositionChangedResult::NotChanged;
   }
 
   mImaginaryCaretRect = imaginaryCaretRect;
 
-  // SetCaretElementPosition() and SetSelectionBarElementPosition() require the
+  // SetCaretElementStyle() and SetSelectionBarElementStyle() require the
   // input rect relative to container frame.
   nsRect imaginaryCaretRectInContainerFrame = imaginaryCaretRectInFrame;
   nsLayoutUtils::TransformRect(aFrame, CustomContentContainerFrame(),
                                imaginaryCaretRectInContainerFrame);
-  SetCaretElementPosition(imaginaryCaretRectInContainerFrame);
-  SetSelectionBarElementPosition(imaginaryCaretRectInContainerFrame);
+  SetCaretElementStyle(imaginaryCaretRectInContainerFrame);
+  SetSelectionBarElementStyle(imaginaryCaretRectInContainerFrame);
 
   return PositionChangedResult::Changed;
 }
 
 nsIFrame*
 AccessibleCaret::CustomContentContainerFrame() const
 {
   nsCanvasFrame* canvasFrame = mPresShell->GetCanvasFrame();
   Element* container = canvasFrame->GetCustomContentContainer();
   nsIFrame* containerFrame = container->GetPrimaryFrame();
   return containerFrame;
 }
 
 void
-AccessibleCaret::SetCaretElementPosition(const nsRect& aRect)
+AccessibleCaret::SetCaretElementStyle(const nsRect& aRect)
 {
   nsPoint position = CaretElementPosition(aRect);
   nsAutoString styleStr;
   styleStr.AppendPrintf("left: %dpx; top: %dpx;",
                         nsPresContext::AppUnitsToIntCSSPixels(position.x),
                         nsPresContext::AppUnitsToIntCSSPixels(position.y));
 
+  float zoomLevel = GetZoomLevel();
+  styleStr.AppendPrintf(" width: %.2fpx; height: %.2fpx; margin-left: %.2fpx",
+                        sWidth / zoomLevel,
+                        sHeight / zoomLevel,
+                        sMarginLeft / zoomLevel);
+
   ErrorResult rv;
   CaretElement()->SetAttribute(NS_LITERAL_STRING("style"), styleStr, rv);
   MOZ_ASSERT(!rv.Failed());
 
   AC_LOG("Set caret style: %s", NS_ConvertUTF16toUTF8(styleStr).get());
 }
 
 void
-AccessibleCaret::SetSelectionBarElementPosition(const nsRect& aRect)
+AccessibleCaret::SetSelectionBarElementStyle(const nsRect& aRect)
 {
   int32_t height = nsPresContext::AppUnitsToIntCSSPixels(aRect.height);
   nsAutoString barStyleStr;
   barStyleStr.AppendPrintf("margin-top: -%dpx; height: %dpx;",
                            height, height);
 
+  float zoomLevel = GetZoomLevel();
+  barStyleStr.AppendPrintf(" width: %.2fpx;", sBarWidth / zoomLevel);
+
   ErrorResult rv;
   SelectionBarElement()->SetAttribute(NS_LITERAL_STRING("style"), barStyleStr, rv);
   MOZ_ASSERT(!rv.Failed());
 
   AC_LOG("Set bar style: %s", NS_ConvertUTF16toUTF8(barStyleStr).get());
 }
 
+float
+AccessibleCaret::GetZoomLevel()
+{
+  // Full zoom on desktop.
+  float fullZoom = mPresShell->GetPresContext()->GetFullZoom();
+
+  // Pinch-zoom on B2G.
+  float resolution = mPresShell->GetCumulativeResolution();
+
+  return fullZoom * resolution;
+}
+
 } // namespace mozilla
--- a/layout/base/AccessibleCaret.h
+++ b/layout/base/AccessibleCaret.h
@@ -124,18 +124,21 @@ public:
   // Element for 'Intersects' test. Container of image and bar elements.
   dom::Element* CaretElement() const
   {
     return mCaretElementHolder->GetContentNode();
   }
 
 private:
   // Argument aRect should be relative to CustomContentContainerFrame().
-  void SetCaretElementPosition(const nsRect& aRect);
-  void SetSelectionBarElementPosition(const nsRect& aRect);
+  void SetCaretElementStyle(const nsRect& aRect);
+  void SetSelectionBarElementStyle(const nsRect& aRect);
+
+  // Get current zoom level.
+  float GetZoomLevel();
 
   // Element which contains the caret image for 'Contains' test.
   dom::Element* CaretImageElement() const
   {
     return CaretElement()->GetFirstElementChild();
   }
 
   // Element which represents the text selection bar.
@@ -197,13 +200,19 @@ private:
 
   // mImaginaryCaretRect is relative to root frame.
   nsRect mImaginaryCaretRect;
 
   // A no-op touch-start listener which prevents APZ from panning when dragging
   // the caret.
   nsRefPtr<DummyTouchListener> mDummyTouchListener{new DummyTouchListener()};
 
+  // Static class variables
+  static float sWidth;
+  static float sHeight;
+  static float sMarginLeft;
+  static float sBarWidth;
+
 }; // class AccessibleCaret
 
 } // namespace mozilla
 
 #endif // AccessibleCaret_h__
--- a/layout/reftests/floats/float-in-rtl-1-ref.html
+++ b/layout/reftests/floats/float-in-rtl-1-ref.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body>
 <div style="width:0px;height:0px;overflow:visible">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);display:inline-block;position:relative;left:200px;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);display:inline-block;margin-left:200px;"></div>
 </div>
 <div style="width:0px;height:0px;overflow:visible">
-  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);display:inline-block;position:relative;left:100px;"></div>
+  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);display:inline-block;margin-left:100px;"></div>
 </div>
-<div style="background:silver;padding-right:calc(100% - 100px);">
-This text should appear to the LEFT of the red and green blocks.
+<div style="background:silver;">
+  <div style="width:100px">This text should appear to the LEFT of the red and green blocks.</div>
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-1a.html
+++ b/layout/reftests/floats/float-in-rtl-1a.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body>
 <div style="width:300px" dir="rtl">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;"></div>
 </div>
 <div style="width:200px">
-  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;"></div>
 </div>
 <div style="background:silver">
 This text should appear to the LEFT of the red and green blocks.
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-1b.html
+++ b/layout/reftests/floats/float-in-rtl-1b.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body>
 <div style="width:300px">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;"></div>
 </div>
 <div style="width:200px" dir="rtl">
-  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;"></div>
 </div>
 <div style="background:silver">
 This text should appear to the LEFT of the red and green blocks.
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-1c.html
+++ b/layout/reftests/floats/float-in-rtl-1c.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body>
 <div style="width:300px" dir="rtl">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;"></div>
 </div>
 <div style="width:200px" dir="rtl">
-  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;"></div>
 </div>
 <div style="background:silver">
 This text should appear to the LEFT of the red and green blocks.
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-1d.html
+++ b/layout/reftests/floats/float-in-rtl-1d.html
@@ -1,19 +1,19 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body>
 <div dir="rtl" style="width:300px">
   <div style="width:300px">
-    <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+    <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;"></div>
   </div>
   <div style="width:200px">
-    <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+    <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;"></div>
   </div>
 </div>
 <div style="background:silver">
 This text should appear to the LEFT of the red and green blocks.
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-2-ref.html
+++ b/layout/reftests/floats/float-in-rtl-2-ref.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body>
 <div style="width:0px;height:0px;overflow:visible">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);display:inline-block;position:relative;left:0px;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);display:inline-block;"></div>
 </div>
 <div style="width:0px;height:0px;overflow:visible">
-  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);display:inline-block;position:relative;left:100px;"></div>
+  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);display:inline-block;margin-left:100px;"></div>
 </div>
-<div style="background:silver;padding-left:200px;">
-This text should appear to the RIGHT of the green and red blocks.
+<div style="background:silver;">
+  <div style="margin-left:200px;">This text should appear to the RIGHT of the green and red blocks.</div>
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-2a.html
+++ b/layout/reftests/floats/float-in-rtl-2a.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body>
 <div dir="rtl" style="width:300px">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;"></div>
 </div>
 <div style="width:200px">
-  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:left;"></div>
 </div>
 <div style="background:silver">
 This text should appear to the RIGHT of the green and red blocks.
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-2b.html
+++ b/layout/reftests/floats/float-in-rtl-2b.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body>
 <div style="width:300px">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;"></div>
 </div>
 <div dir="rtl" style="width:200px">
-  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:left;"></div>
 </div>
 <div style="background:silver">
 This text should appear to the RIGHT of the green and red blocks.
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-2c.html
+++ b/layout/reftests/floats/float-in-rtl-2c.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body>
 <div dir="rtl" style="width:300px">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;"></div>
 </div>
 <div dir="rtl" style="width:200px">
-  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:left;"></div>
 </div>
 <div style="background:silver">
 This text should appear to the RIGHT of the green and red blocks.
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-2d.html
+++ b/layout/reftests/floats/float-in-rtl-2d.html
@@ -1,19 +1,19 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body>
 <div dir="rtl" style="width:-moz-fit-content">
   <div style="width:300px">
-    <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+    <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;"></div>
   </div>
   <div style="width:200px">
-    <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+    <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:left;"></div>
   </div>
 </div>
 <div style="background:silver">
 This text should appear to the RIGHT of the green and red blocks.
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-3-ref.html
+++ b/layout/reftests/floats/float-in-rtl-3-ref.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body dir="rtl">
 <div style="width:0px;height:0px;overflow:visible">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);display:inline-block;position:relative;right:200px;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);display:inline-block;margin-right:200px;"></div>
 </div>
 <div style="width:0px;height:0px;overflow:visible">
-  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);display:inline-block;position:relative;right:100px;"></div>
+  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);display:inline-block;margin-right:100px;"></div>
 </div>
-<div style="background:silver;padding-left:calc(100% - 100px);">
-This text should appear to the RIGHT of the green and red blocks.
+<div style="background:silver;">
+  <div style="width:100px;">This text should appear to the RIGHT of the green and red blocks.</div>
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-3a.html
+++ b/layout/reftests/floats/float-in-rtl-3a.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body dir="rtl">
 <div dir="ltr" style="width:300px">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;"></div>
 </div>
 <div style="width:200px">
-  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:left;"></div>
 </div>
 <div style="background:silver">
 This text should appear to the RIGHT of the green and red blocks.
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-3b.html
+++ b/layout/reftests/floats/float-in-rtl-3b.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body dir="rtl">
 <div style="width:300px">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;"></div>
 </div>
 <div dir="ltr" style="width:200px">
-  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:left;"></div>
 </div>
 <div style="background:silver">
 This text should appear to the RIGHT of the green and red blocks.
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-3c.html
+++ b/layout/reftests/floats/float-in-rtl-3c.html
@@ -1,16 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body dir="rtl">
 <div dir="ltr" style="width:300px">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;"></div>
 </div>
 <div dir="ltr" style="width:200px">
   <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:left"></div>
 </div>
 <div style="background:silver">
 This text should appear to the RIGHT of the green and red blocks.
 </div>
 </body>
--- a/layout/reftests/floats/float-in-rtl-3d.html
+++ b/layout/reftests/floats/float-in-rtl-3d.html
@@ -1,19 +1,19 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body dir="rtl">
 <div dir="ltr" style="width:-moz-fit-content">
   <div style="width:300px">
-    <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+    <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:left;"></div>
   </div>
   <div style="width:200px">
-    <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+    <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:left;"></div>
   </div>
 </div>
 <div style="background:silver">
 This text should appear to the RIGHT of the green and red blocks.
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-4-ref.html
+++ b/layout/reftests/floats/float-in-rtl-4-ref.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body dir="rtl">
 <div style="width:0px;height:0px;overflow:visible">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);display:inline-block;position:relative;right:0px;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);display:inline-block;"></div>
 </div>
 <div style="width:0px;height:0px;overflow:visible">
-  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);display:inline-block;position:relative;right:100px;"></div>
+  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);display:inline-block;margin-right:100px;"></div>
 </div>
-<div style="background:silver;padding-right:200px;">
-This text should appear to the LEFT of the red and green blocks.
+<div style="background:silver;">
+  <div style="margin-right:200px;">This text should appear to the LEFT of the red and green blocks.</div>
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-4a.html
+++ b/layout/reftests/floats/float-in-rtl-4a.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body dir="rtl">
 <div dir="ltr" style="width:300px">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;"></div>
 </div>
 <div style="width:200px">
-  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;"></div>
 </div>
 <div style="background:silver">
 This text should appear to the LEFT of the red and green blocks.
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-4b.html
+++ b/layout/reftests/floats/float-in-rtl-4b.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body dir="rtl">
 <div style="width:300px">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;"></div>
 </div>
 <div dir="ltr" style="width:200px">
-  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;"></div>
 </div>
 <div style="background:silver">
 This text should appear to the LEFT of the red and green blocks.
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-4c.html
+++ b/layout/reftests/floats/float-in-rtl-4c.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body dir="rtl">
 <div dir="ltr" style="width:300px">
-  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+  <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;"></div>
 </div>
 <div dir="ltr" style="width:200px">
-  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+  <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;"></div>
 </div>
 <div style="background:silver">
 This text should appear to the LEFT of the red and green blocks.
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-4d.html
+++ b/layout/reftests/floats/float-in-rtl-4d.html
@@ -1,19 +1,19 @@
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bug 1114329 testcase</title>
 </head>
 <body dir="rtl">
 <div dir="ltr" style="width:-moz-fit-content">
   <div style="width:300px">
-    <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+    <div style="width:100px;height:120px;background:rgba(0,255,0,0.8);float:right;"></div>
   </div>
   <div style="width:200px">
-    <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+    <div style="width:100px;height:150px;background:rgba(255,0,0,0.8);float:right;"></div>
   </div>
 </div>
 <div style="background:silver">
 This text should appear to the LEFT of the red and green blocks.
 </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-1-ref.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-1-ref.html
@@ -1,24 +1,24 @@
 <!DOCTYPE html>
-<html class="vlr">
+<html>
 <head>
 <title>Bug 1114329 testcase</title>
 <style>
  .vlr {
    writing-mode: vertical-lr;
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
 }
 </style>
 </head>
 <body>
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;position:relative;top:200px;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;margin-top:200px;"></div>
   </div>
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;position:relative;top:100px;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;margin-top:100px;"></div>
   </div>
-  <div style="background:silver;padding-bottom:calc(100% - 100px);">
-This text should appear ABOVE the red and green blocks.
+  <div class="vlr" style="background:silver; height: calc(100vh - 16px);">
+    <div style="height:100px;">This text should appear ABOVE the red and green blocks.</div>
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-1a.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-1a.html
@@ -7,18 +7,18 @@
    writing-mode: vertical-lr;
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
 }
 </style>
 </head>
 <body>
   <div style="height:300px" dir="rtl">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
   </div>
   <div style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-1b.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-1b.html
@@ -7,18 +7,18 @@
    writing-mode: vertical-lr;
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
 }
 </style>
 </head>
 <body>
   <div style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
   </div>
   <div style="height:200px" dir="rtl">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-1c.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-1c.html
@@ -7,18 +7,18 @@
    writing-mode: vertical-lr;
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
 }
 </style>
 </head>
 <body>
   <div style="height:300px" dir="rtl">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
   </div>
   <div style="height:200px" dir="rtl">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-1d.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-1d.html
@@ -8,19 +8,19 @@
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
 }
 </style>
 </head>
 <body>
   <div dir="rtl" style="height:300px">
     <div style="height:300px">
-      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
     </div>
     <div style="height:200px">
-      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
     </div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-2-ref.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-2-ref.html
@@ -1,24 +1,26 @@
 <!DOCTYPE html>
-<html class="vlr">
+<html>
 <head>
 <title>Bug 1114329 testcase</title>
 <style>
  .vlr {
    writing-mode: vertical-lr;
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
 }
 </style>
 </head>
 <body>
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;position:relative;top:0px;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;"></div>
   </div>
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;position:relative;top:100px;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;margin-top:100px;"></div>
   </div>
-  <div style="background:silver;padding-top:200px;">
-This text should appear BELOW the green and red blocks.
+  <div style="height:0px;width:0px;overflow:visible">
+    <div class="vlr" style="background:silver; height: calc(100vh - 16px);">
+      <div style="margin-top:200px;">This text should appear BELOW the green and red blocks.</div>
+    </div>
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-2a.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-2a.html
@@ -7,18 +7,18 @@
    writing-mode: vertical-lr;
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
 }
 </style>
 </head>
 <body>
   <div dir="rtl" style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
   </div>
   <div style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;"></div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-2b.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-2b.html
@@ -7,18 +7,18 @@
    writing-mode: vertical-lr;
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
 }
 </style>
 </head>
 <body>
   <div style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
   </div>
   <div dir="rtl" style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;"></div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-2c.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-2c.html
@@ -7,18 +7,18 @@
    writing-mode: vertical-lr;
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
 }
 </style>
 </head>
 <body>
   <div dir="rtl" style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
   </div>
   <div dir="rtl" style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;"></div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-2d.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-2d.html
@@ -8,19 +8,19 @@
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
 }
 </style>
 </head>
 <body>
   <div dir="rtl" style="inline-size:-moz-fit-content">
     <div style="height:300px">
-      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
     </div>
     <div style="height:200px">
-      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;"></div>
     </div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-3-ref.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-3-ref.html
@@ -1,26 +1,26 @@
 <!DOCTYPE html>
-<html class="vlr">
+<html>
 <head>
 <title>Bug 1114329 testcase</title>
 <style>
  .vlr {
    writing-mode: vertical-lr;
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
 }
 </style>
 </head>
 <body>
- <div style="height:600px; direction: rtl;">
+ <div style="height:600px;">
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;position:relative;bottom: 200px;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;margin-top:300px;"></div>
   </div>
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;position:relative;bottom: 100px);"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;margin-top:400px;"></div>
   </div>
-  <div style="background:silver;padding-top:calc(100% - 100px);">
-This text should appear BELOW the green and red blocks.
+  <div class="vlr" style="background:silver; height: 100%;">
+    <div style="padding-top:500px; direction:rtl">This text should appear BELOW the green and red blocks.</div>
   </div>
  </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-3a.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-3a.html
@@ -8,19 +8,19 @@
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
 }
 </style>
 </head>
 <body>
  <div style="height:600px; direction: rtl;">
   <div dir="ltr" style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
   </div>
   <div style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;"></div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
  </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-3b.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-3b.html
@@ -8,19 +8,19 @@
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
 }
 </style>
 </head>
 <body>
  <div style="height:600px; direction: rtl;">
   <div style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
   </div>
   <div dir="ltr" style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;"></div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
  </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-3c.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-3c.html
@@ -8,17 +8,17 @@
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
 }
 </style>
 </head>
 <body>
  <div style="height:600px; direction: rtl;">
   <div dir="ltr" style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
   </div>
   <div dir="ltr" style="height:200px">
     <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left"></div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
  </div>
--- a/layout/reftests/floats/float-in-rtl-vlr-3d.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-3d.html
@@ -9,20 +9,20 @@
    writing-mode: tb-lr;
 }
 </style>
 </head>
 <body>
  <div style="height:600px; direction: rtl;">
   <div dir="ltr" style="inline-size:-moz-fit-content">
     <div style="height:300px">
-      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
     </div>
     <div style="height:200px">
-      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;"></div>
     </div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
  </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-4-ref.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-4-ref.html
@@ -1,25 +1,26 @@
 <!DOCTYPE html>
-<html class="vlr">
+<html>
 <head>
 <title>Bug 1114329 testcase</title>
 <style>
  .vlr {
    writing-mode: vertical-lr;
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
-   direction: rtl;
 }
 </style>
 </head>
 <body>
+ <div style="height:600px;">
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;position:relative;bottom:0px;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;margin-top:500px;"></div>
   </div>
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;position:relative;bottom:100px;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;margin-top:400px;"></div>
   </div>
-  <div style="background:silver;padding-bottom:200px;">
-This text should appear ABOVE the red and green blocks.
+  <div class="vlr" style="background:silver; height: 100%;">
+    <div style="padding-bottom: 200px; direction:rtl">This text should appear ABOVE the green and red blocks.</div>
   </div>
+ </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-4a.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-4a.html
@@ -8,18 +8,18 @@
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
    direction: rtl;
 }
 </style>
 </head>
 <body>
   <div dir="ltr" style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
   </div>
   <div style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-4b.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-4b.html
@@ -8,18 +8,18 @@
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
    direction: rtl;
 }
 </style>
 </head>
 <body>
   <div style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
   </div>
   <div dir="ltr" style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-4c.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-4c.html
@@ -8,18 +8,18 @@
    -webkit-writing-mode: vertical-lr;
    writing-mode: tb-lr;
    direction: rtl;
 }
 </style>
 </head>
 <body>
   <div dir="ltr" style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
   </div>
   <div dir="ltr" style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vlr-4d.html
+++ b/layout/reftests/floats/float-in-rtl-vlr-4d.html
@@ -9,19 +9,19 @@
    writing-mode: tb-lr;
    direction: rtl;
 }
 </style>
 </head>
 <body>
   <div dir="ltr" style="inline-size:-moz-fit-content">
     <div style="height:300px">
-      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
     </div>
     <div style="height:200px">
-      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
     </div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-1-ref.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-1-ref.html
@@ -1,26 +1,24 @@
 <!DOCTYPE html>
-<html class="vrl">
+<html>
 <head>
 <title>Bug 1114329 testcase</title>
 <style>
  .vrl {
    writing-mode: vertical-rl;
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
-   direction: ltr;
 }
 </style>
 </head>
-<body dir="rtl">
-<div dir="ltr">
+<body dir=rtl>
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;position:relative;top:200px;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;margin-top:200px;"></div>
   </div>
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;position:relative;top:100px;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;margin-top:100px;"></div>
   </div>
-  <div style="background:silver;padding-bottom:calc(100% - 100px);">
-This text should appear ABOVE the red and green blocks.
+  <div dir=ltr class="vrl" style="background:silver; height: calc(100vh - 16px);">
+    <div style="height:100px;">This text should appear ABOVE the red and green blocks.</div>
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-1a.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-1a.html
@@ -8,18 +8,18 @@
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
    direction: ltr;
 }
 </style>
 </head>
 <body>
   <div style="height:300px" dir="rtl">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
   </div>
   <div style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-1b.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-1b.html
@@ -8,18 +8,18 @@
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
    direction: ltr;
 }
 </style>
 </head>
 <body>
   <div style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
   </div>
   <div style="height:200px" dir="rtl">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-1c.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-1c.html
@@ -8,18 +8,18 @@
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
    direction: ltr;
 }
 </style>
 </head>
 <body>
   <div style="height:300px" dir="rtl">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
   </div>
   <div style="height:200px" dir="rtl">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-1d.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-1d.html
@@ -9,19 +9,19 @@
    writing-mode: tb-rl;
    direction: ltr;
 }
 </style>
 </head>
 <body>
   <div dir="rtl" style="height:300px">
     <div style="height:300px">
-      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
     </div>
     <div style="height:200px">
-      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
     </div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-2-ref.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-2-ref.html
@@ -1,25 +1,26 @@
 <!DOCTYPE html>
-<html class="vrl">
+<html>
 <head>
 <title>Bug 1114329 testcase</title>
 <style>
  .vrl {
    writing-mode: vertical-rl;
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
-   direction: ltr;
 }
 </style>
 </head>
-<body>
+<body dir=rtl>
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;position:relative;top:0px;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;"></div>
   </div>
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;position:relative;top:100px;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;margin-top:100px;"></div>
   </div>
-  <div style="background:silver;padding-top:200px;">
-This text should appear BELOW the green and red blocks.
+  <div style="height:0px;width:0px;overflow:visible">
+    <div dir=ltr class="vrl" style="background:silver; height: calc(100vh - 16px);">
+      <div style="margin-top:200px;">This text should appear BELOW the green and red blocks.</div>
+    </div>
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-2a.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-2a.html
@@ -8,18 +8,18 @@
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
    direction: ltr;
 }
 </style>
 </head>
 <body>
   <div dir="rtl" style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
   </div>
   <div style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;"></div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-2b.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-2b.html
@@ -8,18 +8,18 @@
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
    direction: ltr;
 }
 </style>
 </head>
 <body>
   <div style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
   </div>
   <div dir="rtl" style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;"></div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-2c.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-2c.html
@@ -8,18 +8,18 @@
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
    direction: ltr;
 }
 </style>
 </head>
 <body>
   <div dir="rtl" style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
   </div>
   <div dir="rtl" style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;"></div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-2d.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-2d.html
@@ -9,19 +9,19 @@
    writing-mode: tb-rl;
    direction: ltr;
 }
 </style>
 </head>
 <body>
   <div dir="rtl" style="inline-size:-moz-fit-content">
     <div style="height:300px">
-      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
     </div>
     <div style="height:200px">
-      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;"></div>
     </div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-3-ref.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-3-ref.html
@@ -1,26 +1,26 @@
 <!DOCTYPE html>
-<html class="vrl">
+<html>
 <head>
 <title>Bug 1114329 testcase</title>
 <style>
  .vrl {
    writing-mode: vertical-rl;
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
 }
 </style>
 </head>
-<body>
- <div style="height:600px; direction: rtl;">
+<body dir=rtl>
+ <div style="height:600px;">
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;position:relative;bottom:200px;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;margin-top:300px;"></div>
   </div>
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;position:relative;bottom:100px;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;margin-top:400px;"></div>
   </div>
-  <div style="background:silver;padding-top:calc(100% - 100px);">
-This text should appear BELOW the green and red blocks.
+  <div dir=ltr class="vrl" style="background:silver; height: 100%;">
+    <div style="padding-top:500px; direction:rtl">This text should appear BELOW the green and red blocks.</div>
   </div>
  </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-3a.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-3a.html
@@ -8,19 +8,19 @@
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
 }
 </style>
 </head>
 <body>
  <div style="height:600px; direction: rtl;">
   <div dir="ltr" style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
   </div>
   <div style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;"></div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
  </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-3b.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-3b.html
@@ -8,19 +8,19 @@
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
 }
 </style>
 </head>
 <body>
  <div style="height:600px; direction: rtl;">
   <div style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
   </div>
   <div dir="ltr" style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;"></div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
  </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-3c.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-3c.html
@@ -8,17 +8,17 @@
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
 }
 </style>
 </head>
 <body>
  <div style="height:600px; direction: rtl;">
   <div dir="ltr" style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
   </div>
   <div dir="ltr" style="height:200px">
     <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left"></div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
  </div>
--- a/layout/reftests/floats/float-in-rtl-vrl-3d.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-3d.html
@@ -9,20 +9,20 @@
    writing-mode: tb-rl;
 }
 </style>
 </head>
 <body>
  <div style="height:600px; direction: rtl;">
   <div dir="ltr" style="inline-size:-moz-fit-content">
     <div style="height:300px">
-      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;position:relative;"></div>
+      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
     </div>
     <div style="height:200px">
-      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;position:relative;"></div>
+      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;"></div>
     </div>
   </div>
   <div style="background:silver">
 This text should appear BELOW the green and red blocks.
   </div>
  </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-4-ref.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-4-ref.html
@@ -1,25 +1,26 @@
 <!DOCTYPE html>
-<html class="vrl">
+<html>
 <head>
 <title>Bug 1114329 testcase</title>
 <style>
  .vrl {
    writing-mode: vertical-rl;
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
-   direction: rtl;
 }
 </style>
 </head>
-<body>
+<body dir=rtl>
+ <div style="height:600px;">
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;position:relative;bottom:0px;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);display:inline-block;margin-top:500px;"></div>
   </div>
   <div style="height:0px;width:0px;overflow:visible">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;position:relative;bottom:100px;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);display:inline-block;margin-top:400px;"></div>
   </div>
-  <div style="background:silver;padding-bottom:200px;">
-This text should appear ABOVE the red and green blocks.
+  <div dir=ltr class="vrl" style="background:silver; height: 100%;">
+    <div style="padding-bottom: 200px; direction:rtl">This text should appear ABOVE the green and red blocks.</div>
   </div>
+ </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-4a.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-4a.html
@@ -8,18 +8,18 @@
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
    direction: rtl;
 }
 </style>
 </head>
 <body>
   <div dir="ltr" style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
   </div>
   <div style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-4b.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-4b.html
@@ -8,18 +8,18 @@
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
    direction: rtl;
 }
 </style>
 </head>
 <body>
   <div style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
   </div>
   <div dir="ltr" style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-4c.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-4c.html
@@ -8,18 +8,18 @@
    -webkit-writing-mode: vertical-rl;
    writing-mode: tb-rl;
    direction: rtl;
 }
 </style>
 </head>
 <body>
   <div dir="ltr" style="height:300px">
-    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
   </div>
   <div dir="ltr" style="height:200px">
-    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+    <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/floats/float-in-rtl-vrl-4d.html
+++ b/layout/reftests/floats/float-in-rtl-vrl-4d.html
@@ -9,19 +9,19 @@
    writing-mode: tb-rl;
    direction: rtl;
 }
 </style>
 </head>
 <body>
   <div dir="ltr" style="inline-size:-moz-fit-content">
     <div style="height:300px">
-      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;position:relative;"></div>
+      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:right;"></div>
     </div>
     <div style="height:200px">
-      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;position:relative;"></div>
+      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:right;"></div>
     </div>
   </div>
   <div style="background:silver">
 This text should appear ABOVE the red and green blocks.
   </div>
 </body>
 </html>
--- a/layout/reftests/reftest.list
+++ b/layout/reftests/reftest.list
@@ -383,8 +383,11 @@ include ../../editor/reftests/reftest.li
 # box-sizing
 include box-sizing/reftest.list
 
 # invalidation
 include invalidation/reftest.list
 
 # encodings
 include ../../dom/encoding/test/reftest/reftest.list
+
+# APZ/async positioning tests
+include ../../gfx/layers/apz/reftests/reftest.list
--- a/layout/style/ua.css
+++ b/layout/style/ua.css
@@ -316,36 +316,29 @@ parsererror|sourcetext {
 
 div:-moz-native-anonymous.moz-accessiblecaret,
 div:-moz-native-anonymous.moz-accessiblecaret > div.image,
 div:-moz-native-anonymous.moz-accessiblecaret > div.bar {
   position: absolute;
   z-index: 2147483647;
 }
 
-div:-moz-native-anonymous.moz-accessiblecaret {
-  width: 44px;
-  height: 47px;
-  margin-left: -23px;
-}
-
 div:-moz-native-anonymous.moz-accessiblecaret > div.image {
   background-position: center center;
   background-size: 100% 100%;
   width: 100%;
   height: 100%;
 
   /* Override this property in moz-custom-content-container to make dummy touch
    * listener work. */
   pointer-events: auto;
 }
 
 div:-moz-native-anonymous.moz-accessiblecaret > div.bar {
   margin-left: 49%;
-  width: 2px;
   background-color: #008aa0;
 }
 
 div:-moz-native-anonymous.moz-accessiblecaret.no-bar > div.bar {
   display: none;
 }
 
 div:-moz-native-anonymous.moz-accessiblecaret.normal > div.image {
--- a/media/webrtc/signaling/src/jsep/JsepCodecDescription.h
+++ b/media/webrtc/signaling/src/jsep/JsepCodecDescription.h
@@ -319,18 +319,20 @@ struct JsepVideoCodecDescription : publi
   AddRtcpFbs(SdpRtcpFbAttributeList& rtcpfb) const override
   {
     // Just hard code for now
     rtcpfb.PushEntry(mDefaultPt, SdpRtcpFbAttributeList::kNack);
     rtcpfb.PushEntry(
         mDefaultPt, SdpRtcpFbAttributeList::kNack, SdpRtcpFbAttributeList::pli);
     rtcpfb.PushEntry(
         mDefaultPt, SdpRtcpFbAttributeList::kCcm, SdpRtcpFbAttributeList::fir);
-    rtcpfb.PushEntry(
-        mDefaultPt, SdpRtcpFbAttributeList::kCcm, SdpRtcpFbAttributeList::tmmbr);
+    if (mUseTmmbr) {
+      rtcpfb.PushEntry(
+          mDefaultPt, SdpRtcpFbAttributeList::kCcm, SdpRtcpFbAttributeList::tmmbr);
+    }
   }
 
   SdpFmtpAttributeList::H264Parameters
   GetH264Parameters(const std::string& pt,
                     const SdpMediaSection& msection) const
   {
     // Will contain defaults if nothing else
     SdpFmtpAttributeList::H264Parameters result;
@@ -663,16 +665,17 @@ struct JsepVideoCodecDescription : publi
   // H264-specific stuff
   uint32_t mProfileLevelId;
   uint32_t mMaxFr;
   uint32_t mPacketizationMode;
   uint32_t mMaxMbps;
   uint32_t mMaxCpb;
   uint32_t mMaxDpb;
   uint32_t mMaxBr;
+  bool     mUseTmmbr;
   std::string mSpropParameterSets;
 };
 
 struct JsepApplicationCodecDescription : public JsepCodecDescription {
   JsepApplicationCodecDescription(const std::string& defaultPt,
                                   const std::string& name,
                                   uint16_t channels,
                                   bool enabled = true)
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -961,16 +961,20 @@ PeerConnectionImpl::ConfigureJsepSession
             int32_t maxFr = 0;
             branch->GetIntPref("media.navigator.video.max_fr", &maxFr);
             if (maxFr <= 0) {
               maxFr = 60; // We must specify something other than 0
             }
             videoCodec.mMaxFr = maxFr;
 
           }
+
+          videoCodec.mUseTmmbr = false;
+          branch->GetBoolPref("media.navigator.video.use_tmmbr",
+            &videoCodec.mUseTmmbr);
         }
         break;
       case SdpMediaSection::kText:
       case SdpMediaSection::kApplication:
       case SdpMediaSection::kMessage:
         {} // Nothing to configure for these.
     }
   }
--- a/media/webrtc/signaling/test/signaling_unittests.cpp
+++ b/media/webrtc/signaling/test/signaling_unittests.cpp
@@ -902,17 +902,16 @@ class SignalingAgent {
   explicit SignalingAgent(const std::string &aName,
     const std::string stun_addr = g_stun_server_address,
     uint16_t stun_port = g_stun_server_port) :
     pc(nullptr),
     name(aName),
     mBundleEnabled(true),
     mExpectedFrameRequestType(VideoSessionConduit::FrameRequestPli),
     mExpectNack(true),
-    mExpectTmmbr(true),
     mExpectRtcpMuxAudio(true),
     mExpectRtcpMuxVideo(true),
     mRemoteDescriptionSet(false) {
     cfg_.addStunServer(stun_addr, stun_port);
 
     PeerConnectionImpl *pcImpl =
       PeerConnectionImpl::CreatePeerConnection();
     EXPECT_TRUE(pcImpl);
@@ -1197,17 +1196,16 @@ class SignalingAgent {
       ASSERT_TRUE(pipeline->IsVideo()) << "Remote track " << trackId
                                        << " was not video";
       mozilla::MediaSessionConduit *conduit = pipeline->Conduit();
       ASSERT_TRUE(conduit);
       ASSERT_EQ(conduit->type(), mozilla::MediaSessionConduit::VIDEO);
       mozilla::VideoSessionConduit *video_conduit =
         static_cast<mozilla::VideoSessionConduit*>(conduit);
       ASSERT_EQ(mExpectNack, video_conduit->UsingNackBasic());
-      ASSERT_EQ(mExpectTmmbr, video_conduit->UsingTmmbr());
       ASSERT_EQ(mExpectedFrameRequestType,
                 video_conduit->FrameRequestMethod());
       ASSERT_EQ(mExpectRtcpMuxVideo, pipeline->IsDoingRtcpMux())
         << "Pipeline for remote track " << trackId
         << " is" << (mExpectRtcpMuxVideo ? " not " : " ") << "using rtcp-mux";
       // No checking for video RTP yet, since we don't have support for fake
       // video here yet. (bug 1142320)
     } else {
@@ -1546,17 +1544,16 @@ public:
   std::string offer_;
   std::string answer_;
   std::vector<nsRefPtr<DOMMediaStream>> domMediaStreams_;
   IceConfiguration cfg_;
   const std::string name;
   bool mBundleEnabled;
   VideoSessionConduit::FrameRequestType mExpectedFrameRequestType;
   bool mExpectNack;
-  bool mExpectTmmbr;
   bool mExpectRtcpMuxAudio;
   bool mExpectRtcpMuxVideo;
   bool mRemoteDescriptionSet;
 
   std::map<Msid, SdpMediaSection::MediaType> mAddedTracks;
 
   typedef struct {
     std::string candidate;
@@ -1988,17 +1985,16 @@ public:
     // Double-check that the offered SDP matches what we expect
     CheckRtcpFbSdp(sdpWrapper.getSdp(), feedback);
 
     return sdpWrapper.getSdp();
   }
 
   void TestRtcpFbAnswer(const std::set<std::string>& feedback,
       bool expectNack,
-      bool expectTmmbr,
       VideoSessionConduit::FrameRequestType frameRequestType) {
     EnsureInit();
     OfferOptions options;
 
     a1_->CreateOffer(options, OFFER_AV);
     a1_->SetLocal(TestObserver::OFFER, a1_->offer());
 
     a2_->SetRemote(TestObserver::OFFER, a1_->offer());
@@ -2007,41 +2003,38 @@ public:
     a2_->SetLocal(TestObserver::ANSWER, a2_->answer());
 
     std::string modifiedAnswer(HardcodeRtcpFb(a2_->answer(), feedback));
 
     a1_->SetRemote(TestObserver::ANSWER, modifiedAnswer);
 
     a1_->SetExpectedFrameRequestType(frameRequestType);
     a1_->mExpectNack = expectNack;
-    a1_->mExpectTmmbr = expectTmmbr;
 
     WaitForCompleted();
     CheckPipelines();
 
     CloseStreams();
   }
 
   void TestRtcpFbOffer(
       const std::set<std::string>& feedback,
       bool expectNack,
-      bool expectTmmbr,
       VideoSessionConduit::FrameRequestType frameRequestType) {
     EnsureInit();
     OfferOptions options;
 
     a1_->CreateOffer(options, OFFER_AV);
     a1_->SetLocal(TestObserver::OFFER, a1_->offer());
 
     std::string modifiedOffer = HardcodeRtcpFb(a1_->offer(), feedback);
 
     a2_->SetRemote(TestObserver::OFFER, modifiedOffer);
     a2_->SetExpectedFrameRequestType(frameRequestType);
     a2_->mExpectNack = expectNack;
-    a2_->mExpectTmmbr = expectTmmbr;
 
     a2_->CreateAnswer(OFFER_AV | ANSWER_AV);
 
     a2_->SetLocal(TestObserver::ANSWER, a2_->answer());
     a1_->SetRemote(TestObserver::ANSWER, a2_->answer());
 
     WaitForCompleted();
 
@@ -3389,161 +3382,145 @@ TEST_P(SignalingTest, FullCallAudioNoMux
 }
 
 // TODO: Move to jsep_sesion_unittest
 TEST_P(SignalingTest, RtcpFbInOffer)
 {
   EnsureInit();
   OfferOptions options;
   a1_->CreateOffer(options, OFFER_AV);
-  const char *expected[] = { "nack", "nack pli", "ccm fir", "ccm tmmbr" };
+  const char *expected[] = { "nack", "nack pli", "ccm fir" };
   CheckRtcpFbSdp(a1_->offer(), ARRAY_TO_SET(std::string, expected));
 }
 
 TEST_P(SignalingTest, RtcpFbOfferAll)
 {
-  const char *feedbackTypes[] = { "nack", "nack pli", "ccm fir", "ccm tmmbr" };
+  const char *feedbackTypes[] = { "nack", "nack pli", "ccm fir" };
   TestRtcpFbOffer(ARRAY_TO_SET(std::string, feedbackTypes),
                   true,
-                  true,
                   VideoSessionConduit::FrameRequestPli);
 }
 
 TEST_P(SignalingTest, RtcpFbOfferNoNackBasic)
 {
-  const char *feedbackTypes[] = { "nack pli", "ccm fir", "ccm tmmbr" };
+  const char *feedbackTypes[] = { "nack pli", "ccm fir" };
   TestRtcpFbOffer(ARRAY_TO_SET(std::string, feedbackTypes),
                   false,
-                  true,
                   VideoSessionConduit::FrameRequestPli);
 }
 
 TEST_P(SignalingTest, RtcpFbOfferNoNackPli)
 {
   const char *feedbackTypes[] = { "nack", "ccm fir" };
   TestRtcpFbOffer(ARRAY_TO_SET(std::string, feedbackTypes),
                   true,
-                  false,
                   VideoSessionConduit::FrameRequestFir);
 }
 
 TEST_P(SignalingTest, RtcpFbOfferNoCcmFir)
 {
   const char *feedbackTypes[] = { "nack", "nack pli" };
   TestRtcpFbOffer(ARRAY_TO_SET(std::string, feedbackTypes),
                   true,
-                  false,
                   VideoSessionConduit::FrameRequestPli);
 }
 
 TEST_P(SignalingTest, RtcpFbOfferNoNack)
 {
   const char *feedbackTypes[] = { "ccm fir" };
   TestRtcpFbOffer(ARRAY_TO_SET(std::string, feedbackTypes),
                   false,
-                  false,
                   VideoSessionConduit::FrameRequestFir);
 }
 
 TEST_P(SignalingTest, RtcpFbOfferNoFrameRequest)
 {
   const char *feedbackTypes[] = { "nack" };
   TestRtcpFbOffer(ARRAY_TO_SET(std::string, feedbackTypes),
                   true,
-                  false,
                   VideoSessionConduit::FrameRequestNone);
 }
 
 TEST_P(SignalingTest, RtcpFbOfferPliOnly)
 {
   const char *feedbackTypes[] = { "nack pli" };
   TestRtcpFbOffer(ARRAY_TO_SET(std::string, feedbackTypes),
                   false,
-                  false,
                   VideoSessionConduit::FrameRequestPli);
 }
 
 TEST_P(SignalingTest, RtcpFbOfferNoFeedback)
 {
   const char *feedbackTypes[] = { };
   TestRtcpFbOffer(ARRAY_TO_SET(std::string, feedbackTypes),
                   false,
-                  false,
                   VideoSessionConduit::FrameRequestNone);
 }
 
 TEST_P(SignalingTest, RtcpFbAnswerAll)
 {
   const char *feedbackTypes[] = { "nack", "nack pli", "ccm fir" };
   TestRtcpFbAnswer(ARRAY_TO_SET(std::string, feedbackTypes),
                   true,
-                  false,
                   VideoSessionConduit::FrameRequestPli);
 }
 
 TEST_P(SignalingTest, RtcpFbAnswerNoNackBasic)
 {
   const char *feedbackTypes[] = { "nack pli", "ccm fir" };
   TestRtcpFbAnswer(ARRAY_TO_SET(std::string, feedbackTypes),
                   false,
-                  false,
                   VideoSessionConduit::FrameRequestPli);
 }
 
 TEST_P(SignalingTest, RtcpFbAnswerNoNackPli)
 {
   const char *feedbackTypes[] = { "nack", "ccm fir" };
   TestRtcpFbAnswer(ARRAY_TO_SET(std::string, feedbackTypes),
                   true,
-                  false,
                   VideoSessionConduit::FrameRequestFir);
 }
 
 TEST_P(SignalingTest, RtcpFbAnswerNoCcmFir)
 {
   const char *feedbackTypes[] = { "nack", "nack pli" };
   TestRtcpFbAnswer(ARRAY_TO_SET(std::string, feedbackTypes),
                   true,
-                  false,
                   VideoSessionConduit::FrameRequestPli);
 }
 
 TEST_P(SignalingTest, RtcpFbAnswerNoNack)
 {
   const char *feedbackTypes[] = { "ccm fir" };
   TestRtcpFbAnswer(ARRAY_TO_SET(std::string, feedbackTypes),
                   false,
-                  false,
                   VideoSessionConduit::FrameRequestFir);
 }
 
 TEST_P(SignalingTest, RtcpFbAnswerNoFrameRequest)
 {
   const char *feedbackTypes[] = { "nack" };
   TestRtcpFbAnswer(ARRAY_TO_SET(std::string, feedbackTypes),
                   true,
-                  false,
                   VideoSessionConduit::FrameRequestNone);
 }
 
 TEST_P(SignalingTest, RtcpFbAnswerPliOnly)
 {
   const char *feedbackTypes[] = { "nack pli" };
   TestRtcpFbAnswer(ARRAY_TO_SET(std::string, feedbackTypes),
-                  false,
-                  false,
+                  0,
                   VideoSessionConduit::FrameRequestPli);
 }
 
 TEST_P(SignalingTest, RtcpFbAnswerNoFeedback)
 {
   const char *feedbackTypes[] = { };
   TestRtcpFbAnswer(ARRAY_TO_SET(std::string, feedbackTypes),
-                  false,
-                  false,
+                  0,
                   VideoSessionConduit::FrameRequestNone);
 }
 
 // In this test we will change the offer SDP's a=setup value
 // from actpass to passive.  This will make the answer do active.
 TEST_P(SignalingTest, AudioCallForceDtlsRoles)
 {
   EnsureInit();
@@ -4386,22 +4363,16 @@ TEST_P(SignalingTest, UseNonPrefferedPay
                  "\r\na=rtcp-fb:121 nack pli");
 
   match = answer.find("\r\na=rtcp-fb:120 ccm fir");
   ASSERT_NE(std::string::npos, match);
   answer.replace(match,
                  strlen("\r\na=rtcp-fb:121 ccm fir"),
                  "\r\na=rtcp-fb:121 ccm fir");
 
-  match = answer.find("\r\na=rtcp-fb:120 ccm tmmbr");
-  ASSERT_NE(std::string::npos, match);
-  answer.replace(match,
-                 strlen("\r\na=rtcp-fb:121 ccm tmmbr"),
-                 "\r\na=rtcp-fb:121 ccm tmmbr");
-
   std::cout << "Modified SDP " << std::endl
             << indent(answer) << std::endl;
 
   a2_->SetLocal(TestObserver::ANSWER, answer, false);
 
   ASSERT_EQ(a2_->pObserver->lastStatusCode,
             PeerConnectionImpl::kNoError);
 
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4601,16 +4601,22 @@ pref("touchcaret.extendedvisibility", fa
 
 // Desktop and b2g don't need to open or close the Android
 // TextSelection (Actionbar) utility.
 pref("caret.manages-android-actionbar", false);
 
 // New implementation to unify touch-caret and selection-carets.
 pref("layout.accessiblecaret.enabled", false);
 
+// CSS attributes of the AccessibleCaret in CSS pixels.
+pref("layout.accessiblecaret.width", "44.0");
+pref("layout.accessiblecaret.height", "47.0");
+pref("layout.accessiblecaret.margin-left", "-23.5");
+pref("layout.accessiblecaret.bar.width", "2.0");
+
 // Timeout in milliseconds to hide the accessiblecaret under cursor mode while
 // no one touches it. Set the value to 0 to disable this feature.
 pref("layout.accessiblecaret.timeout_ms", 3000);
 
 // Wakelock is disabled by default.
 pref("dom.wakelock.enabled", false);
 
 // The URL of the Firefox Accounts auth server backend
--- a/netwerk/base/Predictor.cpp
+++ b/netwerk/base/Predictor.cpp
@@ -123,17 +123,17 @@ const uint32_t ONE_MONTH = 30U * ONE_DAY
 const uint32_t ONE_YEAR = 365U * ONE_DAY;
 
 const uint32_t STARTUP_WINDOW = 5U * 60U; // 5min
 
 // Version of metadata entries we expect
 const uint32_t METADATA_VERSION = 1;
 
 // ID Extensions for cache entries
-const char PREDICTOR_ORIGIN_EXTENSION[] = "predictor-origin";
+#define PREDICTOR_ORIGIN_EXTENSION "predictor-origin"
 
 // Get the full origin (scheme, host, port) out of a URI (maybe should be part
 // of nsIURI instead?)
 static nsresult
 ExtractOrigin(nsIURI *uri, nsIURI **originUri, nsIIOService *ioService)
 {
   nsAutoCString s;
   s.Truncate();
@@ -501,26 +501,26 @@ class NuwaMarkPredictorThreadRunner : pu
     return NS_OK;
   }
 };
 } // anon namespace
 #endif
 
 // Predictor::nsICacheEntryMetaDataVisitor
 
-static const char seenMetaData[] = "predictor::seen";
-static const char metaDataPrefix[] = "predictor::";
+#define SEEN_META_DATA "predictor::seen"
+#define META_DATA_PREFIX "predictor::"
 nsresult
 Predictor::OnMetaDataElement(const char *asciiKey, const char *asciiValue)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!StringBeginsWith(nsDependentCString(asciiKey),
-                        NS_LITERAL_CSTRING(metaDataPrefix)) ||
-      NS_LITERAL_CSTRING(seenMetaData).Equals(asciiKey)) {
+                        NS_LITERAL_CSTRING(META_DATA_PREFIX)) ||
+      NS_LITERAL_CSTRING(SEEN_META_DATA).Equals(asciiKey)) {
     // This isn't a bit of metadata we care about
     return NS_OK;
   }
 
   nsCString key, value;
   key.AssignASCII(asciiKey);
   value.AssignASCII(asciiValue);
   mKeysToOperateOn.AppendElement(key);
@@ -1331,20 +1331,20 @@ void
 Predictor::LearnInternal(PredictorLearnReason reason, nsICacheEntry *entry,
                          bool isNew, bool fullUri, nsIURI *targetURI,
                          nsIURI *sourceURI)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCString junk;
   if (!fullUri && reason == nsINetworkPredictor::LEARN_LOAD_TOPLEVEL &&
-      NS_FAILED(entry->GetMetaDataElement(seenMetaData, getter_Copies(junk)))) {
+      NS_FAILED(entry->GetMetaDataElement(SEEN_META_DATA, getter_Copies(junk)))) {
     // This is an origin-only entry that we haven't seen before. Let's mark it
     // as seen.
-    entry->SetMetaDataElement(seenMetaData, "1");
+    entry->SetMetaDataElement(SEEN_META_DATA, "1");
 
     // Need to ensure someone else can get to the entry if necessary
     entry->MetaDataReady();
     return;
   }
 
   switch (reason) {
     case nsINetworkPredictor::LEARN_LOAD_TOPLEVEL:
@@ -1371,18 +1371,18 @@ Predictor::LearnInternal(PredictorLearnR
 NS_IMPL_ISUPPORTS(Predictor::SpaceCleaner, nsICacheEntryMetaDataVisitor)
 
 NS_IMETHODIMP
 Predictor::SpaceCleaner::OnMetaDataElement(const char *key, const char *value)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!StringBeginsWith(nsDependentCString(key),
-                        NS_LITERAL_CSTRING(metaDataPrefix)) ||
-      NS_LITERAL_CSTRING(seenMetaData).Equals(key)) {
+                        NS_LITERAL_CSTRING(META_DATA_PREFIX)) ||
+      NS_LITERAL_CSTRING(SEEN_META_DATA).Equals(key)) {
     // This isn't a bit of metadata we care about
     return NS_OK;
   }
 
   nsCOMPtr<nsIURI> sanityCheck;
   uint32_t hitCount, lastHit, flags;
   bool ok = mPredictor->ParseMetaDataEntry(key, value,
                                            getter_AddRefs(sanityCheck),
@@ -1415,17 +1415,17 @@ Predictor::LearnForSubresource(nsICacheE
   nsresult rv = entry->GetLastFetched(&lastLoad);
   RETURN_IF_FAILED(rv);
 
   int32_t loadCount;
   rv = entry->GetFetchCount(&loadCount);
   RETURN_IF_FAILED(rv);
 
   nsCString key;
-  key.AssignASCII(metaDataPrefix);
+  key.AssignLiteral(META_DATA_PREFIX);
   nsCString uri;
   targetURI->GetAsciiSpec(uri);
   key.Append(uri);
 
   nsCString value;
   rv = entry->GetMetaDataElement(key.BeginReading(), getter_Copies(value));
 
   uint32_t hitCount, lastHit, flags;
@@ -1549,17 +1549,17 @@ Predictor::ParseMetaDataEntry(const char
   lastHit = static_cast<uint32_t>(atoi(value));
   PREDICTOR_LOG(("    lastHit -> %u", lastHit));
 
   value = comma + 1;
   flags = static_cast<uint32_t>(atoi(value));
   PREDICTOR_LOG(("    flags -> %u", flags));
 
   if (key) {
-    const char *uriStart = key + (sizeof(metaDataPrefix) - 1);
+    const char *uriStart = key + (sizeof(META_DATA_PREFIX) - 1);
     nsresult rv = NS_NewURI(uri, uriStart, nullptr, mIOService);
     if (NS_FAILED(rv)) {
       PREDICTOR_LOG(("    NS_NewURI returned 0x%X", rv));
       return false;
     }
     PREDICTOR_LOG(("    uri -> %s", uriStart));
   }
 
@@ -1647,17 +1647,17 @@ Predictor::Resetter::OnCacheEntryAvailab
 
 NS_IMETHODIMP
 Predictor::Resetter::OnMetaDataElement(const char *asciiKey,
                                        const char *asciiValue)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!StringBeginsWith(nsDependentCString(asciiKey),
-                        NS_LITERAL_CSTRING(metaDataPrefix))) {
+                        NS_LITERAL_CSTRING(META_DATA_PREFIX))) {
     // Not a metadata entry we care about, carry on
     return NS_OK;
   }
 
   nsCString key;
   key.AssignASCII(asciiKey);
   mKeysToDelete.AppendElement(key);
 
--- a/netwerk/cache2/CacheFileContextEvictor.cpp
+++ b/netwerk/cache2/CacheFileContextEvictor.cpp
@@ -15,19 +15,19 @@
 #include "nsISimpleEnumerator.h"
 #include "nsIDirectoryEnumerator.h"
 #include "mozilla/Base64.h"
 
 
 namespace mozilla {
 namespace net {
 
-const char kContextEvictionPrefix[] = "ce_";
+#define CONTEXT_EVICTION_PREFIX "ce_"
 const uint32_t kContextEvictionPrefixLength =
-  sizeof(kContextEvictionPrefix) - 1;
+  sizeof(CONTEXT_EVICTION_PREFIX) - 1;
 
 bool CacheFileContextEvictor::sDiskAlreadySearched = false;
 
 CacheFileContextEvictor::CacheFileContextEvictor()
   : mEvicting(false)
   , mIndexIsUpToDate(false)
 {
   LOG(("CacheFileContextEvictor::CacheFileContextEvictor() [this=%p]", this));
@@ -51,17 +51,17 @@ CacheFileContextEvictor::Init(nsIFile *a
 
   mCacheDirectory = aCacheDirectory;
 
   rv = aCacheDirectory->Clone(getter_AddRefs(mEntriesDir));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  rv = mEntriesDir->AppendNative(NS_LITERAL_CSTRING(kEntriesDir));
+  rv = mEntriesDir->AppendNative(NS_LITERAL_CSTRING(ENTRIES_DIR));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (!sDiskAlreadySearched) {
     LoadEvictInfoFromDisk();
     if ((mEntries.Length() != 0) && mIndexIsUpToDate) {
       CreateIterators();
@@ -341,17 +341,17 @@ CacheFileContextEvictor::LoadEvictInfoFr
            "GetNativeLeafName() failed! Skipping file."));
       continue;
     }
 
     if (leaf.Length() < kContextEvictionPrefixLength) {
       continue;
     }
 
-    if (!StringBeginsWith(leaf, NS_LITERAL_CSTRING(kContextEvictionPrefix))) {
+    if (!StringBeginsWith(leaf, NS_LITERAL_CSTRING(CONTEXT_EVICTION_PREFIX))) {
       continue;
     }
 
     nsAutoCString encoded;
     encoded = Substring(leaf, kContextEvictionPrefixLength);
     encoded.ReplaceChar('-', '/');
 
     nsAutoCString decoded;
@@ -390,17 +390,17 @@ CacheFileContextEvictor::LoadEvictInfoFr
 
 nsresult
 CacheFileContextEvictor::GetContextFile(nsILoadContextInfo *aLoadContextInfo,
                                         nsIFile **_retval)
 {
   nsresult rv;
 
   nsAutoCString leafName;
-  leafName.Assign(NS_LITERAL_CSTRING(kContextEvictionPrefix));
+  leafName.AssignLiteral(CONTEXT_EVICTION_PREFIX);
 
   nsAutoCString keyPrefix;
   CacheFileUtils::AppendKeyPrefix(aLoadContextInfo, keyPrefix);
 
   nsAutoCString data64;
   rv = Base64Encode(keyPrefix, data64);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
--- a/netwerk/cache2/CacheFileIOManager.cpp
+++ b/netwerk/cache2/CacheFileIOManager.cpp
@@ -2797,32 +2797,32 @@ CacheFileIOManager::EvictAllInternal()
   }
 
   nsCOMPtr<nsIFile> file;
   rv = mCacheDirectory->Clone(getter_AddRefs(file));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  rv = file->AppendNative(NS_LITERAL_CSTRING(kEntriesDir));
+  rv = file->AppendNative(NS_LITERAL_CSTRING(ENTRIES_DIR));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // Trash current entries directory
   rv = TrashDirectory(file);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // Files are now inaccessible in entries directory, notify observers.
   NS_DispatchToMainThread(r);
 
   // Create a new empty entries directory
-  rv = CheckAndCreateDir(mCacheDirectory, kEntriesDir, false);
+  rv = CheckAndCreateDir(mCacheDirectory, ENTRIES_DIR, false);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   CacheIndex::RemoveAll();
 
   return NS_OK;
 }
@@ -3008,17 +3008,17 @@ CacheFileIOManager::TrashDirectory(nsIFi
   rv = aFile->Clone(getter_AddRefs(dir));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = aFile->Clone(getter_AddRefs(trash));
   NS_ENSURE_SUCCESS(rv, rv);
 
   srand(static_cast<unsigned>(PR_Now()));
   while (true) {
-    leaf = kTrashDir;
+    leaf = TRASH_DIR;
     leaf.AppendInt(rand());
     rv = trash->SetNativeLeafName(leaf);
     NS_ENSURE_SUCCESS(rv, rv);
 
     bool exists;
     if (NS_SUCCEEDED(trash->Exists(&exists)) && !exists) {
       break;
     }
@@ -3251,21 +3251,21 @@ CacheFileIOManager::FindTrashDirToRemove
     }
 
     nsAutoCString leafName;
     rv = file->GetNativeLeafName(leafName);
     if (NS_FAILED(rv)) {
       continue;
     }
 
-    if (leafName.Length() < strlen(kTrashDir)) {
+    if (leafName.Length() < strlen(TRASH_DIR)) {
       continue;
     }
 
-    if (!StringBeginsWith(leafName, NS_LITERAL_CSTRING(kTrashDir))) {
+    if (!StringBeginsWith(leafName, NS_LITERAL_CSTRING(TRASH_DIR))) {
       continue;
     }
 
     if (mFailedTrashDirs.Contains(leafName)) {
       continue;
     }
 
     LOG(("CacheFileIOManager::FindTrashDirToRemove() - Returning directory %s",
@@ -3417,17 +3417,17 @@ CacheFileIOManager::StrToHash(const nsAC
 nsresult
 CacheFileIOManager::GetFile(const SHA1Sum::Hash *aHash, nsIFile **_retval)
 {
   nsresult rv;
   nsCOMPtr<nsIFile> file;
   rv = mCacheDirectory->Clone(getter_AddRefs(file));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = file->AppendNative(NS_LITERAL_CSTRING(kEntriesDir));
+  rv = file->AppendNative(NS_LITERAL_CSTRING(ENTRIES_DIR));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString leafName;
   HashToStr(aHash, leafName);
 
   rv = file->AppendNative(leafName);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -3453,17 +3453,17 @@ CacheFileIOManager::GetSpecialFile(const
 nsresult
 CacheFileIOManager::GetDoomedFile(nsIFile **_retval)
 {
   nsresult rv;
   nsCOMPtr<nsIFile> file;
   rv = mCacheDirectory->Clone(getter_AddRefs(file));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = file->AppendNative(NS_LITERAL_CSTRING(kDoomedDir));
+  rv = file->AppendNative(NS_LITERAL_CSTRING(DOOMED_DIR));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = file->AppendNative(NS_LITERAL_CSTRING("dummyleaf"));
   NS_ENSURE_SUCCESS(rv, rv);
 
   srand(static_cast<unsigned>(PR_Now()));
   nsAutoCString leafName;
   uint32_t iter=0;
@@ -3581,21 +3581,21 @@ CacheFileIOManager::CreateCacheTree()
   rv = CheckAndCreateDir(parentDir, nullptr, false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // ensure cache directory exists
   rv = CheckAndCreateDir(mCacheDirectory, nullptr, false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // ensure entries directory exists
-  rv = CheckAndCreateDir(mCacheDirectory, kEntriesDir, false);
+  rv = CheckAndCreateDir(mCacheDirectory, ENTRIES_DIR, false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // ensure doomed directory exists
-  rv = CheckAndCreateDir(mCacheDirectory, kDoomedDir, true);
+  rv = CheckAndCreateDir(mCacheDirectory, DOOMED_DIR, true);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mTreeCreated = true;
 
   if (!mContextEvictor) {
     nsRefPtr<CacheFileContextEvictor> contextEvictor;
     contextEvictor = new CacheFileContextEvictor();
 
@@ -3777,18 +3777,18 @@ CacheFileIOManager::SyncRemoveDir(nsIFil
 
 void
 CacheFileIOManager::SyncRemoveAllCacheFiles()
 {
   LOG(("CacheFileIOManager::SyncRemoveAllCacheFiles()"));
 
   nsresult rv;
 
-  SyncRemoveDir(mCacheDirectory, kEntriesDir);
-  SyncRemoveDir(mCacheDirectory, kDoomedDir);
+  SyncRemoveDir(mCacheDirectory, ENTRIES_DIR);
+  SyncRemoveDir(mCacheDirectory, DOOMED_DIR);
 
   // Clear any intermediate state of trash dir enumeration.
   mFailedTrashDirs.Clear();
   mTrashDir = nullptr;
 
   while (true) {
     // FindTrashDirToRemove() fills mTrashDir if there is any trash directory.
     rv = FindTrashDirToRemove();
--- a/netwerk/cache2/CacheFileIOManager.h
+++ b/netwerk/cache2/CacheFileIOManager.h
@@ -27,19 +27,19 @@ class nsILoadContextInfo;
 namespace mozilla {
 namespace net {
 
 class CacheFile;
 #ifdef DEBUG_HANDLES
 class CacheFileHandlesEntry;
 #endif
 
-const char kEntriesDir[] = "entries";
-const char kDoomedDir[]  = "doomed";
-const char kTrashDir[]   = "trash";
+#define ENTRIES_DIR "entries"
+#define DOOMED_DIR  "doomed"
+#define TRASH_DIR   "trash"
 
 
 class CacheFileHandle : public nsISupports
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   bool DispatchRelease();
 
--- a/netwerk/cache2/CacheIndex.cpp
+++ b/netwerk/cache2/CacheIndex.cpp
@@ -23,19 +23,19 @@
 
 
 #define kMinUnwrittenChanges   300
 #define kMinDumpInterval       20000 // in milliseconds
 #define kMaxBufSize            16384
 #define kIndexVersion          0x00000001
 #define kUpdateIndexStartDelay 50000 // in milliseconds
 
-const char kIndexName[]     = "index";
-const char kTempIndexName[] = "index.tmp";
-const char kJournalName[]   = "index.log";
+#define INDEX_NAME      "index"
+#define TEMP_INDEX_NAME "index.tmp"
+#define JOURNAL_NAME    "index.log"
 
 namespace mozilla {
 namespace net {
 
 /**
  * This helper class is responsible for keeping CacheIndex::mIndexStats and
  * CacheIndex::mFrecencyArray up to date.
  */
@@ -1034,17 +1034,17 @@ CacheIndex::RemoveAll()
 
     // Doom index and journal handles but don't null them out since this will be
     // done in FinishWrite/FinishRead methods.
     if (index->mIndexHandle) {
       CacheFileIOManager::DoomFile(index->mIndexHandle, nullptr);
     } else {
       // We don't have a handle to index file, so get the file here, but delete
       // it outside the lock. Ignore the result since this is not fatal.
-      index->GetFile(NS_LITERAL_CSTRING(kIndexName), getter_AddRefs(file));
+      index->GetFile(NS_LITERAL_CSTRING(INDEX_NAME), getter_AddRefs(file));
     }
 
     if (index->mJournalHandle) {
       CacheFileIOManager::DoomFile(index->mJournalHandle, nullptr);
     }
 
     switch (index->mState) {
       case WRITING:
@@ -1567,17 +1567,17 @@ CacheIndex::WriteIndexToDisk()
   MOZ_ASSERT(!mRWBuf);
   MOZ_ASSERT(!mRWHash);
 
   ChangeState(WRITING);
 
   mProcessEntries = mIndexStats.ActiveEntriesCount();
 
   mIndexFileOpener = new FileOpenHelper(this);
-  rv = CacheFileIOManager::OpenFile(NS_LITERAL_CSTRING(kTempIndexName),
+  rv = CacheFileIOManager::OpenFile(NS_LITERAL_CSTRING(TEMP_INDEX_NAME),
                                     CacheFileIOManager::SPECIAL_FILE |
                                     CacheFileIOManager::CREATE,
                                     mIndexFileOpener);
   if (NS_FAILED(rv)) {
     LOG(("CacheIndex::WriteIndexToDisk() - Can't open file [rv=0x%08x]", rv));
     FinishWrite(false);
     return;
   }
@@ -1818,19 +1818,19 @@ CacheIndex::RemoveFile(const nsACString 
   return NS_OK;
 }
 
 void
 CacheIndex::RemoveIndexFromDisk()
 {
   LOG(("CacheIndex::RemoveIndexFromDisk()"));
 
-  RemoveFile(NS_LITERAL_CSTRING(kIndexName));
-  RemoveFile(NS_LITERAL_CSTRING(kTempIndexName));
-  RemoveFile(NS_LITERAL_CSTRING(kJournalName));
+  RemoveFile(NS_LITERAL_CSTRING(INDEX_NAME));
+  RemoveFile(NS_LITERAL_CSTRING(TEMP_INDEX_NAME));
+  RemoveFile(NS_LITERAL_CSTRING(JOURNAL_NAME));
 }
 
 class WriteLogHelper
 {
 public:
   explicit WriteLogHelper(PRFileDesc *aFD)
     : mStatus(NS_OK)
     , mFD(aFD)
@@ -1935,24 +1935,24 @@ CacheIndex::WriteLogToDisk()
 {
   LOG(("CacheIndex::WriteLogToDisk()"));
 
   nsresult rv;
 
   MOZ_ASSERT(mPendingUpdates.Count() == 0);
   MOZ_ASSERT(mState == SHUTDOWN);
 
-  RemoveFile(NS_LITERAL_CSTRING(kTempIndexName));
+  RemoveFile(NS_LITERAL_CSTRING(TEMP_INDEX_NAME));
 
   nsCOMPtr<nsIFile> indexFile;
-  rv = GetFile(NS_LITERAL_CSTRING(kIndexName), getter_AddRefs(indexFile));
+  rv = GetFile(NS_LITERAL_CSTRING(INDEX_NAME), getter_AddRefs(indexFile));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIFile> logFile;
-  rv = GetFile(NS_LITERAL_CSTRING(kJournalName), getter_AddRefs(logFile));
+  rv = GetFile(NS_LITERAL_CSTRING(JOURNAL_NAME), getter_AddRefs(logFile));
   NS_ENSURE_SUCCESS(rv, rv);
 
   mIndexStats.Log();
 
   PRFileDesc *fd = nullptr;
   rv = logFile->OpenNSPRFileDesc(PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE,
                                  0600, &fd);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -2012,46 +2012,46 @@ CacheIndex::ReadIndexFromDisk()
   nsresult rv;
 
   AssertOwnsLock();
   MOZ_ASSERT(mState == INITIAL);
 
   ChangeState(READING);
 
   mIndexFileOpener = new FileOpenHelper(this);
-  rv = CacheFileIOManager::OpenFile(NS_LITERAL_CSTRING(kIndexName),
+  rv = CacheFileIOManager::OpenFile(NS_LITERAL_CSTRING(INDEX_NAME),
                                     CacheFileIOManager::SPECIAL_FILE |
                                     CacheFileIOManager::OPEN,
                                     mIndexFileOpener);
   if (NS_FAILED(rv)) {
     LOG(("CacheIndex::ReadIndexFromDisk() - CacheFileIOManager::OpenFile() "
-         "failed [rv=0x%08x, file=%s]", rv, kIndexName));
+         "failed [rv=0x%08x, file=%s]", rv, INDEX_NAME));
     FinishRead(false);
     return;
   }
 
   mJournalFileOpener = new FileOpenHelper(this);
-  rv = CacheFileIOManager::OpenFile(NS_LITERAL_CSTRING(kJournalName),
+  rv = CacheFileIOManager::OpenFile(NS_LITERAL_CSTRING(JOURNAL_NAME),
                                     CacheFileIOManager::SPECIAL_FILE |
                                     CacheFileIOManager::OPEN,
                                     mJournalFileOpener);
   if (NS_FAILED(rv)) {
     LOG(("CacheIndex::ReadIndexFromDisk() - CacheFileIOManager::OpenFile() "
-         "failed [rv=0x%08x, file=%s]", rv, kJournalName));
+         "failed [rv=0x%08x, file=%s]", rv, JOURNAL_NAME));
     FinishRead(false);
   }
 
   mTmpFileOpener = new FileOpenHelper(this);
-  rv = CacheFileIOManager::OpenFile(NS_LITERAL_CSTRING(kTempIndexName),
+  rv = CacheFileIOManager::OpenFile(NS_LITERAL_CSTRING(TEMP_INDEX_NAME),
                                     CacheFileIOManager::SPECIAL_FILE |
                                     CacheFileIOManager::OPEN,
                                     mTmpFileOpener);
   if (NS_FAILED(rv)) {
     LOG(("CacheIndex::ReadIndexFromDisk() - CacheFileIOManager::OpenFile() "
-         "failed [rv=0x%08x, file=%s]", rv, kTempIndexName));
+         "failed [rv=0x%08x, file=%s]", rv, TEMP_INDEX_NAME));
     FinishRead(false);
   }
 }
 
 void
 CacheIndex::StartReadingIndex()
 {
   LOG(("CacheIndex::StartReadingIndex()"));
@@ -2420,18 +2420,18 @@ CacheIndex::FinishRead(bool aSucceeded)
     // -> rebuild
     (!aSucceeded && !mIndexOnDiskIsValid && !mJournalReadSuccessfully) ||
     // -> update
     (!aSucceeded && mIndexOnDiskIsValid && !mJournalReadSuccessfully) ||
     // -> ready
     (aSucceeded && mIndexOnDiskIsValid && mJournalReadSuccessfully));
 
   if (mState == SHUTDOWN) {
-    RemoveFile(NS_LITERAL_CSTRING(kTempIndexName));
-    RemoveFile(NS_LITERAL_CSTRING(kJournalName));
+    RemoveFile(NS_LITERAL_CSTRING(TEMP_INDEX_NAME));
+    RemoveFile(NS_LITERAL_CSTRING(JOURNAL_NAME));
   } else {
     if (mIndexHandle && !mIndexOnDiskIsValid) {
       CacheFileIOManager::DoomFile(mIndexHandle, nullptr);
     }
 
     if (mJournalHandle) {
       CacheFileIOManager::DoomFile(mJournalHandle, nullptr);
     }
@@ -2566,17 +2566,17 @@ CacheIndex::SetupDirectoryEnumerator()
   MOZ_ASSERT(!mDirEnumerator);
 
   nsresult rv;
   nsCOMPtr<nsIFile> file;
 
   rv = mCacheDirectory->Clone(getter_AddRefs(file));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = file->AppendNative(NS_LITERAL_CSTRING(kEntriesDir));
+  rv = file->AppendNative(NS_LITERAL_CSTRING(ENTRIES_DIR));
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool exists;
   rv = file->Exists(&exists);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!exists) {
     NS_WARNING("CacheIndex::SetupDirectoryEnumerator() - Entries directory "
@@ -3362,27 +3362,27 @@ CacheIndex::OnFileOpenedInternal(FileOpe
 
       if (mTmpHandle) {
         CacheFileIOManager::DoomFile(mTmpHandle, nullptr);
         mTmpHandle = nullptr;
 
         if (mJournalHandle) { // this shouldn't normally happen
           LOG(("CacheIndex::OnFileOpenedInternal() - Unexpected state, all "
                "files [%s, %s, %s] should never exist. Removing whole index.",
-               kIndexName, kJournalName, kTempIndexName));
+               INDEX_NAME, JOURNAL_NAME, TEMP_INDEX_NAME));
           FinishRead(false);
           break;
         }
       }
 
       if (mJournalHandle) {
         // Rename journal to make sure we update index on next start in case
         // firefox crashes
         rv = CacheFileIOManager::RenameFile(
-          mJournalHandle, NS_LITERAL_CSTRING(kTempIndexName), this);
+          mJournalHandle, NS_LITERAL_CSTRING(TEMP_INDEX_NAME), this);
         if (NS_FAILED(rv)) {
           LOG(("CacheIndex::OnFileOpenedInternal() - CacheFileIOManager::"
                "RenameFile() failed synchronously [rv=0x%08x]", rv));
           FinishRead(false);
           break;
         }
       } else {
         StartReadingIndex();
@@ -3430,17 +3430,17 @@ CacheIndex::OnDataWritten(CacheFileHandl
         break;
       }
 
       if (NS_FAILED(aResult)) {
         FinishWrite(false);
       } else {
         if (mSkipEntries == mProcessEntries) {
           rv = CacheFileIOManager::RenameFile(mIndexHandle,
-                                              NS_LITERAL_CSTRING(kIndexName),
+                                              NS_LITERAL_CSTRING(INDEX_NAME),
                                               this);
           if (NS_FAILED(rv)) {
             LOG(("CacheIndex::OnDataWritten() - CacheFileIOManager::"
                  "RenameFile() failed synchronously [rv=0x%08x]", rv));
             FinishWrite(false);
           }
         } else {
           WriteRecords();
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -63,17 +63,17 @@ using namespace mozilla::net;
  * nsCookieService impl:
  * useful types & constants
  ******************************************************************************/
 
 static nsCookieService *gCookieService;
 
 // XXX_hack. See bug 178993.
 // This is a hack to hide HttpOnly cookies from older browsers
-static const char kHttpOnlyPrefix[] = "#HttpOnly_";
+#define HTTP_ONLY_PREFIX "#HttpOnly_"
 
 #define COOKIES_FILE "cookies.sqlite"
 #define COOKIES_SCHEMA_VERSION 5
 
 // parameter indexes; see EnsureReadDomain, EnsureReadComplete and
 // ReadCookieDBListener::HandleResult
 #define IDX_NAME 0
 #define IDX_VALUE 1
@@ -87,17 +87,17 @@ static const char kHttpOnlyPrefix[] = "#
 #define IDX_BASE_DOMAIN 9
 #define IDX_APP_ID 10
 #define IDX_BROWSER_ELEM 11
 
 static const int64_t kCookieStaleThreshold = 60 * PR_USEC_PER_SEC; // 1 minute in microseconds
 static const int64_t kCookiePurgeAge =
   int64_t(30 * 24 * 60 * 60) * PR_USEC_PER_SEC; // 30 days in microseconds
 
-static const char kOldCookieFileName[] = "cookies.txt";
+#define OLD_COOKIE_FILE_NAME "cookies.txt"
 
 #undef  LIMIT
 #define LIMIT(x, low, high, default) ((x) >= (low) && (x) <= (high) ? (x) : (default))
 
 #undef  ADD_TEN_PERCENT
 #define ADD_TEN_PERCENT(i) static_cast<uint32_t>((i) + (i)/10)
 
 // default limits for the cookie list. these can be tuned by the
@@ -1232,17 +1232,17 @@ nsCookieService::TryInitDB(bool aRecreat
     getter_AddRefs(oldCookieFile));
   if (NS_FAILED(rv)) return RESULT_OK;
 
   // Import cookies, and clean up the old file regardless of success or failure.
   // Note that we have to switch out our DBState temporarily, in case we're in
   // private browsing mode; otherwise ImportCookies() won't be happy.
   DBState* initialState = mDBState;
   mDBState = mDefaultDBState;
-  oldCookieFile->AppendNative(NS_LITERAL_CSTRING(kOldCookieFileName));
+  oldCookieFile->AppendNative(NS_LITERAL_CSTRING(OLD_COOKIE_FILE_NAME));
   ImportCookies(oldCookieFile);
   oldCookieFile->Remove(false);
   mDBState = initialState;
 
   return RESULT_OK;
 }
 
 // Sets the schema version and creates the moz_cookies table.
@@ -2496,19 +2496,19 @@ nsCookieService::ImportCookies(nsIFile *
   // We will likely be adding a bunch of cookies to the DB, so we use async
   // batching with storage to make this super fast.
   nsCOMPtr<mozIStorageBindingParamsArray> paramsArray;
   if (originalCookieCount == 0 && mDefaultDBState->dbConn) {
     mDefaultDBState->stmtInsert->NewBindingParamsArray(getter_AddRefs(paramsArray));
   }
 
   while (isMore && NS_SUCCEEDED(lineInputStream->ReadLine(buffer, &isMore))) {
-    if (StringBeginsWith(buffer, NS_LITERAL_CSTRING(kHttpOnlyPrefix))) {
+    if (StringBeginsWith(buffer, NS_LITERAL_CSTRING(HTTP_ONLY_PREFIX))) {
       isHttpOnly = true;
-      hostIndex = sizeof(kHttpOnlyPrefix) - 1;
+      hostIndex = sizeof(HTTP_ONLY_PREFIX) - 1;
     } else if (buffer.IsEmpty() || buffer.First() == '#') {
       continue;
     } else {
       isHttpOnly = false;
       hostIndex = 0;
     }
 
     // this is a cheap, cheesy way of parsing a tab-delimited line into
--- a/netwerk/ipc/RemoteOpenFileChild.cpp
+++ b/netwerk/ipc/RemoteOpenFileChild.cpp
@@ -607,16 +607,22 @@ RemoteOpenFileChild::MoveToNative(nsIFil
 
 NS_IMETHODIMP
 RemoteOpenFileChild::RenameTo(nsIFile *newParentDir, const nsAString &newName)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
+RemoteOpenFileChild::RenameToNative(nsIFile *newParentDir, const nsACString &newName)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
 RemoteOpenFileChild::Remove(bool recursive)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 RemoteOpenFileChild::GetPermissions(uint32_t *aPermissions)
 {
--- a/security/manager/ssl/src/CryptoTask.h
+++ b/security/manager/ssl/src/CryptoTask.h
@@ -45,17 +45,17 @@ class CryptoTask : public nsRunnable,
                    public nsNSSShutDownObject
 {
 public:
   template <size_t LEN>
   nsresult Dispatch(const char (&taskThreadName)[LEN])
   {
     static_assert(LEN <= 15,
                   "Thread name must be no more than 15 characters");
-    return Dispatch(NS_LITERAL_CSTRING(taskThreadName));
+    return Dispatch(nsDependentCString(taskThreadName, LEN - 1));
   }
 
   nsresult Dispatch(const nsACString& taskThreadName);
 
   void Skip()
   {
     virtualDestroyNSSReference();
   }
--- a/security/manager/ssl/src/nsCertOverrideService.cpp
+++ b/security/manager/ssl/src/nsCertOverrideService.cpp
@@ -24,17 +24,17 @@
 #include "nsStreamUtils.h"
 #include "nsStringBuffer.h"
 #include "nsThreadUtils.h"
 #include "ssl.h" // For SSL_ClearSessionCache
 
 using namespace mozilla;
 using namespace mozilla::psm;
 
-static const char kCertOverrideFileName[] = "cert_override.txt";
+#define CERT_OVERRIDE_FILE_NAME "cert_override.txt"
 
 void
 nsCertOverride::convertBitsToString(OverrideBits ob, nsACString &str)
 {
   str.Truncate();
 
   if (ob & ob_Mismatch)
     str.Append('M');
@@ -139,17 +139,17 @@ nsCertOverrideService::Observe(nsISuppor
     // The profile has already changed.
     // Now read from the new profile location.
     // we also need to update the cached file location
 
     ReentrantMonitorAutoEnter lock(monitor);
 
     nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(mSettingsFile));
     if (NS_SUCCEEDED(rv)) {
-      mSettingsFile->AppendNative(NS_LITERAL_CSTRING(kCertOverrideFileName));
+      mSettingsFile->AppendNative(NS_LITERAL_CSTRING(CERT_OVERRIDE_FILE_NAME));
     } else {
       mSettingsFile = nullptr;
     }
     Read();
     CountPermanentOverrideTelemetry();
   }
 
   return NS_OK;
--- a/startupcache/StartupCache.cpp
+++ b/startupcache/StartupCache.cpp
@@ -76,17 +76,17 @@ StartupCache::CollectReports(nsIHandleRe
   REPORT("explicit/startup-cache/data", KIND_HEAP,
          HeapSizeOfIncludingThis(StartupCacheMallocSizeOf),
          "Memory used by the startup cache for things other than the file "
          "mapping.");
 
   return NS_OK;
 }
 
-static const char sStartupCacheName[] = "startupCache." SC_WORDSIZE "." SC_ENDIAN;
+#define STARTUP_CACHE_NAME "startupCache." SC_WORDSIZE "." SC_ENDIAN
 
 StartupCache*
 StartupCache::GetSingleton()
 {
   if (!gStartupCache) {
     if (XRE_GetProcessType() != GeckoProcessType_Default) {
       return nullptr;
     }
@@ -191,17 +191,17 @@ StartupCache::Init()
     rv = file->AppendNative(NS_LITERAL_CSTRING("startupCache"));
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Try to create the directory if it's not there yet
     rv = file->Create(nsIFile::DIRECTORY_TYPE, 0777);
     if (NS_FAILED(rv) && rv != NS_ERROR_FILE_ALREADY_EXISTS)
       return rv;
 
-    rv = file->AppendNative(NS_LITERAL_CSTRING(sStartupCacheName));
+    rv = file->AppendNative(NS_LITERAL_CSTRING(STARTUP_CACHE_NAME));
 
     NS_ENSURE_SUCCESS(rv, rv);
 
     mFile = do_QueryInterface(file);
   }
 
   NS_ENSURE_TRUE(mFile, NS_ERROR_UNEXPECTED);
 
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -284,47 +284,69 @@ class MachCommands(MachCommandBase):
         try:
             result = tester.run_tests(tests, self.bindir, symbols_path, interactive=True)
         except Exception as e:
             log.error("Caught exception running cpp unit tests: %s" % str(e))
             result = False
 
         return 0 if result else 1
 
+def executable_name(name):
+    return name + '.exe' if sys.platform.startswith('win') else name
+
 @CommandProvider
 class CheckSpiderMonkeyCommand(MachCommandBase):
     @Command('check-spidermonkey', category='testing', description='Run SpiderMonkey tests (JavaScript engine).')
     @CommandArgument('--valgrind', action='store_true', help='Run jit-test suite with valgrind flag')
 
     def run_checkspidermonkey(self, **params):
         import subprocess
         import sys
 
-        bin_suffix = ''
-        if sys.platform.startswith('win'):
-            bin_suffix = '.exe'
-
-        js = os.path.join(self.bindir, 'js%s' % bin_suffix)
+        js = os.path.join(self.bindir, executable_name('js'))
 
         print('Running jit-tests')
         jittest_cmd = [os.path.join(self.topsrcdir, 'js', 'src', 'jit-test', 'jit_test.py'),
               js, '--no-slow', '--jitflags=all']
         if params['valgrind']:
             jittest_cmd.append('--valgrind')
 
         jittest_result = subprocess.call(jittest_cmd)
 
         print('running jstests')
         jstest_cmd = [os.path.join(self.topsrcdir, 'js', 'src', 'tests', 'jstests.py'),
               js, '--jitflags=all']
         jstest_result = subprocess.call(jstest_cmd)
 
         print('running jsapi-tests')
-        jsapi_tests_cmd = [os.path.join(self.bindir, 'jsapi-tests%s' % bin_suffix)]
+        jsapi_tests_cmd = [os.path.join(self.bindir, executable_name('jsapi-tests'))]
         jsapi_tests_result = subprocess.call(jsapi_tests_cmd)
 
         print('running check-style')
         check_style_cmd = [sys.executable, os.path.join(self.topsrcdir, 'config', 'check_spidermonkey_style.py')]
         check_style_result = subprocess.call(check_style_cmd, cwd=os.path.join(self.topsrcdir, 'js', 'src'))
 
         all_passed = jittest_result and jstest_result and jsapi_tests_result and check_style_result
 
         return all_passed
+
+@CommandProvider
+class JsapiTestsCommand(MachCommandBase):
+    @Command('jsapi-tests', category='testing', description='Run jsapi tests (JavaScript engine).')
+    @CommandArgument('test_name', nargs='?', metavar='N',
+        help='Test to run. Can be a prefix or omitted. If omitted, the entire ' \
+             'test suite is executed.')
+
+    def run_jsapitests(self, **params):
+        import subprocess
+
+        bin_suffix = ''
+        if sys.platform.startswith('win'):
+            bin_suffix = '.exe'
+
+        print('running jsapi-tests')
+        jsapi_tests_cmd = [os.path.join(self.bindir, executable_name('jsapi-tests'))]
+        if params['test_name']:
+            jsapi_tests_cmd.append(params['test_name'])
+
+        jsapi_tests_result = subprocess.call(jsapi_tests_cmd)
+
+        return jsapi_tests_result
--- a/toolkit/components/places/nsPlacesMacros.h
+++ b/toolkit/components/places/nsPlacesMacros.h
@@ -41,17 +41,17 @@
       _sInstance = nullptr;                                                    \
       return nullptr;                                                          \
     }                                                                          \
     return ret.forget();                                                       \
   }
 
 #define PLACES_WARN_DEPRECATED()                                               \
   PR_BEGIN_MACRO                                                               \
-  nsCString msg = NS_LITERAL_CSTRING(__FUNCTION__);                            \
+  nsCString msg(__FUNCTION__);                                                 \
   msg.AppendLiteral(" is deprecated and will be removed in the next version.");\
   NS_WARNING(msg.get());                                                       \
   nsCOMPtr<nsIConsoleService> cs = do_GetService(NS_CONSOLESERVICE_CONTRACTID);\
   if (cs) {                                                                    \
     nsCOMPtr<nsIScriptError> e = do_CreateInstance(NS_SCRIPTERROR_CONTRACTID); \
     if (e && NS_SUCCEEDED(e->Init(NS_ConvertUTF8toUTF16(msg), EmptyString(),   \
                                   EmptyString(), 0, 0,                         \
                                   nsIScriptError::errorFlag, "Places"))) {     \
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -79,20 +79,18 @@ using namespace mozilla::HangMonitor;
 
 using base::BooleanHistogram;
 using base::CountHistogram;
 using base::FlagHistogram;
 using base::Histogram;
 using base::LinearHistogram;
 using base::StatisticsRecorder;
 
-const char KEYED_HISTOGRAM_NAME_SEPARATOR[] = "#";
-#if !defined(MOZ_WIDGET_GONK) && !defined(MOZ_WIDGET_ANDROID)
-const char SUBSESSION_HISTOGRAM_PREFIX[] = "sub#";
-#endif
+#define KEYED_HISTOGRAM_NAME_SEPARATOR "#"
+#define SUBSESSION_HISTOGRAM_PREFIX "sub#"
 
 enum reflectStatus {
   REFLECT_OK,
   REFLECT_CORRUPT,
   REFLECT_FAILURE
 };
 
 nsresult
@@ -866,17 +864,17 @@ IsExpired(const char *expiration){
 bool
 IsExpired(const Histogram *histogram){
   return histogram->histogram_name() == EXPIRED_ID;
 }
 
 bool
 IsValidHistogramName(const nsACString& name)
 {
-  return !FindInReadable(nsCString(KEYED_HISTOGRAM_NAME_SEPARATOR), name);
+  return !FindInReadable(NS_LITERAL_CSTRING(KEYED_HISTOGRAM_NAME_SEPARATOR), name);
 }
 
 bool
 IsInDataset(uint32_t dataset, uint32_t containingDataset)
 {
   if (dataset == containingDataset) {
     return true;
   }
@@ -4143,21 +4141,21 @@ KeyedHistogram::GetHistogram(const nsCSt
   if (entry) {
     *histogram = entry->mData;
     return NS_OK;
   }
 
   nsCString histogramName;
 #if !defined(MOZ_WIDGET_GONK) && !defined(MOZ_WIDGET_ANDROID)
   if (subsession) {
-    histogramName.Append(SUBSESSION_HISTOGRAM_PREFIX);
+    histogramName.AppendLiteral(SUBSESSION_HISTOGRAM_PREFIX);
   }
 #endif
   histogramName.Append(mName);
-  histogramName.Append(KEYED_HISTOGRAM_NAME_SEPARATOR);
+  histogramName.AppendLiteral(KEYED_HISTOGRAM_NAME_SEPARATOR);
   histogramName.Append(key);
 
   Histogram* h;
   nsresult rv = HistogramGet(histogramName.get(), mExpiration.get(),
                              mHistogramType, mMin, mMax, mBucketCount,
                              true, &h);
   if (NS_FAILED(rv)) {
     return rv;
--- a/toolkit/content/browser-child.js
+++ b/toolkit/content/browser-child.js
@@ -142,16 +142,25 @@ let WebProgressListener = {
 
     if (aWebProgress && aWebProgress.isTopLevel) {
       json.documentURI = content.document.documentURIObject.spec;
       json.title = content.document.title;
       json.charset = content.document.characterSet;
       json.mayEnableCharacterEncodingMenu = docShell.mayEnableCharacterEncodingMenu;
       json.principal = content.document.nodePrincipal;
       json.synthetic = content.document.mozSyntheticDocument;
+
+      if (AppConstants.MOZ_CRASHREPORTER && CrashReporter.enabled) {
+        let uri = aLocationURI.clone();
+        try {
+          // If the current URI contains a username/password, remove it.
+          uri.userPass = "";
+        } catch (ex) { /* Ignore failures on about: URIs. */ }
+        CrashReporter.annotateCrashReport("URL", uri.spec);
+      }
     }
 
     this._send("Content:LocationChange", json, objects);
   },
 
   onStatusChange: function onStatusChange(aWebProgress, aRequest, aStatus, aMessage) {
     let json = this._setupJSON(aWebProgress, aRequest);
     let objects = this._setupObjects(aWebProgress, aRequest);
@@ -256,18 +265,27 @@ let WebNavigation =  {
       this.webNavigation.goForward();
   },
 
   gotoIndex: function(index) {
     this.webNavigation.gotoIndex(index);
   },
 
   loadURI: function(uri, flags, referrer, referrerPolicy, baseURI) {
-    if (AppConstants.MOZ_CRASHREPORTER && CrashReporter.enabled)
-      CrashReporter.annotateCrashReport("URL", uri);
+    if (AppConstants.MOZ_CRASHREPORTER && CrashReporter.enabled) {
+      let annotation = uri;
+      try {
+        let url = Services.io.newURI(uri, null, null);
+        // If the current URI contains a username/password, remove it.
+        url.userPass = "";
+        annotation = url.spec;
+      } catch (ex) { /* Ignore failures to parse and failures
+                      on about: URIs. */ }
+      CrashReporter.annotateCrashReport("URL", annotation);
+    }
     if (referrer)
       referrer = Services.io.newURI(referrer, null, null);
     if (baseURI)
       baseURI = Services.io.newURI(baseURI, null, null);
     this.webNavigation.loadURIWithOptions(uri, flags, referrer, referrerPolicy,
                                           null, null, baseURI);
   },
 
--- a/toolkit/content/tests/browser/browser.ini
+++ b/toolkit/content/tests/browser/browser.ini
@@ -26,8 +26,13 @@ support-files =
 [browser_keyevents_during_autoscrolling.js]
 skip-if = e10s # Bug 921935 - focusmanager issues with e10s
 [browser_save_resend_postdata.js]
 support-files =
   common/mockTransfer.js
   data/post_form_inner.sjs
   data/post_form_outer.sjs
 skip-if = e10s # Bug ?????? - test directly manipulates content (gBrowser.contentDocument.getElementById("postForm").submit();)
+[browser_content_url_annotation.js]
+skip-if = !e10s || !crashreporter
+support-files =
+  file_redirect.html
+  file_redirect_to.html
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/browser/browser_content_url_annotation.js
@@ -0,0 +1,139 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+/*global Services, requestLongerTimeout, TestUtils, BrowserTestUtils,
+ ok, info, dump, is, Ci, Cu, Components, ctypes, privateNoteIntentionalCrash,
+ gBrowser, add_task, addEventListener, removeEventListener, ContentTask */
+
+"use strict";
+
+// Running this test in ASAN is slow.
+requestLongerTimeout(2);
+
+/**
+ * Returns a Promise that resolves once a remote <xul:browser> has experienced
+ * a crash. Resolves with the data from the .extra file (the crash annotations).
+ *
+ * @param browser
+ *        The <xul:browser> that will crash
+ * @return Promise
+ */
+function crashBrowser(browser) {
+  let kv = {};
+  Cu.import("resource://gre/modules/KeyValueParser.jsm", kv);
+  // This frame script is injected into the remote browser, and used to
+  // intentionally crash the tab. We crash by using js-ctypes and dereferencing
+  // a bad pointer. The crash should happen immediately upon loading this
+  // frame script.
+  let frame_script = () => {
+    const Cu = Components.utils;
+    Cu.import("resource://gre/modules/ctypes.jsm");
+
+    let dies = function() {
+      privateNoteIntentionalCrash();
+      let zero = new ctypes.intptr_t(8);
+      let badptr = ctypes.cast(zero, ctypes.PointerType(ctypes.int32_t));
+      let crash = badptr.contents;
+    };
+
+    dump("Et tu, Brute?");
+    dies();
+  };
+
+  function checkSubject(subject, data) {
+    return subject instanceof Ci.nsIPropertyBag2 &&
+      subject.hasKey("abnormal");
+  };
+  let crashPromise = TestUtils.topicObserved('ipc:content-shutdown',
+                                             checkSubject);
+  let crashDataPromise = crashPromise.then(([subject, data]) => {
+    ok(subject instanceof Ci.nsIPropertyBag2);
+
+    let dumpID;
+    if ('nsICrashReporter' in Ci) {
+      dumpID = subject.getPropertyAsAString('dumpID');
+      ok(dumpID, "dumpID is present and not an empty string");
+    }
+
+    let extra = null;
+    if (dumpID) {
+      let minidumpDirectory = getMinidumpDirectory();
+      let extrafile = minidumpDirectory.clone();
+      extrafile.append(dumpID + '.extra');
+      ok(extrafile.exists(), 'found .extra file');
+      extra = kv.parseKeyValuePairsFromFile(extrafile);
+      removeFile(minidumpDirectory, dumpID + '.dmp');
+      removeFile(minidumpDirectory, dumpID + '.extra');
+    }
+
+    return extra;
+  });
+
+  // This frame script will crash the remote browser as soon as it is
+  // evaluated.
+  let mm = browser.messageManager;
+  mm.loadFrameScript("data:,(" + frame_script.toString() + ")();", false);
+  return crashDataPromise;
+}
+
+/**
+ * Removes a file from a directory. This is a no-op if the file does not
+ * exist.
+ *
+ * @param directory
+ *        The nsIFile representing the directory to remove from.
+ * @param filename
+ *        A string for the file to remove from the directory.
+ */
+function removeFile(directory, filename) {
+  let file = directory.clone();
+  file.append(filename);
+  if (file.exists()) {
+    file.remove(false);
+  }
+}
+
+/**
+ * Returns the directory where crash dumps are stored.
+ *
+ * @return nsIFile
+ */
+function getMinidumpDirectory() {
+  let dir = Services.dirsvc.get('ProfD', Ci.nsIFile);
+  dir.append("minidumps");
+  return dir;
+}
+
+/**
+ * Checks that the URL is correctly annotated on a content process crash.
+ */
+add_task(function* test_content_url_annotation() {
+  let url = "https://example.com/browser/toolkit/content/tests/browser/file_redirect.html";
+  let redirect_url = "https://example.com/browser/toolkit/content/tests/browser/file_redirect_to.html";
+
+  yield BrowserTestUtils.withNewTab({
+    gBrowser: gBrowser
+  }, function* (browser) {
+    ok(browser.isRemoteBrowser, "Should be a remote browser");
+
+    // file_redirect.html should send us to file_redirect_to.html
+    let promise = ContentTask.spawn(browser, {}, function* () {
+      dump('ContentTask starting...\n');
+      yield new Promise((resolve) => {
+        addEventListener("RedirectDone", function listener() {
+          dump('Got RedirectDone\n');
+          removeEventListener("RedirectDone", listener);
+          resolve();
+        }, true, true);
+      });
+    });
+    browser.loadURI(url);
+    yield promise;
+
+    // Crash the tab
+    let annotations = yield crashBrowser(browser);
+
+    ok("URL" in annotations, "annotated a URL");
+    is(annotations.URL, redirect_url,
+       "Should have annotated the URL after redirect");
+  });
+});
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/browser/file_redirect.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>redirecting...</title>
+<script>
+window.addEventListener("load",
+  () => window.location = "file_redirect_to.html");
+</script>
+<body>
+redirectin u bro
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/browser/file_redirect_to.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>redirected!</title>
+<script>
+window.addEventListener("load", () => {
+  var event = new Event("RedirectDone");
+  document.dispatchEvent(event);
+});
+</script>
+<body>
+u got redirected, bro
+</body>
+</html>
--- a/toolkit/xre/nsUpdateDriver.cpp
+++ b/toolkit/xre/nsUpdateDriver.cpp
@@ -77,26 +77,26 @@ GetUpdateLog()
   static PRLogModuleInfo *sUpdateLog;
   if (!sUpdateLog)
     sUpdateLog = PR_NewLogModule("updatedriver");
   return sUpdateLog;
 }
 #define LOG(args) PR_LOG(GetUpdateLog(), PR_LOG_DEBUG, args)
 
 #ifdef XP_WIN
-static const char kUpdaterBin[] = "updater.exe";
+#define UPDATER_BIN "updater.exe"
 #else
-static const char kUpdaterBin[] = "updater";
+#define UPDATER_BIN "updater"
 #endif
-static const char kUpdaterINI[] = "updater.ini";
+#define UPDATER_INI "updater.ini"
 #ifdef XP_MACOSX
-static const char kUpdaterApp[] = "updater.app";
+#define UPDATER_APP "updater.app"
 #endif
 #if defined(XP_UNIX) && !defined(XP_MACOSX)
-static const char kUpdaterPNG[] = "updater.png";
+#define UPDATER_PNG "updater.png"
 #endif
 
 #if defined(MOZ_WIDGET_GONK)
 #include <linux/ioprio.h>
 
 static const int kB2GServiceArgc = 2;
 static const char *kB2GServiceArgv[] = { "/system/bin/start", "b2g" };
 
@@ -325,19 +325,18 @@ IsOlderVersion(nsIFile *versionFile, con
 
   if (mozilla::Version(appVersion) > buf)
     return true;
 
   return false;
 }
 
 static bool
-CopyFileIntoUpdateDir(nsIFile *parentDir, const char *leafName, nsIFile *updateDir)
+CopyFileIntoUpdateDir(nsIFile *parentDir, const nsACString& leaf, nsIFile *updateDir)
 {
-  nsDependentCString leaf(leafName);
   nsCOMPtr<nsIFile> file;
 
   // Make sure there is not an existing file in the target location.
   nsresult rv = updateDir->Clone(getter_AddRefs(file));
   if (NS_FAILED(rv))
     return false;
   rv = file->AppendNative(leaf);
   if (NS_FAILED(rv))
@@ -359,46 +358,46 @@ CopyFileIntoUpdateDir(nsIFile *parentDir
 }
 
 static bool
 CopyUpdaterIntoUpdateDir(nsIFile *greDir, nsIFile *appDir, nsIFile *updateDir,
                          nsCOMPtr<nsIFile> &updater)
 {
   // Copy the updater application from the GRE and the updater ini from the app
 #if defined(XP_MACOSX)
-  if (!CopyFileIntoUpdateDir(appDir, kUpdaterApp, updateDir))
+  if (!CopyFileIntoUpdateDir(appDir, NS_LITERAL_CSTRING(UPDATER_APP), updateDir))
     return false;
-  CopyFileIntoUpdateDir(greDir, kUpdaterINI, updateDir);
+  CopyFileIntoUpdateDir(greDir, NS_LITERAL_CSTRING(UPDATER_INI), updateDir);
 #else
-  if (!CopyFileIntoUpdateDir(greDir, kUpdaterBin, updateDir))
+  if (!CopyFileIntoUpdateDir(greDir, NS_LITERAL_CSTRING(UPDATER_BIN), updateDir))
     return false;
-  CopyFileIntoUpdateDir(appDir, kUpdaterINI, updateDir);
+  CopyFileIntoUpdateDir(appDir, NS_LITERAL_CSTRING(UPDATER_INI), updateDir);
 #endif
 #if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(ANDROID)
   nsCOMPtr<nsIFile> iconDir;
   appDir->Clone(getter_AddRefs(iconDir));
   iconDir->AppendNative(NS_LITERAL_CSTRING("icons"));
-  if (!CopyFileIntoUpdateDir(iconDir, kUpdaterPNG, updateDir))
+  if (!CopyFileIntoUpdateDir(iconDir, NS_LITERAL_CSTRING(UPDATER_PNG), updateDir))
     return false;
 #endif
   // Finally, return the location of the updater binary.
   nsresult rv = updateDir->Clone(getter_AddRefs(updater));
   if (NS_FAILED(rv))
     return false;
 #if defined(XP_MACOSX)
-  rv  = updater->AppendNative(NS_LITERAL_CSTRING(kUpdaterApp));
+  rv  = updater->AppendNative(NS_LITERAL_CSTRING(UPDATER_APP));
   nsresult tmp = updater->AppendNative(NS_LITERAL_CSTRING("Contents"));
   if (NS_FAILED(tmp)) {
     rv = tmp;
   }
   tmp = updater->AppendNative(NS_LITERAL_CSTRING("MacOS"));
   if (NS_FAILED(tmp) || NS_FAILED(rv))
     return false;
 #endif
-  rv = updater->AppendNative(NS_LITERAL_CSTRING(kUpdaterBin));
+  rv = updater->AppendNative(NS_LITERAL_CSTRING(UPDATER_BIN));
   return NS_SUCCEEDED(rv); 
 }
 
 /**
  * Appends the specified path to the library path.
  * This is used so that updater can find libmozsqlite3.so and other shared libs.
  *
  * @param pathToAppend A new library path to prepend to LD_LIBRARY_PATH
@@ -496,18 +495,17 @@ SwitchToUpdatedApp(nsIFile *greDir, nsIF
   NS_ConvertUTF16toUTF8 appFilePath(appFilePathW);
 
   nsCOMPtr<nsIFile> updater;
   rv = greDir->Clone(getter_AddRefs(updater));
   if (NS_FAILED(rv)) {
     return;
   }
 
-  nsDependentCString leaf(kUpdaterBin);
-  rv = updater->AppendNative(leaf);
+  rv = updater->AppendNative(NS_LITERAL_CSTRING(UPDATER_BIN));
   if (NS_FAILED(rv)) {
     return;
   }
 
   nsAutoString updaterPathW;
   rv = updater->GetPath(updaterPathW);
   if (NS_FAILED(rv)) {
     return;
@@ -765,18 +763,17 @@ ApplyUpdate(nsIFile *greDir, nsIFile *up
   NS_ConvertUTF16toUTF8 appFilePath(appFilePathW);
 
   nsCOMPtr<nsIFile> updater;
   rv = greDir->Clone(getter_AddRefs(updater));
   if (NS_FAILED(rv)) {
     return;
   }
 
-  nsDependentCString leaf(kUpdaterBin);
-  rv = updater->AppendNative(leaf);
+  rv = updater->AppendNative(NS_LITERAL_CSTRING(UPDATER_BIN));
   if (NS_FAILED(rv)) {
     return;
   }
 
   nsAutoString updaterPathW;
   rv = updater->GetPath(updaterPathW);
   if (NS_FAILED(rv)) {
     return;
--- a/widget/windows/nsIMM32Handler.cpp
+++ b/widget/windows/nsIMM32Handler.cpp
@@ -244,17 +244,17 @@ nsIMM32Handler::IsVerticalWritingSupport
 nsIMM32Handler::InitKeyboardLayout(nsWindow* aWindow,
                                    HKL aKeyboardLayout)
 {
   UINT IMENameLength = ::ImmGetDescriptionW(aKeyboardLayout, nullptr, 0);
   if (IMENameLength) {
     // Add room for the terminating null character
     sIMEName.SetLength(++IMENameLength);
     IMENameLength =
-      ::ImmGetDescriptionW(aKeyboardLayout, sIMEName.BeginWriting(),
+      ::ImmGetDescriptionW(aKeyboardLayout, wwc(sIMEName.BeginWriting()),
                            IMENameLength);
     // Adjust the length to ignore the terminating null character
     sIMEName.SetLength(IMENameLength);
   } else {
     sIMEName.Truncate();
   }
 
   WORD langID = LOWORD(aKeyboardLayout);
--- a/xpcom/io/nsIFile.idl
+++ b/xpcom/io/nsIFile.idl
@@ -37,17 +37,17 @@ interface nsISimpleEnumerator;
  * All methods with string parameters have two forms.  The preferred
  * form operates on UCS-2 encoded characters strings.  An alternate
  * form operates on characters strings encoded in the "native" charset.
  *
  * A string containing characters encoded in the native charset cannot
  * be safely passed to javascript via xpconnect.  Therefore, the "native
  * methods" are not scriptable.
  */
-[scriptable, main_process_scriptable_only, uuid(7441fb13-4d9f-42fd-836f-a165692938af), builtinclass]
+[scriptable, main_process_scriptable_only, uuid(890b802d-3522-4887-a892-3dab31df30d9), builtinclass]
 interface nsIFile : nsISupports
 {
     /**
      *  Create Types
      *
      *  NORMAL_FILE_TYPE - A normal file.
      *  DIRECTORY_TYPE   - A directory/folder.
      */
@@ -184,16 +184,17 @@ interface nsIFile : nsISupports
      *  renameTo
      *
      *  This method is identical to moveTo except that if this file or directory
      *  is moved to a a different volume, it fails and returns an error
      *  (NS_ERROR_FILE_ACCESS_DENIED).
      *  This object will still point to the old location after renaming.
      */
     void renameTo(in nsIFile newParentDir, in AString newName);
+    [noscript] void renameToNative(in nsIFile newParentDir, in ACString newName);
 
     /**
      *  This will try to delete this file.  The 'recursive' flag
      *  must be PR_TRUE to delete directories which are not empty.
      *
      *  This will not resolve any symlinks.
      */
     void remove(in boolean recursive);
--- a/xpcom/io/nsLocalFileUnix.cpp
+++ b/xpcom/io/nsLocalFileUnix.cpp
@@ -2149,29 +2149,30 @@ nsresult
 nsLocalFile::MoveTo(nsIFile* aNewParentDir, const nsAString& aNewName)
 {
   SET_UCS_2ARGS_2(MoveToNative, aNewParentDir, aNewName);
 }
 
 NS_IMETHODIMP
 nsLocalFile::RenameTo(nsIFile* aNewParentDir, const nsAString& aNewName)
 {
+  SET_UCS_2ARGS_2(RenameToNative, aNewParentDir, aNewName);
+}
+
+NS_IMETHODIMP
+nsLocalFile::RenameToNative(nsIFile* aNewParentDir, const nsACString& aNewName)
+{
   nsresult rv;
 
   // check to make sure that this has been initialized properly
   CHECK_mPath();
 
   // check to make sure that we have a new parent
   nsAutoCString newPathName;
-  nsAutoCString newNativeName;
-  rv = NS_CopyUnicodeToNative(aNewName, newNativeName);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  rv = GetNativeTargetPathName(aNewParentDir, newNativeName, newPathName);
+  rv = GetNativeTargetPathName(aNewParentDir, aNewName, newPathName);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   // try for atomic rename
   if (rename(mPath.get(), newPathName.get()) < 0) {
 #ifdef VMS
     if (errno == EXDEV || errno == ENXIO) {
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -2264,16 +2264,28 @@ nsLocalFile::RenameTo(nsIFile* aNewParen
   if (!aNewParentDir) {
     options |= SkipNtfsAclReset;
   }
   // Move single file, or move a directory
   return CopySingleFile(this, targetParentDir, aNewName, options);
 }
 
 NS_IMETHODIMP
+nsLocalFile::RenameToNative(nsIFile* aNewParentDir, const nsACString& aNewName)
+{
+  nsAutoString tmp;
+  nsresult rv = NS_CopyNativeToUnicode(aNewName, tmp);
+  if (NS_SUCCEEDED(rv)) {
+    return RenameTo(aNewParentDir, tmp);
+  }
+
+  return rv;
+}
+
+NS_IMETHODIMP
 nsLocalFile::Load(PRLibrary** aResult)
 {
   // Check we are correctly initialized.
   CHECK_mWorkingPath();
 
   bool isFile;
   nsresult rv = IsFile(&isFile);
 
--- a/xpcom/string/nsLiteralString.h
+++ b/xpcom/string/nsLiteralString.h
@@ -25,13 +25,13 @@
 #define NS_MULTILINE_LITERAL_STRING(s)            static_cast<const nsLiteralString&>(nsLiteralString(s))
 #define NS_MULTILINE_LITERAL_STRING_INIT(n,s)     n(s)
 #define NS_NAMED_MULTILINE_LITERAL_STRING(n,s)    const nsLiteralString n(s)
 
 #define NS_LITERAL_STRING(s)                      static_cast<const nsLiteralString&>(nsLiteralString(MOZ_UTF16(s)))
 #define NS_LITERAL_STRING_INIT(n,s)               n(MOZ_UTF16(s))
 #define NS_NAMED_LITERAL_STRING(n,s)              const nsLiteralString n(MOZ_UTF16(s))
 
-#define NS_LITERAL_CSTRING(s)                     static_cast<const nsLiteralCString&>(nsLiteralCString(s))
-#define NS_LITERAL_CSTRING_INIT(n,s)              n(s)
-#define NS_NAMED_LITERAL_CSTRING(n,s)             const nsLiteralCString n(s)
+#define NS_LITERAL_CSTRING(s)                     static_cast<const nsLiteralCString&>(nsLiteralCString("" s))
+#define NS_LITERAL_CSTRING_INIT(n,s)              n("" s)
+#define NS_NAMED_LITERAL_CSTRING(n,s)             const nsLiteralCString n("" s)
 
 #endif /* !defined(nsLiteralString_h___) */
--- a/xpfe/components/windowds/nsWindowDataSource.cpp
+++ b/xpfe/components/windowds/nsWindowDataSource.cpp
@@ -24,33 +24,32 @@ uint32_t nsWindowDataSource::windowCount
 nsIRDFResource* nsWindowDataSource::kNC_Name = nullptr;
 nsIRDFResource* nsWindowDataSource::kNC_WindowRoot = nullptr;
 nsIRDFResource* nsWindowDataSource::kNC_KeyIndex = nullptr;
 
 nsIRDFService*  nsWindowDataSource::gRDFService = nullptr;
 
 uint32_t nsWindowDataSource::gRefCnt = 0;
 
-static const char kURINC_WindowRoot[] = "NC:WindowMediatorRoot";
-
-DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Name);
-DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, KeyIndex);
+#define URINC_WINDOWROOT "NC:WindowMediatorRoot"
+#define URINC_NAME       NC_NAMESPACE_URI "Name"
+#define URINC_KEYINDEX   NC_NAMESPACE_URI "KeyIndex"
 
 nsresult
 nsWindowDataSource::Init()
 {
     nsresult rv;
 
     if (gRefCnt++ == 0) {
         rv = CallGetService("@mozilla.org/rdf/rdf-service;1", &gRDFService);
         if (NS_FAILED(rv)) return rv;
 
-        gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_WindowRoot), &kNC_WindowRoot);
-        gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_Name),       &kNC_Name);
-        gRDFService->GetResource(NS_LITERAL_CSTRING(kURINC_KeyIndex),   &kNC_KeyIndex);
+        gRDFService->GetResource(NS_LITERAL_CSTRING(URINC_WINDOWROOT), &kNC_WindowRoot);
+        gRDFService->GetResource(NS_LITERAL_CSTRING(URINC_NAME),       &kNC_Name);
+        gRDFService->GetResource(NS_LITERAL_CSTRING(URINC_KEYINDEX),   &kNC_KeyIndex);
     }
 
     mInner = do_CreateInstance("@mozilla.org/rdf/datasource;1?name=in-memory-datasource", &rv);
     if (NS_FAILED(rv)) return rv;
 
     nsCOMPtr<nsIRDFContainerUtils> rdfc =
         do_GetService("@mozilla.org/rdf/container-utils;1", &rv);
     if (NS_FAILED(rv)) return rv;