summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fullscreen/api/element-request-fullscreen-screen-size.https.html
blob: 1c2bc9e3d119edb9ebeb88aabe33aeee7b7a334a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<title>
    Element#requestFullscreen() does not affect Screen sizes
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="../trusted-click.js"></script>
<body></body>
<script>
    promise_test(async (t) => {
        const screenWidth = window.screen.width;
        const screenHeight = window.screen.height;

        if ('onchange' in window.screen) {
            window.screen.onchange = () => {
                assert_equals(window.screen.width, screenWidth);
                assert_equals(window.screen.height, screenHeight);
            }
            t.add_cleanup(() => { window.screen.onchange = null; });
        }

        // Await a test_driver or manual click, fullscreen promise, and change.
        await Promise.all([trusted_request(), fullScreenChange()]);
        t.add_cleanup(() => { document.exitFullscreen(); });
        assert_not_equals(document.fullscreenElement, null);

        // Ensure the screen size is unchanged during fullscreen.
        assert_equals(window.screen.width, screenWidth);
        assert_equals(window.screen.height, screenHeight);
    }, "Screen size is unchanged during element fullscreen");

    promise_test(async (t) => {
        const screenWidth = window.screen.width;
        const screenHeight = window.screen.height;

        if ('onchange' in window.screen) {
            window.screen.onchange = () => {
                assert_equals(window.screen.width, screenWidth);
                assert_equals(window.screen.height, screenHeight);
            }
            t.add_cleanup(() => { window.screen.onchange = null; });
        }

        // Await a test_driver or manual click to start tab content capture.
        await trusted_click();
        const stream = await navigator.mediaDevices.getDisplayMedia(
            {video:{displaySurface:"browser"}, selfBrowserSurface:"include"});
        const capabilities = stream.getVideoTracks()[0].getCapabilities();
        assert_equals(capabilities.displaySurface, "browser");
        t.add_cleanup(() => { stream.getTracks().forEach(t => t.stop()) });

        // Await a test_driver or manual click, fullscreen promise, and change.
        await Promise.all([trusted_request(), fullScreenChange()]);
        t.add_cleanup(() => { document.exitFullscreen(); });
        assert_not_equals(document.fullscreenElement, null);

        // Ensure the screen size is unchanged during tab-capture fullscreen.
        assert_equals(window.screen.width, screenWidth);
        assert_equals(window.screen.height, screenHeight);
    }, "Screen size is unchanged during tab-capture element fullscreen");
</script>