From 1f0ca5f515496c812998bc649cb648653a2287dd Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Fri, 28 Nov 2008 15:27:31 -0800 Subject: [PATCH] Bug 464918 - Console clearing test for private browsing should not use a timeout; r=mconnor a191=beltzner --- .../test/browser/browser_console_clear.js | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/browser/components/privatebrowsing/test/browser/browser_console_clear.js b/browser/components/privatebrowsing/test/browser/browser_console_clear.js index 16aebc1e6c5..ceb712d7a85 100644 --- a/browser/components/privatebrowsing/test/browser/browser_console_clear.js +++ b/browser/components/privatebrowsing/test/browser/browser_console_clear.js @@ -47,12 +47,23 @@ 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"; waitForExplicitFinish(); let consoleObserver = { observe: function (aMessage) { if (!aMessage.message) this.gotNull = true; + else if (aMessage.message == kExitMessage) { + // 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 + ok(!messageExists(), "Message should not exist after leaving the private mode"); + + consoleService.unregisterListener(consoleObserver); + prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session"); + finish(); + } }, gotNull: false }; @@ -84,18 +95,6 @@ function test() { ok(messageExists(), "Message should exist after entering the private mode"); pb.privateBrowsingEnabled = false; - let timer = Cc["@mozilla.org/timer;1"]. - createInstance(Ci.nsITimer); - timer.initWithCallback({ - notify: function(timer) { - // make sure that the null message was received - ok(consoleObserver.gotNull, "Console should be cleared after leaving the private mode"); - // make sure the console does not contain kTestMessage - ok(!messageExists(), "Message should not exist after leaving the private mode"); - - consoleService.unregisterListener(consoleObserver); - prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session"); - finish(); - } - }, 1000, Ci.nsITimer.TYPE_ONE_SHOT); + // signal the end of the test + consoleService.logStringMessage(kExitMessage); }