Attachment #516740: patch for bug #633845

View | Details | Raw Unified | Return to bug 633845 | Differences between
and this patch

Collapse All | Expand All

(-)a/dom/base/nsJSEnvironment.cpp (-6 / +16 lines)
Line     Link Here 
 Lines 1247-1262   nsJSContext::EvaluateStringWithValue(con Link Here 
1247
                                                   jsprin,
1247
                                                   jsprin,
1248
                                                   (jschar*)PromiseFlatString(aScript).get(),
1248
                                                   (jschar*)PromiseFlatString(aScript).get(),
1249
                                                   aScript.Length(),
1249
                                                   aScript.Length(),
1250
                                                   aURL,
1250
                                                   aURL,
1251
                                                   aLineNo,
1251
                                                   aLineNo,
1252
                                                   &val,
1252
                                                   &val,
1253
                                                   JSVersion(aVersion));
1253
                                                   JSVersion(aVersion));
1254
1254
1255
    JS_MaybeGC(mContext);
1256
1255
    --mExecuteDepth;
1257
    --mExecuteDepth;
1256
1258
1257
    if (!ok) {
1259
    if (!ok) {
1258
      // Tell XPConnect about any pending exceptions. This is needed
1260
      // Tell XPConnect about any pending exceptions. This is needed
1259
      // to avoid dropping JS exceptions in case we got here through
1261
      // to avoid dropping JS exceptions in case we got here through
1260
      // nested calls through XPConnect.
1262
      // nested calls through XPConnect.
1261
1263
1262
      ReportPendingException();
1264
      ReportPendingException();
 Lines 1454-1469   nsJSContext::EvaluateString(const nsAStr Link Here 
1454
                                                   jsprin,
1456
                                                   jsprin,
1455
                                                   (jschar*)PromiseFlatString(aScript).get(),
1457
                                                   (jschar*)PromiseFlatString(aScript).get(),
1456
                                                   aScript.Length(),
1458
                                                   aScript.Length(),
1457
                                                   aURL,
1459
                                                   aURL,
1458
                                                   aLineNo,
1460
                                                   aLineNo,
1459
                                                   vp,
1461
                                                   vp,
1460
                                                   JSVersion(aVersion));
1462
                                                   JSVersion(aVersion));
1461
1463
1464
    JS_MaybeGC(mContext);
1465
1462
    if (!ok) {
1466
    if (!ok) {
1463
      // Tell XPConnect about any pending exceptions. This is needed
1467
      // Tell XPConnect about any pending exceptions. This is needed
1464
      // to avoid dropping JS exceptions in case we got here through
1468
      // to avoid dropping JS exceptions in case we got here through
1465
      // nested calls through XPConnect.
1469
      // nested calls through XPConnect.
1466
1470
1467
      ReportPendingException();
1471
      ReportPendingException();
1468
    }
1472
    }
1469
  }
1473
  }
 Lines 1616-1636   nsJSContext::ExecuteScript(void *aScript Link Here 
1616
  rv = sSecurityManager->GetObjectPrincipal(mContext, scriptObj, getter_AddRefs(principal));
1620
  rv = sSecurityManager->GetObjectPrincipal(mContext, scriptObj, getter_AddRefs(principal));
1617
  NS_ENSURE_SUCCESS(rv, rv);
1621
  NS_ENSURE_SUCCESS(rv, rv);
1618
1622
1619
  rv = sSecurityManager->PushContextPrincipal(mContext, nsnull, principal);
1623
  rv = sSecurityManager->PushContextPrincipal(mContext, nsnull, principal);
1620
  NS_ENSURE_SUCCESS(rv, rv);
1624
  NS_ENSURE_SUCCESS(rv, rv);
1621
1625
1622
  nsJSContext::TerminationFuncHolder holder(this);
1626
  nsJSContext::TerminationFuncHolder holder(this);
1623
  JSAutoRequest ar(mContext);
1627
  JSAutoRequest ar(mContext);
1628
  JSAutoEnterCompartment ac;
1629
  if (!(ok = ac.enter(mContext, (JSObject *)aScopeObject)))
1630
    rv = NS_ERROR_FAILURE;
1631
1624
  ++mExecuteDepth;
1632
  ++mExecuteDepth;
1625
  ok = ::JS_ExecuteScript(mContext,
1633
  ok = ok && ::JS_ExecuteScript(mContext,
1626
                          (JSObject *)aScopeObject,
1634
                                (JSObject *)aScopeObject,
1627
                          (JSScript*)::JS_GetPrivate(mContext, scriptObj),
1635
                                (JSScript*)::JS_GetPrivate(mContext, scriptObj),
1628
                          &val);
1636
                                &val);
1637
1638
  JS_MaybeGC(mContext);
1629
1639
1630
  if (ok) {
1640
  if (ok) {
1631
    // If all went well, convert val to a string (XXXbe unless undefined?).
1641
    // If all went well, convert val to a string (XXXbe unless undefined?).
1632
    rv = JSValueToAString(mContext, val, aRetValue, aIsUndefined);
1642
    rv = JSValueToAString(mContext, val, aRetValue, aIsUndefined);
1633
  } else {
1643
  } else {
1634
    if (aIsUndefined) {
1644
    if (aIsUndefined) {
1635
      *aIsUndefined = PR_TRUE;
1645
      *aIsUndefined = PR_TRUE;
1636
    }
1646
    }
 Lines 1909-1924   nsJSContext::CallEventHandler(nsISupport Link Here 
1909
                                 &argv, poolRelease, tvr);
1919
                                 &argv, poolRelease, tvr);
1910
    NS_ENSURE_SUCCESS(rv, rv);
1920
    NS_ENSURE_SUCCESS(rv, rv);
1911
1921
1912
    ++mExecuteDepth;
1922
    ++mExecuteDepth;
1913
    PRBool ok = ::JS_CallFunctionValue(mContext, target,
1923
    PRBool ok = ::JS_CallFunctionValue(mContext, target,
1914
                                       funval, argc, argv, &rval);
1924
                                       funval, argc, argv, &rval);
1915
    --mExecuteDepth;
1925
    --mExecuteDepth;
1916
1926
1927
    JS_MaybeGC(mContext);
1928
1917
    if (!ok) {
1929
    if (!ok) {
1918
      // Tell XPConnect about any pending exceptions. This is needed
1930
      // Tell XPConnect about any pending exceptions. This is needed
1919
      // to avoid dropping JS exceptions in case we got here through
1931
      // to avoid dropping JS exceptions in case we got here through
1920
      // nested calls through XPConnect.
1932
      // nested calls through XPConnect.
1921
1933
1922
      ReportPendingException();
1934
      ReportPendingException();
1923
1935
1924
      // Don't pass back results from failed calls.
1936
      // Don't pass back results from failed calls.
 Lines 3168-3185   nsJSContext::ScriptEvaluated(PRBool aTer Link Here 
3168
    for (nsJSContext::TerminationFuncClosure* cur = start;
3180
    for (nsJSContext::TerminationFuncClosure* cur = start;
3169
         cur;
3181
         cur;
3170
         cur = cur->mNext) {
3182
         cur = cur->mNext) {
3171
      (*(cur->mTerminationFunc))(cur->mTerminationFuncArg);
3183
      (*(cur->mTerminationFunc))(cur->mTerminationFuncArg);
3172
    }
3184
    }
3173
    delete start;
3185
    delete start;
3174
  }
3186
  }
3175
3187
3176
  JS_MaybeGC(mContext);
3177
3178
  if (aTerminated) {
3188
  if (aTerminated) {
3179
    mOperationCallbackTime = 0;
3189
    mOperationCallbackTime = 0;
3180
    mModalStateTime = 0;
3190
    mModalStateTime = 0;
3181
  }
3191
  }
3182
}
3192
}
3183
3193
3184
nsresult
3194
nsresult
3185
nsJSContext::SetTerminationFunction(nsScriptTerminationFunc aFunc,
3195
nsJSContext::SetTerminationFunction(nsScriptTerminationFunc aFunc,
(-)a/modules/plugin/base/src/nsJSNPRuntime.cpp (+2 lines)
Line     Link Here 
 Lines 723-738   doInvoke(NPObject *npobj, NPIdentifier m Link Here 
723
      if (newObj) {
723
      if (newObj) {
724
        v = OBJECT_TO_JSVAL(newObj);
724
        v = OBJECT_TO_JSVAL(newObj);
725
        ok = JS_TRUE;
725
        ok = JS_TRUE;
726
      } else {
726
      } else {
727
        ok = JS_FALSE;
727
        ok = JS_FALSE;
728
      }
728
      }
729
    } else {
729
    } else {
730
      ok = ::JS_CallFunctionValue(cx, npjsobj->mJSObj, fv, argCount, jsargs, &v);
730
      ok = ::JS_CallFunctionValue(cx, npjsobj->mJSObj, fv, argCount, jsargs, &v);
731
732
      JS_MaybeGC(cx);
731
    }
733
    }
732
734
733
  }
735
  }
734
736
735
  if (jsargs != jsargs_buf)
737
  if (jsargs != jsargs_buf)
736
    PR_Free(jsargs);
738
    PR_Free(jsargs);
737
739
738
  if (ok)
740
  if (ok)

Return to bug 633845