Bug 1318006 - Clone originAttributes on cached console message events. draft
authorLuca Greco <lgreco@mozilla.com>
Wed, 16 Nov 2016 18:03:08 +0100
changeset 440450 abb82a82da9807acb54a3e02cab66309ad60f7de
parent 439780 19f1c265ffd0708d7cdd7d766651cb536c4f6567
child 537368 f39d10ecdb75b7b9223d2c819558f2d20351fbfc
push id36218
push userluca.greco@alcacoop.it
push dateThu, 17 Nov 2016 14:14:25 +0000
bugs1318006
milestone53.0a1
Bug 1318006 - Clone originAttributes on cached console message events. MozReview-Commit-ID: tnWCa5CsuE
dom/console/ConsoleAPIStorage.js
--- a/dom/console/ConsoleAPIStorage.js
+++ b/dom/console/ConsoleAPIStorage.js
@@ -122,16 +122,22 @@ ConsoleAPIStorageService.prototype = {
    */
   recordEvent: function CS_recordEvent(aId, aOuterId, aEvent)
   {
     if (!_consoleStorage.has(aId)) {
       _consoleStorage.set(aId, []);
     }
 
     let storage = _consoleStorage.get(aId);
+
+    // Clone originAttributes to prevent "TypeError: can't access dead object"
+    // exceptions when cached console messages are retrieved/filtered
+    // by the devtools webconsole actor.
+    aEvent.originAttributes = Cu.cloneInto(aEvent.originAttributes, {});
+
     storage.push(aEvent);
 
     // truncate
     if (storage.length > STORAGE_MAX_EVENTS) {
       storage.shift();
     }
 
     Services.obs.notifyObservers(aEvent, "console-api-log-event", aOuterId);