layout/reftests/svg/nesting-invalid-01.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 // Any copyright is dedicated to the Public Domain.
michael@0 2 // http://creativecommons.org/publicdomain/zero/1.0/
michael@0 3
michael@0 4 // These are all of the SVG 1.1 element names, except for container elements,
michael@0 5 // with the addition of an "UNKNOWN" element in the SVG namespace.
michael@0 6 var es = 'altGlyph altGlyphDef altGlyphItem animate animateColor animateMotion animateTransform circle color-profile cursor desc ellipse feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence filter font font-face font-face-format font-face-name font-face-src font-face-uri glyph glyphRef hkern image line linearGradient metadata missing-glyph mpath path polygon polyline radialGradient rect script set stop style text textPath title tref tspan use view vkern UNKNOWN'.split(' ');
michael@0 7 var colwidth = 200;
michael@0 8 var size = 40;
michael@0 9 var rows = 14;
michael@0 10
michael@0 11 function makeElement(localName, attrs, children) {
michael@0 12 var e = document.createElementNS('http://www.w3.org/2000/svg', localName);
michael@0 13 for (var an in attrs) {
michael@0 14 e.setAttribute(an, attrs[an]);
michael@0 15 }
michael@0 16 if (children) {
michael@0 17 for (var i = 0; i < children.length; i++) {
michael@0 18 if (typeof children[i] == 'object') {
michael@0 19 e.appendChild(children[i]);
michael@0 20 } else {
michael@0 21 e.appendChild(document.createTextNode(children[i]));
michael@0 22 }
michael@0 23 }
michael@0 24 }
michael@0 25 return e;
michael@0 26 }
michael@0 27
michael@0 28 function makeGroup(i, failing, text) {
michael@0 29 var x = colwidth * Math.floor(i / rows),
michael@0 30 y = size * (i % rows);
michael@0 31 return makeElement('g', { 'fill-opacity': failing ? '1' : '0.25' },
michael@0 32 [makeElement('rect', { x: x, y: y, width: colwidth, height: size, fill: 'white' }),
michael@0 33 makeElement('rect', { x: x, y: y, width: size, height: size, fill: failing ? 'red' : 'green' }),
michael@0 34 makeElement('text', { x: x + size + 10, y: y + size / 2 + 6 }, [text])]);
michael@0 35 }

mercurial