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-syntax/serialize-escape-identifiers.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html>
<head>
<title>Properly escape CSS identifiers</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style id="sheet">
@import 'abc' layer(\{\});
@counter-style abc\{\}oops {}
@font-feature-values abc\{\}oops {}
@font-palette-values --abc\{\}oops {}
@keyframes abc\{\}oops {}
@layer abc\;oops\!;
</style>
</head>
<body>
<script>
test(()=>{
const rules = Array.from(document.styleSheets[0].cssRules);
const text = rules.map(r => r.cssText).join('\n');
sheet.innerText = text;
const new_rules = Array.from(document.styleSheets[0].cssRules);
const new_text = new_rules.map(r => r.cssText).join('\n');
assert_equals(new_text, text);
}, 'Rules must be the same after serialization round-trip, even with escaped characters');
</script>