Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | var gTestPage = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; |
michael@0 | 2 | var gTestImage = "http://example.org/browser/browser/base/content/test/general/moz.png"; |
michael@0 | 3 | var gTab1, gTab2, gTab3; |
michael@0 | 4 | var gLevel; |
michael@0 | 5 | const BACK = 0; |
michael@0 | 6 | const FORWARD = 1; |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | waitForExplicitFinish(); |
michael@0 | 10 | |
michael@0 | 11 | Task.spawn(function () { |
michael@0 | 12 | gTab1 = gBrowser.addTab(gTestPage); |
michael@0 | 13 | gTab2 = gBrowser.addTab(); |
michael@0 | 14 | gTab3 = gBrowser.addTab(); |
michael@0 | 15 | |
michael@0 | 16 | yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); |
michael@0 | 17 | yield FullZoomHelper.load(gTab1, gTestPage); |
michael@0 | 18 | yield FullZoomHelper.load(gTab2, gTestPage); |
michael@0 | 19 | }).then(secondPageLoaded, FullZoomHelper.failAndContinue(finish)); |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | function secondPageLoaded() { |
michael@0 | 23 | Task.spawn(function () { |
michael@0 | 24 | FullZoomHelper.zoomTest(gTab1, 1, "Initial zoom of tab 1 should be 1"); |
michael@0 | 25 | FullZoomHelper.zoomTest(gTab2, 1, "Initial zoom of tab 2 should be 1"); |
michael@0 | 26 | FullZoomHelper.zoomTest(gTab3, 1, "Initial zoom of tab 3 should be 1"); |
michael@0 | 27 | |
michael@0 | 28 | // Now have three tabs, two with the test page, one blank. Tab 1 is selected |
michael@0 | 29 | // Zoom tab 1 |
michael@0 | 30 | FullZoom.enlarge(); |
michael@0 | 31 | gLevel = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1)); |
michael@0 | 32 | |
michael@0 | 33 | ok(gLevel > 1, "New zoom for tab 1 should be greater than 1"); |
michael@0 | 34 | FullZoomHelper.zoomTest(gTab2, 1, "Zooming tab 1 should not affect tab 2"); |
michael@0 | 35 | FullZoomHelper.zoomTest(gTab3, 1, "Zooming tab 1 should not affect tab 3"); |
michael@0 | 36 | |
michael@0 | 37 | yield FullZoomHelper.load(gTab3, gTestPage); |
michael@0 | 38 | }).then(thirdPageLoaded, FullZoomHelper.failAndContinue(finish)); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | function thirdPageLoaded() { |
michael@0 | 42 | Task.spawn(function () { |
michael@0 | 43 | FullZoomHelper.zoomTest(gTab1, gLevel, "Tab 1 should still be zoomed"); |
michael@0 | 44 | FullZoomHelper.zoomTest(gTab2, 1, "Tab 2 should still not be affected"); |
michael@0 | 45 | FullZoomHelper.zoomTest(gTab3, gLevel, "Tab 3 should have zoomed as it was loading in the background"); |
michael@0 | 46 | |
michael@0 | 47 | // Switching to tab 2 should update its zoom setting. |
michael@0 | 48 | yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); |
michael@0 | 49 | FullZoomHelper.zoomTest(gTab1, gLevel, "Tab 1 should still be zoomed"); |
michael@0 | 50 | FullZoomHelper.zoomTest(gTab2, gLevel, "Tab 2 should be zoomed now"); |
michael@0 | 51 | FullZoomHelper.zoomTest(gTab3, gLevel, "Tab 3 should still be zoomed"); |
michael@0 | 52 | |
michael@0 | 53 | yield FullZoomHelper.load(gTab1, gTestImage); |
michael@0 | 54 | }).then(imageLoaded, FullZoomHelper.failAndContinue(finish)); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | function imageLoaded() { |
michael@0 | 58 | Task.spawn(function () { |
michael@0 | 59 | FullZoomHelper.zoomTest(gTab1, 1, "Zoom should be 1 when image was loaded in the background"); |
michael@0 | 60 | yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); |
michael@0 | 61 | FullZoomHelper.zoomTest(gTab1, 1, "Zoom should still be 1 when tab with image is selected"); |
michael@0 | 62 | }).then(imageZoomSwitch, FullZoomHelper.failAndContinue(finish)); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | function imageZoomSwitch() { |
michael@0 | 66 | Task.spawn(function () { |
michael@0 | 67 | yield FullZoomHelper.navigate(BACK); |
michael@0 | 68 | yield FullZoomHelper.navigate(FORWARD); |
michael@0 | 69 | FullZoomHelper.zoomTest(gTab1, 1, "Tab 1 should not be zoomed when an image loads"); |
michael@0 | 70 | |
michael@0 | 71 | yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); |
michael@0 | 72 | FullZoomHelper.zoomTest(gTab1, 1, "Tab 1 should still not be zoomed when deselected"); |
michael@0 | 73 | }).then(finishTest, FullZoomHelper.failAndContinue(finish)); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | var finishTestStarted = false; |
michael@0 | 77 | function finishTest() { |
michael@0 | 78 | Task.spawn(function () { |
michael@0 | 79 | ok(!finishTestStarted, "finishTest called more than once"); |
michael@0 | 80 | finishTestStarted = true; |
michael@0 | 81 | yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); |
michael@0 | 82 | FullZoom.reset(); |
michael@0 | 83 | yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1); |
michael@0 | 84 | FullZoom.reset(); |
michael@0 | 85 | yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2); |
michael@0 | 86 | FullZoom.reset(); |
michael@0 | 87 | yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab3); |
michael@0 | 88 | }).then(finish, FullZoomHelper.failAndContinue(finish)); |
michael@0 | 89 | } |