зеркало из https://github.com/mozilla/gecko-dev.git
Bug 849723 - Introduce API to use the private hidden window correctly. r=ehsan
This commit is contained in:
Родитель
f10e0fcf0e
Коммит
cec761b367
|
@ -29,13 +29,7 @@ var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
// We need to wait for the hidden window to load, but can't access
|
// We need to wait for the hidden window to load, but can't access
|
||||||
// an event target for a regular event listener.
|
// an event target for a regular event listener.
|
||||||
var hidden = mainWindow.Services.appShell.hiddenPrivateDOMWindow;
|
var hidden = mainWindow.Services.appShell.hiddenPrivateDOMWindow;
|
||||||
var tmp = setTimeout(function poll() {
|
mainWindow.PrivateBrowsingUtils.whenHiddenPrivateWindowReady(function(hidden) {
|
||||||
if (hidden.location.href != "resource://gre-resources/hiddenWindow.html" ||
|
|
||||||
!hidden.document.body) {
|
|
||||||
setTimeout(poll, 100);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var iframe = hidden.document.createElement('iframe');
|
var iframe = hidden.document.createElement('iframe');
|
||||||
iframe.src = 'generic.html';
|
iframe.src = 'generic.html';
|
||||||
hidden.document.body.appendChild(iframe);
|
hidden.document.body.appendChild(iframe);
|
||||||
|
@ -46,7 +40,7 @@ var tmp = setTimeout(function poll() {
|
||||||
win.close();
|
win.close();
|
||||||
win = null;
|
win = null;
|
||||||
}, false);
|
}, false);
|
||||||
}, 100);
|
});
|
||||||
|
|
||||||
function observer(aSubject, aTopic, aData) {
|
function observer(aSubject, aTopic, aData) {
|
||||||
is(aTopic, "last-pb-context-exited", "Unexpected observer topic");
|
is(aTopic, "last-pb-context-exited", "Unexpected observer topic");
|
||||||
|
|
|
@ -42,6 +42,26 @@ this.PrivateBrowsingUtils = {
|
||||||
},
|
},
|
||||||
get isInTemporaryAutoStartMode() {
|
get isInTemporaryAutoStartMode() {
|
||||||
return gTemporaryAutoStartMode;
|
return gTemporaryAutoStartMode;
|
||||||
|
},
|
||||||
|
|
||||||
|
whenHiddenPrivateWindowReady: function pbu_whenHiddenPrivateWindowReady(cb) {
|
||||||
|
Components.utils.import("resource://gre/modules/Timer.jsm");
|
||||||
|
|
||||||
|
let win = Services.appShell.hiddenPrivateDOMWindow;
|
||||||
|
function isNotLoaded() {
|
||||||
|
return ["complete", "interactive"].indexOf(win.document.readyState) == -1;
|
||||||
|
}
|
||||||
|
if (isNotLoaded()) {
|
||||||
|
setTimeout(function poll() {
|
||||||
|
if (isNotLoaded()) {
|
||||||
|
setTimeout(poll, 100);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cb(Services.appShell.hiddenPrivateDOMWindow);
|
||||||
|
}, 4);
|
||||||
|
} else {
|
||||||
|
cb(Services.appShell.hiddenPrivateDOMWindow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче