Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=780258 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"> |
michael@0 | 8 | <title>Test for Bug 780258</title> |
michael@0 | 9 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script> |
michael@0 | 11 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 12 | <style> |
michael@0 | 13 | p { |
michael@0 | 14 | margin-bottom: 30px; |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | .leftPadd { |
michael@0 | 18 | padding-left: 100px; |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | #container { |
michael@0 | 22 | width: 200px; |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | #box { |
michael@0 | 26 | position: absolute; |
michael@0 | 27 | height: 600px; |
michael@0 | 28 | width: 200px; |
michael@0 | 29 | border: 1px solid blue; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | #constrained { |
michael@0 | 33 | display: none; |
michael@0 | 34 | border: 1px solid red; |
michael@0 | 35 | height: 200px; |
michael@0 | 36 | width: 300px; |
michael@0 | 37 | } |
michael@0 | 38 | </style> |
michael@0 | 39 | </head> |
michael@0 | 40 | <body> |
michael@0 | 41 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=780258">Mozilla Bug 780258</a> |
michael@0 | 42 | <p id="display"></p> |
michael@0 | 43 | |
michael@0 | 44 | <div id="content" style="display: none"> |
michael@0 | 45 | <div id="box"> </div> |
michael@0 | 46 | <div id="container"> |
michael@0 | 47 | <p>All of this text should be completely contained |
michael@0 | 48 | within the blue box. |
michael@0 | 49 | <p>I once knew a man, showed me the sleight of hand. |
michael@0 | 50 | In the blink of an eye he danced across the strings. |
michael@0 | 51 | He played a song I've never heard; poignant and absurd; |
michael@0 | 52 | To this day, it leaves me wondering. |
michael@0 | 53 | <p>Don't let tomorrow find you wishin'. |
michael@0 | 54 | Boy, you've got a mission. |
michael@0 | 55 | Shake it, rattle, and roll. |
michael@0 | 56 | Now, just use your intuition. |
michael@0 | 57 | You'll get less competition |
michael@0 | 58 | from the clock up on the wall. |
michael@0 | 59 | <p>You are what you are. |
michael@0 | 60 | You dream what you dream. |
michael@0 | 61 | Play on your blue guitar for me. |
michael@0 | 62 | </div> |
michael@0 | 63 | <div id="constrained"> |
michael@0 | 64 | <p>This text should not apply the max line box width, since it exists within a constrained height block. This is used for limiting the reflow-on-zoom feature for constrained height blocks, since otherwise they could overflow into an element later in the document, or potentially have their text cut off vertically. |
michael@0 | 65 | </div> |
michael@0 | 66 | </div> |
michael@0 | 67 | <pre id="test"> |
michael@0 | 68 | <script type="application/javascript"> |
michael@0 | 69 | /** Test for Bug 780258 and Bug 803211 **/ |
michael@0 | 70 | |
michael@0 | 71 | var gNarrowerContentSnap; |
michael@0 | 72 | var gWideContentSnap; |
michael@0 | 73 | var gFirstBlankSnap; |
michael@0 | 74 | var gUnchangedContentSnap; |
michael@0 | 75 | var gIncorrectContentSnap; |
michael@0 | 76 | var gCorrectContentSnap; |
michael@0 | 77 | |
michael@0 | 78 | function setupFirstTest() { |
michael@0 | 79 | gFirstBlankSnap = snapshotWindow(window); |
michael@0 | 80 | |
michael@0 | 81 | // Display our content. |
michael@0 | 82 | document.getElementById('content').style.display = 'block'; |
michael@0 | 83 | |
michael@0 | 84 | // Take a snapshot. |
michael@0 | 85 | gUnchangedContentSnap = snapshotWindow(window); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | function performFirstTest() { |
michael@0 | 89 | setupFirstTest(); |
michael@0 | 90 | // Verify this isn't the same as the blank snapshot. |
michael@0 | 91 | var result = compareSnapshots(gFirstBlankSnap, gUnchangedContentSnap, false); |
michael@0 | 92 | ok(result[0], "content should appear different than blank page"); |
michael@0 | 93 | |
michael@0 | 94 | // Set container width to 350px. |
michael@0 | 95 | document.getElementById('container').style.width = '350px'; |
michael@0 | 96 | |
michael@0 | 97 | // Take a snapshot. |
michael@0 | 98 | gIncorrectContentSnap = snapshotWindow(window); |
michael@0 | 99 | |
michael@0 | 100 | // Verify this is NOT the same as the first content snapshot. |
michael@0 | 101 | result = compareSnapshots(gUnchangedContentSnap, gIncorrectContentSnap, false); |
michael@0 | 102 | ok(result[0], "unchanged content should be different than changed content"); |
michael@0 | 103 | |
michael@0 | 104 | // Run the max line box width change. |
michael@0 | 105 | SpecialPowers.setMaxLineBoxWidth(window, 200); |
michael@0 | 106 | |
michael@0 | 107 | // Take snapshot. |
michael@0 | 108 | gCorrectContentSnap = snapshotWindow(window); |
michael@0 | 109 | |
michael@0 | 110 | // Compare snapshots. |
michael@0 | 111 | result = compareSnapshots(gUnchangedContentSnap, gCorrectContentSnap, true); |
michael@0 | 112 | ok(result[0], "unchanged content should be the same as corrected content"); |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | function setupSecondTest() { |
michael@0 | 116 | var elements = document.getElementById("container").getElementsByTagName("p"); |
michael@0 | 117 | for (var i = 0; i < elements.length; i++) { |
michael@0 | 118 | elements[i].setAttribute("class", "leftPadd"); |
michael@0 | 119 | } |
michael@0 | 120 | |
michael@0 | 121 | document.getElementById("box").style.paddingLeft = "100px"; |
michael@0 | 122 | |
michael@0 | 123 | document.getElementById("container").style.width = "300px"; |
michael@0 | 124 | } |
michael@0 | 125 | |
michael@0 | 126 | // Another test to verify that the max line box width is |
michael@0 | 127 | // actually forcing the WIDTH of the line boxes, and not |
michael@0 | 128 | // the absolute right edge to be set |
michael@0 | 129 | function performSecondTest() { |
michael@0 | 130 | setupSecondTest(); |
michael@0 | 131 | SpecialPowers.setMaxLineBoxWidth(window, 2000); |
michael@0 | 132 | |
michael@0 | 133 | // Take a snapshot with a max line box width of 200px; |
michael@0 | 134 | gWideContentSnap = snapshotWindow(window); |
michael@0 | 135 | |
michael@0 | 136 | SpecialPowers.setMaxLineBoxWidth(window, 200); |
michael@0 | 137 | |
michael@0 | 138 | // Take a snapshot with the new max line box width |
michael@0 | 139 | gNarrowerContentSnap = snapshotWindow(window); |
michael@0 | 140 | |
michael@0 | 141 | // Compare snapshots. |
michael@0 | 142 | result = compareSnapshots(gNarrowerContentSnap, gWideContentSnap, true); |
michael@0 | 143 | ok(result[0], "content with a max line box width of 2000px and content with" + |
michael@0 | 144 | " a max line box width of 200px should be the same with a 100px left padding"); |
michael@0 | 145 | } |
michael@0 | 146 | |
michael@0 | 147 | function setupThirdTest() { |
michael@0 | 148 | document.getElementById('container').style.display = 'none'; |
michael@0 | 149 | document.getElementById('box').style.display = 'none'; |
michael@0 | 150 | document.getElementById('constrained').style.display = 'block'; |
michael@0 | 151 | } |
michael@0 | 152 | |
michael@0 | 153 | function performThirdTest() { |
michael@0 | 154 | setupThirdTest(); |
michael@0 | 155 | |
michael@0 | 156 | // Take a snapshot of what the content looks like before. |
michael@0 | 157 | gCorrectContentSnap = snapshotWindow(window); |
michael@0 | 158 | |
michael@0 | 159 | // Apply a max line box width. |
michael@0 | 160 | SpecialPowers.setMaxLineBoxWidth(window, 200); |
michael@0 | 161 | |
michael@0 | 162 | // Take another snapshot. |
michael@0 | 163 | gNarrowerContentSnap = snapshotWindow(window); |
michael@0 | 164 | |
michael@0 | 165 | // Verify the max line box width change hasn't changed anything. |
michael@0 | 166 | result = compareSnapshots(gNarrowerContentSnap, gCorrectContentSnap, true); |
michael@0 | 167 | ok(result[0], "constrained height elements should not be subjected to max line box width adjustments"); |
michael@0 | 168 | } |
michael@0 | 169 | |
michael@0 | 170 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 171 | |
michael@0 | 172 | // The first test verifies that the max line box width |
michael@0 | 173 | // actually causes a change in page layout. |
michael@0 | 174 | performFirstTest(); |
michael@0 | 175 | |
michael@0 | 176 | // The second test verifies that the max line box width |
michael@0 | 177 | // is actually measuring width, and not position of |
michael@0 | 178 | // the left/right edges of the line box. |
michael@0 | 179 | performSecondTest(); |
michael@0 | 180 | |
michael@0 | 181 | // The third test verifies that the max line box width |
michael@0 | 182 | // does not have any effect on constrained height elements. |
michael@0 | 183 | performThirdTest(); |
michael@0 | 184 | |
michael@0 | 185 | // Finish the test. |
michael@0 | 186 | SimpleTest.finish(); |
michael@0 | 187 | |
michael@0 | 188 | </script> |
michael@0 | 189 | </pre> |
michael@0 | 190 | </body> |
michael@0 | 191 | </html> |