Bug 17847 - CSS caching corruption
Summary: CSS caching corruption
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Macintosh OS X 10.5
: P2 Normal
Assignee: Nobody
: 17848 (view as bug list)
Depends on:
Reported: 2008-03-14 09:19 PDT by Derk-Jan Hartman
Modified: 2012-03-14 20:40 PDT (History)
3 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Derk-Jan Hartman 2008-03-14 09:19:20 PDT
This is a very complicated bug. I encountered this issue when using the javascript tool twinkle on Wikipedia. The tool gives you extra tabs, that open tools in a CSS window. After finishing the "job", the tool redirects you to the original page you visited.

Website of the tool:

In Safari 3 (and the NB), I was experiencing a problem where after the redirect, my page was only showing the background image. 
Screenshot: http://deneb.student.utwente.nl/~hartman/weird%20issue.png

It appeared as if all my CSS styling was down the drain somehow. If I opened other Wikipedia pages on other tabs or windows the problem persisted. I had to force a reload to make the issue disappear. I believe it was reproducible with this webarchive: http://deneb.student.utwente.nl/~hartman/wikipedia/saferversion.webarchive

I have now looked further into this issue. It was very hard to reduce what was causing this. However I think i have now traced the issue.
Making the following changes in the javascript tool fixed the problem for me:

Basically I changed

var cssNode = document.createElement('style');
cssNode.type = 'text/css';
cssNode.rel = 'stylesheet';
cssNode.appendChild( document.createTextNode("")); // Safari bugfix 
var styles = cssNode.sheet ? cssNode.sheet : cssNode.stylesSheet;
styles.insertRule("my line of CSS", 0);
styles.insertRule("another line of CSS", 0);


var cssNode = document.createElement('style');
cssNode.type = 'text/css';
cssNode.rel = 'stylesheet';
cssNode.appendChild( document.createTextNode("myCSS" ));

So it seems that DOM editing and then using insertRule() breaks something that, as far as I know it should not break. As you may note in the original code there is a reference to a Safari bugfix. This would be bug #14462. It might be related in some way, but I'm not sure.
Comment 1 Mark Rowe (bdash) 2008-03-14 10:15:17 PDT
*** Bug 17848 has been marked as a duplicate of this bug. ***
Comment 2 Shane Stephens 2011-07-06 20:52:56 PDT
Is this still happening in recent versions of WebKit? Any chance of a reduction?