event loop for cocktail's document