tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_subframe_textzoom.js (1773B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 /*
      6 * Test the fix for bug 441778 to ensure site-specific page zoom doesn't get
      7 * modified by sub-document loads of content from a different domain.
      8 */
      9 
     10 function test() {
     11  waitForExplicitFinish();
     12 
     13  const TEST_PAGE_URL = 'data:text/html,<body><iframe src=""></iframe></body>';
     14  // eslint-disable-next-line @microsoft/sdl/no-insecure-url
     15  const TEST_IFRAME_URL = "http://test2.example.org/";
     16 
     17  (async function () {
     18    // Prepare the test tab
     19    let tab = BrowserTestUtils.addTab(gBrowser);
     20    await FullZoomHelper.selectTabAndWaitForLocationChange(tab);
     21 
     22    let testBrowser = tab.linkedBrowser;
     23 
     24    await FullZoomHelper.load(tab, TEST_PAGE_URL);
     25 
     26    // Change the zoom level and then save it so we can compare it to the level
     27    // after loading the sub-document.
     28    FullZoom.enlarge();
     29    var zoomLevel = ZoomManager.zoom;
     30 
     31    // Start the sub-document load.
     32    await new Promise(resolve => {
     33      executeSoon(function () {
     34        BrowserTestUtils.browserLoaded(testBrowser, true).then(url => {
     35          is(url, TEST_IFRAME_URL, "got the load event for the iframe");
     36          is(
     37            ZoomManager.zoom,
     38            zoomLevel,
     39            "zoom is retained after sub-document load"
     40          );
     41 
     42          FullZoomHelper.removeTabAndWaitForLocationChange().then(() =>
     43            resolve()
     44          );
     45        });
     46        SpecialPowers.spawn(testBrowser, [TEST_IFRAME_URL], url => {
     47          content.document.querySelector("iframe").src = url;
     48        });
     49      });
     50    });
     51  })().then(finish, FullZoomHelper.failAndContinue(finish));
     52 }