Bug 1223277 - Refactor clicks.html and depending unit tests.
The testcase file clicks.html contains a couple of elements which are
not in use, and makes it hard to keep an overview what's actually used.
Lets refactor it to only keep what's really needed.
MozReview-Commit-ID: D9PVWUSmOHr
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_click.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_click.py
@@ -1,17 +1,21 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import urllib
from marionette_driver import By, errors
-from marionette_harness import MarionetteTestCase, run_if_e10s, skip_if_mobile
+from marionette_harness import (
+ MarionetteTestCase,
+ run_if_e10s,
+ skip_if_mobile,
+)
def inline(doc):
return "data:text/html;charset=utf-8,{}".format(urllib.quote(doc))
# The <a> element in the following HTML is not interactable because it
# is hidden by an overlay when scrolled into the top of the viewport.
@@ -90,32 +94,32 @@ class TestLegacyClick(MarionetteTestCase
button = self.marionette.find_element(By.TAG_NAME, "button")
button.click()
self.assertEqual(1, self.marionette.execute_script("return window.clicks", sandbox=None))
def test_click_number_link(self):
test_html = self.marionette.absolute_url("clicks.html")
self.marionette.navigate(test_html)
self.marionette.find_element(By.LINK_TEXT, "333333").click()
- self.marionette.find_element(By.ID, "username")
- self.assertEqual(self.marionette.title, "XHTML Test Page")
+ self.marionette.find_element(By.ID, "testDiv")
+ self.assertEqual(self.marionette.title, "Marionette Test")
def test_clicking_an_element_that_is_not_displayed_raises(self):
test_html = self.marionette.absolute_url("hidden.html")
self.marionette.navigate(test_html)
with self.assertRaises(errors.ElementNotInteractableException):
self.marionette.find_element(By.ID, "child").click()
def test_clicking_on_a_multiline_link(self):
test_html = self.marionette.absolute_url("clicks.html")
self.marionette.navigate(test_html)
self.marionette.find_element(By.ID, "overflowLink").click()
- self.marionette.find_element(By.ID, "username")
- self.assertEqual(self.marionette.title, "XHTML Test Page")
+ self.marionette.find_element(By.ID, "testDiv")
+ self.assertEqual(self.marionette.title, "Marionette Test")
def test_scroll_into_view_near_end(self):
self.marionette.navigate(fixed_overlay)
link = self.marionette.find_element(By.TAG_NAME, "a")
link.click()
self.assertTrue(self.marionette.execute_script("return window.clicked", sandbox=None))
@@ -303,17 +307,17 @@ class TestClickNavigation(MarionetteTest
popup.find_element(By.ANON_ATTRIBUTE,
{"anonid": "closebutton"}).click()
except errors.NoSuchElementException:
pass
def test_click_link_page_load(self):
self.marionette.find_element(By.LINK_TEXT, "333333").click()
self.assertNotEqual(self.marionette.get_url(), self.test_page)
- self.assertEqual(self.marionette.title, "XHTML Test Page")
+ self.assertEqual(self.marionette.title, "Marionette Test")
@skip_if_mobile("Bug 1325738 - Modal dialogs block execution of code for Fennec")
def test_click_link_page_load_aborted_by_beforeunload(self):
page = self.marionette.absolute_url("beforeunload.html")
self.marionette.navigate(page)
self.marionette.find_element(By.TAG_NAME, "a").click()
# click returns immediately when a beforeunload handler is invoked
@@ -329,17 +333,17 @@ class TestClickNavigation(MarionetteTest
def test_click_link_install_addon(self):
try:
self.marionette.find_element(By.ID, "install-addon").click()
self.assertEqual(self.marionette.get_url(), self.test_page)
finally:
self.close_notification()
def test_click_no_link(self):
- self.marionette.find_element(By.ID, "showbutton").click()
+ self.marionette.find_element(By.ID, "links").click()
self.assertEqual(self.marionette.get_url(), self.test_page)
def test_click_option_navigate(self):
self.marionette.find_element(By.ID, "option").click()
self.marionette.find_element(By.ID, "delay")
@run_if_e10s("Requires e10s mode enabled")
def test_click_remoteness_change(self):
--- a/testing/marionette/harness/marionette_harness/www/clicks.html
+++ b/testing/marionette/harness/marionette_harness/www/clicks.html
@@ -1,45 +1,56 @@
<html>
<head>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
- <title>clicks</title>
+ <title>Testing Clicks</title>
+
+ <script>
+ function addMousedownListener() {
+ var el = document.getElementById('showbutton');
+
+ el.addEventListener('mousedown', function (evt) {
+ evt.target.innerText = evt.button;
+ }, false);
+ }
+ </script>
</head>
+
<body>
<h1>Testing Clicks</h1>
-<iframe id="source" src="click_source.html">
-
-</iframe>
-
-<iframe id="target" name="target">
-
-</iframe>
+<div>
+ <p id="links">Links:</p>
+ <ul>
+ <li><a href="test.html">333333</a>
+ <li><a href="test.html" id="normal">Normal</a>
+ <li><a href="#" id="anchor">I go to an anchor</a>
+ <li><a href="addons/webextension-unsigned.xpi" id="install-addon">Install Add-on</a>
+ </ul>
+</div>
-<a href="xhtmlTest.html" id="normal">I'm a normal link</a>
-<a onclick="history.back();" id="history-back">Back in browser history</a>
-<a onclick="history.forward();" id="history-forward">Forward in browser history</a>
-<a href="#" id="anchor">I go to an anchor</a>
-<a href="addons/webextension-unsigned.xpi" id="install-addon">Install Add-on</a>
-<a href="javascript:window.open('xhtmlTest.html', '_blank')" id="new-window">I open a window with javascript</a>
-<a href="xhtmlTest.html" id="twoClientRects"><span></span><span>Click me</span></a>
-<a href="xhtmlTest.html" id="link-with-enclosed-image"><img id="enclosed-image" src="./icon.gif"/></a>
-<a href="xhtmlTest.html" id="link-with-enclosed-span"><span id="enclosed-span" style="color: rgb(0, 255, 0)">I'm a green link</span></a>
-<p style="background: none repeat scroll 0% 0% rgb(0, 255, 0); width: 5em;"><a id="overflowLink" href="xhtmlTest.html">looooooooooong short looooooooooong</a>
- </p>
-<div id="bubblesTo" onclick="window.bubbledClick = true;">
- <a id="bubblesFrom">I bubble</a>
+<div>
+ <p id="js-links">Javascript links:</p>
+ <ul>
+ <li>Navigate in history:
+ <a href="javascript:history.back();" id="history-back">Back</a>
+ <a href="javascript:history.forward();" id="history-forward">Forward</a>
+ <li><a href="javascript:window.open('test.html', '_blank')" id="new-window">Open a window</a>
+ <li><a id="addbuttonlistener" href="javascript:addMousedownListener();">Click</a> to
+ add an event listener for: <span style="color: red;" id="showbutton">button click</span>
+ </ul>
</div>
-<div id="addbuttonlistener" onclick="var el = document.getElementById('showbutton');el.addEventListener('mousedown', function (evt) { document.getElementById('showbutton').innerHTML = evt.button; }, false);">
- click to add an event listener
-</div>
-<div id="showbutton">
- this will show the button clicked
+
+<div>
+ <p id="special">Special:</p>
+ <select id="option" onclick="window.location = '/slow?delay=1'">
+ <option>Click to navigate</option>
+ </select>
+
+ <p style="background-color: rgb(0, 255, 0); width: 5em;">
+ <a id="overflowLink" href="test.html">looooooooooong short looooooooooong</a>
+ </p>
</div>
-<a href="xhtmlTest.html">333333</a>
-<p><a href="xhtmlTest.html" id="embeddedBlock"><span style="display: block;">I have a span</span><div>And a div</div><span>And another span</span></a></p>
-<select id="option" onclick="window.location = '/slow?delay=1'">
- <option>Click to navigate</option>
-</select>
+
</body>
</html>