views:

289

answers:

2

Firefox has the Sandbox and evalInSandbox(). Chrome has sandboxed execution in their content scripts (they call it isolated execution). I'm looking for the same thing in an IE browser extension.

I can load a javascript file, then call evalScript(), but the code executes in the same environment as javascript that exists on the page. I need a way to run my library (which includes and is based on jQuery) in an sandboxed/isolated environment, but still allow it to modify the DOM as if it were running on the page.

Jint looks promising, but cannot currently evaluate jQuery. (They can parse it.)

How can I do this?

A: 

You might find it worthwhile looking at the Microsoft Web Sandbox at the Live Labs: http://websandbox.livelabs.com/

Although it's more fully fledged and related to mashups and the like it might point you in the right direction.

jmcd
The Microsoft Web Sandbox protects a page from scripts loaded into it. I need to protect the loaded script from the page. It's a good project, but doesn't help me here.
TelegramSam
A: 

Can you elaborate on your goals a bit?

I don't think you've clearly defined what you're trying to accomplish. If your code has the ability to modify the page's DOM, then it effectively is executing in the context of the page. It can create new script blocks to perform any unsafe or unreliable action that it could accomplish were it operating in the same execution environment.

IE doesn't offer a feature to do what you're asking, and I'm not convinced that the Firefox and Chrome features work the way that you expect that they do.

EricLaw -MSFT-
My goals include running javascript on the page, without the page's javascript being able to access my javascript's methods and variables. I also want a fresh copy of javascript. If the page has redefined a method in javascript, I don't want to be subject to their redefinition.I'm not worried about my script's ability to plant script tags in the DOM to jump out of the sandbox. What I have described is available in Firefox and Chrome. I'll post links to the relevant documentation.
TelegramSam