Bug 1425463 - Expose Console API to JSM - xpcshell test, r=smaug

This commit is contained in:
Andrea Marchesini 2017-12-20 14:35:34 +01:00
parent 797ef68515
commit 4d402775e1
3 changed files with 37 additions and 0 deletions

View File

@ -44,5 +44,6 @@ LOCAL_INCLUDES += [
MOCHITEST_MANIFESTS += [ 'tests/mochitest.ini' ]
MOCHITEST_CHROME_MANIFESTS += [ 'tests/chrome.ini' ]
XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini']
FINAL_LIBRARY = 'xul'

View File

@ -0,0 +1,31 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Components.utils.import("resource://gre/modules/Services.jsm");
add_task(async function() {
do_check_true("console" in this);
let p = new Promise(resolve => {
function consoleListener() {
Services.obs.addObserver(this, "console-api-log-event");
}
consoleListener.prototype = {
observe: function(aSubject, aTopic, aData) {
let obj = aSubject.wrappedJSObject;
do_check_true(obj.arguments[0] === 42, "Message received!");
do_check_true(obj.ID === "jsm", "The ID is JSM");
do_check_true(obj.innerID.endsWith("test_basic.js"), "The innerID matches");
Services.obs.removeObserver(this, "console-api-log-event");
resolve();
}
};
new consoleListener();
});
console.log(42);
await p;
});

View File

@ -0,0 +1,5 @@
[DEFAULT]
head =
support-files =
[test_basic.js]