Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

scoping issues while loading external scripts?

#83

This is the fragment of the HMTL file i am loading:

<script type="text/javascript">
    print(" ====== LOADING embedded script with pageTracker def");
    var pageTracker = _gat._getTracker("UA-2476765-1");
    print(" ====== FINISHED FIRST");
</script>

<script type="text/javascript" src="Visitestonia.com_files/search_est.js"></script>

This is the beginning of loaded external script search_est.js:

print(" ====== LOADING search_est.js");

// Google Images
pageTracker._addOrganic("images.google", "prev");

This is the Rhino execution output (never mind the "WARNING" log messages i've added to Rhino and the "[jsvalidate]" prefix prepended by Ant as I'm executing it with the Ant task wrapper that i'm currently working on.. these things don't change anything).

[jsvalidate] -- running Main#processFileSecure [jsvalidate] ====== LOADING embedded script with pageTracker def [jsvalidate] ====== FINISHED FIRST [jsvalidate] WARNING!! msg : Reference to undefined property "interval" (at line 0) [jsvalidate] WARNING!! msg : Reference to undefined property "nodeType" (at line 2074) [jsvalidate] WARNING!! msg : Reference to undefined property "nodeType" (at line 2074) [jsvalidate] WARNING!! msg : Reference to undefined property "nodeType" (at line 2074) [jsvalidate] WARNING!! msg : Reference to undefined property "nodeType" (at line 2074) [jsvalidate] WARNING!! msg : Reference to undefined property "type" (at line 5839) [jsvalidate] WARNING!! msg : Reference to undefined property "type" (at line 5839) [jsvalidate] INFO: [Wed Dec 16 2009 18:10:50 GMT+0200 (EET)] {ENVJS} loading allowed external script :Visitestonia.com_files/search_est.js [jsvalidate] -- running Main#processFileSecure [jsvalidate] ====== LOADING search_est.js [jsvalidate] ERROR: uncaught JavaScript runtime exception: ReferenceError: "pageTracker" is not defined. (at line 0) [jsvalidate] js: uncaught JavaScript runtime exception: ReferenceError: "pageTracker" is not defined.

Why I'm sure i haven't just screwed up my Rhino fork or environment is that indeed if i load the version of HTML-file where pageTracker reference is embedded, everything works as expected (i.e. it doesn't complain about pageTracker being null).

<script type="text/javascript">
    print(" ====== LOADING embedded script with pageTracker def");
    var pageTracker = _gat._getTracker("UA-2476765-1");
    print(" ====== FINISHED FIRST");
</script>

<script type="text/javascript">
    print(" ====== LOADING SECOND EMBEDDED SCRIPT");
    pageTracker.do_something();
</script>

Reported by Sander Sõnajalg · December 16th, 2009 @ 06:22 AM

State: resolved
Milestone: 1.2.x
Assigned to: Thatcher Thatcher

Activity

  1. Sander Sõnajalg
    Sander Sõnajalg

    woww... why is the copypasted output so messy.. unix line feeds? maybe that's better..?

    [jsvalidate] -- running Main#processFileSecure [jsvalidate] ====== LOADING embedded script with pageTracker def [jsvalidate] ====== FINISHED FIRST [jsvalidate] WARNING!! msg : Reference to undefined property "interval" (at line 0) [jsvalidate] WARNING!! msg : Reference to undefined property "nodeType" (at line 2074) [jsvalidate] WARNING!! msg : Reference to undefined property "nodeType" (at line 2074) [jsvalidate] WARNING!! msg : Reference to undefined property "nodeType" (at line 2074) [jsvalidate] WARNING!! msg : Reference to undefined property "nodeType" (at line 2074) [jsvalidate] WARNING!! msg : Reference to undefined property "type" (at line 5839) [jsvalidate] WARNING!! msg : Reference to undefined property "type" (at line 5839) [jsvalidate] INFO: [Wed Dec 16 2009 18:10:50 GMT+0200 (EET)] {ENVJS} loading allowed external script :Visitestonia.com_files/search_est.js [jsvalidate] -- running Main#processFileSecure [jsvalidate] ====== LOADING search_est.js [jsvalidate] ERROR: uncaught JavaScript runtime exception: ReferenceError: "pageTracker" is not defined. (at line 0) [jsvalidate] js: uncaught JavaScript runtime exception: ReferenceError: "pageTracker" is not defined.

    December 16th, 2009 @ 06:24 AM

  2. Sander Sõnajalg
  3. Thatcher
    Thatcher
    • Milestone set to 1.2.x
    • State changed from new to open
    • Assigned user set to Thatcher

    I'm checking into this. This is a great test case. Thanks for the submission!

    Thatcher

    February 3rd, 2010 @ 05:29 PM

  4. Thatcher
    Thatcher
    • State changed from open to resolved
    • Tag set to inline, script, type

    this was fixed in http://github.com/thatcher/env-js/commit/f39ab7c539af81cecc41ef8cc6...

    sorry for the delay we where in the middle of a huge refactor

    March 2nd, 2010 @ 07:45 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.