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