summaryrefslogtreecommitdiffstats
path: root/dom/animation/test/mozilla/test_disabled_properties.html
blob: 2244143cebe9c8d82355e29b6cd477e203fbf999 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!doctype html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';

function waitForSetPref(pref, value) {
  return SpecialPowers.pushPrefEnv({ 'set': [[pref, value]] });
}

/*
 * These tests rely on the fact that the overflow-clip-box property is
 * disabled by the layout.css.overflow-clip-box.enabled pref. If we ever remove
 * that pref we will need to substitute some other pref:property combination.
 */

promise_test(function(t) {
  return waitForSetPref('layout.css.overflow-clip-box.enabled', true).then(() => {
    var anim = addDiv(t).animate({ overflowClipBoxBlock: [ 'padding-box', 'content-box' ]});
    assert_equals(anim.effect.getKeyframes().length, 2,
                  'A property-indexed keyframe specifying only enabled'
                  + ' properties produces keyframes');
    return waitForSetPref('layout.css.overflow-clip-box.enabled', false);
  }).then(() => {
    var anim = addDiv(t).animate({ overflowClipBoxBlock: [ 'padding-box', 'content-box' ]});
    assert_equals(anim.effect.getKeyframes().length, 0,
                  'A property-indexed keyframe specifying only disabled'
                  + ' properties produces no keyframes');
  });
}, 'Specifying a disabled property using a property-indexed keyframe');

promise_test(function(t) {
  var createAnim = () => {
    var anim = addDiv(t).animate([ { overflowClipBoxBlock: 'padding-box' },
                                   { overflowClipBoxBlock: 'content-box' } ]);
    assert_equals(anim.effect.getKeyframes().length, 2,
                  'Animation specified using a keyframe sequence should'
                  + ' return the same number of keyframes regardless of'
                  + ' whether or not the specified properties are disabled');
    return anim;
  };

  var assert_has_property = (anim, index, descr, property) => {
    assert_true(
      anim.effect.getKeyframes()[index].hasOwnProperty(property),
      `${descr} should have the '${property}' property`);
  };
  var assert_does_not_have_property = (anim, index, descr, property) => {
    assert_false(
      anim.effect.getKeyframes()[index].hasOwnProperty(property),
      `${descr} should NOT have the '${property}' property`);
  };

  return waitForSetPref('layout.css.overflow-clip-box.enabled', true).then(() => {
    var anim = createAnim();
    assert_has_property(anim, 0, 'Initial keyframe', 'overflowClipBoxBlock');
    assert_has_property(anim, 1, 'Final keyframe', 'overflowClipBoxBlock');
    return waitForSetPref('layout.css.overflow-clip-box.enabled', false);
  }).then(() => {
    var anim = createAnim();
    assert_does_not_have_property(anim, 0, 'Initial keyframe',
                                  'overflowClipBoxBlock');
    assert_does_not_have_property(anim, 1, 'Final keyframe',
                                  'overflowClipBoxBlock');
  });
}, 'Specifying a disabled property using a keyframe sequence');

</script>
</body>