Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Reftests with caret drawing</title> |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 7 | <script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script> |
michael@0 | 8 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 9 | <style> |
michael@0 | 10 | iframe { |
michael@0 | 11 | width: 600px; |
michael@0 | 12 | height: 600px; |
michael@0 | 13 | } |
michael@0 | 14 | </style> |
michael@0 | 15 | <script type="text/javascript"> |
michael@0 | 16 | |
michael@0 | 17 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 18 | |
michael@0 | 19 | var canvases = []; |
michael@0 | 20 | function callbackTestCanvas(canvas) |
michael@0 | 21 | { |
michael@0 | 22 | canvases.push(canvas); |
michael@0 | 23 | |
michael@0 | 24 | if (canvases.length != 2) |
michael@0 | 25 | return; |
michael@0 | 26 | |
michael@0 | 27 | var result = canvases[0]; |
michael@0 | 28 | var reference = canvases[1]; |
michael@0 | 29 | |
michael@0 | 30 | var ret = compareSnapshots(result.snapshot, reference.snapshot, true); |
michael@0 | 31 | ok(ret[0], "Reftest " + result.src + |
michael@0 | 32 | (ret[0] ? "" : (" FAILED\n" + |
michael@0 | 33 | "RESULT=" + ret[1] + "\n" + |
michael@0 | 34 | "REFERENCE=" + ret[2] + "\n"))); |
michael@0 | 35 | |
michael@0 | 36 | // Remove the iframes if the test was successful |
michael@0 | 37 | if (ret[0]) { |
michael@0 | 38 | result.parentNode.removeChild(result); |
michael@0 | 39 | reference.parentNode.removeChild(reference); |
michael@0 | 40 | } |
michael@0 | 41 | canvases = []; |
michael@0 | 42 | SimpleTest.waitForFocus(nextTest); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function doSnapShot(iframe) { |
michael@0 | 46 | iframe.snapshot = snapshotWindow(iframe.contentWindow, true); |
michael@0 | 47 | callbackTestCanvas(iframe); |
michael@0 | 48 | }; |
michael@0 | 49 | |
michael@0 | 50 | function remotePageLoaded(callback) { |
michael@0 | 51 | var iframe = this; |
michael@0 | 52 | setTimeout(function(){ |
michael@0 | 53 | doSnapShot(iframe); |
michael@0 | 54 | callback(); |
michael@0 | 55 | }, 0); |
michael@0 | 56 | }; |
michael@0 | 57 | |
michael@0 | 58 | const MAX_ITERATIONS = 1000; |
michael@0 | 59 | |
michael@0 | 60 | function createIframe(url,next) { |
michael@0 | 61 | var iframe = document.createElement("iframe"); |
michael@0 | 62 | iframe.src = url; |
michael@0 | 63 | iframe.remotePageLoaded = remotePageLoaded; |
michael@0 | 64 | var me = this; |
michael@0 | 65 | var currentIteration = 0; |
michael@0 | 66 | function iframeLoadCompleted() { |
michael@0 | 67 | var docEl = iframe.contentDocument.documentElement; |
michael@0 | 68 | if (docEl.className.indexOf("reftest-wait") >= 0) { |
michael@0 | 69 | if (currentIteration++ > MAX_ITERATIONS) { |
michael@0 | 70 | ok(false, "iframe load for " + url + " timed out"); |
michael@0 | 71 | endTest(); |
michael@0 | 72 | } else { |
michael@0 | 73 | setTimeout(iframeLoadCompleted, 10); |
michael@0 | 74 | } |
michael@0 | 75 | return; |
michael@0 | 76 | } |
michael@0 | 77 | iframe.remotePageLoaded(function() { |
michael@0 | 78 | if (next) { |
michael@0 | 79 | setTimeout(function(){createIframe(next,null);}, 0) |
michael@0 | 80 | } |
michael@0 | 81 | }); |
michael@0 | 82 | } |
michael@0 | 83 | iframe.addEventListener("load", iframeLoadCompleted, false); |
michael@0 | 84 | window.document.body.appendChild(iframe); |
michael@0 | 85 | iframe.focus(); |
michael@0 | 86 | }; |
michael@0 | 87 | |
michael@0 | 88 | function refTest(test,ref) { |
michael@0 | 89 | createIframe(test,ref); |
michael@0 | 90 | }; |
michael@0 | 91 | |
michael@0 | 92 | var caretBlinkTime = null; |
michael@0 | 93 | function endTest() { |
michael@0 | 94 | if (caretBlinkTime !== null) { |
michael@0 | 95 | SpecialPowers.setIntPref("ui.caretBlinkTime", caretBlinkTime); |
michael@0 | 96 | } else { |
michael@0 | 97 | SpecialPowers.clearUserPref("ui.caretBlinkTime"); |
michael@0 | 98 | } |
michael@0 | 99 | |
michael@0 | 100 | // finish(), yet let the test actually end first, to be safe. |
michael@0 | 101 | SimpleTest.executeSoon(SimpleTest.finish); |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | var tests = [ |
michael@0 | 105 | [ 'bug106855-1.html' , 'bug106855-1-ref.html' ] , |
michael@0 | 106 | [ 'bug106855-2.html' , 'bug106855-1-ref.html' ] , |
michael@0 | 107 | [ 'bug240933-1.html' , 'bug240933-1-ref.html' ] , |
michael@0 | 108 | [ 'bug240933-2.html' , 'bug240933-1-ref.html' ] , |
michael@0 | 109 | [ 'bug389321-1.html' , 'bug389321-1-ref.html' ] , |
michael@0 | 110 | [ 'bug389321-2.html' , 'bug389321-2-ref.html' ] , |
michael@0 | 111 | [ 'bug389321-3.html' , 'bug389321-3-ref.html' ] , |
michael@0 | 112 | [ 'bug482484.html' , 'bug482484-ref.html' ] , |
michael@0 | 113 | [ 'bug585922.html' , 'bug585922-ref.html' ] , |
michael@0 | 114 | [ 'bug597519-1.html' , 'bug597519-1-ref.html' ] , |
michael@0 | 115 | [ 'bug602141-1.html' , 'bug602141-1-ref.html' ] , |
michael@0 | 116 | [ 'bug602141-2.html' , 'bug602141-2-ref.html' ] , |
michael@0 | 117 | [ 'bug602141-3.html' , 'bug602141-3-ref.html' ] , |
michael@0 | 118 | [ 'bug602141-4.html' , 'bug602141-4-ref.html' ] , |
michael@0 | 119 | [ 'bug612271-1.html' , 'bug612271-ref.html' ] , |
michael@0 | 120 | [ 'bug612271-2.html' , 'bug612271-ref.html' ] , |
michael@0 | 121 | [ 'bug612271-3.html' , 'bug612271-ref.html' ] , |
michael@0 | 122 | [ 'bug613433-1.html' , 'bug613433-ref.html' ] , |
michael@0 | 123 | [ 'bug613433-2.html' , 'bug613433-ref.html' ] , |
michael@0 | 124 | [ 'bug613433-3.html' , 'bug613433-ref.html' ] , |
michael@0 | 125 | [ 'bug613807-1.html' , 'bug613807-1-ref.html' ] , |
michael@0 | 126 | [ 'bug632215-1.html' , 'bug632215-ref.html' ] , |
michael@0 | 127 | [ 'bug632215-2.html' , 'bug632215-ref.html' ] , |
michael@0 | 128 | [ 'bug633044-1.html' , 'bug633044-1-ref.html' ] , |
michael@0 | 129 | [ 'bug634406-1.html' , 'bug634406-1-ref.html' ] , |
michael@0 | 130 | [ 'bug644428-1.html' , 'bug644428-1-ref.html' ] , |
michael@0 | 131 | function() {SpecialPowers.setBoolPref("bidi.browser.ui", true);} , |
michael@0 | 132 | [ 'bug646382-1.html' , 'bug646382-1-ref.html' ] , |
michael@0 | 133 | [ 'bug646382-2.html' , 'bug646382-2-ref.html' ] , |
michael@0 | 134 | [ 'bug664087-1.html' , 'bug664087-1-ref.html' ] , |
michael@0 | 135 | [ 'bug664087-2.html' , 'bug664087-2-ref.html' ] , |
michael@0 | 136 | [ 'bug682712-1.html' , 'bug682712-1-ref.html' ] , |
michael@0 | 137 | function() {SpecialPowers.clearUserPref("bidi.browser.ui");} , |
michael@0 | 138 | [ 'bug746993-1.html' , 'bug746993-1-ref.html' ] , |
michael@0 | 139 | [ 'bug1007065-1.html' , 'bug1007065-1-ref.html' ] , |
michael@0 | 140 | ]; |
michael@0 | 141 | |
michael@0 | 142 | if (navigator.appVersion.indexOf("Android") == -1 && |
michael@0 | 143 | SpecialPowers.Services.appinfo.name != "B2G") { |
michael@0 | 144 | tests.push([ 'bug512295-1.html' , 'bug512295-1-ref.html' ]); |
michael@0 | 145 | tests.push([ 'bug512295-2.html' , 'bug512295-2-ref.html' ]); |
michael@0 | 146 | tests.push(function() {SpecialPowers.setBoolPref("layout.css.overflow-clip-box.enabled", true);}); |
michael@0 | 147 | tests.push([ 'bug966992-1.html' , 'bug966992-1-ref.html' ]); |
michael@0 | 148 | tests.push([ 'bug966992-2.html' , 'bug966992-2-ref.html' ]); |
michael@0 | 149 | tests.push([ 'bug966992-3.html' , 'bug966992-3-ref.html' ]); |
michael@0 | 150 | tests.push(function() {SpecialPowers.setBoolPref("layout.css.overflow-clip-box.enabled", false);}); |
michael@0 | 151 | tests.push([ 'bug923376.html' , 'bug923376-ref.html' ]); |
michael@0 | 152 | } else { |
michael@0 | 153 | is(SpecialPowers.getIntPref("layout.spellcheckDefault"), 0, "Spellcheck should be turned off for this platrom or this if..else check removed"); |
michael@0 | 154 | } |
michael@0 | 155 | |
michael@0 | 156 | var testIndex = 0; |
michael@0 | 157 | |
michael@0 | 158 | function nextTest() { |
michael@0 | 159 | if (testIndex < tests.length) { |
michael@0 | 160 | if (typeof(tests[testIndex]) == 'function') { |
michael@0 | 161 | tests[testIndex](); |
michael@0 | 162 | SimpleTest.executeSoon(nextTest); |
michael@0 | 163 | } else { |
michael@0 | 164 | refTest(tests[testIndex][0],tests[testIndex][1]); |
michael@0 | 165 | } |
michael@0 | 166 | ++testIndex; |
michael@0 | 167 | } else { |
michael@0 | 168 | endTest(); |
michael@0 | 169 | } |
michael@0 | 170 | } |
michael@0 | 171 | function runTests() { |
michael@0 | 172 | try { |
michael@0 | 173 | try { |
michael@0 | 174 | caretBlinkTime = SpecialPowers.getIntPref("ui.caretBlinkTime"); |
michael@0 | 175 | } catch (e) {} |
michael@0 | 176 | SpecialPowers.setIntPref("ui.caretBlinkTime", -1); |
michael@0 | 177 | |
michael@0 | 178 | nextTest(); |
michael@0 | 179 | } catch(e) { |
michael@0 | 180 | endTest(); |
michael@0 | 181 | } |
michael@0 | 182 | } |
michael@0 | 183 | |
michael@0 | 184 | SimpleTest.waitForFocus(runTests); |
michael@0 | 185 | |
michael@0 | 186 | </script> |
michael@0 | 187 | </head> |
michael@0 | 188 | <body> |
michael@0 | 189 | </body> |
michael@0 | 190 | </html> |