firebug / har-export-trigger

Trigger HAR export any time directly from within a page.
Other
52 stars 13 forks source link

Reference lost - ReferenceError: HAR is not defined #13

Open JosephCastro opened 8 years ago

JosephCastro commented 8 years ago

Hi

I trying to get the HAR for youtube video, so what I do is basically the same actions for load HAR plugin (works with other sites):

I trying to lose the reference with other video sites, but only happen with youtube (not always), so There's a way to lose the reference to HAR object?

Thanks for your response.

janodvarko commented 8 years ago

What version of Firefox and HAR Export Trigger do use use?

I tried the STR on Nightly with the latest source (HARExportTrigger, master) and it seems to be working for me. Also, do you open the Toolbox or do you have extensions.netmonitor.har.autoConnect pref set to true?

Honza

janodvarko commented 8 years ago

Btw. I just fixed one compatibility bug with Fx42 Here is a test build http://janodvarko.cz/temp/har/harexporttrigger-0.5.0-beta.7.11.1.xpi

@JosephCastro Does it fix your problem?

Honza

JosephCastro commented 8 years ago

Firefox 42, HAR Export Trigger 0.5.0-beta6, toolbox open. But without the extensions.netmonitor.har.autoConnect (false).

Now I testing the 0.5.0-beta7 without the pref and have the same problem, but setting the pref to true, sometimes works fine, other times HAR is not defined. It's a little bit random.

Maybe can be a JS from youtube or too many redirects ... but the plugin is attached to the tab (also I open all in the home tab) not to the page.

janodvarko commented 8 years ago

Here is my config:

And here are my steps to reproduce the problem (STR): 1) Start Firefox 2) Open a new (empty) tab by clicking on the + button in the tab bar 3) Typing: youtube.com in the URL bar, pressing enter 4) The address is redirected to: https://www.youtube.com/ 5) Opening the developer Toolbox by pressing F12 (Win7) 6) Selecting the Console panel and executing "HAR" (no quotes) expression on the command line 7) The HAR object exists 8) Clicking on one of the videos, it start playing 9) Again, executing "HAR" (no quotes) expression on the command line 10) The HAR object still exists

Does this works for you? If yes, what's the difference from your STR?

Honza

JosephCastro commented 8 years ago

Yes, your STR works.

Config:

STR: 1.- Start firefox 2.- Open toolbox (F12) 3.- Test: HAR is defined (by executing HAR in command line) 3.- Using the default tab, adding the youtube.com url 4.- Log in into youtube.com 5.- Wait until the redirect to youtube home 6.- Test: HAR is defined 7.- Type the url to go (some video) 8.- Wait until load 9.- Test: HAR is defined or not.

In the last step, sometimes the HAR is defined other times not. I tested with other sites, but the HAR is defined, only with youtube video site give me sometimes the reference error.

janodvarko commented 8 years ago

I can't reproduce it... :(

Do you see any errors in the Browser Console? (except of the reference error)

Honza

JosephCastro commented 8 years ago

Nope, no more errors.

It's random... I can't reproduce always. :c

JosephCastro commented 8 years ago

Note: This happen when I get a video ad (not nonlinear or companions)

janodvarko commented 8 years ago

Note: This happen when I get a video ad (not nonlinear or companions)

What do you mean by nonlinear or companions?

Honza

JosephCastro commented 8 years ago

They are three types of ads in youtube:

janodvarko commented 8 years ago

@JosephCastro I am unable to see the issue on my machine.

Could you provide a simple online page that I could access and see the problem?

Honza

JosephCastro commented 8 years ago

It's difficult to do that, but I will try it.

janodvarko commented 8 years ago

Thanks!

Honza

tobli commented 8 years ago

I'm running Firefox and exporting HARs via Selenium (FF 42, harexporttrigger-0.5.0-beta.7), and had the same issue. I solved it like this:

            function triggerExport() {
              HAR.triggerExport({'token':'test', 'getData':true})
              .then((result) => {…/* return har via callback */}));
            };
            if (typeof HAR === 'undefined') {
              addEventListener('har-api-ready', triggerExport, false);
            } else {
              triggerExport();
            }`;

If HAR isn't yet defined, wait for the har-api-ready event. Otherwise trigger the export right away.

janodvarko commented 8 years ago

Nice!

I don't know if this solves the reported issue for @JosephCastro, but I am sure the script will be useful for others.

I've put it on FAQ page: https://github.com/firebug/har-export-trigger/wiki/FAQ#har-is-not-defined

Honza

JosephCastro commented 8 years ago

I can't create a test for this error, I can't replicate the youtube error. @tobli Nice, I will try it.