GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit 838c00e3 authored by Alex Catarineu's avatar Alex Catarineu

Fix svg tests

parent e8a5a6b2
......@@ -439,11 +439,8 @@ our @tests = (
use_net => 1,
prefs => {
'extensions.torbutton.security_custom' => 'true',
'svg.in-content.enabled' => 'false',
'svg.disabled' => 'true',
},
# Bug 28798: temporarily disable test
enable => sub { undef },
#enable => sub { $OSNAME eq 'linux' },
},
{
name => 'svg-enable',
......@@ -453,11 +450,8 @@ our @tests = (
use_net => 1,
prefs => {
'extensions.torbutton.security_custom' => 'true',
'svg.in-content.enabled' => 'true',
'svg.disabled' => 'false',
},
# Bug 28798: temporarily disable test
enable => sub { undef },
#enable => sub { $OSNAME eq 'linux' },
},
{
name => 'download_pdf',
......
from marionette_driver import By
from marionette_driver.errors import MarionetteException, JavascriptException, NoSuchElementException
from marionette_harness import MarionetteTestCase
import testsuite
class Test(MarionetteTestCase):
def setUp(self):
......@@ -14,62 +12,58 @@ class Test(MarionetteTestCase):
ts = testsuite.TestSuite()
self.ts = ts
self.svg_dir = "file://%s/svg/" % ts.t['options']['test_data_dir']
self.marionette.set_pref("network.proxy.allow_hijacking_localhost", False)
def test_svg(self):
m = self.marionette
svg_enabled = self.ts.t['test']['name'] == 'svg-enable'
self.assertEqual(self.marionette.get_pref('svg.in-content.enabled'),
svg_enabled,
msg="svg.in-content.enabled is not set correctly")
self.assertEqual(self.marionette.get_pref('svg.disabled'),
not svg_enabled,
msg="svg.disabled is not set correctly")
m.set_search_timeout(1000)
self.marionette.timeout.implicit = 1
with m.using_context('content'):
# img src url
m.navigate("%s/img_src_url.html" % self.svg_dir)
m.navigate(self.marionette.absolute_url("svg/img_src_url.html"))
svg_elt = m.find_element('id', 'svgImgElem')
self.assertEqual(svg_elt.get_property('width'),
450 if svg_enabled else 24,
msg="img src url")
# img data url
m.navigate("%s/img_data_url.html" % self.svg_dir)
m.navigate(self.marionette.absolute_url("svg/img_data_url.html"))
svg_elt = m.find_element('id', 'svgImgElem')
self.assertEqual(svg_elt.get_property('width'),
300 if svg_enabled else 24,
msg="img data url")
# object data url
m.navigate("%s/object_data_url.html" % self.svg_dir)
try:
visibility = m.execute_script('''
m.navigate(self.marionette.absolute_url("svg/object_data_url.html"))
width = m.execute_script('''
var elt = document.getElementById("svgObjectElem");
return elt.contentDocument.visibilityState;
return elt.getBoundingClientRect().width;
''')
except JavascriptException:
visibility = 'invisible'
self.assertEqual(visibility,
'visible' if svg_enabled else 'invisible',
msg='object data url')
self.assertEqual(width,
450 if svg_enabled else 300,
msg="object data url")
# object remote url
m.navigate("%s/object_remote_url.html" % self.svg_dir)
try:
visibility = m.execute_script('''
m.navigate(self.marionette.absolute_url("svg/object_remote_url.html"))
svg_elt = m.find_element('id', 'svgObjectElem')
width = m.execute_script('''
var elt = document.getElementById("svgObjectElem");
return elt.contentDocument.visibilityState;
return elt.getBoundingClientRect().width;
''')
except JavascriptException:
visibility = 'invisible'
self.assertEqual(visibility,
'visible' if svg_enabled else 'invisible',
msg='object remote url')
self.assertEqual(width,
450 if svg_enabled else 300,
msg="object remote url")
# inline svg
m.navigate('%s/inline_svg.html' % self.svg_dir)
m.navigate(self.marionette.absolute_url("svg/inline_svg.html"))
try:
elt_width = m.execute_script('''
var elt = document.getElementById("inlineSVG");
......@@ -77,19 +71,18 @@ class Test(MarionetteTestCase):
''')
except JavascriptException:
elt_width = None
print "width: %s" % elt_width
self.assertEqual(elt_width,
300 if svg_enabled else None,
msg='inline svg')
# iframe remote url
m.navigate('%s/iframe_remote_url.html' % self.svg_dir)
m.navigate(self.marionette.absolute_url("svg/iframe_remote_url.html"))
m.switch_to_frame(m.find_element('id', 'svgIframeElem'))
found_elt = True
try:
svg_elt = m.find_element('tag name', 'svg')
except NoSuchElementException:
found_elt = False
self.assertEqual(found_elt, True if svg_enabled else False,
svg_elt = m.find_element('tag name', 'svg')
width = m.execute_script('''
var elt = document.getElementsByTagName("svg")[0];
return elt.getBoundingClientRect().width;
''')
self.assertEqual(width,
450 if svg_enabled else 500,
msg="iframe remote url prompt")
......@@ -5,7 +5,7 @@
<title>SVG Test</title>
<body>
<div>object with data URL:<br>
<object id="svgObjectElem" type="image/svg+xml" data="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><linearGradient id='g' x2='0' y2='100%'><stop stop-color='%23faf'/><stop offset='100%' stop-color='white'/></linearGradient><rect fill='url(%23g)' width='100%' height='100%'/></svg>">
<object id="svgObjectElem" type="image/svg+xml" data="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='450'><linearGradient id='g' x2='0' y2='100%'><stop stop-color='%23faf'/><stop offset='100%' stop-color='white'/></linearGradient><rect fill='url(%23g)' width='100%' height='100%'/></svg>">
this text appears when SVG is disabled
</object>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment