httpswitchboard icon indicating copy to clipboard operation
httpswitchboard copied to clipboard

Inline script tags not reported in matrix under certain conditions

Open gorhill opened this issue 11 years ago • 0 comments

Test case: https://news.ycombinator.com/.

Conditions:

  • Scripts allowed by default in matrix
  • No 3rd-party scripts on the page

The problem is this piece of code in contentScriptSummaryHandler() in https://github.com/gorhill/httpswitchboard/blob/master/js/messaging-handlers.js:

if ( pageStats && inlineScriptBlocked ) {
    urls = details.scriptSources;
    for ( url in urls ) {
        if ( !urls.hasOwnProperty(url) ) {
            continue;
        }
        if ( url === '{inline_script}' ) {
            url = frameURL + '{inline_script}';
        }
        r = httpsb.filterRequest(pageURL, 'script', url);
        pageStats.recordRequest('script', url, r !== false, r);
    }
}

Inline script tags should always be counted, even if inlineScriptBlocked is false. inlineScriptBlocked needs to be used to filter out 3rd-party scripts to avoid counting them twice.

gorhill avatar Sep 16 '14 14:09 gorhill