diff options
Diffstat (limited to 'testing/web-platform/mozilla/tests/css')
14 files changed, 429 insertions, 0 deletions
diff --git a/testing/web-platform/mozilla/tests/css/css-contain/content-visibility-hidden-document-reflow-count.html b/testing/web-platform/mozilla/tests/css/css-contain/content-visibility-hidden-document-reflow-count.html new file mode 100644 index 0000000000..69c1c4b7dd --- /dev/null +++ b/testing/web-platform/mozilla/tests/css/css-contain/content-visibility-hidden-document-reflow-count.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<html> + <meta charset="utf-8"> + <title>CSS Contain: Test content-visibility:hidden reflow counts</title> + <link rel="author" title="Martin Robinson" href="mailto:mrobinson@igalia.com"> + + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + + <body style="content-visibility: hidden;"> + hello + </body> + + <script> + let gUtils = SpecialPowers.getDOMWindowUtils(window); + let gTestContainer = document.getElementById("test"); + + function flushLayout() { + document.documentElement.offsetHeight; + } + + function getReflowCount() { + flushLayout(); + return gUtils.framesReflowed; + } + + function runTestFunctionAndCountReflows(testFunction) { + const beforeCount = getReflowCount(); + testFunction(); + const afterCount = getReflowCount(); + console.log(afterCount - beforeCount); + return afterCount - beforeCount; + } + + test(() => { + flushLayout(); + + const reflows = runTestFunctionAndCountReflows(() => { + document.body.innerText = "something else"; + }); + assert_equals(reflows, 1, "Reflow only triggered on body."); + }, "Changing text of 'content-visibility: hidden' body only triggers a single reflow."); + </script> +</html> diff --git a/testing/web-platform/mozilla/tests/css/css-contain/content-visibility-hidden-reflow-count.html b/testing/web-platform/mozilla/tests/css/css-contain/content-visibility-hidden-reflow-count.html new file mode 100644 index 0000000000..c1484d9c54 --- /dev/null +++ b/testing/web-platform/mozilla/tests/css/css-contain/content-visibility-hidden-reflow-count.html @@ -0,0 +1,120 @@ +<!DOCTYPE html> +<html> + <meta charset="utf-8"> + <title>CSS Contain: Test content-visibility:hidden reflow counts</title> + <link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com"> + <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1746098"> + + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + + <style> + .container { + content-visibility: visible; + contain: strict; + } + .flex { + display: flex; + } + .grid { + display: grid; + grid: repeat(2, 60px) / auto-flow 80px; + } + </style> + + <div id="test"></div> + + <script> + let gUtils = SpecialPowers.getDOMWindowUtils(window); + let gTestContainer = document.getElementById("test"); + + function setupContainerWithStrictContainment() { + const container = document.createElement("div"); + container.classList.add("container"); + gTestContainer.innerHTML = ""; + gTestContainer.appendChild(container); + return container; + } + + function flushLayout() { + document.documentElement.offsetHeight; + } + + function getReflowCount() { + flushLayout(); + return gUtils.framesReflowed; + } + + function runTestFunctionAndCountReflows(testFunction, container) { + const beforeCount = getReflowCount(); + testFunction(container); + const afterCount = getReflowCount(); + return afterCount - beforeCount; + } + + function assertContentVisibilityHiddenHasFewerReflows(testSetup, testFunction) { + let container = setupContainerWithStrictContainment(); + testSetup(container); + flushLayout(); + + const visibleReflows = runTestFunctionAndCountReflows(testFunction, container); + + container = setupContainerWithStrictContainment(); + testSetup(container); + container.style.contentVisibility = "hidden"; + flushLayout(); + + const hiddenReflows = runTestFunctionAndCountReflows(testFunction, container); + assert_less_than(hiddenReflows, visibleReflows, + "Style / layout changes in hidden content resulted in fewer reflows than visible content."); + } + + test(() => { + assertContentVisibilityHiddenHasFewerReflows( + (container) => { + const div = document.createElement("div"); + div.innerText = "Test Content"; + container.appendChild(div); + }, + (container) => { + container.children[0].style.width = "100px"; + container.children[0].style.height = "100px"; + }); + }, `Avoiding layout while modifying a simple div's style.`); + + test(() => { + assertContentVisibilityHiddenHasFewerReflows( + (container) => { + container.classList.add("flex"); + + const flexContainer = document.createElement("div"); + flexContainer.classList.add("flex"); + container.appendChild(flexContainer); + + container.appendChild(document.createElement("div")); + }, + (container) => { + container.children[0].style.flexDirection = "row-reverse"; + } + ); + }, `Avoiding layout while modifying a div with flex display mode.`); + + test(() => { + assertContentVisibilityHiddenHasFewerReflows( + (container) => { + container.classList.add("grid"); + + const gridChild = document.createElement("div"); + gridChild.style.display = "grid"; + container.appendChild(gridChild); + + container.appendChild(document.createElement("div")); + }, + (container) => { + container.children[0].style.rowGap = "30px"; + }, + ); + }, `Avoiding layout while modifying a div with grid display mode.`); + + </script> +</html> diff --git a/testing/web-platform/mozilla/tests/css/css-overflow/scrollbar-gutter-reflow-counts-001.html b/testing/web-platform/mozilla/tests/css/css-overflow/scrollbar-gutter-reflow-counts-001.html new file mode 100644 index 0000000000..aa4ed4667b --- /dev/null +++ b/testing/web-platform/mozilla/tests/css/css-overflow/scrollbar-gutter-reflow-counts-001.html @@ -0,0 +1,115 @@ +<!DOCTYPE html> +<html> + <meta charset="utf-8"> + <title>CSS Overflow: Test scrollbar-gutter reflow counts</title> + <link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com"> + <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1746098"> + + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + + <style> + #target { + inline-size: 200px; + block-size: 100px; + background: lightgray; + overflow: auto; + } + + #targetChild { + inline-size: 100%; + block-size: 100%; + background: orange; + } + </style> + + <p>Here is a scroll contaier for testing:</p> + <div id="target"> + <div id="targetChild"></div> + </div> + + <script> + let gUtils = SpecialPowers.getDOMWindowUtils(window); + let gTarget = document.getElementById("target"); + let gTargetChild = document.getElementById("targetChild"); + + function getReflowCount() + { + document.documentElement.offsetHeight; // flush layout + return gUtils.framesReflowed; + } + + function cleanUp() { + gTarget.style.writingMode = ""; + gTarget.style.scrollbarGutter = ""; + gTargetChild.style.blockSize = ""; + } + + function tweakStyleAndCountReflows(aAddStyle, aAddScrollbarGutter) + { + let beforeCount = getReflowCount(); + if (aAddScrollbarGutter) { + gTarget.style.scrollbarGutter = "stable"; + } + aAddStyle(); + let afterCount = getReflowCount(); + cleanUp(); + + let numReflows = afterCount - beforeCount; + assert_greater_than(numReflows, 0, "We should've reflowed *something* after changing styles:"); + return numReflows; + } + + let gTestCases = [ + { + name : "Enlarge the child's block-size to 200%", + addStyle : function () { + gTargetChild.style.blockSize = "200%"; + }, + }, + { + name : "Enlarge the child's block-size to 300px", + addStyle : function () { + gTargetChild.style.blockSize = "300px"; + }, + }, + { + name : "Enlarge the child's block-size to 200% in a vertical-lr scroll container", + addStyle : function () { + gTarget.style.writingMode = "vertical-lr"; + gTargetChild.style.blockSize = "200%"; + }, + }, + { + name : "Enlarge the child's block-size to 300px in a vertical-lr scroll container", + addStyle : function () { + gTarget.style.writingMode = "vertical-lr"; + gTargetChild.style.blockSize = "300px"; + }, + }, + { + name : "Enlarge the child's block-size to 200% in a vertical-rl scroll container", + addStyle : function () { + gTarget.style.writingMode = "vertical-rl"; + gTargetChild.style.blockSize = "200%"; + }, + }, + { + name : "Enlarge the child's block-size to 300px in a vertical-rl scroll container", + addStyle : function () { + gTarget.style.writingMode = "vertical-rl"; + gTargetChild.style.blockSize = "300px"; + }, + }, + ]; + + for (let testcase of gTestCases) { + test(function () { + let numTestReflows = tweakStyleAndCountReflows(testcase.addStyle, true); + let numReferenceReflows = tweakStyleAndCountReflows(testcase.addStyle, false); + assert_less_than(numTestReflows, numReferenceReflows, + "A scroll container with 'scrollbar-gutter:stable' should have less reflow counts:"); + }, testcase.name) + } + </script> +</html> diff --git a/testing/web-platform/mozilla/tests/css/cssom/media-print-change-print-ref.html b/testing/web-platform/mozilla/tests/css/cssom/media-print-change-print-ref.html new file mode 100644 index 0000000000..1fc00e7e39 --- /dev/null +++ b/testing/web-platform/mozilla/tests/css/cssom/media-print-change-print-ref.html @@ -0,0 +1,2 @@ +<!doctype html> +<div>PASS</div> diff --git a/testing/web-platform/mozilla/tests/css/cssom/media-print-change-print.html b/testing/web-platform/mozilla/tests/css/cssom/media-print-change-print.html new file mode 100644 index 0000000000..8e9172956c --- /dev/null +++ b/testing/web-platform/mozilla/tests/css/cssom/media-print-change-print.html @@ -0,0 +1,8 @@ +<!doctype html> +<link rel=match href="media-print-change-print-ref.html"> +<div id="target">FAIL</div> +<script> + matchMedia("print").addEventListener("change", function() { + document.getElementById("target").innerHTML = "PASS"; + }); +</script> diff --git a/testing/web-platform/mozilla/tests/css/cssom/window_size_rounding.html b/testing/web-platform/mozilla/tests/css/cssom/window_size_rounding.html new file mode 100644 index 0000000000..695bf8f34b --- /dev/null +++ b/testing/web-platform/mozilla/tests/css/cssom/window_size_rounding.html @@ -0,0 +1,35 @@ +<!doctype html> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<pre> +<script> +test(function() { + let originalWidth = window.innerWidth; + let originalHeight = window.innerHeight; + + assert_equals(window.devicePixelRatio, 1, `precondition: ${originalWidth}x${originalHeight}`); + + // This precondition holds because of: + // https://searchfox.org/mozilla-central/rev/50215d649d4854812837f1343e8f47bd998dacb5/browser/base/content/browser.js#1717 + // + // But if this test starts failing you can just update the assert and the + // factor below accordingly so that the asserts keep passing. + assert_equals(originalWidth, 1280, "precondition"); + + // Set a fractional scale factor that guarantees that we get a fractional innerWidth + const kFactor = 1.5; + const kOneAppUnit = 1 / 60; + + SpecialPowers.setFullZoom(window, kFactor); + assert_approx_equals(window.devicePixelRatio, kFactor, kOneAppUnit); + assert_not_equals(window.innerWidth, originalWidth); + assert_not_equals(window.innerHeight, originalHeight); + if (SpecialPowers.getBoolPref("dom.innerSize.rounded")) { + assert_equals(window.innerWidth, Math.round(originalWidth / kFactor)); + assert_equals(window.innerHeight, Math.round(originalHeight / kFactor)); + } else { + assert_not_equals(window.innerWidth, Math.round(window.innerWidth)); + } + SpecialPowers.setFullZoom(window, 1); // Restore zoom so results can be seen fine... +}); +</script> diff --git a/testing/web-platform/mozilla/tests/css/file-selector-button-margin-notref.html b/testing/web-platform/mozilla/tests/css/file-selector-button-margin-notref.html new file mode 100644 index 0000000000..67fc0af389 --- /dev/null +++ b/testing/web-platform/mozilla/tests/css/file-selector-button-margin-notref.html @@ -0,0 +1,2 @@ +<!doctype html> +<input type=file> diff --git a/testing/web-platform/mozilla/tests/css/file-selector-button-margin.html b/testing/web-platform/mozilla/tests/css/file-selector-button-margin.html new file mode 100644 index 0000000000..46c1bd0e3e --- /dev/null +++ b/testing/web-platform/mozilla/tests/css/file-selector-button-margin.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>CSS Test: margin can be used to shrink the spacing between the file selector button and its label</title> +<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1673895"> +<link rel="mismatch" href="file-selector-margin-notref.html"> +<style> +::file-selector-button { + margin: 0; +} +</style> +<input type=file> diff --git a/testing/web-platform/mozilla/tests/css/iframe-os-text-scale-print-ref.html b/testing/web-platform/mozilla/tests/css/iframe-os-text-scale-print-ref.html new file mode 100644 index 0000000000..ad2922d8a1 --- /dev/null +++ b/testing/web-platform/mozilla/tests/css/iframe-os-text-scale-print-ref.html @@ -0,0 +1,5 @@ +<!doctype html> +<style> + body { margin: 0 } +</style> +<iframe frameborder=0 scrolling=no src="resources/iframe-os-text-scale-inner.html"></iframe> diff --git a/testing/web-platform/mozilla/tests/css/iframe-os-text-scale-print.sub.html b/testing/web-platform/mozilla/tests/css/iframe-os-text-scale-print.sub.html new file mode 100644 index 0000000000..d0647da9b3 --- /dev/null +++ b/testing/web-platform/mozilla/tests/css/iframe-os-text-scale-print.sub.html @@ -0,0 +1,6 @@ +<!doctype html> +<link rel=match href="iframe-os-text-scale-print-ref.html"> +<style> + body { margin: 0 } +</style> +<iframe frameborder=0 scrolling=no src="//{{hosts[alt][www]}}:{{ports[http][0]}}{{location[path]}}/../resources/iframe-os-text-scale-inner.html"></iframe> diff --git a/testing/web-platform/mozilla/tests/css/mediaqueries/mq-gamut-resist-fingerprinting.html b/testing/web-platform/mozilla/tests/css/mediaqueries/mq-gamut-resist-fingerprinting.html new file mode 100644 index 0000000000..06424705ac --- /dev/null +++ b/testing/web-platform/mozilla/tests/css/mediaqueries/mq-gamut-resist-fingerprinting.html @@ -0,0 +1,40 @@ +<!doctype html> +<title>Test: color-gamut only matches sRGB when resisting fingerprinting</title> +<link rel="match" href="../reference/ref-filled-green-100px-square.xht"> +<!-- + This test is trivial as long as Firefox only matches the sRGB color-gamut media + query. Once Firefox can match additional color-gamuts, though, we should still + only match sRGB when resisting fingerprinting. +--> +<style> +div { + width: 100px; + height: 100px; +} + +div.with-gamut { + background-color: red; +} + +div.without-gamuts { + background-color: green; +} + +@media (color-gamut: srgb) { + div.with-gamut { + background-color: green; + } +} + +@media (color-gamut: p3), (color-gamut: rec2020) { + div.without-gamuts { + background-color: red; + } +} +</style> + +<p>Test passes if there are two filled green squares and <strong>no red</strong>. + +<div class=with-gamut></div> +<p></p> +<div class=without-gamuts></div> diff --git a/testing/web-platform/mozilla/tests/css/quirks-invalidation-standard-sheet.html b/testing/web-platform/mozilla/tests/css/quirks-invalidation-standard-sheet.html new file mode 100644 index 0000000000..b926f81af4 --- /dev/null +++ b/testing/web-platform/mozilla/tests/css/quirks-invalidation-standard-sheet.html @@ -0,0 +1,14 @@ +<!-- quirks, intentionally --> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div class="mixedCase"></div> +<script> + test(function() { + const kLime = "rgb(0, 255, 0)"; + + let div = document.querySelector("div"); + assert_not_equals(getComputedStyle(div).color, kLime); + SpecialPowers.DOMWindowUtils.loadSheetUsingURIString('data:text/css,.mixedCase{color:lime}', 1) + assert_equals(getComputedStyle(div).color, kLime); + }, "Invalidation of quirks documents when standard sheets are inserted works properly") +</script> diff --git a/testing/web-platform/mozilla/tests/css/reference/ref-filled-green-100px-square.xht b/testing/web-platform/mozilla/tests/css/reference/ref-filled-green-100px-square.xht new file mode 100644 index 0000000000..9b647491e9 --- /dev/null +++ b/testing/web-platform/mozilla/tests/css/reference/ref-filled-green-100px-square.xht @@ -0,0 +1,19 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>CSS Reftest Reference</title> + <style type="text/css"><![CDATA[ + div { + background-color: green; + height: 100px; + width: 100px; + } + ]]></style> + </head> + <body> + <p>Test passes if there are two filled green squares and <strong>no red</strong>.</p> + <div></div> + <p></p> + <div></div> + </body> +</html> diff --git a/testing/web-platform/mozilla/tests/css/resources/iframe-os-text-scale-inner.html b/testing/web-platform/mozilla/tests/css/resources/iframe-os-text-scale-inner.html new file mode 100644 index 0000000000..be51cc957c --- /dev/null +++ b/testing/web-platform/mozilla/tests/css/resources/iframe-os-text-scale-inner.html @@ -0,0 +1,9 @@ +<!doctype html> +<style> +body { + background-color: green; + height: 100vh; + width: 100vw; +} +</style> +TEST |