michael@0: 'use strict'; michael@0: michael@0: const { Ci } = require('chrome'); michael@0: const { openTab, closeTab } = require('sdk/tabs/utils'); michael@0: const { browserWindows } = require('sdk/windows'); michael@0: const { getOwnerWindow } = require('sdk/private-browsing/window/utils'); michael@0: const { isPrivate } = require('sdk/private-browsing'); michael@0: michael@0: exports.testIsPrivateOnTab = function(assert) { michael@0: let window = browserWindows.activeWindow; michael@0: michael@0: let chromeWindow = getOwnerWindow(window); michael@0: michael@0: assert.ok(chromeWindow instanceof Ci.nsIDOMWindow, 'associated window is found'); michael@0: assert.ok(!isPrivate(chromeWindow), 'the top level window is not private'); michael@0: michael@0: let rawTab = openTab(chromeWindow, 'data:text/html,

Hi!

', { michael@0: isPrivate: true michael@0: }); michael@0: michael@0: // test that the tab is private michael@0: assert.ok(rawTab.browser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing); michael@0: assert.ok(isPrivate(rawTab.browser.contentWindow)); michael@0: assert.ok(isPrivate(rawTab.browser)); michael@0: michael@0: closeTab(rawTab); michael@0: };