browser/base/content/test/general/browser_backButtonFitts.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_backButtonFitts.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,30 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/
     1.6 + */
     1.7 +
     1.8 +function test () {
     1.9 +  waitForExplicitFinish();
    1.10 +  var firstLocation = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
    1.11 +  gBrowser.selectedTab = gBrowser.addTab(firstLocation);
    1.12 +  gBrowser.selectedBrowser.addEventListener("pageshow", function onPageShow1() {
    1.13 +    gBrowser.selectedBrowser.removeEventListener("pageshow", onPageShow1);
    1.14 +    gBrowser.selectedBrowser.contentWindow.history.pushState("page2", "page2", "page2");
    1.15 +    window.maximize();
    1.16 +
    1.17 +    // Find where the nav-bar is vertically.
    1.18 +    var navBar = document.getElementById("nav-bar");
    1.19 +    var boundingRect = navBar.getBoundingClientRect();
    1.20 +    var yPixel = boundingRect.top + Math.floor(boundingRect.height / 2);
    1.21 +    var xPixel = 0; // Use the first pixel of the screen since it is maximized.
    1.22 +
    1.23 +    gBrowser.selectedBrowser.contentWindow.addEventListener("popstate", function onPopState() {
    1.24 +      gBrowser.selectedBrowser.contentWindow.removeEventListener("popstate", onPopState);
    1.25 +      is(gBrowser.selectedBrowser.contentDocument.location.href, firstLocation,
    1.26 +         "Clicking the first pixel should have navigated back.");
    1.27 +      window.restore();
    1.28 +      gBrowser.removeCurrentTab();
    1.29 +      finish();
    1.30 +    });
    1.31 +    EventUtils.synthesizeMouseAtPoint(xPixel, yPixel, {}, window);
    1.32 +  });
    1.33 +}

mercurial