Commit 05853da1 authored by Julian Descottes's avatar Julian Descottes
Browse files

Bug 1822772 - [wdspec] Add tests for document open with bidi load events...

Bug 1822772 - [wdspec] Add tests for document open with bidi load events r=webdriver-reviewers,whimboo

Depends on D173164

Differential Revision: https://phabricator.services.mozilla.com/D173022
parent 118a86f5
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
import pytest
from tests.support.sync import AsyncPoll
from webdriver.bidi.modules.script import ContextTarget

from ... import int_interval
from .. import assert_navigation_info
@@ -119,3 +120,18 @@ async def test_new_context(bidi_session, subscribe_events, wait_for_event, type_
    event = await on_entry

    assert_navigation_info(event, {"context": new_context["context"], "url": "about:blank"})


async def test_document_write(bidi_session, subscribe_events, top_context, wait_for_event):
    await subscribe_events(events=[DOM_CONTENT_LOADED_EVENT])

    on_entry = wait_for_event(DOM_CONTENT_LOADED_EVENT)

    await bidi_session.script.evaluate(
        expression="""document.open(); document.write("<h1>Replaced</h1>"); document.close();""",
        target=ContextTarget(top_context["context"]),
        await_promise=False
    )

    event = await on_entry
    assert_navigation_info(event, {"context": top_context["context"]})
+16 −0
Original line number Diff line number Diff line
import pytest
from tests.support.sync import AsyncPoll
from webdriver.bidi.modules.script import ContextTarget
from webdriver.error import TimeoutException

from ... import int_interval
@@ -108,3 +109,18 @@ async def test_new_context(bidi_session, subscribe_events, wait_for_event, type_
    event = await on_entry

    assert_navigation_info(event, {"context": new_context["context"], "url": "about:blank"})


async def test_document_write(bidi_session, subscribe_events, top_context, wait_for_event):
    await subscribe_events(events=[CONTEXT_LOAD_EVENT])

    on_entry = wait_for_event(CONTEXT_LOAD_EVENT)

    await bidi_session.script.evaluate(
        expression="""document.open(); document.write("<h1>Replaced</h1>"); document.close();""",
        target=ContextTarget(top_context["context"]),
        await_promise=False
    )

    event = await on_entry
    assert_navigation_info(event, {"context": top_context["context"]})