layout/reftests/svg/dynamic-clipPath-01.svg

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.

michael@0 1 <!--
michael@0 2 Any copyright is dedicated to the Public Domain.
michael@0 3 http://creativecommons.org/publicdomain/zero/1.0/
michael@0 4 -->
michael@0 5 <svg xmlns="http://www.w3.org/2000/svg" version="1.1"
michael@0 6 class="reftest-wait"
michael@0 7 onload="startTest()"
michael@0 8 xmlns:xlink="http://www.w3.org/1999/xlink">
michael@0 9 <title>Testing that dynamic changes to the element for a given ID are reflected in clip-path</title>
michael@0 10 <defs>
michael@0 11 <svg id="d">
michael@0 12 <rect width="100%" height="50%" fill="lime"/>
michael@0 13 <rect y="50%" width="100%" height="50%" fill="red"/>
michael@0 14 </svg>
michael@0 15 </defs>
michael@0 16
michael@0 17 <rect y="30%" width="100%" height="70%" fill="lime"/>
michael@0 18
michael@0 19 <use xlink:href="#d" id="u1" x="10%" width="11%" height="100%" clip-path="url(#r1)"/>
michael@0 20 <script>
michael@0 21 // force frame construction; test that parsing "r1" after frame construction
michael@0 22 // is still bound to "u1" eventually
michael@0 23 var rect = document.getElementById("u1").getBoundingClientRect();
michael@0 24 </script>
michael@0 25 <clipPath id="r1">
michael@0 26 <rect width="100%" height="40%"/>
michael@0 27 </clipPath>
michael@0 28
michael@0 29 <clipPath id="x">
michael@0 30 <rect width="100%" height="40%"/>
michael@0 31 </clipPath>
michael@0 32 <use xlink:href="#d" id="u2" x="20%" width="11%" height="100%" clip-path="url(#r2)"/>
michael@0 33
michael@0 34 <clipPath id="r3">
michael@0 35 <rect width="100%" height="100%"/>
michael@0 36 </clipPath>
michael@0 37 <clipPath id="r3">
michael@0 38 <rect width="100%" height="40%"/>
michael@0 39 </clipPath>
michael@0 40 <use xlink:href="#d" id="u3" x="30%" width="11%" height="100%" clip-path="url(#r3)"/>
michael@0 41
michael@0 42 <clipPath id="r4">
michael@0 43 <rect width="100%" height="100%"/>
michael@0 44 </clipPath>
michael@0 45 <clipPath id="r4">
michael@0 46 <rect width="100%" height="40%"/>
michael@0 47 </clipPath>
michael@0 48 <use xlink:href="#d" id="u4" x="40%" width="11%" height="100%" clip-path="url(#r4)"/>
michael@0 49
michael@0 50 <clipPath id="r5">
michael@0 51 <rect width="100%" height="100%"/>
michael@0 52 </clipPath>
michael@0 53 <use xlink:href="#d" id="u5" x="50%" width="11%" height="100%" clip-path="url(#r5)"/>
michael@0 54
michael@0 55 <clipPath id="r6">
michael@0 56 <rect width="100%" height="100%"/>
michael@0 57 </clipPath>
michael@0 58 <clipPath id="r6-2">
michael@0 59 <rect width="100%" height="40%"/>
michael@0 60 </clipPath>
michael@0 61 <use xlink:href="#d" id="u6" x="60%" width="11%" height="100%" clip-path="url(#r6)"/>
michael@0 62
michael@0 63 <clipPath id="r7">
michael@0 64 <rect width="100%" height="40%"/>
michael@0 65 </clipPath>
michael@0 66 <clipPath id="r7-2">
michael@0 67 <rect width="100%" height="100%"/>
michael@0 68 </clipPath>
michael@0 69 <use xlink:href="#d" id="u7" x="70%" width="11%" height="100%" clip-path="url(#r7)"/>
michael@0 70
michael@0 71 <clipPath id="r8-2">
michael@0 72 <rect width="100%" height="40%"/>
michael@0 73 </clipPath>
michael@0 74 <clipPath id="r8">
michael@0 75 <rect width="100%" height="100%"/>
michael@0 76 </clipPath>
michael@0 77 <use xlink:href="#d" id="u8" x="80%" width="11%" height="100%" clip-path="url(#r8)"/>
michael@0 78
michael@0 79 <rect width="11%" height="100%" fill="lime"/>
michael@0 80 <rect x="90%" width="11%" height="100%" fill="lime"/>
michael@0 81
michael@0 82 <script>
michael@0 83 function startTest() {
michael@0 84 document.addEventListener("MozReftestInvalidate", doTest, false);
michael@0 85 setTimeout(doTest, 4000); // fallback for running outside reftest
michael@0 86 }
michael@0 87
michael@0 88 function doTest() {
michael@0 89 // check that changing an id to "r2" lets u2 find it
michael@0 90 var r2 = document.getElementById("x");
michael@0 91 r2.setAttribute("id", "r2");
michael@0 92
michael@0 93 var rect = document.getElementById("u3").getBoundingClientRect();
michael@0 94 // check that removing the bad r3 lets u3 find the good one
michael@0 95 var r3 = document.getElementById("r3");
michael@0 96 r3.parentNode.removeChild(r3);
michael@0 97
michael@0 98 // check that renaming the bad r4 lets u4 find the good one
michael@0 99 var r4 = document.getElementById("r4");
michael@0 100 r4.removeAttribute("id");
michael@0 101
michael@0 102 // check that changing u5's reference works
michael@0 103 var u5 = document.getElementById("u5");
michael@0 104 u5.setAttribute("clip-path", "url(#r1)");
michael@0 105
michael@0 106 // check that inserting a good element before the bad r6 works
michael@0 107 var r6 = document.getElementById("r6-2");
michael@0 108 r6.parentNode.removeChild(r6);
michael@0 109 r6.setAttribute("id", "r6");
michael@0 110 document.documentElement.insertBefore(r6, document.documentElement.firstChild);
michael@0 111
michael@0 112 // check that inserting a bad element after a good one doesn't break anything
michael@0 113 var r7 = document.getElementById("r7-2");
michael@0 114 r7.parentNode.removeChild(r7);
michael@0 115 r7.setAttribute("id", "r7");
michael@0 116 document.documentElement.appendChild(r7);
michael@0 117
michael@0 118 // check that renaming a good element to r8 works
michael@0 119 var r8 = document.getElementById("r8-2");
michael@0 120 r8.setAttribute("id", "r8");
michael@0 121
michael@0 122 document.documentElement.removeAttribute("class");
michael@0 123 }
michael@0 124 </script>
michael@0 125 </svg>

mercurial