Skip to content
This repository has been archived by the owner on Nov 15, 2017. It is now read-only.

Commit

Permalink
this fixes #191
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Feb 23, 2014
1 parent bc75708 commit 47cca7e
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions js/traffic.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,17 @@ function onBeforeRequestHandler(details) {

pageStats = httpsb.pageStatsFromTabId(tabId);

// Re-classify orphan HTTP requests as behind-the-scene requests. There is
// not much else which can be done, because there are URLs
// which cannot be handled by HTTP Switchboard, i.e. `opera://startpage`,
// as this would lead to complications with no obvious solution, like how
// to scope on unknown scheme? Etc.
// https://github.com/gorhill/httpswitchboard/issues/191
if ( !pageStats ) {
tabId = httpsb.behindTheSceneTabId;
pageStats = httpsb.pageStatsFromTabId(tabId);
}

// rhill 2013-12-16: I don't remember... Can pageStats still be nil at
// this point?
// Answer: Yes. Requests might still be dispatched after
Expand All @@ -179,7 +190,7 @@ function onBeforeRequestHandler(details) {
// console.error('onBeforeRequestHandler() > no pageStats: %o', details);
// }

if ( isApp && pageStats ) {
if ( isApp ) {
pageStats.ignore = true;
}

Expand All @@ -193,7 +204,7 @@ function onBeforeRequestHandler(details) {
type = httpsb.transposeType(type, requestURL);
}

if ( pageStats && pageStats.ignore ) {
if ( pageStats.ignore ) {
canEvaluate = false;
}

Expand All @@ -204,14 +215,12 @@ function onBeforeRequestHandler(details) {
block = httpsb.blacklisted(pageURL, type, hostname);
}

if ( pageStats ) {
// rhill 2014-01-15: Delay logging of non-blocked top `main_frame`
// requests, in order to ensure any potential redirects is reported
// in proper chronological order.
// https://github.com/gorhill/httpswitchboard/issues/112
if ( !isWebPage || block ) {
pageStats.recordRequest(type, requestURL, block);
}
// rhill 2014-01-15: Delay logging of non-blocked top `main_frame`
// requests, in order to ensure any potential redirects is reported
// in proper chronological order.
// https://github.com/gorhill/httpswitchboard/issues/112
if ( !isWebPage || block ) {
pageStats.recordRequest(type, requestURL, block);
}

// Collect global stats
Expand Down

0 comments on commit 47cca7e

Please sign in to comment.