File: multiple-scopes.html

package info (click to toggle)
firefox 144.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,637,504 kB
  • sloc: cpp: 7,576,692; javascript: 6,430,831; ansic: 3,748,119; python: 1,398,978; xml: 628,810; asm: 438,679; java: 186,194; sh: 63,212; makefile: 19,159; objc: 13,086; perl: 12,986; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (88 lines) | stat: -rw-r--r-- 3,062 bytes parent folder | download | duplicates (10)
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
<!DOCTYPE HTML>
<title>::part() and pseudo-elements from multiple scopes (encapsulation contexts)</title>
<link rel="help" href="https://drafts.csswg.org/css-cascade-4/#cascade-sort">
<link rel="help" href="https://drafts.csswg.org/css-shadow-parts/#part">
<link rel="author" title="L. David Baron" href="https://dbaron.org/">
<link rel="author" title="Google" href="http://www.google.com/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>

::part(e1)::file-selector-button { border-top-width: 7px; }
::part(p1)::file-selector-button { border-top-color: red; }
::file-selector-button { border-top-style: dashed; }

</style>

<body>

<div id="outerhost"></div>

<script>
"use strict";

let target_cs;

test(t => {
  let outer_host = document.getElementById("outerhost");
  let outer_shadow = outer_host.attachShadow({mode: "open"});
  outer_shadow.innerHTML = `
    <style>
      ::part(e1)::file-selector-button { border-right-width: 6px; }
      ::part(p1)::file-selector-button { border-right-color: lime; }
      ::file-selector-button { border-right-style: dotted; }
    </style>
    <div id="innerhost" exportparts="p1:e1"></div>
  `;

  let inner_host = outer_shadow.getElementById("innerhost");
  let inner_shadow = inner_host.attachShadow({mode: "open"});
  inner_shadow.innerHTML = `
    <style>
      ::part(e1)::file-selector-button { border-bottom-width: 5px; }
      ::part(p1)::file-selector-button { border-bottom-color: red; }
      ::file-selector-button { border: 3px double black; }
    </style>
    <input type="file" part="p1" id="target">
  `;
  target_cs = getComputedStyle(inner_shadow.getElementById("target"), "::file-selector-button");
  assert_true(true);
}, "successful test setup");

test(t => {
  assert_equals(target_cs.borderTopWidth, "7px");
}, "exported part selector matches from outer scope");

test(t => {
  assert_equals(target_cs.borderTopColor, "rgb(0, 0, 0)");
}, "non-exported part selector does not match from outer scope");

test(t => {
  assert_equals(target_cs.borderTopStyle, "double");
}, "pseudo-element selector alone does not match from outer scope");

test(t => {
  assert_equals(target_cs.borderRightWidth, "3px");
}, "exported part selector (for outer scope) does not match from middle scope");

test(t => {
  assert_equals(target_cs.borderRightColor, "rgb(0, 255, 0)");
}, "correct part selector matches from middle scope");

test(t => {
  assert_equals(target_cs.borderRightStyle, "double");
}, "pseudo-element selector alone does not match from middle scope");

test(t => {
  assert_equals(target_cs.borderBottomWidth, "3px");
}, "selector with ::part(exported name) does not match from inner scope that exports the part");

test(t => {
  assert_equals(target_cs.borderBottomColor, "rgb(0, 0, 0)");
}, "selector with ::part(original name) does not match from inner scope that exports the part");

test(t => {
  assert_equals(target_cs.borderBottomStyle, "double");
}, "pseudo-element selector alone matches from inner scope");

</script>