зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1479363 part 1 - Use JSAutoRealm instead of JSAutoRealmAllowCCW in dom/base. r=bz
This commit is contained in:
Родитель
baecd0e884
Коммит
3bbc9aa20d
|
@ -217,7 +217,7 @@ ChromeUtils::ShallowClone(GlobalObject& aGlobal,
|
|||
return;
|
||||
}
|
||||
|
||||
JSAutoRealmAllowCCW ar(cx, obj);
|
||||
JSAutoRealm ar(cx, obj);
|
||||
|
||||
if (!JS_Enumerate(cx, obj, &ids) ||
|
||||
!values.reserve(ids.length())) {
|
||||
|
@ -240,7 +240,7 @@ ChromeUtils::ShallowClone(GlobalObject& aGlobal,
|
|||
|
||||
JS::RootedObject obj(cx);
|
||||
{
|
||||
Maybe<JSAutoRealmAllowCCW> ar;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
if (aTarget) {
|
||||
JS::RootedObject target(cx, js::CheckedUnwrap(aTarget));
|
||||
if (!target) {
|
||||
|
@ -726,7 +726,7 @@ ChromeUtils::CreateError(const GlobalObject& aGlobal, const nsAString& aMessage,
|
|||
uint32_t line = 0;
|
||||
uint32_t column = 0;
|
||||
|
||||
Maybe<JSAutoRealmAllowCCW> ar;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
JS::RootedObject stack(cx);
|
||||
if (aStack) {
|
||||
stack = UncheckedUnwrap(aStack);
|
||||
|
|
|
@ -3744,7 +3744,7 @@ Element::Animate(const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
|||
|
||||
// Animation constructor follows the standard Xray calling convention and
|
||||
// needs to be called in the target element's realm.
|
||||
Maybe<JSAutoRealmAllowCCW> ar;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
if (js::GetContextCompartment(aContext) !=
|
||||
js::GetObjectCompartment(ownerGlobal->GetGlobalJSObject())) {
|
||||
ar.emplace(aContext, ownerGlobal->GetGlobalJSObject());
|
||||
|
|
|
@ -77,7 +77,7 @@ PostMessageEvent::Run()
|
|||
targetWindow->IsDying())
|
||||
return NS_OK;
|
||||
|
||||
JSAutoRealmAllowCCW ar(cx, targetWindow->GetWrapper());
|
||||
JSAutoRealm ar(cx, targetWindow->GetWrapper());
|
||||
|
||||
// Ensure that any origin which might have been provided is the origin of this
|
||||
// window's document. Note that we do this *now* instead of when postMessage
|
||||
|
|
|
@ -38,7 +38,7 @@ StructuredCloneBlob::Constructor(GlobalObject& aGlobal, JS::HandleValue aValue,
|
|||
|
||||
RefPtr<StructuredCloneBlob> holder = StructuredCloneBlob::Create();
|
||||
|
||||
Maybe<JSAutoRealmAllowCCW> ar;
|
||||
Maybe<JSAutoRealm> ar;
|
||||
JS::RootedValue value(cx, aValue);
|
||||
|
||||
if (aTargetGlobal) {
|
||||
|
@ -87,7 +87,7 @@ StructuredCloneBlob::Deserialize(JSContext* aCx, JS::HandleObject aTargetScope,
|
|||
}
|
||||
|
||||
{
|
||||
JSAutoRealmAllowCCW ar(aCx, scope);
|
||||
JSAutoRealm ar(aCx, scope);
|
||||
|
||||
Read(xpc::NativeGlobal(scope), aCx, aResult, aRv);
|
||||
if (aRv.Failed()) {
|
||||
|
|
|
@ -7038,7 +7038,7 @@ nsContentUtils::IsPatternMatching(nsAString& aValue, nsAString& aPattern,
|
|||
|
||||
// We can use the junk scope here, because we're just using it for
|
||||
// regexp evaluation, not actual script execution.
|
||||
JSAutoRealmAllowCCW ar(cx, xpc::UnprivilegedJunkScope());
|
||||
JSAutoRealm ar(cx, xpc::UnprivilegedJunkScope());
|
||||
|
||||
// The pattern has to match the entire value.
|
||||
aPattern.InsertLiteral(u"^(?:", 0);
|
||||
|
|
|
@ -6997,7 +6997,7 @@ nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv)
|
|||
// It's kind of irrelevant, given that we're passing aAllowWrapping =
|
||||
// false, and documents should always insist on being wrapped in an
|
||||
// canonical scope. But we try to pass something sane anyway.
|
||||
JSAutoRealmAllowCCW ar(cx, GetScopeObject()->GetGlobalJSObject());
|
||||
JSAutoRealm ar(cx, GetScopeObject()->GetGlobalJSObject());
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
rv = nsContentUtils::WrapNative(cx, this, this, &v,
|
||||
/* aAllowWrapping = */ false);
|
||||
|
@ -9649,7 +9649,7 @@ nsIDocument::GetStateObject(nsIVariant** aState)
|
|||
NS_ENSURE_TRUE(sgo, NS_ERROR_UNEXPECTED);
|
||||
JS::Rooted<JSObject*> global(cx, sgo->GetGlobalJSObject());
|
||||
NS_ENSURE_TRUE(global, NS_ERROR_UNEXPECTED);
|
||||
JSAutoRealmAllowCCW ar(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
mStateObjectContainer->
|
||||
DeserializeToVariant(cx, getter_AddRefs(mStateObjectCached));
|
||||
|
|
|
@ -1895,7 +1895,7 @@ nsFrameLoader::SetOwnerContent(Element* aContent)
|
|||
|
||||
JS::RootedObject wrapper(jsapi.cx(), GetWrapper());
|
||||
if (wrapper) {
|
||||
JSAutoRealmAllowCCW ar(jsapi.cx(), wrapper);
|
||||
JSAutoRealm ar(jsapi.cx(), wrapper);
|
||||
IgnoredErrorResult rv;
|
||||
ReparentWrapper(jsapi.cx(), wrapper, rv);
|
||||
Unused << NS_WARN_IF(rv.Failed());
|
||||
|
|
|
@ -1001,7 +1001,7 @@ nsFrameMessageManager::GetInitialProcessData(JSContext* aCx,
|
|||
// We create the initial object in the junk scope. If we created it in a
|
||||
// normal realm, that realm would leak until shutdown.
|
||||
JS::RootedObject global(aCx, xpc::PrivilegedJunkScope());
|
||||
JSAutoRealmAllowCCW ar(aCx, global);
|
||||
JSAutoRealm ar(aCx, global);
|
||||
|
||||
JS::RootedObject obj(aCx, JS_NewPlainObject(aCx));
|
||||
if (!obj) {
|
||||
|
|
|
@ -793,7 +793,7 @@ NewOuterWindowProxy(JSContext *cx, JS::Handle<JSObject*> global, bool isChrome)
|
|||
{
|
||||
MOZ_ASSERT(JS_IsGlobalObject(global));
|
||||
|
||||
JSAutoRealmAllowCCW ar(cx, global);
|
||||
JSAutoRealm ar(cx, global);
|
||||
|
||||
js::WrapperOptions options;
|
||||
options.setClass(&OuterWindowProxyClass);
|
||||
|
@ -1513,7 +1513,7 @@ static const JSFunctionSpec EnablePrivilegeSpec[] = {
|
|||
static bool
|
||||
InitializeLegacyNetscapeObject(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
|
||||
{
|
||||
JSAutoRealmAllowCCW ar(aCx, aGlobal);
|
||||
JSAutoRealm ar(aCx, aGlobal);
|
||||
|
||||
// Note: MathJax depends on window.netscape being exposed. See bug 791526.
|
||||
JS::Rooted<JSObject*> obj(aCx);
|
||||
|
@ -1850,7 +1850,7 @@ nsGlobalWindowOuter::SetNewDocument(nsIDocument* aDocument,
|
|||
}
|
||||
|
||||
// Enter the new global's realm.
|
||||
JSAutoRealmAllowCCW ar(cx, GetWrapperPreserveColor());
|
||||
JSAutoRealm ar(cx, GetWrapperPreserveColor());
|
||||
|
||||
{
|
||||
JS::Rooted<JSObject*> outer(cx, GetWrapperPreserveColor());
|
||||
|
@ -1882,7 +1882,7 @@ nsGlobalWindowOuter::SetNewDocument(nsIDocument* aDocument,
|
|||
}
|
||||
}
|
||||
|
||||
JSAutoRealmAllowCCW ar(cx, GetWrapperPreserveColor());
|
||||
JSAutoRealm ar(cx, GetWrapperPreserveColor());
|
||||
|
||||
if (!aState && !reUseInnerWindow) {
|
||||
// Loading a new page and creating a new inner window, *not*
|
||||
|
@ -3778,7 +3778,7 @@ nsGlobalWindowOuter::DispatchResizeEvent(const CSSIntSize& aSize)
|
|||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
JSAutoRealmAllowCCW ar(cx, GetWrapperPreserveColor());
|
||||
JSAutoRealm ar(cx, GetWrapperPreserveColor());
|
||||
|
||||
DOMWindowResizeEventDetail detail;
|
||||
detail.mWidth = aSize.width;
|
||||
|
@ -5570,7 +5570,7 @@ nsGlobalWindowOuter::CallerInnerWindow()
|
|||
// sandboxPrototype. This used to work incidentally for unrelated reasons, but
|
||||
// now we need to do some special handling to support it.
|
||||
if (xpc::IsSandbox(scope)) {
|
||||
JSAutoRealmAllowCCW ar(cx, scope);
|
||||
JSAutoRealm ar(cx, scope);
|
||||
JS::Rooted<JSObject*> scopeProto(cx);
|
||||
bool ok = JS_GetPrototype(cx, scope, &scopeProto);
|
||||
NS_ENSURE_TRUE(ok, nullptr);
|
||||
|
@ -7115,7 +7115,7 @@ nsGlobalWindowOuter::SecurityCheckURL(const char *aURL, nsIURI** aURI)
|
|||
}
|
||||
AutoJSContext cx;
|
||||
nsGlobalWindowInner* sourceWin = nsGlobalWindowInner::Cast(sourceWindow);
|
||||
JSAutoRealmAllowCCW ar(cx, sourceWin->GetGlobalJSObject());
|
||||
JSAutoRealm ar(cx, sourceWin->GetGlobalJSObject());
|
||||
|
||||
// Resolve the baseURI, which could be relative to the calling window.
|
||||
//
|
||||
|
|
|
@ -1296,7 +1296,7 @@ CheckForOutdatedParent(nsINode* aParent, nsINode* aNode, ErrorResult& aError)
|
|||
|
||||
if (JS::GetNonCCWObjectGlobal(existingObj) !=
|
||||
global->GetGlobalJSObject()) {
|
||||
JSAutoRealmAllowCCW ar(cx, existingObj);
|
||||
JSAutoRealm ar(cx, existingObj);
|
||||
ReparentWrapper(cx, existingObj, aError);
|
||||
}
|
||||
}
|
||||
|
@ -1316,7 +1316,7 @@ ReparentWrappersInSubtree(nsIContent* aRoot)
|
|||
JS::Rooted<JSObject*> reflector(cx);
|
||||
for (nsIContent* cur = aRoot; cur; cur = cur->GetNextNode(aRoot)) {
|
||||
if ((reflector = cur->GetWrapper())) {
|
||||
JSAutoRealmAllowCCW ar(cx, reflector);
|
||||
JSAutoRealm ar(cx, reflector);
|
||||
ReparentWrapper(cx, reflector, rv);
|
||||
rv.WouldReportJSException();
|
||||
if (rv.Failed()) {
|
||||
|
|
|
@ -813,7 +813,7 @@ nsJSContext::ConvertSupportsTojsvals(nsISupports* aArgs,
|
|||
NS_ASSERTION(prim == nullptr,
|
||||
"Don't pass nsISupportsPrimitives - use nsIVariant!");
|
||||
#endif
|
||||
JSAutoRealmAllowCCW ar(cx, aScope);
|
||||
JSAutoRealm ar(cx, aScope);
|
||||
rv = nsContentUtils::WrapNative(cx, arg, thisVal);
|
||||
}
|
||||
}
|
||||
|
@ -1004,7 +1004,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
|
|||
|
||||
JS::Rooted<JSObject*> scope(cx, GetWindowProxy());
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
JSAutoRealmAllowCCW ar(cx, scope);
|
||||
JSAutoRealm ar(cx, scope);
|
||||
nsresult rv = nsContentUtils::WrapNative(cx, data, iid, &v);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -1139,7 +1139,7 @@ nsJSContext::InitClasses(JS::Handle<JSObject*> aGlobalObj)
|
|||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
JSAutoRealmAllowCCW ar(cx, aGlobalObj);
|
||||
JSAutoRealm ar(cx, aGlobalObj);
|
||||
|
||||
// Attempt to initialize profiling functions
|
||||
::JS_DefineProfilingFunctions(cx, aGlobalObj);
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
JSContext* mCx;
|
||||
|
||||
// Handles switching to our global's realm.
|
||||
JSAutoRealmAllowCCW mRealm;
|
||||
JSAutoRealm mRealm;
|
||||
|
||||
// Set to a valid handle if a return value is expected.
|
||||
JS::Rooted<JS::Value> mRetValue;
|
||||
|
|
|
@ -562,7 +562,7 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
|
|||
JS::Rooted<JSObject*> wrapper(cx);
|
||||
if ((wrapper = aNode->GetWrapper())) {
|
||||
MOZ_ASSERT(IsDOMObject(wrapper));
|
||||
JSAutoRealmAllowCCW ar(cx, wrapper);
|
||||
JSAutoRealm ar(cx, wrapper);
|
||||
ReparentWrapper(cx, wrapper, aError);
|
||||
if (aError.Failed()) {
|
||||
if (wasRegistered) {
|
||||
|
|
|
@ -3700,7 +3700,7 @@ nsObjectLoadingContent::TeardownProtoChain()
|
|||
MOZ_ASSERT(obj);
|
||||
|
||||
JS::Rooted<JSObject*> proto(cx);
|
||||
JSAutoRealmAllowCCW ar(cx, obj);
|
||||
JSAutoRealm ar(cx, obj);
|
||||
|
||||
// Loop over the DOM element's JS object prototype chain and remove
|
||||
// all JS objects of the class sNPObjectJSWrapperClass
|
||||
|
|
Загрузка…
Ссылка в новой задаче