Bug 870339 - Fix Intermittent browser/devtools/styleeditor/test/browser_styleeditor_bug_740541_iframes.js. r=harth

This commit is contained in:
David Creswick 2013-08-20 21:12:37 -04:00
Родитель 4c314563ea
Коммит b0ce980179
3 изменённых файлов: 56 добавлений и 1 удалений

Просмотреть файл

@ -95,12 +95,17 @@ StyleEditorDebuggee.prototype = {
*/ */
clear: function() { clear: function() {
this.baseURI = null; this.baseURI = null;
this.clearStyleSheets();
},
/**
* Clear stylesheets.
*/
clearStyleSheets: function() {
for (let stylesheet of this.styleSheets) { for (let stylesheet of this.styleSheets) {
stylesheet.destroy(); stylesheet.destroy();
} }
this.styleSheets = []; this.styleSheets = [];
this.emit("stylesheets-cleared"); this.emit("stylesheets-cleared");
}, },
@ -137,6 +142,9 @@ StyleEditorDebuggee.prototype = {
* Object with 'styleSheets' array of actor forms * Object with 'styleSheets' array of actor forms
*/ */
_onDocumentLoad: function(type, request) { _onDocumentLoad: function(type, request) {
if (this.styleSheets.length > 0) {
this.clearStyleSheets();
}
let sheets = []; let sheets = [];
for (let form of request.styleSheets) { for (let form of request.styleSheets) {
let sheet = this._addStyleSheet(form); let sheet = this._addStyleSheet(form);

Просмотреть файл

@ -26,6 +26,7 @@ MOCHITEST_BROWSER_FILES := \
browser_styleeditor_sv_resize.js \ browser_styleeditor_sv_resize.js \
browser_styleeditor_bug_740541_iframes.js \ browser_styleeditor_bug_740541_iframes.js \
browser_styleeditor_bug_851132_middle_click.js \ browser_styleeditor_bug_851132_middle_click.js \
browser_styleeditor_bug_870339.js \
browser_styleeditor_nostyle.js \ browser_styleeditor_nostyle.js \
browser_styleeditor_reload.js \ browser_styleeditor_reload.js \
head.js \ head.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(
["<!DOCTYPE html>",
"<html>",
" <head>",
" <title>Bug 870339</title>",
' <link rel="stylesheet" type="text/css" href="'+SIMPLE+'">',
" </head>",
" <body>",
" </body>",
"</html>"
].join("\n"));
waitForExplicitFinish();
addTabAndOpenStyleEditor(function (aPanel) {
let debuggee = aPanel._debuggee;
// Spam the _onNewDocument callback multiple times before the
// StyleEditorActor has a chance to respond to the first one.
const SPAM_COUNT = 2;
for (let i=0; i<SPAM_COUNT; ++i) {
debuggee._onNewDocument();
}
// Wait for the StyleEditorActor to respond to each "newDocument"
// message.
let loadCount = 0;
debuggee.on("document-load", function () {
++loadCount;
if (loadCount == SPAM_COUNT) {
// No matter how large SPAM_COUNT is, the number of style
// sheets should never be more than the number of style sheets
// in the document.
is(debuggee.styleSheets.length, 1, "correct style sheet count");
finish();
}
});
});
content.location = DOCUMENT_WITH_ONE_STYLESHEET;
}