dom/svg/test/test_valueLeaks.xhtml
author David Walsh <dwalsh@mozilla.com>
Tue, 23 Oct 2018 13:06:03 -0500
changeset 442769 b48368889eb5756251512ac0595078d49983be42
parent 329664 7b434711753b98a87603453caaa0945791ffe12b
child 466515 69b00bf72f9e848f4da07120f391c5cf147ea5a5
permissions -rw-r--r--
Bug 1501379 - Update debugger frontend v95. r=jdescottes

<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=467671
-->
<head>
  <title>Test for Bug 467671</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=467671">Mozilla Bug 467671</a>
<p id="display"></p>
<div id="content" style="display: none">
  
</div>
<pre id="test">
<script type="application/javascript">
<![CDATA[

/** Test for Bug 467671 **/

function storeSVGPropertyAsExpando(localName, prop)
{
    var elem = document.createElementNS("http://www.w3.org/2000/svg", localName);

    elem.addEventListener("click", function(){});

    var propVal = elem[prop];
    Object.prototype.toSource[prop + "_expando"] = propVal;
    if (propVal instanceof SVGAnimatedAngle || propVal instanceof SVGAnimatedLength ||
        propVal instanceof SVGAnimatedRect || propVal instanceof SVGAnimatedPreserveAspectRatio) {
        Object.prototype.toSource[prop + "_baseVal_expando"] = propVal.baseVal;
        Object.prototype.toSource[prop + "_animVal_expando"] = propVal.animVal;
    }
}

// class
storeSVGPropertyAsExpando("marker", "class");

// angle
storeSVGPropertyAsExpando("marker", "orientAngle");

// viewBox
storeSVGPropertyAsExpando("marker", "viewBox");

// preserveAspectRatio
storeSVGPropertyAsExpando("marker", "preserveAspectRatio");

// boolean
storeSVGPropertyAsExpando("feConvolveMatrix", "preserveAlpha");

// enum
storeSVGPropertyAsExpando("feConvolveMatrix", "edgeMode");

// special marker enum
storeSVGPropertyAsExpando("marker", "orientType");

// integer
storeSVGPropertyAsExpando("feConvolveMatrix", "orderX");

// length
storeSVGPropertyAsExpando("feConvolveMatrix", "x");

// number
storeSVGPropertyAsExpando("feConvolveMatrix", "divisor");

// string
storeSVGPropertyAsExpando("feConvolveMatrix", "in1");

var elem1 = document.createElementNS("http://www.w3.org/2000/svg", "switch");
var elem2 = document.createElementNS("http://www.w3.org/2000/svg", "rect");
elem1.appendChild(elem2);
document.getElementById("content").appendChild(elem1);

elem2.addEventListener("click", function(){});

Object.prototype.toSource.expando = elem1;

ok(true, "SVG shouldn't leak.");

]]>
</script>
</pre>
</body>
</html>