Skip to content

Commit

Permalink
[netxport] Issue 5160: Add absolute timeout for HAR auto-export
Browse files Browse the repository at this point in the history
  • Loading branch information
janodvarko committed Feb 5, 2012
1 parent 5539ea5 commit 97a8760
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
33 changes: 26 additions & 7 deletions chrome/content/netexport/automation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

FBL.ns(function() { with (FBL) {

// ********************************************************************************************* //

const Cc = Components.classes;
const Ci = Components.interfaces;

Expand All @@ -13,7 +15,7 @@ var prefDomain = "extensions.firebug.netexport";
Components.utils["import"]("resource://firebug/firebug-http-observer.js");
var httpObserver = httpRequestObserver;

// ************************************************************************************************
// ********************************************************************************************* //
// Controller for automatic export.

/**
Expand Down Expand Up @@ -182,7 +184,7 @@ Firebug.NetExport.Automation = extend(Firebug.Module,
}
});

// ************************************************************************************************
// ********************************************************************************************* //

/**
* @class This object is created for a top level window that is being loaded. All requests
Expand All @@ -203,6 +205,11 @@ Firebug.NetExport.PageLoadObserver = function(win)
this.painted = false;

this.registerForWindowLoad();

// This timeout causes the page to be exported even if it's not fully loaded yet.
var time = Firebug.getPref(prefDomain, "timeout");
if (time > 0)
this.absoluteTimeout = setTimeout(bindFixed(this.onAbsoluteTimeout, this), time);
}

Firebug.NetExport.PageLoadObserver.prototype =
Expand Down Expand Up @@ -257,6 +264,15 @@ Firebug.NetExport.PageLoadObserver.prototype =
HttpObserver.onPageLoaded(this.window);
},

// Absolute timout used to export pages that never finish loading.
onAbsoluteTimeout: function()
{
if (FBTrace.DBG_NETEXPORT)
FBTrace.sysout("netexport.onAbsoluteTimeout; Export now!");

HttpObserver.onPageLoaded(this.window);
},

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Support for window loaded events.

Expand Down Expand Up @@ -332,6 +348,9 @@ Firebug.NetExport.PageLoadObserver.prototype =

try
{
clearTimeout(this.absoluteTimeout);
delete this.absoluteTimeout;

clearTimeout(this.timeout);
delete this.timeout;

Expand All @@ -350,7 +369,7 @@ Firebug.NetExport.PageLoadObserver.prototype =
},
};

// ************************************************************************************************
// ********************************************************************************************* //
// HTTP Observer

/**
Expand Down Expand Up @@ -625,7 +644,7 @@ Firebug.NetExport.HttpObserver = extend(new Firebug.Listener(),
},
});

// ************************************************************************************************
// ********************************************************************************************* //

Firebug.NetExport.Logger =
{
Expand Down Expand Up @@ -668,17 +687,17 @@ Firebug.NetExport.Logger =
},
}

// ************************************************************************************************
// ********************************************************************************************* //
// Shortcuts for this namespace

var Automation = Firebug.NetExport.Automation;
var HttpObserver = Firebug.NetExport.HttpObserver;
var PageLoadObserver = Firebug.NetExport.PageLoadObserver;
var Logger = Firebug.NetExport.Logger;

// ************************************************************************************************
// ********************************************************************************************* //

Firebug.registerModule(Firebug.NetExport.Automation);

// ************************************************************************************************
// ********************************************************************************************* //
}});
10 changes: 5 additions & 5 deletions chrome/content/netexport/pageLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const dirService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsI

var prefDomain = "extensions.firebug.netexport";

// ************************************************************************************************
// ********************************************************************************************* //
// Automated load of a page suite

Firebug.NetExport.PageLoader = extend(Firebug.Module,
Expand Down Expand Up @@ -84,7 +84,7 @@ Firebug.NetExport.PageLoader = extend(Firebug.Module,
}
});

// ************************************************************************************************
// ********************************************************************************************* //
// Page load automation

Firebug.NetExport.PageSuite = function(pages)
Expand Down Expand Up @@ -154,14 +154,14 @@ Firebug.NetExport.PageSuite.prototype =
}
}

// ************************************************************************************************
// ********************************************************************************************* //
// Shortcuts for this namespace

var PageSuite = Firebug.NetExport.PageSuite;

// ************************************************************************************************
// ********************************************************************************************* //

Firebug.registerModule(Firebug.NetExport.PageLoader);

// ************************************************************************************************
// ********************************************************************************************* //
}});
4 changes: 4 additions & 0 deletions defaults/preferences/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ pref("extensions.firebug.netexport.sendToConfirmation", true);
// Number of milliseconds to wait after the last page request to declare the page loaded.
pref("extensions.firebug.netexport.pageLoadedTimeout", 1500);

// Number of milliseconds to wait after the page is exported even if not loaded yet.
// Set to zero to switch off this feature.
pref("extensions.firebug.netexport.timeout", 60000);

// Auto export feature is enabled by default.
pref("extensions.firebug.netexport.alwaysEnableAutoExport", false);

Expand Down

0 comments on commit 97a8760

Please sign in to comment.