зеркало из https://github.com/mozilla/gecko-dev.git
Bug 877478 - Fix test to use SpecialPowers.{add,remove}Observer. r=mrbkap
This way, we get the callback wrapping behavior for free.
This commit is contained in:
Родитель
4de0ea3e6a
Коммит
da92b2ad75
|
@ -43,20 +43,22 @@ is(i2outer, i1inner + 1, "Frame 2 comes right after frame 1");
|
|||
var innerWindowDestroyID;
|
||||
var outerWindowDestroyID;
|
||||
|
||||
function outerObserver(id) {
|
||||
outerWindowDestroyID =
|
||||
SpecialPowers.wrap(id).QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
|
||||
}
|
||||
function innerObserver(id) {
|
||||
var outerObserver = {
|
||||
observe: function(id) {
|
||||
outerWindowDestroyID =
|
||||
SpecialPowers.wrap(id).QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
|
||||
}
|
||||
};
|
||||
var innerObserver = {
|
||||
observe: function(id) {
|
||||
innerWindowDestroyID =
|
||||
SpecialPowers.wrap(id).QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function removeFrame(iframe) {
|
||||
var obsSvc = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
obsSvc.addObserver(outerObserver, "outer-window-destroyed", false);
|
||||
obsSvc.addObserver(innerObserver, "inner-window-destroyed", false);
|
||||
SpecialPowers.addObserver(outerObserver, "outer-window-destroyed", false);
|
||||
SpecialPowers.addObserver(innerObserver, "inner-window-destroyed", false);
|
||||
|
||||
iframe.parentNode.removeChild(iframe);
|
||||
}
|
||||
|
@ -66,10 +68,8 @@ SimpleTest.waitForExplicitFinish();
|
|||
SimpleTest.executeSoon(function() {
|
||||
is(innerWindowDestroyID, i1inner, "inner window of frame 1 should be destroyed");
|
||||
is(outerWindowDestroyID, i1outer, "outer window of frame 1 should be destroyed");
|
||||
var obsSvc = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
obsSvc.removeObserver(outerObserver, "outer-window-destroyed");
|
||||
obsSvc.removeObserver(innerObserver, "inner-window-destroyed");
|
||||
SpecialPowers.removeObserver(outerObserver, "outer-window-destroyed");
|
||||
SpecialPowers.removeObserver(innerObserver, "inner-window-destroyed");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ function checkTest() {
|
|||
ok(login.timeLastUsed == login.timePasswordChanged, "timeUsed == timeChanged");
|
||||
|
||||
// cleanup
|
||||
observerService.removeObserver(PasswordMgrObserver, "passwordmgr-storage-changed");
|
||||
SpecialPowers.removeObserver(PasswordMgrObserver, "passwordmgr-storage-changed");
|
||||
popupNotifications.panel.removeEventListener("popupshown", checkTest, false);
|
||||
|
||||
login2.password = "pass2";
|
||||
|
@ -182,10 +182,7 @@ var login1 = new nsLoginInfo("http://mochi.test:8888", "http://mochi.test:8888",
|
|||
var login2 = new nsLoginInfo("http://mochi.test:8888", "http://mochi.test:8888", null,
|
||||
"notifyu2", "notifyp2", "user", "pass");
|
||||
|
||||
var observerService = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
|
||||
observerService.addObserver(PasswordMgrObserver, "passwordmgr-storage-changed", false);
|
||||
SpecialPowers.addObserver(PasswordMgrObserver, "passwordmgr-storage-changed", false);
|
||||
|
||||
// popupNotifications (not *popup*) is a constant, per-tab container. So, we
|
||||
// only need to fetch it once.
|
||||
|
|
Загрузка…
Ссылка в новой задаче