зеркало из https://github.com/mozilla/gecko-dev.git
Bug 728538. (Av1) browser_ConsoleStorageAPITests.js: Improve code a little. r=gavin.sharp.
This commit is contained in:
Родитель
190f19bce5
Коммит
a4ac4954c0
|
@ -24,21 +24,20 @@ var ConsoleObserver = {
|
|||
if (aTopic == "console-storage-cache-event") {
|
||||
apiCallCount ++;
|
||||
if (apiCallCount == 4) {
|
||||
// remove the observer so we don't trigger this test again
|
||||
Services.obs.removeObserver(this, "console-storage-cache-event");
|
||||
|
||||
try {
|
||||
var tab = gBrowser.selectedTab;
|
||||
let tab = gBrowser.selectedTab;
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
let win = XPCNativeWrapper.unwrap(browser.contentWindow);
|
||||
let windowID = getWindowId(win);
|
||||
let messages = ConsoleAPIStorage.getEvents(windowID);
|
||||
|
||||
ok(messages.length >= 4, "Some messages found in the storage service");
|
||||
|
||||
ConsoleAPIStorage.clearEvents();
|
||||
messages = ConsoleAPIStorage.getEvents(windowID);
|
||||
ok(messages.length == 0, "Cleared Storage, no events found");
|
||||
|
||||
// remove the observer so we don't trigger this test again
|
||||
Services.obs.removeObserver(this, "console-storage-cache-event");
|
||||
is(messages.length, 0, "Cleared Storage");
|
||||
|
||||
// make sure a closed window's events are in fact removed from the
|
||||
// storage cache
|
||||
|
@ -48,28 +47,26 @@ var ConsoleObserver = {
|
|||
gBrowser.removeTab(tab, {animate: false});
|
||||
|
||||
window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils).garbageCollect();
|
||||
executeSoon(function (){
|
||||
.getInterface(Ci.nsIDOMWindowUtils).garbageCollect();
|
||||
executeSoon(function () {
|
||||
// use the old windowID again to see if we have any stray cached messages
|
||||
messages = ConsoleAPIStorage.getEvents(windowID);
|
||||
ok(messages.length == 0, "0 events found, tab close is clearing the cache");
|
||||
is(messages.length, 0, "tab close is clearing the cache");
|
||||
finish();
|
||||
});
|
||||
} catch (ex) {
|
||||
dump(ex + "\n\n\n");
|
||||
dump(ex.stack + "\n\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function tearDown()
|
||||
{
|
||||
while (gBrowser.tabs.length > 1) {
|
||||
while (gBrowser.tabs.length > 1)
|
||||
gBrowser.removeCurrentTab();
|
||||
}
|
||||
}
|
||||
|
||||
function test()
|
||||
|
@ -86,10 +83,7 @@ function test()
|
|||
browser.addEventListener("DOMContentLoaded", function onLoad(event) {
|
||||
browser.removeEventListener("DOMContentLoaded", onLoad, false);
|
||||
executeSoon(function test_executeSoon() {
|
||||
var contentWin = browser.contentWindow;
|
||||
|
||||
let win = XPCNativeWrapper.unwrap(contentWin);
|
||||
|
||||
let win = XPCNativeWrapper.unwrap(browser.contentWindow);
|
||||
win.console.log("this", "is", "a", "log message");
|
||||
win.console.info("this", "is", "a", "info message");
|
||||
win.console.warn("this", "is", "a", "warn message");
|
||||
|
|
Загрузка…
Ссылка в новой задаче