Commit 0da80cf2 authored by Neil Deakin's avatar Neil Deakin
Browse files

Bug 1093404, rewrite test to account for asynchronous tab opening, r=gijs

parent e939a4d7
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -182,7 +182,6 @@ skip-if = e10s # Bug 866413 - PageInfo doesn't work in e10s
[browser_bug462289.js]
skip-if = toolkit == "cocoa" || e10s # Bug 1102017 - middle-button mousedown on selected tab2 does not activate tab - Didn't expect [object XULElement], but got it
[browser_bug462673.js]
skip-if = e10s # Bug 1093404 - test expects sync window opening from content and is disappointed in that expectation
[browser_bug477014.js]
[browser_bug479408.js]
skip-if = buildapp == 'mulet'
+30 −55
Original line number Diff line number Diff line
var runs = [
  function (win, tabbrowser, tab) {
    is(tabbrowser.browsers.length, 2, "test_bug462673.html has opened a second tab");
    is(tabbrowser.selectedTab, tab.nextSibling, "dependent tab is selected");
    tabbrowser.removeTab(tab);
    // Closing a tab will also close its parent chrome window, but async
    executeSoon(function() {
      ok(win.closed, "Window is closed");
      testComplete(win);
    });
  },
  function (win, tabbrowser, tab) {
    var newTab = tabbrowser.addTab();
    var newBrowser = newTab.linkedBrowser;
    tabbrowser.removeTab(tab);
    ok(!win.closed, "Window stays open");
    if (!win.closed) {
      is(tabbrowser.tabContainer.childElementCount, 1, "Window has one tab");
      is(tabbrowser.browsers.length, 1, "Window has one browser");
      is(tabbrowser.selectedTab, newTab, "Remaining tab is selected");
      is(tabbrowser.selectedBrowser, newBrowser, "Browser for remaining tab is selected");
      is(tabbrowser.mTabBox.selectedPanel, newBrowser.parentNode.parentNode.parentNode.parentNode, "Panel for remaining tab is selected");
    }
    testComplete(win);
  }
];
add_task(function* () {
  var win = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no");
  yield SimpleTest.promiseFocus(win);

function test() {
  waitForExplicitFinish();
  runOneTest();
}
  let tab = win.gBrowser.tabContainer.firstChild;
  yield promiseTabLoadEvent(tab, getRootDirectory(gTestPath) + "test_bug462673.html");

function testComplete(win) {
  win.close();
  if (runs.length)
    runOneTest();
  else
    finish();
}
  is(win.gBrowser.browsers.length, 2, "test_bug462673.html has opened a second tab");
  is(win.gBrowser.selectedTab, tab.nextSibling, "dependent tab is selected");
  win.gBrowser.removeTab(tab);

function runOneTest() {
  var win = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no");
  // Closing a tab will also close its parent chrome window, but async
  yield promiseWindowWillBeClosed(win);
});

  win.addEventListener("load", function () {
    win.removeEventListener("load", arguments.callee, false);
add_task(function* () {
  var win = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no");
  yield SimpleTest.promiseFocus(win);

    var tab = win.gBrowser.tabContainer.firstChild;
    var browser = tab.linkedBrowser;
  let tab = win.gBrowser.tabContainer.firstChild;
  yield promiseTabLoadEvent(tab, getRootDirectory(gTestPath) + "test_bug462673.html");

    browser.addEventListener("load", function () {
      browser.removeEventListener("load", arguments.callee, true);
  var newTab = win.gBrowser.addTab();
  var newBrowser = newTab.linkedBrowser;
  win.gBrowser.removeTab(tab);
  ok(!win.closed, "Window stays open");
  if (!win.closed) {
    is(win.gBrowser.tabContainer.childElementCount, 1, "Window has one tab");
    is(win.gBrowser.browsers.length, 1, "Window has one browser");
    is(win.gBrowser.selectedTab, newTab, "Remaining tab is selected");
    is(win.gBrowser.selectedBrowser, newBrowser, "Browser for remaining tab is selected");
    is(win.gBrowser.mTabBox.selectedPanel, newBrowser.parentNode.parentNode.parentNode.parentNode, "Panel for remaining tab is selected");
  }

      executeSoon(function () {
        runs.shift()(win, win.gBrowser, tab);
  yield promiseWindowClosed(win);
});
    }, true);

    var rootDir = getRootDirectory(gTestPath);
    browser.contentWindow.location = rootDir + "test_bug462673.html"
  }, false);
}