Bug 205499

Summary: Improve stylesheet error loading handling
Product: WebKit Reporter: Rob Buis <rbuis>
Component: Page LoadingAssignee: Rob Buis <rbuis>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: beidson, cdumez, darin, dbates, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, japhet, macpherson, menard, youennf
Priority: P2    
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Rob Buis 2019-12-20 05:59:43 PST
Improve stylesheet error loading handling
Comment 1 Rob Buis 2019-12-20 06:04:29 PST
Created attachment 386211 [details]
Patch
Comment 2 Rob Buis 2019-12-22 09:55:32 PST
Created attachment 386317 [details]
Patch
Comment 3 youenn fablet 2019-12-24 02:03:09 PST
Comment on attachment 386317 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=386317&action=review

> Source/WebCore/ChangeLog:12
> +        Behavior matches Firefox.

Change looks fine to me, I am wondering about backward compat though.
Does it match Chrome behavior? If not, do you know if Chrome is planning to align here?
Comment 4 Darin Adler 2019-12-26 20:50:16 PST
Comment on attachment 386317 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=386317&action=review

Behavior change looks good, but the way it’s implemented seems really confusing and sort of backward.

> Source/WebCore/css/StyleSheetContents.cpp:327
> +        const_cast<CachedCSSStyleSheet*>(cachedStyleSheet)->setStatus(CachedResource::LoadError);

Seems really unfortunate to do this with a const_cast and a side effect. Can we do something else to make it clear this is correct? Like do this at another level, inside the cache, instead of here?

> Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp:155
> +    bool typeOK = mimeType.isEmpty() || equalLettersIgnoringASCIICase(mimeType, "text/css") || equalLettersIgnoringASCIICase(mimeType, "application/x-unknown-content-type") || !isValidContentType(mimeType);

I don’t understand this change.

This code says "all invalid content types are OK". Why is that correct? Nothing in the change log or the comments makes that clear.
Comment 5 Rob Buis 2020-01-05 08:40:16 PST
(In reply to youenn fablet from comment #3)
> Comment on attachment 386317 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=386317&action=review
> 
> > Source/WebCore/ChangeLog:12
> > +        Behavior matches Firefox.
> 
> Change looks fine to me, I am wondering about backward compat though.
> Does it match Chrome behavior? If not, do you know if Chrome is planning to
> align here?

No, I try to explicitly state the implementations that support the feature, so if I do not list it it means I believe the implementation does not support it.

I don't know if Chrome is planning to support it, I could ask but I think I'll just upload a patch and see if there is interest.

I noticed recently that this existing bug is probably more relevant, so I'll move my work over there:
https://bugs.webkit.org/show_bug.cgi?id=189913
Comment 6 Rob Buis 2020-01-05 08:42:28 PST
Comment on attachment 386317 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=386317&action=review

>> Source/WebCore/css/StyleSheetContents.cpp:327
>> +        const_cast<CachedCSSStyleSheet*>(cachedStyleSheet)->setStatus(CachedResource::LoadError);
> 
> Seems really unfortunate to do this with a const_cast and a side effect. Can we do something else to make it clear this is correct? Like do this at another level, inside the cache, instead of here?

Yes that was a bit hacky. I believe I found a cleaner way, continuing my work on https://bugs.webkit.org/show_bug.cgi?id=189913.

>> Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp:155
>> +    bool typeOK = mimeType.isEmpty() || equalLettersIgnoringASCIICase(mimeType, "text/css") || equalLettersIgnoringASCIICase(mimeType, "application/x-unknown-content-type") || !isValidContentType(mimeType);
> 
> I don’t understand this change.
> 
> This code says "all invalid content types are OK". Why is that correct? Nothing in the change log or the comments makes that clear.

Will provide a link to the spec soon, whenever this shows up on https://bugs.webkit.org/show_bug.cgi?id=189913.
Comment 7 Rob Buis 2020-01-05 08:43:09 PST

*** This bug has been marked as a duplicate of bug 189913 ***