Skip to content

Commit

Permalink
Bug 1883840 - Export layout/reftests/radicalbar*.html to WPT. r=emilio
Browse files Browse the repository at this point in the history
In this patch, MathML reftests radicalbar*.html are converted to
WPT. These tests rely on the `reftest-zoom` attribute to verify that
the radical bar does not disappear at smaller zoom level (bug 1011020).
However, this attribute is not supported by WPT. So we keep them as
internal tests for now, emulating support for the `reftest-zoom`
attribute via the `SpecialPowers.*fullZoom` API.

It was verified that reverting the patch for bug 1011020 make these
reftests fail, contrary to alternative approaches (CSS zoom property and
`SpecialPowers.snapshotWindowWithOptions). Please refer to bug 1850661
for the initial attempts.

A `common/reftest-zoom.js` file is introduced so that it could be used
by similar tests in the future. Infrastructure tests are added to verify
the basic behavior.

Differential Revision: https://phabricator.services.mozilla.com/D203728
  • Loading branch information
fred-wang committed Mar 8, 2024
1 parent 0e2538b commit a9ea9c9
Show file tree
Hide file tree
Showing 31 changed files with 185 additions and 72 deletions.
24 changes: 0 additions & 24 deletions layout/reftests/mathml/reftest.list

This file was deleted.

3 changes: 0 additions & 3 deletions layout/reftests/reftest.list
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,6 @@ include line-breaking/reftest.list
# list-item/
include list-item/reftest.list

# mathml/
include mathml/reftest.list

# margin-collapsing
include margin-collapsing/reftest.list

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[clamp-full-zoom-001.html]
prefs: [zoom.minPercent:50]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[clamp-full-zoom-002.html]
prefs: [zoom.maxPercent:200]
29 changes: 29 additions & 0 deletions testing/web-platform/mozilla/tests/common/reftest-zoom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// This JS file allows to emulate reftest-zoom.
// See https://firefox-source-docs.mozilla.org/layout/Reftest.html#zoom-tests-reftest-zoom-float

// Retrieve reftest-zoom attribute.
const reftestZoom = "reftest-zoom";
const root = document.documentElement;
if (!root.hasAttribute(reftestZoom)) {
throw new Error(`${reftestZoom} attribute not found on the root element.`);
}

// Parse reftest-zoom value.
let zoom = parseFloat(root.getAttribute(reftestZoom));
if (Number.isNaN(zoom)) {
throw new Error(`${reftestZoom} is not a float number.`);
}

// Clamp reftest-zoom value.
let minZoom = SpecialPowers.getIntPref("zoom.minPercent") / 100;
let maxZoom = SpecialPowers.getIntPref("zoom.maxPercent") / 100;
zoom = Math.min(Math.max(zoom, minZoom), maxZoom);

// Ensure the original zoom level is restored after the screenshot.
const originalZoom = SpecialPowers.getFullZoom(window);
window.addEventListener("beforeunload", () => {
SpecialPowers.setFullZoom(window, originalZoom);
});

// Set the zoom level to the specified value.
SpecialPowers.setFullZoom(window, zoom);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE html>
<html style="zoom: .5">
<div style="width: 500px; height: 500px; background: green"></div>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html reftest-zoom="0">
<link rel="help" href="https://firefox-source-docs.mozilla.org/layout/Reftest.html#zoom-tests-reftest-zoom-float"/>
<link rel="match" href="clamp-full-zoom-001-ref.html"/>
<!-- zoom.minPercent is set to 50 in the corresponding ini file. -->
<meta name="assert" content="Zoom is at least by zoom.minPercent."/>
<script src="/_mozilla/common/reftest-zoom.js"></script>
<div style="width: 500px; height: 500px; background: green"></div>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE html>
<html style="zoom: 2">
<div style="width: 250px; height: 250px; background: green"></div>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html reftest-zoom="10">
<link rel="help" href="https://firefox-source-docs.mozilla.org/layout/Reftest.html#zoom-tests-reftest-zoom-float"/>
<link rel="match" href="clamp-full-zoom-002-ref.html"/>
<!-- zoom.maxPercent is set to 200 in the corresponding ini file. -->
<meta name="assert" content="Zoom is at most by zoom.maxPercent."/>
<script src="/_mozilla/common/reftest-zoom.js"></script>
<div style="width: 250px; height: 250px; background: green"></div>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE html>
<html style="zoom: .5">
<div style="width: 500px; height: 500px; background: green"></div>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html reftest-zoom=".5">
<link rel="help" href="https://firefox-source-docs.mozilla.org/layout/Reftest.html#zoom-tests-reftest-zoom-float"/>
<link rel="match" href="set-full-zoom-001-ref.html"/>
<meta name="assert" content="Zoom less than one scales down the rect."/>
<script src="/_mozilla/common/reftest-zoom.js"></script>
<div style="width: 500px; height: 500px; background: green"></div>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE html>
<html style="zoom: 2">
<div style="width: 250px; height: 250px; background: green"></div>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html reftest-zoom="2">
<link rel="help" href="https://firefox-source-docs.mozilla.org/layout/Reftest.html#zoom-tests-reftest-zoom-float"/>
<link rel="match" href="set-full-zoom-002-ref.html"/>
<meta name="assert" content="Zoom more than one scales up the rect."/>
<script src="/_mozilla/common/reftest-zoom.js"></script>
<div style="width: 250px; height: 250px; background: green"></div>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE html>
<html style="zoom: 1">
<div style="width: 250px; height: 250px; background: green"></div>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<link rel="match" href="set-full-zoom-003-ref.html"/>
<meta name="assert" content="Initial zoom is equal to one."/>
<!-- Note that when running all the tests by alphabetical order, this test
would fail if set-zoom-002.html does not reset the zoom to one.
It would pass when re-running after a browser restart, though. -->
<div style="width: 250px; height: 250px; background: green"></div>
</html>
2 changes: 2 additions & 0 deletions testing/web-platform/mozilla/tests/mathml/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ any specification:
[whitespace trimming in token elements](https://www.w3.org/TR/MathML3/chapter2.html#fund.collapse)
which is not described in the initial version of MathML Core.
See [issue 149](https://github.com/w3c/mathml-core/issues/149).

- `zoom`: Tests to check MathML rendering at different zoom levels.
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<!DOCTYPE html>
<html>
<html>
<head>
<link rel="mismatch" href="about:blank"/>
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1011020"/>
<!-- Default to invisible text -->
<style type="text/css" media="screen, print">
.hidden {
color: white;
color: white;
}
.visible {
color: black;
color: black;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<html reftest-zoom=".5">
<html reftest-zoom=".5">
<head>
<link rel="mismatch" href="about:blank"/>
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1011020"/>
<script src="/_mozilla/common/reftest-zoom.js"></script>
<!-- Default to invisible text -->
<style type="text/css" media="screen, print">
.hidden {
color: white;
color: white;
}
.visible {
color: black;
color: black;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<html reftest-zoom=".4">
<html reftest-zoom=".4">
<head>
<link rel="mismatch" href="about:blank"/>
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1011020"/>
<script src="/_mozilla/common/reftest-zoom.js"></script>
<!-- Default to invisible text -->
<style type="text/css" media="screen, print">
.hidden {
color: white;
color: white;
}
.visible {
color: black;
color: black;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<html reftest-zoom=".3">
<html reftest-zoom=".3">
<head>
<link rel="mismatch" href="about:blank"/>
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1011020"/>
<script src="/_mozilla/common/reftest-zoom.js"></script>
<!-- Default to invisible text -->
<style type="text/css" media="screen, print">
.hidden {
color: white;
color: white;
}
.visible {
color: black;
color: black;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<html reftest-zoom=".2">
<html reftest-zoom=".2">
<head>
<link rel="mismatch" href="about:blank"/>
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1011020"/>
<script src="/_mozilla/common/reftest-zoom.js"></script>
<!-- Default to invisible text -->
<style type="text/css" media="screen, print">
.hidden {
color: white;
color: white;
}
.visible {
color: black;
color: black;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<!DOCTYPE html>
<html>
<html>
<head>
<link rel="mismatch" href="about:blank"/>
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1011020"/>
<!-- Default to invisible text -->
<style type="text/css" media="screen, print">
.hidden {
color: white;
color: white;
}
.visible {
color: black;
color: black;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<html reftest-zoom="0.5">
<html reftest-zoom="0.5">
<head>
<link rel="mismatch" href="about:blank"/>
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1011020"/>
<script src="/_mozilla/common/reftest-zoom.js"></script>
<!-- Default to invisible text -->
<style type="text/css" media="screen, print">
.hidden {
color: white;
color: white;
}
.visible {
color: black;
color: black;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<html reftest-zoom="0.4">
<html reftest-zoom="0.4">
<head>
<link rel="mismatch" href="about:blank"/>
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1011020"/>
<script src="/_mozilla/common/reftest-zoom.js"></script>
<!-- Default to invisible text -->
<style type="text/css" media="screen, print">
.hidden {
color: white;
color: white;
}
.visible {
color: black;
color: black;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<html reftest-zoom="0.3">
<html reftest-zoom="0.3">
<head>
<link rel="mismatch" href="about:blank"/>
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1011020"/>
<script src="/_mozilla/common/reftest-zoom.js"></script>
<!-- Default to invisible text -->
<style type="text/css" media="screen, print">
.hidden {
color: white;
color: white;
}
.visible {
color: black;
color: black;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<html reftest-zoom="0.2">
<html reftest-zoom="0.2">
<head>
<link rel="mismatch" href="about:blank"/>
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1011020"/>
<script src="/_mozilla/common/reftest-zoom.js"></script>
<!-- Default to invisible text -->
<style type="text/css" media="screen, print">
.hidden {
color: white;
color: white;
}
.visible {
color: black;
color: black;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<!DOCTYPE html>
<html>
<html>
<head>
<link rel="mismatch" href="about:blank"/>
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1011020"/>
<!-- Default to invisible text -->
<style type="text/css" media="screen, print">
.hidden {
color: white;
color: white;
}
.visible {
color: black;
color: black;
}
</style>
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<html reftest-zoom="0.5">
<html reftest-zoom="0.5">
<head>
<link rel="mismatch" href="about:blank"/>
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1011020"/>
<script src="/_mozilla/common/reftest-zoom.js"></script>
<!-- Default to invisible text -->
<style type="text/css" media="screen, print">
.hidden {
color: white;
color: white;
}
.visible {
color: black;
color: black;
}
</style>
</head>
Expand Down
Loading

0 comments on commit a9ea9c9

Please sign in to comment.