browser/base/content/test/general/browser_bug623893.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_bug623893.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,47 @@
     1.4 +function test() {
     1.5 +  waitForExplicitFinish();
     1.6 +
     1.7 +  loadAndWait("data:text/plain,1", function () {
     1.8 +    loadAndWait("data:text/plain,2", function () {
     1.9 +      loadAndWait("data:text/plain,3", runTests);
    1.10 +    });
    1.11 +  });
    1.12 +}
    1.13 +
    1.14 +function runTests() {
    1.15 +  duplicate(0, "maintained the original index", function () {
    1.16 +    gBrowser.removeCurrentTab();
    1.17 +
    1.18 +    duplicate(-1, "went back", function () {
    1.19 +      duplicate(1, "went forward", function () {
    1.20 +        gBrowser.removeCurrentTab();
    1.21 +        gBrowser.removeCurrentTab();
    1.22 +        gBrowser.addTab();
    1.23 +        gBrowser.removeCurrentTab();
    1.24 +        finish();
    1.25 +      });
    1.26 +    });
    1.27 +  });
    1.28 +}
    1.29 +
    1.30 +function duplicate(delta, msg, cb) {
    1.31 +  var start = gBrowser.sessionHistory.index;
    1.32 +
    1.33 +  duplicateTabIn(gBrowser.selectedTab, "tab", delta);
    1.34 +  let tab = gBrowser.selectedTab;
    1.35 +
    1.36 +  tab.addEventListener("SSTabRestored", function tabRestoredListener() {
    1.37 +    tab.removeEventListener("SSTabRestored", tabRestoredListener, false);
    1.38 +    is(gBrowser.sessionHistory.index, start + delta, msg);
    1.39 +    executeSoon(cb);
    1.40 +  }, false);
    1.41 +}
    1.42 +
    1.43 +function loadAndWait(url, cb) {
    1.44 +  gBrowser.selectedBrowser.addEventListener("load", function () {
    1.45 +    gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
    1.46 +    executeSoon(cb);
    1.47 +  }, true);
    1.48 +
    1.49 +  gBrowser.loadURI(url);
    1.50 +}

mercurial