diff --git a/browser/devtools/styleeditor/StyleEditorDebuggee.jsm b/browser/devtools/styleeditor/StyleEditorDebuggee.jsm index ff7a9be6035f..272f3322b175 100644 --- a/browser/devtools/styleeditor/StyleEditorDebuggee.jsm +++ b/browser/devtools/styleeditor/StyleEditorDebuggee.jsm @@ -95,12 +95,17 @@ StyleEditorDebuggee.prototype = { */ clear: function() { this.baseURI = null; + this.clearStyleSheets(); + }, + /** + * Clear stylesheets. + */ + clearStyleSheets: function() { for (let stylesheet of this.styleSheets) { stylesheet.destroy(); } this.styleSheets = []; - this.emit("stylesheets-cleared"); }, @@ -137,6 +142,9 @@ StyleEditorDebuggee.prototype = { * Object with 'styleSheets' array of actor forms */ _onDocumentLoad: function(type, request) { + if (this.styleSheets.length > 0) { + this.clearStyleSheets(); + } let sheets = []; for (let form of request.styleSheets) { let sheet = this._addStyleSheet(form); diff --git a/browser/devtools/styleeditor/test/Makefile.in b/browser/devtools/styleeditor/test/Makefile.in index 519ce166c171..1918c406a217 100644 --- a/browser/devtools/styleeditor/test/Makefile.in +++ b/browser/devtools/styleeditor/test/Makefile.in @@ -26,6 +26,7 @@ MOCHITEST_BROWSER_FILES := \ browser_styleeditor_sv_resize.js \ browser_styleeditor_bug_740541_iframes.js \ browser_styleeditor_bug_851132_middle_click.js \ + browser_styleeditor_bug_870339.js \ browser_styleeditor_nostyle.js \ browser_styleeditor_reload.js \ head.js \ diff --git a/browser/devtools/styleeditor/test/browser_styleeditor_bug_870339.js b/browser/devtools/styleeditor/test/browser_styleeditor_bug_870339.js new file mode 100644 index 000000000000..6daa0f4f8b99 --- /dev/null +++ b/browser/devtools/styleeditor/test/browser_styleeditor_bug_870339.js @@ -0,0 +1,46 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function test() +{ + const SIMPLE = TEST_BASE_HTTP + "simple.css"; + const DOCUMENT_WITH_ONE_STYLESHEET = "data:text/html;charset=UTF-8," + + encodeURIComponent( + ["", + "", + "
", + "