Bug 1396185 - [wdspec] Fix race condition in test_title_after_modification. r=ato, a=test-only
authorHenrik Skupin <mail@hskupin.info>
Thu, 26 Apr 2018 23:13:12 +0200
changeset 795871 3274916e9c7be879da3680fa0329a69403abdbf7
parent 795870 c06b7fd656fb86b8c5f9e512e9bc592e13bad96b
child 795872 f7e822f67a4490520630cc8271b948c0fa30d112
push id110108
push userbmo:tom@mozilla.com
push dateWed, 16 May 2018 18:43:56 +0000
reviewersato, test-only
bugs1396185
milestone60.0.1
Bug 1396185 - [wdspec] Fix race condition in test_title_after_modification. r=ato, a=test-only Using "WebDriver:ExecuteScript" to set the document title can cause a race condition when the title gets retrieved from the parent process. To guard against it "wait()" should be used. MozReview-Commit-ID: DyrHpQSKLjy
testing/web-platform/tests/webdriver/tests/navigation/get_title.py
--- a/testing/web-platform/tests/webdriver/tests/navigation/get_title.py
+++ b/testing/web-platform/tests/webdriver/tests/navigation/get_title.py
@@ -1,11 +1,12 @@
 from tests.support.asserts import assert_error, assert_success, assert_dialog_handled
 from tests.support.fixtures import create_dialog
 from tests.support.inline import inline
+from tests.support.wait import wait
 
 
 def read_global(session, name):
     return session.execute_script("return %s;" % name)
 
 
 def get_title(session):
     return session.transport.send(
@@ -144,20 +145,21 @@ def test_title_without_element(session):
     session.url = inline("<h2>Hello</h2>")
 
     result = get_title(session)
     assert_success(result, read_global(session, "document.title"))
 
 
 def test_title_after_modification(session):
     session.url = inline("<title>Initial</title><h2>Hello</h2>")
-    session.execute_script("document.title = 'updated'")
+    session.execute_script("document.title = 'Updated'")
 
-    result = get_title(session)
-    assert_success(result, read_global(session, "document.title"))
+    wait(session,
+         lambda s: assert_success(get_title(s)) == read_global(session, "document.title"),
+         "Document title doesn't match '{}'".format(read_global(session, "document.title")))
 
 
 def test_title_strip_and_collapse(session):
     document = "<title>   a b\tc\nd\t \n e\t\n </title><h2>Hello</h2>"
     session.url = inline(document)
 
     result = get_title(session)
     assert_success(result, read_global(session, "document.title"))