Don't call SetSheet with a null sheet. (Bug 645951) r=bzbarsky

This commit is contained in:
L. David Baron 2011-03-29 20:46:12 -07:00
parent 2d607acb83
commit 809999141b
5 changed files with 24 additions and 4 deletions

View File

@ -0,0 +1,4 @@
<!DOCTYPE HTML>
<title>Test, bug 645951</title>
<body>
<p style="color: green">Should not crash, and should be green too.</p>

View File

@ -0,0 +1 @@
@import url(chrome:///browser/skin/);

View File

@ -0,0 +1,11 @@
<!DOCTYPE HTML>
<title>Test, bug 645951</title>
<link rel=stylesheet href="645951-1.css">
<link id="two" rel=stylesheet href="645951-1.css">
<body onload="run()">
<script>
function run() {
document.getElementById("two").sheet.insertRule("p { color: green}", 1);
}
</script>
<p>Should not crash, and should be green too.</p>

View File

@ -64,3 +64,4 @@ load 592698-1.html
load 601437-1.html
load 601439-1.html
load 605689-1.html
== 645951-1.html 645951-1-ref.html

View File

@ -368,12 +368,15 @@ ImportRule::ImportRule(const ImportRule& aCopy)
: nsCSSRule(aCopy),
mURLSpec(aCopy.mURLSpec)
{
nsRefPtr<nsCSSStyleSheet> sheet;
// Whether or not an @import rule has a null sheet is a permanent
// property of that @import rule, since it is null only if the target
// sheet failed security checks.
if (aCopy.mChildSheet) {
sheet = aCopy.mChildSheet->Clone(nsnull, this, nsnull, nsnull);
nsRefPtr<nsCSSStyleSheet> sheet =
aCopy.mChildSheet->Clone(nsnull, this, nsnull, nsnull);
SetSheet(sheet);
// SetSheet sets mMedia appropriately
}
SetSheet(sheet);
// SetSheet sets mMedia appropriately
}
ImportRule::~ImportRule()