From fbcca5fe45dd7f2cf9c939eaf588f15bf83786a7 Mon Sep 17 00:00:00 2001 From: Matthew Wein Date: Thu, 7 Jul 2016 16:17:43 -0700 Subject: [PATCH] Bug 1275330 - Fix console.log error in event-emitter.js by importing Console.jsm r=jryans MozReview-Commit-ID: 1CyZHRhQQs6 --HG-- extra : transplant_source : u%EF%BA%C8%12%89%92%CB%FC%A2%9F%CF%2B%04V%13%87%A0x%E6 --- devtools/shared/event-emitter.js | 3 +++ .../mochitest/test_eventemitter_basic.html | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/devtools/shared/event-emitter.js b/devtools/shared/event-emitter.js index 4d3d773744e1..8d1ed6cb983c 100644 --- a/devtools/shared/event-emitter.js +++ b/devtools/shared/event-emitter.js @@ -21,6 +21,8 @@ return Cu.import("resource://gre/modules/Promise.jsm", {}).Promise.defer; case "Services": return Cu.import("resource://gre/modules/Services.jsm", {}).Services; + case "resource://gre/modules/Console.jsm": + return Cu.import("resource://gre/modules/Console.jsm", {}); case "chrome": return { Cu, @@ -38,6 +40,7 @@ // See comment in JSM module boilerplate when adding a new dependency. const { components } = require("chrome"); + const { console } = require("resource://gre/modules/Console.jsm"); const Services = require("Services"); const defer = require("devtools/shared/defer"); let loggingEnabled = true; diff --git a/devtools/shared/tests/mochitest/test_eventemitter_basic.html b/devtools/shared/tests/mochitest/test_eventemitter_basic.html index 4c683ceabad0..ff648a1fee73 100644 --- a/devtools/shared/tests/mochitest/test_eventemitter_basic.html +++ b/devtools/shared/tests/mochitest/test_eventemitter_basic.html @@ -74,10 +74,25 @@ } function onlyOnce() { - ok(!beenHere2, "\"once\" listner has been called once"); + ok(!beenHere2, "\"once\" listener has been called once"); beenHere2 = true; emitter.emit("onlyonce"); + testThrowingExceptionInListener(); + } + + function testThrowingExceptionInListener() { + function throwListener() { + emitter.off("throw-exception"); + throw { + toString: () => "foo", + stack: "bar", + }; + } + + emitter.on("throw-exception", throwListener); + emitter.emit("throw-exception"); + killItWhileEmitting(); }