Skip to content

Commit

Permalink
[tst][add] Marionette test: URI without host
Browse files Browse the repository at this point in the history
Convert Mozmill test "testRequestLog/testUriWithoutHost.js" to
Marionette.

The test is in fact not about the Request Log, more about such
URIs in general, so the Marionette test uses the "Requests" API
instead of the "RequestLog" UI library, which is faster.
  • Loading branch information
myrdd committed Oct 9, 2015
1 parent 1ee0464 commit dcda823
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/marionette/tests/policy/manifest.ini
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
[test_rule_with_scheme_only.py]
[test_uris.py]
47 changes: 47 additions & 0 deletions tests/marionette/tests/policy/test_uris.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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.testcases import RequestPolicyTestCase


class TestUris(RequestPolicyTestCase):
"""Class for testing specific URI types."""

def setUp(self):
super(TestUris, self).setUp()

self.marionette.set_context("content")

def tearDown(self):
try:
self.requests.stop_listening()
self.marionette.set_context("chrome")
finally:
super(TestUris, self).tearDown()

def test_uri_without_host(self):
url = "http://www.maindomain.test/scheme-unknown-and-without-host.html"

self.requests.start_listening()

def get_requests_by_dest(dest_uri):
return [request
for request in self.requests.all
if request["dest"] == dest_uri]

with self.marionette.using_context("content"):
self.marionette.navigate(url)

link = self.marionette.find_element("tag name", "a")
link_uri = link.get_attribute("href")

self.assertEqual(len(get_requests_by_dest(link_uri)), 0,
("There hasn't been any request to '{}' yet."
.format(link_uri)))

link.click()

self.assertEqual(len(get_requests_by_dest(link_uri)), 1,
("There has been exactly one request to '{}'."
.format(link_uri)))

0 comments on commit dcda823

Please sign in to comment.