Bug 15986

Summary: Dynamically inserting CSS rule with @media query fails with DOM Exception 12
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: CSSAssignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: bdakin, darin, eric, zimmermann
Priority: P2 Keywords: HasReduction
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.4   
Attachments:
Description Flags
Test case
none
Static test case (works)
none
Patch v1 darin: review+

Description David Kilzer (:ddkilzer) 2007-11-14 08:55:57 PST
* SUMMARY
Dynamically inserting a CSS rule with an @media query fails with DOM Exception 12.  The same rule in a static stylesheet is valid and is applied correctly.

* STEPS TO REPRODUCE
1. Open test case in Safari/WebKit.

* RESULTS
Test fails.

* REGRESSION
Not a regression as Safari 2.0.4 (419.3) with original WebKit fails with a "TypeError - Null value" exception.

* NOTES
Opera 9.22 works.
Firefox 2.0.0.9 and 3.0b2 (today's download) both also fail.
Comment 1 David Kilzer (:ddkilzer) 2007-11-14 08:57:06 PST
Created attachment 17269 [details]
Test case
Comment 2 David Kilzer (:ddkilzer) 2007-11-14 08:57:52 PST
Created attachment 17270 [details]
Static test case (works)
Comment 3 David Kilzer (:ddkilzer) 2008-01-03 16:56:14 PST
Created attachment 18256 [details]
Patch v1

Proposed fix.

If you'd prefer a test for @page that expects an exception to be thrown, let me know.
Comment 4 Darin Adler 2008-01-03 17:08:01 PST
Comment on attachment 18256 [details]
Patch v1

r=me

Does this match other browsers?
Comment 5 David Kilzer (:ddkilzer) 2008-01-03 18:26:44 PST
(In reply to comment #4)
> Does this match other browsers?

Regarding @font-face:  Opera 9.2x and Firefox 2.0.0.x don't implement it yet.

Regarding @media:  It matches Opera 9.2x.  Firefox 2.0.0.x doesn't implement @media yet.

Will try @page with Opera and Firefox before landing.

Will try all three with MSIE 7 as well.

Comment 6 Eric Seidel (no email) 2008-01-10 18:47:38 PST
Did this land?
Comment 7 David Kilzer (:ddkilzer) 2008-01-10 19:05:56 PST
(In reply to comment #6)
> Did this land?

Not yet.  Was waiting to do some testing on other browsers first.  Regardless, without this feature, it's not possible to add @media, @page or @font-face rules individually using insertRule().
Comment 8 Eric Seidel (no email) 2008-03-03 11:17:24 PST
WildFox just ran into this while trying to create a nice test case for Acid3 Test 77... We'd love to see this land. :)
Comment 9 David Kilzer (:ddkilzer) 2008-03-03 11:29:24 PST
Working on it now!

Comment 10 David Kilzer (:ddkilzer) 2008-03-03 11:46:13 PST
Committed revision 30715.

Comment 11 Eric Seidel (no email) 2008-03-03 13:05:27 PST
Thank you David!