Backed out changeset c3f16a179c93 (bug 1414674)

This commit is contained in:
Tooru Fujisawa 2018-02-18 01:24:08 +09:00
Родитель 6bd0320c4c
Коммит d70a10cbd8
13 изменённых файлов: 24 добавлений и 215 удалений

Просмотреть файл

@ -1,6 +1,4 @@
[DEFAULT]
prefs =
dom.animations-api.core.enabled=true
support-files =
head.js
head_pageAction.js
@ -212,4 +210,3 @@ tags = fullscreen
skip-if = os == 'mac' # Fails when windows are randomly opened in fullscreen mode
[browser_ext_windows_update.js]
tags = fullscreen
[browser_ext_contentscript_animate.js]

Просмотреть файл

@ -1,95 +0,0 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
add_task(async function test_animate() {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/");
let extension = ExtensionTestUtils.loadExtension({
manifest: {
"content_scripts": [
{
"matches": ["http://mochi.test/*"],
"js": ["content-script.js"],
},
],
},
files: {
"content-script.js": function() {
let elem = document.getElementsByTagName("body")[0];
elem.style.border = "2px solid red";
let anim = elem.animate({opacity: [1, 0]}, 2000);
let frames = anim.effect.getKeyframes();
browser.test.assertEq(frames.length, 2,
"frames for Element.animate should be non-zero");
browser.test.assertEq(frames[0].opacity, "1",
"first frame opacity for Element.animate should be specified value");
browser.test.assertEq(frames[0].computedOffset, 0,
"first frame offset for Element.animate should be 0");
browser.test.assertEq(frames[1].opacity, "0",
"last frame opacity for Element.animate should be specified value");
browser.test.assertEq(frames[1].computedOffset, 1,
"last frame offset for Element.animate should be 1");
browser.test.notifyPass("contentScriptAnimate");
},
},
});
await extension.startup();
await extension.awaitFinish("contentScriptAnimate");
await extension.unload();
await BrowserTestUtils.removeTab(tab);
});
add_task(async function test_KeyframeEffect() {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/");
let extension = ExtensionTestUtils.loadExtension({
manifest: {
"content_scripts": [
{
"matches": ["http://mochi.test/*"],
"js": ["content-script.js"],
},
],
},
files: {
"content-script.js": function() {
let elem = document.getElementsByTagName("body")[0];
elem.style.border = "2px solid red";
let effect = new KeyframeEffect(elem, [
{opacity: 1, offset: 0},
{opacity: 0, offset: 1},
], {duration: 1000, fill: "forwards"});
let frames = effect.getKeyframes();
browser.test.assertEq(frames.length, 2,
"frames for KeyframeEffect ctor should be non-zero");
browser.test.assertEq(frames[0].opacity, "1",
"first frame opacity for KeyframeEffect ctor should be specified value");
browser.test.assertEq(frames[0].computedOffset, 0,
"first frame offset for KeyframeEffect ctor should be 0");
browser.test.assertEq(frames[1].opacity, "0",
"last frame opacity for KeyframeEffect ctor should be specified value");
browser.test.assertEq(frames[1].computedOffset, 1,
"last frame offset for KeyframeEffect ctor should be 1");
let animation = new Animation(effect, document.timeline);
animation.play();
browser.test.notifyPass("contentScriptKeyframeEffect");
},
},
});
await extension.startup();
await extension.awaitFinish("contentScriptKeyframeEffect");
await extension.unload();
await BrowserTestUtils.removeTab(tab);
});

Просмотреть файл

@ -49,16 +49,6 @@ AnimationUtils::GetCurrentRealmDocument(JSContext* aCx)
return win->GetDoc();
}
/* static */ nsIDocument*
AnimationUtils::GetDocumentFromGlobal(JSObject* aGlobalObject)
{
nsGlobalWindowInner* win = xpc::WindowOrNull(aGlobalObject);
if (!win) {
return nullptr;
}
return win->GetDoc();
}
/* static */ bool
AnimationUtils::IsOffscreenThrottlingEnabled()
{

Просмотреть файл

@ -61,14 +61,6 @@ public:
static nsIDocument*
GetCurrentRealmDocument(JSContext* aCx);
/**
* Get the document from the global object, or nullptr if the document has
* no window, to use when constructing DOM object without entering the
* target window's compartment (see KeyframeEffect constructor).
*/
static nsIDocument*
GetDocumentFromGlobal(JSObject* aGlobalObject);
/**
* Checks if offscreen animation throttling is enabled.
*/

Просмотреть файл

@ -903,17 +903,7 @@ KeyframeEffectReadOnly::ConstructKeyframeEffect(
const OptionsType& aOptions,
ErrorResult& aRv)
{
// We should get the document from `aGlobal` instead of the current Realm
// to make this works in Xray case.
//
// In all non-Xray cases, `aGlobal` matches the current Realm, so this
// matches the spec behavior.
//
// In Xray case, the new objects should be created using the document of
// the target global, but KeyframeEffect and KeyframeEffectReadOnly
// constructors are called in the caller's compartment to access
// `aKeyframes` object.
nsIDocument* doc = AnimationUtils::GetDocumentFromGlobal(aGlobal.Get());
nsIDocument* doc = AnimationUtils::GetCurrentRealmDocument(aGlobal.Context());
if (!doc) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;

Просмотреть файл

@ -8,7 +8,6 @@ support-files =
[chrome/test_animate_xrays.html]
# file_animate_xrays.html needs to go in mochitest.ini since it is served
# over HTTP
[chrome/test_keyframe_effect_xrays.html]
[chrome/test_animation_observers_async.html]
[chrome/test_animation_observers_sync.html]
[chrome/test_animation_performance_warning.html]

Просмотреть файл

@ -6,9 +6,10 @@
Element.prototype.animate = function() {
throw 'Called animate() as defined in content document';
}
for (let name of ["KeyframeEffect", "KeyframeEffectReadOnly", "Animation"]) {
this[name] = function() {
throw `Called overridden ${name} constructor`;
// Bug 1211783: Use KeyframeEffect (not KeyframeEffectReadOnly) here
for (var obj of [KeyframeEffectReadOnly, Animation]) {
obj = function() {
throw 'Called overridden ' + String(obj) + ' constructor';
};
}
</script>

Просмотреть файл

@ -6,8 +6,8 @@
<script type="application/javascript" src="../testcommon.js"></script>
</head>
<body>
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1414674"
target="_blank">Mozilla Bug 1414674</a>
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1045994"
target="_blank">Mozilla Bug 1045994</a>
<div id="log"></div>
<iframe id="iframe"
src="http://example.org/tests/dom/animation/test/chrome/file_animate_xrays.html"></iframe>
@ -19,19 +19,10 @@ var win = document.getElementById('iframe').contentWindow;
async_test(function(t) {
window.addEventListener('load', t.step_func(function() {
var target = win.document.getElementById('target');
var anim = target.animate({opacity: [ 1, 0 ]}, 100 * MS_PER_SEC);
// The frames object should be accessible via x-ray.
var frames = anim.effect.getKeyframes();
assert_equals(frames.length, 2,
"frames for Element.animate should be non-zero");
assert_equals(frames[0].opacity, "1",
"first frame opacity for Element.animate should be specified value");
assert_equals(frames[0].computedOffset, 0,
"first frame offset for Element.animate should be 0");
assert_equals(frames[1].opacity, "0",
"last frame opacity for Element.animate should be specified value");
assert_equals(frames[1].computedOffset, 1,
"last frame offset for Element.animate should be 1");
var anim = target.animate({ opacity: [ 0, 1 ] }, 100 * MS_PER_SEC);
// In the x-ray case, the frames object will be given an opaque wrapper
// so it won't be possible to fetch any frames from it.
assert_equals(anim.effect.getKeyframes().length, 0);
t.done();
}));
}, 'Calling animate() across x-rays');

Просмотреть файл

@ -1,45 +0,0 @@
<!doctype html>
<head>
<meta charset=utf-8>
<script type="application/javascript" src="../testharness.js"></script>
<script type="application/javascript" src="../testharnessreport.js"></script>
<script type="application/javascript" src="../testcommon.js"></script>
</head>
<body>
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1414674"
target="_blank">Mozilla Bug 1414674</a>
<div id="log"></div>
<iframe id="iframe"
src="http://example.org/tests/dom/animation/test/chrome/file_animate_xrays.html"></iframe>
<script>
'use strict';
var win = document.getElementById('iframe').contentWindow;
async_test(function(t) {
window.addEventListener('load', t.step_func(function() {
var target = win.document.getElementById('target');
var effect = new win.KeyframeEffect(target, [
{opacity: 1, offset: 0},
{opacity: 0, offset: 1},
], {duration: 100 * MS_PER_SEC, fill: "forwards"});
// The frames object should be accessible via x-ray.
var frames = effect.getKeyframes();
assert_equals(frames.length, 2,
"frames for KeyframeEffect ctor should be non-zero");
assert_equals(frames[0].opacity, "1",
"first frame opacity for KeyframeEffect ctor should be specified value");
assert_equals(frames[0].computedOffset, 0,
"first frame offset for KeyframeEffect ctor should be 0");
assert_equals(frames[1].opacity, "0",
"last frame opacity for KeyframeEffect ctor should be specified value");
assert_equals(frames[1].computedOffset, 1,
"last frame offset for KeyframeEffect ctor should be 1");
var animation = new win.Animation(effect, document.timeline);
animation.play();
t.done();
}));
}, 'Calling KeyframeEffect() ctor across x-rays');
</script>
</body>

Просмотреть файл

@ -3804,23 +3804,22 @@ Element::Animate(const Nullable<ElementOrCSSPseudoElement>& aTarget,
GlobalObject global(aContext, ownerGlobal->GetGlobalJSObject());
MOZ_ASSERT(!global.Failed());
// KeyframeEffect constructor doesn't follow the standard Xray calling
// convention and needs to be called in caller's compartment.
// This should match to RunConstructorInCallerCompartment attribute in
// KeyframeEffect.webidl.
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 compartment.
// Wrap the aKeyframes object for the cross-compartment case.
JS::Rooted<JSObject*> keyframes(aContext);
keyframes = aKeyframes;
Maybe<JSAutoCompartment> ac;
if (js::GetContextCompartment(aContext) !=
js::GetObjectCompartment(ownerGlobal->GetGlobalJSObject())) {
ac.emplace(aContext, ownerGlobal->GetGlobalJSObject());
if (!JS_WrapObject(aContext, &keyframes)) {
return nullptr;
}
}
RefPtr<KeyframeEffect> effect =
KeyframeEffect::Constructor(global, aTarget, keyframes, aOptions, aError);
if (aError.Failed()) {
return nullptr;
}
AnimationTimeline* timeline = referenceElement->OwnerDoc()->Timeline();

Просмотреть файл

@ -7806,10 +7806,7 @@ class CGPerSignatureCall(CGThing):
needsUnwrap = False
argsPost = []
runConstructorInCallerCompartment = \
descriptor.interface.getExtendedAttribute(
'RunConstructorInCallerCompartment')
if isConstructor and not runConstructorInCallerCompartment:
if isConstructor:
needsUnwrap = True
needsUnwrappedVar = False
unwrappedVar = "obj"

Просмотреть файл

@ -1743,7 +1743,6 @@ class IDLInterface(IDLInterfaceOrNamespace):
identifier == "LegacyEventInit" or
identifier == "ProbablyShortLivingWrapper" or
identifier == "LegacyUnenumerableNamedProperties" or
identifier == "RunConstructorInCallerCompartment" or
identifier == "NonOrdinaryGetPrototypeOf"):
# Known extended attributes that do not take values
if not attr.noArguments():

Просмотреть файл

@ -20,10 +20,7 @@ dictionary KeyframeEffectOptions : AnimationEffectTimingProperties {
CompositeOperation composite = "replace";
};
// KeyframeEffectReadOnly should run in the caller's compartment to do custom
// processing on the `keyframes` object.
[Func="nsDocument::IsWebAnimationsEnabled",
RunConstructorInCallerCompartment,
Constructor ((Element or CSSPseudoElement)? target,
object? keyframes,
optional (unrestricted double or KeyframeEffectOptions) options),
@ -57,10 +54,7 @@ partial interface KeyframeEffectReadOnly {
[ChromeOnly, Throws] sequence<AnimationPropertyDetails> getProperties();
};
// KeyframeEffect should run in the caller's compartment to do custom
// processing on the `keyframes` object.
[Func="nsDocument::IsWebAnimationsEnabled",
RunConstructorInCallerCompartment,
Constructor ((Element or CSSPseudoElement)? target,
object? keyframes,
optional (unrestricted double or KeyframeEffectOptions) options),