Bug 1396185 - [wdspec] Fix race condition in test_title_after_modification.
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
--- a/testing/web-platform/meta/webdriver/tests/navigation/get_title.py.ini
+++ b/testing/web-platform/meta/webdriver/tests/navigation/get_title.py.ini
@@ -1,13 +1,8 @@
[get_title.py]
disabled:
if webrender: bug 1425588
[test_title_handle_prompt_dismiss]
expected: FAIL
[test_title_handle_prompt_accept]
expected: FAIL
-
- [test_title_after_modification]
- disabled:
- if not debug and stylo and e10s and (os == "linux") and (version == "Ubuntu 16.04") and (processor == "x86_64") and (bits == 64): wpt-sync Bug 1444558
-
--- 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"))