browser/base/content/test/general/browser_bug386835.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/base/content/test/general/browser_bug386835.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,89 @@
     1.4 +var gTestPage = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
     1.5 +var gTestImage = "http://example.org/browser/browser/base/content/test/general/moz.png";
     1.6 +var gTab1, gTab2, gTab3;
     1.7 +var gLevel;
     1.8 +const BACK = 0;
     1.9 +const FORWARD = 1;
    1.10 +
    1.11 +function test() {
    1.12 +  waitForExplicitFinish();
    1.13 +
    1.14 +  Task.spawn(function () {
    1.15 +    gTab1 = gBrowser.addTab(gTestPage);
    1.16 +    gTab2 = gBrowser.addTab();
    1.17 +    gTab3 = gBrowser.addTab();
    1.18 +
    1.19 +    yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
    1.20 +    yield FullZoomHelper.load(gTab1, gTestPage);
    1.21 +    yield FullZoomHelper.load(gTab2, gTestPage);
    1.22 +  }).then(secondPageLoaded, FullZoomHelper.failAndContinue(finish));
    1.23 +}
    1.24 +
    1.25 +function secondPageLoaded() {
    1.26 +  Task.spawn(function () {
    1.27 +    FullZoomHelper.zoomTest(gTab1, 1, "Initial zoom of tab 1 should be 1");
    1.28 +    FullZoomHelper.zoomTest(gTab2, 1, "Initial zoom of tab 2 should be 1");
    1.29 +    FullZoomHelper.zoomTest(gTab3, 1, "Initial zoom of tab 3 should be 1");
    1.30 +
    1.31 +    // Now have three tabs, two with the test page, one blank. Tab 1 is selected
    1.32 +    // Zoom tab 1
    1.33 +    FullZoom.enlarge();
    1.34 +    gLevel = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1));
    1.35 +
    1.36 +    ok(gLevel > 1, "New zoom for tab 1 should be greater than 1");
    1.37 +    FullZoomHelper.zoomTest(gTab2, 1, "Zooming tab 1 should not affect tab 2");
    1.38 +    FullZoomHelper.zoomTest(gTab3, 1, "Zooming tab 1 should not affect tab 3");
    1.39 +
    1.40 +    yield FullZoomHelper.load(gTab3, gTestPage);
    1.41 +  }).then(thirdPageLoaded, FullZoomHelper.failAndContinue(finish));
    1.42 +}
    1.43 +
    1.44 +function thirdPageLoaded() {
    1.45 +  Task.spawn(function () {
    1.46 +    FullZoomHelper.zoomTest(gTab1, gLevel, "Tab 1 should still be zoomed");
    1.47 +    FullZoomHelper.zoomTest(gTab2, 1, "Tab 2 should still not be affected");
    1.48 +    FullZoomHelper.zoomTest(gTab3, gLevel, "Tab 3 should have zoomed as it was loading in the background");
    1.49 +
    1.50 +    // Switching to tab 2 should update its zoom setting.
    1.51 +    yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
    1.52 +    FullZoomHelper.zoomTest(gTab1, gLevel, "Tab 1 should still be zoomed");
    1.53 +    FullZoomHelper.zoomTest(gTab2, gLevel, "Tab 2 should be zoomed now");
    1.54 +    FullZoomHelper.zoomTest(gTab3, gLevel, "Tab 3 should still be zoomed");
    1.55 +
    1.56 +    yield FullZoomHelper.load(gTab1, gTestImage);
    1.57 +  }).then(imageLoaded, FullZoomHelper.failAndContinue(finish));
    1.58 +}
    1.59 +
    1.60 +function imageLoaded() {
    1.61 +  Task.spawn(function () {
    1.62 +    FullZoomHelper.zoomTest(gTab1, 1, "Zoom should be 1 when image was loaded in the background");
    1.63 +    yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
    1.64 +    FullZoomHelper.zoomTest(gTab1, 1, "Zoom should still be 1 when tab with image is selected");
    1.65 +  }).then(imageZoomSwitch, FullZoomHelper.failAndContinue(finish));
    1.66 +}
    1.67 +
    1.68 +function imageZoomSwitch() {
    1.69 +  Task.spawn(function () {
    1.70 +    yield FullZoomHelper.navigate(BACK);
    1.71 +    yield FullZoomHelper.navigate(FORWARD);
    1.72 +    FullZoomHelper.zoomTest(gTab1, 1, "Tab 1 should not be zoomed when an image loads");
    1.73 +
    1.74 +    yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
    1.75 +    FullZoomHelper.zoomTest(gTab1, 1, "Tab 1 should still not be zoomed when deselected");
    1.76 +  }).then(finishTest, FullZoomHelper.failAndContinue(finish));
    1.77 +}
    1.78 +
    1.79 +var finishTestStarted  = false;
    1.80 +function finishTest() {
    1.81 +  Task.spawn(function () {
    1.82 +    ok(!finishTestStarted, "finishTest called more than once");
    1.83 +    finishTestStarted = true;
    1.84 +    yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
    1.85 +    FullZoom.reset();
    1.86 +    yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1);
    1.87 +    FullZoom.reset();
    1.88 +    yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2);
    1.89 +    FullZoom.reset();
    1.90 +    yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab3);
    1.91 +  }).then(finish, FullZoomHelper.failAndContinue(finish));
    1.92 +}

mercurial