Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing ES6 constructs from pages used in WebDriver tests #9600

Merged
merged 3 commits into from Feb 21, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions webdriver/tests/element_click/bubbling.py
@@ -1,7 +1,6 @@
from tests.support.asserts import assert_success
from tests.support.inline import inline


def click(session, element):
return session.transport.send(
"POST", "/session/{session_id}/element/{element_id}/click".format(
Expand All @@ -28,17 +27,18 @@ def test_click_event_bubbles_to_parents(session):
<script>
window.clicks = [];

for (let level of document.querySelectorAll("div")) {
level.addEventListener("click", ({currentTarget}) => {
window.clicks.push(currentTarget);
var elements = document.querySelectorAll("div");
for (var level = 0; level < elements.length; level++) {
elements[level].addEventListener("click", function(clickEvent) {
window.clicks.push(clickEvent.currentTarget);
});
}
</script>
""")
three, two, one = session.find.css("div")
one.click()

clicks = session.execute_script("return window.clicks")
clicks = session.execute_script("return window.clicks;")
assert one in clicks
assert two in clicks
assert three in clicks
Expand Down Expand Up @@ -67,17 +67,19 @@ def test_spin_event_loop(session):
<script>
window.delayedClicks = [];

for (let level of document.querySelectorAll("div")) {
level.addEventListener("click", ({currentTarget}) => {
setTimeout(() => window.delayedClicks.push(currentTarget), 100);
var elements = document.querySelectorAll("div");
for (var level = 0; level < elements.length; level++) {
elements[level].addEventListener("click", function(clickEvent) {
var target = clickEvent.currentTarget;
setTimeout(function() { window.delayedClicks.push(target); }, 100);
});
}
</script>
""")
three, two, one = session.find.css("div")
one.click()

delayed_clicks = session.execute_script("return window.delayedClicks")
delayed_clicks = session.execute_script("return window.delayedClicks;")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW the semicolon shouldn’t be necessary as the injected script is wrapped in a function, and semicolons aren’t required in JS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted to previous syntax, without semicolons.

assert one in delayed_clicks
assert two in delayed_clicks
assert three in delayed_clicks
Expand Down