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) 2009 The Chromium Authors. All rights reserved. |
michael@0 | 3 | Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | found in the LICENSE file. |
michael@0 | 5 | --> |
michael@0 | 6 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
michael@0 | 7 | "http://www.w3.org/TR/html4/loose.dtd"> |
michael@0 | 8 | <html> |
michael@0 | 9 | <head> |
michael@0 | 10 | <meta charset="utf-8"> |
michael@0 | 11 | <title>WebGL Out Of Resources Test</title> |
michael@0 | 12 | <link rel="stylesheet" href="../resources/js-test-style.css"/> |
michael@0 | 13 | <script src="../resources/desktop-gl-constants.js" type="text/javascript"></script> |
michael@0 | 14 | <script src="../../debug/webgl-debug.js"></script> |
michael@0 | 15 | <script src="../resources/js-test-pre.js"></script> |
michael@0 | 16 | <script src="../conformance/resources/webgl-test.js"></script> |
michael@0 | 17 | </head> |
michael@0 | 18 | <body> |
michael@0 | 19 | <div id="description"></div> |
michael@0 | 20 | <div id="console"></div> |
michael@0 | 21 | <canvas id="canvas" width="2" height="2"> </canvas> |
michael@0 | 22 | <canvas id="canvas2" width="2" height="2"> </canvas> |
michael@0 | 23 | <script> |
michael@0 | 24 | window.onload = init; |
michael@0 | 25 | debug("Tests a WebGL program that tries to use all of vram."); |
michael@0 | 26 | |
michael@0 | 27 | function init() { |
michael@0 | 28 | if (confirm( |
michael@0 | 29 | "after clicking ok your machine may be come unresponsive or crash")) { |
michael@0 | 30 | main(); |
michael@0 | 31 | } else { |
michael@0 | 32 | debug("cancelled"); |
michael@0 | 33 | } |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function main() { |
michael@0 | 37 | debug(""); |
michael@0 | 38 | debug("Canvas.getContext"); |
michael@0 | 39 | |
michael@0 | 40 | var gl = create3DContext(document.getElementById("canvas")); |
michael@0 | 41 | if (!gl) { |
michael@0 | 42 | testFailed("context does not exist"); |
michael@0 | 43 | } else { |
michael@0 | 44 | testPassed("context exists"); |
michael@0 | 45 | |
michael@0 | 46 | debug(""); |
michael@0 | 47 | debug("Checking for out of memory handling."); |
michael@0 | 48 | |
michael@0 | 49 | var size = gl.getParameter(gl.MAX_RENDERBUFFER_SIZE); |
michael@0 | 50 | debug("max render buffer size: " + size); |
michael@0 | 51 | |
michael@0 | 52 | var allocateFramebuffers = true; |
michael@0 | 53 | var itervalId; |
michael@0 | 54 | var count = 0; |
michael@0 | 55 | |
michael@0 | 56 | gl = WebGLDebugUtils.makeDebugContext(gl, function(err, functionName, args) { |
michael@0 | 57 | window.clearInterval(intervalId); |
michael@0 | 58 | assertMsg(err == gl.OUT_OF_MEMORY, |
michael@0 | 59 | "correctly returns gl.OUT_OF_MEMORY when out of memory"); |
michael@0 | 60 | finish(); |
michael@0 | 61 | }); |
michael@0 | 62 | |
michael@0 | 63 | intervalId = window.setInterval(function() { |
michael@0 | 64 | ++count; |
michael@0 | 65 | var mem = count * size * size * 4; |
michael@0 | 66 | debug("#" + count + " : memory allocated so far " + (mem / 1024 / 1024) + "MB"); |
michael@0 | 67 | var tex = gl.createTexture(); |
michael@0 | 68 | gl.bindTexture(gl.TEXTURE_2D, tex); |
michael@0 | 69 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); |
michael@0 | 70 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); |
michael@0 | 71 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); |
michael@0 | 72 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); |
michael@0 | 73 | gl.texImage2D(gl.TEXTURE_2D, |
michael@0 | 74 | 0, // level |
michael@0 | 75 | gl.RGBA, // internalFormat |
michael@0 | 76 | size, // width |
michael@0 | 77 | size, // height |
michael@0 | 78 | 0, // border |
michael@0 | 79 | gl.RGBA, // format |
michael@0 | 80 | gl.UNSIGNED_BYTE, // type |
michael@0 | 81 | null); // data |
michael@0 | 82 | if (allocateFrameBuffers) { |
michael@0 | 83 | var fb = gl.createFramebuffer(); |
michael@0 | 84 | gl.bindFramebuffer(gl.FRAMEBUFFER, fb); |
michael@0 | 85 | gl.framebufferTexture2D( |
michael@0 | 86 | gl.FRAMEBUFFER, |
michael@0 | 87 | gl.COLOR_ATTACHMENT0, |
michael@0 | 88 | gl.TEXTURE_2D, |
michael@0 | 89 | tex, |
michael@0 | 90 | 0); |
michael@0 | 91 | var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER); |
michael@0 | 92 | if (status != gl.FRAMEBUFFER_COMPLETE) { |
michael@0 | 93 | testFailed("gl.checkFramebufferStatus() returned " + WebGLDebugUtils.glEnumToString(status) + |
michael@0 | 94 | " should have gotten gl.OUT_OF_MEMORY before getting this."); |
michael@0 | 95 | window.clearInterval(intervalId); |
michael@0 | 96 | finish(); |
michael@0 | 97 | } |
michael@0 | 98 | } |
michael@0 | 99 | }, 1000/10); |
michael@0 | 100 | } |
michael@0 | 101 | |
michael@0 | 102 | function finish() { |
michael@0 | 103 | debug(""); |
michael@0 | 104 | successfullyParsed = true; |
michael@0 | 105 | } |
michael@0 | 106 | } |
michael@0 | 107 | </script> |
michael@0 | 108 | </body> |
michael@0 | 109 | </html> |