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

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 // Any copyright is dedicated to the Public Domain.
     2 // http://creativecommons.org/publicdomain/zero/1.0/
     4 // These are all of the SVG 1.1 element names, except for container elements,
     5 // with the addition of an "UNKNOWN" element in the SVG namespace.
     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(' ');
     7 var colwidth = 200;
     8 var size = 40;
     9 var rows = 14;
    11 function makeElement(localName, attrs, children) {
    12   var e = document.createElementNS('http://www.w3.org/2000/svg', localName);
    13   for (var an in attrs) {
    14     e.setAttribute(an, attrs[an]);
    15   }
    16   if (children) {
    17     for (var i = 0; i < children.length; i++) {
    18       if (typeof children[i] == 'object') {
    19         e.appendChild(children[i]);
    20       } else {
    21         e.appendChild(document.createTextNode(children[i]));
    22       }
    23     }
    24   }
    25   return e;
    26 }
    28 function makeGroup(i, failing, text) {
    29   var x = colwidth * Math.floor(i / rows),
    30       y = size * (i % rows);
    31   return makeElement('g', { 'fill-opacity': failing ? '1' : '0.25' },
    32            [makeElement('rect', { x: x, y: y, width: colwidth, height: size, fill: 'white' }),
    33             makeElement('rect', { x: x, y: y, width: size, height: size, fill: failing ? 'red' : 'green' }),
    34             makeElement('text', { x: x + size + 10, y: y + size / 2 + 6 }, [text])]);
    35 }

mercurial