Bug 1574155 - [wdspec] Use different top-level domains for cross-site iframe tests. r=webdriver-reviewers,ato
authorHenrik Skupin <mail@hskupin.info>
Fri, 16 Aug 2019 10:54:32 +0000
changeset 488479 a61a256c7eafbbbc11b57ed0d8f0e1a1e0144cae
parent 488478 90203b8c145dfc2c1672e0d59f1a2d07e4ee8c2a
child 488480 4918a9dc15d7d8b84fe1cb700e679c75e828503b
push id36444
push userccoroiu@mozilla.com
push dateFri, 16 Aug 2019 16:24:18 +0000
treeherdermozilla-central@8a9e9189cd98 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswebdriver-reviewers, ato
bugs1574155
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1574155 - [wdspec] Use different top-level domains for cross-site iframe tests. r=webdriver-reviewers,ato Using a different subdomain as host for an iframe source doesn't actually qualify for a cross-site origin. Instead the TLD has to be different. Differential Revision: https://phabricator.services.mozilla.com/D42213
testing/web-platform/tests/webdriver/tests/support/fixtures.py
testing/web-platform/tests/webdriver/tests/switch_to_frame/cross_origin.py
--- a/testing/web-platform/tests/webdriver/tests/support/fixtures.py
+++ b/testing/web-platform/tests/webdriver/tests/support/fixtures.py
@@ -163,20 +163,20 @@ def session(capabilities, configuration,
 
 @pytest.fixture(scope="function")
 def current_session():
     return _current_session
 
 
 @pytest.fixture
 def url(server_config):
-    def inner(path, protocol="http", subdomain="", query="", fragment=""):
-        domain = server_config["domains"][""][subdomain]
+    def inner(path, protocol="http", domain="", subdomain="", query="", fragment=""):
+        domain = server_config["domains"][domain][subdomain]
         port = server_config["ports"][protocol][0]
-        host = "%s:%s" % (domain, port)
+        host = "{0}:{1}".format(domain, port)
         return urlparse.urlunsplit((protocol, host, path, query, fragment))
 
     inner.__name__ = "url"
     return inner
 
 
 @pytest.fixture
 def create_dialog(session):
--- a/testing/web-platform/tests/webdriver/tests/switch_to_frame/cross_origin.py
+++ b/testing/web-platform/tests/webdriver/tests/switch_to_frame/cross_origin.py
@@ -1,16 +1,15 @@
+from urlparse import urlparse
+
 import webdriver.protocol as protocol
 
 from tests.support.asserts import assert_success
 from tests.support.helpers import document_location
-from tests.support.inline import (
-    iframe,
-    inline,
-)
+from tests.support.inline import iframe, inline
 
 
 """
 Tests that WebDriver can transcend site origins.
 
 Many modern browsers impose strict cross-origin checks,
 and WebDriver should be able to transcend these.
 
@@ -24,37 +23,42 @@ def switch_to_frame(session, frame):
     return session.transport.send(
         "POST", "/session/{session_id}/frame".format(**vars(session)),
         {"id": frame},
         encoder=protocol.Encoder, decoder=protocol.Decoder,
         session=session)
 
 
 def test_cross_origin_iframe(session, server_config):
-    session.url = inline(iframe("", subdomain="www"))
+    session.url = inline(iframe("", domain="alt"))
     frame_element = session.find.css("iframe", all=False)
 
     response = switch_to_frame(session, frame_element)
-    value = assert_success(response)
-    assert document_location(session).startswith(
-        "http://www.{}".format(server_config["browser_host"]))
+    assert_success(response)
+
+    parse_result = urlparse(document_location(session))
+    assert parse_result.netloc != server_config["browser_host"]
 
 
 def test_nested_cross_origin_iframe(session, server_config):
-    frame2 = iframe("", subdomain="www.www")
-    frame1 = iframe(frame2, subdomain="www")
-    top_doc = inline(frame1, subdomain="")
+    frame2 = iframe("", domain="alt", subdomain="www")
+    frame1 = iframe(frame2)
+    top_doc = inline(frame1, domain="alt")
 
     session.url = top_doc
-    assert document_location(session).startswith(
-        "http://{}".format(server_config["browser_host"]))
+
+    parse_result = urlparse(document_location(session))
+    top_level_host = parse_result.netloc
+    assert not top_level_host.startswith(server_config["browser_host"])
 
-    frame1_el = session.find.css("iframe", all=False)
-    response = switch_to_frame(session, frame1_el)
-    value = assert_success(response)
-    assert document_location(session).startswith(
-        "http://www.{}".format(server_config["browser_host"]))
+    frame1_element = session.find.css("iframe", all=False)
+    response = switch_to_frame(session, frame1_element)
+    assert_success(response)
+
+    parse_result = urlparse(document_location(session))
+    assert parse_result.netloc.startswith(server_config["browser_host"])
 
     frame2_el = session.find.css("iframe", all=False)
     response = switch_to_frame(session, frame2_el)
-    value = assert_success(response)
-    assert document_location(session).startswith(
-        "http://www.www.{}".format(server_config["browser_host"]))
+    assert_success(response)
+
+    parse_result = urlparse(document_location(session))
+    assert parse_result.netloc == "www.{}".format(top_level_host)