[Pkg-mozext-commits] [requestpolicy] 50/257: [tst][add] Marionette test: <a> link click
David Prévot
taffit at moszumanska.debian.org
Thu Jan 28 03:19:55 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit 611aeef8d617544dfd903c97b9dc8efb7a4ccced
Author: Martin Kimmerle <dev at 256k.de>
Date: Wed Sep 9 15:31:21 2015 +0200
[tst][add] Marionette test: <a> link click
Convert Mozmill test
"testLinks/testHTMLAnchorElement/testLinkClick.js"
to Marionette.
---
.../rp_puppeteer/ui/redirect_notification.py | 34 ++++++++++++++++++++++
.../tests/links/html_anchor_element/manifest.ini | 1 +
.../links/html_anchor_element/test_link_click.py | 32 ++++++++++++++++++++
tests/marionette/tests/links/manifest.ini | 1 +
tests/marionette/tests/manifest.ini | 1 +
5 files changed, 69 insertions(+)
diff --git a/tests/marionette/rp_puppeteer/ui/redirect_notification.py b/tests/marionette/rp_puppeteer/ui/redirect_notification.py
new file mode 100644
index 0000000..4759e2d
--- /dev/null
+++ b/tests/marionette/rp_puppeteer/ui/redirect_notification.py
@@ -0,0 +1,34 @@
+# 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/.
+
+from firefox_puppeteer.base import BaseLib
+from marionette_driver.errors import NoSuchElementException
+
+
+REDIRECT_NOTIFICATION_VALUE = "request-policy-meta-redirect"
+
+
+class RedirectNotification(BaseLib):
+ def get_panel(self):
+ """Find the redirection notification bar in the tab currently focused.
+
+ Raises:
+ NoSuchElementException
+ """
+
+ with self.marionette.using_context("chrome"):
+ # TODO: use notification bar class when bug 1139544 lands
+ return (self.marionette.find_element("id", "content")
+ .find_element("anon attribute",
+ {"value": REDIRECT_NOTIFICATION_VALUE}))
+
+ def panel_exists(self):
+ """Check if the redirection notification bar is present.
+ """
+
+ try:
+ self.get_panel()
+ return True
+ except NoSuchElementException:
+ return False
diff --git a/tests/marionette/tests/links/html_anchor_element/manifest.ini b/tests/marionette/tests/links/html_anchor_element/manifest.ini
new file mode 100644
index 0000000..89bd789
--- /dev/null
+++ b/tests/marionette/tests/links/html_anchor_element/manifest.ini
@@ -0,0 +1 @@
+[test_link_click.py]
diff --git a/tests/marionette/tests/links/html_anchor_element/test_link_click.py b/tests/marionette/tests/links/html_anchor_element/test_link_click.py
new file mode 100644
index 0000000..feacbe3
--- /dev/null
+++ b/tests/marionette/tests/links/html_anchor_element/test_link_click.py
@@ -0,0 +1,32 @@
+# 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/.
+
+from rp_ui_harness import RequestPolicyTestCase
+from rp_puppeteer.ui.redirect_notification import RedirectNotification
+
+
+TEST_URL = "http://www.maindomain.test/link_1.html";
+PREF_DEFAULT_ALLOW = "extensions.requestpolicy.defaultPolicy.allow"
+
+
+class TestLinkClick(RequestPolicyTestCase):
+ def setUp(self):
+ RequestPolicyTestCase.setUp(self)
+ self.prefs.set_pref(PREF_DEFAULT_ALLOW, False);
+ self.redir = RedirectNotification(lambda: self.marionette)
+
+
+ def test_link_click(self):
+ with self.marionette.using_context("content"):
+ # load the test url
+ self.marionette.navigate(TEST_URL)
+ # get the link, its url, and click the link
+ link = self.marionette.find_element("tag name", "a")
+ link_url = link.get_attribute("href")
+ link.click()
+
+ self.assertFalse(self.redir.panel_exists(),
+ "Following the link didn't cause a redirect.")
+ self.assertEqual(self.browser.tabbar.selected_tab.location,
+ link_url, "The location is correct.")
diff --git a/tests/marionette/tests/links/manifest.ini b/tests/marionette/tests/links/manifest.ini
new file mode 100644
index 0000000..49e9c81
--- /dev/null
+++ b/tests/marionette/tests/links/manifest.ini
@@ -0,0 +1 @@
+[include:html_anchor_element/manifest.ini]
diff --git a/tests/marionette/tests/manifest.ini b/tests/marionette/tests/manifest.ini
index eca1a79..3cf37b3 100644
--- a/tests/marionette/tests/manifest.ini
+++ b/tests/marionette/tests/manifest.ini
@@ -1,2 +1,3 @@
[include:addon_install_and_upgrade/manifest.ini]
+[include:links/manifest.ini]
[test_setup_page.py]
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list