summaryrefslogtreecommitdiffstats
path: root/browser/components/screenshots/tests/browser/browser_test_resize.js
blob: b249a346d68d691a74b59b1012cc7a89d1ac4ed8 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const windowWidth = 768;

add_task(async function test_window_resize() {
  await BrowserTestUtils.withNewTab(
    {
      gBrowser,
      url: RESIZE_TEST_PAGE,
    },
    async browser => {
      let helper = new ScreenshotsHelper(browser);
      await helper.resizeContentWindow(windowWidth, window.outerHeight);
      const originalContentDimensions = await helper.getContentDimensions();
      info(JSON.stringify(originalContentDimensions, null, 2));

      await helper.zoomBrowser(1.5);

      helper.triggerUIFromToolbar();
      await helper.waitForOverlay();

      await helper.scrollContentWindow(windowWidth, window.outerHeight);

      await helper.clickTestPageElement("hello");

      await helper.zoomBrowser(1);

      await helper.waitForOverlaySizeChangeTo(
        originalContentDimensions.scrollWidth,
        originalContentDimensions.scrollHeight
      );

      let contentDims = await helper.getContentDimensions();
      info(JSON.stringify(contentDims, null, 2));

      is(
        contentDims.scrollWidth,
        originalContentDimensions.scrollWidth,
        "Width of page is back to original"
      );
      is(
        contentDims.scrollHeight,
        originalContentDimensions.scrollHeight,
        "Height of page is back to original"
      );
    }
  );
});

add_task(async function test_window_resize_vertical_writing_mode() {
  await BrowserTestUtils.withNewTab(
    {
      gBrowser,
      url: RESIZE_TEST_PAGE,
    },
    async browser => {
      await SpecialPowers.spawn(browser, [], () => {
        content.document.documentElement.style = "writing-mode: vertical-lr;";
      });

      let helper = new ScreenshotsHelper(browser);
      await helper.resizeContentWindow(windowWidth, window.outerHeight);
      const originalContentDimensions = await helper.getContentDimensions();
      info(JSON.stringify(originalContentDimensions, null, 2));

      await helper.zoomBrowser(1.5);

      helper.triggerUIFromToolbar();
      await helper.waitForOverlay();

      await helper.scrollContentWindow(windowWidth, window.outerHeight);

      await helper.clickTestPageElement("hello");

      await helper.zoomBrowser(1);

      await helper.waitForOverlaySizeChangeTo(
        originalContentDimensions.scrollWidth,
        originalContentDimensions.scrollHeight
      );

      let contentDims = await helper.getContentDimensions();
      info(JSON.stringify(contentDims, null, 2));

      is(
        contentDims.scrollWidth,
        originalContentDimensions.scrollWidth,
        "Width of page is back to original"
      );
      is(
        contentDims.scrollHeight,
        originalContentDimensions.scrollHeight,
        "Height of page is back to original"
      );
    }
  );
});