exports["test unload tab observer"] = function(assert, done) {
  let loader = Loader(module);

  let window = loader.require("api-utils/window-utils").activeBrowserWindow;
  let observer = loader.require("api-utils/tabs/observer").observer;
  let opened = 0;
  let closed = 0;

  observer.on("open", function onOpen(window) { opened++; });
  observer.on("close", function onClose(window) { closed++; });

  // Open and close tab to trigger observers.
  closeTab(openTab(window, "data:text/html;charset=utf-8,tab-1"));

  // Unload the module so that all listeners set by observer are removed.
  loader.unload();

  // Open and close tab once again.
  closeTab(openTab(window, "data:text/html;charset=utf-8,tab-2"));

  // Enqueuing asserts to make sure that assertion is not performed early.
  setTimeout(function () {
    assert.equal(1, opened, "observer open was called before unload only");
    assert.equal(1, closed, "observer close was called before unload only");
    done();
  }, 0);
};
示例#2
0
  setTimeout(function() {
    activateTab(tab);

    assert.equal(isChromeVisible(window), is('Fennec'), 'chrome is not visible for addon page');

    closeTab(tab);
    assert.ok(isChromeVisible(window), 'chrome is visible again');
    loader.unload();
    done();
  });
示例#3
0
 forEach(function(tab) {
   // Note: `onUntrack` will be called for all windows on add-on unloads,
   // so we want to clean them up from these URLs.
   remove(window.XULBrowserWindow.inContentWhitelist, addonURL);
   closeTab(tab);
 });