summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/general/browser_bug1015721.js
blob: e3e7153961e965044d7f7231d01bb99392a6de54 (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
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

const TEST_PAGE = "http://example.org/browser/browser/base/content/test/general/zoom_test.html";

var gTab1, gTab2, gLevel1;

function test() {
  waitForExplicitFinish();

  Task.spawn(function* () {
    gTab1 = gBrowser.addTab();
    gTab2 = gBrowser.addTab();

    yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
    yield FullZoomHelper.load(gTab1, TEST_PAGE);
    yield FullZoomHelper.load(gTab2, TEST_PAGE);
  }).then(zoomTab1, FullZoomHelper.failAndContinue(finish));
}

function zoomTab1() {
  Task.spawn(function* () {
    is(gBrowser.selectedTab, gTab1, "Tab 1 is selected");
    FullZoomHelper.zoomTest(gTab1, 1, "Initial zoom of tab 1 should be 1");
    FullZoomHelper.zoomTest(gTab2, 1, "Initial zoom of tab 2 should be 1");

    let browser1 = gBrowser.getBrowserForTab(gTab1);
    yield BrowserTestUtils.synthesizeMouse(null, 10, 10, {
      wheel: true, ctrlKey: true, deltaY: -1, deltaMode: WheelEvent.DOM_DELTA_LINE
    }, browser1);

    info("Waiting for tab 1 to be zoomed");
    yield promiseWaitForCondition(() => {
      gLevel1 = ZoomManager.getZoomForBrowser(browser1);
      return gLevel1 > 1;
    });

    yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
    FullZoomHelper.zoomTest(gTab2, gLevel1, "Tab 2 should have zoomed along with tab 1");
  }).then(finishTest, FullZoomHelper.failAndContinue(finish));
}

function finishTest() {
  Task.spawn(function* () {
    yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
    yield FullZoom.reset();
    yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1);
    yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
    yield FullZoom.reset();
    yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2);
  }).then(finish, FullZoomHelper.failAndContinue(finish));
}