browser/base/content/test/general/browser_bug441778.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_bug441778.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,46 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +/*
     1.9 + * Test the fix for bug 441778 to ensure site-specific page zoom doesn't get
    1.10 + * modified by sub-document loads of content from a different domain.
    1.11 + */
    1.12 +
    1.13 +function test() {
    1.14 +  waitForExplicitFinish();
    1.15 +
    1.16 +  const TEST_PAGE_URL = 'data:text/html,<body><iframe src=""></iframe></body>';
    1.17 +  const TEST_IFRAME_URL = "http://test2.example.org/";
    1.18 +
    1.19 +  Task.spawn(function () {
    1.20 +    // Prepare the test tab
    1.21 +    let tab = gBrowser.addTab();
    1.22 +    yield FullZoomHelper.selectTabAndWaitForLocationChange(tab);
    1.23 +
    1.24 +    let testBrowser = tab.linkedBrowser;
    1.25 +
    1.26 +    yield FullZoomHelper.load(tab, TEST_PAGE_URL);
    1.27 +
    1.28 +    // Change the zoom level and then save it so we can compare it to the level
    1.29 +    // after loading the sub-document.
    1.30 +    FullZoom.enlarge();
    1.31 +    var zoomLevel = ZoomManager.zoom;
    1.32 +
    1.33 +    // Start the sub-document load.
    1.34 +    let deferred = Promise.defer();
    1.35 +    executeSoon(function () {
    1.36 +      testBrowser.addEventListener("load", function (e) {
    1.37 +        testBrowser.removeEventListener("load", arguments.callee, true);
    1.38 +
    1.39 +        is(e.target.defaultView.location, TEST_IFRAME_URL, "got the load event for the iframe");
    1.40 +        is(ZoomManager.zoom, zoomLevel, "zoom is retained after sub-document load");
    1.41 +
    1.42 +        FullZoomHelper.removeTabAndWaitForLocationChange().
    1.43 +          then(() => deferred.resolve());
    1.44 +      }, true);
    1.45 +      content.document.querySelector("iframe").src = TEST_IFRAME_URL;
    1.46 +    });
    1.47 +    yield deferred.promise;
    1.48 +  }).then(finish, FullZoomHelper.failAndContinue(finish));
    1.49 +}

mercurial