def test_add_init_script_work_with_browser_context_scripts_for_already_created_pages(
        page: Page, context: BrowserContext) -> None:
    context.add_init_script("window.temp = 123")
    page.add_init_script("window.injected = window.temp")
    page.goto(
        "data:text/html,<script>window.result = window.injected</script>")
    assert page.evaluate("window.result") == 123
def test_add_init_script_work_with_browser_context_scripts_with_a_path(
        page: Page, context: BrowserContext, assetdir: Path) -> None:
    context.add_init_script(path=assetdir / "injectedfile.js")
    page = context.new_page()
    page.goto(
        "data:text/html,<script>window.result = window.injected</script>")
    assert page.evaluate("window.result") == 123