summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/resize-observer/devicepixel2-ref.html
blob: 7674eb0ab835a1b02541a28b4ed9084e61b2e088 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!doctype html>
<body>
<script type="module">
import createPatternDataURL from './create-pattern-data-url.js';

const { patternSize, dataURL } = createPatternDataURL();
document.body.style.backgroundImage = `url("${dataURL}")`;

function setBackgroundPatternTo1DevicePixel() {
  const oneDevicePixel = 1 / devicePixelRatio;
  const patternPixels = oneDevicePixel * patternSize;
  document.body.style.backgroundSize = `${patternPixels}px ${patternPixels}px`;
}
setBackgroundPatternTo1DevicePixel();

// If we're viewed interactively and the user activates
// full-page-zoom, changes the page zoom level, or resizes
// the window, update the rendering to account for that:
window.addEventListener('resize', setBackgroundPatternTo1DevicePixel);
</script>
</body>