Bug 14979 - REGRESSION: fast/css/css-selector-text.html failing after r25098
Summary: REGRESSION: fast/css/css-selector-text.html failing after r25098
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.4
: P1 Normal
Assignee: Nobody
URL: http://build.webkit.org/results/post-...
Keywords: InRadar, LayoutTestFailure, Regression
Depends on:
Blocks:
 
Reported: 2007-08-15 15:47 PDT by mitz
Modified: 2022-08-11 10:09 PDT (History)
8 users (show)

See Also:


Attachments
Test case (411 bytes, text/html)
2007-08-15 23:25 PDT, mitz
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description mitz 2007-08-15 15:47:27 PDT
fast/css/css-selector-text.html is failing on the build bot (and on my local build) after <http://trac.webkit.org/projects/webkit/changeset/25098>. It was also failing after the previous incarnation of that change.
Comment 1 Beth Dakin 2007-08-15 16:39:09 PDT
The problem is in this function:

function parseThenSerializeRule(rule)
{
    var styleElement = document.createElement("style");
    styleElement.appendChild(document.createTextNode(rule));
    return styleElement.sheet.cssRules[0].cssText;
}

with my patch, styleElement.sheet.cssRules[0] is null.
Comment 2 Beth Dakin 2007-08-15 17:01:19 PDT
This is failing because the style element is not in the document, so we do not create the sheet.
Comment 3 Beth Dakin 2007-08-15 21:52:43 PDT
The test may have to change. It does not pass in Firefox for what appears to be the same reason. 
Comment 4 mitz 2007-08-15 23:17:30 PDT
Firefox is consistent: it always returns null for the 'sheet' property of a <style> element that is not in the document. TOT WebKit always returns a CSSStyleSheet, and the stylesheet will contain no rules if the <style> element has never been inserted into the document; but if it has been inserted at some point, the rules will persist even after it has been removed, so there is no consistent "not in document" behavior.
Comment 5 mitz 2007-08-15 23:25:22 PDT
Created attachment 15993 [details]
Test case

In this test case, the rule that's added using insertRule() is knocked out and replaced with the rule in the text node when the <style> element is removed and re-inserted into the document. I think if you are going to match Firefox, it will be better not to allow something like that to happen (e.g. by also returning null for the 'sheet' property when not in a document). I don't think the Firefox behavior makes sense (or follows the specification), though.
Comment 6 Beth Dakin 2007-08-16 12:10:16 PDT
cc-ing Hyatt. I am interested to know his thoughts on this.
Comment 7 Dave Hyatt 2007-08-16 13:25:52 PDT
I don't think this is worth fixing for Leopard, even though it is inconsistent.  Both link element and style element need to null out their sheet stuff in their removedFromDocument methods.

In the case of <link>, we should get rid of the process() call in removedFromDocument() because it is a no-op, and we should move the code from the destructor into removedFromDocument.  We should also null out m_sheet.

In the case of <style>, we should add the code that is in createSheet near the top that nulls out m_sheet and calls removePendingSheet if the sheet was loading.  updateStyleSelector should still be called.
Comment 8 Beth Dakin 2007-08-16 13:56:15 PDT
I changed the test with r25111 to get it passing. 
Comment 9 mitz 2007-08-16 14:34:13 PDT
(In reply to comment #7)
> Both link element and style element need to null out their sheet stuff in
> their removedFromDocument methods.

Why is that? Because of <http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.html#StyleSheets-extensions> ? It seems odd that if you remove and re-insert a <style> element it will be re-parsed and you will lose any dynamic changes you've made to it.
Comment 10 David Kilzer (:ddkilzer) 2008-05-09 18:43:23 PDT
<rdar://problem/5925718>
Comment 11 Ahmad Saleem 2022-08-11 10:09:28 PDT
I am unable to reproduce this bug in Safari 15.6 on macOS 12.5 and does not get expected result of "green" and "solid border". It is same across all browsers (Chrome Canary 106 and Firefox Nightly 105).

Since all browsers are rendering this test case same, I am going to mark this as "RESOLVED CONFIGURATION CHANGED". Please reopen, if you think test case need to be tweak and my testing is not applicable. Thanks!