Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /css/css-cascade/scope-import-scope-pseudo.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>@import scope(), :scope rules in imported stylesheet</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
@import url("resources/scope-imported.css") scope((.scope));
</style>
<main id=main>
<div class=scope>
<div class=y>Inside</div>
<div>
<div class=y>Inside, but should not match</div>
</div>
</div>
<div class=y>Outside</div>
</main>
<script>
test(() => {
let inside = main.querySelector('.scope > .y');
assert_equals(getComputedStyle(inside).getPropertyValue('--y'), '1');
let inside_no_match = main.querySelector('.scope > div > .y');
assert_equals(getComputedStyle(inside_no_match).getPropertyValue('--y'), '');
let outside = main.querySelector('#main > .y');
assert_equals(getComputedStyle(outside).getPropertyValue('--y'), '');
}, 'The :scope pseudo-class works in imported stylesheets');
</script>