From f1954e832e773dcf1b8150974f5615cc68be2296 Mon Sep 17 00:00:00 2001 From: Henrik Skupin Date: Tue, 25 Aug 2020 19:32:48 +0000 Subject: [PATCH] Bug 1660426 - [wdspec] Improve tests for "Get Title" and add site-isolation test. r=maja_zf,marionette-reviewers Differential Revision: https://phabricator.services.mozilla.com/D88016 --- .../tests/unit/test_navigation.py | 18 +++++ .../tests/unit/test_title.py | 50 +------------ .../webdriver/tests/get_title/iframe.py.ini | 4 ++ .../tests/webdriver/tests/get_title/get.py | 53 +++++--------- .../tests/webdriver/tests/get_title/iframe.py | 70 +++++++++++++++++++ 5 files changed, 114 insertions(+), 81 deletions(-) create mode 100644 testing/web-platform/meta/webdriver/tests/get_title/iframe.py.ini create mode 100644 testing/web-platform/tests/webdriver/tests/get_title/iframe.py diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py b/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py index bcd6cf109fa8..3f63c0acadab 100644 --- a/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py @@ -15,6 +15,7 @@ from marionette_driver.marionette import Alert from marionette_harness import ( MarionetteTestCase, run_if_manage_instance, + skip, WindowManagerMixin, ) @@ -163,6 +164,23 @@ class TestNavigate(BaseNavigationTestCase): self.marionette.navigate(self.test_page_frameset) self.marionette.find_element(By.NAME, "third") + @skip("https://bugzilla.mozilla.org/show_bug.cgi?id=1255946") + def test_navigate_top_frame_from_nested_context(self): + self.marionette.navigate(inline("""foo +" % frame_doc) +nested_frames_doc = inline("foo" % one_frame_doc) + + +def get_title(session): + return session.transport.send( + "GET", "session/{session_id}/title".format(**vars(session))) + + +def test_no_iframe(session): + session.url = inline("Foobar

Hello

") + + result = get_title(session) + assert_success(result, "Foobar") + + +def test_iframe(session): + session.url = one_frame_doc + + frame = session.find.css("iframe", all=False) + session.switch_frame(frame) + session.find.css("p", all=False) + + response = get_title(session) + assert_success(response, "bar") + + +def test_nested_iframe(session): + session.url = nested_frames_doc + + outer_frame = session.find.css("iframe", all=False) + session.switch_frame(outer_frame) + + inner_frame = session.find.css("iframe", all=False) + session.switch_frame(inner_frame) + session.find.css("p", all=False) + + response = get_title(session) + assert_success(response, "foo") + + +@pytest.mark.parametrize("domain", ["", "alt"], ids=["same_origin", "cross_origin"]) +def test_origin(session, domain, url): + session.url = inline("foo{}".format( + iframe("bar

frame", domain=domain))) + + frame = session.find.css("iframe", all=False) + session.switch_frame(frame) + session.find.css("p", all=False) + + response = get_title(session) + assert_success(response, "foo")