browser_bug441778.js
Go to the documentation of this file.
1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * The contents of this file are subject to the Mozilla Public License Version
5  * 1.1 (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS" basis,
10  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11  * for the specific language governing rights and limitations under the
12  * License.
13  *
14  * The Original Code is Firefox Browser Test Code.
15  *
16  * The Initial Developer of the Original Code is
17  * Edward Lee <edward.lee@engineering.uiuc.edu>.
18  * Portions created by the Initial Developer are Copyright (C) 2008
19  * the Initial Developer. All Rights Reserved.
20  *
21  * Contributor(s):
22  * Myk Melez <myk@mozilla.org>
23  *
24  * Alternatively, the contents of this file may be used under the terms of
25  * either the GNU General Public License Version 2 or later (the "GPL"), or
26  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27  * in which case the provisions of the GPL or the LGPL are applicable instead
28  * of those above. If you wish to allow use of your version of this file only
29  * under the terms of either the GPL or the LGPL, and not to allow others to
30  * use your version of this file under the terms of the MPL, indicate your
31  * decision by deleting the provisions above and replace them with the notice
32  * and other provisions required by the GPL or the LGPL. If you do not delete
33  * the provisions above, a recipient may use your version of this file under
34  * the terms of any one of the MPL, the GPL or the LGPL.
35  *
36  * ***** END LICENSE BLOCK ***** */
37 
38 /*
39  * Test the fix for bug 441778 to ensure site-specific page zoom doesn't get
40  * modified by sub-document loads of content from a different domain.
41  */
42 
43 let testPage = 'data:text/html,<body><iframe id="a" src=""></iframe></body>';
44 
45 function test() {
47 
48  // The zoom level before the sub-document load. We set this in continueTest
49  // and then compare it to the current zoom level in finishTest to make sure
50  // it hasn't changed.
51  let zoomLevel;
52 
53  // Prepare the test tab
54  gBrowser.selectedTab = gBrowser.addTab();
55  let testBrowser = gBrowser.selectedBrowser;
56 
57  let finishTest = function() {
58  testBrowser.removeProgressListener(progressListener);
59  is(ZoomManager.zoom, zoomLevel, "zoom is retained after sub-document load");
60  gBrowser.removeCurrentTab();
61  finish();
62  };
63 
64  let progressListener = {
65  QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
66  Ci.nsISupportsWeakReference]),
67  onStateChange: function() {},
68  onProgressChange: function() {},
69  onLocationChange: function() {
70  window.setTimeout(finishTest, 0);
71  },
72  onStatusChange: function() {},
73  onSecurityChange: function() {}
74  };
75 
76  let continueTest = function() {
77  // Change the zoom level and then save it so we can compare it to the level
78  // after loading the sub-document.
79  FullZoom.enlarge();
80  zoomLevel = ZoomManager.zoom;
81 
82  // Finish the test in a timeout after the sub-document location change
83  // to give the zoom controller time to respond to it.
84  testBrowser.addProgressListener(progressListener);
85 
86  // Start the sub-document load.
87  content.document.getElementById("a").src = "http://test2.example.org/";
88  };
89 
90  // Continue the test after the test page has loaded.
91  // Note: in order for the sub-document load to trigger a location change
92  // the way it does under real world usage scenarios, we have to continue
93  // the test in a timeout for some unknown reason.
94  let continueListener = function() {
95  window.setTimeout(continueTest, 0);
96 
97  // Remove the load listener so it doesn't get called for the sub-document.
98  testBrowser.removeEventListener("load", continueListener, true);
99  };
100  testBrowser.addEventListener("load", continueListener, true);
101 
102  // Start the test by loading the test page.
103  testBrowser.contentWindow.location = testPage;
104 }
var FullZoom
var testBrowser
function finishTest()
sbOSDControlService prototype QueryInterface
let window
var progressListener
waitForExplicitFinish()
var zoomLevel
let testPage
const Ci
ContinuingWebProgressListener prototype onStateChange
function test()