Bug 147721 - Web Inspector: Cached external stylesheets do not (re)output parser warnings for stylesheet to console
Summary: Web Inspector: Cached external stylesheets do not (re)output parser warnings ...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-08-05 21:29 PDT by Joseph Pecoraro
Modified: 2016-12-13 15:38 PST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2015-08-05 21:29:07 PDT
* SUMMARY
Cached external stylesheets do not (re)output parser warnings for stylesheet to console.

* STEPS TO REPRODUCE
1. Inspect inspector-protocol/console/css-source-locations.html via http
  => console warnings for external stylesheet errors.css and inline style
2. Reload
  => console warnings for just inline style

* NOTES
- When errors.css was cached the warnings are not output in the new page load

- HTMLLinkElement::setCSSStyleSheet has a block of code that seems to re-use a cachable sheet, and doesn't re-parse it, without re-parsing (parseAuthorStyleSheet) it the warnings are not re-logged to the console

>    void HTMLLinkElement::setCSSStyleSheet(const String& href, const URL& baseURL, const String& charset, const CachedCSSStyleSheet* cachedStyleSheet)
>    {
>        ...
>        if (RefPtr<StyleSheetContents> restoredSheet = const_cast<CachedCSSStyleSheet*>(cachedStyleSheet)->restoreParsedStyleSheet(parserContext, cachePolicy)) {
>            ...
>            m_loading = false;
>            sheetLoaded();
>            notifyLoadedSheetAndAllCriticalSubresources(false);
>            return;
>        }
>        ...
>        styleSheet.get().parseAuthorStyleSheet(cachedStyleSheet, document().securityOrigin());
>        ...
>    }
Comment 1 Joseph Pecoraro 2015-08-05 21:35:59 PDT
User impact is that if the resource was cached (and restored by this path) then the user will never see parser warnings if they open the stylesheet and view in Web Inspector. If they opened the same resource when it was not cached (in this way) they see the warnings inline.
Comment 2 Antti Koivisto 2015-08-06 01:42:57 PDT
I suppose the right approach here depends what the inspector intention is. Should it accurately report what happens during the page load? We don't parse the sheet if it is cached so there are no parse errors. Or should it show maximum amount of information about the page resources?
Comment 3 BJ Burg 2015-08-06 09:35:55 PDT
(In reply to comment #2)
> I suppose the right approach here depends what the inspector intention is.
> Should it accurately report what happens during the page load? We don't
> parse the sheet if it is cached so there are no parse errors. Or should it
> show maximum amount of information about the page resources?

IMO, not reparsing is a performance optimization that should not be surfaced.  I think the Inspector should show the same parse errors, whether or not the resource was cached- this is what happens for other cached resources that have syntax errors, like JS.

The inspector does not currently show whether the stylesheet was reparsed or not. (In fact, it gets reparsed by the inspector many times, but this is transparent.) Joe and I had to dig into WebCore and use breakpoints to get some ground truth on whether something was reparsed.
Comment 4 David Kilzer (:ddkilzer) 2016-09-09 11:54:23 PDT
<rdar://problem/28229430>