summaryrefslogtreecommitdiffstats
path: root/layout/style/test/test_computed_style.html
blob: 0ff8750fd4ea6b79783abe64a16a43390c5cbb99 (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
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
<!DOCTYPE HTML>
<html>
<head>
  <title>Test for miscellaneous computed style issues</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <style id="style"></style>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">

/** Test for miscellaneous computed style issues **/

var frame_container = document.getElementById("display");
var noframe_container = document.getElementById("content");

(function test_bug_595650() {
  // Test handling of horizontal and vertical percentages for border-radius
  // and -moz-outline-radius.
  var p = document.createElement("p");
  p.setAttribute("style", "width: 256px; height: 128px");
  p.style.borderTopLeftRadius = "1.5625%"; /* 1/64 == 4px 2px */
  p.style.borderTopRightRadius = "5px";
  p.style.borderBottomRightRadius = "5px 3px";
  p.style.borderBottomLeftRadius = "1.5625% 3.125%" /* 1/64 1/32 == 4px 4px */
  p.style.MozOutlineRadiusTopleft = "1.5625%"; /* 1/64 == 4px 2px */
  p.style.MozOutlineRadiusTopright = "5px";
  p.style.MozOutlineRadiusBottomright = "5px 3px";
  p.style.MozOutlineRadiusBottomleft = "1.5625% 3.125%" /* 1/64 1/32 == 4px 4px */
  var cs = getComputedStyle(p, "");

  frame_container.appendChild(p);
  is(cs.borderTopLeftRadius, "1.5625%",
     "computed value of % border-radius, with frame");
  is(cs.borderTopRightRadius, "5px",
     "computed value of px border-radius, with frame");
  is(cs.borderBottomRightRadius, "5px 3px",
     "computed value of px border-radius, with frame");
  is(cs.borderBottomLeftRadius, "1.5625% 3.125%",
     "computed value of % border-radius, with frame");
  is(cs.MozOutlineRadiusTopleft, "1.5625%",
     "computed value of % outline-radius, with frame");
  is(cs.MozOutlineRadiusTopright, "5px",
     "computed value of px outline-radius, with frame");
  is(cs.MozOutlineRadiusBottomright, "5px 3px",
     "computed value of px outline-radius, with frame");
  is(cs.MozOutlineRadiusBottomleft, "1.5625% 3.125%",
     "computed value of % outline-radius, with frame");

  noframe_container.appendChild(p);
  is(cs.borderTopLeftRadius, "1.5625%",
     "computed value of % border-radius, without frame");
  is(cs.borderTopRightRadius, "5px",
     "computed value of px border-radius, without frame");
  is(cs.borderBottomRightRadius, "5px 3px",
     "computed value of px border-radius, without frame");
  is(cs.borderBottomLeftRadius, "1.5625% 3.125%",
     "computed value of % border-radius, without frame");
  is(cs.MozOutlineRadiusTopleft, "1.5625%",
     "computed value of % outline-radius, without frame");
  is(cs.MozOutlineRadiusTopright, "5px",
     "computed value of px outline-radius, without frame");
  is(cs.MozOutlineRadiusBottomright, "5px 3px",
     "computed value of px outline-radius, without frame");
  is(cs.MozOutlineRadiusBottomleft, "1.5625% 3.125%",
     "computed value of % outline-radius, without frame");

  p.remove();
})();

(function test_bug_1292447() {
  // Was for bug 595651 which tests that clamping of border-radius
  // is reflected in computed style.
  // For compatibility issue, resolved value is computed value now.
  var p = document.createElement("p");
  p.setAttribute("style", "width: 190px; height: 90px; border: 5px solid;");
  p.style.borderRadius = "1000px";
  var cs = getComputedStyle(p, "");

  frame_container.appendChild(p);
  is(cs.borderTopLeftRadius, "1000px",
     "computed value of clamped border radius (top left)");
  is(cs.borderTopRightRadius, "1000px",
     "computed value of clamped border radius (top right)");
  is(cs.borderBottomRightRadius, "1000px",
     "computed value of clamped border radius (bottom right)");
  is(cs.borderBottomLeftRadius, "1000px",
     "computed value of clamped border radius (bottom left)");

  p.style.overflowY = "scroll";
  is(cs.borderTopLeftRadius, "1000px",
     "computed value of clamped border radius (top left, overflow-y)");
  // Fennec doesn't have scrollbars for overflow:scroll content
  if (p.clientWidth == p.offsetWidth - 10) {
    is(cs.borderTopRightRadius, "1000px",
       "computed value of border radius (top right, overflow-y)");
    is(cs.borderBottomRightRadius, "1000px",
       "computed value of border radius (bottom right, overflow-y)");
  } else {
    is(cs.borderTopRightRadius, "1000px",
       "computed value of clamped border radius (top right, overflow-y)");
    is(cs.borderBottomRightRadius, "1000px",
       "computed value of clamped border radius (bottom right, overflow-y)");
  }
  is(cs.borderBottomLeftRadius, "1000px",
     "computed value of clamped border radius (bottom left, overflow-y)");

  p.style.overflowY = "hidden";
  p.style.overflowX = "scroll";
  is(cs.borderTopLeftRadius, "1000px",
     "computed value of clamped border radius (top left, overflow-x)");
  is(cs.borderTopRightRadius, "1000px",
     "computed value of clamped border radius (top right, overflow-x)");
  // Fennec doesn't have scrollbars for overflow:scroll content
  if (p.clientHeight == p.offsetHeight - 10) {
    is(cs.borderBottomRightRadius, "1000px",
       "computed value of border radius (bottom right, overflow-x)");
    is(cs.borderBottomLeftRadius, "1000px",
       "computed value of  border radius (bottom left, overflow-x)");
  } else {
    is(cs.borderBottomRightRadius, "1000px",
       "computed value of clamped border radius (bottom right, overflow-x)");
    is(cs.borderBottomLeftRadius, "1000px",
       "computed value of clamped border radius (bottom left, overflow-x)");
  }

  p.remove();
})();

(function test_bug_647885_1() {
  // Test that various background-position styles round-trip correctly
  var backgroundPositions = [
    [ "0 0", "0px 0px", "unitless 0" ],
    [ "0px 0px", "0px 0px", "0 with units" ],
    [ "0% 0%", "0% 0%", "0%" ],
    [ "calc(0px) 0", "0px 0px", "0 calc with units x" ],
    [ "0 calc(0px)", "0px 0px", "0 calc with units y" ],
    [ "calc(3px - 3px) 0", "0px 0px", "computed 0 calc with units x" ],
    [ "0 calc(3px - 3px)", "0px 0px", "computed 0 calc with units y" ],
    [ "calc(0%) 0", "0% 0px", "0% calc x"],
    [ "0 calc(0%)", "0px 0%", "0% calc y"],
    [ "calc(3px + 2% - 2%) 0", "calc(0% + 3px) 0px",
      "computed 0% calc x"],
    [ "0 calc(3px + 2% - 2%)", "0px calc(0% + 3px)",
      "computed 0% calc y"],
    [ "calc(3px - 5px) calc(6px - 7px)", "-2px -1px",
      "negative pixel width"],
    [ "", "0% 0%", "initial value" ],
  ];

  var p = document.createElement("p");
  var cs = getComputedStyle(p, "");
  frame_container.appendChild(p);

  for (var i = 0; i < backgroundPositions.length; ++i) {
    var test = backgroundPositions[i];
    p.style.backgroundPosition = test[0];
    is(cs.backgroundPosition, test[1], "computed value of " + test[2] + " background-position");
  }

  p.remove();
})();

(function test_bug_647885_2() {
  // Test that various background-size styles round-trip correctly
  var backgroundSizes = [
    [ "0 0", "0px 0px", "unitless 0" ],
    [ "0px 0px", "0px 0px", "0 with units" ],
    [ "0% 0%", "0% 0%", "0%" ],
    [ "calc(0px) 0", "0px 0px", "0 calc with units horizontal" ],
    [ "0 calc(0px)", "0px 0px", "0 calc with units vertical" ],
    [ "calc(3px - 3px) 0", "0px 0px", "computed 0 calc with units horizontal" ],
    [ "0 calc(3px - 3px)", "0px 0px", "computed 0 calc with units vertical" ],
    [ "calc(0%) 0", "0% 0px", "0% calc horizontal"],
    [ "0 calc(0%)", "0px 0%", "0% calc vertical"],
    [ "calc(3px + 2% - 2%) 0", "calc(0% + 3px) 0px",
                      "computed 0% calc horizontal"],
    [ "0 calc(3px + 2% - 2%)", "0px calc(0% + 3px)",
                      "computed 0% calc vertical"],
    [ "calc(3px - 5px) calc(6px - 9px)", "0px 0px", "negative pixel width" ],
    [ "", "auto", "initial value" ],
  ];

  var p = document.createElement("p");
  var cs = getComputedStyle(p, "");
  frame_container.appendChild(p);

  for (var i = 0; i < backgroundSizes.length; ++i) {
    var test = backgroundSizes[i];
    p.style.backgroundSize = test[0];
    is(cs.backgroundSize, test[1], "computed value of " + test[2] + " background-size");
  }

  p.remove();
})();

(function test_bug_716628() {
  // Test that various gradient styles round-trip correctly
  var backgroundImages = [
    [ "radial-gradient(at 10% bottom, #ffffff, black)",
      "radial-gradient(at 10% 100%, rgb(255, 255, 255), rgb(0, 0, 0))",
      "radial gradient 1" ],
    [ "radial-gradient(#ffffff, black)",
      "radial-gradient(rgb(255, 255, 255), rgb(0, 0, 0))",
      "radial gradient 2" ],
    [ "radial-gradient(farthest-corner, #ffffff, black)",
      "radial-gradient(rgb(255, 255, 255), rgb(0, 0, 0))",
      "radial gradient 3" ],
    [ "linear-gradient(red, blue)",
      "linear-gradient(rgb(255, 0, 0), rgb(0, 0, 255))",
      "linear gradient 1" ],
    [ "linear-gradient(to bottom, red, blue)",
      "linear-gradient(rgb(255, 0, 0), rgb(0, 0, 255))",
      "linear gradient 2" ],
    [ "linear-gradient(to right, red, blue)",
      "linear-gradient(to right, rgb(255, 0, 0), rgb(0, 0, 255))",
      "linear gradient 3" ],
    [ "linear-gradient(-45deg, red, blue)",
      "linear-gradient(-45deg, rgb(255, 0, 0), rgb(0, 0, 255))",
      "linear gradient with angle in degrees" ],
    [ "linear-gradient(-0.125turn, red, blue)",
      "linear-gradient(-45deg, rgb(255, 0, 0), rgb(0, 0, 255))",
      "linear gradient with angle in turns" ],
  ];

  var p = document.createElement("p");
  var cs = getComputedStyle(p, "");
  frame_container.appendChild(p);

  for (var i = 0; i < backgroundImages.length; ++i) {
    var test = backgroundImages[i];
    p.style.backgroundImage = test[0];
    is(cs.backgroundImage, test[1], "computed value of " + test[2] + " background-image");
  }

  p.remove();
})();

(function test_bug_1235015() {
  // "masks" object contains non-initial mask longhand values.
  var emptyMasks = {
    // More then one <mask-reference>, or any mask-image value other then
    // <mask-source>,
    "mask-image": [
      "url(#mask1), url(#mask2)",
      "linear-gradient(red, yellow)",
      "-moz-element(#test)"
    ],
    // any mask-clip value other than "border-box".
    "mask-clip": [
      "content-box", "padding-box", "margin-box", "fill-box", "stroke-box",
      "view-box", "no-clip"
    ],
    // any mask-origin  value other than "border-box".
    "mask-origin": [
      "content-box", "padding-box", "margin-box", "fill-box", "stroke-box",
      "view-box"
    ],
    // any mask-composite value other than "add".
    "mask-composite": [
      "subtract", "intersect", "exclude"
    ],
    // any mask-mode value other than "match-source".
    "mask-mode": [
      "alpha", "luminance"
    ],
    // any mask-position value other then "0%" "top" "left"
    // "center center".
    "mask-position": [
      "0%", "center", "right", "bottom", "50%", "100%"
    ],
    // any mask-repeat value other then "repeat" "repeat repeat".
    "mask-repeat": [
      "repeat-x", "repeat-y", "no-repeat", "space", "round"
    ],
    // any mask-size value other then "auto" "auto auto".
    "mask-size": [
      "10px", "100%", "cover", "contain", "auto 5px"
    ],
  };

  // "masks" object contains initial mask longhand values.
  var nonEmptyMasks = {
    "mask-image": [
      "url(#mask1)", "none"
    ],
    "mask-clip": [
      "border-box"
    ],
    "mask-origin": [
      "border-box"
    ],
    "mask-composite": [
      "add"
    ],
    "mask-mode": [
      "match-source"
    ],
    "mask-position": [
      "0% 0%", "left top"
    ],
    "mask-repeat": [
      "repeat", "repeat repeat"
    ],
    "mask-size": [
      "auto", "auto auto"
    ],
  };

  var p = document.createElement("p");
  var cs = getComputedStyle(p, "");
  frame_container.appendChild(p);

  for (var prop in emptyMasks) {
    var subProp = emptyMasks[prop];
    for (var i = 0; i < subProp.length; i++) {
      p.style.mask = subProp[i];
      is(cs.mask, "", "computed value of " + subProp[i] + " mask");
    }
  }

  for (var prop in nonEmptyMasks) {
    var subProp = nonEmptyMasks[prop];
    for (var i = 0; i < subProp.length; i++) {
      p.style.mask = subProp[i];
      isnot(cs.mask, "", "computed value of " + subProp[i] + " mask");
    }
  }
  p.remove();
})();

(function test_bug_1363349_linear() {
  const specPrefix = "-webkit-gradient(linear, ";
  const specSuffix = ", from(blue), to(lime))";

  const expPrefix = "linear-gradient(";
  const expSuffix = "rgb(0, 0, 255) 0%, rgb(0, 255, 0) 100%)";

  let testcases = [
    [ "calc(5 + 5) top, calc(10 + 10) top",
      "to right",
      "calc(num+num) in position"
    ],
    [ "left calc(25% - 10%), right calc(75% + 10%)",
      "to right bottom",
      "calc(pct+pct) in position "
    ]
  ];

  let p = document.createElement("p");
  let cs = getComputedStyle(p, "");
  frame_container.appendChild(p);

  for (let test of testcases) {
    let specifiedStyle = specPrefix + test[0] + specSuffix;
    let expectedStyle = expPrefix;
    if (test[1] != "") {
      expectedStyle += test[1] + ", ";
    }
    expectedStyle += expSuffix;

    p.style.backgroundImage = specifiedStyle;
    is(cs.backgroundImage, expectedStyle,
       "computed value of -webkit-gradient expression (" + test[2] + ")");
    p.style.backgroundImage = "";
  }

  p.remove();
})();

(function test_bug_1363349_radial() {
  const specPrefix = "-webkit-gradient(radial, ";
  const specSuffix = ", from(blue), to(lime))";

  const expPrefix = "radial-gradient(";
  const expSuffix = "rgb(0, 0, 255) 0%, rgb(0, 255, 0) 100%)";

  let testcases = [
    [ "1 2, 0, 3 4, calc(1 + 5)",
      "6px at 3px 4px",
      "calc(num+num) in radius"
    ],
    [ "1 2, calc(1 + 2), 3 4, calc(1 + 5)",
      "6px at 3px 4px",
      "calc(num+num) in radius"
    ],
    [ "calc(0 + 1) calc(1 + 1), calc(1 + 2), calc(1 + 2) 4, calc(1 + 5)",
      "6px at 3px 4px",
      "calc(num+num) in position and radius"
    ]
  ];

  let p = document.createElement("p");
  let cs = getComputedStyle(p, "");
  frame_container.appendChild(p);

  for (let test of testcases) {
    let specifiedStyle = specPrefix + test[0] + specSuffix;
    let expectedStyle = expPrefix;
    if (test[1] != "") {
      expectedStyle += test[1] + ", ";
    }
    expectedStyle += expSuffix;

    p.style.backgroundImage = specifiedStyle;
    is(cs.backgroundImage, expectedStyle,
       "computed value of -webkit-gradient expression (" + test[2] + ")");
    p.style.backgroundImage = "";
  }

  p.remove();
})();

(function test_bug_1241623() {
  // Test that -webkit-gradient() styles are approximated the way we expect:

  // For compactness, we'll pull out the common prefix & suffix from all of the
  // specified & expected styles, and construct the full expression on the fly:
  const specPrefix = "-webkit-gradient(linear, ";
  const specSuffix = ", from(blue), to(lime))";

  const expPrefix = "linear-gradient(";
  const expSuffix = "rgb(0, 0, 255) 0%, rgb(0, 255, 0) 100%)";

  let testcases = [
    //
    // [ legacyDirection,
    //   modernDirection, // (empty string means use default direction)
    //   descriptionOfTestcase ],

    // If start & end are at same point, we just produce a gradient with
    // the default direction.
    [ "left top, left top",
      "",
      "start & end point are the same" ],
    [ "40 40, 40 40",
      "",
      "start & end point are the same" ],
    [ "center center, center center",
      "",
      "start & end point are the same" ],

    // If start & end use different units in the same coordinate, we generally
    // can't extract a direction (because we can't know whether arbitrary
    // percent values are larger or smaller than arbitrary pixel values). So
    // we produce a gradient in the default direction.
    [ "left top, 30 100%",  // (Note: keywords like "left" are really % vals.)
      "",
      "start & end point have different units" ],
    [ "100% 15, right bottom",
      "",
      "start & end point have different units" ],
    [ "0 0%, 20 20",
      "",
      "start & end point have different units" ],
    [ "0 0, 100% 20",
      "",
      "start & end point have different units" ],
    [ "5% 30, 20 50%",
      "",
      "start & end point have different units" ],
    [ "5% 6%, 20 30",
      "",
      "start & end point have different units" ],

    // Gradient starting/ending somewhere arbitrary in middle:
    [ "center center, right top",
      "to right top",
      "from center to right top" ],
    [ "left top, center center",
      "to right bottom",
      "from left top to center" ],
    [ "10 15, 5 20",
      "to left bottom",
      "from arbitrary point to another point in lower-left direction" ],

    // Gradient using negative coordinates:
    [ "-10 -15, 0 0",
      "to right bottom",
      "from negative point to origin" ],
    [ "-100 10, 20 30",
      "to right bottom",
      "from negative-x point to another point in lower-right direction" ],
    [ "10 -100, 5 10",
      "to left bottom",
      "from negative-y point to another point in lower-left direction" ],

    // Diagonal gradient between sides/corners:
    [ "center top, left center",
      "to left bottom",
      "left/bottom-wards, using edge keywords" ],
    [ "left center, center top",
      "to right top",
      "top/right-wards, using edge keywords" ],
    [ "right center, center top",
      "to left top",
      "top/left-wards, using edge keywords" ],
    [ "right top, center bottom",
      "to left bottom",
      "bottom/left-wards, using edge keywords" ],
    [ "left top, right bottom",
      "to right bottom",
      "bottom/right-wards, using edge keywords" ],
    [ "left bottom, right top",
      "to right top",
      "top/right-wards, using edge keywords" ],
  ];

  let p = document.createElement("p");
  let cs = getComputedStyle(p, "");
  frame_container.appendChild(p);

  for (let test of testcases) {
    let specifiedStyle = specPrefix + test[0] + specSuffix;
    let expectedStyle = expPrefix;
    if (test[1] != "") {
      expectedStyle += test[1] + ", ";
    }
    expectedStyle += expSuffix;

    p.style.backgroundImage = specifiedStyle;
    is(cs.backgroundImage, expectedStyle,
       "computed value of -webkit-gradient expression (" + test[2] + ")");
    p.style.backgroundImage = "";
  }

  p.remove();
})();

(function test_bug_1293164() {

  var p = document.createElement("p");
  var cs = getComputedStyle(p, "");
  frame_container.appendChild(p);

  var docPath = document.URL.substring(0, document.URL.lastIndexOf("/") + 1);

  var localURL = "url(\"#foo\")";
  var nonLocalURL = "url(\"foo.svg#foo\")";
  var resolvedNonLocalURL = "url(\"" + docPath + "foo.svg#foo\")";

  var testStyles = [
    "mask",
    "markerStart",
    "markerMid",
    "markerEnd",
    "clipPath",
    "filter",
    "fill",
    "stroke",
  ];

  for (var prop of testStyles) {
    p.style[prop] = localURL;
    is(cs[prop], localURL, "computed value of " + prop);
    p.style[prop] = nonLocalURL;
    is(cs[prop], resolvedNonLocalURL, "computed value of " + prop);
  }

  p.remove();
})();

(function test_bug_1347164() {
  // Test that computed color values are serialized as "rgb()"
  // IFF they're fully-opaque (and otherwise as "rgba()").
  var color = [
    ["rgba(0, 0, 0, 1)", "rgb(0, 0, 0)"],
    ["rgba(0, 0, 0, 0.5)", "rgba(0, 0, 0, 0.5)"],
    ["hsla(0, 0%, 0%, 1)", "rgb(0, 0, 0)"],
    ["hsla(0, 0%, 0%, 0.5)", "rgba(0, 0, 0, 0.5)"],
  ];

  var css_color_4 = [
    ["rgba(0 0 0 / 1)", "rgb(0, 0, 0)"],
    ["rgba(0 0 0 / 0.1)", "rgba(0, 0, 0, 0.1)"],
    ["rgb(0 0 0 / 1)", "rgb(0, 0, 0)"],
    ["rgb(0 0 0 / 0.2)", "rgba(0, 0, 0, 0.2)"],
    ["hsla(0 0% 0% / 1)", "rgb(0, 0, 0)"],
    ["hsla(0deg 0% 0% / 0.3)", "rgba(0, 0, 0, 0.3)"],
    ["hsl(0 0% 0% / 1)", "rgb(0, 0, 0)"],
    ["hsl(0 0% 0% / 0.4)", "rgba(0, 0, 0, 0.4)"],
  ];

  var p = document.createElement("p");
  var cs = getComputedStyle(p, "");
  frame_container.appendChild(p);

  for (var i = 0; i < color.length; ++i) {
    var test = color[i];
    p.style.color = test[0];
    is(cs.color, test[1], "computed value of " + test[0]);
  }
  for (var i = 0; i < css_color_4.length; ++i) {
    var test = css_color_4[i];
    p.style.color = test[0];
    is(cs.color, test[1], "css-color-4 computed value of " + test[0]);
  }

  p.remove();
})();

(function test_bug_1357117() {
  // Test that vendor-prefixed gradient styles round-trip with the same prefix,
  // or with no prefix.
  var backgroundImages = [
    // [ specified style,
    //   expected computed style,
    //   descriptionOfTestcase ],
    // Linear gradient with legacy-gradient-line (needs prefixed syntax):
    [ "-webkit-linear-gradient(10deg, red, blue)",
      "-webkit-linear-gradient(10deg, rgb(255, 0, 0), rgb(0, 0, 255))",
      "-webkit-linear-gradient with angled legacy-gradient-line" ],

    // Linear gradient with box corner (needs prefixed syntax):
    [ "-webkit-linear-gradient(top left, red, blue)",
      "-webkit-linear-gradient(left top, rgb(255, 0, 0), rgb(0, 0, 255))",
      "-webkit-linear-gradient with box corner" ],

    // Linear gradient with default keyword (should be serialized without keyword):
    [ "-webkit-linear-gradient(top, red, blue)",
      "-webkit-linear-gradient(rgb(255, 0, 0), rgb(0, 0, 255))",
      "-webkit-linear-gradient with legacy default direction keyword" ],

    // Radial gradients (should be serialized using modern unprefixed style):
    [ "-webkit-radial-gradient(contain, red, blue)",
      "-webkit-radial-gradient(closest-side, rgb(255, 0, 0), rgb(0, 0, 255))",
      "-webkit-radial-gradient with legacy 'contain' keyword" ],
  ];

  var p = document.createElement("p");
  var cs = getComputedStyle(p, "");
  frame_container.appendChild(p);

  for (var i = 0; i < backgroundImages.length; ++i) {
    var test = backgroundImages[i];
    p.style.backgroundImage = test[0];
    is(cs.backgroundImage, test[1],
       "computed value of prefixed gradient expression (" + test[2] + ")");
  }

  p.remove();
})();

(function test_bug_1367028() {
  const borderImageSubprops = [
    "border-image-slice",
    "border-image-outset",
    "border-image-width"
  ];
  const rectValues = [
    {
      values: ["5 5 5 5", "5 5 5", "5 5", "5"],
      expected: "5",
      desc: "identical four sides",
    },
    {
      values: ["5 6 5 6", "5 6 5", "5 6"],
      expected: "5 6",
      desc: "identical values on each axis",
    },
    {
      values: ["5 6 7 6", "5 6 7"],
      expected: "5 6 7",
      desc: "identical values on left and right",
    },
    {
      values: ["5 6 5 7"],
      desc: "identical values on top and bottom",
    },
    {
      values: ["5 5 6 6", "5 6 6 5"],
      desc: "identical values on unrelated sides",
    },
    {
      values: ["5 6 7 8"],
      desc: "different values on all sides",
    },
  ];

  let frameContainer = document.getElementById("display");
  let p = document.createElement("p");
  frameContainer.appendChild(p);
  let cs = getComputedStyle(p);

  for (let prop of borderImageSubprops) {
    for (let {values, expected, desc} of rectValues) {
      for (let value of values) {
        p.style.setProperty(prop, value);
        is(cs.getPropertyValue(prop),
           expected ? expected : value, `${desc} for ${prop}`);
        p.style.removeProperty(prop);
      }
    }
  }

  p.remove();
})();

(function test_bug_1378368() {
  // Test that negative results of calc()s in basic-shapes (e.g. polygon()) should
  // not be clamped to 0px.
  var clipPaths = [
    // [ specified style,
    //   expected computed style,
    //   descriptionOfTestcase ],
    // polygon:
    [ "polygon(calc(10px - 20px) 0px, 100px 100px, 0px 100px)",
      "polygon(-10px 0px, 100px 100px, 0px 100px)",
      "polygon with negative calc() coordinates" ],
    // inset:
    [ "inset(calc(10px - 20px))",
      "inset(-10px)",
      "inset with negative calc() coordinates" ],
  ];

  var p = document.createElement("p");
  var cs = getComputedStyle(p, "");
  frame_container.appendChild(p);

  for (let test of clipPaths) {
    p.style.clipPath = test[0];
    is(cs.clipPath, test[1],
       "computed value of clip-path for basic-shapes (" + test[2] + ")");
  }

  p.remove();
})();

(function test_bug_1418433() {
  // Test that the style data read through getComputedStyle is always up-to-date,
  // even for non-displayed elements.

  var d = document.createElement("div");
  d.setAttribute("id", "nonDisplayedDiv");
  var cs = getComputedStyle(d, null);
  noframe_container.appendChild(d);

  // Test for stylesheet change, i.e., added/changed/removed
  var style = document.getElementById("style");
  is(cs.height, "auto",
     "computed value of display none element (before testing)");
  style.textContent = "#nonDisplayedDiv { height: 100px; }";
  is(cs.height, "100px",
     "computed value of display none element (sheet added)");
  style.textContent = "#nonDisplayedDiv { height: 10px; }";
  is(cs.height, "10px",
     "computed value of display none element (sheet changed)");
  style.textContent = "";
  is(cs.height, "auto",
     "computed value of display none element (sheet removed)");

  // Test for rule change, i.e., added/changed/removed
  var styleSheet = style.sheet;
  is(cs.width, "auto",
     "computed value of display none element (before testing)");
  styleSheet.insertRule("#nonDisplayedDiv { width: 100px; }", 0);
  is(cs.width, "100px",
     "computed value of display none element (rule added)");
  styleSheet.deleteRule(0);
  styleSheet.insertRule("#nonDisplayedDiv { width: 10px; }", 0);
  is(cs.width, "10px",
     "computed value of display none element (rule changed)");
  styleSheet.deleteRule(0);
  is(cs.width, "auto",
     "computed value of display none element (rule removed)");

  d.remove();
})();

</script>
</pre>
</body>
</html>