summaryrefslogtreecommitdiffstats
path: root/layout/style/test/test_font_face_cascade.html
blob: 0d98f9d606beb60a57ca55365617458574dbb528 (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
<!DOCTYPE HTML>
<title>Test that @font-face rules from different origins cascade correctly</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
<script>
let io = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
  .getService(SpecialPowers.Ci.nsIIOService);

let utils = SpecialPowers.getDOMWindowUtils(window);

function load_sheet(sheet_text, level) {
  if (level != "AGENT_SHEET" && level != "USER_SHEET" && level != "AUTHOR_SHEET") {
    throw "unknown level";
  }

  let uri = io.newURI("data:text/css," + encodeURI(sheet_text));
  utils.loadSheet(uri, utils[level]);
}

load_sheet(
  "@font-face { font-family: TestAgent; src: url(about:invalid); }",
  "AGENT_SHEET");

load_sheet(
  "@font-face { font-family: TestAuthor; src: url(about:invalid); }",
  "AUTHOR_SHEET");

load_sheet(
  "@font-face { font-family: TestUser; src: url(about:invalid); }",
  "USER_SHEET");

is([...document.fonts].map(f => f.family).join(" "),
   'TestAuthor',
   "document.fonts only contains author @font-face rules");
</script>