summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-cascade/layer-font-face-override.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/css/css-cascade/layer-font-face-override.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-cascade/layer-font-face-override.html')
-rw-r--r--testing/web-platform/tests/css/css-cascade/layer-font-face-override.html141
1 files changed, 141 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-cascade/layer-font-face-override.html b/testing/web-platform/tests/css/css-cascade/layer-font-face-override.html
new file mode 100644
index 0000000000..d35caca012
--- /dev/null
+++ b/testing/web-platform/tests/css/css-cascade/layer-font-face-override.html
@@ -0,0 +1,141 @@
+<!DOCTYPE html>
+<title>Resolving @keyframe name conflicts with cascade layers</title>
+<link rel="help" href="https://drafts.csswg.org/css-cascade-5/#layering">
+<link rel="author" href="mailto:xiaochengh@chromium.org">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+#target {
+ font-size: 20px;
+ width: min-content;
+}
+</style>
+
+<div id="target">Test</div>
+
+<script>
+// In all tests, width of #target should be 80px.
+
+const testCases = [
+ {
+ title: '@font-face unlayered overrides layered',
+ style: `
+ #target {
+ font-family: custom-font;
+ }
+
+ @font-face {
+ font-family: custom-font;
+ src: url('/fonts/Ahem.ttf');
+ }
+
+ @layer {
+ @font-face {
+ font-family: custom-font;
+ src: url('/fonts/noto/noto-sans-v8-latin-regular.woff') format('woff');
+ }
+ }
+ `
+ },
+
+ {
+ title: '@font-face override between layers',
+ style: `
+ @layer base, override;
+
+ #target {
+ font-family: custom-font;
+ }
+
+ @layer override {
+ @font-face {
+ font-family: custom-font;
+ src: url('/fonts/Ahem.ttf');
+ }
+ }
+
+ @layer base {
+ @font-face {
+ font-family: custom-font;
+ src: url('/fonts/noto/noto-sans-v8-latin-regular.woff') format('woff');
+ }
+ }
+ `
+ },
+
+ {
+ title: '@font-face override update with appended sheet 1',
+ style: `
+ @layer base, override;
+
+ #target {
+ font-family: custom-font;
+ }
+
+ @layer override {
+ @font-face {
+ font-family: custom-font;
+ src: url('/fonts/Ahem.ttf');
+ }
+ }
+ `,
+ append: `
+ @layer base {
+ @font-face {
+ font-family: custom-font;
+ src: url('/fonts/noto/noto-sans-v8-latin-regular.woff') format('woff');
+ }
+ }
+ `
+ },
+
+ {
+ title: '@font-face override update with appended sheet 2',
+ style: `
+ @layer base, override;
+
+ #target {
+ font-family: custom-font;
+ }
+
+ @layer base {
+ @font-face {
+ font-family: custom-font;
+ src: url('/fonts/noto/noto-sans-v8-latin-regular.woff') format('woff');
+ }
+ }
+ `,
+ append: `
+ @layer override {
+ @font-face {
+ font-family: custom-font;
+ src: url('/fonts/Ahem.ttf');
+ }
+ }
+ `
+ },
+];
+
+for (let testCase of testCases) {
+ promise_test(async () => {
+ var documentStyle = document.createElement('style');
+ documentStyle.appendChild(document.createTextNode(testCase['style']));
+ document.head.appendChild(documentStyle);
+
+ var appendedStyle;
+ if (testCase['append']) {
+ document.body.offsetLeft; // Force style update
+ appendedStyle = document.createElement('style');
+ appendedStyle.appendChild(document.createTextNode(testCase['append']));
+ document.head.appendChild(appendedStyle);
+ }
+
+ await document.fonts.load('20px/1 custom-font');
+ assert_equals(getComputedStyle(target).width, '80px');
+
+ if (appendedStyle)
+ appendedStyle.remove();
+ documentStyle.remove();
+ }, testCase['title']);
+}
+</script>