Screen.width and screen.height are wrong

Description of the issue:

In JavaScript, screen.width and screen.height are supposed to report your monitor size. It does under Chrome and Firefox but is in error under Brave. With Brave, the values change when you resize the window. It shouldn’t. The monitor (screen) size is a constant.

Steps to Reproduce (add as many as necessary): 1. 2. 3.

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Device Information</title>
    <script>
        function updateInfo() {
            document.body.innerHTML = `Display size = ${screen.width}x${screen.height}<br>Window size = ${window.innerWidth}x${window.innerHeight}`;
            window.onresize = updateInfo;
        }
    </script>
</head>
<body onload="updateInfo()" style="font-size: medium;">
</body>
</html>

Actual Result (gifs and screenshots are welcome!):

screen.width and screen.height change when the browser is resized.

Expected result:

They should be constant because the screen/monitor size is constant.

Reproduces how often:

Every time.

Operating System and Brave Version(See the About Brave page in the main menu):

64-bit Linux. Brave 1.45.123 Chrome 107.0.5304.110 Official Build 64-bit

Additional Information:

https://jsfiddle.net/pk5q6ugv/ does that not work for you? Resizing the window works for me, at least in windows.

Its definitly an error in the last update. screen.availWidth, screen.availHeight, screen.width and scrren.height have to be constant. My application will not work any more with brave. It would be great, if this bug would be fixed in the next update.

I just found that the values of screenX and clientX (and Y) are wrong. It seems to me that the values are based on the acutal window instead of the screen.

It’s not an error of Brave Software - it is obviously a side effect of the filtering. If I disable the filtering the error is gone.

This is a new fingerprinting protection we are rolling out. It is currently at 50% in Desktop Release and will be at 100% in a couple of weeks. For details please see https://github.com/brave/brave-browser/issues/23170.

@datenschvtz are you able to share more about your application and how we might find a workaround?

The application uses screenX/Y for determining the mouse position for the displaying of context menus. With screen.width (availWidth) will be ensured the the menus are visible on screen.

We’re working on a couple of fixes that I expect will solve some issues: