From ff5524e902abdd6f72964b274362f0dd04b807c2 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Tue, 20 Jan 2015 18:20:03 +0000 Subject: [PATCH] Bug 1116714 part 1 - Store the document where we added anonomous content so we can call removeAnonymousContent() on it later without throwing. r=pbrosset Store GlobalForObject for the document too to wallpaper weird devtools test failures. Filed as bug 1123362. --- toolkit/devtools/server/actors/highlighter.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/toolkit/devtools/server/actors/highlighter.js b/toolkit/devtools/server/actors/highlighter.js index dc47bf74d59..cda5acca9e7 100644 --- a/toolkit/devtools/server/actors/highlighter.js +++ b/toolkit/devtools/server/actors/highlighter.js @@ -421,6 +421,9 @@ let CustomHighlighterFront = protocol.FrontClass(CustomHighlighterActor, {}); function CanvasFrameAnonymousContentHelper(tabActor, nodeBuilder) { this.tabActor = tabActor; this.nodeBuilder = nodeBuilder; + this.anonymousContentDocument = this.tabActor.window.document; + // XXX the next line is a wallpaper for bug 1123362. + this.anonymousContentGlobal = Cu.getGlobalForObject(this.anonymousContentDocument); this._insert(); @@ -433,11 +436,13 @@ CanvasFrameAnonymousContentHelper.prototype = { // If the current window isn't the one the content was inserted into, this // will fail, but that's fine. try { - let doc = this.tabActor.window.document; + let doc = this.anonymousContentDocument; doc.removeAnonymousContent(this._content); - } catch (e) {} + } catch (e) {console.error(e)} events.off(this.tabActor, "navigate", this._onNavigate); this.tabActor = this.nodeBuilder = this._content = null; + this.anonymousContentDocument = null; + this.anonymousContentGlobal = null; }, _insert: function() {