Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Exporting HAR from the Network panel

653 views
Skip to first unread message

Jan Odvarko

unread,
May 27, 2015, 11:19:15 AM5/27/15
to dev-developer-tools dev
I have been working on a firebug-gaps feature related to HAR export
(exporting data collected by the Network panel into HTTP Archive Format).
The manual export (copy to clipboard and save as HAR) is quite
straightforward and there is already a working patch waiting for a review
(Bug 1167080).

The second part of the feature is support for automation. It should be
possible to automate HAR exporting using e.g. Selenium. For instance, run a
test suite and get HAR data for every loaded test page automatically. All
HAR data can be consequently analyzed to figure out also page load
peformance during testing. You can follow bug 1167080 (there is already a
patch for it).

I have solved this by designing a simple HAR API. If a preference is set
(new pref introduced for the HAR feature) the HAR API is exposed to the
content.

There are two methods:
HAR.triggerExport() : allows triggering HAR export at any time during the
page life time.
HAR.clear() : allows clearing content of the Network panel (to avoid
duplicated data exports).

Here is an example of a script that can automatically trigger the export
(from within the content scope):

// myWebApplication.html
// Helper function that exports data collected by the Network panel
// and then clears its content.
function onExportHar(e) {
var options = {
fileName: "myFile.har", // Save into this file
getData: true, // get also HAR string back
}

HAR.triggerExport(options).then(result) {
// Log HAR string into the console
console.log(result.data);

// Data exported, clean up the Network panel
HAR.clear();
});
}

addEventListener("load", onExportHar, true);

---


This approach is simple and flexible enough to fully automate the export.
I have already collected some feedback here:
https://groups.google.com/forum/#!topic/firebug/u3nbmQfiMHk


Do you have any opinions about the approach?
Could it be yet improved/simplified?


Honza

Panos Astithas

unread,
May 28, 2015, 8:57:32 AM5/28/15
to Jan Odvarko, dev-developer-tools dev
I only looked briefly, but injecting a content-accessible API is something
that we have never done before in devtools. I'm not saying that we
shouldn't do it, but that we have to discuss it with DOM and security folks
first. Bobby Holley might be a good candidate for having this discussion.
> _______________________________________________
> dev-developer-tools mailing list
> dev-devel...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-developer-tools
>

Jan Odvarko

unread,
May 28, 2015, 9:28:50 AM5/28/15
to Panos Astithas, dev-developer-tools dev

> On 28 May 2015, at 14:57, Panos Astithas <pa...@mozilla.com> wrote:
>
> I only looked briefly, but injecting a content-accessible API is something that we have never done before in devtools. I'm not saying that we shouldn't do it, but that we have to discuss it with DOM and security folks first. Bobby Holley might be a good candidate for having this discussion.
Yes, precisely, I am aware of that, I’ll ping Bobby.

Any thoughts about an alternative?
(e.g. another place where the API could be exposed
and still being accessible by automated tools).

Honza
> https://groups.google.com/forum/#!topic/firebug/u3nbmQfiMHk <https://groups.google.com/forum/#!topic/firebug/u3nbmQfiMHk>
>
>
> Do you have any opinions about the approach?
> Could it be yet improved/simplified?
>
>
> Honza
> _______________________________________________
> dev-developer-tools mailing list
> dev-devel...@lists.mozilla.org <mailto:dev-devel...@lists.mozilla.org>
> https://lists.mozilla.org/listinfo/dev-developer-tools <https://lists.mozilla.org/listinfo/dev-developer-tools>
>

Joe Walker

unread,
May 28, 2015, 9:46:50 AM5/28/15
to Jan Odvarko, dev-developer-tools dev
Would this be primarily for Selenium? If so, maybe we should just ask David
Burns (@automatedtester) what to do.

Joe.
> https://lists.mozilla.org/listinfo/dev-developer-tools
>

Jan Odvarko

unread,
May 28, 2015, 9:57:56 AM5/28/15
to Joe Walker, dev-developer-tools dev

> On 28 May 2015, at 15:46, Joe Walker <jwa...@mozilla.com> wrote:
>
>
> Would this be primarily for Selenium? If so, maybe we should just ask David Burns (@automatedtester) what to do.
Not only for Selenium, but having opinion from David
is good idea (email just sent).

Honza


>
> Joe.
>
>
> On Thu, May 28, 2015 at 2:33 PM, Jan Odvarko <odv...@gmail.com <mailto:odv...@gmail.com>> wrote:
> > https://groups.google.com/forum/#!topic/firebug/u3nbmQfiMHk <https://groups.google.com/forum/#!topic/firebug/u3nbmQfiMHk> <https://groups.google.com/forum/#!topic/firebug/u3nbmQfiMHk <https://groups.google.com/forum/#!topic/firebug/u3nbmQfiMHk>>
> >
> >
> > Do you have any opinions about the approach?
> > Could it be yet improved/simplified?
> >
> >
> > Honza
> > _______________________________________________
> > dev-developer-tools mailing list
> > dev-devel...@lists.mozilla.org <mailto:dev-devel...@lists.mozilla.org> <mailto:dev-devel...@lists.mozilla.org <mailto:dev-devel...@lists.mozilla.org>>
> > https://lists.mozilla.org/listinfo/dev-developer-tools <https://lists.mozilla.org/listinfo/dev-developer-tools> <https://lists.mozilla.org/listinfo/dev-developer-tools <https://lists.mozilla.org/listinfo/dev-developer-tools>>

dbu...@mozilla.com

unread,
May 28, 2015, 11:10:14 AM5/28/15
to mozilla-dev-d...@lists.mozilla.org
I know that there is a need for this type of data to be exported and doing so through automation would be a great idea.

The simplest approach from a Selenium point of view is to have an object we can call and use the results. Ideally this would just be some content JavaScript that we can call.

E.g. driver.execute_script("return Har.getHar()") #JS API made up so can be anything.

Marionette, the replacement for the selenium firefoxdriver, can do chrome JavaScript calls but we are not going to be exposing that to the selenium community (It might void their Firefox warranty) and they don't really need it. They can use our python library for that type of automation.

If security are worried about this, and since it's for automation only, we can see about only exposing this when webdriver/marionette is enabled. I have raised a bug[1] to add fingerprinting when the browser in automation mode.

I hope that answers your questions :)

David

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1169290

Jordan Santell

unread,
May 28, 2015, 11:13:29 AM5/28/15
to dbu...@mozilla.com, mozilla-dev-d...@lists.mozilla.org
For what it's worth, this kind of automation insight is desirable for
performance tools as well.

On Thu, May 28, 2015 at 8:10 AM, <dbu...@mozilla.com> wrote:

> I know that there is a need for this type of data to be exported and doing
> so through automation would be a great idea.
>
> The simplest approach from a Selenium point of view is to have an object
> we can call and use the results. Ideally this would just be some content
> JavaScript that we can call.
>
> E.g. driver.execute_script("return Har.getHar()") #JS API made up so can
> be anything.
>
> Marionette, the replacement for the selenium firefoxdriver, can do chrome
> JavaScript calls but we are not going to be exposing that to the selenium
> community (It might void their Firefox warranty) and they don't really need
> it. They can use our python library for that type of automation.
>
> If security are worried about this, and since it's for automation only, we
> can see about only exposing this when webdriver/marionette is enabled. I
> have raised a bug[1] to add fingerprinting when the browser in automation
> mode.
>
> I hope that answers your questions :)
>
> David
>
> [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1169290
>
>
>
> On Wednesday, 27 May 2015 16:19:15 UTC+1, Jan Odvarko wrote:
> _______________________________________________
> dev-developer-tools mailing list
> dev-devel...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-developer-tools
>

David Burns

unread,
May 28, 2015, 3:37:19 PM5/28/15
to Jordan Santell, mozilla-dev-d...@lists.mozilla.org
Yea, I can see value of having it on the performance timing interface.

David

On 28 May 2015 at 16:13, Jordan Santell <jsan...@mozilla.com> wrote:

> For what it's worth, this kind of automation insight is desirable for
> performance tools as well.
>
> On Thu, May 28, 2015 at 8:10 AM, <dbu...@mozilla.com> wrote:
>
>> I know that there is a need for this type of data to be exported and
>> doing so through automation would be a great idea.
>>
>> The simplest approach from a Selenium point of view is to have an object
>> we can call and use the results. Ideally this would just be some content
>> JavaScript that we can call.
>>
>> E.g. driver.execute_script("return Har.getHar()") #JS API made up so can
>> be anything.
>>
>> Marionette, the replacement for the selenium firefoxdriver, can do chrome
>> JavaScript calls but we are not going to be exposing that to the selenium
>> community (It might void their Firefox warranty) and they don't really need
>> it. They can use our python library for that type of automation.
>>
>> If security are worried about this, and since it's for automation only,
>> we can see about only exposing this when webdriver/marionette is enabled. I
>> have raised a bug[1] to add fingerprinting when the browser in automation
>> mode.
>>
>> I hope that answers your questions :)
>>
>> David
>>
>> [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1169290
>>
>>
>>
>> On Wednesday, 27 May 2015 16:19:15 UTC+1, Jan Odvarko wrote:
0 new messages