addon-sdk/source/test/private-browsing/tabs.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/addon-sdk/source/test/private-browsing/tabs.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,27 @@
     1.4 +'use strict';
     1.5 +
     1.6 +const { Ci } = require('chrome');
     1.7 +const { openTab, closeTab } = require('sdk/tabs/utils');
     1.8 +const { browserWindows } = require('sdk/windows');
     1.9 +const { getOwnerWindow } = require('sdk/private-browsing/window/utils');
    1.10 +const { isPrivate } = require('sdk/private-browsing');
    1.11 +
    1.12 +exports.testIsPrivateOnTab = function(assert) {
    1.13 +  let window = browserWindows.activeWindow;
    1.14 +
    1.15 +  let chromeWindow = getOwnerWindow(window);
    1.16 +
    1.17 +  assert.ok(chromeWindow instanceof Ci.nsIDOMWindow, 'associated window is found');
    1.18 +  assert.ok(!isPrivate(chromeWindow), 'the top level window is not private');
    1.19 +
    1.20 +  let rawTab = openTab(chromeWindow, 'data:text/html,<h1>Hi!</h1>', {
    1.21 +    isPrivate: true
    1.22 +  });
    1.23 +
    1.24 +  // test that the tab is private
    1.25 +  assert.ok(rawTab.browser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing);
    1.26 +  assert.ok(isPrivate(rawTab.browser.contentWindow));
    1.27 +  assert.ok(isPrivate(rawTab.browser));
    1.28 +
    1.29 +  closeTab(rawTab);
    1.30 +};

mercurial