#156 new

scoping in iframes: global objects missing

Reported by gleneivey | April 16th, 2010 @ 11:58 AM

This is reproduced by the test specs/frame in thatcher/env-js/tree/frame-scope as of fa042d516cf1c26bafcd2e10ac61b6295d2d70e1.

This test fails with error messages like:

 [java] could not load script  file:///home/gei/Repos/Mainlines/env-js/specs/dom/spec.js
 [java]   ReferenceError: "XMLSerializer" is not defined. 
 [java] error loading script  [object HTMLScriptElement]   ReferenceError: "XMLSerializer" is not defined.

because top-level code in JavaScript files included by <script> tags within HTML loaded into an IFrame doesn't have access to global objects the way it should. The code executing in the IFrame does have its own global object, and objects defined in the global scope in one included JavaScript file (like the QUnit framework) are accessible from others (like specs/dom/spec.js), but the global scope seems not to be loaded with the normal set of global objects. (For what it's worth, some investigation I've done indicates that the global object creation code in env.js itself does not execute each time an IFrame is instantiated, so this may be part of the problem.) In addition, while the test as committed to Git doesn't show this, I've also found that including print() calls (intended for the Rhino shell) in code loaded within an IFrame also generate ReferenceErrors, but top.print() works as expected.

Comments and changes to this ticket

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

a javascript browser environment

People watching this ticket


Referenced by