michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const TEST_URI = "data:text/html;charset=utf-8,

Web Console test for notifications"; michael@0: michael@0: function test() { michael@0: observer.init(); michael@0: addTab(TEST_URI); michael@0: browser.addEventListener("load", onLoad, true); michael@0: } michael@0: michael@0: function webConsoleCreated(aID) michael@0: { michael@0: Services.obs.removeObserver(observer, "web-console-created"); michael@0: ok(HUDService.getHudReferenceById(aID), "We have a hud reference"); michael@0: content.wrappedJSObject.console.log("adding a log message"); michael@0: } michael@0: michael@0: function webConsoleDestroyed(aID) michael@0: { michael@0: Services.obs.removeObserver(observer, "web-console-destroyed"); michael@0: ok(!HUDService.getHudReferenceById(aID), "We do not have a hud reference"); michael@0: executeSoon(finishTest); michael@0: } michael@0: michael@0: function webConsoleMessage(aID, aNodeID) michael@0: { michael@0: Services.obs.removeObserver(observer, "web-console-message-created"); michael@0: ok(aID, "we have a console ID"); michael@0: is(typeof aNodeID, "string", "message node id is a string"); michael@0: executeSoon(closeConsole); michael@0: } michael@0: michael@0: let observer = { michael@0: michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]), michael@0: michael@0: observe: function observe(aSubject, aTopic, aData) michael@0: { michael@0: aSubject = aSubject.QueryInterface(Ci.nsISupportsString); michael@0: michael@0: switch(aTopic) { michael@0: case "web-console-created": michael@0: webConsoleCreated(aSubject.data); michael@0: break; michael@0: case "web-console-destroyed": michael@0: webConsoleDestroyed(aSubject.data); michael@0: break; michael@0: case "web-console-message-created": michael@0: webConsoleMessage(aSubject, aData); michael@0: break; michael@0: default: michael@0: break; michael@0: } michael@0: }, michael@0: michael@0: init: function init() michael@0: { michael@0: Services.obs.addObserver(this, "web-console-created", false); michael@0: Services.obs.addObserver(this, "web-console-destroyed", false); michael@0: Services.obs.addObserver(this, "web-console-message-created", false); michael@0: } michael@0: }; michael@0: michael@0: function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: openConsole(); michael@0: }