test-tabs.js 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. const tabs = require('sdk/tabs');
  3. const { isPrivate } = require('sdk/private-browsing');
  4. const pbUtils = require('sdk/private-browsing/utils');
  5. const { getOwnerWindow } = require('sdk/private-browsing/window/utils');
  6. exports.testPrivateTabsAreListed = function (assert, done) {
  7. let originalTabCount = tabs.length;
  8. tabs.open({
  9. url: 'about:blank',
  10. isPrivate: true,
  11. onOpen: function(tab) {
  12. let win = getOwnerWindow(tab);
  13. // PWPB case
  14. if (pbUtils.isWindowPBSupported || pbUtils.isTabPBSupported) {
  15. assert.ok(isPrivate(tab), "tab is private");
  16. assert.equal(tabs.length, originalTabCount + 1,
  17. 'New private window\'s tab are visible in tabs list');
  18. }
  19. else {
  20. // Global case, openDialog didn't opened a private window/tab
  21. assert.ok(!isPrivate(tab), "tab isn't private");
  22. assert.equal(tabs.length, originalTabCount + 1,
  23. 'New non-private window\'s tab is visible in tabs list');
  24. }
  25. tab.close(done);
  26. }
  27. });
  28. };