2011-02-28 12:42:20 -08:00
|
|
|
/* vim:set ts=2 sw=2 sts=2 et: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-02-28 12:42:20 -08:00
|
|
|
|
2012-03-24 04:34:42 -07:00
|
|
|
const TEST_URI = "data:text/html;charset=utf-8,<p>Web Console test for notifications";
|
2011-02-28 12:42:20 -08:00
|
|
|
|
|
|
|
function test() {
|
|
|
|
observer.init();
|
|
|
|
addTab(TEST_URI);
|
2012-01-06 11:34:56 -08:00
|
|
|
browser.addEventListener("load", onLoad, true);
|
2011-02-28 12:42:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function webConsoleCreated(aID)
|
|
|
|
{
|
2011-06-29 07:39:18 -07:00
|
|
|
Services.obs.removeObserver(observer, "web-console-created");
|
2013-08-02 10:11:57 -07:00
|
|
|
ok(HUDService.getHudReferenceById(aID), "We have a hud reference");
|
2012-01-06 11:34:56 -08:00
|
|
|
content.wrappedJSObject.console.log("adding a log message");
|
2011-02-28 12:42:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function webConsoleDestroyed(aID)
|
|
|
|
{
|
|
|
|
Services.obs.removeObserver(observer, "web-console-destroyed");
|
2013-08-02 10:11:57 -07:00
|
|
|
ok(!HUDService.getHudReferenceById(aID), "We do not have a hud reference");
|
2012-01-06 11:34:56 -08:00
|
|
|
executeSoon(finishTest);
|
2011-02-28 12:42:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function webConsoleMessage(aID, aNodeID)
|
|
|
|
{
|
|
|
|
Services.obs.removeObserver(observer, "web-console-message-created");
|
|
|
|
ok(aID, "we have a console ID");
|
2012-01-06 11:34:56 -08:00
|
|
|
is(typeof aNodeID, "string", "message node id is a string");
|
|
|
|
executeSoon(closeConsole);
|
2011-02-28 12:42:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
let observer = {
|
|
|
|
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
|
|
|
|
|
|
|
|
observe: function observe(aSubject, aTopic, aData)
|
|
|
|
{
|
|
|
|
aSubject = aSubject.QueryInterface(Ci.nsISupportsString);
|
|
|
|
|
|
|
|
switch(aTopic) {
|
|
|
|
case "web-console-created":
|
2013-08-02 10:11:57 -07:00
|
|
|
webConsoleCreated(aSubject.data);
|
2011-02-28 12:42:20 -08:00
|
|
|
break;
|
|
|
|
case "web-console-destroyed":
|
2013-08-02 10:11:57 -07:00
|
|
|
webConsoleDestroyed(aSubject.data);
|
2011-02-28 12:42:20 -08:00
|
|
|
break;
|
|
|
|
case "web-console-message-created":
|
|
|
|
webConsoleMessage(aSubject, aData);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
init: function init()
|
|
|
|
{
|
|
|
|
Services.obs.addObserver(this, "web-console-created", false);
|
|
|
|
Services.obs.addObserver(this, "web-console-destroyed", false);
|
|
|
|
Services.obs.addObserver(this, "web-console-message-created", false);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
function onLoad() {
|
2012-01-06 11:34:56 -08:00
|
|
|
browser.removeEventListener("load", onLoad, true);
|
2011-02-28 12:42:20 -08:00
|
|
|
openConsole();
|
|
|
|
}
|