Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Side by Side Diff: LayoutTests/inspector/profiler/webgl/webgl-profiler-get-error.html

Issue 1073863003: DevTools: remove Canvas profiler from DevTools source base. See details in the bug. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: tests gone Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../canvas-profiler-test.js"></script>
5 <script>
6 if (window.internals)
7 window.internals.settings.setWebGLErrorsToConsoleEnabled(false);
8
9 /**
10 * @constructor
11 */
12 function Cache()
13 {
14 this.reset();
15 }
16
17 Cache.prototype = {
18 /**
19 * @return {number}
20 */
21 size: function()
22 {
23 return this._size;
24 },
25
26 reset: function()
27 {
28 /** @type {!Object.<number, Object>} */
29 this._items = Object.create(null);
30 /** @type {number} */
31 this._size = 0;
32 },
33
34 /**
35 * @param {number} key
36 * @return {boolean}
37 */
38 has: function(key)
39 {
40 return key in this._items;
41 },
42
43 /**
44 * @param {number} key
45 * @return {Object}
46 */
47 get: function(key)
48 {
49 return this._items[key];
50 },
51
52 /**
53 * @param {number} key
54 * @param {Object} item
55 */
56 put: function(key, item)
57 {
58 if (!this.has(key))
59 ++this._size;
60 this._items[key] = item;
61 }
62 }
63
64 var gl;
65 var rawGL;
66 var glResource;
67
68 function assertNoErrors(gl)
69 {
70 console.assert(gl.getError() === gl.NO_ERROR, "No GL error was expected at t his time");
71 }
72
73 function assertEqualArrays(a, b)
74 {
75 console.assert(a.length === b.length, "assertEqualArrays: a.length=" + a.len gth + ", b.length=" + b.length);
76 a = a.slice();
77 b = b.slice();
78 a.sort();
79 b.sort();
80 a.forEach(function(element, index) {
81 console.assert(a[index] === b[index], "assertEqualArrays: different valu es at index " + index);
82 });
83 }
84
85 function generateWebGLError(gl, error)
86 {
87 switch (error) {
88 case gl.INVALID_ENUM:
89 gl.pixelStorei(123, 234);
90 break;
91 case gl.INVALID_VALUE:
92 gl.pixelStorei(gl.PACK_ALIGNMENT, 234);
93 break;
94 case gl.INVALID_OPERATION:
95 default:
96 gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
97 break;
98 }
99 }
100
101 function getAllErrors(gl)
102 {
103 var errors = [];
104 while (true) {
105 var error = gl.getError();
106 if (error === gl.NO_ERROR)
107 break;
108 console.assert(typeof error === "number", "getError() should return a nu mber instead of a " + (typeof error));
109 errors.push(error);
110 }
111 return errors;
112 }
113
114 function createAndRunWebGLProgram()
115 {
116 gl = createWebGLContext();
117 console.assert(gl, "Failed to create WebGL context");
118
119 glResource = gl["__resourceObject"];
120 console.assert(glResource, "WebGL context is not wrapped");
121
122 rawGL = glResource.wrappedObject();
123 console.assert(rawGL, "No raw WebGL context found");
124 console.assert(gl !== rawGL, "Proxy and RAW contexts should not be the same" );
125
126 assertNoErrors(gl);
127 assertNoErrors(rawGL);
128
129 // 1) Generate errors directly on the RAW context
130 // 2) Pick them via proxy.
131 var errors = [rawGL.INVALID_ENUM, rawGL.INVALID_VALUE, rawGL.INVALID_OPERATI ON];
132 errors.forEach(generateWebGLError.bind(this, rawGL));
133 assertEqualArrays(errors, getAllErrors(gl));
134 assertNoErrors(gl);
135 assertNoErrors(rawGL);
136
137 // 1) Generate errors on RAW context
138 // 2) Convert Resource to a Replayable => this should clean up the RAW conte xt and save the errors in proxy
139 // 3) Check that RAW context no longer have errors
140 // 4) Check that proxy still has the original errors saved
141 var errors = [rawGL.INVALID_ENUM, rawGL.INVALID_VALUE, rawGL.INVALID_OPERATI ON];
142 errors.forEach(generateWebGLError.bind(this, rawGL));
143 glResource.toReplayable(new Cache());
144 assertNoErrors(rawGL);
145 assertEqualArrays(errors, getAllErrors(gl));
146 assertNoErrors(gl);
147
148 // 1) Repeat 1-3 steps from the above
149 // 2) Check proxy and RAW errors interleaved
150 var errors = [rawGL.INVALID_ENUM, rawGL.INVALID_VALUE, rawGL.INVALID_OPERATI ON];
151 errors.forEach(generateWebGLError.bind(this, rawGL));
152 glResource.toReplayable(new Cache());
153 assertNoErrors(rawGL);
154
155 var value = gl.getError();
156 console.assert(typeof value === "number", "getError() should return a number instead of a " + (typeof value));
157 console.assert(value !== gl.NO_ERROR, "An error was expected");
158 errors.forEach(generateWebGLError.bind(this, rawGL)); // Generate again in t he RAW context.
159 // Now we "have" 2 errors left in the proxy and 3 new errors in the RAW cont ext => should return 3 errors from the proxy.
160 assertEqualArrays(errors, getAllErrors(gl));
161 assertNoErrors(gl);
162 assertNoErrors(rawGL);
163
164 return "SUCCESS";
165 }
166
167 function test()
168 {
169 InspectorTest.enableCanvasAgent(step1);
170 function step1()
171 {
172 InspectorTest.evaluateInPage("createAndRunWebGLProgram()", step2);
173 }
174 function step2(error)
175 {
176 InspectorTest.assertEquals("SUCCESS", error.description);
177 InspectorTest.completeTest();
178 }
179 }
180
181 </script>
182 </head>
183 <body onload="runTest()">
184 <p>
185 Tests WebGL getError() status.
186 </p>
187 <a href="https://bugs.webkit.org/show_bug.cgi?id=95443">Bug 95443</a>
188 </body>
189 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698