tabs.js 928 B

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. const { Ci } = require('chrome');
  3. const { openTab, closeTab } = require('sdk/tabs/utils');
  4. const { browserWindows } = require('sdk/windows');
  5. const { getOwnerWindow } = require('sdk/private-browsing/window/utils');
  6. const { isPrivate } = require('sdk/private-browsing');
  7. exports.testIsPrivateOnTab = function(assert) {
  8. let window = browserWindows.activeWindow;
  9. let chromeWindow = getOwnerWindow(window);
  10. assert.ok(chromeWindow instanceof Ci.nsIDOMWindow, 'associated window is found');
  11. assert.ok(!isPrivate(chromeWindow), 'the top level window is not private');
  12. let rawTab = openTab(chromeWindow, 'data:text/html,<h1>Hi!</h1>', {
  13. isPrivate: true
  14. });
  15. // test that the tab is private
  16. assert.ok(rawTab.browser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing);
  17. assert.ok(isPrivate(rawTab.browser.contentWindow));
  18. assert.ok(isPrivate(rawTab.browser));
  19. closeTab(rawTab);
  20. };