Bug 719552 - Scheme-less URLs references in the style sheet are lost when editing. r=rcampbell

This commit is contained in:
Cedric Vivier 2012-02-23 04:15:00 +01:00
parent 86b67052e6
commit e6f07b4aa1
3 changed files with 26 additions and 13 deletions

View File

@ -11,6 +11,9 @@ const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const DOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"]
.getService(Ci.inIDOMUtils);
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
@ -634,16 +637,7 @@ StyleEditor.prototype = {
if (this.sourceEditor) {
this._state.text = this.sourceEditor.getText();
}
let source = this._state.text;
let oldNode = this.styleSheet.ownerNode;
let oldIndex = this.styleSheetIndex;
let content = this.contentDocument;
let newNode = content.createElement("style");
newNode.setAttribute("type", "text/css");
newNode.appendChild(content.createTextNode(source));
oldNode.parentNode.replaceChild(newNode, oldNode);
this._styleSheet = content.styleSheets[oldIndex];
DOMUtils.parseStyleSheet(this.styleSheet, this._state.text);
this._persistExpando();
if (!TRANSITIONS_ENABLED) {
@ -652,6 +646,8 @@ StyleEditor.prototype = {
return;
}
let content = this.contentDocument;
// Insert the global transition rule
// Use a ref count to make sure we do not add it multiple times.. and remove
// it only when all pending StyleEditor-generated transitions ended.

View File

@ -35,6 +35,10 @@ let gNewEditor; // to make sure only one new stylesheet got created
let gUpdateCount = 0; // to make sure only one Update event is triggered
let gCommitCount = 0; // to make sure only one Commit event is triggered
let gTransitionEndCount = 0;
let gOriginalStyleSheet;
let gOriginalOwnerNode;
let gOriginalHref;
function finishOnTransitionEndAndCommit() {
if (gCommitCount && gTransitionEndCount) {
@ -42,7 +46,17 @@ function finishOnTransitionEndAndCommit() {
is(gCommitCount, 1, "received one Commit event");
is(gTransitionEndCount, 1, "received one transitionend event");
finish();
if (gNewEditor) {
is(gNewEditor.styleSheet, gOriginalStyleSheet,
"style sheet object did not change");
is(gNewEditor.styleSheet.ownerNode, gOriginalOwnerNode,
"style sheet owner node did not change");
is(gNewEditor.styleSheet.href, gOriginalHref,
"style sheet href did not change");
gNewEditor = null;
finish();
}
}
}
@ -68,6 +82,10 @@ function testEditorAdded(aChrome, aEditor)
let listener = {
onAttach: function (aEditor) {
waitForFocus(function () {
gOriginalStyleSheet = aEditor.styleSheet;
gOriginalOwnerNode = aEditor.styleSheet.ownerNode;
gOriginalHref = aEditor.styleSheet.href;
ok(aEditor.isLoaded,
"new editor is loaded when attached");
ok(aEditor.hasFlag("new"),
@ -142,7 +160,6 @@ function testEditorAdded(aChrome, aEditor)
"StyleEditor's transition class has been removed from content");
aEditor.removeActionListener(listener);
gNewEditor = null;
executeSoon(finishOnTransitionEndAndCommit);
}

View File

@ -2,7 +2,7 @@
<html>
<head>
<title>simple testcase</title>
<link rel="stylesheet" type="text/css" media="scren" href="simple.css"/>
<link rel="stylesheet" type="text/css" media="screen" href="simple.css"/>
<style type="text/css">
body {
background: white;