Need our own RunInContext #37

Closed
assaf opened this Issue Jan 5, 2011 · 7 comments

Comments

Projects
None yet
3 participants
Owner

assaf commented Jan 5, 2011

Node.js implements RunInContext by creating a context and using the sandbox to copy properties in/out of the context.

To make it work synchronously we start by having Windows be the context and the define certain properties to be non-configurable (location, storage, etc) so Node doesn't attempt to copy them (e.g. copying location from context to sandbox redirects the page).

But that doesn't work asynchronously, asynchronous events that run later on (e.g. XHR) operate on the context, properties changed them (global/window) do not propagate back to the sandbox.

So we're going to need our own implementation that can evaluate a script in the context of an object we give it (Window) without all the variable copying. And we know we can trust the evaluated code because, well, we're running tests.

Contributor

boblail commented Jan 21, 2011

I believe this is the reason why the Capybara example Capybara::Driver::Zombie it should behave like session with javascript support all JS specs#wait_until should wait for block to return true is failing for capybara-zombie

Contributor

juggy commented Jan 27, 2011

Is it why code executed in jquery onload callback is not executed in the window context. I am also having trouble with xhr callbacks.

Contributor

boblail commented Jan 27, 2011

Yes, I believe this ticket describes the root of the problems you're experiencing.

Contributor

juggy commented Jan 27, 2011

In the code you commented this:
# Unfortunately, using the same context in multiple scripts
# doesn't agree with jQuery, Sammy and other scripts I tested,
# so each script gets a new context.

Did you investigate as to why they didn't work?

Julien.

Owner

assaf commented Feb 17, 2011

And ... it's a wrap.

This is a native extension, so if you're checking it out from head, run cake build first.

Contributor

boblail commented Feb 18, 2011

Assaf, congratulations! I got the notice this morning and couldn't wait to get home from work to try it out. :)

Nice work.

Owner

assaf commented Feb 18, 2011

Thanks.

djanowski pushed a commit to djanowski/zombie that referenced this issue Jun 12, 2015

djanowski pushed a commit to djanowski/zombie that referenced this issue Jun 12, 2015

djanowski pushed a commit to djanowski/zombie that referenced this issue Jun 12, 2015

djanowski pushed a commit to djanowski/zombie that referenced this issue Jun 12, 2015

djanowski pushed a commit to djanowski/zombie that referenced this issue Jun 12, 2015

djanowski pushed a commit to djanowski/zombie that referenced this issue Jun 12, 2015

djanowski pushed a commit to djanowski/zombie that referenced this issue Jun 12, 2015

djanowski pushed a commit to djanowski/zombie that referenced this issue Jun 12, 2015

[#37] Compile scripts once, speed up test suite.
Fixed error handling on timeout/XHR scripts, these now generate an onerror event.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment