Bug 1126362 - Add unit tests for navigating to a data: url containing an image r?whimboo
MozReview-Commit-ID: GZg1BOY7tOj
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
@@ -17,19 +17,25 @@ from marionette_harness import (
skip,
skip_if_mobile,
WindowManagerMixin,
)
here = os.path.abspath(os.path.dirname(__file__))
+BLACK_PIXEL = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==' # noqa
+RED_PIXEL = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX/TQBcNTh/AAAAAXRSTlPM0jRW/QAAAApJREFUeJxjYgAAAAYAAzY3fKgAAAAASUVORK5CYII=' # noqa
+
def inline(doc):
return "data:text/html;charset=utf-8,%s" % urllib.quote(doc)
+def inline_image(data):
+ return 'data:image/png;base64,%s' % data
+
class BaseNavigationTestCase(WindowManagerMixin, MarionetteTestCase):
def setUp(self):
super(BaseNavigationTestCase, self).setUp()
file_path = os.path.join(here, 'data', 'test.html').replace("\\", "/")
@@ -482,16 +488,19 @@ class TestBackForwardNavigation(BaseNavi
{"url": self.marionette.absolute_url("white.png")},
]
self.run_bfcache_test(test_pages)
def test_image_to_image(self):
test_pages = [
{"url": self.marionette.absolute_url("black.png")},
{"url": self.marionette.absolute_url("white.png")},
+ {"url": inline_image(RED_PIXEL)},
+ {"url": inline_image(BLACK_PIXEL)},
+ {"url": self.marionette.absolute_url("black.png")},
]
self.run_bfcache_test(test_pages)
@run_if_e10s("Requires e10s mode enabled")
def test_remoteness_change(self):
test_pages = [
{"url": "about:robots", "is_remote": False},
{"url": self.test_page_remote, "is_remote": True},