зеркало из https://github.com/mozilla/gecko-dev.git
Bug 806682 - Port browser_privatebrowsing_cookieacceptdialog.js to the new per-window PB APIs; r=jdm
--HG-- rename : browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_cookieacceptdialog.js => browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_cookieacceptdialog.js
This commit is contained in:
Родитель
957bc7dad1
Коммит
12623dc7b8
|
@ -15,6 +15,7 @@ MOCHITEST_BROWSER_FILES = \
|
|||
browser_privatebrowsing_certexceptionsui.js \
|
||||
browser_privatebrowsing_concurrent.js \
|
||||
browser_privatebrowsing_concurrent_page.html \
|
||||
browser_privatebrowsing_cookieacceptdialog.js \
|
||||
browser_privatebrowsing_lastpbcontextexited.js \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// This test makes sure that private browsing mode disables the "remember"
|
||||
// option in the cookie accept dialog.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let cp = Cc["@mozilla.org/embedcomp/cookieprompt-service;1"].
|
||||
getService(Ci.nsICookiePromptService);
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
function checkRememberOption(expectedDisabled, aWindow, callback) {
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
|
||||
Services.ww.unregisterNotification(observer);
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
win.addEventListener("load", function onLoad(event) {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
|
||||
executeSoon(function () {
|
||||
let doc = win.document;
|
||||
let remember = doc.getElementById("persistDomainAcceptance");
|
||||
ok(remember, "The remember checkbox should exist");
|
||||
|
||||
if (expectedDisabled)
|
||||
is(remember.getAttribute("disabled"), "true",
|
||||
"The checkbox should be disabled");
|
||||
else
|
||||
ok(!remember.hasAttribute("disabled"),
|
||||
"The checkbox should not be disabled");
|
||||
|
||||
win.close();
|
||||
callback();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
Services.ww.registerNotification(observer);
|
||||
|
||||
let remember = {};
|
||||
const time = (new Date("Jan 1, 2030")).getTime() / 1000;
|
||||
let cookie = {
|
||||
name: "foo",
|
||||
value: "bar",
|
||||
isDomain: true,
|
||||
host: "mozilla.org",
|
||||
path: "/baz",
|
||||
isSecure: false,
|
||||
expires: time,
|
||||
status: 0,
|
||||
policy: 0,
|
||||
isSession: false,
|
||||
expiry: time,
|
||||
isHttpOnly: true,
|
||||
QueryInterface: function(iid) {
|
||||
const validIIDs = [Ci.nsISupports,
|
||||
Ci.nsICookie,
|
||||
Ci.nsICookie2];
|
||||
for (var i = 0; i < validIIDs.length; ++i)
|
||||
if (iid == validIIDs[i])
|
||||
return this;
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
};
|
||||
cp.cookieDialog(aWindow, cookie, "mozilla.org", 10, false, remember);
|
||||
}
|
||||
|
||||
var windowsToClose = [];
|
||||
function testOnWindow(options, callback) {
|
||||
var win = OpenBrowserWindow(options);
|
||||
win.addEventListener("load", function onLoad() {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
windowsToClose.push(win);
|
||||
callback(win);
|
||||
}, false);
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
windowsToClose.forEach(function(win) {
|
||||
win.close();
|
||||
});
|
||||
});
|
||||
|
||||
testOnWindow({private: true}, function(win) {
|
||||
checkRememberOption(true, win, function() {
|
||||
testOnWindow(undefined, function(win) {
|
||||
checkRememberOption(false, win, finish);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
Загрузка…
Ссылка в новой задаче