Bug 1548305. Fix incorrect Maybe<JSAutoRealm> use in Element::Animate. r=jandem
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 02 May 2019 07:14:35 +0000
changeset 531049 cee3233dc4f3741e294c2b3026391e0561eb3aa8
parent 531048 1f1bcf9c471dc10ef3df04c56aa4814cf34c1c1d
child 531050 1376a67f22b4d4d28c712bd74217644fbd5fb040
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1548305
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1548305. Fix incorrect Maybe<JSAutoRealm> use in Element::Animate. r=jandem We just want to enter the Realm unconditionally. Also, we can get the global from our GlobalObject. Differential Revision: https://phabricator.services.mozilla.com/D29580
dom/base/Element.cpp
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -3447,21 +3447,17 @@ already_AddRefed<Animation> Element::Ani
   RefPtr<KeyframeEffect> effect = KeyframeEffect::Constructor(
       global, aTarget, aKeyframes, aOptions, aError);
   if (aError.Failed()) {
     return nullptr;
   }
 
   // Animation constructor follows the standard Xray calling convention and
   // needs to be called in the target element's realm.
-  Maybe<JSAutoRealm> ar;
-  if (js::GetContextCompartment(aContext) !=
-      js::GetObjectCompartment(ownerGlobal->GetGlobalJSObject())) {
-    ar.emplace(aContext, ownerGlobal->GetGlobalJSObject());
-  }
+  JSAutoRealm ar(aContext, global.Get());
 
   AnimationTimeline* timeline = referenceElement->OwnerDoc()->Timeline();
   RefPtr<Animation> animation = Animation::Constructor(
       global, effect, Optional<AnimationTimeline*>(timeline), aError);
   if (aError.Failed()) {
     return nullptr;
   }