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.

Unverified Commit 6b268cb7 authored by boklm's avatar boklm
Browse files

Convert the svg tests to marionette

parent fed6ce1d
......@@ -389,10 +389,9 @@ our @tests = (
},
{
name => 'svg-disable',
type => 'mozmill',
type => 'marionette',
descr => 'Check if disabling svg is working',
mozmill_test => 'svg',
svg_enabled => 0,
marionette_test => 'svg',
use_net => 1,
prefs => {
'extensions.torbutton.security_custom' => 'true',
......@@ -402,11 +401,10 @@ our @tests = (
},
{
name => 'svg-enable',
type => 'mozmill',
type => 'marionette',
descr => 'Check if enabling svg is working',
mozmill_test => 'svg',
marionette_test => 'svg',
use_net => 1,
svg_enabled => 1,
prefs => {
'extensions.torbutton.security_custom' => 'true',
'svg.in-content.enabled' => 'true',
......
from marionette_driver import By
from marionette_driver.errors import MarionetteException, JavascriptException
from firefox_ui_harness import FirefoxTestCase
import testsuite
class Test(FirefoxTestCase):
def setUp(self):
FirefoxTestCase.setUp(self)
ts = testsuite.TestSuite()
self.ts = ts
self.svg_dir = "file://%s/svg/" % ts.t['options']['test_data_dir']
def test_svg(self):
m = self.marionette
svg_enabled = self.ts.t['test']['name'] == 'svg-enable'
self.assertEqual(self.prefs.get_pref('svg.in-content.enabled'),
svg_enabled,
msg="svg.in-content.enabled is not set correctly")
m.set_search_timeout(1000)
with m.using_context('content'):
# img src url
m.navigate("%s/img_src_url.html" % self.svg_dir)
svg_elt = m.find_element('id', 'svgImgElem')
self.assertEqual(svg_elt.get_attribute('width'),
'450' if svg_enabled else '24',
msg="img src url")
# img data url
m.navigate("%s/img_data_url.html" % self.svg_dir)
svg_elt = m.find_element('id', 'svgImgElem')
self.assertEqual(svg_elt.get_attribute('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('''
var elt = document.getElementById("svgObjectElem");
return elt.contentDocument.visibilityState;
''')
except JavascriptException:
visibility = 'invisible'
self.assertEqual(visibility,
'visible' if svg_enabled else 'invisible',
msg='object data url')
# object remote url
m.navigate("%s/object_remote_url.html" % self.svg_dir)
try:
visibility = m.execute_script('''
var elt = document.getElementById("svgObjectElem");
return elt.contentDocument.visibilityState;
''')
except JavascriptException:
visibility = 'invisible'
self.assertEqual(visibility,
'visible' if svg_enabled else 'invisible',
msg='object remote url')
# iframe remote url
current_window = m.current_chrome_window_handle
m.navigate('%s/iframe_remote_url.html' % self.svg_dir)
# close all windows except the current one. When svg is disabled
# the closed window should be a download prompt.
closed_window = 0
with m.using_context('chrome'):
for window in m.chrome_window_handles:
if window != current_window:
m.switch_to_window(window)
m.close()
closed_window += 1
m.switch_to_window(current_window)
self.assertEqual(closed_window, 0 if svg_enabled else 1,
msg="iframe remote url prompt")
# inline svg
m.navigate('%s/inline_svg.html' % self.svg_dir)
try:
elt_width = m.execute_script('''
var elt = document.getElementById("inlineSVG");
return elt.width.baseVal.value;
''')
except JavascriptException:
elt_width = None
print "width: %s" % elt_width
self.assertEqual(elt_width,
1 if svg_enabled else None,
msg='inline svg')
"use strict";
var {expect} = require("../mozilla-mozmill-tests/lib/assertions");
var prefs = require("../mozilla-mozmill-tests/firefox/lib/prefs");
var common = require("../lib/common");
var testsuite = require("../lib/testsuite");
var setupModule = function(aModule) {
aModule.controller = mozmill.getBrowserController();
}
var testStartTBB = function() {
var svgdir = testsuite.options.test_data_dir + "/svg/";
var svg_enabled = Boolean(testsuite.test.svg_enabled);
var prefSrv = prefs.preferences;
expect.equal(prefSrv.getPref("svg.in-content.enabled", false), svg_enabled,
"svg.in-content.enabled pref");
common.load_page(controller, svgdir + 'img_src_url.html');
var svg_elem = elementslib.ID(controller.window.document, "svgImgElem");
expect.equal(svg_elem.getNode().width, svg_enabled ? 450 : 24, "img src url");
common.load_page(controller, svgdir + 'img_data_url.html');
var svg_elem = elementslib.ID(controller.window.document, "svgImgElem");
expect.equal(svg_elem.getNode().width, svg_enabled ? 300 : 24, "img data url");
common.load_page(controller, svgdir + 'object_data_url.html');
var svg_elem = elementslib.ID(controller.window.document, "svgObjectElem");
if (svg_enabled)
expect.equal(svg_elem.getNode().contentDocument.visibilityState, "visible", "object data url");
else
expect.equal(svg_elem.getNode().contentDocument, null, "object data url");
common.load_page(controller, svgdir + 'object_remote_url.html');
var svg_elem = elementslib.ID(controller.window.document, "svgObjectElem");
if (svg_enabled)
expect.equal(svg_elem.getNode().contentDocument.visibilityState, "visible", "object remote url");
else
expect.equal(svg_elem.getNode().contentDocument, null, "object remote url");
/* FIXME: when svg not enabled, close prompt asking to save the svg file */
if (svg_enabled) {
common.load_page(controller, svgdir + 'iframe_remote_url.html');
var svg_elem = elementslib.ID(controller.window.document, "svgIframeElem");
expect.equal(svg_elem.getNode().contentDocument.visibilityState, "visible", "iframe remote url");
}
common.load_page(controller, svgdir + 'inline_svg.html');
var svg_elem = elementslib.ID(controller.window.document, "inlineSVG");
if (svg_enabled)
expect.equal(svg_elem.getNode().width.baseVal.value, 1, "inline svg tag");
else
expect.equal(svg_elem.getNode().width, undefined, "no inline svg tag");
}
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