This repository has been archived by the owner. It is now read-only.

Wipe document.body on every browser test? #74

Closed
augustl opened this Issue Feb 15, 2012 · 10 comments

Comments

Projects
None yet
3 participants
@augustl
Member

augustl commented Feb 15, 2012

Just document.body.innerHTML = ""; That way we can safely add elements to the body of the page in our tests without having to worry about cross test side effects.

Is there any good reason NOT to do this?

@augustl

This comment has been minimized.

Member

augustl commented Feb 15, 2012

Just thought of a good reason not to do it.. In the app I'm testing now, I have this testbed:

<!DOCTYPE html><html><head></head><body><div id="app"></div></body></html>

Some of my code expects there to be a document.getElementById("app") available, so I added it to the testbed. Wiping all of body on every test would break this, obviously.

@magnars

This comment has been minimized.

Member

magnars commented Feb 15, 2012

For people coming from jsTestDriver, not clearing the DOM is gonna be a huge source of WTFs. I think I'd rather have clearing the DOM than testbeds with elements in <body>.

@cjohansen

This comment has been minimized.

Member

cjohansen commented Feb 15, 2012

We could just keep a reference to document.body.innerHTML before running tests, and reset to that between each test? Best of both worlds FTW?

@magnars

This comment has been minimized.

Member

magnars commented Feb 16, 2012

Sounds good!

@augustl

This comment has been minimized.

Member

augustl commented Feb 16, 2012

Obvious +1 is obvious!

@cjohansen

This comment has been minimized.

Member

cjohansen commented Feb 21, 2012

In buster-static, recreating the body on each test will brake incremental output. Any suggestions for how to do it there? Not?

@augustl

This comment has been minimized.

Member

augustl commented Feb 21, 2012

Perhaps we should use a html4 frameset for the testbed in buster-static, just like buster-capture-server.

@cjohansen

This comment has been minimized.

Member

cjohansen commented Feb 21, 2012

Fixed! I added a little kicker: before we save the innerHTML to reuse for later tests, I remove any script tags in the body, so as to avoid downloading scripts over and over.

@cjohansen cjohansen closed this Feb 21, 2012

@cjohansen

This comment has been minimized.

Member

cjohansen commented Feb 22, 2012

Let me clarify: The static fix is not in.

@augustl

This comment has been minimized.

Member

augustl commented Feb 22, 2012

Created a new issue for the buster-static part, so we don't forget.#99

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