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 | <!-- |
michael@0 | 2 | Copyright (C) 2012 Opera Software ASA. All rights reserved. |
michael@0 | 3 | |
michael@0 | 4 | Redistribution and use in source and binary forms, with or without |
michael@0 | 5 | modification, are permitted provided that the following conditions |
michael@0 | 6 | are met: |
michael@0 | 7 | 1. Redistributions of source code must retain the above copyright |
michael@0 | 8 | notice, this list of conditions and the following disclaimer. |
michael@0 | 9 | 2. Redistributions in binary form must reproduce the above copyright |
michael@0 | 10 | notice, this list of conditions and the following disclaimer in the |
michael@0 | 11 | documentation and/or other materials provided with the distribution. |
michael@0 | 12 | |
michael@0 | 13 | THIS SOFTWARE IS PROVIDED BY OPERA SOFTWARE ASA. ''AS IS'' AND ANY |
michael@0 | 14 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
michael@0 | 15 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
michael@0 | 16 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
michael@0 | 17 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
michael@0 | 18 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
michael@0 | 19 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
michael@0 | 20 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
michael@0 | 21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
michael@0 | 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
michael@0 | 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 24 | --> |
michael@0 | 25 | <!DOCTYPE html> |
michael@0 | 26 | <html> |
michael@0 | 27 | <head> |
michael@0 | 28 | <meta charset="utf-8"> |
michael@0 | 29 | <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
michael@0 | 30 | <script src="../../resources/js-test-pre.js"></script> |
michael@0 | 31 | <script src="../resources/webgl-test.js"></script> |
michael@0 | 32 | <style> |
michael@0 | 33 | canvas { |
michael@0 | 34 | width:50px; |
michael@0 | 35 | height:50px; |
michael@0 | 36 | } |
michael@0 | 37 | .square { |
michael@0 | 38 | display:inline-block; |
michael@0 | 39 | width:50px; |
michael@0 | 40 | height:50px; |
michael@0 | 41 | background-color:red; |
michael@0 | 42 | } |
michael@0 | 43 | </style> |
michael@0 | 44 | <script> |
michael@0 | 45 | function checkResult(ctx1, ctx2, preserve) { |
michael@0 | 46 | var imgData1 = ctx1.getImageData(0,0,1,1); |
michael@0 | 47 | var imgData2 = ctx2.getImageData(0,0,1,1); |
michael@0 | 48 | var correct1 = [255,0,0,255]; |
michael@0 | 49 | var correct2 = preserve ? [255,0,0,255] : [0,0,0,255]; |
michael@0 | 50 | var ok1 = true; |
michael@0 | 51 | var ok2 = true; |
michael@0 | 52 | for (var p = 0; p < 4; ++p) { |
michael@0 | 53 | if (imgData1.data[p] != correct1[p]) |
michael@0 | 54 | ok1 = false; |
michael@0 | 55 | if (imgData2.data[p] != correct2[p]) |
michael@0 | 56 | ok2 = false; |
michael@0 | 57 | } |
michael@0 | 58 | if (ok1 && ok2) |
michael@0 | 59 | testPassed('Rendered ok with preserveDrawingBuffer ' + preserve +'.'); |
michael@0 | 60 | else |
michael@0 | 61 | testFailed('Did not render ok with preserveDrawingBuffer ' + preserve + '.'); |
michael@0 | 62 | if (preserve) { |
michael@0 | 63 | debug('<br /><span class="pass">TEST COMPLETE</span>'); |
michael@0 | 64 | notifyFinishedToHarness() |
michael@0 | 65 | } else { |
michael@0 | 66 | runTest(true); |
michael@0 | 67 | } |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | function runTest(preserve) { |
michael@0 | 71 | var c1 = document.getElementById('c' + (preserve * 3 + 1)); |
michael@0 | 72 | var c2 = document.getElementById('c' + (preserve * 3 + 2)); |
michael@0 | 73 | var c3 = document.getElementById('c' + (preserve * 3 + 3)); |
michael@0 | 74 | var ctx1 = c1.getContext('2d'); |
michael@0 | 75 | var ctx2 = c2.getContext('2d'); |
michael@0 | 76 | var gl = c3.getContext('experimental-webgl', { alpha:false, preserveDrawingBuffer:preserve }); |
michael@0 | 77 | gl.clearColor(1, 0, 0, 1); |
michael@0 | 78 | gl.clear(gl.COLOR_BUFFER_BIT); |
michael@0 | 79 | ctx1.drawImage(c3, 0, 0); |
michael@0 | 80 | setTimeout(function() { ctx2.drawImage(c3, 0, 0); checkResult(ctx1, ctx2, preserve); }, 100); |
michael@0 | 81 | |
michael@0 | 82 | } |
michael@0 | 83 | </script> |
michael@0 | 84 | </head> |
michael@0 | 85 | <body> |
michael@0 | 86 | <div> |
michael@0 | 87 | <canvas id='c1'></canvas> |
michael@0 | 88 | <canvas id='c2'></canvas> |
michael@0 | 89 | <canvas id='c3'></canvas> |
michael@0 | 90 | <span>should look as right pattern</span> |
michael@0 | 91 | <div class='square'></div> |
michael@0 | 92 | <div class='square' style='background-color:black'></div> |
michael@0 | 93 | <div class='square'></div> |
michael@0 | 94 | </div> |
michael@0 | 95 | <div> |
michael@0 | 96 | <canvas id='c4'></canvas> |
michael@0 | 97 | <canvas id='c5'></canvas> |
michael@0 | 98 | <canvas id='c6'></canvas> |
michael@0 | 99 | <span>should look as right pattern</span> |
michael@0 | 100 | <div class='square'></div> |
michael@0 | 101 | <div class='square'></div> |
michael@0 | 102 | <div class='square'></div> |
michael@0 | 103 | </div> |
michael@0 | 104 | <div id="description"></div> |
michael@0 | 105 | <div id="console"></div> |
michael@0 | 106 | <script> |
michael@0 | 107 | description('Verify that preserveDrawingBuffer attribute is honored.'); |
michael@0 | 108 | runTest(false); |
michael@0 | 109 | successfullyParsed = true; |
michael@0 | 110 | shouldBeTrue("successfullyParsed"); |
michael@0 | 111 | </script> |
michael@0 | 112 | </body> |
michael@0 | 113 | </html> |