Backed out changeset 9035e4de3c03 (bug 1117851) for suspicion of causing Linux32 dromaeo DOM regressions (bug 1118257).
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 06 Jan 2015 15:24:45 -0500
changeset 239001 a3a485cf8fda0c97d77882614adbf9bd591fe235
parent 239000 c2f28da3fbb1cad970853b20020bec03ec690c2e
child 239002 577febac37903e41297055eef33e0804151f3ce9
push id7472
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 20:36:27 +0000
treeherdermozilla-aurora@300ca104f8fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1117851, 1118257
milestone37.0a1
backs out9035e4de3c038aadba2a78a3927be5a48fab69ab
Backed out changeset 9035e4de3c03 (bug 1117851) for suspicion of causing Linux32 dromaeo DOM regressions (bug 1118257).
dom/base/EventSource.cpp
dom/base/nsContentUtils.cpp
dom/base/nsJSTimeoutHandler.cpp
dom/base/nsJSUtils.cpp
dom/base/nsJSUtils.h
dom/indexedDB/IDBRequest.cpp
dom/workers/WorkerPrivate.cpp
--- a/dom/base/EventSource.cpp
+++ b/dom/base/EventSource.cpp
@@ -196,17 +196,21 @@ EventSource::Init(nsISupports* aOwner,
   nsCOMPtr<nsIPrincipal> principal = scriptPrincipal->GetPrincipal();
   NS_ENSURE_STATE(principal);
 
   mPrincipal = principal;
   mWithCredentials = aWithCredentials;
 
   // The conditional here is historical and not necessarily sane.
   if (JSContext *cx = nsContentUtils::GetCurrentJSContext()) {
-    nsJSUtils::GetCallingLocation(cx, mScriptFile, &mScriptLine);
+    const char *filename;
+    if (nsJSUtils::GetCallingLocation(cx, &filename, &mScriptLine)) {
+      mScriptFile.AssignASCII(filename);
+    }
+
     mInnerWindowID = nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx);
   }
 
   // Get the load group for the page. When requesting we'll add ourselves to it.
   // This way any pending requests will be automatically aborted if the user
   // leaves the page.
   nsresult rv;
   nsIScriptContext* sc = GetContextForEventHandlers(&rv);
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -3359,17 +3359,22 @@ nsContentUtils::ReportToConsoleNonLocali
     rv = CallGetService(NS_CONSOLESERVICE_CONTRACTID, &sConsoleService);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   nsAutoCString spec;
   if (!aLineNumber) {
     JSContext *cx = GetCurrentJSContext();
     if (cx) {
-      nsJSUtils::GetCallingLocation(cx, spec, &aLineNumber);
+      const char* filename;
+      uint32_t lineno;
+      if (nsJSUtils::GetCallingLocation(cx, &filename, &lineno)) {
+        spec = filename;
+        aLineNumber = lineno;
+      }
     }
   }
   if (spec.IsEmpty() && aURI)
     aURI->GetSpec(spec);
 
   nsCOMPtr<nsIScriptError> errorObject =
       do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/base/nsJSTimeoutHandler.cpp
+++ b/dom/base/nsJSTimeoutHandler.cpp
@@ -168,18 +168,21 @@ CheckCSPForEval(JSContext* aCx, nsGlobal
 
   if (reportViolation) {
     // TODO : need actual script sample in violation report.
     NS_NAMED_LITERAL_STRING(scriptSample,
                             "call to eval() or related function blocked by CSP");
 
     // Get the calling location.
     uint32_t lineNum = 0;
+    const char *fileName;
     nsAutoString fileNameString;
-    if (!nsJSUtils::GetCallingLocation(aCx, fileNameString, &lineNum)) {
+    if (nsJSUtils::GetCallingLocation(aCx, &fileName, &lineNum)) {
+      AppendUTF8toUTF16(fileName, fileNameString);
+    } else {
       fileNameString.AssignLiteral("unknown");
     }
 
     csp->LogViolationDetails(nsIContentSecurityPolicy::VIOLATION_TYPE_EVAL,
                              fileNameString, scriptSample, lineNum,
                              EmptyString(), EmptyString());
   }
 
@@ -225,17 +228,20 @@ nsJSScriptTimeoutHandler::nsJSScriptTime
   }
 
   *aAllowEval = CheckCSPForEval(aCx, aWindow, aError);
   if (aError.Failed() || !*aAllowEval) {
     return;
   }
 
   // Get the calling location.
-  nsJSUtils::GetCallingLocation(aCx, mFileName, &mLineNo);
+  const char *filename;
+  if (nsJSUtils::GetCallingLocation(aCx, &filename, &mLineNo)) {
+    mFileName.Assign(filename);
+  }
 }
 
 nsJSScriptTimeoutHandler::~nsJSScriptTimeoutHandler()
 {
   ReleaseJSObjects();
 }
 
 void
@@ -342,17 +348,20 @@ nsJSScriptTimeoutHandler::Init(nsGlobalW
     if (error.Failed() || !*aAllowEval) {
       return error.ErrorCode();
     }
 
     MOZ_ASSERT(mExpr.IsEmpty());
     AssignJSFlatString(mExpr, expr);
 
     // Get the calling location.
-    nsJSUtils::GetCallingLocation(cx, mFileName, &mLineNo);
+    const char *filename;
+    if (nsJSUtils::GetCallingLocation(cx, &filename, &mLineNo)) {
+      mFileName.Assign(filename);
+    }
   } else if (funobj) {
     *aAllowEval = true;
 
     mozilla::HoldJSObjects(this);
 
     mFunction = new Function(funobj, GetIncumbentGlobal());
 
     // Create our arg array.  argc is the number of arguments passed
--- a/dom/base/nsJSUtils.cpp
+++ b/dom/base/nsJSUtils.cpp
@@ -29,38 +29,29 @@
 
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ScriptSettings.h"
 
 using namespace mozilla::dom;
 
 bool
-nsJSUtils::GetCallingLocation(JSContext* aContext, nsACString& aFilename,
+nsJSUtils::GetCallingLocation(JSContext* aContext, const char* *aFilename,
                               uint32_t* aLineno)
 {
   JS::AutoFilename filename;
-  if (!JS::DescribeScriptedCaller(aContext, &filename, aLineno)) {
+  unsigned lineno = 0;
+
+  if (!JS::DescribeScriptedCaller(aContext, &filename, &lineno)) {
     return false;
   }
 
-  aFilename.Assign(filename.get());
-  return true;
-}
+  *aFilename = filename.get();
+  *aLineno = lineno;
 
-bool
-nsJSUtils::GetCallingLocation(JSContext* aContext, nsAString& aFilename,
-                              uint32_t* aLineno)
-{
-  JS::AutoFilename filename;
-  if (!JS::DescribeScriptedCaller(aContext, &filename, aLineno)) {
-    return false;
-  }
-
-  aFilename.Assign(NS_ConvertUTF8toUTF16(filename.get()));
   return true;
 }
 
 nsIScriptGlobalObject *
 nsJSUtils::GetStaticScriptGlobal(JSObject* aObj)
 {
   if (!aObj)
     return nullptr;
--- a/dom/base/nsJSUtils.h
+++ b/dom/base/nsJSUtils.h
@@ -27,19 +27,17 @@ namespace dom {
 class AutoJSAPI;
 class Element;
 }
 }
 
 class nsJSUtils
 {
 public:
-  static bool GetCallingLocation(JSContext* aContext, nsACString& aFilename,
-                                 uint32_t* aLineno);
-  static bool GetCallingLocation(JSContext* aContext, nsAString& aFilename,
+  static bool GetCallingLocation(JSContext* aContext, const char* *aFilename,
                                  uint32_t* aLineno);
 
   static nsIScriptGlobalObject *GetStaticScriptGlobal(JSObject* aObj);
 
   static nsIScriptContext *GetStaticScriptContext(JSObject* aObj);
 
   /**
    * Retrieve the inner window ID based on the given JSContext.
--- a/dom/indexedDB/IDBRequest.cpp
+++ b/dom/indexedDB/IDBRequest.cpp
@@ -163,17 +163,26 @@ IDBRequest::SetLoggingSerialNumber(uint6
 
 void
 IDBRequest::CaptureCaller(nsAString& aFilename, uint32_t* aLineNo)
 {
   MOZ_ASSERT(aFilename.IsEmpty());
   MOZ_ASSERT(aLineNo);
 
   ThreadsafeAutoJSContext cx;
-  nsJSUtils::GetCallingLocation(cx, aFilename, aLineNo);
+
+  const char* filename = nullptr;
+  uint32_t lineNo = 0;
+  if (!nsJSUtils::GetCallingLocation(cx, &filename, &lineNo)) {
+    *aLineNo = 0;
+    return;
+  }
+
+  aFilename.Assign(NS_ConvertUTF8toUTF16(filename));
+  *aLineNo = lineNo;
 }
 
 void
 IDBRequest::GetSource(
              Nullable<OwningIDBObjectStoreOrIDBIndexOrIDBCursor>& aSource) const
 {
   AssertIsOnOwningThread();
 
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -5697,17 +5697,23 @@ WorkerPrivate::SetTimeout(JSContext* aCx
       extraArgVals.AppendElement(aArguments[index]);
     }
     newInfo->mExtraArgVals.SwapElements(extraArgVals);
   }
 
   newInfo->mTargetTime = TimeStamp::Now() + newInfo->mInterval;
 
   if (!newInfo->mTimeoutString.IsEmpty()) {
-    if (!nsJSUtils::GetCallingLocation(aCx, newInfo->mFilename, &newInfo->mLineNumber)) {
+    const char* filenameChars;
+    uint32_t lineNumber;
+    if (nsJSUtils::GetCallingLocation(aCx, &filenameChars, &lineNumber)) {
+      newInfo->mFilename = filenameChars;
+      newInfo->mLineNumber = lineNumber;
+    }
+    else {
       NS_WARNING("Failed to get calling location!");
     }
   }
 
   nsAutoPtr<TimeoutInfo>* insertedInfo =
     mTimeouts.InsertElementSorted(newInfo.forget(), GetAutoPtrComparator(mTimeouts));
 
   // If the timeout we just made is set to fire next then we need to update the