Bug 1332122 - Add unit tests for navigating to file:// URLs.
MozReview-Commit-ID: 7GAHkfuvMcB
new file mode 100644
--- /dev/null
+++ b/testing/marionette/harness/marionette_harness/tests/unit/data/test.html
@@ -0,0 +1,13 @@
+<!-- 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/. -->
+
+<!DOCTYPE html>
+<html>
+<head>
+<title>Marionette Test</title>
+</head>
+<body>
+ <p id="file-url">Loaded via file://</p>
+</body>
+</html>
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
@@ -1,36 +1,42 @@
# 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 contextlib
+import os
import urllib
from marionette_driver import By, errors, expected, Wait
from marionette_driver.keys import Keys
from marionette_harness import (
MarionetteTestCase,
run_if_e10s,
run_if_manage_instance,
skip,
skip_if_mobile,
WindowManagerMixin,
)
+here = os.path.abspath(os.path.dirname(__file__))
+
def inline(doc):
return "data:text/html;charset=utf-8,%s" % urllib.quote(doc)
class BaseNavigationTestCase(WindowManagerMixin, MarionetteTestCase):
def setUp(self):
super(BaseNavigationTestCase, self).setUp()
+ file_path = os.path.join(here, 'data', 'test.html').replace("\\", "/")
+
+ self.test_page_file_url = "file:///{}".format(file_path)
self.test_page_frameset = self.marionette.absolute_url("frameset.html")
self.test_page_insecure = self.fixtures.where_is("test.html", on="https")
self.test_page_not_remote = "about:robots"
self.test_page_remote = self.marionette.absolute_url("test.html")
self.test_page_slow_resource = self.marionette.absolute_url("slow_resource.html")
if self.marionette.session_capabilities["platformName"] == "darwin":
self.mod_key = Keys.META
@@ -186,16 +192,35 @@ class TestNavigate(BaseNavigationTestCas
def test_navigate_hash_change(self):
doc = inline("<p id=foo>")
self.marionette.navigate(doc)
self.marionette.execute_script("window.visited = true", sandbox=None)
self.marionette.navigate("{}#foo".format(doc))
self.assertTrue(self.marionette.execute_script(
"return window.visited", sandbox=None))
+ @skip_if_mobile("Test file is only located on host machine")
+ def test_navigate_file_url(self):
+ self.marionette.navigate(self.test_page_file_url)
+ self.marionette.find_element(By.ID, "file-url")
+ self.marionette.navigate(self.test_page_remote)
+
+ @run_if_e10s("Requires e10s mode enabled")
+ @skip_if_mobile("Test file is only located on host machine")
+ def test_navigate_file_url_remoteness_change(self):
+ self.marionette.navigate("about:robots")
+ self.assertFalse(self.is_remote_tab)
+
+ self.marionette.navigate(self.test_page_file_url)
+ self.assertTrue(self.is_remote_tab)
+ self.marionette.find_element(By.ID, "file-url")
+
+ self.marionette.navigate("about:robots")
+ self.assertFalse(self.is_remote_tab)
+
@skip_if_mobile("Bug 1334095 - Timeout: No new tab has been opened")
def test_about_blank_for_new_docshell(self):
self.assertEqual(self.marionette.get_url(), "about:blank")
self.marionette.navigate("about:blank")
@skip("Bug 1332064 - NoSuchElementException: Unable to locate element: :focus")
@run_if_manage_instance("Only runnable if Marionette manages the instance")
@@ -329,16 +354,25 @@ class TestBackForwardNavigation(BaseNavi
def test_same_document_hash_change(self):
test_pages = [
{"url": "{}#23".format(self.test_page_remote)},
{"url": self.test_page_remote},
{"url": "{}#42".format(self.test_page_remote)},
]
self.run_bfcache_test(test_pages)
+ @skip_if_mobile("Test file is only located on host machine")
+ def test_file_url(self):
+ test_pages = [
+ {"url": self.test_page_remote},
+ {"url": self.test_page_file_url},
+ {"url": self.test_page_remote},
+ ]
+ self.run_bfcache_test(test_pages)
+
@skip("Causes crashes for JS GC (bug 1344863) and a11y (bug 1344868)")
def test_frameset(self):
test_pages = [
{"url": self.marionette.absolute_url("frameset.html")},
{"url": self.test_page_remote},
{"url": self.marionette.absolute_url("frameset.html")},
]
self.run_bfcache_test(test_pages)
@@ -507,16 +541,24 @@ class TestRefresh(BaseNavigationTestCase
frame = self.marionette.find_element(By.NAME, "third")
self.marionette.switch_to_frame(frame)
self.assertRaises(errors.NoSuchElementException,
self.marionette.find_element, By.NAME, "third")
self.marionette.refresh()
self.marionette.find_element(By.NAME, "third")
+ @skip_if_mobile("Test file is only located on host machine")
+ def test_file_url(self):
+ self.marionette.navigate(self.test_page_file_url)
+ self.assertEqual(self.test_page_file_url, self.marionette.get_url())
+
+ self.marionette.refresh()
+ self.assertEqual(self.test_page_file_url, self.marionette.get_url())
+
def test_image(self):
image = self.marionette.absolute_url('black.png')
self.marionette.navigate(image)
self.assertEqual(image, self.marionette.get_url())
self.marionette.refresh()
self.assertEqual(image, self.marionette.get_url())