зеркало из https://github.com/mozilla/gecko-dev.git
81 строка
2.5 KiB
XML
81 строка
2.5 KiB
XML
<?xml version="1.0"?>
|
|
<!--
|
|
Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
-->
|
|
<window title="Console + JSM"
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
onload="test();">
|
|
|
|
<script type="application/javascript"
|
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
|
<script type="application/javascript"
|
|
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
|
|
|
<script type="application/javascript">
|
|
<![CDATA[
|
|
|
|
const JSM = "chrome://mochitests/content/chrome/dom/console/tests/console.jsm";
|
|
|
|
let dumpCalled = 0;
|
|
function dumpFunction(msg) {
|
|
ok(msg.indexOf("_PREFIX_") != -1, "we have a prefix");
|
|
dump("Message received: " + msg); // Just for debugging
|
|
dumpCalled++;
|
|
}
|
|
|
|
function consoleListener() {
|
|
SpecialPowers.addObserver(this, "console-api-log-event");
|
|
}
|
|
|
|
consoleListener.prototype = {
|
|
count: 0,
|
|
|
|
observe: function(aSubject, aTopic, aData) {
|
|
if (aTopic == "console-api-log-event") {
|
|
var obj = aSubject.wrappedJSObject;
|
|
if (obj.innerID == JSM) {
|
|
is(obj.ID, "jsm", "ID and InnerID are correctly set.");
|
|
is(obj.arguments[0], "Hello world!", "Message matches");
|
|
is(obj.consoleID, "", "No consoleID for console API");
|
|
|
|
// We want to see 2 messages from this innerID, the first is generated
|
|
// by console.log, the second one from createInstance().log();
|
|
++this.count;
|
|
} else if (obj.innerID == "CUSTOM INNER") {
|
|
is(obj.ID, "jsm", "ID and InnerID are correctly set.");
|
|
is(obj.arguments[0], "Hello world!", "Message matches");
|
|
is(obj.consoleID, "wow", "consoleID is set by consoleInstance");
|
|
++this.count;
|
|
} else if (obj.innerID == "LEVEL") {
|
|
// Nothing special... just we don't want to see 'invisible' messages.
|
|
is(obj.ID, "jsm", "ID and InnerID are correctly set.");
|
|
is(obj.arguments[0], "Hello world!", "Message matches");
|
|
++this.count;
|
|
}
|
|
|
|
if (this.count == 4) {
|
|
is(dumpCalled, 2, "Dump has been called!");
|
|
SpecialPowers.removeObserver(this, "console-api-log-event");
|
|
SimpleTest.finish();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function test() {
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
SpecialPowers.pushPrefEnv({set: [["pref.test.console", "log"]]}).then(() => {
|
|
var cl = new consoleListener();
|
|
Components.utils.import(JSM);
|
|
ConsoleTest.go(dumpFunction);
|
|
});
|
|
}
|
|
|
|
]]>
|
|
</script>
|
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
</body>
|
|
</window>
|