summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/permission-element/bounded-css-properties.tentative.html
blob: c0f0fe34542f4b6e7742a99f725985e14aa1e876 (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
<!DOCTYPE html>
<meta charset=utf-8>
<link rel="help" href="https://github.com/WICG/PEPC/blob/main/explainer.md#locking-the-pepc-style">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<!--The permission element should have some limits for specific properties:
  * font-weight is adjusted to be at least 200.
  * font-style should only have "normal" or "italic" values.
  * word-spacing should be at most 0.5 of the font size, and non-negative.
  * letter-spacing should be between -0.05 and 0.2 of the font size.
-->
<style>
  #id-over-bounds {
    font-weight: 100;
    font-style: oblique 30deg;
    word-spacing: 1em;
    font-size: 100px;
    letter-spacing: 21px;
  }
  #id-under-bounds {
    word-spacing: -1px;
    font-size: 100px;
    letter-spacing: -6px;
  }
  #id-within-bounds {
    font-weight: 300;
    font-style: italic;
    word-spacing: 0.4em;
    font-size: 100px;
    letter-spacing: 15px;
  }
</style>


<permission id="id-over-bounds" type="geolocation">
<permission id="id-under-bounds" type="camera">
<permission id="id-within-bounds" type="microphone">

<script>
  test(function(){
    var el = document.getElementById("id-over-bounds");
    assert_equals(getComputedStyle(el).fontWeight, "200", "font-weight");
    assert_equals(getComputedStyle(el).fontStyle, "normal", "font-style");
    assert_equals(getComputedStyle(el).wordSpacing, "50px", "word-spacing");
    assert_equals(getComputedStyle(el).letterSpacing, "20px", "letter-spacing");

    el = document.getElementById("id-under-bounds");
    assert_equals(getComputedStyle(el).wordSpacing, "0px", "word-spacing, negative");
    assert_equals(getComputedStyle(el).letterSpacing, "-5px", "letter-spacing, negative");
  }, "Properties with out-of-bounds values should be corrected");

  test(function(){
    var el = document.getElementById("id-within-bounds");
    assert_equals(getComputedStyle(el).fontWeight, "300", "font-weight");
    assert_equals(getComputedStyle(el).fontStyle, "italic", "font-style");
    assert_equals(getComputedStyle(el).wordSpacing, "40px", "word-spacing");
    assert_equals(getComputedStyle(el).letterSpacing, "15px", "letter-spacing");

    el.style.letterSpacing = "-4px";
    assert_equals(getComputedStyle(el).letterSpacing, "-4px", "letter-spacing, negative");
  }, "Properties with values in bounds should not be modified");
</script>
</body>