Bug 1319237 - Correct window size- and position test; r?automatedtester,jgraham draft
authorAndreas Tolfsen <ato@mozilla.com>
Mon, 21 Nov 2016 23:30:23 +0100
changeset 442935 79ee575b835f963d4bcdfcece810745022805ccb
parent 442901 2a47a071271f61d69019aed92da55383fdc05cef
child 442936 a2cbc8bed522894cfe844470e44e8a7d852f4a8d
push id36873
push userbmo:ato@mozilla.com
push dateWed, 23 Nov 2016 16:03:30 +0000
reviewersautomatedtester, jgraham
bugs1319237
milestone53.0a1
Bug 1319237 - Correct window size- and position test; r?automatedtester,jgraham MozReview-Commit-ID: Fajaksg2DhG
testing/web-platform/meta/webdriver/contexts.py.ini
testing/web-platform/tests/webdriver/contexts.py
deleted file mode 100644
--- a/testing/web-platform/meta/webdriver/contexts.py.ini
+++ /dev/null
@@ -1,10 +0,0 @@
-[contexts.py]
-  type: wdspec
-  expected:
-    if not debug and (version != "Ubuntu 16.04"): TIMEOUT
-  [contexts.py::test_resize]
-    expected: FAIL
-
-  [contexts.py::test_resize_by_script]
-    expected: FAIL
-
--- a/testing/web-platform/tests/webdriver/contexts.py
+++ b/testing/web-platform/tests/webdriver/contexts.py
@@ -1,41 +1,56 @@
 import json
 import pytest
 import webdriver
 
+def window_size_supported(session):
+    try:
+        session.window.size = ("a", "b")
+    except webdriver.UnsupportedOperationException:
+        return False
+    except webdriver.InvalidArgumentException:
+        return True
 
-@pytest.mark.xfail(raises=webdriver.UnsupportedOperationException)
+def window_position_supported(session):
+    try:
+        session.window.position = ("a", "b")
+    except webdriver.UnsupportedOperationException:
+        return False
+    except webdriver.InvalidArgumentException:
+        return True
+
 def test_window_size_types(http, session):
-    session.start()
+    if not window_size_supported(session):
+        pytest.skip()
+
     with http.get("/session/%s/window/size" % session.session_id) as resp:
         assert resp.status == 200
         body = json.load(resp)
     assert "width" in body
     assert "height" in body
     assert isinstance(body["width"], int)
     assert isinstance(body["height"], int)
 
     size = session.window.size
     assert isinstance(size, tuple)
     assert isinstance(size[0], int)
     assert isinstance(size[1], int)
 
 
-@pytest.mark.xfail(raises=webdriver.UnsupportedOperationException)
 def test_window_resize(session):
+    if not window_size_supported(session):
+        pytest.skip()
+
     # setting the window size by webdriver is synchronous
     # so we should see the results immediately
 
     session.window.size = (400, 500)
     assert session.window.size == (400, 500)
 
-    session.window.size = (500, 600)
-    assert session.window.size == (500, 600)
-
 
 """
 TODO(ato):
 
     Disable test because the while statements are wrong.
     To fix this properly we need to write an explicit wait utility.
 
 def test_window_resize_by_script(session):
@@ -53,23 +68,24 @@ def test_window_resize_by_script(session
     session.execute_script("window.resizeTo(800, 900)")
     size2 = session.window.size
     while size1 == size2:
         size2 = session.window.size
         assert size2 == (800, 900)
     assert size2 == {"width": 200, "height": 100}
 """
 
-@pytest.mark.xfail(raises=webdriver.UnsupportedOperationException)
 def test_window_position_types(http, session):
-    session.start()
+    if not window_position_supported(session):
+        pytest.skip()
+
     with http.get("/session/%s/window/position" % session.session_id) as resp:
         assert resp.status == 200
         body = json.load(resp)
     assert "x" in body
     assert "y" in body
     assert isinstance(body["x"], int)
     assert isinstance(body["y"], int)
 
-    size = session.window.position
-    assert isinstance(size, tuple)
-    assert isinstance(size[0], int)
-    assert isinstance(size[1], int)
+    pos = session.window.position
+    assert isinstance(pos, tuple)
+    assert isinstance(pos[0], int)
+    assert isinstance(pos[1], int)