forked from RequestPolicyContinued/requestpolicy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tst][add] Marionette test: URI without host
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
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
[test_rule_with_scheme_only.py] | ||
[test_uris.py] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) |