43 let
pb =
Cc[
"@mozilla.org/privatebrowsing;1"].
48 let tabAbout = gBrowser.addTab();
49 gBrowser.selectedTab = tabAbout;
50 let aboutBrowser = gBrowser.getBrowserForTab(tabAbout);
51 aboutBrowser.addEventListener(
"load",
function () {
52 aboutBrowser.removeEventListener(
"load",
arguments.callee,
true);
54 let
ww =
Cc[
"@mozilla.org/embedcomp/window-watcher;1"].
58 if (aTopic ==
"domwindowopened") {
59 ww.unregisterNotification(
this);
61 let
win = aSubject.QueryInterface(
Ci.nsIDOMEventTarget);
62 win.addEventListener(
"load",
function() {
63 win.removeEventListener(
"load",
arguments.callee,
false);
65 let
browser = win.document.defaultView.getBrowser();
66 browser.addEventListener(
"load",
function() {
67 browser.removeEventListener(
"load",
arguments.callee,
true);
76 ww.registerNotification(observer);
80 function openViewSource() {
82 let
event = document.createEvent(
"Events");
83 event.initEvent(
"command",
true,
true);
84 document.getElementById(
"View:PageSource").dispatchEvent(
event);
90 if (aTopic ==
"domwindowclosed") {
91 ok(
true,
"Entering the private browsing mode should close the view source window");
92 ww.unregisterNotification(observer);
96 else if (aTopic ==
"domwindowopened")
97 ok(
false,
"Entering the private browsing mode should not open any view source window");
100 ww.registerNotification(observer);
102 gBrowser.addTabsProgressListener({
103 onLocationChange:
function() {},
104 onProgressChange:
function() {},
105 onSecurityChange:
function() {},
106 onStatusChange:
function() {},
107 onRefreshAttempted:
function() {},
108 onLinkIconAvailable:
function() {},
110 if (aStateFlags & (
Ci.nsIWebProgressListener.STATE_STOP |
111 Ci.nsIWebProgressListener.STATE_IS_WINDOW)) {
112 gBrowser.removeTabsProgressListener(
this);
120 pb.privateBrowsingEnabled =
true;
124 step2 = step3 =
function() {
132 if (aTopic ==
"domwindowopened") {
133 ww.unregisterNotification(
this);
135 let
win = aSubject.QueryInterface(
Ci.nsIDOMEventTarget);
136 win.addEventListener(
"load",
function() {
137 win.removeEventListener(
"load",
arguments.callee,
false);
139 let
browser = win.document.defaultView.getBrowser();
140 browser.addEventListener(
"load",
function() {
141 browser.removeEventListener(
"load",
arguments.callee,
true);
150 ww.registerNotification(observer);
160 if (aTopic ==
"domwindowclosed") {
161 ok(
true,
"Leaving the private browsing mode should close the existing view source window");
163 ww.unregisterNotification(observer);
165 else if (aTopic ==
"domwindowopened") {
166 ok(
true,
"Leaving the private browsing mode should restore the previous view source window");
168 ww.unregisterNotification(observer);
170 let
win = aSubject.QueryInterface(
Ci.nsIDOMEventTarget);
171 win.addEventListener(
"load",
function() {
172 win.removeEventListener(
"load",
arguments.callee,
false);
174 let
browser = win.document.defaultView.getBrowser();
175 browser.addEventListener(
"load",
function() {
176 browser.removeEventListener(
"load",
arguments.callee,
true);
178 is(browser.currentURI.spec,
"view-source:about:",
179 "The correct view source window should be restored");
183 gBrowser.removeTab(gBrowser.selectedTab);
190 ww.registerNotification(observer);
193 pb.privateBrowsingEnabled =
false;
196 aboutBrowser.loadURI(
"about:");
getService(Ci.sbIFaceplateManager)
return!aWindow arguments!aWindow arguments[0]
_updateTextAndScrollDataForTab aBrowser
ContinuingWebProgressListener prototype onStateChange
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe