testing/web-platform/tests/webdriver/tests/close_window/user_prompts.py
author Henrik Skupin <mail@hskupin.info>
Fri, 20 Apr 2018 10:50:14 +0200
changeset 468798 2ec2ee71cc277daf81db6ae6bb21db9495c229b3
parent 468785 295fd2df534f6a5f59f9d620be955a3e70ade74b
child 469608 b27cb10f8110cb9a3475c8ffa4579dac5017520b
permissions -rw-r--r--
Bug 1455282 - [wdspec] Add tests for Close Window command. r=ato MozReview-Commit-ID: 13j69lZhr1G

from tests.support.asserts import assert_error, assert_dialog_handled
from tests.support.fixtures import create_dialog, create_window
from tests.support.inline import inline


def close(session):
    return session.transport.send("DELETE", "session/%s/window" % session.session_id)


def test_handle_prompt_dismiss_and_notify():
    """TODO"""


def test_handle_prompt_accept_and_notify():
    """TODO"""


def test_handle_prompt_ignore():
    """TODO"""


def test_handle_prompt_accept(new_session, add_browser_capabilites):
    _, session = new_session({"capabilities": {
        "alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "accept"})}})
    session.window_handle = create_window(session)()

    session.url = inline("<title>WD doc title</title>")

    create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
    response = close(session)
    assert response.status == 200
    assert_dialog_handled(session, "dismiss #1")

    create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
    response = close(session)
    assert response.status == 200
    assert_dialog_handled(session, "dismiss #2")

    create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
    response = close(session)
    assert response.status == 200
    assert_dialog_handled(session, "dismiss #3")


def test_handle_prompt_missing_value(session, create_dialog, create_window):
    session.window_handle = create_window()

    session.url = inline("<title>WD doc title</title>")
    create_dialog("alert", text="dismiss #1", result_var="dismiss1")

    response = close(session)

    assert_error(response, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #1")

    create_dialog("confirm", text="dismiss #2", result_var="dismiss2")

    response = close(session)
    assert_error(response, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #2")

    create_dialog("prompt", text="dismiss #3", result_var="dismiss3")

    response = close(session)
    assert_error(response, "unexpected alert open")
    assert_dialog_handled(session, "dismiss #3")