add constrain for window and document objects