Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / widget / tests / system_font_changes.xhtml
blob1cef6500153f8d93f57bcb71751c56e8e8e7f3b1
1 <?xml version="1.0"?>
3 <!-- This Source Code Form is subject to the terms of the Mozilla Public
4 - License, v. 2.0. If a copy of the MPL was not distributed with this
5 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
7 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
9 <window id="system_font_changes_window"
10 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
11 width="300"
12 height="300"
13 onload="start();">
15 <span id="target" style="font:menu">Hello world</span>
17 <script type="application/javascript"><![CDATA[
18 function is(condition, message) {
19 window.arguments[0].SimpleTest.is(condition, message);
21 function registerCleanupFunction(func) {
22 window.arguments[0].SimpleTest.registerCleanupFunction(func);
25 async function waitForFrame() {
26 return new Promise(resolve => {
27 requestAnimationFrame(resolve);
28 });
31 let windowUtils = window.windowUtils;
32 async function start() {
33 await waitForFrame();
35 const originalSystemFont = windowUtils.systemFont;
36 registerCleanupFunction(() => {
37 windowUtils.systemFont = originalSystemFont;
38 });
40 windowUtils.systemFont = 'Sans 11';
41 is(windowUtils.systemFont, 'Sans 11');
43 // Wait for two frames for the safety since the notification for system
44 // font changes is asynchronously processed.
45 await waitForFrame();
46 await waitForFrame();
48 const target = document.getElementById('target');
49 is(getComputedStyle(target).fontFamily, 'Sans');
51 windowUtils.systemFont = 'Serif 11';
52 is(windowUtils.systemFont, 'Serif 11');
54 await waitForFrame();
55 await waitForFrame();
57 is(getComputedStyle(target).fontFamily, 'Serif');
59 window.close();
60 window.arguments[0].SimpleTest.finish();
62 ]]></script>
63 </window>