forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_transitions_per_property.html
1149 lines (1063 loc) · 52.8 KB
/
test_transitions_per_property.html
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=435441
-->
<head>
<title>Test for Bug 435441</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="property_database.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style type="text/css">
#display > p { margin-top: 0; margin-bottom: 0; }
</style>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=435441">Mozilla Bug 435441</a>
<!--
fixed-height container so percentage heights compute to different
(i.e., nonzero) values
fixed-width container so that percentages for margin-top and
margin-bottom are all relative to the same size container (rather than
one that depends on whether we're tall enough to need a scrollbar)
Use a 20px font size and line-height so that percentage line-height
and vertical-align doesn't accumulate rounding error.
-->
<div style="height: 50px; width: 300px; font-size: 20px; line-height: 20px">
<div id="display">
</div>
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 435441 **/
function has_num(str)
{
return !!String(str).match(/^([\d.]+)/);
}
function any_unit_to_num(str)
{
return Number(String(str).match(/^([\d.]+)/)[1]);
}
var supported_properties = {
"border-bottom-left-radius": [ test_radius_transition ],
"border-bottom-right-radius": [ test_radius_transition ],
"border-top-left-radius": [ test_radius_transition ],
"border-top-right-radius": [ test_radius_transition ],
"-moz-box-flex": [ test_float_zeroToOne_transition,
test_float_aboveOne_transition ],
"box-shadow": [ test_shadow_transition ],
"-moz-column-count": [ test_pos_integer_or_auto_transition ],
"-moz-column-gap": [ test_length_transition ],
"-moz-column-rule-color": [ test_color_transition,
test_border_color_transition ],
"-moz-column-rule-width": [ test_length_transition ],
"-moz-column-width": [ test_length_transition ],
"-moz-image-region": [ test_rect_transition ],
"-moz-outline-radius-bottomleft": [ test_radius_transition ],
"-moz-outline-radius-bottomright": [ test_radius_transition ],
"-moz-outline-radius-topleft": [ test_radius_transition ],
"-moz-outline-radius-topright": [ test_radius_transition ],
"-moz-transform": [ test_transform_transition ],
"-moz-transform-origin": [ test_length_pair_transition,
test_length_percent_pair_transition ],
"background-color": [ test_color_transition ],
"background-position": [ test_background_position_transition ],
"background-size": [ test_background_size_transition ],
"border-bottom-color": [ test_color_transition,
test_border_color_transition ],
"border-bottom-width": [ test_length_transition ],
"border-left-color": [ test_color_transition,
test_border_color_transition ],
"border-left-width": [ test_length_transition ],
"border-right-color": [ test_color_transition,
test_border_color_transition ],
"border-right-width": [ test_length_transition ],
"border-spacing": [ test_length_pair_transition ],
"border-top-color": [ test_color_transition,
test_border_color_transition ],
"border-top-width": [ test_length_transition ],
"bottom": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"clip": [ test_rect_transition ],
"color": [ test_color_transition ],
"fill": [ test_color_transition ],
"fill-opacity" : [ test_float_zeroToOne_transition ],
"flood-color": [ test_color_transition ],
"flood-opacity" : [ test_float_zeroToOne_transition ],
"font-size": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"font-size-adjust": [ test_float_zeroToOne_transition,
test_float_aboveOne_transition ],
"font-stretch": [ test_font_stretch ],
"font-weight": [ test_font_weight ],
"height": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"left": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"letter-spacing": [ test_length_transition ],
"lighting-color": [ test_color_transition ],
// NOTE: when calc() is supported on 'line-height', we should add
// test_length_percent_calc_transition.
"line-height": [ test_length_transition, test_percent_transition ],
"margin-bottom": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"margin-left": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"margin-right": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"margin-top": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"marker-offset": [ test_length_transition ],
"max-height": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"max-width": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"min-height": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"min-width": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"opacity" : [ test_float_zeroToOne_transition ],
"outline-color": [ test_color_transition ],
"outline-offset": [ test_length_transition ],
"outline-width": [ test_length_transition ],
"padding-bottom": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"padding-left": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"padding-right": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"padding-top": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"right": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"stop-color": [ test_color_transition ],
"stop-opacity" : [ test_float_zeroToOne_transition ],
"stroke": [ test_color_transition ],
"stroke-dasharray": [ test_dasharray_transition ],
// NOTE: when calc() is supported on 'stroke-dashoffset', we should
// add test_length_percent_calc_transition.
"stroke-dashoffset": [ test_length_transition, test_percent_transition ],
"stroke-miterlimit": [ test_float_aboveOne_transition ],
"stroke-opacity" : [ test_float_zeroToOne_transition ],
// NOTE: when calc() is supported on 'stroke-width', we should add
// test_length_percent_calc_transition.
"stroke-width": [ test_length_transition, test_percent_transition ],
"text-indent": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"text-shadow": [ test_shadow_transition ],
"top": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"vertical-align": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"visibility": [ test_visibility_transition ],
"width": [ test_length_transition, test_percent_transition,
test_length_percent_calc_transition ],
"word-spacing": [ test_length_transition ],
"z-index": [ test_zindex_transition, test_pos_integer_or_auto_transition ],
};
var div = document.getElementById("display");
var cs = getComputedStyle(div, "");
var prop;
for (prop in supported_properties) {
// Test that prop is in the property database.
ok(prop in gCSSProperties, "property " + prop + " in gCSSProperties");
// Test that the entry has at least one test function.
ok(supported_properties[prop].length > 0,
"property " + prop + " must have at least one test function");
}
// Test that transitions don't do anything (i.e., aren't supported) on
// the properties not in our test list above (and not transition
// properties themselves).
for (prop in gCSSProperties) {
var info = gCSSProperties[prop];
if (!(prop in supported_properties) &&
info.type != CSS_TYPE_TRUE_SHORTHAND &&
!prop.match(/^-moz-transition-/) &&
// FIXME (Bug 119078): THIS SHOULD REALLY NOT BE NEEDED!
prop != "-moz-binding") {
if ("prerequisites" in info) {
var prereqs = info.prerequisites;
for (var prereq in prereqs) {
div.style.setProperty(prereq, prereqs[prereq], "");
}
}
var all_values = info.initial_values.concat(info.other_values);
var all_computed = [];
for (var idx in all_values) {
var val = all_values[idx];
div.style.setProperty(prop, val, "");
all_computed.push(cs.getPropertyValue(prop));
}
div.style.removeProperty(prop);
div.style.setProperty("-moz-transition", prop + " 20s linear", "");
for (var i = 0; i < all_values.length; ++i) {
for (var j = i + 1; j < all_values.length; ++j) {
div.style.setProperty(prop, all_values[i], "");
is(cs.getPropertyValue(prop), all_computed[i],
"transitions not supported for property " + prop +
" value " + all_values[i]);
div.style.setProperty(prop, all_values[j], "");
is(cs.getPropertyValue(prop), all_computed[j],
"transitions not supported for property " + prop +
" value " + all_values[j]);
}
}
div.style.removeProperty("-moz-transition");
div.style.removeProperty(prop);
if ("prerequisites" in info) {
var prereqs = info.prerequisites;
for (var prereq in prereqs) {
div.style.removeProperty(prereq);
}
}
}
}
// Do 4-second linear transitions with -1 second transition delay and
// linear timing function so that we can expect the transition to be
// one quarter of the way through the value space right after changing
// the property.
div.style.setProperty("-moz-transition-duration", "4s", "");
div.style.setProperty("-moz-transition-delay", "-1s", "");
div.style.setProperty("-moz-transition-timing-function", "linear", "");
for (prop in supported_properties) {
var tinfo = supported_properties[prop];
var info = gCSSProperties[prop];
isnot(info.type, CSS_TYPE_TRUE_SHORTHAND,
prop + " must not be a shorthand");
if ("prerequisites" in info) {
var prereqs = info.prerequisites;
for (var prereq in prereqs) {
// We don't want the 19px font-size prereq of line-height, since we
// want to leave it 20px.
if (prop != "line-height" || prereq != "font-size") {
div.style.setProperty(prereq, prereqs[prereq], "");
}
}
}
for (var idx in tinfo) {
tinfo[idx](prop);
}
// Make sure to unset the property and stop transitions on it.
div.style.setProperty("-moz-transition-property", "none", "");
div.style.removeProperty(prop);
cs.getPropertyValue(prop);
if ("prerequisites" in info) {
var prereqs = info.prerequisites;
for (var prereq in prereqs) {
div.style.removeProperty(prereq);
}
}
}
div.style.removeProperty("-moz-transition");
function get_distance(prop, v1, v2)
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils);
return utils.computeAnimationDistance(div, prop, v1, v2);
}
function check_distance(prop, start, quarter, end)
{
var sq = get_distance(prop, start, quarter);
var se = get_distance(prop, start, end);
var qe = get_distance(prop, quarter, end);
ok(Math.abs((sq * 4 - se) / se) < 0.0001, "property '" + prop + "': distance " + sq + " from start '" + start + "' to quarter '" + quarter + "' should be quarter distance " + se + " from start '" + start + "' to end '" + end + "'");
ok(Math.abs((qe * 4 - se * 3) / se) < 0.0001, "property '" + prop + "': distance " + qe + " from quarter '" + quarter + "' to end '" + end + "' should be three quarters distance " + se + " from start '" + start + "' to end '" + end + "'");
}
function test_length_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "4px", "");
is(cs.getPropertyValue(prop), "4px",
"length-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "12px", "");
is(cs.getPropertyValue(prop), "6px",
"length-valued property " + prop + ": interpolation of lengths");
check_distance(prop, "4px", "6px", "12px");
}
// Test using float values in the range [0, 1] (e.g. opacity)
function test_float_zeroToOne_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "0.3", "");
is(cs.getPropertyValue(prop), "0.3",
"float-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "0.8", "");
is(cs.getPropertyValue(prop), "0.425",
"float-valued property " + prop + ": interpolation of floats");
check_distance(prop, "0.3", "0.425", "0.8");
}
// Test using float values in the range [1, infinity) (e.g. stroke-miterlimit)
function test_float_aboveOne_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "1", "");
is(cs.getPropertyValue(prop), "1",
"float-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "2.1", "");
is(cs.getPropertyValue(prop), "1.275",
"float-valued property " + prop + ": interpolation of floats");
check_distance(prop, "1", "1.275", "2.1");
}
function test_percent_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "25%", "");
var av = cs.getPropertyValue(prop);
var a = any_unit_to_num(av);
div.style.setProperty(prop, "75%", "");
var bv = cs.getPropertyValue(prop);
var b = any_unit_to_num(bv);
isnot(b, a, "different percentages (" + av + " and " + bv +
") should be different for " + prop);
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "25%", "");
var res = cs.getPropertyValue(prop);
is(any_unit_to_num(res) * 4, 3 * b + a,
"percent-valued property " + prop + ": interpolation of percents: " +
res + " should be a quarter of the way between " + bv + " and " + av);
ok(has_num(res),
"percent-valued property " + prop + ": percent computes to number");
check_distance(prop, "25%", "37.5%", "75%");
}
function test_length_percent_calc_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "0%", "");
var av = cs.getPropertyValue(prop);
var a = any_unit_to_num(av);
div.style.setProperty(prop, "100%", "");
var bv = cs.getPropertyValue(prop);
var b = any_unit_to_num(bv);
div.style.setProperty(prop, "100px", "");
var cv = cs.getPropertyValue(prop);
var c = any_unit_to_num(cv);
isnot(b, a, "different percentages (" + av + " and " + bv +
") should be different for " + prop);
div.style.setProperty(prop, "50%", "");
var v1v = cs.getPropertyValue(prop);
is(any_unit_to_num(v1v) * 2, a + b,
"computed value before transition for " + prop + ": '" +
v1v + "' should be halfway " +
"between '" + av + "' + and '" + bv + "'.");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "200px", "");
var v2v = cs.getPropertyValue(prop);
is(any_unit_to_num(v2v) * 8, 5*a + 3*b + 4*c,
"interpolation between length and percent for " + prop + ": '"
+ v2v + "'");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "-moz-calc(25% + 100px)", "");
v1v = cs.getPropertyValue(prop);
is(any_unit_to_num(v1v) * 4, b + 4*c,
"computed value before transition for " + prop + ": '" + v1v + "'");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "75%", "");
v2v = cs.getPropertyValue(prop);
is(any_unit_to_num(v2v) * 8, 5*a + 3*b + 6*c,
"interpolation between calc() and percent for " + prop + ": '" +
v2v + "'");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "150px", "");
v1v = cs.getPropertyValue(prop);
is(any_unit_to_num(v1v) * 2, c * 3,
"computed value before transition for " + prop + ": '" + v1v + "'");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "-moz-calc(50% + 50px)", "");
v2v = cs.getPropertyValue(prop);
is(any_unit_to_num(v2v) * 8, 7 * a + b + 10*c,
"interpolation between length and calc() for " + prop + ": '" +
v2v + "'");
check_distance(prop, "50%", "-moz-calc(37.5% + 50px)", "200px");
check_distance(prop, "-moz-calc(25% + 100px)", "-moz-calc(37.5% + 75px)",
"75%");
check_distance(prop, "150px", "-moz-calc(125px + 12.5%)",
"-moz-calc(50% + 50px)");
}
function test_color_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "rgb(255, 28, 0)", "");
is(cs.getPropertyValue(prop), "rgb(255, 28, 0)",
"color-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "rgb(75, 84, 128)", "");
is(cs.getPropertyValue(prop), "rgb(210, 42, 32)",
"color-valued property " + prop + ": interpolation of colors");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "rgb(128, 64, 0)", "");
(prop == "color" ? div.parentNode : div).style.
setProperty("color", "rgb(0, 0, 128)", "");
is(cs.getPropertyValue(prop), "rgb(128, 64, 0)",
"color-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "currentColor", "");
is(cs.getPropertyValue(prop), "rgb(96, 48, 32)",
"color-valued property " + prop + ": interpolation of currentColor");
check_distance(prop, "rgb(255, 28, 0)", "rgb(210, 42, 32)",
"rgb(75, 84, 128)");
check_distance(prop, "rgb(128, 64, 0)", "rgb(96, 48, 32)", "currentColor");
(prop == "color" ? div.parentNode : div).style.removeProperty("color");
}
function test_border_color_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "rgb(128, 64, 0)", "");
div.style.setProperty("color", "rgb(0, 0, 128)", "");
is(cs.getPropertyValue(prop), "rgb(128, 64, 0)",
"color-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.removeProperty(prop);
is(cs.getPropertyValue(prop), "rgb(96, 48, 32)",
"color-valued property " + prop + ": interpolation of initial value");
check_distance(prop, "rgb(128, 64, 0)", "rgb(96, 48, 32)", "-moz-initial");
div.style.removeProperty("color");
}
function test_shadow_transition(prop) {
var spreadStr = (prop == "box-shadow") ? " 0px" : "";
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "none", "");
is(cs.getPropertyValue(prop), "none",
"shadow-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "4px 8px 3px red", "");
is(cs.getPropertyValue(prop), "rgba(255, 0, 0, 0.25) 1px 2px 0.75px" + spreadStr,
"shadow-valued property " + prop + ": interpolation of shadows");
check_distance(prop, "none", "rgba(255, 0, 0, 0.25) 1px 2px 0.75px",
"4px 8px 3px red");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "#038000 4px 4px, 2px 2px blue", "");
is(cs.getPropertyValue(prop), "rgb(3, 128, 0) 4px 4px 0px" + spreadStr + ", rgb(0, 0, 255) 2px 2px 0px" + spreadStr,
"shadow-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "8px 8px 8px red", "");
is(cs.getPropertyValue(prop), "rgb(66, 96, 0) 5px 5px 2px" + spreadStr + ", rgba(0, 0, 255, 0.75) 1.5px 1.5px 0px" + spreadStr,
"shadow-valued property " + prop + ": interpolation of shadows");
check_distance(prop, "#038000 4px 4px, 2px 2px blue",
"rgb(66, 96, 0) 5px 5px 2px, rgba(0, 0, 255, 0.75) 1.5px 1.5px 0px",
"8px 8px 8px red");
if (prop == "box-shadow") {
div.style.setProperty(prop, "8px 8px 8px red inset", "");
is(cs.getPropertyValue(prop), "rgb(255, 0, 0) 8px 8px 8px 0px inset",
"shadow-valued property " + prop + ": non-interpolable cases");
div.style.setProperty(prop, "8px 8px 8px 8px red inset", "");
is(cs.getPropertyValue(prop), "rgb(255, 0, 0) 8px 8px 8px 2px inset",
"shadow-valued property " + prop + ": interpolation of spread");
// Leave in same state whether in the |if| or not.
div.style.setProperty(prop, "8px 8px 8px red", "");
is(cs.getPropertyValue(prop), "rgb(255, 0, 0) 8px 8px 8px 0px",
"shadow-valued property " + prop + ": non-interpolable cases");
check_distance(prop, "8px 8px 8px red inset",
"rgb(255, 0, 0) 8px 8px 8px 2px inset",
"8px 8px 8px 8px red inset");
}
var defaultColor = cs.getPropertyValue("color") + " ";
div.style.setProperty(prop, "2px 2px 2px", "");
is(cs.getPropertyValue(prop), defaultColor + "2px 2px 2px" + spreadStr,
"shadow-valued property " + prop + ": non-interpolable cases");
div.style.setProperty(prop, "6px 14px 10px", "");
is(cs.getPropertyValue(prop), defaultColor + "3px 5px 4px" + spreadStr,
"shadow-valued property " + prop + ": interpolation without color");
check_distance(prop, "2px 2px 2px", "3px 5px 4px", "6px 14px 10px");
}
function test_dasharray_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "3", "");
is(cs.getPropertyValue(prop), "3",
"dasharray-valued property " + prop +
": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "15px", "");
is(cs.getPropertyValue(prop), "6",
"dasharray-valued property " + prop + ": interpolation of dasharray");
check_distance(prop, "3", "6", "15px");
div.style.setProperty(prop, "none", "");
is(cs.getPropertyValue(prop), "none",
"dasharray-valued property " + prop + ": non-interpolability of none");
div.style.setProperty(prop, "6,8px,4,4", "");
is(cs.getPropertyValue(prop), "6, 8px, 4, 4",
"dasharray-valued property " + prop +
": computed value before transition");
div.style.setProperty(prop, "14, 12,16,16px", "");
is(cs.getPropertyValue(prop), "8, 9, 7, 7",
"dasharray-valued property " + prop + ": interpolation of dasharray");
check_distance(prop, "6,8px,4,4", "8,9,7,7", "14, 12,16,16px");
div.style.setProperty(prop, "none", "");
is(cs.getPropertyValue(prop), "none",
"dasharray-valued property " + prop + ": non-interpolability of none");
div.style.setProperty(prop, "8,16,4", "");
is(cs.getPropertyValue(prop), "8, 16, 4",
"dasharray-valued property " + prop +
": computed value before transition");
div.style.setProperty(prop, "4,8,12,16", "");
is(cs.getPropertyValue(prop), "7, 14, 6, 10, 13, 5, 9, 16, 4, 8, 15, 7",
"dasharray-valued property " + prop + ": interpolation of dasharray");
check_distance(prop, "8,16,4", "7, 14, 6, 10, 13, 5, 9, 16, 4, 8, 15, 7",
"4,8,12,16");
div.style.setProperty(prop, "2,50%,6,10", "");
is(cs.getPropertyValue(prop), "2, 50%, 6, 10",
"dasharray-valued property " + prop + ": non-interpolability of mixed units");
div.style.setProperty(prop, "6,30%,2,2", "");
is(cs.getPropertyValue(prop), "3, 45%, 5, 8",
"dasharray-valued property " + prop + ": interpolation of dasharray");
check_distance(prop, "2,50%,6,10", "3, 45%, 5, 8", "6,30%,2,2");
}
function test_radius_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
// FIXME: Test a square for now, since we haven't updated to the spec
// for vertical components being relative to the height.
div.style.setProperty("width", "200px", "");
div.style.setProperty("height", "200px", "");
div.style.setProperty("border", "none", "");
div.style.setProperty("padding", "0", "");
div.style.setProperty(prop, "3px", "");
is(cs.getPropertyValue(prop), "3px",
"radius-valued property " + prop +
": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "15px", "");
is(cs.getPropertyValue(prop), "6px",
"radius-valued property " + prop + ": interpolation of radius");
check_distance(prop, "3px", "6px", "15px");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "5%", "");
is(cs.getPropertyValue(prop), "10px",
"radius-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "25%", "");
is(cs.getPropertyValue(prop), "20px",
"radius-valued property " + prop + ": interpolation of radius");
check_distance(prop, "5%", "10%", "25%");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "3px 8px", "");
is(cs.getPropertyValue(prop), "3px 8px",
"radius-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "15px 12px", "");
is(cs.getPropertyValue(prop), "6px 9px",
"radius-valued property " + prop + ": interpolation of radius");
check_distance(prop, "3px 8px", "6px 9px", "15px 12px");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "5% 15%", "");
is(cs.getPropertyValue(prop), "10px 30px",
"radius-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "25%", "");
is(cs.getPropertyValue(prop), "20px 35px",
"radius-valued property " + prop + ": interpolation of radius");
check_distance(prop, "5% 15%", "10% 17.5%", "25%");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "8% 12%", "");
is(cs.getPropertyValue(prop), "16px 24px",
"radius-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "40px 20px", "");
is(cs.getPropertyValue(prop), "22px 23px",
"radius-valued property " + prop + ": interpolation of radius with mixed units");
check_distance(prop, "8% 12%", "-moz-calc(6% + 10px) -moz-calc(5px + 9%)",
"40px 20px");
test_length_percent_calc_transition(prop);
div.style.removeProperty("width");
div.style.removeProperty("height");
div.style.removeProperty("border");
div.style.removeProperty("padding");
}
function test_zindex_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "4", "");
is(cs.getPropertyValue(prop), "4",
"integer-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "-14", "");
is(cs.getPropertyValue(prop), "-1",
"integer-valued property " + prop + ": interpolation of lengths");
check_distance(prop, "6", "1", "-14");
div.style.setProperty(prop, "auto", "");
is(cs.getPropertyValue(prop), "auto",
"integer-valued property " + prop + ": auto not interpolable");
div.style.setProperty(prop, "-4", "");
is(cs.getPropertyValue(prop), "-4",
"integer-valued property " + prop + ": computed value before transition");
div.style.setProperty(prop, "8", "");
is(cs.getPropertyValue(prop), "-1",
"integer-valued property " + prop + ": interpolation of lengths");
check_distance(prop, "-4", "-1", "8");
}
function test_font_stretch(prop) {
is(prop, "font-stretch", "only designed for one property");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "normal", "");
is(cs.getPropertyValue(prop), "normal",
"font-stretch property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "ultra-expanded", "");
is(cs.getPropertyValue(prop), "semi-expanded",
"font-stretch property " + prop + ": interpolation of font-stretches");
check_distance(prop, "normal", "semi-expanded", "ultra-expanded");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "expanded", "");
is(cs.getPropertyValue(prop), "expanded",
"font-stretch property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "extra-condensed", "");
is(cs.getPropertyValue(prop), "normal",
"font-stretch property " + prop + ": interpolation of font-stretches");
check_distance(prop, "expanded", "semi-expanded", "condensed");
}
function test_font_weight(prop) {
is(prop, "font-weight", "only designed for one property");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "normal", "");
is(cs.getPropertyValue(prop), "400",
"font-weight property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "900", "");
is(cs.getPropertyValue(prop), "500",
"font-weight property " + prop + ": interpolation of font-weights");
check_distance(prop, "400", "500", "800");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "900", "");
is(cs.getPropertyValue(prop), "900",
"font-weight property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "100", "");
is(cs.getPropertyValue(prop), "700",
"font-weight property " + prop + ": interpolation of font-weights");
check_distance(prop, "900", "700", "100");
}
function test_pos_integer_or_auto_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "4", "");
is(cs.getPropertyValue(prop), "4",
"integer-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "11", "");
is(cs.getPropertyValue(prop), "5",
"integer-valued property " + prop + ": interpolation of lengths");
check_distance(prop, "4", "6", "12");
div.style.setProperty(prop, "auto", "");
is(cs.getPropertyValue(prop), "auto",
"integer-valued property " + prop + ": auto not interpolable");
div.style.setProperty(prop, "8", "");
is(cs.getPropertyValue(prop), "8",
"integer-valued property " + prop + ": computed value before transition");
div.style.setProperty(prop, "4", "");
is(cs.getPropertyValue(prop), "7",
"integer-valued property " + prop + ": interpolation of lengths");
check_distance(prop, "8", "7", "4");
}
function test_length_pair_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "4px 6px", "");
is(cs.getPropertyValue(prop), "4px 6px",
"length-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "12px 10px", "");
is(cs.getPropertyValue(prop), "6px 7px",
"length-valued property " + prop + ": interpolation of lengths");
check_distance(prop, "4px 6px", "6px 7px", "12px 10px");
}
function test_length_percent_pair_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "4px 50%", "");
is(cs.getPropertyValue(prop), "4px 50%",
"length-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "12px 70%", "");
is(cs.getPropertyValue(prop), "6px 55%",
"length-valued property " + prop + ": interpolation of lengths");
check_distance(prop, "4px 50%", "6px 55%", "12px 70%");
}
function test_rect_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "rect(4px, 16px, 12px, 6px)", "");
is(cs.getPropertyValue(prop), "rect(4px, 16px, 12px, 6px)",
"rect-valued property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "rect(0px, 4px, 4px, 2px)", "");
is(cs.getPropertyValue(prop), "rect(3px, 13px, 10px, 5px)",
"rect-valued property " + prop + ": interpolation of rects");
check_distance(prop, "rect(4px, 16px, 12px, 6px)",
"rect(3px, 13px, 10px, 5px)",
"rect(0px, 4px, 4px, 2px)");
if (prop == "clip") {
div.style.setProperty(prop, "rect(0px, 6px, 4px, auto)", "");
is(cs.getPropertyValue(prop), "rect(0px, 6px, 4px, auto)",
"rect-valued property " + prop + ": can't interpolate auto components");
div.style.setProperty(prop, "rect(0px, 6px, 4px, 2px)", "");
}
div.style.setProperty(prop, "auto", "");
is(cs.getPropertyValue(prop), "auto",
"rect-valued property " + prop + ": can't interpolate auto components");
}
function test_visibility_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "visible", "");
is(cs.getPropertyValue(prop), "visible",
"visibility property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "hidden", "");
is(cs.getPropertyValue(prop), "visible",
"visibility property " + prop + ": interpolation of visibility");
isnot(get_distance(prop, "visible", "hidden"), 0,
"distance between visible and hidden should not be zero");
is(get_distance(prop, "visible", "visible"), 0,
"distance between visible and visible should not be zero");
is(get_distance(prop, "hidden", "hidden"), 0,
"distance between hidden and hidden should not be zero");
}
function test_background_size_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "50% 80%", "");
is(cs.getPropertyValue(prop), "50% 80%",
"property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "100% 100%", "");
is(cs.getPropertyValue(prop), "62.5% 85%",
"property " + prop + ": interpolation of percents");
check_distance(prop, "50% 80%", "62.5% 85%", "100% 100%");
div.style.setProperty(prop, "contain", "");
is(cs.getPropertyValue(prop), "contain",
"property " + prop + ": can't interpolate 'contain'");
test_background_position_size_common(prop);
}
function test_background_position_transition(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "center 80%", "");
is(cs.getPropertyValue(prop), "50% 80%",
"property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "bottom right", "");
is(cs.getPropertyValue(prop), "62.5% 85%",
"property " + prop + ": interpolation of percents");
check_distance(prop, "center 80%", "62.5% 85%", "bottom right");
test_background_position_size_common(prop);
}
function test_background_position_size_common(prop) {
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "10px 40px", "");
is(cs.getPropertyValue(prop), "10px 40px",
"property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "50px 0", "");
is(cs.getPropertyValue(prop), "20px 30px",
"property " + prop + ": interpolation of lengths");
check_distance(prop, "10px 40px", "20px 30px", "50px 0");
div.style.setProperty(prop, "10px 40px, 50px 50px, 30px 20px", "");
is(cs.getPropertyValue(prop), "10px 40px, 50px 50px, 30px 20px",
"property " + prop + ": computed value before transition");
div.style.setProperty(prop, "50px 20px, 70px 50px, 30px 40px", "");
is(cs.getPropertyValue(prop), "20px 35px, 55px 50px, 30px 25px",
"property " + prop + ": interpolation of lists of lengths");
check_distance(prop, "10px 40px, 50px 50px, 30px 20px",
"20px 35px, 55px 50px, 30px 25px",
"50px 20px, 70px 50px, 30px 40px");
div.style.setProperty(prop, "10px 40%, 50% 50px, 30% 20%, 5px 10px", "");
is(cs.getPropertyValue(prop), "10px 40%, 50% 50px, 30% 20%, 5px 10px",
"property " + prop + ": computed value before transition");
div.style.setProperty(prop, "50px 20%, 70% 50px, 30% 40%, 25px 50px", "");
is(cs.getPropertyValue(prop), "20px 35%, 55% 50px, 30% 25%, 10px 20px",
"property " + prop + ": interpolation of lists of lengths and percents");
check_distance(prop, "10px 40%, 50% 50px, 30% 20%, 5px 10px",
"20px 35%, 55% 50px, 30% 25%, 10px 20px",
"50px 20%, 70% 50px, 30% 40%, 25px 50px");
div.style.setProperty(prop, "20% 40%, 8px 12px", "");
is(cs.getPropertyValue(prop), "20% 40%, 8px 12px",
"property " + prop + ": computed value before transition");
div.style.setProperty(prop, "12px 20px, 40% 16%", "");
is(cs.getPropertyValue(prop), "-moz-calc(3px + 15%) -moz-calc(5px + 30%), -moz-calc(6px + 10%) -moz-calc(9px + 4%)",
"property " + prop + ": interpolation that computes to calc()");
check_distance(prop, "20% 40%, 8px 12px",
"-moz-calc(3px + 15%) -moz-calc(5px + 30%), -moz-calc(6px + 10%) -moz-calc(9px + 4%)",
"12px 20px, 40% 16%");
div.style.setProperty(prop, "-moz-calc(20% + 40px) -moz-calc(40px + 40%), 8px 12%, -moz-calc(20px + 12%) -moz-calc(24px + 8%)", "");
is(cs.getPropertyValue(prop), "-moz-calc(40px + 20%) -moz-calc(40px + 40%), 8px 12%, -moz-calc(20px + 12%) -moz-calc(24px + 8%)",
"property " + prop + ": computed value before transition");
div.style.setProperty(prop, "12px 20%, -moz-calc(20%) -moz-calc(16px + 60%), -moz-calc(8px + 20%) -moz-calc(40px + 16%)", "");
is(cs.getPropertyValue(prop), "-moz-calc(33px + 15%) -moz-calc(30px + 35%), -moz-calc(6px + 5%) -moz-calc(4px + 24%), -moz-calc(17px + 14%) -moz-calc(28px + 10%)",
"property " + prop + ": interpolation that computes to calc()");
check_distance(prop, "-moz-calc(20% + 40px) -moz-calc(40px + 40%), 8px 12%, -moz-calc(20px + 12%) -moz-calc(24px + 8%)",
"-moz-calc(33px + 15%) -moz-calc(30px + 35%), -moz-calc(6px + 5%) -moz-calc(4px + 24%), -moz-calc(17px + 14%) -moz-calc(28px + 10%)",
"12px 20%, -moz-calc(20%) -moz-calc(16px + 60%), -moz-calc(8px + 20%) -moz-calc(40px + 16%)");
}
function test_transform_transition(prop) {
function c(v) {
div.style.setProperty(prop, v, "");
var result = cs.getPropertyValue(prop);
div.style.removeProperty(prop);
return result;
}
var c_rot_15 = c("rotate(15deg)");
is(c_rot_15.substring(0,6), "matrix", "should compute to matrix value");
var c_rot_60 = c("rotate(60deg)");
is(c_rot_60.substring(0,6), "matrix", "should compute to matrix value");
var tests = [
// rotate
{ start: 'none', end: 'rotate(60deg)',
expected_uncomputed: 'rotate(15deg)',
expected: c_rot_15 },
{ start: 'rotate(0)', end: 'rotate(60deg)',
expected_uncomputed: 'rotate(15deg)',
expected: c_rot_15 },
{ start: 'rotate(0deg)', end: 'rotate(60deg)',
expected_uncomputed: 'rotate(15deg)',
expected: c_rot_15 },
{ start: 'none', end: c_rot_60,
expected: c_rot_15 },
{ start: 'none', end: 'rotate(360deg)',
expected_uncomputed: 'rotate(90deg)',
expected: c('rotate(90deg)') },
{ start: 'none', end: 'rotate(720deg)',
expected_uncomputed: 'rotate(180deg)',
expected: c('rotate(180deg)') },
{ start: 'none', end: 'rotate(1080deg)',
expected_uncomputed: 'rotate(270deg)',
expected: c('rotate(270deg)') },
{ start: 'none', end: 'rotate(1440deg)',
expected_uncomputed: 'rotate(360deg)',
expected: c('scale(1)'),
round_error_ok: true },
// translate
{ start: 'translate(20px)', end: 'none',
expected_uncomputed: 'translate(15px)',
expected: 'matrix(1, 0, 0, 1, 15px, 0px)' },
{ start: 'translate(20px, 12px)', end: 'none',
expected_uncomputed: 'translate(15px, 9px)',
expected: 'matrix(1, 0, 0, 1, 15px, 9px)' },
{ start: 'translateX(-20px)', end: 'none',
expected_uncomputed: 'translateX(-15px)',
expected: 'matrix(1, 0, 0, 1, -15px, 0px)' },
{ start: 'translateY(-40px)', end: 'none',
expected_uncomputed: 'translateY(-30px)',
expected: 'matrix(1, 0, 0, 1, 0px, -30px)' },
// percentages are relative to 300px (width) and 50px (height)
// per the prerequisites in property_database.js
{ start: 'translate(20%)', end: 'none',
expected_uncomputed: 'translate(15%)',
expected: 'matrix(1, 0, 0, 1, 45px, 0px)' },
{ start: 'translate(20%, 12%)', end: 'none',
expected_uncomputed: 'translate(15%, 9%)',
expected: 'matrix(1, 0, 0, 1, 45px, 4.5px)' },
{ start: 'translateX(-20%)', end: 'none',
expected_uncomputed: 'translateX(-15%)',
expected: 'matrix(1, 0, 0, 1, -45px, 0px)' },
{ start: 'translateY(-40%)', end: 'none',
expected_uncomputed: 'translateY(-30%)',
expected: 'matrix(1, 0, 0, 1, 0px, -15px)' },
{ start: 'none', end: 'rotate(90deg) translate(20%, 20%) rotate(-90deg)',
expected_uncomputed: 'rotate(22.5deg) translate(5%, 5%) rotate(-22.5deg)' },
{ start: 'none', end: 'rotate(-90deg) translate(20%, 20%) rotate(90deg)',
expected_uncomputed: 'rotate(-22.5deg) translate(5%, 5%) rotate(22.5deg)' },
// test percent translation using matrix decomposition
{ start: 'rotate(45deg) rotate(-45deg)',
end: 'rotate(90deg) translate(20%, 20%) rotate(-90deg)',
expected: 'matrix(1, 0, 0, 1, -2.5px, 15px)' },
{ start: 'rotate(45deg) rotate(-45deg)',
end: 'rotate(-90deg) translate(20%, 20%) rotate(90deg)',
expected: 'matrix(1, 0, 0, 1, 2.5px, -15px)' },
// test calc() in translate
// Note that font-size: is 20px, and that percentages are relative
// to 300px (width) and 50px (height) per the prerequisites in
// property_database.js
{ start: 'translateX(20%)', /* 60px */
end: 'translateX(-moz-calc(10% + 1em))', /* 30px + 20px = 50px */
expected_uncomputed: 'translateX(-moz-calc(17.5% + 0.25em))',
expected: 'matrix(1, 0, 0, 1, 57.5px, 0px)' },
{ start: 'translate(-moz-calc(0.75 * 3em + 1.5 * 10%), -moz-calc(0.5 * 5em + 0.5 * 8%))', /* 90px, 52px */
end: 'rotate(90deg) translateY(20%) rotate(90deg) translateY(-moz-calc(10% + 0.5em)) rotate(180deg)', /* -10px, -15px */
expected: 'matrix(1, 0, 0, 1, 65px, 35.25px)' },
// scale
{ start: 'scale(2)', end: 'none',
expected_uncomputed: 'scale(1.75)',
expected: 'matrix(1.75, 0, 0, 1.75, 0px, 0px)' },
{ start: 'none', end: 'scale(0.4)',
expected_uncomputed: 'scale(0.85)',
expected: 'matrix(0.85, 0, 0, 0.85, 0px, 0px)' },
{ start: 'scale(2)', end: 'scale(-2)',
expected_uncomputed: 'scale(1)',
expected: 'matrix(1, 0, 0, 1, 0px, 0px)' },
{ start: 'scale(2)', end: 'scale(-6)',
expected_uncomputed: 'scale(0)',
expected: 'matrix(0, 0, 0, 0, 0px, 0px)' },
{ start: 'scale(2, 0.4)', end: 'none',
expected_uncomputed: 'scale(1.75, 0.55)',
expected: 'matrix(1.75, 0, 0, 0.55, 0px, 0px)' },
{ start: 'scaleX(3)', end: 'none',
expected_uncomputed: 'scaleX(2.5)',
expected: 'matrix(2.5, 0, 0, 1, 0px, 0px)' },
{ start: 'scaleY(5)', end: 'none',
expected_uncomputed: 'scaleY(4)',
expected: 'matrix(1, 0, 0, 4, 0px, 0px)' },
// skew
{ start: 'skewX(45deg)', end: 'none',
expected_uncomputed: 'skewX(33.75deg)' },
{ start: 'skewY(45deg)', end: 'none',
expected_uncomputed: 'skewY(33.75deg)' },
{ start: 'skew(45deg)', end: 'none',
expected_uncomputed: 'skew(33.75deg)' },
{ start: 'skew(45deg, 45deg)', end: 'none',
expected_uncomputed: 'skew(33.75deg, 33.75deg)' },
{ start: 'skewX(45deg)', end: 'skewX(-45deg)',
expected_uncomputed: 'skewX(22.5deg)' },
{ start: 'skewX(0)', end: 'skewX(-45deg)',
expected_uncomputed: 'skewX(-11.25deg)' },
{ start: 'skewY(45deg)', end: 'skewY(-45deg)',
expected_uncomputed: 'skewY(22.5deg)' },
// matrix : skewX
{ start: 'matrix(1, 0, 3, 1, 0px, 0px)', end: 'none',
force_compute: true,
expected_uncomputed: 'matrix(1, 0, ' + Math.tan(Math.atan(3) * 0.75) + ', 1, 0px, 0px)' },
{ start: 'skewX(0)', end: 'skewX(-45deg) translate(0)',
expected_uncomputed: 'skewX(-11.25deg)' },
// matrix : rotate
{ start: 'rotate(-30deg)', end: 'matrix(0, 1, -1, 0, 0px, 0px)',
expected_uncomputed: 'matrix(1, 0, 0, 1, 0px, 0px)' },
{ start: 'rotate(-30deg) translateX(0)',
end: 'translateX(0) rotate(-90deg)',
expected: c('rotate(-45deg)') },
// matrix decomposition of skewY
{ start: 'skewY(60deg)', end: 'skewY(-60deg) translateX(0)',
expected: c('rotate(30deg) skewX(30deg) scale(2, 0.5)') },
// matrix decomposition
// Four pairs of the same matrix expressed different ways.
{ start: 'matrix(-1, 0, 0, -1, 0pt, 0pt)', /* rotate(180deg) */
end: 'matrix(1, 0, 0, 1, 0, 0)',
expected: c('rotate(135deg)') },
{ start: 'scale(-1)', end: 'none',
expected_uncomputed: 'scale(-0.5)',
expected: 'matrix(-0.5, 0, 0, -0.5, 0px, 0px)' },