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 f71ee9f3 authored by boklm's avatar boklm
Browse files

Bug 15802: add automated tests for svg.in-content.enabled

Start adding some tests for svg.in-content.enabled, using test cases
from the svgtest.html file atteched on ticket #12827 by mcs.
parent b7477d66
......@@ -315,6 +315,28 @@ our @tests = (
timeout => 50000,
interval => 100,
},
{
name => 'svg-disable',
type => 'mozmill',
descr => 'Check if disabling svg is working',
mozmill_test => 'svg',
svg_enabled => 0,
prefs => {
'extensions.torbutton.security_custom' => 'true',
'svg.in-content.enabled' => 'false',
},
},
{
name => 'svg-enable',
type => 'mozmill',
descr => 'Check if enabling svg is working',
mozmill_test => 'svg',
svg_enabled => 1,
prefs => {
'extensions.torbutton.security_custom' => 'true',
'svg.in-content.enabled' => 'true',
},
},
);
sub toggle_https_everywhere {
......
"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().nodeName, "svg", "inline svg tag");
else
expect.equal(svg_elem.getNode(), null, "no inline svg tag");
}
The file fuji1.svg used in the tests has been downloaded from this page:
http://plurib.us/1shot/2009/fuji/
© Copyright 2009 Brian Lukis
Licensed under a Creative Commons License.
This diff is collapsed.
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="UTF-8">
<title>SVG Test</title>
<body>
<div>iframe with remote URL:<br>
<iframe id="svgIframeElem" src="fuji1.svg" width="500" height="500">
</iframe>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="UTF-8">
<title>SVG Test</title>
<body>
<div>img with data URL:<br>
<img src="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><linearGradient id='g' x2='0' y2='100%'><stop stop-color='%23f00'/><stop offset='100%' stop-color='white'/></linearGradient><rect fill='url(%23g)' width='100%' height='100%'/></svg>" id="svgImgElem">
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="UTF-8">
<title>SVG Test</title>
<body>
<div>img src="fuji1.svg":<br>
<img id="svgImgElem" src="fuji1.svg" />
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="UTF-8">
<title>SVG Test</title>
<body>
<div>Inline svg tags:<br>
<svg id="inlineSVG">
<circle cx="50" cy="50" r="40" stroke="blue" stroke-width="4" fill="yellow" />
Your browser does not support inline SVG.
</svg>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="UTF-8">
<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>">
this text appears when SVG is disabled
</object>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="UTF-8">
<title>SVG Test</title>
<body>
<div>object with remote URL:<br>
<object id="svgObjectElem" type="image/svg+xml" data="fuji1.svg">
this text appears when SVG is disabled
</object>
</div>
</body>
</html>
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