зеркало из https://github.com/mozilla/pjs.git
Use ordinary JS functions as observer callbacks in browser chrome tests
This commit is contained in:
Родитель
4481cad856
Коммит
316383f052
|
@ -13,27 +13,25 @@ function test() {
|
|||
content.location =
|
||||
"https://example.com/browser/browser/base/content/test/feed_tab.html";
|
||||
|
||||
var observer = {
|
||||
observe: function(win, topic, data) {
|
||||
if (topic != "page-info-dialog-loaded")
|
||||
return;
|
||||
function observer(win, topic, data) {
|
||||
if (topic != "page-info-dialog-loaded")
|
||||
return;
|
||||
|
||||
switch (atTest) {
|
||||
case 0:
|
||||
atTest++;
|
||||
handlePageInfo();
|
||||
break;
|
||||
case 1:
|
||||
atTest++;
|
||||
pageInfo = win;
|
||||
testLockClick();
|
||||
break;
|
||||
case 2:
|
||||
atTest++;
|
||||
obs.removeObserver(observer, "page-info-dialog-loaded");
|
||||
testLockDoubleClick();
|
||||
break;
|
||||
}
|
||||
switch (atTest) {
|
||||
case 0:
|
||||
atTest++;
|
||||
handlePageInfo();
|
||||
break;
|
||||
case 1:
|
||||
atTest++;
|
||||
pageInfo = win;
|
||||
testLockClick();
|
||||
break;
|
||||
case 2:
|
||||
atTest++;
|
||||
obs.removeObserver(observer, "page-info-dialog-loaded");
|
||||
testLockDoubleClick();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,15 +145,14 @@ function test()
|
|||
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Ci.nsIWindowWatcher);
|
||||
let win = ww.getWindowByName("Sanatize", null);
|
||||
if (win && (win instanceof Ci.nsIDOMWindowInternal)) win.close();
|
||||
if (win && (win instanceof Ci.nsIDOMWindowInternal))
|
||||
win.close();
|
||||
|
||||
// Start the test when the sanitize window loads
|
||||
ww.registerNotification({
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
ww.unregisterNotification(this);
|
||||
aSubject.QueryInterface(Ci.nsIDOMEventTarget).
|
||||
addEventListener("DOMContentLoaded", doTest, false);
|
||||
}
|
||||
ww.registerNotification(function (aSubject, aTopic, aData) {
|
||||
ww.unregisterNotification(arguments.callee);
|
||||
aSubject.QueryInterface(Ci.nsIDOMEventTarget)
|
||||
.addEventListener("DOMContentLoaded", doTest, false);
|
||||
});
|
||||
|
||||
// Let the methods that run onload finish before we test
|
||||
|
|
|
@ -536,69 +536,67 @@ WindowHelper.prototype = {
|
|||
open: function () {
|
||||
let wh = this;
|
||||
|
||||
let windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic !== "domwindowopened")
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
|
||||
winWatch.unregisterNotification(windowObserver);
|
||||
|
||||
var loaded = false;
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
|
||||
win.addEventListener("load", function onload(event) {
|
||||
win.removeEventListener("load", onload, false);
|
||||
|
||||
if (win.name !== "SanitizeDialog")
|
||||
return;
|
||||
|
||||
winWatch.unregisterNotification(this);
|
||||
wh.win = win;
|
||||
loaded = true;
|
||||
|
||||
var loaded = false;
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
|
||||
win.addEventListener("load", function onload(event) {
|
||||
win.removeEventListener("load", onload, false);
|
||||
|
||||
if (win.name !== "SanitizeDialog")
|
||||
return;
|
||||
|
||||
wh.win = win;
|
||||
loaded = true;
|
||||
|
||||
executeSoon(function () {
|
||||
// Some exceptions that reach here don't reach the test harness, but
|
||||
// ok()/is() do...
|
||||
try {
|
||||
wh.onload();
|
||||
}
|
||||
catch (exc) {
|
||||
win.close();
|
||||
ok(false, "Unexpected exception: " + exc + "\n" + exc.stack);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}, false);
|
||||
|
||||
win.addEventListener("unload", function onunload(event) {
|
||||
if (win.name !== "SanitizeDialog") {
|
||||
win.removeEventListener("unload", onunload, false);
|
||||
return;
|
||||
executeSoon(function () {
|
||||
// Some exceptions that reach here don't reach the test harness, but
|
||||
// ok()/is() do...
|
||||
try {
|
||||
wh.onload();
|
||||
}
|
||||
catch (exc) {
|
||||
win.close();
|
||||
ok(false, "Unexpected exception: " + exc + "\n" + exc.stack);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}, false);
|
||||
|
||||
// Why is unload fired before load?
|
||||
if (!loaded)
|
||||
return;
|
||||
|
||||
win.addEventListener("unload", function onunload(event) {
|
||||
if (win.name !== "SanitizeDialog") {
|
||||
win.removeEventListener("unload", onunload, false);
|
||||
wh.win = win;
|
||||
return;
|
||||
}
|
||||
|
||||
executeSoon(function () {
|
||||
// Some exceptions that reach here don't reach the test harness, but
|
||||
// ok()/is() do...
|
||||
try {
|
||||
if (wh.onunload)
|
||||
wh.onunload();
|
||||
doNextTest();
|
||||
}
|
||||
catch (exc) {
|
||||
win.close();
|
||||
ok(false, "Unexpected exception: " + exc + "\n" + exc.stack);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
};
|
||||
// Why is unload fired before load?
|
||||
if (!loaded)
|
||||
return;
|
||||
|
||||
win.removeEventListener("unload", onunload, false);
|
||||
wh.win = win;
|
||||
|
||||
executeSoon(function () {
|
||||
// Some exceptions that reach here don't reach the test harness, but
|
||||
// ok()/is() do...
|
||||
try {
|
||||
if (wh.onunload)
|
||||
wh.onunload();
|
||||
doNextTest();
|
||||
}
|
||||
catch (exc) {
|
||||
win.close();
|
||||
ok(false, "Unexpected exception: " + exc + "\n" + exc.stack);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
winWatch.registerNotification(windowObserver);
|
||||
winWatch.openWindow(null,
|
||||
"chrome://browser/content/sanitize.xul",
|
||||
|
|
|
@ -618,30 +618,29 @@ function ensureHistoryClearedState(aURIs, aShouldBeCleared) {
|
|||
* A function that will be called once the dialog has loaded
|
||||
*/
|
||||
function openWindow(aOnloadCallback) {
|
||||
let windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
winWatch.unregisterNotification(this);
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
win.addEventListener("load", function onload(event) {
|
||||
win.removeEventListener("load", onload, false);
|
||||
executeSoon(function () {
|
||||
// Some exceptions that reach here don't reach the test harness, but
|
||||
// ok()/is() do...
|
||||
try {
|
||||
aOnloadCallback(win);
|
||||
doNextTest();
|
||||
}
|
||||
catch (exc) {
|
||||
win.close();
|
||||
ok(false, "Unexpected exception: " + exc + "\n" + exc.stack);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
|
||||
winWatch.unregisterNotification(windowObserver);
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
win.addEventListener("load", function onload(event) {
|
||||
win.removeEventListener("load", onload, false);
|
||||
executeSoon(function () {
|
||||
// Some exceptions that reach here don't reach the test harness, but
|
||||
// ok()/is() do...
|
||||
try {
|
||||
aOnloadCallback(win);
|
||||
doNextTest();
|
||||
}
|
||||
catch (exc) {
|
||||
win.close();
|
||||
ok(false, "Unexpected exception: " + exc + "\n" + exc.stack);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
winWatch.registerNotification(windowObserver);
|
||||
winWatch.openWindow(null,
|
||||
"chrome://browser/content/sanitize.xul",
|
||||
|
|
|
@ -47,47 +47,45 @@ const TEST_URI = "http://www.mozilla.org/";
|
|||
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Ci.nsIWindowWatcher);
|
||||
|
||||
var windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
var organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
organizer.addEventListener("load", function onLoad(event) {
|
||||
organizer.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
// Check left pane.
|
||||
ok(PlacesUIUtils.leftPaneFolderId > 0,
|
||||
"Left pane folder correctly created");
|
||||
var leftPaneItems =
|
||||
PlacesUtils.annotations
|
||||
.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
|
||||
is(leftPaneItems.length, 1,
|
||||
"We correctly have only 1 left pane folder");
|
||||
var leftPaneRoot = leftPaneItems[0];
|
||||
is(leftPaneRoot, PlacesUIUtils.leftPaneFolderId,
|
||||
"leftPaneFolderId getter has correct value");
|
||||
// Check version has been upgraded.
|
||||
var version =
|
||||
PlacesUtils.annotations.getItemAnnotation(leftPaneRoot,
|
||||
ORGANIZER_FOLDER_ANNO);
|
||||
is(version, ORGANIZER_LEFTPANE_VERSION,
|
||||
"Left pane version has been correctly upgraded");
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
ww.unregisterNotification(windowObserver);
|
||||
var organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
organizer.addEventListener("load", function onLoad(event) {
|
||||
organizer.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
// Check left pane.
|
||||
ok(PlacesUIUtils.leftPaneFolderId > 0,
|
||||
"Left pane folder correctly created");
|
||||
var leftPaneItems =
|
||||
PlacesUtils.annotations
|
||||
.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
|
||||
is(leftPaneItems.length, 1,
|
||||
"We correctly have only 1 left pane folder");
|
||||
var leftPaneRoot = leftPaneItems[0];
|
||||
is(leftPaneRoot, PlacesUIUtils.leftPaneFolderId,
|
||||
"leftPaneFolderId getter has correct value");
|
||||
// Check version has been upgraded.
|
||||
var version =
|
||||
PlacesUtils.annotations.getItemAnnotation(leftPaneRoot,
|
||||
ORGANIZER_FOLDER_ANNO);
|
||||
is(version, ORGANIZER_LEFTPANE_VERSION,
|
||||
"Left pane version has been correctly upgraded");
|
||||
|
||||
// Check left pane is populated.
|
||||
organizer.PlacesOrganizer.selectLeftPaneQuery('History');
|
||||
is(organizer.PlacesOrganizer._places.selectedNode.itemId,
|
||||
PlacesUIUtils.leftPaneQueries["History"],
|
||||
"Library left pane is populated and working");
|
||||
// Check left pane is populated.
|
||||
organizer.PlacesOrganizer.selectLeftPaneQuery('History');
|
||||
is(organizer.PlacesOrganizer._places.selectedNode.itemId,
|
||||
PlacesUIUtils.leftPaneQueries["History"],
|
||||
"Library left pane is populated and working");
|
||||
|
||||
// Close Library window.
|
||||
organizer.close();
|
||||
// No need to cleanup anything, we have a correct left pane now.
|
||||
finish();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
// Close Library window.
|
||||
organizer.close();
|
||||
// No need to cleanup anything, we have a correct left pane now.
|
||||
finish();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
|
|
@ -225,17 +225,15 @@ gTests.push({
|
|||
var tagsField = this.window.document.getElementById("editBMPanel_tagsField");
|
||||
var self = this;
|
||||
|
||||
var windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowclosed" &&
|
||||
aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL) {
|
||||
ww.unregisterNotification(this);
|
||||
tagsField.popup.removeEventListener("popuphidden", popupListener, true);
|
||||
ok(false, "Dialog window should not be closed by pressing Enter on the autocomplete popup");
|
||||
self.finish();
|
||||
}
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowclosed" &&
|
||||
aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL) {
|
||||
ww.unregisterNotification(windowObserver);
|
||||
tagsField.popup.removeEventListener("popuphidden", popupListener, true);
|
||||
ok(false, "Dialog window should not be closed by pressing Enter on the autocomplete popup");
|
||||
self.finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var popupListener = {
|
||||
handleEvent: function(aEvent) {
|
||||
|
@ -384,17 +382,15 @@ gTests.push({
|
|||
var tagsField = this.window.document.getElementById("editBMPanel_tagsField");
|
||||
var self = this;
|
||||
|
||||
var windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowclosed" &&
|
||||
aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL) {
|
||||
ww.unregisterNotification(this);
|
||||
tagsField.popup.removeEventListener("popuphidden", popupListener, true);
|
||||
ok(false, "Dialog window should not be closed by pressing Escape on the autocomplete popup");
|
||||
self.finish();
|
||||
}
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowclosed" &&
|
||||
aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL) {
|
||||
ww.unregisterNotification(windowObserver);
|
||||
tagsField.popup.removeEventListener("popuphidden", popupListener, true);
|
||||
ok(false, "Dialog window should not be closed by pressing Escape on the autocomplete popup");
|
||||
self.finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var popupListener = {
|
||||
handleEvent: function(aEvent) {
|
||||
|
@ -486,17 +482,15 @@ gTests.push({
|
|||
var folderTree = this.window.document.getElementById("editBMPanel_folderTree");
|
||||
var self = this;
|
||||
|
||||
var windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowclosed" &&
|
||||
aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL_MINIMAL_UI) {
|
||||
ww.unregisterNotification(this);
|
||||
ok(self._cleanShutdown,
|
||||
"Dialog window should not be closed by pressing ESC in folder name textbox");
|
||||
self.finish();
|
||||
}
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowclosed" &&
|
||||
aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL_MINIMAL_UI) {
|
||||
ww.unregisterNotification(windowObserver);
|
||||
ok(self._cleanShutdown,
|
||||
"Dialog window should not be closed by pressing ESC in folder name textbox");
|
||||
self.finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
ww.registerNotification(windowObserver);
|
||||
|
||||
folderTree.addEventListener("DOMAttrModified", function onDOMAttrModified(event) {
|
||||
|
@ -601,28 +595,26 @@ function open_properties_dialog() {
|
|||
"We have a places node selected: " + tree.selectedNode.title);
|
||||
|
||||
// Wait for the Properties dialog.
|
||||
var windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
var win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
win.addEventListener("focus", function(event) {
|
||||
win.removeEventListener("focus", arguments.callee, false);
|
||||
// Windows has been loaded, execute our test now.
|
||||
executeSoon(function () {
|
||||
// Ensure overlay is loaded
|
||||
ok(win.gEditItemOverlay._initialized, "EditItemOverlay is initialized");
|
||||
gCurrentTest.window = win;
|
||||
try {
|
||||
gCurrentTest.run();
|
||||
} catch (ex) {
|
||||
ok(false, "An error occured during test run: " + ex.message);
|
||||
}
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
ww.unregisterNotification(windowObserver);
|
||||
var win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
win.addEventListener("focus", function (event) {
|
||||
win.removeEventListener("focus", arguments.callee, false);
|
||||
// Windows has been loaded, execute our test now.
|
||||
executeSoon(function () {
|
||||
// Ensure overlay is loaded
|
||||
ok(win.gEditItemOverlay._initialized, "EditItemOverlay is initialized");
|
||||
gCurrentTest.window = win;
|
||||
try {
|
||||
gCurrentTest.run();
|
||||
} catch (ex) {
|
||||
ok(false, "An error occured during test run: " + ex.message);
|
||||
}
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
ww.registerNotification(windowObserver);
|
||||
|
||||
var command = null;
|
||||
|
|
|
@ -55,54 +55,52 @@ function test() {
|
|||
});
|
||||
|
||||
function testForgetThisSiteVisibility(selectionCount, funcNext) {
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
organizer.addEventListener("load", function onLoad(event) {
|
||||
organizer.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
// Select History in the left pane.
|
||||
organizer.PlacesOrganizer.selectLeftPaneQuery('History');
|
||||
let PO = organizer.PlacesOrganizer;
|
||||
let histContainer = PO._places.selectedNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
|
||||
histContainer.containerOpen = true;
|
||||
PO._places.selectNode(histContainer.getChild(0));
|
||||
// Select the first history entry.
|
||||
let doc = organizer.document;
|
||||
let tree = PO._content;
|
||||
let selection = tree.view.selection;
|
||||
selection.clearSelection();
|
||||
selection.rangedSelect(0, selectionCount - 1, true);
|
||||
is(selection.count, selectionCount,
|
||||
"The selected range is as big as expected");
|
||||
// Open the context menu
|
||||
let contextmenu = doc.getElementById("placesContext");
|
||||
contextmenu.addEventListener("popupshown", function() {
|
||||
contextmenu.removeEventListener("popupshown", arguments.callee, false);
|
||||
let forgetThisSite = doc.getElementById("placesContext_deleteHost");
|
||||
let hideForgetThisSite = (selectionCount != 1);
|
||||
is(forgetThisSite.hidden, hideForgetThisSite,
|
||||
"The Forget this site menu item should " + (hideForgetThisSite ? "" : "not ") +
|
||||
"be hidden with " + selectionCount + " items selected");
|
||||
// Close the context menu
|
||||
contextmenu.hidePopup();
|
||||
// Close Library window.
|
||||
organizer.close();
|
||||
// Proceed
|
||||
funcNext();
|
||||
}, false);
|
||||
let event = document.createEvent("MouseEvents");
|
||||
event.initMouseEvent("contextmenu", true, true, organizer, 0,
|
||||
0, 0, 0, 0, false, false, false, false,
|
||||
0, null);
|
||||
tree.dispatchEvent(event);
|
||||
});
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
ww.unregisterNotification(observer);
|
||||
let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
organizer.addEventListener("load", function onLoad(event) {
|
||||
organizer.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
// Select History in the left pane.
|
||||
organizer.PlacesOrganizer.selectLeftPaneQuery('History');
|
||||
let PO = organizer.PlacesOrganizer;
|
||||
let histContainer = PO._places.selectedNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
|
||||
histContainer.containerOpen = true;
|
||||
PO._places.selectNode(histContainer.getChild(0));
|
||||
// Select the first history entry.
|
||||
let doc = organizer.document;
|
||||
let tree = PO._content;
|
||||
let selection = tree.view.selection;
|
||||
selection.clearSelection();
|
||||
selection.rangedSelect(0, selectionCount - 1, true);
|
||||
is(selection.count, selectionCount,
|
||||
"The selected range is as big as expected");
|
||||
// Open the context menu
|
||||
let contextmenu = doc.getElementById("placesContext");
|
||||
contextmenu.addEventListener("popupshown", function() {
|
||||
contextmenu.removeEventListener("popupshown", arguments.callee, false);
|
||||
let forgetThisSite = doc.getElementById("placesContext_deleteHost");
|
||||
let hideForgetThisSite = (selectionCount != 1);
|
||||
is(forgetThisSite.hidden, hideForgetThisSite,
|
||||
"The Forget this site menu item should " + (hideForgetThisSite ? "" : "not ") +
|
||||
"be hidden with " + selectionCount + " items selected");
|
||||
// Close the context menu
|
||||
contextmenu.hidePopup();
|
||||
// Close Library window.
|
||||
organizer.close();
|
||||
// Proceed
|
||||
funcNext();
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
let event = document.createEvent("MouseEvents");
|
||||
event.initMouseEvent("contextmenu", true, true, organizer, 0,
|
||||
0, 0, 0, 0, false, false, false, false,
|
||||
0, null);
|
||||
tree.dispatchEvent(event);
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
ww.registerNotification(observer);
|
||||
ww.openWindow(null,
|
||||
|
|
|
@ -219,21 +219,19 @@ function nextTest() {
|
|||
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Ci.nsIWindowWatcher);
|
||||
|
||||
var windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
gLibrary.addEventListener("load", function onLoad(event) {
|
||||
gLibrary.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
// Execute tests.
|
||||
nextTest();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
ww.unregisterNotification(windowObserver);
|
||||
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
gLibrary.addEventListener("load", function onLoad(event) {
|
||||
gLibrary.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
// Execute tests.
|
||||
nextTest();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
function test() {
|
||||
dump("Starting test browser_library_infoBox.js\n");
|
||||
|
|
|
@ -176,21 +176,19 @@ function nextTest() {
|
|||
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Ci.nsIWindowWatcher);
|
||||
|
||||
var windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
gLibrary.addEventListener("load", function onLoad(event) {
|
||||
gLibrary.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
// Execute tests.
|
||||
nextTest();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
ww.unregisterNotification(windowObserver);
|
||||
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
gLibrary.addEventListener("load", function onLoad(event) {
|
||||
gLibrary.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
// Execute tests.
|
||||
nextTest();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
|
|
@ -49,34 +49,32 @@ var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
|||
// correctTitle: original and correct query's title.
|
||||
var leftPaneQueries = [];
|
||||
|
||||
var windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
var organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
organizer.addEventListener("load", function onLoad(event) {
|
||||
organizer.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
// Check titles have been fixed.
|
||||
for (var i = 0; i < leftPaneQueries.length; i++) {
|
||||
var query = leftPaneQueries[i];
|
||||
is(PlacesUtils.bookmarks.getItemTitle(query.itemId),
|
||||
query.correctTitle, "Title is correct for query " + query.name);
|
||||
if ("concreteId" in query) {
|
||||
is(PlacesUtils.bookmarks.getItemTitle(query.concreteId),
|
||||
query.concreteTitle, "Concrete title is correct for query " + query.name);
|
||||
}
|
||||
}
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
ww.unregisterNotification(windowObserver);
|
||||
var organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
organizer.addEventListener("load", function onLoad(event) {
|
||||
organizer.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
// Check titles have been fixed.
|
||||
for (var i = 0; i < leftPaneQueries.length; i++) {
|
||||
var query = leftPaneQueries[i];
|
||||
is(PlacesUtils.bookmarks.getItemTitle(query.itemId),
|
||||
query.correctTitle, "Title is correct for query " + query.name);
|
||||
if ("concreteId" in query) {
|
||||
is(PlacesUtils.bookmarks.getItemTitle(query.concreteId),
|
||||
query.concreteTitle, "Concrete title is correct for query " + query.name);
|
||||
}
|
||||
}
|
||||
|
||||
// Close Library window.
|
||||
organizer.close();
|
||||
// No need to cleanup anything, we have a correct left pane now.
|
||||
finish();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
// Close Library window.
|
||||
organizer.close();
|
||||
// No need to cleanup anything, we have a correct left pane now.
|
||||
finish();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
|
|
@ -267,19 +267,17 @@ function test() {
|
|||
// Window watcher for Library window.
|
||||
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Ci.nsIWindowWatcher);
|
||||
var windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
gLibrary.addEventListener("load", function onLoad(event) {
|
||||
gLibrary.removeEventListener("load", onLoad, false);
|
||||
// Kick off tests.
|
||||
setTimeout(runNextTest, 0);
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
ww.unregisterNotification(windowObserver);
|
||||
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
gLibrary.addEventListener("load", function onLoad(event) {
|
||||
gLibrary.removeEventListener("load", onLoad, false);
|
||||
// Kick off tests.
|
||||
setTimeout(runNextTest, 0);
|
||||
}, false);
|
||||
}
|
||||
|
||||
// Open Library window.
|
||||
ww.registerNotification(windowObserver);
|
||||
|
|
|
@ -48,22 +48,20 @@
|
|||
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Ci.nsIWindowWatcher);
|
||||
|
||||
let windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
win.addEventListener("load", function onLoad(event) {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
ok(true, "Library has been correctly opened");
|
||||
win.close();
|
||||
finish();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
ww.unregisterNotification(windowObserver);
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
win.addEventListener("load", function onLoad(event) {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
ok(true, "Library has been correctly opened");
|
||||
win.close();
|
||||
finish();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
|
|
@ -53,37 +53,35 @@ const TEST_URI = "http://www.mozilla.org/";
|
|||
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Ci.nsIWindowWatcher);
|
||||
|
||||
let windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
organizer.addEventListener("load", function onLoad(event) {
|
||||
organizer.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
let contentTree = organizer.document.getElementById("placeContent");
|
||||
isnot(contentTree, null, "Sanity check: placeContent tree should exist");
|
||||
isnot(organizer.PlacesOrganizer, null, "Sanity check: PlacesOrganizer should exist");
|
||||
isnot(organizer.gEditItemOverlay, null, "Sanity check: gEditItemOverlay should exist");
|
||||
isnot(organizer.gEditItemOverlay.itemId, -1, "Editing a bookmark");
|
||||
// Select History in the left pane.
|
||||
organizer.PlacesOrganizer.selectLeftPaneQuery('History');
|
||||
// Select the first history entry.
|
||||
let selection = contentTree.view.selection;
|
||||
selection.clearSelection();
|
||||
selection.rangedSelect(0, 0, true);
|
||||
// Check the panel is editing the history entry.
|
||||
is(organizer.gEditItemOverlay.itemId, -1, "Editing an history entry");
|
||||
// Close Library window.
|
||||
organizer.close();
|
||||
// Clean up history.
|
||||
PlacesUtils.history.QueryInterface(Ci.nsIBrowserHistory).removeAllPages();
|
||||
finish();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
ww.unregisterNotification(windowObserver);
|
||||
let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
organizer.addEventListener("load", function onLoad(event) {
|
||||
organizer.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
let contentTree = organizer.document.getElementById("placeContent");
|
||||
isnot(contentTree, null, "Sanity check: placeContent tree should exist");
|
||||
isnot(organizer.PlacesOrganizer, null, "Sanity check: PlacesOrganizer should exist");
|
||||
isnot(organizer.gEditItemOverlay, null, "Sanity check: gEditItemOverlay should exist");
|
||||
isnot(organizer.gEditItemOverlay.itemId, -1, "Editing a bookmark");
|
||||
// Select History in the left pane.
|
||||
organizer.PlacesOrganizer.selectLeftPaneQuery('History');
|
||||
// Select the first history entry.
|
||||
let selection = contentTree.view.selection;
|
||||
selection.clearSelection();
|
||||
selection.rangedSelect(0, 0, true);
|
||||
// Check the panel is editing the history entry.
|
||||
is(organizer.gEditItemOverlay.itemId, -1, "Editing an history entry");
|
||||
// Close Library window.
|
||||
organizer.close();
|
||||
// Clean up history.
|
||||
PlacesUtils.history.QueryInterface(Ci.nsIBrowserHistory).removeAllPages();
|
||||
finish();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
|
|
@ -300,18 +300,16 @@ function test() {
|
|||
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Ci.nsIWindowWatcher);
|
||||
|
||||
var windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
var win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
win.addEventListener("load", function onLoad(event) {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () testHelper(win));
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
ww.unregisterNotification(windowObserver);
|
||||
var win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
win.addEventListener("load", function onLoad(event) {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () testHelper(win));
|
||||
}, false);
|
||||
}
|
||||
|
||||
ww.registerNotification(windowObserver);
|
||||
ww.openWindow(null,
|
||||
|
|
|
@ -58,18 +58,16 @@ function test() {
|
|||
// Open Library, we will check the left pane.
|
||||
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Ci.nsIWindowWatcher);
|
||||
var windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
gLibrary.addEventListener("load", function onLoad(event) {
|
||||
gLibrary.removeEventListener("load", onLoad, false);
|
||||
executeSoon(startTest);
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
ww.unregisterNotification(windowObserver);
|
||||
gLibrary = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
gLibrary.addEventListener("load", function onLoad(event) {
|
||||
gLibrary.removeEventListener("load", onLoad, false);
|
||||
executeSoon(startTest);
|
||||
}, false);
|
||||
}
|
||||
ww.registerNotification(windowObserver);
|
||||
ww.openWindow(null,
|
||||
"chrome://browser/content/places/places.xul",
|
||||
|
|
|
@ -124,24 +124,22 @@ function test() {
|
|||
if (preFunc)
|
||||
preFunc();
|
||||
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
let alertDialog = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
alertDialog.addEventListener("load", function() {
|
||||
alertDialog.removeEventListener("load", arguments.callee, false);
|
||||
info("alert dialog observed as expected");
|
||||
executeSoon(function() {
|
||||
alertDialog.close();
|
||||
toggleSidebar(currentTest.sidebarName);
|
||||
currentTest.cleanup();
|
||||
postFunc();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
ww.unregisterNotification(observer);
|
||||
let alertDialog = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
alertDialog.addEventListener("load", function () {
|
||||
alertDialog.removeEventListener("load", arguments.callee, false);
|
||||
info("alert dialog observed as expected");
|
||||
executeSoon(function () {
|
||||
alertDialog.close();
|
||||
toggleSidebar(currentTest.sidebarName);
|
||||
currentTest.cleanup();
|
||||
postFunc();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
ww.registerNotification(observer);
|
||||
|
||||
// Select the inserted places item.
|
||||
|
|
|
@ -271,32 +271,30 @@ function test() {
|
|||
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Ci.nsIWindowWatcher);
|
||||
|
||||
let windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
win.addEventListener("load", function onLoad(event) {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
let tree = win.document.getElementById("placeContent");
|
||||
isnot(tree, null, "sanity check: placeContent tree should exist");
|
||||
// Run the tests.
|
||||
testSortByColAndDir(win, tree, true);
|
||||
testSortByColAndDir(win, tree, false);
|
||||
testSortByDir(win, tree, true);
|
||||
testSortByDir(win, tree, false);
|
||||
testInvalid(win, tree);
|
||||
// Reset the sort to SORT_BY_NONE.
|
||||
setSort(win, tree, false, false);
|
||||
// Close the window and finish.
|
||||
win.close();
|
||||
finish();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
ww.unregisterNotification(windowObserver);
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
win.addEventListener("load", function onLoad(event) {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
let tree = win.document.getElementById("placeContent");
|
||||
isnot(tree, null, "sanity check: placeContent tree should exist");
|
||||
// Run the tests.
|
||||
testSortByColAndDir(win, tree, true);
|
||||
testSortByColAndDir(win, tree, false);
|
||||
testSortByDir(win, tree, true);
|
||||
testSortByDir(win, tree, false);
|
||||
testInvalid(win, tree);
|
||||
// Reset the sort to SORT_BY_NONE.
|
||||
setSort(win, tree, false, false);
|
||||
// Close the window and finish.
|
||||
win.close();
|
||||
finish();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
ww.registerNotification(windowObserver);
|
||||
ww.openWindow(null,
|
||||
|
|
|
@ -19,15 +19,13 @@ function test() {
|
|||
var obs = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
|
||||
var observer = {
|
||||
observe: function(win, topic, data) {
|
||||
if (topic != "app-handler-pane-loaded")
|
||||
return;
|
||||
function observer(win, topic, data) {
|
||||
if (topic != "app-handler-pane-loaded")
|
||||
return;
|
||||
|
||||
obs.removeObserver(observer, "app-handler-pane-loaded");
|
||||
runTest(win);
|
||||
}
|
||||
};
|
||||
obs.removeObserver(observer, "app-handler-pane-loaded");
|
||||
runTest(win);
|
||||
}
|
||||
obs.addObserver(observer, "app-handler-pane-loaded", false);
|
||||
|
||||
openDialog("chrome://browser/content/preferences/preferences.xul", "Preferences",
|
||||
|
|
|
@ -45,17 +45,17 @@ function test() {
|
|||
getService(Ci.nsIPrivateBrowsingService);
|
||||
let consoleService = Cc["@mozilla.org/consoleservice;1"].
|
||||
getService(Ci.nsIConsoleService);
|
||||
const kExitMessage = "Message to signal the end of the test";
|
||||
const EXIT_MESSAGE = "Message to signal the end of the test";
|
||||
waitForExplicitFinish();
|
||||
|
||||
let consoleObserver = {
|
||||
observe: function (aMessage) {
|
||||
if (!aMessage.message)
|
||||
this.gotNull = true;
|
||||
else if (aMessage.message == kExitMessage) {
|
||||
else if (aMessage.message == EXIT_MESSAGE) {
|
||||
// make sure that the null message was received
|
||||
ok(this.gotNull, "Console should be cleared after leaving the private mode");
|
||||
// make sure the console does not contain kTestMessage
|
||||
// make sure the console does not contain TEST_MESSAGE
|
||||
ok(!messageExists(), "Message should not exist after leaving the private mode");
|
||||
|
||||
consoleService.unregisterListener(consoleObserver);
|
||||
|
@ -72,15 +72,15 @@ function test() {
|
|||
consoleService.getMessageArray(out, {});
|
||||
let messages = out.value || [];
|
||||
for (let i = 0; i < messages.length; ++i) {
|
||||
if (messages[i].message == kTestMessage)
|
||||
if (messages[i].message == TEST_MESSAGE)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const kTestMessage = "Test message from the private browsing test";
|
||||
const TEST_MESSAGE = "Test message from the private browsing test";
|
||||
// make sure that the console is not empty
|
||||
consoleService.logStringMessage(kTestMessage);
|
||||
consoleService.logStringMessage(TEST_MESSAGE);
|
||||
ok(!consoleObserver.gotNull, "Console shouldn't be cleared yet");
|
||||
ok(messageExists(), "Message should exist before leaving the private mode");
|
||||
|
||||
|
@ -90,5 +90,5 @@ function test() {
|
|||
pb.privateBrowsingEnabled = false;
|
||||
|
||||
// signal the end of the test
|
||||
consoleService.logStringMessage(kExitMessage);
|
||||
consoleService.logStringMessage(EXIT_MESSAGE);
|
||||
}
|
||||
|
|
|
@ -40,30 +40,26 @@
|
|||
// handler prevents the private browsing mode transition.
|
||||
|
||||
function test() {
|
||||
const kTestPage1 = "data:text/html,<body%20onbeforeunload='return%20false;'>first</body>";
|
||||
const kTestPage2 = "data:text/html,<body%20onbeforeunload='return%20false;'>second</body>";
|
||||
const TEST_PAGE_1 = "data:text/html,<body%20onbeforeunload='return%20false;'>first</body>";
|
||||
const TEST_PAGE_2 = "data:text/html,<body%20onbeforeunload='return%20false;'>second</body>";
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"]
|
||||
.getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
let promptHelper = {
|
||||
rejectDialog: 0,
|
||||
acceptDialog: 0,
|
||||
confirmCalls: 0,
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
let dialogWin = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
this.confirmCalls++;
|
||||
let button;
|
||||
if (this.acceptDialog-- > 0)
|
||||
button = dialogWin.document.documentElement.getButton("accept").click();
|
||||
else if (this.rejectDialog-- > 0)
|
||||
button = dialogWin.document.documentElement.getButton("cancel").click();
|
||||
}
|
||||
};
|
||||
let rejectDialog = 0;
|
||||
let acceptDialog = 0;
|
||||
let confirmCalls = 0;
|
||||
function promptObserver(aSubject, aTopic, aData) {
|
||||
let dialogWin = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
confirmCalls++;
|
||||
if (acceptDialog-- > 0)
|
||||
dialogWin.document.documentElement.getButton("accept").click();
|
||||
else if (rejectDialog-- > 0)
|
||||
dialogWin.document.documentElement.getButton("cancel").click();
|
||||
}
|
||||
|
||||
Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(Ci.nsIObserverService)
|
||||
.addObserver(promptHelper, "common-dialog-loaded", false);
|
||||
.addObserver(promptObserver, "common-dialog-loaded", false);
|
||||
|
||||
waitForExplicitFinish();
|
||||
let browser1 = gBrowser.getBrowserForTab(gBrowser.addTab());
|
||||
|
@ -74,35 +70,35 @@ function test() {
|
|||
browser2.addEventListener("load", function() {
|
||||
browser2.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
promptHelper.rejectDialog = 1;
|
||||
rejectDialog = 1;
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
ok(!pb.privateBrowsingEnabled, "Private browsing mode should not have been activated");
|
||||
is(promptHelper.confirmCalls, 1, "Only one confirm box should be shown");
|
||||
is(confirmCalls, 1, "Only one confirm box should be shown");
|
||||
is(gBrowser.tabContainer.childNodes.length, 3,
|
||||
"No tabs should be closed because private browsing mode transition was canceled");
|
||||
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild).currentURI.spec, "about:blank",
|
||||
"The first tab should be a blank tab");
|
||||
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild.nextSibling).currentURI.spec, kTestPage1,
|
||||
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild.nextSibling).currentURI.spec, TEST_PAGE_1,
|
||||
"The middle tab should be the same one we opened");
|
||||
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, kTestPage2,
|
||||
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, TEST_PAGE_2,
|
||||
"The last tab should be the same one we opened");
|
||||
is(promptHelper.rejectDialog, 0, "Only one confirm dialog should have been rejected");
|
||||
is(rejectDialog, 0, "Only one confirm dialog should have been rejected");
|
||||
|
||||
promptHelper.confirmCalls = 0;
|
||||
promptHelper.acceptDialog = 2;
|
||||
confirmCalls = 0;
|
||||
acceptDialog = 2;
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
ok(pb.privateBrowsingEnabled, "Private browsing mode should have been activated");
|
||||
is(promptHelper.confirmCalls, 2, "Only two confirm boxes should be shown");
|
||||
is(confirmCalls, 2, "Only two confirm boxes should be shown");
|
||||
is(gBrowser.tabContainer.childNodes.length, 1,
|
||||
"Incorrect number of tabs after transition into private browsing");
|
||||
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, "about:privatebrowsing",
|
||||
is(gBrowser.currentURI.spec, "about:privatebrowsing",
|
||||
"Incorrect page displayed after private browsing transition");
|
||||
is(promptHelper.acceptDialog, 0, "Two confirm dialogs should have been accepted");
|
||||
is(acceptDialog, 0, "Two confirm dialogs should have been accepted");
|
||||
|
||||
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
@ -111,26 +107,26 @@ function test() {
|
|||
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
promptHelper.confirmCalls = 0;
|
||||
promptHelper.rejectDialog = 1;
|
||||
confirmCalls = 0;
|
||||
rejectDialog = 1;
|
||||
pb.privateBrowsingEnabled = false;
|
||||
|
||||
ok(pb.privateBrowsingEnabled, "Private browsing mode should not have been deactivated");
|
||||
is(promptHelper.confirmCalls, 1, "Only one confirm box should be shown");
|
||||
is(confirmCalls, 1, "Only one confirm box should be shown");
|
||||
is(gBrowser.tabContainer.childNodes.length, 2,
|
||||
"No tabs should be closed because private browsing mode transition was canceled");
|
||||
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild).currentURI.spec, kTestPage1,
|
||||
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild).currentURI.spec, TEST_PAGE_1,
|
||||
"The first tab should be the same one we opened");
|
||||
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, kTestPage2,
|
||||
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, TEST_PAGE_2,
|
||||
"The last tab should be the same one we opened");
|
||||
is(promptHelper.rejectDialog, 0, "Only one confirm dialog should have been rejected");
|
||||
is(rejectDialog, 0, "Only one confirm dialog should have been rejected");
|
||||
|
||||
promptHelper.confirmCalls = 0;
|
||||
promptHelper.acceptDialog = 2;
|
||||
confirmCalls = 0;
|
||||
acceptDialog = 2;
|
||||
pb.privateBrowsingEnabled = false;
|
||||
|
||||
ok(!pb.privateBrowsingEnabled, "Private browsing mode should have been deactivated");
|
||||
is(promptHelper.confirmCalls, 2, "Only two confirm boxes should be shown");
|
||||
is(confirmCalls, 2, "Only two confirm boxes should be shown");
|
||||
is(gBrowser.tabContainer.childNodes.length, 3,
|
||||
"Incorrect number of tabs after transition into private browsing");
|
||||
|
||||
|
@ -143,28 +139,31 @@ function test() {
|
|||
|
||||
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild).currentURI.spec, "about:blank",
|
||||
"The first tab should be a blank tab");
|
||||
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild.nextSibling).currentURI.spec, kTestPage1,
|
||||
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild.nextSibling).currentURI.spec, TEST_PAGE_1,
|
||||
"The middle tab should be the same one we opened");
|
||||
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, kTestPage2,
|
||||
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, TEST_PAGE_2,
|
||||
"The last tab should be the same one we opened");
|
||||
is(promptHelper.acceptDialog, 0, "Two confirm dialogs should have been accepted");
|
||||
is(promptHelper.acceptDialog, 0, "Two prompts should have been raised");
|
||||
is(acceptDialog, 0, "Two confirm dialogs should have been accepted");
|
||||
is(acceptDialog, 0, "Two prompts should have been raised");
|
||||
|
||||
promptHelper.acceptDialog = 2;
|
||||
acceptDialog = 2;
|
||||
gBrowser.removeTab(gBrowser.tabContainer.lastChild);
|
||||
gBrowser.removeTab(gBrowser.tabContainer.lastChild);
|
||||
|
||||
Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(Ci.nsIObserverService)
|
||||
.removeObserver(promptObserver, "common-dialog-loaded", false);
|
||||
finish();
|
||||
}
|
||||
for (let i = 0; i < gBrowser.browsers.length; ++i)
|
||||
gBrowser.browsers[i].addEventListener("load", waitForLoad, true);
|
||||
}, true);
|
||||
gBrowser.selectedBrowser.loadURI(kTestPage2);
|
||||
gBrowser.selectedBrowser.loadURI(TEST_PAGE_2);
|
||||
}, true);
|
||||
gBrowser.selectedBrowser.loadURI(kTestPage1);
|
||||
gBrowser.selectedBrowser.loadURI(TEST_PAGE_1);
|
||||
}, true);
|
||||
}, true);
|
||||
browser2.loadURI(kTestPage2);
|
||||
browser2.loadURI(TEST_PAGE_2);
|
||||
}, true);
|
||||
browser1.loadURI(kTestPage1);
|
||||
browser1.loadURI(TEST_PAGE_1);
|
||||
}
|
||||
|
|
|
@ -65,19 +65,17 @@ function test() {
|
|||
function testCheckbox() {
|
||||
let obsSvc = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
obsSvc.addObserver({
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
obsSvc.removeObserver(this, "cert-exception-ui-ready", false);
|
||||
ok(win.gCert, "The certificate information should be available now");
|
||||
obsSvc.addObserver(function (aSubject, aTopic, aData) {
|
||||
obsSvc.removeObserver(arguments.callee, "cert-exception-ui-ready", false);
|
||||
ok(win.gCert, "The certificate information should be available now");
|
||||
|
||||
let checkbox = win.document.getElementById("permanent");
|
||||
ok(checkbox.hasAttribute("disabled"),
|
||||
"the permanent checkbox should be disabled when handling the private browsing mode");
|
||||
ok(!checkbox.hasAttribute("checked"),
|
||||
"the permanent checkbox should not be checked when handling the private browsing mode");
|
||||
win.close();
|
||||
step2();
|
||||
}
|
||||
let checkbox = win.document.getElementById("permanent");
|
||||
ok(checkbox.hasAttribute("disabled"),
|
||||
"the permanent checkbox should be disabled when handling the private browsing mode");
|
||||
ok(!checkbox.hasAttribute("checked"),
|
||||
"the permanent checkbox should not be checked when handling the private browsing mode");
|
||||
win.close();
|
||||
step2();
|
||||
}, "cert-exception-ui-ready", false);
|
||||
}
|
||||
var win = openDialog(EXCEPTIONS_DLG_URL, "", EXCEPTIONS_DLG_FEATURES, params);
|
||||
|
@ -94,19 +92,17 @@ function test() {
|
|||
function testCheckbox() {
|
||||
let obsSvc = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
obsSvc.addObserver({
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
obsSvc.removeObserver(this, "cert-exception-ui-ready", false);
|
||||
ok(win.gCert, "The certificate information should be available now");
|
||||
obsSvc.addObserver(function (aSubject, aTopic, aData) {
|
||||
obsSvc.removeObserver(arguments.callee, "cert-exception-ui-ready", false);
|
||||
ok(win.gCert, "The certificate information should be available now");
|
||||
|
||||
let checkbox = win.document.getElementById("permanent");
|
||||
ok(!checkbox.hasAttribute("disabled"),
|
||||
"the permanent checkbox should not be disabled when not handling the private browsing mode");
|
||||
ok(checkbox.hasAttribute("checked"),
|
||||
"the permanent checkbox should be checked when not handling the private browsing mode");
|
||||
win.close();
|
||||
cleanup();
|
||||
}
|
||||
let checkbox = win.document.getElementById("permanent");
|
||||
ok(!checkbox.hasAttribute("disabled"),
|
||||
"the permanent checkbox should not be disabled when not handling the private browsing mode");
|
||||
ok(checkbox.hasAttribute("checked"),
|
||||
"the permanent checkbox should be checked when not handling the private browsing mode");
|
||||
win.close();
|
||||
cleanup();
|
||||
}, "cert-exception-ui-ready", false);
|
||||
}
|
||||
var win = openDialog(EXCEPTIONS_DLG_URL, "", EXCEPTIONS_DLG_FEATURES, params);
|
||||
|
|
|
@ -117,11 +117,9 @@ function test() {
|
|||
}
|
||||
}
|
||||
|
||||
let observer = {
|
||||
observe: function (aSubject, aTopic, aData) {
|
||||
isnot(aTopic, "domwindowopened", "The -private-toggle argument should be silent");
|
||||
}
|
||||
};
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
isnot(aTopic, "domwindowopened", "The -private-toggle argument should be silent");
|
||||
}
|
||||
ww.registerNotification(observer);
|
||||
|
||||
let tab = gBrowser.selectedTab;
|
||||
|
|
|
@ -50,33 +50,32 @@ function test() {
|
|||
waitForExplicitFinish();
|
||||
|
||||
function checkRememberOption(expectedDisabled, callback) {
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
win.addEventListener("load", function onLoad(event) {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
|
||||
executeSoon(function() {
|
||||
let doc = win.document;
|
||||
let remember = doc.getElementById("persistDomainAcceptance");
|
||||
ok(remember, "The remember checkbox should exist");
|
||||
ww.unregisterNotification(observer);
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
win.addEventListener("load", function onLoad(event) {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
|
||||
if (expectedDisabled)
|
||||
is(remember.getAttribute("disabled"), "true",
|
||||
"The checkbox should be disabled");
|
||||
else
|
||||
ok(!remember.hasAttribute("disabled"),
|
||||
"The checkbox should not be disabled");
|
||||
executeSoon(function () {
|
||||
let doc = win.document;
|
||||
let remember = doc.getElementById("persistDomainAcceptance");
|
||||
ok(remember, "The remember checkbox should exist");
|
||||
|
||||
win.close();
|
||||
callback();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
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);
|
||||
}
|
||||
ww.registerNotification(observer);
|
||||
|
||||
let remember = {};
|
||||
|
|
|
@ -44,45 +44,41 @@ function test() {
|
|||
getService(Ci.nsIPrivateBrowsingService);
|
||||
let os = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
let ss = Cc["@mozilla.org/browser/sessionstore;1"].
|
||||
getService(Ci.nsISessionStore);
|
||||
let pbCmd = document.getElementById("Tools:PrivateBrowsing");
|
||||
waitForExplicitFinish();
|
||||
|
||||
let observer = {
|
||||
pass: 1,
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
switch (aTopic) {
|
||||
case "private-browsing":
|
||||
setTimeout(function() {
|
||||
ok(document.getElementById("Tools:PrivateBrowsing").hasAttribute("disabled"),
|
||||
"The private browsing command should be disabled immediately after the mode switch");
|
||||
}, 0);
|
||||
break;
|
||||
let pass = 1;
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
switch (aTopic) {
|
||||
case "private-browsing":
|
||||
setTimeout(function () {
|
||||
ok(document.getElementById("Tools:PrivateBrowsing").hasAttribute("disabled"),
|
||||
"The private browsing command should be disabled immediately after the mode switch");
|
||||
}, 0);
|
||||
break;
|
||||
|
||||
case "private-browsing-transition-complete":
|
||||
if (this.pass++ == 1) {
|
||||
setTimeout(function() {
|
||||
ok(!pbCmd.hasAttribute("disabled"),
|
||||
"The private browsing command should be re-enabled after entering the private browsing mode");
|
||||
case "private-browsing-transition-complete":
|
||||
if (pass++ == 1) {
|
||||
setTimeout(function () {
|
||||
ok(!pbCmd.hasAttribute("disabled"),
|
||||
"The private browsing command should be re-enabled after entering the private browsing mode");
|
||||
|
||||
pb.privateBrowsingEnabled = false;
|
||||
}, 100);
|
||||
}
|
||||
else {
|
||||
setTimeout(function() {
|
||||
ok(!pbCmd.hasAttribute("disabled"),
|
||||
"The private browsing command should be re-enabled after exiting the private browsing mode");
|
||||
pb.privateBrowsingEnabled = false;
|
||||
}, 100);
|
||||
}
|
||||
else {
|
||||
setTimeout(function () {
|
||||
ok(!pbCmd.hasAttribute("disabled"),
|
||||
"The private browsing command should be re-enabled after exiting the private browsing mode");
|
||||
|
||||
os.removeObserver(observer, "private-browsing");
|
||||
os.removeObserver(observer, "private-browsing-transition-complete");
|
||||
finish();
|
||||
}, 100);
|
||||
}
|
||||
break;
|
||||
}
|
||||
os.removeObserver(observer, "private-browsing");
|
||||
os.removeObserver(observer, "private-browsing-transition-complete");
|
||||
finish();
|
||||
}, 100);
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
os.addObserver(observer, "private-browsing", false);
|
||||
os.addObserver(observer, "private-browsing-transition-complete", false);
|
||||
|
||||
|
|
|
@ -55,54 +55,53 @@ function test() {
|
|||
ok(visitId > 0, TEST_URI + " successfully marked visited");
|
||||
|
||||
function testForgetThisSiteVisibility(expected, funcNext) {
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic === "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
organizer.addEventListener("load", function onLoad(event) {
|
||||
organizer.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
// Select History in the left pane.
|
||||
let PO = organizer.PlacesOrganizer;
|
||||
PO.selectLeftPaneQuery('History');
|
||||
let histContainer = PO._places.selectedNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
|
||||
histContainer.containerOpen = true;
|
||||
PO._places.selectNode(histContainer.getChild(0));
|
||||
// Select the first history entry.
|
||||
let doc = organizer.document;
|
||||
let tree = PO._content;
|
||||
let selection = tree.view.selection;
|
||||
selection.clearSelection();
|
||||
selection.rangedSelect(0, 0, true);
|
||||
is(tree.selectedNode.uri, TEST_URI, "The correct history item has been selected");
|
||||
// Open the context menu
|
||||
let contextmenu = doc.getElementById("placesContext");
|
||||
contextmenu.addEventListener("popupshown", function() {
|
||||
contextmenu.removeEventListener("popupshown", arguments.callee, false);
|
||||
let forgetThisSite = doc.getElementById("placesContext_deleteHost");
|
||||
is(forgetThisSite.hidden, !expected,
|
||||
"The Forget This Site menu item should " + (expected ? "not " : "") + "be hidden");
|
||||
let forgetThisSiteCmd = doc.getElementById("placesCmd_deleteDataHost");
|
||||
if (forgetThisSiteCmd.disabled, !expected,
|
||||
"The Forget This Site command should " + (expected ? "not " : "") + "be disabled");
|
||||
// Close the context menu
|
||||
contextmenu.hidePopup();
|
||||
// Close Library window.
|
||||
organizer.close();
|
||||
// Proceed
|
||||
funcNext();
|
||||
}, false);
|
||||
let event = document.createEvent("MouseEvents");
|
||||
event.initMouseEvent("contextmenu", true, true, organizer, 0,
|
||||
0, 0, 0, 0, false, false, false, false,
|
||||
0, null);
|
||||
tree.dispatchEvent(event);
|
||||
});
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
|
||||
ww.unregisterNotification(observer);
|
||||
let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
organizer.addEventListener("load", function onLoad(event) {
|
||||
organizer.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
// Select History in the left pane.
|
||||
let PO = organizer.PlacesOrganizer;
|
||||
PO.selectLeftPaneQuery('History');
|
||||
let histContainer = PO._places.selectedNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
|
||||
histContainer.containerOpen = true;
|
||||
PO._places.selectNode(histContainer.getChild(0));
|
||||
// Select the first history entry.
|
||||
let doc = organizer.document;
|
||||
let tree = PO._content;
|
||||
let selection = tree.view.selection;
|
||||
selection.clearSelection();
|
||||
selection.rangedSelect(0, 0, true);
|
||||
is(tree.selectedNode.uri, TEST_URI, "The correct history item has been selected");
|
||||
// Open the context menu
|
||||
let contextmenu = doc.getElementById("placesContext");
|
||||
contextmenu.addEventListener("popupshown", function() {
|
||||
contextmenu.removeEventListener("popupshown", arguments.callee, false);
|
||||
let forgetThisSite = doc.getElementById("placesContext_deleteHost");
|
||||
is(forgetThisSite.hidden, !expected,
|
||||
"The Forget This Site menu item should " + (expected ? "not " : "") + "be hidden");
|
||||
let forgetThisSiteCmd = doc.getElementById("placesCmd_deleteDataHost");
|
||||
if (forgetThisSiteCmd.disabled, !expected,
|
||||
"The Forget This Site command should " + (expected ? "not " : "") + "be disabled");
|
||||
// Close the context menu
|
||||
contextmenu.hidePopup();
|
||||
// Close Library window.
|
||||
organizer.close();
|
||||
// Proceed
|
||||
funcNext();
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
let event = document.createEvent("MouseEvents");
|
||||
event.initMouseEvent("contextmenu", true, true, organizer, 0,
|
||||
0, 0, 0, 0, false, false, false, false,
|
||||
0, null);
|
||||
tree.dispatchEvent(event);
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
ww.registerNotification(observer);
|
||||
ww.openWindow(null,
|
||||
|
|
|
@ -47,9 +47,8 @@ function test() {
|
|||
waitForExplicitFinish();
|
||||
|
||||
function openLocation(url, autofilled, callback) {
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
switch (aTopic) {
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
switch (aTopic) {
|
||||
case "domwindowopened":
|
||||
let dialog = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
dialog.addEventListener("load", function () {
|
||||
|
@ -76,11 +75,10 @@ function test() {
|
|||
break;
|
||||
|
||||
case "domwindowclosed":
|
||||
ww.unregisterNotification(this);
|
||||
ww.unregisterNotification(arguments.callee);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ww.registerNotification(observer);
|
||||
gPrefService.setIntPref("general.open_location.last_window_choice", 0);
|
||||
|
|
|
@ -44,57 +44,56 @@ let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
|||
getService(Ci.nsIPrivateBrowsingService);
|
||||
let _obs = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
let observerNotified = 0, firstUnloadFired = 0, secondUnloadFired = 0;
|
||||
let observerNotified = 0, firstUnloadFired = 0, secondUnloadFired = 0;
|
||||
|
||||
let pbObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "private-browsing") {
|
||||
switch(aData) {
|
||||
case "enter":
|
||||
observerNotified++;
|
||||
is(observerNotified, 1, "This should be the first notification");
|
||||
is(firstUnloadFired, 1, "The first unload event should have been processed by now");
|
||||
break;
|
||||
case "exit":
|
||||
_obs.removeObserver(this, "private-browsing");
|
||||
observerNotified++;
|
||||
is(observerNotified, 2, "This should be the second notification");
|
||||
is(secondUnloadFired, 1, "The second unload event should have been processed by now");
|
||||
break;
|
||||
}
|
||||
}
|
||||
function pbObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic != "private-browsing")
|
||||
return;
|
||||
switch (aData) {
|
||||
case "enter":
|
||||
observerNotified++;
|
||||
is(observerNotified, 1, "This should be the first notification");
|
||||
is(firstUnloadFired, 1, "The first unload event should have been processed by now");
|
||||
break;
|
||||
case "exit":
|
||||
_obs.removeObserver(pbObserver, "private-browsing");
|
||||
observerNotified++;
|
||||
is(observerNotified, 2, "This should be the second notification");
|
||||
is(secondUnloadFired, 1, "The second unload event should have been processed by now");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
_obs.addObserver(pbObserver, "private-browsing", false);
|
||||
is(gBrowser.tabContainer.childNodes.length, 1, "There should only be one tab");
|
||||
let testTab = gBrowser.addTab();
|
||||
gBrowser.selectedTab = testTab;
|
||||
testTab.linkedBrowser.addEventListener("unload", (function() {
|
||||
testTab.linkedBrowser.addEventListener("unload", function () {
|
||||
testTab.linkedBrowser.removeEventListener("unload", arguments.callee, true);
|
||||
firstUnloadFired++;
|
||||
is(observerNotified, 0, "The notification shouldn't have been sent yet");
|
||||
}), true);
|
||||
}, true);
|
||||
|
||||
pb.privateBrowsingEnabled = true;
|
||||
let testTab = gBrowser.addTab();
|
||||
gBrowser.selectedTab = testTab;
|
||||
testTab.linkedBrowser.addEventListener("unload", (function() {
|
||||
testTab.linkedBrowser.addEventListener("unload", function () {
|
||||
testTab.linkedBrowser.removeEventListener("unload", arguments.callee, true);
|
||||
secondUnloadFired++;
|
||||
is(observerNotified, 1, "The notification shouldn't have been sent yet");
|
||||
cookieManager.add("example.com", "test/", "PB", "1", false, false, false, 1000000000000);
|
||||
}), true);
|
||||
}, true);
|
||||
|
||||
pb.privateBrowsingEnabled = false;
|
||||
gBrowser.tabContainer.lastChild.linkedBrowser.addEventListener("unload", (function() {
|
||||
gBrowser.tabContainer.lastChild.linkedBrowser.addEventListener("unload", function () {
|
||||
gBrowser.tabContainer.lastChild.linkedBrowser.removeEventListener("unload", arguments.callee, true);
|
||||
let count = cookieManager.countCookiesFromHost("example.com");
|
||||
is(count, 0, "There shouldn't be any cookies once pb mode has exited");
|
||||
cookieManager.QueryInterface(Ci.nsICookieManager);
|
||||
cookieManager.remove("example.com", "PB", "test/", false);
|
||||
}), true);
|
||||
}, true);
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}
|
||||
|
|
|
@ -43,13 +43,11 @@ function test() {
|
|||
gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
let observer = {
|
||||
observe: function (aSubject, aTopic, aData) {
|
||||
if (aTopic == "private-browsing")
|
||||
this.data = aData;
|
||||
},
|
||||
data: null
|
||||
};
|
||||
let observerData;
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
if (aTopic == "private-browsing")
|
||||
observerData = aData;
|
||||
}
|
||||
let os = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
os.addObserver(observer, "private-browsing", false);
|
||||
|
@ -68,13 +66,13 @@ function test() {
|
|||
is(pb.privateBrowsingEnabled, true, "The private browsing mode should be started");
|
||||
is(gPrivateBrowsingUI.privateBrowsingEnabled, true, "gPrivateBrowsingUI should expose the correct private browsing status");
|
||||
// check to see if the Private Browsing mode was activated successfully
|
||||
is(observer.data, "enter", "Private Browsing mode was activated using the gPrivateBrowsingUI object");
|
||||
is(observerData, "enter", "Private Browsing mode was activated using the gPrivateBrowsingUI object");
|
||||
is(pbMenuItem.getAttribute("label"), pbMenuItem.getAttribute("stoplabel"), "The Private Browsing menu item should read \"Stop Private Browsing\"");
|
||||
gPrivateBrowsingUI.toggleMode()
|
||||
is(pb.privateBrowsingEnabled, false, "The private browsing mode should not be started");
|
||||
is(gPrivateBrowsingUI.privateBrowsingEnabled, false, "gPrivateBrowsingUI should expose the correct private browsing status");
|
||||
// check to see if the Private Browsing mode was deactivated successfully
|
||||
is(observer.data, "exit", "Private Browsing mode was deactivated using the gPrivateBrowsingUI object");
|
||||
is(observerData, "exit", "Private Browsing mode was deactivated using the gPrivateBrowsingUI object");
|
||||
is(pbMenuItem.getAttribute("label"), pbMenuItem.getAttribute("startlabel"), "The Private Browsing menu item should read \"Start Private Browsing\"");
|
||||
|
||||
// now, test using the <command> object
|
||||
|
@ -83,12 +81,12 @@ function test() {
|
|||
var func = new Function("", cmd.getAttribute("oncommand"));
|
||||
func.call(cmd);
|
||||
// check to see if the Private Browsing mode was activated successfully
|
||||
is(observer.data, "enter", "Private Browsing mode was activated using the command object");
|
||||
is(observerData, "enter", "Private Browsing mode was activated using the command object");
|
||||
// check to see that the window title has been changed correctly
|
||||
isnot(document.title, originalTitle, "Private browsing mode has correctly changed the title");
|
||||
func.call(cmd);
|
||||
// check to see if the Private Browsing mode was deactivated successfully
|
||||
is(observer.data, "exit", "Private Browsing mode was deactivated using the command object");
|
||||
is(observerData, "exit", "Private Browsing mode was deactivated using the command object");
|
||||
// check to see that the window title has been restored correctly
|
||||
is(document.title, originalTitle, "Private browsing mode has correctly restored the title");
|
||||
|
||||
|
|
|
@ -52,26 +52,25 @@ function test() {
|
|||
|
||||
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Ci.nsIWindowWatcher);
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
|
||||
win.addEventListener("load", function() {
|
||||
win.removeEventListener("load", arguments.callee, false);
|
||||
ww.unregisterNotification(observer);
|
||||
|
||||
let browser = win.gBrowser;
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
// view source window is loaded, proceed with the rest of the test
|
||||
step1();
|
||||
}, true);
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
|
||||
win.addEventListener("load", function () {
|
||||
win.removeEventListener("load", arguments.callee, false);
|
||||
|
||||
let browser = win.gBrowser;
|
||||
browser.addEventListener("load", function () {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
// view source window is loaded, proceed with the rest of the test
|
||||
step1();
|
||||
}, true);
|
||||
}, false);
|
||||
}
|
||||
ww.registerNotification(observer);
|
||||
|
||||
openViewSource();
|
||||
|
@ -82,18 +81,16 @@ function test() {
|
|||
}
|
||||
|
||||
function step1() {
|
||||
observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowclosed") {
|
||||
ok(true, "Entering the private browsing mode should close the view source window");
|
||||
ww.unregisterNotification(observer);
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowclosed") {
|
||||
ok(true, "Entering the private browsing mode should close the view source window");
|
||||
ww.unregisterNotification(observer);
|
||||
|
||||
step2();
|
||||
}
|
||||
else if (aTopic == "domwindowopened")
|
||||
ok(false, "Entering the private browsing mode should not open any view source window");
|
||||
step2();
|
||||
}
|
||||
};
|
||||
else if (aTopic == "domwindowopened")
|
||||
ok(false, "Entering the private browsing mode should not open any view source window");
|
||||
}
|
||||
ww.registerNotification(observer);
|
||||
|
||||
gBrowser.addTabsProgressListener({
|
||||
|
@ -123,26 +120,25 @@ function test() {
|
|||
}
|
||||
|
||||
function step4() {
|
||||
observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowopened") {
|
||||
ww.unregisterNotification(this);
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
|
||||
win.addEventListener("load", function() {
|
||||
win.removeEventListener("load", arguments.callee, false);
|
||||
ww.unregisterNotification(observer);
|
||||
|
||||
let browser = win.gBrowser;
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
// view source window inside private browsing mode opened
|
||||
step5();
|
||||
}, true);
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
|
||||
win.addEventListener("load", function () {
|
||||
win.removeEventListener("load", arguments.callee, false);
|
||||
|
||||
let browser = win.gBrowser;
|
||||
browser.addEventListener("load", function () {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
// view source window inside private browsing mode opened
|
||||
step5();
|
||||
}, true);
|
||||
}, false);
|
||||
}
|
||||
ww.registerNotification(observer);
|
||||
|
||||
openViewSource();
|
||||
|
@ -151,38 +147,36 @@ function test() {
|
|||
function step5() {
|
||||
let events = 0;
|
||||
|
||||
observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowclosed") {
|
||||
ok(true, "Leaving the private browsing mode should close the existing view source window");
|
||||
if (++events == 2)
|
||||
ww.unregisterNotification(observer);
|
||||
}
|
||||
else if (aTopic == "domwindowopened") {
|
||||
ok(true, "Leaving the private browsing mode should restore the previous view source window");
|
||||
if (++events == 2)
|
||||
ww.unregisterNotification(observer);
|
||||
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
|
||||
win.addEventListener("load", function() {
|
||||
win.removeEventListener("load", arguments.callee, false);
|
||||
|
||||
let browser = win.gBrowser;
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
is(win.content.location.href, "view-source:about:",
|
||||
"The correct view source window should be restored");
|
||||
|
||||
// cleanup
|
||||
win.close();
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}, true);
|
||||
}, false);
|
||||
}
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowclosed") {
|
||||
ok(true, "Leaving the private browsing mode should close the existing view source window");
|
||||
if (++events == 2)
|
||||
ww.unregisterNotification(observer);
|
||||
}
|
||||
};
|
||||
else if (aTopic == "domwindowopened") {
|
||||
ok(true, "Leaving the private browsing mode should restore the previous view source window");
|
||||
if (++events == 2)
|
||||
ww.unregisterNotification(observer);
|
||||
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
|
||||
win.addEventListener("load", function () {
|
||||
win.removeEventListener("load", arguments.callee, false);
|
||||
|
||||
let browser = win.gBrowser;
|
||||
browser.addEventListener("load", function () {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
is(win.content.location.href, "view-source:about:",
|
||||
"The correct view source window should be restored");
|
||||
|
||||
// cleanup
|
||||
win.close();
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}, true);
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
ww.registerNotification(observer);
|
||||
|
||||
// exit private browsing mode
|
||||
|
|
|
@ -38,21 +38,19 @@ var gSS = Cc["@mozilla.org/browser/search-service;1"].
|
|||
var gObs = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
|
||||
var observers = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
switch (aData) {
|
||||
case "engine-added":
|
||||
test2();
|
||||
break;
|
||||
case "engine-current":
|
||||
test3();
|
||||
break;
|
||||
case "engine-removed":
|
||||
test4();
|
||||
break;
|
||||
}
|
||||
function observers(aSubject, aTopic, aData) {
|
||||
switch (aData) {
|
||||
case "engine-added":
|
||||
test2();
|
||||
break;
|
||||
case "engine-current":
|
||||
test3();
|
||||
break;
|
||||
case "engine-removed":
|
||||
test4();
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
|
|
@ -13,26 +13,24 @@ function test() {
|
|||
var ss = Cc["@mozilla.org/browser/search-service;1"].
|
||||
getService(Ci.nsIBrowserSearchService);
|
||||
|
||||
var observer = {
|
||||
observe: function(aSub, aTopic, aData) {
|
||||
switch (aData) {
|
||||
case "engine-added":
|
||||
var engine = ss.getEngineByName("Bug 426329");
|
||||
ok(engine, "Engine was added.");
|
||||
//XXX Bug 493051
|
||||
//ss.currentEngine = engine;
|
||||
break;
|
||||
case "engine-current":
|
||||
ok(ss.currentEngine.name == "Bug 426329", "currentEngine set");
|
||||
testReturn();
|
||||
break;
|
||||
case "engine-removed":
|
||||
obs.removeObserver(this, "browser-search-engine-modified");
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
function observer(aSub, aTopic, aData) {
|
||||
switch (aData) {
|
||||
case "engine-added":
|
||||
var engine = ss.getEngineByName("Bug 426329");
|
||||
ok(engine, "Engine was added.");
|
||||
//XXX Bug 493051
|
||||
//ss.currentEngine = engine;
|
||||
break;
|
||||
case "engine-current":
|
||||
ok(ss.currentEngine.name == "Bug 426329", "currentEngine set");
|
||||
testReturn();
|
||||
break;
|
||||
case "engine-removed":
|
||||
obs.removeObserver(observer, "browser-search-engine-modified");
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
obs.addObserver(observer, "browser-search-engine-modified", false);
|
||||
ss.addEngine("http://localhost:8888/browser/browser/components/search/test/426329.xml",
|
||||
|
|
|
@ -41,23 +41,21 @@ let gObs = Cc["@mozilla.org/observer-service;1"].
|
|||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
switch (aData) {
|
||||
case "engine-added":
|
||||
let engine = gSS.getEngineByName("483086a");
|
||||
ok(engine, "Test engine 1 installed");
|
||||
isnot(engine.searchForm, "foo://example.com",
|
||||
"Invalid SearchForm URL dropped");
|
||||
gSS.removeEngine(engine);
|
||||
break;
|
||||
case "engine-removed":
|
||||
gObs.removeObserver(this, "browser-search-engine-modified");
|
||||
test2();
|
||||
break;
|
||||
}
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
switch (aData) {
|
||||
case "engine-added":
|
||||
let engine = gSS.getEngineByName("483086a");
|
||||
ok(engine, "Test engine 1 installed");
|
||||
isnot(engine.searchForm, "foo://example.com",
|
||||
"Invalid SearchForm URL dropped");
|
||||
gSS.removeEngine(engine);
|
||||
break;
|
||||
case "engine-removed":
|
||||
gObs.removeObserver(observer, "browser-search-engine-modified");
|
||||
test2();
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
gObs.addObserver(observer, "browser-search-engine-modified", false);
|
||||
gSS.addEngine("http://localhost:8888/browser/browser/components/search/test/483086-1.xml",
|
||||
|
@ -66,22 +64,20 @@ function test() {
|
|||
}
|
||||
|
||||
function test2() {
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
switch (aData) {
|
||||
case "engine-added":
|
||||
let engine = gSS.getEngineByName("483086b");
|
||||
ok(engine, "Test engine 2 installed");
|
||||
is(engine.searchForm, "http://example.com", "SearchForm is correct");
|
||||
gSS.removeEngine(engine);
|
||||
break;
|
||||
case "engine-removed":
|
||||
gObs.removeObserver(this, "browser-search-engine-modified");
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
switch (aData) {
|
||||
case "engine-added":
|
||||
let engine = gSS.getEngineByName("483086b");
|
||||
ok(engine, "Test engine 2 installed");
|
||||
is(engine.searchForm, "http://example.com", "SearchForm is correct");
|
||||
gSS.removeEngine(engine);
|
||||
break;
|
||||
case "engine-removed":
|
||||
gObs.removeObserver(observer, "browser-search-engine-modified");
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
gObs.addObserver(observer, "browser-search-engine-modified", false);
|
||||
gSS.addEngine("http://localhost:8888/browser/browser/components/search/test/483086-2.xml",
|
||||
|
|
|
@ -67,20 +67,16 @@ function test() {
|
|||
getService(Ci.nsIObserverService);
|
||||
function waitForFileExistence(aMessage, aDoNext) {
|
||||
const TOPIC = "sessionstore-state-write-complete";
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData)
|
||||
{
|
||||
// Remove the observer so we do not leak.
|
||||
os.removeObserver(this, TOPIC);
|
||||
os.addObserver(function (aSubject, aTopic, aData) {
|
||||
// Remove the observer so we do not leak.
|
||||
os.removeObserver(arguments.callee, TOPIC);
|
||||
|
||||
// Check that the file exists.
|
||||
ok(getSessionstoreFile().exists(), aMessage);
|
||||
// Check that the file exists.
|
||||
ok(getSessionstoreFile().exists(), aMessage);
|
||||
|
||||
// Run our next set of work.
|
||||
aDoNext();
|
||||
}
|
||||
};
|
||||
os.addObserver(observer, TOPIC, false);
|
||||
// Run our next set of work.
|
||||
aDoNext();
|
||||
}, TOPIC, false);
|
||||
}
|
||||
|
||||
function actualTest() {
|
||||
|
|
|
@ -162,20 +162,17 @@ function test() {
|
|||
/**
|
||||
* Helper: Will observe and handle the notifications for us
|
||||
*/
|
||||
let observer = {
|
||||
hitCount: 0,
|
||||
let hitCount = 0;
|
||||
function observer(aCancel, aTopic, aData) {
|
||||
// count so that we later may compare
|
||||
observing[aTopic]++;
|
||||
|
||||
observe: function(aCancel, aTopic, aData) {
|
||||
// count so that we later may compare
|
||||
observing[aTopic]++;
|
||||
|
||||
// handle some tests
|
||||
if (++this.hitCount == 1) {
|
||||
// Test 6
|
||||
aCancel.QueryInterface(Ci.nsISupportsPRBool).data = true;
|
||||
}
|
||||
// handle some tests
|
||||
if (++hitCount == 1) {
|
||||
// Test 6
|
||||
aCancel.QueryInterface(Ci.nsISupportsPRBool).data = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
let observerService = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
|
||||
|
@ -197,9 +194,8 @@ function test() {
|
|||
*/
|
||||
function setupTestsuite(testFn) {
|
||||
// Register our observers
|
||||
for (let o in observing) {
|
||||
for (let o in observing)
|
||||
observerService.addObserver(observer, o, false);
|
||||
}
|
||||
|
||||
// Make the main test window not count as a browser window any longer
|
||||
oldWinType = document.documentElement.getAttribute("windowtype");
|
||||
|
@ -211,18 +207,17 @@ function test() {
|
|||
*/
|
||||
function cleanupTestsuite(callback) {
|
||||
// Finally remove observers again
|
||||
for (let o in observing) {
|
||||
for (let o in observing)
|
||||
observerService.removeObserver(observer, o, false);
|
||||
}
|
||||
|
||||
// Reset the prefs we touched
|
||||
for each (let pref in [
|
||||
[
|
||||
"browser.startup.page",
|
||||
"browser.privatebrowsing.keep_current_session"
|
||||
]) {
|
||||
if (gPrefService.prefHasUserValue(pref)) {
|
||||
].forEach(function (pref) {
|
||||
if (gPrefService.prefHasUserValue(pref))
|
||||
gPrefService.clearUserPref(pref);
|
||||
}
|
||||
}
|
||||
});
|
||||
gPrefService.setBoolPref("browser.tabs.warnOnClose", oldWarnTabsOnClose);
|
||||
|
||||
// Reset the window type
|
||||
|
|
|
@ -76,11 +76,11 @@ function test() {
|
|||
// would timeout.
|
||||
let os = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
os.addObserver({observe: function(aSubject, aTopic, aData) {
|
||||
os.removeObserver(this, aTopic);
|
||||
os.addObserver(function (aSubject, aTopic, aData) {
|
||||
os.removeObserver(arguments.callee, aTopic);
|
||||
info("sessionstore.js is being written");
|
||||
executeSoon(continue_test);
|
||||
}}, "sessionstore-state-write", false);
|
||||
}, "sessionstore-state-write", false);
|
||||
|
||||
// Remove the sessionstore.js file before setting the interval to 0
|
||||
let profilePath = Cc["@mozilla.org/file/directory_service;1"].
|
||||
|
|
|
@ -36,66 +36,62 @@
|
|||
|
||||
function test() {
|
||||
/** Test for Bug 448741 **/
|
||||
|
||||
|
||||
// test setup
|
||||
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
||||
let os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
|
||||
waitForExplicitFinish();
|
||||
|
||||
|
||||
let uniqueName = "bug 448741";
|
||||
let uniqueValue = "as good as unique: " + Date.now();
|
||||
|
||||
|
||||
// set a unique value on a new, blank tab
|
||||
var tab = gBrowser.addTab();
|
||||
tab.linkedBrowser.stop();
|
||||
ss.setTabValue(tab, uniqueName, uniqueValue);
|
||||
let valueWasCleaned = false;
|
||||
|
||||
|
||||
// prevent our value from being written to disk
|
||||
let cleaningObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
ok(aTopic == "sessionstore-state-write", "observed correct topic?");
|
||||
ok(aSubject instanceof Ci.nsISupportsString, "subject is a string?");
|
||||
ok(aSubject.data.indexOf(uniqueValue) > -1, "data contains our value?");
|
||||
|
||||
// find the data for the newly added tab and delete it
|
||||
let state = eval(aSubject.data);
|
||||
state.windows.forEach(function (winData) {
|
||||
winData.tabs.forEach(function (tabData) {
|
||||
if (tabData.extData && uniqueName in tabData.extData &&
|
||||
tabData.extData[uniqueName] == uniqueValue) {
|
||||
delete tabData.extData[uniqueName];
|
||||
valueWasCleaned = true;
|
||||
}
|
||||
});
|
||||
function cleaningObserver(aSubject, aTopic, aData) {
|
||||
ok(aTopic == "sessionstore-state-write", "observed correct topic?");
|
||||
ok(aSubject instanceof Ci.nsISupportsString, "subject is a string?");
|
||||
ok(aSubject.data.indexOf(uniqueValue) > -1, "data contains our value?");
|
||||
|
||||
// find the data for the newly added tab and delete it
|
||||
let state = eval(aSubject.data);
|
||||
state.windows.forEach(function (winData) {
|
||||
winData.tabs.forEach(function (tabData) {
|
||||
if (tabData.extData && uniqueName in tabData.extData &&
|
||||
tabData.extData[uniqueName] == uniqueValue) {
|
||||
delete tabData.extData[uniqueName];
|
||||
valueWasCleaned = true;
|
||||
}
|
||||
});
|
||||
|
||||
ok(valueWasCleaned, "found and removed the specific tab value");
|
||||
aSubject.data = uneval(state);
|
||||
os.removeObserver(this, aTopic, false);
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
ok(valueWasCleaned, "found and removed the specific tab value");
|
||||
aSubject.data = uneval(state);
|
||||
os.removeObserver(cleaningObserver, aTopic, false);
|
||||
}
|
||||
|
||||
// make sure that all later observers don't see that value any longer
|
||||
let checkingObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
ok(valueWasCleaned && aSubject instanceof Ci.nsISupportsString,
|
||||
"ready to check the cleaned state?");
|
||||
ok(aSubject.data.indexOf(uniqueValue) == -1, "data no longer contains our value?");
|
||||
|
||||
// clean up
|
||||
gBrowser.removeTab(tab);
|
||||
os.removeObserver(this, aTopic, false);
|
||||
if (gPrefService.prefHasUserValue("browser.sessionstore.interval"))
|
||||
gPrefService.clearUserPref("browser.sessionstore.interval");
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
function checkingObserver(aSubject, aTopic, aData) {
|
||||
ok(valueWasCleaned && aSubject instanceof Ci.nsISupportsString,
|
||||
"ready to check the cleaned state?");
|
||||
ok(aSubject.data.indexOf(uniqueValue) == -1, "data no longer contains our value?");
|
||||
|
||||
// clean up
|
||||
gBrowser.removeTab(tab);
|
||||
os.removeObserver(checkingObserver, aTopic, false);
|
||||
if (gPrefService.prefHasUserValue("browser.sessionstore.interval"))
|
||||
gPrefService.clearUserPref("browser.sessionstore.interval");
|
||||
finish();
|
||||
}
|
||||
|
||||
// last added observers are invoked first
|
||||
os.addObserver(checkingObserver, "sessionstore-state-write", false);
|
||||
os.addObserver(cleaningObserver, "sessionstore-state-write", false);
|
||||
|
||||
|
||||
// trigger an immediate save operation
|
||||
gPrefService.setIntPref("browser.sessionstore.interval", 0);
|
||||
}
|
||||
|
|
|
@ -67,49 +67,47 @@ function test() {
|
|||
curClosedWindowCount + 1);
|
||||
|
||||
var origWin;
|
||||
let windowObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
let theWin = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
if (origWin && theWin != origWin)
|
||||
return;
|
||||
function windowObserver(aSubject, aTopic, aData) {
|
||||
let theWin = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
if (origWin && theWin != origWin)
|
||||
return;
|
||||
|
||||
switch (aTopic) {
|
||||
case "domwindowopened":
|
||||
origWin = theWin;
|
||||
theWin.addEventListener("load", function () {
|
||||
theWin.removeEventListener("load", arguments.callee, false);
|
||||
executeSoon(function() {
|
||||
// Close the window as soon as the first tab loads, or
|
||||
// immediately if there are no tabs.
|
||||
if (aState.windowState.windows[0].tabs[0].entries.length) {
|
||||
theWin.gBrowser.addEventListener("load", function() {
|
||||
theWin.gBrowser.removeEventListener("load",
|
||||
arguments.callee, true);
|
||||
theWin.close();
|
||||
}, true);
|
||||
} else {
|
||||
executeSoon(function() {
|
||||
theWin.close();
|
||||
});
|
||||
}
|
||||
ss.setWindowState(theWin, JSON.stringify(aState.windowState),
|
||||
true);
|
||||
});
|
||||
}, false);
|
||||
break;
|
||||
|
||||
case "domwindowclosed":
|
||||
ww.unregisterNotification(this);
|
||||
// Use executeSoon to ensure this happens after SS observer.
|
||||
executeSoon(function() {
|
||||
is(ss.getClosedWindowCount(),
|
||||
curClosedWindowCount + (aState.shouldBeAdded ? 1 : 0),
|
||||
"That window should " + (aState.shouldBeAdded ? "" : "not ") +
|
||||
"be restorable");
|
||||
executeSoon(runNextTest);
|
||||
switch (aTopic) {
|
||||
case "domwindowopened":
|
||||
origWin = theWin;
|
||||
theWin.addEventListener("load", function () {
|
||||
theWin.removeEventListener("load", arguments.callee, false);
|
||||
executeSoon(function () {
|
||||
// Close the window as soon as the first tab loads, or
|
||||
// immediately if there are no tabs.
|
||||
if (aState.windowState.windows[0].tabs[0].entries.length) {
|
||||
theWin.gBrowser.addEventListener("load", function() {
|
||||
theWin.gBrowser.removeEventListener("load",
|
||||
arguments.callee, true);
|
||||
theWin.close();
|
||||
}, true);
|
||||
} else {
|
||||
executeSoon(function () {
|
||||
theWin.close();
|
||||
});
|
||||
}
|
||||
ss.setWindowState(theWin, JSON.stringify(aState.windowState),
|
||||
true);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}, false);
|
||||
break;
|
||||
|
||||
case "domwindowclosed":
|
||||
ww.unregisterNotification(windowObserver);
|
||||
// Use executeSoon to ensure this happens after SS observer.
|
||||
executeSoon(function () {
|
||||
is(ss.getClosedWindowCount(),
|
||||
curClosedWindowCount + (aState.shouldBeAdded ? 1 : 0),
|
||||
"That window should " + (aState.shouldBeAdded ? "" : "not ") +
|
||||
"be restorable");
|
||||
executeSoon(runNextTest);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
ww.registerNotification(windowObserver);
|
||||
|
|
|
@ -77,35 +77,33 @@ function test() {
|
|||
selectedWindow: 1
|
||||
};
|
||||
|
||||
let observer = {
|
||||
pass: 1,
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
is(aTopic, "sessionstore-browser-state-restored",
|
||||
"The sessionstore-browser-state-restored notification was observed");
|
||||
let pass = 1;
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
is(aTopic, "sessionstore-browser-state-restored",
|
||||
"The sessionstore-browser-state-restored notification was observed");
|
||||
|
||||
if (this.pass++ == 1) {
|
||||
browserWindowsCount(2);
|
||||
if (pass++ == 1) {
|
||||
browserWindowsCount(2);
|
||||
|
||||
// let the first window be focused (see above)
|
||||
function pollMostRecentWindow() {
|
||||
if (wm.getMostRecentWindow("navigator:browser") == window) {
|
||||
ss.setBrowserState(oldState);
|
||||
} else {
|
||||
info("waiting for the current window to become active");
|
||||
setTimeout(pollMostRecentWindow, 0);
|
||||
window.focus(); //XXX Why is this needed?
|
||||
}
|
||||
// let the first window be focused (see above)
|
||||
function pollMostRecentWindow() {
|
||||
if (wm.getMostRecentWindow("navigator:browser") == window) {
|
||||
ss.setBrowserState(oldState);
|
||||
} else {
|
||||
info("waiting for the current window to become active");
|
||||
setTimeout(pollMostRecentWindow, 0);
|
||||
window.focus(); //XXX Why is this needed?
|
||||
}
|
||||
pollMostRecentWindow();
|
||||
}
|
||||
else {
|
||||
browserWindowsCount(1);
|
||||
ok(!window.closed, "Restoring the old state should have left this window open");
|
||||
os.removeObserver(this, "sessionstore-browser-state-restored");
|
||||
finish();
|
||||
}
|
||||
pollMostRecentWindow();
|
||||
}
|
||||
};
|
||||
else {
|
||||
browserWindowsCount(1);
|
||||
ok(!window.closed, "Restoring the old state should have left this window open");
|
||||
os.removeObserver(observer, "sessionstore-browser-state-restored");
|
||||
finish();
|
||||
}
|
||||
}
|
||||
os.addObserver(observer, "sessionstore-browser-state-restored", false);
|
||||
|
||||
// set browser to test state
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
function test() {
|
||||
let quitRequestObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
ok(aTopic == "quit-application-requested" &&
|
||||
aSubject instanceof Components.interfaces.nsISupportsPRBool,
|
||||
"Received a quit request we're going to deny");
|
||||
aSubject.data = true;
|
||||
}
|
||||
};
|
||||
function quitRequestObserver(aSubject, aTopic, aData) {
|
||||
ok(aTopic == "quit-application-requested" &&
|
||||
aSubject instanceof Components.interfaces.nsISupportsPRBool,
|
||||
"Received a quit request we're going to deny");
|
||||
aSubject.data = true;
|
||||
}
|
||||
|
||||
// ensure that we don't accidentally quit
|
||||
let os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
let os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
|
||||
os.addObserver(quitRequestObserver, "quit-application-requested", false);
|
||||
|
||||
ok(!Application.quit(), "Tried to quit - and didn't succeed");
|
||||
|
|
|
@ -9,21 +9,9 @@ function test() {
|
|||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
prefs.setIntPref("network.cookie.cookieBehavior", 1);
|
||||
|
||||
var o = new obs();
|
||||
|
||||
// kick off a favicon load
|
||||
PageProxySetIcon("http://example.org/tests/extensions/cookie/test/image1.png");
|
||||
}
|
||||
|
||||
function obs () {
|
||||
this.os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
this.os.addObserver(this, "cookie-rejected", false);
|
||||
}
|
||||
|
||||
obs.prototype = {
|
||||
observe: function obs_observe (theSubject, theTopic, theData)
|
||||
{
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
os.addObserver(function (theSubject, theTopic, theData) {
|
||||
var uri = theSubject.QueryInterface(Components.interfaces.nsIURI);
|
||||
var domain = uri.host;
|
||||
|
||||
|
@ -34,11 +22,12 @@ obs.prototype = {
|
|||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
prefs.setIntPref("network.cookie.cookieBehavior", 0);
|
||||
|
||||
this.os.removeObserver(this, "cookie-rejected");
|
||||
this.os = null;
|
||||
os.removeObserver(arguments.callee, "cookie-rejected");
|
||||
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, "cookie-rejected", false);
|
||||
|
||||
// kick off a favicon load
|
||||
PageProxySetIcon("http://example.org/tests/extensions/cookie/test/image1.png");
|
||||
}
|
||||
|
|
|
@ -61,18 +61,12 @@ function test()
|
|||
|
||||
// register a callback to add a load listener to know when the download
|
||||
// manager opens
|
||||
var obs = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
// unregister ourself
|
||||
ww.unregisterNotification(this);
|
||||
ww.registerNotification(function (aSubject, aTopic, aData) {
|
||||
ww.unregisterNotification(arguments.callee);
|
||||
|
||||
var win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
|
||||
win.addEventListener("DOMContentLoaded", finishUp, false);
|
||||
}
|
||||
};
|
||||
|
||||
// register our observer
|
||||
ww.registerNotification(obs);
|
||||
var win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
|
||||
win.addEventListener("DOMContentLoaded", finishUp, false);
|
||||
});
|
||||
|
||||
// The window doesn't open once we call show, so we need to wait a little bit
|
||||
function finishUp() {
|
||||
|
|
|
@ -115,29 +115,24 @@ function test() {
|
|||
|
||||
// only watch for a confirmation dialog every other time being called
|
||||
if (showMode) {
|
||||
let obs = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowclosed")
|
||||
ww.unregisterNotification(this);
|
||||
else if (aTopic == "domwindowopened") {
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
|
||||
SimpleTest.waitForFocus(function() {
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, win)
|
||||
}, win);
|
||||
}
|
||||
ww.registerNotification(function (aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowclosed")
|
||||
ww.unregisterNotification(arguments.callee);
|
||||
else if (aTopic == "domwindowopened") {
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
|
||||
SimpleTest.waitForFocus(function() {
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, win)
|
||||
}, win);
|
||||
}
|
||||
};
|
||||
ww.registerNotification(obs);
|
||||
});
|
||||
}
|
||||
|
||||
let obsSvc = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
obsSvc.addObserver({
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "passwordmgr-password-toggle-complete") {
|
||||
obsSvc.removeObserver(this, "passwordmgr-password-toggle-complete", false);
|
||||
func();
|
||||
}
|
||||
obsSvc.addObserver(function (aSubject, aTopic, aData) {
|
||||
if (aTopic == "passwordmgr-password-toggle-complete") {
|
||||
obsSvc.removeObserver(arguments.callee, aTopic, false);
|
||||
func();
|
||||
}
|
||||
}, "passwordmgr-password-toggle-complete", false);
|
||||
|
||||
|
@ -239,14 +234,12 @@ function test() {
|
|||
checkColumnEntries(2, expectedValues);
|
||||
checkSortDirection(passwordCol, true);
|
||||
// cleanup
|
||||
ww.registerNotification({
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
// unregister ourself
|
||||
ww.unregisterNotification(this);
|
||||
|
||||
pwmgr.removeAllLogins();
|
||||
finish();
|
||||
}
|
||||
ww.registerNotification(function (aSubject, aTopic, aData) {
|
||||
// unregister ourself
|
||||
ww.unregisterNotification(arguments.callee);
|
||||
|
||||
pwmgr.removeAllLogins();
|
||||
finish();
|
||||
});
|
||||
pwmgrdlg.close();
|
||||
}
|
||||
|
|
|
@ -125,29 +125,24 @@ function test() {
|
|||
|
||||
// only watch for a confirmation dialog every other time being called
|
||||
if (showMode) {
|
||||
let obs = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowclosed")
|
||||
ww.unregisterNotification(this);
|
||||
else if (aTopic == "domwindowopened") {
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
|
||||
SimpleTest.waitForFocus(function() {
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, win)
|
||||
}, win);
|
||||
}
|
||||
ww.registerNotification(function (aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowclosed")
|
||||
ww.unregisterNotification(arguments.callee);
|
||||
else if (aTopic == "domwindowopened") {
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
|
||||
SimpleTest.waitForFocus(function() {
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, win)
|
||||
}, win);
|
||||
}
|
||||
};
|
||||
ww.registerNotification(obs);
|
||||
});
|
||||
}
|
||||
|
||||
let obsSvc = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
obsSvc.addObserver({
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "passwordmgr-password-toggle-complete") {
|
||||
obsSvc.removeObserver(this, "passwordmgr-password-toggle-complete", false);
|
||||
func();
|
||||
}
|
||||
obsSvc.addObserver(function (aSubject, aTopic, aData) {
|
||||
if (aTopic == "passwordmgr-password-toggle-complete") {
|
||||
obsSvc.removeObserver(arguments.callee, aTopic, false);
|
||||
func();
|
||||
}
|
||||
}, "passwordmgr-password-toggle-complete", false);
|
||||
|
||||
|
@ -224,14 +219,12 @@ function test() {
|
|||
|
||||
function lastStep() {
|
||||
// cleanup
|
||||
ww.registerNotification({
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
// unregister ourself
|
||||
ww.unregisterNotification(this);
|
||||
ww.registerNotification(function (aSubject, aTopic, aData) {
|
||||
// unregister ourself
|
||||
ww.unregisterNotification(arguments.callee);
|
||||
|
||||
pwmgr.removeAllLogins();
|
||||
finish();
|
||||
}
|
||||
pwmgr.removeAllLogins();
|
||||
finish();
|
||||
});
|
||||
pwmgrdlg.close();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче